Fix stale packed textures in summit marker export

This commit is contained in:
2026-10-31 11:04:53 +09:00
parent 1b8698565a
commit 18dfb63350
4 changed files with 27 additions and 1 deletions
+16
View File
@@ -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());