re apply rotation patch

This commit is contained in:
tresabhi committed 2026-10-27 11:40:47 -05:00
1 parent 3470d68204
commit fae0277b69
1 file changed
+23 -9
@@ -107,14 +107,11 @@ export async function extractModel(
break; break;
case "TransformComponent": { case "TransformComponent": {
const localTranslation = component["tc.localTranslation"]; const t = component["tc.localTranslation"];
// The game resets top-level node translation to [0, 0, 0] on load. const r = component["tc.localRotation"];
// Child nodes and customization parts must keep their authored
// local offsets. node.setTranslation([t[0], t[2], -t[1]]);
node.setTranslation( node.setRotation([r[0], r[2], -r[1], r[3]]);
parent instanceof Scene && !isPart ? [0, 0, 0] : localTranslation,
);
node.setRotation(component["tc.localRotation"]);
node.setScale(component["tc.localScale"]); node.setScale(component["tc.localScale"]);
break; break;
@@ -184,10 +181,27 @@ export async function extractModel(
} }
const vertexSize = vertexAttributeGltfVectorSizes[attribute]; const vertexSize = vertexAttributeGltfVectorSizes[attribute];
const processed = new Float32Array(value.flat());
if (
attribute === VertexAttribute.VERTEX ||
attribute === VertexAttribute.NORMAL ||
attribute === VertexAttribute.TANGENT ||
attribute === VertexAttribute.BINORMAL
) {
for (let i = 0; i < processed.length; i += 3) {
const y = processed[i + 1];
const z = processed[i + 2];
processed[i + 1] = z;
processed[i + 2] = -y;
}
}
const attributeAccessor = document const attributeAccessor = document
.createAccessor(name) .createAccessor(name)
.setType(vertexSize === 1 ? "SCALAR" : `VEC${vertexSize}`) .setType(vertexSize === 1 ? "SCALAR" : `VEC${vertexSize}`)
.setArray(new Float32Array(value.flat())) .setArray(processed)
.setBuffer(buffer); .setBuffer(buffer);
primitive.setAttribute(name, attributeAccessor); primitive.setAttribute(name, attributeAccessor);