@pan-ya/libgeo3dviewer 1.7.32 → 1.7.33

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.
@@ -1190,7 +1190,7 @@ vPositionW = vec3(worldPos);
1190
1190
 
1191
1191
  #define CUSTOM_VERTEX_MAIN_END
1192
1192
  vColor = vec4(instanceColor.rgb, instanceColor.a);
1193
- }`,LightMetalMaterial=({alpha:e,zOffset:t,zOffsetUnits:n,disableDepthWrite:a})=>jsxRuntime.jsx("pbrMaterial",{name:"metal-pbr-material",alpha:e,transparencyMode:e!==void 0&&e<1?EngineCore.Material.MATERIAL_ALPHABLEND:EngineCore.Material.MATERIAL_OPAQUE,alphaMode:EngineCore.Engine.ALPHA_COMBINE,roughness:.25,metallic:1,albedoColor:new EngineCore.Color3(.7,.7,.7),metallicF0Factor:.1,zOffset:t,zOffsetUnits:n,disableDepthWrite:a}),DarkMetalMaterial=({alpha:e,zOffset:t,zOffsetUnits:n,disableDepthWrite:a})=>jsxRuntime.jsx("pbrMaterial",{name:"metal-pbr-material",alpha:e,transparencyMode:e!==void 0&&e<1?EngineCore.Material.MATERIAL_ALPHABLEND:EngineCore.Material.MATERIAL_OPAQUE,alphaMode:EngineCore.Engine.ALPHA_COMBINE,roughness:.25,metallic:1,albedoColor:new EngineCore.Color3(.2,.2,.2),metallicF0Factor:.1,zOffsetUnits:n,zOffset:t,disableDepthWrite:a});var RepeatedTextureMode=(e=>(e[e.TRIGONOMETRIC=0]="TRIGONOMETRIC",e[e.PLANE=1]="PLANE",e[e.FLAT=2]="FLAT",e))(RepeatedTextureMode||{});const RepeatedTextureMaterial=e=>{const t=reactBabylonjs.useScene(),[n,a]=React.useState(null),[r,o]=React.useState(null),{tilingFactor:i=.1,sideTilingFactor:s=.1,texture:l,alpha:c=1,mode:f=0,zOffset:u,zOffsetUnits:d,sideTexture:h,uvOffset:m=EngineCore.Vector2.Zero(),counterLine:R=void 0,scalePlane:v=1,scaleDepth:g=1,boundingBox:x=void 0,lines:y=[],text:E=[],disableDepthWrite:k,flatModeRotate:b=0}=e,C=_=>{a(_)};return React.useEffect(()=>{n&&l&&(n.setTexture("textureSampler",l),n.setFloat("textureFlatRotate",b),n.setVector2("uvOffset",m))},[b,n,l,m]),React.useEffect(()=>{n&&n.setFloat("alpha",c)},[c,n]),React.useEffect(()=>{n&&n.setFloat("tilingFactor",i),n&&n.setFloat("sideTilingFactor",s)},[i,s,n]),React.useEffect(()=>{n&&n.setInt("mode",f)},[n,f]),React.useEffect(()=>{n&&(h?n.setTexture("textureSideSampler",h):n.setTexture("textureSideSampler",l))},[n,h,l]),React.useEffect(()=>{var _;if(n)if(R&&x){const A=(_=R.startHeight)!=null?_:x.minimumWorld.y/g;return n.setFloat("contourLineStartHeight",A*g),n.setColor3("contourLineColor",R.color),n.setFloat("contourLineWidth",R.width),n.setFloat("contourLineStep",R.stepHeight*g),console.log("[Geo3DViewer] 等高线设置 ",R,x.centerWorld.y,A*g,A*g+16*R.stepHeight*g),()=>{n&&(n.setFloat("contourLineStartHeight",0),n.setColor3("contourLineColor",new EngineCore.Color3(0,0,0)),n.setFloat("contourLineWidth",0),n.setFloat("contourLineStep",0))}}else n.setFloat("contourLineStartHeight",0),n.setColor3("contourLineColor",new EngineCore.Color3(0,0,0)),n.setFloat("contourLineWidth",0),n.setFloat("contourLineStep",0),console.log("[Geo3DViewer] 等高线设置 关闭")},[R,g,v,x,n]),React.useEffect(()=>{t&&n&&x&&o(_=>{_&&_.dispose();let A=(x.maximum.x-x.minimum.x)/v,N=(x.maximum.z-x.minimum.z)/v,S=0;if(A<N){const F=A;A=N,N=F,S=1}const I=A/N;A*N>2048*2048&&(A=2048,N=2048/I);const O=new EngineCore.DynamicTexture("dynamic-texture",{width:A,height:N},t,!1);return O.clear(),console.log("[Geo3DViewer] 设置动态划线 ",x,A,N,v),n.setVector3("oMin",x.minimum),n.setVector3("oMax",x.maximum),n.setFloat("textureOverlayRotate",S),n.setTexture("textureOverlaySampler",O),O})},[x,n,v,t]),React.useEffect(()=>{var _;if(r&&x)if((_=r.getScene())!=null&&_.getEngine()){r.clear();let A=(x.maximum.x-x.minimum.x)/v,N=(x.maximum.z-x.minimum.z)/v;if(A<N){const O=A;A=N,N=O}const S=A/N;A*N>2048*2048&&(A=2048,N=2048/S);const I=r.getContext();y.forEach(O=>{if(O.points.length<2)return;I.beginPath();const F=O.offset?O.offset:new EngineCore.Vector2(0,0),w=1-O.points[0].x+F.x,L=1-O.points[0].y+F.y;I.moveTo(w*A,L*N);for(let B=1;B<O.points.length;B++){const D=O.offset?O.offset:new EngineCore.Vector2(0,0),W=1-O.points[B].x+D.x,ae=1-O.points[B].y+D.y;I.lineTo(W*A,ae*N)}I.strokeStyle=`rgb(${O.color.r*255}, ${O.color.g*255}, ${O.color.b*255})`,A*N>2048*2048?I.lineWidth=O.width/S:I.lineWidth=O.width,I.stroke()}),E.forEach(O=>{var B,D;I.font=`${O.fontSize}px Arial`;const F=(B=O.color)!=null?B:EngineCore.Color3.White(),w=O.offset?O.offset:new EngineCore.Vector2(0,0),L=(D=O.rotation)!=null?D:0;if(I.save(),I.translate((1-O.position.x+w.x)*A,(1-O.position.y+w.y)*N),I.rotate(L),O.clearArea){const W=I.measureText(O.text);I.clearRect(-W.width*.15,.5*O.fontSize*(1-.3),W.width*1.3,-O.fontSize*1.3)}if(O.background){I.fillStyle=`rgba(${O.background.r*255}, ${O.background.g*255}, ${O.background.b*255})`;const W=I.measureText(O.text);I.fillRect(-W.width*.05,.5*(O.fontSize*(.5-.1)),W.width*1.1,-O.fontSize*1.1)}I.fillStyle=`rgb(${F.r*255}, ${F.g*255}, ${F.b*255})`,I.fillText(O.text,0,0),I.restore()}),r.update()}else console.log("[Geo3DViewer] 动态纹理未准备好,正准备下一次绘制")},[y,E,r,x,v]),jsxRuntime.jsx(CustomShader$1,{...e,ref:C,vertex:repeatedTextureVertexSource,fragment:repeatedTextureFragmentSource,options:{attributes:["position","color","alpha","normal"],uniforms:["worldViewProjection","tilingFactor","sideTilingFactor","mode","uvOffset","contourLineStartHeight","contourLineColor","contourLineWidth","contourLineStep","oMin","oMax","textureOverlayRotate","textureFlatRotate"],samplers:["textureSampler","textureOverlaySampler","textureSideSampler"],needAlphaBlending:!0,needAlphaTesting:!0},zOffset:u,zOffsetUnits:d,disableDepthWrite:k})},RemapColorByRedChannelMaterial=e=>{const t=reactBabylonjs.useScene(),n=React.useRef(null),a=React.useContext(ColorCodecImageContext),[r,o]=React.useState(null),{name:i,colorCodec:s,alpha:l=1,backFaceCulling:c,needDepthPrePass:f=!1,transparencyMode:u=EngineCore.Material.MATERIAL_OPAQUE,alphaMode:d=EngineCore.Engine.ALPHA_COMBINE,zOffset:h,zOffsetUnits:m,clipPlane:R,counterLine:v=void 0,scalePlane:g=1,scaleDepth:x=1,boundingBox:y,lines:E=[],text:k=[],disableDepthWrite:b}=e;return React.useEffect(()=>{const C=n.current;C&&t&&(C.loadFromSerialization(remapNodeMaterialSource,""),C.build(!1,!0,!1))},[t]),React.useEffect(()=>{const C=n.current;C&&(C.name=`${i}-material`,C.backFaceCulling=c!=null?c:!0,C.needDepthPrePass=f,C.transparencyMode=u,C.alphaMode=d,C.alpha=l,C.zOffset=h!=null?h:1,C.zOffsetUnits=m!=null?m:0,C.clipPlane=R!=null?R:null,C.disableDepthWrite=b!=null?b:!1)},[l,d,c,R,b,i,f,u,h,m]),React.useEffect(()=>{if(s){const C=n.current;C&&(C.metadata={colorCodec:s},EngineCore.Tags.EnableFor(C),EngineCore.Tags.AddTagsTo(C,"remap"))}if(s&&a&&t&&a.colorCodecsImage.current[s]){const C=n.current;if(C){const _=C.getBlockByName("RemappedTexture");_&&(_.texture=a.colorCodecsImage.current[s].texture,C.markAsDirty(EngineCore.NodeMaterial.TextureDirtyFlag))}}},[s,t]),React.useEffect(()=>{n.current&&t&&(console.log("[Geo3DViewer] RemapColorByRedChannel 透明度更新 ",l),n.current.alpha=l)},[t,l]),React.useEffect(()=>{var _;const C=n.current;if(C){const A=C.getBlockByName("contourLineStartHeight"),N=C.getBlockByName("contourLineColor"),S=C.getBlockByName("contourLineWidth"),I=C.getBlockByName("contourLineStep");if(v&&y){const O=(_=v.startHeight)!=null?_:y.centerWorld.y/x;return A&&(A.value=O*x),N&&(N.value=v.color),S&&(S.value=v.width),I&&(I.value=v.stepHeight*x),console.log("[Geo3DViewer] 等高线设置 ",v,y.centerWorld,y.centerWorld.y,O*x,O*x+16*v.stepHeight*x),()=>{C&&(A&&(A.value=0),N&&(N.value=new EngineCore.Color3(0,0,0)),S&&(S.value=0),I&&(I.value=0))}}else A&&(A.value=0),N&&(N.value=new EngineCore.Color3(0,0,0)),S&&(S.value=0),I&&(I.value=0),console.log("[Geo3DViewer] 等高线设置 关闭");C.markAsDirty(EngineCore.NodeMaterial.MiscDirtyFlag)}},[v,x,g,y]),React.useEffect(()=>{t&&y&&o(C=>{var w,L;C&&C.dispose();let _=(y.maximum.x-y.minimum.x)/g,A=(y.maximum.z-y.minimum.z)/g,N=0;if(_<A){const B=_;_=A,A=B,N=1}const S=_/A;_*A>2048*2048&&(_=2048,A=2048/S);const I=new EngineCore.DynamicTexture("dynamic-texture",{width:_,height:A},t,!1);I.clear(),console.log("[Geo3DViewer] 设置动态划线 ",y,_,A,g);const O=(w=n.current)==null?void 0:w.getBlockByName("angle"),F=(L=n.current)==null?void 0:L.getBlockByName("OverlayTexture");return O&&(O.value=N*(Math.PI/2)),F&&(F.texture=I),I})},[y,g,t]),React.useEffect(()=>{var C;if(r&&y)if((C=r.getScene())!=null&&C.getEngine()){r.clear();let _=(y.maximum.x-y.minimum.x)/g,A=(y.maximum.z-y.minimum.z)/g;if(_<A){const I=_;_=A,A=I}const N=_/A;_*A>2048*2048&&(_=2048,A=2048/N);const S=r.getContext();E.forEach(I=>{if(I.points.length<2)return;S.beginPath();const O=I.offset?I.offset:new EngineCore.Vector2(0,0),F=1-I.points[0].x+O.x,w=1-I.points[0].y+O.y;S.moveTo(F*_,w*A);for(let L=1;L<I.points.length;L++){const B=I.offset?I.offset:new EngineCore.Vector2(0,0),D=1-I.points[L].x+B.x,W=1-I.points[L].y+B.y;S.lineTo(D*_,W*A)}S.strokeStyle=`rgb(${I.color.r*255}, ${I.color.g*255}, ${I.color.b*255})`,_*A>2048*2048?S.lineWidth=I.width/N:S.lineWidth=I.width,S.stroke()}),k.forEach(I=>{var L,B;S.font=`${I.fontSize}px Arial`;const O=(L=I.color)!=null?L:EngineCore.Color3.White(),F=I.offset?I.offset:new EngineCore.Vector2(0,0),w=(B=I.rotation)!=null?B:0;if(S.save(),S.translate((1-I.position.x+F.x)*_,(1-I.position.y+F.y)*A),S.rotate(w),I.clearArea){const D=S.measureText(I.text);S.clearRect(-D.width*.15,.5*I.fontSize*(1-.3),D.width*1.3,-I.fontSize*1.3)}if(I.background){S.fillStyle=`rgba(${I.background.r*255}, ${I.background.g*255}, ${I.background.b*255})`;const D=S.measureText(I.text);S.fillRect(-D.width*.05,.5*(I.fontSize*(.5-.1)),D.width*1.1,-I.fontSize*1.1)}S.fillStyle=`rgb(${O.r*255}, ${O.g*255}, ${O.b*255})`,S.fillText(I.text,0,0),S.restore()}),r.update()}else console.log("[Geo3DViewer] 动态纹理未准备好,正准备下一次绘制")},[E,r,y,g,k]),jsxRuntime.jsx("nodeMaterial",{ref:n,name:`${i}-material`,backFaceCulling:c,needDepthPrePass:f,transparencyMode:u,alphaMode:d,alpha:l,zOffset:h,zOffsetUnits:m,clipPlane:R,disableDepthWrite:b})},ProgressedRemapColorByRedChannelMaterial=e=>{const t=reactBabylonjs.useScene(),n=React.useContext(ColorCodecImageContext),a=React.useRef(null),[r,o]=React.useState(null),[i,s]=React.useState(null),[l,c]=React.useState(null),[f,u]=React.useState(null),[d,h]=React.useState(null),[m,R]=React.useState(null),[v,g]=React.useState(null),[x,y]=React.useState(null),{boundingBox:E,colorCodec:k,alphaStage:b,cutNormal:C,value:_,zOffset:A,zOffsetUnits:N,counterLine:S=void 0,scaleDepth:I=1,scalePlane:O=1,lines:F=[],text:w=[],disableDepthWrite:L}=e;return React.useEffect(()=>{const B=(D,W,ae)=>{if(E){const ee=E.maximumWorld.multiply(W),H=E.minimumWorld.multiply(W),oe=E.centerWorld.multiply(W),te=Math.max(ee.x,ee.y,ee.z),K=Math.max(H.x,H.y,H.z),Z=Math.max(oe.x,oe.y,oe.z),ce=Math.max(Math.abs(W.x),Math.abs(W.z));D(new EngineCore.Plane(W.x,W.y,W.z,((te-K)*(1-ae-.5)*ce+Z)*-1))}else D(null)};E&&x&&(B(o,x.cutPlane1,_.value1),x.cutPlane2&&_.value2?B(s,x.cutPlane2,_.value2):s(null),x.cutPlane3&&_.value3?B(c,x.cutPlane3,_.value3):c(null),x.cutPlane4&&_.value4?B(u,x.cutPlane4,_.value4):u(null),x.cutPlane5&&_.value5?B(h,x.cutPlane5,_.value5):c(null),x.cutPlane6&&_.value6?B(R,x.cutPlane6,_.value6):R(null))},[E,x,_]),React.useEffect(()=>{y({cutPlane1:EngineCore.Vector3.Normalize(C.cutPlane1),cutPlane2:C.cutPlane2?EngineCore.Vector3.Normalize(C.cutPlane2):void 0,cutPlane3:C.cutPlane3?EngineCore.Vector3.Normalize(C.cutPlane3):void 0,cutPlane4:C.cutPlane4?EngineCore.Vector3.Normalize(C.cutPlane4):void 0,cutPlane5:C.cutPlane5?EngineCore.Vector3.Normalize(C.cutPlane5):void 0,cutPlane6:C.cutPlane6?EngineCore.Vector3.Normalize(C.cutPlane6):void 0})},[C]),React.useEffect(()=>{const B=a.current;B&&(B.clipPlane=r,B.clipPlane2=i,B.clipPlane3=l,B.clipPlane4=f,B.clipPlane5=d,B.clipPlane6=m)},[r,i,l,f,d,m]),React.useEffect(()=>{var B,D,W,ae,ee;a.current&&t&&(a.current.setFloat("alpha1",b.alpha1),a.current.setFloat("alpha2",(B=b.alpha2)!=null?B:1),a.current.setFloat("alpha3",(D=b.alpha3)!=null?D:1),a.current.setFloat("alpha4",(W=b.alpha4)!=null?W:1),a.current.setFloat("alpha5",(ae=b.alpha5)!=null?ae:1),a.current.setFloat("alpha6",(ee=b.alpha6)!=null?ee:1))},[t,b]),React.useEffect(()=>{if(k){const B=a.current;B&&(B.metadata={colorCodec:k},EngineCore.Tags.EnableFor(B),EngineCore.Tags.AddTagsTo(B,"remap"))}if(k&&n&&t&&n.colorCodecsImage.current[k]){const B=a.current;B&&(console.log(n.colorCodecsImage.current[k]),B.setTexture("textureSampler",n.colorCodecsImage.current[k].texture),B.metadata={colorCodec:k},EngineCore.Tags.EnableFor(B),EngineCore.Tags.AddTagsTo(B,"remap"))}},[k,t]),React.useEffect(()=>{var D;const B=a.current;if(B&&E)if(S){const W=(D=S.startHeight)!=null?D:E.minimumWorld.y/I;return B.setFloat("contourLineStartHeight",W*I),B.setColor3("contourLineColor",S.color),B.setFloat("contourLineWidth",S.width),B.setFloat("contourLineStep",S.stepHeight*I),console.log("[Geo3DViewer] 等高线设置 ",S,E.centerWorld.y,W*I,W*I+16*S.stepHeight*I),()=>{B&&(B.setFloat("contourLineStartHeight",0),B.setColor3("contourLineColor",new EngineCore.Color3(0,0,0)),B.setFloat("contourLineWidth",0),B.setFloat("contourLineStep",0))}}else B.setFloat("contourLineStartHeight",0),B.setColor3("contourLineColor",new EngineCore.Color3(0,0,0)),B.setFloat("contourLineWidth",0),B.setFloat("contourLineStep",0),console.log("[Geo3DViewer] 等高线设置 关闭")},[S,I,O,E]),React.useEffect(()=>{t&&E&&g(B=>{var oe,te,K,Z;B&&B.dispose();let D=(E.maximum.x-E.minimum.x)/O,W=(E.maximum.z-E.minimum.z)/O,ae=0;if(D<W){const ce=D;D=W,W=ce,ae=1}const ee=D/W;D*W>2048*2048&&(D=2048,W=2048/ee);const H=new EngineCore.DynamicTexture("dynamic-texture",{width:D,height:W},t,!1);return H.clear(),console.log("[Geo3DViewer] 设置动态划线 ",E,D,W,O),(oe=a.current)==null||oe.setVector3("oMin",E.minimum),(te=a.current)==null||te.setVector3("oMax",E.maximum),(K=a.current)==null||K.setFloat("textureOverlayRotate",ae),(Z=a.current)==null||Z.setTexture("textureOverlaySampler",H),H})},[E,O,t]),React.useEffect(()=>{var B;if(v&&E)if((B=v.getScene())!=null&&B.getEngine()){v.clear();let D=(E.maximum.x-E.minimum.x)/O,W=(E.maximum.z-E.minimum.z)/O;if(D<W){const H=D;D=W,W=H}const ae=D/W;D*W>2048*2048&&(D=2048,W=2048/ae);const ee=v.getContext();F.forEach(H=>{if(H.points.length<2)return;ee.beginPath();const oe=H.offset?H.offset:new EngineCore.Vector2(0,0),te=1-H.points[0].x+oe.x,K=1-H.points[0].y+oe.y;ee.moveTo(te*D,K*W);for(let Z=1;Z<H.points.length;Z++){const ce=H.offset?H.offset:new EngineCore.Vector2(0,0),Q=1-H.points[Z].x+ce.x,G=1-H.points[Z].y+ce.y;ee.lineTo(Q*D,G*W)}ee.strokeStyle=`rgb(${H.color.r*255}, ${H.color.g*255}, ${H.color.b*255})`,D*W>2048*2048?ee.lineWidth=H.width/ae:ee.lineWidth=H.width,ee.stroke()}),w.forEach(H=>{var Z,ce;ee.font=`${H.fontSize}px Arial`;const oe=(Z=H.color)!=null?Z:EngineCore.Color3.White(),te=H.offset?H.offset:new EngineCore.Vector2(0,0),K=(ce=H.rotation)!=null?ce:0;if(ee.save(),ee.translate((1-H.position.x+te.x)*D,(1-H.position.y+te.y)*W),ee.rotate(K),H.clearArea){const Q=ee.measureText(H.text);ee.clearRect(-Q.width*.15,.5*H.fontSize*(1-.3),Q.width*1.3,-H.fontSize*1.3)}if(H.background){ee.fillStyle=`rgba(${H.background.r*255}, ${H.background.g*255}, ${H.background.b*255})`;const Q=ee.measureText(H.text);ee.fillRect(-Q.width*.05,.5*(H.fontSize*(.5-.1)),Q.width*1.1,-H.fontSize*1.1)}ee.fillStyle=`rgb(${oe.r*255}, ${oe.g*255}, ${oe.b*255})`,ee.fillText(H.text,0,0),ee.restore()}),v.update()}else console.log("[Geo3DViewer] 动态纹理未准备好,正准备下一次绘制")},[F,v,E,O,w]),jsxRuntime.jsx(CustomShader$1,{...e,ref:a,vertex:remapProgressedVertexSource,fragment:remapProgressedFragmentSource,options:{attributes:["position","color","normal"],uniforms:["world","worldViewProjection","alpha1","alpha2","alpha3","alpha4","alpha5","alpha6","oMin","oMax","contourLineStartHeight","contourLineColor","contourLineWidth","contourLineStep","textureOverlayRotate"],samplers:["textureOverlaySampler","textureSampler"],needAlphaBlending:!0,needAlphaTesting:!0,useClipPlane:!0},disableDepthWrite:L,zOffset:A,zOffsetUnits:N})},ProgressedRepeatedTextureMaterial=e=>{const t=reactBabylonjs.useScene(),[n,a]=React.useState(null),[r,o]=React.useState(null),[i,s]=React.useState(null),[l,c]=React.useState(null),[f,u]=React.useState(null),[d,h]=React.useState(null),[m,R]=React.useState(null),[v,g]=React.useState(null),[x,y]=React.useState(null),{boundingBox:E=void 0,texture:k,sideTexture:b,alphaStage:C,cutNormal:_,value:A,tilingFactor:N=.1,sideTilingFactor:S=.1,mode:I=0,zOffset:O,zOffsetUnits:F,overlay:w={},counterLine:L=void 0,scalePlane:B=1,scaleDepth:D=1,lines:W=[],text:ae=[],disableDepthWrite:ee,textureFlatRotate:H=0}=e,oe=te=>{a(te)};return React.useEffect(()=>{n&&n.setFloat("textureFlatRotate",H)},[n,H]),React.useEffect(()=>{const te=(K,Z,ce)=>{if(E){const Q=E.maximumWorld.multiply(Z),G=E.minimumWorld.multiply(Z),ge=E.centerWorld.multiply(Z),fe=Math.max(Q.x,Q.y,Q.z),V=Math.max(G.x,G.y,G.z),J=Math.max(ge.x,ge.y,ge.z),Re=Math.max(Math.abs(Z.x),Math.abs(Z.z)),Ce=new EngineCore.Plane(Z.x,Z.y,Z.z,((fe-V)*(1-ce-.5)*Re+J)*-1);K(Ce),console.log("[Geo3DViewer] 设置实际 CutPlane 为 ",Ce,Re)}else K(null)};E&&x&&(te(o,x.cutPlane1,A.value1),x.cutPlane2&&A.value2?te(s,x.cutPlane2,A.value2):s(null),x.cutPlane3&&A.value3?te(c,x.cutPlane3,A.value3):c(null),x.cutPlane4&&A.value4?te(u,x.cutPlane4,A.value4):u(null),x.cutPlane5&&A.value5?te(h,x.cutPlane5,A.value5):c(null),x.cutPlane6&&A.value6?te(R,x.cutPlane6,A.value6):R(null))},[x,E,A]),React.useEffect(()=>{y({cutPlane1:EngineCore.Vector3.Normalize(_.cutPlane1),cutPlane2:_.cutPlane2?EngineCore.Vector3.Normalize(_.cutPlane2):void 0,cutPlane3:_.cutPlane3?EngineCore.Vector3.Normalize(_.cutPlane3):void 0,cutPlane4:_.cutPlane4?EngineCore.Vector3.Normalize(_.cutPlane4):void 0,cutPlane5:_.cutPlane5?EngineCore.Vector3.Normalize(_.cutPlane5):void 0,cutPlane6:_.cutPlane6?EngineCore.Vector3.Normalize(_.cutPlane6):void 0})},[_]),React.useEffect(()=>{n&&(n.clipPlane=r,n.clipPlane2=i,n.clipPlane3=l,n.clipPlane4=f,n.clipPlane5=d,n.clipPlane6=m)},[n,r,i,l,f,d,m]),React.useEffect(()=>{var te,K,Z,ce,Q;n&&t&&(n.setFloat("alpha1",C.alpha1),n.setFloat("alpha2",(te=C.alpha2)!=null?te:1),n.setFloat("alpha3",(K=C.alpha3)!=null?K:1),n.setFloat("alpha4",(Z=C.alpha4)!=null?Z:1),n.setFloat("alpha5",(ce=C.alpha5)!=null?ce:1),n.setFloat("alpha6",(Q=C.alpha6)!=null?Q:1))},[t,C,n]),React.useEffect(()=>{n&&k&&n.setTexture("textureSampler",k)},[n,k]),React.useEffect(()=>{n&&N&&n.setFloat("tilingFactor",N),n&&S&&n.setFloat("sideTilingFactor",S)},[N,S,n]),React.useEffect(()=>{n&&I&&n.setInt("mode",I)},[n,I]),React.useEffect(()=>{n&&(b?n.setTexture("textureSideSampler",b):n.setTexture("textureSideSampler",k))},[n,b,k]),React.useEffect(()=>{n&&(w.texture1?n.setTexture("textureSampler1",w.texture1):n.setTexture("textureSampler1",k),w.sideTexture1?n.setTexture("textureSideSampler1",w.sideTexture1):n.setTexture("textureSideSampler1",k),w.color1?n.setColor3("vColor1",w.color1):n.setColor3("vColor1",new EngineCore.Color3(1,1,1)),w.texture2?n.setTexture("textureSampler2",w.texture2):n.setTexture("textureSampler2",k),w.sideTexture2?n.setTexture("textureSideSampler2",w.sideTexture2):n.setTexture("textureSideSampler2",k),w.color2?n.setColor3("vColor2",w.color2):n.setColor3("vColor2",new EngineCore.Color3(1,1,1)),w.texture3?n.setTexture("textureSampler3",w.texture3):n.setTexture("textureSampler3",k),w.sideTexture3?n.setTexture("textureSideSampler3",w.sideTexture3):n.setTexture("textureSideSampler2",k),w.color3?n.setColor3("vColor3",w.color3):n.setColor3("vColor3",new EngineCore.Color3(1,1,1)),w.texture4?n.setTexture("textureSampler4",w.texture4):n.setTexture("textureSampler4",k),w.sideTexture4?n.setTexture("textureSideSampler4",w.sideTexture4):n.setTexture("textureSideSampler4",k),w.color4?n.setColor3("vColor4",w.color4):n.setColor3("vColor4",new EngineCore.Color3(1,1,1)),w.texture5?n.setTexture("textureSampler5",w.texture5):n.setTexture("textureSampler5",k),w.sideTexture5?n.setTexture("textureSideSampler5",w.sideTexture5):n.setTexture("textureSideSampler5",k),w.color5?n.setColor3("vColor5",w.color5):n.setColor3("vColor5",new EngineCore.Color3(1,1,1)),w.texture6?n.setTexture("textureSampler6",w.texture6):n.setTexture("textureSampler6",k),w.sideTexture6?n.setTexture("textureSideSampler6",w.sideTexture6):n.setTexture("textureSideSampler6",k),w.color6?n.setColor3("vColor6",w.color6):n.setColor3("vColor6",new EngineCore.Color3(1,1,1)))},[n,w,k]),React.useEffect(()=>{var te;if(n&&E)if(L){const K=(te=L.startHeight)!=null?te:E.minimumWorld.y/D;return n.setFloat("contourLineStartHeight",K*D),n.setColor3("contourLineColor",L.color),n.setFloat("contourLineWidth",L.width),n.setFloat("contourLineStep",L.stepHeight*D),console.log("[Geo3DViewer] 等高线设置 ",L,E.centerWorld.y,K*D,K*D+16*L.stepHeight*D),()=>{n&&(n.setFloat("contourLineStartHeight",0),n.setColor3("contourLineColor",new EngineCore.Color3(0,0,0)),n.setFloat("contourLineWidth",0),n.setFloat("contourLineStep",0))}}else n.setFloat("contourLineStartHeight",0),n.setColor3("contourLineColor",new EngineCore.Color3(0,0,0)),n.setFloat("contourLineWidth",0),n.setFloat("contourLineStep",0),console.log("[Geo3DViewer] 等高线设置 关闭")},[L,D,B,E,n]),React.useEffect(()=>{t&&n&&E&&g(te=>{te&&te.dispose();let K=(E.maximum.x-E.minimum.x)/B,Z=(E.maximum.z-E.minimum.z)/B,ce=0;if(K<Z){const ge=K;K=Z,Z=ge,ce=1}const Q=K/Z;K*Z>2048*2048&&(K=2048,Z=2048/Q);const G=new EngineCore.DynamicTexture("dynamic-texture",{width:K,height:Z},t,!1);return G.clear(),console.log("[Geo3DViewer] 设置动态划线 ",E,K,Z,B),n.setVector3("oMin",E.minimum),n.setVector3("oMax",E.maximum),n.setFloat("textureOverlayRotate",ce),n.setTexture("textureOverlaySampler",G),G})},[E,n,B,t]),React.useEffect(()=>{var te;if(v&&E)if((te=v.getScene())!=null&&te.getEngine()){v.clear();let K=(E.maximum.x-E.minimum.x)/B,Z=(E.maximum.z-E.minimum.z)/B;if(K<Z){const G=K;K=Z,Z=G}const ce=K/Z;K*Z>2048*2048&&(K=2048,Z=2048/ce);const Q=v.getContext();W.forEach(G=>{if(G.points.length<2)return;Q.beginPath();const ge=G.offset?G.offset:new EngineCore.Vector2(0,0),fe=1-G.points[0].x+ge.x,V=1-G.points[0].y+ge.y;Q.moveTo(fe*K,V*Z);for(let J=1;J<G.points.length;J++){const Re=G.offset?G.offset:new EngineCore.Vector2(0,0),Ce=1-G.points[J].x+Re.x,Y=1-G.points[J].y+Re.y;Q.lineTo(Ce*K,Y*Z)}Q.strokeStyle=`rgb(${G.color.r*255}, ${G.color.g*255}, ${G.color.b*255})`,K*Z>2048*2048?Q.lineWidth=G.width/ce:Q.lineWidth=G.width,Q.stroke()}),ae.forEach(G=>{var J,Re;Q.font=`${G.fontSize}px Arial`;const ge=(J=G.color)!=null?J:EngineCore.Color3.White(),fe=G.offset?G.offset:new EngineCore.Vector2(0,0),V=(Re=G.rotation)!=null?Re:0;if(Q.save(),Q.translate((1-G.position.x+fe.x)*K,(1-G.position.y+fe.y)*Z),Q.rotate(V),G.clearArea){const Ce=Q.measureText(G.text);Q.clearRect(-Ce.width*.15,.5*G.fontSize*(1-.3),Ce.width*1.3,-G.fontSize*1.3)}if(G.background){Q.fillStyle=`rgba(${G.background.r*255}, ${G.background.g*255}, ${G.background.b*255})`;const Ce=Q.measureText(G.text);Q.fillRect(-Ce.width*.05,.5*(G.fontSize*(.5-.1)),Ce.width*1.1,-G.fontSize*1.1)}Q.fillStyle=`rgb(${ge.r*255}, ${ge.g*255}, ${ge.b*255})`,Q.fillText(G.text,0,0),Q.restore()}),v.update()}else console.log("[Geo3DViewer] 动态纹理未准备好,正准备下一次绘制")},[W,v,E,B,ae]),jsxRuntime.jsx(CustomShader$1,{...e,ref:oe,vertex:repeatedTextureProgressedVertexSource,fragment:repeatedTextureProgressedFragmentSource,options:{attributes:["position","color","normal"],uniforms:["world","worldViewProjection","alpha1","alpha2","alpha3","alpha4","alpha5","alpha6","oMin","oMax","tilingFactor","sideTilingFactor","mode","vColor1","vColor2","vColor3","vColor4","vColor5","vColor6","contourLineStartHeight","contourLineColor","contourLineWidth","contourLineStep","textureOverlayRotate","textureFlatRotate"],samplers:["textureSampler","textureOverlaySampler","textureSideSampler","textureSampler1","textureSideSampler1","textureSampler2","textureSideSampler2","textureSampler3","textureSideSampler3","textureSampler4","textureSideSampler4","textureSampler5","textureSideSampler5","textureSampler6","textureSideSampler6"],needAlphaBlending:!0,needAlphaTesting:!0,useClipPlane:!0},zOffset:O,zOffsetUnits:F,disableDepthWrite:ee})},FlatMaterial=e=>jsxRuntime.jsx(CustomShader$1,{...e,vertex:flatVertexSource,fragment:flatFragmentSource,options:{needAlphaBlending:!0},zOffset:e.zOffset,zOffsetUnits:e.zOffsetUnits,disableDepthWrite:e.disableDepthWrite}),PickingMaterial=()=>jsxRuntime.jsx(CustomShader$1,{name:"picking-material",vertex:pickingVertexSource,fragment:pickingFragmentSource,backFaceCulling:!1,options:{attributes:["position","color","normal"],uniforms:["world","worldViewProjection","pickingColor","isPickable"]}}),createMultiStageWaterEffectMaterial=({name:e,scene:t})=>{const n=EngineCore.NodeMaterial.Parse(MultiStageWaterMaterial,t);return n.name=e,n.backFaceCulling=!1,n.build(!1,!0,!1),n},useIntersectingLineMaterial=({name:e,lineColor:t,lineWidth:n=.5})=>{const a=reactBabylonjs.useScene(),[r,o]=React.useState(null);return React.useEffect(()=>{if(a){const i=EngineCore.NodeMaterial.Parse(intersectingLineSource,a);return i.name=`${e}-material`,i.backFaceCulling=!1,i.build(!1,!0,!1),o(i),()=>{o(s=>(s==null||s.dispose(!0,!1),null))}}},[e,a]),React.useEffect(()=>{o(i=>i&&t?(i.getBlockByName("Color3").value=t,i.build(!1,!0,!1),i):null)},[t]),React.useEffect(()=>{o(i=>{if(i&&n!==void 0&&n!==null){let s=n;return n<1&&(s=1),i.getBlockByName("offset").value=1-s,i.build(!1,!0,!1),i}return null})},[n]),r},VoxelGridMaterial=(e,t)=>{const n=React.useRef(null);return React.useEffect(()=>{n.current&&(n.current.setVector4("typeAlpha1",new EngineCore.Vector4(e.typeAlpha.typeAlpha0===void 0?1:e.typeAlpha.typeAlpha0,e.typeAlpha.typeAlpha1,e.typeAlpha.typeAlpha2,e.typeAlpha.typeAlpha3)),n.current.setVector4("typeAlpha2",new EngineCore.Vector4(e.typeAlpha.typeAlpha4,e.typeAlpha.typeAlpha5,e.typeAlpha.typeAlpha6,e.typeAlpha.typeAlpha7)),n.current.setVector4("typeAlpha3",new EngineCore.Vector4(e.typeAlpha.typeAlpha8,e.typeAlpha.typeAlpha9,e.typeAlpha.typeAlpha10,e.typeAlpha.typeAlpha11)),n.current.setVector4("typeAlpha4",new EngineCore.Vector4(e.typeAlpha.typeAlpha12,e.typeAlpha.typeAlpha13,e.typeAlpha.typeAlpha14,e.typeAlpha.typeAlpha15)),n.current.setVector4("typeAlpha5",new EngineCore.Vector4(e.typeAlpha.typeAlpha16,e.typeAlpha.typeAlpha17,e.typeAlpha.typeAlpha18,e.typeAlpha.typeAlpha19)))},[e.typeAlpha]),React.useImperativeHandle(t,()=>n.current,[]),jsxRuntime.jsx(CustomShader$1,{ref:n,name:e.name,backFaceCulling:!0,needDepthPrePass:!1,vertex:voxelGridVertexSource,fragment:voxelGridFragmentSource,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,alphaMode:EngineCore.Engine.ALPHA_COMBINE,options:{attributes:["position","color","uv","normal","world0","world1","world2","world3","instanceColor"],uniforms:["world","worldViewProjection","view","viewProjection","typeAlpha1","typeAlpha2","typeAlpha3","typeAlpha4","worldView","projection","previousWorld","vEyePosition"],defines:["#define INSTANCESCOLOR","#define INSTANCES"],needAlphaBlending:!0,needAlphaTesting:!0}})},OneColorMaterial=e=>{const t=reactBabylonjs.useScene(),[n,a]=React.useState(null),r=React.useRef(null),{boundingBox:o,counterLine:i,scaleDepth:s=1,scalePlane:l=1,color:c,alpha:f=1,lines:u=[],text:d=[],surfaceCanvasOptions:h={textureIncludeSide:!0},disableDepthWrite:m,disableNormalShadow:R=!1}=e,{textureIncludeSide:v}=h;return React.useEffect(()=>{r.current&&(console.log("[Geo3DViewer] 设置材质 ",c,f),r.current.setColor3("vColor",c),r.current.setFloat("vAlpha",f),r.current.setFloat("textureIncludeSide",v==null?1:0))},[c,f,v]),React.useEffect(()=>{var x;const g=r.current;if(g&&o)if(i){const y=(x=i.startHeight)!=null?x:o.maximumWorld.y/s;return g.setFloat("contourLineStartHeight",y*s),g.setColor3("contourLineColor",i.color),g.setFloat("contourLineWidth",i.width),g.setFloat("contourLineStep",i.stepHeight*s),console.log("[Geo3DViewer] 等高线设置 ",i,o.centerWorld.y,y*s,y*s-16*i.stepHeight*s),()=>{g&&(g.setFloat("contourLineStartHeight",0),g.setColor3("contourLineColor",new EngineCore.Color3(0,0,0)),g.setFloat("contourLineWidth",0),g.setFloat("contourLineStep",0))}}else g.setFloat("contourLineStartHeight",0),g.setColor3("contourLineColor",new EngineCore.Color3(0,0,0)),g.setFloat("contourLineWidth",0),g.setFloat("contourLineStep",0),console.log("[Geo3DViewer] 等高线设置 关闭")},[o,i,s,l]),React.useEffect(()=>{const g=r.current;t&&o&&g&&a(x=>{let y=(o.maximum.x-o.minimum.x)/l,E=(o.maximum.z-o.minimum.z)/l,k=0;if(y<E){const _=y;y=E,E=_,k=1}const b=y/E;y*E>2048*2048&&(y=2048,E=2048/b);let C;return x?(x.scaleTo(y,E),x.update(),C=x):C=new EngineCore.DynamicTexture("dynamic-texture",{width:y,height:E},t,!1),C.clear(),C.update(),console.log("[Geo3DViewer] 设置动态划线 ",o,y,E,l),g.setVector3("oMin",o.minimum),g.setVector3("oMax",o.maximum),g.setFloat("textureOverlayRotate",k),g.setTexture("textureOverlaySampler",C),C})},[o,l,t]),React.useEffect(()=>{var g;if(n&&o&&(u.length>0||d.length>0))if((g=n.getScene())!=null&&g.getEngine()){n.clear();let x=(o.maximum.x-o.minimum.x)/l,y=(o.maximum.z-o.minimum.z)/l;if(x<y){const b=x;x=y,y=b}const E=x/y;x*y>2048*2048&&(x=2048,y=2048/E);const k=n.getContext();u.forEach(b=>{if(b.points.length<2)return;k.beginPath();const C=b.offset?b.offset:new EngineCore.Vector2(0,0),_=1-b.points[0].x+C.x,A=1-b.points[0].y+C.y;k.moveTo(_*x,A*y);for(let N=1;N<b.points.length;N++){const S=b.offset?b.offset:new EngineCore.Vector2(0,0),I=1-b.points[N].x+S.x,O=1-b.points[N].y+S.y;k.lineTo(I*x,O*y)}k.strokeStyle=`rgb(${b.color.r*255}, ${b.color.g*255}, ${b.color.b*255})`,x*y>2048*2048?k.lineWidth=b.width/E:k.lineWidth=b.width,k.stroke()}),d.forEach(b=>{var N,S;k.font=`${b.fontSize}px Arial`;const C=(N=b.color)!=null?N:EngineCore.Color3.White(),_=b.offset?b.offset:new EngineCore.Vector2(0,0),A=(S=b.rotation)!=null?S:0;if(k.save(),k.translate((1-b.position.x+_.x)*x,(1-b.position.y+_.y)*y),k.rotate(A),b.clearArea){const I=k.measureText(b.text);k.clearRect(-I.width*.15,.5*b.fontSize*(1-.3),I.width*1.3,-b.fontSize*1.3)}if(b.background){k.fillStyle=`rgba(${b.background.r*255}, ${b.background.g*255}, ${b.background.b*255})`;const I=k.measureText(b.text);k.fillRect(-I.width*.05,.5*(b.fontSize*(.5-.1)),I.width*1.1,-b.fontSize*1.1)}k.fillStyle=`rgb(${C.r*255}, ${C.g*255}, ${C.b*255})`,k.fillText(b.text,0,0),k.restore()}),n.update()}else console.log("[Geo3DViewer] 动态纹理未准备好,正准备下一次绘制")},[u,n,o,l,d]),React.useEffect(()=>{const g=r.current;if(g){if(R)return g.setFloat("disableNormalShadow",1),console.log("[Geo3DViewer] 禁用法向阴影 启用"),()=>{g&&g.setFloat("disableNormalShadow",0)};g.setFloat("disableNormalShadow",0),console.log("[Geo3DViewer] 禁用法向阴影 禁用")}},[R]),jsxRuntime.jsx(CustomShader$1,{ref:r,name:e.name,backFaceCulling:e.backFaceCulling,needDepthPrePass:e.needDepthPrePass,vertex:oneColorVertexSource,fragment:oneColorFragmentSource,transparencyMode:e.transparencyMode,alphaMode:e.alphaMode,options:{attributes:["position","color","normal"],uniforms:["world","worldViewProjection","vAlpha","vColor","contourLineStartHeight","contourLineColor","contourLineWidth","contourLineStep","oMin","oMax","textureOverlayRotate","textureIncludeSide","disableNormalShadow"],samplers:["textureOverlaySampler"],needAlphaBlending:!0,needAlphaTesting:!0},zOffset:e.zOffset,zOffsetUnits:e.zOffsetUnits,disableDepthWrite:m})},VoxelGridMaterialForwardRef=React.forwardRef(VoxelGridMaterial),AttributeBody=({name:e,url:t,offset:n=EngineCore.Vector3.Zero(),alpha:a=1,material:r,visible:o=!0,actions:i})=>{const s=reactBabylonjs.useScene(),l=React.useRef(null),c=React.useContext(WorkspaceMetaContext),f=useCachedBinary({url:t,cacheType:CacheType.URL_PREFIX_MATCH}),u=useCachedTexture({url:r.texture,cacheType:CacheType.URL_PREFIX_MATCH}),d=useCachedTexture({url:r.sideTexture,cacheType:CacheType.URL_PREFIX_MATCH}),[h,m]=React.useState(EngineCore.Vector3.Zero()),[R,v]=React.useState();return React.useEffect(()=>{console.log("[Geo3DViewer] AttributeBody Loading: ",t)},[t]),React.useEffect(()=>{if(s&&l.current&&t&&f){EngineCore.Tags.EnableFor(l.current),EngineCore.Tags.AddTagsTo(l.current,"loading");const g=VirtualVolume.decode(new Uint8Array(f)),{points:x,indices:y,value:E,center:k}=g,b=new EngineCore.VertexData;b.positions=x,b.indices=y,b.colors=E;const C=[];EngineCore.VertexData.ComputeNormals(x,y,C),b.normals=C,k&&m(new EngineCore.Vector3(k.x,k.y,k.z));const _=l.current;_&&(b.applyToMesh(_),_.getScene().onAfterRenderObservable.addOnce(()=>{if(!_.isDisposed()){const N=_.getBoundingInfo();v(N.boundingBox)}})),EngineCore.Tags.RemoveTagsFrom(l.current,"loading")}},[t,s,f]),React.useEffect(()=>{l.current&&(l.current.metadata={pickable:i?{name:e,onLeftClick:i.onLeftClick,onRightClick:i.onRightClick,onMiddleClick:i.onMiddleClick,onHover:i.onHover,extra:i.extra}:null})},[i,e]),jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx("transformNode",{name:`transform-attribute-${e}`,position:h.add(n).multiplyByFloats(c&&c.scalePlane?c.scalePlane:1,c&&c.scaleDepth?c.scaleDepth:1,c&&c.scalePlane?c.scalePlane:1),scaling:new EngineCore.Vector3(c?c.scalePlane:1,c?c.scaleDepth:1,c?c.scalePlane:1),children:jsxRuntime.jsx("mesh",{name:`attributebody-${e}-mesh`,ref:l,setEnabled:o,useVertexColors:r.type===MaterialType.COLOR_CODEC,children:r.type===MaterialType.COLOR_CODEC&&r.colorCodec?jsxRuntime.jsx(RemapColorByRedChannelMaterial,{name:`attributebody-${e}-mat`,backFaceCulling:r.backFaceCulling===void 0?!0:r.backFaceCulling,needDepthPrePass:r.needDepthPrePass===void 0?!1:r.needDepthPrePass,alpha:r.alpha?r.alpha:a,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,alphaMode:EngineCore.Engine.ALPHA_COMBINE,colorCodec:r.colorCodec,boundingBox:R,lines:r.lines,text:r.text,scaleDepth:c?c.scaleDepth:1,scalePlane:c?c.scalePlane:1,disableDepthWrite:r.disableDepthWrite}):r.type===MaterialType.ONE_COLOR&&r.color?jsxRuntime.jsx("standardMaterial",{name:`attributebody-${e}-overwrite-mat`,backFaceCulling:r.backFaceCulling===void 0?!0:r.backFaceCulling,needDepthPrePass:r.needDepthPrePass===void 0?!1:r.needDepthPrePass,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,specularColor:new EngineCore.Color3(0,0,0),ambientColor:new EngineCore.Color3(1,1,1),diffuseColor:new EngineCore.Color3(r.color.r,r.color.g,r.color.b),emissiveColor:EngineCore.Color3.Black(),alphaMode:EngineCore.Engine.ALPHA_COMBINE,alpha:r.alpha?r.alpha:a,zOffset:-3,disableDepthWrite:r.disableDepthWrite}):r.type===MaterialType.TEXTURE&&u?jsxRuntime.jsx(RepeatedTextureMaterial,{name:`attributebody-${e}-texture-mat`,backFaceCulling:r.backFaceCulling===void 0?!0:r.backFaceCulling,needDepthPrePass:r.needDepthPrePass===void 0?!1:r.needDepthPrePass,alpha:r.alpha?r.alpha:a,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,alphaMode:EngineCore.Engine.ALPHA_COMBINE,texture:u,sideTexture:d,mode:r.textureMode===void 0?RepeatedTextureMode.PLANE:r.textureMode,boundingBox:R,disableDepthWrite:r.disableDepthWrite}):jsxRuntime.jsx(jsxRuntime.Fragment,{})})})})},AttributeBody$1=AttributeBody,ColorCodec=({codec:e,showValue:t=!1,showTitle:n=!0,width:a=80,height:r=200})=>{const o=React.useContext(ColorCodecImageContext);return jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsxs("adtFullscreenUi",{name:`adt-color-codec-${e}`,children:[n?jsxRuntime.jsx("textBlock",{name:`color-codec-title-${e}`,text:e,color:"white",paddingBottomInPixels:r+40/200*r,paddingRightInPixels:30/80*a,textVerticalAlignment:EngineGui.Control.VERTICAL_ALIGNMENT_CENTER,textHorizontalAlignment:EngineGui.Control.HORIZONTAL_ALIGNMENT_RIGHT}):jsxRuntime.jsx(jsxRuntime.Fragment,{}),jsxRuntime.jsx("babylon-image",{name:`color-codec-${e}`,source:o!=null&&o.colorCodecsImage.current[e]?o.colorCodecsImage.current[e].blobUrl:"",height:`${r}px`,width:`${a}px`,verticalAlignment:EngineGui.Control.VERTICAL_ALIGNMENT_CENTER,horizontalAlignment:EngineGui.Control.HORIZONTAL_ALIGNMENT_RIGHT,paddingRightInPixels:20}),t&&(o!=null&&o.colorCodecsImage.current[e])?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("textBlock",{name:"color-codec-value-min",text:o.colorCodecsImage.current[e].min.toFixed(1).toString(),color:"white",paddingBottomInPixels:-1*r,paddingRightInPixels:90,textVerticalAlignment:EngineGui.Control.VERTICAL_ALIGNMENT_CENTER,textHorizontalAlignment:EngineGui.Control.HORIZONTAL_ALIGNMENT_RIGHT}),jsxRuntime.jsx("textBlock",{name:"color-codec-title-avg",text:((o.colorCodecsImage.current[e].max-o.colorCodecsImage.current[e].min)/2).toFixed(1).toString(),color:"white",paddingBottomInPixels:0,paddingRightInPixels:a+10,textVerticalAlignment:EngineGui.Control.VERTICAL_ALIGNMENT_CENTER,textHorizontalAlignment:EngineGui.Control.HORIZONTAL_ALIGNMENT_RIGHT}),jsxRuntime.jsx("textBlock",{name:"color-codec-title-max",text:o.colorCodecsImage.current[e].max.toFixed(1).toString(),color:"white",paddingBottomInPixels:r,paddingRightInPixels:a+10,textVerticalAlignment:EngineGui.Control.VERTICAL_ALIGNMENT_CENTER,textHorizontalAlignment:EngineGui.Control.HORIZONTAL_ALIGNMENT_RIGHT})]}):null]})})},ColorCodec$1=ColorCodec;function createBaseFormation(){return{name:"",colorId:0,points:[],indices:[],bottomIndices:[],value:[],vMin:0,vMax:0,border:[],side:[],sideIndices:[],sideValue:[],center:void 0}}const Formation={encode(e,t=minimal.Writer.create()){e.name!==""&&t.uint32(10).string(e.name),e.colorId!==0&&t.uint32(16).uint32(e.colorId),t.uint32(170).fork();for(const n of e.points)t.float(n);t.ldelim(),t.uint32(178).fork();for(const n of e.indices)t.uint32(n);t.ldelim(),t.uint32(186).fork();for(const n of e.bottomIndices)t.uint32(n);t.ldelim(),t.uint32(194).fork();for(const n of e.value)t.float(n);t.ldelim(),e.vMin!==0&&t.uint32(205).float(e.vMin),e.vMax!==0&&t.uint32(213).float(e.vMax),t.uint32(218).fork();for(const n of e.border)t.uint32(n);t.ldelim(),t.uint32(226).fork();for(const n of e.side)t.float(n);t.ldelim(),t.uint32(234).fork();for(const n of e.sideIndices)t.uint32(n);t.ldelim(),t.uint32(242).fork();for(const n of e.sideValue)t.float(n);return t.ldelim(),e.center!==void 0&&Vertex.encode(e.center,t.uint32(250).fork()).ldelim(),t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseFormation();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.name=n.string();continue;case 2:if(o!==16)break;r.colorId=n.uint32();continue;case 21:if(o===173){r.points.push(n.float());continue}if(o===170){const i=n.uint32()+n.pos;for(;n.pos<i;)r.points.push(n.float());continue}break;case 22:if(o===176){r.indices.push(n.uint32());continue}if(o===178){const i=n.uint32()+n.pos;for(;n.pos<i;)r.indices.push(n.uint32());continue}break;case 23:if(o===184){r.bottomIndices.push(n.uint32());continue}if(o===186){const i=n.uint32()+n.pos;for(;n.pos<i;)r.bottomIndices.push(n.uint32());continue}break;case 24:if(o===197){r.value.push(n.float());continue}if(o===194){const i=n.uint32()+n.pos;for(;n.pos<i;)r.value.push(n.float());continue}break;case 25:if(o!==205)break;r.vMin=n.float();continue;case 26:if(o!==213)break;r.vMax=n.float();continue;case 27:if(o===216){r.border.push(n.uint32());continue}if(o===218){const i=n.uint32()+n.pos;for(;n.pos<i;)r.border.push(n.uint32());continue}break;case 28:if(o===229){r.side.push(n.float());continue}if(o===226){const i=n.uint32()+n.pos;for(;n.pos<i;)r.side.push(n.float());continue}break;case 29:if(o===232){r.sideIndices.push(n.uint32());continue}if(o===234){const i=n.uint32()+n.pos;for(;n.pos<i;)r.sideIndices.push(n.uint32());continue}break;case 30:if(o===245){r.sideValue.push(n.float());continue}if(o===242){const i=n.uint32()+n.pos;for(;n.pos<i;)r.sideValue.push(n.float());continue}break;case 31:if(o!==250)break;r.center=Vertex.decode(n,n.uint32());continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{name:isSet$b(e.name)?globalThis.String(e.name):"",colorId:isSet$b(e.colorId)?globalThis.Number(e.colorId):0,points:globalThis.Array.isArray(e==null?void 0:e.points)?e.points.map(t=>globalThis.Number(t)):[],indices:globalThis.Array.isArray(e==null?void 0:e.indices)?e.indices.map(t=>globalThis.Number(t)):[],bottomIndices:globalThis.Array.isArray(e==null?void 0:e.bottomIndices)?e.bottomIndices.map(t=>globalThis.Number(t)):[],value:globalThis.Array.isArray(e==null?void 0:e.value)?e.value.map(t=>globalThis.Number(t)):[],vMin:isSet$b(e.vMin)?globalThis.Number(e.vMin):0,vMax:isSet$b(e.vMax)?globalThis.Number(e.vMax):0,border:globalThis.Array.isArray(e==null?void 0:e.border)?e.border.map(t=>globalThis.Number(t)):[],side:globalThis.Array.isArray(e==null?void 0:e.side)?e.side.map(t=>globalThis.Number(t)):[],sideIndices:globalThis.Array.isArray(e==null?void 0:e.sideIndices)?e.sideIndices.map(t=>globalThis.Number(t)):[],sideValue:globalThis.Array.isArray(e==null?void 0:e.sideValue)?e.sideValue.map(t=>globalThis.Number(t)):[],center:isSet$b(e.center)?Vertex.fromJSON(e.center):void 0}},toJSON(e){var n,a,r,o,i,s,l,c;const t={};return e.name!==""&&(t.name=e.name),e.colorId!==0&&(t.colorId=Math.round(e.colorId)),(n=e.points)!=null&&n.length&&(t.points=e.points),(a=e.indices)!=null&&a.length&&(t.indices=e.indices.map(f=>Math.round(f))),(r=e.bottomIndices)!=null&&r.length&&(t.bottomIndices=e.bottomIndices.map(f=>Math.round(f))),(o=e.value)!=null&&o.length&&(t.value=e.value),e.vMin!==0&&(t.vMin=e.vMin),e.vMax!==0&&(t.vMax=e.vMax),(i=e.border)!=null&&i.length&&(t.border=e.border.map(f=>Math.round(f))),(s=e.side)!=null&&s.length&&(t.side=e.side),(l=e.sideIndices)!=null&&l.length&&(t.sideIndices=e.sideIndices.map(f=>Math.round(f))),(c=e.sideValue)!=null&&c.length&&(t.sideValue=e.sideValue),e.center!==void 0&&(t.center=Vertex.toJSON(e.center)),t},create(e){return Formation.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o,i,s,l,c,f,u,d,h;const t=createBaseFormation();return t.name=(n=e.name)!=null?n:"",t.colorId=(a=e.colorId)!=null?a:0,t.points=((r=e.points)==null?void 0:r.map(m=>m))||[],t.indices=((o=e.indices)==null?void 0:o.map(m=>m))||[],t.bottomIndices=((i=e.bottomIndices)==null?void 0:i.map(m=>m))||[],t.value=((s=e.value)==null?void 0:s.map(m=>m))||[],t.vMin=(l=e.vMin)!=null?l:0,t.vMax=(c=e.vMax)!=null?c:0,t.border=((f=e.border)==null?void 0:f.map(m=>m))||[],t.side=((u=e.side)==null?void 0:u.map(m=>m))||[],t.sideIndices=((d=e.sideIndices)==null?void 0:d.map(m=>m))||[],t.sideValue=((h=e.sideValue)==null?void 0:h.map(m=>m))||[],t.center=e.center!==void 0&&e.center!==null?Vertex.fromPartial(e.center):void 0,t}};function isSet$b(e){return e!=null}function earcut(e,t,n=2){const a=t&&t.length,r=a?t[0]*n:e.length;let o=linkedList(e,0,r,n,!0);const i=[];if(!o||o.next===o.prev)return i;let s,l,c;if(a&&(o=eliminateHoles(e,t,o,n)),e.length>80*n){s=e[0],l=e[1];let f=s,u=l;for(let d=n;d<r;d+=n){const h=e[d],m=e[d+1];h<s&&(s=h),m<l&&(l=m),h>f&&(f=h),m>u&&(u=m)}c=Math.max(f-s,u-l),c=c!==0?32767/c:0}return earcutLinked(o,i,n,s,l,c,0),i}function linkedList(e,t,n,a,r){let o;if(r===signedArea(e,t,n,a)>0)for(let i=t;i<n;i+=a)o=insertNode(i/a|0,e[i],e[i+1],o);else for(let i=n-a;i>=t;i-=a)o=insertNode(i/a|0,e[i],e[i+1],o);return o&&equals(o,o.next)&&(removeNode(o),o=o.next),o}function filterPoints(e,t){if(!e)return e;t||(t=e);let n=e,a;do if(a=!1,!n.steiner&&(equals(n,n.next)||area(n.prev,n,n.next)===0)){if(removeNode(n),n=t=n.prev,n===n.next)break;a=!0}else n=n.next;while(a||n!==t);return t}function earcutLinked(e,t,n,a,r,o,i){if(!e)return;!i&&o&&indexCurve(e,a,r,o);let s=e;for(;e.prev!==e.next;){const l=e.prev,c=e.next;if(o?isEarHashed(e,a,r,o):isEar(e)){t.push(l.i,e.i,c.i),removeNode(e),e=c.next,s=c.next;continue}if(e=c,e===s){i?i===1?(e=cureLocalIntersections(filterPoints(e),t),earcutLinked(e,t,n,a,r,o,2)):i===2&&splitEarcut(e,t,n,a,r,o):earcutLinked(filterPoints(e),t,n,a,r,o,1);break}}}function isEar(e){const t=e.prev,n=e,a=e.next;if(area(t,n,a)>=0)return!1;const r=t.x,o=n.x,i=a.x,s=t.y,l=n.y,c=a.y,f=Math.min(r,o,i),u=Math.min(s,l,c),d=Math.max(r,o,i),h=Math.max(s,l,c);let m=a.next;for(;m!==t;){if(m.x>=f&&m.x<=d&&m.y>=u&&m.y<=h&&pointInTriangleExceptFirst(r,s,o,l,i,c,m.x,m.y)&&area(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function isEarHashed(e,t,n,a){const r=e.prev,o=e,i=e.next;if(area(r,o,i)>=0)return!1;const s=r.x,l=o.x,c=i.x,f=r.y,u=o.y,d=i.y,h=Math.min(s,l,c),m=Math.min(f,u,d),R=Math.max(s,l,c),v=Math.max(f,u,d),g=zOrder(h,m,t,n,a),x=zOrder(R,v,t,n,a);let y=e.prevZ,E=e.nextZ;for(;y&&y.z>=g&&E&&E.z<=x;){if(y.x>=h&&y.x<=R&&y.y>=m&&y.y<=v&&y!==r&&y!==i&&pointInTriangleExceptFirst(s,f,l,u,c,d,y.x,y.y)&&area(y.prev,y,y.next)>=0||(y=y.prevZ,E.x>=h&&E.x<=R&&E.y>=m&&E.y<=v&&E!==r&&E!==i&&pointInTriangleExceptFirst(s,f,l,u,c,d,E.x,E.y)&&area(E.prev,E,E.next)>=0))return!1;E=E.nextZ}for(;y&&y.z>=g;){if(y.x>=h&&y.x<=R&&y.y>=m&&y.y<=v&&y!==r&&y!==i&&pointInTriangleExceptFirst(s,f,l,u,c,d,y.x,y.y)&&area(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;E&&E.z<=x;){if(E.x>=h&&E.x<=R&&E.y>=m&&E.y<=v&&E!==r&&E!==i&&pointInTriangleExceptFirst(s,f,l,u,c,d,E.x,E.y)&&area(E.prev,E,E.next)>=0)return!1;E=E.nextZ}return!0}function cureLocalIntersections(e,t){let n=e;do{const a=n.prev,r=n.next.next;!equals(a,r)&&intersects(a,n,n.next,r)&&locallyInside(a,r)&&locallyInside(r,a)&&(t.push(a.i,n.i,r.i),removeNode(n),removeNode(n.next),n=e=r),n=n.next}while(n!==e);return filterPoints(n)}function splitEarcut(e,t,n,a,r,o){let i=e;do{let s=i.next.next;for(;s!==i.prev;){if(i.i!==s.i&&isValidDiagonal(i,s)){let l=splitPolygon(i,s);i=filterPoints(i,i.next),l=filterPoints(l,l.next),earcutLinked(i,t,n,a,r,o,0),earcutLinked(l,t,n,a,r,o,0);return}s=s.next}i=i.next}while(i!==e)}function eliminateHoles(e,t,n,a){const r=[];for(let o=0,i=t.length;o<i;o++){const s=t[o]*a,l=o<i-1?t[o+1]*a:e.length,c=linkedList(e,s,l,a,!1);c===c.next&&(c.steiner=!0),r.push(getLeftmost(c))}r.sort(compareXYSlope);for(let o=0;o<r.length;o++)n=eliminateHole(r[o],n);return n}function compareXYSlope(e,t){let n=e.x-t.x;if(n===0&&(n=e.y-t.y,n===0)){const a=(e.next.y-e.y)/(e.next.x-e.x),r=(t.next.y-t.y)/(t.next.x-t.x);n=a-r}return n}function eliminateHole(e,t){const n=findHoleBridge(e,t);if(!n)return t;const a=splitPolygon(n,e);return filterPoints(a,a.next),filterPoints(n,n.next)}function findHoleBridge(e,t){let n=t;const a=e.x,r=e.y;let o=-1/0,i;if(equals(e,n))return n;do{if(equals(e,n.next))return n.next;if(r<=n.y&&r>=n.next.y&&n.next.y!==n.y){const u=n.x+(r-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(u<=a&&u>o&&(o=u,i=n.x<n.next.x?n:n.next,u===a))return i}n=n.next}while(n!==t);if(!i)return null;const s=i,l=i.x,c=i.y;let f=1/0;n=i;do{if(a>=n.x&&n.x>=l&&a!==n.x&&pointInTriangle(r<c?a:o,r,l,c,r<c?o:a,r,n.x,n.y)){const u=Math.abs(r-n.y)/(a-n.x);locallyInside(n,e)&&(u<f||u===f&&(n.x>i.x||n.x===i.x&&sectorContainsSector(i,n)))&&(i=n,f=u)}n=n.next}while(n!==s);return i}function sectorContainsSector(e,t){return area(e.prev,e,t.prev)<0&&area(t.next,e,e.next)<0}function indexCurve(e,t,n,a){let r=e;do r.z===0&&(r.z=zOrder(r.x,r.y,t,n,a)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==e);r.prevZ.nextZ=null,r.prevZ=null,sortLinked(r)}function sortLinked(e){let t,n=1;do{let a=e,r;e=null;let o=null;for(t=0;a;){t++;let i=a,s=0;for(let c=0;c<n&&(s++,i=i.nextZ,!!i);c++);let l=n;for(;s>0||l>0&&i;)s!==0&&(l===0||!i||a.z<=i.z)?(r=a,a=a.nextZ,s--):(r=i,i=i.nextZ,l--),o?o.nextZ=r:e=r,r.prevZ=o,o=r;a=i}o.nextZ=null,n*=2}while(t>1);return e}function zOrder(e,t,n,a,r){return e=(e-n)*r|0,t=(t-a)*r|0,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e|t<<1}function getLeftmost(e){let t=e,n=e;do(t.x<n.x||t.x===n.x&&t.y<n.y)&&(n=t),t=t.next;while(t!==e);return n}function pointInTriangle(e,t,n,a,r,o,i,s){return(r-i)*(t-s)>=(e-i)*(o-s)&&(e-i)*(a-s)>=(n-i)*(t-s)&&(n-i)*(o-s)>=(r-i)*(a-s)}function pointInTriangleExceptFirst(e,t,n,a,r,o,i,s){return!(e===i&&t===s)&&pointInTriangle(e,t,n,a,r,o,i,s)}function isValidDiagonal(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!intersectsPolygon(e,t)&&(locallyInside(e,t)&&locallyInside(t,e)&&middleInside(e,t)&&(area(e.prev,e,t.prev)||area(e,t.prev,t))||equals(e,t)&&area(e.prev,e,e.next)>0&&area(t.prev,t,t.next)>0)}function area(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function equals(e,t){return e.x===t.x&&e.y===t.y}function intersects(e,t,n,a){const r=sign(area(e,t,n)),o=sign(area(e,t,a)),i=sign(area(n,a,e)),s=sign(area(n,a,t));return!!(r!==o&&i!==s||r===0&&onSegment(e,n,t)||o===0&&onSegment(e,a,t)||i===0&&onSegment(n,e,a)||s===0&&onSegment(n,t,a))}function onSegment(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function sign(e){return e>0?1:e<0?-1:0}function intersectsPolygon(e,t){let n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&intersects(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}function locallyInside(e,t){return area(e.prev,e,e.next)<0?area(e,t,e.next)>=0&&area(e,e.prev,t)>=0:area(e,t,e.prev)<0||area(e,e.next,t)<0}function middleInside(e,t){let n=e,a=!1;const r=(e.x+t.x)/2,o=(e.y+t.y)/2;do n.y>o!=n.next.y>o&&n.next.y!==n.y&&r<(n.next.x-n.x)*(o-n.y)/(n.next.y-n.y)+n.x&&(a=!a),n=n.next;while(n!==e);return a}function splitPolygon(e,t){const n=createNode(e.i,e.x,e.y),a=createNode(t.i,t.x,t.y),r=e.next,o=t.prev;return e.next=t,t.prev=e,n.next=r,r.prev=n,a.next=n,n.prev=a,o.next=a,a.prev=o,a}function insertNode(e,t,n,a){const r=createNode(e,t,n);return a?(r.next=a.next,r.prev=a,a.next.prev=r,a.next=r):(r.prev=r,r.next=r),r}function removeNode(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function createNode(e,t,n){return{i:e,x:t,y:n,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function signedArea(e,t,n,a){let r=0;for(let o=t,i=n-a;o<n;o+=a)r+=(e[i]-e[o])*(e[o+1]+e[i+1]),i=o;return r}const Me=class Me{constructor(t,n,a="",r={},o=EngineCore.EngineStore.LastCreatedScene){le(this,"_name");le(this,"_text","");le(this,"_font");le(this,"_mesh",null);le(this,"_externalMesh");le(this,"_color",new EngineCore.Color4(1,1,1,1));le(this,"_fontSize",16);le(this,"_resolution",64);le(this,"_depth",10);le(this,"_scene");le(this,"_material");le(this,"_lowPriority",!0);le(this,"_disposed",!1);le(this,"_buildVersion",0);var i,s;this._name=t,this._font=n,this._text=a,this._fontSize=r.fontSize||16,this._resolution=r.resolution||64,this._depth=r.depth||1,this._color=r.color||new EngineCore.Color4(1,1,1,1),this._lowPriority=(i=r.lowPriority)!=null?i:!0,this._scene=o,this._externalMesh=new EngineCore.Mesh(`${t}-external-mesh`,o),this._externalMesh.billboardMode=(s=r.billboardMode)!=null?s:EngineCore.Mesh.BILLBOARDMODE_ALL,this._material=new EngineCore.StandardMaterial(`${t}-material`,o),this._material.diffuseColor=EngineCore.Color3.FromArray(this._color.asArray()),this._material.specularColor=new EngineCore.Color3(0,0,0),this._material.emissiveColor=EngineCore.Color3.FromArray(this._color.asArray()),this._material.disableLighting=!0,this._material.alpha=this._color.a,this._material.transparencyMode=EngineCore.Material.MATERIAL_ALPHABLEND,this.rebuildTextMesh()}static scheduleFlush(){if(Me._interactionPaused||Me._flushHandle!==null||Me._flushTimerHandle!==null)return;const t=globalThis;if(typeof t.requestIdleCallback=="function"){Me._flushHandle=t.requestIdleCallback(n=>{if(Me._flushHandle=null,!n.didTimeout&&n.timeRemaining()<3){Me.scheduleFlush();return}Me.flushQueue(1)},{timeout:120});return}if(typeof t.requestAnimationFrame=="function"){Me._flushHandle=t.requestAnimationFrame(()=>{Me._flushHandle=null,Me.flushQueue(1)});return}Me._flushTimerHandle=t.setTimeout(()=>{Me._flushTimerHandle=null,Me.flushQueue(1)},24)}static flushQueue(t){let n=0;for(;Me._pendingTasks.length>0&&n<t;){const a=Me._pendingTasks.shift();a==null||a(),n+=1}Me._pendingTasks.length>0&&Me.scheduleFlush()}static enqueueTask(t){Me._pendingTasks.push(t),Me.scheduleFlush()}static setInteractionPaused(t){Me._interactionPaused=t,t||Me.scheduleFlush()}createTextMeshNow(){this._disposed||(this._mesh=EngineCore.MeshBuilder.CreateText(this._name,this._text,this._font,{size:this._fontSize,resolution:this._resolution,depth:this._depth},this._scene,earcut),this._mesh.parent=this._externalMesh,this._mesh.material=this._material,this._mesh.billboardMode=this._externalMesh.billboardMode)}rebuildTextMesh(){this._buildVersion+=1;const t=this._buildVersion;if(this._mesh&&(this._mesh.dispose(),this._mesh=null),!(this._disposed||this._text===void 0||this._text===null||this._text.trim()==="")){if(!this._lowPriority){this.createTextMeshNow();return}Me.enqueueTask(()=>{this._disposed||t!==this._buildVersion||this.createTextMeshNow()})}}set color(t){this._color=t,this._material&&(this._material.diffuseColor=EngineCore.Color3.FromArray(t.asArray()),this._material.emissiveColor=EngineCore.Color3.FromArray(t.asArray()),this._material.alpha=t.a)}get color(){return this._color}set text(t){this._text!==t&&(this._text=t,this.rebuildTextMesh())}get text(){return this._text}set fontSize(t){this._fontSize!==t&&(this._fontSize=t,this.rebuildTextMesh())}get fontSize(){return this._fontSize}set resolution(t){this._resolution!==t&&(this._resolution=t,this.rebuildTextMesh())}get resolution(){return this._resolution}set depth(t){this._depth!==t&&(this._depth=t,this.rebuildTextMesh())}set billboardMode(t){this._externalMesh.billboardMode!==t&&(this._externalMesh.billboardMode=t,this._mesh&&(this._mesh.billboardMode=t))}get billboardMode(){return this._externalMesh.billboardMode}set lowPriority(t){const n=this._lowPriority!==t;this._lowPriority=t,n&&!t&&!this._mesh&&this._text.trim()!==""&&this.rebuildTextMesh()}get lowPriority(){return this._lowPriority}update(t){let n=!1;t.text!==void 0&&t.text!==this._text&&(this._text=t.text,n=!0),t.fontSize!==void 0&&t.fontSize!==this._fontSize&&(this._fontSize=t.fontSize,n=!0),t.resolution!==void 0&&t.resolution!==this._resolution&&(this._resolution=t.resolution,n=!0),t.depth!==void 0&&t.depth!==this._depth&&(this._depth=t.depth,n=!0),t.color!==void 0&&(this.color=t.color),t.billboardMode!==void 0&&(this.billboardMode=t.billboardMode),t.lowPriority!==void 0&&t.lowPriority!==this._lowPriority&&(this._lowPriority=t.lowPriority,!this._lowPriority&&!this._mesh&&this._text.trim()!==""&&(n=!0)),n&&this.rebuildTextMesh()}get depth(){return this._depth}get mesh(){return this._externalMesh}get textMesh(){return this._mesh}dispose(){this._disposed=!0,this._buildVersion+=1,this._mesh&&this._mesh.dispose(),this._material.dispose(),this._externalMesh.dispose(),this._mesh=null}};le(Me,"_pendingTasks",[]),le(Me,"_flushHandle",null),le(Me,"_flushTimerHandle",null),le(Me,"_interactionPaused",!1);let FreeTypeText=Me;const FreeTypeText$1=FreeTypeText,GUIText=e=>{const t=reactBabylonjs.useScene(),n=React.useRef(null),a=React.useRef(null),r=useCachedJSON({url:"/Noto Sans SC_Regular.json"}),{name:o,text:i,fontSize:s,color:l,billboardMode:c=EngineCore.Mesh.BILLBOARDMODE_ALL,lowPriority:f=!0}=e;return React.useEffect(()=>{var u;if(a.current&&a.current.dispose(),r&&t)return a.current=new FreeTypeText$1((u=e.name)!=null?u:"gui-text-no-name",r,e.text,{fontSize:e.fontSize,color:typeof e.color=="string"?EngineCore.Color4.FromHexString(e.color):e.color,billboardMode:c,lowPriority:f},t),a.current.mesh.parent=n.current,a.current.mesh.onDisposeObservable.addOnce(()=>{a.current=null}),()=>{var d;(d=a.current)==null||d.dispose(),a.current=null}},[r,t]),React.useEffect(()=>{a.current&&(a.current.update({text:i,fontSize:s,color:typeof l=="string"?EngineCore.Color4.FromHexString(l):l,lowPriority:f}),a.current.mesh.parent=n.current)},[i,s,l,f]),React.useEffect(()=>{a.current&&c!==void 0&&(a.current.billboardMode=c)},[c]),React.useEffect(()=>{if(!t||!t.activeCamera)return;let u=null;const d=()=>{FreeTypeText$1.setInteractionPaused(!0),u&&clearTimeout(u),u=setTimeout(()=>{FreeTypeText$1.setInteractionPaused(!1)},150)},h=t.activeCamera.onViewMatrixChangedObservable.add(d);return()=>{var m;(m=t.activeCamera)==null||m.onViewMatrixChangedObservable.remove(h),u&&clearTimeout(u),FreeTypeText$1.setInteractionPaused(!1)}},[t]),jsxRuntime.jsx("transformNode",{name:o!=null?o:"no-name-text",ref:n})},GUIText$1=GUIText,FormationFace=({urlTopLayer:e,urlBottomLayer:t,showLayerLabel:n=!1,labelStyle:a,position:r=EngineCore.Vector3.Zero(),visible:o=!0,showBottomLayer:i=!1,actions:s,material:l={type:MaterialType.COLOR_ID,alpha:1}})=>{var O,F;const c=React.useRef(null),f=React.useRef(null),[u,d]=React.useState(""),[h,m]=React.useState(null),R=React.useContext(WorkspaceMetaContext),v=React.useContext(ColorProviderContext),[g,x]=React.useState(EngineCore.Color3.White()),y=useCachedBinary({url:e,cacheType:CacheType.URL_PREFIX_MATCH}),E=useCachedBinary({url:t,cacheType:CacheType.URL_PREFIX_MATCH}),k=useCachedTexture({url:l==null?void 0:l.texture,cacheType:CacheType.URL_PREFIX_MATCH}),b=useCachedTexture({url:l==null?void 0:l.sideTexture,cacheType:CacheType.URL_PREFIX_MATCH});React.useEffect(()=>{console.log("[Geo3DViewer] FormationFace Loading: ",e,t)},[e,t]);const[C,_]=React.useState(),[A,N]=React.useState(EngineCore.Vector3.Zero()),[S,I]=React.useState(void 0);return React.useEffect(()=>{if(y){const w=c.current;w&&(EngineCore.Tags.EnableFor(w),EngineCore.Tags.AddTagsTo(w,"loading"));let L=[],B=[],D=[];const W=Formation.decode(new Uint8Array(y));{const{name:H,points:oe,indices:te,colorId:K,value:Z,center:ce}=W;L=oe,B=te,D=Z,m(K),d(H),ce&&N(new EngineCore.Vector3(ce.x,ce.y,ce.z))}const ae=new EngineCore.VertexData;ae.positions=L,ae.indices=B,ae.colors=D;const ee=[];if(EngineCore.VertexData.ComputeNormals(L,B,ee),ae.normals=ee,w){ae.applyToMesh(w);const H=w.getBoundingInfo();_(H.boundingBox.center.add(new EngineCore.Vector3(H.boundingBox.extendSize.x,0,0))),i||w.getScene().onAfterRenderObservable.addOnce(()=>{if(!w.isDisposed()){const te=w.getBoundingInfo();I(te.boundingBox)}})}return w&&EngineCore.Tags.RemoveTagsFrom(w,"loading"),()=>{w&&new EngineCore.VertexData().applyToMesh(w)}}},[y,i]),React.useEffect(()=>{if(y&&E){const w=f.current;w&&(EngineCore.Tags.EnableFor(w),EngineCore.Tags.AddTagsTo(w,"loading"));let L=[],B=[],D=[],W=[],ae=[],ee=[],H=[],oe=[];{const fe=Formation.decode(new Uint8Array(y)),{points:V,indices:J,border:Re,value:Ce}=fe;L=V,B=J,W=Re,D=Ce}{const fe=Formation.decode(new Uint8Array(E)),{points:V,bottomIndices:J,border:Re,value:Ce}=fe;ae=V,ee=J,H=Re,oe=Ce}const te=new EngineCore.VertexData,K=new Float32Array(L.length+ae.length);let Z=B.length+ee.length;Z=Z+(W.length-1)*6;const ce=new Int32Array(Z),Q=new Float32Array(D.length+oe.length);K.set(L),ce.set(B),Q.set(D),K.set(ae,L.length),ce.set(ee,B.length),Q.set(oe,D.length);const G=[];for(let fe=0;fe<W.length-1;fe++)G.push(W[fe+1]),G.push(W[fe]),G.push(H[fe]+L.length/3),G.push(H[fe+1]+L.length/3),G.push(H[fe]+L.length/3),G.push(W[fe+1]);ce.set(G,B.length+ee.length),te.positions=K,te.indices=ce,te.colors=Q;const ge=[];return EngineCore.VertexData.ComputeNormals(K,ce,ge),te.normals=ge,w&&(te.applyToMesh(w),i&&w.getScene().onAfterRenderObservable.addOnce(()=>{if(!w.isDisposed()){const V=w.getBoundingInfo();I(V.boundingBox)}})),w&&EngineCore.Tags.RemoveTagsFrom(w,"loading"),()=>{w&&new EngineCore.VertexData().applyToMesh(w)}}},[E,y,i]),React.useEffect(()=>{var w;x(l.type===MaterialType.ONE_COLOR?(w=l==null?void 0:l.color)!=null?w:EngineCore.Color3.Random():h&&v.colorIDs[h]?new EngineCore.Color3(v.colorIDs[h].r,v.colorIDs[h].g,v.colorIDs[h].b):EngineCore.Color3.Random())},[v.colorIDs,h,l==null?void 0:l.color,l.type]),React.useEffect(()=>{c.current&&(c.current.metadata={pickable:s?{name:u,onLeftClick:s.onLeftClick,onRightClick:s.onRightClick,onMiddleClick:s.onMiddleClick,onHover:s.onHover,extra:s.extra}:null}),f.current&&(f.current.metadata={pickable:s?{name:u,onLeftClick:s.onLeftClick,onRightClick:s.onRightClick,onMiddleClick:s.onMiddleClick,onHover:s.onHover,extra:s.extra}:null})},[s,u]),jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsxs("transformNode",{name:`transform-formation-${u}-${e}`,position:A.add(r).multiplyByFloats(R&&R.scalePlane?R.scalePlane:1,R&&R.scaleDepth?R.scaleDepth:1,R&&R.scalePlane?R.scalePlane:1),scaling:new EngineCore.Vector3(R?R.scalePlane:1,R?R.scaleDepth:1,R?R.scalePlane:1),setEnabled:o,children:[jsxRuntime.jsx("mesh",{name:`formation-${u}-mesh-${e}`,ref:c,setEnabled:!i,useVertexColors:l.type===MaterialType.COLOR_CODEC,alwaysSelectAsActiveMesh:!0,children:l.type===MaterialType.TEXTURE?k?jsxRuntime.jsx(RepeatedTextureMaterial,{name:`formation-${u}-mat-${e}`,backFaceCulling:l.backFaceCulling===void 0?!0:l.backFaceCulling,needDepthPrePass:l.needDepthPrePass===void 0?!0:l.needDepthPrePass,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,alphaMode:EngineCore.Engine.ALPHA_COMBINE,alpha:l.alpha,texture:k,sideTexture:b,tilingFactor:l.tilingFactor,sideTilingFactor:(O=l==null?void 0:l.sideTilingFactor)!=null?O:l==null?void 0:l.tilingFactor,mode:l.textureMode===void 0?RepeatedTextureMode.PLANE:l.textureMode,boundingBox:S,lines:l.lines,text:l.text,scaleDepth:R?R.scaleDepth:1,scalePlane:R?R.scalePlane:1,disableDepthWrite:l.disableDepthWrite}):jsxRuntime.jsx(jsxRuntime.Fragment,{}):l.type===MaterialType.COLOR_CODEC?l.colorCodec?jsxRuntime.jsx(RemapColorByRedChannelMaterial,{name:`formation-${u}-mat-${e}`,backFaceCulling:l.backFaceCulling===void 0?!0:l.backFaceCulling,needDepthPrePass:l.needDepthPrePass===void 0?!0:l.needDepthPrePass,alpha:l.alpha,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,alphaMode:EngineCore.Engine.ALPHA_COMBINE,colorCodec:l.colorCodec,boundingBox:S,lines:l.lines,text:l.text,scaleDepth:R?R.scaleDepth:1,scalePlane:R?R.scalePlane:1,disableDepthWrite:l.disableDepthWrite}):jsxRuntime.jsx(jsxRuntime.Fragment,{}):l.type===MaterialType.COLOR_ID?jsxRuntime.jsx(OneColorMaterial,{name:`formation-${u}-vol-mat-${e}`,backFaceCulling:l.backFaceCulling===void 0?!0:l.backFaceCulling,needDepthPrePass:l.needDepthPrePass===void 0?!0:l.needDepthPrePass,surfaceCanvasOptions:l.surfaceCanvasOptions,color:g,alphaMode:EngineCore.Engine.ALPHA_COMBINE,alpha:l.alpha,boundingBox:S,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,lines:l.lines,text:l.text,scaleDepth:R?R.scaleDepth:1,scalePlane:R?R.scalePlane:1,disableDepthWrite:l.disableDepthWrite,disableNormalShadow:l.disableNormalShadow}):jsxRuntime.jsx(OneColorMaterial,{name:`formation-${u}-vol-mat-${e}`,backFaceCulling:l.backFaceCulling===void 0?!0:l.backFaceCulling,needDepthPrePass:l.needDepthPrePass===void 0?!0:l.needDepthPrePass,color:g,surfaceCanvasOptions:l.surfaceCanvasOptions,alphaMode:EngineCore.Engine.ALPHA_COMBINE,alpha:l.alpha,boundingBox:S,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,lines:l.lines,text:l.text,scaleDepth:R?R.scaleDepth:1,scalePlane:R?R.scalePlane:1,disableDepthWrite:l.disableDepthWrite,disableNormalShadow:l.disableNormalShadow})}),jsxRuntime.jsx("mesh",{name:`formation-${u}-vol-${e}`,ref:f,setEnabled:i,useVertexColors:l.type===MaterialType.COLOR_CODEC,alwaysSelectAsActiveMesh:!0,children:l.type===MaterialType.TEXTURE?k?jsxRuntime.jsx(RepeatedTextureMaterial,{name:`formation-${u}-vol-mat-${e}`,backFaceCulling:l.backFaceCulling===void 0?!0:l.backFaceCulling,needDepthPrePass:l.needDepthPrePass===void 0?!0:l.needDepthPrePass,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,alphaMode:EngineCore.Engine.ALPHA_COMBINE,alpha:l.alpha,sideTexture:b,texture:k,tilingFactor:l.tilingFactor,sideTilingFactor:(F=l==null?void 0:l.sideTilingFactor)!=null?F:l==null?void 0:l.tilingFactor,mode:l.textureMode===void 0?RepeatedTextureMode.PLANE:l.textureMode,boundingBox:S,lines:l.lines,text:l.text,scaleDepth:R?R.scaleDepth:1,scalePlane:R?R.scalePlane:1,disableDepthWrite:l.disableDepthWrite}):jsxRuntime.jsx(jsxRuntime.Fragment,{}):l.type===MaterialType.COLOR_CODEC?l.colorCodec?jsxRuntime.jsx(RemapColorByRedChannelMaterial,{name:`formation-${u}-vol-mat-${e}`,backFaceCulling:l.backFaceCulling===void 0?!0:l.backFaceCulling,needDepthPrePass:l.needDepthPrePass===void 0?!0:l.needDepthPrePass,alpha:l.alpha,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,alphaMode:EngineCore.Engine.ALPHA_COMBINE,colorCodec:l.colorCodec,boundingBox:S,lines:l.lines,text:l.text,scaleDepth:R?R.scaleDepth:1,scalePlane:R?R.scalePlane:1,disableDepthWrite:l.disableDepthWrite}):jsxRuntime.jsx(jsxRuntime.Fragment,{}):l.type===MaterialType.COLOR_ID?jsxRuntime.jsx(OneColorMaterial,{name:`formation-${u}-vol-mat-${e}`,backFaceCulling:l.backFaceCulling===void 0?!0:l.backFaceCulling,needDepthPrePass:l.needDepthPrePass===void 0?!0:l.needDepthPrePass,surfaceCanvasOptions:l.surfaceCanvasOptions,color:g,alphaMode:EngineCore.Engine.ALPHA_COMBINE,alpha:l.alpha,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,boundingBox:S,lines:l.lines,text:l.text,scaleDepth:R?R.scaleDepth:1,scalePlane:R?R.scalePlane:1,disableDepthWrite:l.disableDepthWrite,disableNormalShadow:l.disableNormalShadow}):jsxRuntime.jsx(OneColorMaterial,{name:`formation-${u}-vol-mat-${e}`,backFaceCulling:l.backFaceCulling===void 0?!0:l.backFaceCulling,needDepthPrePass:l.needDepthPrePass===void 0?!0:l.needDepthPrePass,surfaceCanvasOptions:l.surfaceCanvasOptions,color:g,alphaMode:EngineCore.Engine.ALPHA_COMBINE,alpha:l.alpha,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,boundingBox:S,lines:l.lines,text:l.text,scaleDepth:R?R.scaleDepth:1,scalePlane:R?R.scalePlane:1,disableDepthWrite:l.disableDepthWrite,disableNormalShadow:l.disableNormalShadow})}),u&&C&&jsxRuntime.jsx("transformNode",{name:`${u}-title-${e}`,position:C.add(a!=null&&a.offset?a.offset.multiplyByFloats(R!=null&&R.scalePlane?R==null?void 0:R.scalePlane:1,1,R!=null&&R.scalePlane?R==null?void 0:R.scalePlane:1):EngineCore.Vector3.Zero()),scaling:calcGUIScale(R).multiply(new EngineCore.Vector3(3,3,3)),setEnabled:n,children:jsxRuntime.jsx(GUIText$1,{text:u,fontSize:a!=null&&a.fontSize?a.fontSize:40,color:a!=null&&a.color?a.color:"white"})})]})})},FormationFace$1=FormationFace,FormationVolume=({url:e,showLayerLabel:t=!1,labelStyle:n,position:a=EngineCore.Vector3.Zero(),visible:r=!0,showBottomLayer:o=!1,actions:i,material:s={type:MaterialType.COLOR_ID,counterLine:void 0,alpha:1}})=>{var S,I;const l=React.useRef(null),c=React.useRef(null),[f,u]=React.useState(""),[d,h]=React.useState(null),[m,R]=React.useState(EngineCore.Color3.White()),v=React.useContext(WorkspaceMetaContext),g=React.useContext(ColorProviderContext),[x,y]=React.useState(EngineCore.Vector3.Zero()),[E,k]=React.useState(),b=useCachedBinary({url:e,cacheType:CacheType.URL_PREFIX_MATCH}),C=useCachedTexture({url:s==null?void 0:s.texture,cacheType:CacheType.URL_PREFIX_MATCH}),_=useCachedTexture({url:s==null?void 0:s.sideTexture,cacheType:CacheType.URL_PREFIX_MATCH}),[A,N]=React.useState(void 0);return React.useEffect(()=>{console.log("[Geo3DViewer] FormationVolume Loading: ",e)},[e]),React.useEffect(()=>{if(b){const O=l.current,F=c.current;EngineCore.Tags.EnableFor(O),EngineCore.Tags.AddTagsTo(O,"loading"),EngineCore.Tags.EnableFor(c),EngineCore.Tags.AddTagsTo(c,"loading");let w=[],L=[],B=[],D=[];const W=Formation.decode(new Uint8Array(b)),{name:ae,points:ee,indices:H,colorId:oe,side:te,sideIndices:K,center:Z,value:ce,sideValue:Q}=W;Z&&y(new EngineCore.Vector3(Z.x,Z.y,Z.z)),w=ee,L=H,B=te,D=K,h(oe),u(ae);const G=new EngineCore.VertexData,ge=new EngineCore.VertexData,fe=new Float32Array(w.length+B.length),V=new Int32Array(L.length+D.length),J=new Float32Array(ce.length+Q.length);G.positions=w,G.indices=L,G.colors=ce;const Re=[];EngineCore.VertexData.ComputeNormals(ee,H,Re),G.normals=Re,fe.set(w),V.set(L),J.set(ce),fe.set(B,w.length),V.set(D,L.length),J.set(Q,ce.length),ge.positions=fe,ge.indices=V,ge.colors=J;const Ce=[];if(EngineCore.VertexData.ComputeNormals(fe,V,Ce),ge.normals=Ce,O){G.applyToMesh(O);const Y=O.getBoundingInfo();k(Y.boundingBox.center.add(new EngineCore.Vector3(Y.boundingBox.extendSize.x,0,0))),o||O.getScene().onAfterRenderObservable.addOnce(()=>{if(!O.isDisposed()){const ne=O.getBoundingInfo();N(ne.boundingBox)}})}return F&&(ge.applyToMesh(F),o&&F.getScene().onAfterRenderObservable.addOnce(()=>{if(!F.isDisposed()){const ue=F.getBoundingInfo();N(ue.boundingBox)}})),EngineCore.Tags.RemoveTagsFrom(O,"loading"),EngineCore.Tags.RemoveTagsFrom(c,"loading"),()=>{O&&new EngineCore.VertexData().applyToMesh(O),F&&new EngineCore.VertexData().applyToMesh(F)}}},[b,o]),React.useEffect(()=>{var O;R(s.type===MaterialType.ONE_COLOR?(O=s==null?void 0:s.color)!=null?O:EngineCore.Color3.Random():d&&g.colorIDs[d]?new EngineCore.Color3(g.colorIDs[d].r,g.colorIDs[d].g,g.colorIDs[d].b):EngineCore.Color3.Random())},[g.colorIDs,d,s==null?void 0:s.color,s.type]),React.useEffect(()=>{l.current&&(l.current.metadata={pickable:i?{name:f,onLeftClick:i.onLeftClick,onRightClick:i.onRightClick,onMiddleClick:i.onMiddleClick,onHover:i.onHover,extra:i.extra}:null}),c.current&&(c.current.metadata={pickable:i?{name:f,onLeftClick:i.onLeftClick,onRightClick:i.onRightClick,onMiddleClick:i.onMiddleClick,onHover:i.onHover,extra:i.extra}:null})},[i,f]),jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsxs("transformNode",{name:`transform-formation-${f}-${e}`,position:x.add(a).multiplyByFloats(v&&v.scalePlane?v.scalePlane:1,v&&v.scaleDepth?v.scaleDepth:1,v&&v.scalePlane?v.scalePlane:1),scaling:new EngineCore.Vector3(v?v.scalePlane:1,v?v.scaleDepth:1,v?v.scalePlane:1),setEnabled:r,children:[jsxRuntime.jsx("mesh",{name:`formation-${f}-mesh-${e}`,ref:l,setEnabled:!o,useVertexColors:s.type===MaterialType.COLOR_CODEC,children:s.type===MaterialType.TEXTURE?C?jsxRuntime.jsx(RepeatedTextureMaterial,{name:`formation-${f}-mat-${e}`,backFaceCulling:s.backFaceCulling===void 0?!0:s.backFaceCulling,needDepthPrePass:s.needDepthPrePass===void 0?!0:s.needDepthPrePass,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,alphaMode:EngineCore.Engine.ALPHA_COMBINE,alpha:s.alpha,flatModeRotate:s.flatModeRotate,sideTexture:_,texture:C,tilingFactor:s.tilingFactor,sideTilingFactor:(S=s==null?void 0:s.sideTilingFactor)!=null?S:s==null?void 0:s.tilingFactor,mode:s.textureMode===void 0?RepeatedTextureMode.PLANE:s.textureMode,counterLine:s.counterLine,boundingBox:A,lines:s.lines,text:s.text,scaleDepth:v?v.scaleDepth:1,scalePlane:v?v.scalePlane:1,disableDepthWrite:s.disableDepthWrite}):jsxRuntime.jsx(jsxRuntime.Fragment,{}):s.type===MaterialType.COLOR_CODEC?s.colorCodec?jsxRuntime.jsx(RemapColorByRedChannelMaterial,{name:`formation-${f}-mat-${e}`,backFaceCulling:s.backFaceCulling===void 0?!0:s.backFaceCulling,needDepthPrePass:s.needDepthPrePass===void 0?!0:s.needDepthPrePass,alpha:s.alpha,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,alphaMode:EngineCore.Engine.ALPHA_COMBINE,colorCodec:s.colorCodec,counterLine:s.counterLine,boundingBox:A,lines:s.lines,text:s.text,scaleDepth:v?v.scaleDepth:1,scalePlane:v?v.scalePlane:1,disableDepthWrite:s.disableDepthWrite}):jsxRuntime.jsx(jsxRuntime.Fragment,{}):s.type===MaterialType.COLOR_ID?jsxRuntime.jsx(DiffuseTerrainMaterial$1,{name:`formation-${f}-vol-mat-${e}`,backFaceCulling:s.backFaceCulling===void 0?!0:s.backFaceCulling,needDepthPrePass:s.needDepthPrePass===void 0?!0:s.needDepthPrePass,color:m,alphaMode:EngineCore.Engine.ALPHA_COMBINE,alpha:s.alpha,lightPosition:s.lightPosition,intensity:s.intensity,surfaceCanvasOptions:s.surfaceCanvasOptions,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,boundingBox:A,lines:s.lines,text:s.text,zOffset:s.zOffset,zOffsetUnits:s.zOffsetUnits,contrast:s.contrast,sideIntensity:s.sideIntensity,cullFace:s.cullFace,scaleDepth:v?v.scaleDepth:1,scalePlane:v?v.scalePlane:1,disableDepthWrite:s.disableDepthWrite}):jsxRuntime.jsx(DiffuseTerrainMaterial$1,{name:`formation-${f}-vol-mat-${e}`,backFaceCulling:s.backFaceCulling===void 0?!0:s.backFaceCulling,needDepthPrePass:s.needDepthPrePass===void 0?!0:s.needDepthPrePass,color:m,alphaMode:EngineCore.Engine.ALPHA_COMBINE,surfaceCanvasOptions:s.surfaceCanvasOptions,alpha:s.alpha,lightPosition:s.lightPosition,intensity:s.intensity,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,boundingBox:A,lines:s.lines,text:s.text,zOffset:s.zOffset,zOffsetUnits:s.zOffsetUnits,contrast:s.contrast,sideIntensity:s.sideIntensity,cullFace:s.cullFace,scaleDepth:v?v.scaleDepth:1,scalePlane:v?v.scalePlane:1,disableDepthWrite:s.disableDepthWrite})}),jsxRuntime.jsx("mesh",{name:`formation-${f}-vol-${e}`,ref:c,setEnabled:o,useVertexColors:s.type===MaterialType.COLOR_CODEC,children:s.type===MaterialType.TEXTURE?C?jsxRuntime.jsx(RepeatedTextureMaterial,{name:`formation-${f}-vol-mat-${e}`,backFaceCulling:s.backFaceCulling===void 0?!0:s.backFaceCulling,needDepthPrePass:s.needDepthPrePass===void 0?!0:s.needDepthPrePass,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,alphaMode:EngineCore.Engine.ALPHA_COMBINE,alpha:s.alpha,sideTexture:_,texture:C,tilingFactor:s.tilingFactor,sideTilingFactor:(I=s==null?void 0:s.sideTilingFactor)!=null?I:s==null?void 0:s.tilingFactor,mode:s.textureMode===void 0?RepeatedTextureMode.PLANE:s.textureMode,flatModeRotate:s.flatModeRotate,counterLine:s.counterLine,boundingBox:A,lines:s.lines,text:s.text,scaleDepth:v?v.scaleDepth:1,scalePlane:v?v.scalePlane:1,disableDepthWrite:s.disableDepthWrite}):jsxRuntime.jsx(jsxRuntime.Fragment,{}):s.type===MaterialType.COLOR_CODEC?s.colorCodec?jsxRuntime.jsx(RemapColorByRedChannelMaterial,{name:`formation-${f}-vol-mat-${e}`,backFaceCulling:s.backFaceCulling===void 0?!0:s.backFaceCulling,needDepthPrePass:s.needDepthPrePass===void 0?!0:s.needDepthPrePass,alpha:s.alpha,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,alphaMode:EngineCore.Engine.ALPHA_COMBINE,colorCodec:s.colorCodec,counterLine:s.counterLine,boundingBox:A,lines:s.lines,text:s.text,scaleDepth:v?v.scaleDepth:1,scalePlane:v?v.scalePlane:1,disableDepthWrite:s.disableDepthWrite}):jsxRuntime.jsx(jsxRuntime.Fragment,{}):s.type===MaterialType.COLOR_ID?jsxRuntime.jsx(DiffuseTerrainMaterial$1,{name:`formation-${f}-vol-mat-${e}`,backFaceCulling:s.backFaceCulling===void 0?!0:s.backFaceCulling,needDepthPrePass:s.needDepthPrePass===void 0?!0:s.needDepthPrePass,color:m,surfaceCanvasOptions:s.surfaceCanvasOptions,alphaMode:EngineCore.Engine.ALPHA_COMBINE,alpha:s.alpha,lightPosition:s.lightPosition,intensity:s.intensity,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,boundingBox:A,lines:s.lines,text:s.text,zOffset:s.zOffset,zOffsetUnits:s.zOffsetUnits,contrast:s.contrast,sideIntensity:s.sideIntensity,cullFace:s.cullFace,scaleDepth:v?v.scaleDepth:1,scalePlane:v?v.scalePlane:1,disableDepthWrite:s.disableDepthWrite}):jsxRuntime.jsx(DiffuseTerrainMaterial$1,{name:`formation-${f}-vol-mat-${e}`,backFaceCulling:s.backFaceCulling===void 0?!0:s.backFaceCulling,needDepthPrePass:s.needDepthPrePass===void 0?!0:s.needDepthPrePass,color:m,surfaceCanvasOptions:s.surfaceCanvasOptions,alphaMode:EngineCore.Engine.ALPHA_COMBINE,alpha:s.alpha,lightPosition:s.lightPosition,intensity:s.intensity,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,boundingBox:A,lines:s.lines,text:s.text,zOffset:s.zOffset,zOffsetUnits:s.zOffsetUnits,contrast:s.contrast,sideIntensity:s.sideIntensity,cullFace:s.cullFace,scaleDepth:v?v.scaleDepth:1,scalePlane:v?v.scalePlane:1,disableDepthWrite:s.disableDepthWrite})}),f&&E&&jsxRuntime.jsx("transformNode",{name:`${f}-title-${e}`,position:E.add(n!=null&&n.offset?n.offset.multiplyByFloats(v!=null&&v.scalePlane?v==null?void 0:v.scalePlane:1,1,v!=null&&v.scalePlane?v==null?void 0:v.scalePlane:1):EngineCore.Vector3.Zero()),scaling:calcGUIScale(v).multiply(new EngineCore.Vector3(3,3,3)),setEnabled:t,children:jsxRuntime.jsx(GUIText$1,{text:f,fontSize:n!=null&&n.fontSize?n.fontSize:40,color:n!=null&&n.color?n.color:"white"})})]})})},FormationVolume$1=FormationVolume;var FormationGroup_FormationMode=(e=>(e[e.FACE=0]="FACE",e[e.VOLUME=1]="VOLUME",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED",e))(FormationGroup_FormationMode||{});function formationGroup_FormationModeFromJSON(e){switch(e){case 0:case"FACE":return 0;case 1:case"VOLUME":return 1;case-1:case"UNRECOGNIZED":default:return-1}}function formationGroup_FormationModeToJSON(e){switch(e){case 0:return"FACE";case 1:return"VOLUME";case-1:default:return"UNRECOGNIZED"}}function createBaseFormationGroup(){return{name:"",formations:[],mode:0,effectMeshs:[]}}const FormationGroup={encode(e,t=minimal.Writer.create()){e.name!==""&&t.uint32(10).string(e.name);for(const n of e.formations)FormationGroup_FormationInfo.encode(n,t.uint32(34).fork()).ldelim();e.mode!==0&&t.uint32(40).int32(e.mode);for(const n of e.effectMeshs)Mesh.encode(n,t.uint32(50).fork()).ldelim();return t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseFormationGroup();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.name=n.string();continue;case 4:if(o!==34)break;r.formations.push(FormationGroup_FormationInfo.decode(n,n.uint32()));continue;case 5:if(o!==40)break;r.mode=n.int32();continue;case 6:if(o!==50)break;r.effectMeshs.push(Mesh.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{name:isSet$a(e.name)?globalThis.String(e.name):"",formations:globalThis.Array.isArray(e==null?void 0:e.formations)?e.formations.map(t=>FormationGroup_FormationInfo.fromJSON(t)):[],mode:isSet$a(e.mode)?formationGroup_FormationModeFromJSON(e.mode):0,effectMeshs:globalThis.Array.isArray(e==null?void 0:e.effectMeshs)?e.effectMeshs.map(t=>Mesh.fromJSON(t)):[]}},toJSON(e){var n,a;const t={};return e.name!==""&&(t.name=e.name),(n=e.formations)!=null&&n.length&&(t.formations=e.formations.map(r=>FormationGroup_FormationInfo.toJSON(r))),e.mode!==0&&(t.mode=formationGroup_FormationModeToJSON(e.mode)),(a=e.effectMeshs)!=null&&a.length&&(t.effectMeshs=e.effectMeshs.map(r=>Mesh.toJSON(r))),t},create(e){return FormationGroup.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o;const t=createBaseFormationGroup();return t.name=(n=e.name)!=null?n:"",t.formations=((a=e.formations)==null?void 0:a.map(i=>FormationGroup_FormationInfo.fromPartial(i)))||[],t.mode=(r=e.mode)!=null?r:0,t.effectMeshs=((o=e.effectMeshs)==null?void 0:o.map(i=>Mesh.fromPartial(i)))||[],t}};function createBaseFormationGroup_FormationInfo(){return{name:"",url:""}}const FormationGroup_FormationInfo={encode(e,t=minimal.Writer.create()){return e.name!==""&&t.uint32(10).string(e.name),e.url!==""&&t.uint32(18).string(e.url),t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseFormationGroup_FormationInfo();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.name=n.string();continue;case 2:if(o!==18)break;r.url=n.string();continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{name:isSet$a(e.name)?globalThis.String(e.name):"",url:isSet$a(e.url)?globalThis.String(e.url):""}},toJSON(e){const t={};return e.name!==""&&(t.name=e.name),e.url!==""&&(t.url=e.url),t},create(e){return FormationGroup_FormationInfo.fromPartial(e!=null?e:{})},fromPartial(e){var n,a;const t=createBaseFormationGroup_FormationInfo();return t.name=(n=e.name)!=null?n:"",t.url=(a=e.url)!=null?a:"",t}};function isSet$a(e){return e!=null}const StructureLayer=({url:e,alpha:t=1,position:n=EngineCore.Vector3.Zero(),visible:a=!0,colorCodec:r,actions:o,counterLine:i=void 0,lines:s,text:l,disableDepthWrite:c})=>{const f=React.useRef(null),[u,d]=React.useState(""),h=React.useContext(WorkspaceMetaContext),m=React.useContext(ColorProviderContext),[R,v]=React.useState(null),[g,x]=React.useState(EngineCore.Color3.White()),y=useCachedBinary({url:e,cacheType:CacheType.URL_PREFIX_MATCH}),[E,k]=React.useState(EngineCore.Vector3.Zero()),[b,C]=React.useState();return React.useEffect(()=>{console.log("[Geo3DViewer] StructureLayer Loading: ",e)},[e]),React.useEffect(()=>{if(y){const _=f.current;EngineCore.Tags.EnableFor(_),EngineCore.Tags.AddTagsTo(_,"loading");const A=Formation.decode(new Uint8Array(y)),{name:N,points:S,indices:I,value:O,colorId:F,center:w}=A;w&&k(new EngineCore.Vector3(w.x,w.y,w.z));const L=new EngineCore.VertexData;L.positions=S,L.indices=I,L.colors=O;const B=[];return EngineCore.VertexData.ComputeNormals(S,I,B),L.normals=B,v(F),d(N),_&&(L.applyToMesh(_),_.getScene().onAfterRenderObservable.addOnce(()=>{if(!_.isDisposed()){const W=_.getBoundingInfo();C(W.boundingBox)}})),EngineCore.Tags.RemoveTagsFrom(_,"loading"),()=>{v(null),d(""),_&&new EngineCore.VertexData().applyToMesh(_)}}},[y]),React.useEffect(()=>{const _=R&&m.colorIDs[R]?m.colorIDs[R]:EngineCore.Color3.White();x(EngineCore.Color3.FromArray([_.r,_.g,_.b]))},[R,m.colorIDs]),React.useEffect(()=>{f.current&&(f.current.metadata={pickable:o?{name:u,onLeftClick:o.onLeftClick,onRightClick:o.onRightClick,onMiddleClick:o.onMiddleClick,onHover:o.onHover,extra:o.extra}:null})},[o,u]),jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsxs("transformNode",{name:`transform-structurelayer-${u}`,position:E.add(n).multiplyByFloats(h&&h.scalePlane?h.scalePlane:1,h&&h.scaleDepth?h.scaleDepth:1,h&&h.scalePlane?h.scalePlane:1),scaling:new EngineCore.Vector3(h?h.scalePlane:1,h?h.scaleDepth:1,h?h.scalePlane:1),setEnabled:a,children:[jsxRuntime.jsx("transformNode",{name:`structurelayer-${u}-load`}),jsxRuntime.jsx("mesh",{name:`structurelayer-${u}-mesh`,ref:f,useVertexColors:r!=null,children:r?jsxRuntime.jsx(RemapColorByRedChannelMaterial,{name:`structurelayer-${u}-mat`,backFaceCulling:!1,alpha:t,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,alphaMode:EngineCore.Engine.ALPHA_COMBINE,colorCodec:r,needDepthPrePass:!0,counterLine:i,boundingBox:b,lines:s,scaleDepth:h?h.scaleDepth:1,scalePlane:h?h.scalePlane:1,text:l,disableDepthWrite:c}):jsxRuntime.jsx("standardMaterial",{name:`structurelayer-${u}-mat`,backFaceCulling:!1,specularColor:new EngineCore.Color3(0,0,0),ambientColor:new EngineCore.Color3(1,1,1),diffuseColor:g,needDepthPrePass:!0,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,alphaMode:EngineCore.Engine.ALPHA_COMBINE,alpha:t,disableDepthWrite:c})})]})})},StructureLayer$1=StructureLayer,FormationEdgeEffect=e=>{const{id:t,visible:n=!0,position:a=EngineCore.Vector3.Zero(),diffuseTextureUrl:r,diffuseTextureSufaceUrl:o,bumpTextureUrl:i,mesh:s}=e,l=React.useRef(null),c=React.useContext(WorkspaceMetaContext),[f,u]=React.useState(),[d,h]=React.useState(),[m,R]=React.useState();return React.useEffect(()=>{const v=l.current;if(v&&s){const g=new EngineCore.VertexData;g.positions=s.vertices,g.indices=s.indices,g.uvs=s.uv;const x=[];EngineCore.VertexData.ComputeNormals(s.vertices,s.indices,x),g.normals=x,g.applyToMesh(v)}},[s,s==null?void 0:s.indices,s==null?void 0:s.uv,s==null?void 0:s.vertices]),React.useEffect(()=>{const v=new EngineCore.Texture(r);if(v.uScale=500,v.vScale=.5,u(v),o){const x=new EngineCore.Texture(o);x.uScale=500,x.vScale=.5,h(x)}const g=new EngineCore.Texture(i);g.uScale=500,g.vScale=.5,R(g)},[i,o,r]),jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx("transformNode",{name:`transform-formation-edge-${t}`,position:a.multiplyByFloats(c&&c.scalePlane?c.scalePlane:1,c&&c.scaleDepth?c.scaleDepth:1,c&&c.scalePlane?c.scalePlane:1),scaling:new EngineCore.Vector3(c?c.scalePlane:1,c?c.scaleDepth:1,c?c.scalePlane:1),setEnabled:n,children:jsxRuntime.jsx("mesh",{name:"mesh",ref:l,children:jsxRuntime.jsx("standardMaterial",{name:`edge-${t}-material`,zOffset:-1,zOffsetUnits:-1,diffuseTexture:o?d:f,bumpTexture:o?void 0:m})})})})},FormationEdgeEffect$1=FormationEdgeEffect,ComplexFormationManager=({url:e,visible:t=!0,filter:n,explodedView:a=0,showLayerLabel:r,labelStyle:o,offset:i=new EngineCore.Vector3(0,0,0),showTopLayerAsStructureLayer:s=!1,useColorCodecOnTopLayer:l=!1,colorCodec:c,actions:f,materials:u,topLayerCounterLine:d=void 0,topLayerHeightOffset:h=1,diffuseTextureUrl:m,diffuseTextureSufaceUrl:R,bumpTextureUrl:v,visibleEdgeEffect:g=!1})=>{var I,O;const[x,y]=React.useState(),E=React.useContext(WorkspaceMetaContext),[k,b]=React.useState(!0),[C,_]=React.useState(""),A=useCachedBinary({url:e,cacheType:CacheType.URL_PREFIX_MATCH}),[N,S]=React.useState([]);return React.useEffect(()=>{console.log("[Geo3DViewer] ComplexFormationManager Loading: ",e)},[e]),React.useEffect(()=>{if(A){const F=FormationGroup.decode(new Uint8Array(A)),w=F.formations;if(F.mode==FormationGroup_FormationMode.FACE){b(!0),_(F.name);const L=[];w.forEach((B,D)=>{const W={name:B.name,topUrl:B.url,bottomUrl:w[D+1]?w[D+1].url:void 0};L.push(W)}),y(L)}else{b(!1),_(F.name);const L=[];w.forEach(B=>{const D={name:B.name,topUrl:B.url};L.push(D)}),y(L)}return console.log(F),S(F.effectMeshs),()=>{y([])}}},[A]),jsxRuntime.jsxs("abstractMesh",{name:`complexformationmanager-${C}`,children:[s&&x&&x.length>1?jsxRuntime.jsx(StructureLayer$1,{url:x[0].topUrl,alpha:(I=u==null?void 0:u[x[0].name])==null?void 0:I.alpha,position:new EngineCore.Vector3(0,h>=0?h*(E&&(O=E.scaleDepth)!=null?O:1):0,0).add(i),visible:t&&(n?n.includes(x[0].name):!0),colorCodec:c,counterLine:d},`${C}-${x[0].name}-SL`):null,x?x.map((F,w)=>k?s&&w===0?jsxRuntime.jsx(jsxRuntime.Fragment,{}):jsxRuntime.jsx("transformNode",{name:`${C}-${F.name}-EV`,position:i.add(new EngineCore.Vector3(0,w*(-1*a*(E&&E.scaleDepth?E.scaleDepth:0)),0)),children:jsxRuntime.jsx(FormationFace$1,{showLayerLabel:r,labelStyle:o,urlTopLayer:F.topUrl,urlBottomLayer:F.bottomUrl,visible:t&&(n?n.includes(F.name):!0),showBottomLayer:x[w+1]?n?n.includes(x[w+1].name):!0:!1,actions:f,material:w===0&&l?{...u==null?void 0:u[F.name],colorCodec:c,type:MaterialType.COLOR_CODEC}:u==null?void 0:u[F.name]},`${C}-${F.name}`)},`${C}-${F.name}`):s&&w===0?jsxRuntime.jsx(jsxRuntime.Fragment,{}):jsxRuntime.jsx("transformNode",{name:`${C}-${F.name}-EV`,position:i.add(new EngineCore.Vector3(0,w*(-1*a*(E&&E.scaleDepth?E.scaleDepth:0)),0)),children:jsxRuntime.jsx(FormationVolume$1,{url:F.topUrl,showLayerLabel:r,labelStyle:o,visible:t&&(n?n.includes(F.name):!0),showBottomLayer:x[w+1]?n?n.includes(x[w+1].name):!0:!1,actions:f,material:u==null?void 0:u[F.name]},`${C}-${F.name}`)},`${C}-${F.name}`)):null,N&&m&&v&&a===0&&N.map((F,w)=>jsxRuntime.jsx(FormationEdgeEffect$1,{visible:g,id:w,diffuseTextureUrl:m,diffuseTextureSufaceUrl:w===0?R:void 0,bumpTextureUrl:v,mesh:F},w))]})},ComplexFormationManager$1=ComplexFormationManager,Coordinate=({visible:e=!0,color:t=EngineCore.Color3.White(),fontSize:n=80,step:a=200,keyFrameDistance:r=[],keyFrameStep:o=[],keyFrameFontSize:i=[],textureSizeX:s=512,textureSizeY:l=512,init:c=!0})=>{const f=reactBabylonjs.useScene(),u=React.useRef(null),d=React.useContext(WorkspaceMetaContext),[h,m]=React.useState([]),[R,v]=React.useState([]),[g,x]=React.useState([]),[y,E]=React.useState(0),k=React.useCallback(b=>{if(f&&b){const C=new EngineMaterial.GridMaterial("axis-material",f);C.majorUnitFrequency=o.length>0?o[0]:50,C.minorUnitVisibility=0,C.gridRatio=2,C.sideOrientation=EngineCore.Material.ClockWiseSideOrientation,C.backFaceCulling=!0,C.mainColor=t,C.lineColor=t,C.opacity=.98,b.material=C}},[t,o,f]);return React.useEffect(()=>()=>{var b;(b=u.current)==null||b.dispose()},[]),React.useEffect(()=>{const b=()=>{const C=(f==null?void 0:f.activeCamera).radius;for(let _=0;_<r.length;_++)if(C<=r[_]){E(_);break}};return f&&f.activeCamera&&(f==null||f.activeCamera.onViewMatrixChangedObservable.add(b)),()=>{f&&f.activeCamera&&(f==null||f.activeCamera.onViewMatrixChangedObservable.removeCallback(b))}},[r,i,o,f,e]),React.useEffect(()=>{if(d&&d.min&&d.max&&c){const b=d.origin||EngineCore.Vector3.Zero(),C=[],_=[],A=[],N=[...o];N.length===0&&N.push(a);for(let S=0;S<N.length;S++){let I=N[S]/1;I<1&&(I=200);const O=[];for(let L=0;L<=d.max.x-d.min.x;L+=I)O.push({text:`${L+d.min.x+b.x}`,position:new EngineCore.Vector3(L,0,0)}),O.push({text:`${L+d.min.x+b.x}`,position:new EngineCore.Vector3(L,d.max.y-d.min.y,d.max.z-d.min.z)}),O.push({text:`${L+d.min.x+b.x}`,position:new EngineCore.Vector3(L,d.max.y-d.min.y,0)}),O.push({text:`${L+d.min.x+b.x}`,position:new EngineCore.Vector3(L,0,d.max.z-d.min.z)});C.push(O);const F=[];for(let L=0;L<=d.max.y-d.min.y;L+=I)F.push({text:`${L+d.min.y+b.y}`,position:new EngineCore.Vector3(0,L,0)}),F.push({text:`${L+d.min.y+b.y}`,position:new EngineCore.Vector3(d.max.x-d.min.x,L,d.max.z-d.min.z)}),F.push({text:`${L+d.min.y+b.y}`,position:new EngineCore.Vector3(d.max.x-d.min.x,L,0)}),F.push({text:`${L+d.min.y+b.y}`,position:new EngineCore.Vector3(0,L,d.max.z-d.min.z)});_.push(F);const w=[];for(let L=0;L<=d.max.z-d.min.z;L+=I)w.push({text:`${L+d.min.z+b.z}`,position:new EngineCore.Vector3(0,0,L)}),w.push({text:`${L+d.min.z+b.z}`,position:new EngineCore.Vector3(d.max.x-d.min.x,d.max.y-d.min.y,L)}),w.push({text:`${L+d.min.z+b.z}`,position:new EngineCore.Vector3(0,d.max.y-d.min.y,L)}),w.push({text:`${L+d.min.z+b.z}`,position:new EngineCore.Vector3(d.max.x-d.min.x,0,L)});A.push(w)}m(C),v(_),x(A)}},[c,o,d,a]),d&&d.min&&d.max&&d.max.x-d.min.x>0&&d.max.y-d.min.y>0&&d.max.z-d.min.z>0?jsxRuntime.jsxs("transformNode",{name:"coord",setEnabled:e,position:(d&&d.min&&d.max?EngineCore.Vector3.Center(d.min,d.max):EngineCore.Vector3.Zero()).multiply(calcTransformNodeScale(d)),scaling:new EngineCore.Vector3(calcTransformNodeScale(d).x,calcTransformNodeScale(d).y,calcTransformNodeScale(d).z),children:[jsxRuntime.jsx("box",{name:"axis",width:d&&d.min&&d.max?d.max.x-d.min.x:0,height:d&&d.min&&d.max?d.max.y-d.min.y:0,depth:d&&d.min&&d.max?d.max.z-d.min.z:0,ref:k,isPickable:!1,isBlocker:!1},`axis-${d.max.x-d.min.x}-${d.max.y-d.min.y}-${d.max.z-d.min.z}`),jsxRuntime.jsxs("transformNode",{name:"axis-offset",position:d&&d.min&&d.max?new EngineCore.Vector3(-(d.max.x-d.min.x)/2,-(d.max.y-d.min.y)/2,-(d.max.z-d.min.z)/2):EngineCore.Vector3.Zero(),children:[h.map((b,C)=>b.map((_,A)=>{var S;const N=_;return jsxRuntime.jsx("transformNode",{name:`axis-x-${C}-${A}`,position:N==null?void 0:N.position,setEnabled:C===y,scaling:new EngineCore.Vector3(1/calcTransformNodeScale(d).x,1/calcTransformNodeScale(d).y,1/calcTransformNodeScale(d).z),children:jsxRuntime.jsx(GUIText$1,{text:`${N?N.text:""}`,fontSize:(S=i[C])!=null?S:n,color:t.toHexString()})},`axis-x-${C}-${A}`)})),R.map((b,C)=>b.map((_,A)=>{var S;const N=_;return jsxRuntime.jsx("transformNode",{name:`axis-x-${C}-${A}`,position:N==null?void 0:N.position,setEnabled:C===y,scaling:new EngineCore.Vector3(1/calcTransformNodeScale(d).x,1/calcTransformNodeScale(d).y,1/calcTransformNodeScale(d).z),children:jsxRuntime.jsx(GUIText$1,{text:`${N?N.text:""}`,fontSize:(S=i[C])!=null?S:n,color:t.toHexString()})},`axis-x-${C}-${A}`)})),g.map((b,C)=>b.map((_,A)=>{var S;const N=_;return jsxRuntime.jsx("transformNode",{name:`axis-x-${C}-${A}`,position:N==null?void 0:N.position,setEnabled:C===y,scaling:new EngineCore.Vector3(1/calcTransformNodeScale(d).x,1/calcTransformNodeScale(d).y,1/calcTransformNodeScale(d).z),children:jsxRuntime.jsx(GUIText$1,{text:`${N?N.text:""}`,fontSize:(S=i[C])!=null?S:n,color:t.toHexString()})},`axis-x-${C}-${A}`)}))]})]},`coord-${d.min.x}-${d.min.y}-${d.min.z}-${d.max.x}-${d.max.y}-${d.max.z}-${Math.abs(d.max.x-d.min.x)}-${Math.abs(d.max.y-d.min.y)}-${Math.abs(d.max.z-d.min.z)}`):jsxRuntime.jsx(jsxRuntime.Fragment,{})},Coordinate$1=Coordinate;function contourLine_ContourLineTypeFromJSON(e){switch(e){case 0:case"NORMAL":return 0;case 1:case"CICLE":return 1;case-1:case"UNRECOGNIZED":default:return-1}}function contourLine_ContourLineTypeToJSON(e){switch(e){case 0:return"NORMAL";case 1:return"CICLE";case-1:default:return"UNRECOGNIZED"}}function createBaseContourLine(){return{name:"",lines:[]}}const ContourLine$2={encode(e,t=minimal.Writer.create()){e.name!==""&&t.uint32(10).string(e.name);for(const n of e.lines)ContourLine_Line.encode(n,t.uint32(18).fork()).ldelim();return t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseContourLine();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.name=n.string();continue;case 2:if(o!==18)break;r.lines.push(ContourLine_Line.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{name:isSet$9(e.name)?globalThis.String(e.name):"",lines:globalThis.Array.isArray(e==null?void 0:e.lines)?e.lines.map(t=>ContourLine_Line.fromJSON(t)):[]}},toJSON(e){var n;const t={};return e.name!==""&&(t.name=e.name),(n=e.lines)!=null&&n.length&&(t.lines=e.lines.map(a=>ContourLine_Line.toJSON(a))),t},create(e){return ContourLine$2.fromPartial(e!=null?e:{})},fromPartial(e){var n,a;const t=createBaseContourLine();return t.name=(n=e.name)!=null?n:"",t.lines=((a=e.lines)==null?void 0:a.map(r=>ContourLine_Line.fromPartial(r)))||[],t}};function createBaseContourLine_LineSegment(){return{positions:[]}}const ContourLine_LineSegment={encode(e,t=minimal.Writer.create()){for(const n of e.positions)Position.encode(n,t.uint32(10).fork()).ldelim();return t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseContourLine_LineSegment();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.positions.push(Position.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{positions:globalThis.Array.isArray(e==null?void 0:e.positions)?e.positions.map(t=>Position.fromJSON(t)):[]}},toJSON(e){var n;const t={};return(n=e.positions)!=null&&n.length&&(t.positions=e.positions.map(a=>Position.toJSON(a))),t},create(e){return ContourLine_LineSegment.fromPartial(e!=null?e:{})},fromPartial(e){var n;const t=createBaseContourLine_LineSegment();return t.positions=((n=e.positions)==null?void 0:n.map(a=>Position.fromPartial(a)))||[],t}};function createBaseContourLine_Line(){return{segments:[],type:0,position:void 0}}const ContourLine_Line={encode(e,t=minimal.Writer.create()){for(const n of e.segments)ContourLine_LineSegment.encode(n,t.uint32(10).fork()).ldelim();return e.type!==0&&t.uint32(16).int32(e.type),e.position!==void 0&&Position.encode(e.position,t.uint32(26).fork()).ldelim(),t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseContourLine_Line();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.segments.push(ContourLine_LineSegment.decode(n,n.uint32()));continue;case 2:if(o!==16)break;r.type=n.int32();continue;case 3:if(o!==26)break;r.position=Position.decode(n,n.uint32());continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{segments:globalThis.Array.isArray(e==null?void 0:e.segments)?e.segments.map(t=>ContourLine_LineSegment.fromJSON(t)):[],type:isSet$9(e.type)?contourLine_ContourLineTypeFromJSON(e.type):0,position:isSet$9(e.position)?Position.fromJSON(e.position):void 0}},toJSON(e){var n;const t={};return(n=e.segments)!=null&&n.length&&(t.segments=e.segments.map(a=>ContourLine_LineSegment.toJSON(a))),e.type!==0&&(t.type=contourLine_ContourLineTypeToJSON(e.type)),e.position!==void 0&&(t.position=Position.toJSON(e.position)),t},create(e){return ContourLine_Line.fromPartial(e!=null?e:{})},fromPartial(e){var n,a;const t=createBaseContourLine_Line();return t.segments=((n=e.segments)==null?void 0:n.map(r=>ContourLine_LineSegment.fromPartial(r)))||[],t.type=(a=e.type)!=null?a:0,t.position=e.position!==void 0&&e.position!==null?Position.fromPartial(e.position):void 0,t}};function isSet$9(e){return e!=null}const Line=({points:e=[],showPoint:t=!0,color:n=EngineCore.Color3.White(),pointSize:a=2,alwaysOnTop:r=!1,offset:o=EngineCore.Vector3.Zero(),alpha:i,lineWidth:s})=>{const l=reactBabylonjs.useScene(),c=React.useRef(null),f=React.useContext(WorkspaceMetaContext);return React.useEffect(()=>{if(l){const u=[],d=calcTransformNodeScale(f);if(e.forEach(h=>{u.push(h.add(o).multiply(d))}),s){const h={path:u,radius:s,updatable:!0};if(c.current)h.instance=c.current,EngineCore.MeshBuilder.CreateTube("line",h);else{c.current=EngineCore.MeshBuilder.CreateTube("line",h,l);const m=new EngineCore.StandardMaterial("line-mat");return m.diffuseColor=n,m.specularColor=EngineCore.Color3.Black(),m.emissiveColor=n,i!==void 0&&(m.alpha=i,m.transparencyMode=2),m.depthFunction=r?EngineCore.Constants.ALWAYS:0,c.current.material=m,()=>{c.current&&(l.removeMesh(c.current),c.current=null)}}}else{const h={points:u,updateable:!0};if(c.current)h.instance=c.current,EngineCore.MeshBuilder.CreateLines("line",h);else{c.current=EngineCore.MeshBuilder.CreateLines("line",h,l);const m=new EngineCore.StandardMaterial("line-mat");return m.diffuseColor=n,m.specularColor=EngineCore.Color3.Black(),m.emissiveColor=n,i!==void 0&&(m.alpha=i,m.transparencyMode=2),m.depthFunction=r?EngineCore.Constants.ALWAYS:0,()=>{c.current&&(l.removeMesh(c.current),c.current=null)}}}}},[r,n,f,o,e,l,s,c,i]),jsxRuntime.jsx("transformNode",{name:"transform-line",children:t?jsxRuntime.jsx("transformNode",{name:"lines-point",children:e.map((u,d)=>jsxRuntime.jsx("sphere",{diameter:a,name:`lines-point-${d}`,position:u.add(o).multiply(calcTransformNodeScale(f)),scalingDeterminant:s&&(f==null?void 0:f.scalePlane)||1,children:jsxRuntime.jsx("standardMaterial",{name:`lines-point-${d}-mat`,diffuseColor:n,emissiveColor:n,specularColor:EngineCore.Color3.White(),depthFunction:r?EngineCore.Constants.ALWAYS:void 0})},`lines-point-${u.x}-${u.y}-${u.z}`))}):jsxRuntime.jsx(jsxRuntime.Fragment,{})})},Line$1=Line,ContourText=e=>{const{name:t,prev:n,next:a,textColor:r,fontSize:o}=e,i=reactBabylonjs.useScene(),s=React.useRef(null);return React.useEffect(()=>{const l=i==null?void 0:i.activeCamera,c=i==null?void 0:i.getEngine();if(i&&l&&c&&s.current){const f=s.current.getChildren()[0],u=EngineCore.Vector3.Normalize(a.subtract(n)),d=new EngineCore.Vector3(1,0,0),h=Math.acos(EngineCore.Vector3.Dot(u,d)),m=EngineCore.Vector3.Cross(u,d);f.rotation.z=m.y>0?h:Math.PI*2-h,f.rotation.x=Math.PI/2,f.renderingGroupId=3}},[a,n,i]),jsxRuntime.jsx("transformNode",{name:`${t}`,position:EngineCore.Vector3.Lerp(n,a,.5),ref:s,children:jsxRuntime.jsx(GUIText$1,{text:t,fontSize:o,color:r,billboardMode:EngineCore.Mesh.BILLBOARDMODE_NONE})})},ContourText$1=ContourText,ContourLine=e=>{const{url:t,color:n,alpha:a,visible:r=!0,fontSize:o=30,textColor:i="red",linewidth:s=10}=e,l=reactBabylonjs.useScene(),[c,f]=React.useState([]),[u,d]=React.useState([]),h=React.useContext(WorkspaceMetaContext);return React.useEffect(()=>{axios.get(t,{responseType:"arraybuffer"}).then(m=>{const R=ContourLine$2.decode(new Uint8Array(m.data));console.log(R);const v=[],g=[];for(let x=0;x<R.lines.length;x++){const y=R.lines[x];if(y.segments.length<2)continue;const E=[];for(let k=0;k<y.segments.length;k++){const b=[...convertPositionArrayToVector3(y.segments[k].positions)];v.push([...b]),E.push(b[0]),E.push(b[b.length-1])}y.type===1&&E.push(convertPositionToVector3(y.segments[0].positions[0])),g.push(E)}f(v),d(g),console.log(g),console.log(v)})},[l,t]),jsxRuntime.jsxs("transformNode",{name:"contourline",setEnabled:r,children:[c.map((m,R)=>m.length<2||!r?null:jsxRuntime.jsx(Line$1,{points:m,showPoint:!1,color:n,alpha:a,lineWidth:s,alwaysOnTop:!0},R)),u.map(m=>m.map((R,v)=>v%2===0||v===m.length-1?null:jsxRuntime.jsx(ContourText$1,{name:R.y.toFixed(0),prev:calcTransformNodeScale(h).multiply(R),next:calcTransformNodeScale(h).multiply(m[v+1]),fontSize:o,textColor:i},v)))]})},ContourLine$1=ContourLine;function densitySlice_DirectionFromJSON(e){switch(e){case 0:case"X":return 0;case 1:case"Y":return 1;case 2:case"Z":return 2;case 3:case"FREE":return 3;case-1:case"UNRECOGNIZED":default:return-1}}function densitySlice_DirectionToJSON(e){switch(e){case 0:return"X";case 1:return"Y";case 2:return"Z";case 3:return"FREE";case-1:default:return"UNRECOGNIZED"}}function createBaseDensitySlice(){return{layer:0,direction:0,colorId:0,points:[],indices:[],value:[],vMin:0,vMax:0,center:void 0}}const DensitySlice$2={encode(e,t=minimal.Writer.create()){e.layer!==0&&t.uint32(8).uint32(e.layer),e.direction!==0&&t.uint32(16).int32(e.direction),e.colorId!==0&&t.uint32(24).uint32(e.colorId),t.uint32(170).fork();for(const n of e.points)t.float(n);t.ldelim(),t.uint32(178).fork();for(const n of e.indices)t.uint32(n);t.ldelim(),t.uint32(186).fork();for(const n of e.value)t.float(n);return t.ldelim(),e.vMin!==0&&t.uint32(205).float(e.vMin),e.vMax!==0&&t.uint32(213).float(e.vMax),e.center!==void 0&&Vertex.encode(e.center,t.uint32(250).fork()).ldelim(),t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseDensitySlice();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==8)break;r.layer=n.uint32();continue;case 2:if(o!==16)break;r.direction=n.int32();continue;case 3:if(o!==24)break;r.colorId=n.uint32();continue;case 21:if(o===173){r.points.push(n.float());continue}if(o===170){const i=n.uint32()+n.pos;for(;n.pos<i;)r.points.push(n.float());continue}break;case 22:if(o===176){r.indices.push(n.uint32());continue}if(o===178){const i=n.uint32()+n.pos;for(;n.pos<i;)r.indices.push(n.uint32());continue}break;case 23:if(o===189){r.value.push(n.float());continue}if(o===186){const i=n.uint32()+n.pos;for(;n.pos<i;)r.value.push(n.float());continue}break;case 25:if(o!==205)break;r.vMin=n.float();continue;case 26:if(o!==213)break;r.vMax=n.float();continue;case 31:if(o!==250)break;r.center=Vertex.decode(n,n.uint32());continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{layer:isSet$8(e.layer)?globalThis.Number(e.layer):0,direction:isSet$8(e.direction)?densitySlice_DirectionFromJSON(e.direction):0,colorId:isSet$8(e.colorId)?globalThis.Number(e.colorId):0,points:globalThis.Array.isArray(e==null?void 0:e.points)?e.points.map(t=>globalThis.Number(t)):[],indices:globalThis.Array.isArray(e==null?void 0:e.indices)?e.indices.map(t=>globalThis.Number(t)):[],value:globalThis.Array.isArray(e==null?void 0:e.value)?e.value.map(t=>globalThis.Number(t)):[],vMin:isSet$8(e.vMin)?globalThis.Number(e.vMin):0,vMax:isSet$8(e.vMax)?globalThis.Number(e.vMax):0,center:isSet$8(e.center)?Vertex.fromJSON(e.center):void 0}},toJSON(e){var n,a,r;const t={};return e.layer!==0&&(t.layer=Math.round(e.layer)),e.direction!==0&&(t.direction=densitySlice_DirectionToJSON(e.direction)),e.colorId!==0&&(t.colorId=Math.round(e.colorId)),(n=e.points)!=null&&n.length&&(t.points=e.points),(a=e.indices)!=null&&a.length&&(t.indices=e.indices.map(o=>Math.round(o))),(r=e.value)!=null&&r.length&&(t.value=e.value),e.vMin!==0&&(t.vMin=e.vMin),e.vMax!==0&&(t.vMax=e.vMax),e.center!==void 0&&(t.center=Vertex.toJSON(e.center)),t},create(e){return DensitySlice$2.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o,i,s,l,c;const t=createBaseDensitySlice();return t.layer=(n=e.layer)!=null?n:0,t.direction=(a=e.direction)!=null?a:0,t.colorId=(r=e.colorId)!=null?r:0,t.points=((o=e.points)==null?void 0:o.map(f=>f))||[],t.indices=((i=e.indices)==null?void 0:i.map(f=>f))||[],t.value=((s=e.value)==null?void 0:s.map(f=>f))||[],t.vMin=(l=e.vMin)!=null?l:0,t.vMax=(c=e.vMax)!=null?c:0,t.center=e.center!==void 0&&e.center!==null?Vertex.fromPartial(e.center):void 0,t}};function isSet$8(e){return e!=null}const DensitySlice=({name:e,url:t,visible:n=!0,colorCodec:a,alpha:r=1,position:o=EngineCore.Vector3.Zero(),actions:i})=>{const s=React.useRef(null),[l,c]=React.useState(""),[f,u]=React.useState(""),d=React.useContext(WorkspaceMetaContext),h=useCachedBinary({url:t,cacheType:CacheType.URL_PREFIX_MATCH}),[m,R]=React.useState(EngineCore.Vector3.Zero());return React.useEffect(()=>{if(h){EngineCore.Tags.EnableFor(s.current),EngineCore.Tags.AddTagsTo(s.current,"loading");const v=DensitySlice$2.decode(new Uint8Array(h)),{layer:g,direction:x,points:y,indices:E,value:k,center:b}=v,C=new EngineCore.VertexData;C.positions=y,C.indices=E,C.colors=k;const _=[];EngineCore.VertexData.ComputeNormals(y,E,_),C.normals=_,b&&R(new EngineCore.Vector3(b.x,b.y,b.z));const A=s.current;return A&&(C.applyToMesh(A),c(g.toString()),u(x.toString())),EngineCore.Tags.RemoveTagsFrom(A,"loading"),()=>{c(""),u(""),A&&new EngineCore.VertexData().applyToMesh(A)}}},[h]),React.useEffect(()=>{s.current&&(s.current.metadata={pickable:i?{name:e,onLeftClick:i.onLeftClick,onRightClick:i.onRightClick,onMiddleClick:i.onMiddleClick,onHover:i.onHover,extra:i.extra}:null})},[i,e]),React.useEffect(()=>{console.log("[Geo3DViewer] DensitySlice Loading: ",t)},[t]),jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx("transformNode",{name:`densityslice-${e}-${f}-${l}-transform`,position:m.add(o).multiplyByFloats(d&&d.scalePlane?d.scalePlane:1,d&&d.scaleDepth?d.scaleDepth:1,d&&d.scalePlane?d.scalePlane:1),scaling:new EngineCore.Vector3(d?d.scalePlane:1,d?d.scaleDepth:1,d?d.scalePlane:1),children:jsxRuntime.jsx("mesh",{name:`densityslice-${e}-${f}-${l}-mesh`,ref:s,setEnabled:n,children:jsxRuntime.jsx(RemapColorByRedChannelMaterial,{name:`densityslice-${e}-${f}-${l}-mat`,backFaceCulling:!1,needDepthPrePass:!0,alpha:r,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,alphaMode:EngineCore.Engine.ALPHA_COMBINE,colorCodec:a})})})})},DensitySlice$1=DensitySlice,FPS=()=>{const e=reactBabylonjs.useScene(),t=React.useRef(void 0);return React.useEffect(()=>{const n=setInterval(()=>{if(e&&t.current){const a=e.getEngine().getFps();t.current.getControlByName("fps").text=a.toFixed(0)+"FPS"}},1e3);return()=>{clearInterval(n)}},[e]),React.useEffect(()=>{var n,a;if(e&&!t.current){const r=EngineGui.AdvancedDynamicTexture.CreateFullscreenUI("UI",!0,e);t.current=r;const o=new EngineGui.TextBlock("fps");o.text="0FPS",o.color="white",o.fontSize=15,o.width=100,o.height=50;const i=window.devicePixelRatio||1,s=(n=e.getEngine().getRenderingCanvas())==null?void 0:n.clientHeight,l=(a=e.getEngine().getRenderingCanvas())==null?void 0:a.clientWidth;o.left=l?-(l*i/2-50):0,o.top=s?-(s*i/2-25):0,r.addControl(o)}return()=>{e&&t.current}},[e]),null},FPS$1=FPS,FormationManager=({url:e,visible:t=!0,filter:n,explodedView:a=0,offset:r=new EngineCore.Vector3(0,0,0),showLayerLabel:o,labelStyle:i,actions:s,materials:l})=>{const[c,f]=React.useState(),u=React.useContext(WorkspaceMetaContext),[d,h]=React.useState(!0),[m,R]=React.useState(""),v=useCachedBinary({url:e,cacheType:CacheType.URL_PREFIX_MATCH});return React.useEffect(()=>{console.log("[Geo3DViewer] FormationManager Loading: ",e)},[e]),React.useEffect(()=>{if(v){const g=FormationGroup.decode(new Uint8Array(v)),x=g.formations;if(g.mode==FormationGroup_FormationMode.FACE){h(!0),R(g.name);const y=[];x.forEach((E,k)=>{const b={name:E.name,topUrl:E.url,bottomUrl:x[k+1]?x[k+1].url:void 0};y.push(b)}),f(y)}else{h(!1),R(g.name);const y=[];x.forEach(E=>{const k={name:E.name,topUrl:E.url};y.push(k)}),f(y)}return console.log(x),()=>{R(""),f([])}}},[v]),jsxRuntime.jsx("abstractMesh",{name:`formationmanager-${m}`,children:c?c.map((g,x)=>d?jsxRuntime.jsx("transformNode",{name:`${m}-${g.name}-EV`,position:r.add(new EngineCore.Vector3(0,x*(-1*a*(u&&u.scaleDepth?u.scaleDepth:0)),0)),children:jsxRuntime.jsx(FormationFace$1,{showLayerLabel:o,labelStyle:i,urlTopLayer:g.topUrl,urlBottomLayer:g.bottomUrl,visible:t&&(n?n.includes(g.name):!0),showBottomLayer:c[x+1]?n?n.includes(c[x+1].name):!0:!1,actions:s,material:l==null?void 0:l[g.name]},`${m}-${g.name}`)},`${m}-${g.name}`):jsxRuntime.jsx("transformNode",{name:`${m}-${g.name}-EV`,position:r.add(new EngineCore.Vector3(0,x*(-1*a*(u&&u.scaleDepth?u.scaleDepth:0)),0)),children:jsxRuntime.jsx(FormationVolume$1,{url:g.topUrl,showLayerLabel:o,labelStyle:i,visible:t&&(n?n.includes(g.name):!0),showBottomLayer:c[x+1]?n?n.includes(c[x+1].name):!0:!1,actions:s,material:l==null?void 0:l[g.name]},`${m}-${g.name}`)},`${m}-${g.name}`)):null})},FormationManager$1=FormationManager;function createBaseFormationSlices(){return{name:"",slices:[],center:void 0}}const FormationSlices={encode(e,t=minimal.Writer.create()){e.name!==""&&t.uint32(10).string(e.name);for(const n of e.slices)FormationSlices_Slice.encode(n,t.uint32(18).fork()).ldelim();return e.center!==void 0&&Vertex.encode(e.center,t.uint32(250).fork()).ldelim(),t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseFormationSlices();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.name=n.string();continue;case 2:if(o!==18)break;r.slices.push(FormationSlices_Slice.decode(n,n.uint32()));continue;case 31:if(o!==250)break;r.center=Vertex.decode(n,n.uint32());continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{name:isSet$7(e.name)?globalThis.String(e.name):"",slices:globalThis.Array.isArray(e==null?void 0:e.slices)?e.slices.map(t=>FormationSlices_Slice.fromJSON(t)):[],center:isSet$7(e.center)?Vertex.fromJSON(e.center):void 0}},toJSON(e){var n;const t={};return e.name!==""&&(t.name=e.name),(n=e.slices)!=null&&n.length&&(t.slices=e.slices.map(a=>FormationSlices_Slice.toJSON(a))),e.center!==void 0&&(t.center=Vertex.toJSON(e.center)),t},create(e){return FormationSlices.fromPartial(e!=null?e:{})},fromPartial(e){var n,a;const t=createBaseFormationSlices();return t.name=(n=e.name)!=null?n:"",t.slices=((a=e.slices)==null?void 0:a.map(r=>FormationSlices_Slice.fromPartial(r)))||[],t.center=e.center!==void 0&&e.center!==null?Vertex.fromPartial(e.center):void 0,t}};function createBaseFormationSlices_Slice(){return{name:"",colorId:0,vertices:[],indices:[],edges:[]}}const FormationSlices_Slice={encode(e,t=minimal.Writer.create()){e.name!==""&&t.uint32(10).string(e.name),e.colorId!==0&&t.uint32(16).uint32(e.colorId),t.uint32(26).fork();for(const n of e.vertices)t.float(n);t.ldelim(),t.uint32(34).fork();for(const n of e.indices)t.uint32(n);t.ldelim();for(const n of e.edges)Vertex.encode(n,t.uint32(42).fork()).ldelim();return t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseFormationSlices_Slice();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.name=n.string();continue;case 2:if(o!==16)break;r.colorId=n.uint32();continue;case 3:if(o===29){r.vertices.push(n.float());continue}if(o===26){const i=n.uint32()+n.pos;for(;n.pos<i;)r.vertices.push(n.float());continue}break;case 4:if(o===32){r.indices.push(n.uint32());continue}if(o===34){const i=n.uint32()+n.pos;for(;n.pos<i;)r.indices.push(n.uint32());continue}break;case 5:if(o!==42)break;r.edges.push(Vertex.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{name:isSet$7(e.name)?globalThis.String(e.name):"",colorId:isSet$7(e.colorId)?globalThis.Number(e.colorId):0,vertices:globalThis.Array.isArray(e==null?void 0:e.vertices)?e.vertices.map(t=>globalThis.Number(t)):[],indices:globalThis.Array.isArray(e==null?void 0:e.indices)?e.indices.map(t=>globalThis.Number(t)):[],edges:globalThis.Array.isArray(e==null?void 0:e.edges)?e.edges.map(t=>Vertex.fromJSON(t)):[]}},toJSON(e){var n,a,r;const t={};return e.name!==""&&(t.name=e.name),e.colorId!==0&&(t.colorId=Math.round(e.colorId)),(n=e.vertices)!=null&&n.length&&(t.vertices=e.vertices),(a=e.indices)!=null&&a.length&&(t.indices=e.indices.map(o=>Math.round(o))),(r=e.edges)!=null&&r.length&&(t.edges=e.edges.map(o=>Vertex.toJSON(o))),t},create(e){return FormationSlices_Slice.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o,i;const t=createBaseFormationSlices_Slice();return t.name=(n=e.name)!=null?n:"",t.colorId=(a=e.colorId)!=null?a:0,t.vertices=((r=e.vertices)==null?void 0:r.map(s=>s))||[],t.indices=((o=e.indices)==null?void 0:o.map(s=>s))||[],t.edges=((i=e.edges)==null?void 0:i.map(s=>Vertex.fromPartial(s)))||[],t}};function isSet$7(e){return e!=null}const FormationComponent=(e,t)=>{var O,F,w,L;const n=reactBabylonjs.useScene(),a=React.useRef(null),r=React.useRef(null),o=React.useContext(WorkspaceMetaContext),i=React.useContext(ColorProviderContext),[s,l]=React.useState(EngineCore.Color3.White()),{id:c,visible:f=!0,vertices:u,indices:d,colorId:h,position:m,normals:R,material:v={type:MaterialType.COLOR_ID},children:g,alpha:x=1,style:y,name:E="formation",highStyle:k,lowStyle:b,edges:C=[]}=e,_=useCachedTexture({url:v==null?void 0:v.texture,cacheType:CacheType.URL_PREFIX_MATCH}),A=useCachedTexture({url:v==null?void 0:v.sideTexture,cacheType:CacheType.URL_PREFIX_MATCH}),[N,S]=React.useState();React.useImperativeHandle(t,()=>r.current,[]),React.useEffect(()=>{if(a&&a.current&&n){const B=new EngineCore.VertexData;B.positions=u,B.indices=d,B.normals=R;const D=a.current;B.applyToMesh(D),D.getScene().onAfterRenderObservable.addOnce(()=>{if(!D.isDisposed()){const ae=D.getBoundingInfo();S(ae.boundingBox)}})}},[d,u,n,c,R]),React.useEffect(()=>{var B;l(v.type===MaterialType.ONE_COLOR?(B=v==null?void 0:v.color)!=null?B:EngineCore.Color3.Random():h&&i.colorIDs[h]?new EngineCore.Color3(i.colorIDs[h].r,i.colorIDs[h].g,i.colorIDs[h].b):EngineCore.Color3.Random())},[i.colorIDs,h,v==null?void 0:v.color,v.type]);const I=(B,D,W)=>{const ae=D.subtract(B),ee=1+1e3/EngineCore.Vector3.Distance(B,D)*(W-1),H=ae.scale(ee);return B.add(H)};return jsxRuntime.jsxs("transformNode",{name:`node-${E}-${c}`,setEnabled:f,children:[jsxRuntime.jsxs("transformNode",{name:`${E}`,position:m?m.multiply(calcTransformNodeScale(o)):new EngineCore.Vector3(0,0,0),scaling:calcTransformNodeScale(o),ref:r,children:[jsxRuntime.jsx("mesh",{name:`${E}-mesh`,ref:a,children:v.type===MaterialType.TEXTURE?_?jsxRuntime.jsx(RepeatedTextureMaterial,{name:`formationslice-${E}-mat`,backFaceCulling:!1,needDepthPrePass:v.needDepthPrePass===void 0?!1:v.needDepthPrePass,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,alphaMode:EngineCore.Engine.ALPHA_COMBINE,alpha:x,sideTexture:A,texture:_,tilingFactor:v.tilingFactor,sideTilingFactor:(O=v==null?void 0:v.sideTilingFactor)!=null?O:v==null?void 0:v.tilingFactor,mode:v.textureMode===void 0?RepeatedTextureMode.PLANE:v.textureMode,boundingBox:N,lines:v.lines,text:v.text,scaleDepth:o?o.scaleDepth:1,scalePlane:o?o.scalePlane:1,disableDepthWrite:v.disableDepthWrite}):jsxRuntime.jsx(jsxRuntime.Fragment,{}):v.type===MaterialType.COLOR_CODEC?v.colorCodec?jsxRuntime.jsx(RemapColorByRedChannelMaterial,{name:`formation-${E}-mat`,backFaceCulling:!1,needDepthPrePass:v.needDepthPrePass===void 0?!1:v.needDepthPrePass,alpha:x,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,alphaMode:EngineCore.Engine.ALPHA_COMBINE,colorCodec:v.colorCodec,boundingBox:N,lines:v.lines,text:v.text,scaleDepth:o?o.scaleDepth:1,scalePlane:o?o.scalePlane:1,disableDepthWrite:v.disableDepthWrite}):jsxRuntime.jsx(jsxRuntime.Fragment,{}):v.type===MaterialType.COLOR_ID?jsxRuntime.jsx("standardMaterial",{name:`formation-${E}-mat`,backFaceCulling:!1,needDepthPrePass:v.needDepthPrePass===void 0?!1:v.needDepthPrePass,specularColor:new EngineCore.Color3(0,0,0),ambientColor:new EngineCore.Color3(1,1,1),diffuseColor:s,alphaMode:EngineCore.Engine.ALPHA_COMBINE,alpha:x,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,disableDepthWrite:v.disableDepthWrite}):jsxRuntime.jsx("standardMaterial",{name:`formation-${E}-mat`,backFaceCulling:!1,needDepthPrePass:v.needDepthPrePass===void 0?!1:v.needDepthPrePass,specularColor:new EngineCore.Color3(0,0,0),ambientColor:new EngineCore.Color3(1,1,1),diffuseColor:s,alphaMode:EngineCore.Engine.ALPHA_COMBINE,alpha:x,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,disableDepthWrite:v.disableDepthWrite})}),y.position&&jsxRuntime.jsx("transformNode",{name:`${E}-title`,position:I(convertVertexToVector3(y.basePosition==="left"?C[4]:C[5]),y.position,(F=y.offset)!=null?F:1),scaling:calcGUIScale(o),children:y.title&&jsxRuntime.jsx(GUIText$1,{text:y.title,fontSize:y.fontSize?y.fontSize:40,color:y.color?y.color:"black"})}),b&&b.position&&jsxRuntime.jsx("transformNode",{name:`${E}-up-title`,position:I(convertVertexToVector3(b.basePosition==="left"?C[4]:C[5]),b.position,(w=b.offset)!=null?w:1),scaling:calcGUIScale(o),children:b.title&&jsxRuntime.jsx(GUIText$1,{text:b.title,fontSize:b.fontSize?b.fontSize:40,color:b.color?b.color:"black"})}),k&&k.position&&jsxRuntime.jsx("transformNode",{name:`${E}-down-title`,position:I(convertVertexToVector3(k.basePosition==="left"?C[4]:C[5]),k.position,(L=k.offset)!=null?L:1),scaling:calcGUIScale(o),children:k.title&&jsxRuntime.jsx(GUIText$1,{text:k.title,fontSize:k.fontSize?k.fontSize:40,color:k.color?k.color:"black"})})]}),g]})},FormationComponent$1=React.forwardRef(FormationComponent),FormationSlice=e=>{const[t,n]=React.useState([]),[a,r]=React.useState(""),{url:o,visible:i=!0,materials:s,actions:l,style:c,highStyle:f,lowStyle:u,basePosition:d="left"}=e,h=React.useRef(null),m=React.useContext(WorkspaceMetaContext),R=useCachedBinary({url:o,cacheType:CacheType.URL_PREFIX_MATCH}),[v,g]=React.useState(EngineCore.Vector3.Zero());return React.useEffect(()=>{console.log("[Geo3DViewer] FormationSlice Loading: ",o)},[o]),React.useEffect(()=>{if(R){const x=FormationSlices.decode(new Uint8Array(R));x.center&&g(new EngineCore.Vector3(x.center.x,x.center.y,x.center.z));const y=x.slices.map(E=>{const k=[];return EngineCore.VertexData.ComputeNormals(E.vertices,E.indices,k),{name:E.name,colorId:E.colorId,vertices:E.vertices,indices:E.indices,edges:E.edges,normals:k}});return r(x.name),n(y),()=>{r(""),n([])}}},[R]),React.useEffect(()=>{var y;const x=(y=h.current)==null?void 0:y.getChildMeshes()[0];x&&(x.metadata={pickable:l?{name:a,onLeftClick:l.onLeftClick,onRightClick:l.onRightClick,onMiddleClick:l.onMiddleClick,onHover:l.onHover,extra:l.extra}:null})},[l,a]),jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx("transformNode",{name:`foramtionslice-${a}-holder`,setEnabled:i,position:v.multiply(calcTransformNodeScale(m)),children:t.map((x,y)=>{const E=x.edges.length>0?convertVertexToVector3(d==="left"?x.edges[0]:x.edges[2]):new EngineCore.Vector3(0,0,0),k=x.edges.length>0?convertVertexToVector3(d==="left"?x.edges[1]:x.edges[3]):new EngineCore.Vector3(0,0,0),b=EngineCore.Vector3.Lerp(E,k,.5);return jsxRuntime.jsx(FormationComponent$1,{id:y,vertices:x.vertices,indices:x.indices,colorId:x.colorId,normals:x.normals,name:x.name,edges:x.edges,style:c?{position:b,title:x.name,basePosition:d,...c}:{},lowStyle:u?{position:k,title:(v.y+k.y).toFixed(0).toString(),basePosition:d,...u}:{},highStyle:f&&y===t.length-1?{position:E,title:(v.y+E.y).toFixed(0).toString(),basePosition:d,...f}:{},material:s?{...s[x.name],backFaceCulling:!1}:void 0,ref:h},y)})})})},FormationSlice$1=FormationSlice,TransformGUIText=e=>{const{name:t="node",text:n,fontSize:a,color:r,position:o=EngineCore.Vector3.Zero(),scale:i=EngineCore.Vector3.One(),blink:s=!1}=e,[l,c]=React.useState(!0);return React.useEffect(()=>{const f=setInterval(()=>{s&&c(u=>!u)},1e3);return()=>{clearInterval(f)}},[s]),jsxRuntime.jsx("transformNode",{name:`${t}-text`,position:o,scaling:i,setEnabled:l,children:jsxRuntime.jsx(GUIText$1,{name:t,text:n,fontSize:a,color:r})})},TransformGUIText$1=TransformGUIText;var AxesViewerPosition=(e=>(e[e.NONE=0]="NONE",e[e.BOTTOM_LEFT=1]="BOTTOM_LEFT",e[e.BOTTOM_RIGHT=2]="BOTTOM_RIGHT",e[e.TOP_LEFT=3]="TOP_LEFT",e[e.TOP_RIGHT=4]="TOP_RIGHT",e))(AxesViewerPosition||{});const Geo3DCamera=({target:e,radius:t,alpha:n,beta:a,axesViewerOffset:r=EngineCore.Vector3.Zero(),panningSensibility:o=2,wheelDeltaPercentage:i=0,axesViewer:s=0,farPlane:l=1e4,skipPickingWhenCameraMoves:c=!1})=>{const f=reactBabylonjs.useScene(),u=React.useContext(WorkspaceMetaContext),[d,h]=React.useState(null),[m,R]=React.useState(null),[v,g]=React.useState(n),[x,y]=React.useState(a),[,E]=React.useState(null),k=React.useCallback(N=>{R(N)},[]),{setViewCamera:b}=React.useContext(ViewerCameraPropsContext),C=React.useCallback(()=>{if(m&&d){const N=new EngineCore.Vector3;N.addInPlace(m.position),N.addInPlace(m.getDirection(new EngineCore.Vector3(0,0,25))),s==4?(N.addInPlace(m.getDirection(new EngineCore.Vector3(0,7+r.y,0))),N.addInPlace(m.getDirection(new EngineCore.Vector3(15+r.x,0,0)))):s==3?(N.addInPlace(m.getDirection(new EngineCore.Vector3(0,7+r.y,0))),N.addInPlace(m.getDirection(new EngineCore.Vector3(-15+r.x,0,0)))):s==2?(N.addInPlace(m.getDirection(new EngineCore.Vector3(0,-7+r.y,0))),N.addInPlace(m.getDirection(new EngineCore.Vector3(15+r.x,0,0)))):s==1&&(N.addInPlace(m.getDirection(new EngineCore.Vector3(0,-7+r.y,0))),N.addInPlace(m.getDirection(new EngineCore.Vector3(-15+r.x,0,0)))),d.xAxis.position=N.clone(),d.yAxis.position=N.clone(),d.zAxis.position=N.clone()}},[m,d,s,r.y,r.x]);React.useEffect(()=>{if(f&&s!=0){const N=new EngineCore.AxesViewer(f,2,null);return h(N),()=>{N==null||N.dispose(),h(null)}}},[f,s]),React.useEffect(()=>{C()},[C]);const _=React.useCallback(N=>{if(u&&u.min&&u.max)return EngineCore.Vector3.Clamp(N,u==null?void 0:u.min,u==null?void 0:u.max)},[u]),A=React.useCallback(N=>{f&&(f.skipPointerMovePicking=N)},[f]);return React.useEffect(()=>{if(!f||!m)return;const N=m.onViewMatrixChangedObservable.add(()=>{c&&(A(!0),E(S=>(S&&clearTimeout(S),setTimeout(()=>{A(!1),E(null)},250)))),g(m.alpha),y(m.beta),C()});return()=>{m.onViewMatrixChangedObservable.remove(N),E(S=>(S&&clearTimeout(S),null)),A(!1)}},[f,s,m,u,d,C,_,A,c]),React.useEffect(()=>{b(f&&m?m:void 0)},[f,m,b]),React.useEffect(()=>{},[_,u,e]),jsxRuntime.jsx(jsxRuntime.Fragment,{children:e&&jsxRuntime.jsx("arcRotateCamera",{name:"rootCamera",target:e,radius:t,alpha:v,beta:x,maxZ:l,panningSensibility:o,wheelDeltaPercentage:i,ref:k,setActiveOnSceneIfNoneActive:!0})})},Geo3DCamera$1=Geo3DCamera,Geo3DUniversalCamera=(e,t)=>{const{position:n=EngineCore.Vector3.Zero(),axesViewer:a=AxesViewerPosition.NONE,axesViewerOffset:r=EngineCore.Vector3.Zero(),skipPickingWhenCameraMoves:o=!1,wheelDeltaPercentage:i=3,rotationSensibility:s=1,panningSensibility:l=10}=e,c=reactBabylonjs.useScene(),f=React.useContext(WorkspaceMetaContext),[u,d]=React.useState(null),[h,m]=React.useState(null),{setViewCamera:R,cameraRefObject:v}=React.useContext(ViewerCameraPropsContext),[,g]=React.useState(null),x=React.useRef(null),[y,E]=React.useState(null),k=React.useRef(null),b=React.useCallback(S=>{c&&(c.skipPointerMovePicking=S)},[c]);React.useEffect(()=>(k.current=new EngineCore.ArcRotateCamera("dummy-camera",0,0,.1,EngineCore.Vector3.Zero(),c||void 0,!1),()=>{var S;(S=k.current)==null||S.dispose()}),[c]),React.useEffect(()=>{if(c){const S=h,I=c.onPointerObservable.add(O=>{if(O.type===EngineCore.PointerEventTypes.POINTERDOWN&&(x.current=new EngineCore.Vector2(O.event.clientX,O.event.clientY)),O.type===EngineCore.PointerEventTypes.POINTERUP&&(x.current=null),O.type===EngineCore.PointerEventTypes.POINTERMOVE&&x.current){const F=O.event.clientX-x.current.x,w=O.event.clientY-x.current.y;if(O.event.buttons===1){let L=null;(S.lockedTarget||y)&&(S.lockedTarget&&(L=S.lockedTarget.position),y&&(L=y)),L&&k.current?(k.current.target=L,k.current.position=S.position.clone(),k.current.wheelDeltaPercentage=i,k.current.panningSensibility=l,k.current.alpha+=F/100*s,k.current.beta+=w/100*s,k.current.update(),S.position=k.current.position.clone(),S.rotation=k.current.rotation.clone()):(S.rotation.y-=F/100*s,S.rotation.x-=w/100*s)}O.event.buttons===2&&(S.position.x-=F/100*l,S.position.y+=w/100*l),x.current=new EngineCore.Vector2(O.event.clientX,O.event.clientY)}});return()=>{c.onPointerObservable.remove(I)}}},[y,l,h,s,c,i]);const C=React.useCallback(S=>{S&&(S.inputs.addMouseWheel(),S.inputs.removeMouse(),R(S),m(S))},[R]);React.useEffect(()=>{if(h){const S=h.inputs.attached.mousewheel;S.wheelPrecisionX=i,S.wheelPrecisionY=i,S.wheelPrecisionZ=i}},[h,i]);const _=React.useCallback(()=>{if(h&&u){const S=new EngineCore.Vector3;S.addInPlace(h.position),S.addInPlace(h.getDirection(new EngineCore.Vector3(0,0,25))),a==AxesViewerPosition.TOP_RIGHT?(S.addInPlace(h.getDirection(new EngineCore.Vector3(0,7+r.y,0))),S.addInPlace(h.getDirection(new EngineCore.Vector3(15+r.x,0,0)))):a==AxesViewerPosition.TOP_LEFT?(S.addInPlace(h.getDirection(new EngineCore.Vector3(0,7+r.y,0))),S.addInPlace(h.getDirection(new EngineCore.Vector3(-15+r.x,0,0)))):a==AxesViewerPosition.BOTTOM_RIGHT?(S.addInPlace(h.getDirection(new EngineCore.Vector3(0,-7+r.y,0))),S.addInPlace(h.getDirection(new EngineCore.Vector3(15+r.x,0,0)))):a==AxesViewerPosition.BOTTOM_LEFT&&(S.addInPlace(h.getDirection(new EngineCore.Vector3(0,-7+r.y,0))),S.addInPlace(h.getDirection(new EngineCore.Vector3(-15+r.x,0,0)))),u.xAxis.position=S.clone(),u.yAxis.position=S.clone(),u.zAxis.position=S.clone()}},[h,u,a,r.y,r.x]);React.useEffect(()=>{if(c&&a!=AxesViewerPosition.NONE){const S=new EngineCore.AxesViewer(c,2,null);return d(S),()=>{S==null||S.dispose(),d(null)}}},[c,a]),React.useEffect(()=>{_()},[_]),React.useEffect(()=>{R(c&&h?h:void 0)},[c,h,R]),React.useEffect(()=>{if(!c||!h)return;const S=h.onViewMatrixChangedObservable.add(()=>{o&&(b(!0),g(I=>(I&&clearTimeout(I),setTimeout(()=>{b(!1),g(null)},250)))),_()});return()=>{h.onViewMatrixChangedObservable.remove(S),g(I=>(I&&clearTimeout(I),null)),b(!1)}},[c,a,h,f,u,_,o,b]);const[A,N]=React.useState();return React.useEffect(()=>{if(h){const S={lookAt:I=>{h&&h.setTarget(I)},updatePosition:I=>{h&&(h.position=I)},lockTarget:I=>{h&&(E(null),h.lockedTarget=I)},lockTo:I=>{h&&(h.lockedTarget=null,E(I))}};N(S),v&&v.current&&(v.current.rawCamera=h,v.current.cameraTools=S)}},[v,h]),React.useImperativeHandle(t,()=>({rawCamera:h,cameraTools:A}),[A,h]),jsxRuntime.jsx("universalCamera",{name:"universal-main-camera",position:n,ref:C,maxZ:0})},Geo3DUniversalCamera$1=React.forwardRef(Geo3DUniversalCamera);class FreeCameraPointersInput extends EngineCore.BaseCameraPointersInput{constructor(){super(...arguments);le(this,"camera");le(this,"buttons",[0,1,2,4]);le(this,"panningSensibility",10);le(this,"angularSensibility",1e4);le(this,"_isPanClick",!1);le(this,"_isPinching",!1)}getClassName(){return"FreeCameraPointersInput"}onButtonDown(n){(n.buttons===1||n.buttons===4)&&(this._isPinching=!0),n.buttons===2&&(this._isPanClick=!0)}onButtonUp(n){n&&(this._isPanClick=!1,this._isPinching=!1)}onTouch(n,a,r){if(this.panningSensibility!==0&&this._isPanClick){const o=-a/this.panningSensibility,i=r/this.panningSensibility;this.camera._localDirection.copyFromFloats(o,i,0),this.camera.getViewMatrix().invertToRef(this.camera._cameraTransformMatrix),EngineCore.Vector3.TransformNormalToRef(this.camera._localDirection,this.camera._cameraTransformMatrix,this.camera._transformedDirection),this.camera.cameraDirection.addInPlace(this.camera._transformedDirection)}if(this.angularSensibility!==0&&this._isPinching){const o=EngineCore.Quaternion.FromEulerAngles(this.camera.rotation.x,this.camera.rotation.y,this.camera.rotation.z),i=EngineCore.Quaternion.RotationAxis(EngineCore.Axis.Y,EngineCore.Tools.ToDegrees(a/this.angularSensibility)),s=EngineCore.Quaternion.RotationAxis(EngineCore.Axis.X,EngineCore.Tools.ToDegrees(r/this.angularSensibility)),l=o.multiply(i).multiply(s);this.camera.rotation=l.toEulerAngles()}}onLostFocus(){this._isPanClick=!1,this._isPinching=!1}}const Geo3DFreeCamera=e=>{const{position:t,target:n=new EngineCore.Vector3(0,0,0),panningSensibility:a=5,angularSensibility:r=2e3,skipPickingWhenCameraMoves:o=!1}=e,i=reactBabylonjs.useScene(),s=React.useRef(null),l=React.useRef(null),c=React.useCallback(f=>{i&&(i.skipPointerMovePicking=f)},[i]);return React.useEffect(()=>{if(s.current){s.current.inputs.removeByType("FreeCameraMouseInput");const f=new FreeCameraPointersInput,u=new EngineCore.FreeCameraMouseWheelInput;s.current.inputs.add(f),s.current.inputs.add(u)}},[]),React.useEffect(()=>{s.current&&n&&s.current.setTarget(n)},[n]),React.useEffect(()=>{if(!i||!s.current)return;const f=s.current.onViewMatrixChangedObservable.add(()=>{o&&(c(!0),l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{c(!1),l.current=null},250))});return()=>{var u;(u=s.current)==null||u.onViewMatrixChangedObservable.remove(f),l.current&&(clearTimeout(l.current),l.current=null),c(!1)}},[i,c,o]),React.useEffect(()=>{if(s.current){if(s.current.inputs.attached.pointers){const f=s.current.inputs.attached.pointers;f.panningSensibility=Math.abs(a),f.angularSensibility=Math.abs(r)}if(s.current.inputs.attached.pointersPanning){const f=s.current.inputs.attached.pointersPanning;f.panningSensibility=Math.abs(a)}if(s.current.inputs.attached.around){const f=s.current.inputs.attached.around;f.angularSensibility=Math.abs(r)}}},[r,a]),jsxRuntime.jsx("freeCamera",{name:"rootCamera",position:t,ref:s})},Geo3DFreeCamera$1=Geo3DFreeCamera;class DepthTextureDebuggerNode extends EngineCore.TransformNode{constructor(n,a,r){super(n,a);le(this,"_showDepthTexture",!1);le(this,"_postProcess");this._postProcess=r,this.showDepthTexture=!1,this.inspectableCustomProperties=[{label:"Show Depth Texture",propertyName:"showDepthTexture",type:EngineCore.InspectableType.Checkbox}]}set showDepthTexture(n){var a,r;this._showDepthTexture=n,this._postProcess&&(this._showDepthTexture?(a=this.getScene().activeCamera)==null||a.attachPostProcess(this._postProcess):(r=this.getScene().activeCamera)==null||r.detachPostProcess(this._postProcess))}get showDepthTexture(){return this._showDepthTexture}}const DepthTextureDebugger=()=>{const e=reactBabylonjs.useEngine(),t=reactBabylonjs.useScene();return React.useEffect(()=>{if(t&&e){EngineCore.Effect.ShadersStore.depthbufferPixelShader=`#ifdef GL_ES
1193
+ }`,LightMetalMaterial=({alpha:e,zOffset:t,zOffsetUnits:n,disableDepthWrite:a})=>jsxRuntime.jsx("pbrMaterial",{name:"metal-pbr-material",alpha:e,transparencyMode:e!==void 0&&e<1?EngineCore.Material.MATERIAL_ALPHABLEND:EngineCore.Material.MATERIAL_OPAQUE,alphaMode:EngineCore.Engine.ALPHA_COMBINE,roughness:.25,metallic:1,albedoColor:new EngineCore.Color3(.7,.7,.7),metallicF0Factor:.1,zOffset:t,zOffsetUnits:n,disableDepthWrite:a}),DarkMetalMaterial=({alpha:e,zOffset:t,zOffsetUnits:n,disableDepthWrite:a})=>jsxRuntime.jsx("pbrMaterial",{name:"metal-pbr-material",alpha:e,transparencyMode:e!==void 0&&e<1?EngineCore.Material.MATERIAL_ALPHABLEND:EngineCore.Material.MATERIAL_OPAQUE,alphaMode:EngineCore.Engine.ALPHA_COMBINE,roughness:.25,metallic:1,albedoColor:new EngineCore.Color3(.2,.2,.2),metallicF0Factor:.1,zOffsetUnits:n,zOffset:t,disableDepthWrite:a});var RepeatedTextureMode=(e=>(e[e.TRIGONOMETRIC=0]="TRIGONOMETRIC",e[e.PLANE=1]="PLANE",e[e.FLAT=2]="FLAT",e))(RepeatedTextureMode||{});const RepeatedTextureMaterial=e=>{const t=reactBabylonjs.useScene(),[n,a]=React.useState(null),[r,o]=React.useState(null),{tilingFactor:i=.1,sideTilingFactor:s=.1,texture:l,alpha:c=1,mode:f=0,zOffset:u,zOffsetUnits:d,sideTexture:h,uvOffset:m=EngineCore.Vector2.Zero(),counterLine:R=void 0,scalePlane:v=1,scaleDepth:g=1,boundingBox:x=void 0,lines:y=[],text:E=[],disableDepthWrite:k,flatModeRotate:b=0}=e,C=_=>{a(_)};return React.useEffect(()=>{n&&l&&(n.setTexture("textureSampler",l),n.setFloat("textureFlatRotate",b),n.setVector2("uvOffset",m))},[b,n,l,m]),React.useEffect(()=>{n&&n.setFloat("alpha",c)},[c,n]),React.useEffect(()=>{n&&n.setFloat("tilingFactor",i),n&&n.setFloat("sideTilingFactor",s)},[i,s,n]),React.useEffect(()=>{n&&n.setInt("mode",f)},[n,f]),React.useEffect(()=>{n&&(h?n.setTexture("textureSideSampler",h):n.setTexture("textureSideSampler",l))},[n,h,l]),React.useEffect(()=>{var _;if(n)if(R&&x){const A=(_=R.startHeight)!=null?_:x.minimumWorld.y/g;return n.setFloat("contourLineStartHeight",A*g),n.setColor3("contourLineColor",R.color),n.setFloat("contourLineWidth",R.width),n.setFloat("contourLineStep",R.stepHeight*g),console.log("[Geo3DViewer] 等高线设置 ",R,x.centerWorld.y,A*g,A*g+16*R.stepHeight*g),()=>{n&&(n.setFloat("contourLineStartHeight",0),n.setColor3("contourLineColor",new EngineCore.Color3(0,0,0)),n.setFloat("contourLineWidth",0),n.setFloat("contourLineStep",0))}}else n.setFloat("contourLineStartHeight",0),n.setColor3("contourLineColor",new EngineCore.Color3(0,0,0)),n.setFloat("contourLineWidth",0),n.setFloat("contourLineStep",0),console.log("[Geo3DViewer] 等高线设置 关闭")},[R,g,v,x,n]),React.useEffect(()=>{t&&n&&x&&o(_=>{_&&_.dispose();let A=(x.maximum.x-x.minimum.x)/v,N=(x.maximum.z-x.minimum.z)/v,S=0;if(A<N){const F=A;A=N,N=F,S=1}const I=A/N;A*N>2048*2048&&(A=2048,N=2048/I);const O=new EngineCore.DynamicTexture("dynamic-texture",{width:A,height:N},t,!1);return O.clear(),console.log("[Geo3DViewer] 设置动态划线 ",x,A,N,v),n.setVector3("oMin",x.minimum),n.setVector3("oMax",x.maximum),n.setFloat("textureOverlayRotate",S),n.setTexture("textureOverlaySampler",O),O})},[x,n,v,t]),React.useEffect(()=>{var _;if(r&&x)if((_=r.getScene())!=null&&_.getEngine()){r.clear();let A=(x.maximum.x-x.minimum.x)/v,N=(x.maximum.z-x.minimum.z)/v;if(A<N){const O=A;A=N,N=O}const S=A/N;A*N>2048*2048&&(A=2048,N=2048/S);const I=r.getContext();y.forEach(O=>{if(O.points.length<2)return;I.beginPath();const F=O.offset?O.offset:new EngineCore.Vector2(0,0),w=1-O.points[0].x+F.x,L=1-O.points[0].y+F.y;I.moveTo(w*A,L*N);for(let B=1;B<O.points.length;B++){const D=O.offset?O.offset:new EngineCore.Vector2(0,0),W=1-O.points[B].x+D.x,ae=1-O.points[B].y+D.y;I.lineTo(W*A,ae*N)}I.strokeStyle=`rgb(${O.color.r*255}, ${O.color.g*255}, ${O.color.b*255})`,A*N>2048*2048?I.lineWidth=O.width/S:I.lineWidth=O.width,I.stroke()}),E.forEach(O=>{var B,D;I.font=`${O.fontSize}px Arial`;const F=(B=O.color)!=null?B:EngineCore.Color3.White(),w=O.offset?O.offset:new EngineCore.Vector2(0,0),L=(D=O.rotation)!=null?D:0;if(I.save(),I.translate((1-O.position.x+w.x)*A,(1-O.position.y+w.y)*N),I.rotate(L),O.clearArea){const W=I.measureText(O.text);I.clearRect(-W.width*.15,.5*O.fontSize*(1-.3),W.width*1.3,-O.fontSize*1.3)}if(O.background){I.fillStyle=`rgba(${O.background.r*255}, ${O.background.g*255}, ${O.background.b*255})`;const W=I.measureText(O.text);I.fillRect(-W.width*.05,.5*(O.fontSize*(.5-.1)),W.width*1.1,-O.fontSize*1.1)}I.fillStyle=`rgb(${F.r*255}, ${F.g*255}, ${F.b*255})`,I.fillText(O.text,0,0),I.restore()}),r.update()}else console.log("[Geo3DViewer] 动态纹理未准备好,正准备下一次绘制")},[y,E,r,x,v]),jsxRuntime.jsx(CustomShader$1,{...e,ref:C,vertex:repeatedTextureVertexSource,fragment:repeatedTextureFragmentSource,options:{attributes:["position","color","alpha","normal"],uniforms:["worldViewProjection","tilingFactor","sideTilingFactor","mode","uvOffset","contourLineStartHeight","contourLineColor","contourLineWidth","contourLineStep","oMin","oMax","textureOverlayRotate","textureFlatRotate"],samplers:["textureSampler","textureOverlaySampler","textureSideSampler"],needAlphaBlending:!0,needAlphaTesting:!0},zOffset:u,zOffsetUnits:d,disableDepthWrite:k})},RemapColorByRedChannelMaterial=e=>{const t=reactBabylonjs.useScene(),n=React.useRef(null),a=React.useContext(ColorCodecImageContext),[r,o]=React.useState(null),{name:i,colorCodec:s,alpha:l=1,backFaceCulling:c,needDepthPrePass:f=!1,transparencyMode:u=EngineCore.Material.MATERIAL_OPAQUE,alphaMode:d=EngineCore.Engine.ALPHA_COMBINE,zOffset:h,zOffsetUnits:m,clipPlane:R,counterLine:v=void 0,scalePlane:g=1,scaleDepth:x=1,boundingBox:y,lines:E=[],text:k=[],disableDepthWrite:b}=e;return React.useEffect(()=>{const C=n.current;C&&t&&(C.loadFromSerialization(remapNodeMaterialSource,""),C.build(!1,!0,!1))},[t]),React.useEffect(()=>{const C=n.current;C&&(C.name=`${i}-material`,C.backFaceCulling=c!=null?c:!0,C.needDepthPrePass=f,C.transparencyMode=u,C.alphaMode=d,C.alpha=l,C.zOffset=h!=null?h:1,C.zOffsetUnits=m!=null?m:0,C.clipPlane=R!=null?R:null,C.disableDepthWrite=b!=null?b:!1)},[l,d,c,R,b,i,f,u,h,m]),React.useEffect(()=>{if(s){const C=n.current;C&&(C.metadata={colorCodec:s},EngineCore.Tags.EnableFor(C),EngineCore.Tags.AddTagsTo(C,"remap"))}if(s&&a&&t&&a.colorCodecsImage.current[s]){const C=n.current;if(C){const _=C.getBlockByName("RemappedTexture");_&&(_.texture=a.colorCodecsImage.current[s].texture,C.markAsDirty(EngineCore.NodeMaterial.TextureDirtyFlag))}}},[s,t]),React.useEffect(()=>{n.current&&t&&(console.log("[Geo3DViewer] RemapColorByRedChannel 透明度更新 ",l),n.current.alpha=l)},[t,l]),React.useEffect(()=>{var _;const C=n.current;if(C){const A=C.getBlockByName("contourLineStartHeight"),N=C.getBlockByName("contourLineColor"),S=C.getBlockByName("contourLineWidth"),I=C.getBlockByName("contourLineStep");if(v&&y){const O=(_=v.startHeight)!=null?_:y.centerWorld.y/x;return A&&(A.value=O*x),N&&(N.value=v.color),S&&(S.value=v.width),I&&(I.value=v.stepHeight*x),console.log("[Geo3DViewer] 等高线设置 ",v,y.centerWorld,y.centerWorld.y,O*x,O*x+16*v.stepHeight*x),()=>{C&&(A&&(A.value=0),N&&(N.value=new EngineCore.Color3(0,0,0)),S&&(S.value=0),I&&(I.value=0))}}else A&&(A.value=0),N&&(N.value=new EngineCore.Color3(0,0,0)),S&&(S.value=0),I&&(I.value=0),console.log("[Geo3DViewer] 等高线设置 关闭");C.markAsDirty(EngineCore.NodeMaterial.MiscDirtyFlag)}},[v,x,g,y]),React.useEffect(()=>{t&&y&&o(C=>{var w,L;C&&C.dispose();let _=(y.maximum.x-y.minimum.x)/g,A=(y.maximum.z-y.minimum.z)/g,N=0;if(_<A){const B=_;_=A,A=B,N=1}const S=_/A;_*A>2048*2048&&(_=2048,A=2048/S);const I=new EngineCore.DynamicTexture("dynamic-texture",{width:_,height:A},t,!1);I.clear(),console.log("[Geo3DViewer] 设置动态划线 ",y,_,A,g);const O=(w=n.current)==null?void 0:w.getBlockByName("angle"),F=(L=n.current)==null?void 0:L.getBlockByName("OverlayTexture");return O&&(O.value=N*(Math.PI/2)),F&&(F.texture=I),I})},[y,g,t]),React.useEffect(()=>{var C;if(r&&y)if((C=r.getScene())!=null&&C.getEngine()){r.clear();let _=(y.maximum.x-y.minimum.x)/g,A=(y.maximum.z-y.minimum.z)/g;if(_<A){const I=_;_=A,A=I}const N=_/A;_*A>2048*2048&&(_=2048,A=2048/N);const S=r.getContext();E.forEach(I=>{if(I.points.length<2)return;S.beginPath();const O=I.offset?I.offset:new EngineCore.Vector2(0,0),F=1-I.points[0].x+O.x,w=1-I.points[0].y+O.y;S.moveTo(F*_,w*A);for(let L=1;L<I.points.length;L++){const B=I.offset?I.offset:new EngineCore.Vector2(0,0),D=1-I.points[L].x+B.x,W=1-I.points[L].y+B.y;S.lineTo(D*_,W*A)}S.strokeStyle=`rgb(${I.color.r*255}, ${I.color.g*255}, ${I.color.b*255})`,_*A>2048*2048?S.lineWidth=I.width/N:S.lineWidth=I.width,S.stroke()}),k.forEach(I=>{var L,B;S.font=`${I.fontSize}px Arial`;const O=(L=I.color)!=null?L:EngineCore.Color3.White(),F=I.offset?I.offset:new EngineCore.Vector2(0,0),w=(B=I.rotation)!=null?B:0;if(S.save(),S.translate((1-I.position.x+F.x)*_,(1-I.position.y+F.y)*A),S.rotate(w),I.clearArea){const D=S.measureText(I.text);S.clearRect(-D.width*.15,.5*I.fontSize*(1-.3),D.width*1.3,-I.fontSize*1.3)}if(I.background){S.fillStyle=`rgba(${I.background.r*255}, ${I.background.g*255}, ${I.background.b*255})`;const D=S.measureText(I.text);S.fillRect(-D.width*.05,.5*(I.fontSize*(.5-.1)),D.width*1.1,-I.fontSize*1.1)}S.fillStyle=`rgb(${O.r*255}, ${O.g*255}, ${O.b*255})`,S.fillText(I.text,0,0),S.restore()}),r.update()}else console.log("[Geo3DViewer] 动态纹理未准备好,正准备下一次绘制")},[E,r,y,g,k]),jsxRuntime.jsx("nodeMaterial",{ref:n,name:`${i}-material`,backFaceCulling:c,needDepthPrePass:f,transparencyMode:u,alphaMode:d,alpha:l,zOffset:h,zOffsetUnits:m,clipPlane:R,disableDepthWrite:b})},ProgressedRemapColorByRedChannelMaterial=e=>{const t=reactBabylonjs.useScene(),n=React.useContext(ColorCodecImageContext),a=React.useRef(null),[r,o]=React.useState(null),[i,s]=React.useState(null),[l,c]=React.useState(null),[f,u]=React.useState(null),[d,h]=React.useState(null),[m,R]=React.useState(null),[v,g]=React.useState(null),[x,y]=React.useState(null),{boundingBox:E,colorCodec:k,alphaStage:b,cutNormal:C,value:_,zOffset:A,zOffsetUnits:N,counterLine:S=void 0,scaleDepth:I=1,scalePlane:O=1,lines:F=[],text:w=[],disableDepthWrite:L}=e;return React.useEffect(()=>{const B=(D,W,ae)=>{if(E){const ee=E.maximumWorld.multiply(W),H=E.minimumWorld.multiply(W),oe=E.centerWorld.multiply(W),te=Math.max(ee.x,ee.y,ee.z),K=Math.max(H.x,H.y,H.z),Z=Math.max(oe.x,oe.y,oe.z),ce=Math.max(Math.abs(W.x),Math.abs(W.z));D(new EngineCore.Plane(W.x,W.y,W.z,((te-K)*(1-ae-.5)*ce+Z)*-1))}else D(null)};E&&x&&(B(o,x.cutPlane1,_.value1),x.cutPlane2&&_.value2?B(s,x.cutPlane2,_.value2):s(null),x.cutPlane3&&_.value3?B(c,x.cutPlane3,_.value3):c(null),x.cutPlane4&&_.value4?B(u,x.cutPlane4,_.value4):u(null),x.cutPlane5&&_.value5?B(h,x.cutPlane5,_.value5):c(null),x.cutPlane6&&_.value6?B(R,x.cutPlane6,_.value6):R(null))},[E,x,_]),React.useEffect(()=>{y({cutPlane1:EngineCore.Vector3.Normalize(C.cutPlane1),cutPlane2:C.cutPlane2?EngineCore.Vector3.Normalize(C.cutPlane2):void 0,cutPlane3:C.cutPlane3?EngineCore.Vector3.Normalize(C.cutPlane3):void 0,cutPlane4:C.cutPlane4?EngineCore.Vector3.Normalize(C.cutPlane4):void 0,cutPlane5:C.cutPlane5?EngineCore.Vector3.Normalize(C.cutPlane5):void 0,cutPlane6:C.cutPlane6?EngineCore.Vector3.Normalize(C.cutPlane6):void 0})},[C]),React.useEffect(()=>{const B=a.current;B&&(B.clipPlane=r,B.clipPlane2=i,B.clipPlane3=l,B.clipPlane4=f,B.clipPlane5=d,B.clipPlane6=m)},[r,i,l,f,d,m]),React.useEffect(()=>{var B,D,W,ae,ee;a.current&&t&&(a.current.setFloat("alpha1",b.alpha1),a.current.setFloat("alpha2",(B=b.alpha2)!=null?B:1),a.current.setFloat("alpha3",(D=b.alpha3)!=null?D:1),a.current.setFloat("alpha4",(W=b.alpha4)!=null?W:1),a.current.setFloat("alpha5",(ae=b.alpha5)!=null?ae:1),a.current.setFloat("alpha6",(ee=b.alpha6)!=null?ee:1))},[t,b]),React.useEffect(()=>{if(k){const B=a.current;B&&(B.metadata={colorCodec:k},EngineCore.Tags.EnableFor(B),EngineCore.Tags.AddTagsTo(B,"remap"))}if(k&&n&&t&&n.colorCodecsImage.current[k]){const B=a.current;B&&(console.log(n.colorCodecsImage.current[k]),B.setTexture("textureSampler",n.colorCodecsImage.current[k].texture),B.metadata={colorCodec:k},EngineCore.Tags.EnableFor(B),EngineCore.Tags.AddTagsTo(B,"remap"))}},[k,t]),React.useEffect(()=>{var D;const B=a.current;if(B&&E)if(S){const W=(D=S.startHeight)!=null?D:E.minimumWorld.y/I;return B.setFloat("contourLineStartHeight",W*I),B.setColor3("contourLineColor",S.color),B.setFloat("contourLineWidth",S.width),B.setFloat("contourLineStep",S.stepHeight*I),console.log("[Geo3DViewer] 等高线设置 ",S,E.centerWorld.y,W*I,W*I+16*S.stepHeight*I),()=>{B&&(B.setFloat("contourLineStartHeight",0),B.setColor3("contourLineColor",new EngineCore.Color3(0,0,0)),B.setFloat("contourLineWidth",0),B.setFloat("contourLineStep",0))}}else B.setFloat("contourLineStartHeight",0),B.setColor3("contourLineColor",new EngineCore.Color3(0,0,0)),B.setFloat("contourLineWidth",0),B.setFloat("contourLineStep",0),console.log("[Geo3DViewer] 等高线设置 关闭")},[S,I,O,E]),React.useEffect(()=>{t&&E&&g(B=>{var oe,te,K,Z;B&&B.dispose();let D=(E.maximum.x-E.minimum.x)/O,W=(E.maximum.z-E.minimum.z)/O,ae=0;if(D<W){const ce=D;D=W,W=ce,ae=1}const ee=D/W;D*W>2048*2048&&(D=2048,W=2048/ee);const H=new EngineCore.DynamicTexture("dynamic-texture",{width:D,height:W},t,!1);return H.clear(),console.log("[Geo3DViewer] 设置动态划线 ",E,D,W,O),(oe=a.current)==null||oe.setVector3("oMin",E.minimum),(te=a.current)==null||te.setVector3("oMax",E.maximum),(K=a.current)==null||K.setFloat("textureOverlayRotate",ae),(Z=a.current)==null||Z.setTexture("textureOverlaySampler",H),H})},[E,O,t]),React.useEffect(()=>{var B;if(v&&E)if((B=v.getScene())!=null&&B.getEngine()){v.clear();let D=(E.maximum.x-E.minimum.x)/O,W=(E.maximum.z-E.minimum.z)/O;if(D<W){const H=D;D=W,W=H}const ae=D/W;D*W>2048*2048&&(D=2048,W=2048/ae);const ee=v.getContext();F.forEach(H=>{if(H.points.length<2)return;ee.beginPath();const oe=H.offset?H.offset:new EngineCore.Vector2(0,0),te=1-H.points[0].x+oe.x,K=1-H.points[0].y+oe.y;ee.moveTo(te*D,K*W);for(let Z=1;Z<H.points.length;Z++){const ce=H.offset?H.offset:new EngineCore.Vector2(0,0),Q=1-H.points[Z].x+ce.x,G=1-H.points[Z].y+ce.y;ee.lineTo(Q*D,G*W)}ee.strokeStyle=`rgb(${H.color.r*255}, ${H.color.g*255}, ${H.color.b*255})`,D*W>2048*2048?ee.lineWidth=H.width/ae:ee.lineWidth=H.width,ee.stroke()}),w.forEach(H=>{var Z,ce;ee.font=`${H.fontSize}px Arial`;const oe=(Z=H.color)!=null?Z:EngineCore.Color3.White(),te=H.offset?H.offset:new EngineCore.Vector2(0,0),K=(ce=H.rotation)!=null?ce:0;if(ee.save(),ee.translate((1-H.position.x+te.x)*D,(1-H.position.y+te.y)*W),ee.rotate(K),H.clearArea){const Q=ee.measureText(H.text);ee.clearRect(-Q.width*.15,.5*H.fontSize*(1-.3),Q.width*1.3,-H.fontSize*1.3)}if(H.background){ee.fillStyle=`rgba(${H.background.r*255}, ${H.background.g*255}, ${H.background.b*255})`;const Q=ee.measureText(H.text);ee.fillRect(-Q.width*.05,.5*(H.fontSize*(.5-.1)),Q.width*1.1,-H.fontSize*1.1)}ee.fillStyle=`rgb(${oe.r*255}, ${oe.g*255}, ${oe.b*255})`,ee.fillText(H.text,0,0),ee.restore()}),v.update()}else console.log("[Geo3DViewer] 动态纹理未准备好,正准备下一次绘制")},[F,v,E,O,w]),jsxRuntime.jsx(CustomShader$1,{...e,ref:a,vertex:remapProgressedVertexSource,fragment:remapProgressedFragmentSource,options:{attributes:["position","color","normal"],uniforms:["world","worldViewProjection","alpha1","alpha2","alpha3","alpha4","alpha5","alpha6","oMin","oMax","contourLineStartHeight","contourLineColor","contourLineWidth","contourLineStep","textureOverlayRotate"],samplers:["textureOverlaySampler","textureSampler"],needAlphaBlending:!0,needAlphaTesting:!0,useClipPlane:!0},disableDepthWrite:L,zOffset:A,zOffsetUnits:N})},ProgressedRepeatedTextureMaterial=e=>{const t=reactBabylonjs.useScene(),[n,a]=React.useState(null),[r,o]=React.useState(null),[i,s]=React.useState(null),[l,c]=React.useState(null),[f,u]=React.useState(null),[d,h]=React.useState(null),[m,R]=React.useState(null),[v,g]=React.useState(null),[x,y]=React.useState(null),{boundingBox:E=void 0,texture:k,sideTexture:b,alphaStage:C,cutNormal:_,value:A,tilingFactor:N=.1,sideTilingFactor:S=.1,mode:I=0,zOffset:O,zOffsetUnits:F,overlay:w={},counterLine:L=void 0,scalePlane:B=1,scaleDepth:D=1,lines:W=[],text:ae=[],disableDepthWrite:ee,textureFlatRotate:H=0}=e,oe=te=>{a(te)};return React.useEffect(()=>{n&&n.setFloat("textureFlatRotate",H)},[n,H]),React.useEffect(()=>{const te=(K,Z,ce)=>{if(E){const Q=E.maximumWorld.multiply(Z),G=E.minimumWorld.multiply(Z),ge=E.centerWorld.multiply(Z),fe=Math.max(Q.x,Q.y,Q.z),V=Math.max(G.x,G.y,G.z),J=Math.max(ge.x,ge.y,ge.z),Re=Math.max(Math.abs(Z.x),Math.abs(Z.z)),Ce=new EngineCore.Plane(Z.x,Z.y,Z.z,((fe-V)*(1-ce-.5)*Re+J)*-1);K(Ce),console.log("[Geo3DViewer] 设置实际 CutPlane 为 ",Ce,Re)}else K(null)};E&&x&&(te(o,x.cutPlane1,A.value1),x.cutPlane2&&A.value2?te(s,x.cutPlane2,A.value2):s(null),x.cutPlane3&&A.value3?te(c,x.cutPlane3,A.value3):c(null),x.cutPlane4&&A.value4?te(u,x.cutPlane4,A.value4):u(null),x.cutPlane5&&A.value5?te(h,x.cutPlane5,A.value5):c(null),x.cutPlane6&&A.value6?te(R,x.cutPlane6,A.value6):R(null))},[x,E,A]),React.useEffect(()=>{y({cutPlane1:EngineCore.Vector3.Normalize(_.cutPlane1),cutPlane2:_.cutPlane2?EngineCore.Vector3.Normalize(_.cutPlane2):void 0,cutPlane3:_.cutPlane3?EngineCore.Vector3.Normalize(_.cutPlane3):void 0,cutPlane4:_.cutPlane4?EngineCore.Vector3.Normalize(_.cutPlane4):void 0,cutPlane5:_.cutPlane5?EngineCore.Vector3.Normalize(_.cutPlane5):void 0,cutPlane6:_.cutPlane6?EngineCore.Vector3.Normalize(_.cutPlane6):void 0})},[_]),React.useEffect(()=>{n&&(n.clipPlane=r,n.clipPlane2=i,n.clipPlane3=l,n.clipPlane4=f,n.clipPlane5=d,n.clipPlane6=m)},[n,r,i,l,f,d,m]),React.useEffect(()=>{var te,K,Z,ce,Q;n&&t&&(n.setFloat("alpha1",C.alpha1),n.setFloat("alpha2",(te=C.alpha2)!=null?te:1),n.setFloat("alpha3",(K=C.alpha3)!=null?K:1),n.setFloat("alpha4",(Z=C.alpha4)!=null?Z:1),n.setFloat("alpha5",(ce=C.alpha5)!=null?ce:1),n.setFloat("alpha6",(Q=C.alpha6)!=null?Q:1))},[t,C,n]),React.useEffect(()=>{n&&k&&n.setTexture("textureSampler",k)},[n,k]),React.useEffect(()=>{n&&N&&n.setFloat("tilingFactor",N),n&&S&&n.setFloat("sideTilingFactor",S)},[N,S,n]),React.useEffect(()=>{n&&I&&n.setInt("mode",I)},[n,I]),React.useEffect(()=>{n&&(b?n.setTexture("textureSideSampler",b):n.setTexture("textureSideSampler",k))},[n,b,k]),React.useEffect(()=>{n&&(w.texture1?n.setTexture("textureSampler1",w.texture1):n.setTexture("textureSampler1",k),w.sideTexture1?n.setTexture("textureSideSampler1",w.sideTexture1):n.setTexture("textureSideSampler1",k),w.color1?n.setColor3("vColor1",w.color1):n.setColor3("vColor1",new EngineCore.Color3(1,1,1)),w.texture2?n.setTexture("textureSampler2",w.texture2):n.setTexture("textureSampler2",k),w.sideTexture2?n.setTexture("textureSideSampler2",w.sideTexture2):n.setTexture("textureSideSampler2",k),w.color2?n.setColor3("vColor2",w.color2):n.setColor3("vColor2",new EngineCore.Color3(1,1,1)),w.texture3?n.setTexture("textureSampler3",w.texture3):n.setTexture("textureSampler3",k),w.sideTexture3?n.setTexture("textureSideSampler3",w.sideTexture3):n.setTexture("textureSideSampler2",k),w.color3?n.setColor3("vColor3",w.color3):n.setColor3("vColor3",new EngineCore.Color3(1,1,1)),w.texture4?n.setTexture("textureSampler4",w.texture4):n.setTexture("textureSampler4",k),w.sideTexture4?n.setTexture("textureSideSampler4",w.sideTexture4):n.setTexture("textureSideSampler4",k),w.color4?n.setColor3("vColor4",w.color4):n.setColor3("vColor4",new EngineCore.Color3(1,1,1)),w.texture5?n.setTexture("textureSampler5",w.texture5):n.setTexture("textureSampler5",k),w.sideTexture5?n.setTexture("textureSideSampler5",w.sideTexture5):n.setTexture("textureSideSampler5",k),w.color5?n.setColor3("vColor5",w.color5):n.setColor3("vColor5",new EngineCore.Color3(1,1,1)),w.texture6?n.setTexture("textureSampler6",w.texture6):n.setTexture("textureSampler6",k),w.sideTexture6?n.setTexture("textureSideSampler6",w.sideTexture6):n.setTexture("textureSideSampler6",k),w.color6?n.setColor3("vColor6",w.color6):n.setColor3("vColor6",new EngineCore.Color3(1,1,1)))},[n,w,k]),React.useEffect(()=>{var te;if(n&&E)if(L){const K=(te=L.startHeight)!=null?te:E.minimumWorld.y/D;return n.setFloat("contourLineStartHeight",K*D),n.setColor3("contourLineColor",L.color),n.setFloat("contourLineWidth",L.width),n.setFloat("contourLineStep",L.stepHeight*D),console.log("[Geo3DViewer] 等高线设置 ",L,E.centerWorld.y,K*D,K*D+16*L.stepHeight*D),()=>{n&&(n.setFloat("contourLineStartHeight",0),n.setColor3("contourLineColor",new EngineCore.Color3(0,0,0)),n.setFloat("contourLineWidth",0),n.setFloat("contourLineStep",0))}}else n.setFloat("contourLineStartHeight",0),n.setColor3("contourLineColor",new EngineCore.Color3(0,0,0)),n.setFloat("contourLineWidth",0),n.setFloat("contourLineStep",0),console.log("[Geo3DViewer] 等高线设置 关闭")},[L,D,B,E,n]),React.useEffect(()=>{t&&n&&E&&g(te=>{te&&te.dispose();let K=(E.maximum.x-E.minimum.x)/B,Z=(E.maximum.z-E.minimum.z)/B,ce=0;if(K<Z){const ge=K;K=Z,Z=ge,ce=1}const Q=K/Z;K*Z>2048*2048&&(K=2048,Z=2048/Q);const G=new EngineCore.DynamicTexture("dynamic-texture",{width:K,height:Z},t,!1);return G.clear(),console.log("[Geo3DViewer] 设置动态划线 ",E,K,Z,B),n.setVector3("oMin",E.minimum),n.setVector3("oMax",E.maximum),n.setFloat("textureOverlayRotate",ce),n.setTexture("textureOverlaySampler",G),G})},[E,n,B,t]),React.useEffect(()=>{var te;if(v&&E)if((te=v.getScene())!=null&&te.getEngine()){v.clear();let K=(E.maximum.x-E.minimum.x)/B,Z=(E.maximum.z-E.minimum.z)/B;if(K<Z){const G=K;K=Z,Z=G}const ce=K/Z;K*Z>2048*2048&&(K=2048,Z=2048/ce);const Q=v.getContext();W.forEach(G=>{if(G.points.length<2)return;Q.beginPath();const ge=G.offset?G.offset:new EngineCore.Vector2(0,0),fe=1-G.points[0].x+ge.x,V=1-G.points[0].y+ge.y;Q.moveTo(fe*K,V*Z);for(let J=1;J<G.points.length;J++){const Re=G.offset?G.offset:new EngineCore.Vector2(0,0),Ce=1-G.points[J].x+Re.x,Y=1-G.points[J].y+Re.y;Q.lineTo(Ce*K,Y*Z)}Q.strokeStyle=`rgb(${G.color.r*255}, ${G.color.g*255}, ${G.color.b*255})`,K*Z>2048*2048?Q.lineWidth=G.width/ce:Q.lineWidth=G.width,Q.stroke()}),ae.forEach(G=>{var J,Re;Q.font=`${G.fontSize}px Arial`;const ge=(J=G.color)!=null?J:EngineCore.Color3.White(),fe=G.offset?G.offset:new EngineCore.Vector2(0,0),V=(Re=G.rotation)!=null?Re:0;if(Q.save(),Q.translate((1-G.position.x+fe.x)*K,(1-G.position.y+fe.y)*Z),Q.rotate(V),G.clearArea){const Ce=Q.measureText(G.text);Q.clearRect(-Ce.width*.15,.5*G.fontSize*(1-.3),Ce.width*1.3,-G.fontSize*1.3)}if(G.background){Q.fillStyle=`rgba(${G.background.r*255}, ${G.background.g*255}, ${G.background.b*255})`;const Ce=Q.measureText(G.text);Q.fillRect(-Ce.width*.05,.5*(G.fontSize*(.5-.1)),Ce.width*1.1,-G.fontSize*1.1)}Q.fillStyle=`rgb(${ge.r*255}, ${ge.g*255}, ${ge.b*255})`,Q.fillText(G.text,0,0),Q.restore()}),v.update()}else console.log("[Geo3DViewer] 动态纹理未准备好,正准备下一次绘制")},[W,v,E,B,ae]),jsxRuntime.jsx(CustomShader$1,{...e,ref:oe,vertex:repeatedTextureProgressedVertexSource,fragment:repeatedTextureProgressedFragmentSource,options:{attributes:["position","color","normal"],uniforms:["world","worldViewProjection","alpha1","alpha2","alpha3","alpha4","alpha5","alpha6","oMin","oMax","tilingFactor","sideTilingFactor","mode","vColor1","vColor2","vColor3","vColor4","vColor5","vColor6","contourLineStartHeight","contourLineColor","contourLineWidth","contourLineStep","textureOverlayRotate","textureFlatRotate"],samplers:["textureSampler","textureOverlaySampler","textureSideSampler","textureSampler1","textureSideSampler1","textureSampler2","textureSideSampler2","textureSampler3","textureSideSampler3","textureSampler4","textureSideSampler4","textureSampler5","textureSideSampler5","textureSampler6","textureSideSampler6"],needAlphaBlending:!0,needAlphaTesting:!0,useClipPlane:!0},zOffset:O,zOffsetUnits:F,disableDepthWrite:ee})},FlatMaterial=e=>jsxRuntime.jsx(CustomShader$1,{...e,vertex:flatVertexSource,fragment:flatFragmentSource,options:{needAlphaBlending:!0},zOffset:e.zOffset,zOffsetUnits:e.zOffsetUnits,disableDepthWrite:e.disableDepthWrite}),PickingMaterial=()=>jsxRuntime.jsx(CustomShader$1,{name:"picking-material",vertex:pickingVertexSource,fragment:pickingFragmentSource,backFaceCulling:!1,options:{attributes:["position","color","normal"],uniforms:["world","worldViewProjection","pickingColor","isPickable"]}}),createMultiStageWaterEffectMaterial=({name:e,scene:t})=>{const n=EngineCore.NodeMaterial.Parse(MultiStageWaterMaterial,t);return n.name=e,n.backFaceCulling=!1,n.build(!1,!0,!1),n},useIntersectingLineMaterial=({name:e,lineColor:t,lineWidth:n=.5})=>{const a=reactBabylonjs.useScene(),[r,o]=React.useState(null);return React.useEffect(()=>{if(a){const i=EngineCore.NodeMaterial.Parse(intersectingLineSource,a);return i.name=`${e}-material`,i.backFaceCulling=!1,i.build(!1,!0,!1),o(i),()=>{o(s=>(s==null||s.dispose(!0,!1),null))}}},[e,a]),React.useEffect(()=>{o(i=>i&&t?(i.getBlockByName("Color3").value=t,i.build(!1,!0,!1),i):null)},[t]),React.useEffect(()=>{o(i=>{if(i&&n!==void 0&&n!==null){let s=n;return n<1&&(s=1),i.getBlockByName("offset").value=1-s,i.build(!1,!0,!1),i}return null})},[n]),r},VoxelGridMaterial=(e,t)=>{const n=React.useRef(null);return React.useEffect(()=>{n.current&&(n.current.setVector4("typeAlpha1",new EngineCore.Vector4(e.typeAlpha.typeAlpha0===void 0?1:e.typeAlpha.typeAlpha0,e.typeAlpha.typeAlpha1,e.typeAlpha.typeAlpha2,e.typeAlpha.typeAlpha3)),n.current.setVector4("typeAlpha2",new EngineCore.Vector4(e.typeAlpha.typeAlpha4,e.typeAlpha.typeAlpha5,e.typeAlpha.typeAlpha6,e.typeAlpha.typeAlpha7)),n.current.setVector4("typeAlpha3",new EngineCore.Vector4(e.typeAlpha.typeAlpha8,e.typeAlpha.typeAlpha9,e.typeAlpha.typeAlpha10,e.typeAlpha.typeAlpha11)),n.current.setVector4("typeAlpha4",new EngineCore.Vector4(e.typeAlpha.typeAlpha12,e.typeAlpha.typeAlpha13,e.typeAlpha.typeAlpha14,e.typeAlpha.typeAlpha15)),n.current.setVector4("typeAlpha5",new EngineCore.Vector4(e.typeAlpha.typeAlpha16,e.typeAlpha.typeAlpha17,e.typeAlpha.typeAlpha18,e.typeAlpha.typeAlpha19)))},[e.typeAlpha]),React.useImperativeHandle(t,()=>n.current,[]),jsxRuntime.jsx(CustomShader$1,{ref:n,name:e.name,backFaceCulling:!0,needDepthPrePass:!1,vertex:voxelGridVertexSource,fragment:voxelGridFragmentSource,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,alphaMode:EngineCore.Engine.ALPHA_COMBINE,options:{attributes:["position","color","uv","normal","world0","world1","world2","world3","instanceColor"],uniforms:["world","worldViewProjection","view","viewProjection","typeAlpha1","typeAlpha2","typeAlpha3","typeAlpha4","worldView","projection","previousWorld","vEyePosition"],defines:["#define INSTANCESCOLOR","#define INSTANCES"],needAlphaBlending:!0,needAlphaTesting:!0}})},OneColorMaterial=e=>{const t=reactBabylonjs.useScene(),[n,a]=React.useState(null),r=React.useRef(null),{boundingBox:o,counterLine:i,scaleDepth:s=1,scalePlane:l=1,color:c,alpha:f=1,lines:u=[],text:d=[],surfaceCanvasOptions:h={textureIncludeSide:!0},disableDepthWrite:m,disableNormalShadow:R=!1}=e,{textureIncludeSide:v}=h;return React.useEffect(()=>{r.current&&(console.log("[Geo3DViewer] 设置材质 ",c,f),r.current.setColor3("vColor",c),r.current.setFloat("vAlpha",f),r.current.setFloat("textureIncludeSide",v==null?1:0))},[c,f,v]),React.useEffect(()=>{var x;const g=r.current;if(g&&o)if(i){const y=(x=i.startHeight)!=null?x:o.maximumWorld.y/s;return g.setFloat("contourLineStartHeight",y*s),g.setColor3("contourLineColor",i.color),g.setFloat("contourLineWidth",i.width),g.setFloat("contourLineStep",i.stepHeight*s),console.log("[Geo3DViewer] 等高线设置 ",i,o.centerWorld.y,y*s,y*s-16*i.stepHeight*s),()=>{g&&(g.setFloat("contourLineStartHeight",0),g.setColor3("contourLineColor",new EngineCore.Color3(0,0,0)),g.setFloat("contourLineWidth",0),g.setFloat("contourLineStep",0))}}else g.setFloat("contourLineStartHeight",0),g.setColor3("contourLineColor",new EngineCore.Color3(0,0,0)),g.setFloat("contourLineWidth",0),g.setFloat("contourLineStep",0),console.log("[Geo3DViewer] 等高线设置 关闭")},[o,i,s,l]),React.useEffect(()=>{const g=r.current;t&&o&&g&&a(x=>{let y=(o.maximum.x-o.minimum.x)/l,E=(o.maximum.z-o.minimum.z)/l,k=0;if(y<E){const _=y;y=E,E=_,k=1}const b=y/E;y*E>2048*2048&&(y=2048,E=2048/b);let C;return x?(x.scaleTo(y,E),x.update(),C=x):C=new EngineCore.DynamicTexture("dynamic-texture",{width:y,height:E},t,!1),C.clear(),C.update(),console.log("[Geo3DViewer] 设置动态划线 ",o,y,E,l),g.setVector3("oMin",o.minimum),g.setVector3("oMax",o.maximum),g.setFloat("textureOverlayRotate",k),g.setTexture("textureOverlaySampler",C),C})},[o,l,t]),React.useEffect(()=>{var g;if(n&&o&&(u.length>0||d.length>0))if((g=n.getScene())!=null&&g.getEngine()){n.clear();let x=(o.maximum.x-o.minimum.x)/l,y=(o.maximum.z-o.minimum.z)/l;if(x<y){const b=x;x=y,y=b}const E=x/y;x*y>2048*2048&&(x=2048,y=2048/E);const k=n.getContext();u.forEach(b=>{if(b.points.length<2)return;k.beginPath();const C=b.offset?b.offset:new EngineCore.Vector2(0,0),_=1-b.points[0].x+C.x,A=1-b.points[0].y+C.y;k.moveTo(_*x,A*y);for(let N=1;N<b.points.length;N++){const S=b.offset?b.offset:new EngineCore.Vector2(0,0),I=1-b.points[N].x+S.x,O=1-b.points[N].y+S.y;k.lineTo(I*x,O*y)}k.strokeStyle=`rgb(${b.color.r*255}, ${b.color.g*255}, ${b.color.b*255})`,x*y>2048*2048?k.lineWidth=b.width/E:k.lineWidth=b.width,k.stroke()}),d.forEach(b=>{var N,S;k.font=`${b.fontSize}px Arial`;const C=(N=b.color)!=null?N:EngineCore.Color3.White(),_=b.offset?b.offset:new EngineCore.Vector2(0,0),A=(S=b.rotation)!=null?S:0;if(k.save(),k.translate((1-b.position.x+_.x)*x,(1-b.position.y+_.y)*y),k.rotate(A),b.clearArea){const I=k.measureText(b.text);k.clearRect(-I.width*.15,.5*b.fontSize*(1-.3),I.width*1.3,-b.fontSize*1.3)}if(b.background){k.fillStyle=`rgba(${b.background.r*255}, ${b.background.g*255}, ${b.background.b*255})`;const I=k.measureText(b.text);k.fillRect(-I.width*.05,.5*(b.fontSize*(.5-.1)),I.width*1.1,-b.fontSize*1.1)}k.fillStyle=`rgb(${C.r*255}, ${C.g*255}, ${C.b*255})`,k.fillText(b.text,0,0),k.restore()}),n.update()}else console.log("[Geo3DViewer] 动态纹理未准备好,正准备下一次绘制")},[u,n,o,l,d]),React.useEffect(()=>{const g=r.current;if(g){if(R)return g.setFloat("disableNormalShadow",1),console.log("[Geo3DViewer] 禁用法向阴影 启用"),()=>{g&&g.setFloat("disableNormalShadow",0)};g.setFloat("disableNormalShadow",0),console.log("[Geo3DViewer] 禁用法向阴影 禁用")}},[R]),jsxRuntime.jsx(CustomShader$1,{ref:r,name:e.name,backFaceCulling:e.backFaceCulling,needDepthPrePass:e.needDepthPrePass,vertex:oneColorVertexSource,fragment:oneColorFragmentSource,transparencyMode:e.transparencyMode,alphaMode:e.alphaMode,options:{attributes:["position","color","normal"],uniforms:["world","worldViewProjection","vAlpha","vColor","contourLineStartHeight","contourLineColor","contourLineWidth","contourLineStep","oMin","oMax","textureOverlayRotate","textureIncludeSide","disableNormalShadow"],samplers:["textureOverlaySampler"],needAlphaBlending:!0,needAlphaTesting:!0},zOffset:e.zOffset,zOffsetUnits:e.zOffsetUnits,disableDepthWrite:m})},VoxelGridMaterialForwardRef=React.forwardRef(VoxelGridMaterial),AttributeBody=({name:e,url:t,offset:n=EngineCore.Vector3.Zero(),alpha:a=1,material:r,visible:o=!0,actions:i})=>{const s=reactBabylonjs.useScene(),l=React.useRef(null),c=React.useContext(WorkspaceMetaContext),f=useCachedBinary({url:t,cacheType:CacheType.URL_PREFIX_MATCH}),u=useCachedTexture({url:r.texture,cacheType:CacheType.URL_PREFIX_MATCH}),d=useCachedTexture({url:r.sideTexture,cacheType:CacheType.URL_PREFIX_MATCH}),[h,m]=React.useState(EngineCore.Vector3.Zero()),[R,v]=React.useState();return React.useEffect(()=>{console.log("[Geo3DViewer] AttributeBody Loading: ",t)},[t]),React.useEffect(()=>{if(s&&l.current&&t&&f){EngineCore.Tags.EnableFor(l.current),EngineCore.Tags.AddTagsTo(l.current,"loading");const g=VirtualVolume.decode(new Uint8Array(f)),{points:x,indices:y,value:E,center:k}=g,b=new EngineCore.VertexData;b.positions=x,b.indices=y,b.colors=E;const C=[];EngineCore.VertexData.ComputeNormals(x,y,C),b.normals=C,k&&m(new EngineCore.Vector3(k.x,k.y,k.z));const _=l.current;_&&(b.applyToMesh(_),_.getScene().onAfterRenderObservable.addOnce(()=>{if(!_.isDisposed()){const N=_.getBoundingInfo();v(N.boundingBox)}})),EngineCore.Tags.RemoveTagsFrom(l.current,"loading")}},[t,s,f]),React.useEffect(()=>{l.current&&(l.current.metadata={pickable:i?{name:e,onLeftClick:i.onLeftClick,onRightClick:i.onRightClick,onMiddleClick:i.onMiddleClick,onHover:i.onHover,extra:i.extra}:null})},[i,e]),jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx("transformNode",{name:`transform-attribute-${e}`,position:h.add(n).multiplyByFloats(c&&c.scalePlane?c.scalePlane:1,c&&c.scaleDepth?c.scaleDepth:1,c&&c.scalePlane?c.scalePlane:1),scaling:new EngineCore.Vector3(c?c.scalePlane:1,c?c.scaleDepth:1,c?c.scalePlane:1),children:jsxRuntime.jsx("mesh",{name:`attributebody-${e}-mesh`,ref:l,setEnabled:o,useVertexColors:r.type===MaterialType.COLOR_CODEC,children:r.type===MaterialType.COLOR_CODEC&&r.colorCodec?jsxRuntime.jsx(RemapColorByRedChannelMaterial,{name:`attributebody-${e}-mat`,backFaceCulling:r.backFaceCulling===void 0?!0:r.backFaceCulling,needDepthPrePass:r.needDepthPrePass===void 0?!1:r.needDepthPrePass,alpha:r.alpha?r.alpha:a,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,alphaMode:EngineCore.Engine.ALPHA_COMBINE,colorCodec:r.colorCodec,boundingBox:R,lines:r.lines,text:r.text,scaleDepth:c?c.scaleDepth:1,scalePlane:c?c.scalePlane:1,disableDepthWrite:r.disableDepthWrite}):r.type===MaterialType.ONE_COLOR&&r.color?jsxRuntime.jsx("standardMaterial",{name:`attributebody-${e}-overwrite-mat`,backFaceCulling:r.backFaceCulling===void 0?!0:r.backFaceCulling,needDepthPrePass:r.needDepthPrePass===void 0?!1:r.needDepthPrePass,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,specularColor:new EngineCore.Color3(0,0,0),ambientColor:new EngineCore.Color3(1,1,1),diffuseColor:new EngineCore.Color3(r.color.r,r.color.g,r.color.b),emissiveColor:EngineCore.Color3.Black(),alphaMode:EngineCore.Engine.ALPHA_COMBINE,alpha:r.alpha?r.alpha:a,zOffset:-3,disableDepthWrite:r.disableDepthWrite}):r.type===MaterialType.TEXTURE&&u?jsxRuntime.jsx(RepeatedTextureMaterial,{name:`attributebody-${e}-texture-mat`,backFaceCulling:r.backFaceCulling===void 0?!0:r.backFaceCulling,needDepthPrePass:r.needDepthPrePass===void 0?!1:r.needDepthPrePass,alpha:r.alpha?r.alpha:a,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,alphaMode:EngineCore.Engine.ALPHA_COMBINE,texture:u,sideTexture:d,mode:r.textureMode===void 0?RepeatedTextureMode.PLANE:r.textureMode,boundingBox:R,disableDepthWrite:r.disableDepthWrite}):jsxRuntime.jsx(jsxRuntime.Fragment,{})})})})},AttributeBody$1=AttributeBody,ColorCodec=({codec:e,showValue:t=!1,showTitle:n=!0,width:a=80,height:r=200})=>{const o=React.useContext(ColorCodecImageContext);return jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsxs("adtFullscreenUi",{name:`adt-color-codec-${e}`,children:[n?jsxRuntime.jsx("textBlock",{name:`color-codec-title-${e}`,text:e,color:"white",paddingBottomInPixels:r+40/200*r,paddingRightInPixels:30/80*a,textVerticalAlignment:EngineGui.Control.VERTICAL_ALIGNMENT_CENTER,textHorizontalAlignment:EngineGui.Control.HORIZONTAL_ALIGNMENT_RIGHT}):jsxRuntime.jsx(jsxRuntime.Fragment,{}),jsxRuntime.jsx("babylon-image",{name:`color-codec-${e}`,source:o!=null&&o.colorCodecsImage.current[e]?o.colorCodecsImage.current[e].blobUrl:"",height:`${r}px`,width:`${a}px`,verticalAlignment:EngineGui.Control.VERTICAL_ALIGNMENT_CENTER,horizontalAlignment:EngineGui.Control.HORIZONTAL_ALIGNMENT_RIGHT,paddingRightInPixels:20}),t&&(o!=null&&o.colorCodecsImage.current[e])?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("textBlock",{name:"color-codec-value-min",text:o.colorCodecsImage.current[e].min.toFixed(1).toString(),color:"white",paddingBottomInPixels:-1*r,paddingRightInPixels:90,textVerticalAlignment:EngineGui.Control.VERTICAL_ALIGNMENT_CENTER,textHorizontalAlignment:EngineGui.Control.HORIZONTAL_ALIGNMENT_RIGHT}),jsxRuntime.jsx("textBlock",{name:"color-codec-title-avg",text:((o.colorCodecsImage.current[e].max-o.colorCodecsImage.current[e].min)/2).toFixed(1).toString(),color:"white",paddingBottomInPixels:0,paddingRightInPixels:a+10,textVerticalAlignment:EngineGui.Control.VERTICAL_ALIGNMENT_CENTER,textHorizontalAlignment:EngineGui.Control.HORIZONTAL_ALIGNMENT_RIGHT}),jsxRuntime.jsx("textBlock",{name:"color-codec-title-max",text:o.colorCodecsImage.current[e].max.toFixed(1).toString(),color:"white",paddingBottomInPixels:r,paddingRightInPixels:a+10,textVerticalAlignment:EngineGui.Control.VERTICAL_ALIGNMENT_CENTER,textHorizontalAlignment:EngineGui.Control.HORIZONTAL_ALIGNMENT_RIGHT})]}):null]})})},ColorCodec$1=ColorCodec;function createBaseFormation(){return{name:"",colorId:0,points:[],indices:[],bottomIndices:[],value:[],vMin:0,vMax:0,border:[],side:[],sideIndices:[],sideValue:[],center:void 0}}const Formation={encode(e,t=minimal.Writer.create()){e.name!==""&&t.uint32(10).string(e.name),e.colorId!==0&&t.uint32(16).uint32(e.colorId),t.uint32(170).fork();for(const n of e.points)t.float(n);t.ldelim(),t.uint32(178).fork();for(const n of e.indices)t.uint32(n);t.ldelim(),t.uint32(186).fork();for(const n of e.bottomIndices)t.uint32(n);t.ldelim(),t.uint32(194).fork();for(const n of e.value)t.float(n);t.ldelim(),e.vMin!==0&&t.uint32(205).float(e.vMin),e.vMax!==0&&t.uint32(213).float(e.vMax),t.uint32(218).fork();for(const n of e.border)t.uint32(n);t.ldelim(),t.uint32(226).fork();for(const n of e.side)t.float(n);t.ldelim(),t.uint32(234).fork();for(const n of e.sideIndices)t.uint32(n);t.ldelim(),t.uint32(242).fork();for(const n of e.sideValue)t.float(n);return t.ldelim(),e.center!==void 0&&Vertex.encode(e.center,t.uint32(250).fork()).ldelim(),t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseFormation();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.name=n.string();continue;case 2:if(o!==16)break;r.colorId=n.uint32();continue;case 21:if(o===173){r.points.push(n.float());continue}if(o===170){const i=n.uint32()+n.pos;for(;n.pos<i;)r.points.push(n.float());continue}break;case 22:if(o===176){r.indices.push(n.uint32());continue}if(o===178){const i=n.uint32()+n.pos;for(;n.pos<i;)r.indices.push(n.uint32());continue}break;case 23:if(o===184){r.bottomIndices.push(n.uint32());continue}if(o===186){const i=n.uint32()+n.pos;for(;n.pos<i;)r.bottomIndices.push(n.uint32());continue}break;case 24:if(o===197){r.value.push(n.float());continue}if(o===194){const i=n.uint32()+n.pos;for(;n.pos<i;)r.value.push(n.float());continue}break;case 25:if(o!==205)break;r.vMin=n.float();continue;case 26:if(o!==213)break;r.vMax=n.float();continue;case 27:if(o===216){r.border.push(n.uint32());continue}if(o===218){const i=n.uint32()+n.pos;for(;n.pos<i;)r.border.push(n.uint32());continue}break;case 28:if(o===229){r.side.push(n.float());continue}if(o===226){const i=n.uint32()+n.pos;for(;n.pos<i;)r.side.push(n.float());continue}break;case 29:if(o===232){r.sideIndices.push(n.uint32());continue}if(o===234){const i=n.uint32()+n.pos;for(;n.pos<i;)r.sideIndices.push(n.uint32());continue}break;case 30:if(o===245){r.sideValue.push(n.float());continue}if(o===242){const i=n.uint32()+n.pos;for(;n.pos<i;)r.sideValue.push(n.float());continue}break;case 31:if(o!==250)break;r.center=Vertex.decode(n,n.uint32());continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{name:isSet$b(e.name)?globalThis.String(e.name):"",colorId:isSet$b(e.colorId)?globalThis.Number(e.colorId):0,points:globalThis.Array.isArray(e==null?void 0:e.points)?e.points.map(t=>globalThis.Number(t)):[],indices:globalThis.Array.isArray(e==null?void 0:e.indices)?e.indices.map(t=>globalThis.Number(t)):[],bottomIndices:globalThis.Array.isArray(e==null?void 0:e.bottomIndices)?e.bottomIndices.map(t=>globalThis.Number(t)):[],value:globalThis.Array.isArray(e==null?void 0:e.value)?e.value.map(t=>globalThis.Number(t)):[],vMin:isSet$b(e.vMin)?globalThis.Number(e.vMin):0,vMax:isSet$b(e.vMax)?globalThis.Number(e.vMax):0,border:globalThis.Array.isArray(e==null?void 0:e.border)?e.border.map(t=>globalThis.Number(t)):[],side:globalThis.Array.isArray(e==null?void 0:e.side)?e.side.map(t=>globalThis.Number(t)):[],sideIndices:globalThis.Array.isArray(e==null?void 0:e.sideIndices)?e.sideIndices.map(t=>globalThis.Number(t)):[],sideValue:globalThis.Array.isArray(e==null?void 0:e.sideValue)?e.sideValue.map(t=>globalThis.Number(t)):[],center:isSet$b(e.center)?Vertex.fromJSON(e.center):void 0}},toJSON(e){var n,a,r,o,i,s,l,c;const t={};return e.name!==""&&(t.name=e.name),e.colorId!==0&&(t.colorId=Math.round(e.colorId)),(n=e.points)!=null&&n.length&&(t.points=e.points),(a=e.indices)!=null&&a.length&&(t.indices=e.indices.map(f=>Math.round(f))),(r=e.bottomIndices)!=null&&r.length&&(t.bottomIndices=e.bottomIndices.map(f=>Math.round(f))),(o=e.value)!=null&&o.length&&(t.value=e.value),e.vMin!==0&&(t.vMin=e.vMin),e.vMax!==0&&(t.vMax=e.vMax),(i=e.border)!=null&&i.length&&(t.border=e.border.map(f=>Math.round(f))),(s=e.side)!=null&&s.length&&(t.side=e.side),(l=e.sideIndices)!=null&&l.length&&(t.sideIndices=e.sideIndices.map(f=>Math.round(f))),(c=e.sideValue)!=null&&c.length&&(t.sideValue=e.sideValue),e.center!==void 0&&(t.center=Vertex.toJSON(e.center)),t},create(e){return Formation.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o,i,s,l,c,f,u,d,h;const t=createBaseFormation();return t.name=(n=e.name)!=null?n:"",t.colorId=(a=e.colorId)!=null?a:0,t.points=((r=e.points)==null?void 0:r.map(m=>m))||[],t.indices=((o=e.indices)==null?void 0:o.map(m=>m))||[],t.bottomIndices=((i=e.bottomIndices)==null?void 0:i.map(m=>m))||[],t.value=((s=e.value)==null?void 0:s.map(m=>m))||[],t.vMin=(l=e.vMin)!=null?l:0,t.vMax=(c=e.vMax)!=null?c:0,t.border=((f=e.border)==null?void 0:f.map(m=>m))||[],t.side=((u=e.side)==null?void 0:u.map(m=>m))||[],t.sideIndices=((d=e.sideIndices)==null?void 0:d.map(m=>m))||[],t.sideValue=((h=e.sideValue)==null?void 0:h.map(m=>m))||[],t.center=e.center!==void 0&&e.center!==null?Vertex.fromPartial(e.center):void 0,t}};function isSet$b(e){return e!=null}function earcut(e,t,n=2){const a=t&&t.length,r=a?t[0]*n:e.length;let o=linkedList(e,0,r,n,!0);const i=[];if(!o||o.next===o.prev)return i;let s,l,c;if(a&&(o=eliminateHoles(e,t,o,n)),e.length>80*n){s=e[0],l=e[1];let f=s,u=l;for(let d=n;d<r;d+=n){const h=e[d],m=e[d+1];h<s&&(s=h),m<l&&(l=m),h>f&&(f=h),m>u&&(u=m)}c=Math.max(f-s,u-l),c=c!==0?32767/c:0}return earcutLinked(o,i,n,s,l,c,0),i}function linkedList(e,t,n,a,r){let o;if(r===signedArea(e,t,n,a)>0)for(let i=t;i<n;i+=a)o=insertNode(i/a|0,e[i],e[i+1],o);else for(let i=n-a;i>=t;i-=a)o=insertNode(i/a|0,e[i],e[i+1],o);return o&&equals(o,o.next)&&(removeNode(o),o=o.next),o}function filterPoints(e,t){if(!e)return e;t||(t=e);let n=e,a;do if(a=!1,!n.steiner&&(equals(n,n.next)||area(n.prev,n,n.next)===0)){if(removeNode(n),n=t=n.prev,n===n.next)break;a=!0}else n=n.next;while(a||n!==t);return t}function earcutLinked(e,t,n,a,r,o,i){if(!e)return;!i&&o&&indexCurve(e,a,r,o);let s=e;for(;e.prev!==e.next;){const l=e.prev,c=e.next;if(o?isEarHashed(e,a,r,o):isEar(e)){t.push(l.i,e.i,c.i),removeNode(e),e=c.next,s=c.next;continue}if(e=c,e===s){i?i===1?(e=cureLocalIntersections(filterPoints(e),t),earcutLinked(e,t,n,a,r,o,2)):i===2&&splitEarcut(e,t,n,a,r,o):earcutLinked(filterPoints(e),t,n,a,r,o,1);break}}}function isEar(e){const t=e.prev,n=e,a=e.next;if(area(t,n,a)>=0)return!1;const r=t.x,o=n.x,i=a.x,s=t.y,l=n.y,c=a.y,f=Math.min(r,o,i),u=Math.min(s,l,c),d=Math.max(r,o,i),h=Math.max(s,l,c);let m=a.next;for(;m!==t;){if(m.x>=f&&m.x<=d&&m.y>=u&&m.y<=h&&pointInTriangleExceptFirst(r,s,o,l,i,c,m.x,m.y)&&area(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function isEarHashed(e,t,n,a){const r=e.prev,o=e,i=e.next;if(area(r,o,i)>=0)return!1;const s=r.x,l=o.x,c=i.x,f=r.y,u=o.y,d=i.y,h=Math.min(s,l,c),m=Math.min(f,u,d),R=Math.max(s,l,c),v=Math.max(f,u,d),g=zOrder(h,m,t,n,a),x=zOrder(R,v,t,n,a);let y=e.prevZ,E=e.nextZ;for(;y&&y.z>=g&&E&&E.z<=x;){if(y.x>=h&&y.x<=R&&y.y>=m&&y.y<=v&&y!==r&&y!==i&&pointInTriangleExceptFirst(s,f,l,u,c,d,y.x,y.y)&&area(y.prev,y,y.next)>=0||(y=y.prevZ,E.x>=h&&E.x<=R&&E.y>=m&&E.y<=v&&E!==r&&E!==i&&pointInTriangleExceptFirst(s,f,l,u,c,d,E.x,E.y)&&area(E.prev,E,E.next)>=0))return!1;E=E.nextZ}for(;y&&y.z>=g;){if(y.x>=h&&y.x<=R&&y.y>=m&&y.y<=v&&y!==r&&y!==i&&pointInTriangleExceptFirst(s,f,l,u,c,d,y.x,y.y)&&area(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;E&&E.z<=x;){if(E.x>=h&&E.x<=R&&E.y>=m&&E.y<=v&&E!==r&&E!==i&&pointInTriangleExceptFirst(s,f,l,u,c,d,E.x,E.y)&&area(E.prev,E,E.next)>=0)return!1;E=E.nextZ}return!0}function cureLocalIntersections(e,t){let n=e;do{const a=n.prev,r=n.next.next;!equals(a,r)&&intersects(a,n,n.next,r)&&locallyInside(a,r)&&locallyInside(r,a)&&(t.push(a.i,n.i,r.i),removeNode(n),removeNode(n.next),n=e=r),n=n.next}while(n!==e);return filterPoints(n)}function splitEarcut(e,t,n,a,r,o){let i=e;do{let s=i.next.next;for(;s!==i.prev;){if(i.i!==s.i&&isValidDiagonal(i,s)){let l=splitPolygon(i,s);i=filterPoints(i,i.next),l=filterPoints(l,l.next),earcutLinked(i,t,n,a,r,o,0),earcutLinked(l,t,n,a,r,o,0);return}s=s.next}i=i.next}while(i!==e)}function eliminateHoles(e,t,n,a){const r=[];for(let o=0,i=t.length;o<i;o++){const s=t[o]*a,l=o<i-1?t[o+1]*a:e.length,c=linkedList(e,s,l,a,!1);c===c.next&&(c.steiner=!0),r.push(getLeftmost(c))}r.sort(compareXYSlope);for(let o=0;o<r.length;o++)n=eliminateHole(r[o],n);return n}function compareXYSlope(e,t){let n=e.x-t.x;if(n===0&&(n=e.y-t.y,n===0)){const a=(e.next.y-e.y)/(e.next.x-e.x),r=(t.next.y-t.y)/(t.next.x-t.x);n=a-r}return n}function eliminateHole(e,t){const n=findHoleBridge(e,t);if(!n)return t;const a=splitPolygon(n,e);return filterPoints(a,a.next),filterPoints(n,n.next)}function findHoleBridge(e,t){let n=t;const a=e.x,r=e.y;let o=-1/0,i;if(equals(e,n))return n;do{if(equals(e,n.next))return n.next;if(r<=n.y&&r>=n.next.y&&n.next.y!==n.y){const u=n.x+(r-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(u<=a&&u>o&&(o=u,i=n.x<n.next.x?n:n.next,u===a))return i}n=n.next}while(n!==t);if(!i)return null;const s=i,l=i.x,c=i.y;let f=1/0;n=i;do{if(a>=n.x&&n.x>=l&&a!==n.x&&pointInTriangle(r<c?a:o,r,l,c,r<c?o:a,r,n.x,n.y)){const u=Math.abs(r-n.y)/(a-n.x);locallyInside(n,e)&&(u<f||u===f&&(n.x>i.x||n.x===i.x&&sectorContainsSector(i,n)))&&(i=n,f=u)}n=n.next}while(n!==s);return i}function sectorContainsSector(e,t){return area(e.prev,e,t.prev)<0&&area(t.next,e,e.next)<0}function indexCurve(e,t,n,a){let r=e;do r.z===0&&(r.z=zOrder(r.x,r.y,t,n,a)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==e);r.prevZ.nextZ=null,r.prevZ=null,sortLinked(r)}function sortLinked(e){let t,n=1;do{let a=e,r;e=null;let o=null;for(t=0;a;){t++;let i=a,s=0;for(let c=0;c<n&&(s++,i=i.nextZ,!!i);c++);let l=n;for(;s>0||l>0&&i;)s!==0&&(l===0||!i||a.z<=i.z)?(r=a,a=a.nextZ,s--):(r=i,i=i.nextZ,l--),o?o.nextZ=r:e=r,r.prevZ=o,o=r;a=i}o.nextZ=null,n*=2}while(t>1);return e}function zOrder(e,t,n,a,r){return e=(e-n)*r|0,t=(t-a)*r|0,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e|t<<1}function getLeftmost(e){let t=e,n=e;do(t.x<n.x||t.x===n.x&&t.y<n.y)&&(n=t),t=t.next;while(t!==e);return n}function pointInTriangle(e,t,n,a,r,o,i,s){return(r-i)*(t-s)>=(e-i)*(o-s)&&(e-i)*(a-s)>=(n-i)*(t-s)&&(n-i)*(o-s)>=(r-i)*(a-s)}function pointInTriangleExceptFirst(e,t,n,a,r,o,i,s){return!(e===i&&t===s)&&pointInTriangle(e,t,n,a,r,o,i,s)}function isValidDiagonal(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!intersectsPolygon(e,t)&&(locallyInside(e,t)&&locallyInside(t,e)&&middleInside(e,t)&&(area(e.prev,e,t.prev)||area(e,t.prev,t))||equals(e,t)&&area(e.prev,e,e.next)>0&&area(t.prev,t,t.next)>0)}function area(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function equals(e,t){return e.x===t.x&&e.y===t.y}function intersects(e,t,n,a){const r=sign(area(e,t,n)),o=sign(area(e,t,a)),i=sign(area(n,a,e)),s=sign(area(n,a,t));return!!(r!==o&&i!==s||r===0&&onSegment(e,n,t)||o===0&&onSegment(e,a,t)||i===0&&onSegment(n,e,a)||s===0&&onSegment(n,t,a))}function onSegment(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function sign(e){return e>0?1:e<0?-1:0}function intersectsPolygon(e,t){let n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&intersects(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}function locallyInside(e,t){return area(e.prev,e,e.next)<0?area(e,t,e.next)>=0&&area(e,e.prev,t)>=0:area(e,t,e.prev)<0||area(e,e.next,t)<0}function middleInside(e,t){let n=e,a=!1;const r=(e.x+t.x)/2,o=(e.y+t.y)/2;do n.y>o!=n.next.y>o&&n.next.y!==n.y&&r<(n.next.x-n.x)*(o-n.y)/(n.next.y-n.y)+n.x&&(a=!a),n=n.next;while(n!==e);return a}function splitPolygon(e,t){const n=createNode(e.i,e.x,e.y),a=createNode(t.i,t.x,t.y),r=e.next,o=t.prev;return e.next=t,t.prev=e,n.next=r,r.prev=n,a.next=n,n.prev=a,o.next=a,a.prev=o,a}function insertNode(e,t,n,a){const r=createNode(e,t,n);return a?(r.next=a.next,r.prev=a,a.next.prev=r,a.next=r):(r.prev=r,r.next=r),r}function removeNode(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function createNode(e,t,n){return{i:e,x:t,y:n,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function signedArea(e,t,n,a){let r=0;for(let o=t,i=n-a;o<n;o+=a)r+=(e[i]-e[o])*(e[o+1]+e[i+1]),i=o;return r}const Me=class Me{constructor(t,n,a="",r={},o=EngineCore.EngineStore.LastCreatedScene){le(this,"_name");le(this,"_text","");le(this,"_font");le(this,"_mesh",null);le(this,"_externalMesh");le(this,"_color",new EngineCore.Color4(1,1,1,1));le(this,"_fontSize",16);le(this,"_resolution",64);le(this,"_depth",10);le(this,"_scene");le(this,"_material");le(this,"_lowPriority",!0);le(this,"_disposed",!1);le(this,"_buildVersion",0);var i,s;this._name=t,this._font=n,this._text=a,this._fontSize=r.fontSize||16,this._resolution=r.resolution||64,this._depth=r.depth||1,this._color=r.color||new EngineCore.Color4(1,1,1,1),this._lowPriority=(i=r.lowPriority)!=null?i:!0,this._scene=o,this._externalMesh=new EngineCore.Mesh(`${t}-external-mesh`,o),this._externalMesh.billboardMode=(s=r.billboardMode)!=null?s:EngineCore.Mesh.BILLBOARDMODE_ALL,this._material=new EngineCore.StandardMaterial(`${t}-material`,o),this._material.diffuseColor=EngineCore.Color3.FromArray(this._color.asArray()),this._material.specularColor=new EngineCore.Color3(0,0,0),this._material.emissiveColor=EngineCore.Color3.FromArray(this._color.asArray()),this._material.disableLighting=!0,this._material.alpha=this._color.a,this._material.transparencyMode=EngineCore.Material.MATERIAL_ALPHABLEND,this.rebuildTextMesh()}static scheduleFlush(){if(Me._interactionPaused||Me._flushHandle!==null||Me._flushTimerHandle!==null)return;const t=globalThis;if(typeof t.requestIdleCallback=="function"){Me._flushHandle=t.requestIdleCallback(n=>{if(Me._flushHandle=null,!n.didTimeout&&n.timeRemaining()<3){Me.scheduleFlush();return}Me.flushQueue(1)},{timeout:120});return}if(typeof t.requestAnimationFrame=="function"){Me._flushHandle=t.requestAnimationFrame(()=>{Me._flushHandle=null,Me.flushQueue(1)});return}Me._flushTimerHandle=t.setTimeout(()=>{Me._flushTimerHandle=null,Me.flushQueue(1)},24)}static flushQueue(t){let n=0;for(;Me._pendingTasks.length>0&&n<t;){const a=Me._pendingTasks.shift();a==null||a(),n+=1}Me._pendingTasks.length>0&&Me.scheduleFlush()}static enqueueTask(t){Me._pendingTasks.push(t),Me.scheduleFlush()}static setInteractionPaused(t){Me._interactionPaused=t,t||Me.scheduleFlush()}createTextMeshNow(){this._disposed||(this._mesh=EngineCore.MeshBuilder.CreateText(this._name,this._text,this._font,{size:this._fontSize,resolution:this._resolution,depth:this._depth},this._scene,earcut),this._mesh.parent=this._externalMesh,this._mesh.material=this._material,this._mesh.billboardMode=this._externalMesh.billboardMode)}rebuildTextMesh(){this._buildVersion+=1;const t=this._buildVersion;if(this._mesh&&(this._mesh.dispose(),this._mesh=null),!(this._disposed||this._text===void 0||this._text===null||this._text.trim()==="")){if(!this._lowPriority){this.createTextMeshNow();return}Me.enqueueTask(()=>{this._disposed||t!==this._buildVersion||this.createTextMeshNow()})}}set color(t){this._color=t,this._material&&(this._material.diffuseColor=EngineCore.Color3.FromArray(t.asArray()),this._material.emissiveColor=EngineCore.Color3.FromArray(t.asArray()),this._material.alpha=t.a)}get color(){return this._color}set text(t){this._text!==t&&(this._text=t,this.rebuildTextMesh())}get text(){return this._text}set fontSize(t){this._fontSize!==t&&(this._fontSize=t,this.rebuildTextMesh())}get fontSize(){return this._fontSize}set resolution(t){this._resolution!==t&&(this._resolution=t,this.rebuildTextMesh())}get resolution(){return this._resolution}set depth(t){this._depth!==t&&(this._depth=t,this.rebuildTextMesh())}set billboardMode(t){this._externalMesh.billboardMode!==t&&(this._externalMesh.billboardMode=t,this._mesh&&(this._mesh.billboardMode=t))}get billboardMode(){return this._externalMesh.billboardMode}set lowPriority(t){const n=this._lowPriority!==t;this._lowPriority=t,n&&!t&&!this._mesh&&this._text.trim()!==""&&this.rebuildTextMesh()}get lowPriority(){return this._lowPriority}update(t){let n=!1;t.text!==void 0&&t.text!==this._text&&(this._text=t.text,n=!0),t.fontSize!==void 0&&t.fontSize!==this._fontSize&&(this._fontSize=t.fontSize,n=!0),t.resolution!==void 0&&t.resolution!==this._resolution&&(this._resolution=t.resolution,n=!0),t.depth!==void 0&&t.depth!==this._depth&&(this._depth=t.depth,n=!0),t.color!==void 0&&(this.color=t.color),t.billboardMode!==void 0&&(this.billboardMode=t.billboardMode),t.lowPriority!==void 0&&t.lowPriority!==this._lowPriority&&(this._lowPriority=t.lowPriority,!this._lowPriority&&!this._mesh&&this._text.trim()!==""&&(n=!0)),n&&this.rebuildTextMesh()}get depth(){return this._depth}get mesh(){return this._externalMesh}get textMesh(){return this._mesh}dispose(){this._disposed=!0,this._buildVersion+=1,this._mesh&&this._mesh.dispose(),this._material.dispose(),this._externalMesh.dispose(),this._mesh=null}};le(Me,"_pendingTasks",[]),le(Me,"_flushHandle",null),le(Me,"_flushTimerHandle",null),le(Me,"_interactionPaused",!1);let FreeTypeText=Me;const FreeTypeText$1=FreeTypeText,GUIText=e=>{const t=reactBabylonjs.useScene(),n=React.useRef(null),a=React.useRef(null),r=useCachedJSON({url:"/Noto Sans SC_Regular.json"}),{name:o,text:i,fontSize:s,color:l,billboardMode:c=EngineCore.Mesh.BILLBOARDMODE_ALL,lowPriority:f=!0}=e;return React.useEffect(()=>{var u;if(a.current&&a.current.dispose(),r&&t)return a.current=new FreeTypeText$1((u=e.name)!=null?u:"gui-text-no-name",r,e.text,{fontSize:e.fontSize,color:typeof e.color=="string"?EngineCore.Color4.FromHexString(e.color):e.color,billboardMode:c,lowPriority:f},t),a.current.mesh.parent=n.current,a.current.mesh.onDisposeObservable.addOnce(()=>{a.current=null}),()=>{var d;(d=a.current)==null||d.dispose(),a.current=null}},[r,t]),React.useEffect(()=>{a.current&&(a.current.update({text:i,fontSize:s,color:typeof l=="string"?EngineCore.Color4.FromHexString(l):l,lowPriority:f}),a.current.mesh.parent=n.current)},[i,s,l,f]),React.useEffect(()=>{a.current&&c!==void 0&&(a.current.billboardMode=c)},[c]),React.useEffect(()=>{if(!t||!t.activeCamera)return;let u=null;const d=()=>{FreeTypeText$1.setInteractionPaused(!0),u&&clearTimeout(u),u=setTimeout(()=>{FreeTypeText$1.setInteractionPaused(!1)},150)},h=t.activeCamera.onViewMatrixChangedObservable.add(d);return()=>{var m;(m=t.activeCamera)==null||m.onViewMatrixChangedObservable.remove(h),u&&clearTimeout(u),FreeTypeText$1.setInteractionPaused(!1)}},[t]),jsxRuntime.jsx("transformNode",{name:o!=null?o:"no-name-text",ref:n})},GUIText$1=GUIText,FormationFace=({urlTopLayer:e,urlBottomLayer:t,showLayerLabel:n=!1,labelStyle:a,position:r=EngineCore.Vector3.Zero(),visible:o=!0,showBottomLayer:i=!1,actions:s,material:l={type:MaterialType.COLOR_ID,alpha:1}})=>{var O,F;const c=React.useRef(null),f=React.useRef(null),[u,d]=React.useState(""),[h,m]=React.useState(null),R=React.useContext(WorkspaceMetaContext),v=React.useContext(ColorProviderContext),[g,x]=React.useState(EngineCore.Color3.White()),y=useCachedBinary({url:e,cacheType:CacheType.URL_PREFIX_MATCH}),E=useCachedBinary({url:t,cacheType:CacheType.URL_PREFIX_MATCH}),k=useCachedTexture({url:l==null?void 0:l.texture,cacheType:CacheType.URL_PREFIX_MATCH}),b=useCachedTexture({url:l==null?void 0:l.sideTexture,cacheType:CacheType.URL_PREFIX_MATCH});React.useEffect(()=>{console.log("[Geo3DViewer] FormationFace Loading: ",e,t)},[e,t]);const[C,_]=React.useState(),[A,N]=React.useState(EngineCore.Vector3.Zero()),[S,I]=React.useState(void 0);return React.useEffect(()=>{if(y){const w=c.current;w&&(EngineCore.Tags.EnableFor(w),EngineCore.Tags.AddTagsTo(w,"loading"));let L=[],B=[],D=[];const W=Formation.decode(new Uint8Array(y));{const{name:H,points:oe,indices:te,colorId:K,value:Z,center:ce}=W;L=oe,B=te,D=Z,m(K),d(H),ce&&N(new EngineCore.Vector3(ce.x,ce.y,ce.z))}const ae=new EngineCore.VertexData;ae.positions=L,ae.indices=B,ae.colors=D;const ee=[];if(EngineCore.VertexData.ComputeNormals(L,B,ee),ae.normals=ee,w){ae.applyToMesh(w);const H=w.getBoundingInfo();_(H.boundingBox.center.add(new EngineCore.Vector3(H.boundingBox.extendSize.x,0,0))),i||w.getScene().onAfterRenderObservable.addOnce(()=>{if(!w.isDisposed()){const te=w.getBoundingInfo();I(te.boundingBox)}})}return w&&EngineCore.Tags.RemoveTagsFrom(w,"loading"),()=>{w&&new EngineCore.VertexData().applyToMesh(w)}}},[y,i]),React.useEffect(()=>{if(y&&E){const w=f.current;w&&(EngineCore.Tags.EnableFor(w),EngineCore.Tags.AddTagsTo(w,"loading"));let L=[],B=[],D=[],W=[],ae=[],ee=[],H=[],oe=[];{const fe=Formation.decode(new Uint8Array(y)),{points:V,indices:J,border:Re,value:Ce}=fe;L=V,B=J,W=Re,D=Ce}{const fe=Formation.decode(new Uint8Array(E)),{points:V,bottomIndices:J,border:Re,value:Ce}=fe;ae=V,ee=J,H=Re,oe=Ce}const te=new EngineCore.VertexData,K=new Float32Array(L.length+ae.length);let Z=B.length+ee.length;Z=Z+((W.length<1?1:W.length)-1)*6;const ce=new Int32Array(Z),Q=new Float32Array(D.length+oe.length);K.set(L),ce.set(B),Q.set(D),K.set(ae,L.length),ce.set(ee,B.length),Q.set(oe,D.length);const G=[];for(let fe=0;fe<W.length-1;fe++)G.push(W[fe+1]),G.push(W[fe]),G.push(H[fe]+L.length/3),G.push(H[fe+1]+L.length/3),G.push(H[fe]+L.length/3),G.push(W[fe+1]);ce.set(G,B.length+ee.length),te.positions=K,te.indices=ce,te.colors=Q;const ge=[];return EngineCore.VertexData.ComputeNormals(K,ce,ge),te.normals=ge,w&&(te.applyToMesh(w),i&&w.getScene().onAfterRenderObservable.addOnce(()=>{if(!w.isDisposed()){const V=w.getBoundingInfo();I(V.boundingBox)}})),w&&EngineCore.Tags.RemoveTagsFrom(w,"loading"),()=>{w&&new EngineCore.VertexData().applyToMesh(w)}}},[E,y,i]),React.useEffect(()=>{var w;x(l.type===MaterialType.ONE_COLOR?(w=l==null?void 0:l.color)!=null?w:EngineCore.Color3.Random():h&&v.colorIDs[h]?new EngineCore.Color3(v.colorIDs[h].r,v.colorIDs[h].g,v.colorIDs[h].b):EngineCore.Color3.Random())},[v.colorIDs,h,l==null?void 0:l.color,l.type]),React.useEffect(()=>{c.current&&(c.current.metadata={pickable:s?{name:u,onLeftClick:s.onLeftClick,onRightClick:s.onRightClick,onMiddleClick:s.onMiddleClick,onHover:s.onHover,extra:s.extra}:null}),f.current&&(f.current.metadata={pickable:s?{name:u,onLeftClick:s.onLeftClick,onRightClick:s.onRightClick,onMiddleClick:s.onMiddleClick,onHover:s.onHover,extra:s.extra}:null})},[s,u]),jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsxs("transformNode",{name:`transform-formation-${u}-${e}`,position:A.add(r).multiplyByFloats(R&&R.scalePlane?R.scalePlane:1,R&&R.scaleDepth?R.scaleDepth:1,R&&R.scalePlane?R.scalePlane:1),scaling:new EngineCore.Vector3(R?R.scalePlane:1,R?R.scaleDepth:1,R?R.scalePlane:1),setEnabled:o,children:[jsxRuntime.jsx("mesh",{name:`formation-${u}-mesh-${e}`,ref:c,setEnabled:!i,useVertexColors:l.type===MaterialType.COLOR_CODEC,alwaysSelectAsActiveMesh:!0,children:l.type===MaterialType.TEXTURE?k?jsxRuntime.jsx(RepeatedTextureMaterial,{name:`formation-${u}-mat-${e}`,backFaceCulling:l.backFaceCulling===void 0?!0:l.backFaceCulling,needDepthPrePass:l.needDepthPrePass===void 0?!0:l.needDepthPrePass,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,alphaMode:EngineCore.Engine.ALPHA_COMBINE,alpha:l.alpha,texture:k,sideTexture:b,tilingFactor:l.tilingFactor,sideTilingFactor:(O=l==null?void 0:l.sideTilingFactor)!=null?O:l==null?void 0:l.tilingFactor,mode:l.textureMode===void 0?RepeatedTextureMode.PLANE:l.textureMode,boundingBox:S,lines:l.lines,text:l.text,scaleDepth:R?R.scaleDepth:1,scalePlane:R?R.scalePlane:1,disableDepthWrite:l.disableDepthWrite}):jsxRuntime.jsx(jsxRuntime.Fragment,{}):l.type===MaterialType.COLOR_CODEC?l.colorCodec?jsxRuntime.jsx(RemapColorByRedChannelMaterial,{name:`formation-${u}-mat-${e}`,backFaceCulling:l.backFaceCulling===void 0?!0:l.backFaceCulling,needDepthPrePass:l.needDepthPrePass===void 0?!0:l.needDepthPrePass,alpha:l.alpha,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,alphaMode:EngineCore.Engine.ALPHA_COMBINE,colorCodec:l.colorCodec,boundingBox:S,lines:l.lines,text:l.text,scaleDepth:R?R.scaleDepth:1,scalePlane:R?R.scalePlane:1,disableDepthWrite:l.disableDepthWrite}):jsxRuntime.jsx(jsxRuntime.Fragment,{}):l.type===MaterialType.COLOR_ID?jsxRuntime.jsx(OneColorMaterial,{name:`formation-${u}-vol-mat-${e}`,backFaceCulling:l.backFaceCulling===void 0?!0:l.backFaceCulling,needDepthPrePass:l.needDepthPrePass===void 0?!0:l.needDepthPrePass,surfaceCanvasOptions:l.surfaceCanvasOptions,color:g,alphaMode:EngineCore.Engine.ALPHA_COMBINE,alpha:l.alpha,boundingBox:S,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,lines:l.lines,text:l.text,scaleDepth:R?R.scaleDepth:1,scalePlane:R?R.scalePlane:1,disableDepthWrite:l.disableDepthWrite,disableNormalShadow:l.disableNormalShadow}):jsxRuntime.jsx(OneColorMaterial,{name:`formation-${u}-vol-mat-${e}`,backFaceCulling:l.backFaceCulling===void 0?!0:l.backFaceCulling,needDepthPrePass:l.needDepthPrePass===void 0?!0:l.needDepthPrePass,color:g,surfaceCanvasOptions:l.surfaceCanvasOptions,alphaMode:EngineCore.Engine.ALPHA_COMBINE,alpha:l.alpha,boundingBox:S,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,lines:l.lines,text:l.text,scaleDepth:R?R.scaleDepth:1,scalePlane:R?R.scalePlane:1,disableDepthWrite:l.disableDepthWrite,disableNormalShadow:l.disableNormalShadow})}),jsxRuntime.jsx("mesh",{name:`formation-${u}-vol-${e}`,ref:f,setEnabled:i,useVertexColors:l.type===MaterialType.COLOR_CODEC,alwaysSelectAsActiveMesh:!0,children:l.type===MaterialType.TEXTURE?k?jsxRuntime.jsx(RepeatedTextureMaterial,{name:`formation-${u}-vol-mat-${e}`,backFaceCulling:l.backFaceCulling===void 0?!0:l.backFaceCulling,needDepthPrePass:l.needDepthPrePass===void 0?!0:l.needDepthPrePass,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,alphaMode:EngineCore.Engine.ALPHA_COMBINE,alpha:l.alpha,sideTexture:b,texture:k,tilingFactor:l.tilingFactor,sideTilingFactor:(F=l==null?void 0:l.sideTilingFactor)!=null?F:l==null?void 0:l.tilingFactor,mode:l.textureMode===void 0?RepeatedTextureMode.PLANE:l.textureMode,boundingBox:S,lines:l.lines,text:l.text,scaleDepth:R?R.scaleDepth:1,scalePlane:R?R.scalePlane:1,disableDepthWrite:l.disableDepthWrite}):jsxRuntime.jsx(jsxRuntime.Fragment,{}):l.type===MaterialType.COLOR_CODEC?l.colorCodec?jsxRuntime.jsx(RemapColorByRedChannelMaterial,{name:`formation-${u}-vol-mat-${e}`,backFaceCulling:l.backFaceCulling===void 0?!0:l.backFaceCulling,needDepthPrePass:l.needDepthPrePass===void 0?!0:l.needDepthPrePass,alpha:l.alpha,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,alphaMode:EngineCore.Engine.ALPHA_COMBINE,colorCodec:l.colorCodec,boundingBox:S,lines:l.lines,text:l.text,scaleDepth:R?R.scaleDepth:1,scalePlane:R?R.scalePlane:1,disableDepthWrite:l.disableDepthWrite}):jsxRuntime.jsx(jsxRuntime.Fragment,{}):l.type===MaterialType.COLOR_ID?jsxRuntime.jsx(OneColorMaterial,{name:`formation-${u}-vol-mat-${e}`,backFaceCulling:l.backFaceCulling===void 0?!0:l.backFaceCulling,needDepthPrePass:l.needDepthPrePass===void 0?!0:l.needDepthPrePass,surfaceCanvasOptions:l.surfaceCanvasOptions,color:g,alphaMode:EngineCore.Engine.ALPHA_COMBINE,alpha:l.alpha,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,boundingBox:S,lines:l.lines,text:l.text,scaleDepth:R?R.scaleDepth:1,scalePlane:R?R.scalePlane:1,disableDepthWrite:l.disableDepthWrite,disableNormalShadow:l.disableNormalShadow}):jsxRuntime.jsx(OneColorMaterial,{name:`formation-${u}-vol-mat-${e}`,backFaceCulling:l.backFaceCulling===void 0?!0:l.backFaceCulling,needDepthPrePass:l.needDepthPrePass===void 0?!0:l.needDepthPrePass,surfaceCanvasOptions:l.surfaceCanvasOptions,color:g,alphaMode:EngineCore.Engine.ALPHA_COMBINE,alpha:l.alpha,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,boundingBox:S,lines:l.lines,text:l.text,scaleDepth:R?R.scaleDepth:1,scalePlane:R?R.scalePlane:1,disableDepthWrite:l.disableDepthWrite,disableNormalShadow:l.disableNormalShadow})}),u&&C&&jsxRuntime.jsx("transformNode",{name:`${u}-title-${e}`,position:C.add(a!=null&&a.offset?a.offset.multiplyByFloats(R!=null&&R.scalePlane?R==null?void 0:R.scalePlane:1,1,R!=null&&R.scalePlane?R==null?void 0:R.scalePlane:1):EngineCore.Vector3.Zero()),scaling:calcGUIScale(R).multiply(new EngineCore.Vector3(3,3,3)),setEnabled:n,children:jsxRuntime.jsx(GUIText$1,{text:u,fontSize:a!=null&&a.fontSize?a.fontSize:40,color:a!=null&&a.color?a.color:"white"})})]})})},FormationFace$1=FormationFace,FormationVolume=({url:e,showLayerLabel:t=!1,labelStyle:n,position:a=EngineCore.Vector3.Zero(),visible:r=!0,showBottomLayer:o=!1,actions:i,material:s={type:MaterialType.COLOR_ID,counterLine:void 0,alpha:1}})=>{var S,I;const l=React.useRef(null),c=React.useRef(null),[f,u]=React.useState(""),[d,h]=React.useState(null),[m,R]=React.useState(EngineCore.Color3.White()),v=React.useContext(WorkspaceMetaContext),g=React.useContext(ColorProviderContext),[x,y]=React.useState(EngineCore.Vector3.Zero()),[E,k]=React.useState(),b=useCachedBinary({url:e,cacheType:CacheType.URL_PREFIX_MATCH}),C=useCachedTexture({url:s==null?void 0:s.texture,cacheType:CacheType.URL_PREFIX_MATCH}),_=useCachedTexture({url:s==null?void 0:s.sideTexture,cacheType:CacheType.URL_PREFIX_MATCH}),[A,N]=React.useState(void 0);return React.useEffect(()=>{console.log("[Geo3DViewer] FormationVolume Loading: ",e)},[e]),React.useEffect(()=>{if(b){const O=l.current,F=c.current;EngineCore.Tags.EnableFor(O),EngineCore.Tags.AddTagsTo(O,"loading"),EngineCore.Tags.EnableFor(c),EngineCore.Tags.AddTagsTo(c,"loading");let w=[],L=[],B=[],D=[];const W=Formation.decode(new Uint8Array(b)),{name:ae,points:ee,indices:H,colorId:oe,side:te,sideIndices:K,center:Z,value:ce,sideValue:Q}=W;Z&&y(new EngineCore.Vector3(Z.x,Z.y,Z.z)),w=ee,L=H,B=te,D=K,h(oe),u(ae);const G=new EngineCore.VertexData,ge=new EngineCore.VertexData,fe=new Float32Array(w.length+B.length),V=new Int32Array(L.length+D.length),J=new Float32Array(ce.length+Q.length);G.positions=w,G.indices=L,G.colors=ce;const Re=[];EngineCore.VertexData.ComputeNormals(ee,H,Re),G.normals=Re,fe.set(w),V.set(L),J.set(ce),fe.set(B,w.length),V.set(D,L.length),J.set(Q,ce.length),ge.positions=fe,ge.indices=V,ge.colors=J;const Ce=[];if(EngineCore.VertexData.ComputeNormals(fe,V,Ce),ge.normals=Ce,O){G.applyToMesh(O);const Y=O.getBoundingInfo();k(Y.boundingBox.center.add(new EngineCore.Vector3(Y.boundingBox.extendSize.x,0,0))),o||O.getScene().onAfterRenderObservable.addOnce(()=>{if(!O.isDisposed()){const ne=O.getBoundingInfo();N(ne.boundingBox)}})}return F&&(ge.applyToMesh(F),o&&F.getScene().onAfterRenderObservable.addOnce(()=>{if(!F.isDisposed()){const ue=F.getBoundingInfo();N(ue.boundingBox)}})),EngineCore.Tags.RemoveTagsFrom(O,"loading"),EngineCore.Tags.RemoveTagsFrom(c,"loading"),()=>{O&&new EngineCore.VertexData().applyToMesh(O),F&&new EngineCore.VertexData().applyToMesh(F)}}},[b,o]),React.useEffect(()=>{var O;R(s.type===MaterialType.ONE_COLOR?(O=s==null?void 0:s.color)!=null?O:EngineCore.Color3.Random():d&&g.colorIDs[d]?new EngineCore.Color3(g.colorIDs[d].r,g.colorIDs[d].g,g.colorIDs[d].b):EngineCore.Color3.Random())},[g.colorIDs,d,s==null?void 0:s.color,s.type]),React.useEffect(()=>{l.current&&(l.current.metadata={pickable:i?{name:f,onLeftClick:i.onLeftClick,onRightClick:i.onRightClick,onMiddleClick:i.onMiddleClick,onHover:i.onHover,extra:i.extra}:null}),c.current&&(c.current.metadata={pickable:i?{name:f,onLeftClick:i.onLeftClick,onRightClick:i.onRightClick,onMiddleClick:i.onMiddleClick,onHover:i.onHover,extra:i.extra}:null})},[i,f]),jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsxs("transformNode",{name:`transform-formation-${f}-${e}`,position:x.add(a).multiplyByFloats(v&&v.scalePlane?v.scalePlane:1,v&&v.scaleDepth?v.scaleDepth:1,v&&v.scalePlane?v.scalePlane:1),scaling:new EngineCore.Vector3(v?v.scalePlane:1,v?v.scaleDepth:1,v?v.scalePlane:1),setEnabled:r,children:[jsxRuntime.jsx("mesh",{name:`formation-${f}-mesh-${e}`,ref:l,setEnabled:!o,useVertexColors:s.type===MaterialType.COLOR_CODEC,children:s.type===MaterialType.TEXTURE?C?jsxRuntime.jsx(RepeatedTextureMaterial,{name:`formation-${f}-mat-${e}`,backFaceCulling:s.backFaceCulling===void 0?!0:s.backFaceCulling,needDepthPrePass:s.needDepthPrePass===void 0?!0:s.needDepthPrePass,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,alphaMode:EngineCore.Engine.ALPHA_COMBINE,alpha:s.alpha,flatModeRotate:s.flatModeRotate,sideTexture:_,texture:C,tilingFactor:s.tilingFactor,sideTilingFactor:(S=s==null?void 0:s.sideTilingFactor)!=null?S:s==null?void 0:s.tilingFactor,mode:s.textureMode===void 0?RepeatedTextureMode.PLANE:s.textureMode,counterLine:s.counterLine,boundingBox:A,lines:s.lines,text:s.text,scaleDepth:v?v.scaleDepth:1,scalePlane:v?v.scalePlane:1,disableDepthWrite:s.disableDepthWrite}):jsxRuntime.jsx(jsxRuntime.Fragment,{}):s.type===MaterialType.COLOR_CODEC?s.colorCodec?jsxRuntime.jsx(RemapColorByRedChannelMaterial,{name:`formation-${f}-mat-${e}`,backFaceCulling:s.backFaceCulling===void 0?!0:s.backFaceCulling,needDepthPrePass:s.needDepthPrePass===void 0?!0:s.needDepthPrePass,alpha:s.alpha,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,alphaMode:EngineCore.Engine.ALPHA_COMBINE,colorCodec:s.colorCodec,counterLine:s.counterLine,boundingBox:A,lines:s.lines,text:s.text,scaleDepth:v?v.scaleDepth:1,scalePlane:v?v.scalePlane:1,disableDepthWrite:s.disableDepthWrite}):jsxRuntime.jsx(jsxRuntime.Fragment,{}):s.type===MaterialType.COLOR_ID?jsxRuntime.jsx(DiffuseTerrainMaterial$1,{name:`formation-${f}-vol-mat-${e}`,backFaceCulling:s.backFaceCulling===void 0?!0:s.backFaceCulling,needDepthPrePass:s.needDepthPrePass===void 0?!0:s.needDepthPrePass,color:m,alphaMode:EngineCore.Engine.ALPHA_COMBINE,alpha:s.alpha,lightPosition:s.lightPosition,intensity:s.intensity,surfaceCanvasOptions:s.surfaceCanvasOptions,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,boundingBox:A,lines:s.lines,text:s.text,zOffset:s.zOffset,zOffsetUnits:s.zOffsetUnits,contrast:s.contrast,sideIntensity:s.sideIntensity,cullFace:s.cullFace,scaleDepth:v?v.scaleDepth:1,scalePlane:v?v.scalePlane:1,disableDepthWrite:s.disableDepthWrite}):jsxRuntime.jsx(DiffuseTerrainMaterial$1,{name:`formation-${f}-vol-mat-${e}`,backFaceCulling:s.backFaceCulling===void 0?!0:s.backFaceCulling,needDepthPrePass:s.needDepthPrePass===void 0?!0:s.needDepthPrePass,color:m,alphaMode:EngineCore.Engine.ALPHA_COMBINE,surfaceCanvasOptions:s.surfaceCanvasOptions,alpha:s.alpha,lightPosition:s.lightPosition,intensity:s.intensity,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,boundingBox:A,lines:s.lines,text:s.text,zOffset:s.zOffset,zOffsetUnits:s.zOffsetUnits,contrast:s.contrast,sideIntensity:s.sideIntensity,cullFace:s.cullFace,scaleDepth:v?v.scaleDepth:1,scalePlane:v?v.scalePlane:1,disableDepthWrite:s.disableDepthWrite})}),jsxRuntime.jsx("mesh",{name:`formation-${f}-vol-${e}`,ref:c,setEnabled:o,useVertexColors:s.type===MaterialType.COLOR_CODEC,children:s.type===MaterialType.TEXTURE?C?jsxRuntime.jsx(RepeatedTextureMaterial,{name:`formation-${f}-vol-mat-${e}`,backFaceCulling:s.backFaceCulling===void 0?!0:s.backFaceCulling,needDepthPrePass:s.needDepthPrePass===void 0?!0:s.needDepthPrePass,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,alphaMode:EngineCore.Engine.ALPHA_COMBINE,alpha:s.alpha,sideTexture:_,texture:C,tilingFactor:s.tilingFactor,sideTilingFactor:(I=s==null?void 0:s.sideTilingFactor)!=null?I:s==null?void 0:s.tilingFactor,mode:s.textureMode===void 0?RepeatedTextureMode.PLANE:s.textureMode,flatModeRotate:s.flatModeRotate,counterLine:s.counterLine,boundingBox:A,lines:s.lines,text:s.text,scaleDepth:v?v.scaleDepth:1,scalePlane:v?v.scalePlane:1,disableDepthWrite:s.disableDepthWrite}):jsxRuntime.jsx(jsxRuntime.Fragment,{}):s.type===MaterialType.COLOR_CODEC?s.colorCodec?jsxRuntime.jsx(RemapColorByRedChannelMaterial,{name:`formation-${f}-vol-mat-${e}`,backFaceCulling:s.backFaceCulling===void 0?!0:s.backFaceCulling,needDepthPrePass:s.needDepthPrePass===void 0?!0:s.needDepthPrePass,alpha:s.alpha,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,alphaMode:EngineCore.Engine.ALPHA_COMBINE,colorCodec:s.colorCodec,counterLine:s.counterLine,boundingBox:A,lines:s.lines,text:s.text,scaleDepth:v?v.scaleDepth:1,scalePlane:v?v.scalePlane:1,disableDepthWrite:s.disableDepthWrite}):jsxRuntime.jsx(jsxRuntime.Fragment,{}):s.type===MaterialType.COLOR_ID?jsxRuntime.jsx(DiffuseTerrainMaterial$1,{name:`formation-${f}-vol-mat-${e}`,backFaceCulling:s.backFaceCulling===void 0?!0:s.backFaceCulling,needDepthPrePass:s.needDepthPrePass===void 0?!0:s.needDepthPrePass,color:m,surfaceCanvasOptions:s.surfaceCanvasOptions,alphaMode:EngineCore.Engine.ALPHA_COMBINE,alpha:s.alpha,lightPosition:s.lightPosition,intensity:s.intensity,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,boundingBox:A,lines:s.lines,text:s.text,zOffset:s.zOffset,zOffsetUnits:s.zOffsetUnits,contrast:s.contrast,sideIntensity:s.sideIntensity,cullFace:s.cullFace,scaleDepth:v?v.scaleDepth:1,scalePlane:v?v.scalePlane:1,disableDepthWrite:s.disableDepthWrite}):jsxRuntime.jsx(DiffuseTerrainMaterial$1,{name:`formation-${f}-vol-mat-${e}`,backFaceCulling:s.backFaceCulling===void 0?!0:s.backFaceCulling,needDepthPrePass:s.needDepthPrePass===void 0?!0:s.needDepthPrePass,color:m,surfaceCanvasOptions:s.surfaceCanvasOptions,alphaMode:EngineCore.Engine.ALPHA_COMBINE,alpha:s.alpha,lightPosition:s.lightPosition,intensity:s.intensity,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,boundingBox:A,lines:s.lines,text:s.text,zOffset:s.zOffset,zOffsetUnits:s.zOffsetUnits,contrast:s.contrast,sideIntensity:s.sideIntensity,cullFace:s.cullFace,scaleDepth:v?v.scaleDepth:1,scalePlane:v?v.scalePlane:1,disableDepthWrite:s.disableDepthWrite})}),f&&E&&jsxRuntime.jsx("transformNode",{name:`${f}-title-${e}`,position:E.add(n!=null&&n.offset?n.offset.multiplyByFloats(v!=null&&v.scalePlane?v==null?void 0:v.scalePlane:1,1,v!=null&&v.scalePlane?v==null?void 0:v.scalePlane:1):EngineCore.Vector3.Zero()),scaling:calcGUIScale(v).multiply(new EngineCore.Vector3(3,3,3)),setEnabled:t,children:jsxRuntime.jsx(GUIText$1,{text:f,fontSize:n!=null&&n.fontSize?n.fontSize:40,color:n!=null&&n.color?n.color:"white"})})]})})},FormationVolume$1=FormationVolume;var FormationGroup_FormationMode=(e=>(e[e.FACE=0]="FACE",e[e.VOLUME=1]="VOLUME",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED",e))(FormationGroup_FormationMode||{});function formationGroup_FormationModeFromJSON(e){switch(e){case 0:case"FACE":return 0;case 1:case"VOLUME":return 1;case-1:case"UNRECOGNIZED":default:return-1}}function formationGroup_FormationModeToJSON(e){switch(e){case 0:return"FACE";case 1:return"VOLUME";case-1:default:return"UNRECOGNIZED"}}function createBaseFormationGroup(){return{name:"",formations:[],mode:0,effectMeshs:[]}}const FormationGroup={encode(e,t=minimal.Writer.create()){e.name!==""&&t.uint32(10).string(e.name);for(const n of e.formations)FormationGroup_FormationInfo.encode(n,t.uint32(34).fork()).ldelim();e.mode!==0&&t.uint32(40).int32(e.mode);for(const n of e.effectMeshs)Mesh.encode(n,t.uint32(50).fork()).ldelim();return t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseFormationGroup();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.name=n.string();continue;case 4:if(o!==34)break;r.formations.push(FormationGroup_FormationInfo.decode(n,n.uint32()));continue;case 5:if(o!==40)break;r.mode=n.int32();continue;case 6:if(o!==50)break;r.effectMeshs.push(Mesh.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{name:isSet$a(e.name)?globalThis.String(e.name):"",formations:globalThis.Array.isArray(e==null?void 0:e.formations)?e.formations.map(t=>FormationGroup_FormationInfo.fromJSON(t)):[],mode:isSet$a(e.mode)?formationGroup_FormationModeFromJSON(e.mode):0,effectMeshs:globalThis.Array.isArray(e==null?void 0:e.effectMeshs)?e.effectMeshs.map(t=>Mesh.fromJSON(t)):[]}},toJSON(e){var n,a;const t={};return e.name!==""&&(t.name=e.name),(n=e.formations)!=null&&n.length&&(t.formations=e.formations.map(r=>FormationGroup_FormationInfo.toJSON(r))),e.mode!==0&&(t.mode=formationGroup_FormationModeToJSON(e.mode)),(a=e.effectMeshs)!=null&&a.length&&(t.effectMeshs=e.effectMeshs.map(r=>Mesh.toJSON(r))),t},create(e){return FormationGroup.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o;const t=createBaseFormationGroup();return t.name=(n=e.name)!=null?n:"",t.formations=((a=e.formations)==null?void 0:a.map(i=>FormationGroup_FormationInfo.fromPartial(i)))||[],t.mode=(r=e.mode)!=null?r:0,t.effectMeshs=((o=e.effectMeshs)==null?void 0:o.map(i=>Mesh.fromPartial(i)))||[],t}};function createBaseFormationGroup_FormationInfo(){return{name:"",url:""}}const FormationGroup_FormationInfo={encode(e,t=minimal.Writer.create()){return e.name!==""&&t.uint32(10).string(e.name),e.url!==""&&t.uint32(18).string(e.url),t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseFormationGroup_FormationInfo();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.name=n.string();continue;case 2:if(o!==18)break;r.url=n.string();continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{name:isSet$a(e.name)?globalThis.String(e.name):"",url:isSet$a(e.url)?globalThis.String(e.url):""}},toJSON(e){const t={};return e.name!==""&&(t.name=e.name),e.url!==""&&(t.url=e.url),t},create(e){return FormationGroup_FormationInfo.fromPartial(e!=null?e:{})},fromPartial(e){var n,a;const t=createBaseFormationGroup_FormationInfo();return t.name=(n=e.name)!=null?n:"",t.url=(a=e.url)!=null?a:"",t}};function isSet$a(e){return e!=null}const StructureLayer=({url:e,alpha:t=1,position:n=EngineCore.Vector3.Zero(),visible:a=!0,colorCodec:r,actions:o,counterLine:i=void 0,lines:s,text:l,disableDepthWrite:c})=>{const f=React.useRef(null),[u,d]=React.useState(""),h=React.useContext(WorkspaceMetaContext),m=React.useContext(ColorProviderContext),[R,v]=React.useState(null),[g,x]=React.useState(EngineCore.Color3.White()),y=useCachedBinary({url:e,cacheType:CacheType.URL_PREFIX_MATCH}),[E,k]=React.useState(EngineCore.Vector3.Zero()),[b,C]=React.useState();return React.useEffect(()=>{console.log("[Geo3DViewer] StructureLayer Loading: ",e)},[e]),React.useEffect(()=>{if(y){const _=f.current;EngineCore.Tags.EnableFor(_),EngineCore.Tags.AddTagsTo(_,"loading");const A=Formation.decode(new Uint8Array(y)),{name:N,points:S,indices:I,value:O,colorId:F,center:w}=A;w&&k(new EngineCore.Vector3(w.x,w.y,w.z));const L=new EngineCore.VertexData;L.positions=S,L.indices=I,L.colors=O;const B=[];return EngineCore.VertexData.ComputeNormals(S,I,B),L.normals=B,v(F),d(N),_&&(L.applyToMesh(_),_.getScene().onAfterRenderObservable.addOnce(()=>{if(!_.isDisposed()){const W=_.getBoundingInfo();C(W.boundingBox)}})),EngineCore.Tags.RemoveTagsFrom(_,"loading"),()=>{v(null),d(""),_&&new EngineCore.VertexData().applyToMesh(_)}}},[y]),React.useEffect(()=>{const _=R&&m.colorIDs[R]?m.colorIDs[R]:EngineCore.Color3.White();x(EngineCore.Color3.FromArray([_.r,_.g,_.b]))},[R,m.colorIDs]),React.useEffect(()=>{f.current&&(f.current.metadata={pickable:o?{name:u,onLeftClick:o.onLeftClick,onRightClick:o.onRightClick,onMiddleClick:o.onMiddleClick,onHover:o.onHover,extra:o.extra}:null})},[o,u]),jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsxs("transformNode",{name:`transform-structurelayer-${u}`,position:E.add(n).multiplyByFloats(h&&h.scalePlane?h.scalePlane:1,h&&h.scaleDepth?h.scaleDepth:1,h&&h.scalePlane?h.scalePlane:1),scaling:new EngineCore.Vector3(h?h.scalePlane:1,h?h.scaleDepth:1,h?h.scalePlane:1),setEnabled:a,children:[jsxRuntime.jsx("transformNode",{name:`structurelayer-${u}-load`}),jsxRuntime.jsx("mesh",{name:`structurelayer-${u}-mesh`,ref:f,useVertexColors:r!=null,children:r?jsxRuntime.jsx(RemapColorByRedChannelMaterial,{name:`structurelayer-${u}-mat`,backFaceCulling:!1,alpha:t,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,alphaMode:EngineCore.Engine.ALPHA_COMBINE,colorCodec:r,needDepthPrePass:!0,counterLine:i,boundingBox:b,lines:s,scaleDepth:h?h.scaleDepth:1,scalePlane:h?h.scalePlane:1,text:l,disableDepthWrite:c}):jsxRuntime.jsx("standardMaterial",{name:`structurelayer-${u}-mat`,backFaceCulling:!1,specularColor:new EngineCore.Color3(0,0,0),ambientColor:new EngineCore.Color3(1,1,1),diffuseColor:g,needDepthPrePass:!0,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,alphaMode:EngineCore.Engine.ALPHA_COMBINE,alpha:t,disableDepthWrite:c})})]})})},StructureLayer$1=StructureLayer,FormationEdgeEffect=e=>{const{id:t,visible:n=!0,position:a=EngineCore.Vector3.Zero(),diffuseTextureUrl:r,diffuseTextureSufaceUrl:o,bumpTextureUrl:i,mesh:s}=e,l=React.useRef(null),c=React.useContext(WorkspaceMetaContext),[f,u]=React.useState(),[d,h]=React.useState(),[m,R]=React.useState();return React.useEffect(()=>{const v=l.current;if(v&&s){const g=new EngineCore.VertexData;g.positions=s.vertices,g.indices=s.indices,g.uvs=s.uv;const x=[];EngineCore.VertexData.ComputeNormals(s.vertices,s.indices,x),g.normals=x,g.applyToMesh(v)}},[s,s==null?void 0:s.indices,s==null?void 0:s.uv,s==null?void 0:s.vertices]),React.useEffect(()=>{const v=new EngineCore.Texture(r);if(v.uScale=500,v.vScale=.5,u(v),o){const x=new EngineCore.Texture(o);x.uScale=500,x.vScale=.5,h(x)}const g=new EngineCore.Texture(i);g.uScale=500,g.vScale=.5,R(g)},[i,o,r]),jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx("transformNode",{name:`transform-formation-edge-${t}`,position:a.multiplyByFloats(c&&c.scalePlane?c.scalePlane:1,c&&c.scaleDepth?c.scaleDepth:1,c&&c.scalePlane?c.scalePlane:1),scaling:new EngineCore.Vector3(c?c.scalePlane:1,c?c.scaleDepth:1,c?c.scalePlane:1),setEnabled:n,children:jsxRuntime.jsx("mesh",{name:"mesh",ref:l,children:jsxRuntime.jsx("standardMaterial",{name:`edge-${t}-material`,zOffset:-1,zOffsetUnits:-1,diffuseTexture:o?d:f,bumpTexture:o?void 0:m})})})})},FormationEdgeEffect$1=FormationEdgeEffect,ComplexFormationManager=({url:e,visible:t=!0,filter:n,explodedView:a=0,showLayerLabel:r,labelStyle:o,offset:i=new EngineCore.Vector3(0,0,0),showTopLayerAsStructureLayer:s=!1,useColorCodecOnTopLayer:l=!1,colorCodec:c,actions:f,materials:u,topLayerCounterLine:d=void 0,topLayerHeightOffset:h=1,diffuseTextureUrl:m,diffuseTextureSufaceUrl:R,bumpTextureUrl:v,visibleEdgeEffect:g=!1})=>{var I,O;const[x,y]=React.useState(),E=React.useContext(WorkspaceMetaContext),[k,b]=React.useState(!0),[C,_]=React.useState(""),A=useCachedBinary({url:e,cacheType:CacheType.URL_PREFIX_MATCH}),[N,S]=React.useState([]);return React.useEffect(()=>{console.log("[Geo3DViewer] ComplexFormationManager Loading: ",e)},[e]),React.useEffect(()=>{if(A){const F=FormationGroup.decode(new Uint8Array(A)),w=F.formations;if(F.mode==FormationGroup_FormationMode.FACE){b(!0),_(F.name);const L=[];w.forEach((B,D)=>{const W={name:B.name,topUrl:B.url,bottomUrl:w[D+1]?w[D+1].url:void 0};L.push(W)}),y(L)}else{b(!1),_(F.name);const L=[];w.forEach(B=>{const D={name:B.name,topUrl:B.url};L.push(D)}),y(L)}return console.log(F),S(F.effectMeshs),()=>{y([])}}},[A]),jsxRuntime.jsxs("abstractMesh",{name:`complexformationmanager-${C}`,children:[s&&x&&x.length>1?jsxRuntime.jsx(StructureLayer$1,{url:x[0].topUrl,alpha:(I=u==null?void 0:u[x[0].name])==null?void 0:I.alpha,position:new EngineCore.Vector3(0,h>=0?h*(E&&(O=E.scaleDepth)!=null?O:1):0,0).add(i),visible:t&&(n?n.includes(x[0].name):!0),colorCodec:c,counterLine:d},`${C}-${x[0].name}-SL`):null,x?x.map((F,w)=>k?s&&w===0?jsxRuntime.jsx(jsxRuntime.Fragment,{}):jsxRuntime.jsx("transformNode",{name:`${C}-${F.name}-EV`,position:i.add(new EngineCore.Vector3(0,w*(-1*a*(E&&E.scaleDepth?E.scaleDepth:0)),0)),children:jsxRuntime.jsx(FormationFace$1,{showLayerLabel:r,labelStyle:o,urlTopLayer:F.topUrl,urlBottomLayer:F.bottomUrl,visible:t&&(n?n.includes(F.name):!0),showBottomLayer:x[w+1]?n?n.includes(x[w+1].name):!0:!1,actions:f,material:w===0&&l?{...u==null?void 0:u[F.name],colorCodec:c,type:MaterialType.COLOR_CODEC}:u==null?void 0:u[F.name]},`${C}-${F.name}`)},`${C}-${F.name}`):s&&w===0?jsxRuntime.jsx(jsxRuntime.Fragment,{}):jsxRuntime.jsx("transformNode",{name:`${C}-${F.name}-EV`,position:i.add(new EngineCore.Vector3(0,w*(-1*a*(E&&E.scaleDepth?E.scaleDepth:0)),0)),children:jsxRuntime.jsx(FormationVolume$1,{url:F.topUrl,showLayerLabel:r,labelStyle:o,visible:t&&(n?n.includes(F.name):!0),showBottomLayer:x[w+1]?n?n.includes(x[w+1].name):!0:!1,actions:f,material:u==null?void 0:u[F.name]},`${C}-${F.name}`)},`${C}-${F.name}`)):null,N&&m&&v&&a===0&&N.map((F,w)=>jsxRuntime.jsx(FormationEdgeEffect$1,{visible:g,id:w,diffuseTextureUrl:m,diffuseTextureSufaceUrl:w===0?R:void 0,bumpTextureUrl:v,mesh:F},w))]})},ComplexFormationManager$1=ComplexFormationManager,Coordinate=({visible:e=!0,color:t=EngineCore.Color3.White(),fontSize:n=80,step:a=200,keyFrameDistance:r=[],keyFrameStep:o=[],keyFrameFontSize:i=[],textureSizeX:s=512,textureSizeY:l=512,init:c=!0})=>{const f=reactBabylonjs.useScene(),u=React.useRef(null),d=React.useContext(WorkspaceMetaContext),[h,m]=React.useState([]),[R,v]=React.useState([]),[g,x]=React.useState([]),[y,E]=React.useState(0),k=React.useCallback(b=>{if(f&&b){const C=new EngineMaterial.GridMaterial("axis-material",f);C.majorUnitFrequency=o.length>0?o[0]:50,C.minorUnitVisibility=0,C.gridRatio=2,C.sideOrientation=EngineCore.Material.ClockWiseSideOrientation,C.backFaceCulling=!0,C.mainColor=t,C.lineColor=t,C.opacity=.98,b.material=C}},[t,o,f]);return React.useEffect(()=>()=>{var b;(b=u.current)==null||b.dispose()},[]),React.useEffect(()=>{const b=()=>{const C=(f==null?void 0:f.activeCamera).radius;for(let _=0;_<r.length;_++)if(C<=r[_]){E(_);break}};return f&&f.activeCamera&&(f==null||f.activeCamera.onViewMatrixChangedObservable.add(b)),()=>{f&&f.activeCamera&&(f==null||f.activeCamera.onViewMatrixChangedObservable.removeCallback(b))}},[r,i,o,f,e]),React.useEffect(()=>{if(d&&d.min&&d.max&&c){const b=d.origin||EngineCore.Vector3.Zero(),C=[],_=[],A=[],N=[...o];N.length===0&&N.push(a);for(let S=0;S<N.length;S++){let I=N[S]/1;I<1&&(I=200);const O=[];for(let L=0;L<=d.max.x-d.min.x;L+=I)O.push({text:`${L+d.min.x+b.x}`,position:new EngineCore.Vector3(L,0,0)}),O.push({text:`${L+d.min.x+b.x}`,position:new EngineCore.Vector3(L,d.max.y-d.min.y,d.max.z-d.min.z)}),O.push({text:`${L+d.min.x+b.x}`,position:new EngineCore.Vector3(L,d.max.y-d.min.y,0)}),O.push({text:`${L+d.min.x+b.x}`,position:new EngineCore.Vector3(L,0,d.max.z-d.min.z)});C.push(O);const F=[];for(let L=0;L<=d.max.y-d.min.y;L+=I)F.push({text:`${L+d.min.y+b.y}`,position:new EngineCore.Vector3(0,L,0)}),F.push({text:`${L+d.min.y+b.y}`,position:new EngineCore.Vector3(d.max.x-d.min.x,L,d.max.z-d.min.z)}),F.push({text:`${L+d.min.y+b.y}`,position:new EngineCore.Vector3(d.max.x-d.min.x,L,0)}),F.push({text:`${L+d.min.y+b.y}`,position:new EngineCore.Vector3(0,L,d.max.z-d.min.z)});_.push(F);const w=[];for(let L=0;L<=d.max.z-d.min.z;L+=I)w.push({text:`${L+d.min.z+b.z}`,position:new EngineCore.Vector3(0,0,L)}),w.push({text:`${L+d.min.z+b.z}`,position:new EngineCore.Vector3(d.max.x-d.min.x,d.max.y-d.min.y,L)}),w.push({text:`${L+d.min.z+b.z}`,position:new EngineCore.Vector3(0,d.max.y-d.min.y,L)}),w.push({text:`${L+d.min.z+b.z}`,position:new EngineCore.Vector3(d.max.x-d.min.x,0,L)});A.push(w)}m(C),v(_),x(A)}},[c,o,d,a]),d&&d.min&&d.max&&d.max.x-d.min.x>0&&d.max.y-d.min.y>0&&d.max.z-d.min.z>0?jsxRuntime.jsxs("transformNode",{name:"coord",setEnabled:e,position:(d&&d.min&&d.max?EngineCore.Vector3.Center(d.min,d.max):EngineCore.Vector3.Zero()).multiply(calcTransformNodeScale(d)),scaling:new EngineCore.Vector3(calcTransformNodeScale(d).x,calcTransformNodeScale(d).y,calcTransformNodeScale(d).z),children:[jsxRuntime.jsx("box",{name:"axis",width:d&&d.min&&d.max?d.max.x-d.min.x:0,height:d&&d.min&&d.max?d.max.y-d.min.y:0,depth:d&&d.min&&d.max?d.max.z-d.min.z:0,ref:k,isPickable:!1,isBlocker:!1},`axis-${d.max.x-d.min.x}-${d.max.y-d.min.y}-${d.max.z-d.min.z}`),jsxRuntime.jsxs("transformNode",{name:"axis-offset",position:d&&d.min&&d.max?new EngineCore.Vector3(-(d.max.x-d.min.x)/2,-(d.max.y-d.min.y)/2,-(d.max.z-d.min.z)/2):EngineCore.Vector3.Zero(),children:[h.map((b,C)=>b.map((_,A)=>{var S;const N=_;return jsxRuntime.jsx("transformNode",{name:`axis-x-${C}-${A}`,position:N==null?void 0:N.position,setEnabled:C===y,scaling:new EngineCore.Vector3(1/calcTransformNodeScale(d).x,1/calcTransformNodeScale(d).y,1/calcTransformNodeScale(d).z),children:jsxRuntime.jsx(GUIText$1,{text:`${N?N.text:""}`,fontSize:(S=i[C])!=null?S:n,color:t.toHexString()})},`axis-x-${C}-${A}`)})),R.map((b,C)=>b.map((_,A)=>{var S;const N=_;return jsxRuntime.jsx("transformNode",{name:`axis-x-${C}-${A}`,position:N==null?void 0:N.position,setEnabled:C===y,scaling:new EngineCore.Vector3(1/calcTransformNodeScale(d).x,1/calcTransformNodeScale(d).y,1/calcTransformNodeScale(d).z),children:jsxRuntime.jsx(GUIText$1,{text:`${N?N.text:""}`,fontSize:(S=i[C])!=null?S:n,color:t.toHexString()})},`axis-x-${C}-${A}`)})),g.map((b,C)=>b.map((_,A)=>{var S;const N=_;return jsxRuntime.jsx("transformNode",{name:`axis-x-${C}-${A}`,position:N==null?void 0:N.position,setEnabled:C===y,scaling:new EngineCore.Vector3(1/calcTransformNodeScale(d).x,1/calcTransformNodeScale(d).y,1/calcTransformNodeScale(d).z),children:jsxRuntime.jsx(GUIText$1,{text:`${N?N.text:""}`,fontSize:(S=i[C])!=null?S:n,color:t.toHexString()})},`axis-x-${C}-${A}`)}))]})]},`coord-${d.min.x}-${d.min.y}-${d.min.z}-${d.max.x}-${d.max.y}-${d.max.z}-${Math.abs(d.max.x-d.min.x)}-${Math.abs(d.max.y-d.min.y)}-${Math.abs(d.max.z-d.min.z)}`):jsxRuntime.jsx(jsxRuntime.Fragment,{})},Coordinate$1=Coordinate;function contourLine_ContourLineTypeFromJSON(e){switch(e){case 0:case"NORMAL":return 0;case 1:case"CICLE":return 1;case-1:case"UNRECOGNIZED":default:return-1}}function contourLine_ContourLineTypeToJSON(e){switch(e){case 0:return"NORMAL";case 1:return"CICLE";case-1:default:return"UNRECOGNIZED"}}function createBaseContourLine(){return{name:"",lines:[]}}const ContourLine$2={encode(e,t=minimal.Writer.create()){e.name!==""&&t.uint32(10).string(e.name);for(const n of e.lines)ContourLine_Line.encode(n,t.uint32(18).fork()).ldelim();return t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseContourLine();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.name=n.string();continue;case 2:if(o!==18)break;r.lines.push(ContourLine_Line.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{name:isSet$9(e.name)?globalThis.String(e.name):"",lines:globalThis.Array.isArray(e==null?void 0:e.lines)?e.lines.map(t=>ContourLine_Line.fromJSON(t)):[]}},toJSON(e){var n;const t={};return e.name!==""&&(t.name=e.name),(n=e.lines)!=null&&n.length&&(t.lines=e.lines.map(a=>ContourLine_Line.toJSON(a))),t},create(e){return ContourLine$2.fromPartial(e!=null?e:{})},fromPartial(e){var n,a;const t=createBaseContourLine();return t.name=(n=e.name)!=null?n:"",t.lines=((a=e.lines)==null?void 0:a.map(r=>ContourLine_Line.fromPartial(r)))||[],t}};function createBaseContourLine_LineSegment(){return{positions:[]}}const ContourLine_LineSegment={encode(e,t=minimal.Writer.create()){for(const n of e.positions)Position.encode(n,t.uint32(10).fork()).ldelim();return t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseContourLine_LineSegment();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.positions.push(Position.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{positions:globalThis.Array.isArray(e==null?void 0:e.positions)?e.positions.map(t=>Position.fromJSON(t)):[]}},toJSON(e){var n;const t={};return(n=e.positions)!=null&&n.length&&(t.positions=e.positions.map(a=>Position.toJSON(a))),t},create(e){return ContourLine_LineSegment.fromPartial(e!=null?e:{})},fromPartial(e){var n;const t=createBaseContourLine_LineSegment();return t.positions=((n=e.positions)==null?void 0:n.map(a=>Position.fromPartial(a)))||[],t}};function createBaseContourLine_Line(){return{segments:[],type:0,position:void 0}}const ContourLine_Line={encode(e,t=minimal.Writer.create()){for(const n of e.segments)ContourLine_LineSegment.encode(n,t.uint32(10).fork()).ldelim();return e.type!==0&&t.uint32(16).int32(e.type),e.position!==void 0&&Position.encode(e.position,t.uint32(26).fork()).ldelim(),t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseContourLine_Line();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.segments.push(ContourLine_LineSegment.decode(n,n.uint32()));continue;case 2:if(o!==16)break;r.type=n.int32();continue;case 3:if(o!==26)break;r.position=Position.decode(n,n.uint32());continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{segments:globalThis.Array.isArray(e==null?void 0:e.segments)?e.segments.map(t=>ContourLine_LineSegment.fromJSON(t)):[],type:isSet$9(e.type)?contourLine_ContourLineTypeFromJSON(e.type):0,position:isSet$9(e.position)?Position.fromJSON(e.position):void 0}},toJSON(e){var n;const t={};return(n=e.segments)!=null&&n.length&&(t.segments=e.segments.map(a=>ContourLine_LineSegment.toJSON(a))),e.type!==0&&(t.type=contourLine_ContourLineTypeToJSON(e.type)),e.position!==void 0&&(t.position=Position.toJSON(e.position)),t},create(e){return ContourLine_Line.fromPartial(e!=null?e:{})},fromPartial(e){var n,a;const t=createBaseContourLine_Line();return t.segments=((n=e.segments)==null?void 0:n.map(r=>ContourLine_LineSegment.fromPartial(r)))||[],t.type=(a=e.type)!=null?a:0,t.position=e.position!==void 0&&e.position!==null?Position.fromPartial(e.position):void 0,t}};function isSet$9(e){return e!=null}const Line=({points:e=[],showPoint:t=!0,color:n=EngineCore.Color3.White(),pointSize:a=2,alwaysOnTop:r=!1,offset:o=EngineCore.Vector3.Zero(),alpha:i,lineWidth:s})=>{const l=reactBabylonjs.useScene(),c=React.useRef(null),f=React.useContext(WorkspaceMetaContext);return React.useEffect(()=>{if(l){const u=[],d=calcTransformNodeScale(f);if(e.forEach(h=>{u.push(h.add(o).multiply(d))}),s){const h={path:u,radius:s,updatable:!0};if(c.current)h.instance=c.current,EngineCore.MeshBuilder.CreateTube("line",h);else{c.current=EngineCore.MeshBuilder.CreateTube("line",h,l);const m=new EngineCore.StandardMaterial("line-mat");return m.diffuseColor=n,m.specularColor=EngineCore.Color3.Black(),m.emissiveColor=n,i!==void 0&&(m.alpha=i,m.transparencyMode=2),m.depthFunction=r?EngineCore.Constants.ALWAYS:0,c.current.material=m,()=>{c.current&&(l.removeMesh(c.current),c.current=null)}}}else{const h={points:u,updateable:!0};if(c.current)h.instance=c.current,EngineCore.MeshBuilder.CreateLines("line",h);else{c.current=EngineCore.MeshBuilder.CreateLines("line",h,l);const m=new EngineCore.StandardMaterial("line-mat");return m.diffuseColor=n,m.specularColor=EngineCore.Color3.Black(),m.emissiveColor=n,i!==void 0&&(m.alpha=i,m.transparencyMode=2),m.depthFunction=r?EngineCore.Constants.ALWAYS:0,()=>{c.current&&(l.removeMesh(c.current),c.current=null)}}}}},[r,n,f,o,e,l,s,c,i]),jsxRuntime.jsx("transformNode",{name:"transform-line",children:t?jsxRuntime.jsx("transformNode",{name:"lines-point",children:e.map((u,d)=>jsxRuntime.jsx("sphere",{diameter:a,name:`lines-point-${d}`,position:u.add(o).multiply(calcTransformNodeScale(f)),scalingDeterminant:s&&(f==null?void 0:f.scalePlane)||1,children:jsxRuntime.jsx("standardMaterial",{name:`lines-point-${d}-mat`,diffuseColor:n,emissiveColor:n,specularColor:EngineCore.Color3.White(),depthFunction:r?EngineCore.Constants.ALWAYS:void 0})},`lines-point-${u.x}-${u.y}-${u.z}`))}):jsxRuntime.jsx(jsxRuntime.Fragment,{})})},Line$1=Line,ContourText=e=>{const{name:t,prev:n,next:a,textColor:r,fontSize:o}=e,i=reactBabylonjs.useScene(),s=React.useRef(null);return React.useEffect(()=>{const l=i==null?void 0:i.activeCamera,c=i==null?void 0:i.getEngine();if(i&&l&&c&&s.current){const f=s.current.getChildren()[0],u=EngineCore.Vector3.Normalize(a.subtract(n)),d=new EngineCore.Vector3(1,0,0),h=Math.acos(EngineCore.Vector3.Dot(u,d)),m=EngineCore.Vector3.Cross(u,d);f.rotation.z=m.y>0?h:Math.PI*2-h,f.rotation.x=Math.PI/2,f.renderingGroupId=3}},[a,n,i]),jsxRuntime.jsx("transformNode",{name:`${t}`,position:EngineCore.Vector3.Lerp(n,a,.5),ref:s,children:jsxRuntime.jsx(GUIText$1,{text:t,fontSize:o,color:r,billboardMode:EngineCore.Mesh.BILLBOARDMODE_NONE})})},ContourText$1=ContourText,ContourLine=e=>{const{url:t,color:n,alpha:a,visible:r=!0,fontSize:o=30,textColor:i="red",linewidth:s=10}=e,l=reactBabylonjs.useScene(),[c,f]=React.useState([]),[u,d]=React.useState([]),h=React.useContext(WorkspaceMetaContext);return React.useEffect(()=>{axios.get(t,{responseType:"arraybuffer"}).then(m=>{const R=ContourLine$2.decode(new Uint8Array(m.data));console.log(R);const v=[],g=[];for(let x=0;x<R.lines.length;x++){const y=R.lines[x];if(y.segments.length<2)continue;const E=[];for(let k=0;k<y.segments.length;k++){const b=[...convertPositionArrayToVector3(y.segments[k].positions)];v.push([...b]),E.push(b[0]),E.push(b[b.length-1])}y.type===1&&E.push(convertPositionToVector3(y.segments[0].positions[0])),g.push(E)}f(v),d(g),console.log(g),console.log(v)})},[l,t]),jsxRuntime.jsxs("transformNode",{name:"contourline",setEnabled:r,children:[c.map((m,R)=>m.length<2||!r?null:jsxRuntime.jsx(Line$1,{points:m,showPoint:!1,color:n,alpha:a,lineWidth:s,alwaysOnTop:!0},R)),u.map(m=>m.map((R,v)=>v%2===0||v===m.length-1?null:jsxRuntime.jsx(ContourText$1,{name:R.y.toFixed(0),prev:calcTransformNodeScale(h).multiply(R),next:calcTransformNodeScale(h).multiply(m[v+1]),fontSize:o,textColor:i},v)))]})},ContourLine$1=ContourLine;function densitySlice_DirectionFromJSON(e){switch(e){case 0:case"X":return 0;case 1:case"Y":return 1;case 2:case"Z":return 2;case 3:case"FREE":return 3;case-1:case"UNRECOGNIZED":default:return-1}}function densitySlice_DirectionToJSON(e){switch(e){case 0:return"X";case 1:return"Y";case 2:return"Z";case 3:return"FREE";case-1:default:return"UNRECOGNIZED"}}function createBaseDensitySlice(){return{layer:0,direction:0,colorId:0,points:[],indices:[],value:[],vMin:0,vMax:0,center:void 0}}const DensitySlice$2={encode(e,t=minimal.Writer.create()){e.layer!==0&&t.uint32(8).uint32(e.layer),e.direction!==0&&t.uint32(16).int32(e.direction),e.colorId!==0&&t.uint32(24).uint32(e.colorId),t.uint32(170).fork();for(const n of e.points)t.float(n);t.ldelim(),t.uint32(178).fork();for(const n of e.indices)t.uint32(n);t.ldelim(),t.uint32(186).fork();for(const n of e.value)t.float(n);return t.ldelim(),e.vMin!==0&&t.uint32(205).float(e.vMin),e.vMax!==0&&t.uint32(213).float(e.vMax),e.center!==void 0&&Vertex.encode(e.center,t.uint32(250).fork()).ldelim(),t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseDensitySlice();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==8)break;r.layer=n.uint32();continue;case 2:if(o!==16)break;r.direction=n.int32();continue;case 3:if(o!==24)break;r.colorId=n.uint32();continue;case 21:if(o===173){r.points.push(n.float());continue}if(o===170){const i=n.uint32()+n.pos;for(;n.pos<i;)r.points.push(n.float());continue}break;case 22:if(o===176){r.indices.push(n.uint32());continue}if(o===178){const i=n.uint32()+n.pos;for(;n.pos<i;)r.indices.push(n.uint32());continue}break;case 23:if(o===189){r.value.push(n.float());continue}if(o===186){const i=n.uint32()+n.pos;for(;n.pos<i;)r.value.push(n.float());continue}break;case 25:if(o!==205)break;r.vMin=n.float();continue;case 26:if(o!==213)break;r.vMax=n.float();continue;case 31:if(o!==250)break;r.center=Vertex.decode(n,n.uint32());continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{layer:isSet$8(e.layer)?globalThis.Number(e.layer):0,direction:isSet$8(e.direction)?densitySlice_DirectionFromJSON(e.direction):0,colorId:isSet$8(e.colorId)?globalThis.Number(e.colorId):0,points:globalThis.Array.isArray(e==null?void 0:e.points)?e.points.map(t=>globalThis.Number(t)):[],indices:globalThis.Array.isArray(e==null?void 0:e.indices)?e.indices.map(t=>globalThis.Number(t)):[],value:globalThis.Array.isArray(e==null?void 0:e.value)?e.value.map(t=>globalThis.Number(t)):[],vMin:isSet$8(e.vMin)?globalThis.Number(e.vMin):0,vMax:isSet$8(e.vMax)?globalThis.Number(e.vMax):0,center:isSet$8(e.center)?Vertex.fromJSON(e.center):void 0}},toJSON(e){var n,a,r;const t={};return e.layer!==0&&(t.layer=Math.round(e.layer)),e.direction!==0&&(t.direction=densitySlice_DirectionToJSON(e.direction)),e.colorId!==0&&(t.colorId=Math.round(e.colorId)),(n=e.points)!=null&&n.length&&(t.points=e.points),(a=e.indices)!=null&&a.length&&(t.indices=e.indices.map(o=>Math.round(o))),(r=e.value)!=null&&r.length&&(t.value=e.value),e.vMin!==0&&(t.vMin=e.vMin),e.vMax!==0&&(t.vMax=e.vMax),e.center!==void 0&&(t.center=Vertex.toJSON(e.center)),t},create(e){return DensitySlice$2.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o,i,s,l,c;const t=createBaseDensitySlice();return t.layer=(n=e.layer)!=null?n:0,t.direction=(a=e.direction)!=null?a:0,t.colorId=(r=e.colorId)!=null?r:0,t.points=((o=e.points)==null?void 0:o.map(f=>f))||[],t.indices=((i=e.indices)==null?void 0:i.map(f=>f))||[],t.value=((s=e.value)==null?void 0:s.map(f=>f))||[],t.vMin=(l=e.vMin)!=null?l:0,t.vMax=(c=e.vMax)!=null?c:0,t.center=e.center!==void 0&&e.center!==null?Vertex.fromPartial(e.center):void 0,t}};function isSet$8(e){return e!=null}const DensitySlice=({name:e,url:t,visible:n=!0,colorCodec:a,alpha:r=1,position:o=EngineCore.Vector3.Zero(),actions:i})=>{const s=React.useRef(null),[l,c]=React.useState(""),[f,u]=React.useState(""),d=React.useContext(WorkspaceMetaContext),h=useCachedBinary({url:t,cacheType:CacheType.URL_PREFIX_MATCH}),[m,R]=React.useState(EngineCore.Vector3.Zero());return React.useEffect(()=>{if(h){EngineCore.Tags.EnableFor(s.current),EngineCore.Tags.AddTagsTo(s.current,"loading");const v=DensitySlice$2.decode(new Uint8Array(h)),{layer:g,direction:x,points:y,indices:E,value:k,center:b}=v,C=new EngineCore.VertexData;C.positions=y,C.indices=E,C.colors=k;const _=[];EngineCore.VertexData.ComputeNormals(y,E,_),C.normals=_,b&&R(new EngineCore.Vector3(b.x,b.y,b.z));const A=s.current;return A&&(C.applyToMesh(A),c(g.toString()),u(x.toString())),EngineCore.Tags.RemoveTagsFrom(A,"loading"),()=>{c(""),u(""),A&&new EngineCore.VertexData().applyToMesh(A)}}},[h]),React.useEffect(()=>{s.current&&(s.current.metadata={pickable:i?{name:e,onLeftClick:i.onLeftClick,onRightClick:i.onRightClick,onMiddleClick:i.onMiddleClick,onHover:i.onHover,extra:i.extra}:null})},[i,e]),React.useEffect(()=>{console.log("[Geo3DViewer] DensitySlice Loading: ",t)},[t]),jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx("transformNode",{name:`densityslice-${e}-${f}-${l}-transform`,position:m.add(o).multiplyByFloats(d&&d.scalePlane?d.scalePlane:1,d&&d.scaleDepth?d.scaleDepth:1,d&&d.scalePlane?d.scalePlane:1),scaling:new EngineCore.Vector3(d?d.scalePlane:1,d?d.scaleDepth:1,d?d.scalePlane:1),children:jsxRuntime.jsx("mesh",{name:`densityslice-${e}-${f}-${l}-mesh`,ref:s,setEnabled:n,children:jsxRuntime.jsx(RemapColorByRedChannelMaterial,{name:`densityslice-${e}-${f}-${l}-mat`,backFaceCulling:!1,needDepthPrePass:!0,alpha:r,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,alphaMode:EngineCore.Engine.ALPHA_COMBINE,colorCodec:a})})})})},DensitySlice$1=DensitySlice,FPS=()=>{const e=reactBabylonjs.useScene(),t=React.useRef(void 0);return React.useEffect(()=>{const n=setInterval(()=>{if(e&&t.current){const a=e.getEngine().getFps();t.current.getControlByName("fps").text=a.toFixed(0)+"FPS"}},1e3);return()=>{clearInterval(n)}},[e]),React.useEffect(()=>{var n,a;if(e&&!t.current){const r=EngineGui.AdvancedDynamicTexture.CreateFullscreenUI("UI",!0,e);t.current=r;const o=new EngineGui.TextBlock("fps");o.text="0FPS",o.color="white",o.fontSize=15,o.width=100,o.height=50;const i=window.devicePixelRatio||1,s=(n=e.getEngine().getRenderingCanvas())==null?void 0:n.clientHeight,l=(a=e.getEngine().getRenderingCanvas())==null?void 0:a.clientWidth;o.left=l?-(l*i/2-50):0,o.top=s?-(s*i/2-25):0,r.addControl(o)}return()=>{e&&t.current}},[e]),null},FPS$1=FPS,FormationManager=({url:e,visible:t=!0,filter:n,explodedView:a=0,offset:r=new EngineCore.Vector3(0,0,0),showLayerLabel:o,labelStyle:i,actions:s,materials:l})=>{const[c,f]=React.useState(),u=React.useContext(WorkspaceMetaContext),[d,h]=React.useState(!0),[m,R]=React.useState(""),v=useCachedBinary({url:e,cacheType:CacheType.URL_PREFIX_MATCH});return React.useEffect(()=>{console.log("[Geo3DViewer] FormationManager Loading: ",e)},[e]),React.useEffect(()=>{if(v){const g=FormationGroup.decode(new Uint8Array(v)),x=g.formations;if(g.mode==FormationGroup_FormationMode.FACE){h(!0),R(g.name);const y=[];x.forEach((E,k)=>{const b={name:E.name,topUrl:E.url,bottomUrl:x[k+1]?x[k+1].url:void 0};y.push(b)}),f(y)}else{h(!1),R(g.name);const y=[];x.forEach(E=>{const k={name:E.name,topUrl:E.url};y.push(k)}),f(y)}return console.log(x),()=>{R(""),f([])}}},[v]),jsxRuntime.jsx("abstractMesh",{name:`formationmanager-${m}`,children:c?c.map((g,x)=>d?jsxRuntime.jsx("transformNode",{name:`${m}-${g.name}-EV`,position:r.add(new EngineCore.Vector3(0,x*(-1*a*(u&&u.scaleDepth?u.scaleDepth:0)),0)),children:jsxRuntime.jsx(FormationFace$1,{showLayerLabel:o,labelStyle:i,urlTopLayer:g.topUrl,urlBottomLayer:g.bottomUrl,visible:t&&(n?n.includes(g.name):!0),showBottomLayer:c[x+1]?n?n.includes(c[x+1].name):!0:!1,actions:s,material:l==null?void 0:l[g.name]},`${m}-${g.name}`)},`${m}-${g.name}`):jsxRuntime.jsx("transformNode",{name:`${m}-${g.name}-EV`,position:r.add(new EngineCore.Vector3(0,x*(-1*a*(u&&u.scaleDepth?u.scaleDepth:0)),0)),children:jsxRuntime.jsx(FormationVolume$1,{url:g.topUrl,showLayerLabel:o,labelStyle:i,visible:t&&(n?n.includes(g.name):!0),showBottomLayer:c[x+1]?n?n.includes(c[x+1].name):!0:!1,actions:s,material:l==null?void 0:l[g.name]},`${m}-${g.name}`)},`${m}-${g.name}`)):null})},FormationManager$1=FormationManager;function createBaseFormationSlices(){return{name:"",slices:[],center:void 0}}const FormationSlices={encode(e,t=minimal.Writer.create()){e.name!==""&&t.uint32(10).string(e.name);for(const n of e.slices)FormationSlices_Slice.encode(n,t.uint32(18).fork()).ldelim();return e.center!==void 0&&Vertex.encode(e.center,t.uint32(250).fork()).ldelim(),t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseFormationSlices();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.name=n.string();continue;case 2:if(o!==18)break;r.slices.push(FormationSlices_Slice.decode(n,n.uint32()));continue;case 31:if(o!==250)break;r.center=Vertex.decode(n,n.uint32());continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{name:isSet$7(e.name)?globalThis.String(e.name):"",slices:globalThis.Array.isArray(e==null?void 0:e.slices)?e.slices.map(t=>FormationSlices_Slice.fromJSON(t)):[],center:isSet$7(e.center)?Vertex.fromJSON(e.center):void 0}},toJSON(e){var n;const t={};return e.name!==""&&(t.name=e.name),(n=e.slices)!=null&&n.length&&(t.slices=e.slices.map(a=>FormationSlices_Slice.toJSON(a))),e.center!==void 0&&(t.center=Vertex.toJSON(e.center)),t},create(e){return FormationSlices.fromPartial(e!=null?e:{})},fromPartial(e){var n,a;const t=createBaseFormationSlices();return t.name=(n=e.name)!=null?n:"",t.slices=((a=e.slices)==null?void 0:a.map(r=>FormationSlices_Slice.fromPartial(r)))||[],t.center=e.center!==void 0&&e.center!==null?Vertex.fromPartial(e.center):void 0,t}};function createBaseFormationSlices_Slice(){return{name:"",colorId:0,vertices:[],indices:[],edges:[]}}const FormationSlices_Slice={encode(e,t=minimal.Writer.create()){e.name!==""&&t.uint32(10).string(e.name),e.colorId!==0&&t.uint32(16).uint32(e.colorId),t.uint32(26).fork();for(const n of e.vertices)t.float(n);t.ldelim(),t.uint32(34).fork();for(const n of e.indices)t.uint32(n);t.ldelim();for(const n of e.edges)Vertex.encode(n,t.uint32(42).fork()).ldelim();return t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseFormationSlices_Slice();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.name=n.string();continue;case 2:if(o!==16)break;r.colorId=n.uint32();continue;case 3:if(o===29){r.vertices.push(n.float());continue}if(o===26){const i=n.uint32()+n.pos;for(;n.pos<i;)r.vertices.push(n.float());continue}break;case 4:if(o===32){r.indices.push(n.uint32());continue}if(o===34){const i=n.uint32()+n.pos;for(;n.pos<i;)r.indices.push(n.uint32());continue}break;case 5:if(o!==42)break;r.edges.push(Vertex.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{name:isSet$7(e.name)?globalThis.String(e.name):"",colorId:isSet$7(e.colorId)?globalThis.Number(e.colorId):0,vertices:globalThis.Array.isArray(e==null?void 0:e.vertices)?e.vertices.map(t=>globalThis.Number(t)):[],indices:globalThis.Array.isArray(e==null?void 0:e.indices)?e.indices.map(t=>globalThis.Number(t)):[],edges:globalThis.Array.isArray(e==null?void 0:e.edges)?e.edges.map(t=>Vertex.fromJSON(t)):[]}},toJSON(e){var n,a,r;const t={};return e.name!==""&&(t.name=e.name),e.colorId!==0&&(t.colorId=Math.round(e.colorId)),(n=e.vertices)!=null&&n.length&&(t.vertices=e.vertices),(a=e.indices)!=null&&a.length&&(t.indices=e.indices.map(o=>Math.round(o))),(r=e.edges)!=null&&r.length&&(t.edges=e.edges.map(o=>Vertex.toJSON(o))),t},create(e){return FormationSlices_Slice.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o,i;const t=createBaseFormationSlices_Slice();return t.name=(n=e.name)!=null?n:"",t.colorId=(a=e.colorId)!=null?a:0,t.vertices=((r=e.vertices)==null?void 0:r.map(s=>s))||[],t.indices=((o=e.indices)==null?void 0:o.map(s=>s))||[],t.edges=((i=e.edges)==null?void 0:i.map(s=>Vertex.fromPartial(s)))||[],t}};function isSet$7(e){return e!=null}const FormationComponent=(e,t)=>{var O,F,w,L;const n=reactBabylonjs.useScene(),a=React.useRef(null),r=React.useRef(null),o=React.useContext(WorkspaceMetaContext),i=React.useContext(ColorProviderContext),[s,l]=React.useState(EngineCore.Color3.White()),{id:c,visible:f=!0,vertices:u,indices:d,colorId:h,position:m,normals:R,material:v={type:MaterialType.COLOR_ID},children:g,alpha:x=1,style:y,name:E="formation",highStyle:k,lowStyle:b,edges:C=[]}=e,_=useCachedTexture({url:v==null?void 0:v.texture,cacheType:CacheType.URL_PREFIX_MATCH}),A=useCachedTexture({url:v==null?void 0:v.sideTexture,cacheType:CacheType.URL_PREFIX_MATCH}),[N,S]=React.useState();React.useImperativeHandle(t,()=>r.current,[]),React.useEffect(()=>{if(a&&a.current&&n){const B=new EngineCore.VertexData;B.positions=u,B.indices=d,B.normals=R;const D=a.current;B.applyToMesh(D),D.getScene().onAfterRenderObservable.addOnce(()=>{if(!D.isDisposed()){const ae=D.getBoundingInfo();S(ae.boundingBox)}})}},[d,u,n,c,R]),React.useEffect(()=>{var B;l(v.type===MaterialType.ONE_COLOR?(B=v==null?void 0:v.color)!=null?B:EngineCore.Color3.Random():h&&i.colorIDs[h]?new EngineCore.Color3(i.colorIDs[h].r,i.colorIDs[h].g,i.colorIDs[h].b):EngineCore.Color3.Random())},[i.colorIDs,h,v==null?void 0:v.color,v.type]);const I=(B,D,W)=>{const ae=D.subtract(B),ee=1+1e3/EngineCore.Vector3.Distance(B,D)*(W-1),H=ae.scale(ee);return B.add(H)};return jsxRuntime.jsxs("transformNode",{name:`node-${E}-${c}`,setEnabled:f,children:[jsxRuntime.jsxs("transformNode",{name:`${E}`,position:m?m.multiply(calcTransformNodeScale(o)):new EngineCore.Vector3(0,0,0),scaling:calcTransformNodeScale(o),ref:r,children:[jsxRuntime.jsx("mesh",{name:`${E}-mesh`,ref:a,children:v.type===MaterialType.TEXTURE?_?jsxRuntime.jsx(RepeatedTextureMaterial,{name:`formationslice-${E}-mat`,backFaceCulling:!1,needDepthPrePass:v.needDepthPrePass===void 0?!1:v.needDepthPrePass,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,alphaMode:EngineCore.Engine.ALPHA_COMBINE,alpha:x,sideTexture:A,texture:_,tilingFactor:v.tilingFactor,sideTilingFactor:(O=v==null?void 0:v.sideTilingFactor)!=null?O:v==null?void 0:v.tilingFactor,mode:v.textureMode===void 0?RepeatedTextureMode.PLANE:v.textureMode,boundingBox:N,lines:v.lines,text:v.text,scaleDepth:o?o.scaleDepth:1,scalePlane:o?o.scalePlane:1,disableDepthWrite:v.disableDepthWrite}):jsxRuntime.jsx(jsxRuntime.Fragment,{}):v.type===MaterialType.COLOR_CODEC?v.colorCodec?jsxRuntime.jsx(RemapColorByRedChannelMaterial,{name:`formation-${E}-mat`,backFaceCulling:!1,needDepthPrePass:v.needDepthPrePass===void 0?!1:v.needDepthPrePass,alpha:x,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,alphaMode:EngineCore.Engine.ALPHA_COMBINE,colorCodec:v.colorCodec,boundingBox:N,lines:v.lines,text:v.text,scaleDepth:o?o.scaleDepth:1,scalePlane:o?o.scalePlane:1,disableDepthWrite:v.disableDepthWrite}):jsxRuntime.jsx(jsxRuntime.Fragment,{}):v.type===MaterialType.COLOR_ID?jsxRuntime.jsx("standardMaterial",{name:`formation-${E}-mat`,backFaceCulling:!1,needDepthPrePass:v.needDepthPrePass===void 0?!1:v.needDepthPrePass,specularColor:new EngineCore.Color3(0,0,0),ambientColor:new EngineCore.Color3(1,1,1),diffuseColor:s,alphaMode:EngineCore.Engine.ALPHA_COMBINE,alpha:x,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,disableDepthWrite:v.disableDepthWrite}):jsxRuntime.jsx("standardMaterial",{name:`formation-${E}-mat`,backFaceCulling:!1,needDepthPrePass:v.needDepthPrePass===void 0?!1:v.needDepthPrePass,specularColor:new EngineCore.Color3(0,0,0),ambientColor:new EngineCore.Color3(1,1,1),diffuseColor:s,alphaMode:EngineCore.Engine.ALPHA_COMBINE,alpha:x,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,disableDepthWrite:v.disableDepthWrite})}),y.position&&jsxRuntime.jsx("transformNode",{name:`${E}-title`,position:I(convertVertexToVector3(y.basePosition==="left"?C[4]:C[5]),y.position,(F=y.offset)!=null?F:1),scaling:calcGUIScale(o),children:y.title&&jsxRuntime.jsx(GUIText$1,{text:y.title,fontSize:y.fontSize?y.fontSize:40,color:y.color?y.color:"black"})}),b&&b.position&&jsxRuntime.jsx("transformNode",{name:`${E}-up-title`,position:I(convertVertexToVector3(b.basePosition==="left"?C[4]:C[5]),b.position,(w=b.offset)!=null?w:1),scaling:calcGUIScale(o),children:b.title&&jsxRuntime.jsx(GUIText$1,{text:b.title,fontSize:b.fontSize?b.fontSize:40,color:b.color?b.color:"black"})}),k&&k.position&&jsxRuntime.jsx("transformNode",{name:`${E}-down-title`,position:I(convertVertexToVector3(k.basePosition==="left"?C[4]:C[5]),k.position,(L=k.offset)!=null?L:1),scaling:calcGUIScale(o),children:k.title&&jsxRuntime.jsx(GUIText$1,{text:k.title,fontSize:k.fontSize?k.fontSize:40,color:k.color?k.color:"black"})})]}),g]})},FormationComponent$1=React.forwardRef(FormationComponent),FormationSlice=e=>{const[t,n]=React.useState([]),[a,r]=React.useState(""),{url:o,visible:i=!0,materials:s,actions:l,style:c,highStyle:f,lowStyle:u,basePosition:d="left"}=e,h=React.useRef(null),m=React.useContext(WorkspaceMetaContext),R=useCachedBinary({url:o,cacheType:CacheType.URL_PREFIX_MATCH}),[v,g]=React.useState(EngineCore.Vector3.Zero());return React.useEffect(()=>{console.log("[Geo3DViewer] FormationSlice Loading: ",o)},[o]),React.useEffect(()=>{if(R){const x=FormationSlices.decode(new Uint8Array(R));x.center&&g(new EngineCore.Vector3(x.center.x,x.center.y,x.center.z));const y=x.slices.map(E=>{const k=[];return EngineCore.VertexData.ComputeNormals(E.vertices,E.indices,k),{name:E.name,colorId:E.colorId,vertices:E.vertices,indices:E.indices,edges:E.edges,normals:k}});return r(x.name),n(y),()=>{r(""),n([])}}},[R]),React.useEffect(()=>{var y;const x=(y=h.current)==null?void 0:y.getChildMeshes()[0];x&&(x.metadata={pickable:l?{name:a,onLeftClick:l.onLeftClick,onRightClick:l.onRightClick,onMiddleClick:l.onMiddleClick,onHover:l.onHover,extra:l.extra}:null})},[l,a]),jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx("transformNode",{name:`foramtionslice-${a}-holder`,setEnabled:i,position:v.multiply(calcTransformNodeScale(m)),children:t.map((x,y)=>{const E=x.edges.length>0?convertVertexToVector3(d==="left"?x.edges[0]:x.edges[2]):new EngineCore.Vector3(0,0,0),k=x.edges.length>0?convertVertexToVector3(d==="left"?x.edges[1]:x.edges[3]):new EngineCore.Vector3(0,0,0),b=EngineCore.Vector3.Lerp(E,k,.5);return jsxRuntime.jsx(FormationComponent$1,{id:y,vertices:x.vertices,indices:x.indices,colorId:x.colorId,normals:x.normals,name:x.name,edges:x.edges,style:c?{position:b,title:x.name,basePosition:d,...c}:{},lowStyle:u?{position:k,title:(v.y+k.y).toFixed(0).toString(),basePosition:d,...u}:{},highStyle:f&&y===t.length-1?{position:E,title:(v.y+E.y).toFixed(0).toString(),basePosition:d,...f}:{},material:s?{...s[x.name],backFaceCulling:!1}:void 0,ref:h},y)})})})},FormationSlice$1=FormationSlice,TransformGUIText=e=>{const{name:t="node",text:n,fontSize:a,color:r,position:o=EngineCore.Vector3.Zero(),scale:i=EngineCore.Vector3.One(),blink:s=!1}=e,[l,c]=React.useState(!0);return React.useEffect(()=>{const f=setInterval(()=>{s&&c(u=>!u)},1e3);return()=>{clearInterval(f)}},[s]),jsxRuntime.jsx("transformNode",{name:`${t}-text`,position:o,scaling:i,setEnabled:l,children:jsxRuntime.jsx(GUIText$1,{name:t,text:n,fontSize:a,color:r})})},TransformGUIText$1=TransformGUIText;var AxesViewerPosition=(e=>(e[e.NONE=0]="NONE",e[e.BOTTOM_LEFT=1]="BOTTOM_LEFT",e[e.BOTTOM_RIGHT=2]="BOTTOM_RIGHT",e[e.TOP_LEFT=3]="TOP_LEFT",e[e.TOP_RIGHT=4]="TOP_RIGHT",e))(AxesViewerPosition||{});const Geo3DCamera=({target:e,radius:t,alpha:n,beta:a,axesViewerOffset:r=EngineCore.Vector3.Zero(),panningSensibility:o=2,wheelDeltaPercentage:i=0,axesViewer:s=0,farPlane:l=1e4,skipPickingWhenCameraMoves:c=!1})=>{const f=reactBabylonjs.useScene(),u=React.useContext(WorkspaceMetaContext),[d,h]=React.useState(null),[m,R]=React.useState(null),[v,g]=React.useState(n),[x,y]=React.useState(a),[,E]=React.useState(null),k=React.useCallback(N=>{R(N)},[]),{setViewCamera:b}=React.useContext(ViewerCameraPropsContext),C=React.useCallback(()=>{if(m&&d){const N=new EngineCore.Vector3;N.addInPlace(m.position),N.addInPlace(m.getDirection(new EngineCore.Vector3(0,0,25))),s==4?(N.addInPlace(m.getDirection(new EngineCore.Vector3(0,7+r.y,0))),N.addInPlace(m.getDirection(new EngineCore.Vector3(15+r.x,0,0)))):s==3?(N.addInPlace(m.getDirection(new EngineCore.Vector3(0,7+r.y,0))),N.addInPlace(m.getDirection(new EngineCore.Vector3(-15+r.x,0,0)))):s==2?(N.addInPlace(m.getDirection(new EngineCore.Vector3(0,-7+r.y,0))),N.addInPlace(m.getDirection(new EngineCore.Vector3(15+r.x,0,0)))):s==1&&(N.addInPlace(m.getDirection(new EngineCore.Vector3(0,-7+r.y,0))),N.addInPlace(m.getDirection(new EngineCore.Vector3(-15+r.x,0,0)))),d.xAxis.position=N.clone(),d.yAxis.position=N.clone(),d.zAxis.position=N.clone()}},[m,d,s,r.y,r.x]);React.useEffect(()=>{if(f&&s!=0){const N=new EngineCore.AxesViewer(f,2,null);return h(N),()=>{N==null||N.dispose(),h(null)}}},[f,s]),React.useEffect(()=>{C()},[C]);const _=React.useCallback(N=>{if(u&&u.min&&u.max)return EngineCore.Vector3.Clamp(N,u==null?void 0:u.min,u==null?void 0:u.max)},[u]),A=React.useCallback(N=>{f&&(f.skipPointerMovePicking=N)},[f]);return React.useEffect(()=>{if(!f||!m)return;const N=m.onViewMatrixChangedObservable.add(()=>{c&&(A(!0),E(S=>(S&&clearTimeout(S),setTimeout(()=>{A(!1),E(null)},250)))),g(m.alpha),y(m.beta),C()});return()=>{m.onViewMatrixChangedObservable.remove(N),E(S=>(S&&clearTimeout(S),null)),A(!1)}},[f,s,m,u,d,C,_,A,c]),React.useEffect(()=>{b(f&&m?m:void 0)},[f,m,b]),React.useEffect(()=>{},[_,u,e]),jsxRuntime.jsx(jsxRuntime.Fragment,{children:e&&jsxRuntime.jsx("arcRotateCamera",{name:"rootCamera",target:e,radius:t,alpha:v,beta:x,maxZ:l,panningSensibility:o,wheelDeltaPercentage:i,ref:k,setActiveOnSceneIfNoneActive:!0})})},Geo3DCamera$1=Geo3DCamera,Geo3DUniversalCamera=(e,t)=>{const{position:n=EngineCore.Vector3.Zero(),axesViewer:a=AxesViewerPosition.NONE,axesViewerOffset:r=EngineCore.Vector3.Zero(),skipPickingWhenCameraMoves:o=!1,wheelDeltaPercentage:i=3,rotationSensibility:s=1,panningSensibility:l=10}=e,c=reactBabylonjs.useScene(),f=React.useContext(WorkspaceMetaContext),[u,d]=React.useState(null),[h,m]=React.useState(null),{setViewCamera:R,cameraRefObject:v}=React.useContext(ViewerCameraPropsContext),[,g]=React.useState(null),x=React.useRef(null),[y,E]=React.useState(null),k=React.useRef(null),b=React.useCallback(S=>{c&&(c.skipPointerMovePicking=S)},[c]);React.useEffect(()=>(k.current=new EngineCore.ArcRotateCamera("dummy-camera",0,0,.1,EngineCore.Vector3.Zero(),c||void 0,!1),()=>{var S;(S=k.current)==null||S.dispose()}),[c]),React.useEffect(()=>{if(c){const S=h,I=c.onPointerObservable.add(O=>{if(O.type===EngineCore.PointerEventTypes.POINTERDOWN&&(x.current=new EngineCore.Vector2(O.event.clientX,O.event.clientY)),O.type===EngineCore.PointerEventTypes.POINTERUP&&(x.current=null),O.type===EngineCore.PointerEventTypes.POINTERMOVE&&x.current){const F=O.event.clientX-x.current.x,w=O.event.clientY-x.current.y;if(O.event.buttons===1){let L=null;(S.lockedTarget||y)&&(S.lockedTarget&&(L=S.lockedTarget.position),y&&(L=y)),L&&k.current?(k.current.target=L,k.current.position=S.position.clone(),k.current.wheelDeltaPercentage=i,k.current.panningSensibility=l,k.current.alpha+=F/100*s,k.current.beta+=w/100*s,k.current.update(),S.position=k.current.position.clone(),S.rotation=k.current.rotation.clone()):(S.rotation.y-=F/100*s,S.rotation.x-=w/100*s)}O.event.buttons===2&&(S.position.x-=F/100*l,S.position.y+=w/100*l),x.current=new EngineCore.Vector2(O.event.clientX,O.event.clientY)}});return()=>{c.onPointerObservable.remove(I)}}},[y,l,h,s,c,i]);const C=React.useCallback(S=>{S&&(S.inputs.addMouseWheel(),S.inputs.removeMouse(),R(S),m(S))},[R]);React.useEffect(()=>{if(h){const S=h.inputs.attached.mousewheel;S.wheelPrecisionX=i,S.wheelPrecisionY=i,S.wheelPrecisionZ=i}},[h,i]);const _=React.useCallback(()=>{if(h&&u){const S=new EngineCore.Vector3;S.addInPlace(h.position),S.addInPlace(h.getDirection(new EngineCore.Vector3(0,0,25))),a==AxesViewerPosition.TOP_RIGHT?(S.addInPlace(h.getDirection(new EngineCore.Vector3(0,7+r.y,0))),S.addInPlace(h.getDirection(new EngineCore.Vector3(15+r.x,0,0)))):a==AxesViewerPosition.TOP_LEFT?(S.addInPlace(h.getDirection(new EngineCore.Vector3(0,7+r.y,0))),S.addInPlace(h.getDirection(new EngineCore.Vector3(-15+r.x,0,0)))):a==AxesViewerPosition.BOTTOM_RIGHT?(S.addInPlace(h.getDirection(new EngineCore.Vector3(0,-7+r.y,0))),S.addInPlace(h.getDirection(new EngineCore.Vector3(15+r.x,0,0)))):a==AxesViewerPosition.BOTTOM_LEFT&&(S.addInPlace(h.getDirection(new EngineCore.Vector3(0,-7+r.y,0))),S.addInPlace(h.getDirection(new EngineCore.Vector3(-15+r.x,0,0)))),u.xAxis.position=S.clone(),u.yAxis.position=S.clone(),u.zAxis.position=S.clone()}},[h,u,a,r.y,r.x]);React.useEffect(()=>{if(c&&a!=AxesViewerPosition.NONE){const S=new EngineCore.AxesViewer(c,2,null);return d(S),()=>{S==null||S.dispose(),d(null)}}},[c,a]),React.useEffect(()=>{_()},[_]),React.useEffect(()=>{R(c&&h?h:void 0)},[c,h,R]),React.useEffect(()=>{if(!c||!h)return;const S=h.onViewMatrixChangedObservable.add(()=>{o&&(b(!0),g(I=>(I&&clearTimeout(I),setTimeout(()=>{b(!1),g(null)},250)))),_()});return()=>{h.onViewMatrixChangedObservable.remove(S),g(I=>(I&&clearTimeout(I),null)),b(!1)}},[c,a,h,f,u,_,o,b]);const[A,N]=React.useState();return React.useEffect(()=>{if(h){const S={lookAt:I=>{h&&h.setTarget(I)},updatePosition:I=>{h&&(h.position=I)},lockTarget:I=>{h&&(E(null),h.lockedTarget=I)},lockTo:I=>{h&&(h.lockedTarget=null,E(I))}};N(S),v&&v.current&&(v.current.rawCamera=h,v.current.cameraTools=S)}},[v,h]),React.useImperativeHandle(t,()=>({rawCamera:h,cameraTools:A}),[A,h]),jsxRuntime.jsx("universalCamera",{name:"universal-main-camera",position:n,ref:C,maxZ:0})},Geo3DUniversalCamera$1=React.forwardRef(Geo3DUniversalCamera);class FreeCameraPointersInput extends EngineCore.BaseCameraPointersInput{constructor(){super(...arguments);le(this,"camera");le(this,"buttons",[0,1,2,4]);le(this,"panningSensibility",10);le(this,"angularSensibility",1e4);le(this,"_isPanClick",!1);le(this,"_isPinching",!1)}getClassName(){return"FreeCameraPointersInput"}onButtonDown(n){(n.buttons===1||n.buttons===4)&&(this._isPinching=!0),n.buttons===2&&(this._isPanClick=!0)}onButtonUp(n){n&&(this._isPanClick=!1,this._isPinching=!1)}onTouch(n,a,r){if(this.panningSensibility!==0&&this._isPanClick){const o=-a/this.panningSensibility,i=r/this.panningSensibility;this.camera._localDirection.copyFromFloats(o,i,0),this.camera.getViewMatrix().invertToRef(this.camera._cameraTransformMatrix),EngineCore.Vector3.TransformNormalToRef(this.camera._localDirection,this.camera._cameraTransformMatrix,this.camera._transformedDirection),this.camera.cameraDirection.addInPlace(this.camera._transformedDirection)}if(this.angularSensibility!==0&&this._isPinching){const o=EngineCore.Quaternion.FromEulerAngles(this.camera.rotation.x,this.camera.rotation.y,this.camera.rotation.z),i=EngineCore.Quaternion.RotationAxis(EngineCore.Axis.Y,EngineCore.Tools.ToDegrees(a/this.angularSensibility)),s=EngineCore.Quaternion.RotationAxis(EngineCore.Axis.X,EngineCore.Tools.ToDegrees(r/this.angularSensibility)),l=o.multiply(i).multiply(s);this.camera.rotation=l.toEulerAngles()}}onLostFocus(){this._isPanClick=!1,this._isPinching=!1}}const Geo3DFreeCamera=e=>{const{position:t,target:n=new EngineCore.Vector3(0,0,0),panningSensibility:a=5,angularSensibility:r=2e3,skipPickingWhenCameraMoves:o=!1}=e,i=reactBabylonjs.useScene(),s=React.useRef(null),l=React.useRef(null),c=React.useCallback(f=>{i&&(i.skipPointerMovePicking=f)},[i]);return React.useEffect(()=>{if(s.current){s.current.inputs.removeByType("FreeCameraMouseInput");const f=new FreeCameraPointersInput,u=new EngineCore.FreeCameraMouseWheelInput;s.current.inputs.add(f),s.current.inputs.add(u)}},[]),React.useEffect(()=>{s.current&&n&&s.current.setTarget(n)},[n]),React.useEffect(()=>{if(!i||!s.current)return;const f=s.current.onViewMatrixChangedObservable.add(()=>{o&&(c(!0),l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{c(!1),l.current=null},250))});return()=>{var u;(u=s.current)==null||u.onViewMatrixChangedObservable.remove(f),l.current&&(clearTimeout(l.current),l.current=null),c(!1)}},[i,c,o]),React.useEffect(()=>{if(s.current){if(s.current.inputs.attached.pointers){const f=s.current.inputs.attached.pointers;f.panningSensibility=Math.abs(a),f.angularSensibility=Math.abs(r)}if(s.current.inputs.attached.pointersPanning){const f=s.current.inputs.attached.pointersPanning;f.panningSensibility=Math.abs(a)}if(s.current.inputs.attached.around){const f=s.current.inputs.attached.around;f.angularSensibility=Math.abs(r)}}},[r,a]),jsxRuntime.jsx("freeCamera",{name:"rootCamera",position:t,ref:s})},Geo3DFreeCamera$1=Geo3DFreeCamera;class DepthTextureDebuggerNode extends EngineCore.TransformNode{constructor(n,a,r){super(n,a);le(this,"_showDepthTexture",!1);le(this,"_postProcess");this._postProcess=r,this.showDepthTexture=!1,this.inspectableCustomProperties=[{label:"Show Depth Texture",propertyName:"showDepthTexture",type:EngineCore.InspectableType.Checkbox}]}set showDepthTexture(n){var a,r;this._showDepthTexture=n,this._postProcess&&(this._showDepthTexture?(a=this.getScene().activeCamera)==null||a.attachPostProcess(this._postProcess):(r=this.getScene().activeCamera)==null||r.detachPostProcess(this._postProcess))}get showDepthTexture(){return this._showDepthTexture}}const DepthTextureDebugger=()=>{const e=reactBabylonjs.useEngine(),t=reactBabylonjs.useScene();return React.useEffect(()=>{if(t&&e){EngineCore.Effect.ShadersStore.depthbufferPixelShader=`#ifdef GL_ES
1194
1194
  precision highp float;
1195
1195
  #endif
1196
1196
 
@@ -1223,7 +1223,7 @@ precision highp float;
1223
1223
 
1224
1224
  void main(void)
1225
1225
  {}`;const a=new EngineCore.PostProcess("GPU Picking Display","gpuPickingBuffer",null,null,1,null,void 0,e,!0);a.onApply=i=>{i._bindTexture("textureSampler",n.gpuPickingTexture.current.getInternalTexture())};const r=new GPUPickingTextureDebuggerNode("GPU Picking Debugger",t,a),o=t.getTransformNodeByName("Debugger");return o&&(r.parent=o),()=>{var i;(i=t.activeCamera)==null||i.detachPostProcess(a),r&&t.removeTransformNode(r),r.dispose(),a.dispose()}}},[t,e,n]),jsxRuntime.jsx(jsxRuntime.Fragment,{})},GPUPickingTextureDebugger$1=GPUPickingTextureDebugger,DebugLayer=({showDebugLayer:e=!1})=>{const t=reactBabylonjs.useScene(),n=reactBabylonjs.useEngine();return React.useEffect(()=>{n&&t&&(e?(n.captureGPUFrameTime=a=>{},inspector.Inspector.Show(t,{embedMode:!0})):inspector.Inspector.Hide())},[n,t,e]),React.useEffect(()=>()=>{t&&inspector.Inspector.Hide()},[t]),jsxRuntime.jsxs("transformNode",{name:"Debugger",children:[jsxRuntime.jsx(DepthTextureDebugger$1,{}),jsxRuntime.jsx(GPUPickingTextureDebugger$1,{})]})},DebugLayer$1=DebugLayer,EngineFixer=()=>{const e=reactBabylonjs.useScene(),t=reactBabylonjs.useEngine();return React.useEffect(()=>{const n=t;if(window.BABYLON&&n)return window.BABYLON.EngineStore.Instances.push(n),dynamic.registerBuiltInLoaders(),()=>{if(window.BABYLON){const a=window.BABYLON.EngineStore.Instances.indexOf(n);a>-1&&window.BABYLON.EngineStore.Instances.splice(a,1)}}},[t]),React.useEffect(()=>{const n=t;if(n)return EngineCore.EngineStore.Instances.push(n),()=>{const a=window.BABYLON.EngineStore.Instances.indexOf(n);a>-1&&window.BABYLON.EngineStore.Instances.splice(a,1)}},[t]),React.useEffect(()=>{const n=e;if(window.BABYLON&&n)return window.BABYLON.EngineStore._LastCreatedScene=e,()=>{window.BABYLON&&window.BABYLON.EngineStore._LastCreatedScene===n&&(window.BABYLON.EngineStore._LastCreatedScene=null)}},[e]),React.useEffect(()=>{const n=e;if(n)return EngineCore.EngineStore._LastCreatedScene=e,()=>{EngineCore.EngineStore._LastCreatedScene===n&&(EngineCore.EngineStore._LastCreatedScene=null)}},[e]),React.useEffect(()=>{e&&(e._forceBlockMaterialDirtyMechanism=a=>{e._blockMaterialDirtyMechanism=a})},[e]),jsxRuntime.jsx(jsxRuntime.Fragment,{})},EngineFixer$1=EngineFixer;class ResourceManager{constructor(){le(this,"urls",[]);le(this,"resources",new Map);le(this,"listeners",new Map);this.urls=[]}addListener(t,n){var a;this.listeners.has(t)?(a=this.listeners.get(t))==null||a.push(n):this.listeners.set(t,[n])}removeListener(t,n){var a,r;if(this.listeners.has(t)){const o=(a=this.listeners.get(t))==null?void 0:a.findIndex(i=>i===n);o!==void 0&&o!==-1&&((r=this.listeners.get(t))==null||r.splice(o,1))}}notifyProgress(t,n){var a;(a=this.listeners.get(t))==null||a.forEach(r=>r.onProgress(n))}notifyComplete(t){var n;(n=this.listeners.get(t))==null||n.forEach(a=>a.onComplete(this.resources.get(t)))}notifyError(t,n){var a;(a=this.listeners.get(t))==null||a.forEach(r=>r.onError(n))}download(t,n="BIN"){if(n==="BIN"){axios.get(t,{responseType:"arraybuffer"}).then(a=>{console.log(a),this.resources.set(t,a.data),this.notifyComplete(t)}).catch(a=>{this.notifyError(t,a)});return}}load(t,n,a){this.urls.findIndex(o=>o===t)===-1?(this.urls.push(t),this.download(t,n),this.addListener(t,a)):this.resources.get(t)?this.notifyComplete(t):this.addListener(t,a)}}const ResourceContext=React.createContext(void 0),useAsset=(e,t="BIN")=>{const n=React.useContext(ResourceContext),[a,r]=React.useState(void 0),o=React.useMemo(()=>{const i={onProgress:function(s){console.log(s)},onComplete:function(s){console.log(e,s),r(s)},onError:function(s){console.log(s),n==null||n.removeListener(e,i)}};return i},[n,e]);return React.useEffect(()=>(n==null||n.load(e,t,o),()=>{n==null||n.removeListener(e,o)}),[o,n,t,e]),a},Geo3DViewer=(e,t)=>{const{children:n,showDebugLayer:a=!1,meta:r,colorProvider:o,cacheProvider:i,options:s={backgroundColor:EngineCore.Color4.FromArray([.2,.2,.3,1]),light:{intensity:1,direction:new EngineCore.Vector3(1,1,1)}}}=e,{light:l={intensity:1,direction:new EngineCore.Vector3(1,1,1)}}=s,{intensity:c=1,direction:f=new EngineCore.Vector3(1,1,1)}=l,u=React.useRef(null),[d,h]=React.useState(!1);return React.useEffect(()=>{console.log(`
1226
- %c Geo3DViewer Library %c Version: 1.7.32 %c
1226
+ %c Geo3DViewer Library %c Version: 1.7.33 %c
1227
1227
  `,"color:#e0e0e0;background:#873e23;padding:5px 0;border-top-left-radius:5px;border-bottom-left-radius:5px;","color:#455a64;background:#e0e0e0;padding:5px 0;","color:#455a64;background:#e0e0e0;padding:5px 0;border-top-right-radius:5px;border-bottom-right-radius:5px;")},[]),React.useImperativeHandle(t,()=>({scene:u,camera:null}),[u]),React.useEffect(()=>{a&&h(!0)},[a]),jsxRuntime.jsx(reactBabylonjs.Engine,{antialias:!0,adaptToDeviceRatio:!0,canvasId:"rootGeo3DCanvas",engineOptions:{useHighPrecisionFloats:!0,depth:!0,useHighPrecisionMatrix:!0,stencil:!0},children:jsxRuntime.jsxs(reactBabylonjs.Scene,{clearColor:s.backgroundColor,useRightHandedSystem:s.useRightHandedSystem,children:[jsxRuntime.jsx(EngineFixer$1,{}),jsxRuntime.jsx("ground",{name:"picking-material-holder",setEnabled:!1,children:jsxRuntime.jsx(PickingMaterial,{})}),jsxRuntime.jsx(ResourceContext.Provider,{value:new ResourceManager,children:jsxRuntime.jsxs(Geo3DProvider$1,{workspaceMeta:r,colorProvider:o,cacheProvider:i,ref:u,children:[d||a?jsxRuntime.jsx(DebugLayer$1,{showDebugLayer:a}):null,jsxRuntime.jsx("hemisphericLight",{name:"light",intensity:c,direction:f}),n]})}),s.environment?jsxRuntime.jsx("cubeTexture",{assignTo:"environmentTexture",rootUrl:s.environment}):jsxRuntime.jsx(jsxRuntime.Fragment,{})]})})},Geo3DViewer$1=React.forwardRef(Geo3DViewer);var GridDiagram_GridDiagramMode=(e=>(e[e.ATTRIBUTE=0]="ATTRIBUTE",e[e.COLOR=1]="COLOR",e[e.STATIC_ATTRIBUTE=2]="STATIC_ATTRIBUTE",e[e.STATIC_COLOR=3]="STATIC_COLOR",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED",e))(GridDiagram_GridDiagramMode||{});function gridDiagram_GridDiagramModeFromJSON(e){switch(e){case 0:case"ATTRIBUTE":return 0;case 1:case"COLOR":return 1;case 2:case"STATIC_ATTRIBUTE":return 2;case 3:case"STATIC_COLOR":return 3;case-1:case"UNRECOGNIZED":default:return-1}}function gridDiagram_GridDiagramModeToJSON(e){switch(e){case 0:return"ATTRIBUTE";case 1:return"COLOR";case 2:return"STATIC_ATTRIBUTE";case 3:return"STATIC_COLOR";case-1:default:return"UNRECOGNIZED"}}function createBaseGridDiagram(){return{name:"",step:0,xCount:0,yCount:0,zCount:0,xSliceUrl:"",ySliceUrl:"",zSliceUrl:"",mode:0}}const GridDiagram$2={encode(e,t=minimal.Writer.create()){return e.name!==""&&t.uint32(10).string(e.name),e.step!==0&&t.uint32(16).uint32(e.step),e.xCount!==0&&t.uint32(24).uint32(e.xCount),e.yCount!==0&&t.uint32(32).uint32(e.yCount),e.zCount!==0&&t.uint32(40).uint32(e.zCount),e.xSliceUrl!==""&&t.uint32(50).string(e.xSliceUrl),e.ySliceUrl!==""&&t.uint32(58).string(e.ySliceUrl),e.zSliceUrl!==""&&t.uint32(66).string(e.zSliceUrl),e.mode!==0&&t.uint32(72).int32(e.mode),t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseGridDiagram();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.name=n.string();continue;case 2:if(o!==16)break;r.step=n.uint32();continue;case 3:if(o!==24)break;r.xCount=n.uint32();continue;case 4:if(o!==32)break;r.yCount=n.uint32();continue;case 5:if(o!==40)break;r.zCount=n.uint32();continue;case 6:if(o!==50)break;r.xSliceUrl=n.string();continue;case 7:if(o!==58)break;r.ySliceUrl=n.string();continue;case 8:if(o!==66)break;r.zSliceUrl=n.string();continue;case 9:if(o!==72)break;r.mode=n.int32();continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{name:isSet$6(e.name)?globalThis.String(e.name):"",step:isSet$6(e.step)?globalThis.Number(e.step):0,xCount:isSet$6(e.xCount)?globalThis.Number(e.xCount):0,yCount:isSet$6(e.yCount)?globalThis.Number(e.yCount):0,zCount:isSet$6(e.zCount)?globalThis.Number(e.zCount):0,xSliceUrl:isSet$6(e.xSliceUrl)?globalThis.String(e.xSliceUrl):"",ySliceUrl:isSet$6(e.ySliceUrl)?globalThis.String(e.ySliceUrl):"",zSliceUrl:isSet$6(e.zSliceUrl)?globalThis.String(e.zSliceUrl):"",mode:isSet$6(e.mode)?gridDiagram_GridDiagramModeFromJSON(e.mode):0}},toJSON(e){const t={};return e.name!==""&&(t.name=e.name),e.step!==0&&(t.step=Math.round(e.step)),e.xCount!==0&&(t.xCount=Math.round(e.xCount)),e.yCount!==0&&(t.yCount=Math.round(e.yCount)),e.zCount!==0&&(t.zCount=Math.round(e.zCount)),e.xSliceUrl!==""&&(t.xSliceUrl=e.xSliceUrl),e.ySliceUrl!==""&&(t.ySliceUrl=e.ySliceUrl),e.zSliceUrl!==""&&(t.zSliceUrl=e.zSliceUrl),e.mode!==0&&(t.mode=gridDiagram_GridDiagramModeToJSON(e.mode)),t},create(e){return GridDiagram$2.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o,i,s,l,c,f;const t=createBaseGridDiagram();return t.name=(n=e.name)!=null?n:"",t.step=(a=e.step)!=null?a:0,t.xCount=(r=e.xCount)!=null?r:0,t.yCount=(o=e.yCount)!=null?o:0,t.zCount=(i=e.zCount)!=null?i:0,t.xSliceUrl=(s=e.xSliceUrl)!=null?s:"",t.ySliceUrl=(l=e.ySliceUrl)!=null?l:"",t.zSliceUrl=(c=e.zSliceUrl)!=null?c:"",t.mode=(f=e.mode)!=null?f:0,t}};function isSet$6(e){return e!=null}const GridDiagram=({name:e,url:t,step:n,visible:a=!0,colorCodec:r,alpha:o=1,actions:i,materials:s})=>{const[l,c]=React.useState(),[f,u]=React.useState(0),d=useCachedBinary({url:t,cacheType:CacheType.URL_PREFIX_MATCH});return React.useEffect(()=>{console.log("[Geo3DViewer] GriDDiagram Loading: ",t)},[t]),React.useEffect(()=>{if(d){const h=GridDiagram$2.decode(new Uint8Array(d)),{xCount:m,zCount:R,xSliceUrl:v,zSliceUrl:g}=h,x=[];if(h.mode===GridDiagram_GridDiagramMode.ATTRIBUTE||h.mode===GridDiagram_GridDiagramMode.COLOR){if(n<=0){console.error("[Geo3DViewer] 此文件为动态数据文件,step 值必须大于 0"),c([]),u(0);return}let y=0;for(let E=0;E<m;E+=n)x.push(v.replace("%s",E.toString())),y=E;y>=m&&x.push(v.replace("%s",(m-1).toString()));for(let E=0;E<R;E+=n)x.push(g.replace("%s",E.toString())),y=E;y>=R&&x.push(g.replace("%s",(R-1).toString()))}else if(h.mode===GridDiagram_GridDiagramMode.STATIC_ATTRIBUTE||h.mode===GridDiagram_GridDiagramMode.STATIC_COLOR){if(n!==0){console.error("[Geo3DViewer] 静态栅状图数据必须传入 step=0 以确认您明确此数据无法使用动态加载模式"),c([]),u(0);return}for(let y=0;y<m;y+=1)x.push(v.replace("%s",y.toString()))}return c(x),u(h.mode===GridDiagram_GridDiagramMode.ATTRIBUTE?1:h.mode===GridDiagram_GridDiagramMode.COLOR?2:h.mode===GridDiagram_GridDiagramMode.STATIC_ATTRIBUTE?1:h.mode===GridDiagram_GridDiagramMode.STATIC_COLOR?2:0),()=>{c([]),u(0)}}},[d,n]),jsxRuntime.jsx("abstractMesh",{name:`gridDiagram-${e}`,children:f===1?l?l.map((h,m)=>jsxRuntime.jsx(DensitySlice$1,{name:e,url:h,visible:a,colorCodec:r,alpha:o,actions:i},`densityslice-group-${e}-${h}-${m}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}):f===2?l?l.map((h,m)=>jsxRuntime.jsx(FormationSlice$1,{url:h,visible:a,materials:s,actions:i},`formationslice-group-${e}-${h}-${m}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}):jsxRuntime.jsx(jsxRuntime.Fragment,{})})},GridDiagram$1=GridDiagram,IntersectingLine=({name:e,position:t,width:n,height:a,color:r,lineWidth:o,rotation:i,showDebugPlane:s=!1})=>{const l=React.useContext(WorkspaceMetaContext),c=React.useRef(null),f=useIntersectingLineMaterial({name:e,lineColor:r,lineWidth:o});return React.useEffect(()=>{c.current&&(c.current.material=f)},[f]),jsxRuntime.jsxs("transformNode",{name:`intersecting-line-${e}`,position:t.multiply(calcTransformNodeScale(l)),rotation:i||EngineCore.Vector3.Zero(),children:[jsxRuntime.jsx("plane",{name:e,width:n,height:a,isPickable:!1,isBlocker:!1,ref:c}),jsxRuntime.jsx("plane",{name:e,width:n,height:a,isPickable:!1,isBlocker:!1,setEnabled:s,children:jsxRuntime.jsx("standardMaterial",{name:"intersecting-line-material",diffuseColor:EngineCore.Color3.Gray(),backFaceCulling:!1,alpha:.5,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND})})]})},IntersectingLine$1=IntersectingLine,LookAt=e=>{const t=reactBabylonjs.useScene(),{target:n,distance:a}=e;return React.useEffect(()=>{if(t&&t.activeCamera&&n){const r=t.activeCamera;let o=new EngineCore.Vector3(0,0,0);if(typeof n=="string"){const i=t.getMeshById(n);i&&(o=i.getBoundingInfo().boundingBox.center)}else n.position?o=n.getBoundingInfo().boundingBox.center:o=n;if(r instanceof EngineCore.ArcRotateCamera){r.setTarget(o),r.radius=a;return}if(r instanceof EngineCore.FreeCamera){const i=o,s=r.position.clone(),l=a/EngineCore.Vector3.Distance(i,s),f=s.subtract(i).scale(l),u=i.add(f);r.position=u,r.setTarget(o)}return}},[a,t,n]),null},LookAt$1=LookAt,getChildBone=e=>{const t=e.getChildren();return t.length>0?[e,...getChildBone(t[0])]:[e]},ModelLoader=({name:e,url:t,position:n=EngineCore.Vector3.Zero(),rotation:a=EngineCore.Vector3.Zero(),localScale:r=1,visible:o=!0,showPickingBox:i=!1,useGlobalScale:s=!1,actions:l,alpha:c=1,boneRotation:f,pickingBoxScale:u=EngineCore.Vector3.One(),labelStyle:d},h)=>{const m=reactBabylonjs.useScene(),R=useCachedModel({url:t}),v=React.useRef(null),g=React.useRef(null),[x,y]=React.useState(null),[E,k]=React.useState(5),[b,C]=React.useState(5),[_,A]=React.useState(5),[N,S]=React.useState(EngineCore.Vector3.Zero()),[I,O]=React.useState(EngineCore.Vector3.One()),[F,w]=React.useState([]),L=React.useContext(WorkspaceMetaContext),{scaleWithParent:B=!0}=d||{};return React.useEffect(()=>{console.log("[Geo3DViewer] ModelLoader Loading: ",t)},[t]),React.useImperativeHandle(h,()=>g.current,[]),React.useEffect(()=>{if(R){const D=R.instantiateModelsToScene(W=>`${e}-${W}`,!0);return console.log("[Geo3DViewer] ModelLoader 实例化: ",e),y(D),()=>{console.log("[Geo3DViewer] ModelLoader 反实例化: ",e),y(null)}}},[R,e]),React.useEffect(()=>{if(x){const D=x,W=D.skeletons;if(W&&W.length>0){const ee=W[0].bones,H=[];ee.filter(oe=>oe.name==="MorphBoneBase").forEach((oe,te)=>{if(te===0){const K=getChildBone(oe);H.push(...K.map(Z=>{var ce;return(ce=Z.getTransformNode())!=null?ce:Z}))}}),w(H),console.log("[Geo3DViewer] ModelLoader 设定 Morph 骨骼: ",H)}return()=>{console.log("[Geo3DViewer] ModelLoader 注销 Model"),D.dispose(),w([])}}},[x]),React.useEffect(()=>{f&&F&&(console.log("[Geo3DViewer] ModelLoader 设定骨骼旋转"),F.forEach((D,W)=>{f.length>W?D.rotation=f[W]:D.rotation=EngineCore.Vector3.Zero()}),(!f||f.length===0)&&console.log("[Geo3DViewer] ModelLoader 的鼠标拾取功能由于 boneRotation 被禁用"))},[f,F]),React.useEffect(()=>{v.current&&(v.current.metadata={pickable:l?{name:e,onLeftClick:l.onLeftClick,onRightClick:l.onRightClick,onMiddleClick:l.onMiddleClick,onHover:l.onHover,valueCallback:null,extra:l.extra}:null})},[l,e]),React.useEffect(()=>{if(m&&x&&g.current){console.log("[Geo3DViewer] ModelLoader 创建容器: ",e);const D=new EngineCore.TransformNode(`amesh-model-${e}`);D.parent=g.current,x.rootNodes.forEach(K=>{K&&(K.parent=D)}),D.computeWorldMatrix(!0),EngineCore.PivotTools._RemoveAndStorePivotPoint(D);const W=D.parent;D.parent=null;const ae=EngineCore.Quaternion.RotationYawPitchRoll(D.rotation.y,D.rotation.x,D.rotation.z),ee=new EngineCore.Vector3(D.position.x,D.position.y,D.position.z);D.rotation.set(0,0,0),D.position.set(0,0,0);const H=D.getHierarchyBoundingVectors(!0),oe=H.max.subtract(H.min);k(oe.y),C(oe.z),A(oe.x),O(ae.toEulerAngles());const te=new EngineCore.Vector3((H.max.x+H.min.x)/2,(H.max.y+H.min.y)/2,(H.max.z+H.min.z)/2);return S(te),D.position=ee,D.rotationQuaternion=ae,D.parent=W,EngineCore.PivotTools._RestorePivotPoint(D),console.log("[Geo3DViewer] 创建 ModelLoader 鼠标拾取外框 ",e," 于 ",te," 大小为 ",oe.x,oe.y,oe.z),()=>{console.log("[Geo3DViewer] ModelLoader 注销容器: ",e),D.dispose()}}},[x,e,m]),React.useEffect(()=>{x&&x.rootNodes.forEach(D=>{D.getChildMeshes().forEach(W=>{W.material&&(W.material.transparencyMode=EngineCore.Material.MATERIAL_ALPHABLEND,W.material.alpha=c)})})},[x,c]),jsxRuntime.jsx("transformNode",{name:`transform-model-${e}`,position:n,rotation:a,scalingDeterminant:r,setEnabled:o,children:jsxRuntime.jsxs("transformNode",{name:`transform-model-global-${e}`,ref:g,scaling:s?new EngineCore.Vector3(L&&L.scalePlane?L.scalePlane:1,L&&L.scaleDepth?L.scaleDepth:1,L&&L.scalePlane?L.scalePlane:1):new EngineCore.Vector3(1,1,1),children:[d?jsxRuntime.jsx("transformNode",{name:`transform-model-label-${e}`,position:N.add(d!=null&&d.offset?d.offset.multiplyByFloats(L!=null&&L.scalePlane?L==null?void 0:L.scalePlane:1,1,L!=null&&L.scalePlane?L==null?void 0:L.scalePlane:1):EngineCore.Vector3.Zero()),scalingDeterminant:B?r*3:3,children:jsxRuntime.jsx(GUIText$1,{text:d.title,fontSize:d.fontSize?d.fontSize:40,color:d.color?d.color:"white"})}):jsxRuntime.jsx(jsxRuntime.Fragment,{}),jsxRuntime.jsx("box",{name:`pick-mesh-${e}`,ref:v,size:1,scaling:new EngineCore.Vector3(_,E,b).multiply(u),position:N,rotation:I,setEnabled:f?f.length===0:!0,children:jsxRuntime.jsx("standardMaterial",{name:`pick-mesh-${e}-mat`,alpha:i?.5:0})})]})})},ModelLoader$1=React.forwardRef(ModelLoader),ModelAnimationLoader=({name:e,url:t,position:n=EngineCore.Vector3.Zero(),rotation:a=EngineCore.Vector3.Zero(),localScale:r=1,visible:o=!0},i)=>{const s=reactBabylonjs.useScene(),l=useCachedModel({url:t}),c=React.useRef(null),[f,u]=React.useState(null);return React.useEffect(()=>{console.log("[Geo3DViewer] ModelLoader Loading: ",t)},[t]),React.useImperativeHandle(i,()=>c.current,[]),React.useEffect(()=>{if(l){const d=l.instantiateModelsToScene(h=>`${e}-${h}`,!0);return console.log("[Geo3DViewer] ModelLoader 实例化: ",e),u(d),()=>{console.log("[Geo3DViewer] ModelLoader 反实例化: ",e),u(null)}}},[l,e]),React.useEffect(()=>{s&&f&&c.current&&(s.animationGroups.forEach(d=>{console.log("play animtion:"+d.name),d.start(!0)}),f.rootNodes.forEach(d=>{d&&(d.parent=c.current)}))},[f,e,s]),jsxRuntime.jsx("transformNode",{name:`transform-model-${e}`,position:n,rotation:a,scalingDeterminant:r,setEnabled:o,ref:c})},ModleAnimationLoader=React.forwardRef(ModelAnimationLoader),Optimizer=()=>{const e=reactBabylonjs.useScene();return React.useEffect(()=>{if(e){const t=EngineCore.SceneOptimizerOptions.ModerateDegradationAllowed();t.optimizations;const n=new EngineCore.SceneOptimizer(e,t,!0,!0);return n.start(),console.log("[Geo3DViewer] 渐进式优化器已启动,如遭遇技术性渲染问题,请优先尝试禁用此优化器。"),()=>{n.stop(),n.dispose(),console.log("[Geo3DViewer] 渐进式优化器已停止。")}}},[e]),jsxRuntime.jsx(jsxRuntime.Fragment,{})},Optimizer$1=Optimizer,ParticleSystem=e=>{const{name:t,url:n,rootURL:a,doNotStart:r,capacity:o,position:i=new EngineCore.Vector3}=e,s=reactBabylonjs.useScene(),[l,c]=React.useState();return React.useEffect(()=>()=>{l&&l.dispose()},[l]),React.useEffect(()=>{if(s&&!l){const f=new EngineCore.AssetsManager(s),u=f.addTextFileTask(t!=null?t:"particle-system",n);f.load(),f.onFinish=function(d){console.log("task successful",d);const h=JSON.parse(u.text),m=EngineCore.ParticleSystem.Parse(h,s,a,r,o);m.emitter=i,c(m)}}return()=>{l&&(l.dispose(),console.log(t,"effect disposed!"))}},[o,r,t,l,i,a,s,n]),null},ParticleSystem$1=ParticleSystem,WaterEffect=e=>{const{id:t,position:n,useGPU:a=!0,renderAsFluid:r,numParticles:o=1e3,emitRate:i=1500*2,blendMode:s=EngineCore.ParticleSystem.BLENDMODE_ADD,color1:l,color2:c,colorDead:f,minSize:u,maxSize:d,minLifeTime:h,maxLifeTime:m,gravity:R,minEmitPower:v,maxEmitPower:g,updateSpeed:x,textureUrl:y,angle:E=Math.PI/2,radius:k=4,fluidRender:b}=e,C=reactBabylonjs.useScene(),[_,A]=React.useState(),N=React.useRef(null);return React.useEffect(()=>{_&&(_.blendMode=s,l&&(_.color1=l),c&&(_.color2=c),f&&(_.colorDead=f),u!==void 0&&(_.minSize=u),d!==void 0&&(_.maxSize=d),h!==void 0&&(_.minLifeTime=h),m!==void 0&&(_.maxLifeTime=m),v!==void 0&&(_.minEmitPower=v),g!==void 0&&(_.maxEmitPower=g),x!==void 0&&(_.updateSpeed=x),_.preWarmCycles=60*8,R&&(_.gravity=R),_.createConeEmitter(k,E),y&&(_.particleTexture=new EngineCore.Texture(y),_.particleTexture.onLoadObservable.add(()=>{_.start()})))},[E,s,l,c,f,R,g,m,d,v,h,u,_,k,y,x]),React.useEffect(()=>{if(!_&&C)if(a){const S=new EngineCore.GPUParticleSystem("particle-"+t,{capacity:o},C);A(S)}else{const S=new EngineCore.ParticleSystem("particle-"+t,o,C);A(S)}return()=>{console.log("particlesystem disposed!"),N.current&&(N.current.object.particleSize=0)}},[t,o,_,C,a]),React.useEffect(()=>{_&&(C==null||C.executeWhenReady(()=>{var S,I,O;if(C.updateTransformMatrix(!0),_==null||_.render(),r&&_){const F=C.enableFluidRenderer();if(F){F.addParticleSystem(_);const w=F.getRenderObjectFromParticleSystem(_);N.current=w,w&&(w.object.particleSize=(S=b==null?void 0:b.particleSize)!=null?S:.75,w.object.particleThicknessAlpha=.02,w.object.useTrueRenderingForDiffuseTexture=!0,w.targetRenderer.minimumThickness=w.object.particleThicknessAlpha,w.targetRenderer.blurDepthFilterSize=10,w.targetRenderer.blurDepthDepthScale=10,w.targetRenderer.thicknessMapSize=1024,w.targetRenderer.density=(I=b==null?void 0:b.density)!=null?I:8,w.targetRenderer.fresnelClamp=.04,w.targetRenderer.fluidColor=(O=b==null?void 0:b.fluidColor)!=null?O:new EngineCore.Color3(219/255,228/255,1),w.targetRenderer.generateDiffuseTexture=!1)}}}))},[b==null?void 0:b.density,b==null?void 0:b.fluidColor,b==null?void 0:b.particleSize,_,r,C]),React.useEffect(()=>{_&&(_.emitter=n,_.emitRate=i)},[i,_,n]),null},WaterEffect$1=WaterEffect,PlaneImage=(e,t)=>{var b,C,_;const n=reactBabylonjs.useScene(),a=React.useContext(WorkspaceMetaContext),{name:r,width:o,height:i,localScale:s=EngineCore.Vector3.One(),rotation:l=EngineCore.Vector3.Zero(),position:c=EngineCore.Vector3.Zero(),textureUrl:f,videoUrl:u,canvas:d,backFaceCulling:h=!0,billboard:m=!1,actions:R,labelStyle:v}=e,g=useCachedTexture({url:f}),x=React.useRef(null),y=React.useRef(null),[E,k]=React.useState(null);return React.useEffect(()=>{if(u)return k(A=>{A==null||A.dispose();const N=new EngineCore.VideoTexture("video-texture",u,n,!1,!1,void 0,{autoPlay:!0,autoUpdateTexture:!0});return N.hasAlpha=!0,N}),()=>{k(A=>(A==null||A.dispose(),null))}},[u]),React.useEffect(()=>{if(d){const A=new EngineCore.DynamicTexture("dyn-texture",d,n);return A.hasAlpha=!0,x.current=A,()=>{var N;(N=x.current)==null||N.dispose()}}},[d]),React.useEffect(()=>{x.current&&(x.current.name=r)},[r]),React.useImperativeHandle(t,()=>x,[x]),React.useEffect(()=>{var N;const A=(N=y.current)==null?void 0:N.getChildMeshes()[0];A&&(A.metadata={pickable:R?{name:r,onLeftClick:R.onLeftClick,onRightClick:R.onRightClick,onMiddleClick:R.onMiddleClick,onHover:R.onHover,extra:R.extra}:null})},[R,r]),jsxRuntime.jsxs("transformNode",{ref:y,name:`transform-planeimage-${r}`,position:c.multiply(a?new EngineCore.Vector3((b=a.scalePlane)!=null?b:1,(C=a.scaleDepth)!=null?C:1,(_=a.scalePlane)!=null?_:1):EngineCore.Vector3.One()),rotation:m?EngineCore.Vector3.Zero():l,billboardMode:m?EngineCore.Mesh.BILLBOARDMODE_ALL:EngineCore.Mesh.BILLBOARDMODE_NONE,children:[jsxRuntime.jsx("plane",{name:`plane-planeimage-${r}`,width:o,height:i,scaling:s,children:jsxRuntime.jsx("standardMaterial",{name:`plane-planeimage-${r}`,emissiveColor:EngineCore.Color3.White(),specularColor:EngineCore.Color3.Black(),diffuseTexture:x.current?x.current:E||g,useAlphaFromDiffuseTexture:!0,backFaceCulling:h,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND})}),v&&jsxRuntime.jsx(GUIText$1,{...v})]})},PlaneImage$1=React.forwardRef(PlaneImage);var PointClickZoneObjectType=(e=>(e[e.TETRAHEDRON=0]="TETRAHEDRON",e[e.OCTAHEDRON=1]="OCTAHEDRON",e[e.DODECAHEDRON=2]="DODECAHEDRON",e[e.ICOSAHEDRON=3]="ICOSAHEDRON",e[e.RHOMBICUBOCTAHEDRON=4]="RHOMBICUBOCTAHEDRON",e))(PointClickZoneObjectType||{});const PointClickZone=({size:e,alpha:t=1,position:n,visible:a,objectType:r,title:o,actions:i,labelStyle:s,color:l,scaleMode:c})=>{const f=React.useRef(null),u=React.useContext(WorkspaceMetaContext);React.useEffect(()=>{f.current&&(f.current.metadata={pickable:i?{name:o,onLeftClick:i.onLeftClick,onRightClick:i.onRightClick,onMiddleClick:i.onMiddleClick,onHover:i.onHover,extra:i.extra}:null})},[i,o]);const[d,h]=React.useState(1);return React.useEffect(()=>{switch(c){case ScaleMode.PLANE:h(u&&u.scalePlane?u.scalePlane:1);break;case ScaleMode.DEPTH:h(u&&u.scaleDepth?u.scaleDepth:1);break;case ScaleMode.NONE:h(1);break}},[u,c]),jsxRuntime.jsxs("transformNode",{setEnabled:a,name:`transform-spaceheat-${o}`,position:n.multiplyByFloats(u&&u.scalePlane?u.scalePlane:1,u&&u.scaleDepth?u.scaleDepth:1,u&&u.scalePlane?u.scalePlane:1),scalingDeterminant:d,children:[jsxRuntime.jsx("polyhedron",{ref:f,name:`point-${o}`,type:r,size:e,children:jsxRuntime.jsx("standardMaterial",{name:`point-${o}-mat`,backFaceCulling:!1,needDepthPrePass:!0,specularColor:new EngineCore.Color3(0,0,0),ambientColor:new EngineCore.Color3(1,1,1),emissiveColor:EngineCore.Color3.Black(),alphaMode:EngineCore.Engine.ALPHA_COMBINE,diffuseColor:l,alpha:t})}),jsxRuntime.jsx("transformNode",{name:`${o}-title`,position:s!=null&&s.offset?s.offset.multiplyByFloats(u!=null&&u.scalePlane?u==null?void 0:u.scalePlane:1,1,u!=null&&u.scalePlane?u==null?void 0:u.scalePlane:1):EngineCore.Vector3.Zero(),scaling:calcGUIScale(u).multiply(new EngineCore.Vector3(3,3,3)),children:jsxRuntime.jsx(GUIText$1,{text:o,fontSize:s!=null&&s.fontSize?s.fontSize:10,color:s!=null&&s.color?s.color:"white"})})]})},PointClickZone$1=PointClickZone,ProgressedAttributeBody=({name:e,url:t,offset:n=EngineCore.Vector3.Zero(),alpha:a,color:r,visible:o=!0,cutNormal:i,value:s,actions:l,textureOverride:c,progressTexture:f={},counterLine:u=void 0,lines:d=[],text:h=[],disableDepthWrite:m=!1,checkLines:R=[],checkLineWidth:v=4})=>{var te,K,Z,ce,Q,G,ge,fe,V,J,Re,Ce,Y,ue,ne,de,_e,ye,Te;const g=reactBabylonjs.useScene(),x=React.useRef(null),y=React.useContext(WorkspaceMetaContext),E=useCachedBinary({url:t,cacheType:CacheType.URL_PREFIX_MATCH}),[k,b]=React.useState(EngineCore.Vector3.Zero()),[C,_]=React.useState(void 0),A=useCachedTexture({url:c==null?void 0:c.texture,cacheType:CacheType.URL_PREFIX_MATCH}),N=useCachedTexture({url:c==null?void 0:c.sideTexture,cacheType:CacheType.URL_PREFIX_MATCH}),S=useCachedTexture({url:(te=f.segment1)==null?void 0:te.texture,cacheType:CacheType.URL_PREFIX_MATCH}),I=useCachedTexture({url:(K=f.segment1)==null?void 0:K.sideTexture,cacheType:CacheType.URL_PREFIX_MATCH}),O=useCachedTexture({url:(Z=f.segment2)==null?void 0:Z.texture,cacheType:CacheType.URL_PREFIX_MATCH}),F=useCachedTexture({url:(ce=f.segment2)==null?void 0:ce.sideTexture,cacheType:CacheType.URL_PREFIX_MATCH}),w=useCachedTexture({url:(Q=f.segment3)==null?void 0:Q.texture,cacheType:CacheType.URL_PREFIX_MATCH}),L=useCachedTexture({url:(G=f.segment3)==null?void 0:G.sideTexture,cacheType:CacheType.URL_PREFIX_MATCH}),B=useCachedTexture({url:(ge=f.segment4)==null?void 0:ge.texture,cacheType:CacheType.URL_PREFIX_MATCH}),D=useCachedTexture({url:(fe=f.segment4)==null?void 0:fe.sideTexture,cacheType:CacheType.URL_PREFIX_MATCH}),W=useCachedTexture({url:(V=f.segment5)==null?void 0:V.texture,cacheType:CacheType.URL_PREFIX_MATCH}),ae=useCachedTexture({url:(J=f.segment5)==null?void 0:J.sideTexture,cacheType:CacheType.URL_PREFIX_MATCH}),ee=useCachedTexture({url:(Re=f.segment6)==null?void 0:Re.texture,cacheType:CacheType.URL_PREFIX_MATCH}),H=useCachedTexture({url:(Ce=f.segment6)==null?void 0:Ce.sideTexture,cacheType:CacheType.URL_PREFIX_MATCH});React.useEffect(()=>{console.log("[Geo3DViewer] ProgressedAttributeBody Loading: ",t)},[t]),React.useEffect(()=>{if(g&&x.current&&t&&E){const Ee=x.current;EngineCore.Tags.EnableFor(Ee),EngineCore.Tags.AddTagsTo(Ee,"loading");const Se=VirtualVolume.decode(new Uint8Array(E)),{points:be,indices:Ae,value:Ie,center:Pe}=Se;Pe&&b(new EngineCore.Vector3(Pe.x,Pe.y,Pe.z));const Oe=new EngineCore.VertexData;Oe.positions=be,Oe.indices=Ae,Oe.colors=Ie;const Fe=[];EngineCore.VertexData.ComputeNormals(be,Ae,Fe),Oe.normals=Fe,Ee&&(Oe.applyToMesh(Ee),Ee.getScene().onAfterRenderObservable.addOnce(()=>{if(!Ee.isDisposed()){const re=Ee.getBoundingInfo();_(re.boundingBox)}})),EngineCore.Tags.RemoveTagsFrom(Ee,"loading")}},[t,g,E]);function oe(Ee,Se,be){const Ae=be.subtract(Se),Ie=Ee.subtract(Se),Pe=EngineCore.Vector3.Dot(EngineCore.Vector3.Normalize(Ae),EngineCore.Vector3.Normalize(Ie)),Oe=Ie.length()/Pe,Fe=Se.add(Ae.scale(Oe/EngineCore.Vector3.Distance(Se,be)));return EngineCore.Vector3.Distance(Ee,Fe)}return React.useEffect(()=>{x.current&&(x.current.metadata={pickable:l?{name:e,valueCallback:(Ee,Se,be)=>{if(console.log(e,Ee,Se,be),x.current&&Se){const Ae=x.current.getBoundingInfo().boundingBox;console.log(Ae);for(let Ie=0;Ie<R.length;Ie++){const Pe=R[Ie];if(oe(new EngineCore.Vector3(Se.x,0,Se.z),Pe.start,Pe.end)<v){const Fe=[];for(let M=0;M<11;M++){const re=Pe.end.subtract(Pe.start),se=Pe.start.add(re.scale(M/10)),me=new EngineCore.Vector3(se.x,Se.y+Ae.extendSize.y*4,se.z),z=new EngineCore.Vector3(se.x,Se.y+Ae.extendSize.y*2,se.z),X=EngineCore.Vector3.Normalize(z.subtract(me)),T=Ae.extendSize.y*10,ie=new EngineCore.Ray(me,X,T),xe=g==null?void 0:g.pickWithRay(ie,p=>p===x.current);xe!=null&&xe.hit&&xe.pickedPoint&&Fe.push(xe.pickedPoint)}for(let M=0;M<11;M++){const re=Pe.end.subtract(Pe.start),se=Pe.start.add(re.scale(M/10)),me=new EngineCore.Vector3(se.x,Se.y-Ae.extendSize.y*4,se.z),z=new EngineCore.Vector3(se.x,Se.y-Ae.extendSize.y*2,se.z),X=EngineCore.Vector3.Normalize(z.subtract(me)),T=Ae.extendSize.y*10,ie=new EngineCore.Ray(me,X,T),xe=g==null?void 0:g.pickWithRay(ie,p=>p===x.current);xe!=null&&xe.hit&&xe.pickedPoint&&Fe.push(xe.pickedPoint)}return{value:Ie,points:Fe}}}}},onLeftClick:l.onLeftClick,onRightClick:l.onRightClick,onMiddleClick:l.onMiddleClick,onHover:l.onHover,extra:l.extra}:null})},[l,e,R]),jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx("transformNode",{name:`transform-progressedattribute-${e}`,position:k.add(n).multiplyByFloats(y&&y.scalePlane?y.scalePlane:1,y&&y.scaleDepth?y.scaleDepth:1,y&&y.scalePlane?y.scalePlane:1),scaling:new EngineCore.Vector3(y?y.scalePlane:1,y?y.scaleDepth:1,y?y.scalePlane:1),children:jsxRuntime.jsx("mesh",{name:`attributebody-${e}-mesh`,ref:x,setEnabled:o,useVertexColors:!A,alwaysSelectAsActiveMesh:!0,children:C&&origin?A?jsxRuntime.jsx(ProgressedRepeatedTextureMaterial,{name:`progressedattributebody-${e}-mat`,backFaceCulling:!0,needDepthPrePass:!1,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,alphaMode:EngineCore.Engine.ALPHA_COMBINE,texture:A,sideTexture:N,alphaStage:a,cutNormal:i,value:s,boundingBox:C,tilingFactor:c==null?void 0:c.tilingFactor,textureFlatRotate:c==null?void 0:c.flatModeRotate,sideTilingFactor:(Y=c==null?void 0:c.sideTilingFactor)!=null?Y:c==null?void 0:c.tilingFactor,mode:c==null?void 0:c.mode,overlay:{texture1:S,sideTexture1:I,texture2:O,sideTexture2:F,texture3:w,sideTexture3:L,texture4:B,sideTexture4:D,texture5:W,sideTexture5:ae,texture6:ee,sideTexture6:H,color1:(ue=f.segment1)==null?void 0:ue.color,color2:(ne=f.segment2)==null?void 0:ne.color,color3:(de=f.segment3)==null?void 0:de.color,color4:(_e=f.segment4)==null?void 0:_e.color,color5:(ye=f.segment5)==null?void 0:ye.color,color6:(Te=f.segment6)==null?void 0:Te.color},scaleDepth:y?y.scaleDepth:1,scalePlane:y?y.scalePlane:1,counterLine:u,lines:d,text:h,disableDepthWrite:m}):r?jsxRuntime.jsx(ProgressedRemapColorByRedChannelMaterial,{name:`progressedattributebody-${e}-mat`,backFaceCulling:!0,needDepthPrePass:!1,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,alphaMode:EngineCore.Engine.ALPHA_COMBINE,colorCodec:r,alphaStage:a,cutNormal:i,value:s,boundingBox:C,scaleDepth:y?y.scaleDepth:1,scalePlane:y?y.scalePlane:1,counterLine:u,lines:d,text:h,disableDepthWrite:m}):jsxRuntime.jsx(jsxRuntime.Fragment,{}):jsxRuntime.jsx(jsxRuntime.Fragment,{})})})})},ProgressedAttributeBody$1=ProgressedAttributeBody,RayClick=({onPick:e,pickAll:t=!1})=>{const n=reactBabylonjs.useScene(),a=React.useContext(WorkspaceMetaContext),r=React.useRef(null),o=React.useRef([]),i=React.useRef(!1),s=React.useCallback(d=>{if(!d){e(null);return}let h=1,m=1;a&&(a.scalePlane&&(h=a.scalePlane),a.scaleDepth&&(m=a.scaleDepth)),e(new EngineCore.Vector3(d.x/h,d.y/m,d.z/h))},[a,e]),l=React.useCallback(()=>{if(!n)return[];const d=n.meshes.filter(m=>!!m&&!m.isDisposed()&&m.isPickable&&m.isVisible&&m.isEnabled()&&m.isReady(!0)),h=d.length!==o.current.length||d.some((m,R)=>o.current[R]!==m);return r.current||(r.current=new gpuPicker.GPUPicker),h&&(r.current.setPickingList(d.length>0?d.slice():null),o.current=d),d},[n]),c=React.useCallback(async()=>{if(!n||i.current||n.skipPointerMovePicking)return;if(!l().length||!r.current){e(null);return}i.current=!0;try{const h=await r.current.pickAsync(n.pointerX,n.pointerY,!1),m=h==null?void 0:h.mesh;if(!m){e(null);return}const R=n.pick(n.pointerX,n.pointerY,v=>v.uniqueId===m.uniqueId,!1,void 0);if(!(R!=null&&R.pickedPoint)){e(null);return}s(R.pickedPoint)}finally{i.current=!1}},[s,e,n,l]),f=React.useCallback(()=>{var h;if(!n||n.skipPointerMovePicking)return;const d=n.pick(n.pointerX,n.pointerY,void 0,!1,void 0);s((h=d==null?void 0:d.pickedPoint)!=null?h:null)},[s,n]),u=React.useCallback(d=>{switch(d.type){case EngineCore.PointerEventTypes.POINTERUP:{t?f():c();break}}},[t,f,c]);return React.useEffect(()=>{if(n){const d=n.onPointerObservable.add(u);return()=>{n.onPointerObservable.remove(d)}}},[u,n]),React.useEffect(()=>()=>{var d;(d=r.current)==null||d.dispose(),r.current=null,o.current=[],i.current=!1},[]),jsxRuntime.jsx(jsxRuntime.Fragment,{})},RayClick$1=RayClick,RibbonLayer=({name:e,paths:t,color:n,alpha:a,sideOrientation:r=MaterialSideOrientation.CounterClockWiseSideOrientation,position:o=EngineCore.Vector3.Zero(),rotation:i=EngineCore.Vector3.Zero(),scaling:s=EngineCore.Vector3.One(),backFaceCulling:l=!1,labelStyle:c,showLayerLabel:f=!1,actions:u})=>{const d=React.useContext(WorkspaceMetaContext),h=calcTransformNodeScale(d),m=React.useRef(null),[R,v]=React.useState();return React.useEffect(()=>{if(m.current){const g=m.current.getBoundingInfo();v(g.boundingBox.centerWorld)}},[t,o,i,s]),React.useEffect(()=>{m.current&&(m.current.metadata={pickable:u?{name:e,onLeftClick:u.onLeftClick,onRightClick:u.onRightClick,onMiddleClick:u.onMiddleClick,onHover:u.onHover,extra:u.extra}:null})},[u,e]),jsxRuntime.jsxs("transformNode",{name:`${e}-transform`,position:o.multiply(h),rotation:i,scaling:s.multiply(h),children:[jsxRuntime.jsx("ribbon",{name:`${e}-transform`,pathArray:t,updatable:!0,ref:m,sideOrientation:r,children:jsxRuntime.jsx("standardMaterial",{name:`${e}-material`,diffuseColor:n,alpha:a,specularColor:EngineCore.Color3.Black(),ambientColor:EngineCore.Color3.White(),transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,backFaceCulling:l})}),e&&R&&jsxRuntime.jsx("transformNode",{name:`${e}-title`,position:R.add(c!=null&&c.offset?c.offset.multiplyByFloats(d!=null&&d.scalePlane?d==null?void 0:d.scalePlane:1,1,d!=null&&d.scalePlane?d==null?void 0:d.scalePlane:1):EngineCore.Vector3.Zero()),scaling:calcGUIScale(d).multiply(new EngineCore.Vector3(3,3,3)),setEnabled:f,children:jsxRuntime.jsx(GUIText$1,{text:e,fontSize:c!=null&&c.fontSize?c.fontSize:40,color:c!=null&&c.color?c.color:"white"})})]})},RibbonLayer$1=RibbonLayer,percentFragmentSource=`#ifdef GL_ES
1228
1228
  precision highp float;
1229
1229
  #endif
@@ -14713,7 +14713,7 @@ const FreeTypeText$1 = FreeTypeText, GUIText = (e) => {
14713
14713
  }
14714
14714
  const te = new VertexData(), Q = new Float32Array(L.length + ie.length);
14715
14715
  let J = B.length + ee.length;
14716
- J = J + (W.length - 1) * 6;
14716
+ J = J + ((W.length < 1 ? 1 : W.length) - 1) * 6;
14717
14717
  const ce = new Int32Array(J), j = new Float32Array(D.length + oe.length);
14718
14718
  Q.set(L), ce.set(B), j.set(D), Q.set(ie, L.length), ce.set(ee, B.length), j.set(oe, D.length);
14719
14719
  const G = [];
@@ -17778,7 +17778,7 @@ const ResourceContext = createContext(void 0), useAsset = (e, t = "BIN") => {
17778
17778
  return useEffect(() => {
17779
17779
  console.log(
17780
17780
  `
17781
- %c Geo3DViewer Library %c Version: 1.7.32 %c
17781
+ %c Geo3DViewer Library %c Version: 1.7.33 %c
17782
17782
  `,
17783
17783
  "color:#e0e0e0;background:#873e23;padding:5px 0;border-top-left-radius:5px;border-bottom-left-radius:5px;",
17784
17784
  "color:#455a64;background:#e0e0e0;padding:5px 0;",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pan-ya/libgeo3dviewer",
3
- "version": "1.7.32",
3
+ "version": "1.7.33",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite",