@crystaldesign/real-time-viewer-next 26.13.0-beta.2 → 26.13.0-beta.3

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.
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see 114.real-time-viewer-next.umd.min.js.LICENSE.txt */
2
- "use strict";(self.webpackChunkCrystaldesignRealTimeViewerNext=self.webpackChunkCrystaldesignRealTimeViewerNext||[]).push([[114],{3114:(r,t,a)=>{a.r(t),a.d(t,{SunLensflare:()=>SunLensflare});var o=a(7080),i=a(7363),u=a(3946),c=a(4088),l=a(6831),d=a(8614),p=a(6514),m=a(7514);function _createForOfIteratorHelper(r,t){var a="undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(!a){if(Array.isArray(r)||(a=function _unsupportedIterableToArray(r,t){if(r){if("string"==typeof r)return _arrayLikeToArray(r,t);var a={}.toString.call(r).slice(8,-1);return"Object"===a&&r.constructor&&(a=r.constructor.name),"Map"===a||"Set"===a?Array.from(r):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?_arrayLikeToArray(r,t):void 0}}(r))||t&&r&&"number"==typeof r.length){a&&(r=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=r.length?{done:!0}:{done:!1,value:r[o++]}},e:function e(r){throw r},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var u,c=!0,l=!1;return{s:function s(){a=a.call(r)},n:function n(){var r=a.next();return c=r.done,r},e:function e(r){l=!0,u=r},f:function f(){try{c||null==a.return||a.return()}finally{if(l)throw u}}}}function _arrayLikeToArray(r,t){(null==t||t>r.length)&&(t=r.length);for(var a=0,o=Array(t);a<t;a++)o[a]=r[a];return o}var v=256,y=[[0,1],[.04,.8],[.12,.36],[.3,.13],[.6,.035],[1,0]],h=[[0,.55],[.35,.2],[.7,.04],[1,0]],g=[[0,0],[.55,0],[.72,.45],[.8,.5],[.9,.12],[1,0]];function drawFlareSprite(r){var t=document.createElement("canvas");t.width=v,t.height=v;var a=t.getContext("2d");if(!a)return t;var i,u=128,c=a.createRadialGradient(u,u,0,u,u,u),l=_createForOfIteratorHelper(r);try{for(l.s();!(i=l.n()).done;){var d=(0,o.Z)(i.value,2),p=d[0],m=d[1];c.addColorStop(p,"rgba(255,246,232,".concat(m,")"))}}catch(r){l.e(r)}finally{l.f()}return a.fillStyle=c,a.fillRect(0,0,v,v),t}function drawHexSprite(){var r=document.createElement("canvas");r.width=v,r.height=v;var t=r.getContext("2d");if(!t)return r;var a=128,i=102.4;t.save(),t.translate(512,0),t.shadowOffsetX=-512,t.shadowBlur=12.8,t.shadowColor="rgba(255,246,232,1)",t.beginPath();for(var u=0;u<6;u++){var c=Math.PI/3*u+Math.PI/6,l=a+Math.cos(c)*i,d=a+Math.sin(c)*i;0===u?t.moveTo(l,d):t.lineTo(l,d)}t.closePath(),t.fillStyle="rgba(255,246,232,1)",t.fill(),t.restore();for(var p=t.createRadialGradient(a,a,0,a,a,i),m=0,y=[[0,.35],[.55,.45],[.85,1],[1,.8]];m<y.length;m++){var h=(0,o.Z)(y[m],2),g=h[0],w=h[1];p.addColorStop(g,"rgba(255,255,255,".concat(w,")"))}return t.globalCompositeOperation="destination-in",t.fillStyle=p,t.fillRect(0,0,v,v),r}var w=[{mapIndex:0,size:1e3,along:0,opacity:1},{mapIndex:2,size:70,along:.16,opacity:.5,tint:"#ffd9a0"},{mapIndex:2,size:130,along:.45,opacity:.35,tint:"#9fd8ff"},{mapIndex:3,size:210,along:.52,opacity:.3,tint:"#ffe9c8"},{mapIndex:1,size:70,along:.68,opacity:.5,tint:"#ffb37d"},{mapIndex:1,size:60,along:1,opacity:.5}],M=.018,S=[[0,0,2],[1,0,1],[-1,0,1],[0,1,1],[0,-1,1],[.7071,.7071,1],[-.7071,.7071,1],[.7071,-.7071,1],[-.7071,-.7071,1]];function SunLensflare(r){var t=r.sunDirection,a=r.color,v=void 0===a?"#ffffff":a,b=r.distanceScale,x=void 0===b?1:b,I=r.sizeScale,R=void 0===I?1:I,P=r.occlusionEnabled,z=void 0===P||P,k=r.occludersRevision,C=void 0===k?0:k,j=(0,c.D)((function(r){return r.scene})),A=(0,i.useMemo)((function(){return[drawFlareSprite(y),drawFlareSprite(h),drawHexSprite(),drawFlareSprite(g)].map((function(r){var t=new l.ROQ(r);return t.colorSpace=l.KI_,t}))}),[]);(0,i.useEffect)((function(){return function(){A.forEach((function(r){return r.dispose()}))}}),[A]);var T=(0,i.useRef)(null),O=(0,i.useRef)([]),L=(0,i.useMemo)((function(){return new l.Pa4}),[]),_=(0,i.useMemo)((function(){return new l.Pa4}),[]),E=(0,i.useMemo)((function(){return new l.Pa4}),[]),V=(0,i.useMemo)((function(){return new l.Pa4}),[]),H=(0,i.useMemo)((function(){return new l.Pa4}),[]),Z=(0,i.useMemo)((function(){return new l.Pa4}),[]),W=(0,i.useMemo)((function(){return new l.Pa4}),[]),B=(0,i.useMemo)((function(){return new l.Pa4}),[]),G=(0,i.useMemo)((function(){return new l.Pa4}),[]),Q=(0,i.useMemo)((function(){return new l.Pa4}),[]),q=(0,i.useMemo)((function(){var r=new l.iMs;return r.near=.1,r.far=1e4,r.firstHitOnly=!0,r}),[]),D=(0,i.useRef)([]),N=(0,i.useRef)(1),X=(0,i.useRef)(0),K=(0,i.useRef)(0),U=(0,i.useRef)(0),Y=(0,i.useRef)([]),$=(0,i.useRef)(null),J=Math.max(10,200*x),ee=(0,i.useMemo)((function(){var r=new l.Ilk(v);return w.map((function(t){var a;return new l.Ilk(null!==(a=t.tint)&&void 0!==a?a:"#ffffff").multiply(r)}))}),[v]);return(0,c.F)((function(r){var a=r.camera,i=T.current;if(i){a.getWorldPosition(E),_.set(t[0],t[1],t[2]).normalize(),L.copy(_).multiplyScalar(J).add(E),V.copy(L).applyMatrix4(a.matrixWorldInverse);var u=function viewZInFront(r){return r<0}(V.z);if(z){H.set(1,0,0).applyQuaternion(a.quaternion).normalize(),Z.set(0,1,0).applyQuaternion(a.quaternion).normalize();var c=U.current++;if(u&&c%3==0){$.current!==C&&($.current=C,(0,d.B5)(),Y.current=(0,p.L)(j).meshes);for(var l=Y.current,m=0,v=0,y=0,h=0,g=0,b=0;b<S.length;b++){var x=(0,o.Z)(S[b],3),I=x[0],R=x[1],P=x[2];W.copy(_).addScaledVector(H,I*M).addScaledVector(Z,R*M).normalize(),q.set(E,W);for(var k=D.current,A=!1,ee=0;ee<l.length&&!A;ee++)k.length=0,q.intersectObject(l[ee],!1,k),A=k.length>0;var re=A?0:1;m+=P,v+=re*P,y+=I*re*P,h+=R*re*P,0===b&&(g=re)}var ne=.4*(m>0?v/m:0)+.6*g,te=v>1e-4?y/v:0,ae=v>1e-4?h/v:0,oe=N.current,ie=ne<oe?.55:.2;N.current=Math.min(1,Math.max(0,oe+(ne-oe)*ie)),X.current+=.2*(te-X.current),K.current+=.2*(ae-K.current)}else u||(N.current*=1-.55);var ue=J*M*.75;B.copy(H).multiplyScalar(X.current*ue).addScaledVector(Z,K.current*ue),Q.copy(L).add(B)}else N.current=u?1:0,X.current=0,K.current=0,Q.copy(L);var ce=N.current;if(i.visible=u&&ce>.01,i.visible){i.position.copy(Q),V.copy(Q).project(a);var le=V.x,fe=V.y,se=1-(Math.hypot(le,fe)-.35)/1.15;se=(se=Math.min(1,Math.max(0,se)))*se*(3-2*se);for(var de=i.children.length,pe=0;pe<de;pe++){var me=w[pe],ve=i.children[pe],ye=1-2*me.along;G.set(le*ye,fe*ye,.5).unproject(a).sub(E).normalize(),ve.position.copy(G).multiplyScalar(J).add(E).sub(i.position);var he=O.current[pe];he&&(he.opacity=me.opacity*ce*(0===me.along?1:se))}}}})),(0,m.jsx)("group",{ref:T,frustumCulled:!1,children:w.map((function(r,t){var a=.022222222222222223*r.size*R;return(0,m.jsx)("group",{children:(0,m.jsx)(u.V,{follow:!0,lockX:!1,lockY:!1,lockZ:!1,children:(0,m.jsxs)("mesh",{renderOrder:1e4,children:[(0,m.jsx)("planeGeometry",{args:[a,a]}),(0,m.jsx)("meshBasicMaterial",{ref:function ref(r){O.current[t]=r},map:A[r.mapIndex],color:ee[t],transparent:!0,opacity:r.opacity,depthTest:!1,depthWrite:!1,toneMapped:!1,blending:l.WMw})]})})},t)}))})}}}]);
2
+ "use strict";(self.webpackChunkCrystaldesignRealTimeViewerNext=self.webpackChunkCrystaldesignRealTimeViewerNext||[]).push([[114],{3114:(r,t,a)=>{a.r(t),a.d(t,{SunLensflare:()=>SunLensflare});var o=a(7080),i=a(7363),u=a(3946),c=a(4088),l=a(6831),d=a(7756),p=a(6514),m=a(7514);function _createForOfIteratorHelper(r,t){var a="undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(!a){if(Array.isArray(r)||(a=function _unsupportedIterableToArray(r,t){if(r){if("string"==typeof r)return _arrayLikeToArray(r,t);var a={}.toString.call(r).slice(8,-1);return"Object"===a&&r.constructor&&(a=r.constructor.name),"Map"===a||"Set"===a?Array.from(r):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?_arrayLikeToArray(r,t):void 0}}(r))||t&&r&&"number"==typeof r.length){a&&(r=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=r.length?{done:!0}:{done:!1,value:r[o++]}},e:function e(r){throw r},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var u,c=!0,l=!1;return{s:function s(){a=a.call(r)},n:function n(){var r=a.next();return c=r.done,r},e:function e(r){l=!0,u=r},f:function f(){try{c||null==a.return||a.return()}finally{if(l)throw u}}}}function _arrayLikeToArray(r,t){(null==t||t>r.length)&&(t=r.length);for(var a=0,o=Array(t);a<t;a++)o[a]=r[a];return o}var v=256,y=[[0,1],[.04,.8],[.12,.36],[.3,.13],[.6,.035],[1,0]],h=[[0,.55],[.35,.2],[.7,.04],[1,0]],g=[[0,0],[.55,0],[.72,.45],[.8,.5],[.9,.12],[1,0]];function drawFlareSprite(r){var t=document.createElement("canvas");t.width=v,t.height=v;var a=t.getContext("2d");if(!a)return t;var i,u=128,c=a.createRadialGradient(u,u,0,u,u,u),l=_createForOfIteratorHelper(r);try{for(l.s();!(i=l.n()).done;){var d=(0,o.Z)(i.value,2),p=d[0],m=d[1];c.addColorStop(p,"rgba(255,246,232,".concat(m,")"))}}catch(r){l.e(r)}finally{l.f()}return a.fillStyle=c,a.fillRect(0,0,v,v),t}function drawHexSprite(){var r=document.createElement("canvas");r.width=v,r.height=v;var t=r.getContext("2d");if(!t)return r;var a=128,i=102.4;t.save(),t.translate(512,0),t.shadowOffsetX=-512,t.shadowBlur=12.8,t.shadowColor="rgba(255,246,232,1)",t.beginPath();for(var u=0;u<6;u++){var c=Math.PI/3*u+Math.PI/6,l=a+Math.cos(c)*i,d=a+Math.sin(c)*i;0===u?t.moveTo(l,d):t.lineTo(l,d)}t.closePath(),t.fillStyle="rgba(255,246,232,1)",t.fill(),t.restore();for(var p=t.createRadialGradient(a,a,0,a,a,i),m=0,y=[[0,.35],[.55,.45],[.85,1],[1,.8]];m<y.length;m++){var h=(0,o.Z)(y[m],2),g=h[0],w=h[1];p.addColorStop(g,"rgba(255,255,255,".concat(w,")"))}return t.globalCompositeOperation="destination-in",t.fillStyle=p,t.fillRect(0,0,v,v),r}var w=[{mapIndex:0,size:1e3,along:0,opacity:1},{mapIndex:2,size:70,along:.16,opacity:.5,tint:"#ffd9a0"},{mapIndex:2,size:130,along:.45,opacity:.35,tint:"#9fd8ff"},{mapIndex:3,size:210,along:.52,opacity:.3,tint:"#ffe9c8"},{mapIndex:1,size:70,along:.68,opacity:.5,tint:"#ffb37d"},{mapIndex:1,size:60,along:1,opacity:.5}],M=.018,S=[[0,0,2],[1,0,1],[-1,0,1],[0,1,1],[0,-1,1],[.7071,.7071,1],[-.7071,.7071,1],[.7071,-.7071,1],[-.7071,-.7071,1]];function SunLensflare(r){var t=r.sunDirection,a=r.color,v=void 0===a?"#ffffff":a,b=r.distanceScale,x=void 0===b?1:b,I=r.sizeScale,R=void 0===I?1:I,P=r.occlusionEnabled,z=void 0===P||P,k=r.occludersRevision,C=void 0===k?0:k,j=(0,c.D)((function(r){return r.scene})),A=(0,i.useMemo)((function(){return[drawFlareSprite(y),drawFlareSprite(h),drawHexSprite(),drawFlareSprite(g)].map((function(r){var t=new l.ROQ(r);return t.colorSpace=l.KI_,t}))}),[]);(0,i.useEffect)((function(){return function(){A.forEach((function(r){return r.dispose()}))}}),[A]);var T=(0,i.useRef)(null),O=(0,i.useRef)([]),L=(0,i.useMemo)((function(){return new l.Pa4}),[]),_=(0,i.useMemo)((function(){return new l.Pa4}),[]),E=(0,i.useMemo)((function(){return new l.Pa4}),[]),V=(0,i.useMemo)((function(){return new l.Pa4}),[]),H=(0,i.useMemo)((function(){return new l.Pa4}),[]),Z=(0,i.useMemo)((function(){return new l.Pa4}),[]),W=(0,i.useMemo)((function(){return new l.Pa4}),[]),B=(0,i.useMemo)((function(){return new l.Pa4}),[]),G=(0,i.useMemo)((function(){return new l.Pa4}),[]),Q=(0,i.useMemo)((function(){return new l.Pa4}),[]),q=(0,i.useMemo)((function(){var r=new l.iMs;return r.near=.1,r.far=1e4,r.firstHitOnly=!0,r}),[]),D=(0,i.useRef)([]),N=(0,i.useRef)(1),X=(0,i.useRef)(0),K=(0,i.useRef)(0),U=(0,i.useRef)(0),Y=(0,i.useRef)([]),$=(0,i.useRef)(null),J=Math.max(10,200*x),ee=(0,i.useMemo)((function(){var r=new l.Ilk(v);return w.map((function(t){var a;return new l.Ilk(null!==(a=t.tint)&&void 0!==a?a:"#ffffff").multiply(r)}))}),[v]);return(0,c.F)((function(r){var a=r.camera,i=T.current;if(i){a.getWorldPosition(E),_.set(t[0],t[1],t[2]).normalize(),L.copy(_).multiplyScalar(J).add(E),V.copy(L).applyMatrix4(a.matrixWorldInverse);var u=function viewZInFront(r){return r<0}(V.z);if(z){H.set(1,0,0).applyQuaternion(a.quaternion).normalize(),Z.set(0,1,0).applyQuaternion(a.quaternion).normalize();var c=U.current++;if(u&&c%3==0){$.current!==C&&($.current=C,(0,d.B5)(),Y.current=(0,p.L)(j).meshes);for(var l=Y.current,m=0,v=0,y=0,h=0,g=0,b=0;b<S.length;b++){var x=(0,o.Z)(S[b],3),I=x[0],R=x[1],P=x[2];W.copy(_).addScaledVector(H,I*M).addScaledVector(Z,R*M).normalize(),q.set(E,W);for(var k=D.current,A=!1,ee=0;ee<l.length&&!A;ee++)k.length=0,q.intersectObject(l[ee],!1,k),A=k.length>0;var re=A?0:1;m+=P,v+=re*P,y+=I*re*P,h+=R*re*P,0===b&&(g=re)}var ne=.4*(m>0?v/m:0)+.6*g,te=v>1e-4?y/v:0,ae=v>1e-4?h/v:0,oe=N.current,ie=ne<oe?.55:.2;N.current=Math.min(1,Math.max(0,oe+(ne-oe)*ie)),X.current+=.2*(te-X.current),K.current+=.2*(ae-K.current)}else u||(N.current*=1-.55);var ue=J*M*.75;B.copy(H).multiplyScalar(X.current*ue).addScaledVector(Z,K.current*ue),Q.copy(L).add(B)}else N.current=u?1:0,X.current=0,K.current=0,Q.copy(L);var ce=N.current;if(i.visible=u&&ce>.01,i.visible){i.position.copy(Q),V.copy(Q).project(a);var le=V.x,fe=V.y,se=1-(Math.hypot(le,fe)-.35)/1.15;se=(se=Math.min(1,Math.max(0,se)))*se*(3-2*se);for(var de=i.children.length,pe=0;pe<de;pe++){var me=w[pe],ve=i.children[pe],ye=1-2*me.along;G.set(le*ye,fe*ye,.5).unproject(a).sub(E).normalize(),ve.position.copy(G).multiplyScalar(J).add(E).sub(i.position);var he=O.current[pe];he&&(he.opacity=me.opacity*ce*(0===me.along?1:se))}}}})),(0,m.jsx)("group",{ref:T,frustumCulled:!1,children:w.map((function(r,t){var a=.022222222222222223*r.size*R;return(0,m.jsx)("group",{children:(0,m.jsx)(u.V,{follow:!0,lockX:!1,lockY:!1,lockZ:!1,children:(0,m.jsxs)("mesh",{renderOrder:1e4,children:[(0,m.jsx)("planeGeometry",{args:[a,a]}),(0,m.jsx)("meshBasicMaterial",{ref:function ref(r){O.current[t]=r},map:A[r.mapIndex],color:ee[t],transparent:!0,opacity:r.opacity,depthTest:!1,depthWrite:!1,toneMapped:!1,blending:l.WMw})]})})},t)}))})}}}]);
@@ -0,0 +1,2 @@
1
+ /*! For license information please see 699.real-time-viewer-next.umd.min.js.LICENSE.txt */
2
+ "use strict";(self.webpackChunkCrystaldesignRealTimeViewerNext=self.webpackChunkCrystaldesignRealTimeViewerNext||[]).push([[699],{1699:(t,r,a)=>{a.r(r),a.d(r,{WaterSurface:()=>WaterSurface});var o=a(7080),i=a(7363),l=a(7620),c=a(4088),u=a(6831),h=a(5590),d=a(7582),v=a(5150),p=a(2942);function _createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=function _unsupportedIterableToArray(t,r){if(t){if("string"==typeof t)return _arrayLikeToArray(t,r);var a={}.toString.call(t).slice(8,-1);return"Object"===a&&t.constructor&&(a=t.constructor.name),"Map"===a||"Set"===a?Array.from(t):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?_arrayLikeToArray(t,r):void 0}}(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var l,c=!0,u=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return c=t.done,t},e:function e(t){u=!0,l=t},f:function f(){try{c||null==a.return||a.return()}finally{if(u)throw l}}}}function _arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=Array(r);a<r;a++)o[a]=t[a];return o}var m=function(){return(0,d.Z)((function PoolHeightMap(){(0,h.Z)(this,PoolHeightMap),(0,v.Z)(this,"rt",void 0),(0,v.Z)(this,"overrideMaterial",void 0),(0,v.Z)(this,"camera",void 0),(0,v.Z)(this,"lastCenter",new u.Pa4(1/0,1/0,1/0)),(0,v.Z)(this,"lastHalf",new u.Pa4(0,0,0)),(0,v.Z)(this,"lastGeometryVersion",-1),(0,v.Z)(this,"age",120),this.rt=new u.dd2(256,256,{type:u.cLu,format:u.wk1,depthBuffer:!0,stencilBuffer:!1,minFilter:u.wem,magFilter:u.wem}),this.camera=new u.iKG(-1,1,1,-1,.01,1),this.overrideMaterial=new u.jyz({vertexShader:"\n uniform vec3 uVolumeCenter;\n uniform vec3 uPoolHalf;\n varying float vHeightEncoded;\n void main() {\n vec4 worldPosition = vec4(position, 1.0);\n #ifdef USE_INSTANCING\n worldPosition = instanceMatrix * worldPosition;\n #endif\n worldPosition = modelMatrix * worldPosition;\n vHeightEncoded = (worldPosition.y - uVolumeCenter.y + uPoolHalf.y) / (3.0 * uPoolHalf.y);\n gl_Position = projectionMatrix * viewMatrix * worldPosition;\n }\n",fragmentShader:"\n varying float vHeightEncoded;\n void main() {\n gl_FragColor = vec4(vHeightEncoded, 0.0, 0.0, 1.0);\n }\n",uniforms:{uVolumeCenter:{value:new u.Pa4},uPoolHalf:{value:new u.Pa4(1,1,1)}},side:u.ehD})}),[{key:"texture",get:function get(){return this.rt.texture}},{key:"updateCamera",value:function updateCamera(t,r){var a=this.camera;a.up.set(0,0,-1),a.position.set(t.x,t.y+.3,t.z),a.lookAt(t.x,t.y-r.y,t.z),a.left=-r.x,a.right=r.x,a.top=-r.z,a.bottom=r.z,a.near=.01,a.far=.3+r.y+.5,a.updateProjectionMatrix(),a.updateMatrixWorld(!0)}},{key:"renderIfNeeded",value:function renderIfNeeded(t,r,a,o,i,l){var c=this;if(this.age+=1,!(i!==this.lastGeometryVersion||!a.equals(this.lastCenter)||!o.equals(this.lastHalf)||this.age>=120))return!1;this.overrideMaterial.uniforms.uVolumeCenter.value.copy(a),this.overrideMaterial.uniforms.uPoolHalf.value.copy(o),this.updateCamera(a,o);var h,d=[],v=_createForOfIteratorHelper(l);try{for(v.s();!(h=v.n()).done;){var m=h.value;m&&m.visible&&(m.visible=!1,d.push(m))}}catch(t){v.e(t)}finally{v.f()}r.traverse((function(t){var r=t;if(t.visible){if(r.isLine||r.isPoints||r.isSprite)return t.visible=!1,void d.push(t);if(r.isMesh){var a=t,o=a.material,i=function receives(t){if(!(t instanceof u.Wid))return!1;if(t.transparent||t.opacity<1)return!1;var r=t.transmission;return!("number"==typeof r&&r>0)};(Array.isArray(o)?o.some(i):i(o))||(a.visible=!1,d.push(a))}}}));var g=r.overrideMaterial,y=r.background;try{(0,p.s)(t,{target:this.rt,clearColor:0,clearAlpha:1},(function(){t.clear(!0,!0,!1),r.background=null,r.overrideMaterial=c.overrideMaterial,t.render(r,c.camera)}))}finally{r.overrideMaterial=g,r.background=y;for(var x=0,w=d;x<w.length;x++){w[x].visible=!0}}return this.lastCenter.copy(a),this.lastHalf.copy(o),this.lastGeometryVersion=i,this.age=0,!0}},{key:"dispose",value:function dispose(){this.rt.dispose(),this.overrideMaterial.dispose()}}])}();function SceneCapture_createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=function SceneCapture_unsupportedIterableToArray(t,r){if(t){if("string"==typeof t)return SceneCapture_arrayLikeToArray(t,r);var a={}.toString.call(t).slice(8,-1);return"Object"===a&&t.constructor&&(a=t.constructor.name),"Map"===a||"Set"===a?Array.from(t):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?SceneCapture_arrayLikeToArray(t,r):void 0}}(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var l,c=!0,u=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return c=t.done,t},e:function e(t){u=!0,l=t},f:function f(){try{c||null==a.return||a.return()}finally{if(u)throw l}}}}function SceneCapture_arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=Array(r);a<r;a++)o[a]=t[a];return o}var g=new u.ZzF,y=function(){return(0,d.Z)((function SceneCapture(){var t,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(0,h.Z)(this,SceneCapture),(0,v.Z)(this,"rt",void 0),(0,v.Z)(this,"width",0),(0,v.Z)(this,"height",0),this.rt=new u.dd2(1,1,{type:u.cLu,format:null!==(t=r.format)&&void 0!==t?t:u.wk1,depthBuffer:!0,stencilBuffer:!1,minFilter:u.wem,magFilter:u.wem}),this.width=1,this.height=1}),[{key:"texture",get:function get(){return this.rt.texture}},{key:"resizeIfNeeded",value:function resizeIfNeeded(t,r,a){var o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,i=Math.max(1,Math.round(t*a*o)),l=Math.max(1,Math.round(r*a*o));return(i!==this.width||l!==this.height)&&(this.rt.setSize(i,l),this.width=i,this.height=l,!0)}},{key:"render",value:function render(t,r,a,o,i,l,c){var h,d=this,v=[],m=SceneCapture_createForOfIteratorHelper(o);try{for(m.s();!(h=m.n()).done;){var y=h.value;y&&y.visible&&(y.visible=!1,v.push(y))}}catch(t){m.e(t)}finally{m.f()}c&&r.traverse((function(t){var r=t;if(r.isMesh&&r.visible){var a=r.geometry;if(a){null===a.boundingBox&&a.computeBoundingBox();var o=a.boundingBox;o&&(g.copy(o).applyMatrix4(r.matrixWorld),g.intersectsBox(c)||(r.visible=!1,v.push(r)))}}})),this.rt.scissorTest=!1;var x=r.background;r.background=null;try{(0,p.s)(t,{target:this.rt,toneMapping:u.uL9,clearAlpha:0,clippingPlanes:i},(function(){t.clear(!0,!0,!1),l&&(d.rt.scissor.copy(l),d.rt.scissorTest=!0,t.setRenderTarget(d.rt));try{t.render(r,a)}finally{d.rt.scissorTest=!1}}))}finally{r.background=x;for(var w=0,b=v;w<b.length;w++){b[w].visible=!0}}}},{key:"dispose",value:function dispose(){this.rt.dispose()}}])}(),x=a(8133),w=new u.ZzF,b=new u.iWj,S=new u.yGw,P=new u.Ltg,C=new u.Ltg,M=new u.FM8;var H=function(){return(0,d.Z)((function RefractionCapture(){(0,h.Z)(this,RefractionCapture),(0,v.Z)(this,"capture",new y),(0,v.Z)(this,"clipPlanes",[new u.JOQ(new u.Pa4(-1,0,0),0),new u.JOQ(new u.Pa4(1,0,0),0),new u.JOQ(new u.Pa4(0,-1,0),0),new u.JOQ(new u.Pa4(0,1,0),0),new u.JOQ(new u.Pa4(0,0,-1),0),new u.JOQ(new u.Pa4(0,0,1),0)]),(0,v.Z)(this,"framesSinceCapture",15),(0,v.Z)(this,"capturedViewProj",new u.yGw),(0,v.Z)(this,"capturedBox",new u.ZzF),(0,v.Z)(this,"capturedGeometryVersion",-1)}),[{key:"texture",get:function get(){return this.capture.texture}},{key:"update",value:function update(t){var r=t.renderer,a=t.camera,o=t.material,i=t.volumeCenter,l=t.poolHalf,c=this.capture.resizeIfNeeded(t.cssWidth,t.cssHeight,r.getPixelRatio(),.5);o.uniforms.uSceneColor.value=this.capture.texture,r.getDrawingBufferSize(M),o.uniforms.uResolution.value.set(1/Math.max(1,M.x),1/Math.max(1,M.y));var u=i.x,h=i.y,d=i.z,v=l.x+.25,p=l.y,m=l.z+.25;this.clipPlanes[0].constant=u+v,this.clipPlanes[1].constant=v-u,this.clipPlanes[2].constant=h,this.clipPlanes[3].constant=p-h,this.clipPlanes[4].constant=d+m,this.clipPlanes[5].constant=m-d,w.min.set(u-v,h-p-.4,d-m),w.max.set(u+v,h+.4,d+m),a.updateMatrixWorld(),S.multiplyMatrices(a.projectionMatrix,a.matrixWorldInverse),b.setFromProjectionMatrix(S);var g=t.sceneMutating||t.geometryVersion!==this.capturedGeometryVersion||!w.equals(this.capturedBox)||!function matricesApproxEqual(t,r,a){for(var o=t.elements,i=r.elements,l=0;l<16;l++)if(Math.abs(o[l]-i[l])>a)return!1;return!0}(S,this.capturedViewProj,1e-6);if(this.framesSinceCapture+=1,function isCaptureDue(t,r,a){return a||t>=(r?1:15)}(this.framesSinceCapture,g,c)&&b.intersectsBox(w)){var y=function fitScissorToBox(t,r,a,o,i,l){for(var c=1/0,u=1/0,h=-1/0,d=-1/0,v=0;v<8;v++){if(C.set(1&v?t.max.x:t.min.x,2&v?t.max.y:t.min.y,4&v?t.max.z:t.min.z,1).applyMatrix4(r),C.w<=1e-6)return!1;var p=C.x/C.w,m=C.y/C.w;p<c&&(c=p),p>h&&(h=p),m<u&&(u=m),m>d&&(d=m)}var g=i*a+1,y=i*o+1,x=Math.max(0,Math.floor((.5*c+.5)*a-g)),w=Math.max(0,Math.floor((.5*u+.5)*o-y)),b=Math.min(a,Math.ceil((.5*h+.5)*a+g)),S=Math.min(o,Math.ceil((.5*d+.5)*o+y));return!(b<=x||S<=w)&&(l.set(x,w,b-x,S-w),!0)}(w,S,this.capture.width,this.capture.height,.03,P);(0,x.Jm)(!0);try{this.capture.render(r,t.scene,a,[t.surfaceMesh],this.clipPlanes,y?P:null,w)}finally{(0,x.Jm)(!1)}this.framesSinceCapture=0,this.capturedViewProj.copy(S),this.capturedBox.copy(w),this.capturedGeometryVersion=t.geometryVersion}}},{key:"dispose",value:function dispose(){this.capture.dispose()}}])}();var z=a(7534),R="\n const float IOR_AIR = 1.0;\n const float IOR_WATER = 1.333;\n uniform vec3 light;\n uniform vec3 uPoolHalf; // (halfX, depth, halfZ) — see file header\n uniform sampler2D water;\n\n vec2 intersectCube(vec3 origin, vec3 ray, vec3 cubeMin, vec3 cubeMax) {\n vec3 tMin = (cubeMin - origin) / ray;\n vec3 tMax = (cubeMax - origin) / ray;\n vec3 t1 = min(tMin, tMax);\n vec3 t2 = max(tMin, tMax);\n float tNear = max(max(t1.x, t1.y), t1.z);\n float tFar = min(min(t2.x, t2.y), t2.z);\n return vec2(tNear, tFar);\n }\n";function heightSamplerGLSL(t,r){return"\n float ".concat(t,"(vec2 xz) {\n float encoded = texture2D(").concat(r,", xz / (2.0 * uPoolHalf.xz) + 0.5).r;\n return clamp(encoded * 3.0 * uPoolHalf.y - uPoolHalf.y, -uPoolHalf.y, 0.0);\n }\n")}function heightFieldMarchGLSL(t){var r=t.name,a=t.sampler,o=t.coarseSteps,i=t.guardShallowRays,l=["for (int k = 0; k < 3; k++) {"," p += ray * ((".concat(a,"(p.xz) - p.y) / ray.y);"),"}"],c=i?["if (ray.y < -0.001) {"].concat((0,z.Z)(l.map((function(t){return" ".concat(t)}))),["}"]):l;return"\n vec3 ".concat(r,"(vec3 origin, vec3 ray) {\n vec2 t = intersectCube(origin, ray, vec3(-uPoolHalf.x, -uPoolHalf.y, -uPoolHalf.z), vec3(uPoolHalf.x, 2.0 * uPoolHalf.y, uPoolHalf.z));\n float tEnd = max(t.y, 0.0);\n float lo = 0.0;\n float hi = tEnd;\n bool crossed = false;\n for (int i = 1; i <= ").concat(o,"; i++) {\n float ti = tEnd * float(i) / ").concat(o.toFixed(1),";\n vec3 p = origin + ray * ti;\n if (p.y <= ").concat(a,"(p.xz)) {\n hi = ti;\n crossed = true;\n break;\n }\n lo = ti;\n }\n if (!crossed) {\n vec3 p = origin + ray * tEnd;\n").concat(c.map((function(t){return" ".concat(t)})).join("\n"),"\n return p;\n }\n for (int j = 0; j < 4; j++) {\n float mid = 0.5 * (lo + hi);\n vec3 pm = origin + ray * mid;\n if (pm.y <= ").concat(a,"(pm.xz)) {\n hi = mid;\n } else {\n lo = mid;\n }\n }\n return origin + ray * (0.5 * (lo + hi));\n }\n")}var k="\n ".concat(R,"\n ").concat('\n uniform float uWaterClarity;\n uniform vec3 uWallColor; // MOD #1: replaces sampler2D tiles\n uniform vec3 uSkyHorizonColor; // MOD #2: drives sampleProceduralSky\n uniform vec3 uSkyZenithColor; // MOD #2: drives sampleProceduralSky\n uniform sampler2D causticTex;\n\n // MOD #2: replaces textureCube(sky, ray). Two-color vertical gradient.\n vec3 sampleProceduralSky(vec3 ray) {\n float t = clamp(ray.y * 0.5 + 0.5, 0.0, 1.0);\n return mix(uSkyHorizonColor, uSkyZenithColor, pow(t, 1.5));\n }\n\n // Sample the heightfield at a WORLD-METER xz position. The heightfield\n // texture\'s UV [0, 1]² spans the full pool footprint [-halfX, +halfX] ×\n // [-halfZ, +halfZ].\n vec4 sampleWaterAt(vec2 worldXZ) {\n return texture2D(water, worldXZ / (2.0 * uPoolHalf.xz) + 0.5);\n }\n\n // Sample the caustic texture for a point at WORLD-METER position. The\n // caustic texture indexes by "where would the light from this point have\n // come from at the water surface", projected back along refractedLight.\n // Mapping mirrors the caustics-vertex gl_Position write:\n // clip_xz = 0.75 * (point.xz - point.y * slope) / uPoolHalf.xz\n // Both vertex and fragment use this identical formula so reading and\n // writing into the texture are consistent across the full pool.\n vec4 sampleCausticAt(vec3 point, vec3 refractedLight) {\n vec2 lookup = (point.xz - point.y * refractedLight.xz / refractedLight.y) / uPoolHalf.xz;\n return texture2D(causticTex, 0.75 * lookup * 0.5 + 0.5);\n }\n\n vec3 getWallColor(vec3 point) {\n float scale = 0.5;\n\n vec3 wallColor;\n vec3 normal;\n // Wall detection: a tiny relative epsilon (0.1% of pool half-extent) so\n // we still recognise points sitting exactly on the wall geometry while\n // being tolerant of floating-point noise in the ray-march hit positions.\n if (abs(point.x) > uPoolHalf.x * 0.999) {\n wallColor = uWallColor; // MOD #1\n normal = vec3(-point.x, 0.0, 0.0);\n } else if (abs(point.z) > uPoolHalf.z * 0.999) {\n wallColor = uWallColor; // MOD #1\n normal = vec3(0.0, 0.0, -point.z);\n } else {\n wallColor = uWallColor; // MOD #1\n normal = vec3(0.0, 1.0, 0.0);\n }\n\n scale /= mix(length(point), 1.0, uWaterClarity); /* pool ambient occlusion */\n\n /* caustics */\n vec3 refractedLight = -refract(-light, vec3(0.0, 1.0, 0.0), IOR_AIR / IOR_WATER);\n float diffuse = max(0.0, dot(refractedLight, normal));\n vec4 info = sampleWaterAt(point.xz);\n if (point.y < info.r) {\n vec4 caustic = sampleCausticAt(point, refractedLight);\n scale += diffuse * caustic.r * 2.0 * caustic.g;\n } else {\n /* shadow for the rim of the pool */\n vec2 t = intersectCube(point, refractedLight, vec3(-uPoolHalf.x, -uPoolHalf.y, -uPoolHalf.z), vec3(uPoolHalf.x, 2.0 * uPoolHalf.y, uPoolHalf.z));\n diffuse *= 1.0 / (1.0 + exp(-200.0 / (1.0 + 10.0 * (t.y - t.x)) * (point.y + refractedLight.y * t.y - uPoolHalf.y / 6.0)));\n\n scale += diffuse * 0.5;\n }\n\n return wallColor * scale;\n }\n',"\n uniform vec3 eye;\n // Screen-space refraction inputs. The host renders the scene minus the\n // water surface itself to uSceneColor once per frame (SceneCapture.ts);\n // the surface then samples that texture at its own screen UV. This\n // replaces the demo's in-shader intersectCube + getWallColor AABB\n // raytrace so the underwater view shows the ACTUAL pool geo in the scene.\n uniform sampler2D uSceneColor;\n uniform vec2 uResolution;\n uniform float uUseScreenSpaceRefraction;\n uniform vec3 uRefractionFallbackColor;\n // Grazing-angle ceiling of the Schlick fresnel, in [fresnelBase, 1.0]. The\n // standard formula reaches 1.0 at cosI = 0, which on steep wave fronts reads\n // as harsh bright streaks (env.water.fresnelMax).\n uniform float uFresnelMax;\n // MOD #7 debug views (0 in production):\n // 4 = LANDING — ramp of the landing height the caustic composite\n // anchors to at this pixel (caustic texture .b at the marched\n // view-ray hit). Downstream of the height map AND caustics pass.\n // 5 = HEIGHTMAP — the raw PoolHeightMap capture painted over the pool\n // footprint. Upstream: exactly what the top-down pass recorded.\n uniform float uCausticDebugMode;\n // Pool receiving-geometry height map (PoolHeightMap.ts) — PRODUCTION\n // input: the SSR composite marches the view ray against it to find the\n // displayed wall/floor point. Also drives debug view 5.\n uniform sampler2D uPoolHeightMap;\n varying vec3 vWaterPos;\n\n // Landing-height debug ramp. Magenta = no data (encoded 0: cleared height\n // map texel, or a caustic ray that landed at the analytic volume floor);\n // blue = volume floor, green = mid-depth, red = waterline.\n vec3 rtvLandingRamp(float encoded) {\n if (encoded < 0.002) return vec3(1.0, 0.0, 1.0);\n float t = clamp(encoded * 3.0, 0.0, 1.0);\n return t < 0.5 ? mix(vec3(0.0, 0.2, 1.0), vec3(0.0, 1.0, 0.2), t * 2.0) : mix(vec3(0.0, 1.0, 0.2), vec3(1.0, 0.1, 0.0), t * 2.0 - 1.0);\n }\n\n ").concat(heightSamplerGLSL("rtvSampleHeight","uPoolHeightMap"),"\n\n // Height-field normal from central differences. Steep wall bands in the\n // map tilt it toward horizontal, so walls get a proper light-incidence\n // term without any analytic-AABB face detection.\n vec3 rtvHeightFieldNormal(vec2 xz) {\n float eps = uPoolHalf.x / 128.0;\n float hxp = rtvSampleHeight(xz + vec2(eps, 0.0));\n float hxm = rtvSampleHeight(xz - vec2(eps, 0.0));\n float hzp = rtvSampleHeight(xz + vec2(0.0, eps));\n float hzm = rtvSampleHeight(xz - vec2(0.0, eps));\n return normalize(vec3(hxm - hxp, 2.0 * eps, hzm - hzp));\n }\n\n /* MOD #7 — find the displayed geometry point along the straight view ray by\n marching it against the pool height map. Runs per FRAGMENT, hence the\n coarser 12-step pass; see heightFieldMarchGLSL for the algorithm. */\n ").concat(heightFieldMarchGLSL({name:"rtvMarchViewRay",sampler:"rtvSampleHeight",coarseSteps:12,guardShallowRays:!0}),"\n\n /*\n * Screen-space refraction sampler.\n *\n * gl_FragCoord.xy * uResolution (with uResolution = 1/drawingBuffer)\n * gives the current fragment's screen UV — the same UV the SceneCapture\n * target was written with, and the UV we sample at. Refraction is flat:\n * the sample is never displaced by the wave normal.\n *\n * The SceneCapture pass clips everything outside the water bbox via\n * six clipping planes installed on the renderer, so any fragment of\n * geometry that sits outside the water volume (above, below, beside\n * the pool) is discarded — those screen pixels stay at the cleared\n * alpha = 0 in the capture.\n *\n * When the sample is alpha=0 (or near-black, since a cleared capture\n * pixel reads as opaque-but-zero on some drivers) — a tall wave crest\n * peeking above the original waterline, so behind it on screen there's\n * no captured geo — return uRefractionFallbackColor, a host-configurable\n * deep-water tint surfaced as a Leva colour picker.\n */\n // Treat cleared / clipped capture pixels as a miss even if alpha is wrong.\n bool rtvSceneCaptureMissed(vec4 s) {\n return s.a < 0.5 || (s.r + s.g + s.b) < 0.02;\n }\n\n vec3 sampleScreenSpaceRefraction(vec3 viewRay, vec3 waterColor) {\n vec2 sampleUV = gl_FragCoord.xy * uResolution;\n vec4 sceneSample = texture2D(uSceneColor, sampleUV);\n\n // Live caustic composite. The capture is rendered with the caustic\n // receivers SUSPENDED (see setCausticReceiversSuspended) so still-scene\n // captures stay byte-identical for the throttle; the animated caustic\n // term is applied here every frame instead.\n //\n // MOD #7 — the hit marches the STRAIGHT view ray, not the refracted\n // one: the capture is an unrefracted straight-view render sampled at\n // the fragment's own screen UV, so the geometry displayed at this\n // fragment lies along the camera ray.\n float causticBoost = 1.0;\n vec3 refractedLight = -refract(-light, vec3(0.0, 1.0, 0.0), IOR_AIR / IOR_WATER);\n vec3 hit = rtvMarchViewRay(vWaterPos, viewRay);\n vec3 hitNormal = rtvHeightFieldNormal(hit.xz);\n float diffuseTerm = max(0.0, dot(refractedLight, hitNormal));\n vec4 info = sampleWaterAt(hit.xz);\n if (hit.y < info.r) {\n vec4 caustic = sampleCausticAt(hit, refractedLight);\n // Landing-height shadow, same rule as the receivers: a hit clearly\n // below the ray's landing is behind the surface that caught the\n // light. b == 0 is the no-data sentinel → no occlusion.\n float landingY = caustic.b * 3.0 * uPoolHalf.y - uPoolHalf.y;\n float occlusion = 1.0 - step(0.002, caustic.b) * smoothstep(0.05, 0.2, landingY - hit.y);\n // Hard ceiling on the contribution: at concave edges the tilted\n // height-field normal and the fold-compressed caustic can multiply\n // into an outline far brighter than the open-floor pattern.\n causticBoost += min(diffuseTerm * caustic.r * 2.0 * caustic.g * occlusion, 0.8);\n }\n\n // The fallback gets the boost too so a caustic band doesn't cut off\n // abruptly at the valid-sample/fallback boundary.\n if (rtvSceneCaptureMissed(sceneSample)) {\n return uRefractionFallbackColor * causticBoost;\n }\n return sceneSample.rgb * causticBoost * waterColor;\n }\n\n vec3 getSurfaceRayColor(vec3 origin, vec3 ray, vec3 waterColor) {\n vec3 color;\n if (ray.y < 0.0) {\n vec2 t = intersectCube(origin, ray, vec3(-uPoolHalf.x, -uPoolHalf.y, -uPoolHalf.z), vec3(uPoolHalf.x, 2.0 * uPoolHalf.y, uPoolHalf.z));\n color = getWallColor(origin + ray * t.y);\n } else {\n vec2 t = intersectCube(origin, ray, vec3(-uPoolHalf.x, -uPoolHalf.y, -uPoolHalf.z), vec3(uPoolHalf.x, 2.0 * uPoolHalf.y, uPoolHalf.z));\n vec3 hit = origin + ray * t.y;\n if (hit.y < uPoolHalf.y / 6.0) {\n color = getWallColor(hit);\n } else {\n color = sampleProceduralSky(ray); // MOD #2\n color += vec3(pow(max(0.0, dot(light, ray)), 5000.0)) * vec3(10.0, 8.0, 6.0);\n }\n }\n if (ray.y < 0.0) color *= waterColor;\n return color;\n }\n\n void main() {\n vec2 coord = vWaterPos.xz / (2.0 * uPoolHalf.xz) + 0.5;\n vec4 info = texture2D(water, coord);\n\n // HEIGHTMAP debug view — the raw PoolHeightMap capture over the pool\n // footprint (same UV the caustics pass samples with).\n if (uCausticDebugMode > 4.5) {\n gl_FragColor = vec4(rtvLandingRamp(texture2D(uPoolHeightMap, coord).r), 1.0);\n return;\n }\n\n // Footprint of the UN-displaced surface UV, in heightfield texels per screen pixel — taken\n // BEFORE the peaks loop so per-pixel displacement jitter cannot spike the derivative.\n vec2 hfTexels = vec2(textureSize(water, 0));\n float footprint = max(fwidth(coord.x) * hfTexels.x, fwidth(coord.y) * hfTexels.y);\n\n /* make water look more \"peaked\" */\n for (int i = 0; i < 5; i++) {\n coord += info.ba * 0.005;\n info = texture2D(water, coord);\n }\n\n // Resolution-adaptive normal smoothing (spec-AA): when one screen pixel spans several\n // heightfield texels (low effective DPR on tablets, grazing distance), the per-pixel wave\n // normal aliases into reflection/refraction sparkle. Flatten the wave component toward\n // vertical with the footprint — a no-op at 1:1 sampling, so dense desktop rendering keeps\n // its full wave detail.\n info.ba *= 1.0 / (1.0 + 1.5 * max(0.0, footprint - 1.0));\n\n vec3 normal = vec3(info.b, sqrt(max(0.0, 1.0 - dot(info.ba, info.ba))), info.a);\n vec3 incomingRay = normalize(vWaterPos - eye);\n\n /* above water */\n vec3 reflectedRay = reflect(incomingRay, normal);\n vec3 refractedRay = refract(incomingRay, normal, IOR_AIR / IOR_WATER);\n\n // LANDING debug view — the landing height the composite uses at this\n // pixel, computed with the same view-ray march as production.\n if (uCausticDebugMode > 3.5) {\n vec3 dbgRefractedLight = -refract(-light, vec3(0.0, 1.0, 0.0), IOR_AIR / IOR_WATER);\n vec3 dbgHit = rtvMarchViewRay(vWaterPos, incomingRay);\n gl_FragColor = vec4(rtvLandingRamp(sampleCausticAt(dbgHit, dbgRefractedLight).b), 1.0);\n return;\n }\n\n float fresnelBase = mix(0.25, 0.05, uWaterClarity);\n // Schlick fresnel. CRITICAL: clamp the cos-incidence term to [0, 1]\n // BEFORE the pow(). On steep wave fronts dot(normal, -incomingRay)\n // can slip slightly above 1.0 (fp error) — then 1.0 - dot becomes\n // negative and pow(negative, 3.0) is undefined in GLSL → NaN.\n // The NaN propagates into fresnel and into mix(refracted, reflected,\n // fresnel), and the framebuffer write clamps NaN to 0, producing\n // pure-black wave-front streaks. The clamp keeps fresnel a well-\n // defined float in [fresnelBase, uFresnelMax] everywhere.\n float cosI = clamp(dot(normal, -incomingRay), 0.0, 1.0);\n float fresnel = mix(fresnelBase, uFresnelMax, pow(1.0 - cosI, 3.0));\n\n vec3 abovewaterColor = mix(vec3(0.25, 1.0, 1.25), vec3(1.0), uWaterClarity);\n vec3 reflectedColor = getSurfaceRayColor(vWaterPos, reflectedRay, abovewaterColor);\n // Refraction path: screen-space sample of the captured scene texture when\n // uUseScreenSpaceRefraction is on, falling back to the demo's in-shader\n // AABB raytrace otherwise. Both paths share the same abovewaterColor tint\n // so toggling between them doesn't shift the overall hue.\n vec3 refractedColor;\n if (uUseScreenSpaceRefraction > 0.5) {\n refractedColor = sampleScreenSpaceRefraction(incomingRay, abovewaterColor);\n } else {\n refractedColor = getSurfaceRayColor(vWaterPos, refractedRay, abovewaterColor);\n }\n\n gl_FragColor = vec4(mix(refractedColor, reflectedColor, fresnel), 1.0);\n }\n"),T="\n ".concat(R,"\n uniform float uCausticIntensity; // MOD #4\n // MOD #7 — receiving-geometry height map (PoolHeightMap.ts). R channel:\n // volume-local height as (y + poolHalf.y) / (3 * poolHalf.y); the cleared\n // texture (0) decodes to the floor plane.\n uniform sampler2D uHeightMap;\n uniform float uHeightMapEnabled;\n varying vec3 oldPos;\n varying vec3 newPos;\n varying vec3 vRay;\n varying float vEdgeFade;\n\n ").concat(heightSamplerGLSL("causticSampleHeight","uHeightMap"),"\n\n /* Runs per VERTEX of the caustic mesh, so it affords a 24-step coarse pass;\n see heightFieldMarchGLSL for the algorithm. */\n ").concat(heightFieldMarchGLSL({name:"causticMarchLightRay",sampler:"causticSampleHeight",coarseSteps:24,guardShallowRays:!1}),"\n\n /* Land the ray on the receiving geometry. Without a height map: the\n demo's AABB clip + flat-floor projection. With one: march the ray\n against the height map — walls, ROUNDED CORNERS and stairs all\n terminate rays at their real position. (The analytic AABB attributes\n corner rays to the wrong wall face: square box vs rounded pool.)\n The caustic-clip lookup is invariant to where along the ray we stop. */\n vec3 project(vec3 origin, vec3 ray, vec3 refractedLight) {\n if (uHeightMapEnabled < 0.5) {\n vec2 tcube = intersectCube(origin, ray, vec3(-uPoolHalf.x, -uPoolHalf.y, -uPoolHalf.z), vec3(uPoolHalf.x, 2.0 * uPoolHalf.y, uPoolHalf.z));\n origin += ray * tcube.y;\n float tplane = (-origin.y - uPoolHalf.y) / refractedLight.y;\n return origin + refractedLight * tplane;\n }\n return causticMarchLightRay(origin, ray);\n }\n\n void main() {\n vec4 info = texture2D(water, position.xy / (2.0 * uPoolHalf.xz) + 0.5);\n info.ba *= uCausticIntensity; // MOD #4: was *= 0.5\n vec3 normal = vec3(info.b, sqrt(max(0.0, 1.0 - dot(info.ba, info.ba))), info.a);\n\n /* project the vertices along the refracted vertex ray */\n vec3 refractedLight = refract(-light, vec3(0.0, 1.0, 0.0), IOR_AIR / IOR_WATER);\n vRay = refract(-light, normal, IOR_AIR / IOR_WATER);\n oldPos = project(position.xzy, refractedLight, refractedLight);\n newPos = project(position.xzy + vec3(0.0, info.r, 0.0), vRay, refractedLight);\n\n // Concave-edge fade. Grazing light makes the landing mapping\n // near-singular at riser bases and wall coves — wave-normal jitter\n // funnels rays onto the exact corner line, which the area-ratio math\n // rewards with harsh max-brightness dashes. Fade landings that are\n // FLAT at their own position (small-radius gradient) but have a STEEP\n // feature nearby (large-radius gradient) — the signature of a concave\n // base line. Wall-FACE landings are steep at both radii and therefore\n // never faded; open floor is flat at both and also untouched.\n vEdgeFade = 1.0;\n if (uHeightMapEnabled > 0.5) {\n float epsNear = uPoolHalf.x / 128.0;\n float epsFar = uPoolHalf.x / 24.0;\n float gxN = causticSampleHeight(newPos.xz + vec2(epsNear, 0.0)) - causticSampleHeight(newPos.xz - vec2(epsNear, 0.0));\n float gzN = causticSampleHeight(newPos.xz + vec2(0.0, epsNear)) - causticSampleHeight(newPos.xz - vec2(0.0, epsNear));\n float gxF = causticSampleHeight(newPos.xz + vec2(epsFar, 0.0)) - causticSampleHeight(newPos.xz - vec2(epsFar, 0.0));\n float gzF = causticSampleHeight(newPos.xz + vec2(0.0, epsFar)) - causticSampleHeight(newPos.xz - vec2(0.0, epsFar));\n float flatHere = 1.0 - smoothstep(0.2, 0.6, length(vec2(gxN, gzN)) / (2.0 * epsNear));\n float steepNearby = smoothstep(0.25, 0.6, length(vec2(gxF, gzF)) / (2.0 * epsFar));\n vEdgeFade = 1.0 - steepNearby * flatHere;\n }\n\n // Caustic-clip output mirrors sampleCausticAt exactly: same projection,\n // same uPoolHalf.xz divide, same 0.75 margin. With slope = 0 (vertical\n // sun) this lands the pool floor [-uPoolHalf.xz, +uPoolHalf.xz] in\n // caustic-clip [-0.75, +0.75], leaving a 25% border for slanted-sun\n // projection drift.\n vec2 lookup = (newPos.xz - newPos.y * refractedLight.xz / refractedLight.y) / uPoolHalf.xz;\n gl_Position = vec4(0.75 * lookup, 0.0, 1.0);\n }\n"),A="\n ".concat(R,"\n varying vec3 oldPos;\n varying vec3 newPos;\n varying vec3 vRay;\n varying float vEdgeFade;\n\n void main() {\n /* if the triangle gets smaller, it gets brighter, and vice versa */\n float oldArea = length(dFdx(oldPos)) * length(dFdy(oldPos));\n float newArea = length(dFdx(newPos)) * length(dFdy(newPos));\n // vEdgeFade suppresses the fold-caustic line at concave height-field\n // edges (riser bases, wall coves) — see CAUSTICS_VERTEX.\n gl_FragColor = vec4(oldArea / newArea * 0.2 * vEdgeFade, 1.0, 0.0, 0.0);\n\n vec3 refractedLight = refract(-light, vec3(0.0, 1.0, 0.0), IOR_AIR / IOR_WATER);\n\n /* shadow for the rim of the pool */\n vec2 t = intersectCube(newPos, -refractedLight, vec3(-uPoolHalf.x, -uPoolHalf.y, -uPoolHalf.z), vec3(uPoolHalf.x, 2.0 * uPoolHalf.y, uPoolHalf.z));\n gl_FragColor.r *= 1.0 / (1.0 + exp(-200.0 / (1.0 + 10.0 * (t.y - t.x)) * (newPos.y - refractedLight.y * t.y - uPoolHalf.y / 6.0)));\n\n // MOD #7 — landing height into the blue channel (same normalization as\n // the height map). Consumers occlude fragments clearly below it.\n gl_FragColor.b = clamp((newPos.y + uPoolHalf.y) / (3.0 * uPoolHalf.y), 0.0, 1.0);\n }\n"),D={vertex:"\n uniform sampler2D water;\n uniform vec3 uPoolHalf;\n varying vec3 vWaterPos;\n void main() {\n vec4 info = texture2D(water, position.xz / (2.0 * uPoolHalf.xz) + 0.5);\n vWaterPos = vec3(position.x, info.r, position.z);\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position.x, info.r, position.z, 1.0);\n }\n",fragment:k},W={vertex:T,fragment:A};function ownKeys(t,r){var a=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);r&&(o=o.filter((function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable}))),a.push.apply(a,o)}return a}function _objectSpread(t){for(var r=1;r<arguments.length;r++){var a=null!=arguments[r]?arguments[r]:{};r%2?ownKeys(Object(a),!0).forEach((function(r){(0,v.Z)(t,r,a[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(a)):ownKeys(Object(a)).forEach((function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(a,r))}))}return t}function buildSharedUniformValues(t){var r,a,o,i,l,c,h,d;return{light:{value:(null!==(r=t.light)&&void 0!==r?r:new u.Pa4(.7071,.7071,0)).clone()},water:{value:null!==(a=t.water)&&void 0!==a?a:null},causticTex:{value:null!==(o=t.causticTex)&&void 0!==o?o:null},uPoolHalf:{value:(null!==(i=t.uPoolHalf)&&void 0!==i?i:new u.Pa4(1,1,1)).clone()},uWallColor:{value:(null!==(l=t.uWallColor)&&void 0!==l?l:new u.Pa4(.7,.78,.85)).clone()},uSkyHorizonColor:{value:(null!==(c=t.uSkyHorizonColor)&&void 0!==c?c:new u.Pa4(.78,.85,.95)).clone()},uSkyZenithColor:{value:(null!==(h=t.uSkyZenithColor)&&void 0!==h?h:new u.Pa4(.18,.36,.78)).clone()},uWaterClarity:{value:null!==(d=t.uWaterClarity)&&void 0!==d?d:0}}}function updateSharedUniforms(t,r){var a=t.uniforms;r.light&&a.light.value.copy(r.light),void 0!==r.water&&(a.water.value=r.water),void 0!==r.causticTex&&(a.causticTex.value=r.causticTex),r.uPoolHalf&&a.uPoolHalf.value.copy(r.uPoolHalf),r.uWallColor&&a.uWallColor.value.copy(r.uWallColor),r.uSkyHorizonColor&&a.uSkyHorizonColor.value.copy(r.uSkyHorizonColor),r.uSkyZenithColor&&a.uSkyZenithColor.value.copy(r.uSkyZenithColor),void 0!==r.uWaterClarity&&(a.uWaterClarity.value=r.uWaterClarity)}var L=a(82),O="\n varying vec2 coord;\n void main() {\n coord = position.xy * 0.5 + 0.5;\n gl_Position = vec4(position.xyz, 1.0);\n }\n",I="\n const float PI = 3.141592653589793;\n uniform sampler2D tSrc;\n uniform vec2 center; // pool-normalized [-1, 1]\n uniform float radius; // WORLD METERS\n uniform float strength;\n uniform vec2 poolHalf; // (vx, vz) world half-extents (meters)\n varying vec2 coord;\n void main() {\n vec4 info = texture2D(tSrc, coord);\n\n vec2 texelWorld = (coord * 2.0 - 1.0) * poolHalf;\n vec2 centerWorld = center * poolHalf;\n float drop = max(0.0, 1.0 - distance(texelWorld, centerWorld) / radius);\n drop = 0.5 - cos(drop * PI) * 0.5;\n info.r += drop * strength;\n\n gl_FragColor = info;\n }\n",Z="\n uniform sampler2D tSrc;\n uniform vec2 delta;\n uniform float damping;\n varying vec2 coord;\n void main() {\n /* get vertex info */\n vec4 info = texture2D(tSrc, coord);\n\n /* calculate average neighbor height */\n vec2 dx = vec2(delta.x, 0.0);\n vec2 dy = vec2(0.0, delta.y);\n float average = (\n texture2D(tSrc, coord - dx).r +\n texture2D(tSrc, coord - dy).r +\n texture2D(tSrc, coord + dx).r +\n texture2D(tSrc, coord + dy).r\n ) * 0.25;\n\n /* change the velocity to move toward the average */\n info.g += (average - info.r) * 2.0;\n\n /* attenuate the velocity a little so waves do not last forever */\n info.g *= damping;\n\n /* move the vertex along the velocity */\n info.r += info.g;\n\n gl_FragColor = info;\n }\n",E="\n uniform sampler2D tSrc;\n uniform vec2 delta;\n varying vec2 coord;\n void main() {\n /* get vertex info */\n vec4 info = texture2D(tSrc, coord);\n\n /* update the normal */\n vec3 dx = vec3(delta.x, texture2D(tSrc, vec2(coord.x + delta.x, coord.y)).r - info.r, 0.0);\n vec3 dy = vec3(0.0, texture2D(tSrc, vec2(coord.x, coord.y + delta.y)).r - info.r, delta.y);\n info.ba = normalize(cross(dy, dx)).xz;\n\n gl_FragColor = info;\n }\n",_=function(){return(0,d.Z)((function Heightfield(){var t,r,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(0,h.Z)(this,Heightfield),(0,v.Z)(this,"sizeX",void 0),(0,v.Z)(this,"sizeY",void 0),(0,v.Z)(this,"delta",void 0),(0,v.Z)(this,"poolHalf",void 0),(0,v.Z)(this,"rtA",void 0),(0,v.Z)(this,"rtB",void 0),(0,v.Z)(this,"scene",void 0),(0,v.Z)(this,"camera",void 0),(0,v.Z)(this,"quad",void 0),(0,v.Z)(this,"dropMat",void 0),(0,v.Z)(this,"updateMat",void 0),(0,v.Z)(this,"normalMat",void 0),(0,v.Z)(this,"clearedOnce",!1),this.sizeX=null!==(t=a.sizeX)&&void 0!==t?t:256,this.sizeY=null!==(r=a.sizeY)&&void 0!==r?r:this.sizeX,this.delta=new u.FM8(1/this.sizeX,1/this.sizeY),this.poolHalf=new u.FM8(1,1),a.poolHalf&&this.poolHalf.copy(a.poolHalf);var o={type:u.cLu,format:u.wk1,wrapS:u.uWy,wrapT:u.uWy,magFilter:u.wem,minFilter:u.wem,depthBuffer:!1,stencilBuffer:!1};this.rtA=new u.dd2(this.sizeX,this.sizeY,o),this.rtB=new u.dd2(this.sizeX,this.sizeY,o),this.scene=new u.xsS,this.camera=new u.iKG(-1,1,1,-1,0,1),this.quad=new u.Kj0(new u._12(2,2)),this.scene.add(this.quad),this.dropMat=new u.jyz({vertexShader:O,fragmentShader:I,uniforms:{tSrc:{value:null},center:{value:new u.FM8(0,0)},radius:{value:.1},strength:{value:.01},poolHalf:{value:this.poolHalf}},depthTest:!1,depthWrite:!1}),this.updateMat=new u.jyz({vertexShader:O,fragmentShader:Z,uniforms:{tSrc:{value:null},delta:{value:this.delta},damping:{value:.995}},depthTest:!1,depthWrite:!1}),this.normalMat=new u.jyz({vertexShader:O,fragmentShader:E,uniforms:{tSrc:{value:null},delta:{value:this.delta}},depthTest:!1,depthWrite:!1})}),[{key:"currentTexture",get:function get(){return this.rtA.texture}},{key:"ensureCleared",value:function ensureCleared(t){var r=this;this.clearedOnce||((0,p.s)(t,{target:this.rtA,clearColor:0,clearAlpha:0},(function(){t.clear(!0,!0,!0),t.setRenderTarget(r.rtB),t.clear(!0,!0,!0)})),this.clearedOnce=!0)}},{key:"renderPass",value:function renderPass(t,r){this.quad.material=r,t.setRenderTarget(this.rtB),t.render(this.scene,this.camera),t.setRenderTarget(null);var a=[this.rtB,this.rtA];this.rtA=a[0],this.rtB=a[1]}},{key:"addDrop",value:function addDrop(t,r){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:.1,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:.01;this.ensureCleared(t),this.dropMat.uniforms.tSrc.value=this.rtA.texture,this.dropMat.uniforms.center.value.copy(r),this.dropMat.uniforms.radius.value=a,this.dropMat.uniforms.strength.value=o,this.renderPass(t,this.dropMat)}},{key:"step",value:function step(t){this.ensureCleared(t),this.updateMat.uniforms.tSrc.value=this.rtA.texture,this.renderPass(t,this.updateMat)}},{key:"setDamping",value:function setDamping(t){this.updateMat.uniforms.damping.value=t}},{key:"updateNormals",value:function updateNormals(t){this.ensureCleared(t),this.normalMat.uniforms.tSrc.value=this.rtA.texture,this.renderPass(t,this.normalMat)}},{key:"dispose",value:function dispose(){this.rtA.dispose(),this.rtB.dispose(),this.dropMat.dispose(),this.updateMat.dispose(),this.normalMat.dispose(),this.quad.geometry.dispose()}}])}(),j=function(){return(0,d.Z)((function CausticsTexture(){var t,r,a,o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(0,h.Z)(this,CausticsTexture),(0,v.Z)(this,"size",void 0),(0,v.Z)(this,"poolHalf",void 0),(0,v.Z)(this,"rt",void 0),(0,v.Z)(this,"scene",void 0),(0,v.Z)(this,"camera",void 0),(0,v.Z)(this,"quad",void 0),(0,v.Z)(this,"material",void 0),this.size=null!==(t=o.size)&&void 0!==t?t:1024;var i=null!==(r=o.detail)&&void 0!==r?r:200;this.poolHalf=(null!==(a=o.poolHalf)&&void 0!==a?a:new u.Pa4(1,1,1)).clone(),this.rt=new u.dd2(this.size,this.size,{type:u.ywz,format:u.wk1,depthBuffer:!1,stencilBuffer:!1,generateMipmaps:!0,minFilter:u.D1R}),this.scene=new u.xsS,this.camera=new u.iKG(-1,1,1,-1,0,1),this.material=new u.jyz({vertexShader:W.vertex,fragmentShader:W.fragment,uniforms:{light:{value:new u.Pa4(.7071,.7071,0)},water:{value:null},uPoolHalf:{value:this.poolHalf.clone()},uCausticIntensity:{value:.5},uHeightMap:{value:null},uHeightMapEnabled:{value:0}},depthTest:!1,depthWrite:!1});var l=this.poolHalf.x,c=this.poolHalf.z,d=Math.max(l,c),p=i/Math.max(.001,2*d),m=Math.max(32,Math.round(2*l*p)),g=Math.max(32,Math.round(2*c*p));this.quad=new u.Kj0(new u._12(2*l,2*c,m,g),this.material),this.scene.add(this.quad)}),[{key:"texture",get:function get(){return this.rt.texture}},{key:"render",value:function render(t){var r=this;(0,p.s)(t,{target:this.rt,clearColor:0,clearAlpha:0},(function(){t.clear(!0,!1,!1),t.render(r.scene,r.camera)}))}},{key:"setHeightfield",value:function setHeightfield(t){this.material.uniforms.water.value=t}},{key:"setLight",value:function setLight(t,r,a){this.material.uniforms.light.value.set(t,r,a)}},{key:"setIntensity",value:function setIntensity(t){this.material.uniforms.uCausticIntensity.value=t}},{key:"setHeightMap",value:function setHeightMap(t){this.material.uniforms.uHeightMap.value=t,this.material.uniforms.uHeightMapEnabled.value=t?1:0}},{key:"dispose",value:function dispose(){this.rt.dispose(),this.material.dispose(),this.quad.geometry.dispose()}}])}();function useWaveSimulation_createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=function useWaveSimulation_unsupportedIterableToArray(t,r){if(t){if("string"==typeof t)return useWaveSimulation_arrayLikeToArray(t,r);var a={}.toString.call(t).slice(8,-1);return"Object"===a&&t.constructor&&(a=t.constructor.name),"Map"===a||"Set"===a?Array.from(t):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?useWaveSimulation_arrayLikeToArray(t,r):void 0}}(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var l,c=!0,u=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return c=t.done,t},e:function e(t){u=!0,l=t},f:function f(){try{c||null==a.return||a.return()}finally{if(u)throw l}}}}function useWaveSimulation_arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=Array(r);a<r;a++)o[a]=t[a];return o}var B=function(){return(0,d.Z)((function SubstepAccumulator(){(0,h.Z)(this,SubstepAccumulator),(0,v.Z)(this,"leftover",0)}),[{key:"take",value:function take(t,r){this.leftover+=t*Math.min(r,.06666666666666667);var a=Math.floor(this.leftover);return this.leftover-=a,a}},{key:"reset",value:function reset(){this.leftover=0}}])}();var N={off:0,overlay:1,isolate:2,mask:3,landing:4,heightmap:5};var V=a(120),U=a(7514);function WaterSurfaceRenderer(t){var r=t.position,a=t.volumeSize,o=t.sunDirection,h=t.wallColor,d=t.skyHorizonColor,v=t.skyZenithColor,p=t.heightfieldSize,g=t.causticTextureSize,y=t.substeps,x=t.ambientDropPeriod,w=t.pointerStrength,b=t.causticIntensity,S=t.waterClarity,P=t.useScreenSpaceRefraction,C=t.refractionFallbackColor,M=t.fresnelMax,z=t.causticDebugMode,R=(0,i.useRef)(null),k=(0,i.useRef)(null),T=(0,c.D)((function(t){return t.gl})),A=(0,c.D)((function(t){return t.camera})),W=(0,c.D)((function(t){return t.scene})),O=(0,c.D)((function(t){return t.size})),I=(0,i.useRef)(null);null===I.current&&(I.current=new H);var Z=(0,i.useRef)(null);null===Z.current&&(Z.current=new m);var E=(0,i.useMemo)((function(){return new u.Pa4(a[0]/2,a[1],a[2]/2)}),[a[0],a[1],a[2]]),X=function useWaveSimulation(t){var r=t.poolHalf,a=t.heightfieldSize,o=t.causticTextureSize,l=t.substeps,h=t.ambientDropPeriod,d=(0,c.D)((function(t){return t.gl})),v=(0,i.useRef)(null),p=(0,i.useRef)(null),m=(0,i.useRef)([]),g=(0,i.useRef)(!1),y=(0,i.useRef)(0),x=(0,i.useRef)(new B),w=(0,i.useMemo)((function(){var t=r.x,o=r.z,i=a/(2*Math.max(t,o));return{sizeX:Math.max(32,Math.round(2*t*i)),sizeY:Math.max(32,Math.round(2*o*i)),poolHalfX:t,poolHalfZ:o,poolDepth:r.y}}),[r.x,r.y,r.z,a]);return(0,i.useEffect)((function(){var t=new _({sizeX:w.sizeX,sizeY:w.sizeY,poolHalf:new u.FM8(w.poolHalfX,w.poolHalfZ)}),r=new j({poolHalf:new u.Pa4(w.poolHalfX,w.poolDepth,w.poolHalfZ),size:o});return v.current=t,p.current=r,g.current=!1,x.current.reset(),function(){t.dispose(),r.dispose(),v.current=null,p.current=null}}),[w,o]),{queueDrop:(0,i.useCallback)((function(t,r,a){m.current.push({center:t,radius:r,strength:a})}),[]),advance:function advance(t){var r=v.current,a=p.current;if(!r||!a)return!1;if(!g.current){for(var o=0;o<10;o++){var i=2*Math.random()-1,c=2*Math.random()-1;r.addDrop(d,new u.FM8(i,c),.3,1&o?.04:-.04)}g.current=!0}if(h>0&&(y.current+=t,y.current>=h)){y.current=0;var w=2*Math.random()-1,b=2*Math.random()-1;r.addDrop(d,new u.FM8(w,b),.24,.04)}if(m.current.length>0){var S,P=useWaveSimulation_createForOfIteratorHelper(m.current);try{for(P.s();!(S=P.n()).done;){var C=S.value;r.addDrop(d,C.center,C.radius,C.strength)}}catch(t){P.e(t)}finally{P.f()}m.current.length=0}var M=60*l;if(M>0){r.setDamping(Math.pow(.547,1/M));for(var H=x.current.take(M,t),z=0;z<H;z++)r.step(d)}return r.updateNormals(d),!0},setHeightMap:function setHeightMap(t){var r;null===(r=p.current)||void 0===r||r.setHeightMap(t)},renderCaustics:function renderCaustics(t,r){var a=v.current,o=p.current;a&&o&&(o.setHeightfield(a.currentTexture),o.setLight(t.x,t.y,t.z),o.setIntensity(r),o.render(d))},get heightTexture(){var t,r;return null!==(t=null===(r=v.current)||void 0===r?void 0:r.currentTexture)&&void 0!==t?t:null},get causticTexture(){var t,r;return null!==(t=null===(r=p.current)||void 0===r?void 0:r.texture)&&void 0!==t?t:null}}}({poolHalf:E,heightfieldSize:p,causticTextureSize:g,substeps:y,ambientDropPeriod:x}),q=function useWaterPointer(t,r){var a=(0,i.useCallback)((function(r,a){r.uv&&t(new u.FM8(2*r.uv.x-1,1-2*r.uv.y),.1,a)}),[t]);return{onPointerMove:(0,i.useCallback)((function(t){return a(t,.01*r)}),[a,r]),onPointerDown:(0,i.useCallback)((function(t){return a(t,.04*r)}),[a,r])}}(X.queueDrop,w),Y=(0,i.useMemo)((function(){var t=function segs(t){return Math.max(32,Math.min(256,Math.round(50*t)))},r=new u._12(2*E.x,2*E.z,t(2*E.x),t(2*E.z));r.rotateX(Math.PI/2);for(var a=r.attributes.normal.array,o=1;o<a.length;o+=3)a[o]=1;return r}),[E.x,E.z]),J=(0,i.useMemo)((function(){return new u._12(2*E.x,2*E.z)}),[E.x,E.z]),K=(0,i.useMemo)((function(){return new u.vBJ({colorWrite:!1,depthWrite:!1,side:u.ehD})}),[]),Q=(0,i.useMemo)((function(){return function createWaterSurfaceAboveMaterial(){var t,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new u.jyz({vertexShader:D.vertex,fragmentShader:D.fragment,uniforms:_objectSpread(_objectSpread({},buildSharedUniformValues(r)),{},{eye:{value:(null!==(t=r.eye)&&void 0!==t?t:new u.Pa4(0,5,5)).clone()},uSceneColor:{value:null},uResolution:{value:new u.FM8(1,1)},uUseScreenSpaceRefraction:{value:0},uRefractionFallbackColor:{value:new u.Pa4(.039,.145,.251)},uFresnelMax:{value:1},uCausticDebugMode:{value:0},uPoolHeightMap:{value:null}}),transparent:!1,side:u.ehD})}({uPoolHalf:E.clone(),uWallColor:colorToVec3(h),uSkyHorizonColor:colorToVec3(d),uSkyZenithColor:colorToVec3(v)})}),[]);(0,i.useEffect)((function(){return function(){Y.dispose(),J.dispose()}}),[Y,J]),(0,i.useEffect)((function(){return function(){K.dispose(),Q.dispose()}}),[K,Q]),(0,i.useEffect)((function(){updateSharedUniforms(Q,{uPoolHalf:E}),L.f.poolHalf.copy(E)}),[E,Q]),(0,i.useEffect)((function(){return function(){(0,L.g)()}}),[]),(0,i.useEffect)((function(){return function(){var t,r;null===(t=I.current)||void 0===t||t.dispose(),I.current=null,null===(r=Z.current)||void 0===r||r.dispose(),Z.current=null}}),[]),(0,i.useEffect)((function(){var t=colorToVec3(h),r=colorToVec3(d),a=colorToVec3(v);updateSharedUniforms(Q,{uWallColor:t,uSkyHorizonColor:r,uSkyZenithColor:a,uWaterClarity:S})}),[h,d,v,S,Q]),(0,i.useEffect)((function(){var t=colorToVec3(C);Q.uniforms.uRefractionFallbackColor.value.copy(t)}),[C,Q]);var $=(0,i.useRef)(new u.Pa4),ee=(0,i.useRef)(new u.Pa4);return(0,c.F)((function(t,r){if(!T.getContext().isContextLost()){try{!function frameBody(){if(X.advance(r)){var t=R.current;if(t){var a=t.position;$.current.set(A.position.x-a.x,A.position.y-a.y,A.position.z-a.z)}else $.current.copy(A.position);ee.current.set(o[0],o[1],o[2]).normalize(),t&&t.getWorldPosition(L.f.volumeCenter);var i=l.tb.getState(),c=i.articleVersion+i.decorVersion,u=Z.current;u&&(u.renderIfNeeded(T,W,L.f.volumeCenter,E,c,[t]),X.setHeightMap(u.texture)),X.renderCaustics(ee.current,b),updateSharedUniforms(Q,{water:X.heightTexture,causticTex:X.causticTexture,light:ee.current}),Q.uniforms.eye.value.copy($.current);var h=I.current;h&&P&&h.update({renderer:T,scene:W,camera:A,material:Q,surfaceMesh:k.current,volumeCenter:L.f.volumeCenter,poolHalf:E,cssWidth:O.width,cssHeight:O.height,geometryVersion:c,sceneMutating:i.isDragging||null!==i.accessoryMove}),Q.uniforms.uUseScreenSpaceRefraction.value=P?1:0,Q.uniforms.uFresnelMax.value=M,L.f.waterTex=X.heightTexture,L.f.causticTex=X.causticTexture,L.f.light.copy(ee.current),function publishCausticDebugMode(t,r){var a=N[r];L.f.causticDebugMode=a<=3?a:0,t.uniforms.uCausticDebugMode.value=a}(Q,z),Q.uniforms.uPoolHeightMap.value=u?u.texture:null,L.f.enabled=!0}}()}catch(t){if(!T.getContext().isContextLost())throw t;l.tb.getState().setGLContextLost(!0)}}}),V.l.WATER_CAPTURE),(0,U.jsxs)("group",{ref:R,position:r,children:[(0,U.jsx)("mesh",{ref:k,geometry:Y,material:Q,raycast:G}),(0,U.jsx)("mesh",{geometry:J,material:K,rotation:[-Math.PI/2,0,0],onPointerMove:q.onPointerMove,onPointerDown:q.onPointerDown})]})}var G=function NOOP_RAYCAST(){};function colorToVec3(t){var r=new u.Ilk(t);return new u.Pa4(r.r,r.g,r.b)}var X=a(7067);function WaterSurface(){var t,r,a=(0,l.tb)((function(t){return t.resolvedEnvironment.water})),c=(0,l.tb)((function(t){return t.resolvedEnvironment.lighting.sun})),u=(0,l.tb)((function(t){return t.waterVolumeOverride})),h=(0,i.useState)(u),d=(0,o.Z)(h,2),v=d[0],p=d[1];(0,i.useEffect)((function(){if(u!==v){var t=window.setTimeout((function(){return p(u)}),300);return function(){return window.clearTimeout(t)}}}),[u,v]);var m=a.causticSun,g=(0,i.useMemo)((function(){return m?(0,X.mo)(m.azimuth,m.elevation):(0,X.ww)(c)}),[m,c]);return(0,U.jsx)(WaterSurfaceRenderer,{position:null!==(t=null==v?void 0:v.center)&&void 0!==t?t:a.volume.center,volumeSize:null!==(r=null==v?void 0:v.size)&&void 0!==r?r:a.volume.size,sunDirection:g,wallColor:a.wallColor,skyHorizonColor:a.skyHorizonColor,skyZenithColor:a.skyZenithColor,waterClarity:a.waterClarity,ambientDropPeriod:a.ambientDropPeriod,pointerStrength:a.pointerStrength,heightfieldSize:a.heightfieldSize,causticTextureSize:a.causticTextureSize,causticIntensity:a.causticIntensity,useScreenSpaceRefraction:a.useScreenSpaceRefraction,refractionFallbackColor:a.refractionFallbackColor,fresnelMax:a.fresnelMax,causticDebugMode:a.causticDebugMode,substeps:a.waveSpeed})}}}]);
@@ -0,0 +1 @@
1
+ /*! filename:699 */
@@ -0,0 +1,2 @@
1
+ /*! For license information please see 964.real-time-viewer-next.umd.min.js.LICENSE.txt */
2
+ "use strict";(self.webpackChunkCrystaldesignRealTimeViewerNext=self.webpackChunkCrystaldesignRealTimeViewerNext||[]).push([[964],{6964:(t,r,a)=>{a.r(r),a.d(r,{DeckCutoutSubsystem:()=>DeckCutoutSubsystem});var o=a(7363),i=a(7080),l=a(5150),u=a(7659),c=a(4088),m=a(7620),v=a(8683),h=a(6831),p=a(8141),y="Element#",g=new h.ZzF,x=new h.ZzF;function topLevelElements(t){return t.filter((function(t){for(var r=t.parent;r;r=r.parent)if(r.name.startsWith(y))return!1;return!0}))}var b=a(7534);function _createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=function _unsupportedIterableToArray(t,r){if(t){if("string"==typeof t)return _arrayLikeToArray(t,r);var a={}.toString.call(t).slice(8,-1);return"Object"===a&&t.constructor&&(a=t.constructor.name),"Map"===a||"Set"===a?Array.from(t):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?_arrayLikeToArray(t,r):void 0}}(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var l,u=!0,c=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){c=!0,l=t},f:function f(){try{u||null==a.return||a.return()}finally{if(c)throw l}}}}function _arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=Array(r);a<r;a++)o[a]=t[a];return o}var M=1e-9;function polygonSignedArea(t){for(var r=0,a=0;a<t.length;a++){var o=(0,i.Z)(t[a],2),l=o[0],u=o[1],c=(0,i.Z)(t[(a+1)%t.length],2),m=c[0];r+=l*c[1]-m*u}return r/2}function simplifyChain(t,r,a,o,l){for(var u=[r,a];u.length>0;){var c=u.pop(),m=u.pop();if(c-m<2)for(var v=m;v<c;v++)l.push(t[v]);else{for(var h=(0,i.Z)(t[m],2),p=h[0],y=h[1],g=(0,i.Z)(t[c],2),x=g[0],b=g[1],A=Math.hypot(x-p,b-y)||M,S=-1,w=-1,k=m+1;k<c;k++){var C=(0,i.Z)(t[k],2),Z=C[0],T=C[1],O=Math.abs((x-p)*(y-T)-(p-Z)*(b-y))/A;O>S&&(S=O,w=k)}S<=o?l.push(t[m]):u.push(w,c,m,w)}}}function simplifyClosedPolygon(t,r){if(t.length<4||r<=0)return(0,b.Z)(t);for(var a=(0,i.Z)(t[0],2),o=a[0],l=a[1],u=1,c=-1,m=1;m<t.length;m++){var v=Math.hypot(t[m][0]-o,t[m][1]-l);v>c&&(c=v,u=m)}var h=[];simplifyChain(t,0,u,r,h);var p=[].concat((0,b.Z)(t.slice(u)),[t[0]]);return simplifyChain(p,0,p.length-1,r,h),h}function segmentsCross(t,r,a,o,i,l,u,c){var m=function cross(t,r,a,o,i,l){return(a-t)*(l-r)-(o-r)*(i-t)},v=m(t,r,a,o,i,l),h=m(t,r,a,o,u,c),p=m(i,l,u,c,t,r),y=m(i,l,u,c,a,o);return(v>0&&h<0||v<0&&h>0)&&(p>0&&y<0||p<0&&y>0)}function ensureSimplePolygon(t){if(t.length<3)return null;if(function isSimplePolygon(t){var r=t.length;if(r<4)return!0;for(var a=0;a<r;a++)for(var o=(0,i.Z)(t[a],2),l=o[0],u=o[1],c=(0,i.Z)(t[(a+1)%r],2),m=c[0],v=c[1],h=a+1;h<r;h++)if(h!==a+1&&(0!==a||h!==r-1)){var p=(0,i.Z)(t[h],2),y=p[0],g=p[1],x=(0,i.Z)(t[(h+1)%r],2);if(segmentsCross(l,u,m,v,y,g,x[0],x[1]))return!1}return!0}(t))return Math.abs(polygonSignedArea(t))<=M?null:{points:(0,b.Z)(t),repaired:!1};var r=function convexHull(t){if(t.length<3)return(0,b.Z)(t);var r=(0,b.Z)(t).sort((function(t,r){return t[0]-r[0]||t[1]-r[1]})),a=function cross(t,r,a){return(r[0]-t[0])*(a[1]-t[1])-(r[1]-t[1])*(a[0]-t[0])},o=function build(t){var r,o=[],i=_createForOfIteratorHelper(t);try{for(i.s();!(r=i.n()).done;){for(var l=r.value;o.length>=2&&a(o[o.length-2],o[o.length-1],l)<=0;)o.pop();o.push(l)}}catch(t){i.e(t)}finally{i.f()}return o},i=o(r),l=o((0,b.Z)(r).reverse());return[].concat((0,b.Z)(i.slice(0,-1)),(0,b.Z)(l.slice(0,-1)))}(t);return r.length<3||Math.abs(polygonSignedArea(r))<=M?null:{points:r,repaired:!0}}function rasterMask_createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=function rasterMask_unsupportedIterableToArray(t,r){if(t){if("string"==typeof t)return rasterMask_arrayLikeToArray(t,r);var a={}.toString.call(t).slice(8,-1);return"Object"===a&&t.constructor&&(a=t.constructor.name),"Map"===a||"Set"===a?Array.from(t):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?rasterMask_arrayLikeToArray(t,r):void 0}}(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var l,u=!0,c=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){c=!0,l=t},f:function f(){try{u||null==a.return||a.return()}finally{if(c)throw l}}}}function rasterMask_arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=Array(r);a<r;a++)o[a]=t[a];return o}var A=[new Uint8Array(0),new Uint8Array(0)];function pooledMaskBuffer(t,r){A[t].length<r&&(A[t]=new Uint8Array(r));var a=A[t].subarray(0,r);return a.fill(0),a}function closeMask(t,r,a,o){if(!(o<1)){var i=pooledMaskBuffer(1,t.length);boxPassX(t,i,r,a,o,!0),boxPassZ(i,t,r,a,o,!0),boxPassX(t,i,r,a,o,!1),boxPassZ(i,t,r,a,o,!1)}}function fillEnclosed(t,r,a){for(var o=pooledMaskBuffer(1,t.length),i=new Int32Array(t.length),l=0,u=function visit(r){0===t[r]&&0===o[r]&&(o[r]=1,i[l++]=r)},c=0;c<r;c++)u(c),u((a-1)*r+c);for(var m=0;m<a;m++)u(m*r),u(m*r+r-1);for(;l>0;){var v=i[--l],h=v%r,p=(v-h)/r;h>0&&u(v-1),h<r-1&&u(v+1),p>0&&u(v-r),p<a-1&&u(v+r)}for(var y=0,g=0;g<t.length;g++)0===t[g]&&0===o[g]&&(t[g]=1,y+=1);return y}function offsetMask(t,r,a,o,i){var l=pooledMaskBuffer(1,t.length);boxPassX(t,l,r,a,o,i),boxPassZ(l,t,r,a,o,i)}function windowSizes(t,r){for(var a=new Int32Array(r),o=0;o<r;o++)a[o]=Math.min(r-1,o+t)-Math.max(0,o-t)+1;return a}function boxPassX(t,r,a,o,i,l){for(var u=windowSizes(i,a),c=0;c<o;c++){for(var m=c*a,v=0,h=0;h<=i&&h<a;h++)v+=t[m+h];for(var p=0;p<a;p++){r[m+p]=(l?v>0:v===u[p])?1:0;var y=p-i,g=p+i+1;y>=0&&(v-=t[m+y]),g<a&&(v+=t[m+g])}}}function boxPassZ(t,r,a,o,i,l){for(var u=new Int32Array(a),c=windowSizes(i,o),m=0;m<=i&&m<o;m++)for(var v=m*a,h=0;h<a;h++)u[h]+=t[v+h];for(var p=0;p<o;p++){for(var y=p*a,g=c[p],x=0;x<a;x++)r[y+x]=(l?u[x]>0:u[x]===g)?1:0;var b=p-i,M=p+i+1;if(b>=0)for(var A=b*a,S=0;S<a;S++)u[S]-=t[A+S];if(M<o)for(var w=M*a,k=0;k<a;k++)u[k]+=t[w+k]}}var S=[[],[[3,0]],[[0,1]],[[3,1]],[[1,2]],[[3,0],[1,2]],[[0,2]],[[3,2]],[[2,3]],[[0,2]],[[0,1],[2,3]],[[1,2]],[[1,3]],[[0,1]],[[3,0]],[]];function marchingSquaresLoops(t,r,a,o,l,u){for(var c=function edgeKey(t,a,o){return 0===t?2*(o*r+a):2===t?2*((o+1)*r+a):3===t?2*(o*r+a)+1:2*(o*r+a+1)+1},m=function edgePoint(t){var a=Math.floor(t/2),i=a%r,c=Math.floor(a/r);return t%2==0?[o+(i+1)*u,l+(c+.5)*u]:[o+(i+.5)*u,l+(c+1)*u]},v=new Map,h=function link(t,r){var a=v.get(t);a?a.push(r):v.set(t,[r]);var o=v.get(r);o?o.push(t):v.set(r,[t])},p=0;p<a-1;p++)for(var y=0;y<r-1;y++){var g=t[p*r+y]|t[p*r+y+1]<<1|t[(p+1)*r+y+1]<<2|t[(p+1)*r+y]<<3;if(0!==g&&15!==g){var x,b=rasterMask_createForOfIteratorHelper(S[g]);try{for(b.s();!(x=b.n()).done;){var M=(0,i.Z)(x.value,2),A=M[0],w=M[1];h(c(A,y,p),c(w,y,p))}}catch(t){b.e(t)}finally{b.f()}}}var k,C=new Set,Z=[],T=rasterMask_createForOfIteratorHelper(v.keys());try{var O=function _loop(){var t=k.value;if(C.has(t))return 1;for(var r=[],a=t,o=-1;!C.has(a);){var i;C.add(a),r.push(m(a));var l=(null!==(i=v.get(a))&&void 0!==i?i:[]).find((function(t){return t!==o&&!C.has(t)}));if(void 0===l)break;o=a,a=l}r.length>=3&&Z.push(r)};for(T.s();!(k=T.n()).done;)O()}catch(t){T.e(t)}finally{T.f()}return Z}var w=16e6,k=4e6;function footprint_createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=function footprint_unsupportedIterableToArray(t,r){if(t){if("string"==typeof t)return footprint_arrayLikeToArray(t,r);var a={}.toString.call(t).slice(8,-1);return"Object"===a&&t.constructor&&(a=t.constructor.name),"Map"===a||"Set"===a?Array.from(t):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?footprint_arrayLikeToArray(t,r):void 0}}(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var l,u=!0,c=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){c=!0,l=t},f:function f(){try{u||null==a.return||a.return()}finally{if(c)throw l}}}}function footprint_arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=Array(r);a<r;a++)o[a]=t[a];return o}function matchArticleRule(t,r){var a,o=footprint_createForOfIteratorHelper(t);try{for(o.s();!(a=o.n()).done;){var i=a.value,l=i.match.trim();if(""===l||"*"===l)return i;if(void 0!==r)if(l.split(",").map((function(t){return t.trim()})).filter((function(t){return t.length>0})).some((function(t){return r.includes(t)})))return i}}catch(t){o.e(t)}finally{o.f()}return null}function articleFootprint_createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=function articleFootprint_unsupportedIterableToArray(t,r){if(t){if("string"==typeof t)return articleFootprint_arrayLikeToArray(t,r);var a={}.toString.call(t).slice(8,-1);return"Object"===a&&t.constructor&&(a=t.constructor.name),"Map"===a||"Set"===a?Array.from(t):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?articleFootprint_arrayLikeToArray(t,r):void 0}}(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var l,u=!0,c=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){c=!0,l=t},f:function f(){try{u||null==a.return||a.return()}finally{if(c)throw l}}}}function articleFootprint_arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=Array(r);a<r;a++)o[a]=t[a];return o}var C=.6,Z=new h.yGw,T=new h.Pa4;function measuredRectFootprint(t,r){var a=t.minX-r,o=t.maxX+r,i=t.minZ-r,l=t.maxZ+r;return o-a<.1||l-i<.1?null:[[a,i],[o,i],[o,l],[a,l]]}function traceArticleFootprint(t,r,a,o,l,u,c,m){var v,h=[],p=[],y=articleFootprint_createForOfIteratorHelper(t);try{for(y.s();!(v=y.n()).done;){v.value.traverse((function(t){var r=t;if(r.isMesh&&r.visible){var a=r.geometry.getAttribute("position");a&&(h.push(r),p.push("".concat(r.name,":").concat(a.count)))}}))}}catch(t){y.e(t)}finally{y.f()}if(0===h.length)return null;var g=a.maxX-a.minX,x=a.maxY-a.minY,b=a.maxZ-a.minZ,M="".concat(o.toFixed(3),"|").concat((a.maxY+m).toFixed(3),"|").concat(l.toFixed(3),"|").concat(g.toFixed(3),"x").concat(x.toFixed(3),"x").concat(b.toFixed(3),"|").concat(p.join(","));if(!c.current||c.current.signature!==M){var A=performance.now(),S=0,C=h.map((function(t){var a=t.geometry.getAttribute("position");S+=a.count,Z.multiplyMatrices(r,t.matrixWorld);for(var o=new Float32Array(3*a.count),i=0;i<a.count;i++)T.set(a.getX(i),a.getY(i),a.getZ(i)).applyMatrix4(Z),o[3*i]=T.x,o[3*i+1]=T.y+m,o[3*i+2]=T.z;return o})),O=function forEachSliceTriangle(t){for(var r=0,a=0;a<h.length;a++)for(var i=h[a].geometry,l=i.getAttribute("position"),u=C[a],c=i.index,m=c?Math.floor(c.count/3):Math.floor(l.count/3),v=0;v<m;v++){var p=c?c.getX(3*v):3*v,y=c?c.getX(3*v+1):3*v+1,g=c?c.getX(3*v+2):3*v+2;u[3*p+1]<o&&u[3*y+1]<o&&u[3*g+1]<o||(r+=1,t&&t(u[3*p],u[3*p+2],u[3*y],u[3*y+2],u[3*g],u[3*g+2]))}return r},X=O(null),E=new Float32Array(6*X),I=0;O((function(t,r,a,o,i,l){E[I]=t,E[I+1]=r,E[I+2]=a,E[I+3]=o,E[I+4]=i,E[I+5]=l,I+=6}));var D=function traceFootprintFromTriangles(t){var r,a,o,l,u=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},c=null!==(r=u.cellSize)&&void 0!==r?r:.005,m=Math.floor(t.length/6);if(m<1||c<=0)return[];for(var v=1/0,h=-1/0,p=1/0,y=-1/0,g=0;g<6*m;g+=2){var x=t[g],b=t[g+1];x<v&&(v=x),x>h&&(h=x),b<p&&(p=b),b>y&&(y=b)}if(!Number.isFinite(v)||h-v<c||y-p<c)return[];var M=(Math.ceil((h-v)/c)+1)*(Math.ceil((y-p)/c)+1),A=M>k?c*Math.sqrt(M/k):c,S=null!==(a=u.simplifyTolerance)&&void 0!==a?a:A,C=null!==(o=u.closeGap)&&void 0!==o?o:.02,Z=C<=0?0:Math.max(1,Math.round(C/(2*A))),T=null!==(l=u.offset)&&void 0!==l?l:0,O=Math.round(Math.abs(T)/A),X=T>0,E=Z+(X?O:0)+1,I=v-E*A,D=p-E*A,_=Math.ceil((h-v)/A)+2*E+1,L=Math.ceil((y-p)/A)+2*E+1;if(_*L>w)return[];for(var j=pooledMaskBuffer(0,_*L),z=function cellOf(t,r,a){return Math.min(a-E-1,Math.max(E,Math.floor((t-r)/A)))},P=function mark(t,r){j[z(r,D,L)*_+z(t,I,_)]=1},N=0;N<m;N++){var Y=6*N,R=t[Y],B=t[Y+1],H=t[Y+2],U=t[Y+3],W=t[Y+4],V=t[Y+5];P(R,B),P(H,U),P(W,V);var q=Math.abs((H-R)*(V-B)-(W-R)*(U-B)),G=Math.max(Math.hypot(H-R,U-B),Math.hypot(W-H,V-U),Math.hypot(R-W,B-V));if((G>1e-9?q/G:0)<1.5*A)for(var $=0,K=[[R,B,H,U],[H,U,W,V],[W,V,R,B]];$<K.length;$++)for(var J=(0,i.Z)(K[$],4),Q=J[0],ee=J[1],te=J[2],re=J[3],ne=Math.ceil(Math.hypot(te-Q,re-ee)/(.7*A)),ae=1;ae<ne;ae++){var oe=ae/ne;P(Q+(te-Q)*oe,ee+(re-ee)*oe)}for(var ie=z(Math.min(B,U,V),D,L),le=z(Math.max(B,U,V),D,L),ue=ie;ue<=le;ue++){for(var ce=D+(ue+.5)*A,fe=1/0,se=-1/0,me=0;me<3;me++){var ve=0===me?R:1===me?H:W,de=0===me?B:1===me?U:V,he=0===me?H:1===me?W:R,pe=0===me?U:1===me?V:B;if(de!==pe&&!(ce<Math.min(de,pe)||ce>=Math.max(de,pe))){var ye=ve+(ce-de)/(pe-de)*(he-ve);ye<fe&&(fe=ye),ye>se&&(se=ye)}}if(!(fe>se)){var ge=Math.max(E,Math.ceil((fe-I)/A-.5)),xe=Math.min(_-E-1,Math.floor((se-I)/A-.5));ge<=xe&&j.fill(1,ue*_+ge,ue*_+xe+1)}}}closeMask(j,_,L,Z);var be=fillEnclosed(j,_,L);O>=1&&offsetMask(j,_,L,O,X);var Me=u.diagnostics;if(Me){Me.enclosedFilled=be;for(var Ae=0,Se=0;Se<j.length;Se++)Ae+=j[Se];Me.filledCells=Ae}var Fe=marchingSquaresLoops(j,_,L,I,D,A);if(Me&&(Me.loops=Fe.length),0===Fe.length)return[];for(var we=Fe[0],ke=Math.abs(polygonSignedArea(we)),Ce=ke,Ze=1;Ze<Fe.length;Ze++){var Te=Math.abs(polygonSignedArea(Fe[Ze]));Ce+=Te,Te>ke&&(ke=Te,we=Fe[Ze])}var Oe=simplifyClosedPolygon(we,S);return Me&&(Me.chosenAreaShare=Ce>0?ke/Ce:0,Me.pointsBeforeSimplify=we.length,Me.pointsAfterSimplify=Oe.length),Oe.length>=3?Oe:[]}(E,{cellSize:.005,offset:l,diagnostics:u});return c.current={signature:M,relPoints:D.map((function(t){var r=(0,i.Z)(t,2),o=r[0],l=r[1];return[o-a.minX,l-a.minZ]})),triCount:X,vertexCount:S},{points:D,triCount:X,vertexCount:S,retraced:!0,traceMs:performance.now()-A}}var _=c.current,L=_.relPoints,j=_.triCount,z=_.vertexCount;return{points:L.map((function(t){var r=(0,i.Z)(t,2),o=r[0],l=r[1];return[o+a.minX,l+a.minZ]})),triCount:j,vertexCount:z,retraced:!1,traceMs:0}}function anchorElements_createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=function anchorElements_unsupportedIterableToArray(t,r){if(t){if("string"==typeof t)return anchorElements_arrayLikeToArray(t,r);var a={}.toString.call(t).slice(8,-1);return"Object"===a&&t.constructor&&(a=t.constructor.name),"Map"===a||"Set"===a?Array.from(t):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?anchorElements_arrayLikeToArray(t,r):void 0}}(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var l,u=!0,c=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){c=!0,l=t},f:function f(){try{u||null==a.return||a.return()}finally{if(c)throw l}}}}function anchorElements_arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=Array(r);a<r;a++)o[a]=t[a];return o}var O=.001,X=new h.Pa4,E=new h.Pa4;function anchorDelta1D(t,r,a,o,i,l){return"min"===t?r-a+l-o:"max"===t?r+a-l-i:r+l-(o+i)/2}var I=new h.Vkp,D=new h.Pa4,_=new h.Pa4,L=new h.Pa4;function measureDiagnostics_createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=function measureDiagnostics_unsupportedIterableToArray(t,r){if(t){if("string"==typeof t)return measureDiagnostics_arrayLikeToArray(t,r);var a={}.toString.call(t).slice(8,-1);return"Object"===a&&t.constructor&&(a=t.constructor.name),"Map"===a||"Set"===a?Array.from(t):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?measureDiagnostics_arrayLikeToArray(t,r):void 0}}(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var l,u=!0,c=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){c=!0,l=t},f:function f(){try{u||null==a.return||a.return()}finally{if(c)throw l}}}}function measureDiagnostics_arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=Array(r);a<r;a++)o[a]=t[a];return o}var j=a(4399);function ownKeys(t,r){var a=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);r&&(o=o.filter((function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable}))),a.push.apply(a,o)}return a}function _objectSpread(t){for(var r=1;r<arguments.length;r++){var a=null!=arguments[r]?arguments[r]:{};r%2?ownKeys(Object(a),!0).forEach((function(r){(0,l.Z)(t,r,a[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(a)):ownKeys(Object(a)).forEach((function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(a,r))}))}return t}var z=(0,v.getLogger)("RealTimeViewer","DeckCutoutArticleSync");function DeckCutoutArticleSync(){var t=(0,c.D)((function(t){return t.scene})),r=(0,u.K)((function(t){return t.scene.deckCutout})),a=(0,m.tb)((function(t){return t.setWaterVolumeOverride})),l=(0,m.tb)((function(t){return t.setDeckCutoutFootprintOverride})),v=(0,o.useRef)(0),b=(0,o.useRef)(0),M=(0,o.useRef)(!1),A=(0,o.useRef)(null),S=(0,o.useRef)(null),w=(0,o.useRef)(!1),k=(0,o.useRef)(0),Z=r.enabled&&r.articleSync.enabled,T=Z&&r.elementAnchor.enabled,P=Z&&r.waterSync.enabled;(0,o.useEffect)((function(){return Z||l(null),function(){return l(null)}}),[Z,l]),(0,o.useEffect)((function(){var t=function clear(){Object.keys(m.tb.getState().elementAnchorOffsets).length>0&&m.tb.getState().setElementAnchorOffsets({})};return T||t(),t}),[T]),(0,o.useEffect)((function(){return P||a(null),function(){return a(null)}}),[P,a]);var N=(0,o.useMemo)((function(){return r.nodeMatch.split(",").map((function(t){return t.trim()})).filter((function(t){return t.length>0}))}),[r.nodeMatch]),Y=(0,m.tb)((function(t){return t.articleVersion})),R=(0,m.tb)((function(t){return t.decorVersion}));return(0,o.useEffect)((function(){Z&&(w.current=!0,k.current=0)}),[Y,R,Z]),(0,c.F)((function(){if(Z&&0!==N.length&&(v.current+=1,w.current||v.current%30==1)){var o=m.tb.getState(),u=o.waterVolumeOverride,c=o.deckCutoutFootprintOverride,Y=!1,R=function finishMeasure(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(t)return k.current=0,void(w.current=!1);var r=m.tb.getState(),a=Y||r.waterVolumeOverride!==u||r.deckCutoutFootprintOverride!==c;if(a)return k.current=0,void(w.current=!0);k.current+=1,k.current>=3&&(w.current=!1)};b.current+=1;var B=function measureArticle(t,r,a){var o,i,l=[],u=[],c=[];if(x.makeEmpty(),t.traverse((function(t){var o;if(0===c.length){var i=t;i.isMesh&&r.some((function(t){return i.name.includes(t)}))&&c.push(i)}if(t.name.startsWith(y)&&(l.push(t),g.setFromObject(t),!g.isEmpty())){x.union(g);var m=null===(o=a.get((0,p.zs)(t.name)))||void 0===o?void 0:o.articleCodex;void 0!==m&&u.push({codex:m,area:(g.max.x-g.min.x)*(g.max.z-g.min.z)})}})),u.sort((function(t,r){return r.area-t.area})),x.isEmpty())return null;var m=c[0];if(!m)return null;var v=(new h.yGw).copy(m.matrixWorld).invert(),b=m.geometry;b.boundingBox||b.computeBoundingBox();var M=null!==(o=null===(i=b.boundingBox)||void 0===i?void 0:i.max.y)&&void 0!==o?o:0,A=x.min.y;return x.applyMatrix4(v),{rect:{minX:x.min.x,maxX:x.max.x,minY:x.min.y,maxY:x.max.y,minZ:x.min.z,maxZ:x.max.z},worldBottomY:A,elementObjects:l,codexesByArea:u,floorWorld:m.matrixWorld,floorLocal:v,floorTopY:M}}(t,N,m.tb.getState().elementsInfo);if(!B)return a(null),l(null),void R(!0);var H=function pickArticleRule(t,r){var a,o,i=null===(a=r[0])||void 0===a?void 0:a.codex,l=matchArticleRule(t,void 0),u=articleFootprint_createForOfIteratorHelper(r);try{for(u.s();!(o=u.n()).done;){var c=o.value,m=matchArticleRule(t,c.codex);if(m){l=m,i=c.codex;break}}}catch(t){u.e(t)}finally{u.f()}return{rule:l,primaryCodex:i}}(r.articleRules,B.codexesByArea),U=H.rule,W=H.primaryCodex,V=r.elementAnchor,q=T?(V.alignTopToDeck?B.floorTopY-B.rect.maxY:0)+V.offsetY:0,G=function deriveArticleFootprint(t,r,a,o){var l,u,c=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,m={points:null,rim:null,sampledCount:0,source:"",repairNote:"",tracedBounds:"",trace:{filledCells:0,enclosedFilled:0,loops:0,chosenAreaShare:0,pointsBeforeSimplify:0,pointsAfterSimplify:0}};if(!r||!r.footprintFromGeometry)return m;var v=t.rect,h=t.floorLocal,p=t.floorTopY,y=t.elementObjects,g=v.maxX-v.minX,x=v.maxZ-v.minZ,b=traceArticleFootprint(topLevelElements(y),h,v,p-r.footprintSliceDepth,a,m.trace,o,c),M=1/0,A=-1/0,S=1/0,w=-1/0;if(b&&b.points.length>=3){var k,Z=articleFootprint_createForOfIteratorHelper(b.points);try{for(Z.s();!(k=Z.n()).done;){var T=(0,i.Z)(k.value,2),O=T[0],X=T[1];O<M&&(M=O),O>A&&(A=O),X<S&&(S=X),X>w&&(w=X)}}catch(t){Z.e(t)}finally{Z.f()}M+=a,A-=a,S+=a,w-=a,m.tracedBounds="X [".concat(M.toFixed(2),", ").concat(A.toFixed(2),"] Z [").concat(S.toFixed(2),", ").concat(w.toFixed(2),"]")}var E=A>M&&A-M>=g*C&&w-S>=x*C;if(b&&E){var I;m.rim={minX:M,maxX:A,minZ:S,maxZ:w};var D=ensureSimplePolygon(b.points);return null!=D&&D.repaired&&(m.repairNote=" | HULL-REPAIRED, traced outline self-intersects (concavities lost)"),null===D&&(m.repairNote=" | outline UNUSABLE even as a hull"),m.points=null!==(I=null==D?void 0:D.points)&&void 0!==I?I:null,m.sampledCount=b.points.length,m.source=b.retraced?"geometry traced in ".concat(b.traceMs.toFixed(1)," ms (").concat(b.vertexCount," verts, ").concat(b.triCount," tris in slice)"):"geometry cached (".concat(b.triCount," tris in slice)"),m}return m.points=measuredRectFootprint(v,a),m.sampledCount=null!==(l=null===(u=m.points)||void 0===u?void 0:u.length)&&void 0!==l?l:0,m.source=A>M?"geometry: TRACE COVERS ONLY ".concat(((A-M)/g*100).toFixed(0),"%×").concat(((w-S)/x*100).toFixed(0),"% of the article — fell back to the measured rect"):"geometry: NO TRIANGLES ABOVE THE SLICE PLANE — fell back to the measured rect",m}(B,U,r.articleSync.margin,S,q),$=G.rim?_objectSpread(_objectSpread({},B.rect),G.rim):B.rect,K=function measureLog(t){var r,a,o,l=t.measurement,u=t.rule,c=t.primaryCodex,m=t.footprint,v=t.hole,h=l.rect,p=l.floorTopY,y=m.points,g=1/0,x=-1/0,b=1/0,M=-1/0;if(y){var A,S=measureDiagnostics_createForOfIteratorHelper(y);try{for(S.s();!(A=S.n()).done;){var w=(0,i.Z)(A.value,2),k=w[0],C=w[1];k<g&&(g=k),k>x&&(x=k),C<b&&(b=C),C>M&&(M=C)}}catch(t){S.e(t)}finally{S.f()}}var Z=y?[g,x,b,M]:null;return{key:"".concat(null!=c?c:"","|").concat(null!==(r=null==u?void 0:u.match)&&void 0!==r?r:"","|").concat(m.sampledCount,"|").concat(null!==(a=null==y?void 0:y.length)&&void 0!==a?a:0,"|").concat(null!==(o=null==Z?void 0:Z.map((function(t){return t.toFixed(2)})).join(","))&&void 0!==o?o:""),message:function message(){var t,r=h.maxX-h.minX,a=h.maxZ-h.minZ,o=u&&u.footprintFromGeometry?" | Y: deck top ".concat(p.toFixed(2),", article [").concat(h.minY.toFixed(2),", ").concat(h.maxY.toFixed(2),"], slice keeps ≥ ").concat((p-u.footprintSliceDepth).toFixed(2)):"";if(""===m.source)t=" | NO outline rule matched this codex → NO COLLAR, the authored hole stays fully open";else if(Z&&y){var i=[Z[0]-(v.centerX-v.halfExtentX),v.centerX+v.halfExtentX-Z[1],Z[2]-(v.centerZ-v.halfExtentZ),v.centerZ+v.halfExtentZ-Z[3]].map((function(t){return t.toFixed(2)}));t=" | measured ".concat(r.toFixed(2),"×").concat(a.toFixed(2))+(""===m.tracedBounds?"":" | traced ".concat(m.sampledCount," pts ").concat(m.tracedBounds))+" | outline ".concat(y.length," pts X [").concat(Z[0].toFixed(2),", ").concat(Z[1].toFixed(2),"] Z [").concat(Z[2].toFixed(2),", ").concat(Z[3].toFixed(2),"]")+" | hole X [".concat((v.centerX-v.halfExtentX).toFixed(2),", ").concat((v.centerX+v.halfExtentX).toFixed(2),"] Z [").concat((v.centerZ-v.halfExtentZ).toFixed(2),", ").concat((v.centerZ+v.halfExtentZ).toFixed(2),"]")+" | slack X ".concat(i[0],"/").concat(i[1]," Z ").concat(i[2],"/").concat(i[3])+" | ".concat(m.source).concat(m.repairNote)+(m.trace.loops>0?" | trace: ".concat(m.trace.filledCells," cells (").concat(m.trace.enclosedFilled," filled in), ").concat(m.trace.loops," loop(s), kept ").concat((100*m.trace.chosenAreaShare).toFixed(0),"% of contour area, ").concat(m.trace.pointsBeforeSimplify," → ").concat(m.trace.pointsAfterSimplify," pts"):"")}else t=" | ".concat(m.source," produced NO usable outline (").concat(m.sampledCount," pts)").concat(m.repairNote," → NO COLLAR, the authored hole stays fully open");return"[DeckCutout] article codex: ".concat(null!=c?c:"(unknown)"," → rule: ").concat(u?"'".concat(u.match,"'"):"(none — articleSync globals)").concat(o).concat(t)}}}({measurement:B,rule:U,primaryCodex:W,footprint:G,hole:r.authoredHole});A.current!==K.key&&(A.current=K.key,z.debug(K.message()));var J=T?function deriveElementAnchor(t){var r=t.rect,a=t.hole,o=t.anchor,i=t.floorWorld,l=t.elementObjects,u=t.deckTopLocalY,c=t.currentOffsets,m=anchorDelta1D(o.anchorX,a.centerX,a.halfExtentX,r.minX,r.maxX,o.offsetX),v=anchorDelta1D(o.anchorZ,a.centerZ,a.halfExtentZ,r.minZ,r.maxZ,o.offsetZ),h=(r.minX+r.maxX)/2,y=(r.minZ+r.maxZ)/2,g=r.maxY,x=(o.alignTopToDeck?u-g:0)+o.offsetY;X.set(h+m,g+x,y+v).applyMatrix4(i),E.set(h,g,y).applyMatrix4(i);var b=X.x-E.x,M=X.y-E.y,A=X.z-E.z;if(Math.abs(b)<O&&Math.abs(M)<O&&Math.abs(A)<O)return null;var S=topLevelElements(l);if(0===S.length)return null;var w,k={},C=anchorElements_createForOfIteratorHelper(S);try{for(C.s();!(w=C.n()).done;){var Z,T=w.value,I=(0,p.zs)(T.name),D=null!==(Z=c[I])&&void 0!==Z?Z:[0,0,0];k[I]=[D[0]+b,D[1]+M,D[2]+A]}}catch(t){C.e(t)}finally{C.f()}return{delta:{dx:m,dy:x,dz:v},offsets:k}}({rect:$,hole:r.authoredHole,anchor:r.elementAnchor,floorWorld:B.floorWorld,elementObjects:B.elementObjects,deckTopLocalY:B.floorTopY,currentOffsets:m.tb.getState().elementAnchorOffsets}):null;Y=null!==J,J&&m.tb.getState().setElementAnchorOffsets(J.offsets);var Q=J?function shiftRect(t,r){return{minX:t.minX+r.dx,maxX:t.maxX+r.dx,minY:t.minY+r.dy,maxY:t.maxY+r.dy,minZ:t.minZ+r.dz,maxZ:t.maxZ+r.dz}}($,J.delta):$;l(G.points&&J?G.points.map((function(t){var r=(0,i.Z)(t,2),a=r[0],o=r[1];return[a+J.delta.dx,o+J.delta.dz]})):G.points),M.current||null===m.tb.getState().deckCutoutFootprintOverride||(M.current=!0,(0,j._m)("deck: first footprint published",{measures:b.current})),P&&a(function deriveWaterVolume(t){var r=t.rect,a=t.waterSync,o=t.floorWorld,i=t.articleWorldBottomY,l=t.waterlineY,u=a.inset,c=Math.max(r.maxX-r.minX-2*u,.1),m=Math.max(r.maxZ-r.minZ-2*u,.1);D.set((r.minX+r.maxX)/2+a.offsetX,0,(r.minZ+r.maxZ)/2+a.offsetZ),D.applyMatrix4(o),I.setFromMatrix4(o),_.set(c,0,0).applyMatrix3(I),L.set(0,0,m).applyMatrix3(I);var v=Math.abs(_.x)+Math.abs(L.x),h=Math.abs(_.z)+Math.abs(L.z),p=Math.max(l-i,.5);return{center:[D.x,l,D.z],size:[v,p,h]}}({rect:Q,waterSync:r.waterSync,floorWorld:B.floorWorld,articleWorldBottomY:B.worldBottomY,waterlineY:m.tb.getState().resolvedEnvironment.water.volume.center[1]})),R()}})),null}var P=12,N=1e-12;function solve3(t,r){var a=t[0]*(t[4]*t[8]-t[5]*t[7])-t[1]*(t[3]*t[8]-t[5]*t[6])+t[2]*(t[3]*t[7]-t[4]*t[6]);if(Math.abs(a)<N)return null;return[function d(r,a,o){return r*(t[4]*t[8]-t[5]*t[7])-t[1]*(a*t[8]-t[5]*o)+t[2]*(a*t[7]-t[4]*o)}(r[0],r[1],r[2])/a,(t[0]*(r[1]*t[8]-t[5]*r[2])-r[0]*(t[3]*t[8]-t[5]*t[6])+t[2]*(t[3]*r[2]-r[1]*t[6]))/a,(t[0]*(t[4]*r[2]-r[1]*t[7])-t[1]*(t[3]*r[2]-r[1]*t[6])+r[0]*(t[3]*t[7]-t[4]*t[6]))/a]}function fitAffineUV(t,r){var a=3*r;if(a<3)return null;for(var o=0,i=0,l=0,u=0,c=0,m=0,v=0,h=0,p=0,y=0,g=0,x=0;x<a;x++){var b=4*x,M=t[b],A=t[b+1],S=t[b+2],w=t[b+3];o+=M*M,i+=M*A,l+=M,u+=A*A,c+=A,m+=M*S,v+=A*S,h+=S,p+=M*w,y+=A*w,g+=w}var k=[o,i,l,i,u,c,l,c,a],C=solve3(k,[m,v,h]),Z=solve3(k,[p,y,g]);if(!C||!Z)return null;for(var T=0,O=0;O<a;O++){var X=4*O,E=t[X],I=t[X+1],D=C[0]*E+C[1]*I+C[2]-t[X+2],_=Z[0]*E+Z[1]*I+Z[2]-t[X+3];T+=D*D+_*_}var L=(Math.hypot(C[0],C[1])+Math.hypot(Z[0],Z[1]))/2,j=Math.sqrt(T/a);return{ux:C[0],uz:C[1],u0:C[2],vx:Z[0],vz:Z[1],v0:Z[2],residualMetres:L>N?j/L:1/0}}function segmentDistanceSq(t,r,a,o,i,l){var u=i-a,c=l-o,m=u*u+c*c,v=m<N?0:Math.max(0,Math.min(1,((t-a)*u+(r-o)*c)/m)),h=a+v*u-t,p=o+v*c-r;return h*h+p*p}function triangleDistanceSq(t,r,a,o,i,l,u,c){if((i-a)*(c-o)-(u-a)*(l-o)==0)return 1/0;var m=(i-a)*(r-o)-(l-o)*(t-a),v=(u-i)*(r-l)-(c-l)*(t-i),h=(a-u)*(r-c)-(o-c)*(t-u);return m>=0&&v>=0&&h>=0||m<=0&&v<=0&&h<=0?0:Math.min(segmentDistanceSq(t,r,a,o,i,l),segmentDistanceSq(t,r,i,l,u,c),segmentDistanceSq(t,r,u,c,a,o))}function nearestTriangleLinear(t,r,a,o){for(var i=1/0,l=-1,u=0;u<r;u++){var c=u*P,m=triangleDistanceSq(a,o,t[c],t[c+1],t[c+4],t[c+5],t[c+8],t[c+9]);if(m<i&&(i=m,l=u,0===m))break}return l}var Y=1e7;function isFiniteXZ(t,r,a,o,i,l){return Number.isFinite(t)&&Number.isFinite(r)&&Number.isFinite(a)&&Number.isFinite(o)&&Number.isFinite(i)&&Number.isFinite(l)}function gridDim(t,r){return Math.min(256,Math.max(1,Math.ceil(t/r)))}function cellOf(t,r,a,o){var i=Math.floor((t-r)/a);return i<0?0:i>=o?o-1:i}function buildTriangleGridIndex(t,r){if(r<64)return null;for(var a=1/0,o=-1/0,i=1/0,l=-1/0,u=0,c=0,m=0;m<r;m++){var v=m*P,h=t[v],p=t[v+1],y=t[v+4],g=t[v+5],x=t[v+8],b=t[v+9];if(isFiniteXZ(h,p,y,g,x,b)){var M=Math.min(h,y,x),A=Math.max(h,y,x),S=Math.min(p,g,b),w=Math.max(p,g,b);M<a&&(a=M),A>o&&(o=A),S<i&&(i=S),w>l&&(l=w),u+=Math.max(A-M,w-S),c+=1}}if(c<64||r-c>.25*r)return null;var k=o-a,C=l-i,Z=Math.max(k,C);if(!(Z>0))return null;var T=k*C/c,O=Math.max(u/c,T>0?Math.sqrt(T):0,Z/256),X=gridDim(k,O),E=gridDim(C,O),I=Math.max(1024,4*c);X*E>I&&(X=gridDim(k,O*=Math.sqrt(X*E/I)),E=gridDim(C,O));for(var D=X*E,_=new Int32Array(4*r),L=new Int32Array(D+1),j=[],z=0;z<r;z++){var N=z*P,Y=t[N],R=t[N+1],B=t[N+4],H=t[N+5],U=t[N+8],W=t[N+9];if(isFiniteXZ(Y,R,B,H,U,W)&&(B-Y)*(W-R)-(U-Y)*(H-R)!=0){var V=cellOf(Math.min(Y,B,U),a,O,X),q=cellOf(Math.max(Y,B,U),a,O,X),G=cellOf(Math.min(R,H,W),i,O,E),$=cellOf(Math.max(R,H,W),i,O,E);if((q-V+1)*($-G+1)>64)_[4*z]=-1,j.push(z);else{_[4*z]=V,_[4*z+1]=q,_[4*z+2]=G,_[4*z+3]=$;for(var K=G;K<=$;K++)for(var J=V;J<=q;J++)L[K*X+J+1]+=1}}else _[4*z]=-1,j.push(z)}if(j.length>.25*r)return null;for(var Q=0;Q<D;Q++)L[Q+1]+=L[Q];for(var ee=new Int32Array(L[D]),te=L.slice(0,D),re=0;re<r;re++){var ne=_[4*re];if(!(ne<0))for(var ae=_[4*re+1],oe=_[4*re+2],ie=_[4*re+3],le=oe;le<=ie;le++)for(var ue=ne;ue<=ae;ue++){var ce=le*X+ue;ee[te[ce]]=re,te[ce]+=1}}return{triangleCount:r,minX:a,minZ:i,cellSize:O,cols:X,rows:E,cellStart:L,cellItems:ee,extras:Int32Array.from(j)}}function sampleNearestTriangleUV(t,r,a,o,i){var l=i&&i.triangleCount===r?function nearestTriangleIndexed(t,r,a,o){var i=o.minX,l=o.minZ,u=o.cellSize,c=o.cols,m=o.rows,v=o.cellStart,h=o.cellItems,p=o.extras,y=Math.floor((r-i)/u),g=Math.floor((a-l)/u);if(!Number.isFinite(y)||!Number.isFinite(g)||Math.abs(y)>Y||Math.abs(g)>Y)return nearestTriangleLinear(t,o.triangleCount,r,a);for(var x=1/0,b=-1,M=function consider(o){var i=o*P,l=triangleDistanceSq(r,a,t[i],t[i+1],t[i+4],t[i+5],t[i+8],t[i+9]);(l<x||l===x&&o<b)&&(x=l,b=o)},A=function scanCell(t){for(var r=v[t+1],a=v[t];a<r;a++)M(h[a])},S=0;S<p.length;S++)M(p[S]);for(var w=Math.max(0,-y,y-c+1,-g,g-m+1),k=Math.max(y,c-1-y,g,m-1-g),C=w;C<=k;C++){var Z=y-C,T=y+C,O=g-C,X=g+C,E=Math.max(0,Z),I=Math.min(c-1,T);if(O>=0&&O<m)for(var D=E;D<=I;D++)A(O*c+D);if(C>0){if(X>=0&&X<m)for(var _=E;_<=I;_++)A(X*c+_);var L=Math.max(0,O+1),j=Math.min(m-1,X-1);if(Z>=0&&Z<c)for(var z=L;z<=j;z++)A(z*c+Z);if(T>=0&&T<c)for(var N=L;N<=j;N++)A(N*c+T)}var R=Math.min(r-(i+Z*u),i+(T+1)*u-r,a-(l+O*u),l+(X+1)*u-a);if(R>0&&x<R*R*(1-1e-9))return b}return b}(t,a,o,i):nearestTriangleLinear(t,r,a,o);if(l<0)return null;var u=l*P,c=t[u],m=t[u+1],v=t[u+4],h=t[u+5],p=t[u+8],y=t[u+9],g=(h-y)*(c-p)+(p-v)*(m-y);if(Math.abs(g)<N)return null;var x=((h-y)*(a-p)+(p-v)*(o-y))/g,b=((y-m)*(a-p)+(c-p)*(o-y))/g,M=1-x-b;return[x*t[u+2]+b*t[u+6]+M*t[u+10],x*t[u+3]+b*t[u+7]+M*t[u+11]]}var R=a(7831);function collectDeckTriangles_createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=function collectDeckTriangles_unsupportedIterableToArray(t,r){if(t){if("string"==typeof t)return collectDeckTriangles_arrayLikeToArray(t,r);var a={}.toString.call(t).slice(8,-1);return"Object"===a&&t.constructor&&(a=t.constructor.name),"Map"===a||"Set"===a?Array.from(t):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?collectDeckTriangles_arrayLikeToArray(t,r):void 0}}(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var l,u=!0,c=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){c=!0,l=t},f:function f(){try{u||null==a.return||a.return()}finally{if(c)throw l}}}}function collectDeckTriangles_arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=Array(r);a<r;a++)o[a]=t[a];return o}var B=.005,H=new h.yGw,U=new h.Vkp,W=new h.Pa4,V=new h.Pa4;function sampleDeckSurface(t,r){var a,o,i,l,u,c=function meshesMatching(t,r){var a=[];return t.traverse((function(t){var o=t;o.isMesh&&r.some((function(t){return o.name.includes(t)}))&&a.push(o)})),a}(t,r),m=null!==(a=c[0])&&void 0!==a?a:null;if(!m)return{reference:null,surface:null};var v=m.geometry;v.boundingBox||v.computeBoundingBox();var p,y,g=function patternAttributeName(t){var r=Array.isArray(t)?t[0]:t;return r instanceof h.Wid&&r.map?0===r.map.channel?"uv":"uv".concat(r.map.channel):"uv"}(m.material),x=function collectDeckTriangles(t,r,a){var o,i=H.copy(r.matrixWorld).invert().clone(),l=[],u={minX:1/0,maxX:-1/0,minZ:1/0,maxZ:-1/0},c=collectDeckTriangles_createForOfIteratorHelper(t);try{for(c.s();!(o=c.n()).done;){var m,v=o.value,h=v.geometry,p=h.getAttribute("position"),y=null!==(m=h.getAttribute(a))&&void 0!==m?m:h.getAttribute("uv");if(p&&y){var g=h.getAttribute("normal");H.multiplyMatrices(i,v.matrixWorld);for(var x=new Float32Array(3*p.count),b=0;b<p.count;b++)W.set(p.getX(b),p.getY(b),p.getZ(b)).applyMatrix4(H),x[3*b]=W.x,x[3*b+1]=W.y,x[3*b+2]=W.z,W.x<u.minX&&(u.minX=W.x),W.x>u.maxX&&(u.maxX=W.x),W.z<u.minZ&&(u.minZ=W.z),W.z>u.maxZ&&(u.maxZ=W.z);var M=new Float32Array(g?g.count:0);if(g){U.getNormalMatrix(H);for(var A=0;A<g.count;A++)V.set(g.getX(A),g.getY(A),g.getZ(A)).applyMatrix3(U).normalize(),M[A]=V.y}var S=-1/0;if(!g){for(var w=1/0,k=-1/0,C=0;C<p.count;C++){var Z=x[3*C+1];Z<w&&(w=Z),Z>k&&(k=Z)}S=(w+k)/2}for(var T=h.index,O=T?Math.floor(T.count/3):Math.floor(p.count/3),X=0;X<O;X++){var E=T?T.getX(3*X):3*X,I=T?T.getX(3*X+1):3*X+1,D=T?T.getX(3*X+2):3*X+2;if(g?M[E]>=.9&&M[I]>=.9&&M[D]>=.9:x[3*E+1]>S&&x[3*I+1]>S&&x[3*D+1]>S)for(var _=0,L=[E,I,D];_<L.length;_++){var j=L[_];l.push(x[3*j],x[3*j+2],y.getX(j),y.getY(j))}}}}}catch(t){c.e(t)}finally{c.f()}var z=l.length/P;return z<1?null:{triangles:new Float32Array(l),triangleCount:z,extent:u}}(c,m,g),b=v.boundingBox;return{reference:m,surface:{meshName:m.name,topY:null!==(o=null==b?void 0:b.max.y)&&void 0!==o?o:0,slabThickness:b?b.max.y-b.min.y:0,material:x?(p=Array.isArray(m.material)?m.material[0]:m.material,y=p.clone(),(0,R.pN)(y),y instanceof h.Wid&&(y.aoMap=null,y.lightMap=null),y.needsUpdate=!0,y):null,triangles:null!==(i=null==x?void 0:x.triangles)&&void 0!==i?i:null,triangleCount:null!==(l=null==x?void 0:x.triangleCount)&&void 0!==l?l:0,triangleIndex:x?buildTriangleGridIndex(x.triangles,x.triangleCount):null,attributeName:g,uvFit:x?fitAffineUV(x.triangles,x.triangleCount):null,extent:null!==(u=null==x?void 0:x.extent)&&void 0!==u?u:null}}}var q=.001;var G=(0,v.getLogger)("RealTimeViewer","DeckCutoutCollar"),$=new h.dpR;var K=a(7514);function DeckCutoutCollar_createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=function DeckCutoutCollar_unsupportedIterableToArray(t,r){if(t){if("string"==typeof t)return DeckCutoutCollar_arrayLikeToArray(t,r);var a={}.toString.call(t).slice(8,-1);return"Object"===a&&t.constructor&&(a=t.constructor.name),"Map"===a||"Set"===a?Array.from(t):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?DeckCutoutCollar_arrayLikeToArray(t,r):void 0}}(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var l,u=!0,c=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){c=!0,l=t},f:function f(){try{u||null==a.return||a.return()}finally{if(c)throw l}}}}function DeckCutoutCollar_arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=Array(r);a<r;a++)o[a]=t[a];return o}var J=(0,v.getLogger)("RealTimeViewer","DeckCutoutCollar"),Q=!1;function DeckCutoutCollar(){var t,r=(0,c.D)((function(t){return t.scene})),a=(0,u.K)((function(t){return t.scene.deckCutout})),l=(0,m.tb)((function(t){return t.deckCutoutFootprintOverride})),v=(0,m.tb)((function(t){return t.decorVersion})),p=function useCollarTextures(t){var r=t.mapUrl,a=t.normalMapUrl,l=t.roughnessMapUrl,u=(0,o.useState)(null),c=(0,i.Z)(u,2),m=c[0],v=c[1];return(0,o.useEffect)((function(){if(""!==r){var t=!0,o=[],u=function load(r){return""===r?Promise.resolve(null):$.loadAsync(r).then((function(r){return t?(o.push(r),r):(r.dispose(),null)}),(function(){return G.debug("[DeckCutoutCollar] collar texture failed to load: ".concat(r)),null}))};return Promise.all([u(r),u(a),u(l)]).then((function(r){var a=(0,i.Z)(r,3),o=a[0],l=a[1],u=a[2];if(t&&o){o.colorSpace=h.KI_;for(var c=0,m=[o,l,u];c<m.length;c++){var p=m[c];p&&(p.wrapS=h.rpg,p.wrapT=h.rpg,p.needsUpdate=!0)}v({map:o,normalMap:l,roughnessMap:u})}})),function(){t=!1;for(var r=0,a=o;r<a.length;r++)a[r].dispose();v(null)}}v(null)}),[r,a,l]),m}(a.collar.material),y=(0,o.useRef)(null),g=(0,o.useRef)(null),x=(0,o.useRef)(null),b=(0,o.useRef)(-1),M=(0,o.useState)(null),A=(0,i.Z)(M,2),S=A[0],w=A[1],k=(0,o.useMemo)((function(){return a.nodeMatch.split(",").map((function(t){return t.trim()})).filter((function(t){return t.length>0}))}),[a.nodeMatch]);(0,o.useEffect)((function(){g.current=null,x.current=null,w(null)}),[k]);var C=a.collar,Z=a.authoredHole,T=a.enabled,O=T&&null!==l&&l.length>=3;(0,o.useEffect)((function(){if(T&&!Q)return m.tb.getState().beginSceneLoad(m.Wz,{timeoutMs:25e3,onTimeout:function onTimeout(){return Q=!0}}),function(){return m.tb.getState().endSceneLoad(m.Wz)}}),[T]),(0,o.useEffect)((function(){O&&!Q&&m.tb.getState().beginSceneLoad(m.Wz,{timeoutMs:8e3,onTimeout:function onTimeout(){return Q=!0}})}),[O]);var X=(0,o.useCallback)((function(){var t=sampleDeckSurface(r,k),a=t.reference,o=t.surface;g.current=a;var i=function deckSurfaceKey(t){return t?"".concat(t.meshName,"|").concat(t.topY.toFixed(4),"|").concat(t.attributeName,"|").concat(t.triangleCount):"none"}(o);if(x.current!==i&&(x.current=i,w(o),o)){(0,j._m)("deck: surface sampled");var l,u=DeckCutoutCollar_createForOfIteratorHelper(function describeDeckSurface(t,r){var a=[],o=t.extent;return o&&a.push("[DeckCutoutCollar] matched deck meshes span X [".concat(o.minX.toFixed(3),", ").concat(o.maxX.toFixed(3),"] Z [").concat(o.minZ.toFixed(3),", ").concat(o.maxZ.toFixed(3),"]")),a.push("[DeckCutoutCollar] UV source: ".concat(r?"own material (declared world-planar tiling)":null===t.uvFit?"no fit possible (per-vertex sampling)":t.uvFit.residualMetres<=B?"one fitted mapping, residual ".concat((1e3*t.uvFit.residualMetres).toFixed(2)," mm"):"per-vertex sampling — fit residual ".concat((1e3*t.uvFit.residualMetres).toFixed(1)," mm exceeds ").concat(5," mm, deck unwrap is not one plane"))),a}(o,null!==p));try{for(u.s();!(l=u.n()).done;){var c=l.value;J.debug(c)}}catch(t){u.e(t)}finally{u.f()}}}),[r,k,p]);(0,o.useEffect)((function(){T&&(b.current=1)}),[T,v,X]),(0,o.useEffect)((function(){O&&null===S&&J.debug("[DeckCutoutCollar] footprint active but NO floor mesh matches '".concat(a.nodeMatch,"'"))}),[O,S,a.nodeMatch]),(0,c.F)((function(){if(T){b.current>=0&&(0===b.current&&X(),b.current-=1);var t=g.current;t&&!t.parent&&X();var r=y.current;t&&r&&(r.matrix.copy(t.matrixWorld),r.matrixWorldNeedsUpdate=!0)}}));var E=(0,o.useMemo)((function(){if(!T||null===S||null===l||l.length<3)return null;var t=function buildCollarGeometry(t){var r=t.footprint,a=t.hole,o=t.collar,i=t.deck,l=t.ownMaterial,u=new h.bnF,c=a.centerX-a.halfExtentX-o.overlap,m=a.centerX+a.halfExtentX+o.overlap,v=a.centerZ-a.halfExtentZ-o.overlap,p=a.centerZ+a.halfExtentZ+o.overlap;u.moveTo(c,v),u.lineTo(m,v),u.lineTo(m,p),u.lineTo(c,p),u.closePath();for(var y=0,g=1/0,x=-1/0,b=1/0,M=-1/0,A=new h.y$t,S=0;S<r.length;S++){var w=Math.min(m-q,Math.max(c+q,r[S][0])),k=Math.min(p-q,Math.max(v+q,r[S][1]));w===r[S][0]&&k===r[S][1]||(y+=1),w<g&&(g=w),w>x&&(x=w),k<b&&(b=k),k>M&&(M=k),0===S?A.moveTo(w,k):A.lineTo(w,k)}A.closePath(),u.holes.push(A);var C=(x-g)*(M-b)/((m-c)*(p-v)),Z="[DeckCutoutCollar] ring built: hole X [".concat(c.toFixed(2),", ").concat(m.toFixed(2),"] Z [").concat(v.toFixed(2),", ").concat(p.toFixed(2),"] | opening X [").concat(g.toFixed(2),", ").concat(x.toFixed(2),"] Z [").concat(b.toFixed(2),", ").concat(M.toFixed(2),"] = ").concat((100*C).toFixed(0),"% of it | ").concat(y,"/").concat(r.length," outline pts clamped").concat(y>0?" — THE ARTICLE IS LARGER THAN ITS HOLE":""),T=o.skirtDepth>0?o.skirtDepth:Math.max(i.slabThickness,.01),O=new h.O7d(u,{depth:T,bevelEnabled:!1});if(O.rotateX(Math.PI/2),O.translate(0,i.topY-o.recess,0),l){for(var X=l.textureScale,E=l.rotationDeg,I=l.offsetX,D=l.offsetZ,_=X>0?X:1,L=E*Math.PI/180,j=Math.cos(L),z=Math.sin(L),P=O.getAttribute("position"),N=new Float32Array(2*P.count),Y=0;Y<P.count;Y++){var R=P.getX(Y)+I,H=P.getZ(Y)+D;N[2*Y]=(R*j-H*z)/_,N[2*Y+1]=(R*z+H*j)/_}var U=new h.TlE(N,2);O.setAttribute("uv",U),O.setAttribute("uv1",U)}else if(i.triangles){for(var W=i.uvFit&&i.uvFit.residualMetres<=B?i.uvFit:null,V=O.getAttribute("position"),G=new Float32Array(2*V.count),$=0;$<V.count;$++){var K=V.getX($),J=V.getZ($);if(W)G[2*$]=W.ux*K+W.uz*J+W.u0,G[2*$+1]=W.vx*K+W.vz*J+W.v0;else{var Q=sampleNearestTriangleUV(i.triangles,i.triangleCount,K,J,i.triangleIndex);Q&&(G[2*$]=Q[0],G[2*$+1]=Q[1])}}var ee=new h.TlE(G,2);O.setAttribute("uv",ee),O.setAttribute("uv1",ee)}return{geometry:O,diagnostic:Z}}({footprint:l,hole:Z,collar:C,deck:S,ownMaterial:p?C.material:null});return J.debug(t.diagnostic),t.geometry}),[T,l,Z.centerX,Z.centerZ,Z.halfExtentX,Z.halfExtentZ,C,S,p]);(0,o.useEffect)((function(){E&&!Q&&(Q=!0,(0,j._m)("deck: first collar geometry"),m.tb.getState().endSceneLoad(m.Wz))}),[E]),(0,o.useEffect)((function(){return function(){return null==E?void 0:E.dispose()}}),[E]);var I=null!==(t=null==S?void 0:S.material)&&void 0!==t?t:null;return(0,o.useEffect)((function(){return function(){return null==I?void 0:I.dispose()}}),[I]),E?p?(0,K.jsx)("mesh",{ref:y,geometry:E,matrixAutoUpdate:!1,receiveShadow:!0,castShadow:!0,children:(0,K.jsx)("meshStandardMaterial",{map:p.map,normalMap:p.normalMap,roughnessMap:p.roughnessMap,color:C.color,roughness:C.roughness,metalness:0})}):I?(0,K.jsx)("mesh",{ref:y,geometry:E,material:I,matrixAutoUpdate:!1,receiveShadow:!0,castShadow:!0}):(0,K.jsx)("mesh",{ref:y,geometry:E,matrixAutoUpdate:!1,receiveShadow:!0,castShadow:!0,children:(0,K.jsx)("meshStandardMaterial",{color:C.color,roughness:C.roughness,metalness:0})}):null}function DeckCutoutSubsystem(){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(DeckCutoutArticleSync,{}),(0,K.jsx)(DeckCutoutCollar,{})]})}}}]);
@@ -0,0 +1 @@
1
+ /*! filename:964 */