Add function to transform world point to local in box brush components
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user