selva-compute 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +110 -0
  3. package/dist/base-DbB0Ggdq.d.cts +118 -0
  4. package/dist/base-DbB0Ggdq.d.ts +118 -0
  5. package/dist/chunk-24EXIE4G.js +3 -0
  6. package/dist/chunk-24EXIE4G.js.map +1 -0
  7. package/dist/chunk-5DJRUPGI.cjs +2 -0
  8. package/dist/chunk-5DJRUPGI.cjs.map +1 -0
  9. package/dist/chunk-AEQTQHPY.js +2 -0
  10. package/dist/chunk-AEQTQHPY.js.map +1 -0
  11. package/dist/chunk-JJLRDYYP.js +2 -0
  12. package/dist/chunk-JJLRDYYP.js.map +1 -0
  13. package/dist/chunk-OXD76DAK.js +2 -0
  14. package/dist/chunk-OXD76DAK.js.map +1 -0
  15. package/dist/chunk-P57VU27W.cjs +3 -0
  16. package/dist/chunk-P57VU27W.cjs.map +1 -0
  17. package/dist/chunk-PNG3L5TM.cjs +2 -0
  18. package/dist/chunk-PNG3L5TM.cjs.map +1 -0
  19. package/dist/chunk-TVCJBLSW.cjs +2 -0
  20. package/dist/chunk-TVCJBLSW.cjs.map +1 -0
  21. package/dist/core.cjs +2 -0
  22. package/dist/core.cjs.map +1 -0
  23. package/dist/core.d.cts +114 -0
  24. package/dist/core.d.ts +114 -0
  25. package/dist/core.js +2 -0
  26. package/dist/core.js.map +1 -0
  27. package/dist/files.cjs +2 -0
  28. package/dist/files.cjs.map +1 -0
  29. package/dist/files.d.cts +34 -0
  30. package/dist/files.d.ts +34 -0
  31. package/dist/files.js +2 -0
  32. package/dist/files.js.map +1 -0
  33. package/dist/grasshopper.cjs +2 -0
  34. package/dist/grasshopper.cjs.map +1 -0
  35. package/dist/grasshopper.d.cts +741 -0
  36. package/dist/grasshopper.d.ts +741 -0
  37. package/dist/grasshopper.js +2 -0
  38. package/dist/grasshopper.js.map +1 -0
  39. package/dist/index.cjs +2 -0
  40. package/dist/index.cjs.map +1 -0
  41. package/dist/index.d.cts +8 -0
  42. package/dist/index.d.ts +8 -0
  43. package/dist/index.js +2 -0
  44. package/dist/index.js.map +1 -0
  45. package/dist/schemas-5LuPKgX2.d.cts +202 -0
  46. package/dist/schemas-5LuPKgX2.d.ts +202 -0
  47. package/dist/types-SwbLAMW8.d.cts +27 -0
  48. package/dist/types-SwbLAMW8.d.ts +27 -0
  49. package/dist/types-r00wVwfo.d.cts +77 -0
  50. package/dist/types-r00wVwfo.d.ts +77 -0
  51. package/dist/visualization.cjs +2 -0
  52. package/dist/visualization.cjs.map +1 -0
  53. package/dist/visualization.d.cts +202 -0
  54. package/dist/visualization.d.ts +202 -0
  55. package/dist/visualization.js +2 -0
  56. package/dist/visualization.js.map +1 -0
  57. package/package.json +117 -0
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunk5DJRUPGIcjs = require('./chunk-5DJRUPGI.cjs');var _chunkP57VU27Wcjs = require('./chunk-P57VU27W.cjs');var _three = require('three'); var i = _interopRequireWildcard(_three); var R = _interopRequireWildcard(_three); var m = _interopRequireWildcard(_three); var w = _interopRequireWildcard(_three);var _OrbitControlsjs = require('three/addons/controls/OrbitControls.js');var _RGBELoaderjs = require('three/addons/loaders/RGBELoader.js');var k=new i.Vector3(0,0,1),_= exports.initThree =function(e,r){let t=Z(r||{}),n=J(t),o=re(t),a=oe(e,t),s=se(o,e,t);ee(n,t),te(n,t),_optionalChain([t, 'access', _2 => _2.floor, 'optionalAccess', _3 => _3.enabled])&&ne(n,t);let l=t.events.enableEventHandlers!==!1?ae(e,n,o,s,t):{dispose:()=>{},fitToView:()=>{},clearSelection:()=>{}},{resize:c,dispose:T}=Q(e,a,o),{animate:h,dispose:u}=X(a,n,o,s);h();let p=_optionalChain([t, 'access', _4 => _4.environment, 'optionalAccess', _5 => _5.sceneUp])||k;return n.up.set(p.x,p.y,p.z),{scene:n,camera:o,controls:s,renderer:a,dispose:()=>{u(),T(),l.dispose(),s.dispose(),a.dispose(),n.traverse(f=>{f instanceof i.Mesh&&(_optionalChain([f, 'access', _6 => _6.geometry, 'optionalAccess', _7 => _7.dispose, 'call', _8 => _8()]),Array.isArray(f.material)?f.material.forEach(H=>H.dispose()):_optionalChain([f, 'access', _9 => _9.material, 'optionalAccess', _10 => _10.dispose, 'call', _11 => _11()]))})},resize:c,fitToView:l.fitToView,clearSelection:l.clearSelection}};function Z(e){let r=e.sceneScale||"m",n={mm:{cameraDistance:20,near:.1,far:2e3,floorSize:100,lightDistance:10,lightHeight:20,minDistance:.1,shadowSize:100,scaleFactor:1e3},cm:{cameraDistance:20,near:.1,far:2e3,floorSize:100,lightDistance:25,lightHeight:50,minDistance:.1,shadowSize:100,scaleFactor:100},m:{cameraDistance:10,near:.01,far:2e3,floorSize:50,lightDistance:25,lightHeight:50,minDistance:.001,shadowSize:100,scaleFactor:1},inches:{cameraDistance:15,near:.1,far:2e3,floorSize:80,lightDistance:20,lightHeight:40,minDistance:.1,shadowSize:80,scaleFactor:39.37},feet:{cameraDistance:8,near:.1,far:2e3,floorSize:40,lightDistance:15,lightHeight:30,minDistance:.1,shadowSize:60,scaleFactor:3.28084}}[r];return{sceneScale:r,camera:{position:_optionalChain([e, 'access', _12 => _12.camera, 'optionalAccess', _13 => _13.position])||new i.Vector3(-n.cameraDistance,n.cameraDistance,n.cameraDistance),fov:_optionalChain([e, 'access', _14 => _14.camera, 'optionalAccess', _15 => _15.fov])||20,near:_optionalChain([e, 'access', _16 => _16.camera, 'optionalAccess', _17 => _17.near])||n.near,far:_optionalChain([e, 'access', _18 => _18.camera, 'optionalAccess', _19 => _19.far])||n.far,target:_optionalChain([e, 'access', _20 => _20.camera, 'optionalAccess', _21 => _21.target])||new i.Vector3(0,0,0)},lighting:{enableSunlight:_nullishCoalesce(_optionalChain([e, 'access', _22 => _22.lighting, 'optionalAccess', _23 => _23.enableSunlight]), () => (!0)),sunlightIntensity:_optionalChain([e, 'access', _24 => _24.lighting, 'optionalAccess', _25 => _25.sunlightIntensity])||1,sunlightPosition:_optionalChain([e, 'access', _26 => _26.lighting, 'optionalAccess', _27 => _27.sunlightPosition])||new i.Vector3(n.lightDistance,n.lightHeight,n.lightDistance),ambientLightColor:_optionalChain([e, 'access', _28 => _28.lighting, 'optionalAccess', _29 => _29.ambientLightColor])||new i.Color(4210752),ambientLightIntensity:_optionalChain([e, 'access', _30 => _30.lighting, 'optionalAccess', _31 => _31.ambientLightIntensity])||1,sunlightColor:_optionalChain([e, 'access', _32 => _32.lighting, 'optionalAccess', _33 => _33.sunlightColor])||16777215},environment:{hdrPath:_optionalChain([e, 'access', _34 => _34.environment, 'optionalAccess', _35 => _35.hdrPath])||"/baseHDR.hdr",backgroundColor:_optionalChain([e, 'access', _36 => _36.environment, 'optionalAccess', _37 => _37.backgroundColor])||new i.Color(15790320),enableEnvironmentLighting:_nullishCoalesce(_optionalChain([e, 'access', _38 => _38.environment, 'optionalAccess', _39 => _39.enableEnvironmentLighting]), () => (!0)),sceneUp:_optionalChain([e, 'access', _40 => _40.environment, 'optionalAccess', _41 => _41.sceneUp])||k,showEnvironment:_nullishCoalesce(_optionalChain([e, 'access', _42 => _42.environment, 'optionalAccess', _43 => _43.showEnvironment]), () => (!1))},floor:{enabled:_nullishCoalesce(_optionalChain([e, 'access', _44 => _44.floor, 'optionalAccess', _45 => _45.enabled]), () => (!1)),size:_optionalChain([e, 'access', _46 => _46.floor, 'optionalAccess', _47 => _47.size])||n.floorSize,color:_optionalChain([e, 'access', _48 => _48.floor, 'optionalAccess', _49 => _49.color])||new i.Color(8421504),roughness:_optionalChain([e, 'access', _50 => _50.floor, 'optionalAccess', _51 => _51.roughness])||.7,metalness:_optionalChain([e, 'access', _52 => _52.floor, 'optionalAccess', _53 => _53.metalness])||0,receiveShadow:_nullishCoalesce(_optionalChain([e, 'access', _54 => _54.floor, 'optionalAccess', _55 => _55.receiveShadow]), () => (!0))},render:{enableShadows:_nullishCoalesce(_optionalChain([e, 'access', _56 => _56.render, 'optionalAccess', _57 => _57.enableShadows]), () => (!0)),shadowMapSize:_optionalChain([e, 'access', _58 => _58.render, 'optionalAccess', _59 => _59.shadowMapSize])||2048,antialias:_nullishCoalesce(_optionalChain([e, 'access', _60 => _60.render, 'optionalAccess', _61 => _61.antialias]), () => (!0)),pixelRatio:_optionalChain([e, 'access', _62 => _62.render, 'optionalAccess', _63 => _63.pixelRatio])||Math.min(window.devicePixelRatio,2),toneMapping:_optionalChain([e, 'access', _64 => _64.render, 'optionalAccess', _65 => _65.toneMapping])||i.NeutralToneMapping,toneMappingExposure:_optionalChain([e, 'access', _66 => _66.render, 'optionalAccess', _67 => _67.toneMappingExposure])||1,preserveDrawingBuffer:_nullishCoalesce(_optionalChain([e, 'access', _68 => _68.render, 'optionalAccess', _69 => _69.preserveDrawingBuffer]), () => (!1))},controls:{enableDamping:_nullishCoalesce(_optionalChain([e, 'access', _70 => _70.controls, 'optionalAccess', _71 => _71.enableDamping]), () => (!1)),dampingFactor:_optionalChain([e, 'access', _72 => _72.controls, 'optionalAccess', _73 => _73.dampingFactor])||.05,autoRotate:_nullishCoalesce(_optionalChain([e, 'access', _74 => _74.controls, 'optionalAccess', _75 => _75.autoRotate]), () => (!1)),autoRotateSpeed:_optionalChain([e, 'access', _76 => _76.controls, 'optionalAccess', _77 => _77.autoRotateSpeed])||.5,enableZoom:_nullishCoalesce(_optionalChain([e, 'access', _78 => _78.controls, 'optionalAccess', _79 => _79.enableZoom]), () => (!0)),enablePan:_nullishCoalesce(_optionalChain([e, 'access', _80 => _80.controls, 'optionalAccess', _81 => _81.enablePan]), () => (!0)),minDistance:_optionalChain([e, 'access', _82 => _82.controls, 'optionalAccess', _83 => _83.minDistance])||n.minDistance,maxDistance:_optionalChain([e, 'access', _84 => _84.controls, 'optionalAccess', _85 => _85.maxDistance])||1/0},events:{onBackgroundClicked:_optionalChain([e, 'access', _86 => _86.events, 'optionalAccess', _87 => _87.onBackgroundClicked]),onObjectSelected:_optionalChain([e, 'access', _88 => _88.events, 'optionalAccess', _89 => _89.onObjectSelected]),onMeshMetadataClicked:_optionalChain([e, 'access', _90 => _90.events, 'optionalAccess', _91 => _91.onMeshMetadataClicked]),selectionColor:_optionalChain([e, 'access', _92 => _92.events, 'optionalAccess', _93 => _93.selectionColor])||"#ff0000",enableEventHandlers:_nullishCoalesce(_optionalChain([e, 'access', _94 => _94.events, 'optionalAccess', _95 => _95.enableEventHandlers]), () => (!0)),enableKeyboardControls:_nullishCoalesce(_optionalChain([e, 'access', _96 => _96.events, 'optionalAccess', _97 => _97.enableKeyboardControls]), () => (!0)),enableClickToFocus:_nullishCoalesce(_optionalChain([e, 'access', _98 => _98.events, 'optionalAccess', _99 => _99.enableClickToFocus]), () => (!0))}}}function J(e){let r=new i.Scene;r.children.forEach(n=>{n.userData.id!=="floor"&&r.remove(n)});let t=typeof e.environment.backgroundColor=="string"?new i.Color(e.environment.backgroundColor):e.environment.backgroundColor;return r.background=t||null,r}function X(e,r,t,n){let o=null,a=function(){o=requestAnimationFrame(a),n.enableDamping&&n.update(),e.render(r,t)};return{animate:a,dispose:()=>{o!==null&&(cancelAnimationFrame(o),o=null)}}}function Q(e,r,t){let n=e.parentElement,o,a=null,s=()=>n?{width:n.clientWidth,height:n.clientHeight}:{width:window.innerWidth,height:window.innerHeight},l=()=>{o&&clearTimeout(o),o=setTimeout(()=>{let{width:T,height:h}=s();(r.domElement.width!==T||r.domElement.height!==h)&&(r.setSize(T,h,!1),t.aspect=T/h,t.updateProjectionMatrix())},16)};return n&&typeof ResizeObserver<"u"?(a=new ResizeObserver(l),a.observe(n)):window.addEventListener("resize",l),{resize:l,dispose:()=>{o&&clearTimeout(o),a?a.disconnect():window.removeEventListener("resize",l)}}}function ee(e,r){r.environment.enableEnvironmentLighting&&new (0, _RGBELoaderjs.RGBELoader)().load(r.environment.hdrPath||"/baseHDR.hdr",function(t){t.mapping=i.EquirectangularReflectionMapping,e.environment=t,r.environment.showEnvironment&&(e.background=t)},void 0,function(t){_chunkP57VU27Wcjs.j.call(void 0, ).warn("HDR texture could not be loaded, falling back to basic lighting:",t);let n=new i.AmbientLight(4210752,.4);e.add(n)})}function te(e,r){let t=new i.AmbientLight(r.lighting.ambientLightColor,r.lighting.ambientLightIntensity);if(e.add(t),r.lighting.enableSunlight){let n=new i.DirectionalLight(_nullishCoalesce(r.lighting.sunlightColor, () => (16777215)),r.lighting.sunlightIntensity),o=r.lighting.sunlightPosition;if(o&&n.position.set(o.x,o.y,o.z),r.render.enableShadows){n.castShadow=!0;let a=r.sceneScale==="mm"?.1:r.sceneScale==="cm"?10:100;n.shadow.camera.left=-a,n.shadow.camera.right=a,n.shadow.camera.top=a,n.shadow.camera.bottom=-a;let s=r.sceneScale==="mm"?.001:r.sceneScale==="cm"?.1:.5,l=r.sceneScale==="mm"?1:r.sceneScale==="cm"?100:500;n.shadow.camera.near=s,n.shadow.camera.far=l,n.shadow.mapSize.width=r.render.shadowMapSize||2048,n.shadow.mapSize.height=r.render.shadowMapSize||2048,n.shadow.bias=-1e-4,n.shadow.normalBias=.02}e.add(n)}}function ne(e,r){let t=r.floor.size,n=new i.PlaneGeometry(t,t),o=typeof r.floor.color=="string"?new i.Color(r.floor.color):r.floor.color,a=new i.MeshStandardMaterial({color:o,roughness:r.floor.roughness,metalness:r.floor.metalness,side:i.DoubleSide}),s=new i.Mesh(n,a);s.userData.id="floor",s.name="floor",s.rotation.x=-Math.PI/2,s.position.y=0,r.floor.receiveShadow&&r.render.enableShadows&&(s.receiveShadow=!0),e.add(s)}function re(e){let t=_optionalChain([document, 'access', _100 => _100.querySelector, 'call', _101 => _101("canvas"), 'optionalAccess', _102 => _102.parentElement]),n=t?t.clientWidth:window.innerWidth,o=t?t.clientHeight:window.innerHeight,a=new i.PerspectiveCamera(e.camera.fov,n/o,e.camera.near,e.camera.far),s=e.camera.position;return s&&a.position.set(s.x,s.y,s.z),a}function oe(e,r){let t=new i.WebGLRenderer({antialias:r.render.antialias,canvas:e,alpha:!0,powerPreference:"high-performance",preserveDrawingBuffer:r.render.preserveDrawingBuffer,logarithmicDepthBuffer:!0}),n=e.parentElement,o=n?n.clientWidth:window.innerWidth,a=n?n.clientHeight:window.innerHeight;return n&&(e.style.width="100%",e.style.height="100%",e.style.display="block"),t.setSize(o,a,!1),t.setPixelRatio(r.render.pixelRatio||Math.min(window.devicePixelRatio,2)),r.render.enableShadows&&(t.shadowMap.enabled=!0,t.shadowMap.type=i.VSMShadowMap),t.toneMapping=r.render.toneMapping||i.ACESFilmicToneMapping,t.toneMappingExposure=r.render.toneMappingExposure||1,t.outputColorSpace=i.SRGBColorSpace,t.sortObjects=!0,t}function ae(e,r,t,n,o){let a=new Set,s=new Map,l=new i.Raycaster,c=new i.Vector2,T=new i.Vector2,h=()=>{let d=new i.Box3;if(r.traverse(B=>{B.visible&&B.userData.id!=="floor"&&B instanceof i.Mesh&&d.expandByObject(B)}),d.isEmpty()){_chunkP57VU27Wcjs.j.call(void 0, ).warn("No objects to fit to view");return}let b=d.getCenter(new i.Vector3),g=d.getSize(new i.Vector3),v=Math.max(g.x,g.y,g.z),y=t.fov*(Math.PI/180),S=v/(2*Math.tan(y/2));S*=1.5;let $=t.position.clone().sub(n.target).normalize();t.position.copy(b.clone().add($.multiplyScalar(S))),n.target.copy(b),n.update()},u=typeof o.events.selectionColor=="string"?new i.Color(o.events.selectionColor):o.events.selectionColor instanceof i.Color?o.events.selectionColor:new i.Color("#ff0000"),p=()=>{a.forEach(d=>{d instanceof i.Mesh&&s.has(d)&&(d.material=s.get(d),s.delete(d))}),a.clear()},x=d=>{T.set(d.clientX,d.clientY)},f=d=>{let b=new i.Vector2(d.clientX,d.clientY);if(T.distanceTo(b)>5)return;let g=e.getBoundingClientRect();c.x=(d.clientX-g.left)/g.width*2-1,c.y=-((d.clientY-g.top)/g.height)*2+1,l.setFromCamera(c,t);let v=l.intersectObjects(r.children,!0);if(v.length>0){let y=v[0].object;if(!a.has(y)){if(p(),a.add(y),y instanceof i.Mesh&&y.material instanceof i.Material){s.set(y,y.material);let S=y.material.clone();S.emissive=u.clone(),y.material=S}_optionalChain([o, 'access', _103 => _103.events, 'optionalAccess', _104 => _104.onObjectSelected, 'optionalCall', _105 => _105(y)]),y instanceof i.Mesh&&Object.keys(y.userData).length>0&&_optionalChain([o, 'access', _106 => _106.events, 'optionalAccess', _107 => _107.onMeshMetadataClicked, 'optionalCall', _108 => _108(y.userData)])}}else p(),_optionalChain([o, 'access', _109 => _109.events, 'optionalAccess', _110 => _110.onBackgroundClicked, 'optionalCall', _111 => _111({x:c.x,y:c.y})])},H=d=>{if(_optionalChain([o, 'access', _112 => _112.events, 'optionalAccess', _113 => _113.enableKeyboardControls]))switch(d.key.toLowerCase()){case"f":d.preventDefault(),h();break;case"escape":d.preventDefault(),p();break;case" ":d.preventDefault(),h();break}};return _optionalChain([o, 'access', _114 => _114.events, 'optionalAccess', _115 => _115.enableClickToFocus])&&(e.addEventListener("mousedown",x),e.addEventListener("click",f)),_optionalChain([o, 'access', _116 => _116.events, 'optionalAccess', _117 => _117.enableKeyboardControls])&&(e.setAttribute("tabindex","0"),e.addEventListener("keydown",H)),{dispose:()=>{e.removeEventListener("mousedown",x),e.removeEventListener("click",f),e.removeEventListener("keydown",H),p()},fitToView:h,clearSelection:p}}function se(e,r,t){let n=new (0, _OrbitControlsjs.OrbitControls)(e,r),o=t.camera.target;return o&&n.target.set(o.x,o.y,o.z),n.enableDamping=t.controls.enableDamping||!1,n.dampingFactor=t.controls.dampingFactor||.05,n.autoRotate=t.controls.autoRotate||!1,n.autoRotateSpeed=t.controls.autoRotateSpeed||.5,n.enableZoom=t.controls.enableZoom||!0,n.enablePan=t.controls.enablePan||!0,n.minDistance=t.controls.minDistance||.001,n.maxDistance=t.controls.maxDistance||1/0,n.screenSpacePanning=!1,n.maxPolarAngle=Math.PI,n.update(),n}function N(e,r,t,n,o){if(ie(e),r.length===0)return;let a=new R.Box3;r.forEach(h=>{e.add(h);let u=new R.Box3().setFromObject(h);a.union(u)});let s=a.getCenter(new R.Vector3),l=a.getSize(new R.Vector3),c=Math.max(l.x,l.y,l.z);if(c/Math.min(l.x||1,l.y||1,l.z||1)>100||c>1e4?(t.near=c*1e-4,t.far=c*100):c>1e3?(t.near=c*.001,t.far=c*50):(t.near=Math.max(.01,c*.01),t.far=Math.max(2e3,c*20)),t.updateProjectionMatrix(),o)n.minDistance=t.near*2,n.maxDistance=t.far*.9;else{let h=c*4;t.position.set(s.x+h*.8,s.y+h,s.z+h*1.2),n.target=s,n.minDistance=t.near*2,n.maxDistance=t.far*.9,n.update()}}function I(e){if(!e||typeof e!="string")return _chunkP57VU27Wcjs.j.call(void 0, ).warn(`Invalid color input: ${e}, using white`),new R.Color(16777215);let r=e.trim();if(r.startsWith("#")||/^[0-9A-Fa-f]{6}$/.test(r))try{let t=r.startsWith("#")?r:`#${r}`;return new R.Color(t)}catch (e2){return _chunkP57VU27Wcjs.j.call(void 0, ).warn(`Invalid hex color: ${e}, using white`),new R.Color(16777215)}if(r.includes(",")){let t=r.split(",").map(n=>parseInt(n.trim(),10));if(t.length===3&&t.every(n=>!isNaN(n)&&n>=0&&n<=255))return new R.Color(t[0]/255,t[1]/255,t[2]/255)}try{return new R.Color(r.toLowerCase())}catch (e3){return _chunkP57VU27Wcjs.j.call(void 0, ).warn(`Invalid color string: ${e}, using white`),new R.Color(16777215)}}function D(e,r){e.forEach(t=>{t.position.y-=r})}function A(e){let r=new R.Box3;return e.forEach(t=>{t.geometry.computeBoundingBox(),t.geometry.boundingBox&&r.union(t.geometry.boundingBox)}),r}function ie(e){let r=[];e.traverse(t=>{t instanceof R.Mesh&&t.userData.id!=="floor"&&r.push(t)}),r.forEach(t=>{t instanceof R.Mesh&&(_optionalChain([t, 'access', _118 => _118.geometry, 'optionalAccess', _119 => _119.dispose, 'call', _120 => _120()]),(Array.isArray(t.material)?t.material:[t.material]).forEach(o=>{Object.values(o).forEach(a=>{a instanceof R.Texture&&a.dispose()}),o.dispose()})),t.removeFromParent()})}var L={};_chunkP57VU27Wcjs.a.call(void 0, L,{CONCRETE_MATERIAL:()=>fe,EMISSIVE_MATERIAL:()=>ce,GLASS_MATERIAL:()=>he,METAL_MATERIAL:()=>le,PLASTIC_MATERIAL:()=>de,RUBBER_MATERIAL:()=>me,WOOD_MATERIAL:()=>ue});var ce=new m.MeshPhysicalMaterial({color:0,emissive:new m.Color(16777215),emissiveIntensity:5,metalness:0,roughness:.2,clearcoat:.3,clearcoatRoughness:.2,depthWrite:!0,depthTest:!0,transparent:!1,alphaTest:0,polygonOffset:!0,side:m.FrontSide,dithering:!0}),le=new m.MeshPhysicalMaterial({color:new m.Color(0),metalness:.9,roughness:.3,envMapIntensity:1.2,clearcoat:.3,clearcoatRoughness:.2,reflectivity:1,ior:2.5,thickness:1,depthWrite:!0,transparent:!1,alphaTest:0,depthTest:!0,polygonOffset:!0,side:m.FrontSide,dithering:!0}),fe=new m.MeshPhysicalMaterial({color:new m.Color(13421772),metalness:0,roughness:.92,envMapIntensity:.15,clearcoat:.05,clearcoatRoughness:.9,reflectivity:.15,transmission:0,ior:1.45,thickness:0,depthWrite:!0,transparent:!1,alphaTest:.5,depthTest:!0,polygonOffset:!0,side:m.FrontSide,dithering:!0}),de=new m.MeshPhysicalMaterial({color:new m.Color(16777215),metalness:0,roughness:.3,envMapIntensity:.5,clearcoat:.5,clearcoatRoughness:.1,reflectivity:.5,ior:1.4,transmission:0,transparent:!1,depthWrite:!0,side:m.FrontSide,dithering:!0,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}),he=new m.MeshPhysicalMaterial({color:new m.Color(16777215),metalness:0,roughness:0,transmission:.95,transparent:!0,opacity:.3,envMapIntensity:1,clearcoat:1,clearcoatRoughness:0,ior:1.52,reflectivity:.9,thickness:1,side:m.DoubleSide,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}),me=new m.MeshPhysicalMaterial({color:new m.Color(1710618),metalness:0,roughness:.9,envMapIntensity:.2,clearcoat:.1,clearcoatRoughness:.8,reflectivity:.2,ior:1.3,transmission:0,depthWrite:!0,side:m.FrontSide,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}),ue=new m.MeshPhysicalMaterial({color:new m.Color(8934707),metalness:0,roughness:.7,envMapIntensity:.3,clearcoat:.3,clearcoatRoughness:.4,reflectivity:.3,ior:1.3,transmission:0,depthWrite:!0,side:m.FrontSide,dithering:!0,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1});var _fflate = require('fflate'); var U = _interopRequireWildcard(_fflate);_chunkP57VU27Wcjs.i.call(void 0, );async function W(e){return new Promise((r,t)=>{try{let n=()=>{try{let o=_chunk5DJRUPGIcjs.c.call(void 0, e),a=U.gunzipSync(o),s=Ee(a);r(s)}catch(o){t(new (0, _chunkP57VU27Wcjs.d)(o instanceof _chunkP57VU27Wcjs.d?o.message:`Failed to decompress batched data: ${o instanceof Error?o.message:String(o)}`,o instanceof _chunkP57VU27Wcjs.d?o.code:_chunkP57VU27Wcjs.f.VALIDATION_ERROR,{context:{base64StringLength:e.length},originalError:o instanceof Error?o:new Error(String(o))}))}};"requestIdleCallback"in globalThis?globalThis.requestIdleCallback(n,{timeout:5e3}):setTimeout(n,0)}catch(n){t(new (0, _chunkP57VU27Wcjs.d)(`Failed to schedule decompression: ${n instanceof Error?n.message:String(n)}`,_chunkP57VU27Wcjs.f.VALIDATION_ERROR,{originalError:n instanceof Error?n:new Error(String(n))}))}})}function Ee(e){let r=new DataView(e.buffer,e.byteOffset,e.byteLength),t=0;if(t+4>r.byteLength)throw new (0, _chunkP57VU27Wcjs.d)("Insufficient data to read the number of vertex floats.",_chunkP57VU27Wcjs.f.VALIDATION_ERROR,{context:{expectedBytes:4,availableBytes:r.byteLength,offset:t}});let n=r.getUint32(t,!0);if(t+=4,n%3!==0)throw new (0, _chunkP57VU27Wcjs.d)("Invalid number of vertex floats; should be divisible by 3.",_chunkP57VU27Wcjs.f.VALIDATION_ERROR,{context:{numVertexFloats:n,remainder:n%3,totalBytes:r.byteLength}});let o=n*Float32Array.BYTES_PER_ELEMENT;if(t+o>r.byteLength)throw new (0, _chunkP57VU27Wcjs.d)("Insufficient data to read vertices.",_chunkP57VU27Wcjs.f.VALIDATION_ERROR,{context:{expectedBytes:o,availableBytes:r.byteLength-t,offset:t}});let a=new Float32Array(e.buffer,e.byteOffset+t,n);if(t+=o,t+4>r.byteLength)throw new (0, _chunkP57VU27Wcjs.d)("Insufficient data to read the number of face indices.",_chunkP57VU27Wcjs.f.VALIDATION_ERROR,{context:{expectedBytes:4,availableBytes:r.byteLength-t,offset:t}});let s=r.getUint32(t,!0);t+=4;let l=s*Uint32Array.BYTES_PER_ELEMENT;if(t+l>r.byteLength)throw new (0, _chunkP57VU27Wcjs.d)("Insufficient data to read face indices.",_chunkP57VU27Wcjs.f.VALIDATION_ERROR,{context:{expectedBytes:l,availableBytes:r.byteLength-t,offset:t}});let c=new Uint32Array(e.buffer,e.byteOffset+t,s);return{vertices:a,faces:c}}async function z(e,r){let{mergeByMaterial:t=!0,applyTransforms:n=!0,debug:o=!1}=_nullishCoalesce(r, () => ({})),a=o?performance.now():0,s=0;try{let l=performance.now(),c=JSON.parse(e);return s=performance.now()-l,await F(c,{mergeByMaterial:t,applyTransforms:n,debug:o,parseTime:s,perfStart:a})}catch(l){return _chunkP57VU27Wcjs.j.call(void 0, ).error("Error parsing mesh batch:",l),[]}}async function F(e,r){let{mergeByMaterial:t=!0,applyTransforms:n=!0,scaleFactor:o=1,debug:a=!1,parseTime:s=0,perfStart:l=a?performance.now():0}=_nullishCoalesce(r, () => ({})),c=0,T=0;try{let h=performance.now(),{vertices:u,faces:p}=await W(e.compressedData);c=performance.now()-h;let x=(e.compressedData.length*.75/1024/1024).toFixed(2),f=((u.byteLength+p.byteLength)/1024/1024).toFixed(2),H=((1-parseFloat(x)/parseFloat(f))*100).toFixed(1);a&&(_chunkP57VU27Wcjs.j.call(void 0, ).debug("Mesh Batch Stats:"),_chunkP57VU27Wcjs.j.call(void 0, ).debug(` Materials: ${e.materials.length} | Groups: ${e.groups.length}`),_chunkP57VU27Wcjs.j.call(void 0, ).debug(` Vertices: ${(u.length/3).toLocaleString()} | Faces: ${(p.length/3).toLocaleString()}`),_chunkP57VU27Wcjs.j.call(void 0, ).debug(` Compressed: ${x} MB | Uncompressed: ${f} MB`),_chunkP57VU27Wcjs.j.call(void 0, ).debug(` Compression Ratio: ${H}%`)),n&&Te(u);let O=performance.now(),d=e.materials.map(pe),b=[];for(let g of e.groups)if(t&&g.meshes.length>1){let v=ge(g,u,p,d);b.push(v)}else{let v=Re(g,u,p,d);b.push(...v)}if(o!==1)for(let g of b)g.scale.set(o,o,o);if(T=performance.now()-O,a){let g=performance.now()-l;_chunkP57VU27Wcjs.j.call(void 0, ).debug("Performance:"),s>0&&_chunkP57VU27Wcjs.j.call(void 0, ).debug(` Parse JSON: ${s.toFixed(2)}ms`),_chunkP57VU27Wcjs.j.call(void 0, ).debug(` Decompress: ${c.toFixed(2)}ms`),_chunkP57VU27Wcjs.j.call(void 0, ).debug(` Create Meshes: ${T.toFixed(2)}ms`),_chunkP57VU27Wcjs.j.call(void 0, ).debug(` Total: ${g.toFixed(2)}ms`)}return b}catch(h){return _chunkP57VU27Wcjs.j.call(void 0, ).error("Error parsing mesh batch object:",h),[]}}function pe(e){let r=I(e.color);return new w.MeshPhysicalMaterial({color:r,metalness:e.metalness,roughness:e.roughness,opacity:e.opacity,transparent:e.transparent,side:w.DoubleSide,polygonOffset:!0,polygonOffsetFactor:.5,polygonOffsetUnits:.5,depthWrite:!0,depthTest:!0})}function ge(e,r,t,n){let o=new w.BufferGeometry,a=0,s=0;for(let f of e.meshes)a+=f.vertexCount,s+=f.faceCount;let l=new Float32Array(a),c=new Uint32Array(s),T=0,h=0;for(let f of e.meshes){l.set(r.subarray(f.vertexOffset,f.vertexOffset+f.vertexCount),T);let H=t.subarray(f.faceOffset,f.faceOffset+f.faceCount),O=Math.floor(f.vertexOffset/3),b=Math.floor(T/3)-O;for(let g=0;g<H.length;g++)c[h+g]=H[g]+b;T+=f.vertexCount,h+=f.faceCount}o.setAttribute("position",new w.BufferAttribute(l,3)),o.setIndex(new w.BufferAttribute(c,1)),o.computeVertexNormals();let u=new w.Mesh(o,n[e.materialId]),p=e.meshes.map(f=>f.name).filter(f=>f&&f.length>0);u.name=p.length>0?p[0]:`merged_material_${e.materialId}`,u.castShadow=!0,u.receiveShadow=!0;let x=e.meshes.map(f=>f.metadata).filter(f=>f);return x.length>0&&(u.userData.mergedMetadata=x),u}function Re(e,r,t,n){let o=[];for(let a of e.meshes){let s=new w.BufferGeometry,l=r.subarray(a.vertexOffset,a.vertexOffset+a.vertexCount),c=t.subarray(a.faceOffset,a.faceOffset+a.faceCount),T=Math.floor(a.vertexOffset/3),h=new Uint32Array(c.length);for(let p=0;p<c.length;p++)h[p]=c[p]-T;s.setAttribute("position",new w.BufferAttribute(l,3)),s.setIndex(new w.BufferAttribute(h,1)),s.computeVertexNormals();let u=new w.Mesh(s,n[e.materialId]);u.name=a.name,a.metadata&&(u.userData={...u.userData,...a.metadata}),u.castShadow=!0,u.receiveShadow=!0,o.push(u)}return o}function Te(e){let r=Math.cos(-Math.PI/2),t=Math.sin(-Math.PI/2);for(let n=0;n<e.length;n+=3){let o=e[n],a=e[n+1],s=e[n+2];e[n]=o,e[n+1]=a*r-s*t,e[n+2]=a*t+s*r}}var P={Millimeters:1/1e3,Centimeters:1/100,Meters:1,Inches:1/39.37,Feet:1/3.28084},we="Display";async function G(e,r){let t=performance.now(),n=[],{allowScaling:o=!0,allowAutoPosition:a=!0,debug:s=!1,parsing:l={}}=_nullishCoalesce(r, () => ({}));try{let c=o?ye(e.modelunits):1;return await be(e,n,c,l,s),a&&xe(n),n}catch(c){throw He(c,n),c}finally{s&&Ce(t)}}function ye(e){return _nullishCoalesce(P[e], () => (1))}async function be(e,r,t,n,o){for(let a of e.values){let s=a.InnerTree;for(let l in s){let c=s[l];c&&await Me(c,r,t,n,o)}}}async function Me(e,r,t,n,o){for(let a of e)if(a.type.includes(we)){let s={mergeByMaterial:!0,applyTransforms:!0,debug:!1,...n},l=await z(a.data,s);if(t!==1)for(let c of l)c.scale.set(t,t,t);r.push(...l),o&&_chunkP57VU27Wcjs.j.call(void 0, ).debug(`Extracted ${l.length} meshes from batch`)}}function xe(e){if(e.length===0)return;let t=A(e).min.y;D(e,t)}function He(e,r){_chunkP57VU27Wcjs.j.call(void 0, ).error("An unexpected error occurred:",e),ve(r)}function ve(e){for(let r of e)r.geometry&&r.geometry.dispose(),r.material&&(Array.isArray(r.material)?r.material.forEach(t=>t.dispose()):r.material.dispose())}function Ce(e){let r=performance.now()-e;_chunkP57VU27Wcjs.j.call(void 0, ).info("Time to process meshes:",`${r.toFixed(2)}ms`)}exports.Materials = L; exports.SCALE_FACTORS = P; exports.getThreeMeshesFromComputeResponse = G; exports.initThree = _; exports.parseMeshBatchObject = F; exports.updateScene = N;
2
+ //# sourceMappingURL=visualization.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/felix/coding/selva-compute/dist/visualization.cjs","../src/features/visualization/threejs/three-initializer.ts","../src/features/visualization/threejs/three-helpers.ts"],"names":["defaultUp","initThree","canvas","options","config","applyDefaults","scene","createScene","camera","createCamera","renderer","setupRenderer","controls","setupControls","setupEnvironment","setupLighting","addFloor","eventHandlers","setupEventHandlers","resize","disposeResize","setupResponsiveResize","animate","disposeAnimation","createAnimationLoop","sceneUp","object","material","scale","defaults","child","bgColor","animationId","parent","resizeTimeout","resizeObserver","getSize","handleResize","width","height","RGBELoader","envMap","error","getLogger","ambientLight","sunlight","pos","shadowSize","shadowNear","shadowFar","floorSize","floorGeometry","floorColor","floorMaterial","floor","selectedObjects","originalMaterials","raycaster","mouse","mouseDownPosition","fitToView","box","center","size","maxDim","fov","distance","direction","selectionColorObj","clearSelection","obj","handleMouseDown","event","handleCanvasClick","currentMousePosition","rect","intersects","clickedObject","clonedMaterial","handleKeydown","OrbitControls","target","updateScene","meshes","initialPositionSet","clearScene","unionBoundingBox","mesh","boundingBox","parseColor","colorString","trimmed","hex"],"mappings":"AAAA,2/BAAwC,wDAAqE,kMCAtF,yEACO,kEACH,IAKrBA,CAAAA,CAAY,IAAU,CAAA,CAAA,OAAA,CAAQ,CAAA,CAAG,CAAA,CAAG,CAAC,CAAA,CAS9BC,CAAAA,qBAAY,QAAA,CACxBC,CAAAA,CACAC,CAAAA,CAUC,CACD,IAAMC,CAAAA,CAASC,CAAAA,CAAcF,CAAAA,EAAW,CAAC,CAAC,CAAA,CAGpCG,CAAAA,CAAQC,CAAAA,CAAYH,CAAM,CAAA,CAC1BI,CAAAA,CAASC,EAAAA,CAAaL,CAAM,CAAA,CAC5BM,CAAAA,CAAWC,EAAAA,CAAcT,CAAAA,CAAQE,CAAM,CAAA,CACvCQ,CAAAA,CAAWC,EAAAA,CAAcL,CAAAA,CAAQN,CAAAA,CAAQE,CAAM,CAAA,CAGrDU,EAAAA,CAAiBR,CAAAA,CAAOF,CAAM,CAAA,CAC9BW,EAAAA,CAAcT,CAAAA,CAAOF,CAAM,CAAA,iBAGvBA,CAAAA,qBAAO,KAAA,6BAAO,SAAA,EACjBY,EAAAA,CAASV,CAAAA,CAAOF,CA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cjs","sourcesContent":[null,"import * as THREE from 'three';\nimport { OrbitControls } from 'three/addons/controls/OrbitControls.js';\nimport { RGBELoader } from 'three/addons/loaders/RGBELoader.js';\n\nimport { getLogger } from '@/core';\nimport { ThreeInitializerOptions } from '../types';\n\nconst defaultUp = new THREE.Vector3(0, 0, 1);\n\n/**\n * Initializes a comprehensive Three.js environment with enhanced render quality and flexible configuration.\n *\n * @param canvas - The HTML canvas element to render the scene on.\n * @param options - Configuration options for the Three.js environment.\n * @returns An object containing the scene, camera, controls, renderer, and utility methods.\n */\nexport const initThree = function (\n\tcanvas: HTMLCanvasElement,\n\toptions?: ThreeInitializerOptions\n): {\n\tscene: THREE.Scene;\n\tcamera: THREE.PerspectiveCamera;\n\tcontrols: OrbitControls;\n\trenderer: THREE.WebGLRenderer;\n\tdispose: () => void;\n\tresize: () => void;\n\tfitToView: () => void;\n\tclearSelection: () => void;\n} {\n\tconst config = applyDefaults(options || {});\n\n\t// Initialize core components\n\tconst scene = createScene(config);\n\tconst camera = createCamera(config);\n\tconst renderer = setupRenderer(canvas, config);\n\tconst controls = setupControls(camera, canvas, config);\n\n\t// Setup environment and lighting\n\tsetupEnvironment(scene, config);\n\tsetupLighting(scene, config);\n\n\t// Add floor if enabled\n\tif (config.floor?.enabled) {\n\t\taddFloor(scene, config);\n\t}\n\n\tconst eventHandlers = config.events.enableEventHandlers !== false\n\t\t? setupEventHandlers(canvas, scene, camera, controls, config)\n\t\t: { dispose: () => { }, fitToView: () => { }, clearSelection: () => { } };\n\n\t// Handle resizing\n\tconst { resize, dispose: disposeResize } = setupResponsiveResize(canvas, renderer, camera);\n\n\t// Animation loop\n\tconst { animate, dispose: disposeAnimation } = createAnimationLoop(\n\t\trenderer,\n\t\tscene,\n\t\tcamera,\n\t\tcontrols\n\t);\n\tanimate();\n\n\t// Set scene up vector\n\tconst sceneUp = config.environment?.sceneUp || defaultUp;\n\tscene.up.set(sceneUp.x, sceneUp.y, sceneUp.z);\n\n\t// Comprehensive disposal\n\tconst dispose = () => {\n\t\tdisposeAnimation(); // Stop animation loop\n\t\tdisposeResize(); // Remove resize listeners\n\t\teventHandlers.dispose(); // Remove click/keyboard listeners\n\t\tcontrols.dispose(); // Dispose controls\n\t\trenderer.dispose(); // Dispose renderer\n\n\t\t// Dispose geometries and materials\n\t\tscene.traverse((object) => {\n\t\t\tif (object instanceof THREE.Mesh) {\n\t\t\t\tobject.geometry?.dispose();\n\t\t\t\tif (Array.isArray(object.material)) {\n\t\t\t\t\tobject.material.forEach((material) => material.dispose());\n\t\t\t\t} else {\n\t\t\t\t\tobject.material?.dispose();\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t};\n\n\treturn {\n\t\tscene,\n\t\tcamera,\n\t\tcontrols,\n\t\trenderer,\n\t\tdispose,\n\t\tresize,\n\t\tfitToView: eventHandlers.fitToView,\n\t\tclearSelection: eventHandlers.clearSelection\n\t};\n};\n\nfunction applyDefaults(options: ThreeInitializerOptions): Required<ThreeInitializerOptions> {\n\tconst scale = options.sceneScale || 'm';\n\n\t// Define sensible defaults for each scale\n\t// Note: All Rhino geometry is normalized to METERS (1 unit = 1 meter), sceneScale just changes the viewing perspective\n\tconst scaleDefaults = {\n\t\tmm: {\n\t\t\t// Geometry scaled UP by 1000x (mm to m conversion for better precision)\n\t\t\tcameraDistance: 20,\n\t\t\tnear: 0.1,\n\t\t\tfar: 2000,\n\t\t\tfloorSize: 100,\n\t\t\tlightDistance: 10,\n\t\t\tlightHeight: 20,\n\t\t\tminDistance: 0.1,\n\t\t\tshadowSize: 100,\n\t\t\tscaleFactor: 1000\n\t\t},\n\t\tcm: {\n\t\t\t// Geometry scaled UP by 100x (cm to m conversion)\n\t\t\tcameraDistance: 20,\n\t\t\tnear: 0.1,\n\t\t\tfar: 2000,\n\t\t\tfloorSize: 100,\n\t\t\tlightDistance: 25,\n\t\t\tlightHeight: 50,\n\t\t\tminDistance: 0.1,\n\t\t\tshadowSize: 100,\n\t\t\tscaleFactor: 100\n\t\t},\n\t\tm: {\n\t\t\t// Natural Three.js scale (1 unit = 1 meter)\n\t\t\tcameraDistance: 10,\n\t\t\tnear: 0.01,\n\t\t\tfar: 2000,\n\t\t\tfloorSize: 50,\n\t\t\tlightDistance: 25,\n\t\t\tlightHeight: 50,\n\t\t\tminDistance: 0.001,\n\t\t\tshadowSize: 100,\n\t\t\tscaleFactor: 1\n\t\t},\n\t\tinches: {\n\t\t\t// Geometry scaled UP by ~39.37x (inches to m conversion)\n\t\t\tcameraDistance: 15,\n\t\t\tnear: 0.1,\n\t\t\tfar: 2000,\n\t\t\tfloorSize: 80,\n\t\t\tlightDistance: 20,\n\t\t\tlightHeight: 40,\n\t\t\tminDistance: 0.1,\n\t\t\tshadowSize: 80,\n\t\t\tscaleFactor: 39.37\n\t\t},\n\t\tfeet: {\n\t\t\t// Geometry scaled UP by ~3.28x (feet to m conversion)\n\t\t\tcameraDistance: 8,\n\t\t\tnear: 0.1,\n\t\t\tfar: 2000,\n\t\t\tfloorSize: 40,\n\t\t\tlightDistance: 15,\n\t\t\tlightHeight: 30,\n\t\t\tminDistance: 0.1,\n\t\t\tshadowSize: 60,\n\t\t\tscaleFactor: 3.28084\n\t\t}\n\t};\n\n\tconst defaults = scaleDefaults[scale];\n\n\treturn {\n\t\tsceneScale: scale,\n\t\tcamera: {\n\t\t\tposition:\n\t\t\t\toptions.camera?.position ||\n\t\t\t\tnew THREE.Vector3(\n\t\t\t\t\t-defaults.cameraDistance,\n\t\t\t\t\tdefaults.cameraDistance,\n\t\t\t\t\tdefaults.cameraDistance\n\t\t\t\t),\n\t\t\tfov: options.camera?.fov || 20,\n\t\t\tnear: options.camera?.near || defaults.near,\n\t\t\tfar: options.camera?.far || defaults.far,\n\t\t\ttarget: options.camera?.target || new THREE.Vector3(0, 0, 0)\n\t\t},\n\t\tlighting: {\n\t\t\tenableSunlight: options.lighting?.enableSunlight ?? true,\n\t\t\tsunlightIntensity: options.lighting?.sunlightIntensity || 1,\n\t\t\tsunlightPosition:\n\t\t\t\toptions.lighting?.sunlightPosition ||\n\t\t\t\tnew THREE.Vector3(defaults.lightDistance, defaults.lightHeight, defaults.lightDistance),\n\t\t\tambientLightColor: options.lighting?.ambientLightColor || new THREE.Color(0x404040),\n\t\t\tambientLightIntensity: options.lighting?.ambientLightIntensity || 1,\n\t\t\tsunlightColor: options.lighting?.sunlightColor || 0xffffff // Default to white sunlight\n\t\t},\n\t\tenvironment: {\n\t\t\thdrPath: options.environment?.hdrPath || '/baseHDR.hdr',\n\t\t\tbackgroundColor: options.environment?.backgroundColor || new THREE.Color(0xf0f0f0),\n\t\t\tenableEnvironmentLighting: options.environment?.enableEnvironmentLighting ?? true,\n\t\t\tsceneUp: options.environment?.sceneUp || defaultUp,\n\t\t\tshowEnvironment: options.environment?.showEnvironment ?? false\n\t\t},\n\t\tfloor: {\n\t\t\tenabled: options.floor?.enabled ?? false,\n\t\t\tsize: options.floor?.size || defaults.floorSize,\n\t\t\tcolor: options.floor?.color || new THREE.Color(0x808080),\n\t\t\troughness: options.floor?.roughness || 0.7,\n\t\t\tmetalness: options.floor?.metalness || 0.0,\n\t\t\treceiveShadow: options.floor?.receiveShadow ?? true\n\t\t},\n\t\trender: {\n\t\t\tenableShadows: options.render?.enableShadows ?? true,\n\t\t\tshadowMapSize: options.render?.shadowMapSize || 2048,\n\t\t\tantialias: options.render?.antialias ?? true,\n\t\t\tpixelRatio: options.render?.pixelRatio || Math.min(window.devicePixelRatio, 2),\n\t\t\ttoneMapping: options.render?.toneMapping || THREE.NeutralToneMapping,\n\t\t\ttoneMappingExposure: options.render?.toneMappingExposure || 1,\n\t\t\tpreserveDrawingBuffer: options.render?.preserveDrawingBuffer ?? false\n\t\t},\n\t\tcontrols: {\n\t\t\tenableDamping: options.controls?.enableDamping ?? false,\n\t\t\tdampingFactor: options.controls?.dampingFactor || 0.05,\n\t\t\tautoRotate: options.controls?.autoRotate ?? false,\n\t\t\tautoRotateSpeed: options.controls?.autoRotateSpeed || 0.5,\n\t\t\tenableZoom: options.controls?.enableZoom ?? true,\n\t\t\tenablePan: options.controls?.enablePan ?? true,\n\t\t\tminDistance: options.controls?.minDistance || defaults.minDistance,\n\t\t\tmaxDistance: options.controls?.maxDistance || Infinity\n\t\t},\n\t\tevents: {\n\t\t\tonBackgroundClicked: options.events?.onBackgroundClicked,\n\t\t\tonObjectSelected: options.events?.onObjectSelected,\n\t\t\tonMeshMetadataClicked: options.events?.onMeshMetadataClicked,\n\t\t\tselectionColor: options.events?.selectionColor || '#ff0000', // Default to red\n\t\t\tenableEventHandlers: options.events?.enableEventHandlers ?? true,\n\t\t\tenableKeyboardControls: options.events?.enableKeyboardControls ?? true,\n\t\t\tenableClickToFocus: options.events?.enableClickToFocus ?? true\n\t\t}\n\t};\n}\n\n/**\n * Creates and configures the scene.\n */\nfunction createScene(config: Required<ThreeInitializerOptions>): THREE.Scene {\n\tconst scene = new THREE.Scene();\n\n\t// Clear existing children except floor\n\tscene.children.forEach((child) => {\n\t\tif (child.userData.id !== 'floor') {\n\t\t\tscene.remove(child);\n\t\t}\n\t});\n\n\t// Set background color\n\tconst bgColor =\n\t\ttypeof config.environment.backgroundColor === 'string'\n\t\t\t? new THREE.Color(config.environment.backgroundColor)\n\t\t\t: config.environment.backgroundColor;\n\tscene.background = bgColor || null;\n\n\treturn scene;\n}\n\n/**\n * Creates an optimized animation loop with proper disposal.\n */\nfunction createAnimationLoop(\n\trenderer: THREE.WebGLRenderer,\n\tscene: THREE.Scene,\n\tcamera: THREE.PerspectiveCamera,\n\tcontrols: OrbitControls\n): { animate: () => void; dispose: () => void } {\n\tlet animationId: number | null = null;\n\n\tconst animate = function () {\n\t\tanimationId = requestAnimationFrame(animate);\n\n\t\t// Update controls if damping is enabled\n\t\tif (controls.enableDamping) {\n\t\t\tcontrols.update();\n\t\t}\n\n\t\trenderer.render(scene, camera);\n\t};\n\n\tconst dispose = () => {\n\t\tif (animationId !== null) {\n\t\t\tcancelAnimationFrame(animationId);\n\t\t\tanimationId = null;\n\t\t}\n\t};\n\n\treturn { animate, dispose };\n}\n\n/**\n * Sets up responsive resizing with improved performance and proper parent handling.\n */\nfunction setupResponsiveResize(\n\tcanvas: HTMLCanvasElement,\n\trenderer: THREE.WebGLRenderer,\n\tcamera: THREE.PerspectiveCamera\n): { resize: () => void; dispose: () => void } {\n\tconst parent = canvas.parentElement;\n\tlet resizeTimeout: NodeJS.Timeout;\n\tlet resizeObserver: ResizeObserver | null = null;\n\n\tconst getSize = () => {\n\t\tif (parent) {\n\t\t\treturn {\n\t\t\t\twidth: parent.clientWidth,\n\t\t\t\theight: parent.clientHeight\n\t\t\t};\n\t\t} else {\n\t\t\treturn {\n\t\t\t\twidth: window.innerWidth,\n\t\t\t\theight: window.innerHeight\n\t\t\t};\n\t\t}\n\t};\n\n\tconst handleResize = () => {\n\t\tif (resizeTimeout) {\n\t\t\tclearTimeout(resizeTimeout);\n\t\t}\n\n\t\tresizeTimeout = setTimeout(() => {\n\t\t\tconst { width, height } = getSize();\n\n\t\t\t// Only update if size actually changed\n\t\t\tif (renderer.domElement.width !== width || renderer.domElement.height !== height) {\n\t\t\t\trenderer.setSize(width, height, false);\n\t\t\t\tcamera.aspect = width / height;\n\t\t\t\tcamera.updateProjectionMatrix();\n\t\t\t}\n\t\t}, 16); // ~60fps throttling\n\t};\n\n\t// Set up the appropriate resize observer\n\tif (parent && typeof ResizeObserver !== 'undefined') {\n\t\t// Use ResizeObserver for parent container\n\t\tresizeObserver = new ResizeObserver(handleResize);\n\t\tresizeObserver.observe(parent);\n\t} else {\n\t\t// Fallback to window resize for fullscreen or older browsers\n\t\twindow.addEventListener('resize', handleResize);\n\t}\n\n\tconst dispose = () => {\n\t\tif (resizeTimeout) {\n\t\t\tclearTimeout(resizeTimeout);\n\t\t}\n\t\tif (resizeObserver) {\n\t\t\tresizeObserver.disconnect();\n\t\t} else {\n\t\t\twindow.removeEventListener('resize', handleResize);\n\t\t}\n\t};\n\n\treturn { resize: handleResize, dispose };\n}\n\n/**\n * Sets up environment lighting and HDR.\n */\nfunction setupEnvironment(scene: THREE.Scene, config: Required<ThreeInitializerOptions>) {\n\tif (config.environment.enableEnvironmentLighting) {\n\t\tnew RGBELoader().load(\n\t\t\tconfig.environment.hdrPath || '/baseHDR.hdr',\n\t\t\tfunction (envMap) {\n\t\t\t\tenvMap.mapping = THREE.EquirectangularReflectionMapping;\n\t\t\t\tscene.environment = envMap;\n\t\t\t\tif (config.environment.showEnvironment) {\n\t\t\t\t\tscene.background = envMap;\n\t\t\t\t}\n\t\t\t},\n\t\t\tundefined,\n\t\t\tfunction (error) {\n\t\t\t\tgetLogger().warn('HDR texture could not be loaded, falling back to basic lighting:', error);\n\t\t\t\t// Add basic ambient light as fallback\n\t\t\t\tconst ambientLight = new THREE.AmbientLight(0x404040, 0.4);\n\t\t\t\tscene.add(ambientLight);\n\t\t\t}\n\t\t);\n\t}\n}\n\nfunction setupLighting(scene: THREE.Scene, config: Required<ThreeInitializerOptions>) {\n\t// Add ambient light\n\tconst ambientLight = new THREE.AmbientLight(\n\t\tconfig.lighting.ambientLightColor,\n\t\tconfig.lighting.ambientLightIntensity\n\t);\n\tscene.add(ambientLight);\n\n\t// Add directional light (sunlight)\n\tif (config.lighting.enableSunlight) {\n\t\tconst sunlight = new THREE.DirectionalLight(\n\t\t\tconfig.lighting.sunlightColor ?? 0xffffff,\n\t\t\tconfig.lighting.sunlightIntensity\n\t\t);\n\t\tconst pos = config.lighting.sunlightPosition;\n\t\tif (pos) {\n\t\t\tsunlight.position.set(pos.x, pos.y, pos.z);\n\t\t}\n\n\t\tif (config.render.enableShadows) {\n\t\t\tsunlight.castShadow = true;\n\t\t\tconst shadowSize = config.sceneScale === 'mm' ? 0.1 : config.sceneScale === 'cm' ? 10 : 100;\n\n\t\t\tsunlight.shadow.camera.left = -shadowSize;\n\t\t\tsunlight.shadow.camera.right = shadowSize;\n\t\t\tsunlight.shadow.camera.top = shadowSize;\n\t\t\tsunlight.shadow.camera.bottom = -shadowSize;\n\n\t\t\tconst shadowNear =\n\t\t\t\tconfig.sceneScale === 'mm' ? 0.001 : config.sceneScale === 'cm' ? 0.1 : 0.5;\n\n\t\t\tconst shadowFar = config.sceneScale === 'mm' ? 1 : config.sceneScale === 'cm' ? 100 : 500;\n\n\t\t\tsunlight.shadow.camera.near = shadowNear;\n\t\t\tsunlight.shadow.camera.far = shadowFar;\n\n\t\t\tsunlight.shadow.mapSize.width = config.render.shadowMapSize || 2048;\n\t\t\tsunlight.shadow.mapSize.height = config.render.shadowMapSize || 2048;\n\n\t\t\t// Improved shadow quality\n\t\t\tsunlight.shadow.bias = -0.0001;\n\t\t\tsunlight.shadow.normalBias = 0.02;\n\t\t}\n\n\t\tscene.add(sunlight);\n\t}\n}\n\n/**\n * Adds a floor to the scene with scale-aware sizing.\n */\nfunction addFloor(scene: THREE.Scene, config: Required<ThreeInitializerOptions>) {\n\tconst floorSize = config.floor.size;\n\tconst floorGeometry = new THREE.PlaneGeometry(floorSize, floorSize);\n\n\tconst floorColor =\n\t\ttypeof config.floor.color === 'string'\n\t\t\t? new THREE.Color(config.floor.color)\n\t\t\t: config.floor.color;\n\n\tconst floorMaterial = new THREE.MeshStandardMaterial({\n\t\tcolor: floorColor,\n\t\troughness: config.floor.roughness,\n\t\tmetalness: config.floor.metalness,\n\t\tside: THREE.DoubleSide\n\t});\n\n\tconst floor = new THREE.Mesh(floorGeometry, floorMaterial);\n\tfloor.userData.id = 'floor';\n\tfloor.name = 'floor';\n\tfloor.rotation.x = -Math.PI / 2;\n\tfloor.position.y = 0;\n\n\tif (config.floor.receiveShadow && config.render.enableShadows) {\n\t\tfloor.receiveShadow = true;\n\t}\n\n\tscene.add(floor);\n}\n\n/**\n * Creates and configures the camera with proper aspect ratio.\n */\nfunction createCamera(config: Required<ThreeInitializerOptions>): THREE.PerspectiveCamera {\n\t// Get proper aspect ratio from canvas parent or window\n\tconst canvas = document.querySelector('canvas');\n\tconst parent = canvas?.parentElement;\n\tconst width = parent ? parent.clientWidth : window.innerWidth;\n\tconst height = parent ? parent.clientHeight : window.innerHeight;\n\n\tconst camera = new THREE.PerspectiveCamera(\n\t\tconfig.camera.fov,\n\t\twidth / height,\n\t\tconfig.camera.near,\n\t\tconfig.camera.far\n\t);\n\n\tconst pos = config.camera.position;\n\tif (pos) {\n\t\tcamera.position.set(pos.x, pos.y, pos.z);\n\t}\n\n\treturn camera;\n}\n\n/**\n * Sets up enhanced WebGL renderer with improved quality settings.\n */\nfunction setupRenderer(\n\tcanvas: HTMLCanvasElement,\n\tconfig: Required<ThreeInitializerOptions>\n): THREE.WebGLRenderer {\n\tconst renderer = new THREE.WebGLRenderer({\n\t\tantialias: config.render.antialias,\n\t\tcanvas,\n\t\talpha: true,\n\t\tpowerPreference: 'high-performance',\n\t\tpreserveDrawingBuffer: config.render.preserveDrawingBuffer,\n\t\t// Enable logarithmic depth buffer for extreme scale ranges\n\t\t// This dramatically improves depth precision for mixed scales (mm to km)\n\t\tlogarithmicDepthBuffer: true\n\t});\n\n\t// Get proper dimensions - parent container or window\n\tconst parent = canvas.parentElement;\n\tconst width = parent ? parent.clientWidth : window.innerWidth;\n\tconst height = parent ? parent.clientHeight : window.innerHeight;\n\n\t// Set canvas style to fill parent if it exists\n\tif (parent) {\n\t\tcanvas.style.width = '100%';\n\t\tcanvas.style.height = '100%';\n\t\tcanvas.style.display = 'block';\n\t}\n\n\trenderer.setSize(width, height, false);\n\trenderer.setPixelRatio(config.render.pixelRatio || Math.min(window.devicePixelRatio, 2));\n\n\t// Enhanced shadow settings\n\tif (config.render.enableShadows) {\n\t\trenderer.shadowMap.enabled = true;\n\t\t// Use VSM for better quality with extreme scales\n\t\trenderer.shadowMap.type = THREE.VSMShadowMap;\n\t}\n\n\t// Improved tone mapping and color management\n\trenderer.toneMapping = config.render.toneMapping || THREE.ACESFilmicToneMapping;\n\trenderer.toneMappingExposure = config.render.toneMappingExposure || 1.0;\n\trenderer.outputColorSpace = THREE.SRGBColorSpace;\n\n\t// Additional quality settings for depth rendering\n\trenderer.sortObjects = true; // Ensure proper render order\n\n\treturn renderer;\n}\n\n// Add event handler setup function\nfunction setupEventHandlers(\n\tcanvas: HTMLCanvasElement,\n\tscene: THREE.Scene,\n\tcamera: THREE.PerspectiveCamera,\n\tcontrols: OrbitControls,\n\tconfig: Required<ThreeInitializerOptions>\n): {\n\tdispose: () => void;\n\tfitToView: () => void;\n\tclearSelection: () => void;\n} {\n\tconst selectedObjects = new Set<THREE.Object3D>();\n\tconst originalMaterials = new Map<THREE.Object3D, THREE.Material | THREE.Material[]>();\n\tconst raycaster = new THREE.Raycaster();\n\tconst mouse = new THREE.Vector2();\n\tconst mouseDownPosition = new THREE.Vector2();\n\n\t// Fit scene to view\n\tconst fitToView = () => {\n\t\tconst box = new THREE.Box3();\n\n\t\t// Calculate bounding box of all visible objects (excluding floor)\n\t\tscene.traverse((object) => {\n\t\t\tif (object.visible && object.userData.id !== 'floor' && object instanceof THREE.Mesh) {\n\t\t\t\tbox.expandByObject(object);\n\t\t\t}\n\t\t});\n\n\t\tif (box.isEmpty()) {\n\t\t\tgetLogger().warn('No objects to fit to view');\n\t\t\treturn;\n\t\t}\n\n\t\tconst center = box.getCenter(new THREE.Vector3());\n\t\tconst size = box.getSize(new THREE.Vector3());\n\n\t\t// Calculate distance needed to fit the object\n\t\tconst maxDim = Math.max(size.x, size.y, size.z);\n\t\tconst fov = camera.fov * (Math.PI / 180);\n\t\tlet distance = maxDim / (2 * Math.tan(fov / 2));\n\n\t\t// Add some padding\n\t\tdistance *= 1.5;\n\n\t\t// Position camera\n\t\tconst direction = camera.position.clone().sub(controls.target).normalize();\n\t\tcamera.position.copy(center.clone().add(direction.multiplyScalar(distance)));\n\n\t\t// Update controls target\n\t\tcontrols.target.copy(center);\n\t\tcontrols.update();\n\t};\n\n\t// Parse selection color\n\tconst selectionColorObj = typeof config.events.selectionColor === 'string'\n\t\t? new THREE.Color(config.events.selectionColor)\n\t\t: config.events.selectionColor instanceof THREE.Color\n\t\t\t? config.events.selectionColor\n\t\t\t: new THREE.Color('#ff0000');\n\n\t// Clear selection\n\tconst clearSelection = () => {\n\t\tselectedObjects.forEach((obj) => {\n\t\t\t// Restore original material\n\t\t\tif (obj instanceof THREE.Mesh && originalMaterials.has(obj)) {\n\t\t\t\tobj.material = originalMaterials.get(obj)!;\n\t\t\t\toriginalMaterials.delete(obj);\n\t\t\t}\n\t\t});\n\t\tselectedObjects.clear();\n\t};\n\n\tconst handleMouseDown = (event: MouseEvent) => {\n\t\tmouseDownPosition.set(event.clientX, event.clientY);\n\t};\n\n\t// Handle canvas clicks\n\tconst handleCanvasClick = (event: MouseEvent) => {\n\t\t// Ignore if mouse has moved significantly (drag)\n\t\tconst currentMousePosition = new THREE.Vector2(event.clientX, event.clientY);\n\t\tif (mouseDownPosition.distanceTo(currentMousePosition) > 5) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Calculate mouse position in normalized device coordinates\n\t\tconst rect = canvas.getBoundingClientRect();\n\t\tmouse.x = ((event.clientX - rect.left) / rect.width) * 2 - 1;\n\t\tmouse.y = -((event.clientY - rect.top) / rect.height) * 2 + 1;\n\n\t\t// Raycast to find intersected objects\n\t\traycaster.setFromCamera(mouse, camera);\n\t\tconst intersects = raycaster.intersectObjects(scene.children, true);\n\n\t\tif (intersects.length > 0) {\n\t\t\tconst clickedObject = intersects[0].object;\n\n\t\t\t// Handle object selection\n\t\t\tif (!selectedObjects.has(clickedObject)) {\n\t\t\t\tclearSelection();\n\t\t\t\tselectedObjects.add(clickedObject);\n\n\t\t\t\t// Clone material and apply selection color only to this mesh\n\t\t\t\tif (clickedObject instanceof THREE.Mesh && clickedObject.material instanceof THREE.Material) {\n\t\t\t\t\t// Store original material\n\t\t\t\t\toriginalMaterials.set(clickedObject, clickedObject.material);\n\n\t\t\t\t\t// Clone the material so we don't affect other meshes\n\t\t\t\t\tconst clonedMaterial = clickedObject.material.clone();\n\t\t\t\t\t(clonedMaterial as any).emissive = selectionColorObj.clone();\n\t\t\t\t\tclickedObject.material = clonedMaterial;\n\t\t\t\t}\n\n\t\t\t\tconfig.events?.onObjectSelected?.(clickedObject);\n\n\t\t\t\t// Call metadata callback if the mesh has metadata\n\t\t\t\tif (clickedObject instanceof THREE.Mesh && Object.keys(clickedObject.userData).length > 0) {\n\t\t\t\t\tconfig.events?.onMeshMetadataClicked?.(clickedObject.userData);\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\t// Background clicked\n\t\t\tclearSelection();\n\t\t\tconfig.events?.onBackgroundClicked?.({ x: mouse.x, y: mouse.y });\n\t\t}\n\t};\n\n\t// Handle keyboard events\n\tconst handleKeydown = (event: KeyboardEvent) => {\n\t\tif (!config.events?.enableKeyboardControls) return;\n\n\t\tswitch (event.key.toLowerCase()) {\n\t\t\tcase 'f':\n\t\t\t\tevent.preventDefault();\n\t\t\t\tfitToView();\n\t\t\t\tbreak;\n\t\t\tcase 'escape':\n\t\t\t\tevent.preventDefault();\n\t\t\t\tclearSelection();\n\t\t\t\tbreak;\n\t\t\tcase ' ':\n\t\t\t\tevent.preventDefault();\n\t\t\t\tfitToView();\n\t\t\t\tbreak;\n\t\t}\n\t};\n\n\t// Add event listeners\n\tif (config.events?.enableClickToFocus) {\n\t\tcanvas.addEventListener('mousedown', handleMouseDown);\n\t\tcanvas.addEventListener('click', handleCanvasClick);\n\t}\n\n\tif (config.events?.enableKeyboardControls) {\n\t\t// Make canvas focusable\n\t\tcanvas.setAttribute('tabindex', '0');\n\t\t// Only listen for keydown when canvas has focus\n\t\tcanvas.addEventListener('keydown', handleKeydown);\n\t}\n\n\t// Disposal function\n\tconst dispose = () => {\n\t\tcanvas.removeEventListener('mousedown', handleMouseDown);\n\t\tcanvas.removeEventListener('click', handleCanvasClick);\n\t\tcanvas.removeEventListener('keydown', handleKeydown);\n\t\tclearSelection();\n\t};\n\n\treturn { dispose, fitToView, clearSelection };\n}\n\n/**\n * Sets up enhanced orbit controls with scale-aware distances.\n */\nfunction setupControls(\n\tcamera: THREE.PerspectiveCamera,\n\tcanvas: HTMLCanvasElement,\n\tconfig: Required<ThreeInitializerOptions>\n): OrbitControls {\n\tconst controls = new OrbitControls(camera, canvas);\n\n\t// Set target\n\tconst target = config.camera.target;\n\tif (target) {\n\t\tcontrols.target.set(target.x, target.y, target.z);\n\t}\n\n\t// Configure damping\n\tcontrols.enableDamping = config.controls.enableDamping || false;\n\tcontrols.dampingFactor = config.controls.dampingFactor || 0.05;\n\n\t// Configure auto rotation\n\tcontrols.autoRotate = config.controls.autoRotate || false;\n\tcontrols.autoRotateSpeed = config.controls.autoRotateSpeed || 0.5;\n\n\t// Configure interaction limits\n\tcontrols.enableZoom = config.controls.enableZoom || true;\n\tcontrols.enablePan = config.controls.enablePan || true;\n\tcontrols.minDistance = config.controls.minDistance || 0.001;\n\tcontrols.maxDistance = config.controls.maxDistance || Infinity;\n\n\t// Smooth controls\n\tcontrols.screenSpacePanning = false;\n\tcontrols.maxPolarAngle = Math.PI;\n\n\tcontrols.update();\n\treturn controls;\n}\n","import * as THREE from 'three';\nimport { OrbitControls } from 'three/addons/controls/OrbitControls.js';\nimport { getLogger } from '@/core';\n\n/**\n * Updates the scene with the given meshes and camera settings.\n * If initialPositionSet is false, it positions the camera and sets the controls target based on the bounding boxes of the meshes.\n * @param scene - The THREE.Scene object to update.\n * @param meshes - An array of THREE.Mesh objects to add to the scene.\n * @param camera - The THREE.PerspectiveCamera object to position.\n * @param controls - The OrbitControls object to update.\n * @param initialPositionSet - A boolean indicating whether the initial position of the camera and controls have been set.\n */\nexport function updateScene(\n\tscene: THREE.Scene,\n\tmeshes: THREE.Mesh[],\n\tcamera: THREE.PerspectiveCamera,\n\tcontrols: OrbitControls,\n\tinitialPositionSet: boolean\n) {\n\tclearScene(scene);\n\n\tif (meshes.length === 0) return;\n\n\tconst unionBoundingBox = new THREE.Box3();\n\n\tmeshes.forEach((mesh) => {\n\t\tscene.add(mesh);\n\t\tconst boundingBox = new THREE.Box3().setFromObject(mesh);\n\t\tunionBoundingBox.union(boundingBox);\n\t});\n\n\t// Get the center of the union bounding box\n\tconst center = unionBoundingBox.getCenter(new THREE.Vector3());\n\tconst size = unionBoundingBox.getSize(new THREE.Vector3());\n\n\t// Calculate a distance that is slightly larger than the largest dimension of the union bounding box\n\tconst maxDim = Math.max(size.x, size.y, size.z);\n\n\t// Always update camera frustum to ensure geometry is visible\n\t// This prevents clipping when geometry size changes significantly\n\tconst scaleRatio = maxDim / Math.min(size.x || 1, size.y || 1, size.z || 1);\n\n\tif (scaleRatio > 100 || maxDim > 10000) {\n\t\t// Large scale range detected - use logarithmic depth buffer approach\n\t\tcamera.near = maxDim * 0.0001; // 0.01% of max dimension\n\t\tcamera.far = maxDim * 100; // 100x max dimension\n\t} else if (maxDim > 1000) {\n\t\t// Large scene\n\t\tcamera.near = maxDim * 0.001;\n\t\tcamera.far = maxDim * 50;\n\t} else {\n\t\t// Normal scene\n\t\tcamera.near = Math.max(0.01, maxDim * 0.01);\n\t\tcamera.far = Math.max(2000, maxDim * 20);\n\t}\n\n\tcamera.updateProjectionMatrix();\n\n\t// Only reposition camera and controls on first frame\n\tif (!initialPositionSet) {\n\t\tconst distance = maxDim * 4;\n\n\t\tcamera.position.set(center.x + distance * 0.8, center.y + distance, center.z + distance * 1.2);\n\t\tcontrols.target = center;\n\t\tcontrols.minDistance = camera.near * 2;\n\t\tcontrols.maxDistance = camera.far * 0.9;\n\n\t\tcontrols.update();\n\t} else {\n\t\t// Update control constraints to match new frustum\n\t\tcontrols.minDistance = camera.near * 2;\n\t\tcontrols.maxDistance = camera.far * 0.9;\n\t}\n}\n\n// =========================\n// Helper functions\n// =========================\n\n/**\n * Parses a color string in multiple formats to a THREE.Color object.\n * Supported formats:\n * - Hex: \"#C7A5A5\", \"C7A5A5\"\n * - RGB: \"199, 165, 165\"\n * - CSS named colors: \"red\", \"blue\", etc.\n * @param colorString - The color string to parse.\n * @returns A THREE.Color object.\n */\nexport function parseColor(colorString: string): THREE.Color {\n\tif (!colorString || typeof colorString !== 'string') {\n\t\tgetLogger().warn(`Invalid color input: ${colorString}, using white`);\n\t\treturn new THREE.Color(0xffffff);\n\t}\n\n\tconst trimmed = colorString.trim();\n\n\t// Try hex format (#C7A5A5 or C7A5A5)\n\tif (trimmed.startsWith('#') || /^[0-9A-Fa-f]{6}$/.test(trimmed)) {\n\t\ttry {\n\t\t\tconst hex = trimmed.startsWith('#') ? trimmed : `#${trimmed}`;\n\t\t\treturn new THREE.Color(hex);\n\t\t} catch {\n\t\t\tgetLogger().warn(`Invalid hex color: ${colorString}, using white`);\n\t\t\treturn new THREE.Color(0xffffff);\n\t\t}\n\t}\n\n\t// Try RGB format (R, G, B)\n\tif (trimmed.includes(',')) {\n\t\tconst rgb = trimmed.split(',').map((c) => parseInt(c.trim(), 10));\n\t\tif (rgb.length === 3 && rgb.every((n) => !isNaN(n) && n >= 0 && n <= 255)) {\n\t\t\treturn new THREE.Color(rgb[0] / 255, rgb[1] / 255, rgb[2] / 255);\n\t\t}\n\t}\n\n\t// Try CSS named color\n\ttry {\n\t\treturn new THREE.Color(trimmed.toLowerCase());\n\t} catch {\n\t\tgetLogger().warn(`Invalid color string: ${colorString}, using white`);\n\t\treturn new THREE.Color(0xffffff);\n\t}\n}\n\nexport function applyOffset(meshes: THREE.Mesh[], offsetY: number): void {\n\tmeshes.forEach((mesh) => {\n\t\tmesh.position.y -= offsetY;\n\t});\n}\n\nexport function computeCombinedBoundingBox(meshes: THREE.Mesh[]): THREE.Box3 {\n\tconst combinedBoundingBox = new THREE.Box3();\n\tmeshes.forEach((mesh) => {\n\t\tmesh.geometry.computeBoundingBox();\n\t\tif (mesh.geometry.boundingBox) {\n\t\t\tcombinedBoundingBox.union(mesh.geometry.boundingBox);\n\t\t}\n\t});\n\treturn combinedBoundingBox;\n}\n\n/**\n * Updates shadow camera bounds to match scene geometry.\n * This prevents shadow artifacts and ensures proper shadow coverage.\n */\nexport function updateShadowCameraBounds(\n\tscene: THREE.Scene,\n\tdirectionalLight: THREE.DirectionalLight\n): void {\n\tconst bbox = new THREE.Box3();\n\n\tscene.traverse((object) => {\n\t\tif (object instanceof THREE.Mesh && object.userData.id !== 'floor') {\n\t\t\tbbox.expandByObject(object);\n\t\t}\n\t});\n\n\tif (bbox.isEmpty()) return;\n\n\tconst size = bbox.getSize(new THREE.Vector3());\n\tconst center = bbox.getCenter(new THREE.Vector3());\n\tconst maxDim = Math.max(size.x, size.y, size.z);\n\n\t// Position light relative to scene center\n\tconst lightDistance = maxDim * 2;\n\tdirectionalLight.position.set(\n\t\tcenter.x + lightDistance * 0.5,\n\t\tcenter.y + lightDistance,\n\t\tcenter.z + lightDistance * 0.5\n\t);\n\tdirectionalLight.target.position.copy(center);\n\n\t// Adjust shadow camera bounds to scene size with padding\n\tconst padding = maxDim * 0.2;\n\tdirectionalLight.shadow.camera.left = -maxDim / 2 - padding;\n\tdirectionalLight.shadow.camera.right = maxDim / 2 + padding;\n\tdirectionalLight.shadow.camera.top = maxDim / 2 + padding;\n\tdirectionalLight.shadow.camera.bottom = -maxDim / 2 - padding;\n\tdirectionalLight.shadow.camera.near = 0.1;\n\tdirectionalLight.shadow.camera.far = lightDistance * 3;\n\n\t// Improve shadow quality for extreme scales\n\tif (maxDim > 1000) {\n\t\tdirectionalLight.shadow.bias = -0.001;\n\t\tdirectionalLight.shadow.normalBias = 0.05;\n\t} else {\n\t\tdirectionalLight.shadow.bias = -0.0001;\n\t\tdirectionalLight.shadow.normalBias = 0.02;\n\t}\n\n\tdirectionalLight.shadow.camera.updateProjectionMatrix();\n}\n\n/**\n * Clears the given THREE.Scene by removing all meshes and disposing of associated resources.\n * @param scene - The THREE.Scene to clear.\n */\nfunction clearScene(scene: THREE.Scene): void {\n\tconst objectsToRemove: THREE.Object3D[] = [];\n\n\t// Collect all meshes except the floor\n\tscene.traverse((child: THREE.Object3D) => {\n\t\tif (child instanceof THREE.Mesh && child.userData.id !== 'floor') {\n\t\t\tobjectsToRemove.push(child);\n\t\t}\n\t});\n\n\t// Remove and dispose of each object\n\tobjectsToRemove.forEach((object: THREE.Object3D) => {\n\t\tif (object instanceof THREE.Mesh) {\n\t\t\tobject.geometry?.dispose();\n\n\t\t\tconst materials = Array.isArray(object.material) ? object.material : [object.material];\n\t\t\tmaterials.forEach((material) => {\n\t\t\t\tObject.values(material).forEach((value) => {\n\t\t\t\t\tif (value instanceof THREE.Texture) {\n\t\t\t\t\t\tvalue.dispose();\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\tmaterial.dispose();\n\t\t\t});\n\t\t}\n\n\t\tobject.removeFromParent();\n\t});\n}\n"]}
@@ -0,0 +1,202 @@
1
+ import * as THREE from 'three';
2
+ import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
3
+ import { b as GrasshopperComputeResponse } from './schemas-5LuPKgX2.cjs';
4
+ import { M as MeshExtractionOptions, a as MeshBatch } from './types-r00wVwfo.cjs';
5
+ export { D as DecompressedMeshData, d as MaterialGroup, b as MeshBatchParsingOptions, c as MeshMetadata, S as SerializableMaterial } from './types-r00wVwfo.cjs';
6
+
7
+ type CameraConfig = {
8
+ position?: THREE.Vector3;
9
+ fov?: number;
10
+ near?: number;
11
+ far?: number;
12
+ target?: THREE.Vector3;
13
+ };
14
+ type LightingConfig = {
15
+ enableSunlight?: boolean;
16
+ sunlightIntensity?: number;
17
+ sunlightPosition?: THREE.Vector3;
18
+ ambientLightColor?: THREE.Color;
19
+ ambientLightIntensity?: number;
20
+ sunlightColor?: THREE.Color | number;
21
+ };
22
+ type EnvironmentConfig = {
23
+ hdrPath?: string;
24
+ backgroundColor?: THREE.Color | string;
25
+ enableEnvironmentLighting?: boolean;
26
+ sceneUp?: THREE.Vector3;
27
+ showEnvironment?: boolean;
28
+ };
29
+ type FloorConfig = {
30
+ enabled?: boolean;
31
+ size?: number;
32
+ color?: THREE.Color | string;
33
+ roughness?: number;
34
+ metalness?: number;
35
+ receiveShadow?: boolean;
36
+ };
37
+ type RenderConfig = {
38
+ enableShadows?: boolean;
39
+ shadowMapSize?: number;
40
+ antialias?: boolean;
41
+ pixelRatio?: number;
42
+ toneMapping?: THREE.ToneMapping;
43
+ toneMappingExposure?: number;
44
+ preserveDrawingBuffer?: boolean;
45
+ };
46
+ type ControlsConfig = {
47
+ enableDamping?: boolean;
48
+ dampingFactor?: number;
49
+ autoRotate?: boolean;
50
+ autoRotateSpeed?: number;
51
+ enableZoom?: boolean;
52
+ enablePan?: boolean;
53
+ minDistance?: number;
54
+ maxDistance?: number;
55
+ };
56
+ type ThreeInitializerOptions = {
57
+ sceneScale?: 'mm' | 'cm' | 'm' | 'inches' | 'feet';
58
+ camera?: CameraConfig;
59
+ lighting?: LightingConfig;
60
+ environment?: EnvironmentConfig;
61
+ floor?: FloorConfig;
62
+ render?: RenderConfig;
63
+ controls?: ControlsConfig;
64
+ events?: EventConfig;
65
+ };
66
+ type EventConfig = {
67
+ onBackgroundClicked?: (event: {
68
+ x: number;
69
+ y: number;
70
+ }) => void;
71
+ onObjectSelected?: (object: THREE.Object3D) => void;
72
+ /** Called when a mesh with metadata is clicked. Receives the mesh's metadata object. */
73
+ onMeshMetadataClicked?: (metadata: Record<string, string>) => void;
74
+ /** Color to use for highlighting selected meshes. Defaults to red (#ff0000). */
75
+ selectionColor?: THREE.Color | string;
76
+ /** Enable all event handlers (click/selection/metadata). Defaults to true. */
77
+ enableEventHandlers?: boolean;
78
+ enableKeyboardControls?: boolean;
79
+ enableClickToFocus?: boolean;
80
+ };
81
+
82
+ /**
83
+ * Initializes a comprehensive Three.js environment with enhanced render quality and flexible configuration.
84
+ *
85
+ * @param canvas - The HTML canvas element to render the scene on.
86
+ * @param options - Configuration options for the Three.js environment.
87
+ * @returns An object containing the scene, camera, controls, renderer, and utility methods.
88
+ */
89
+ declare const initThree: (canvas: HTMLCanvasElement, options?: ThreeInitializerOptions) => {
90
+ scene: THREE.Scene;
91
+ camera: THREE.PerspectiveCamera;
92
+ controls: OrbitControls;
93
+ renderer: THREE.WebGLRenderer;
94
+ dispose: () => void;
95
+ resize: () => void;
96
+ fitToView: () => void;
97
+ clearSelection: () => void;
98
+ };
99
+
100
+ /**
101
+ * Updates the scene with the given meshes and camera settings.
102
+ * If initialPositionSet is false, it positions the camera and sets the controls target based on the bounding boxes of the meshes.
103
+ * @param scene - The THREE.Scene object to update.
104
+ * @param meshes - An array of THREE.Mesh objects to add to the scene.
105
+ * @param camera - The THREE.PerspectiveCamera object to position.
106
+ * @param controls - The OrbitControls object to update.
107
+ * @param initialPositionSet - A boolean indicating whether the initial position of the camera and controls have been set.
108
+ */
109
+ declare function updateScene(scene: THREE.Scene, meshes: THREE.Mesh[], camera: THREE.PerspectiveCamera, controls: OrbitControls, initialPositionSet: boolean): void;
110
+
111
+ declare const EMISSIVE_MATERIAL: THREE.MeshPhysicalMaterial;
112
+ declare const METAL_MATERIAL: THREE.MeshPhysicalMaterial;
113
+ declare const CONCRETE_MATERIAL: THREE.MeshPhysicalMaterial;
114
+ declare const PLASTIC_MATERIAL: THREE.MeshPhysicalMaterial;
115
+ declare const GLASS_MATERIAL: THREE.MeshPhysicalMaterial;
116
+ declare const RUBBER_MATERIAL: THREE.MeshPhysicalMaterial;
117
+ declare const WOOD_MATERIAL: THREE.MeshPhysicalMaterial;
118
+
119
+ declare const threeMaterials_CONCRETE_MATERIAL: typeof CONCRETE_MATERIAL;
120
+ declare const threeMaterials_EMISSIVE_MATERIAL: typeof EMISSIVE_MATERIAL;
121
+ declare const threeMaterials_GLASS_MATERIAL: typeof GLASS_MATERIAL;
122
+ declare const threeMaterials_METAL_MATERIAL: typeof METAL_MATERIAL;
123
+ declare const threeMaterials_PLASTIC_MATERIAL: typeof PLASTIC_MATERIAL;
124
+ declare const threeMaterials_RUBBER_MATERIAL: typeof RUBBER_MATERIAL;
125
+ declare const threeMaterials_WOOD_MATERIAL: typeof WOOD_MATERIAL;
126
+ declare namespace threeMaterials {
127
+ export { threeMaterials_CONCRETE_MATERIAL as CONCRETE_MATERIAL, threeMaterials_EMISSIVE_MATERIAL as EMISSIVE_MATERIAL, threeMaterials_GLASS_MATERIAL as GLASS_MATERIAL, threeMaterials_METAL_MATERIAL as METAL_MATERIAL, threeMaterials_PLASTIC_MATERIAL as PLASTIC_MATERIAL, threeMaterials_RUBBER_MATERIAL as RUBBER_MATERIAL, threeMaterials_WOOD_MATERIAL as WOOD_MATERIAL };
128
+ }
129
+
130
+ declare const SCALE_FACTORS: Record<string, number>;
131
+ /**
132
+ * Extracts and processes display meshes from a ComputePointerResponse using the Grasshopper WebDisplay component.
133
+ *
134
+ * This is the primary entry point for extracting mesh geometry from Grasshopper compute responses.
135
+ * It handles all aspects of mesh processing: decompression, coordinate transformation, scaling, and positioning.
136
+ *
137
+ * **Note:** Mesh decompression happens asynchronously in a Web Worker to prevent UI blocking.
138
+ *
139
+ * @param data - The ComputePointerResponse containing Grasshopper output trees.
140
+ * @param options - Configuration for mesh extraction and parsing behavior. All options are optional with sensible defaults.
141
+ * @returns Promise resolving to array of THREE.Mesh objects (may be empty).
142
+ * @throws Rethrows unexpected errors after attempting to dispose any created meshes.
143
+ *
144
+ * @remarks
145
+ * - Only works with the WebDisplay component of GHHeadless.
146
+ * - Requires changes to Rhino.Compute (see https://github.com/TheVessen/compute.rhino3d).
147
+ * - Provides a performant way to display mesh data in Three.js.
148
+ * - Decompression is performed in a Web Worker for non-blocking UI updates.
149
+ * - Supports mesh metadata (names, user data) if provided in the compute response.
150
+ *
151
+ * @internal Internal helper: high-level extraction remains public via visualization module, but this
152
+ * function is considered internal implementation detail for mesh extraction.
153
+ *
154
+ * @example
155
+ * ```ts
156
+ * // Simple usage with defaults (all processing enabled)
157
+ * const meshes = await getThreeMeshesFromComputeResponse(response);
158
+ *
159
+ * // With debugging enabled
160
+ * const meshes = await getThreeMeshesFromComputeResponse(response, { debug: true });
161
+ *
162
+ * // With advanced options
163
+ * const meshes = await getThreeMeshesFromComputeResponse(response, {
164
+ * debug: true,
165
+ * allowScaling: true,
166
+ * allowAutoPosition: false,
167
+ * parsing: {
168
+ * mergeByMaterial: false,
169
+ * applyTransforms: true,
170
+ * debug: true,
171
+ * },
172
+ * });
173
+ * ```
174
+ */
175
+ declare function getThreeMeshesFromComputeResponse(data: GrasshopperComputeResponse, options?: MeshExtractionOptions): Promise<THREE.Mesh[]>;
176
+
177
+ /**
178
+ * Parses a MeshBatch object and creates Three.js meshes.
179
+ * This is useful when you already have a deserialized MeshBatch object.
180
+ *
181
+ * @internal Low-level mesh parsing — keep internal to `selva-compute`.
182
+ *
183
+ * @param batch - MeshBatch object
184
+ * @param options - Rendering options
185
+ * @returns Promise resolving to array of Three.js mesh objects
186
+ */
187
+ declare function parseMeshBatchObject(batch: MeshBatch, options?: {
188
+ /** Merge meshes with same material into single geometry*/
189
+ mergeByMaterial?: boolean;
190
+ /** Apply coordinate system transformations */
191
+ applyTransforms?: boolean;
192
+ /** Scale factor to apply to meshes (e.g., for unit conversion) */
193
+ scaleFactor?: number;
194
+ /** Enable performance monitoring */
195
+ debug?: boolean;
196
+ /** Parse time (optional, for debugging) */
197
+ parseTime?: number;
198
+ /** Performance start time (optional, for debugging) */
199
+ perfStart?: number;
200
+ }): Promise<THREE.Mesh[]>;
201
+
202
+ export { type CameraConfig, type ControlsConfig, type EnvironmentConfig, type EventConfig, type FloorConfig, type LightingConfig, threeMaterials as Materials, MeshBatch, MeshExtractionOptions, type RenderConfig, SCALE_FACTORS, type ThreeInitializerOptions, getThreeMeshesFromComputeResponse, initThree, parseMeshBatchObject, updateScene };
@@ -0,0 +1,202 @@
1
+ import * as THREE from 'three';
2
+ import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
3
+ import { b as GrasshopperComputeResponse } from './schemas-5LuPKgX2.js';
4
+ import { M as MeshExtractionOptions, a as MeshBatch } from './types-r00wVwfo.js';
5
+ export { D as DecompressedMeshData, d as MaterialGroup, b as MeshBatchParsingOptions, c as MeshMetadata, S as SerializableMaterial } from './types-r00wVwfo.js';
6
+
7
+ type CameraConfig = {
8
+ position?: THREE.Vector3;
9
+ fov?: number;
10
+ near?: number;
11
+ far?: number;
12
+ target?: THREE.Vector3;
13
+ };
14
+ type LightingConfig = {
15
+ enableSunlight?: boolean;
16
+ sunlightIntensity?: number;
17
+ sunlightPosition?: THREE.Vector3;
18
+ ambientLightColor?: THREE.Color;
19
+ ambientLightIntensity?: number;
20
+ sunlightColor?: THREE.Color | number;
21
+ };
22
+ type EnvironmentConfig = {
23
+ hdrPath?: string;
24
+ backgroundColor?: THREE.Color | string;
25
+ enableEnvironmentLighting?: boolean;
26
+ sceneUp?: THREE.Vector3;
27
+ showEnvironment?: boolean;
28
+ };
29
+ type FloorConfig = {
30
+ enabled?: boolean;
31
+ size?: number;
32
+ color?: THREE.Color | string;
33
+ roughness?: number;
34
+ metalness?: number;
35
+ receiveShadow?: boolean;
36
+ };
37
+ type RenderConfig = {
38
+ enableShadows?: boolean;
39
+ shadowMapSize?: number;
40
+ antialias?: boolean;
41
+ pixelRatio?: number;
42
+ toneMapping?: THREE.ToneMapping;
43
+ toneMappingExposure?: number;
44
+ preserveDrawingBuffer?: boolean;
45
+ };
46
+ type ControlsConfig = {
47
+ enableDamping?: boolean;
48
+ dampingFactor?: number;
49
+ autoRotate?: boolean;
50
+ autoRotateSpeed?: number;
51
+ enableZoom?: boolean;
52
+ enablePan?: boolean;
53
+ minDistance?: number;
54
+ maxDistance?: number;
55
+ };
56
+ type ThreeInitializerOptions = {
57
+ sceneScale?: 'mm' | 'cm' | 'm' | 'inches' | 'feet';
58
+ camera?: CameraConfig;
59
+ lighting?: LightingConfig;
60
+ environment?: EnvironmentConfig;
61
+ floor?: FloorConfig;
62
+ render?: RenderConfig;
63
+ controls?: ControlsConfig;
64
+ events?: EventConfig;
65
+ };
66
+ type EventConfig = {
67
+ onBackgroundClicked?: (event: {
68
+ x: number;
69
+ y: number;
70
+ }) => void;
71
+ onObjectSelected?: (object: THREE.Object3D) => void;
72
+ /** Called when a mesh with metadata is clicked. Receives the mesh's metadata object. */
73
+ onMeshMetadataClicked?: (metadata: Record<string, string>) => void;
74
+ /** Color to use for highlighting selected meshes. Defaults to red (#ff0000). */
75
+ selectionColor?: THREE.Color | string;
76
+ /** Enable all event handlers (click/selection/metadata). Defaults to true. */
77
+ enableEventHandlers?: boolean;
78
+ enableKeyboardControls?: boolean;
79
+ enableClickToFocus?: boolean;
80
+ };
81
+
82
+ /**
83
+ * Initializes a comprehensive Three.js environment with enhanced render quality and flexible configuration.
84
+ *
85
+ * @param canvas - The HTML canvas element to render the scene on.
86
+ * @param options - Configuration options for the Three.js environment.
87
+ * @returns An object containing the scene, camera, controls, renderer, and utility methods.
88
+ */
89
+ declare const initThree: (canvas: HTMLCanvasElement, options?: ThreeInitializerOptions) => {
90
+ scene: THREE.Scene;
91
+ camera: THREE.PerspectiveCamera;
92
+ controls: OrbitControls;
93
+ renderer: THREE.WebGLRenderer;
94
+ dispose: () => void;
95
+ resize: () => void;
96
+ fitToView: () => void;
97
+ clearSelection: () => void;
98
+ };
99
+
100
+ /**
101
+ * Updates the scene with the given meshes and camera settings.
102
+ * If initialPositionSet is false, it positions the camera and sets the controls target based on the bounding boxes of the meshes.
103
+ * @param scene - The THREE.Scene object to update.
104
+ * @param meshes - An array of THREE.Mesh objects to add to the scene.
105
+ * @param camera - The THREE.PerspectiveCamera object to position.
106
+ * @param controls - The OrbitControls object to update.
107
+ * @param initialPositionSet - A boolean indicating whether the initial position of the camera and controls have been set.
108
+ */
109
+ declare function updateScene(scene: THREE.Scene, meshes: THREE.Mesh[], camera: THREE.PerspectiveCamera, controls: OrbitControls, initialPositionSet: boolean): void;
110
+
111
+ declare const EMISSIVE_MATERIAL: THREE.MeshPhysicalMaterial;
112
+ declare const METAL_MATERIAL: THREE.MeshPhysicalMaterial;
113
+ declare const CONCRETE_MATERIAL: THREE.MeshPhysicalMaterial;
114
+ declare const PLASTIC_MATERIAL: THREE.MeshPhysicalMaterial;
115
+ declare const GLASS_MATERIAL: THREE.MeshPhysicalMaterial;
116
+ declare const RUBBER_MATERIAL: THREE.MeshPhysicalMaterial;
117
+ declare const WOOD_MATERIAL: THREE.MeshPhysicalMaterial;
118
+
119
+ declare const threeMaterials_CONCRETE_MATERIAL: typeof CONCRETE_MATERIAL;
120
+ declare const threeMaterials_EMISSIVE_MATERIAL: typeof EMISSIVE_MATERIAL;
121
+ declare const threeMaterials_GLASS_MATERIAL: typeof GLASS_MATERIAL;
122
+ declare const threeMaterials_METAL_MATERIAL: typeof METAL_MATERIAL;
123
+ declare const threeMaterials_PLASTIC_MATERIAL: typeof PLASTIC_MATERIAL;
124
+ declare const threeMaterials_RUBBER_MATERIAL: typeof RUBBER_MATERIAL;
125
+ declare const threeMaterials_WOOD_MATERIAL: typeof WOOD_MATERIAL;
126
+ declare namespace threeMaterials {
127
+ export { threeMaterials_CONCRETE_MATERIAL as CONCRETE_MATERIAL, threeMaterials_EMISSIVE_MATERIAL as EMISSIVE_MATERIAL, threeMaterials_GLASS_MATERIAL as GLASS_MATERIAL, threeMaterials_METAL_MATERIAL as METAL_MATERIAL, threeMaterials_PLASTIC_MATERIAL as PLASTIC_MATERIAL, threeMaterials_RUBBER_MATERIAL as RUBBER_MATERIAL, threeMaterials_WOOD_MATERIAL as WOOD_MATERIAL };
128
+ }
129
+
130
+ declare const SCALE_FACTORS: Record<string, number>;
131
+ /**
132
+ * Extracts and processes display meshes from a ComputePointerResponse using the Grasshopper WebDisplay component.
133
+ *
134
+ * This is the primary entry point for extracting mesh geometry from Grasshopper compute responses.
135
+ * It handles all aspects of mesh processing: decompression, coordinate transformation, scaling, and positioning.
136
+ *
137
+ * **Note:** Mesh decompression happens asynchronously in a Web Worker to prevent UI blocking.
138
+ *
139
+ * @param data - The ComputePointerResponse containing Grasshopper output trees.
140
+ * @param options - Configuration for mesh extraction and parsing behavior. All options are optional with sensible defaults.
141
+ * @returns Promise resolving to array of THREE.Mesh objects (may be empty).
142
+ * @throws Rethrows unexpected errors after attempting to dispose any created meshes.
143
+ *
144
+ * @remarks
145
+ * - Only works with the WebDisplay component of GHHeadless.
146
+ * - Requires changes to Rhino.Compute (see https://github.com/TheVessen/compute.rhino3d).
147
+ * - Provides a performant way to display mesh data in Three.js.
148
+ * - Decompression is performed in a Web Worker for non-blocking UI updates.
149
+ * - Supports mesh metadata (names, user data) if provided in the compute response.
150
+ *
151
+ * @internal Internal helper: high-level extraction remains public via visualization module, but this
152
+ * function is considered internal implementation detail for mesh extraction.
153
+ *
154
+ * @example
155
+ * ```ts
156
+ * // Simple usage with defaults (all processing enabled)
157
+ * const meshes = await getThreeMeshesFromComputeResponse(response);
158
+ *
159
+ * // With debugging enabled
160
+ * const meshes = await getThreeMeshesFromComputeResponse(response, { debug: true });
161
+ *
162
+ * // With advanced options
163
+ * const meshes = await getThreeMeshesFromComputeResponse(response, {
164
+ * debug: true,
165
+ * allowScaling: true,
166
+ * allowAutoPosition: false,
167
+ * parsing: {
168
+ * mergeByMaterial: false,
169
+ * applyTransforms: true,
170
+ * debug: true,
171
+ * },
172
+ * });
173
+ * ```
174
+ */
175
+ declare function getThreeMeshesFromComputeResponse(data: GrasshopperComputeResponse, options?: MeshExtractionOptions): Promise<THREE.Mesh[]>;
176
+
177
+ /**
178
+ * Parses a MeshBatch object and creates Three.js meshes.
179
+ * This is useful when you already have a deserialized MeshBatch object.
180
+ *
181
+ * @internal Low-level mesh parsing — keep internal to `selva-compute`.
182
+ *
183
+ * @param batch - MeshBatch object
184
+ * @param options - Rendering options
185
+ * @returns Promise resolving to array of Three.js mesh objects
186
+ */
187
+ declare function parseMeshBatchObject(batch: MeshBatch, options?: {
188
+ /** Merge meshes with same material into single geometry*/
189
+ mergeByMaterial?: boolean;
190
+ /** Apply coordinate system transformations */
191
+ applyTransforms?: boolean;
192
+ /** Scale factor to apply to meshes (e.g., for unit conversion) */
193
+ scaleFactor?: number;
194
+ /** Enable performance monitoring */
195
+ debug?: boolean;
196
+ /** Parse time (optional, for debugging) */
197
+ parseTime?: number;
198
+ /** Performance start time (optional, for debugging) */
199
+ perfStart?: number;
200
+ }): Promise<THREE.Mesh[]>;
201
+
202
+ export { type CameraConfig, type ControlsConfig, type EnvironmentConfig, type EventConfig, type FloorConfig, type LightingConfig, threeMaterials as Materials, MeshBatch, MeshExtractionOptions, type RenderConfig, SCALE_FACTORS, type ThreeInitializerOptions, getThreeMeshesFromComputeResponse, initThree, parseMeshBatchObject, updateScene };