Fix stale packed textures in summit marker export
This commit is contained in:
Binary file not shown.
@@ -15,6 +15,16 @@ for obj in [marker,*marker.children_recursive]:obj.select_set(True)
|
|||||||
bpy.context.view_layer.objects.active=marker
|
bpy.context.view_layer.objects.active=marker
|
||||||
location=marker.location.copy();marker.location=(0,0,0)
|
location=marker.location.copy();marker.location=(0,0,0)
|
||||||
photo_body=bpy.data.objects.get('Photo matched summit boulder')
|
photo_body=bpy.data.objects.get('Photo matched summit boulder')
|
||||||
|
# Repacking an already-packed image after baking can retain its old PNG bytes.
|
||||||
|
# Refresh from the saved bake before glTF copies those bytes into the GLB.
|
||||||
|
if photo_body and photo_body.get('paintedInscription'):
|
||||||
|
images={n.image for mat in photo_body.data.materials for n in mat.node_tree.nodes
|
||||||
|
if n.type=='TEX_IMAGE' and n.image and n.image.filepath}
|
||||||
|
for image in images:
|
||||||
|
path=Path(bpy.path.abspath(image.filepath))
|
||||||
|
data=path.read_bytes()
|
||||||
|
image.pack(data=data,data_len=len(data))
|
||||||
|
image.reload()
|
||||||
restore=None
|
restore=None
|
||||||
if photo_body and not photo_body.get('paintedInscription'):
|
if photo_body and not photo_body.get('paintedInscription'):
|
||||||
mat=photo_body.data.materials[0]
|
mat=photo_body.data.materials[0]
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
export const SUMMIT_MARKER = {
|
export const SUMMIT_MARKER = {
|
||||||
assetRevision: '8de117c42335',
|
assetRevision: 'e8ea25042407',
|
||||||
buriedDepth: 0.12,
|
buriedDepth: 0.12,
|
||||||
footHeight: 0.18,
|
footHeight: 0.18,
|
||||||
} as const;
|
} as const;
|
||||||
|
|||||||
@@ -1,8 +1,24 @@
|
|||||||
import assert from 'node:assert/strict';
|
import assert from 'node:assert/strict';
|
||||||
import test from 'node:test';
|
import test from 'node:test';
|
||||||
|
import { readFileSync } from 'node:fs';
|
||||||
import { BoxGeometry, Group, Mesh, MeshStandardMaterial, Vector3 } from 'three';
|
import { BoxGeometry, Group, Mesh, MeshStandardMaterial, Vector3 } from 'three';
|
||||||
import { createSummitMarker } from '../src/scene/summitMarker.ts';
|
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', () => {
|
test('marker seats its foot on sloping bedrock without deforming the stone', () => {
|
||||||
const asset = new Group();
|
const asset = new Group();
|
||||||
const mesh = new Mesh(new BoxGeometry(4, 4, 2), new MeshStandardMaterial());
|
const mesh = new Mesh(new BoxGeometry(4, 4, 2), new MeshStandardMaterial());
|
||||||
|
|||||||
Reference in New Issue
Block a user