From 9a11df514a2e2dfa51e126d47724533c1ae5f13f Mon Sep 17 00:00:00 2001 From: Dr Tracy Gardner Date: Mon, 22 Dec 2025 17:33:19 +0000 Subject: [PATCH] Handle missing rotation quaternion during rotations --- api/transform.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/api/transform.js b/api/transform.js index 506b1261..dc252713 100644 --- a/api/transform.js +++ b/api/transform.js @@ -363,6 +363,19 @@ export const flockTransform = { flock.BABYLON.Tools.ToRadians(x), flock.BABYLON.Tools.ToRadians(z), ); + + if (!mesh.rotationQuaternion) { + const { + x: currentX = 0, + y: currentY = 0, + z: currentZ = 0, + } = mesh.rotation || {}; + mesh.rotationQuaternion = flock.BABYLON.Quaternion.FromEulerAngles( + currentX, + currentY, + currentZ, + ); + } mesh.rotationQuaternion.multiplyInPlace(incrementalRotation).normalize(); if (mesh.physics) {