Fix stale packed textures in summit marker export
This commit is contained in:
@@ -1,8 +1,24 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { BoxGeometry, Group, Mesh, MeshStandardMaterial, Vector3 } from 'three';
|
||||
import { createSummitMarker } from '../src/scene/summitMarker.ts';
|
||||
|
||||
test('exported marker embeds the current baked textures, not stale packed images', () => {
|
||||
const glb = readFileSync(new URL('../public/models/summit/summit-marker.glb', import.meta.url));
|
||||
const jsonLength = glb.readUInt32LE(12);
|
||||
const document = JSON.parse(glb.subarray(20, 20 + jsonLength).toString());
|
||||
const binaryStart = 28 + jsonLength;
|
||||
assert.equal(document.images.length, 4);
|
||||
for (const image of document.images) {
|
||||
const view = document.bufferViews[image.bufferView];
|
||||
const start = binaryStart + (view.byteOffset ?? 0);
|
||||
const embedded = glb.subarray(start, start + view.byteLength);
|
||||
const source = readFileSync(new URL(`../public/terrain/materials/${image.name}.png`, import.meta.url));
|
||||
assert.ok(embedded.equals(source), `${image.name} must match the latest bake`);
|
||||
}
|
||||
});
|
||||
|
||||
test('marker seats its foot on sloping bedrock without deforming the stone', () => {
|
||||
const asset = new Group();
|
||||
const mesh = new Mesh(new BoxGeometry(4, 4, 2), new MeshStandardMaterial());
|
||||
|
||||
Reference in New Issue
Block a user