UNPKG

@polygonjs/polygonjs

Version:

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

51 lines (50 loc) 1.59 kB
"use strict"; import { TypedObjNode } from "./_Base"; import { Group } from "three"; import { TransformedParamConfig, TransformController } from "./utils/TransformController"; import { FlagsControllerD } from "../utils/FlagsController"; import { AxesHelper } from "three"; 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 { constructor() { super(...arguments); this.paramsConfig = ParamsConfig; this.hierarchyController = new HierarchyController(this); this.transformController = new TransformController(this); this.flags = new FlagsControllerD(this); this._helper = new AxesHelper(1); } static type() { return "null"; } createObject() { const group = new Group(); group.matrixAutoUpdate = false; return group; } initializeNode() { this.hierarchyController.initializeNode(); this.transformController.initializeNode(); this._updateHelperHierarchy(); this._helper.matrixAutoUpdate = false; this.flags.display.onUpdate(() => { this._updateHelperHierarchy(); }); } _updateHelperHierarchy() { if (this.flags.display.active()) { this.object.add(this._helper); this._helper.updateMatrix(); } else { this.object.remove(this._helper); } } cook() { this.transformController.update(); this.cookController.endCook(); } }