import assert from 'node:assert/strict'; import { existsSync, readFileSync } from 'node:fs'; import { test } from 'node:test'; import * as THREE from 'three'; import { loadTypescript } from './support/load-typescript.mjs'; import { loadFrameGeometry } from './support/load-frame-geometry.mjs'; const modulePath = new URL('../src/objects/BlenderHouseSurround.ts', import.meta.url); const assetPath = new URL('../public/assets/window/grandma-house-surround.glb', import.meta.url); const load = async () => { assert.ok(existsSync(modulePath), 'A bounded adapter must attach the authored room around the intact photo'); return loadTypescript(modulePath); }; const geometry = () => loadFrameGeometry(assetPath); function vertices(root) { const result=[]; root.traverse(o=>{if(o.isMesh)result.push([...o.geometry.attributes.position.array]);}); return result; } test('house surround attaches to the existing frame scene and has a bounded room fit', async () => { const { houseViewScale } = await load(); assert.equal(houseViewScale('wood'), .82); assert.equal(houseViewScale('booth'), 1); }); test('authored house geometry preserves an open photo aperture, stable resize and slipper proportions', async () => { const { prepareHouseAsset } = await load(), root=geometry(), slippers=root.getObjectByName('HouseSlippers'); slippers.geometry.computeBoundingBox(); const original=slippers.geometry.boundingBox.getSize(new THREE.Vector3()); const asset=prepareHouseAsset(root); for(const [w,h] of [[1,1.32],[1,1],[3,1],[1,3],[.2,4],[4,.2]]) { asset.resize(w,h,.6); root.updateMatrixWorld(true); root.traverse(o=>{if(!o.isMesh)return;const p=o.geometry.attributes.position,n=o.geometry.attributes.normal; for(let i=0;i