forked from phenom/healer-man
Update Healer Man server
This commit is contained in:
1 parent
6114a2295f
commit
69809f7228
593 files changed
+903643
-40774
No files matched your search
@@ -81,6 +81,31 @@ export function transformSourcePointToPrimaryThree(
|
||||
return [point.x * meters, point.y * meters, -point.z * meters];
|
||||
}
|
||||
|
||||
export function transformSourceHeadingToPrimaryThree(sourceYawRadians, primary) {
|
||||
const yaw = Number(sourceYawRadians);
|
||||
if (!Number.isFinite(yaw)) throw new Error("sourceYawRadians must be finite.");
|
||||
const rotation = new Quaternion(...finiteTuple(primary?.rotation, 4, "primary.rotation"));
|
||||
if (rotation.lengthSq() < 1e-12) throw new Error("primary.rotation cannot be zero.");
|
||||
rotation.normalize().invert();
|
||||
const scale = finiteTuple(primary?.scale, 3, "primary.scale");
|
||||
if (scale.some((value) => Math.abs(value) < 1e-12)) {
|
||||
throw new Error("primary.scale cannot contain zero.");
|
||||
}
|
||||
|
||||
// RuneWaker's left-handed forward is -Z at yaw zero. Rotate in the source
|
||||
// basis first, apply inverse primary scale, then reflect Z into Three.js and
|
||||
// normalize the planar vector.
|
||||
const forward = new Vector3(Math.sin(yaw), 0, -Math.cos(yaw)).applyQuaternion(rotation);
|
||||
forward.set(forward.x / scale[0], forward.y / scale[1], forward.z / scale[2]);
|
||||
forward.y = 0;
|
||||
forward.z *= -1;
|
||||
const length = Math.hypot(forward.x, forward.z);
|
||||
if (!Number.isFinite(length) || length < 1e-8) {
|
||||
throw new Error("Source heading collapsed when transformed into the primary frame.");
|
||||
}
|
||||
return [forward.x / length, 0, forward.z / length];
|
||||
}
|
||||
|
||||
function cloneNodeTree(document, node) {
|
||||
const clone = document.createNode(node.getName())
|
||||
.setMatrix(node.getMatrix())
|
||||
|
||||
Reference in new issue
Block a user