mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 10:47:04 +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 {
|
||||
'##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 },
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user