Integrate infrastructure preparation and qualified map delivery with local scenes. Add semantic editing, object provenance, survey caching and operator scene tools.
22 lines
1.1 KiB
JavaScript
22 lines
1.1 KiB
JavaScript
import assert from 'node:assert/strict';
|
|
import {before,after,test} from 'node:test';
|
|
import {createServer} from './support/vite-server.mjs';
|
|
let server,Terrain;
|
|
before(async()=>{
|
|
server=await createServer({appType:'custom',logLevel:'silent',server:{middlewareMode:true}});
|
|
({EditorTerrain:Terrain}=await server.ssrLoadModule('/src/components/simulation/EditorTerrain.ts'));
|
|
});
|
|
after(async()=>{await server?.close();});
|
|
test('picking and ground snapping cannot select surfaces hidden by either plane',()=>{
|
|
const terrain=Object.create(Terrain.prototype);
|
|
const hit=(y,distance,normal=1)=>({point:{y},distance,face:{normal:{y:normal}}});
|
|
const lower=hit(-3,1), middle=hit(2,3), upper=hit(9,2), wall=hit(1,1.5,0);
|
|
terrain.trees=[{raycast:()=>[lower,middle,upper,wall]}];terrain.bounds={max:{y:10}};
|
|
assert.equal(terrain.pick([0,20,0],[0,-1,0],5,0),middle.point);
|
|
assert.equal(terrain.pickSurface([0,20,0],[0,-1,0],5,false,0),wall.point);
|
|
assert.equal(terrain.ground(0,0,-3,5,0),middle.point);
|
|
assert.equal(terrain.pick([0,20,0],[0,-1,0],1,0),null);
|
|
assert.equal(terrain.pick([0,20,0],[0,-1,0]),lower.point);
|
|
assert.equal(terrain.ground(0,0,-3),lower.point);
|
|
});
|