import assert from 'node:assert/strict'; import test from 'node:test'; import { BoxGeometry, Group, Mesh, MeshStandardMaterial, Vector3 } from 'three'; import { createSummitMarker } from '../src/scene/summitMarker.ts'; 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()); mesh.position.y = 2; asset.add(mesh); const groundAt = (x: number, z: number) => 12 + .3*x - .2*z; const rock = new MeshStandardMaterial(); const marker = createSummitMarker(asset, {x:0,z:0}, groundAt, rock); marker.group.updateMatrixWorld(true); const position = mesh.geometry.getAttribute('position'); const point = new Vector3(); let nearestContact = Infinity; for (let i=0; i .05, `base must stay below terrain: ${burial}`); assert.equal(position.getY(i),-2,'base geometry remains unchanged'); nearestContact = Math.min(nearestContact,burial); } else { assert.equal(position.getY(i),2,'upper geometry remains unchanged'); } } assert.ok(nearestContact < .3,'the stone is seated close to its lowest contact'); marker.dispose(); rock.dispose(); });