Changes
Co-authored-by: Reifonas <211114984+Reifonas@users.noreply.github.com>
This commit is contained in:
@@ -33,3 +33,25 @@ export function worldToModelLocal(
|
|||||||
g.worldToLocal(v);
|
g.worldToLocal(v);
|
||||||
return { x: v.x, y: v.y, z: v.z };
|
return { x: v.x, y: v.y, z: v.z };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function modelLocalToWorld(
|
||||||
|
modelId: string | null | undefined,
|
||||||
|
p: { x: number; y: number; z: number },
|
||||||
|
): { x: number; y: number; z: number } | null {
|
||||||
|
const g = getModelLocalGroup(modelId);
|
||||||
|
if (!g) return null;
|
||||||
|
g.updateWorldMatrix(true, false);
|
||||||
|
const v = new THREE.Vector3(p.x, p.y, p.z);
|
||||||
|
g.localToWorld(v);
|
||||||
|
return { x: v.x, y: v.y, z: v.z };
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getModelWorldScaleFactor(modelId: string | null | undefined): number {
|
||||||
|
const g = getModelLocalGroup(modelId);
|
||||||
|
if (!g) return 1;
|
||||||
|
g.updateWorldMatrix(true, false);
|
||||||
|
const s = new THREE.Vector3();
|
||||||
|
g.getWorldScale(s);
|
||||||
|
const factor = (Math.abs(s.x) + Math.abs(s.y) + Math.abs(s.z)) / 3;
|
||||||
|
return Number.isFinite(factor) && factor > 1e-6 ? factor : 1;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user