forked from phenom/healer-man
Update Healer Man server
This commit is contained in:
1 parent
6114a2295f
commit
69809f7228
593 files changed
+903643
-40774
No files matched your search
@@ -0,0 +1,28 @@
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { mkdtemp, rm } from "node:fs/promises";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { Document, NodeIO } from "@gltf-transform/core";
|
||||
import { writeBoundedCollisionGlbs } from "./bounded-collision-glb.mjs";
|
||||
|
||||
test("collision chunking preserves transformed triangles, reflected winding and hard caps", async () => {
|
||||
const directory = await mkdtemp(path.join(os.tmpdir(), "rom-bounded-collision-"));
|
||||
try {
|
||||
const io = new NodeIO(), document = new Document(), buffer = document.createBuffer();
|
||||
const position = document.createAccessor("position", buffer).setType("VEC3").setArray(new Float32Array([0,0,0, 1,0,0, 0,0,1]));
|
||||
const indices = document.createAccessor("indices", buffer).setType("SCALAR").setArray(new Uint16Array([0,1,2, 0,1,2, 0,1,2]));
|
||||
const scene = document.createScene(); document.getRoot().setDefaultScene(scene);
|
||||
scene.addChild(document.createNode().setTranslation([10,2,3]).setScale([-1,1,1]).setMesh(document.createMesh().addPrimitive(document.createPrimitive().setAttribute("POSITION", position).setIndices(indices))));
|
||||
const input = path.join(directory, "source.glb"); await io.write(input, document);
|
||||
const records = await writeBoundedCollisionGlbs(input, directory, "fixture", { maximumTriangles: 2 });
|
||||
assert.deepEqual(records.map(row => row.triangles), [2,1]);
|
||||
const arrays = [];
|
||||
for (const row of records) arrays.push(...(await io.read(path.join(directory, row.file))).getRoot().listAccessors()[0].getArray());
|
||||
assert.deepEqual(arrays, Array(3).fill([10,2,3, 10,2,4, 9,2,3]).flat());
|
||||
} finally {
|
||||
assert.ok(path.resolve(directory).startsWith(path.resolve(os.tmpdir()) + path.sep)
|
||||
&& path.basename(directory).startsWith("rom-bounded-collision-"));
|
||||
await rm(directory, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user