@selvajs/compute 1.5.2-beta.4 → 1.5.2-beta.6
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.
- package/dist/chunk-HO6NH6HB.js +2 -0
- package/dist/chunk-HO6NH6HB.js.map +1 -0
- package/dist/{chunk-R7E2XNH4.js → chunk-J3UKLYH5.js} +2 -2
- package/dist/{chunk-C2VFZAMO.cjs → chunk-TDXM32RV.cjs} +2 -2
- package/dist/{chunk-C2VFZAMO.cjs.map → chunk-TDXM32RV.cjs.map} +1 -1
- package/dist/chunk-TRLKUOOF.cjs +2 -0
- package/dist/{chunk-DSI6FKBA.cjs.map → chunk-TRLKUOOF.cjs.map} +1 -1
- package/dist/grasshopper.cjs +1 -1
- package/dist/grasshopper.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/visualization-NJLK5746.cjs +2 -0
- package/dist/visualization-NJLK5746.cjs.map +1 -0
- package/dist/visualization-T5QNA4RB.js +2 -0
- package/dist/visualization.cjs +1 -1
- package/dist/visualization.cjs.map +1 -1
- package/dist/visualization.d.cts +1 -1
- package/dist/visualization.d.ts +1 -1
- package/dist/visualization.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-DM7RXPP6.js +0 -2
- package/dist/chunk-DM7RXPP6.js.map +0 -1
- package/dist/chunk-DSI6FKBA.cjs +0 -2
- package/dist/visualization-HV5EMX2F.cjs +0 -2
- package/dist/visualization-HV5EMX2F.cjs.map +0 -1
- package/dist/visualization-S47O7BLV.js +0 -2
- /package/dist/{chunk-R7E2XNH4.js.map → chunk-J3UKLYH5.js.map} +0 -0
- /package/dist/{visualization-S47O7BLV.js.map → visualization-T5QNA4RB.js.map} +0 -0
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as b,b as c,c as d,d as g,e as h,f as i,g as j,h as k,i as l,j as n,k as q,l as s}from"./chunk-
|
|
1
|
+
import{a as b,b as c,c as d,d as g,e as h,f as i,g as j,h as k,i as l,j as n,k as q,l as s}from"./chunk-J3UKLYH5.js";import"./chunk-XLHA5YPH.js";import{c as o,d as r,e,f,g as m,h as p,i as t,j as x,k as a}from"./chunk-RHULSS7S.js";export{t as ComputeServerStats,o as ErrorCodes,d as GrasshopperClient,i as GrasshopperResponseProcessor,r as RhinoComputeError,c as SolveScheduler,s as TreeBuilder,a as camelcaseKeys,h as downloadFileData,m as enableDebugLogging,g as extractFilesFromComputeResponse,n as fetchDefinitionIO,q as fetchParsedDefinitionIO,p as fetchRhinoCompute,e as getLogger,b as hashSolveInput,k as processInput,l as processInputs,f as setLogger,j as solveGrasshopperDefinition,x as toCamelCase};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkTRLKUOOFcjs = require('./chunk-TRLKUOOF.cjs');require('./chunk-MZGKJZVP.cjs');require('./chunk-VWOEUM7C.cjs');exports.BINARY_MESH_MAGIC = _chunkTRLKUOOFcjs.g; exports.BINARY_MESH_VERSION = _chunkTRLKUOOFcjs.h; exports.FLAG_FLOAT32 = _chunkTRLKUOOFcjs.i; exports.Materials = _chunkTRLKUOOFcjs.f; exports.SCALE_FACTORS = _chunkTRLKUOOFcjs.n; exports.applyOffset = _chunkTRLKUOOFcjs.d; exports.computeCombinedBoundingBox = _chunkTRLKUOOFcjs.e; exports.getThreeMeshesFromComputeResponse = _chunkTRLKUOOFcjs.o; exports.initThree = _chunkTRLKUOOFcjs.a; exports.parseBinaryMeshBatch = _chunkTRLKUOOFcjs.j; exports.parseColor = _chunkTRLKUOOFcjs.c; exports.parseMeshBatch = _chunkTRLKUOOFcjs.k; exports.parseMeshBatchBlob = _chunkTRLKUOOFcjs.m; exports.parseMeshBatchObject = _chunkTRLKUOOFcjs.l; exports.updateScene = _chunkTRLKUOOFcjs.b;
|
|
2
|
+
//# sourceMappingURL=visualization-NJLK5746.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/selva-compute/selva-compute/dist/visualization-NJLK5746.cjs"],"names":[],"mappings":"AAAA,iIAAqI,gCAA6B,gCAA6B,itBAAoV","file":"/home/runner/work/selva-compute/selva-compute/dist/visualization-NJLK5746.cjs"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as e,b as r,c as o,d as t,e as a,f as s,g as i,h as p,i as n,j as h,k as M,l as f,m,n as B,o as C}from"./chunk-HO6NH6HB.js";import"./chunk-XLHA5YPH.js";import"./chunk-RHULSS7S.js";export{i as BINARY_MESH_MAGIC,p as BINARY_MESH_VERSION,n as FLAG_FLOAT32,s as Materials,B as SCALE_FACTORS,t as applyOffset,a as computeCombinedBoundingBox,C as getThreeMeshesFromComputeResponse,e as initThree,h as parseBinaryMeshBatch,o as parseColor,M as parseMeshBatch,m as parseMeshBatchBlob,f as parseMeshBatchObject,r as updateScene};
|
|
2
|
+
//# sourceMappingURL=visualization-T5QNA4RB.js.map
|
package/dist/visualization.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkTRLKUOOFcjs = require('./chunk-TRLKUOOF.cjs');require('./chunk-MZGKJZVP.cjs');require('./chunk-VWOEUM7C.cjs');exports.Materials = _chunkTRLKUOOFcjs.f; exports.SCALE_FACTORS = _chunkTRLKUOOFcjs.n; exports.getThreeMeshesFromComputeResponse = _chunkTRLKUOOFcjs.o; exports.initThree = _chunkTRLKUOOFcjs.a; exports.parseMeshBatchObject = _chunkTRLKUOOFcjs.l; exports.updateScene = _chunkTRLKUOOFcjs.b;
|
|
2
2
|
//# sourceMappingURL=visualization.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/selva-compute/selva-compute/dist/visualization.cjs"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/selva-compute/selva-compute/dist/visualization.cjs"],"names":[],"mappings":"AAAA,iIAA2E,gCAA6B,gCAA6B,8RAA2I","file":"/home/runner/work/selva-compute/selva-compute/dist/visualization.cjs"}
|
package/dist/visualization.d.cts
CHANGED
|
@@ -202,4 +202,4 @@ declare function parseMeshBatchObject(batch: MeshBatch, options?: {
|
|
|
202
202
|
perfStart?: number;
|
|
203
203
|
}): Promise<THREE.Mesh[]>;
|
|
204
204
|
|
|
205
|
-
export { type CameraConfig, type ControlsConfig, type EnvironmentConfig, type EventConfig, type FloorConfig, type LightingConfig, threeMaterials as Materials, MeshExtractionOptions, type RenderConfig, SCALE_FACTORS, type ThreeInitializerOptions, getThreeMeshesFromComputeResponse, initThree, parseMeshBatchObject, updateScene };
|
|
205
|
+
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 };
|
package/dist/visualization.d.ts
CHANGED
|
@@ -202,4 +202,4 @@ declare function parseMeshBatchObject(batch: MeshBatch, options?: {
|
|
|
202
202
|
perfStart?: number;
|
|
203
203
|
}): Promise<THREE.Mesh[]>;
|
|
204
204
|
|
|
205
|
-
export { type CameraConfig, type ControlsConfig, type EnvironmentConfig, type EventConfig, type FloorConfig, type LightingConfig, threeMaterials as Materials, MeshExtractionOptions, type RenderConfig, SCALE_FACTORS, type ThreeInitializerOptions, getThreeMeshesFromComputeResponse, initThree, parseMeshBatchObject, updateScene };
|
|
205
|
+
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 };
|
package/dist/visualization.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as e,b as o,f as t,l as r,
|
|
1
|
+
import{a as e,b as o,f as t,l as r,n as i,o as n}from"./chunk-HO6NH6HB.js";import"./chunk-XLHA5YPH.js";import"./chunk-RHULSS7S.js";export{t as Materials,i as SCALE_FACTORS,n as getThreeMeshesFromComputeResponse,e as initThree,r as parseMeshBatchObject,o as updateScene};
|
|
2
2
|
//# sourceMappingURL=visualization.js.map
|
package/package.json
CHANGED
package/dist/chunk-DM7RXPP6.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{c as k}from"./chunk-XLHA5YPH.js";import{a as ee,c as O,d as F,e as b}from"./chunk-RHULSS7S.js";import*as l from"three";import{OrbitControls as te}from"three/addons/controls/OrbitControls.js";import{HDRLoader as ne}from"three/addons/loaders/HDRLoader.js";var U=new l.Vector3(0,0,1),P=(e,r,n,t)=>{switch(e){case"mm":return r;case"cm":return n;default:return t}},je=function(e,r){let n=re(r||{}),t=oe(n),o=de(n,e),i=ue(e,n),a=me(o,e,n);se(t,n),le(t,n),n.floor?.enabled&&ce(t,n);let d=n.events.enableEventHandlers!==!1?fe(e,t,o,a,n):{dispose:()=>{},fitToView:()=>{},clearSelection:()=>{}},c=e.parentElement,h=()=>c?{width:c.clientWidth,height:c.clientHeight}:{width:window.innerWidth,height:window.innerHeight},{animate:m,dispose:s}=ie(i,t,o,a,h,n.events.onFrame);m();let E=n.environment?.sceneUp||U;return t.up.set(E.x,E.y,E.z),{scene:t,camera:o,controls:a,renderer:i,dispose:()=>{s(),d.dispose(),a.dispose(),i.dispose(),t.traverse(u=>{u instanceof l.Mesh&&(u.geometry?.dispose(),Array.isArray(u.material)?u.material.forEach(H=>H.dispose()):u.material?.dispose())})},fitToView:d.fitToView,clearSelection:d.clearSelection}};function re(e){let r=e.sceneScale||"m",t={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:e.camera?.position||new l.Vector3(-t.cameraDistance,t.cameraDistance,t.cameraDistance),fov:e.camera?.fov||20,near:e.camera?.near||t.near,far:e.camera?.far||t.far,target:e.camera?.target||new l.Vector3(0,0,0)},lighting:{enableSunlight:e.lighting?.enableSunlight??!0,sunlightIntensity:e.lighting?.sunlightIntensity||1,sunlightPosition:e.lighting?.sunlightPosition||new l.Vector3(t.lightDistance,t.lightHeight,t.lightDistance),ambientLightColor:e.lighting?.ambientLightColor||new l.Color(4210752),ambientLightIntensity:e.lighting?.ambientLightIntensity||1,sunlightColor:e.lighting?.sunlightColor||16777215},environment:{hdrPath:e.environment?.hdrPath||"/baseHDR.hdr",backgroundColor:e.environment?.backgroundColor||new l.Color(15790320),enableEnvironmentLighting:e.environment?.enableEnvironmentLighting??!0,sceneUp:e.environment?.sceneUp||U,showEnvironment:e.environment?.showEnvironment??!1},floor:{enabled:e.floor?.enabled??!1,size:e.floor?.size||t.floorSize,color:e.floor?.color||new l.Color(8421504),roughness:e.floor?.roughness||.7,metalness:e.floor?.metalness||0,receiveShadow:e.floor?.receiveShadow??!0},render:{enableShadows:e.render?.enableShadows??!0,shadowMapSize:e.render?.shadowMapSize||2048,antialias:e.render?.antialias??!0,pixelRatio:e.render?.pixelRatio||Math.min(window.devicePixelRatio,2),toneMapping:e.render?.toneMapping||l.NeutralToneMapping,toneMappingExposure:e.render?.toneMappingExposure||1,preserveDrawingBuffer:e.render?.preserveDrawingBuffer??!1},controls:{enableDamping:e.controls?.enableDamping??!1,dampingFactor:e.controls?.dampingFactor||.05,autoRotate:e.controls?.autoRotate??!1,autoRotateSpeed:e.controls?.autoRotateSpeed||.5,enableZoom:e.controls?.enableZoom??!0,enablePan:e.controls?.enablePan??!0,minDistance:e.controls?.minDistance||t.minDistance,maxDistance:e.controls?.maxDistance||1/0},events:{onBackgroundClicked:e.events?.onBackgroundClicked,onObjectSelected:e.events?.onObjectSelected,onMeshMetadataClicked:e.events?.onMeshMetadataClicked,onMeshDoubleClicked:e.events?.onMeshDoubleClicked,selectionColor:e.events?.selectionColor||"#ff0000",enableEventHandlers:e.events?.enableEventHandlers??!0,enableKeyboardControls:e.events?.enableKeyboardControls??!0,enableClickToFocus:e.events?.enableClickToFocus??!0,enableDoubleClickZoom:e.events?.enableDoubleClickZoom??!0,onReady:e.events?.onReady,onFrame:e.events?.onFrame}}}function oe(e){let r=new l.Scene,n=typeof e.environment.backgroundColor=="string"?new l.Color(e.environment.backgroundColor):e.environment.backgroundColor;return r.background=n||null,r}function ae(e,r,n,t,o=200){let i=e.position.clone(),a=r.target.clone(),d=performance.now(),c=m=>1-Math.pow(1-m,3),h=()=>{let m=performance.now()-d,s=c(Math.min(m/o,1));e.position.lerpVectors(i,n,s),r.target.lerpVectors(a,t,s),r.update(),s<1&&requestAnimationFrame(h)};requestAnimationFrame(h)}function ie(e,r,n,t,o,i){let a=null,d=performance.now(),c=()=>{let{width:s,height:E}=o();if(s===0||E===0)return;let g=Math.min(window.devicePixelRatio,2),u=Math.round(s*g),H=Math.round(E*g);(e.domElement.width!==u||e.domElement.height!==H)&&(e.setPixelRatio(g),e.setSize(s,E,!1),n.aspect=s/E,n.updateProjectionMatrix())},h=function(){a=requestAnimationFrame(h);let s=performance.now(),E=(s-d)/1e3;d=s,c(),(t.enableDamping||t.autoRotate)&&t.update(),i?.(E),e.render(r,n)};return{animate:h,dispose:()=>{a!==null&&(cancelAnimationFrame(a),a=null)}}}function se(e,r){r.environment.enableEnvironmentLighting?new ne().load(r.environment.hdrPath||"/baseHDR.hdr",function(n){n.mapping=l.EquirectangularReflectionMapping,e.environment=n,r.environment.showEnvironment&&(e.background=n),r.events.onReady?.()},void 0,function(n){b().warn("HDR texture could not be loaded, falling back to basic lighting:",n),r.events.onReady?.()}):r.events.onReady?.()}function le(e,r){let n=new l.AmbientLight(r.lighting.ambientLightColor,r.lighting.ambientLightIntensity);if(e.add(n),r.lighting.enableSunlight){let t=new l.DirectionalLight(r.lighting.sunlightColor??16777215,r.lighting.sunlightIntensity),o=r.lighting.sunlightPosition;if(o&&t.position.set(o.x,o.y,o.z),r.render.enableShadows){t.castShadow=!0;let i=P(r.sceneScale,.1,10,100);t.shadow.camera.left=-i,t.shadow.camera.right=i,t.shadow.camera.top=i,t.shadow.camera.bottom=-i;let a=P(r.sceneScale,.001,.1,.5),d=P(r.sceneScale,1,100,500);t.shadow.camera.near=a,t.shadow.camera.far=d,t.shadow.mapSize.width=r.render.shadowMapSize||2048,t.shadow.mapSize.height=r.render.shadowMapSize||2048,t.shadow.bias=-1e-4,t.shadow.normalBias=.02}e.add(t)}}function ce(e,r){let n=r.floor.size,t=new l.PlaneGeometry(n,n),o=typeof r.floor.color=="string"?new l.Color(r.floor.color):r.floor.color,i=new l.MeshStandardMaterial({color:o,roughness:r.floor.roughness,metalness:r.floor.metalness,side:l.DoubleSide}),a=new l.Mesh(t,i);a.userData.id="floor",a.name="floor",a.rotation.x=-Math.PI/2,a.position.y=0,r.floor.receiveShadow&&r.render.enableShadows&&(a.receiveShadow=!0),e.add(a)}function de(e,r){let n=r.parentElement,t=n?n.clientWidth:window.innerWidth,o=n?n.clientHeight:window.innerHeight,i=new l.PerspectiveCamera(e.camera.fov,t/o,e.camera.near,e.camera.far),a=e.camera.position;return a&&i.position.set(a.x,a.y,a.z),i}function ue(e,r){let n=new l.WebGLRenderer({antialias:r.render.antialias,canvas:e,alpha:!0,powerPreference:"high-performance",preserveDrawingBuffer:r.render.preserveDrawingBuffer,logarithmicDepthBuffer:!0}),t=e.parentElement,o=t?t.clientWidth:window.innerWidth,i=t?t.clientHeight:window.innerHeight;return t&&(e.style.width="100%",e.style.height="100%",e.style.display="block"),n.setSize(o,i,!1),n.setPixelRatio(r.render.pixelRatio||Math.min(window.devicePixelRatio,2)),r.render.enableShadows&&(n.shadowMap.enabled=!0,n.shadowMap.type=l.VSMShadowMap),n.toneMapping=r.render.toneMapping,n.toneMappingExposure=r.render.toneMappingExposure||1,n.outputColorSpace=l.SRGBColorSpace,n.sortObjects=!0,n}function fe(e,r,n,t,o){let i=new Set,a=new Map,d=new l.Raycaster,c=new l.Vector2,h=new l.Vector2,m=f=>{let p=f;for(;p;){if(!p.visible)return!1;p=p.parent}return!0},s=()=>{let f=new l.Box3;if(r.traverse(L=>{L.visible&&L.userData.id!=="floor"&&L instanceof l.Mesh&&f.expandByObject(L)}),f.isEmpty()){b().warn("No objects to fit to view");return}let p=f.getCenter(new l.Vector3),T=f.getSize(new l.Vector3),v=Math.max(T.x,T.y,T.z),R=n.fov*(Math.PI/180),C=v/(2*Math.tan(R/2));C*=1.5;let D=n.position.clone().sub(t.target).normalize();n.position.copy(p.clone().add(D.multiplyScalar(C))),t.target.copy(p),t.update()},E=typeof o.events.selectionColor=="string"?new l.Color(o.events.selectionColor):o.events.selectionColor instanceof l.Color?o.events.selectionColor:new l.Color("#ff0000"),g=()=>{i.forEach(f=>{f instanceof l.Mesh&&a.has(f)&&(f.material=a.get(f),a.delete(f))}),i.clear()},u=f=>{h.set(f.clientX,f.clientY)},H=f=>{let p=new l.Vector2(f.clientX,f.clientY);if(h.distanceTo(p)>5)return;let T=e.getBoundingClientRect();c.x=(f.clientX-T.left)/T.width*2-1,c.y=-((f.clientY-T.top)/T.height)*2+1,d.setFromCamera(c,n);let v=d.intersectObjects(r.children,!0).filter(R=>m(R.object));if(v.length>0){let R=v[0].object;if(!i.has(R)){if(g(),i.add(R),R instanceof l.Mesh&&R.material instanceof l.Material){a.set(R,R.material);let C=R.material.clone();C.emissive=E.clone(),R.material=C}o.events?.onObjectSelected?.(R),R instanceof l.Mesh&&Object.keys(R.userData).length>0&&o.events?.onMeshMetadataClicked?.(R.userData)}}else g(),o.events?.onBackgroundClicked?.({x:c.x,y:c.y})},S=f=>{let p=e.getBoundingClientRect();c.x=(f.clientX-p.left)/p.width*2-1,c.y=-((f.clientY-p.top)/p.height)*2+1,d.setFromCamera(c,n);let T=d.intersectObjects(r.children,!0).filter(Q=>m(Q.object));if(T.length===0)return;let v=T[0].object;if(o.events?.onMeshDoubleClicked?.(v),!o.events?.enableDoubleClickZoom)return;let R=new l.Box3().setFromObject(v);if(R.isEmpty())return;let C=R.getCenter(new l.Vector3),D=R.getSize(new l.Vector3),L=Math.max(D.x,D.y,D.z),q=n.fov*(Math.PI/180),K=L/(2*Math.tan(q/2))*1.5,X=n.position.clone().sub(t.target).normalize(),J=C.clone().add(X.multiplyScalar(K));ae(n,t,J,C)},x=f=>{if(o.events?.enableKeyboardControls)switch(f.key.toLowerCase()){case"f":f.preventDefault(),s();break;case"escape":f.preventDefault(),g();break;case" ":f.preventDefault(),s();break}};return o.events?.enableClickToFocus&&(e.addEventListener("mousedown",u),e.addEventListener("click",H),e.addEventListener("dblclick",S)),o.events?.enableKeyboardControls&&(e.setAttribute("tabindex","0"),e.addEventListener("keydown",x)),{dispose:()=>{e.removeEventListener("mousedown",u),e.removeEventListener("click",H),e.removeEventListener("dblclick",S),e.removeEventListener("keydown",x),g()},fitToView:s,clearSelection:g}}function me(e,r,n){let t=new te(e,r),o=n.camera.target;return o&&t.target.set(o.x,o.y,o.z),t.enableDamping=n.controls.enableDamping||!1,t.dampingFactor=n.controls.dampingFactor||.05,t.autoRotate=n.controls.autoRotate||!1,t.autoRotateSpeed=n.controls.autoRotateSpeed||.5,t.enableZoom=n.controls.enableZoom??!0,t.enablePan=n.controls.enablePan??!0,t.minDistance=n.controls.minDistance||.001,t.maxDistance=n.controls.maxDistance||1/0,t.screenSpacePanning=!1,t.maxPolarAngle=Math.PI,t.update(),t}import*as w from"three";var I={HUGE_THRESHOLD:1e4,LARGE_THRESHOLD:1e3,SCALE_RATIO_THRESHOLD:100,NEAR_PLANE_FACTOR:{TINY:1e-4,SMALL:.001,NORMAL:.01},FAR_PLANE_FACTOR:{HUGE:100,LARGE:50,NORMAL:20},INITIAL_DISTANCE_MULTIPLIER:4};function Ke(e,r,n,t,o){if(he(e),r.length===0)return;r.forEach(m=>{e.add(m)});let i=z(r),a=i.getCenter(new w.Vector3),d=i.getSize(new w.Vector3),c=Math.max(d.x,d.y,d.z);if(c/Math.min(d.x||1,d.y||1,d.z||1)>I.SCALE_RATIO_THRESHOLD||c>I.HUGE_THRESHOLD?(n.near=c*I.NEAR_PLANE_FACTOR.TINY,n.far=c*I.FAR_PLANE_FACTOR.HUGE):c>I.LARGE_THRESHOLD?(n.near=c*I.NEAR_PLANE_FACTOR.SMALL,n.far=c*I.FAR_PLANE_FACTOR.LARGE):(n.near=Math.max(.01,c*I.NEAR_PLANE_FACTOR.NORMAL),n.far=Math.max(2e3,c*I.FAR_PLANE_FACTOR.NORMAL)),n.updateProjectionMatrix(),o)t.minDistance=n.near*2,t.maxDistance=n.far*.9;else{let m=c*I.INITIAL_DISTANCE_MULTIPLIER;n.position.set(a.x+m*.8,a.y+m,a.z+m*1.2),t.target.copy(a),t.minDistance=n.near*2,t.maxDistance=n.far*.9,t.update()}}function V(e){if(!e||typeof e!="string")return b().warn(`Invalid color input: ${e}, using white`),new w.Color(16777215);let r=e.trim();if(/^#?[0-9A-Fa-f]{6}$/.test(r))try{let n=r.startsWith("#")?r:`#${r}`;return new w.Color(n)}catch{return b().warn(`Invalid hex color: ${e}, using white`),new w.Color(16777215)}if(r.includes(",")){let n=r.split(",").map(t=>parseInt(t.trim(),10));if(n.length===3&&n.every(t=>!isNaN(t)&&t>=0&&t<=255))return new w.Color(n[0]/255,n[1]/255,n[2]/255)}try{return new w.Color(r.toLowerCase())}catch{return b().warn(`Invalid color string: ${e}, using white`),new w.Color(16777215)}}function N(e,r){e.forEach(n=>{n.position.y-=r})}function z(e){let r=new w.Box3;return e.length===0||e.forEach(n=>{n.updateMatrixWorld(!0);let t=new w.Box3().setFromObject(n);r.union(t)}),r}function he(e){[...e.children].forEach(n=>{n.userData.id!=="floor"&&(n.traverse(t=>{if(!(t instanceof w.Mesh))return;t.geometry?.dispose(),(Array.isArray(t.material)?t.material:[t.material]).forEach(i=>{for(let a of Object.values(i))a instanceof w.Texture&&a.dispose();i.dispose()})}),n.removeFromParent())})}var we={};ee(we,{CONCRETE_MATERIAL:()=>ge,EMISSIVE_MATERIAL:()=>Ee,GLASS_MATERIAL:()=>Re,METAL_MATERIAL:()=>pe,PLASTIC_MATERIAL:()=>ye,RUBBER_MATERIAL:()=>be,WOOD_MATERIAL:()=>Te});import*as y from"three";var Ee=new y.MeshPhysicalMaterial({color:0,emissive:new y.Color(16777215),emissiveIntensity:5,metalness:0,roughness:.2,clearcoat:.3,clearcoatRoughness:.2,depthWrite:!0,depthTest:!0,transparent:!1,alphaTest:0,polygonOffset:!0,side:y.FrontSide,dithering:!0}),pe=new y.MeshPhysicalMaterial({color:new y.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:y.FrontSide,dithering:!0}),ge=new y.MeshPhysicalMaterial({color:new y.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:y.FrontSide,dithering:!0}),ye=new y.MeshPhysicalMaterial({color:new y.Color(16777215),metalness:0,roughness:.3,envMapIntensity:.5,clearcoat:.5,clearcoatRoughness:.1,reflectivity:.5,ior:1.4,transmission:0,transparent:!1,depthWrite:!0,side:y.FrontSide,dithering:!0,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}),Re=new y.MeshPhysicalMaterial({color:new y.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:y.DoubleSide,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}),be=new y.MeshPhysicalMaterial({color:new y.Color(1710618),metalness:0,roughness:.9,envMapIntensity:.2,clearcoat:.1,clearcoatRoughness:.8,reflectivity:.2,ior:1.3,transmission:0,depthWrite:!0,side:y.FrontSide,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}),Te=new y.MeshPhysicalMaterial({color:new y.Color(8934707),metalness:0,roughness:.7,envMapIntensity:.3,clearcoat:.3,clearcoatRoughness:.4,reflectivity:.3,ior:1.3,transmission:0,depthWrite:!0,side:y.FrontSide,dithering:!0,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1});var G=1096174675,$=1,_=1,W=12,Y=56;function j(e){let r=Me(e),n=new DataView(r.buffer,r.byteOffset,r.byteLength);if(r.byteLength<W)throw B("Blob too small to contain SLVA header.",{expectedBytes:W,availableBytes:r.byteLength});let t=0,o=n.getUint32(t,!0);if(t+=4,o!==G)throw B(`Invalid SLVA magic: 0x${o.toString(16)}`,{expectedMagic:`0x${G.toString(16)}`,actualMagic:`0x${o.toString(16)}`});let i=n.getUint32(t,!0);if(t+=4,i!==$)throw B(`Unsupported SLVA version: ${i}`,{expectedVersion:$,actualVersion:i});let a=n.getUint32(t,!0);if(t+=4,t+a>r.byteLength)throw B("Insufficient data to read metadata JSON.",{expectedBytes:a,availableBytes:r.byteLength-t,offset:t});let d=r.subarray(t,t+a);t+=a;let c;try{c=JSON.parse(He(d))}catch(L){throw B(`Failed to parse metadata JSON: ${L instanceof Error?L.message:String(L)}`,{metadataLen:a})}if(t+Y>r.byteLength)throw B("Insufficient data to read geometry header.",{expectedBytes:Y,availableBytes:r.byteLength-t,offset:t});let h=n.getUint32(t,!0);t+=4;let m=n.getFloat64(t,!0);t+=8;let s=n.getFloat64(t,!0);t+=8;let E=n.getFloat64(t,!0);t+=8;let g=n.getFloat64(t,!0);t+=8;let u=n.getFloat64(t,!0);t+=8;let H=n.getFloat64(t,!0);t+=8;let S=n.getUint32(t,!0);t+=4;let x=(h&_)!==0,A=S*3,p=A*(x?4:2);if(t+p>r.byteLength)throw B("Insufficient data to read vertices.",{expectedBytes:p,availableBytes:r.byteLength-t,offset:t,useFloat32:x,vertexCount:S});let T=r.byteOffset+t,v=x?ve(r.buffer,T,A):xe(r.buffer,T,A);if(t+=p,t+4>r.byteLength)throw B("Insufficient data to read index count.",{expectedBytes:4,availableBytes:r.byteLength-t,offset:t});let R=n.getUint32(t,!0);t+=4;let C=R*4;if(t+C>r.byteLength)throw B("Insufficient data to read indices.",{expectedBytes:C,availableBytes:r.byteLength-t,offset:t,indexCount:R});let D=Ce(r.buffer,r.byteOffset+t,R);return{metadata:c,flags:h,vertices:v,indices:D,origin:[m,s,E],scale:[g,u,H]}}function Me(e){return typeof e=="string"?k(e):e instanceof Uint8Array?e:new Uint8Array(e)}function He(e){if(typeof TextDecoder<"u")return new TextDecoder("utf-8").decode(e);if(typeof globalThis.Buffer<"u")return globalThis.Buffer.from(e).toString("utf-8");throw new F("No UTF-8 decoder available in this environment.",O.INVALID_STATE)}function xe(e,r,n){if(n===0)return new Int16Array(0);if(r%2===0)return new Int16Array(e,r,n);let t=new Uint8Array(n*2);return t.set(new Uint8Array(e,r,n*2)),new Int16Array(t.buffer)}function ve(e,r,n){if(n===0)return new Float32Array(0);if(r%4===0)return new Float32Array(e,r,n);let t=new Uint8Array(n*4);return t.set(new Uint8Array(e,r,n*4)),new Float32Array(t.buffer)}function Ce(e,r,n){if(n===0)return new Uint32Array(0);if(r%4===0)return new Uint32Array(e,r,n);let t=new Uint8Array(n*4);return t.set(new Uint8Array(e,r,n*4)),new Uint32Array(t.buffer)}function B(e,r){return new F(e,O.VALIDATION_ERROR,{context:r})}import*as M from"three";async function Z(e,r){let{mergeByMaterial:n=!0,applyTransforms:t=!0,debug:o=!1}=r??{},i=o?performance.now():0,a=0;try{let d=performance.now(),c=JSON.parse(e);return a=performance.now()-d,await Se(c,{mergeByMaterial:n,applyTransforms:t,debug:o,parseTime:a,perfStart:i})}catch(d){return b().error("Error parsing mesh batch:",d),[]}}async function Se(e,r){let{mergeByMaterial:n=!0,applyTransforms:t=!0,scaleFactor:o=1,debug:i=!1,parseTime:a=0,perfStart:d=i?performance.now():0}=r??{},c=0,h=0;try{let m=performance.now(),s=j(e.compressedData);c=performance.now()-m;let E=s.metadata.materials??e.materials,g=s.metadata.groups??e.groups,u=s.metadata.sourceComponentId??e.sourceComponentId,H=(s.flags&_)!==0,S=H?Le(s.vertices,t):Ae(s.vertices,s.origin,s.scale,t);if(i){let p=Oe(e.compressedData),T=s.vertices.byteLength+s.indices.byteLength;b().debug("Mesh Batch Stats:"),b().debug(` Materials: ${E.length} | Groups: ${g.length}`),b().debug(` Vertices: ${s.vertices.length/3} | Indices: ${s.indices.length}`),b().debug(` Format: ${H?"float32":"int16 quantized"}`),b().debug(` Blob: ${(p/1024/1024).toFixed(2)} MB | Geometry on wire: ${(T/1024/1024).toFixed(2)} MB`)}let x=performance.now(),A=E.map(Ie),f=[];for(let p of g)if(n&&p.meshes.length>1){let T=Be(p,S,s.indices,A);T.userData.sourceComponentId=u??null,f.push(T)}else{let T=De(p,S,s.indices,A);for(let v of T)v.userData.sourceComponentId=u??null;f.push(...T)}if(o!==1)for(let p of f)p.scale.set(o,o,o);if(h=performance.now()-x,i){let p=performance.now()-d;b().debug("Performance:"),a>0&&b().debug(` Parse JSON: ${a.toFixed(2)}ms`),b().debug(` Decode binary: ${c.toFixed(2)}ms`),b().debug(` Create Meshes: ${h.toFixed(2)}ms`),b().debug(` Total: ${p.toFixed(2)}ms`)}return f}catch(m){return b().error("Error parsing mesh batch object:",m),[]}}function Ae(e,r,n,t){let o=new Float32Array(e.length),i=r[0],a=r[1],d=r[2],c=n[0],h=n[1],m=n[2];if(t)for(let s=0;s<e.length;s+=3){let E=i+(e[s]+32767)*c,g=a+(e[s+1]+32767)*h,u=d+(e[s+2]+32767)*m;o[s]=E,o[s+1]=u,o[s+2]=-g}else for(let s=0;s<e.length;s+=3)o[s]=i+(e[s]+32767)*c,o[s+1]=a+(e[s+1]+32767)*h,o[s+2]=d+(e[s+2]+32767)*m;return o}function Le(e,r){if(!r)return e;let n=new Float32Array(e.length);for(let t=0;t<e.length;t+=3){let o=e[t],i=e[t+1],a=e[t+2];n[t]=o,n[t+1]=a,n[t+2]=-i}return n}function Ie(e){let r=V(e.color);return new M.MeshPhysicalMaterial({color:r,metalness:e.metalness,roughness:e.roughness,opacity:e.opacity,transparent:e.transparent,side:M.DoubleSide,polygonOffset:!0,polygonOffsetFactor:.5,polygonOffsetUnits:.5,depthWrite:!0,depthTest:!0})}function Be(e,r,n,t){let o=0,i=0;for(let u of e.meshes)o+=u.vertexCount,i+=u.indexCount;let a=new Float32Array(o*3),d=new Uint32Array(i),c=0,h=0;for(let u of e.meshes){let H=u.vertexStart*3,S=u.vertexCount*3;a.set(r.subarray(H,H+S),c*3);let x=n.subarray(u.indexStart,u.indexStart+u.indexCount),A=c-u.vertexStart;if(A===0)d.set(x,h);else for(let f=0;f<x.length;f++)d[h+f]=x[f]+A;c+=u.vertexCount,h+=u.indexCount}let m=new M.BufferGeometry;m.setAttribute("position",new M.BufferAttribute(a,3)),m.setIndex(new M.BufferAttribute(d,1)),m.computeVertexNormals();let s=new M.Mesh(m,t[e.materialId]),E=e.meshes[0],g=e.meshes.map(u=>u.name).filter(u=>u&&u.length>0);return s.name=g.length>0?g[0]:`merged_material_${e.materialId}`,s.castShadow=!0,s.receiveShadow=!0,s.userData={name:s.name,layer:E?.layer??"",originalIndex:E?.originalIndex??0,metadata:E?.metadata??{},mergedFrom:e.meshes.slice(1).map(u=>({name:u.name,layer:u.layer,originalIndex:u.originalIndex}))},s}function De(e,r,n,t){let o=[];for(let i of e.meshes){let a=i.vertexStart*3,d=i.vertexCount*3,c=r.slice(a,a+d),h=n.subarray(i.indexStart,i.indexStart+i.indexCount),m=new Uint32Array(h.length),s=i.vertexStart;for(let u=0;u<h.length;u++)m[u]=h[u]-s;let E=new M.BufferGeometry;E.setAttribute("position",new M.BufferAttribute(c,3)),E.setIndex(new M.BufferAttribute(m,1)),E.computeVertexNormals();let g=new M.Mesh(E,t[e.materialId]);g.name=i.name,g.userData={name:i.name,layer:i.layer??"",originalIndex:i.originalIndex,metadata:i.metadata??{}},g.castShadow=!0,g.receiveShadow=!0,o.push(g)}return o}function Oe(e){return Math.floor(e.length*3/4)}var Fe={Millimeters:1/1e3,Centimeters:1/100,Meters:1,Inches:1/39.37,Feet:1/3.28084},Pe="Display";async function lt(e,r){let n=performance.now(),t=[],{allowScaling:o=!0,allowAutoPosition:i=!0,debug:a=!1,parsing:d={}}=r??{};try{let c=o?ze(e.modelunits):1;return await _e(e,t,c,d,a),i&&Ue(t),t}catch(c){throw Ve(c,t),c}finally{a&&Ge(n)}}function ze(e){return Fe[e]??1}async function _e(e,r,n,t,o){for(let i of e.values){let a=i.InnerTree;for(let d in a){let c=a[d];c&&await ke(c,r,n,t,o)}}}async function ke(e,r,n,t,o){for(let i of e)if(i.type.includes(Pe)){let a={mergeByMaterial:!0,applyTransforms:!0,debug:!1,...t},d=await Z(i.data,a);if(n!==1)for(let c of d)c.scale.set(n,n,n);r.push(...d),o&&b().debug(`Extracted ${d.length} meshes from batch`)}}function Ue(e){if(e.length===0)return;let n=z(e).min.y;N(e,n)}function Ve(e,r){b().error("An unexpected error occurred:",e),Ne(r)}function Ne(e){for(let r of e)r.geometry&&r.geometry.dispose(),r.material&&(Array.isArray(r.material)?r.material.forEach(n=>n.dispose()):r.material.dispose())}function Ge(e){let r=performance.now()-e;b().info("Time to process meshes:",`${r.toFixed(2)}ms`)}export{je as a,Ke as b,V as c,N as d,z as e,we as f,G as g,$ as h,_ as i,j,Z as k,Se as l,Fe as m,lt as n};
|
|
2
|
-
//# sourceMappingURL=chunk-DM7RXPP6.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/features/visualization/threejs/three-initializer.ts","../src/features/visualization/threejs/three-helpers.ts","../src/features/visualization/threejs/three-materials.ts","../src/features/visualization/webdisplay/binary-parser.ts","../src/features/visualization/webdisplay/batch-parser.ts","../src/features/visualization/webdisplay/webdisplay-parser.ts"],"sourcesContent":["import * as THREE from 'three';\nimport { OrbitControls } from 'three/addons/controls/OrbitControls.js';\nimport { HDRLoader } from 'three/addons/loaders/HDRLoader.js';\n\nimport { getLogger } from '@/core';\nimport { ThreeInitializerOptions } from '../types';\n\nconst defaultUp = new THREE.Vector3(0, 0, 1);\n\n// Returns scale-specific values for mm, cm, and m scales\nconst getScaleValue = (scale: string, mmVal: number, cmVal: number, mVal: number): number => {\n\tswitch (scale) {\n\t\tcase 'mm':\n\t\t\treturn mmVal;\n\t\tcase 'cm':\n\t\t\treturn cmVal;\n\t\tdefault:\n\t\t\treturn mVal;\n\t}\n};\n\n/**\n * Initializes a Three.js environment with scene, camera, renderer, and event handling.\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\tfitToView: () => void;\n\tclearSelection: () => void;\n} {\n\tconst config = applyDefaults(options || {});\n\n\tconst scene = createScene(config);\n\tconst camera = createCamera(config, canvas);\n\tconst renderer = setupRenderer(canvas, config);\n\tconst controls = setupControls(camera, canvas, config);\n\n\tsetupEnvironment(scene, config);\n\tsetupLighting(scene, config);\n\n\tif (config.floor?.enabled) {\n\t\taddFloor(scene, config);\n\t}\n\n\tconst eventHandlers =\n\t\tconfig.events.enableEventHandlers !== false\n\t\t\t? setupEventHandlers(canvas, scene, camera, controls, config)\n\t\t\t: { dispose: () => {}, fitToView: () => {}, clearSelection: () => {} };\n\n\tconst parent = canvas.parentElement;\n\tconst getCanvasSize = () =>\n\t\tparent\n\t\t\t? { width: parent.clientWidth, height: parent.clientHeight }\n\t\t\t: { width: window.innerWidth, height: window.innerHeight };\n\n\t// Resize checked every frame so buffer resize and render happen in the same frame,\n\t// preventing visible blank frames on resize\n\tconst { animate, dispose: disposeAnimation } = createAnimationLoop(\n\t\trenderer,\n\t\tscene,\n\t\tcamera,\n\t\tcontrols,\n\t\tgetCanvasSize,\n\t\tconfig.events.onFrame\n\t);\n\tanimate();\n\n\tconst sceneUp = config.environment?.sceneUp || defaultUp;\n\tscene.up.set(sceneUp.x, sceneUp.y, sceneUp.z);\n\n\tconst dispose = () => {\n\t\tdisposeAnimation();\n\t\teventHandlers.dispose();\n\t\tcontrols.dispose();\n\t\trenderer.dispose();\n\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\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// 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\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\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\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\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\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\tonMeshDoubleClicked: options.events?.onMeshDoubleClicked,\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\tenableDoubleClickZoom: options.events?.enableDoubleClickZoom ?? true,\n\t\t\tonReady: options.events?.onReady,\n\t\t\tonFrame: options.events?.onFrame\n\t\t}\n\t};\n}\n\nfunction createScene(config: Required<ThreeInitializerOptions>): THREE.Scene {\n\tconst scene = new THREE.Scene();\n\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\nfunction animateCameraTo(\n\tcamera: THREE.PerspectiveCamera,\n\tcontrols: OrbitControls,\n\ttoPosition: THREE.Vector3,\n\ttoTarget: THREE.Vector3,\n\tdurationMs = 200\n): void {\n\tconst fromPosition = camera.position.clone();\n\tconst fromTarget = controls.target.clone();\n\tconst startTime = performance.now();\n\n\tconst easeOut = (t: number) => 1 - Math.pow(1 - t, 3);\n\n\tconst tick = () => {\n\t\tconst elapsed = performance.now() - startTime;\n\t\tconst t = easeOut(Math.min(elapsed / durationMs, 1));\n\n\t\tcamera.position.lerpVectors(fromPosition, toPosition, t);\n\t\tcontrols.target.lerpVectors(fromTarget, toTarget, t);\n\t\tcontrols.update();\n\n\t\tif (t < 1) requestAnimationFrame(tick);\n\t};\n\n\trequestAnimationFrame(tick);\n}\n\n// Resize applied before render so buffer clear and draw happen in the same frame,\n// preventing visible blank frames when the canvas is resized\nfunction createAnimationLoop(\n\trenderer: THREE.WebGLRenderer,\n\tscene: THREE.Scene,\n\tcamera: THREE.PerspectiveCamera,\n\tcontrols: OrbitControls,\n\tgetCanvasSize: () => { width: number; height: number },\n\tonFrame?: (delta: number) => void\n): { animate: () => void; dispose: () => void } {\n\tlet animationId: number | null = null;\n\tlet lastTime = performance.now();\n\n\tconst checkResize = () => {\n\t\tconst { width, height } = getCanvasSize();\n\t\tif (width === 0 || height === 0) return;\n\n\t\tconst pixelRatio = Math.min(window.devicePixelRatio, 2);\n\t\tconst newW = Math.round(width * pixelRatio);\n\t\tconst newH = Math.round(height * pixelRatio);\n\n\t\tif (renderer.domElement.width !== newW || renderer.domElement.height !== newH) {\n\t\t\trenderer.setPixelRatio(pixelRatio);\n\t\t\trenderer.setSize(width, height, false);\n\t\t\tcamera.aspect = width / height;\n\t\t\tcamera.updateProjectionMatrix();\n\t\t}\n\t};\n\n\tconst animate = function () {\n\t\tanimationId = requestAnimationFrame(animate);\n\n\t\tconst now = performance.now();\n\t\tconst delta = (now - lastTime) / 1000;\n\t\tlastTime = now;\n\n\t\tcheckResize();\n\n\t\tif (controls.enableDamping || controls.autoRotate) {\n\t\t\tcontrols.update();\n\t\t}\n\n\t\tonFrame?.(delta);\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\nfunction setupEnvironment(scene: THREE.Scene, config: Required<ThreeInitializerOptions>) {\n\tif (config.environment.enableEnvironmentLighting) {\n\t\tnew HDRLoader().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\tconfig.events.onReady?.();\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\tconfig.events.onReady?.();\n\t\t\t}\n\t\t);\n\t} else {\n\t\tconfig.events.onReady?.();\n\t}\n}\n\nfunction setupLighting(scene: THREE.Scene, config: Required<ThreeInitializerOptions>) {\n\tconst ambientLight = new THREE.AmbientLight(\n\t\tconfig.lighting.ambientLightColor,\n\t\tconfig.lighting.ambientLightIntensity\n\t);\n\tscene.add(ambientLight);\n\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 = getScaleValue(config.sceneScale, 0.1, 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 = getScaleValue(config.sceneScale, 0.001, 0.1, 0.5);\n\t\t\tconst shadowFar = getScaleValue(config.sceneScale, 1, 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\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\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\nfunction createCamera(\n\tconfig: Required<ThreeInitializerOptions>,\n\tcanvas: HTMLCanvasElement\n): THREE.PerspectiveCamera {\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// Logarithmic depth buffer improves depth precision for mixed scales (mm to km)\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\tlogarithmicDepthBuffer: true\n\t});\n\n\tconst parent = canvas.parentElement;\n\tconst width = parent ? parent.clientWidth : window.innerWidth;\n\tconst height = parent ? parent.clientHeight : window.innerHeight;\n\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\tif (config.render.enableShadows) {\n\t\trenderer.shadowMap.enabled = true;\n\t\trenderer.shadowMap.type = THREE.VSMShadowMap;\n\t}\n\n\trenderer.toneMapping = config.render.toneMapping!;\n\trenderer.toneMappingExposure = config.render.toneMappingExposure || 1.0;\n\trenderer.outputColorSpace = THREE.SRGBColorSpace;\n\n\trenderer.sortObjects = true;\n\n\treturn renderer;\n}\n\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// An object is hittable only if every ancestor is also visible. Three.js's\n\t// recursive intersect doesn't enforce that — it can hit a visible Mesh inside\n\t// a hidden Group.\n\tconst isFullyVisible = (object: THREE.Object3D): boolean => {\n\t\tlet current: THREE.Object3D | null = object;\n\t\twhile (current) {\n\t\t\tif (!current.visible) return false;\n\t\t\tcurrent = current.parent;\n\t\t}\n\t\treturn true;\n\t};\n\n\tconst fitToView = () => {\n\t\tconst box = new THREE.Box3();\n\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\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\tdistance *= 1.5;\n\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\tcontrols.target.copy(center);\n\t\tcontrols.update();\n\t};\n\n\tconst selectionColorObj =\n\t\ttypeof config.events.selectionColor === 'string'\n\t\t\t? new THREE.Color(config.events.selectionColor)\n\t\t\t: config.events.selectionColor instanceof THREE.Color\n\t\t\t\t? config.events.selectionColor\n\t\t\t\t: new THREE.Color('#ff0000');\n\n\tconst clearSelection = () => {\n\t\tselectedObjects.forEach((obj) => {\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\tconst handleCanvasClick = (event: MouseEvent) => {\n\t\t// Ignore if mouse has moved (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\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\traycaster.setFromCamera(mouse, camera);\n\t\tconst intersects = raycaster\n\t\t\t.intersectObjects(scene.children, true)\n\t\t\t.filter((i) => isFullyVisible(i.object));\n\n\t\tif (intersects.length > 0) {\n\t\t\tconst clickedObject = intersects[0].object;\n\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 so we don't affect other meshes\n\t\t\t\tif (\n\t\t\t\t\tclickedObject instanceof THREE.Mesh &&\n\t\t\t\t\tclickedObject.material instanceof THREE.Material\n\t\t\t\t) {\n\t\t\t\t\toriginalMaterials.set(clickedObject, clickedObject.material);\n\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\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\tclearSelection();\n\t\t\tconfig.events?.onBackgroundClicked?.({ x: mouse.x, y: mouse.y });\n\t\t}\n\t};\n\n\tconst handleDoubleClick = (event: MouseEvent) => {\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\traycaster.setFromCamera(mouse, camera);\n\t\tconst intersects = raycaster\n\t\t\t.intersectObjects(scene.children, true)\n\t\t\t.filter((i) => isFullyVisible(i.object));\n\n\t\tif (intersects.length === 0) return;\n\n\t\tconst target = intersects[0].object;\n\t\tconfig.events?.onMeshDoubleClicked?.(target);\n\n\t\tif (!config.events?.enableDoubleClickZoom) return;\n\n\t\tconst box = new THREE.Box3().setFromObject(target);\n\t\tif (box.isEmpty()) return;\n\n\t\tconst center = box.getCenter(new THREE.Vector3());\n\t\tconst size = box.getSize(new THREE.Vector3());\n\t\tconst maxDim = Math.max(size.x, size.y, size.z);\n\t\tconst fov = camera.fov * (Math.PI / 180);\n\t\tconst distance = (maxDim / (2 * Math.tan(fov / 2))) * 1.5;\n\n\t\tconst direction = camera.position.clone().sub(controls.target).normalize();\n\t\tconst targetPosition = center.clone().add(direction.multiplyScalar(distance));\n\n\t\tanimateCameraTo(camera, controls, targetPosition, center);\n\t};\n\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\tif (config.events?.enableClickToFocus) {\n\t\tcanvas.addEventListener('mousedown', handleMouseDown);\n\t\tcanvas.addEventListener('click', handleCanvasClick);\n\t\tcanvas.addEventListener('dblclick', handleDoubleClick);\n\t}\n\n\tif (config.events?.enableKeyboardControls) {\n\t\tcanvas.setAttribute('tabindex', '0');\n\t\tcanvas.addEventListener('keydown', handleKeydown);\n\t}\n\n\tconst dispose = () => {\n\t\tcanvas.removeEventListener('mousedown', handleMouseDown);\n\t\tcanvas.removeEventListener('click', handleCanvasClick);\n\t\tcanvas.removeEventListener('dblclick', handleDoubleClick);\n\t\tcanvas.removeEventListener('keydown', handleKeydown);\n\t\tclearSelection();\n\t};\n\n\treturn { dispose, fitToView, clearSelection };\n}\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\tconst target = config.camera.target;\n\tif (target) {\n\t\tcontrols.target.set(target.x, target.y, target.z);\n\t}\n\n\tcontrols.enableDamping = config.controls.enableDamping || false;\n\tcontrols.dampingFactor = config.controls.dampingFactor || 0.05;\n\n\tcontrols.autoRotate = config.controls.autoRotate || false;\n\tcontrols.autoRotateSpeed = config.controls.autoRotateSpeed || 0.5;\n\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\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// Camera configuration constants\nconst CAMERA_CONFIG = {\n\tHUGE_THRESHOLD: 10000,\n\tLARGE_THRESHOLD: 1000,\n\tSCALE_RATIO_THRESHOLD: 100,\n\tNEAR_PLANE_FACTOR: {\n\t\tTINY: 0.0001,\n\t\tSMALL: 0.001,\n\t\tNORMAL: 0.01\n\t},\n\tFAR_PLANE_FACTOR: {\n\t\tHUGE: 100,\n\t\tLARGE: 50,\n\t\tNORMAL: 20\n\t},\n\tINITIAL_DISTANCE_MULTIPLIER: 4\n};\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\t// Add new meshes to scene\n\tmeshes.forEach((mesh) => {\n\t\tscene.add(mesh);\n\t});\n\n\t// Calculate bounds of the new content\n\tconst unionBoundingBox = computeCombinedBoundingBox(meshes);\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 > CAMERA_CONFIG.SCALE_RATIO_THRESHOLD || maxDim > CAMERA_CONFIG.HUGE_THRESHOLD) {\n\t\t// Large scale range detected - use logarithmic depth buffer approach\n\t\tcamera.near = maxDim * CAMERA_CONFIG.NEAR_PLANE_FACTOR.TINY;\n\t\tcamera.far = maxDim * CAMERA_CONFIG.FAR_PLANE_FACTOR.HUGE;\n\t} else if (maxDim > CAMERA_CONFIG.LARGE_THRESHOLD) {\n\t\t// Large scene\n\t\tcamera.near = maxDim * CAMERA_CONFIG.NEAR_PLANE_FACTOR.SMALL;\n\t\tcamera.far = maxDim * CAMERA_CONFIG.FAR_PLANE_FACTOR.LARGE;\n\t} else {\n\t\t// Normal scene\n\t\tcamera.near = Math.max(0.01, maxDim * CAMERA_CONFIG.NEAR_PLANE_FACTOR.NORMAL);\n\t\tcamera.far = Math.max(2000, maxDim * CAMERA_CONFIG.FAR_PLANE_FACTOR.NORMAL);\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 * CAMERA_CONFIG.INITIAL_DISTANCE_MULTIPLIER;\n\n\t\tcamera.position.set(center.x + distance * 0.8, center.y + distance, center.z + distance * 1.2);\n\t\tcontrols.target.copy(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) — require exactly 6 hex chars\n\tif (/^#?[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\n/**\n * Computes the combined world-axis-aligned bounding box of a set of meshes.\n * Correctly accounts for mesh transformations (rotation, position, scale).\n */\nexport function computeCombinedBoundingBox(meshes: THREE.Mesh[]): THREE.Box3 {\n\tconst combinedBoundingBox = new THREE.Box3();\n\tif (meshes.length === 0) return combinedBoundingBox;\n\tmeshes.forEach((mesh) => {\n\t\t// Ensure the world matrix is up to date before calculating the box\n\t\tmesh.updateMatrixWorld(true);\n\t\tconst bbox = new THREE.Box3().setFromObject(mesh);\n\t\tcombinedBoundingBox.union(bbox);\n\t});\n\treturn combinedBoundingBox;\n}\n\n/**\n * Clears the given THREE.Scene by removing all non-floor top-level children and\n * recursively disposing of their geometry and materials.\n *\n * Removes at the top level rather than traversing for meshes, so parent Groups\n * don't accumulate as ghost nodes after their mesh children are disposed.\n */\nfunction clearScene(scene: THREE.Scene): void {\n\t// Snapshot children — we mutate the array via removeFromParent during iteration\n\tconst topLevel = [...scene.children];\n\n\ttopLevel.forEach((object) => {\n\t\tif (object.userData.id === 'floor') return;\n\n\t\t// Recursively dispose all meshes in this subtree\n\t\tobject.traverse((child) => {\n\t\t\tif (!(child instanceof THREE.Mesh)) return;\n\n\t\t\tchild.geometry?.dispose();\n\n\t\t\tconst materials = Array.isArray(child.material) ? child.material : [child.material];\n\t\t\tmaterials.forEach((material) => {\n\t\t\t\t// Walk only own enumerable properties — `for...in` on a Three.js material\n\t\t\t\t// also iterates the prototype chain, which is needlessly expensive.\n\t\t\t\tfor (const value of Object.values(material)) {\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","import * as THREE from 'three';\n\nexport const EMISSIVE_MATERIAL = new THREE.MeshPhysicalMaterial({\n\tcolor: 0x000000,\n\temissive: new THREE.Color(0xffffff),\n\temissiveIntensity: 5,\n\tmetalness: 0.0,\n\troughness: 0.2,\n\tclearcoat: 0.3,\n\tclearcoatRoughness: 0.2,\n\tdepthWrite: true,\n\tdepthTest: true,\n\ttransparent: false,\n\talphaTest: 0.0,\n\tpolygonOffset: true,\n\tside: THREE.FrontSide,\n\tdithering: true\n});\n\nexport const METAL_MATERIAL = new THREE.MeshPhysicalMaterial({\n\tcolor: new THREE.Color(0x000000),\n\tmetalness: 0.9,\n\troughness: 0.3,\n\tenvMapIntensity: 1.2,\n\tclearcoat: 0.3,\n\tclearcoatRoughness: 0.2,\n\treflectivity: 1,\n\tior: 2.5,\n\tthickness: 1,\n\tdepthWrite: true,\n\ttransparent: false,\n\talphaTest: 0.0,\n\tdepthTest: true,\n\tpolygonOffset: true,\n\tside: THREE.FrontSide,\n\tdithering: true\n});\n\nexport const CONCRETE_MATERIAL = new THREE.MeshPhysicalMaterial({\n\tcolor: new THREE.Color(0xcccccc),\n\tmetalness: 0.0,\n\troughness: 0.92,\n\tenvMapIntensity: 0.15,\n\tclearcoat: 0.05,\n\tclearcoatRoughness: 0.9,\n\treflectivity: 0.15,\n\ttransmission: 0.0,\n\tior: 1.45,\n\tthickness: 0.0,\n\tdepthWrite: true,\n\ttransparent: false,\n\talphaTest: 0.5,\n\tdepthTest: true,\n\tpolygonOffset: true,\n\tside: THREE.FrontSide,\n\tdithering: true\n});\n\nexport const PLASTIC_MATERIAL = new THREE.MeshPhysicalMaterial({\n\tcolor: new THREE.Color(0xffffff), // Default white plastic\n\tmetalness: 0.0,\n\troughness: 0.3,\n\tenvMapIntensity: 0.5,\n\tclearcoat: 0.5,\n\tclearcoatRoughness: 0.1,\n\treflectivity: 0.5,\n\tior: 1.4,\n\ttransmission: 0.0,\n\ttransparent: false,\n\tdepthWrite: true,\n\tside: THREE.FrontSide,\n\tdithering: true,\n\tpolygonOffset: true,\n\tpolygonOffsetFactor: 1,\n\tpolygonOffsetUnits: 1\n});\n\nexport const GLASS_MATERIAL = new THREE.MeshPhysicalMaterial({\n\tcolor: new THREE.Color(0xffffff),\n\tmetalness: 0.0,\n\troughness: 0.0,\n\ttransmission: 0.95,\n\ttransparent: true,\n\topacity: 0.3,\n\tenvMapIntensity: 1.0,\n\tclearcoat: 1.0,\n\tclearcoatRoughness: 0.0,\n\tior: 1.52,\n\treflectivity: 0.9,\n\tthickness: 1.0,\n\tside: THREE.DoubleSide,\n\tpolygonOffset: true,\n\tpolygonOffsetFactor: 1,\n\tpolygonOffsetUnits: 1\n});\n\nexport const RUBBER_MATERIAL = new THREE.MeshPhysicalMaterial({\n\tcolor: new THREE.Color(0x1a1a1a),\n\tmetalness: 0.0,\n\troughness: 0.9,\n\tenvMapIntensity: 0.2,\n\tclearcoat: 0.1,\n\tclearcoatRoughness: 0.8,\n\treflectivity: 0.2,\n\tior: 1.3,\n\ttransmission: 0.0,\n\tdepthWrite: true,\n\tside: THREE.FrontSide,\n\tpolygonOffset: true,\n\tpolygonOffsetFactor: 1,\n\tpolygonOffsetUnits: 1\n});\n\nexport const WOOD_MATERIAL = new THREE.MeshPhysicalMaterial({\n\tcolor: new THREE.Color(0x885533),\n\tmetalness: 0.0,\n\troughness: 0.7,\n\tenvMapIntensity: 0.3,\n\tclearcoat: 0.3,\n\tclearcoatRoughness: 0.4,\n\treflectivity: 0.3,\n\tior: 1.3,\n\ttransmission: 0.0,\n\tdepthWrite: true,\n\tside: THREE.FrontSide,\n\tdithering: true,\n\tpolygonOffset: true,\n\tpolygonOffsetFactor: 1,\n\tpolygonOffsetUnits: 1\n});\n","import { decodeBase64ToBinary } from '@/core/utils/encoding';\nimport { RhinoComputeError, ErrorCodes } from '@/core/errors';\n\nimport type { MaterialGroup, SerializableMaterial } from './types';\n\n// ============================================================================\n// WIRE FORMAT CONSTANTS\n// ============================================================================\n\n/** \"SLVA\" little-endian. */\nexport const BINARY_MESH_MAGIC = 0x41564c53;\n/** Bumped on any wire-layout change. */\nexport const BINARY_MESH_VERSION = 1;\n/** Bit 0 of the geometry flags word: 0 = int16 quantized, 1 = float32 raw. */\nexport const FLAG_FLOAT32 = 0x1;\n\nconst HEADER_PREAMBLE_BYTES = 4 /* magic */ + 4 /* version */ + 4; /* metadataLen */\nconst GEOMETRY_HEADER_BYTES =\n\t4 /* flags */ + 24 /* origin (3 x f64) */ + 24 /* scale (3 x f64) */ + 4; /* vertexCount */\n\n// ============================================================================\n// PARSED TYPES\n// ============================================================================\n\n/**\n * Metadata JSON embedded inside the binary blob.\n *\n * This is the same shape as a `MeshBatch` minus the `compressedData` field (the blob is opaque to\n * its own metadata header). Kept separate from the public `MeshBatch` type because the blob's\n * metadata never carries `compressedData` itself — it would be circular.\n */\nexport interface BinaryMeshMetadata {\n\tmaterials: SerializableMaterial[];\n\tgroups: MaterialGroup[];\n\tsourceComponentId?: string;\n}\n\n/**\n * Result of parsing a binary mesh blob.\n *\n * `vertices` and `indices` are typed-array views over the original `ArrayBuffer` — zero copies.\n * The consumer is responsible for not mutating the underlying buffer if it cares about safety,\n * or for calling `.slice()` to detach.\n */\nexport interface ParsedBinaryMeshBatch {\n\tmetadata: BinaryMeshMetadata;\n\tflags: number;\n\tvertices: Int16Array | Float32Array;\n\tindices: Uint32Array;\n\torigin: [number, number, number];\n\tscale: [number, number, number];\n}\n\n// ============================================================================\n// PARSER\n// ============================================================================\n\n/**\n * Parses a binary mesh batch blob in the SLVA wire format.\n *\n * The blob layout is:\n * ```\n * [4] magic = \"SLVA\" (0x53 0x4C 0x56 0x41)\n * [4] version = uint32 (currently 1)\n * [4] metadataLen = uint32 byte length of UTF-8 metadata JSON\n * [N] metadata = UTF-8 JSON (materials, groups, sourceComponentId, ...)\n * [4] flags = uint32 (bit 0: 0 = int16 quantized, 1 = float32 raw)\n * [24] origin = 3 x float64\n * [24] scale = 3 x float64 (step per int16 unit; identity for float32)\n * [4] vertexCount = uint32 number of vertices (positions = vertexCount * 3 components)\n * [V] vertices = int16[vertexCount*3] OR float32[vertexCount*3]\n * [4] indexCount = uint32 number of indices\n * [I] indices = uint32[indexCount]\n * ```\n *\n * For int16 vertices: world position = `origin + (q + 32767) * scale`. This matches Three.js\n * `BufferAttribute(arr, 3, true)` (`normalized: true`) semantics when the per-mesh transform\n * encodes `origin + scale`.\n *\n * For float32: `origin = (0, 0, 0)`, `scale = (1, 1, 1)`, vertices are raw world positions.\n *\n * @param input - The blob, as either an `ArrayBuffer`/`Uint8Array` (binary transport) or a\n * base64-encoded string (today's JSON-envelope transport).\n * @returns Decoded metadata plus typed-array views into the geometry payload.\n * @throws {RhinoComputeError} On invalid magic, unknown version, or truncated input.\n */\nexport function parseBinaryMeshBatch(\n\tinput: ArrayBuffer | Uint8Array | string\n): ParsedBinaryMeshBatch {\n\tconst bytes = toUint8Array(input);\n\tconst view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);\n\n\tif (bytes.byteLength < HEADER_PREAMBLE_BYTES) {\n\t\tthrow fail('Blob too small to contain SLVA header.', {\n\t\t\texpectedBytes: HEADER_PREAMBLE_BYTES,\n\t\t\tavailableBytes: bytes.byteLength\n\t\t});\n\t}\n\n\tlet offset = 0;\n\n\tconst magic = view.getUint32(offset, true);\n\toffset += 4;\n\tif (magic !== BINARY_MESH_MAGIC) {\n\t\tthrow fail(`Invalid SLVA magic: 0x${magic.toString(16)}`, {\n\t\t\texpectedMagic: `0x${BINARY_MESH_MAGIC.toString(16)}`,\n\t\t\tactualMagic: `0x${magic.toString(16)}`\n\t\t});\n\t}\n\n\tconst version = view.getUint32(offset, true);\n\toffset += 4;\n\tif (version !== BINARY_MESH_VERSION) {\n\t\tthrow fail(`Unsupported SLVA version: ${version}`, {\n\t\t\texpectedVersion: BINARY_MESH_VERSION,\n\t\t\tactualVersion: version\n\t\t});\n\t}\n\n\tconst metadataLen = view.getUint32(offset, true);\n\toffset += 4;\n\tif (offset + metadataLen > bytes.byteLength) {\n\t\tthrow fail('Insufficient data to read metadata JSON.', {\n\t\t\texpectedBytes: metadataLen,\n\t\t\tavailableBytes: bytes.byteLength - offset,\n\t\t\toffset\n\t\t});\n\t}\n\n\tconst metadataBytes = bytes.subarray(offset, offset + metadataLen);\n\toffset += metadataLen;\n\n\tlet metadata: BinaryMeshMetadata;\n\ttry {\n\t\tmetadata = JSON.parse(decodeUtf8(metadataBytes)) as BinaryMeshMetadata;\n\t} catch (error) {\n\t\tthrow fail(\n\t\t\t`Failed to parse metadata JSON: ${error instanceof Error ? error.message : String(error)}`,\n\t\t\t{ metadataLen }\n\t\t);\n\t}\n\n\tif (offset + GEOMETRY_HEADER_BYTES > bytes.byteLength) {\n\t\tthrow fail('Insufficient data to read geometry header.', {\n\t\t\texpectedBytes: GEOMETRY_HEADER_BYTES,\n\t\t\tavailableBytes: bytes.byteLength - offset,\n\t\t\toffset\n\t\t});\n\t}\n\n\tconst flags = view.getUint32(offset, true);\n\toffset += 4;\n\n\tconst originX = view.getFloat64(offset, true);\n\toffset += 8;\n\tconst originY = view.getFloat64(offset, true);\n\toffset += 8;\n\tconst originZ = view.getFloat64(offset, true);\n\toffset += 8;\n\n\tconst scaleX = view.getFloat64(offset, true);\n\toffset += 8;\n\tconst scaleY = view.getFloat64(offset, true);\n\toffset += 8;\n\tconst scaleZ = view.getFloat64(offset, true);\n\toffset += 8;\n\n\tconst vertexCount = view.getUint32(offset, true);\n\toffset += 4;\n\n\tconst useFloat32 = (flags & FLAG_FLOAT32) !== 0;\n\tconst componentCount = vertexCount * 3;\n\tconst bytesPerComponent = useFloat32 ? 4 : 2;\n\tconst verticesByteLength = componentCount * bytesPerComponent;\n\n\tif (offset + verticesByteLength > bytes.byteLength) {\n\t\tthrow fail('Insufficient data to read vertices.', {\n\t\t\texpectedBytes: verticesByteLength,\n\t\t\tavailableBytes: bytes.byteLength - offset,\n\t\t\toffset,\n\t\t\tuseFloat32,\n\t\t\tvertexCount\n\t\t});\n\t}\n\n\t// Typed-array views require alignment to the element size. The header lays out the geometry\n\t// block such that the vertex byte offset is always 4-aligned (preamble 12 + metadataLen + 4 +\n\t// 48 + 4). float32 needs 4-byte alignment (satisfied), int16 needs 2-byte alignment\n\t// (satisfied). We can take a zero-copy view as long as `bytes.byteOffset + offset` agrees with\n\t// that alignment in the underlying buffer — a wrapper Uint8Array could violate it. Fall back\n\t// to a fresh copy if so.\n\tconst absoluteOffset = bytes.byteOffset + offset;\n\tconst verticesView = useFloat32\n\t\t? readFloat32Vertices(bytes.buffer, absoluteOffset, componentCount)\n\t\t: readInt16Vertices(bytes.buffer, absoluteOffset, componentCount);\n\toffset += verticesByteLength;\n\n\tif (offset + 4 > bytes.byteLength) {\n\t\tthrow fail('Insufficient data to read index count.', {\n\t\t\texpectedBytes: 4,\n\t\t\tavailableBytes: bytes.byteLength - offset,\n\t\t\toffset\n\t\t});\n\t}\n\tconst indexCount = view.getUint32(offset, true);\n\toffset += 4;\n\n\tconst indicesByteLength = indexCount * 4;\n\tif (offset + indicesByteLength > bytes.byteLength) {\n\t\tthrow fail('Insufficient data to read indices.', {\n\t\t\texpectedBytes: indicesByteLength,\n\t\t\tavailableBytes: bytes.byteLength - offset,\n\t\t\toffset,\n\t\t\tindexCount\n\t\t});\n\t}\n\n\tconst indicesView = readUint32Indices(bytes.buffer, bytes.byteOffset + offset, indexCount);\n\n\treturn {\n\t\tmetadata,\n\t\tflags,\n\t\tvertices: verticesView,\n\t\tindices: indicesView,\n\t\torigin: [originX, originY, originZ],\n\t\tscale: [scaleX, scaleY, scaleZ]\n\t};\n}\n\n// ============================================================================\n// HELPERS\n// ============================================================================\n\nfunction toUint8Array(input: ArrayBuffer | Uint8Array | string): Uint8Array {\n\tif (typeof input === 'string') {\n\t\treturn decodeBase64ToBinary(input);\n\t}\n\tif (input instanceof Uint8Array) {\n\t\treturn input;\n\t}\n\treturn new Uint8Array(input);\n}\n\nfunction decodeUtf8(bytes: Uint8Array): string {\n\tif (typeof TextDecoder !== 'undefined') {\n\t\treturn new TextDecoder('utf-8').decode(bytes);\n\t}\n\t// Node fallback (Buffer is utf-8 by default).\n\tif (\n\t\ttypeof (globalThis as { Buffer?: { from(b: Uint8Array): { toString(enc: string): string } } })\n\t\t\t.Buffer !== 'undefined'\n\t) {\n\t\treturn (\n\t\t\tglobalThis as { Buffer: { from(b: Uint8Array): { toString(enc: string): string } } }\n\t\t).Buffer.from(bytes).toString('utf-8');\n\t}\n\tthrow new RhinoComputeError(\n\t\t'No UTF-8 decoder available in this environment.',\n\t\tErrorCodes.INVALID_STATE\n\t);\n}\n\nfunction readInt16Vertices(buffer: ArrayBufferLike, byteOffset: number, count: number): Int16Array {\n\tif (count === 0) return new Int16Array(0);\n\tif (byteOffset % 2 === 0) {\n\t\treturn new Int16Array(buffer, byteOffset, count);\n\t}\n\t// Misaligned (rare — would require a wrapper Uint8Array with odd byteOffset).\n\tconst copy = new Uint8Array(count * 2);\n\tcopy.set(new Uint8Array(buffer, byteOffset, count * 2));\n\treturn new Int16Array(copy.buffer);\n}\n\nfunction readFloat32Vertices(\n\tbuffer: ArrayBufferLike,\n\tbyteOffset: number,\n\tcount: number\n): Float32Array {\n\tif (count === 0) return new Float32Array(0);\n\tif (byteOffset % 4 === 0) {\n\t\treturn new Float32Array(buffer, byteOffset, count);\n\t}\n\tconst copy = new Uint8Array(count * 4);\n\tcopy.set(new Uint8Array(buffer, byteOffset, count * 4));\n\treturn new Float32Array(copy.buffer);\n}\n\nfunction readUint32Indices(\n\tbuffer: ArrayBufferLike,\n\tbyteOffset: number,\n\tcount: number\n): Uint32Array {\n\tif (count === 0) return new Uint32Array(0);\n\tif (byteOffset % 4 === 0) {\n\t\treturn new Uint32Array(buffer, byteOffset, count);\n\t}\n\tconst copy = new Uint8Array(count * 4);\n\tcopy.set(new Uint8Array(buffer, byteOffset, count * 4));\n\treturn new Uint32Array(copy.buffer);\n}\n\nfunction fail(message: string, context: Record<string, unknown>): RhinoComputeError {\n\treturn new RhinoComputeError(message, ErrorCodes.VALIDATION_ERROR, { context });\n}\n","import * as THREE from 'three';\n\nimport { parseColor } from '../threejs/three-helpers';\nimport { getLogger } from '@/core';\n\nimport { FLAG_FLOAT32, parseBinaryMeshBatch } from './binary-parser';\n\nimport type { MeshBatch, MaterialGroup, SerializableMaterial } from './types';\n\n/**\n * Parses a batched mesh JSON and creates Three.js meshes.\n *\n * The geometry payload is the binary \"SLVA\" blob produced by the C# `BinaryGeometryWriter`,\n * base64-encoded into the outer JSON envelope. We `JSON.parse` the small envelope, then hand the\n * blob to `parseBinaryMeshBatch` which decodes the geometry without ever turning it into a string.\n *\n * @param batchJson - JSON string containing the batched mesh data\n * @param options - Rendering options\n * @returns Promise resolving to array of Three.js mesh objects\n */\nexport async function parseMeshBatch(\n\tbatchJson: string,\n\toptions?: {\n\t\t/** Merge meshes with same material into single geometry*/\n\t\tmergeByMaterial?: boolean;\n\t\t/** Apply coordinate system transformations */\n\t\tapplyTransforms?: boolean;\n\t\t/** Enable performance monitoring */\n\t\tdebug?: boolean;\n\t}\n): Promise<THREE.Mesh[]> {\n\tconst { mergeByMaterial = true, applyTransforms = true, debug = false } = options ?? {};\n\n\tconst perfStart = debug ? performance.now() : 0;\n\tlet parseTime = 0;\n\n\ttry {\n\t\tconst parseStart = performance.now();\n\t\tconst batch: MeshBatch = JSON.parse(batchJson);\n\t\tparseTime = performance.now() - parseStart;\n\n\t\treturn await parseMeshBatchObject(batch, {\n\t\t\tmergeByMaterial,\n\t\t\tapplyTransforms,\n\t\t\tdebug,\n\t\t\tparseTime,\n\t\t\tperfStart\n\t\t});\n\t} catch (error) {\n\t\tgetLogger().error('Error parsing mesh batch:', error);\n\t\treturn [];\n\t}\n}\n\n/**\n * Parses a MeshBatch object and creates Three.js meshes.\n *\n * The path is synchronous internally — `parseBinaryMeshBatch` does no IO, just typed-array views\n * over the blob. The function stays `async` so callers don't have to change shape if we move\n * parsing into a worker later.\n *\n * @param batch - MeshBatch object\n * @param options - Rendering options\n * @returns Promise resolving to array of Three.js mesh objects\n */\nexport async function parseMeshBatchObject(\n\tbatch: MeshBatch,\n\toptions?: {\n\t\t/** Merge meshes with same material into single geometry*/\n\t\tmergeByMaterial?: boolean;\n\t\t/** Apply coordinate system transformations */\n\t\tapplyTransforms?: boolean;\n\t\t/** Scale factor to apply to meshes (e.g., for unit conversion) */\n\t\tscaleFactor?: number;\n\t\t/** Enable performance monitoring */\n\t\tdebug?: boolean;\n\t\t/** Parse time (optional, for debugging) */\n\t\tparseTime?: number;\n\t\t/** Performance start time (optional, for debugging) */\n\t\tperfStart?: number;\n\t}\n): Promise<THREE.Mesh[]> {\n\tconst {\n\t\tmergeByMaterial = true,\n\t\tapplyTransforms = true,\n\t\tscaleFactor = 1,\n\t\tdebug = false,\n\t\tparseTime = 0,\n\t\tperfStart = debug ? performance.now() : 0\n\t} = options ?? {};\n\n\tlet decodeTime = 0;\n\tlet meshCreateTime = 0;\n\n\ttry {\n\t\tconst decodeStart = performance.now();\n\t\tconst parsed = parseBinaryMeshBatch(batch.compressedData);\n\t\tdecodeTime = performance.now() - decodeStart;\n\n\t\t// Prefer materials/groups from the blob's embedded metadata — that's the source of truth\n\t\t// the C# writer emits. Fall back to the outer envelope for resilience (e.g. if a future\n\t\t// transport drops them from the blob's metadata to save bytes).\n\t\tconst materialsSrc = parsed.metadata.materials ?? batch.materials;\n\t\tconst groups = parsed.metadata.groups ?? batch.groups;\n\t\tconst sourceComponentId = parsed.metadata.sourceComponentId ?? batch.sourceComponentId;\n\n\t\tconst isFloat32 = (parsed.flags & FLAG_FLOAT32) !== 0;\n\n\t\t// Dequantize once up-front into a single Float32Array. Downstream code (per-group merging,\n\t\t// computeVertexNormals, ground-offset, scaleFactor) all expect world-unit floats, and a\n\t\t// single linear pass over the int16 buffer is far cheaper than the legacy gunzip + base64\n\t\t// path. The Z-up -> Y-up rotation, when requested, is folded into the same pass.\n\t\tconst worldVertices = isFloat32\n\t\t\t? maybeRotateFloat32Vertices(parsed.vertices as Float32Array, applyTransforms)\n\t\t\t: dequantizeInt16(\n\t\t\t\t\tparsed.vertices as Int16Array,\n\t\t\t\t\tparsed.origin,\n\t\t\t\t\tparsed.scale,\n\t\t\t\t\tapplyTransforms\n\t\t\t\t);\n\n\t\tif (debug) {\n\t\t\tconst blobBytes = approximateBase64DecodedBytes(batch.compressedData);\n\t\t\tconst wireBytes = parsed.vertices.byteLength + parsed.indices.byteLength;\n\t\t\tgetLogger().debug('Mesh Batch Stats:');\n\t\t\tgetLogger().debug(` Materials: ${materialsSrc.length} | Groups: ${groups.length}`);\n\t\t\tgetLogger().debug(\n\t\t\t\t` Vertices: ${parsed.vertices.length / 3} | Indices: ${parsed.indices.length}`\n\t\t\t);\n\t\t\tgetLogger().debug(` Format: ${isFloat32 ? 'float32' : 'int16 quantized'}`);\n\t\t\tgetLogger().debug(\n\t\t\t\t` Blob: ${(blobBytes / 1024 / 1024).toFixed(2)} MB | Geometry on wire: ${(wireBytes / 1024 / 1024).toFixed(2)} MB`\n\t\t\t);\n\t\t}\n\n\t\tconst meshCreateStart = performance.now();\n\t\tconst materials = materialsSrc.map(createMaterial);\n\n\t\tconst meshes: THREE.Mesh[] = [];\n\n\t\tfor (const group of groups) {\n\t\t\tif (mergeByMaterial && group.meshes.length > 1) {\n\t\t\t\tconst mergedMesh = createMergedMesh(group, worldVertices, parsed.indices, materials);\n\t\t\t\tmergedMesh.userData.sourceComponentId = sourceComponentId ?? null;\n\t\t\t\tmeshes.push(mergedMesh);\n\t\t\t} else {\n\t\t\t\tconst individualMeshes = createIndividualMeshes(\n\t\t\t\t\tgroup,\n\t\t\t\t\tworldVertices,\n\t\t\t\t\tparsed.indices,\n\t\t\t\t\tmaterials\n\t\t\t\t);\n\t\t\t\tfor (const mesh of individualMeshes) {\n\t\t\t\t\tmesh.userData.sourceComponentId = sourceComponentId ?? null;\n\t\t\t\t}\n\t\t\t\tmeshes.push(...individualMeshes);\n\t\t\t}\n\t\t}\n\n\t\tif (scaleFactor !== 1) {\n\t\t\tfor (const mesh of meshes) {\n\t\t\t\tmesh.scale.set(scaleFactor, scaleFactor, scaleFactor);\n\t\t\t}\n\t\t}\n\n\t\tmeshCreateTime = performance.now() - meshCreateStart;\n\n\t\tif (debug) {\n\t\t\tconst totalTime = performance.now() - perfStart;\n\t\t\tgetLogger().debug('Performance:');\n\t\t\tif (parseTime > 0) getLogger().debug(` Parse JSON: ${parseTime.toFixed(2)}ms`);\n\t\t\tgetLogger().debug(` Decode binary: ${decodeTime.toFixed(2)}ms`);\n\t\t\tgetLogger().debug(` Create Meshes: ${meshCreateTime.toFixed(2)}ms`);\n\t\t\tgetLogger().debug(` Total: ${totalTime.toFixed(2)}ms`);\n\t\t}\n\n\t\treturn meshes;\n\t} catch (error) {\n\t\tgetLogger().error('Error parsing mesh batch object:', error);\n\t\treturn [];\n\t}\n}\n\n// ============================================================================\n// DEQUANTIZATION\n// ============================================================================\n\n/**\n * Reconstructs world-unit float32 positions from int16 quantized values.\n *\n * Mirrors the encoder formula: `world = origin + (q + 32767) * scale`. When\n * `applyCoordinateTransform=true` we fold the Rhino Z-up -> Three Y-up shuffle into the same pass\n * (`(x, y, z) -> (x, z, -y)`), saving a second walk over the buffer.\n */\nfunction dequantizeInt16(\n\tq: Int16Array,\n\torigin: [number, number, number],\n\tscale: [number, number, number],\n\tapplyCoordinateTransform: boolean\n): Float32Array {\n\tconst out = new Float32Array(q.length);\n\tconst ox = origin[0];\n\tconst oy = origin[1];\n\tconst oz = origin[2];\n\tconst sx = scale[0];\n\tconst sy = scale[1];\n\tconst sz = scale[2];\n\n\tif (applyCoordinateTransform) {\n\t\t// Rotate -90 deg around X: (x, y, z) -> (x, z, -y)\n\t\tfor (let i = 0; i < q.length; i += 3) {\n\t\t\tconst wx = ox + (q[i]! + 32767) * sx;\n\t\t\tconst wy = oy + (q[i + 1]! + 32767) * sy;\n\t\t\tconst wz = oz + (q[i + 2]! + 32767) * sz;\n\t\t\tout[i] = wx;\n\t\t\tout[i + 1] = wz;\n\t\t\tout[i + 2] = -wy;\n\t\t}\n\t} else {\n\t\tfor (let i = 0; i < q.length; i += 3) {\n\t\t\tout[i] = ox + (q[i]! + 32767) * sx;\n\t\t\tout[i + 1] = oy + (q[i + 1]! + 32767) * sy;\n\t\t\tout[i + 2] = oz + (q[i + 2]! + 32767) * sz;\n\t\t}\n\t}\n\n\treturn out;\n}\n\n/**\n * For float32 batches: when no transform is needed we can pass through the parser's view; the\n * caller doesn't mutate it. When the rotation is needed we have to allocate.\n */\nfunction maybeRotateFloat32Vertices(\n\tvertices: Float32Array,\n\tapplyCoordinateTransform: boolean\n): Float32Array {\n\tif (!applyCoordinateTransform) return vertices;\n\n\tconst out = new Float32Array(vertices.length);\n\tfor (let i = 0; i < vertices.length; i += 3) {\n\t\tconst x = vertices[i]!;\n\t\tconst y = vertices[i + 1]!;\n\t\tconst z = vertices[i + 2]!;\n\t\tout[i] = x;\n\t\tout[i + 1] = z;\n\t\tout[i + 2] = -y;\n\t}\n\treturn out;\n}\n\n// ============================================================================\n// MATERIAL CONSTRUCTION\n// ============================================================================\n\nfunction createMaterial(matData: SerializableMaterial): THREE.MeshPhysicalMaterial {\n\tconst color = parseColor(matData.color);\n\n\treturn new THREE.MeshPhysicalMaterial({\n\t\tcolor,\n\t\tmetalness: matData.metalness,\n\t\troughness: matData.roughness,\n\t\topacity: matData.opacity,\n\t\ttransparent: matData.transparent,\n\t\tside: THREE.DoubleSide,\n\t\t// Reduced polygon offset to minimize artifacts\n\t\t// Only use minimal offset to prevent z-fighting on coplanar faces\n\t\tpolygonOffset: true,\n\t\tpolygonOffsetFactor: 0.5,\n\t\tpolygonOffsetUnits: 0.5,\n\t\t// Improve depth rendering\n\t\tdepthWrite: true,\n\t\tdepthTest: true\n\t});\n}\n\n// ============================================================================\n// MESH CONSTRUCTION\n// ============================================================================\n\n/**\n * Creates a merged mesh from multiple meshes sharing the same material.\n *\n * Indices in the parser output already reference offsets into the combined vertex array (the C#\n * pipeline rebases per-mesh local indices into combined-array indices when assembling the batch).\n * For merged meshes we copy the relevant slices into a fresh contiguous buffer and shift indices\n * to match the new layout.\n */\nfunction createMergedMesh(\n\tgroup: MaterialGroup,\n\tallVertices: Float32Array,\n\tallIndices: Uint32Array,\n\tmaterials: THREE.Material[]\n): THREE.Mesh {\n\tlet totalVertexCount = 0;\n\tlet totalIndexCount = 0;\n\tfor (const meshMeta of group.meshes) {\n\t\ttotalVertexCount += meshMeta.vertexCount;\n\t\ttotalIndexCount += meshMeta.indexCount;\n\t}\n\n\tconst mergedVertices = new Float32Array(totalVertexCount * 3);\n\tconst mergedIndices = new Uint32Array(totalIndexCount);\n\n\tlet vertexWriteCursor = 0;\n\tlet indexWriteCursor = 0;\n\n\tfor (const meshMeta of group.meshes) {\n\t\tconst componentStart = meshMeta.vertexStart * 3;\n\t\tconst componentLen = meshMeta.vertexCount * 3;\n\t\tmergedVertices.set(\n\t\t\tallVertices.subarray(componentStart, componentStart + componentLen),\n\t\t\tvertexWriteCursor * 3\n\t\t);\n\n\t\tconst indicesSlice = allIndices.subarray(\n\t\t\tmeshMeta.indexStart,\n\t\t\tmeshMeta.indexStart + meshMeta.indexCount\n\t\t);\n\t\tconst indexShift = vertexWriteCursor - meshMeta.vertexStart;\n\t\tif (indexShift === 0) {\n\t\t\tmergedIndices.set(indicesSlice, indexWriteCursor);\n\t\t} else {\n\t\t\tfor (let i = 0; i < indicesSlice.length; i++) {\n\t\t\t\tmergedIndices[indexWriteCursor + i] = indicesSlice[i]! + indexShift;\n\t\t\t}\n\t\t}\n\n\t\tvertexWriteCursor += meshMeta.vertexCount;\n\t\tindexWriteCursor += meshMeta.indexCount;\n\t}\n\n\tconst geometry = new THREE.BufferGeometry();\n\tgeometry.setAttribute('position', new THREE.BufferAttribute(mergedVertices, 3));\n\tgeometry.setIndex(new THREE.BufferAttribute(mergedIndices, 1));\n\tgeometry.computeVertexNormals();\n\n\tconst threeMesh = new THREE.Mesh(geometry, materials[group.materialId]);\n\tconst firstMesh = group.meshes[0];\n\tconst meshNames = group.meshes.map((m) => m.name).filter((name) => name && name.length > 0);\n\tthreeMesh.name = meshNames.length > 0 ? meshNames[0]! : `merged_material_${group.materialId}`;\n\tthreeMesh.castShadow = true;\n\tthreeMesh.receiveShadow = true;\n\n\tthreeMesh.userData = {\n\t\tname: threeMesh.name,\n\t\tlayer: firstMesh?.layer ?? '',\n\t\toriginalIndex: firstMesh?.originalIndex ?? 0,\n\t\tmetadata: firstMesh?.metadata ?? {},\n\t\tmergedFrom: group.meshes.slice(1).map((m) => ({\n\t\t\tname: m.name,\n\t\t\tlayer: m.layer,\n\t\t\toriginalIndex: m.originalIndex\n\t\t}))\n\t};\n\n\treturn threeMesh;\n}\n\n/**\n * Creates individual meshes from a material group. Each mesh's indices are rebased so they\n * address its own local vertex slice starting from 0.\n */\nfunction createIndividualMeshes(\n\tgroup: MaterialGroup,\n\tallVertices: Float32Array,\n\tallIndices: Uint32Array,\n\tmaterials: THREE.Material[]\n): THREE.Mesh[] {\n\tconst meshes: THREE.Mesh[] = [];\n\n\tfor (const meshMeta of group.meshes) {\n\t\tconst componentStart = meshMeta.vertexStart * 3;\n\t\tconst componentLen = meshMeta.vertexCount * 3;\n\n\t\t// `subarray` returns a view; copy via `slice` so the BufferAttribute owns its memory and\n\t\t// downstream code (dispose/reuse) can't surprise us by sharing the parser's buffer.\n\t\tconst vertices = allVertices.slice(componentStart, componentStart + componentLen);\n\n\t\tconst indicesSlice = allIndices.subarray(\n\t\t\tmeshMeta.indexStart,\n\t\t\tmeshMeta.indexStart + meshMeta.indexCount\n\t\t);\n\t\tconst rebasedIndices = new Uint32Array(indicesSlice.length);\n\t\tconst baseIndex = meshMeta.vertexStart;\n\t\tfor (let i = 0; i < indicesSlice.length; i++) {\n\t\t\trebasedIndices[i] = indicesSlice[i]! - baseIndex;\n\t\t}\n\n\t\tconst geometry = new THREE.BufferGeometry();\n\t\tgeometry.setAttribute('position', new THREE.BufferAttribute(vertices, 3));\n\t\tgeometry.setIndex(new THREE.BufferAttribute(rebasedIndices, 1));\n\t\tgeometry.computeVertexNormals();\n\n\t\tconst mesh = new THREE.Mesh(geometry, materials[group.materialId]);\n\t\tmesh.name = meshMeta.name;\n\t\tmesh.userData = {\n\t\t\tname: meshMeta.name,\n\t\t\tlayer: meshMeta.layer ?? '',\n\t\t\toriginalIndex: meshMeta.originalIndex,\n\t\t\tmetadata: meshMeta.metadata ?? {}\n\t\t};\n\t\tmesh.castShadow = true;\n\t\tmesh.receiveShadow = true;\n\n\t\tmeshes.push(mesh);\n\t}\n\n\treturn meshes;\n}\n\n// ============================================================================\n// DEBUG HELPERS\n// ============================================================================\n\nfunction approximateBase64DecodedBytes(base64: string): number {\n\treturn Math.floor((base64.length * 3) / 4);\n}\n","import * as THREE from 'three';\n\nimport { applyOffset, computeCombinedBoundingBox } from '../threejs/three-helpers.js';\nimport { getLogger } from '@/core';\n\nimport { parseMeshBatch } from './batch-parser';\n\nimport type { DataItem, GrasshopperComputeResponse } from '@/features/grasshopper/types';\nimport type { MeshExtractionOptions, MeshBatchParsingOptions } from './types';\n\n// Constants\nexport const SCALE_FACTORS: Record<string, number> = {\n\tMillimeters: 1 / 1000,\n\tCentimeters: 1 / 100,\n\tMeters: 1,\n\tInches: 1 / 39.37,\n\tFeet: 1 / 3.28084\n};\n\nconst DISPLAY_COMPONENT_TYPE = 'Display';\n\n/**\n * Extracts and processes display meshes from a ComputePointerResponse using the Grasshopper WebDisplay component.\n *\n * This is the primary entry point for extracting mesh geometry from Grasshopper compute responses.\n * It handles all aspects of mesh processing: decompression, coordinate transformation, scaling, and positioning.\n *\n * **Note:** Mesh decompression happens asynchronously in a Web Worker to prevent UI blocking.\n *\n * @param data - The ComputePointerResponse containing Grasshopper output trees.\n * @param options - Configuration for mesh extraction and parsing behavior. All options are optional with sensible defaults.\n * @returns Promise resolving to array of THREE.Mesh objects (may be empty).\n * @throws Rethrows unexpected errors after attempting to dispose any created meshes.\n *\n * @remarks\n * - Only works with the WebDisplay component of GHHeadless.\n * - Requires changes to Rhino.Compute (see https://github.com/TheVessen/compute.rhino3d).\n * - Provides a performant way to display mesh data in Three.js.\n * - Decompression is performed in a Web Worker for non-blocking UI updates.\n * - Supports mesh metadata (names, user data) if provided in the compute response.\n *\n * @internal Internal helper: high-level extraction remains public via visualization module, but this\n * function is considered internal implementation detail for mesh extraction.\n *\n * @example\n * ```ts\n * // Simple usage with defaults (all processing enabled)\n * const meshes = await getThreeMeshesFromComputeResponse(response);\n *\n * // With debugging enabled\n * const meshes = await getThreeMeshesFromComputeResponse(response, { debug: true });\n *\n * // With advanced options\n * const meshes = await getThreeMeshesFromComputeResponse(response, {\n * debug: true,\n * allowScaling: true,\n * allowAutoPosition: false,\n * parsing: {\n * mergeByMaterial: false,\n * applyTransforms: true,\n * debug: true,\n * },\n * });\n * ```\n */\nexport async function getThreeMeshesFromComputeResponse(\n\tdata: GrasshopperComputeResponse,\n\toptions?: MeshExtractionOptions\n): Promise<THREE.Mesh[]> {\n\tconst startTime = performance.now();\n\tconst meshes: THREE.Mesh[] = [];\n\n\tconst {\n\t\tallowScaling = true,\n\t\tallowAutoPosition = true,\n\t\tdebug = false,\n\t\tparsing: parsingOptions = {}\n\t} = options ?? {};\n\n\ttry {\n\t\tconst scaleFactor = allowScaling ? getScaleFactor(data.modelunits) : 1;\n\t\tawait extractMeshesFromData(data, meshes, scaleFactor, parsingOptions, debug);\n\n\t\tif (allowAutoPosition) {\n\t\t\tapplyGroundOffset(meshes);\n\t\t}\n\n\t\treturn meshes;\n\t} catch (error) {\n\t\thandleError(error, meshes);\n\t\tthrow error;\n\t} finally {\n\t\tif (debug) {\n\t\t\tlogProcessingTime(startTime);\n\t\t}\n\t}\n}\n\n/**\n * Gets the scale factor for the given unit type.\n */\nfunction getScaleFactor(modelUnits: string): number {\n\treturn SCALE_FACTORS[modelUnits] ?? 1;\n}\n\n/**\n * Extracts meshes from compute response data.\n */\nasync function extractMeshesFromData(\n\tdata: GrasshopperComputeResponse,\n\tmeshes: THREE.Mesh[],\n\tscaleFactor: number,\n\tparsingOptions: MeshBatchParsingOptions,\n\tdebug: boolean\n): Promise<void> {\n\tfor (const value of data.values) {\n\t\tconst innerTree = value.InnerTree as { [key: string]: DataItem[] };\n\n\t\tfor (const path in innerTree) {\n\t\t\tconst branch = innerTree[path];\n\t\t\tif (!branch) continue;\n\n\t\t\tawait processDataBranch(branch, meshes, scaleFactor, parsingOptions, debug);\n\t\t}\n\t}\n}\n\n/**\n * Processes a single data branch to extract MeshBatch display meshes.\n */\nasync function processDataBranch(\n\tbranch: DataItem[],\n\tmeshes: THREE.Mesh[],\n\tscaleFactor: number,\n\tparsingOptions: MeshBatchParsingOptions,\n\tdebug: boolean\n): Promise<void> {\n\tfor (const item of branch) {\n\t\tif (item.type.includes(DISPLAY_COMPONENT_TYPE)) {\n\t\t\tconst mergedParsingOptions = {\n\t\t\t\tmergeByMaterial: true,\n\t\t\t\tapplyTransforms: true,\n\t\t\t\tdebug: false,\n\t\t\t\t...parsingOptions\n\t\t\t};\n\n\t\t\tconst batchMeshes = await parseMeshBatch(item.data, mergedParsingOptions);\n\n\t\t\tif (scaleFactor !== 1) {\n\t\t\t\tfor (const mesh of batchMeshes) {\n\t\t\t\t\tmesh.scale.set(scaleFactor, scaleFactor, scaleFactor);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tmeshes.push(...batchMeshes);\n\n\t\t\tif (debug) {\n\t\t\t\tgetLogger().debug(`Extracted ${batchMeshes.length} meshes from batch`);\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Applies vertical offset to position meshes on the Z=0 plane.\n */\nfunction applyGroundOffset(meshes: THREE.Mesh[]): void {\n\tif (meshes.length === 0) return;\n\n\tconst combinedBoundingBox = computeCombinedBoundingBox(meshes);\n\tconst offsetY = combinedBoundingBox.min.y;\n\tapplyOffset(meshes, offsetY);\n}\n\n/**\n * Handles errors by disposing created meshes and logging.\n */\nfunction handleError(error: unknown, meshes: THREE.Mesh[]): void {\n\tgetLogger().error('An unexpected error occurred:', error);\n\tdisposeMeshes(meshes);\n}\n\n/**\n * Disposes of all meshes and their associated resources.\n */\nfunction disposeMeshes(meshes: THREE.Mesh[]): void {\n\tfor (const mesh of meshes) {\n\t\tif (mesh.geometry) {\n\t\t\tmesh.geometry.dispose();\n\t\t}\n\n\t\tif (mesh.material) {\n\t\t\tif (Array.isArray(mesh.material)) {\n\t\t\t\tmesh.material.forEach((material) => material.dispose());\n\t\t\t} else {\n\t\t\t\tmesh.material.dispose();\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Logs the processing time for mesh extraction.\n */\nfunction logProcessingTime(startTime: number): void {\n\tconst elapsed = performance.now() - startTime;\n\tgetLogger().info('Time to process meshes:', `${elapsed.toFixed(2)}ms`);\n}\n"],"mappings":"sGAAA,UAAYA,MAAW,QACvB,OAAS,iBAAAC,OAAqB,yCAC9B,OAAS,aAAAC,OAAiB,oCAK1B,IAAMC,EAAY,IAAU,UAAQ,EAAG,EAAG,CAAC,EAGrCC,EAAgB,CAACC,EAAeC,EAAeC,EAAeC,IAAyB,CAC5F,OAAQH,EAAO,CACd,IAAK,KACJ,OAAOC,EACR,IAAK,KACJ,OAAOC,EACR,QACC,OAAOC,CACT,CACD,EAKaC,GAAY,SACxBC,EACAC,EASC,CACD,IAAMC,EAASC,GAAcF,GAAW,CAAC,CAAC,EAEpCG,EAAQC,GAAYH,CAAM,EAC1BI,EAASC,GAAaL,EAAQF,CAAM,EACpCQ,EAAWC,GAAcT,EAAQE,CAAM,EACvCQ,EAAWC,GAAcL,EAAQN,EAAQE,CAAM,EAErDU,GAAiBR,EAAOF,CAAM,EAC9BW,GAAcT,EAAOF,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xC0B,EAAY1B,EAAQwB,CAAO,CAC5B,CAKA,SAASd,GAAYD,EAAgBT,EAA4B,CAChEuB,EAAU,EAAE,MAAM,gCAAiCd,CAAK,EACxDkB,GAAc3B,CAAM,CACrB,CAKA,SAAS2B,GAAc3B,EAA4B,CAClD,QAAWsB,KAAQtB,EACdsB,EAAK,UACRA,EAAK,SAAS,QAAQ,EAGnBA,EAAK,WACJ,MAAM,QAAQA,EAAK,QAAQ,EAC9BA,EAAK,SAAS,QAASM,GAAaA,EAAS,QAAQ,CAAC,EAEtDN,EAAK,SAAS,QAAQ,EAI1B,CAKA,SAASX,GAAkBZ,EAAyB,CACnD,IAAM8B,EAAU,YAAY,IAAI,EAAI9B,EACpCwB,EAAU,EAAE,KAAK,0BAA2B,GAAGM,EAAQ,QAAQ,CAAC,CAAC,IAAI,CACtE","names":["THREE","OrbitControls","HDRLoader","defaultUp","getScaleValue","scale","mmVal","cmVal","mVal","initThree","canvas","options","config","applyDefaults","scene","createScene","camera","createCamera","renderer","setupRenderer","controls","setupControls","setupEnvironment","setupLighting","addFloor","eventHandlers","setupEventHandlers","parent","getCanvasSize","animate","disposeAnimation","createAnimationLoop","sceneUp","object","material","defaults","bgColor","animateCameraTo","toPosition","toTarget","durationMs","fromPosition","fromTarget","startTime","easeOut","t","tick","elapsed","onFrame","animationId","lastTime","checkResize","width","height","pixelRatio","newW","newH","now","delta","HDRLoader","envMap","error","getLogger","ambientLight","sunlight","pos","shadowSize","shadowNear","shadowFar","floorSize","floorGeometry","floorColor","floorMaterial","floor","selectedObjects","originalMaterials","raycaster","mouse","mouseDownPosition","isFullyVisible","current","fitToView","box","center","size","maxDim","fov","distance","direction","selectionColorObj","clearSelection","obj","handleMouseDown","event","handleCanvasClick","currentMousePosition","rect","intersects","i","clickedObject","clonedMaterial","handleDoubleClick","target","targetPosition","handleKeydown","OrbitControls","THREE","CAMERA_CONFIG","updateScene","scene","meshes","camera","controls","initialPositionSet","clearScene","mesh","unionBoundingBox","computeCombinedBoundingBox","center","size","maxDim","distance","parseColor","colorString","getLogger","trimmed","hex","rgb","c","n","applyOffset","offsetY","combinedBoundingBox","bbox","object","child","material","value","three_materials_exports","__export","CONCRETE_MATERIAL","EMISSIVE_MATERIAL","GLASS_MATERIAL","METAL_MATERIAL","PLASTIC_MATERIAL","RUBBER_MATERIAL","WOOD_MATERIAL","THREE","BINARY_MESH_MAGIC","BINARY_MESH_VERSION","FLAG_FLOAT32","HEADER_PREAMBLE_BYTES","GEOMETRY_HEADER_BYTES","parseBinaryMeshBatch","input","bytes","toUint8Array","view","fail","offset","magic","version","metadataLen","metadataBytes","metadata","decodeUtf8","error","flags","originX","originY","originZ","scaleX","scaleY","scaleZ","vertexCount","useFloat32","componentCount","verticesByteLength","absoluteOffset","verticesView","readFloat32Vertices","readInt16Vertices","indexCount","indicesByteLength","indicesView","readUint32Indices","decodeBase64ToBinary","RhinoComputeError","ErrorCodes","buffer","byteOffset","count","copy","message","context","THREE","parseMeshBatch","batchJson","options","mergeByMaterial","applyTransforms","debug","perfStart","parseTime","parseStart","batch","parseMeshBatchObject","error","getLogger","scaleFactor","decodeTime","meshCreateTime","decodeStart","parsed","parseBinaryMeshBatch","materialsSrc","groups","sourceComponentId","isFloat32","FLAG_FLOAT32","worldVertices","maybeRotateFloat32Vertices","dequantizeInt16","blobBytes","approximateBase64DecodedBytes","wireBytes","meshCreateStart","materials","createMaterial","meshes","group","mergedMesh","createMergedMesh","individualMeshes","createIndividualMeshes","mesh","totalTime","q","origin","scale","applyCoordinateTransform","out","ox","oy","oz","sx","sy","sz","i","wx","wy","wz","vertices","x","y","z","matData","color","parseColor","allVertices","allIndices","totalVertexCount","totalIndexCount","meshMeta","mergedVertices","mergedIndices","vertexWriteCursor","indexWriteCursor","componentStart","componentLen","indicesSlice","indexShift","geometry","threeMesh","firstMesh","meshNames","m","name","rebasedIndices","baseIndex","base64","SCALE_FACTORS","DISPLAY_COMPONENT_TYPE","getThreeMeshesFromComputeResponse","data","options","startTime","meshes","allowScaling","allowAutoPosition","debug","parsingOptions","scaleFactor","getScaleFactor","extractMeshesFromData","applyGroundOffset","error","handleError","logProcessingTime","modelUnits","value","innerTree","path","branch","processDataBranch","item","mergedParsingOptions","batchMeshes","parseMeshBatch","mesh","getLogger","offsetY","computeCombinedBoundingBox","applyOffset","disposeMeshes","material","elapsed"]}
|
package/dist/chunk-DSI6FKBA.cjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
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 _chunkMZGKJZVPcjs = require('./chunk-MZGKJZVP.cjs');var _chunkVWOEUM7Ccjs = require('./chunk-VWOEUM7C.cjs');var _three = require('three'); var l = _interopRequireWildcard(_three); var w = _interopRequireWildcard(_three); var y = _interopRequireWildcard(_three); var M = _interopRequireWildcard(_three);var _OrbitControlsjs = require('three/addons/controls/OrbitControls.js');var _HDRLoaderjs = require('three/addons/loaders/HDRLoader.js');var U=new l.Vector3(0,0,1),P=(e,r,n,t)=>{switch(e){case"mm":return r;case"cm":return n;default:return t}},je= exports.a =function(e,r){let n=re(r||{}),t=oe(n),o=de(n,e),i=ue(e,n),a=me(o,e,n);se(t,n),le(t,n),_optionalChain([n, 'access', _2 => _2.floor, 'optionalAccess', _3 => _3.enabled])&&ce(t,n);let d=n.events.enableEventHandlers!==!1?fe(e,t,o,a,n):{dispose:()=>{},fitToView:()=>{},clearSelection:()=>{}},c=e.parentElement,h=()=>c?{width:c.clientWidth,height:c.clientHeight}:{width:window.innerWidth,height:window.innerHeight},{animate:m,dispose:s}=ie(i,t,o,a,h,n.events.onFrame);m();let E=_optionalChain([n, 'access', _4 => _4.environment, 'optionalAccess', _5 => _5.sceneUp])||U;return t.up.set(E.x,E.y,E.z),{scene:t,camera:o,controls:a,renderer:i,dispose:()=>{s(),d.dispose(),a.dispose(),i.dispose(),t.traverse(u=>{u instanceof l.Mesh&&(_optionalChain([u, 'access', _6 => _6.geometry, 'optionalAccess', _7 => _7.dispose, 'call', _8 => _8()]),Array.isArray(u.material)?u.material.forEach(H=>H.dispose()):_optionalChain([u, 'access', _9 => _9.material, 'optionalAccess', _10 => _10.dispose, 'call', _11 => _11()]))})},fitToView:d.fitToView,clearSelection:d.clearSelection}};function re(e){let r=e.sceneScale||"m",t={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 l.Vector3(-t.cameraDistance,t.cameraDistance,t.cameraDistance),fov:_optionalChain([e, 'access', _14 => _14.camera, 'optionalAccess', _15 => _15.fov])||20,near:_optionalChain([e, 'access', _16 => _16.camera, 'optionalAccess', _17 => _17.near])||t.near,far:_optionalChain([e, 'access', _18 => _18.camera, 'optionalAccess', _19 => _19.far])||t.far,target:_optionalChain([e, 'access', _20 => _20.camera, 'optionalAccess', _21 => _21.target])||new l.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 l.Vector3(t.lightDistance,t.lightHeight,t.lightDistance),ambientLightColor:_optionalChain([e, 'access', _28 => _28.lighting, 'optionalAccess', _29 => _29.ambientLightColor])||new l.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 l.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])||U,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])||t.floorSize,color:_optionalChain([e, 'access', _48 => _48.floor, 'optionalAccess', _49 => _49.color])||new l.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])||l.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])||t.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]),onMeshDoubleClicked:_optionalChain([e, 'access', _92 => _92.events, 'optionalAccess', _93 => _93.onMeshDoubleClicked]),selectionColor:_optionalChain([e, 'access', _94 => _94.events, 'optionalAccess', _95 => _95.selectionColor])||"#ff0000",enableEventHandlers:_nullishCoalesce(_optionalChain([e, 'access', _96 => _96.events, 'optionalAccess', _97 => _97.enableEventHandlers]), () => (!0)),enableKeyboardControls:_nullishCoalesce(_optionalChain([e, 'access', _98 => _98.events, 'optionalAccess', _99 => _99.enableKeyboardControls]), () => (!0)),enableClickToFocus:_nullishCoalesce(_optionalChain([e, 'access', _100 => _100.events, 'optionalAccess', _101 => _101.enableClickToFocus]), () => (!0)),enableDoubleClickZoom:_nullishCoalesce(_optionalChain([e, 'access', _102 => _102.events, 'optionalAccess', _103 => _103.enableDoubleClickZoom]), () => (!0)),onReady:_optionalChain([e, 'access', _104 => _104.events, 'optionalAccess', _105 => _105.onReady]),onFrame:_optionalChain([e, 'access', _106 => _106.events, 'optionalAccess', _107 => _107.onFrame])}}}function oe(e){let r=new l.Scene,n=typeof e.environment.backgroundColor=="string"?new l.Color(e.environment.backgroundColor):e.environment.backgroundColor;return r.background=n||null,r}function ae(e,r,n,t,o=200){let i=e.position.clone(),a=r.target.clone(),d=performance.now(),c=m=>1-Math.pow(1-m,3),h=()=>{let m=performance.now()-d,s=c(Math.min(m/o,1));e.position.lerpVectors(i,n,s),r.target.lerpVectors(a,t,s),r.update(),s<1&&requestAnimationFrame(h)};requestAnimationFrame(h)}function ie(e,r,n,t,o,i){let a=null,d=performance.now(),c=()=>{let{width:s,height:E}=o();if(s===0||E===0)return;let g=Math.min(window.devicePixelRatio,2),u=Math.round(s*g),H=Math.round(E*g);(e.domElement.width!==u||e.domElement.height!==H)&&(e.setPixelRatio(g),e.setSize(s,E,!1),n.aspect=s/E,n.updateProjectionMatrix())},h=function(){a=requestAnimationFrame(h);let s=performance.now(),E=(s-d)/1e3;d=s,c(),(t.enableDamping||t.autoRotate)&&t.update(),_optionalChain([i, 'optionalCall', _108 => _108(E)]),e.render(r,n)};return{animate:h,dispose:()=>{a!==null&&(cancelAnimationFrame(a),a=null)}}}function se(e,r){r.environment.enableEnvironmentLighting?new (0, _HDRLoaderjs.HDRLoader)().load(r.environment.hdrPath||"/baseHDR.hdr",function(n){n.mapping=l.EquirectangularReflectionMapping,e.environment=n,r.environment.showEnvironment&&(e.background=n),_optionalChain([r, 'access', _109 => _109.events, 'access', _110 => _110.onReady, 'optionalCall', _111 => _111()])},void 0,function(n){_chunkVWOEUM7Ccjs.e.call(void 0, ).warn("HDR texture could not be loaded, falling back to basic lighting:",n),_optionalChain([r, 'access', _112 => _112.events, 'access', _113 => _113.onReady, 'optionalCall', _114 => _114()])}):_optionalChain([r, 'access', _115 => _115.events, 'access', _116 => _116.onReady, 'optionalCall', _117 => _117()])}function le(e,r){let n=new l.AmbientLight(r.lighting.ambientLightColor,r.lighting.ambientLightIntensity);if(e.add(n),r.lighting.enableSunlight){let t=new l.DirectionalLight(_nullishCoalesce(r.lighting.sunlightColor, () => (16777215)),r.lighting.sunlightIntensity),o=r.lighting.sunlightPosition;if(o&&t.position.set(o.x,o.y,o.z),r.render.enableShadows){t.castShadow=!0;let i=P(r.sceneScale,.1,10,100);t.shadow.camera.left=-i,t.shadow.camera.right=i,t.shadow.camera.top=i,t.shadow.camera.bottom=-i;let a=P(r.sceneScale,.001,.1,.5),d=P(r.sceneScale,1,100,500);t.shadow.camera.near=a,t.shadow.camera.far=d,t.shadow.mapSize.width=r.render.shadowMapSize||2048,t.shadow.mapSize.height=r.render.shadowMapSize||2048,t.shadow.bias=-1e-4,t.shadow.normalBias=.02}e.add(t)}}function ce(e,r){let n=r.floor.size,t=new l.PlaneGeometry(n,n),o=typeof r.floor.color=="string"?new l.Color(r.floor.color):r.floor.color,i=new l.MeshStandardMaterial({color:o,roughness:r.floor.roughness,metalness:r.floor.metalness,side:l.DoubleSide}),a=new l.Mesh(t,i);a.userData.id="floor",a.name="floor",a.rotation.x=-Math.PI/2,a.position.y=0,r.floor.receiveShadow&&r.render.enableShadows&&(a.receiveShadow=!0),e.add(a)}function de(e,r){let n=r.parentElement,t=n?n.clientWidth:window.innerWidth,o=n?n.clientHeight:window.innerHeight,i=new l.PerspectiveCamera(e.camera.fov,t/o,e.camera.near,e.camera.far),a=e.camera.position;return a&&i.position.set(a.x,a.y,a.z),i}function ue(e,r){let n=new l.WebGLRenderer({antialias:r.render.antialias,canvas:e,alpha:!0,powerPreference:"high-performance",preserveDrawingBuffer:r.render.preserveDrawingBuffer,logarithmicDepthBuffer:!0}),t=e.parentElement,o=t?t.clientWidth:window.innerWidth,i=t?t.clientHeight:window.innerHeight;return t&&(e.style.width="100%",e.style.height="100%",e.style.display="block"),n.setSize(o,i,!1),n.setPixelRatio(r.render.pixelRatio||Math.min(window.devicePixelRatio,2)),r.render.enableShadows&&(n.shadowMap.enabled=!0,n.shadowMap.type=l.VSMShadowMap),n.toneMapping=r.render.toneMapping,n.toneMappingExposure=r.render.toneMappingExposure||1,n.outputColorSpace=l.SRGBColorSpace,n.sortObjects=!0,n}function fe(e,r,n,t,o){let i=new Set,a=new Map,d=new l.Raycaster,c=new l.Vector2,h=new l.Vector2,m=f=>{let p=f;for(;p;){if(!p.visible)return!1;p=p.parent}return!0},s=()=>{let f=new l.Box3;if(r.traverse(L=>{L.visible&&L.userData.id!=="floor"&&L instanceof l.Mesh&&f.expandByObject(L)}),f.isEmpty()){_chunkVWOEUM7Ccjs.e.call(void 0, ).warn("No objects to fit to view");return}let p=f.getCenter(new l.Vector3),T=f.getSize(new l.Vector3),v=Math.max(T.x,T.y,T.z),R=n.fov*(Math.PI/180),C=v/(2*Math.tan(R/2));C*=1.5;let D=n.position.clone().sub(t.target).normalize();n.position.copy(p.clone().add(D.multiplyScalar(C))),t.target.copy(p),t.update()},E=typeof o.events.selectionColor=="string"?new l.Color(o.events.selectionColor):o.events.selectionColor instanceof l.Color?o.events.selectionColor:new l.Color("#ff0000"),g=()=>{i.forEach(f=>{f instanceof l.Mesh&&a.has(f)&&(f.material=a.get(f),a.delete(f))}),i.clear()},u=f=>{h.set(f.clientX,f.clientY)},H=f=>{let p=new l.Vector2(f.clientX,f.clientY);if(h.distanceTo(p)>5)return;let T=e.getBoundingClientRect();c.x=(f.clientX-T.left)/T.width*2-1,c.y=-((f.clientY-T.top)/T.height)*2+1,d.setFromCamera(c,n);let v=d.intersectObjects(r.children,!0).filter(R=>m(R.object));if(v.length>0){let R=v[0].object;if(!i.has(R)){if(g(),i.add(R),R instanceof l.Mesh&&R.material instanceof l.Material){a.set(R,R.material);let C=R.material.clone();C.emissive=E.clone(),R.material=C}_optionalChain([o, 'access', _118 => _118.events, 'optionalAccess', _119 => _119.onObjectSelected, 'optionalCall', _120 => _120(R)]),R instanceof l.Mesh&&Object.keys(R.userData).length>0&&_optionalChain([o, 'access', _121 => _121.events, 'optionalAccess', _122 => _122.onMeshMetadataClicked, 'optionalCall', _123 => _123(R.userData)])}}else g(),_optionalChain([o, 'access', _124 => _124.events, 'optionalAccess', _125 => _125.onBackgroundClicked, 'optionalCall', _126 => _126({x:c.x,y:c.y})])},S=f=>{let p=e.getBoundingClientRect();c.x=(f.clientX-p.left)/p.width*2-1,c.y=-((f.clientY-p.top)/p.height)*2+1,d.setFromCamera(c,n);let T=d.intersectObjects(r.children,!0).filter(Q=>m(Q.object));if(T.length===0)return;let v=T[0].object;if(_optionalChain([o, 'access', _127 => _127.events, 'optionalAccess', _128 => _128.onMeshDoubleClicked, 'optionalCall', _129 => _129(v)]),!_optionalChain([o, 'access', _130 => _130.events, 'optionalAccess', _131 => _131.enableDoubleClickZoom]))return;let R=new l.Box3().setFromObject(v);if(R.isEmpty())return;let C=R.getCenter(new l.Vector3),D=R.getSize(new l.Vector3),L=Math.max(D.x,D.y,D.z),q=n.fov*(Math.PI/180),K=L/(2*Math.tan(q/2))*1.5,X=n.position.clone().sub(t.target).normalize(),J=C.clone().add(X.multiplyScalar(K));ae(n,t,J,C)},x=f=>{if(_optionalChain([o, 'access', _132 => _132.events, 'optionalAccess', _133 => _133.enableKeyboardControls]))switch(f.key.toLowerCase()){case"f":f.preventDefault(),s();break;case"escape":f.preventDefault(),g();break;case" ":f.preventDefault(),s();break}};return _optionalChain([o, 'access', _134 => _134.events, 'optionalAccess', _135 => _135.enableClickToFocus])&&(e.addEventListener("mousedown",u),e.addEventListener("click",H),e.addEventListener("dblclick",S)),_optionalChain([o, 'access', _136 => _136.events, 'optionalAccess', _137 => _137.enableKeyboardControls])&&(e.setAttribute("tabindex","0"),e.addEventListener("keydown",x)),{dispose:()=>{e.removeEventListener("mousedown",u),e.removeEventListener("click",H),e.removeEventListener("dblclick",S),e.removeEventListener("keydown",x),g()},fitToView:s,clearSelection:g}}function me(e,r,n){let t=new (0, _OrbitControlsjs.OrbitControls)(e,r),o=n.camera.target;return o&&t.target.set(o.x,o.y,o.z),t.enableDamping=n.controls.enableDamping||!1,t.dampingFactor=n.controls.dampingFactor||.05,t.autoRotate=n.controls.autoRotate||!1,t.autoRotateSpeed=n.controls.autoRotateSpeed||.5,t.enableZoom=_nullishCoalesce(n.controls.enableZoom, () => (!0)),t.enablePan=_nullishCoalesce(n.controls.enablePan, () => (!0)),t.minDistance=n.controls.minDistance||.001,t.maxDistance=n.controls.maxDistance||1/0,t.screenSpacePanning=!1,t.maxPolarAngle=Math.PI,t.update(),t}var I={HUGE_THRESHOLD:1e4,LARGE_THRESHOLD:1e3,SCALE_RATIO_THRESHOLD:100,NEAR_PLANE_FACTOR:{TINY:1e-4,SMALL:.001,NORMAL:.01},FAR_PLANE_FACTOR:{HUGE:100,LARGE:50,NORMAL:20},INITIAL_DISTANCE_MULTIPLIER:4};function Ke(e,r,n,t,o){if(he(e),r.length===0)return;r.forEach(m=>{e.add(m)});let i=z(r),a=i.getCenter(new w.Vector3),d=i.getSize(new w.Vector3),c=Math.max(d.x,d.y,d.z);if(c/Math.min(d.x||1,d.y||1,d.z||1)>I.SCALE_RATIO_THRESHOLD||c>I.HUGE_THRESHOLD?(n.near=c*I.NEAR_PLANE_FACTOR.TINY,n.far=c*I.FAR_PLANE_FACTOR.HUGE):c>I.LARGE_THRESHOLD?(n.near=c*I.NEAR_PLANE_FACTOR.SMALL,n.far=c*I.FAR_PLANE_FACTOR.LARGE):(n.near=Math.max(.01,c*I.NEAR_PLANE_FACTOR.NORMAL),n.far=Math.max(2e3,c*I.FAR_PLANE_FACTOR.NORMAL)),n.updateProjectionMatrix(),o)t.minDistance=n.near*2,t.maxDistance=n.far*.9;else{let m=c*I.INITIAL_DISTANCE_MULTIPLIER;n.position.set(a.x+m*.8,a.y+m,a.z+m*1.2),t.target.copy(a),t.minDistance=n.near*2,t.maxDistance=n.far*.9,t.update()}}function V(e){if(!e||typeof e!="string")return _chunkVWOEUM7Ccjs.e.call(void 0, ).warn(`Invalid color input: ${e}, using white`),new w.Color(16777215);let r=e.trim();if(/^#?[0-9A-Fa-f]{6}$/.test(r))try{let n=r.startsWith("#")?r:`#${r}`;return new w.Color(n)}catch (e2){return _chunkVWOEUM7Ccjs.e.call(void 0, ).warn(`Invalid hex color: ${e}, using white`),new w.Color(16777215)}if(r.includes(",")){let n=r.split(",").map(t=>parseInt(t.trim(),10));if(n.length===3&&n.every(t=>!isNaN(t)&&t>=0&&t<=255))return new w.Color(n[0]/255,n[1]/255,n[2]/255)}try{return new w.Color(r.toLowerCase())}catch (e3){return _chunkVWOEUM7Ccjs.e.call(void 0, ).warn(`Invalid color string: ${e}, using white`),new w.Color(16777215)}}function N(e,r){e.forEach(n=>{n.position.y-=r})}function z(e){let r=new w.Box3;return e.length===0||e.forEach(n=>{n.updateMatrixWorld(!0);let t=new w.Box3().setFromObject(n);r.union(t)}),r}function he(e){[...e.children].forEach(n=>{n.userData.id!=="floor"&&(n.traverse(t=>{if(!(t instanceof w.Mesh))return;_optionalChain([t, 'access', _138 => _138.geometry, 'optionalAccess', _139 => _139.dispose, 'call', _140 => _140()]),(Array.isArray(t.material)?t.material:[t.material]).forEach(i=>{for(let a of Object.values(i))a instanceof w.Texture&&a.dispose();i.dispose()})}),n.removeFromParent())})}var we={};_chunkVWOEUM7Ccjs.a.call(void 0, we,{CONCRETE_MATERIAL:()=>ge,EMISSIVE_MATERIAL:()=>Ee,GLASS_MATERIAL:()=>Re,METAL_MATERIAL:()=>pe,PLASTIC_MATERIAL:()=>ye,RUBBER_MATERIAL:()=>be,WOOD_MATERIAL:()=>Te});var Ee=new y.MeshPhysicalMaterial({color:0,emissive:new y.Color(16777215),emissiveIntensity:5,metalness:0,roughness:.2,clearcoat:.3,clearcoatRoughness:.2,depthWrite:!0,depthTest:!0,transparent:!1,alphaTest:0,polygonOffset:!0,side:y.FrontSide,dithering:!0}),pe=new y.MeshPhysicalMaterial({color:new y.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:y.FrontSide,dithering:!0}),ge=new y.MeshPhysicalMaterial({color:new y.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:y.FrontSide,dithering:!0}),ye=new y.MeshPhysicalMaterial({color:new y.Color(16777215),metalness:0,roughness:.3,envMapIntensity:.5,clearcoat:.5,clearcoatRoughness:.1,reflectivity:.5,ior:1.4,transmission:0,transparent:!1,depthWrite:!0,side:y.FrontSide,dithering:!0,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}),Re=new y.MeshPhysicalMaterial({color:new y.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:y.DoubleSide,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}),be=new y.MeshPhysicalMaterial({color:new y.Color(1710618),metalness:0,roughness:.9,envMapIntensity:.2,clearcoat:.1,clearcoatRoughness:.8,reflectivity:.2,ior:1.3,transmission:0,depthWrite:!0,side:y.FrontSide,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}),Te=new y.MeshPhysicalMaterial({color:new y.Color(8934707),metalness:0,roughness:.7,envMapIntensity:.3,clearcoat:.3,clearcoatRoughness:.4,reflectivity:.3,ior:1.3,transmission:0,depthWrite:!0,side:y.FrontSide,dithering:!0,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1});var G=1096174675,$= exports.h =1,_= exports.i =1,W=12,Y=56;function j(e){let r=Me(e),n=new DataView(r.buffer,r.byteOffset,r.byteLength);if(r.byteLength<W)throw B("Blob too small to contain SLVA header.",{expectedBytes:W,availableBytes:r.byteLength});let t=0,o=n.getUint32(t,!0);if(t+=4,o!==G)throw B(`Invalid SLVA magic: 0x${o.toString(16)}`,{expectedMagic:`0x${G.toString(16)}`,actualMagic:`0x${o.toString(16)}`});let i=n.getUint32(t,!0);if(t+=4,i!==$)throw B(`Unsupported SLVA version: ${i}`,{expectedVersion:$,actualVersion:i});let a=n.getUint32(t,!0);if(t+=4,t+a>r.byteLength)throw B("Insufficient data to read metadata JSON.",{expectedBytes:a,availableBytes:r.byteLength-t,offset:t});let d=r.subarray(t,t+a);t+=a;let c;try{c=JSON.parse(He(d))}catch(L){throw B(`Failed to parse metadata JSON: ${L instanceof Error?L.message:String(L)}`,{metadataLen:a})}if(t+Y>r.byteLength)throw B("Insufficient data to read geometry header.",{expectedBytes:Y,availableBytes:r.byteLength-t,offset:t});let h=n.getUint32(t,!0);t+=4;let m=n.getFloat64(t,!0);t+=8;let s=n.getFloat64(t,!0);t+=8;let E=n.getFloat64(t,!0);t+=8;let g=n.getFloat64(t,!0);t+=8;let u=n.getFloat64(t,!0);t+=8;let H=n.getFloat64(t,!0);t+=8;let S=n.getUint32(t,!0);t+=4;let x=(h&_)!==0,A=S*3,p=A*(x?4:2);if(t+p>r.byteLength)throw B("Insufficient data to read vertices.",{expectedBytes:p,availableBytes:r.byteLength-t,offset:t,useFloat32:x,vertexCount:S});let T=r.byteOffset+t,v=x?ve(r.buffer,T,A):xe(r.buffer,T,A);if(t+=p,t+4>r.byteLength)throw B("Insufficient data to read index count.",{expectedBytes:4,availableBytes:r.byteLength-t,offset:t});let R=n.getUint32(t,!0);t+=4;let C=R*4;if(t+C>r.byteLength)throw B("Insufficient data to read indices.",{expectedBytes:C,availableBytes:r.byteLength-t,offset:t,indexCount:R});let D=Ce(r.buffer,r.byteOffset+t,R);return{metadata:c,flags:h,vertices:v,indices:D,origin:[m,s,E],scale:[g,u,H]}}function Me(e){return typeof e=="string"?_chunkMZGKJZVPcjs.c.call(void 0, e):e instanceof Uint8Array?e:new Uint8Array(e)}function He(e){if(typeof TextDecoder<"u")return new TextDecoder("utf-8").decode(e);if(typeof globalThis.Buffer<"u")return globalThis.Buffer.from(e).toString("utf-8");throw new (0, _chunkVWOEUM7Ccjs.d)("No UTF-8 decoder available in this environment.",_chunkVWOEUM7Ccjs.c.INVALID_STATE)}function xe(e,r,n){if(n===0)return new Int16Array(0);if(r%2===0)return new Int16Array(e,r,n);let t=new Uint8Array(n*2);return t.set(new Uint8Array(e,r,n*2)),new Int16Array(t.buffer)}function ve(e,r,n){if(n===0)return new Float32Array(0);if(r%4===0)return new Float32Array(e,r,n);let t=new Uint8Array(n*4);return t.set(new Uint8Array(e,r,n*4)),new Float32Array(t.buffer)}function Ce(e,r,n){if(n===0)return new Uint32Array(0);if(r%4===0)return new Uint32Array(e,r,n);let t=new Uint8Array(n*4);return t.set(new Uint8Array(e,r,n*4)),new Uint32Array(t.buffer)}function B(e,r){return new (0, _chunkVWOEUM7Ccjs.d)(e,_chunkVWOEUM7Ccjs.c.VALIDATION_ERROR,{context:r})}async function Z(e,r){let{mergeByMaterial:n=!0,applyTransforms:t=!0,debug:o=!1}=_nullishCoalesce(r, () => ({})),i=o?performance.now():0,a=0;try{let d=performance.now(),c=JSON.parse(e);return a=performance.now()-d,await Se(c,{mergeByMaterial:n,applyTransforms:t,debug:o,parseTime:a,perfStart:i})}catch(d){return _chunkVWOEUM7Ccjs.e.call(void 0, ).error("Error parsing mesh batch:",d),[]}}async function Se(e,r){let{mergeByMaterial:n=!0,applyTransforms:t=!0,scaleFactor:o=1,debug:i=!1,parseTime:a=0,perfStart:d=i?performance.now():0}=_nullishCoalesce(r, () => ({})),c=0,h=0;try{let m=performance.now(),s=j(e.compressedData);c=performance.now()-m;let E=_nullishCoalesce(s.metadata.materials, () => (e.materials)),g=_nullishCoalesce(s.metadata.groups, () => (e.groups)),u=_nullishCoalesce(s.metadata.sourceComponentId, () => (e.sourceComponentId)),H=(s.flags&_)!==0,S=H?Le(s.vertices,t):Ae(s.vertices,s.origin,s.scale,t);if(i){let p=Oe(e.compressedData),T=s.vertices.byteLength+s.indices.byteLength;_chunkVWOEUM7Ccjs.e.call(void 0, ).debug("Mesh Batch Stats:"),_chunkVWOEUM7Ccjs.e.call(void 0, ).debug(` Materials: ${E.length} | Groups: ${g.length}`),_chunkVWOEUM7Ccjs.e.call(void 0, ).debug(` Vertices: ${s.vertices.length/3} | Indices: ${s.indices.length}`),_chunkVWOEUM7Ccjs.e.call(void 0, ).debug(` Format: ${H?"float32":"int16 quantized"}`),_chunkVWOEUM7Ccjs.e.call(void 0, ).debug(` Blob: ${(p/1024/1024).toFixed(2)} MB | Geometry on wire: ${(T/1024/1024).toFixed(2)} MB`)}let x=performance.now(),A=E.map(Ie),f=[];for(let p of g)if(n&&p.meshes.length>1){let T=Be(p,S,s.indices,A);T.userData.sourceComponentId=_nullishCoalesce(u, () => (null)),f.push(T)}else{let T=De(p,S,s.indices,A);for(let v of T)v.userData.sourceComponentId=_nullishCoalesce(u, () => (null));f.push(...T)}if(o!==1)for(let p of f)p.scale.set(o,o,o);if(h=performance.now()-x,i){let p=performance.now()-d;_chunkVWOEUM7Ccjs.e.call(void 0, ).debug("Performance:"),a>0&&_chunkVWOEUM7Ccjs.e.call(void 0, ).debug(` Parse JSON: ${a.toFixed(2)}ms`),_chunkVWOEUM7Ccjs.e.call(void 0, ).debug(` Decode binary: ${c.toFixed(2)}ms`),_chunkVWOEUM7Ccjs.e.call(void 0, ).debug(` Create Meshes: ${h.toFixed(2)}ms`),_chunkVWOEUM7Ccjs.e.call(void 0, ).debug(` Total: ${p.toFixed(2)}ms`)}return f}catch(m){return _chunkVWOEUM7Ccjs.e.call(void 0, ).error("Error parsing mesh batch object:",m),[]}}function Ae(e,r,n,t){let o=new Float32Array(e.length),i=r[0],a=r[1],d=r[2],c=n[0],h=n[1],m=n[2];if(t)for(let s=0;s<e.length;s+=3){let E=i+(e[s]+32767)*c,g=a+(e[s+1]+32767)*h,u=d+(e[s+2]+32767)*m;o[s]=E,o[s+1]=u,o[s+2]=-g}else for(let s=0;s<e.length;s+=3)o[s]=i+(e[s]+32767)*c,o[s+1]=a+(e[s+1]+32767)*h,o[s+2]=d+(e[s+2]+32767)*m;return o}function Le(e,r){if(!r)return e;let n=new Float32Array(e.length);for(let t=0;t<e.length;t+=3){let o=e[t],i=e[t+1],a=e[t+2];n[t]=o,n[t+1]=a,n[t+2]=-i}return n}function Ie(e){let r=V(e.color);return new M.MeshPhysicalMaterial({color:r,metalness:e.metalness,roughness:e.roughness,opacity:e.opacity,transparent:e.transparent,side:M.DoubleSide,polygonOffset:!0,polygonOffsetFactor:.5,polygonOffsetUnits:.5,depthWrite:!0,depthTest:!0})}function Be(e,r,n,t){let o=0,i=0;for(let u of e.meshes)o+=u.vertexCount,i+=u.indexCount;let a=new Float32Array(o*3),d=new Uint32Array(i),c=0,h=0;for(let u of e.meshes){let H=u.vertexStart*3,S=u.vertexCount*3;a.set(r.subarray(H,H+S),c*3);let x=n.subarray(u.indexStart,u.indexStart+u.indexCount),A=c-u.vertexStart;if(A===0)d.set(x,h);else for(let f=0;f<x.length;f++)d[h+f]=x[f]+A;c+=u.vertexCount,h+=u.indexCount}let m=new M.BufferGeometry;m.setAttribute("position",new M.BufferAttribute(a,3)),m.setIndex(new M.BufferAttribute(d,1)),m.computeVertexNormals();let s=new M.Mesh(m,t[e.materialId]),E=e.meshes[0],g=e.meshes.map(u=>u.name).filter(u=>u&&u.length>0);return s.name=g.length>0?g[0]:`merged_material_${e.materialId}`,s.castShadow=!0,s.receiveShadow=!0,s.userData={name:s.name,layer:_nullishCoalesce(_optionalChain([E, 'optionalAccess', _141 => _141.layer]), () => ("")),originalIndex:_nullishCoalesce(_optionalChain([E, 'optionalAccess', _142 => _142.originalIndex]), () => (0)),metadata:_nullishCoalesce(_optionalChain([E, 'optionalAccess', _143 => _143.metadata]), () => ({})),mergedFrom:e.meshes.slice(1).map(u=>({name:u.name,layer:u.layer,originalIndex:u.originalIndex}))},s}function De(e,r,n,t){let o=[];for(let i of e.meshes){let a=i.vertexStart*3,d=i.vertexCount*3,c=r.slice(a,a+d),h=n.subarray(i.indexStart,i.indexStart+i.indexCount),m=new Uint32Array(h.length),s=i.vertexStart;for(let u=0;u<h.length;u++)m[u]=h[u]-s;let E=new M.BufferGeometry;E.setAttribute("position",new M.BufferAttribute(c,3)),E.setIndex(new M.BufferAttribute(m,1)),E.computeVertexNormals();let g=new M.Mesh(E,t[e.materialId]);g.name=i.name,g.userData={name:i.name,layer:_nullishCoalesce(i.layer, () => ("")),originalIndex:i.originalIndex,metadata:_nullishCoalesce(i.metadata, () => ({}))},g.castShadow=!0,g.receiveShadow=!0,o.push(g)}return o}function Oe(e){return Math.floor(e.length*3/4)}var Fe={Millimeters:1/1e3,Centimeters:1/100,Meters:1,Inches:1/39.37,Feet:1/3.28084},Pe="Display";async function lt(e,r){let n=performance.now(),t=[],{allowScaling:o=!0,allowAutoPosition:i=!0,debug:a=!1,parsing:d={}}=_nullishCoalesce(r, () => ({}));try{let c=o?ze(e.modelunits):1;return await _e(e,t,c,d,a),i&&Ue(t),t}catch(c){throw Ve(c,t),c}finally{a&&Ge(n)}}function ze(e){return _nullishCoalesce(Fe[e], () => (1))}async function _e(e,r,n,t,o){for(let i of e.values){let a=i.InnerTree;for(let d in a){let c=a[d];c&&await ke(c,r,n,t,o)}}}async function ke(e,r,n,t,o){for(let i of e)if(i.type.includes(Pe)){let a={mergeByMaterial:!0,applyTransforms:!0,debug:!1,...t},d=await Z(i.data,a);if(n!==1)for(let c of d)c.scale.set(n,n,n);r.push(...d),o&&_chunkVWOEUM7Ccjs.e.call(void 0, ).debug(`Extracted ${d.length} meshes from batch`)}}function Ue(e){if(e.length===0)return;let n=z(e).min.y;N(e,n)}function Ve(e,r){_chunkVWOEUM7Ccjs.e.call(void 0, ).error("An unexpected error occurred:",e),Ne(r)}function Ne(e){for(let r of e)r.geometry&&r.geometry.dispose(),r.material&&(Array.isArray(r.material)?r.material.forEach(n=>n.dispose()):r.material.dispose())}function Ge(e){let r=performance.now()-e;_chunkVWOEUM7Ccjs.e.call(void 0, ).info("Time to process meshes:",`${r.toFixed(2)}ms`)}exports.a = je; exports.b = Ke; exports.c = V; exports.d = N; exports.e = z; exports.f = we; exports.g = G; exports.h = $; exports.i = _; exports.j = j; exports.k = Z; exports.l = Se; exports.m = Fe; exports.n = lt;
|
|
2
|
-
//# sourceMappingURL=chunk-DSI6FKBA.cjs.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkDSI6FKBAcjs = require('./chunk-DSI6FKBA.cjs');require('./chunk-MZGKJZVP.cjs');require('./chunk-VWOEUM7C.cjs');exports.BINARY_MESH_MAGIC = _chunkDSI6FKBAcjs.g; exports.BINARY_MESH_VERSION = _chunkDSI6FKBAcjs.h; exports.FLAG_FLOAT32 = _chunkDSI6FKBAcjs.i; exports.Materials = _chunkDSI6FKBAcjs.f; exports.SCALE_FACTORS = _chunkDSI6FKBAcjs.m; exports.applyOffset = _chunkDSI6FKBAcjs.d; exports.computeCombinedBoundingBox = _chunkDSI6FKBAcjs.e; exports.getThreeMeshesFromComputeResponse = _chunkDSI6FKBAcjs.n; exports.initThree = _chunkDSI6FKBAcjs.a; exports.parseBinaryMeshBatch = _chunkDSI6FKBAcjs.j; exports.parseColor = _chunkDSI6FKBAcjs.c; exports.parseMeshBatch = _chunkDSI6FKBAcjs.k; exports.parseMeshBatchObject = _chunkDSI6FKBAcjs.l; exports.updateScene = _chunkDSI6FKBAcjs.b;
|
|
2
|
-
//# sourceMappingURL=visualization-HV5EMX2F.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/selva-compute/selva-compute/dist/visualization-HV5EMX2F.cjs"],"names":[],"mappings":"AAAA,iIAA8H,gCAA6B,gCAA6B,+pBAA4T","file":"/home/runner/work/selva-compute/selva-compute/dist/visualization-HV5EMX2F.cjs"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as e,b as r,c as o,d as t,e as a,f as s,g as i,h as p,i as n,j as h,k as M,l as f,m,n as C}from"./chunk-DM7RXPP6.js";import"./chunk-XLHA5YPH.js";import"./chunk-RHULSS7S.js";export{i as BINARY_MESH_MAGIC,p as BINARY_MESH_VERSION,n as FLAG_FLOAT32,s as Materials,m as SCALE_FACTORS,t as applyOffset,a as computeCombinedBoundingBox,C as getThreeMeshesFromComputeResponse,e as initThree,h as parseBinaryMeshBatch,o as parseColor,M as parseMeshBatch,f as parseMeshBatchObject,r as updateScene};
|
|
2
|
-
//# sourceMappingURL=visualization-S47O7BLV.js.map
|
|
File without changes
|
|
File without changes
|