UNPKG

@polygonjs/polygonjs

Version:

node-based WebGL 3D engine https://polygonjs.com

35 lines (34 loc) 1.27 kB
"use strict"; import { JsonExportDispatcher } from "./Dispatcher"; import { TimeController } from "../../../scene/utils/TimeController"; export class SceneJsonExporter { constructor(_scene) { this._scene = _scene; this._data = {}; this.dispatcher = new JsonExportDispatcher(); } async data(options = {}) { this._scene.nodesController.resetNodeContextSignatures(); const rootExporter = this.dispatcher.dispatchNode(this._scene.root()); const nodesData = await rootExporter.data(options); const uiData = rootExporter.uiData(options); const shadersData = {}; const jsFunctionBodiesData = {}; await rootExporter.persistedConfigData(shadersData, jsFunctionBodiesData, options); this._data = { properties: { frame: this._scene.frame() || TimeController.START_FRAME, maxFrame: this._scene.maxFrame(), maxFrameLocked: this._scene.timeController.maxFrameLocked(), realtimeState: this._scene.timeController.realtimeState(), mainCameraPath: this._scene.camerasController.mainCameraPath(), versions: options.versions }, root: nodesData, ui: uiData, shaders: shadersData, jsFunctionBodies: jsFunctionBodiesData }; return this._data; } }