From f73ffc3c936d9fb01fe2e4903cbfcf667839fee1 Mon Sep 17 00:00:00 2001 From: tresabhi <43380238+tresabhi@users.noreply.github.com> Date: Wed, 30 Sep 2026 19:00:25 -0500 Subject: [PATCH] correct axes --- packages/core/src/streams/scg.ts | 15 ++++----- packages/website/src/components/TankModel.tsx | 4 +-- .../[...chunk_api]/tanks/[id]/model.glb.ts | 31 ++++++++++++++----- 3 files changed, 31 insertions(+), 19 deletions(-) diff --git a/packages/core/src/streams/scg.ts b/packages/core/src/streams/scg.ts index 181137a75..00e5ed403 100644 --- a/packages/core/src/streams/scg.ts +++ b/packages/core/src/streams/scg.ts @@ -1,8 +1,8 @@ -import { ScpgReadStream, VertexAttribute } from './scpg'; +import { ScpgReadStream, VertexAttribute } from "./scpg"; interface PolygonGroupRaw { - '##name': 'PolygonGroup'; - '#id': ArrayBuffer; + "##name": "PolygonGroup"; + "#id": ArrayBuffer; cubeTextureCoordCount: number; indexCount: number; indexFormat: 0 | 1; @@ -24,7 +24,7 @@ interface BlitzkitPolygonGroup { } const vertexAttributesArray = Object.values(VertexAttribute).filter( - (value) => typeof value === 'number', + (value) => typeof value === "number", ); export const vertexAttributeVectorSizes = { @@ -105,11 +105,8 @@ export class ScgReadStream extends ScpgReadStream { } polygonGroups.set( - new DataView(polygonGroupRaw['#id']).getBigUint64(0, true), - { - vertices, - indices, - }, + new DataView(polygonGroupRaw["#id"]).getBigUint64(0, true), + { vertices, indices }, ); }); diff --git a/packages/website/src/components/TankModel.tsx b/packages/website/src/components/TankModel.tsx index c18a4f170..f3314107f 100644 --- a/packages/website/src/components/TankModel.tsx +++ b/packages/website/src/components/TankModel.tsx @@ -5,7 +5,7 @@ import { applyPitchYawLimits } from "../core/blitz/applyPitchYawLimits"; import { jsxTree } from "../core/blitzkit/jsxTree"; import { modelTransformEvent } from "../core/blitzkit/modelTransform"; import { controlsEnabledEvent } from "../core/controlsEnabled"; -import { DuelModule, useDuel } from "../hooks/useDuel"; +import { DuelModule, getDuel, useDuel } from "../hooks/useDuel"; import { useDuelModel } from "../hooks/useDuelModel"; import { hasEquipment } from "../hooks/useEquipment"; import { useModel } from "../hooks/useModel"; @@ -214,7 +214,7 @@ export function TankModel() { window.addEventListener("pointerup", handlePointerUp); } function handlePointerMove(event: PointerEvent) { - const protagonist = useDuel("protagonist", DuelModule.Tank); + const protagonist = getDuel("protagonist", DuelModule.Tank); const hasImprovedVerticalStabilizer = hasEquipment( 122, diff --git a/packages/website/src/pages/[...chunk_api]/tanks/[id]/model.glb.ts b/packages/website/src/pages/[...chunk_api]/tanks/[id]/model.glb.ts index 6eae18f85..8a56b41fa 100644 --- a/packages/website/src/pages/[...chunk_api]/tanks/[id]/model.glb.ts +++ b/packages/website/src/pages/[...chunk_api]/tanks/[id]/model.glb.ts @@ -262,13 +262,11 @@ async function extractModel(vfs: AbstractVFS, path: string) { break; case "TransformComponent": { - const localTranslation = component["tc.localTranslation"]; - // The game resets top-level node translation to [0, 0, 0] on load. - // Child nodes must keep their authored local offsets. - node.setTranslation( - parent instanceof Scene ? [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; @@ -332,10 +330,27 @@ async function extractModel(vfs: AbstractVFS, path: string) { } 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);