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;
case "TransformComponent": {
const localTranslation = component["tc.localTranslation"];
// The game resets top-level node translation to [0, 0, 0] on load.
// Child nodes and customization parts must keep their authored
// local offsets.
node.setTranslation(
parent instanceof Scene && !isPart ? [0, 0, 0] : localTranslation,
);
node.setRotation(component["tc.localRotation"]);
const t = component["tc.localTranslation"];
const r = component["tc.localRotation"];
node.setTranslation([t[0], t[2], -t[1]]);
node.setRotation([r[0], r[2], -r[1], r[3]]);
node.setScale(component["tc.localScale"]);
break;
@@ -184,10 +181,27 @@ export async function extractModel(
}
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
.createAccessor(name)
.setType(vertexSize === 1 ? "SCALAR" : `VEC${vertexSize}`)
.setArray(new Float32Array(value.flat()))
.setArray(processed)
.setBuffer(buffer);
primitive.setAttribute(name, attributeAccessor);