UNPKG

polygonjs-engine

Version:

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

55 lines (51 loc) 1.79 kB
/** * Creates an empty group. * * @remarks * This node also has its own transforms. And if it is set as input of other nodes, their objects will be added as children to the object of this node. * */ import {TypedObjNode} from './_Base'; import {Group} from 'three/src/objects/Group'; import {TransformedParamConfig, TransformController} from './utils/TransformController'; import {FlagsControllerD} from '../utils/FlagsController'; import {AxesHelper} from 'three/src/helpers/AxesHelper'; import {NodeParamsConfig} from '../utils/params/ParamsConfig'; import {HierarchyController} from './utils/HierarchyController'; class NullObjParamConfig extends TransformedParamConfig(NodeParamsConfig) {} const ParamsConfig = new NullObjParamConfig(); export class NullObjNode extends TypedObjNode<Group, NullObjParamConfig> { params_config = ParamsConfig; static type() { return 'null'; } readonly hierarchy_controller: HierarchyController = new HierarchyController(this); readonly transform_controller: TransformController = new TransformController(this); public readonly flags: FlagsControllerD = new FlagsControllerD(this); private _helper = new AxesHelper(1); create_object() { const group = new Group(); group.matrixAutoUpdate = false; return group; } initializeNode() { this.hierarchy_controller.initializeNode(); this.transform_controller.initializeNode(); this._updateHelperHierarchy(); this._helper.matrixAutoUpdate = false; this.flags.display.add_hook(() => { this._updateHelperHierarchy(); }); } private _updateHelperHierarchy() { if (this.flags.display.active()) { this.object.add(this._helper); } else { this.object.remove(this._helper); } } cook() { this.transform_controller.update(); this.cookController.end_cook(); } }