<!-- SOLID-PLAYTIME · part 151 -->
Z(X){for(let ot=0;ot<X.removed.length;ot++){let Y=X.removed[ot],yt=S.indexOf(Y);if(yt>=0)S[yt]=null,x[yt].disconnect(Y)}for(let ot=0;ot<X.added.length;ot++){let Y=X.added[ot],yt=S.indexOf(Y);if(yt===-1){for(let vt=0;vt<x.length;vt++)if(vt>=S.length){S.push(Y),yt=vt;break}else if(S[vt]===null){S[vt]=Y,yt=vt;break}if(yt===-1)break}let Ht=x[yt];if(Ht)Ht.connect(Y)}}let at=new C,W=new C;function ht(X,ot,Y){at.setFromMatrixPosition(ot.matrixWorld),W.setFromMatrixPosition(Y.matrixWorld);let yt=at.distanceTo(W),Ht=ot.projectionMatrix.elements,vt=Y.projectionMatrix.elements,ye=Ht[14]/(Ht[10]-1),D=Ht[14]/(Ht[10]+1),ce=(Ht[9]+1)/Ht[5],kt=(Ht[9]-1)/Ht[5],Bt=(Ht[8]-1)/Ht[0],St=(vt[8]+1)/vt[0],Ue=ye*Bt,Dt=ye*St,It=yt/(-Bt+St),xe=It*-Bt;if(ot.matrixWorld.decompose(X.position,X.quaternion,X.scale),X.translateX(xe),X.translateZ(It),X.matrixWorld.compose(X.position,X.quaternion,X.scale),X.matrixWorldInverse.copy(X.matrixWorld).invert(),Ht[10]===-1)X.projectionMatrix.copy(ot.projectionMatrix),X.projectionMatrixInverse.copy(ot.projectionMatrixInverse);else{let be=ye+It,Ee=D+It,L=Ue-xe,E=Dt+(yt-xe),B=ce*D/Ee*be,tt=kt*D/Ee*be;X.projectionMatrix.makePerspective(L,E,B,tt,be,Ee),X.projectionMatrixInverse.copy(X.projectionMatrix).invert()}}function mt(X,ot){if(ot===null)X.matrixWorld.copy(X.matrix);else X.matrixWorld.multiplyMatrices(ot.matrixWorld,X.matrix);X.matrixWorldInverse.copy(X.matrixWorld).invert()}this.updateCamera=function(X){if(i===null)return;let{near:ot,far:Y}=X;if(y.texture!==null){if(y.depthNear>0)ot=y.depthNear;if(y.depthFar>0)Y=y.depthFar}if(R.near=b.near=w.near=ot,R.far=b.far=w.far=Y,O!==R.near||V!==R.far)i.updateRenderState({depthNear:R.near,depthFar:R.far}),O=R.near,V=R.far;R.layers.mask=X.layers.mask|6,w.layers.mask=R.layers.mask&3,b.layers.mask=R.layers.mask&5;let yt=X.parent,Ht=R.cameras;mt(R,yt);for(let vt=0;vt<Ht.length;vt++)mt(Ht[vt],yt);if(Ht.length===2)ht(R,w,b);else R.projectionMatrix.copy(w.projectionMatrix);q(X,R,yt)};function q(X,ot,Y){if(Y===null)X.matrix.copy(ot.matrixWorld);else X.matrix.copy(Y.matrixWorld),X.matrix.invert(),X.matrix.multiply(ot.matrixWorld);if(X.matrix.decompose(X.position,X.quaternion,X.scale),X.updateMatrixWorld(!0),X.projectionMatrix.copy(ot.projectionMatrix),X.projectionMatrixInverse.copy(ot.projectionMatrixInverse),X.isPerspectiveCamera)X.fov=ff*2*Math.atan(1/X.projectionMatrix.elements[5]),X.zoom=1}this.getCamera=function(){return R},this.getFoveation=function(){if(f===null&&h===null)return;return o},this.setFoveation=function(X){if(o=X,f!==null)f.fixedFoveation=X;if(h!==null&&h.fixedFoveation!==void 0)h.fixedFoveation=X},this.hasDepthSensing=function(){return y.texture!==null},this.getDepthSensingMesh=function(){return y.getMesh(R)},this.getCameraTexture=function(X){return U[X]};let dt=null;function Ft(X,ot){if(c=ot.getViewerPose(l||a),p=ot,c!==null){let Y=c.views;if(h!==null)t.setRenderTargetFramebuffer(m,h.framebuffer),t.setRenderTarget(m);let yt=!1;if(Y.length!==R.cameras.length)R.cameras.length=0,yt=!0;for(let D=0;D<Y.length;D++){let ce=Y[D],kt=null;if(h!==null)kt=h.getViewport(ce);else{let St=u.getViewSubImage(f,ce);if(kt=St.viewport,D===0)t.setRenderTargetTextures(m,St.colorTexture,St.depthStencilTexture),t.setRenderTarget(m)}let Bt=M[D];if(Bt===void 0)Bt=new xn,Bt.layers.enable(D),Bt.viewport=new Le,M[D]=Bt;if(Bt.matrix.fromArray(ce.transform.matrix),Bt.matrix.decompose(Bt.position,Bt.quaternion,Bt.scale),Bt.projectionMatrix.fromArray(ce.projectionMatrix),Bt.projectionMatrixInverse.copy(Bt.projectionMatrix).invert(),Bt.viewport.set(kt.x,kt.y,kt.width,kt.height),D===0)R.matrix.copy(Bt.matrix),R.matrix.decompose(R.position,R.quaternion,R.scale);if(yt===!0)R.cameras.push(Bt)}let Ht=i.enabledFeatures;if(Ht&&Ht.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&v){u=n.getBinding();let D=u.getDepthInformation(Y[0]);if(D&&D.isValid&&D.texture)y.init(D,i.renderState)}if(Ht&&Ht.includes("camera-access")&&v){t.state.unbindTexture(),u=n.getBinding();for(let D=0;D<Y.length;D++){let ce=Y[D].camera;if(ce){let kt=U[ce];if(!kt)kt=new Of,U[ce]=kt;let Bt=u.getCameraImage(ce);kt.sourceTexture=Bt}}}}for(let Y=0;Y<x.length;Y++){let yt=S[Y],Ht=x[Y];if(yt!==null&&Ht!==void 0)Ht.update(yt,ot,l||a)}if(dt)dt(X,ot);if(ot.detectedPlanes)n.dispatchEvent({type:"planesdetected",data:ot});p=null}let Et=new dM;Et.setAnimationLoop(Ft),this.setAnimationLoop=function(X){dt=X},this.dispose=function(){}}}var gr=new Dn,b3=new ie;function E3(t,e){function n(U,d){if(U.matrixAutoUpdate===!0)U.updateMatrix();d.value.copy(U.matrix)}function i(U,d){if(d.color.getRGB(U.fogColor.value,EU(t)),d.isFog)U.fogNear.value=d.near,U.fogFar.value=d.far;else if(d.isFogExp2)U.fogDensity.value=d.density}function s(U,d,g,m,x){if(d.isMeshBasicMaterial)a(U,d);else if(d.isMeshLambertMaterial)a(U,d);else if(d.isMeshToonMaterial)a(U,d),f(U,d);else if(d.isMeshPhongMaterial)a(U,d),u(U,d);else if(d.isMeshStandardMaterial){if(a(U,d),h(U,d),d.isMeshPhysicalMaterial)p(U,d,x)}else if(d.isMeshM