@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
25 lines (24 loc) • 696 B
JavaScript
;
import { incrementRefSafely, ref } from "../../core/reactivity/CoreReactivity";
const refByNodePath = /* @__PURE__ */ new Map();
export function getOrCreateNodeRef(nodePath) {
return getNodeRef(nodePath) || createNodeRef(nodePath);
}
export function getNodeRef(nodePath) {
return refByNodePath.get(nodePath);
}
export function createNodeRef(nodePath) {
let refForNodePath = refByNodePath.get(nodePath);
if (!refForNodePath) {
refForNodePath = ref(0);
refByNodePath.set(nodePath, refForNodePath);
}
return refForNodePath;
}
export function touchNodeRef(nodePath) {
const _ref = getNodeRef(nodePath);
if (!_ref) {
return;
}
incrementRefSafely(_ref);
}