UNPKG

@polygonjs/polygonjs

Version:

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

52 lines (51 loc) 1.43 kB
"use strict"; import { ref } from "@vue/reactivity"; export class GraphNodesController { constructor(scene) { this.scene = scene; this._graphNodeIdByPath = /* @__PURE__ */ new Map(); this._pathByGraphNodeId = /* @__PURE__ */ new Map(); } notifyNodePathChanged(node) { var _a; this._notifyGraphNodePathChanged(node); const params = node.params.all; for (const param of params) { this.notifyParamPathChanged(param); } (_a = node.childrenController) == null ? void 0 : _a.traverseChildren((child) => { this._notifyGraphNodePathChanged(child); }); } notifyParamPathChanged(param) { this._notifyGraphNodePathChanged(param); } _notifyGraphNodePathChanged(node) { const id = node.graphNodeId(); const newPath = node.path(); const previousPath = this._pathByGraphNodeId.get(id); if (previousPath != null) { const _ref2 = this._graphNodeIdByPath.get(previousPath); if (_ref2) { _ref2.value = null; } } if (node.disposed()) { return; } const _ref = this._findOrCreateRef(newPath); _ref.value = id; this._pathByGraphNodeId.set(id, newPath); } pathRef(path) { return this._findOrCreateRef(path); } _findOrCreateRef(path) { let _ref = this._graphNodeIdByPath.get(path); if (!_ref) { _ref = ref(null); this._graphNodeIdByPath.set(path, _ref); } return _ref; } }