UNPKG

polygonjs-engine

Version:

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

174 lines (173 loc) 5.88 kB
import {CamerasController as CamerasController2} from "./utils/CamerasController"; import {Cooker as Cooker2} from "./utils/Cooker"; import {CookController as CookController2} from "./utils/CookController"; import {CoreGraph as CoreGraph2} from "../../core/graph/CoreGraph"; import {CorePerformance as CorePerformance2} from "../../core/performance/CorePerformance"; import {DispatchController as DispatchController2} from "./utils/DispatchController"; import {ExpressionsController as ExpressionsController2} from "./utils/ExpressionsController"; import {LifeCycleController as LifeCycleController2} from "./utils/LifeCycleController"; import {LoadingController as LoadingController2} from "./utils/LoadingController"; import {MissingReferencesController as MissingReferencesController2} from "./utils/MissingReferencesController"; import {NodesController as NodesController2} from "./utils/NodesController"; import {PolySceneSerializer} from "./utils/Serializer"; import {SceneEventsDispatcher} from "./utils/events/EventsDispatcher"; import {ObjectsController as ObjectsController2} from "./utils/ObjectsController"; import {ReferencesController as ReferencesController2} from "./utils/ReferencesController"; import {TimeController as TimeController2} from "./utils/TimeController"; import {UniformsController as UniformsController2} from "./utils/UniformsController"; import {ViewersRegister as ViewersRegister2} from "./utils/ViewersRegister"; import {WebGLController as WebGLController2} from "./utils/WebGLController"; import {Scene as Scene2} from "three/src/scenes/Scene"; import {SceneAssetsController} from "./utils/AssetsController"; export class PolyScene { constructor() { this._threejsScene = new Scene2(); this._cameras_controller = new CamerasController2(this); this._cooker = new Cooker2(this); this.cookController = new CookController2(); this._graph = new CoreGraph2(); this._missing_expression_references_controller = new MissingReferencesController2(this); this._expressions_controller = new ExpressionsController2(); this._nodes_controller = new NodesController2(this); this._objects_controller = new ObjectsController2(this); this._references_controller = new ReferencesController2(this); this._time_controller = new TimeController2(this); this._read_only = false; this._threejsScene.name = "defaultScene"; this._threejsScene.matrixAutoUpdate = false; this._graph.set_scene(this); this.nodesController.init(); } threejsScene() { return this._threejsScene; } setUuid(uuid) { return this._uuid = uuid; } get uuid() { return this._uuid; } setName(name) { return this._name = name; } name() { return this._name; } get camerasController() { return this._cameras_controller; } masterCameraNode() { return this.camerasController.masterCameraNode(); } get cooker() { return this._cooker; } get assets() { return this._assets_controller = this._assets_controller || new SceneAssetsController(); } async waitForCooksCompleted() { return this.cookController.waitForCooksCompleted(); } get dispatchController() { return this._dispatch_controller = this._dispatch_controller || new DispatchController2(this); } get eventsDispatcher() { return this._events_dispatcher = this._events_dispatcher || new SceneEventsDispatcher(this); } get graph() { return this._graph; } get lifecycleController() { return this._lifecycle_controller = this._lifecycle_controller || new LifeCycleController2(this); } get loadingController() { return this._loading_controller = this._loading_controller || new LoadingController2(this); } get missingExpressionReferencesController() { return this._missing_expression_references_controller; } get expressionsController() { return this._expressions_controller; } get nodesController() { return this._nodes_controller; } nodesByType(type) { return this.nodesController.nodesByType(type); } get objectsController() { return this._objects_controller; } findObjectByMask(mask) { return this._objects_controller.findObjectByMask(mask); } objectsByMask(mask) { return this._objects_controller.objectsByMask(mask); } get referencesController() { return this._references_controller; } get performance() { return this._performance = this._performance || new CorePerformance2(); } get viewersRegister() { return this._viewers_register = this._viewers_register || new ViewersRegister2(this); } get timeController() { return this._time_controller; } setFrame(frame) { this.timeController.setFrame(frame); } frame() { return this.timeController.frame; } time() { return this.timeController.time; } frameRange() { return this.timeController.frame_range; } play() { this.timeController.play(); } pause() { this.timeController.pause(); } get serializer() { return this._serializer = this._serializer || new PolySceneSerializer(this); } toJSON() { return this.serializer.toJSON(); } markAsReadOnly(requester) { if (this._read_only) { return; } this._read_only_requester = requester; this._read_only = true; } readOnly() { return this._read_only; } readOnlyRequester() { return this._read_only_requester; } get uniforms_controller() { return this._uniforms_controller = this._uniforms_controller || new UniformsController2(this); } get webgl_controller() { return this._webgl_controller = this._webgl_controller || new WebGLController2(); } batchUpdates(callback) { this._cooker.block(); callback(); this._cooker.unblock(); } node(path) { return this.nodesController.node(path); } root() { return this.nodesController.root(); } }