UNPKG

@polygonjs/polygonjs

Version:

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

37 lines (36 loc) 864 B
"use strict"; export class HelperController { constructor(node, _helperConstructor, _name) { this.node = node; this._helperConstructor = _helperConstructor; this._name = _name; } initializeNode() { this.node.flags.display.onUpdate(() => { this.update(); }); } visible() { return this.node.flags.display.active() && this.node.pv.showHelper; } _createHelper() { const helper = new this._helperConstructor(this.node, this._name); helper.build(); return helper; } update() { if (this.visible()) { if (!this._helper) { this._helper = this._createHelper(); } if (this._helper) { this.node.light.add(this._helper.object); this._helper.update(); } } else { if (this._helper) { this.node.light.remove(this._helper.object); } } } }