UNPKG

@polygonjs/polygonjs

Version:

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

40 lines (39 loc) 1.26 kB
"use strict"; import { NodeParamsConfig } from "../../utils/params/ParamsConfig"; import { TypedObjNode } from "../_Base"; import { TransformController } from "./TransformController"; class HierarchyParamsConfig extends NodeParamsConfig { } export class HierarchyObjNode extends TypedObjNode { constructor() { super(...arguments); this.hierarchyController = new HierarchyController(this); } } export class HierarchyController { constructor(node) { this.node = node; } initializeNode() { this.node.io.inputs.setCount(0, 1); this.node.io.inputs.setDependsOnInputs(false); this.node.io.outputs.setHasOneOutput(); this.node.io.inputs.add_on_set_input_hook("on_input_updated:update_parent", () => { this.on_input_updated(); }); } static on_input_updated(node) { const parent_object = node.root().getParentForNode(node); if (node.transformController && parent_object) { TransformController.update_node_transform_params_if_required(node, parent_object); } if (node.io.inputs.input(0) != null) { node.root().addToParentTransform(node); } else { node.root().removeFromParentTransform(node); } } on_input_updated() { HierarchyController.on_input_updated(this.node); } }