@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
37 lines (36 loc) • 1.3 kB
JavaScript
;
import { incrementRefSafely, ref } from "../../core/reactivity/CoreReactivity";
const refByRBDObjectUuidByPropertyName = /* @__PURE__ */ new Map();
export function getOrCreatePropertyRef(timeController, object3D, propertyName) {
return getRBDPropertyRef(timeController, object3D, propertyName) || createRBDPropertyRef(object3D, propertyName);
}
function createRBDPropertyRef(object3D, propertyName) {
let mapForObject = refByRBDObjectUuidByPropertyName.get(object3D.uuid);
if (!mapForObject) {
mapForObject = /* @__PURE__ */ new Map();
refByRBDObjectUuidByPropertyName.set(object3D.uuid, mapForObject);
}
let refForProperty = mapForObject.get(propertyName);
if (!refForProperty) {
refForProperty = ref(0);
mapForObject.set(propertyName, refForProperty);
}
return refForProperty;
}
function getRBDPropertyRef(timeController, object3D, propertyName) {
return timeController.timeUniform();
}
export function touchRBDProperties(object3D, propertyNames) {
const map = refByRBDObjectUuidByPropertyName.get(object3D.uuid);
if (!map) {
return;
}
for (const propertyName of propertyNames) {
const _ref = map.get(propertyName);
if (_ref) {
incrementRefSafely(_ref);
}
}
}
export function touchRBDProperty(object3D, propertyName) {
}