Add function to transform world point to local in box brush components

This commit is contained in:
2026-04-05 02:55:05 +02:00
parent 667849750c
commit b83b11e75f

View File

@@ -148,6 +148,20 @@ export function transformBoxBrushWorldVectorToLocal(brush: BoxBrush, worldVector
};
}
export function transformBoxBrushWorldPointToLocal(brush: BoxBrush, worldPoint: Vec3): Vec3 {
const rotation = createBrushRotationEuler(brush);
const inverseRotation = new Quaternion().setFromEuler(rotation).invert();
const localPoint = new Vector3(worldPoint.x - brush.center.x, worldPoint.y - brush.center.y, worldPoint.z - brush.center.z).applyQuaternion(
inverseRotation
);
return {
x: localPoint.x,
y: localPoint.y,
z: localPoint.z
};
}
export function transformBoxBrushLocalPointToWorld(brush: BoxBrush, localPoint: Vec3): Vec3 {
const rotation = createBrushRotationEuler(brush);
const rotatedOffset = new Vector3(localPoint.x, localPoint.y, localPoint.z).applyEuler(rotation);