UNPKG

@polygonjs/polygonjs

Version:

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

61 lines (60 loc) 2.45 kB
"use strict"; import { TypedObjNode } from "./_Base"; import { Scene } from "three"; import { HierarchyController } from "./utils/HierarchyController"; import { NodeParamsConfig } from "../utils/params/ParamsConfig"; import { SceneAutoUpdateParamConfig, SceneAutoUpdateController } from "../manager/utils/Scene/AutoUpdate"; import { SceneBackgroundParamConfig, SceneBackgroundController } from "../manager/utils/Scene/Background"; import { SceneEnvParamConfig, SceneEnvController } from "../manager/utils/Scene/Env"; import { SceneFogParamConfig, SceneFogController } from "../manager/utils/Scene/Fog"; import { SceneMaterialOverrideParamConfig, SceneMaterialOverrideController } from "../manager/utils/Scene/MaterialOverride"; import { ObjType } from "../../poly/registers/nodes/types/Obj"; class SceneObjParamConfig extends SceneMaterialOverrideParamConfig( SceneFogParamConfig(SceneEnvParamConfig(SceneBackgroundParamConfig(SceneAutoUpdateParamConfig(NodeParamsConfig)))) ) { } const ParamsConfig = new SceneObjParamConfig(); export class SceneObjNode extends TypedObjNode { constructor() { super(...arguments); this.paramsConfig = ParamsConfig; this.hierarchyController = new HierarchyController(this); this._cook_main_without_inputs_when_dirty_bound = this._cook_main_without_inputs_when_dirty.bind(this); this.sceneAutoUpdateController = new SceneAutoUpdateController(this); this.sceneBackgroundController = new SceneBackgroundController(this); this.sceneEnvController = new SceneEnvController(this); this.sceneFogController = new SceneFogController(this); this.sceneMaterialOverrideController = new SceneMaterialOverrideController( this ); } static type() { return ObjType.SCENE; } createObject() { const scene = new Scene(); scene.matrixAutoUpdate = false; return scene; } initializeNode() { this.hierarchyController.initializeNode(); this.dirtyController.addPostDirtyHook( "cookMainWithoutInputsOnDirty", this._cook_main_without_inputs_when_dirty_bound ); } async _cook_main_without_inputs_when_dirty() { await this.cookController.cookMainWithoutInputs(); } cook() { this.sceneAutoUpdateController.update(); this.sceneBackgroundController.update(); this.sceneEnvController.update(); this.sceneFogController.update(); this.sceneMaterialOverrideController.update(); this.cookController.endCook(); } }