mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 11:39:50 +02:00
correct axes
This commit is contained in:
1 parent
5d4e0541b2
commit
f73ffc3c93
3 files changed
+31
-19
No files matched your search
@@ -1,8 +1,8 @@
|
|||||||
import { ScpgReadStream, VertexAttribute } from './scpg';
|
import { ScpgReadStream, VertexAttribute } from "./scpg";
|
||||||
|
|
||||||
interface PolygonGroupRaw {
|
interface PolygonGroupRaw {
|
||||||
'##name': 'PolygonGroup';
|
"##name": "PolygonGroup";
|
||||||
'#id': ArrayBuffer;
|
"#id": ArrayBuffer;
|
||||||
cubeTextureCoordCount: number;
|
cubeTextureCoordCount: number;
|
||||||
indexCount: number;
|
indexCount: number;
|
||||||
indexFormat: 0 | 1;
|
indexFormat: 0 | 1;
|
||||||
@@ -24,7 +24,7 @@ interface BlitzkitPolygonGroup {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const vertexAttributesArray = Object.values(VertexAttribute).filter(
|
const vertexAttributesArray = Object.values(VertexAttribute).filter(
|
||||||
(value) => typeof value === 'number',
|
(value) => typeof value === "number",
|
||||||
);
|
);
|
||||||
|
|
||||||
export const vertexAttributeVectorSizes = {
|
export const vertexAttributeVectorSizes = {
|
||||||
@@ -105,11 +105,8 @@ export class ScgReadStream extends ScpgReadStream {
|
|||||||
}
|
}
|
||||||
|
|
||||||
polygonGroups.set(
|
polygonGroups.set(
|
||||||
new DataView(polygonGroupRaw['#id']).getBigUint64(0, true),
|
new DataView(polygonGroupRaw["#id"]).getBigUint64(0, true),
|
||||||
{
|
{ vertices, indices },
|
||||||
vertices,
|
|
||||||
indices,
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { applyPitchYawLimits } from "../core/blitz/applyPitchYawLimits";
|
|||||||
import { jsxTree } from "../core/blitzkit/jsxTree";
|
import { jsxTree } from "../core/blitzkit/jsxTree";
|
||||||
import { modelTransformEvent } from "../core/blitzkit/modelTransform";
|
import { modelTransformEvent } from "../core/blitzkit/modelTransform";
|
||||||
import { controlsEnabledEvent } from "../core/controlsEnabled";
|
import { controlsEnabledEvent } from "../core/controlsEnabled";
|
||||||
import { DuelModule, useDuel } from "../hooks/useDuel";
|
import { DuelModule, getDuel, useDuel } from "../hooks/useDuel";
|
||||||
import { useDuelModel } from "../hooks/useDuelModel";
|
import { useDuelModel } from "../hooks/useDuelModel";
|
||||||
import { hasEquipment } from "../hooks/useEquipment";
|
import { hasEquipment } from "../hooks/useEquipment";
|
||||||
import { useModel } from "../hooks/useModel";
|
import { useModel } from "../hooks/useModel";
|
||||||
@@ -214,7 +214,7 @@ export function TankModel() {
|
|||||||
window.addEventListener("pointerup", handlePointerUp);
|
window.addEventListener("pointerup", handlePointerUp);
|
||||||
}
|
}
|
||||||
function handlePointerMove(event: PointerEvent) {
|
function handlePointerMove(event: PointerEvent) {
|
||||||
const protagonist = useDuel("protagonist", DuelModule.Tank);
|
const protagonist = getDuel("protagonist", DuelModule.Tank);
|
||||||
|
|
||||||
const hasImprovedVerticalStabilizer = hasEquipment(
|
const hasImprovedVerticalStabilizer = hasEquipment(
|
||||||
122,
|
122,
|
||||||
|
|||||||
@@ -262,13 +262,11 @@ async function extractModel(vfs: AbstractVFS, path: string) {
|
|||||||
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 must keep their authored local offsets.
|
|
||||||
node.setTranslation(
|
node.setTranslation([t[0], t[2], -t[1]]);
|
||||||
parent instanceof Scene ? [0, 0, 0] : localTranslation,
|
node.setRotation([r[0], r[2], -r[1], r[3]]);
|
||||||
);
|
|
||||||
node.setRotation(component["tc.localRotation"]);
|
|
||||||
node.setScale(component["tc.localScale"]);
|
node.setScale(component["tc.localScale"]);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -332,10 +330,27 @@ async function extractModel(vfs: AbstractVFS, path: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
|
|||||||
Reference in new issue
Block a user