mylingo3d
Version:
Lingo3D is a React/Vue 3d game development framework that ships with a complete visual editor
25 lines • 827 B
JavaScript
import { Bone, Vector3 } from "three";
import { onAfterRender } from "../../events/onAfterRender";
import getWorldPosition from "./getWorldPosition";
import { box3 } from "./reusables";
const cache = new WeakMap();
export default (object) => {
if (cache.has(object))
return cache.get(object).clone();
let result;
if (object instanceof Bone) {
result = getWorldPosition(object);
}
else {
object.updateWorldMatrix(true, false);
box3.setFromObject(object);
if (box3.isEmpty())
result = getWorldPosition(object);
else
result = box3.getCenter(new Vector3());
}
cache.set(object, result.clone());
onAfterRender(() => cache.delete(object), true);
return result;
};
//# sourceMappingURL=getCenter.js.map