@konfigure/sdk 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +54 -1
- package/dist/chunk-4KQN5AVT.js +782 -0
- package/dist/chunk-EBEY7ID3.js +1 -0
- package/dist/chunk-HFOEVYNK.js +4 -0
- package/dist/chunk-XR6EHOK2.js +482 -0
- package/dist/client-B2yVMro3.d.ts +80 -0
- package/dist/{configurator-6ISAZiAx.d.ts → configurator-CnGR3YDW.d.ts} +1 -1
- package/dist/index.d.ts +5 -57
- package/dist/index.js +1 -4
- package/dist/showroom.d.ts +145 -0
- package/dist/showroom.js +171 -0
- package/dist/{src-GJ5RXX7G.js → src-SHLZZCVA.js} +6 -6
- package/dist/view.d.ts +1 -1
- package/dist/view.js +3 -785
- package/package.json +5 -1
- package/dist/chunk-ARGXORCF.js +0 -1
- package/dist/chunk-OOVVLYAY.js +0 -482
package/dist/view.js
CHANGED
|
@@ -1,777 +1,9 @@
|
|
|
1
|
-
import {k,c,d as d$1,e as e$1,j,i,g,a as a$2,h}from'./chunk-ARGXORCF.js';import {e,d,a as a$1}from'./chunk-OOVVLYAY.js';import {a}from'./chunk-XUSV3KOD.js';import {Vector3,Color,Scene,BoxGeometry,MeshStandardMaterial,BackSide,PointLight,Mesh,MeshBasicMaterial,Matrix4,Matrix3,Vector2,Vector4,Box3,TextureLoader,BufferGeometry,BufferAttribute,WebGLRenderer,SRGBColorSpace,PCFSoftShadowMap,PMREMGenerator,PerspectiveCamera,Group,ShadowMaterial,PlaneGeometry,DirectionalLight,Quaternion,MeshDepthMaterial,ShaderMaterial,AmbientLight,CubeUVReflectionMapping,Euler,UniformsUtils,UniformsLib,InstancedMesh,NeutralToneMapping,ACESFilmicToneMapping,ShaderChunk,NoToneMapping,HalfFloatType,UnsignedByteType,WebGLRenderTarget,DoubleSide,FloatType,DataTexture,RGBAFormat,EquirectangularReflectionMapping,LinearFilter,ClampToEdgeWrapping,OrthographicCamera,CustomToneMapping,Object3D,MeshPhysicalMaterial,RepeatWrapping,LinearMipmapLinearFilter,NoColorSpace,AnimationMixer,QuaternionKeyframeTrack,NearestFilter,Fog,SpotLight,RectAreaLight,WebGLCubeRenderTarget,CubeCamera,LinearToneMapping}from'three';import {GLTFExporter}from'three/addons/exporters/GLTFExporter.js';import {USDZExporter}from'three/addons/exporters/USDZExporter.js';import {RoomEnvironment}from'three/addons/environments/RoomEnvironment.js';import {GLTFLoader}from'three/addons/loaders/GLTFLoader.js';import {FullScreenQuad}from'three/addons/postprocessing/Pass.js';import {OrbitControls}from'three/addons/controls/OrbitControls.js';import {RGBELoader}from'three/addons/loaders/RGBELoader.js';import {OutputPass}from'three/addons/postprocessing/OutputPass.js';import*as fi from'three/examples/jsm/utils/BufferGeometryUtils.js';import {DRACOLoader}from'three/examples/jsm/loaders/DRACOLoader.js';var Ze=typeof window<"u"&&typeof navigator<"u";(()=>{if(!Ze)return false;let e=navigator.userAgent||navigator.vendor||self.opera,o=false;return (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(e)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(e.substr(0,4)))&&(o=true),o})();var zt=Ze&&/android/i.test(navigator.userAgent),on=Ze&&(/iPad|iPhone|iPod/.test(navigator.userAgent)&&!self.MSStream||navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1),Ts=Ze&&/firefox/i.test(navigator.userAgent),Rs=Ze&&/OculusBrowser/.test(navigator.userAgent),rn=zt&&!Ts&&!Rs,nn=on?"ios":zt?"android":"desktop",As=Ze&&!!(window.webkit&&window.webkit.messageHandlers),an=(()=>{if(on){if(/KonfigureKiosk\//.test(navigator.userAgent))return true;if(As)return !!/CriOS\/|EdgiOS\/|GSA\/|DuckDuckGo\//.test(navigator.userAgent);{let e=document.createElement("a");return !!(e.relList&&e.relList.supports&&e.relList.supports("ar"))}}else return false})(),he={QUICK_LOOK:"quick-look",SCENE_VIEWER:"scene-viewer",WEBXR:"webxr",NONE:"none"};var So="arLaunchFailed",wo=["ar"];function sn(){return typeof location>"u"?new URL("https://localhost/"):new URL(location.href)}a(sn,"currentUrl");function ln(e=wo){let o=sn();for(let t of e)o.searchParams.delete(t);return o.toString()}a(ln,"currentUrlWithout");function cn(e=wo){let o=sn();for(let t of e)o.searchParams.delete(t);return o.searchParams.set(So,"1"),o.toString()}a(cn,"buildFallbackUrl");function un(e=wo){if(typeof location>"u"||typeof history>"u")return false;let o=new URL(location.href);if(o.searchParams.get(So)!=="1")return false;o.searchParams.delete(So);for(let t of e)o.searchParams.delete(t);return history.replaceState(history.state,"",o.toString()),true}a(un,"consumeArLaunchFailureFlag");function dn(e=1500){return new Promise(o=>{if(typeof document>"u"){o(false);return}let t=false,n=a(()=>{document.visibilityState==="hidden"&&a$1(true);},"onVis");function a$1(i){t||(t=true,document.removeEventListener("visibilitychange",n),o(i));}a(a$1,"finish"),document.addEventListener("visibilitychange",n),setTimeout(()=>a$1(false),e);})}a(dn,"detectIntentLaunch");function pn(){return typeof location>"u"?false:new URLSearchParams(location.search).get("arDebugFail")==="true"}a(pn,"isArDebugFail");function xo(e,o={}){let t=document.createElement("a");t.style.display="none",o.quickLook&&(t.setAttribute("rel","ar"),t.appendChild(document.createElement("img"))),t.setAttribute("href",e),document.body.appendChild(t),t.click(),t.remove();}a(xo,"launchARAnchor");async function Pt(e){let t=await new USDZExporter().parseAsync(e,{ar:{anchoring:{type:"plane"},planeAnchoring:{alignment:"horizontal"}}}),n=new Blob(t?[t]:[],{type:"model/vnd.usdz+zip"}),a$1=URL.createObjectURL(n);return {href:new URL(a$1,self.location.toString()).toString(),revoke:a(()=>URL.revokeObjectURL(a$1),"revoke")}}a(Pt,"prepareQuickLook");function fn(e){let o=[],t=new Map;return e.traverse(n=>{let a=n;if(!a.isMesh||a.geometry.getIndex())return;let i=a.geometry,s=t.get(i);if(!s){if(!i.getAttribute("position"))return;s=Ls(i),t.set(i,s);}o.push({mesh:a,geometry:i}),a.geometry=s;}),a(function(){for(let{mesh:a,geometry:i}of o)a.geometry=i;for(let a of t.values()){for(let i of Object.keys(a.attributes))a.deleteAttribute(i);a.dispose();}},"restore")}a(fn,"indexGeometriesForExport");function Ls(e){let o=new BufferGeometry;o.name=e.name,o.userData=e.userData;for(let[a,i]of Object.entries(e.attributes))o.setAttribute(a,i);o.morphAttributes=e.morphAttributes,o.morphTargetsRelative=e.morphTargetsRelative;for(let{start:a,count:i,materialIndex:s}of e.groups)o.addGroup(a,i,s);o.setDrawRange(e.drawRange.start,e.drawRange.count);let t=e.getAttribute("position").count,n=t>65535?new Uint32Array(t):new Uint16Array(t);for(let a=0;a<t;a++)n[a]=a;return o.setIndex(new BufferAttribute(n,1)),o}a(Ls,"withTrivialIndex");async function Gt(e){let o=new GLTFExporter,t=fn(e);try{let n=await o.parseAsync(e,{binary:!0});if(!(n instanceof ArrayBuffer))throw new Error("GLTFExporter did not return ArrayBuffer");return n}finally{t();}}a(Gt,"exportGLBBuffer");function Wt(e,o={}){let{version:t="1.0",mode:n="ar_preferred",disableOcclusion:a=true,link:i=ln(),title:s,extraParams:c}=o,l=self.location?.toString()??"https://localhost/",p=new URL(e,l);p.hash&&(p.hash="");let u=new URLSearchParams(p.search);if(u.set("mode",n),u.set("disable_occlusion",String(a)),i&&u.set("link",i),s&&u.set("title",s),c)for(let[v,f]of Object.entries(c))u.set(v,f);let d=pn()?"package=com.example.nonexistent;":"";return `intent://arvr.google.com/scene-viewer/${t}?${u.toString()}&file=${encodeURIComponent(p.toString())}#Intent;scheme=https;${d}action=android.intent.action.VIEW;S.browser_fallback_url=${encodeURIComponent(cn())};end;`}a(Wt,"buildSceneViewerIntentUrl");async function Po(e){let o=await Gt(e.model),t=new Blob([o],{type:"model/gltf-binary"}),{id:n}=await e.upload(t);return {href:Wt(n,e.params)}}a(Po,"prepareSceneViewer");var Co={scanHint:"Point your phone at the floor and move it slowly",placedHint:"Drag to move \xB7 twist with two fingers to rotate",close:"Close AR"},Xs=.9;async function mn(){if(typeof navigator>"u"||!navigator.xr)return false;try{return await navigator.xr.isSessionSupported("immersive-ar")}catch{return false}}a(mn,"isWebXRARSupported");function hn(){return typeof navigator>"u"?false:navigator.userActivation?.isActive??true}a(hn,"hasUserActivation");function gn(e,o=Co){let t=typeof navigator<"u"?navigator.xr:void 0;if(!t)return {started:Promise.reject(new Error("WebXR is not available")),ended:Promise.resolve(),end(){}};let n=Promise.resolve(e);n.catch(()=>{});let a$1=Ks(o);document.body.appendChild(a$1.root);let i=t.requestSession("immersive-ar",{requiredFeatures:["hit-test"],optionalFeatures:["dom-overlay"],domOverlay:{root:a$1.root}}),s=null,c=false,l,p=new Promise(v=>l=v);function u(){c=true,s?.end().catch(()=>{});}return a(u,"end"),a$1.onClose=u,{started:(async()=>{try{s=await i;}catch(S){throw a$1.root.remove(),l(),S}let v=null,f=false;s.addEventListener("end",()=>{f=true,v?.dispose(),v=null,a$1.root.remove(),l();}),c&&u();try{let S=await Ys(s,await n,a$1);f?S.dispose():v=S;}catch(S){if(f)return;throw s.end().catch(()=>{}),S}})(),ended:p,end:u}}a(gn,"startWebXRAR");function Ks(e){let o=document.createElement("div");o.setAttribute("data-konfigure-ar-overlay",""),Object.assign(o.style,{position:"fixed",inset:"0",display:"none",background:"transparent",touchAction:"none",userSelect:"none",fontFamily:"system-ui, -apple-system, sans-serif",zIndex:"2147483647"});let t=document.createElement("button");t.type="button",t.setAttribute("aria-label",e.close),t.innerHTML='<svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" aria-hidden="true"><path d="M6 6l12 12M18 6L6 18"/></svg>',Object.assign(t.style,{position:"absolute",top:"max(16px, env(safe-area-inset-top))",right:"16px",width:"48px",height:"48px",border:"none",borderRadius:"50%",background:"rgba(0, 0, 0, 0.55)",color:"#fff",display:"flex",alignItems:"center",justifyContent:"center",padding:"0"});let n=document.createElement("div");n.textContent=e.scanHint,Object.assign(n.style,{position:"absolute",left:"50%",bottom:"calc(32px + env(safe-area-inset-bottom))",transform:"translateX(-50%)",maxWidth:"calc(100% - 32px)",padding:"10px 16px",borderRadius:"999px",background:"rgba(0, 0, 0, 0.6)",color:"#fff",fontSize:"15px",lineHeight:"1.3",textAlign:"center",pointerEvents:"none"}),o.append(t,n);let a$1={root:o,onClose:a(()=>{},"onClose"),show(){o.style.display="block";},setPlaced(){n.textContent=e.placedHint;}};return t.addEventListener("beforexrselect",i=>i.preventDefault()),t.addEventListener("click",()=>a$1.onClose()),a$1}a(Ks,"createOverlay");async function $s(e,o){let t=typeof XRWebGLBinding<"u"?XRWebGLBinding.prototype:null,n=t?Object.getOwnPropertyDescriptor(t,"createProjectionLayer"):null,a=!!(t&&n?.configurable);a&&delete t.createProjectionLayer;try{await e.xr.setSession(o);}finally{a&&Object.defineProperty(t,"createProjectionLayer",n);}}a($s,"setSessionWithoutLayers");async function Ys(e,o,t){let n=new WebGLRenderer({antialias:true,alpha:true});n.setPixelRatio(window.devicePixelRatio),n.outputColorSpace=SRGBColorSpace,n.shadowMap.enabled=true,n.shadowMap.type=PCFSoftShadowMap,n.xr.enabled=true,n.xr.setReferenceSpaceType("local");let a$1=new PMREMGenerator(n),i=a$1.fromScene(new RoomEnvironment,.04).texture;a$1.dispose();let s=new Scene;s.environment=i;let c=new PerspectiveCamera,{model:l,restore:p}=Qs(o,i);l.updateMatrixWorld(true);let u=new Box3().setFromObject(l),d=u.getSize(new Vector3),v=u.getCenter(new Vector3),f=Math.max(d.x,d.z,.2)/2,S=new Group;S.visible=false;let O=new Group,y=new Group;y.position.set(-v.x,-u.min.y,-v.z),y.add(l),O.add(y),S.add(O);let w=new ShadowMaterial({opacity:.3,depthWrite:false}),P=new PlaneGeometry(f*6,f*6);P.rotateX(-Math.PI/2);let T=new Mesh(P,w);T.receiveShadow=true,S.add(T);let R=new DirectionalLight(16777215,1.2);R.position.set(f*.8,Math.max(d.y,1)*2.5,f*1.2),R.castShadow=true,R.shadow.mapSize.set(1024,1024),R.shadow.radius=6,R.shadow.bias=-5e-4;let z=f*2.5;R.shadow.camera.left=-z,R.shadow.camera.right=z,R.shadow.camera.top=z,R.shadow.camera.bottom=-z,R.shadow.camera.near=.05,R.shadow.camera.far=Math.max(d.y,1)*6,S.add(R,R.target),s.add(S);let g,x;function M(){n.setAnimationLoop(null);for(let h of [g,x])try{h?.cancel();}catch{}y.remove(l),p(),P.dispose(),w.dispose(),R.shadow.map?.dispose(),i.dispose(),n.dispose(),n.forceContextLoss();}a(M,"release");try{await $s(n,e);let h=await e.requestReferenceSpace("viewer");if(g=await e.requestHitTestSource?.({space:h}),!g)throw new Error("WebXR hit testing is not available");x=await e.requestHitTestSourceForTransientInput?.({profile:"generic-touchscreen"})?.catch(()=>{});}catch(h){throw M(),h}let E=g;t.show();let G=false,V=null,C=null,U=null;function N(h){U===null&&(V=h.inputSource,C=null);}a(N,"onSelectStart");function H(h){h.inputSource===V&&(V=null);}a(H,"onSelectEnd"),e.addEventListener("selectstart",N),e.addEventListener("selectend",H);function j(h){let W=h[0],B=h[1];return Math.atan2(B.clientY-W.clientY,B.clientX-W.clientX)}a(j,"touchAngle");function _(h){if(h.touches.length<2){U=null;return}V=null;let W=j(h.touches);if(U!==null){let B=W-U;B>Math.PI&&(B-=Math.PI*2),B<-Math.PI&&(B+=Math.PI*2),O.rotation.y-=B;}U=W;}a(_,"onTouch"),t.root.addEventListener("touchstart",_),t.root.addEventListener("touchmove",_),t.root.addEventListener("touchend",_),t.root.addEventListener("touchcancel",_);let m=new Vector3,k=new Quaternion,b=new Vector3;function A(h,W){let B=h?.getPose(W);if(!B)return null;let{position:Y,orientation:Q}=B.transform;return k.set(Q.x,Q.y,Q.z,Q.w),m.set(0,1,0).applyQuaternion(k),m.y<Xs?null:b.set(Y.x,Y.y,Y.z)}return a(A,"floorPoint"),n.setAnimationLoop((h,W)=>{let B=n.xr.getReferenceSpace();if(W&&B)if(G){if(V&&x){let Y=W.getHitTestResultsForTransientInput(x),Q=Y.find(ne=>ne.inputSource===V)??Y[0],q=A(Q?.results[0],B);q&&(C?S.position.copy(q).add(C):C=S.position.clone().sub(q));}}else {let Y=A(W.getHitTestResults(E)[0],B),Q=W.getViewerPose(B);if(Y&&Q){S.position.copy(Y);let q=Q.transform.position;O.rotation.y=Math.atan2(q.x-Y.x,q.z-Y.z),S.visible=true,G=true,t.setPlaced();}}n.render(s,c);}),{dispose(){e.removeEventListener("selectstart",N),e.removeEventListener("selectend",H),M();}}}a(Ys,"runSession");function Qs(e,o){let t=e.parent?e.clone(true):e,n=new Map,a$1=[];function i(s){let c=n.get(s);if(!c){c=s.clone();let l=c;l.envMap?.isRenderTargetTexture&&(l.envMap=o),n.set(s,c);}return c}return a(i,"adopt"),t.traverse(s=>{let c=s;c.isMesh&&(a$1.push({mesh:c,material:c.material,castShadow:c.castShadow}),c.material=Array.isArray(c.material)?c.material.map(i):i(c.material),c.castShadow=true);}),{model:t,restore(){for(let{mesh:s,material:c,castShadow:l}of a$1)s.material=c,s.castShadow=l;for(let s of n.values())s.dispose();}}}a(Qs,"adoptModel");var Ro={quickLook:"AR Quick Look could not be opened. Make sure you are using Safari on iOS 12 or newer, or try another device.",sceneViewer:"This device has no working AR Viewer. Update the Google app from the Play Store, or try another device.",sceneViewerClosed:"Google's AR viewer closed right after opening. Recent Google app updates have a known bug in it - please try again later or on another device.",webxr:"AR could not be started. Make sure Google Play Services for AR is installed and up to date, or try another device.",...Co},To=[he.WEBXR,he.SCENE_VIEWER,he.QUICK_LOOK],Js=6e3;function bn(e,o,t){let n={...Ro,...t};return e?n[e]:o===he.QUICK_LOOK?n.quickLook:n.sceneViewer}a(bn,"arFailureMessage");function Ao(e){return e!==he.NONE?null:nn==="desktop"?"device":"browser"}a(Ao,"arUnsupportedReason");function Eo(e={}){let o=e.uploadEndpoint??"/api/ar/upload-model",t={mode:he.NONE,loading:false,failed:false,failureKind:null,error:null,prepared:null},n=null,a$1=null;function i(M){Object.assign(t,M),e.onChange?.(t);}a(i,"set");function s(){return {...Ro,...e.messages?.()}}a(s,"messages");function c(M,E,G){i({failureKind:M,failed:true}),l({type:"failed",mode:E,reason:G});}a(c,"fail");function l(M){try{e.onLaunchEvent?.(M);}catch{}}a(l,"emitLaunchEvent");async function p(){for(let E of e.modes??To){if(E===he.WEBXR&&zt&&await mn()){i({mode:he.WEBXR});return}if(E===he.SCENE_VIEWER&&rn){i({mode:he.SCENE_VIEWER});return}if(E===he.QUICK_LOOK&&an){i({mode:he.QUICK_LOOK});return}}let M=navigator;if(M.userAgentData?.getHighEntropyValues)try{let E=await M.userAgentData.getHighEntropyValues(["formFactor"]),G=e.modes??To;if(E.formFactor?.includes("XR")&&G.includes(he.SCENE_VIEWER)){i({mode:he.SCENE_VIEWER});return}}catch{}i({mode:he.NONE});}a(p,"detect");function u(M){return typeof location<"u"?new URL(M,location.href).toString():M}a(u,"absoluteUrl");async function d(M){let E=new FormData;E.append("blob",M,"model.glb");let G=await fetch(o,{method:"POST",body:E});if(!G.ok)throw new Error(`AR model upload failed: ${G.status} ${G.statusText}`);let V=(await G.text()).trim(),C=typeof location<"u"?new URL(o,location.href):void 0;return {id:new URL(V,C).toString()}}a(d,"uploadGLB");async function v(M){return (await new GLTFLoader().loadAsync(M)).scene}a(v,"loadGLB");async function f(M,E){if(M)return await M;if(E)return v(u(E));throw new Error("useAR(): no model source \u2014 pass object, glbUrl, or usdzUrl")}a(f,"resolveModel");async function S(){let M=e.object?.()??null,E=e.glbUrl?.(),G=e.usdzUrl?.();function V(){return f(M,E)}if(a(V,"model"),t.mode===he.WEBXR)return {mode:"webxr",model:await V()};if(t.mode===he.QUICK_LOOK){if(G&&!M)return {mode:"quick-look",href:u(G)};let{href:C,revoke:U}=await Pt(await V());return {mode:"quick-look",href:C,revoke:U}}if(t.mode===he.SCENE_VIEWER){if(E&&!M)return {mode:"scene-viewer",href:Wt(u(E),e.sceneViewerParams)};let{href:C}=await Po({model:await V(),upload:d,params:e.sceneViewerParams});return {mode:"scene-viewer",href:C}}return null}a(S,"buildPrepared");async function O(){z(),i({loading:true,error:null});try{return i({prepared:await S()}),!!t.prepared}catch(M){return i({error:M instanceof Error?M.message:String(M)}),false}finally{i({loading:false});}}a(O,"prepare");function y(){let M=t.prepared;return M?M.mode==="webxr"?P(()=>M.model):(R(),xo(M.href,{quickLook:M.mode==="quick-look"}),l({type:"attempted",mode:M.mode}),M.mode==="scene-viewer"&&T(),M.mode==="quick-look"&&dn().then(E=>{E?l({type:"succeeded",mode:M.mode}):c("quickLook",M.mode,"quick_look_timeout");}),true):false}a(y,"launchPrepared");async function w(){return t.mode===he.WEBXR?P(()=>f(e.object?.()??null,e.glbUrl?.())):await O()?y():false}a(w,"launch");function P(M){if(!hn())return false;if(n)return true;R(),l({type:"attempted",mode:he.WEBXR}),i({loading:true});let E=s(),G=gn(Promise.resolve().then(M),{scanHint:E.scanHint,placedHint:E.placedHint,close:E.close});return n=G,G.started.then(()=>l({type:"succeeded",mode:he.WEBXR}),V=>{i({error:V instanceof Error?V.message:String(V)}),c("webxr",he.WEBXR,V instanceof Error?V.name:"webxr_session_failed");}),G.started.catch(()=>{}).finally(()=>i({loading:false})),G.ended.then(()=>{n===G&&(n=null);}),true}a(P,"startWebXR");function T(){if(typeof document>"u")return;a$1?.();let M=0;function E(){if(document.visibilityState==="hidden"){M=performance.now();return}if(!M)return;let C=performance.now()-M;V(),C<Js&&c("sceneViewerClosed",he.SCENE_VIEWER,"scene_viewer_closed_early");}a(E,"onVisibility");let G=setTimeout(()=>{M||V();},1e4);function V(){document.removeEventListener("visibilitychange",E),clearTimeout(G),a$1===V&&(a$1=null);}a(V,"stop"),document.addEventListener("visibilitychange",E),a$1=V;}a(T,"watchSceneViewerReturn");function R(){i({failed:false,failureKind:null,error:null});}a(R,"dismissFailure");function z(){t.prepared&&"revoke"in t.prepared&&t.prepared.revoke?.(),i({prepared:null});}a(z,"dispose");function g(){let M=p();return un()&&c("sceneViewer",he.SCENE_VIEWER,"scene_viewer_failed"),M}a(g,"start");function x(){z(),a$1?.(),n?.end();}return a(x,"destroy"),{state:t,failureMessage:a(()=>bn(t.failureKind,t.mode,e.messages?.()),"failureMessage"),detect:p,prepare:O,launchPrepared:y,launch:w,dismissFailure:R,dispose:z,start:g,destroy:x}}a(Eo,"createARController");function Mt(e){return e instanceof Mesh}a(Mt,"isMesh");var vn=.5;function Vt(e){let o=Array.isArray(e)?e:[e];return o.length>0&&o.every(t=>t.transparent&&t.opacity<vn||(t.transmission??0)>vn)}a(Vt,"isSeeThrough");var el=new Set(["room","floor","moduleContactShadow","bakedFloorShadow","selectionIndicator"]);function Oo(e){return e instanceof Mesh&&!el.has(e.name)&&!e.name.startsWith("wall")&&!e.userData.isCollider}a(Oo,"isModuleMesh");function Nt(e,o){e.traverse(t=>{Oo(t)&&o(t);});}a(Nt,"forEachModuleMesh");function Je(e,o=true,t=false){e.traverse(n=>{n instanceof Mesh&&(n.castShadow=o&&!Vt(n.material),n.receiveShadow=t);});}a(Je,"setShadows");var Te={blur:.5,blurPasses:[1,.75,.5,.25],blurResolution:256,darkness:1.2,falloff:2,opacity:.5,cameraHeight:.12,contactHeight:.05,contactOpacity:1,groundOffset:4e-4},Lo=1;function Le(e){Lo=Math.min(1,Math.max(0,e));}a(Le,"setContactShadowFade");function et(){return Lo}a(et,"getContactShadowFade");var Io=0;function Re(e){Io=Math.min(1,Math.max(0,e));}a(Re,"setContactShadowCoverage");function tt(){return Io}a(tt,"getContactShadowCoverage");var jt,Ht,De;function nl(){return De||(De=new MeshDepthMaterial,De.userData.darkness={value:Te.darkness},De.userData.falloff={value:Te.falloff},De.userData.contactReach={value:Te.contactHeight/Te.cameraHeight},De.onBeforeCompile=function(e){De&&(e.uniforms.darkness=De.userData.darkness,e.uniforms.falloff=De.userData.falloff,e.uniforms.contactReach=De.userData.contactReach,e.fragmentShader=`
|
|
2
|
-
uniform float darkness;
|
|
3
|
-
uniform float falloff;
|
|
4
|
-
uniform float contactReach;
|
|
5
|
-
${e.fragmentShader.replace("gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );",`float shadow = pow(1.0 - fragCoordZ, falloff) * darkness;
|
|
6
|
-
float contact = pow(clamp(1.0 - fragCoordZ / contactReach, 0.0, 1.0), falloff) * darkness;
|
|
7
|
-
gl_FragColor = vec4(contact, 0.0, 0.0, shadow);`)}
|
|
8
|
-
`);},De.depthTest=true,De.depthWrite=true),De}a(nl,"getDepthMaterial");function al(){return jt||(jt=new ShaderMaterial({uniforms:{tDiffuse:{value:null},h:{value:1/Te.blurResolution}},vertexShader:`
|
|
9
|
-
varying vec2 vUv;
|
|
10
|
-
void main() {
|
|
11
|
-
vUv = uv;
|
|
12
|
-
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
|
13
|
-
}
|
|
14
|
-
`,fragmentShader:`
|
|
15
|
-
uniform sampler2D tDiffuse;
|
|
16
|
-
uniform float h;
|
|
17
|
-
varying vec2 vUv;
|
|
18
|
-
void main() {
|
|
19
|
-
float alphaSum = 0.0;
|
|
20
|
-
float contactSum = 0.0;
|
|
21
|
-
float weights[9];
|
|
22
|
-
weights[0] = 0.051; weights[1] = 0.0918; weights[2] = 0.12245;
|
|
23
|
-
weights[3] = 0.1531; weights[4] = 0.1633; weights[5] = 0.1531;
|
|
24
|
-
weights[6] = 0.12245; weights[7] = 0.0918; weights[8] = 0.051;
|
|
25
|
-
for (int i = -4; i <= 4; i++) {
|
|
26
|
-
vec4 s = texture2D(tDiffuse, vec2(vUv.x + float(i) * h, vUv.y));
|
|
27
|
-
alphaSum += s.a * weights[i + 4];
|
|
28
|
-
contactSum += s.r * weights[i + 4];
|
|
29
|
-
}
|
|
30
|
-
gl_FragColor = vec4(contactSum, 0.0, 0.0, alphaSum);
|
|
31
|
-
}
|
|
32
|
-
`}),jt.depthTest=false),Ht||(Ht=new ShaderMaterial({uniforms:{tDiffuse:{value:null},v:{value:1/Te.blurResolution}},vertexShader:`
|
|
33
|
-
varying vec2 vUv;
|
|
34
|
-
void main() {
|
|
35
|
-
vUv = uv;
|
|
36
|
-
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
|
37
|
-
}
|
|
38
|
-
`,fragmentShader:`
|
|
39
|
-
uniform sampler2D tDiffuse;
|
|
40
|
-
uniform float v;
|
|
41
|
-
varying vec2 vUv;
|
|
42
|
-
void main() {
|
|
43
|
-
float alphaSum = 0.0;
|
|
44
|
-
float contactSum = 0.0;
|
|
45
|
-
float weights[9];
|
|
46
|
-
weights[0] = 0.051; weights[1] = 0.0918; weights[2] = 0.12245;
|
|
47
|
-
weights[3] = 0.1531; weights[4] = 0.1633; weights[5] = 0.1531;
|
|
48
|
-
weights[6] = 0.12245; weights[7] = 0.0918; weights[8] = 0.051;
|
|
49
|
-
for (int i = -4; i <= 4; i++) {
|
|
50
|
-
vec4 s = texture2D(tDiffuse, vec2(vUv.x, vUv.y + float(i) * v));
|
|
51
|
-
alphaSum += s.a * weights[i + 4];
|
|
52
|
-
contactSum += s.r * weights[i + 4];
|
|
53
|
-
}
|
|
54
|
-
gl_FragColor = vec4(contactSum, 0.0, 0.0, alphaSum);
|
|
55
|
-
}
|
|
56
|
-
`}),Ht.depthTest=false),{horizontal:jt,vertical:Ht}}a(al,"getBlurMaterials");var _o=new Map,Ve=new Vector3,il=new Color;function sl(e,o,t){let{horizontal:n,vertical:a}=al();e.blurPlane.visible=true,e.blurPlane.material=n,n.uniforms.tDiffuse&&n.uniforms.h&&(n.uniforms.tDiffuse.value=e.renderTarget.texture,n.uniforms.h.value=o/Te.blurResolution),t.setRenderTarget(e.renderTargetBlur),t.render(e.blurPlane,e.shadowCamera),e.blurPlane.material=a,a.uniforms.tDiffuse&&a.uniforms.v&&(a.uniforms.tDiffuse.value=e.renderTargetBlur.texture,a.uniforms.v.value=o/Te.blurResolution),t.setRenderTarget(e.renderTarget),t.render(e.blurPlane,e.shadowCamera),e.blurPlane.visible=false;}a(sl,"blurShadow");function wn(e,o){e.moduleGroup.updateMatrixWorld(),e.moduleGroup.getWorldPosition(Ve);let t=!Ve.equals(e.lastPosition);t&&e.lastPosition.copy(Ve);let n=null,a=e.moduleGroup.parent;for(;a;){if(a instanceof Scene){n=a;break}a=a.parent;}if(n&&!e.shadowPlane.parent&&(n.add(e.shadowPlane),n.add(e.blurPlane)),e.shadowPlane.position.set(Ve.x,Te.groundOffset,Ve.z),e.blurPlane.position.set(Ve.x,Te.groundOffset,Ve.z),!e.moduleGroup.visible){e.shadowPlane.visible=false;return}if(e.shadowPlane.visible=true,xn(e),!e.needsUpdate&&!t)return;e.needsUpdate=false;let i=e.size/2;e.shadowCamera.position.set(Ve.x,0,Ve.z),e.shadowCamera.rotation.x=Math.PI/2,e.shadowCamera.left=-i,e.shadowCamera.right=i,e.shadowCamera.top=i,e.shadowCamera.bottom=-i,e.shadowCamera.updateProjectionMatrix(),e.shadowCamera.updateMatrixWorld(true),e.shadowPlane.visible=false;let s=nl(),c=new Scene;e.moduleGroup.traverse(u=>{if(u instanceof Mesh&&u.name!=="moduleContactShadow"){let d=new Mesh(u.geometry,s);u.updateWorldMatrix(true,false),d.matrix.copy(u.matrixWorld),d.matrixAutoUpdate=false,c.add(d);}});let l=o.getClearColor(il),p=o.getClearAlpha();o.setClearColor(0,0),o.setRenderTarget(e.renderTarget),o.clear(true,true,true),o.render(c,e.shadowCamera);for(let u of Te.blurPasses)sl(e,Te.blur*u,o);o.setRenderTarget(null),o.setClearColor(l,p),e.shadowPlane.visible=true;}a(wn,"renderModuleContactShadow");function xn(e){if(!(e.shadowPlane.material instanceof ShaderMaterial))return;let{opacity:o,contactOpacity:t,coverage:n}=e.shadowPlane.material.uniforms,a=Lo*(e.shadowPlane.userData.fade??1);o&&(o.value=Te.opacity*a),t&&(t.value=Te.contactOpacity*a),n&&(n.value=Io);}a(xn,"applyFadeAndCoverage");function ft(){for(let e of _o.values())xn(e);}a(ft,"refreshContactShadows");function ot(e){for(let o of _o.values())wn(o,e);}a(ot,"renderAllModuleContactShadows");function Bo(){for(let e of _o.values())e.needsUpdate=true;}a(Bo,"markAllShadowsForUpdate");var Pn={topLight:{intensity:500,position:[.418,16.199,.3]},room:{position:[-0.757,13.219,.717],scale:[31.713,28.305,28.591]},boxes:[{position:[-10.906,2.009,1.846],rotation:-0.195,scale:[2.328,7.905,4.651]},{position:[-5.607,-0.754,-0.758],rotation:.994,scale:[1.97,1.534,3.955]},{position:[6.167,.857,7.803],rotation:.561,scale:[3.927,6.285,3.687]},{position:[-2.017,.018,6.124],rotation:.333,scale:[2.002,4.566,2.064]},{position:[2.291,-0.756,-2.621],rotation:-0.286,scale:[1.546,1.552,1.496]},{position:[-2.193,-0.369,-5.547],rotation:.516,scale:[3.875,3.487,2.986]}],lights:[{intensity:50,position:[-16.116,14.37,8.208],scale:[.1,2.428,2.739]},{intensity:50,position:[-16.109,18.021,-8.207],scale:[.1,2.425,2.751]},{intensity:17,position:[14.904,12.198,-1.832],scale:[.15,4.265,6.331]},{intensity:43,position:[-0.462,8.89,14.52],scale:[4.38,5.441,.088]},{intensity:20,position:[3.235,11.486,-12.541],scale:[2.5,2,.1]},{intensity:100,position:[0,20,0],scale:[1,.1,1]}]};var Mn={topLight:{intensity:400,position:[.5,14,.5]},room:{position:[0,13.2,0],scale:[31.5,28.5,31.5]},boxes:[{position:[-10.906,-1,1.846],rotation:-0.195,scale:[2.328,7.905,4.651]},{position:[-5.607,-0.754,-0.758],rotation:.994,scale:[1.97,1.534,3.955]},{position:[6.167,-0.16,7.803],rotation:.561,scale:[3.927,6.285,3.687]},{position:[-2.017,.018,6.124],rotation:.333,scale:[2.002,4.566,2.064]},{position:[2.291,-0.756,-2.621],rotation:-0.286,scale:[1.546,1.552,1.496]},{position:[-2.193,-0.369,-5.547],rotation:.516,scale:[3.875,3.487,2.986]}],lights:[{intensity:80,position:[-14,5,8],scale:[.1,2.5,2.5]},{intensity:80,position:[-14,7,-4],scale:[.1,2.5,2.5]},{intensity:23,position:[14,6,0],scale:[.1,5,5]},{intensity:16,position:[0,4.5,14],scale:[5,5,.1]},{intensity:80,position:[7,4,-14],scale:[2.5,2.5,.1]},{intensity:80,position:[-7,8,-14],scale:[2.5,2.5,.1]},{intensity:80,position:[0,7,0],scale:[.3,.3,.3]}]};var Cn={hdri:"/hdri/potsdamer_platz_1k.hdr",topLight:{intensity:75.4,color:"#ffffff",position:[0,12.5,0]},room:{color:"#dcdde1",position:[0,13.2,0],scale:[31.5,28.5,31.5]},boxes:[{position:[-12.5,-1.5,-3],rotation:-0.35,scale:[3,6,4]},{position:[11.5,-1.5,-5],rotation:.42,scale:[3.5,5.5,3.5]}],lights:[{intensity:.9,position:[0,4,13.5],scale:[18,13,.1]},{intensity:8.1,position:[-7,7,12.5],scale:[12,10,.1]},{intensity:9.3,position:[-10.5,6.5,11.5],scale:[6,6,.1]},{intensity:6.4,position:[10.5,5,11.5],scale:[5.5,5,.1]},{intensity:7.5,position:[-14,5,0],scale:[.1,6,9]},{intensity:7.5,position:[14,5,0],scale:[.1,6,9]},{intensity:4.6,position:[0,-5,9],scale:[10,2.5,.1]}]};var Tn={topLight:{intensity:150,color:"#fff5e6",position:[.5,14,.5]},room:{color:"#f5ebe0",position:[0,13.2,0],scale:[31.5,28.5,31.5]},boxes:[{position:[-10.906,-1,1.846],rotation:-0.195,scale:[2.328,7.905,4.651]},{position:[6.167,-0.16,7.803],rotation:.561,scale:[3.927,6.285,3.687]}],lights:[{intensity:45,position:[0,6,14],scale:[8,7,.1]},{intensity:40,position:[-14,5,0],scale:[.1,6,8]},{intensity:40,position:[14,5,0],scale:[.1,6,8]},{intensity:30,position:[4,5,-14],scale:[4,5,.1]},{intensity:30,position:[-4,5,-14],scale:[4,5,.1]},{intensity:25,position:[0,8,0],scale:[.5,.3,.5]}]};var ll={legacy:Pn,neutral:Mn,surround:Tn,studio:Cn};function qt(e){return ll[e]}a(qt,"getEnvironmentData");var rt=class extends Scene{static{a(this,"EnvironmentScene");}constructor(o){super(),this.position.y=-3.5;let t=new BoxGeometry;t.deleteAttribute("uv");let n=new MeshStandardMaterial({metalness:0,side:BackSide}),a=new MeshStandardMaterial({metalness:0}),i=qt(o);i.room.color&&(n.color=new Color(i.room.color),a.color=new Color(i.room.color));let s=i.topLight.color?new Color(i.topLight.color):new Color(16777215),c=new PointLight(s,i.topLight.intensity,28,2);c.position.set(...i.topLight.position),this.add(c);let l=new Mesh(t,n);l.position.set(...i.room.position),l.scale.set(...i.room.scale),this.add(l);for(let p of i.boxes){let u=new Mesh(t,a);u.position.set(...p.position),u.rotation.set(0,p.rotation,0),u.scale.set(...p.scale),this.add(u);}for(let p of i.lights){let u=new Mesh(t,ml(p.intensity));u.position.set(...p.position),u.scale.set(...p.scale),this.add(u);}}};function ml(e){let o=new MeshBasicMaterial;return o.color.setScalar(e),o}a(ml,"createAreaLightMaterial");var hl=/swiftshader|llvmpipe|softpipe|lavapipe|software|basic render/i;function gl(e){return hl.test(e)}a(gl,"isSoftwareRendererName");function bl(e){let o=e.getContext(),t=o.getExtension("WEBGL_debug_renderer_info");return String(o.getParameter(t?t.UNMASKED_RENDERER_WEBGL:o.RENDERER)??"")}a(bl,"rendererName");function Kt(e){return gl(bl(e))}a(Kt,"isSoftwareRenderer");var mt=4,Uo=16,Pl=.3,Ml=.35,Cl=.8,Ct=`
|
|
57
|
-
varying vec2 vUv;
|
|
58
|
-
void main() {
|
|
59
|
-
vUv = uv;
|
|
60
|
-
gl_Position = vec4(position.xy, 0.0, 1.0);
|
|
61
|
-
}
|
|
62
|
-
`;function On(){return {bvh:{value:new d},previous:{value:null},envMap:{value:null},envMapRotation:{value:new Matrix3},envIntensity:{value:0},ambient:{value:0},sampleOffset:{value:0},samples:{value:4},rowStart:{value:0},rowEnd:{value:0},lampCount:{value:0},lampA:{value:Array.from({length:mt},()=>new Vector4)},lampB:{value:Array.from({length:mt},()=>new Vector4)},productAlbedo:{value:Ml},floorAlbedo:{value:Cl}}}a(On,"traceUniforms");var Dn=`
|
|
63
|
-
#include <common>
|
|
64
|
-
#include <cube_uv_reflection_fragment>
|
|
65
|
-
${e.common_functions}
|
|
66
|
-
${e.bvh_struct_definitions}
|
|
67
|
-
${e.bvh_ray_functions}
|
|
68
|
-
|
|
69
|
-
uniform BVH bvh;
|
|
70
|
-
uniform sampler2D previous;
|
|
71
|
-
uniform sampler2D envMap;
|
|
72
|
-
uniform mat3 envMapRotation;
|
|
73
|
-
uniform float envIntensity;
|
|
74
|
-
uniform float ambient;
|
|
75
|
-
uniform int sampleOffset;
|
|
76
|
-
uniform int samples;
|
|
77
|
-
// The rows this pass traces; the rest are carried over as they were. A
|
|
78
|
-
// pass over everything can take longer than a frame on a large scene.
|
|
79
|
-
uniform int rowStart;
|
|
80
|
-
uniform int rowEnd;
|
|
81
|
-
uniform int lampCount;
|
|
82
|
-
// xyz: the lamp's position (point) or the direction towards it
|
|
83
|
-
// (directional); w: 0 point, 1 directional.
|
|
84
|
-
uniform vec4 lampA[${mt}];
|
|
85
|
-
// x: intensity, y: decay, z: disc radius (m) or cone half-angle (rad).
|
|
86
|
-
uniform vec4 lampB[${mt}];
|
|
87
|
-
uniform float productAlbedo;
|
|
88
|
-
uniform float floorAlbedo;
|
|
89
|
-
varying vec2 vUv;
|
|
90
|
-
|
|
91
|
-
uvec2 pcg2d(uvec2 v) {
|
|
92
|
-
v = v * 1664525u + 1013904223u;
|
|
93
|
-
v.x += v.y * 1664525u;
|
|
94
|
-
v.y += v.x * 1664525u;
|
|
95
|
-
v = v ^ (v >> 16u);
|
|
96
|
-
v.x += v.y * 1664525u;
|
|
97
|
-
v.y += v.x * 1664525u;
|
|
98
|
-
v = v ^ (v >> 16u);
|
|
99
|
-
return v;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
vec2 texelRandom(uint salt) {
|
|
103
|
-
return vec2(pcg2d(uvec2(gl_FragCoord.xy) + uvec2(salt, salt * 7u))) / 4294967295.0;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
// Every point walks the same low-discrepancy sequence (R2) from its own
|
|
107
|
-
// random offset: evenly spread samples for each point, and no pattern
|
|
108
|
-
// shared between neighbours for the eye to pick up.
|
|
109
|
-
vec2 r2(vec2 offset, float n) {
|
|
110
|
-
return fract(offset + n * vec2(0.7548776662466927, 0.5698402909980532));
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
// Any direction perpendicular to n, and the third one that completes the frame.
|
|
114
|
-
void basis(vec3 n, out vec3 t, out vec3 b) {
|
|
115
|
-
t = normalize(abs(n.y) < 0.99 ? cross(n, vec3(0.0, 1.0, 0.0)) : cross(n, vec3(1.0, 0.0, 0.0)));
|
|
116
|
-
b = cross(n, t);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
bool hit(vec3 origin, vec3 direction, float maxDistance, out vec3 normal) {
|
|
120
|
-
uvec4 faceIndices = uvec4(0u);
|
|
121
|
-
vec3 faceNormal = vec3(0.0, 1.0, 0.0);
|
|
122
|
-
vec3 barycoord = vec3(0.0);
|
|
123
|
-
float side = 1.0;
|
|
124
|
-
float dist = 0.0;
|
|
125
|
-
bool found = bvhIntersectFirstHit(
|
|
126
|
-
bvh, origin, direction, faceIndices, faceNormal, barycoord, side, dist
|
|
127
|
-
);
|
|
128
|
-
// Turned to face the ray's origin by the intersection itself.
|
|
129
|
-
normal = faceNormal;
|
|
130
|
-
return found && dist < maxDistance;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
// The sky's radiance, as irradiance per cosine-weighted sample: the ambient
|
|
134
|
-
// light is uniform, the environment is read the way a fully rough material
|
|
135
|
-
// would read it.
|
|
136
|
-
float sky(vec3 direction) {
|
|
137
|
-
vec3 env = textureCubeUV(envMap, envMapRotation * direction, 1.0).rgb;
|
|
138
|
-
return ambient + envIntensity * PI * dot(env, vec3(0.2126, 0.7152, 0.0722));
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
// This pass's samples at one point: (sky arrived, sky open, lamp arrived, lamp open).
|
|
142
|
-
vec4 gather(vec3 origin, vec3 normal) {
|
|
143
|
-
vec3 t;
|
|
144
|
-
vec3 b;
|
|
145
|
-
basis(normal, t, b);
|
|
146
|
-
vec2 skyOffset = texelRandom(1u);
|
|
147
|
-
vec2 lampOffset = texelRandom(2u);
|
|
148
|
-
vec4 sums = vec4(0.0);
|
|
149
|
-
|
|
150
|
-
for (int i = 0; i < ${Uo}; i++) {
|
|
151
|
-
if (i >= samples) break;
|
|
152
|
-
float n = float(sampleOffset + i);
|
|
153
|
-
|
|
154
|
-
vec2 u = r2(skyOffset, n);
|
|
155
|
-
float r = sqrt(u.x);
|
|
156
|
-
float phi = 2.0 * PI * u.y;
|
|
157
|
-
vec3 direction = normalize(
|
|
158
|
-
t * (r * cos(phi)) + normal * sqrt(max(0.0, 1.0 - u.x)) + b * (r * sin(phi))
|
|
159
|
-
);
|
|
160
|
-
float light = sky(direction);
|
|
161
|
-
sums.y += light;
|
|
162
|
-
vec3 surface;
|
|
163
|
-
if (hit(origin, direction, 1e20, surface)) {
|
|
164
|
-
// Light the product sends back: what its surface receives, which is
|
|
165
|
-
// the open sky on a face turned up and the floor's own bounce on a
|
|
166
|
-
// face turned down.
|
|
167
|
-
float up = 0.5 + 0.5 * surface.y;
|
|
168
|
-
sums.x += productAlbedo * light * mix(floorAlbedo, 1.0, up);
|
|
169
|
-
} else {
|
|
170
|
-
sums.x += light;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
vec2 v = r2(lampOffset, n);
|
|
174
|
-
for (int l = 0; l < ${mt}; l++) {
|
|
175
|
-
if (l >= lampCount) break;
|
|
176
|
-
vec4 a = lampA[l];
|
|
177
|
-
vec4 c = lampB[l];
|
|
178
|
-
vec3 toLamp;
|
|
179
|
-
float reach;
|
|
180
|
-
float irradiance;
|
|
181
|
-
vec3 lt;
|
|
182
|
-
vec3 lb;
|
|
183
|
-
if (a.w < 0.5) {
|
|
184
|
-
vec3 axis = normalize(a.xyz - origin);
|
|
185
|
-
basis(axis, lt, lb);
|
|
186
|
-
float radius = c.z * sqrt(v.x);
|
|
187
|
-
float angle = 2.0 * PI * v.y;
|
|
188
|
-
vec3 target = a.xyz + (lt * cos(angle) + lb * sin(angle)) * radius;
|
|
189
|
-
toLamp = target - origin;
|
|
190
|
-
reach = length(toLamp);
|
|
191
|
-
toLamp /= reach;
|
|
192
|
-
irradiance = c.x / max(pow(reach, c.y), 0.01);
|
|
193
|
-
} else {
|
|
194
|
-
vec3 axis = normalize(a.xyz);
|
|
195
|
-
basis(axis, lt, lb);
|
|
196
|
-
float cosTheta = 1.0 - v.x * (1.0 - cos(c.z));
|
|
197
|
-
float sinTheta = sqrt(max(0.0, 1.0 - cosTheta * cosTheta));
|
|
198
|
-
float angle = 2.0 * PI * v.y;
|
|
199
|
-
toLamp = axis * cosTheta + (lt * cos(angle) + lb * sin(angle)) * sinTheta;
|
|
200
|
-
reach = 1e20;
|
|
201
|
-
irradiance = c.x;
|
|
202
|
-
}
|
|
203
|
-
float incoming = irradiance * max(dot(normal, toLamp), 0.0);
|
|
204
|
-
if (incoming <= 0.0) continue;
|
|
205
|
-
sums.w += incoming;
|
|
206
|
-
if (!hit(origin, toLamp, reach, surface)) sums.z += incoming;
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
return sums;
|
|
210
|
-
}
|
|
211
|
-
`;function kn(){return new ShaderMaterial({defines:{ENVMAP_TYPE_CUBE_UV:""},uniforms:{...On(),rect:{value:new Vector4},floorY:{value:0}},vertexShader:Ct,fragmentShader:`
|
|
212
|
-
${Dn}
|
|
213
|
-
uniform vec4 rect;
|
|
214
|
-
uniform float floorY;
|
|
215
|
-
void main() {
|
|
216
|
-
int row = int(gl_FragCoord.y);
|
|
217
|
-
if (row < rowStart || row >= rowEnd) {
|
|
218
|
-
gl_FragColor = texture2D(previous, vUv);
|
|
219
|
-
return;
|
|
220
|
-
}
|
|
221
|
-
// A millimetre up, so a ray leaving the floor does not start inside a
|
|
222
|
-
// foot resting on it.
|
|
223
|
-
vec3 origin = vec3(rect.x + vUv.x * rect.z, floorY + 0.001, rect.y + vUv.y * rect.w);
|
|
224
|
-
gl_FragColor = texture2D(previous, vUv) + gather(origin, vec3(0.0, 1.0, 0.0));
|
|
225
|
-
}
|
|
226
|
-
`})}a(kn,"createFloorTraceMaterial");function Ln(){return new ShaderMaterial({defines:{ENVMAP_TYPE_CUBE_UV:""},uniforms:{...On(),vertexPositions:{value:null},vertexNormals:{value:null}},vertexShader:Ct,fragmentShader:`
|
|
227
|
-
${Dn}
|
|
228
|
-
uniform sampler2D vertexPositions;
|
|
229
|
-
uniform sampler2D vertexNormals;
|
|
230
|
-
void main() {
|
|
231
|
-
ivec2 texel = ivec2(gl_FragCoord.xy);
|
|
232
|
-
vec4 accumulated = texelFetch(previous, texel, 0);
|
|
233
|
-
if (texel.y < rowStart || texel.y >= rowEnd) {
|
|
234
|
-
gl_FragColor = accumulated;
|
|
235
|
-
return;
|
|
236
|
-
}
|
|
237
|
-
vec3 normal = texelFetch(vertexNormals, texel, 0).xyz;
|
|
238
|
-
// Padding, or a part without normals: left fully lit.
|
|
239
|
-
if (dot(normal, normal) < 0.5) {
|
|
240
|
-
gl_FragColor = accumulated + vec4(float(samples));
|
|
241
|
-
return;
|
|
242
|
-
}
|
|
243
|
-
// Two millimetres off the surface: past the curvature of the
|
|
244
|
-
// neighbouring triangles, still well inside any seam worth shading.
|
|
245
|
-
vec3 origin = texelFetch(vertexPositions, texel, 0).xyz + normal * 0.002;
|
|
246
|
-
gl_FragColor = accumulated + gather(origin, normal);
|
|
247
|
-
}
|
|
248
|
-
`})}a(Ln,"createVertexTraceMaterial");function In(){return new ShaderMaterial({uniforms:{accumulated:{value:null}},vertexShader:Ct,fragmentShader:`
|
|
249
|
-
uniform sampler2D accumulated;
|
|
250
|
-
void main() {
|
|
251
|
-
vec4 sums = texelFetch(accumulated, ivec2(gl_FragCoord.xy), 0);
|
|
252
|
-
float sky = sums.y > 0.0 ? clamp(sums.x / sums.y, 0.0, 1.0) : 1.0;
|
|
253
|
-
float lamp = sums.w > 0.0 ? clamp(sums.z / sums.w, 0.0, 1.0) : 1.0;
|
|
254
|
-
gl_FragColor = vec4(1.0 - sky, 1.0 - lamp, 128.0 / 255.0, 0.0);
|
|
255
|
-
}
|
|
256
|
-
`})}a(In,"createVertexResolveMaterial");var $t=new Color;function Tl(e){return $t.copy(e),.2126*$t.r+.7152*$t.g+.0722*$t.b}a(Tl,"luminance");function Rl(e,o){let t=0,n=[];return e.traverseVisible(a=>{if(!(a instanceof AmbientLight||a instanceof PointLight||a instanceof DirectionalLight)||a.intensity<=0||!a.layers.isEnabled(0))return;let i=a.intensity*Tl(a.color);if(a instanceof AmbientLight){t+=i;return}if(n.length>=mt)return;let s=a.getWorldPosition(new Vector3);if(a instanceof PointLight){let c=Math.max(s.y-o,.1);n.push({a:new Vector4(s.x,s.y,s.z,0),b:new Vector4(i,a.decay,c*Pl,0)});}else {let c=a.target.getWorldPosition(new Vector3);n.push({a:new Vector4(s.x-c.x,s.y-c.y,s.z-c.z,1),b:new Vector4(i,0,.05,0)});}}),{ambient:t,lamps:n}}a(Rl,"gatherLights");function _n(e){let o=[e.environment?.id??0,e.environmentIntensity];return e.traverseVisible(t=>{(t instanceof AmbientLight||t instanceof PointLight||t instanceof DirectionalLight)&&o.push(t.id,t.intensity,...t.position.toArray());}),o.join(",")}a(_n,"lightingSignature");function Vo(e,o,t){let n=e.uniforms,a=o.environment,i=a?.mapping===CubeUVReflectionMapping?a:null,{ambient:s,lamps:c}=Rl(o,t);n.ambient.value=s,n.envMap.value=i,n.envIntensity.value=i?o.environmentIntensity:0;let l=i?i.image.height:256,p=Math.log2(l)-2,u=e.defines,d=String(1/(3*Math.max(2**p,112)));u.CUBEUV_TEXEL_WIDTH!==d&&(u.CUBEUV_TEXEL_WIDTH=d,u.CUBEUV_TEXEL_HEIGHT=String(1/l),u.CUBEUV_MAX_MIP=`${p}.0`,e.needsUpdate=true);let v=new Euler().copy(o.environmentRotation);v.x*=-1,v.y*=-1,v.z*=-1,n.envMapRotation.value.setFromMatrix4(new Matrix4().makeRotationFromEuler(v)),n.lampCount.value=c.length,c.forEach((f,S)=>{n.lampA.value[S].copy(f.a),n.lampB.value[S].copy(f.b);});}a(Vo,"setTraceLighting");var Ll=96,Il=1024;function Fn(e,o){let[t,,n,a,i,s]=e,c=Math.max(i-o,.1),l=Math.min(Math.max(.5+c*.8,.75),3),p=a-t+l*2,u=s-n+l*2,d=Math.min(Ll,Il/Math.max(p,u));return {rect:new Vector4(t-l,n-l,p,u),size:[Math.max(16,Math.round(p*d)),Math.max(16,Math.round(u*d))]}}a(Fn,"floorRect");function zn(){return new ShaderMaterial({uniforms:{accumulated:{value:null},texel:{value:new Vector2}},vertexShader:Ct,fragmentShader:`
|
|
257
|
-
uniform sampler2D accumulated;
|
|
258
|
-
uniform vec2 texel;
|
|
259
|
-
varying vec2 vUv;
|
|
260
|
-
|
|
261
|
-
// All the light that arrives over all that would: the floor is lit by
|
|
262
|
-
// the sky and the lamps together, and darkened by what is missing of both.
|
|
263
|
-
float ratio(vec2 uv) {
|
|
264
|
-
vec4 sums = texture2D(accumulated, uv);
|
|
265
|
-
float open = sums.y + sums.w;
|
|
266
|
-
return open > 0.0 ? clamp((sums.x + sums.z) / open, 0.0, 1.0) : 1.0;
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
// A 5x5 binomial blur: what noise is left after a full bake is per
|
|
270
|
-
// texel, and the shadow itself is soft at this scale everywhere but
|
|
271
|
-
// right at a foot, where a texel is under a centimetre anyway.
|
|
272
|
-
void main() {
|
|
273
|
-
float weights[5] = float[5](1.0, 4.0, 6.0, 4.0, 1.0);
|
|
274
|
-
float sum = 0.0;
|
|
275
|
-
for (int y = 0; y < 5; y++) {
|
|
276
|
-
for (int x = 0; x < 5; x++) {
|
|
277
|
-
sum += weights[x] * weights[y] * ratio(vUv + vec2(float(x - 2), float(y - 2)) * texel);
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
gl_FragColor = vec4(sum / 256.0, 0.0, 0.0, 1.0);
|
|
281
|
-
}
|
|
282
|
-
`})}a(zn,"createFloorResolveMaterial");function Gn(){let e=new ShaderMaterial({uniforms:{map:{value:null},rect:{value:new Vector4},opacity:{value:0},previousMap:{value:null},previousRect:{value:new Vector4},crossfade:{value:1},...UniformsUtils.clone(UniformsLib.fog)},vertexShader:`
|
|
283
|
-
varying vec2 vFloor;
|
|
284
|
-
varying float vFogDepth;
|
|
285
|
-
void main() {
|
|
286
|
-
vec4 world = modelMatrix * vec4(position, 1.0);
|
|
287
|
-
vFloor = world.xz;
|
|
288
|
-
vec4 view = viewMatrix * world;
|
|
289
|
-
vFogDepth = -view.z;
|
|
290
|
-
gl_Position = projectionMatrix * view;
|
|
291
|
-
}
|
|
292
|
-
`,fragmentShader:`
|
|
293
|
-
uniform sampler2D map;
|
|
294
|
-
uniform vec4 rect;
|
|
295
|
-
uniform sampler2D previousMap;
|
|
296
|
-
uniform vec4 previousRect;
|
|
297
|
-
uniform float crossfade;
|
|
298
|
-
uniform float opacity;
|
|
299
|
-
uniform float fogNear;
|
|
300
|
-
uniform float fogFar;
|
|
301
|
-
varying vec2 vFloor;
|
|
302
|
-
varying float vFogDepth;
|
|
303
|
-
|
|
304
|
-
float encode(float linear) {
|
|
305
|
-
return linear <= 0.0031308 ? linear * 12.92 : 1.055 * pow(linear, 1.0 / 2.4) - 0.055;
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
// The light one map leaves on this point of the floor, 1 = unshadowed.
|
|
309
|
-
float lightFrom(sampler2D m, vec4 r) {
|
|
310
|
-
if (r.z <= 0.0) return 1.0;
|
|
311
|
-
vec2 uv = (vFloor - r.xy) / r.zw;
|
|
312
|
-
// The map covers a finite patch; its last few percent ease out so the
|
|
313
|
-
// patch never shows an edge.
|
|
314
|
-
vec2 edge = smoothstep(0.0, 0.06, uv) * smoothstep(0.0, 0.06, 1.0 - uv);
|
|
315
|
-
return 1.0 - (1.0 - texture2D(m, uv).r) * edge.x * edge.y;
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
void main() {
|
|
319
|
-
float light = crossfade >= 1.0
|
|
320
|
-
? lightFrom(map, rect)
|
|
321
|
-
: mix(lightFrom(previousMap, previousRect), lightFrom(map, rect), crossfade);
|
|
322
|
-
// Fogged like the floor it lies on. The plane draws darkness, not a
|
|
323
|
-
// colour, so fog takes the darkness away rather than tinting it \u2014 and
|
|
324
|
-
// without it a scene dissolving into fog left its shadows standing on
|
|
325
|
-
// a floor that had already gone.
|
|
326
|
-
float fogged = fogFar > fogNear ? smoothstep(fogNear, fogFar, vFogDepth) : 0.0;
|
|
327
|
-
float kept = 1.0 - (1.0 - light) * opacity * (1.0 - fogged);
|
|
328
|
-
// The canvas blends in sRGB, after encoding. Black at alpha a keeps
|
|
329
|
-
// (1 - a) of the ENCODED floor, so the alpha that keeps that share of
|
|
330
|
-
// its light is 1 - encode(kept), not 1 - kept, which would shadow
|
|
331
|
-
// about twice as dark as traced.
|
|
332
|
-
gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0 - encode(kept));
|
|
333
|
-
}
|
|
334
|
-
`,transparent:true,fog:true,depthWrite:false,polygonOffset:true,polygonOffsetFactor:-1,polygonOffsetUnits:-1}),o=new Mesh(new PlaneGeometry(1,1).rotateX(-Math.PI/2),e);return o.name="bakedFloorShadow",o.renderOrder=1,o.visible=false,o.matrixAutoUpdate=false,{plane:o,material:e}}a(Gn,"createFloorPlane");var Ne=1024;function Nn(e,o){let t=0,n=0;for(let f of e.parts){let S=o.get(f.key);if(!S)continue;let O=f.matrices.length/16,y=S.positions.length/3;t+=y*O,n+=(S.index?.length??y)*O;}let a=new Float32Array(t*3),i=new Uint32Array(n),s=[1/0,1/0,1/0,-1/0,-1/0,-1/0],c=0,l=0;for(let f of e.parts){let S=o.get(f.key);if(!S)continue;let O=S.positions,y=O.length/3;for(let w=0;w<f.matrices.length/16;w++){let P=f.matrices.subarray(w*16,w*16+16);for(let T=0;T<y;T++){let R=O[T*3],z=O[T*3+1],g=O[T*3+2],x=P[0]*R+P[4]*z+P[8]*g+P[12],M=P[1]*R+P[5]*z+P[9]*g+P[13],E=P[2]*R+P[6]*z+P[10]*g+P[14],G=(c+T)*3;a[G]=x,a[G+1]=M,a[G+2]=E,x<s[0]&&(s[0]=x),M<s[1]&&(s[1]=M),E<s[2]&&(s[2]=E),x>s[3]&&(s[3]=x),M>s[4]&&(s[4]=M),E>s[5]&&(s[5]=E);}if(S.index){for(let T=0;T<S.index.length;T++)i[l+T]=S.index[T]+c;l+=S.index.length;}else {for(let T=0;T<y;T++)i[l+T]=c+T;l+=y;}c+=y;}}let p=zl(e,o),u=new BufferGeometry;u.setAttribute("position",new BufferAttribute(a,3)),u.setIndex(new BufferAttribute(i,1));let d=new a$1(u,{strategy:0,maxLeafSize:8}),v=a$1.serialize(d,{cloneBuffers:false});return {id:e.id,positions:a,index:v.index,roots:v.roots,bounds:s,triangles:n/3,...p}}a(Nn,"buildOccluders");var Wn=new Matrix4,Un=new Matrix3;function zl(e,o){let t=0;for(let c of e.parts){let l=o.get(c.key);c.vertices&&l&&(t+=l.positions.length/3);}let n=Math.max(1,Math.ceil(t/Ne)),a=new Float32Array(n*Ne*4),i=new Float32Array(n*Ne*4),s=0;for(let c of e.parts){let l=o.get(c.key);if(!c.vertices||!l)continue;let p=Wn.fromArray(c.matrices).elements;Un.getNormalMatrix(Wn);let u=Un.elements,{positions:d,normals:v}=l,f=d.length/3;for(let S=0;S<f;S++){let O=d[S*3],y=d[S*3+1],w=d[S*3+2],P=(s+S)*4;if(a[P]=p[0]*O+p[4]*y+p[8]*w+p[12],a[P+1]=p[1]*O+p[5]*y+p[9]*w+p[13],a[P+2]=p[2]*O+p[6]*y+p[10]*w+p[14],a[P+3]=1,!v)continue;let T=v[S*3],R=v[S*3+1],z=v[S*3+2],g=u[0]*T+u[3]*R+u[6]*z,x=u[1]*T+u[4]*R+u[7]*z,M=u[2]*T+u[5]*R+u[8]*z,E=Math.hypot(g,x,M)||1;i[P]=g/E,i[P+1]=x/E,i[P+2]=M/E;}s+=f;}return {vertexPositions:a,vertexNormals:i,vertexCount:t}}a(zl,"bakedVertices");function jn(e){let o=new BufferGeometry;o.setAttribute("position",new BufferAttribute(e.positions,3)),o.setIndex(new BufferAttribute(e.index,1));let t={version:1,roots:e.roots,index:e.index,indirectBuffer:null};return a$1.deserialize(t,o,{setIndex:false})}a(jn,"occluderBVH");var qe="bakedShade",Xn=128,jo=new WeakMap,Qt=new WeakMap,Ho=new Set;function at(e){return jo.get(e)??e}a(at,"sourceGeometry");function Kn(e){let o=e.geometry;if(jo.has(o)&&Qt.get(o)===e)return o;let t=at(o),n=t.attributes.position;if(!n)return o;let a$1=new BufferGeometry;a$1.name=t.name,a$1.index=t.index;for(let[s,c]of Object.entries(t.attributes))s!==qe&&(a$1.attributes[s]=c);a$1.morphAttributes=t.morphAttributes,a$1.morphTargetsRelative=t.morphTargetsRelative,a$1.groups=t.groups,a$1.drawRange=t.drawRange,a$1.boundingBox=t.boundingBox,a$1.boundingSphere=t.boundingSphere,a$1.userData=t.userData,Object.defineProperty(a$1,"boundsTree",{configurable:true,get:a(()=>t.boundsTree,"get"),set:a(s=>{t.boundsTree=s;},"set")});let i=new Uint8Array(n.count*4);for(let s=0;s<n.count;s++)i[s*4+2]=Xn;return a$1.setAttribute(qe,new BufferAttribute(i,4,true)),jo.set(a$1,t),Qt.set(a$1,e),Ho.add(a$1),e.geometry=a$1,a$1}a(Kn,"wrapGeometry");function $n(e,o,t){let n=e.geometry.getAttribute(qe);if(!(n instanceof BufferAttribute)||Qt.get(e.geometry)!==e)return;let a=n.array;a.set(o.subarray(t*4,t*4+a.length)),n.needsUpdate=true;}a($n,"writeShade");function Ul(e,o){for(let t=e;t;t=t.parent)if(t===o)return true;return false}a(Ul,"isAttached");function Yn(e){for(let o of Ho){let t=Qt.get(o);if(t&&t.geometry===o&&Ul(t,e))continue;t&&t.geometry===o&&(t.geometry=at(o));let n=o.attributes[qe];o.attributes=n?{[qe]:n}:{},o.index=null,o.morphAttributes={},o.dispose(),Ho.delete(o);}}a(Yn,"releaseWrappers");var Ce={value:new Vector2(0,0)},Vl={value:1},Hn=new WeakSet;function Qn(e){if(Hn.has(e)||!("isMeshStandardMaterial"in e))return;Hn.add(e);let o=e.onBeforeCompile.bind(e),t=e.customProgramCacheKey.bind(e);e.onBeforeCompile=(n,a)=>{o(n,a),n.uniforms.bakedShadeStrength=Ce,n.uniforms.bakedShadeDirectScale=Vl,n.vertexShader=n.vertexShader.replace("#include <common>",`#include <common>
|
|
335
|
-
attribute vec4 ${qe};
|
|
336
|
-
varying vec2 vBakedShade;`).replace("#include <begin_vertex>",`#include <begin_vertex>
|
|
337
|
-
vBakedShade = abs(${qe}.z - ${Xn}.0 / 255.0) < 0.002
|
|
338
|
-
? ${qe}.xy
|
|
339
|
-
: vec2(0.0);`),n.fragmentShader=n.fragmentShader.replace("#include <common>",`#include <common>
|
|
340
|
-
uniform vec2 bakedShadeStrength;
|
|
341
|
-
uniform float bakedShadeDirectScale;
|
|
342
|
-
varying vec2 vBakedShade;`).replace("#include <aomap_fragment>",`#include <aomap_fragment>
|
|
343
|
-
{
|
|
344
|
-
vec2 kept = 1.0 - vBakedShade * bakedShadeStrength * vec2(1.0, bakedShadeDirectScale);
|
|
345
|
-
reflectedLight.indirectDiffuse *= kept.x;
|
|
346
|
-
// Reflections are occluded too, but less: a glossy surface in a
|
|
347
|
-
// crease still shows a highlight from the open side.
|
|
348
|
-
reflectedLight.indirectSpecular *= mix(1.0, kept.x, 0.5);
|
|
349
|
-
reflectedLight.directDiffuse *= kept.y;
|
|
350
|
-
reflectedLight.directSpecular *= kept.y;
|
|
351
|
-
#ifdef USE_SHEEN
|
|
352
|
-
sheenSpecularIndirect *= kept.x;
|
|
353
|
-
sheenSpecularDirect *= kept.y;
|
|
354
|
-
#endif
|
|
355
|
-
#ifdef USE_CLEARCOAT
|
|
356
|
-
clearcoatSpecularIndirect *= mix(1.0, kept.x, 0.5);
|
|
357
|
-
clearcoatSpecularDirect *= kept.y;
|
|
358
|
-
#endif
|
|
359
|
-
}`);},e.customProgramCacheKey=()=>`${t()}|bakedShade`,e.needsUpdate=true;}a(Qn,"patchMaterial");function jl(e){return (Array.isArray(e)?e:[e]).some(t=>t.visible&&t.colorWrite)}a(jl,"drawsSomething");function Zt(e){let o=[];return e.traverseVisible(t=>{Oo(t)&&jl(t.material)&&!Vt(t.material)&&o.push(t);}),o}a(Zt,"visibleModuleMeshes");function ta(e){let o=2166136261;function t(n){o=Math.imul(o^(n|0),16777619);}a(t,"mix");for(let n of e){let a=at(n.geometry);t(n.id),t(a.id);let i=a.attributes.position;t(i&&"version"in i?i.version:0);for(let s of n.matrixWorld.elements)t(Math.round(s*1e4));n instanceof InstancedMesh&&(t(n.count),t(n.instanceMatrix.version));}return t(e.length),o>>>0}a(ta,"occluderSignature");function Hl(e){let o=at(e.geometry),t=o.attributes.position,n=t&&"version"in t?t.version:0;return `${o.uuid}:${n}:${o.index?.version??-1}`}a(Hl,"shapeKey");function Zn(e){if(!e)return null;if(e instanceof BufferAttribute&&e.array instanceof Float32Array&&e.itemSize===3&&!e.normalized)return e.array;let o=new Float32Array(e.count*3);for(let t=0;t<e.count;t++)o[t*3]=e.getX(t),o[t*3+1]=e.getY(t),o[t*3+2]=e.getZ(t);return o}a(Zn,"floats");function ql(e){let o=at(e.geometry),t=Zn(o.attributes.position);if(!t)return null;let n=o.index?.array,a=!n||n instanceof Uint32Array||n instanceof Uint16Array?n??null:Uint32Array.from(n);return {positions:t,normals:Zn(o.attributes.normal),index:a}}a(ql,"shapeOf");var Jn=new Matrix4,Xl=new Matrix4;function Kl(e){if(!(e instanceof InstancedMesh))return new Float32Array(e.matrixWorld.elements);let o=new Float32Array(e.count*16);for(let t=0;t<e.count;t++)e.getMatrixAt(t,Jn),Xl.multiplyMatrices(e.matrixWorld,Jn).toArray(o,t*16);return o}a(Kl,"matricesOf");function oa(){let e=null,o=new Set,t=0,n=new Map,a$1=new Map;try{throw new Error("@konfigure/sdk builds occluders on the main thread")}catch{e=null;}function i(s){let c=++t,l=[],p={},u=new Set,d=[],v=0;for(let S of s){let O=Hl(S);if(!u.has(O)){let w=e&&o.has(O),P=w?null:ql(S);if(!w&&!P)continue;u.add(O),P&&(p[O]=P);}let y=!(S instanceof InstancedMesh);if(l.push({key:O,matrices:Kl(S),vertices:y}),y){let w=at(S.geometry).attributes.position.count;d.push({mesh:S,offset:v,count:w}),v+=w;}}if(!e){for(let[O,y]of Object.entries(p))a$1.set(O,y);for(let O of a$1.keys())u.has(O)||a$1.delete(O);let S=Promise.resolve(Nn({id:c,parts:l},a$1));return {id:c,ranges:d,result:S}}o=u;let f=new Promise(S=>n.set(c,S));return e.postMessage({id:c,shapes:p,parts:l}),{id:c,ranges:d,result:f}}return a(i,"build"),{build:i,dispose(){e?.terminate(),e=null;for(let s of n.values())s(null);n.clear();}}}a(oa,"createOccluderBuilder");var Jl=64,ec=192,tc=48e6,oc=48,sa=4e5,rc=16e3,nc=64e6,ac=1.5,ic=1.2,sc=60,lc=.2,la=250,cc=1500,uc=4e3,ca=12e3,dc=120,pc=450,fc=.55,mc=.85,hc=.85,Tt=0,ua=new Vector4;function da(e){let{scene:o,renderer:t,requestTick:n}=e,a$1=t.extensions.has("EXT_color_buffer_float"),i=a$1||t.extensions.has("EXT_color_buffer_half_float"),s=t.capabilities.isWebGL2&&i?Kt(t)?"software":null:"unsupported",c=a$1?FloatType:HalfFloatType,l=kn(),p=zn(),u=Ln(),d=In(),{plane:v,material:f}=Gn(),S=new FullScreenQuad(l),O=oa(),y=false,w=null,P=null,T=null,R=new Vector4,z={amount:1,fromNothing:false},g=null,x=null,M=[],E=null,G=null,V=false,C=null,U=0,N,H={still:sa,moving:sa/4},j="still",_=0,m=null,k=0,b=[],A=null,h=null,W=null,B=null,Y=null,Q=0,q=0,ne=null;function oe(L,K){let ee=a(()=>new WebGLRenderTarget(L,K,{type:c,format:RGBAFormat,minFilter:NearestFilter,magFilter:NearestFilter,depthBuffer:false,generateMipmaps:false}),"make");return [ee(),ee()]}a(oe,"accumulationTargets");function ce(L,K,ee){return !!L&&L.width===K&&L.height===ee}a(ce,"sized");function Se(L){let K=t.getRenderTarget(),ee=t.getClearColor(new Color),ae=t.getClearAlpha();t.setRenderTarget(L),t.setClearColor(0,0),t.clear(true,false,false),t.setRenderTarget(K),t.setClearColor(ee,ae);}a(Se,"clear");function ie(L,K){S.material=L;let ee=t.getRenderTarget();t.setRenderTarget(K),S.render(t),t.setRenderTarget(ee);}a(ie,"draw");function ct(L){let K=Zt(o);if(!K.length){B={job:{signature:L,started:performance.now(),activeMs:0,traced:0,stillTraced:0,stillMs:0,rect:new Vector4,ranges:[],floor:null,vertices:null,stats:{triangles:0,vertices:0,floorWidth:0,floorHeight:0,mainThreadMs:0,buildMs:0,vertexSamples:0}},shade:null};return}let ee=performance.now(),{id:ae,ranges:se,result:me}=O.build(K),ge=performance.now()-ee;A={id:ae,signature:L},me.then(fe=>{A?.id===ae&&(A=null,fe&&L===G&&ue(L,fe,se,ee,ge),n());});}a(ct,"prepare");function ue(L,K,ee,ae,se){let me=performance.now(),ge=jn(K);l.uniforms.bvh.value.updateFrom(ge),u.uniforms.bvh.value=l.uniforms.bvh.value;let{rect:fe,size:le}=Fn(K.bounds,Tt);Vo(l,o,Tt),Vo(u,o,Tt),l.uniforms.rect.value.copy(fe),l.uniforms.floorY.value=Tt,ce(w?.[0]??null,...le)||(w?.forEach(Me=>Me.dispose()),w=oe(...le)),Se(w[0]);let ke=K.vertexPositions.length/4/Ne;for(let Me of M)Me.dispose();M=[K.vertexPositions,K.vertexNormals].map(Me=>{let Fe=new DataTexture(Me,Ne,ke,RGBAFormat,FloatType);return Fe.needsUpdate=true,Fe}),u.uniforms.vertexPositions.value=M[0],u.uniforms.vertexNormals.value=M[1],ce(g?.[0]??null,Ne,ke)||(g?.forEach(Me=>Me.dispose()),x?.dispose(),g=oe(Ne,ke),x=new WebGLRenderTarget(Ne,ke,{type:UnsignedByteType,minFilter:NearestFilter,magFilter:NearestFilter,depthBuffer:false,generateMipmaps:false})),Se(g[0]);let $e=a((Me,Fe,wt)=>({material:Me,targets:Fe,goal:wt,done:0,row:0,round:1}),"accumulation"),Ye=Math.max(oc,Math.min(ec,Math.floor(tc/K.vertexCount)));h={signature:L,started:ae,activeMs:0,traced:0,stillTraced:0,stillMs:0,rect:fe,ranges:ee,floor:$e(l,w,Jl),vertices:K.vertexCount?$e(u,g,Ye):null,stats:{triangles:K.triangles,vertices:K.vertexCount,floorWidth:le[0],floorHeight:le[1],mainThreadMs:se+performance.now()-me,buildMs:performance.now()-ae,vertexSamples:K.vertexCount?Ye:0}};}a(ue,"begin");function ut(L,K){if(L.done>=L.goal||K<=0)return 0;let[ee,ae]=L.targets,{width:se,height:me}=ee;L.row===0&&(L.round=Math.max(1,Math.min(Uo,L.goal-L.done,Math.floor(K/(se*me)))));let ge=Math.min(me-L.row,Math.max(1,Math.floor(K/(se*L.round)))),fe=L.material.uniforms;return fe.previous.value=ee.texture,fe.sampleOffset.value=L.done,fe.samples.value=L.round,fe.rowStart.value=L.row,fe.rowEnd.value=L.row+ge,ie(L.material,ae),L.targets=[ae,ee],L.row+=ge,L.row>=me&&(L.row=0,L.done+=L.round),ge*se*L.round}a(ut,"advance");function dt(L,K,ee){if(!h)return;h.activeMs+=L,ee||(h.stillMs+=L);let ae=t.getContext();if(K&&m&&(ae.deleteSync(m),m=null),m){if(ae.clientWaitSync(m,0,0)===ae.TIMEOUT_EXPIRED){k++;return}ae.deleteSync(m),m=null;let Ye=b.length?[...b].sort((wt,xt)=>wt-xt):[1e3/60],Me=Math.max(4,Ye[Math.floor(Ye.length*lc)]),Fe=H[j];k>0||L>Me*ac?H[j]=Math.max(rc,Fe*.7):L<Me*ic&&_>=Fe*.7&&(H[j]=Math.min(nc,Fe*1.25)),k=0;}j=ee?"moving":"still";let se=H[j],me=ut(h.floor,se);_=me+(h.vertices?ut(h.vertices,se-me):0),h.traced+=_,ee||(h.stillTraced+=_),m=ae.fenceSync(ae.SYNC_GPU_COMMANDS_COMPLETE,0),ae.flush();let ge=h.floor.done>=h.floor.goal,fe=!h.vertices||h.vertices.done>=h.vertices.goal;if(!ge||!fe)return;let le=h;if(h=null,w=le.floor.targets,!le.vertices||!x){B={job:le,shade:null};return}g=le.vertices.targets,d.uniforms.accumulated.value=g[0].texture,ie(d,x);let ke=x,$e=new Uint8Array(ke.width*ke.height*4);W={signature:le.signature},t.readRenderTargetPixelsAsync(ke,0,0,ke.width,ke.height,$e).then(()=>{W?.signature===le.signature&&(W=null,le.signature===G&&(B={job:le,shade:$e}),n());}).catch(()=>{W=null;});}a(dt,"step");function I(){let L=z.amount<1,K=z.fromNothing?ua:R;return f.uniforms.crossfade.value=z.amount,f.uniforms.previousRect.value.copy(L?K:ua),f.uniforms.rect.value.z>0||L&&K.z>0}a(I,"applyCrossfade");function X({job:L,shade:K}){Y={...L.stats,bakeMs:performance.now()-L.started};let ee=f.uniforms.rect.value,ae=T;if(T=P,R.copy(ee),f.uniforms.previousMap.value=T?.texture??null,L.rect.z===0||!w)ae?.dispose(),P=null,ee.set(0,0,0,0);else {let[se,me]=[w[0].width,w[0].height];ae&&ce(ae,se,me)?P=ae:(ae?.dispose(),P=new WebGLRenderTarget(se,me,{type:UnsignedByteType,minFilter:LinearFilter,magFilter:LinearFilter,depthBuffer:false,generateMipmaps:false})),p.uniforms.accumulated.value=w[0].texture,p.uniforms.texel.value.set(1/P.width,1/P.height),ie(p,P),f.uniforms.map.value=P.texture,ee.copy(L.rect);let{rect:ge}=L;v.matrix.makeScale(ge.z,1,ge.w).setPosition(ge.x+ge.z/2,Tt+4e-4,ge.y+ge.w/2),v.matrixWorldNeedsUpdate=true;}if(K)for(let se of L.ranges)$n(se.mesh,K,se.offset);}a(X,"show");function $(L){let K=a(se=>se?se.goal*se.targets[0].width*se.targets[0].height:0,"total");if(L.stillMs<cc)return L.activeMs>ca*2?"too-complex":null;let ee=L.stillTraced/L.stillMs;if(ee<uc)return "too-slow";let ae=K(L.floor)+K(L.vertices)-L.traced;return L.activeMs+ae/ee>ca?"too-complex":null}a($,"judge");function re(L){if(!(!y||s||!L)){for(let K of Zt(o)){Kn(K);let ee=Array.isArray(K.material)?K.material:[K.material];for(let ae of ee)Qn(ae);}Yn(o);}}a(re,"beforeRender");function Z(L,K=false){let ee=performance.now(),ae=q?ee-q:1/0,se=ae<50?ae:1e3/60;q=ee,ae<50&&(b.push(ae),b.length>sc&&b.shift());let me=!s&&h?$(h):null;if(me==="too-slow"?s=me:me==="too-complex"&&(C=h.signature,h=null),!y||s)return h=null,A=null,W=null,B=null,v.parent&&v.removeFromParent(),Q&&(Re(0),Ce.value.set(0,0)),Q=0,null;v.parent||o.add(v);let ge=L&&!V||G===null?`${ta(Zt(o))}|${_n(o)}`:G;ge!==G&&(G=ge,U=ee,A=null,h=null,W=null,B=null,clearTimeout(N),N=setTimeout(n,la));let fe=null;E!==G?(Q>0&&(Q=Math.max(0,Q-se/dc),fe="redraw"),h?(dt(se,ne===null||ne!==h,K),ne=h,fe??="work"):!A&&!W&&!B&&C!==G&&ee-U>=la&&ct(G),B&&Q===0&&(X(B),E=B.job.signature,B=null,fe="redraw")):Q<1&&(Q=Math.min(1,Q+se/pc),fe="redraw");let le=I();return v.visible=le&&Q>0,f.uniforms.opacity.value=Q*fc*et(),Re(le?Q:0),Ce.value.set(mc*Q,hc*Q),fe}a(Z,"update");function be(){return !y||s?"off":E===G?Q<1?"fading":"idle":h?"tracing":C===G?Q>0?"fading":"skipped":A?"building":W?"reading":B?"fading":"settling"}return a(be,"phase"),{setEnabled(L){y=L;},setHeld(L){V=L;},setFloorCrossfade(L,K=false){z.amount=Math.min(1,Math.max(0,L)),z.fromNothing=K;let ee=I();v.visible=ee&&Q>0;},beforeRender:re,update:Z,get phase(){return be()},get availability(){return s||(C!==null&&C===G?"too-complex":"available")},hide(){let L=v.visible,K=Ce.value.clone(),ee=tt();return v.visible=false,Ce.value.set(0,0),Re(0),ft(),()=>{v.visible=L,Ce.value.copy(K),Re(ee),ft();}},get stats(){return Y},dispose(){clearTimeout(N),m&&t.getContext().deleteSync(m),O.dispose(),v.removeFromParent(),Re(0),Ce.value.set(0,0),v.geometry.dispose(),l.uniforms.bvh.value.dispose();for(let L of [l,p,u,d,f])L.dispose();S.dispose(),w?.forEach(L=>L.dispose()),g?.forEach(L=>L.dispose()),P?.dispose(),T?.dispose(),x?.dispose();for(let L of M)L.dispose();}}}a(da,"createBakedLighting");var pa={showFloor:true,lighting:{environmentIntensity:.1,ambientLightIntensity:.3*Math.PI,pointLightIntensity:.6*Math.PI},initialCameraPosition:[0,2,4.5],initialTarget:[0,.5,0],minPolarAngle:0,maxPolarAngle:Math.PI/2};var eo={showFloor:true,lighting:{environmentIntensity:.45,ambientLightIntensity:.35,pointLightIntensity:0,rig:[{intensity:.6,position:[-3,2.5,-3]}]},shadowLightIntensity:2.2,updateLighting(e,o,t){let n=new Vector3;t.getCenter(n);let a=new Vector3;t.getSize(a);let i=Math.max(a.x,a.y,a.z,1)*3;o.position.set(n.x+i*.55,n.y+i*.9,n.z+i*.65),o.target.position.set(n.x,n.y*.5,n.z),o.target.updateMatrixWorld(),o.intensity=0,e.position.set(n.x,n.y+9,n.z);},shadowPadding:.6,toneMapping:NeutralToneMapping,toneMappingExposure:1,initialCameraPosition:[-0.8,1.25,1.65],initialTarget:[0,.5,0],snapCameraOnApply:true,minPolarAngle:0,maxPolarAngle:Math.PI/2,minDistance:.6,maxDistance:10,cameraNear:.05,cameraFar:250};var ma={...eo,shadowPadding:1.5,initialCameraPosition:[-2.6,2.3,5.2],initialTarget:[0,1.1,0],minDistance:1.2,maxDistance:18};var ga={showFloor:false,environmentName:"studio",sceneColor:"#dcdcdc",adaptiveBackground:false,shadowPadding:.12,shadowLightIntensity:4.5,castModuleShadows:true,softShadowSize:16,softShadowSamples:24,toneMapping:ACESFilmicToneMapping,toneMappingExposure:1.22,lighting:{environmentIntensity:2,ambientLightIntensity:.18,pointLightIntensity:0,rig:[{intensity:1.5,position:[5,6,10]},{intensity:.5,position:[-5,3,-4]},{intensity:1,position:[1,-1,2]},{intensity:.7,position:[0,4,-6]}]},updateLighting(e,o,t){let n=t.getCenter(new Vector3),a=t.getSize(new Vector3);o.shadow.mapSize.x!==2048&&(o.shadow.mapSize.set(2048,2048),o.shadow.map?.dispose(),o.shadow.map=null),o.shadow.bias=-15e-7,o.shadow.normalBias=8e-4;let i=Math.max(a.length(),.3);e.position.set(n.x+i*2.4,n.y+i*2,n.z+i*1.1),e.castShadow=false,o.intensity=0,o.castShadow=true,o.position.set(n.x,n.y+i*2.2,n.z+i*1.89),o.target.position.copy(n),o.target.updateMatrixWorld();let s=o.position.distanceTo(n),c=Math.max(a.length(),.05);o.shadow.camera.near=Math.max(s-c,.01),o.shadow.camera.far=s+c,o.shadow.camera.updateProjectionMatrix();},initialCameraPosition:[-0.236,1.587,.336],initialTarget:[0,1.5,0],minPolarAngle:0,maxPolarAngle:Math.PI,minDistance:.08,maxDistance:2,cameraNear:.01,cameraFar:50,snapCameraOnApply:true};var to={showFloor:true,sceneColor:"#f0f0f0",adaptiveBackground:true,lighting:{environmentIntensity:.2,ambientLightIntensity:.2*Math.PI,pointLightIntensity:.6*Math.PI},updateLighting(e,o,t){let n=new Vector3;t.getCenter(n);let a=new Vector3;t.getSize(a);let i=Math.max(a.y*1.2,4);e.position.set(n.x,n.y+i,n.z+3),e.castShadow=false,o.intensity=0,o.castShadow=true,o.position.copy(e.position),o.target.position.set(n.x,0,n.z),o.target.updateMatrixWorld();},initialCameraPosition:[0,2,4.5],initialTarget:[0,.5,0],minPolarAngle:0,maxPolarAngle:Math.PI/2};function Sc(){let e=new MeshStandardMaterial({color:"#e0e0e0",roughness:.9}),o=new BoxGeometry(2,3,.2),t=new Mesh(o,e);return t.position.set(0,1.5,-0.5),t.castShadow=true,t.receiveShadow=true,t.name="wall",[t]}a(Sc,"createWallGeometry");function wc(e,o,t){let n=e.find(u=>u.name==="wall");if(!n||o.isEmpty())return;let a=o.getSize(new Vector3),i=o.getCenter(new Vector3),s=a.x+1,c=o.max.y+.5,l=t?.wallThickness??.2,p=t?.wallPositionOffset??0;n.geometry.dispose(),n.geometry=new BoxGeometry(s,c,l),n.position.set(i.x,c/2,o.min.z-l/2+p);}a(wc,"updateWallGeometry");var it={showFloor:true,lighting:{environmentIntensity:.5,ambientLightIntensity:.1*Math.PI,pointLightIntensity:.4*Math.PI},createGeometry:Sc,updateGeometry:wc,initialCameraPosition:[0,2,5],initialTarget:[0,1.5,0],minPolarAngle:Math.PI/6,maxPolarAngle:Math.PI/2};var Sa={...to,createGeometry:it.createGeometry,updateGeometry:it.updateGeometry};function Pc(e,o,t){let n=e.find(u=>u.name==="wall");if(!n||o.isEmpty())return;let a=o.getSize(new Vector3),i=o.getCenter(new Vector3),s=t?.wallThickness??.2,c=t?.wallPositionOffset??0,l=Math.max(o.max.y+.6,2.4),p=Math.max(a.x+1.2,2);n.geometry.dispose(),n.geometry=new BoxGeometry(p,l,s),n.position.set(i.x,l/2,o.min.z-s/2+c);}a(Pc,"updateWallGeometryClose");var xa={...it,updateGeometry:Pc,initialCameraPosition:[0,1.6,.52],initialTarget:[0,1.5,0],snapCameraOnApply:true,minDistance:.12,maxDistance:4};var xe={ROOM:"room",WALL:"wall",SURROUND_LIGHT:"surround_light",SURROUND_LIGHT_WALL:"surround_light_wall",WALL_CLOSE:"wall_close",STUDIO_CLOSE:"studio_close",ROOM_LIT:"room_lit",ROOM_LIT_WIDE:"room_lit_wide"};var Mc={[xe.ROOM]:pa,[xe.WALL]:it,[xe.SURROUND_LIGHT]:to,[xe.SURROUND_LIGHT_WALL]:Sa,[xe.WALL_CLOSE]:xa,[xe.STUDIO_CLOSE]:ga,[xe.ROOM_LIT]:eo,[xe.ROOM_LIT_WIDE]:ma};function $o(e){return Mc[e??xe.ROOM]}a($o,"getScenePreset");function Qo({size:e,samples:o}){let t=ShaderChunk.shadowmap_pars_fragment,a$1=`
|
|
360
|
-
// --- konfigure soft shadows -------------------------------------------------
|
|
361
|
-
#define SOFT_SHADOW_TAPS ${Math.max(1,Math.round(o))}
|
|
362
|
-
#define SOFT_SHADOW_SIZE ${e.toFixed(2)}
|
|
363
|
-
|
|
364
|
-
// Interleaved gradient noise: a rotation per pixel with no visible pattern.
|
|
365
|
-
float softShadowAngle( vec2 fragCoord ) {
|
|
366
|
-
return fract( 52.9829189 * fract( dot( fragCoord, vec2( 0.06711056, 0.00583715 ) ) ) ) * 6.2831853;
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
// Tap i of a Vogel disc of unit radius, turned by angle.
|
|
370
|
-
vec2 softShadowTap( int i, float angle ) {
|
|
371
|
-
float r = sqrt( ( float( i ) + 0.5 ) / float( SOFT_SHADOW_TAPS ) );
|
|
372
|
-
float theta = float( i ) * 2.399963 + angle;
|
|
373
|
-
return vec2( cos( theta ), sin( theta ) ) * r;
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
// The compare at uv blended from its four texels: a hard edge comes out as a
|
|
377
|
-
// ramp a texel wide, never as the texel grid.
|
|
378
|
-
float softShadowCompare( sampler2D shadowMap, vec2 shadowMapSize, vec2 uv, float compare ) {
|
|
379
|
-
vec2 texel = 1.0 / shadowMapSize;
|
|
380
|
-
vec2 grid = uv * shadowMapSize - 0.5;
|
|
381
|
-
vec2 f = fract( grid );
|
|
382
|
-
vec2 base = ( floor( grid ) + 0.5 ) * texel;
|
|
383
|
-
float a = texture2DCompare( shadowMap, base, compare );
|
|
384
|
-
float b = texture2DCompare( shadowMap, base + vec2( texel.x, 0.0 ), compare );
|
|
385
|
-
float c = texture2DCompare( shadowMap, base + vec2( 0.0, texel.y ), compare );
|
|
386
|
-
float d = texture2DCompare( shadowMap, base + texel, compare );
|
|
387
|
-
return mix( mix( a, b, f.x ), mix( c, d, f.x ), f.y );
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
float softShadow( sampler2D shadowMap, vec2 shadowMapSize, float lightSize, vec4 shadowCoord ) {
|
|
391
|
-
vec2 texel = 1.0 / shadowMapSize;
|
|
392
|
-
float angle = softShadowAngle( gl_FragCoord.xy );
|
|
393
|
-
float reach = SOFT_SHADOW_SIZE * lightSize;
|
|
394
|
-
|
|
395
|
-
// Blocker search: the mean depth of what casts onto this point within reach.
|
|
396
|
-
float blockerSum = 0.0;
|
|
397
|
-
float blockers = 0.0;
|
|
398
|
-
for ( int i = 0; i < SOFT_SHADOW_TAPS; i ++ ) {
|
|
399
|
-
vec2 uv = shadowCoord.xy + softShadowTap( i, angle ) * texel * reach;
|
|
400
|
-
float depth = unpackRGBAToDepth( texture2D( shadowMap, uv ) );
|
|
401
|
-
#ifdef USE_REVERSED_DEPTH_BUFFER
|
|
402
|
-
bool blocked = depth > shadowCoord.z;
|
|
403
|
-
#else
|
|
404
|
-
bool blocked = depth < shadowCoord.z;
|
|
405
|
-
#endif
|
|
406
|
-
if ( blocked ) {
|
|
407
|
-
blockerSum += depth;
|
|
408
|
-
blockers += 1.0;
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
if ( blockers == 0.0 ) return 1.0;
|
|
412
|
-
|
|
413
|
-
// Parallel-plane estimate: the penumbra widens with how far behind its
|
|
414
|
-
// blocker the receiver is.
|
|
415
|
-
float blocker = blockerSum / blockers;
|
|
416
|
-
float penumbra = abs( shadowCoord.z - blocker ) / max( blocker, 1e-4 );
|
|
417
|
-
float radius = max( 1.5, ( 1.0 + 1.25 * penumbra * SOFT_SHADOW_SIZE ) * lightSize );
|
|
418
|
-
|
|
419
|
-
float lit = 0.0;
|
|
420
|
-
for ( int i = 0; i < SOFT_SHADOW_TAPS; i ++ ) {
|
|
421
|
-
vec2 uv = shadowCoord.xy + softShadowTap( i, angle ) * texel * radius;
|
|
422
|
-
lit += softShadowCompare( shadowMap, shadowMapSize, uv, shadowCoord.z );
|
|
423
|
-
}
|
|
424
|
-
return lit / float( SOFT_SHADOW_TAPS );
|
|
425
|
-
}
|
|
426
|
-
`,i="float getShadow( sampler2D shadowMap",s="#if defined( SHADOWMAP_TYPE_PCF )",c=t.indexOf(i),l=t.slice(0,c),p=t.slice(c),u=l+a$1+p.replace(s,`return mix( 1.0, softShadow( shadowMap, shadowMapSize, shadowRadius, shadowCoord ), shadowIntensity );
|
|
427
|
-
${s}`);return ShaderChunk.shadowmap_pars_fragment=u,a(function(v,f,S){ShaderChunk.shadowmap_pars_fragment=t,Cc(v,f,S);},"teardown")}a(Qo,"softShadows");function Cc(e,o,t){o.traverse(n=>{let a=n.material;if(a)for(let i of [a].flat())e.properties.remove(i),i.dispose();}),e.info.programs&&(e.info.programs.length=0),e.compile(o,t);}a(Cc,"recompile");var er=.9,Fc=.3,zc=.2;function tr(e,o){let t=new Box3,n=false;return Nt(e,a=>{a.visible&&(n=true,!(o?.excludeWallPanels&&a.userData.excludeFromWallBounds)&&t.expandByObject(a));}),{box:t,hasModules:n}}a(tr,"getModuleBoundingBox");function or(e,o){let t=o.existingScene??new Scene,n=new Mesh,a$1=new PerspectiveCamera(46,1,.1,500),i,s,c=-1,l=-1,p,u,d,v=0,f,S=[],O,y,w=true,P=[],T=true,R={side:.5,top:.3},z=false,g=null,x=false,M=false,E=0,G=o.colorMode,V=true,C=false,U=null,N=false,H=[],j=null,_=false,m=null,k=false,b=false,A=false;function h(){V=true;}a(h,"invalidate");function W(D){C=D,D&&h();}a(W,"setForceRender");function B(D){U=D,h();}a(B,"setCameraDriver");let Y=[];function Q(){return h(),new Promise(D=>Y.push(D))}a(Q,"nextRender");function q(){if(!Y.length)return;let D=Y;Y=[];for(let F of D)F();}a(q,"flushRenderWaiters");let{onAnimate:ne,onFrame:oe,onRender:ce}=o;f=$o(o.scenePreset);function Se(){a$1.near=f.cameraNear??.1,a$1.far=f.cameraFar??500,a$1.updateProjectionMatrix();}a(Se,"applyCameraFrustum"),Se();let ie=new WebGLRenderer({antialias:true,canvas:e,alpha:true});ie.setPixelRatio(window.devicePixelRatio),ie.setSize(o.width,o.height),ie.shadowMap.enabled=true,ie.outputColorSpace=SRGBColorSpace,ie.toneMapping=f.toneMapping??NoToneMapping,ie.toneMappingExposure=f.toneMappingExposure??1;function ct(){N||(t.environment?.dispose(),i?.dispose(),xt(f?.environmentName??"neutral"),Bo(),ie.shadowMap.needsUpdate=true,j&&(j.dispose(),j=null,_&&Hr(true)),h());}a(ct,"onContextRestored"),e.addEventListener("webglcontextrestored",ct),a$1.position.set(...f.initialCameraPosition),a$1.aspect=o.width/o.height;let ue=new OrbitControls(a$1,e);ue.target.set(...f.initialTarget),ue.enableDamping=true,ue.minDistance=f.minDistance??2,ue.maxDistance=f.maxDistance??15,ue.minPolarAngle=f.minPolarAngle,ue.maxPolarAngle=f.maxPolarAngle,ue.maxTargetRadius=10,ue.addEventListener("change",()=>{ue.target.y<.1&&(ue.target.y=.1),h();});let ut=Scene.prototype.add,dt=Scene.prototype.remove;t.add=function(...D){return h(),ut.apply(t,D)},t.remove=function(...D){return h(),dt.apply(t,D)};function I(D){return D==="dark"?{bg:"#555",floor:"#666"}:{bg:g??f?.sceneColor??"#c1c1c1",floor:"#fff"}}a(I,"getSceneColors");function X(){let{bg:D,floor:F}=I(G);t.fog=new Fog(D,30,40),t.background=new Color(D),n.parent&&!z&&(n.material=new MeshStandardMaterial({color:F,roughness:1})),ee=-1;}a(X,"applySceneColors");let $=new Color;function re(D){return D.getRGB($,SRGBColorSpace),.299*$.r+.587*$.g+.114*$.b}a(re,"srgbLuminance");function Z(){let D=0,F=0;return Nt(t,J=>{if(!J.visible||!J.userData.hasConfigurableSurface)return;let te=Array.isArray(J.material)?J.material:[J.material];for(let pe of te){let ve=pe.color;ve&&(D+=re(ve),F++);}}),F>0?D/F:null}a(Z,"getModuleAverageLuminance");let be=new Color,L=new Color,K=new Color,ee=-1;function ae(){let D=Z()??0,F=D<=er?0:(D-er)/(1-er);if(Math.abs(F-ee)<.01)return;ee=F,K.set(g??f?.sceneColor??"#c1c1c1");let J=re(K)-Fc*F;if(be.setRGB(J,J,J,SRGBColorSpace),t.background=be,t.fog instanceof Fog&&t.fog.color.copy(be),n.parent&&!z&&n.material instanceof MeshStandardMaterial){let te=1-zc*F;L.setRGB(te,te,te,SRGBColorSpace),n.material.color.copy(L);}}a(ae,"updateAdaptiveColors");let se=0,me=new Color("#ffffff"),ge=new Color,fe=new Color,le=null,ke=.75;function $e(D,F){let J=Math.min(1,Math.max(0,D));F&&me.set(F),J!==se&&(se=J,h());}a($e,"setFogVeil");function Ye(){if(!(t.fog instanceof Fog))return;if(!se){if(!le)return;t.fog.near=le.near,t.fog.far=le.far,t.fog.color.copy(le.color),t.background=le.background,Le(1),le=null;return}le??={near:t.fog.near,far:t.fog.far,color:t.fog.color.clone(),background:t.background};let D=Math.max(.1,a$1.position.distanceTo(ue.target)),F=Math.max(le.far,D*2),J=Math.max(.05,D*.15),te=Math.pow(se,ke),pe=F*Math.pow(J/F,te);t.fog.far=pe,t.fog.near=pe*(le.far>0?le.near/le.far:.5),t.fog.color.copy(ge.copy(le.color).lerp(me,te));let ve=le.background instanceof Color?le.background:me;t.background=fe.copy(ve).lerp(me,te),Le(1-te);}a(Ye,"applyFogVeil");function Me(D){t.traverse(F=>{if(!(F instanceof Mesh))return;let J=Array.isArray(F.material)?F.material:[F.material];for(let te of J)"envMap"in te&&te.envMap&&(te.envMap=D,te.needsUpdate=true);});}a(Me,"updateEnvironmentMaps");function Fe(D){let F=new PMREMGenerator(ie),J=F.fromScene(new rt(D),.04).texture;return F.dispose(),J}a(Fe,"buildRoomEnvironment");function wt(D,F){new RGBELoader().load(D,J=>{if(!((f?.environmentName??"neutral")===F)||N){J.dispose();return}J.mapping=EquirectangularReflectionMapping;let pe=new PMREMGenerator(ie),ve=pe.fromEquirectangular(J).texture;pe.dispose(),J.dispose(),t.environment?.dispose(),i?.dispose(),i=ve,t.environment=ve,Me(ve),h();});}a(wt,"loadHdriEnvironment");function xt(D){i=Fe(D),t.environment=i,Me(i);let{hdri:F}=qt(D);F&&wt(F,D);}a(xt,"applyEnvironment");function ts(){let D=f?.environmentName??"neutral";xt(D);let F=f.lighting;t.environmentIntensity=F.environmentIntensity,p=new AmbientLight(16777215,F.ambientLightIntensity),t.add(p);for(let ve of F.rig??[]){let we=new DirectionalLight(16777215,ve.intensity);we.position.set(...ve.position),we.castShadow=false,H.push(we),t.add(we);}u=new PointLight(16777215,F.pointLightIntensity,100,0),u.position.set(0,9,0);let J=new PlaneGeometry(1e3,1e3),te=new ShadowMaterial;te.side=BackSide,te.opacity=.15,te.depthWrite=false,te.polygonOffset=true,te.polygonOffsetFactor=-1,te.polygonOffsetUnits=-1;let pe=new Mesh(J,te);pe.receiveShadow=true,pe.position.y=.004,pe.rotateX(Math.PI/2),pe.name="floor",pe.visible=T,t.add(pe),d=new DirectionalLight(16777215,0),d.position.set(0,5,0),d.castShadow=true,d.shadow.bias=-2e-5,d.shadow.intensity=1,d.shadow.camera.left=-10,d.shadow.camera.right=10,d.shadow.camera.top=10,d.shadow.camera.bottom=-10,c=f?.softShadowSize??10,l=f?.softShadowSamples??10,s=Qo({size:c,samples:l}),t.add(u,d,d.target);}a(ts,"setEnvironment");function Wr(){if(!f?.showFloor)return;let D=new PlaneGeometry(1e3,1e3),F=new MeshStandardMaterial({color:G==="dark"?"#666":"#fff",...i&&{envMap:i}});F.roughness=1,F.envMapIntensity=0,n=new Mesh(D,F),n.receiveShadow=false,n.rotation.x=-Math.PI/2,n.position.y=0,n.name="room",n.visible=T,t.add(n);}a(Wr,"createRoom"),Wr(),f.createGeometry&&(S=f.createGeometry(),S.forEach(D=>t.add(D))),ts(),X();function Ur(){!se&&V&&G!=="dark"&&f?.adaptiveBackground&&ae(),Ye(),ot(ie);let D=V;j?.beforeRender(D),m?rs(m):ie.render(t,a$1),V=false,Nr(D),ce?.(),q();}a(Ur,"drawFrame");let os=new Vector2;function rs(D){let{x:F,y:J}=ie.getSize(os),te=Math.round(F*Math.min(1,Math.max(0,D.at)));ie.setScissorTest(true),Vr(D.left,0,te,J),Vr(D.right,te,F-te,J),ie.setScissorTest(false);}a(rs,"renderSplit");function Vr(D,F,J,te){if(J<=0)return;let pe=D.apply?.(),ve=D.bakedLighting===false?j?.hide():void 0;pe&&j?.beforeRender(true),ie.setScissor(F,0,J,te),ie.render(t,a$1),ve?.(),pe?.();}a(Vr,"renderSide");function Nr(D){let F=j?.update(D,A)??null;k=F==="redraw",b=F==="work";}a(Nr,"runBake");function ns(){if(x){q();return}U?U(0):ue.update(),Ur();}a(ns,"renderNow");function jr(){if(!M)return;let D=performance.now()/1e3,F=v>0?D-v:.016;v=D;let J;U?(U(F),J=true):J=ue.update(F),oe?.(F),A=J,!x&&(C||V||J||k)?Ur():!x&&b?Nr(false):x&&q(),ne?.(),E=requestAnimationFrame(jr);}a(jr,"animate");function as(D,F){a$1.aspect=D/F,a$1.updateProjectionMatrix(),ie.setSize(D,F),ie.setPixelRatio(Math.min(window.devicePixelRatio,2)),h();}a(as,"setSize");function is(D){G=D,X(),h();}a(is,"setColorMode");function ss(D){D!==g&&(g=D,X(),h());}a(ss,"setSceneColor");function ls(D){let F=$o(D);if(F===f)return;let J=f?.environmentName??"neutral";S.forEach(de=>{t.remove(de),de instanceof Mesh&&(de.geometry.dispose(),de.material instanceof MeshStandardMaterial&&de.material.dispose());}),S=[];let te=t.getObjectByName("room");if(F.showFloor&&!te?(f=F,Wr()):!F.showFloor&&te&&(t.remove(te),te instanceof Mesh&&(te.geometry.dispose(),te.material instanceof MeshStandardMaterial&&te.material.dispose())),f=F,ue.minDistance=f.minDistance??2,ue.maxDistance=f.maxDistance??15,Se(),f.snapCameraOnApply&&(a$1.position.set(...f.initialCameraPosition),ue.target.set(...f.initialTarget),ue.update()),f.createGeometry){S=f.createGeometry();let de=!!O;S.forEach(ye=>{de&&(ye.visible=false),t.add(ye);});}let pe=F.environmentName??"neutral";J!==pe&&(i?.dispose(),t.environment?.dispose(),xt(pe));let ve=f.lighting;t.environmentIntensity=ve.environmentIntensity,p&&(p.intensity=ve.ambientLightIntensity),u&&(u.intensity=ve.pointLightIntensity);for(let de of H.splice(0))t.remove(de);for(let de of ve.rig??[]){let ye=new DirectionalLight(16777215,de.intensity);ye.position.set(...de.position),ye.castShadow=false,H.push(ye),t.add(ye);}let we=f.softShadowSize??10,We=f.softShadowSamples??10;(we!==c||We!==l)&&(s?.(ie,t,a$1),c=we,l=We,s=Qo({size:we,samples:We})),X(),ie.toneMapping=f.toneMapping??NoToneMapping,ie.toneMappingExposure=f.toneMappingExposure??1,ue.minPolarAngle=f.minPolarAngle,ue.maxPolarAngle=f.maxPolarAngle,qr(),h();}a(ls,"setScenePreset");function cs(D){m=D,h();}a(cs,"setSplitView");function Hr(D){_=D,D&&!j&&(j=da({scene:t,renderer:ie,requestTick:a(()=>{b=true;},"requestTick")})),j?.setEnabled(D),h();}a(Hr,"setBakedLighting");function us(D){x=D,D||h();}a(us,"setPaused");function ds(D){w=D,S.forEach(F=>{F.visible=D&&!O;}),P.forEach(F=>{F.visible=D;}),h();}a(ds,"setWallVisible");function ps(D){T=D;for(let F of ["room","floor"]){let J=t.getObjectByName(F);J&&(J.visible=D);}h();}a(ps,"setFloorVisible");function fs(D){R={side:D.side??.5,top:D.top??.3};}a(fs,"setWallSurround");function ms(D){let F=O!==D;return O=D,F}a(ms,"setWallThickness");function hs(D){let F=y!==D;return y=D,F}a(hs,"setWallPositionOffset");function qr(){if(!u||!d)return;let{box:D,hasModules:F}=tr(t);if(!F||D.isEmpty()){u.position.set(0,9,0),d.position.set(0,5,0),d.shadow.camera.left=-10,d.shadow.camera.right=10,d.shadow.camera.top=10,d.shadow.camera.bottom=-10,d.shadow.camera.updateProjectionMatrix(),ue.maxDistance=15,ue.maxTargetRadius=10,t.fog instanceof Fog&&(t.fog.near=20,t.fog.far=40);return}let J=new Vector3;D.getCenter(J);let te=new Vector3;D.getSize(te);let pe=Math.max(te.x,te.y,te.z),ve=f?.shadowPadding??Math.max(pe*.2,2),we=pe/2+ve;if(f?.updateLighting)f.updateLighting(u,d,D);else {let de=Math.max(9,Math.max(te.x,te.y,te.z)*1.5);u.position.set(J.x,de,J.z),d.intensity=0,d.position.set(J.x,5,J.z),d.target.position.set(J.x,0,J.z),d.target.updateMatrixWorld();}if(d.shadow.camera.left=-we,d.shadow.camera.right=we,d.shadow.camera.top=we,d.shadow.camera.bottom=-we,d.shadow.camera.updateProjectionMatrix(),f?.updateLighting&&d.intensity===0){d.intensity=f.shadowLightIntensity??1,d.layers.disableAll(),d.layers.enable(1),a$1.layers.enable(1);let de=f?.castModuleShadows===true;Nt(t,ye=>{ye.layers.enable(1),de&&(ye.castShadow=true,ye.receiveShadow=true);}),S.forEach(ye=>{ye.traverse(ze=>{ze instanceof Mesh&&ze.layers.enable(1);});});}else d.layers.enableAll();ie.shadowMap.needsUpdate=true,t.traverse(de=>{de instanceof Mesh&&de.material&&(de.material.needsUpdate=true);}),h();let We=Math.max(te.x,te.y,te.z);if(ue.maxDistance=Math.max(15,We*3),ue.maxTargetRadius=Math.max(10,we),t.fog instanceof Fog){let de=f?.fogFarMultiplier??1.5,ye=f?.fogNearMultiplier??.5,ze=Math.max(40,ue.maxDistance*de);t.fog.near=ze*ye,t.fog.far=ze;}if(f?.updateGeometry)if(O)S.forEach(de=>{de.visible=false;});else {let{box:de}=tr(t,{excludeWallPanels:true});f.updateGeometry(S,de,{wallThickness:O,wallPositionOffset:y}),S.forEach(ye=>{ye.visible=w;});}}a(qr,"updateLighting");function gs(){for(let Ue of P)t.remove(Ue),Ue.geometry.dispose(),Ue.material instanceof MeshStandardMaterial&&Ue.material.dispose();if(P=[],!O)return;let{box:D,hasModules:F}=tr(t,{excludeWallPanels:true});if(!F||D.isEmpty())return;let J=D.getSize(new Vector3),te=D.getCenter(new Vector3),pe=O,ve=y??0,we=R.side,We=R.top,de=D.max.y+We,ye=te.z+ve,ze=new MeshStandardMaterial({color:"#e0e0e0",roughness:.9}),Ps=new BoxGeometry(we,de,pe),kt=new Mesh(Ps,ze.clone());kt.name="wall-left",kt.position.set(D.min.x-we/2,de/2,ye),kt.receiveShadow=true;let Ms=new BoxGeometry(we,de,pe),Lt=new Mesh(Ms,ze.clone());Lt.name="wall-right",Lt.position.set(D.max.x+we/2,de/2,ye),Lt.receiveShadow=true;let Kr=J.x,Cs=new BoxGeometry(Kr,We,pe),It=new Mesh(Cs,ze.clone());It.name="wall-top",It.position.set(te.x,D.max.y+We/2,ye),It.receiveShadow=true,P=[kt,Lt,It];let vo=D.min.y;if(vo>.01){let Ue=new BoxGeometry(Kr,vo,pe),_t=new Mesh(Ue,ze.clone());_t.name="wall-bottom",_t.position.set(te.x,vo/2,ye),_t.receiveShadow=true,P.push(_t);}for(let Ue of P)Ue.visible=w,t.add(Ue);}a(gs,"updateWallMesh");function bs(D){let F=S.find(J=>J.name==="wall");F&&(F.material instanceof MeshStandardMaterial&&F.material.dispose(),F.material=D);for(let J of P)J.material instanceof MeshStandardMaterial&&J.material.dispose(),J.material=D.clone();h();}a(bs,"applyWallMaterial");function vs(){let D=[];for(let F of S)F instanceof Mesh&&F.visible&&D.push(F);for(let F of P)F.visible&&D.push(F);return D}a(vs,"getOcclusionColliders");function ys(D){if(!n.parent)return;n.material instanceof MeshStandardMaterial&&n.material.dispose();let F=D.clone();F instanceof MeshStandardMaterial&&F.map&&(F.map=F.map.clone(),F.map.repeat.set(1e3,1e3),F.map.needsUpdate=true),n.material=F,z=true,h();}a(ys,"applyFloorMaterial");function Ss(){M=true,v=0,h(),E=requestAnimationFrame(jr);}a(Ss,"start");function Xr(){M=false,E&&(cancelAnimationFrame(E),E=0);}a(Xr,"stop");function ws(){N=true,Xr(),e.removeEventListener("webglcontextrestored",ct),se=0,le=null,Le(1),s&&s(ie,t,a$1),j?.dispose(),j=null,t.traverse(D=>{D instanceof Mesh&&(D.geometry.dispose(),D.material.dispose());}),t.environment?.dispose(),i?.dispose(),S=[],P=[],z=false,t.clear(),delete t.add,delete t.remove,ue.dispose(),ie.dispose(),ie.forceContextLoss();}a(ws,"dispose");function xs(){return {cameraPosition:[...f.initialCameraPosition],target:[...f.initialTarget]}}return a(xs,"getInitialView"),{scene:t,camera:a$1,renderer:ie,controls:ue,setSize:as,setColorMode:is,setSceneColor:ss,setScenePreset:ls,getInitialView:xs,setPaused:us,setWallVisible:ds,setFloorVisible:ps,setWallSurround:fs,setWallThickness:ms,setWallPositionOffset:hs,updateLighting:qr,updateWallMesh:gs,applyWallMaterial:bs,applyFloorMaterial:ys,getOcclusionColliders:vs,invalidate:h,setForceRender:W,setCameraDriver:B,setFogVeil:$e,setBakedLighting:Hr,setSplitView:cs,get bakedLighting(){return j},nextRender:Q,renderNow:ns,start:Ss,stop:Xr,dispose:ws}}a(or,"createScene");function At(e){return e.extensions.has("EXT_color_buffer_float")||e.extensions.has("EXT_color_buffer_half_float")}a(At,"supportsFloatTargets");function rr(e,o,t,n={}){let a$1=At(e)?HalfFloatType:UnsignedByteType,i=new WebGLRenderTarget(o,t,{type:a$1,samples:n.samples??8}),s=new WebGLRenderTarget(o,t),c=new OutputPass,l=new Uint8Array(o*t*4);function p(u){c.render(e,s,{texture:u},0,false),e.setRenderTarget(null),e.readRenderTargetPixels(s,0,0,o,t,l);let d=new ImageData(o,t),v=o*4;for(let f=0;f<t;f++){let S=(t-1-f)*v;d.data.set(l.subarray(S,S+v),f*v);}return d}return a(p,"encode"),{width:o,height:t,render(u,d){return e.setRenderTarget(i),e.clear(),e.render(u,d),e.setRenderTarget(null),p(i.texture)},encode:p,dispose(){i.dispose(),s.dispose(),c.dispose();}}}a(rr,"createCaptureRenderer");function Ra(e,o="png",t){let n=document.createElement("canvas");return n.width=e.width,n.height=e.height,n.getContext("2d")?.putImageData(e,0,0),n.toDataURL(o==="jpeg"?"image/jpeg":"image/png",t)}a(Ra,"imageDataToDataURL");[{name:"front",dir:new Vector3(0,.3,1).normalize()},{name:"back",dir:new Vector3(0,.3,-1).normalize()},{name:"left",dir:new Vector3(-1,.3,0).normalize()},{name:"right",dir:new Vector3(1,.3,0).normalize()},{name:"top",dir:new Vector3(0,1,.01),distanceMultiplier:1.4},{name:"isometric",dir:new Vector3(1,1,1).normalize(),distanceMultiplier:1.3}];function Aa(e){if(e.length===0)return null;let o=new Box3;for(let t of e){let n=t.getBoundingBoxes(true);for(let a of n)o.union(a);}return o.isEmpty()?null:o}a(Aa,"getCombinedBoundingBox");var Nc=1.15;function Ea(e,o,t,n,a=Nc){let i=e.getCenter(new Vector3),s=n.clone().normalize(),c=new Vector3(0,1,0),l=new Vector3().crossVectors(c,s);l.lengthSq()<1e-6&&l.set(1,0,0),l.normalize();let p=new Vector3().crossVectors(s,l).normalize(),u=Math.tan(o*Math.PI/360),d=u*t,v=[new Vector3(e.min.x,e.min.y,e.min.z),new Vector3(e.min.x,e.min.y,e.max.z),new Vector3(e.min.x,e.max.y,e.min.z),new Vector3(e.min.x,e.max.y,e.max.z),new Vector3(e.max.x,e.min.y,e.min.z),new Vector3(e.max.x,e.min.y,e.max.z),new Vector3(e.max.x,e.max.y,e.min.z),new Vector3(e.max.x,e.max.y,e.max.z)],f=0;for(let S of v){let O=S.sub(i),y=O.dot(s),w=Math.abs(O.dot(l)),P=Math.abs(O.dot(p)),T=a*w/d+y,R=a*P/u+y;f=Math.max(f,T,R);}return f}a(Ea,"calculateCameraDistance");var Oa=30;[{name:"front",dir:new Vector3(0,.3,1).normalize()},{name:"back",dir:new Vector3(0,.3,-1).normalize()},{name:"left",dir:new Vector3(-1,.3,0).normalize()},{name:"right",dir:new Vector3(1,.3,0).normalize()},{name:"top",dir:new Vector3(0,1,.01),distanceMultiplier:1.4},{name:"isometric",dir:new Vector3(1,1,1).normalize(),distanceMultiplier:1.3}];function jc(e,o){let n=[new Vector3(e.min.x,e.min.y,e.min.z),new Vector3(e.min.x,e.min.y,e.max.z),new Vector3(e.min.x,e.max.y,e.min.z),new Vector3(e.min.x,e.max.y,e.max.z),new Vector3(e.max.x,e.min.y,e.min.z),new Vector3(e.max.x,e.min.y,e.max.z),new Vector3(e.max.x,e.max.y,e.min.z),new Vector3(e.max.x,e.max.y,e.max.z)].map(a=>a.clone().project(o).y);return {minY:Math.min(...n),maxY:Math.max(...n)}}a(jc,"getBoundingBoxScreenYExtent");function Da(e,o,t){let{minY:n,maxY:a}=jc(e,o),i=(a+n)/2,s=o.position.distanceTo(t),c=o.fov*Math.PI/180,l=2*Math.tan(c/2)*s;return i/2*l}a(Da,"calculateVerticalCenteringOffset");var nr=["configurator","catalogue","daylight","dramatic","dark"],Ie=a((e,o)=>({enabled:true,softness:.7,temperature:5600,...o,id:e}),"light"),ar={configurator:{id:"configurator",live:true,environment:"neutral",environmentIntensity:0,environmentRotation:0,exposure:0,backdrop:"",floorShadow:1,lights:[]},catalogue:{id:"catalogue",environment:"neutral",environmentIntensity:.4,environmentRotation:0,exposure:0,backdrop:"#f2f2f0",floorShadow:.55,lights:[Ie("key",{azimuth:-40,elevation:40,intensity:1.5,softness:.85}),Ie("fill",{azimuth:55,elevation:20,intensity:.5,softness:1}),Ie("rim",{azimuth:160,elevation:45,intensity:.9,softness:.5})]},daylight:{id:"daylight",environment:"neutral",environmentIntensity:.45,environmentRotation:0,exposure:0,backdrop:"#e9e4dc",floorShadow:.55,lights:[Ie("key",{azimuth:-75,elevation:25,intensity:1.1,softness:1,temperature:6300}),Ie("fill",{azimuth:60,elevation:15,intensity:.25,softness:1,temperature:4800}),Ie("rim",{enabled:false,azimuth:165,elevation:35,intensity:1,softness:.6})]},dramatic:{id:"dramatic",environment:"neutral",environmentIntensity:.15,environmentRotation:0,exposure:0,backdrop:"#5b5b5d",floorShadow:.85,lights:[Ie("key",{azimuth:-70,elevation:30,intensity:2.4,softness:.35,temperature:4900}),Ie("fill",{azimuth:60,elevation:15,intensity:.25,softness:1}),Ie("rim",{azimuth:150,elevation:35,intensity:2,softness:.3,temperature:6500})]},dark:{id:"dark",environment:"neutral",environmentIntensity:.08,environmentRotation:0,exposure:0,backdrop:"#1e1e20",floorShadow:.75,lights:[Ie("key",{azimuth:-25,elevation:55,intensity:2,softness:.8}),Ie("fill",{azimuth:70,elevation:20,intensity:.3,softness:1}),Ie("rim",{azimuth:180,elevation:40,intensity:1.8,softness:.5})]}};function ir(e){return {...e,lights:e.lights.map(o=>({...o}))}}a(ir,"clonePhotoSetup");var qc=5600;function ka(e){let o=Math.min(4e4,Math.max(1e3,e))/100,t=a(s=>Math.min(255,Math.max(0,s))/255,"clamp"),n=o<=66?255:329.698727446*Math.pow(o-60,-0.1332047592),a$1=o<=66?99.4708025861*Math.log(o)-161.1195681661:288.1221695283*Math.pow(o-60,-0.0755148492),i=o>=66?255:o<=19?0:138.5177312231*Math.log(o-10)-305.0447927307;return [t(n),t(a$1),t(i)]}a(ka,"blackBody");function sr(e,o=new Color){let t=ka(e),n=ka(qc),a=t.map((s,c)=>s/n[c]),i=Math.max(...a);return o.setRGB(a[0]/i,a[1]/i,a[2]/i,"srgb")}a(sr,"kelvinToColor");var eu=[1,2,4,8],tu=[1,2,4],Xe=`
|
|
428
|
-
varying vec2 vUv;
|
|
429
|
-
void main() {
|
|
430
|
-
vUv = uv;
|
|
431
|
-
gl_Position = vec4(position.xy, 0.0, 1.0);
|
|
432
|
-
}
|
|
433
|
-
`,_a=`
|
|
434
|
-
varying vec2 vUv;
|
|
435
|
-
uniform vec2 projection; // tan(fov / 2) * aspect, tan(fov / 2)
|
|
436
|
-
// (three's own \`luminance()\` is already in every shader's prelude.)
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
// View-space position from a guide texel: depth is in w (0 = nothing there).
|
|
440
|
-
vec3 viewPosition(vec2 uv, float depth) {
|
|
441
|
-
return vec3((uv * 2.0 - 1.0) * projection * depth, -depth);
|
|
442
|
-
}
|
|
443
|
-
`;function ou(){return new ShaderMaterial({side:DoubleSide,vertexShader:`
|
|
444
|
-
varying vec3 vNormal;
|
|
445
|
-
varying float vDepth;
|
|
446
|
-
void main() {
|
|
447
|
-
vNormal = normalize(normalMatrix * normal);
|
|
448
|
-
vec4 mv = modelViewMatrix * vec4(position, 1.0);
|
|
449
|
-
vDepth = -mv.z;
|
|
450
|
-
gl_Position = projectionMatrix * mv;
|
|
451
|
-
}
|
|
452
|
-
`,fragmentShader:`
|
|
453
|
-
varying vec3 vNormal;
|
|
454
|
-
varying float vDepth;
|
|
455
|
-
void main() {
|
|
456
|
-
gl_FragColor = vec4(normalize(vNormal) * (gl_FrontFacing ? 1.0 : -1.0), vDepth);
|
|
457
|
-
}
|
|
458
|
-
`})}a(ou,"normalDepthMaterial");var Ba="0.03";function ru(){return new ShaderMaterial({defines:{BASE_FLOOR:Ba},uniforms:{traced:{value:null},albedo:{value:null}},vertexShader:Xe,fragmentShader:`
|
|
459
|
-
uniform sampler2D traced;
|
|
460
|
-
uniform sampler2D albedo;
|
|
461
|
-
varying vec2 vUv;
|
|
462
|
-
void main() {
|
|
463
|
-
vec4 t = texture2D(traced, vUv);
|
|
464
|
-
vec4 a = texture2D(albedo, vUv);
|
|
465
|
-
// Floored so a near-black surface (a chair leg) does not turn its
|
|
466
|
-
// noise into fireflies. Compose multiplies by the same floored base.
|
|
467
|
-
vec3 base = max(a.rgb / max(a.a, 1e-4), vec3(BASE_FLOOR));
|
|
468
|
-
gl_FragColor = vec4(t.rgb / base, t.a);
|
|
469
|
-
}
|
|
470
|
-
`})}a(ru,"demodulateMaterial");function nu(){return new ShaderMaterial({uniforms:{source:{value:null},cover:{value:null},useCover:{value:false}},vertexShader:Xe,fragmentShader:`
|
|
471
|
-
uniform sampler2D source;
|
|
472
|
-
uniform sampler2D cover;
|
|
473
|
-
uniform bool useCover;
|
|
474
|
-
varying vec2 vUv;
|
|
475
|
-
void main() {
|
|
476
|
-
float valid = useCover ? 1.0 - texture2D(cover, vUv).a : 1.0;
|
|
477
|
-
gl_FragColor = vec4(texture2D(source, vUv).rgb, valid);
|
|
478
|
-
}
|
|
479
|
-
`})}a(nu,"maskMaterial");function au(){return new ShaderMaterial({uniforms:{image:{value:null},direction:{value:new Vector2}},vertexShader:Xe,fragmentShader:`
|
|
480
|
-
uniform sampler2D image;
|
|
481
|
-
uniform vec2 direction;
|
|
482
|
-
varying vec2 vUv;
|
|
483
|
-
void main() {
|
|
484
|
-
float weights[5];
|
|
485
|
-
weights[0] = 0.2270270270; weights[1] = 0.1945945946; weights[2] = 0.1216216216;
|
|
486
|
-
weights[3] = 0.0540540541; weights[4] = 0.0162162162;
|
|
487
|
-
vec3 sum = vec3(0.0);
|
|
488
|
-
float mass = 0.0;
|
|
489
|
-
float total = 0.0;
|
|
490
|
-
for (int i = -4; i <= 4; i++) {
|
|
491
|
-
float w = weights[i < 0 ? -i : i];
|
|
492
|
-
vec4 t = texture2D(image, vUv + direction * float(i));
|
|
493
|
-
sum += t.rgb * t.a * w;
|
|
494
|
-
mass += t.a * w;
|
|
495
|
-
total += w;
|
|
496
|
-
}
|
|
497
|
-
gl_FragColor = vec4(mass > 0.0 ? sum / mass : texture2D(image, vUv).rgb, mass / total);
|
|
498
|
-
}
|
|
499
|
-
`})}a(au,"gaussianMaterial");function iu(){return new ShaderMaterial({uniforms:{withProduct:{value:null},floorOnly:{value:null}},vertexShader:Xe,fragmentShader:`
|
|
500
|
-
uniform sampler2D withProduct;
|
|
501
|
-
uniform sampler2D floorOnly;
|
|
502
|
-
varying vec2 vUv;
|
|
503
|
-
void main() {
|
|
504
|
-
float lit = luminance(texture2D(withProduct, vUv).rgb);
|
|
505
|
-
float open = luminance(texture2D(floorOnly, vUv).rgb);
|
|
506
|
-
gl_FragColor = vec4(vec3(clamp(1.0 - lit / max(open, 1e-4), 0.0, 1.0)), 1.0);
|
|
507
|
-
}
|
|
508
|
-
`})}a(iu,"shadowMaterial");function su(){return new ShaderMaterial({uniforms:{source:{value:null}},vertexShader:Xe,fragmentShader:`
|
|
509
|
-
uniform sampler2D source;
|
|
510
|
-
varying vec2 vUv;
|
|
511
|
-
void main() { gl_FragColor = texture2D(source, vUv); }
|
|
512
|
-
`})}a(su,"copyMaterial");function lu(){return new ShaderMaterial({uniforms:{lighting:{value:null},texel:{value:null}},vertexShader:Xe,fragmentShader:`
|
|
513
|
-
uniform sampler2D lighting;
|
|
514
|
-
uniform vec2 texel;
|
|
515
|
-
varying vec2 vUv;
|
|
516
|
-
void main() {
|
|
517
|
-
float sum = 0.0;
|
|
518
|
-
float sumSq = 0.0;
|
|
519
|
-
for (int y = -2; y <= 2; y++) {
|
|
520
|
-
for (int x = -2; x <= 2; x++) {
|
|
521
|
-
float l = luminance(texture2D(lighting, vUv + vec2(x, y) * texel).rgb);
|
|
522
|
-
sum += l;
|
|
523
|
-
sumSq += l * l;
|
|
524
|
-
}
|
|
525
|
-
}
|
|
526
|
-
float mean = sum / 25.0;
|
|
527
|
-
gl_FragColor = vec4(max(sumSq / 25.0 - mean * mean, 0.0));
|
|
528
|
-
}
|
|
529
|
-
`})}a(lu,"varianceMaterial");function cu(){return new ShaderMaterial({uniforms:{lighting:{value:null},guide:{value:null},variance:{value:null},texel:{value:null},stepSize:{value:1},projection:{value:null}},vertexShader:Xe,fragmentShader:`
|
|
530
|
-
${_a}
|
|
531
|
-
uniform sampler2D lighting;
|
|
532
|
-
uniform sampler2D guide;
|
|
533
|
-
uniform sampler2D variance;
|
|
534
|
-
uniform vec2 texel;
|
|
535
|
-
uniform float stepSize;
|
|
536
|
-
void main() {
|
|
537
|
-
vec4 centre = texture2D(lighting, vUv);
|
|
538
|
-
vec4 g = texture2D(guide, vUv);
|
|
539
|
-
if (g.a <= 0.0) { gl_FragColor = centre; return; }
|
|
540
|
-
vec3 p = viewPosition(vUv, g.a);
|
|
541
|
-
float l = luminance(centre.rgb);
|
|
542
|
-
float sigmaL = 4.0 * sqrt(texture2D(variance, vUv).r) + 1e-3;
|
|
543
|
-
float kernel[3];
|
|
544
|
-
kernel[0] = 3.0 / 8.0; kernel[1] = 1.0 / 4.0; kernel[2] = 1.0 / 16.0;
|
|
545
|
-
vec4 sum = vec4(0.0);
|
|
546
|
-
float weights = 0.0;
|
|
547
|
-
for (int y = -2; y <= 2; y++) {
|
|
548
|
-
for (int x = -2; x <= 2; x++) {
|
|
549
|
-
vec2 uv = vUv + vec2(x, y) * stepSize * texel;
|
|
550
|
-
vec4 gq = texture2D(guide, uv);
|
|
551
|
-
if (gq.a <= 0.0) continue;
|
|
552
|
-
vec4 c = texture2D(lighting, uv);
|
|
553
|
-
// Same surface: facing the same way, and on the centre's plane
|
|
554
|
-
// (distance from it relative to how far away it is).
|
|
555
|
-
float wn = pow(max(dot(g.rgb, gq.rgb), 0.0), 32.0);
|
|
556
|
-
float plane = abs(dot(g.rgb, viewPosition(uv, gq.a) - p)) / (0.01 * g.a);
|
|
557
|
-
float wp = exp(-plane);
|
|
558
|
-
// Not across a shadow edge: a difference the noise cannot explain.
|
|
559
|
-
float wl = exp(-abs(l - luminance(c.rgb)) / sigmaL);
|
|
560
|
-
float w = kernel[x < 0 ? -x : x] * kernel[y < 0 ? -y : y] * wn * wp * wl;
|
|
561
|
-
sum += c * w;
|
|
562
|
-
weights += w;
|
|
563
|
-
}
|
|
564
|
-
}
|
|
565
|
-
gl_FragColor = weights > 0.0 ? sum / weights : centre;
|
|
566
|
-
}
|
|
567
|
-
`})}a(cu,"atrousMaterial");function uu(){return new ShaderMaterial({defines:{BASE_FLOOR:Ba},uniforms:{lighting:{value:null},guideLow:{value:null},guideHigh:{value:null},albedo:{value:null},lowSize:{value:null},projection:{value:null},transparent:{value:false},shadowMatte:{value:null},useShadow:{value:false},coverage:{value:null},guideProduct:{value:null},highTexel:{value:new Vector2},contact:{value:null},useContact:{value:false},floorOnly:{value:null},floorStrength:{value:1},cameraWorld:{value:new Matrix4},footprint:{value:new Vector4},floorFade:{value:new Vector3}},vertexShader:Xe,fragmentShader:`
|
|
568
|
-
${_a}
|
|
569
|
-
uniform sampler2D lighting;
|
|
570
|
-
uniform sampler2D guideLow;
|
|
571
|
-
uniform sampler2D guideHigh;
|
|
572
|
-
uniform sampler2D albedo;
|
|
573
|
-
uniform vec2 lowSize;
|
|
574
|
-
uniform bool transparent;
|
|
575
|
-
uniform sampler2D shadowMatte;
|
|
576
|
-
uniform bool useShadow;
|
|
577
|
-
uniform sampler2D coverage; // the product alone (a), without floor or sweep \u2014 antialiased
|
|
578
|
-
uniform sampler2D guideProduct; // normal and depth of the product alone
|
|
579
|
-
uniform vec2 highTexel;
|
|
580
|
-
uniform sampler2D contact; // the contact-shadow decals over white: how much light the floor keeps
|
|
581
|
-
uniform bool useContact;
|
|
582
|
-
uniform sampler2D floorOnly; // the floor, path traced without the product
|
|
583
|
-
uniform float floorStrength;
|
|
584
|
-
uniform mat4 cameraWorld;
|
|
585
|
-
uniform vec4 footprint; // the product on the floor: min x, min z, max x, max z
|
|
586
|
-
uniform vec3 floorFade; // floor y, distance the shadow starts and ends fading
|
|
587
|
-
|
|
588
|
-
// How far from the product this pixel's patch of floor is.
|
|
589
|
-
float fromProduct() {
|
|
590
|
-
vec3 direction = (cameraWorld * vec4(normalize(vec3((vUv * 2.0 - 1.0) * projection, -1.0)), 0.0)).xyz;
|
|
591
|
-
vec3 origin = cameraWorld[3].xyz;
|
|
592
|
-
float t = (floorFade.x - origin.y) / direction.y;
|
|
593
|
-
if (t <= 0.0) return 1e6;
|
|
594
|
-
vec3 hit = origin + direction * t;
|
|
595
|
-
vec2 outside = max(vec2(footprint.x - hit.x, footprint.y - hit.z), vec2(hit.x - footprint.z, hit.z - footprint.w));
|
|
596
|
-
return length(max(outside, 0.0));
|
|
597
|
-
}
|
|
598
|
-
|
|
599
|
-
// The lighting at this pixel for a surface with guide \`g\`: the 4 \xD7 4
|
|
600
|
-
// low-res texels around it, weighted by distance (a tent two texels
|
|
601
|
-
// wide) and by whether they lie on that surface. Four would do for
|
|
602
|
-
// broad surfaces, but a seam between two panels is thinner than a
|
|
603
|
-
// low-res texel, and with only four candidates it often found none on
|
|
604
|
-
// its own side: the seams came out as dotted lines.
|
|
605
|
-
vec4 upsample(vec4 g) {
|
|
606
|
-
vec3 p = viewPosition(vUv, g.a);
|
|
607
|
-
vec2 st = vUv * lowSize - 0.5;
|
|
608
|
-
vec2 origin = floor(st) - 1.0;
|
|
609
|
-
vec4 sum = vec4(0.0);
|
|
610
|
-
float weights = 0.0;
|
|
611
|
-
// The neighbour nearest this pixel's surface, for when none is on it.
|
|
612
|
-
vec4 nearest = texture2D(lighting, vUv);
|
|
613
|
-
float nearestPlane = 1e9;
|
|
614
|
-
for (int y = 0; y < 4; y++) {
|
|
615
|
-
for (int x = 0; x < 4; x++) {
|
|
616
|
-
vec2 texelPos = origin + vec2(x, y);
|
|
617
|
-
vec2 uv = (texelPos + 0.5) / lowSize;
|
|
618
|
-
vec2 d = abs(texelPos - st);
|
|
619
|
-
float wb = max(0.0, 1.0 - d.x / 2.0) * max(0.0, 1.0 - d.y / 2.0);
|
|
620
|
-
vec4 gq = texture2D(guideLow, uv);
|
|
621
|
-
vec4 lq = texture2D(lighting, uv);
|
|
622
|
-
float wn = gq.a > 0.0 ? pow(max(dot(g.rgb, gq.rgb), 0.0), 16.0) : 0.0;
|
|
623
|
-
float plane = gq.a > 0.0
|
|
624
|
-
? abs(dot(g.rgb, viewPosition(uv, gq.a) - p)) / (0.02 * g.a)
|
|
625
|
-
: 1e3;
|
|
626
|
-
if (plane < nearestPlane && wn > 0.5) {
|
|
627
|
-
nearestPlane = plane;
|
|
628
|
-
nearest = lq;
|
|
629
|
-
}
|
|
630
|
-
float w = wb * wn * exp(-plane);
|
|
631
|
-
sum += lq * w;
|
|
632
|
-
weights += w;
|
|
633
|
-
}
|
|
634
|
-
}
|
|
635
|
-
// A silhouette pixel can find no low-res texel on its own surface \u2014
|
|
636
|
-
// they all lie on the floor or a farther part. Blending them anyway
|
|
637
|
-
// bit bright notches out of the edges; the nearest one does not.
|
|
638
|
-
return weights > 1e-4 ? sum / weights : nearest;
|
|
639
|
-
}
|
|
640
|
-
|
|
641
|
-
// The product's surface at a pixel its antialiased coverage says it
|
|
642
|
-
// touches. The guide is point-sampled, so at a silhouette the centre
|
|
643
|
-
// sample often lands on what is behind; the ring of neighbours finds
|
|
644
|
-
// the product's own normal and depth instead.
|
|
645
|
-
vec4 productGuide() {
|
|
646
|
-
vec4 g = texture2D(guideProduct, vUv);
|
|
647
|
-
if (g.a > 0.0) return g;
|
|
648
|
-
for (int ring = 1; ring <= 2; ring++) {
|
|
649
|
-
for (int y = -ring; y <= ring; y++) {
|
|
650
|
-
for (int x = -ring; x <= ring; x++) {
|
|
651
|
-
if (abs(x) != ring && abs(y) != ring) continue;
|
|
652
|
-
vec4 gq = texture2D(guideProduct, vUv + vec2(x, y) * highTexel * float(1));
|
|
653
|
-
if (gq.a > 0.0) return gq;
|
|
654
|
-
}
|
|
655
|
-
}
|
|
656
|
-
}
|
|
657
|
-
return g;
|
|
658
|
-
}
|
|
659
|
-
|
|
660
|
-
void main() {
|
|
661
|
-
vec4 a = texture2D(albedo, vUv);
|
|
662
|
-
vec4 cov = texture2D(coverage, vUv);
|
|
663
|
-
float covered = cov.a;
|
|
664
|
-
vec3 base;
|
|
665
|
-
vec4 light;
|
|
666
|
-
if (covered > 0.0) {
|
|
667
|
-
// On the product, or on its antialiased edge: its own base colour
|
|
668
|
-
// and its own surface, so an edge pixel is lit like the product and
|
|
669
|
-
// not like the backdrop behind it \u2014 that is what drew a bright
|
|
670
|
-
// fringe and a staircase along every leg.
|
|
671
|
-
base = cov.rgb / covered;
|
|
672
|
-
vec4 g = productGuide();
|
|
673
|
-
light = g.a > 0.0 ? upsample(g) : texture2D(lighting, vUv);
|
|
674
|
-
} else {
|
|
675
|
-
base = a.rgb / max(a.a, 1e-4);
|
|
676
|
-
vec4 g = texture2D(guideHigh, vUv);
|
|
677
|
-
light = g.a > 0.0 ? upsample(g) : texture2D(lighting, vUv);
|
|
678
|
-
}
|
|
679
|
-
// \xD7 the base floored as demodulation floored it. Multiplied back by
|
|
680
|
-
// the bare base, every channel under the floor kept only base/floor of
|
|
681
|
-
// its light: the blue of a wood stain (~0.01 linear) came back at a
|
|
682
|
-
// third, and every stain turned gold.
|
|
683
|
-
vec3 colour = light.rgb * max(base, vec3(BASE_FLOOR));
|
|
684
|
-
if (useShadow) {
|
|
685
|
-
// The floor traced with and without the product never quite agrees
|
|
686
|
-
// far from it (noise, the product's own bounce light): left in, a
|
|
687
|
-
// percent or two of "shadow" veiled the whole background and drew
|
|
688
|
-
// the floor's far edge as a dotted line. Below a few percent it is
|
|
689
|
-
// not a shadow anyone could see on a floor, so it fades out.
|
|
690
|
-
float darkening = texture2D(shadowMatte, vUv).r;
|
|
691
|
-
darkening *= smoothstep(0.03, 0.1, darkening);
|
|
692
|
-
// The shadow stays AROUND the product. The studio's low, soft fill
|
|
693
|
-
// and rim lay long faint shadows across the whole floor, and at full
|
|
694
|
-
// strength they flooded it; so the shadow fades out with distance
|
|
695
|
-
// from the product's footprint, and the setup scales what is left.
|
|
696
|
-
darkening *= 1.0 - smoothstep(floorFade.y, floorFade.z, fromProduct());
|
|
697
|
-
darkening *= floorStrength;
|
|
698
|
-
// The contact decals on top: the dark spot where a foot meets the
|
|
699
|
-
// floor, which the traced shadow has at too few pixels to keep.
|
|
700
|
-
float kept = (1.0 - darkening) * (useContact ? luminance(texture2D(contact, vUv).rgb) : 1.0);
|
|
701
|
-
if (transparent) {
|
|
702
|
-
// The product over its shadow (black at the shadow's opacity),
|
|
703
|
-
// straight alpha, as a PNG wants it.
|
|
704
|
-
float opacity = covered + (1.0 - covered) * (1.0 - kept);
|
|
705
|
-
gl_FragColor = vec4(opacity > 0.0 ? colour * covered / opacity : vec3(0.0), opacity);
|
|
706
|
-
} else {
|
|
707
|
-
vec3 floorColour = texture2D(floorOnly, vUv).rgb * kept;
|
|
708
|
-
gl_FragColor = vec4(mix(floorColour, colour, covered), 1.0);
|
|
709
|
-
}
|
|
710
|
-
} else {
|
|
711
|
-
gl_FragColor = vec4(colour, transparent ? covered : 1.0);
|
|
712
|
-
}
|
|
713
|
-
}
|
|
714
|
-
`})}a(uu,"composeMaterial");function Fa(e){let o=new FullScreenQuad,t={normalDepth:ou(),demodulate:ru(),variance:lu(),atrous:cu(),compose:uu(),shadow:iu(),copy:su(),mask:nu(),gaussian:au()},n=new Map,a$1=new WeakMap,i=new Color;function s(y,w,P,T=0){let R=n.get(y);return (!R||R.width!==w||R.height!==P)&&(R?.dispose(),R=new WebGLRenderTarget(w,P,{type:HalfFloatType,samples:T}),n.set(y,R)),R}a(s,"target");function c(y,w){o.material=y,e.setRenderTarget(w),o.render(e);}a(c,"pass");function l(y){let w=a$1.get(y);w||(w=new MeshBasicMaterial,a$1.set(y,w));let P=y;return P.color?w.color.copy(P.color):w.color.setRGB(1,1,1),(w.map!==(P.map??null)||w.vertexColors!==(P.vertexColors??false))&&(w.needsUpdate=true),w.map=P.map??null,w.alphaMap=P.alphaMap??null,w.vertexColors=P.vertexColors??false,w.side=y.side,w.transparent=y.transparent,w.opacity=y.opacity,w.alphaTest=y.alphaTest,w}a(l,"albedoOf");function p(y,w,P,T,R,z=[]){let g=z.filter(U=>U.visible);for(let U of g)U.visible=false;let x=s(`albedo${R}`,P,T,4),M=s(`guide${R}`,P,T),E=y.background,G=e.getClearColor(i).clone(),V=e.getClearAlpha(),C=[];y.traverseVisible(U=>{let N=U;N.isMesh&&(C.push([N,N.material]),N.material=Array.isArray(N.material)?N.material.map(l):l(N.material));}),y.background=null,e.setClearColor(0,0),e.setRenderTarget(x),e.clear(),e.render(y,w);for(let[U,N]of C)U.material=N;y.overrideMaterial=t.normalDepth,e.setRenderTarget(M),e.clear(),e.render(y,w),y.overrideMaterial=null,y.background=E,e.setClearColor(G,V),e.setRenderTarget(null);for(let U of g)U.visible=true;return {albedo:x,guide:M}}a(p,"renderGuides");function u(y,w,P,T,R){let z=s("decals",P,T,4),g=y.children.filter(C=>C.visible);for(let C of g)C.visible=false;for(let C of R)C.visible=true;let x=et(),M=tt();Le(1),Re(0),ft();let E=y.background;y.background=null;let G=e.getClearColor(i).clone(),V=e.getClearAlpha();e.setClearColor(16777215,1),e.setRenderTarget(z),e.clear(),e.render(y,w),e.setClearColor(G,V),y.background=E,Le(x),Re(M),ft();for(let C of R)C.visible=false;for(let C of g)C.visible=true;return z}a(u,"renderDecals");function d(y,w,P,T,R,z){let g=s(`${y}A`,T,R),x=s(`${y}B`,T,R),M=t.mask.uniforms;M.source.value=w,M.cover.value=P,M.useCover.value=P!==null,c(t.mask,g);let E=t.gaussian.uniforms;for(let G of z)for(let V of [new Vector2(G/T,0),new Vector2(0,G/R)])E.image.value=g.texture,E.direction.value=V,c(t.gaussian,x),[g,x]=[x,g];return g}a(d,"smoothFloor");function v(y,w,P,T,R,z){t.variance.uniforms.lighting.value=y.texture,t.variance.uniforms.texel.value=R,c(t.variance,P);let g=y,x=w,M=t.atrous.uniforms;M.guide.value=T,M.variance.value=P.texture,M.texel.value=R,M.projection.value=z;for(let E of [1,2,4,8])M.lighting.value=g.texture,M.stepSize.value=E,c(t.atrous,x),[g,x]=[x,g];return g}a(v,"denoise");function f(y,w,P){let T=s("kept",w,P);return t.copy.uniforms.source.value=y,c(t.copy,T),e.setRenderTarget(null),T.texture}a(f,"keep");function S(y){let{scene:w,camera:P,traced:T,width:R,height:z,lowWidth:g,lowHeight:x}=y,M=Math.tan(P.fov*Math.PI/360),E={x:M*P.aspect,y:M},G=p(w,P,R,z,"High",y.hide),V=y.floor&&!y.transparent?p(w,P,R,z,"Coverage",[...y.hide??[],...y.hideForCoverage??[]]):G,C=V.albedo,U=p(w,P,g,x,"Low"),N={x:1/g,y:1/x},H=s("lightingA",g,x),j=s("lightingB",g,x),_=s("variance",g,x);t.demodulate.uniforms.traced.value=T,t.demodulate.uniforms.albedo.value=U.albedo.texture,c(t.demodulate,H);let m=v(H,j,_,U.guide.texture,N,E),k=null,b=null;if(y.floor){let B=p(w,P,g,x,"CoverageLow",[...y.hide??[],...y.hideForCoverage??[]]).albedo,Y=s("matte",g,x);t.shadow.uniforms.withProduct.value=y.floor.withProduct,t.shadow.uniforms.floorOnly.value=y.floor.floorOnly,c(t.shadow,Y),k=d("shadow",Y.texture,B.texture,g,x,tu),y.transparent||(b=d("floor",y.floor.floorOnly,null,g,x,eu));}let A=s("output",R,z),h=t.compose.uniforms;h.lighting.value=m.texture,h.guideLow.value=U.guide.texture,h.guideHigh.value=G.guide.texture,h.albedo.value=G.albedo.texture,h.lowSize.value={x:g,y:x},h.projection.value=E,h.transparent.value=y.transparent,h.useShadow.value=k!==null,h.shadowMatte.value=k?.texture??null,h.coverage.value=C.texture,h.guideProduct.value=V.guide.texture;let W=y.floor&&y.decals?.length?y.decals:[];if(h.useContact.value=W.length>0,h.contact.value=W.length?u(w,P,R,z,W).texture:null,h.highTexel.value=new Vector2(1/R,1/z),h.floorOnly.value=b?.texture??null,y.floor){let{footprint:B,fade:Y,strength:Q}=y.floor;h.floorStrength.value=Q,h.cameraWorld.value=P.matrixWorld,h.footprint.value=new Vector4(B.min.x,B.min.z,B.max.x,B.max.z),h.floorFade.value=new Vector3(B.min.y,Y[0],Y[1]);}return c(t.compose,A),e.setRenderTarget(null),A.texture}a(S,"reconstruct");function O(){o.dispose();for(let y of Object.values(t))y.dispose();for(let y of n.values())y.dispose();}return a(O,"dispose"),{reconstruct:S,keep:f,dispose:O}}a(Fa,"createReconstructor");var ao=Math.atan(.3)*180/Math.PI,pu=Math.asin(1/Math.sqrt(3))*180/Math.PI,io={front:{name:"front",azimuth:0,elevation:ao},back:{name:"back",azimuth:180,elevation:ao},left:{name:"left",azimuth:-90,elevation:ao},right:{name:"right",azimuth:90,elevation:ao},top:{name:"top",azimuth:0,elevation:89.4,zoom:1.2},isometric:{name:"isometric",azimuth:45,elevation:pu,zoom:1.1},threeQuarter:{name:"threeQuarter",azimuth:35,elevation:18},threeQuarterLeft:{name:"threeQuarterLeft",azimuth:-35,elevation:18},hero:{name:"hero",azimuth:30,elevation:7,fov:22},profile:{name:"profile",azimuth:90,elevation:4,fov:20},closeUp:{name:"closeUp",azimuth:25,elevation:14,fov:24,zoom:.55},overhead:{name:"overhead",azimuth:20,elevation:62,zoom:1.1}},lr=Object.keys(io);function Ga(e){return Object.hasOwn(io,e)}a(Ga,"isPhotoShotPreset");function cr(e){if(typeof e!="string")return e;if(!Ga(e))throw new Error(`Unknown photo shot "${e}"`);return io[e]}a(cr,"resolvePhotoShot");var za=Math.PI/180;function ur(e,o=new Vector3){let t=e.azimuth*za,n=Math.min(89.9,Math.max(-20,e.elevation))*za;return o.set(Math.sin(t)*Math.cos(n),Math.sin(n),Math.cos(t)*Math.cos(n)).normalize()}a(ur,"photoShotDirection");function Va(e,o,t=512){let n=t/2,a=new WebGLRenderTarget(t,n,{type:FloatType}),i=new ShaderMaterial({uniforms:{cube:{value:o}},vertexShader:`
|
|
715
|
-
varying vec2 vUv;
|
|
716
|
-
void main() {
|
|
717
|
-
vUv = uv;
|
|
718
|
-
gl_Position = vec4(position.xy, 0.0, 1.0);
|
|
719
|
-
}
|
|
720
|
-
`,fragmentShader:`
|
|
721
|
-
uniform samplerCube cube;
|
|
722
|
-
varying vec2 vUv;
|
|
723
|
-
#define PI 3.141592653589793
|
|
724
|
-
void main() {
|
|
725
|
-
// The inverse of equirectUv: u = atan(z, x) / 2\u03C0 + 0.5, v = asin(y) / \u03C0 + 0.5.
|
|
726
|
-
float phi = (vUv.x - 0.5) * 2.0 * PI;
|
|
727
|
-
float theta = (vUv.y - 0.5) * PI;
|
|
728
|
-
vec3 direction = vec3(cos(theta) * cos(phi), sin(theta), cos(theta) * sin(phi));
|
|
729
|
-
gl_FragColor = vec4(textureCube(cube, direction).rgb, 1.0);
|
|
730
|
-
}
|
|
731
|
-
`,depthTest:false,depthWrite:false}),s=new FullScreenQuad(i),c=e.getRenderTarget();e.setRenderTarget(a),s.render(e),e.setRenderTarget(c);let l=new Float32Array(t*n*4);e.readRenderTargetPixels(a,0,0,t,n,l),s.dispose(),i.dispose(),a.dispose();let p=new DataTexture(l,t,n,RGBAFormat,FloatType);return p.mapping=EquirectangularReflectionMapping,p.minFilter=LinearFilter,p.magFilter=LinearFilter,p.needsUpdate=true,p}a(Va,"cubeToEquirect");var Mu=1024,Cu=.6;function Ya(e){let{product:o,bounds:t,floorY:n}=e,a$1=e.resolution??Mu,i=t.getCenter(new Vector3),s=t.getSize(new Vector3),c=Math.max(s.x,s.z)/2+s.length()*Cu,l={minFilter:LinearFilter,magFilter:LinearFilter,wrapS:ClampToEdgeWrapping,wrapT:ClampToEdgeWrapping,depthBuffer:false,stencilBuffer:false},p=new WebGLRenderTarget(a$1,a$1,l),u=new WebGLRenderTarget(a$1,a$1,l),d=new OrthographicCamera(-c,c,c,-c,.1,20);d.position.set(i.x,n+10,i.z),d.rotation.x=-Math.PI/2,d.updateMatrixWorld();let v=new MeshBasicMaterial({color:16777215,depthTest:false,depthWrite:false}),f=new Scene,S=new ShaderMaterial({uniforms:{tDiffuse:{value:null},direction:{value:new Vector2}},depthTest:false,depthWrite:false,vertexShader:`
|
|
732
|
-
varying vec2 vUv;
|
|
733
|
-
void main() {
|
|
734
|
-
vUv = uv;
|
|
735
|
-
gl_Position = vec4(position.xy, 0.0, 1.0);
|
|
736
|
-
}
|
|
737
|
-
`,fragmentShader:`
|
|
738
|
-
uniform sampler2D tDiffuse;
|
|
739
|
-
uniform vec2 direction;
|
|
740
|
-
varying vec2 vUv;
|
|
741
|
-
void main() {
|
|
742
|
-
vec4 sum = texture2D(tDiffuse, vUv) * 0.2270270270;
|
|
743
|
-
sum += texture2D(tDiffuse, vUv + direction * 1.0) * 0.1945945946;
|
|
744
|
-
sum += texture2D(tDiffuse, vUv - direction * 1.0) * 0.1945945946;
|
|
745
|
-
sum += texture2D(tDiffuse, vUv + direction * 2.0) * 0.1216216216;
|
|
746
|
-
sum += texture2D(tDiffuse, vUv - direction * 2.0) * 0.1216216216;
|
|
747
|
-
sum += texture2D(tDiffuse, vUv + direction * 3.0) * 0.0540540541;
|
|
748
|
-
sum += texture2D(tDiffuse, vUv - direction * 3.0) * 0.0540540541;
|
|
749
|
-
sum += texture2D(tDiffuse, vUv + direction * 4.0) * 0.0162162162;
|
|
750
|
-
sum += texture2D(tDiffuse, vUv - direction * 4.0) * 0.0162162162;
|
|
751
|
-
gl_FragColor = sum;
|
|
752
|
-
}
|
|
753
|
-
`}),O=new Mesh(new PlaneGeometry(2,2),S),y=new Scene;y.add(O);let w=new OrthographicCamera(-1,1,1,-1,0,1);function P(g){let x=g.y-n;return new Matrix4().set(x,-g.x,0,g.x*n,0,x-g.y,0,g.y*n,0,-g.z,x,g.z*n,0,-1,0,x+n)}a(P,"projection");function T(g,x){let M=P(x);f.clear();for(let E of o)E.updateMatrixWorld(true),E.traverse(G=>{let V=G;if(!V.isMesh||!V.visible||V.name==="moduleContactShadow")return;let C=new Mesh(V.geometry,v);C.matrixAutoUpdate=false,C.matrix.multiplyMatrices(M,V.matrixWorld),C.frustumCulled=false,f.add(C);});g.setRenderTarget(p),g.setClearColor(0,0),g.clear(true,false,false),g.render(f,d),f.clear();}a(T,"drawSilhouette");function R(g,x){for(let M of [new Vector2(1,0),new Vector2(0,1)])S.uniforms.tDiffuse.value=p.texture,S.uniforms.direction.value.copy(M).multiplyScalar(x/a$1),g.setRenderTarget(u),g.clear(true,false,false),g.render(y,w),[p,u]=[u,p];}a(R,"blurPass");function z(g,x){let M=g.getRenderTarget(),E=g.autoClear,G=g.getClearColor(new Color),V=g.getClearAlpha();g.autoClear=false;try{T(g,x.light);let C=x.blurWorld/(2*c)*a$1,U=Math.max(C/4,.5);for(let N of [1,.75,.5,.25])R(g,U*N);}finally{g.setRenderTarget(M),g.setClearColor(G,V),g.autoClear=E;}}return a(z,"update"),{get texture(){return p.texture},halfSize:c,update:z,dispose(){p.dispose(),u.dispose(),v.dispose(),S.dispose(),O.geometry.dispose();}}}a(Ya,"createFloorShadow");var ei="// konfigure: studio tone curve",Ja="vec3 CustomToneMapping( vec3 color ) { return color; }",Ru=`vec3 CustomToneMapping( vec3 color ) {
|
|
754
|
-
${ei}
|
|
755
|
-
const float StartCompression = 0.8 - 0.04;
|
|
756
|
-
const float Desaturation = 0.15;
|
|
757
|
-
color *= toneMappingExposure;
|
|
758
|
-
float peak = max( color.r, max( color.g, color.b ) );
|
|
759
|
-
if ( peak < StartCompression ) return color;
|
|
760
|
-
float d = 1. - StartCompression;
|
|
761
|
-
float newPeak = 1. - d * d / ( peak + d - StartCompression );
|
|
762
|
-
color *= newPeak / peak;
|
|
763
|
-
float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
|
|
764
|
-
return mix( color, vec3( newPeak ), g );
|
|
765
|
-
}`;function ti(){let e=ShaderChunk.tonemapping_pars_fragment;return e.includes(ei)?CustomToneMapping:e.includes(Ja)?(ShaderChunk.tonemapping_pars_fragment=e.replace(Ja,Ru),CustomToneMapping):NeutralToneMapping}a(ti,"studioToneMapping");var mr=Math.PI/180,Wu=.8;function Uu(e){let o=e*16,t=e*8,n=e*4.5,a=e*1.5,i=e*10,s=[[-n,t]];for(let p=0;p<=24;p++){let u=p/24*(Math.PI/2);s.push([-(n-a)-Math.cos(u)*a,a-Math.sin(u)*a]);}s.push([i,0]);let c=new PlaneGeometry(o,1,1,s.length-1),l=c.attributes.position;for(let[p,[u,d]]of s.entries())for(let v of [0,1]){let f=p*2+v;l.setXYZ(f,l.getX(f),d,u);}return c.computeVertexNormals(),c}a(Uu,"sweepGeometry");function Vu(e,o){let t=new MeshBasicMaterial({color:0,transparent:true,depthWrite:false,opacity:.35}),n={footprint:{value:[e.min.x,e.min.z,e.max.x,e.max.z]},fadeRange:{value:o}};return t.onBeforeCompile=a=>{Object.assign(a.uniforms,n),a.vertexShader=a.vertexShader.replace("#include <common>",`#include <common>
|
|
766
|
-
varying vec3 vFadeWorld;`).replace("#include <project_vertex>",`#include <project_vertex>
|
|
767
|
-
vFadeWorld = (modelMatrix * vec4(transformed, 1.0)).xyz;`),a.fragmentShader=a.fragmentShader.replace("#include <common>",["#include <common>","varying vec3 vFadeWorld;","uniform vec4 footprint; // the product on the floor: min x, min z, max x, max z","uniform vec2 fadeRange; // distance from the footprint the shadow starts and ends fading","float fromFootprint() {"," vec2 outside = max(vec2(footprint.x - vFadeWorld.x, footprint.y - vFadeWorld.z),"," vec2(vFadeWorld.x - footprint.z, vFadeWorld.z - footprint.w));"," return length(max(outside, 0.0));","}"].join(`
|
|
768
|
-
`)).replace("#include <alphamap_fragment>",`#include <alphamap_fragment>
|
|
769
|
-
diffuseColor.a *= 1.0 - smoothstep(fadeRange.x, fadeRange.y, fromFootprint());`);},t}a(Vu,"fadedFloorMaterial");function ri(e){let{scene:o,renderer:t,product:n}=e,a$1=e.bounds.clone(),i=a$1.getCenter(new Vector3),s=a$1.getSize(new Vector3),c=Math.max(s.length(),.5),l=a$1.min.y,p=new Map;for(let _ of o.children)n.includes(_)||(p.set(_,_.visible),_.visible=false);function u(){return o.children.filter(_=>_.name==="moduleContactShadow")}a(u,"contactShadows");let d={contactShadowFade:et(),contactShadowCoverage:tt(),bakedShade:Ce.value.clone(),fog:o.fog,background:o.background,environment:o.environment,environmentIntensity:o.environmentIntensity,environmentRotation:o.environmentRotation.clone(),toneMapping:t.toneMapping,exposure:t.toneMappingExposure,shadowsEnabled:t.shadowMap.enabled};o.fog=null,t.shadowMap.enabled=true,Re(0),Ce.value.set(0,0);let v=new Group;v.name="photoStage",o.add(v);let f=new MeshStandardMaterial({roughness:.95,metalness:0,side:DoubleSide}),S=new Mesh(Uu(c),f);S.position.set(i.x,l,i.z),S.receiveShadow=false,v.add(S);let O=Ya({product:e.product,bounds:a$1,floorY:l}),y=Vu(a$1,[s.length()*.1,s.length()*.35]);y.alphaMap=O.texture;let w=new Mesh(new PlaneGeometry(O.halfSize*2,O.halfSize*2),y);w.rotation.x=-Math.PI/2,w.position.set(i.x,l+.001,i.z),v.add(w);let P=new MeshStandardMaterial({color:16777215,roughness:1}),T=new Mesh(new PlaneGeometry(c*16,c*16),P);T.rotation.x=-Math.PI/2,T.position.set(i.x,l,i.z),v.add(T);let R=new Map;function z(_){let m=R.get(_);if(!m){let k=new SpotLight(16777215,1,0,Math.PI/3,.9,2);k.target.position.copy(i);let b=new RectAreaLight;v.add(k,k.target,b),m={raster:k,area:b},R.set(_,m);}return m}a(z,"rigFor");let g=new Map;function x(_){let m=g.get(_);if(!m){let k=new rt(_),b=new WebGLCubeRenderTarget(256,{type:HalfFloatType});new CubeCamera(.1,100,b).update(t,k);let A=At(t)?Va(t,b.texture):null,h=new PMREMGenerator(t),W=(A?h.fromEquirectangular(A):h.fromCubemap(b.texture)).texture;h.dispose(),b.dispose(),k.traverse(B=>{let Y=B;if(Y.isMesh){Y.geometry.dispose();for(let Q of [Y.material].flat())Q.dispose();}}),m={equirect:A,pmrem:W},g.set(_,m);}return m}a(x,"environmentFor");let M=c*4;function E(_,m){let k=m+_.azimuth*mr,b=_.elevation*mr;return new Vector3(Math.sin(k)*Math.cos(b),Math.sin(b),Math.cos(k)*Math.cos(b)).multiplyScalar(M).add(i)}a(E,"lightPosition");let G=s.length()*.25;function V(_,m,k){let b=a$1.clone();if(!k||_.live)return b;let A=new Vector3,h=Math.atan2(m.x,m.z),W=[new Vector3(a$1.min.x,a$1.min.y,a$1.min.z),new Vector3(a$1.min.x,a$1.min.y,a$1.max.z),new Vector3(a$1.min.x,a$1.max.y,a$1.min.z),new Vector3(a$1.min.x,a$1.max.y,a$1.max.z),new Vector3(a$1.max.x,a$1.min.y,a$1.min.z),new Vector3(a$1.max.x,a$1.min.y,a$1.max.z),new Vector3(a$1.max.x,a$1.max.y,a$1.min.z),new Vector3(a$1.max.x,a$1.max.y,a$1.max.z)],B=_.lights.find(Y=>Y.id==="key"&&Y.enabled);for(let Y of B?[B]:_.lights.filter(Q=>Q.enabled)){let Q=E(Y,h);for(let q of W){let ne=Q.y-q.y;if(ne<=0)continue;let oe=new Vector3().lerpVectors(Q,q,(Q.y-l)/ne),ce=new Vector3(Math.max(a$1.min.x-oe.x,oe.x-a$1.max.x,0),0,Math.max(a$1.min.z-oe.z,oe.z-a$1.max.z,0)),Se=ce.length();Se>G&&ce.multiplyScalar(G/Se),A.x=Math.max(A.x,ce.x),A.z=Math.max(A.z,ce.z);}}return b.expandByVector(A)}a(V,"framing");let C=new Color;function U(_,m){let k=x(_.environment);o.environment=m.mode==="path"&&k.equirect?k.equirect:k.pmrem,o.environmentIntensity=_.environmentIntensity,o.environmentRotation=new Euler(0,_.environmentRotation*mr,0),o.background=m.transparent?null:new Color(_.backdrop),t.toneMapping=ti(),t.toneMappingExposure=Math.pow(2,_.exposure);let b=Math.atan2(m.cameraDirection.x,m.cameraDirection.z);S.visible=!m.transparent,S.rotation.y=b,f.color.set(_.backdrop);let A=!m.transparent||m.shadow,h=_.lights.find(B=>B.id==="key"&&B.enabled);if(w.visible=m.mode==="raster"&&A&&!!h,w.visible&&h){let B=c*(.08+h.softness*1.4);O.update(t,{light:E(h,b),blurWorld:B*s.y/2/M}),y.opacity=_.floorShadow*(1-h.softness*.35)*.7;}T.visible=m.transparent&&m.shadow&&m.mode==="path";for(let B of u())B.visible=m.mode==="raster"&&A;Le(_.floorShadow);let W=M;for(let B of _.lights){let Y=z(B.id),Q=E(B,b);sr(B.temperature,C);let q=Y.raster;if(q.visible=B.enabled&&m.mode==="raster",q.position.copy(Q),q.color.copy(C),q.intensity=B.intensity*W*W*Wu,q.castShadow=B.id==="key",q.castShadow){let ce=q.shadow.camera;ce.near=W*.2,ce.far=W*3,q.shadow.focus=.5,q.shadow.mapSize.set(2048,2048),q.shadow.radius=1+B.softness*3,q.shadow.intensity=1-B.softness*.35,q.shadow.bias=-2e-4,q.shadow.normalBias=.01,q.shadow.needsUpdate=true,t.shadowMap.needsUpdate=true;}let ne=Y.area,oe=c*(.08+B.softness*1.4);ne.visible=B.enabled&&m.mode==="path",ne.width=oe,ne.height=oe,ne.position.copy(Q),ne.lookAt(i),ne.color.copy(C),ne.intensity=B.intensity*W*W/(oe*oe);}}a(U,"apply");function N(){o.remove(v),S.geometry.dispose(),f.dispose(),w.geometry.dispose(),y.dispose(),O.dispose(),T.geometry.dispose(),P.dispose();for(let{raster:_}of R.values())_.shadow.dispose();for(let _ of g.values())_.equirect?.dispose(),_.pmrem.dispose();for(let _ of n)_.visible=true;for(let[_,m]of p)_.visible=m;Le(d.contactShadowFade),Re(d.contactShadowCoverage),Ce.value.copy(d.bakedShade),o.fog=d.fog,o.background=d.background,o.environment=d.environment,o.environmentIntensity=d.environmentIntensity,o.environmentRotation=d.environmentRotation,t.toneMapping=d.toneMapping,t.toneMappingExposure=d.exposure,t.shadowMap.enabled=d.shadowsEnabled,t.shadowMap.needsUpdate=true;}a(N,"dispose");function H(_){for(let m of n)m.visible=_;}a(H,"setProductVisible");function j(_){let m={fade:et(),coverage:tt(),shade:Ce.value.clone()},k=[];function b(A){for(let h of o.children)h.name!==A||!h.visible||(h.visible=false,k.push(()=>h.visible=true));}a(b,"hide"),v.visible=false;for(let[A,h]of p)A.visible=h;if(H(true),Le(d.contactShadowFade),Re(d.contactShadowCoverage),Ce.value.copy(d.bakedShade),o.fog=d.fog,o.background=d.background,o.environment=d.environment,o.environmentIntensity=d.environmentIntensity,o.environmentRotation=d.environmentRotation,t.toneMapping=d.toneMapping,t.toneMappingExposure=d.exposure,_.transparent){if(o.background=null,o.fog=null,b("room"),!_.shadow)for(let A of ["bakedFloorShadow","moduleContactShadow","floor"])b(A);}else if(_.backdrop){let A=new Color(_.backdrop);if(o.background=A,d.fog instanceof Fog){let W=d.fog.color.clone();d.fog.color.copy(A),k.push(()=>d.fog instanceof Fog&&d.fog.color.copy(W));}let h=o.getObjectByName("room");if(h instanceof Mesh&&h.material instanceof MeshStandardMaterial){let W=h.material,B=W.color.clone();W.color.copy(A),k.push(()=>W.color.copy(B));}}return _.exposure&&(d.toneMapping===NoToneMapping&&(t.toneMapping=LinearToneMapping),t.toneMappingExposure=d.exposure*Math.pow(2,_.exposure)),()=>{for(let A of k.reverse())A();for(let A of p.keys())A.visible=false;v.visible=true,o.fog=null,Le(m.fade),Re(m.coverage),Ce.value.copy(m.shade);}}return a(j,"live"),{bounds:a$1,apply:U,framing:V,shadowFloor:T,backdrop:S,get contactShadows(){return u()},setProductVisible:H,live:j,dispose:N}}a(ri,"createPhotoStage");var Sr=["front","isometric","left","right","back","top"];function Hu(e){let{data:o}=e;for(let t=0;t<o.length;t+=4){let n=o[t+3];n===0||n===255||(o[t]=Math.min(255,Math.round(o[t]*255/n)),o[t+1]=Math.min(255,Math.round(o[t+1]*255/n)),o[t+2]=Math.min(255,Math.round(o[t+2]*255/n)));}}a(Hu,"unpremultiply");function ni(e){let{data:o}=e,t=Math.max(4,Math.floor(o.length/4/4096))*4;for(let n=0;n<o.length;n+=t)if(o[n]||o[n+1]||o[n+2]||o[n+3])return false;return true}a(ni,"isBlank");var ai=128,qu=2500,Xu=12,ii=.5,si=64,br=75e4,Ku=br/(2400*1600),$u=3e6,Yu=12e4,Qu=450,Zu=6;function wr(e){let{scene:o,renderer:t,modules:n,labels:a$1}=e,i=Aa(n);if(!i)throw new Error("No modules available for capture");let s=ri({scene:o,renderer:t,product:e.product,bounds:i}),c=new Map,l=null,p=null,u=Promise.resolve();function d(C){let U=u.then(C,C);return u=U.catch(()=>{}),U}a(d,"exclusive");function v(C,U,N,H){let j=cr(C),_=j.fov??Oa,m=ur(j),k=s.framing(N,m,H),b=Ea(k,_,U,m)*(j.zoom??1),A=k.getCenter(new Vector3),h=new PerspectiveCamera(_,U,.05,1e3);h.layers.enable(1),h.position.copy(A).addScaledVector(m,b),h.lookAt(A),h.updateMatrixWorld();let W=A.clone();W.y+=Da(k,h,A),h.lookAt(W),h.updateMatrixWorld();let B=j.name in a$1?a$1[j.name]:j.name;return {camera:h,label:B,name:j.name}}a(v,"cameraFor");function f(C){return C.position.clone().sub(s.bounds.getCenter(new Vector3)).normalize()}a(f,"directionOf");function S(C,U,N,H,j){s.apply(C,{cameraDirection:f(U),mode:N,transparent:H,shadow:j});}a(S,"stageFor");function O(C,U){return t.shadowMap.needsUpdate=true,ot(t),C.render(o,U)}a(O,"rasterise");function y(C,U){let N=`${C}x${U}`,H=c.get(N);return H||(H=rr(t,C,U,{samples:4}),c.set(N,H)),H}a(y,"previewTargetFor");function w(C,U,N,H,j,_){let m=s.live({transparent:j,shadow:_,backdrop:C.backdrop||null,exposure:C.exposure});try{return T(U,N,H)}finally{m();}}a(w,"renderLive");let P=new Vector2;function T(C,U,N){let H=t.getContext(),j=H.getParameter(H.MAX_VIEWPORT_DIMS),_=Math.min(2048,j[0],j[1]),m=t.getPixelRatio(),k=t.getSize(P).clone(),b=t.getRenderTarget(),A=new ImageData(U,N);ot(t),t.setPixelRatio(1),t.setSize(Math.min(_,U),Math.min(_,N),false),t.setRenderTarget(null);let h=Math.min(_,U,H.drawingBufferWidth),W=Math.min(_,N,H.drawingBufferHeight),B=new Uint8Array(h*W*4);try{for(let Y=0;Y<N;Y+=W)for(let Q=0;Q<U;Q+=h){let q=Math.min(h,U-Q),ne=Math.min(W,N-Y);C.setViewOffset(U,N,Q,Y,q,ne),t.setViewport(0,0,q,ne),t.render(o,C),H.readPixels(0,0,q,ne,H.RGBA,H.UNSIGNED_BYTE,B);for(let oe=0;oe<ne;oe++){let ce=(ne-1-oe)*q*4;A.data.set(B.subarray(ce,ce+q*4),((Y+oe)*U+Q)*4);}}}finally{C.clearViewOffset(),t.setPixelRatio(m),t.setSize(k.x,k.y,false),t.setRenderTarget(b);}return Hu(A),A}a(T,"drawLikeViewport");function R(C,U,N){let{transparent:H,shadow:j,width:_,height:m}=N,k=y(_,m),b=v(U,_/m,C,!H||j);return b?C.live?w(C,b.camera,_,m,H,j):(s.setProductVisible(true),S(C,b.camera,"raster",H,j),O(k,b.camera)):null}a(R,"preview");async function z(C){let U=Math.min(1,Math.sqrt(C.pathPixels/(C.width*C.height))),N=Math.round(C.width*U),H=Math.round(C.height*U),j=!C.transparent||C.shadow,_=j?.75:1;l??=await ed(t),p??=Fa(t),li(l,N,H),ot(t),S(C.setup,C.camera,"path",C.transparent,C.shadow),l.setScene(o,C.camera),await ci(t,l,{samples:C.samples,minSamples:C.minSamples,timeLimit:C.timeLimit*_,signal:C.signal,onFraction:a(k=>C.onFraction?.(k*_),"onFraction")});let m;if(j){let k=p.keep(l.target.texture,N,H);S(C.setup,C.camera,"path",C.transparent,C.shadow),s.setProductVisible(false);try{li(l,Math.max(64,Math.round(N*ii)),Math.max(64,Math.round(H*ii))),l.setScene(o,C.camera),await ci(t,l,{samples:Math.min(C.samples,si),minSamples:Math.min(C.minSamples,si),timeLimit:C.timeLimit*(1-_),signal:C.signal,onFraction:a(A=>C.onFraction?.(_+A*(1-_)),"onFraction")});}finally{s.setProductVisible(true);}let b=s.bounds.getSize(new Vector3).length();m={withProduct:k,floorOnly:l.target.texture,footprint:s.bounds,fade:[b*.1,b*.35],strength:C.setup.floorShadow};}return S(C.setup,C.camera,"path",C.transparent,C.shadow),p.reconstruct({scene:o,camera:C.camera,traced:m?.withProduct??l.target.texture,width:C.width,height:C.height,lowWidth:N,lowHeight:H,transparent:C.transparent,floor:m,decals:m?s.contactShadows:[],hide:[s.shadowFloor],hideForCoverage:[s.backdrop]})}a(z,"trace");function g(C,U,N){return d(async()=>{if(!E||G||C.live)return null;yr(N.signal);let{width:H,height:j,transparent:_,shadow:m}=N,k=v(U,H/j,C,!_||m);if(!k)return null;let b=await z({setup:C,camera:k.camera,width:H,height:j,transparent:N.transparent,shadow:N.shadow,pathPixels:Yu,samples:ai,minSamples:Zu,timeLimit:Qu,signal:N.signal}),A=y(H,j).encode(b);return ni(A)?(G=true,null):A})}a(g,"refine");function x(C){return d(()=>M(C))}a(x,"capture");async function M(C){let{setup:U,width:N,height:H,transparent:j,shadow:_,signal:m,onProgress:k}=C,b=C.quality==="best"&&(U.live||E&&!G)?"best":"fast",A=C.samples??ai,h=Math.min($u,Math.max(br,Math.round(N*H*Ku))),W=(C.timeLimit??qu)*(h/br),B=rr(t,N,H),Y=[];try{for(let[Q,q]of C.angles.entries()){let ne=v(q,N/H,U,!j||_);if(!ne)continue;let oe=a(Se=>k?.({index:Q,count:C.angles.length,angle:ne.name,label:ne.label,fraction:Se}),"report");oe(0),yr(m);let ce=null;if(U.live)ce=w(U,ne.camera,N,H,j,_),await vr();else if(b==="best"&&!G){let Se=await z({setup:U,camera:ne.camera,width:N,height:H,transparent:j,shadow:_,pathPixels:h,samples:A,minSamples:Xu,timeLimit:W,signal:m,onFraction:oe});ce=B.encode(Se),ni(ce)&&(G=!0,ce=null);}ce||(S(U,ne.camera,"raster",j,_),ce=O(B,ne.camera),await vr()),Y.push({name:ne.name,label:ne.label,dataUrl:Ra(ce)}),oe(1);}return Y}finally{B.dispose();}}a(M,"captureNow");let E=At(t)&&!Kt(t),G=false;function V(){for(let C of c.values())C.dispose();l?.dispose(),p?.dispose(),s.dispose();}return a(V,"dispose"),{get canPathTrace(){return E&&!G},preview:R,refine:g,capture:x,dispose:V}}a(wr,"createPhotoStudio");var Ju='MeshBVH: "maxLeafTris" option has been deprecated';async function ed(e){let{WebGLPathTracer:o}=await import('./src-GJ5RXX7G.js'),t=console.warn;console.warn=(...a)=>{typeof a[0]=="string"&&a[0].startsWith(Ju)||t(...a);};let n;try{n=new o(e);}finally{console.warn=t;}return n.renderToCanvas=false,n.rasterizeScene=false,n.synchronizeRenderSize=false,n.renderDelay=0,n.minSamples=0,n.fadeDuration=0,n.bounces=6,n.multipleImportanceSampling=true,n.filterGlossyFactor=.5,n.tiles.set(1,1),n._generator.bvhOptions={maxLeafTris:void 0,maxLeafSize:1},n}a(ed,"createPathTracer");function li(e,o,t){e._pathTracer.setSize(o,t);}a(li,"setPathTracerSize");async function ci(e,o,t){let n=new Float32Array(4),a=performance.now(),i=1;for(;o.samples<t.samples;){yr(t.signal);let s=performance.now();for(let p=0;p<i&&o.samples<t.samples;p++)o.renderSample();e.readRenderTargetPixels(o.target,0,0,1,1,n);let c=performance.now()-s;c<35?i=Math.min(64,i*2):c>70&&(i=Math.max(1,Math.floor(i/2)));let l=performance.now()-a;if(t.onFraction(Math.min(1,Math.max(o.samples/t.samples,l/t.timeLimit))),l>t.timeLimit&&o.samples>=t.minSamples)break;await vr();}}a(ci,"accumulate");function vr(){return new Promise(e=>requestAnimationFrame(()=>e()))}a(vr,"nextFrame");function yr(e){if(e?.aborted)throw new DOMException("Photo capture cancelled","AbortError")}a(yr,"throwIfAborted");function od(e,o){let t=[];return e.traverse(n=>{if(Mt(n)){n.updateWorldMatrix(true,false);let a=n.geometry;if(a.boundingBox===null&&a.computeBoundingBox(),a.boundingBox&&!a.boundingBox.isEmpty()){let i=a.boundingBox.clone();i.applyMatrix4(n.matrixWorld);let s=i.clone(),c=new Vector3(o,o,o);s.min.add(c),s.max.sub(c),t.push({box:s,trueBox:i,ignoreForPartCollision:n.userData?.ignoreCollision||false,isCollider:n.userData?.isCollider||false,collisionGroup:n.userData?.collisionGroup||void 0});}}}),t}a(od,"computePartBoundingBoxes");function ui(e,o=.001){let t=[];function n(){return t=od(e,o),t}a(n,"updateBoundingBoxes");function a$1(c){return t.length===0&&n(),t.filter(l=>!l.isCollider&&(c||!l.ignoreForPartCollision)).map(l=>l.box)}a(a$1,"getBoundingBoxes");function i(c){return t.length===0&&n(),t.filter(l=>!l.isCollider&&!l.ignoreForPartCollision&&l.collisionGroup!==c).map(l=>l.box)}a(i,"getBoundingBoxesExcludingGroup");function s(c){return t.length===0&&n(),t.filter(l=>!l.isCollider&&(c||!l.ignoreForPartCollision)).map(l=>l.trueBox)}return a(s,"getTrueBoundingBoxes"),{updateBoundingBoxes:n,getBoundingBoxes:a$1,getBoundingBoxesExcludingGroup:i,getTrueBoundingBoxes:s}}a(ui,"createBoundingBox");function id(){if(typeof localStorage>"u")return false;let e=localStorage.getItem("debug-show-colliders");return e?JSON.parse(e):false}a(id,"getCollidersVisible");function mi(e){let o=null,t=null,n=false;function a$2(u){u&&(e.remove(u),u.geometry.dispose(),u.material.dispose());}a(a$2,"disposeMesh");function i(u){let d=[],v=new Matrix4().copy(e.matrixWorld).invert();if(e.traverse(O=>{if(O instanceof Mesh){if(O.userData.isCollider||!u&&O.userData.ignoreCollision||u&&!O.visible)return;let y=O.geometry.getAttribute("position");if(!y)return;let w=new BufferGeometry;if(w.setAttribute("position",y.clone()),O.geometry.index)w.setIndex(O.geometry.index.clone());else {let P=y.count,T=new Uint32Array(P);for(let R=0;R<P;R++)T[R]=R;w.setIndex(new BufferAttribute(T,1));}w.applyMatrix4(new Matrix4().multiplyMatrices(v,O.matrixWorld)),d.push(w);}}),d.length===0)return null;let f=fi.mergeGeometries(d,false);f.boundsTree=new a$1(f);let S=new Mesh(f,new MeshStandardMaterial({wireframe:true}));return S.visible=id(),S.userData.isCollider=true,e.add(S),S}a(i,"mergeGeometries");function s(){return a$2(o),a$2(t),o=null,t=null,e.updateWorldMatrix(true,true),o=i(false),o||(t=i(true)),n=true,o}a(s,"updateCollider");function c(){return n||s(),o}a(c,"getCollider");function l(){return n||s(),o??t}a(l,"getOcclusionCollider");function p(){a$2(o),a$2(t),o=null,t=null,n=false;}return a(p,"removeCollider"),{getCollider:c,getOcclusionCollider:l,updateCollider:s,removeCollider:p}}a(mi,"createCollider");var hi=new GLTFLoader,xr=new DRACOLoader;xr.setDecoderPath("/draco/");hi.setDRACOLoader(xr);function Pr(e){xr.setDecoderPath(e);}a(Pr,"setDracoDecoderPath");async function Mr(e){let o=await hi.loadAsync(e);return o.scene.animations=o.animations,o.scene}a(Mr,"loadModel");var lo={ADD:"add",CONFIG:"config"};var Ot=class extends Error{static{a(this,"ConfiguratorError");}constructor(o){super(o),this.name="ConfiguratorError";}},co=class extends Ot{static{a(this,"ModuleNotFoundError");}constructor(o){super(`Module with ID ${o} not found`),this.name="ModuleNotFoundError";}};var ht=class extends Ot{static{a(this,"SlotNotFoundError");}constructor(o,t){let n=t?`Slot "${o}" not found in ${t}`:`Slot "${o}" not found`;super(n),this.name="SlotNotFoundError";}};var gt=class extends Ot{static{a(this,"NotPreloadedError");}constructor(o,t){super(`${o} ${t} not preloaded. Call preloadModelsForModule first.`),this.name="NotPreloadedError";}};function gi(e,o,t){let n=new Vector3;e.point.models.addToModel.getWorldPosition(n);let a=t.clone(),i=new Vector3;o.point.models.addToModel.getWorldPosition(i);let s=c(n,i,a),l=n.clone().sub(a).applyAxisAngle(new Vector3(0,1,0),s).add(a),p=c(i,l,a),u=a.clone(),d=new Vector3().subVectors(a,u),v=t.clone().add(d);return {alpha:s,beta:p,translationOffset:d,newPosition:v,pointAAfterRotation:l}}a(gi,"calculateSwapTransformation");var bi="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var bt=a((e=21)=>{let o="",t=crypto.getRandomValues(new Uint8Array(e|=0));for(;e--;)o+=bi[t[e]&63];return o},"nanoid");function vi({point:e,compatibleModules:o,label:t,slotGroup:n,row:a,hasBuiltInConnector:i,preferConnection:s,disabledBySlotParts:c,enabledBySlotParts:l,disabledByNeighborSlots:p,linkedPartSlotName:u,autoConfigureParts:d,accessoryParts:v,accessoryAnchorPosition:f}){return {id:bt(),point:e,module:void 0,compatibleModules:o,label:t,slotGroup:n,row:a,hasBuiltInConnector:i,preferConnection:s,disabledBySlotParts:c,enabledBySlotParts:l,disabledByNeighborSlots:p,linkedPartSlotName:u,autoConfigureParts:d,accessoryParts:v,accessoryAnchorPosition:f}}a(vi,"createModuleSlot");function yi({part:e,compatibleParts:o,label:t,point:n,slotGroupId:a,column:i,row:s,invertible:c,canRotate:l,order:p,disabledPartsByNeighborSlots:u,enabledPartsByNeighborSlots:d,disabledPartsByNeighborParts:v,backrestBlocksTables:f,hiddenBySlotParts:S,syncWithSlotName:O,defaultInverted:y,isVariantDiscriminator:w}){return {part:e,compatibleParts:o,label:t,point:n,slotGroupId:a,column:i,row:s,invertible:c,inverted:false,canRotate:l,rotated:false,order:p,disabledPartsByNeighborSlots:u,enabledPartsByNeighborSlots:d,disabledPartsByNeighborParts:v,backrestBlocksTables:f,hiddenBySlotParts:S,syncWithSlotName:O,defaultInverted:y,isVariantDiscriminator:w}}a(yi,"createBasePartSlot");var st=new Box3,Si=new Vector3;function fd(e,o){let t=e;for(;t.parent;)t=t.parent;let n;return t.traverse(a=>{!a.visible||!a.name.startsWith("wall")||(st.setFromObject(a),!st.isEmpty()&&(o.x<st.min.x||o.x>st.max.x||st.max.z<o.z||(n===void 0||st.max.y>n)&&(n=st.max.y)));}),n}a(fd,"getOccludingWallTopY");function vt(e,o=[],t=[]){let n=e;return {withSlotAction:a(({targetSlot:a,name:i,action:s})=>{if(!n.moduleSlots[a])throw new ht(String(a),"module");let l=[...o,{targetSlot:String(a),name:i,action:s}];return vt(n,l,t)},"withSlotAction"),withModule:a(({targetSlot:a,newModule:i,connectionSlot:s})=>{if(!n.moduleSlots[a])throw new ht(String(a),"module");if(!i.moduleSlots[s])throw new ht(String(s),"new module");let c=[...t,{targetSlot:String(a),newModule:i,connectionSlot:String(s)}];return vt(n,o,c)},"withModule"),withModuleSlots:a(({moduleSlotsData:a})=>{let i={};return Object.entries(a).forEach(([s,c])=>{let l=vi({point:{models:c.models,parentModuleId:n.id,parentModuleSlotId:void 0,active:c.active,type:c.type},compatibleModules:c.compatibleModules,label:c.label,slotGroup:c.slotGroup,row:c.row,hasBuiltInConnector:c.hasBuiltInConnector,preferConnection:c.preferConnection,disabledBySlotParts:c.disabledBySlotParts,enabledBySlotParts:c.enabledBySlotParts,disabledByNeighborSlots:c.disabledByNeighborSlots,linkedPartSlotName:c.linkedPartSlotName,autoConfigureParts:c.autoConfigureParts,accessoryParts:c.accessoryParts,accessoryAnchorPosition:c.accessoryAnchorPosition});l.point.parentModuleSlotId=l.id,n.moduleGroup.add(l.point.models.pointModel),n.moduleGroup.add(l.point.models.addToModel),i[s]=l;}),n.moduleSlots=i,vt(n,o,t)},"withModuleSlots"),withBasePartSlots:a(({basePartSlotsData:a})=>{let i={};return Object.entries(a).forEach(([s,c])=>{let l=yi({point:{models:c.models,parentModuleId:n.id,parentModuleSlotId:void 0,active:c.active,type:c.type},compatibleParts:c.compatibleParts,label:c.label,part:c.part,slotGroupId:c.slotGroupId,column:c.column,row:c.row,invertible:c.invertible,canRotate:c.canRotate,order:c.order,disabledPartsByNeighborSlots:c.disabledPartsByNeighborSlots,enabledPartsByNeighborSlots:c.enabledPartsByNeighborSlots,disabledPartsByNeighborParts:c.disabledPartsByNeighborParts,backrestBlocksTables:c.backrestBlocksTables,hiddenBySlotParts:c.hiddenBySlotParts,syncWithSlotName:c.syncWithSlotName,defaultInverted:c.defaultInverted,isVariantDiscriminator:c.isVariantDiscriminator});l.point.parentModuleId=n.id,l.point.parentModuleSlotId=l.point.models.pointModel.uuid;let p=s.startsWith("cross_");if((l.part.ignoreCollision||p)&&l.part.partGroup.traverse(u=>{u.userData.ignoreCollision=true;}),l.part.collisionGroup){let u=l.part.collisionGroup;l.part.partGroup.traverse(d=>{d.userData.collisionGroup=u;});}n.moduleGroup.add(l.part.partGroup),n.moduleGroup.add(l.point.models.pointModel),n.moduleGroup.add(l.point.models.addToModel),i[s]=l;}),n.basePartSlots=i,vt(n,o,t)},"withBasePartSlots"),withRotatableModule:a(()=>vt({...n,canSwapModuleSlots:true},o,t),"withRotatableModule"),build:a(()=>{let{getCollider:a$1,getOcclusionCollider:i,updateCollider:s,removeCollider:c}=mi(n.moduleGroup),{updateBoundingBoxes:l,getBoundingBoxes:p,getTrueBoundingBoxes:u}=ui(n.moduleGroup);l(),n.moduleGroup.userData=n.moduleGroup.userData||{},n.moduleGroup.userData.updateCollider=s,n.moduleGroup.userData.updateBoundingBoxes=l,Je(n.moduleGroup,true,true);function d(){let T=p(false);if(T.length===0)return;let R=T[0].clone();for(let M=1;M<T.length;M++)R.union(T[M]);let z=n.configPoint.models.pointModel;z.getWorldPosition(Si);let g=R.max.y,x=fd(n.moduleGroup,Si);x!==void 0&&x>g&&(g=x),z.position.y=g+.15;}a(d,"updateConfigPoint");function v(T){n.moduleGroup.position.set(T.x,T.y,T.z);}a(v,"updatePosition");function f(T){n.moduleGroup.rotation.y=T;}a(f,"updateRotation");function S(T,R,z){let g=z.point.models.addToModel,x=R.point.models.addToModel,M=new Vector3(-1,0,0);g.getWorldDirection(M);let E=new Vector3(1,0,0);x.getWorldDirection(E);let G=Math.atan2(M.x,M.z)-Math.atan2(E.x,E.z)+Math.PI;T.moduleGroup.rotation.y=G;let V=new Vector3;g.getWorldPosition(V);let C=R.point.models.addToModel.position.clone(),U=new Matrix4().makeRotationY(G),N=C.applyMatrix4(U),H=V.clone().sub(N);T.moduleGroup.position.set(H.x,H.y,H.z),T.moduleGroup.userData.updateBoundingBoxes?.();}a(S,"placeNewNeighborModule");function O(T,R,z){z.module=T,R.module=P,z.point.active=false,R.point.active=false,T.predecessorSlotId=z.id,S(T,R,z);}a(O,"addModuleToSlot");function y(){Object.values(n.moduleSlots).forEach(T=>{let R=T.module?.moduleSlots;R&&Object.values(R).forEach(z=>{z.module?.id===n.id&&(z.module=void 0,z.point.active=true);});}),c(),n.moduleGroup.clear();}a(y,"remove");function w(T,R){P.moduleGroup.updateMatrixWorld(true);let z=Object.values(n.moduleSlots),g=P.predecessorSlotId,x=!g,M,E;if(x?(M=0,E=z[0]??null):[M,E]=d$1(z,g),!E||M===-1)return;let G=R??(M+1)%z.length,V=z[G];if(!V||G===M)return;let{alpha:C,beta:U,translationOffset:N}=gi(E,V,n.moduleGroup.position),H=n.moduleGroup.rotation.y;f(H+C),n.moduleGroup.updateMatrixWorld(true);let j=n.moduleGroup.position.clone().add(N);v(j);let _=e$1(n.moduleSlots,P,x?void 0:E.module);if(_.length){let m=new Object3D;m.position.copy(n.moduleGroup.position),T.add(m);for(let k of _)m.attach(k.moduleGroup);m.rotation.y+=x?C:U,m.position.add(N);for(let k of _)T.attach(k.moduleGroup),k.moduleGroup.userData.updateBoundingBoxes?.();T.remove(m);}if(!x){let m=V.module,k=E.module;E.module=m,E.point.active=!m,m&&m.predecessorSlotId===V.id&&(m.predecessorSlotId=E.id),V.module=k,V.point.active=!k;}n.moduleGroup.userData.updateBoundingBoxes?.(),P.moduleGroup.updateMatrixWorld(true);}a(w,"swapModuleSlots"),d();let P={...n,apiModuleId:n.apiModuleId,getCollider:a$1,getOcclusionCollider:i,getBoundingBoxes:p,getTrueBoundingBoxes:u,updateConfigPoint:d,updatePosition:v,updateRotation:f,placeNewNeighborModule:S,addModuleToSlot:O,swapModuleSlots:n.canSwapModuleSlots?w:void 0,remove:y,predecessorSlotId:void 0};return t.forEach(({targetSlot:T,newModule:R,connectionSlot:z})=>{let g=P.moduleSlots[T],x=R.moduleSlots[z];g&&x&&P.addModuleToSlot(R,x,g);}),o.forEach(({targetSlot:T,name:R,action:z})=>{let g=P.moduleSlots[T];g&&(g.point.options?g.point.options.push({name:R,action:a(()=>z(P),"action")}):g.point.options=[{name:R,action:a(()=>z(P),"action")}]);}),P},"build")}}a(vt,"moduleBuilder");function Cr(e){let{moduleData:o,position:t}=e,n=bt(),a=t||new Vector3(0,0,0),i=new Group;i.position.set(a.x,a.y,a.z);let s=new Vector3(o.configPointPosition.x,o.configPointPosition.y,o.configPointPosition.z),c=new Object3D;c.position.copy(s);let l={type:"config",active:true,models:{pointModel:c,addToModel:c},parentModuleId:n,parentModuleSlotId:void 0};i.add(c);let p={id:n,code:o.code||o.name,position:a,moduleSlots:{},moduleSlotsOptions:{},basePartSlots:{},sizes:{x:o.sizes?.x??0,z:o.sizes?.z??0},moduleGroup:i,configPoint:l,slotGroups:o.slotGroups,apiModuleId:o.id,remoteProductLineId:o.remoteProductLineId??null},u=vt(p);return o.rotatableModule?u.withRotatableModule():u}a(Cr,"createModuleBuilderFromData");function xi({part:e,compatibleParts:o,label:t,point:n,mandatory:a,showInPreview:i}){return {part:e,compatibleParts:o,label:t,point:n,mandatory:a,showInPreview:i}}a(xi,"createPartSlot");var Tr=k("PartBuilder");function Pi(e,o){e.userData&&Object.keys(e.userData).length>0&&(o.userData={...o.userData,...e.userData}),e.children.forEach((t,n)=>{let a=o.children[n];a&&Pi(t,a);});}a(Pi,"deepCopyUserData");function Rr(e){let o=e;return {withPartSlots:a(t=>{let n={};return Object.entries(t).forEach(([a,i])=>{let s;if(Tr.debug("Processing slot",{slotKey:a,mandatory:i.mandatory,defaultPartApiId:i.defaultPartApiId,compatiblePartsCount:i.compatibleParts?.length??0}),i.mandatory&&i.defaultPartApiId&&i.compatibleParts){let u=i.compatibleParts.find(d=>d.apiPartId===i.defaultPartApiId);Tr.debug("Mandatory slot lookup",{slotKey:a,apiPartId:i.defaultPartApiId,found:!!u}),u&&(Tr.debug("Creating mandatory part",{slotKey:a}),s=u.createPart(),u.hasConfigurableSurface!==void 0&&(s.hasConfigurableSurface=u.hasConfigurableSurface),u.defaultSurfaceId!==void 0&&(s.defaultSurfaceId=u.defaultSurfaceId,s.hasConfigurableSurface&&(s.surfaceId=u.defaultSurfaceId)),u.allowedSurfaceGroupIds!==void 0&&(s.allowedSurfaceGroupIds=u.allowedSurfaceGroupIds),u.allowedSurfaceIds!==void 0&&(s.allowedSurfaceIds=u.allowedSurfaceIds));}let c=i.models.pointModel.clone(),l=i.models.addToModel.clone(),p=xi({point:{models:{pointModel:c,addToModel:l},parentModuleId:o.id,parentModuleSlotId:void 0,active:i.active,type:i.type},compatibleParts:i.compatibleParts,label:i.label,part:s,mandatory:i.mandatory,showInPreview:i.showInPreview});if(o.partGroup.add(p.point.models.pointModel),o.partGroup.add(p.point.models.addToModel),p.part){if(p.part.ignoreCollision&&p.part.partGroup.traverse(u=>{u.userData.ignoreCollision=true;}),p.part.collisionGroup){let u=p.part.collisionGroup;p.part.partGroup.traverse(d=>{d.userData.collisionGroup=u;});}o.partGroup.add(p.part.partGroup),Je(p.part.partGroup,true,true);}n[a]=p;}),o.partSlots=n,Rr(o)},"withPartSlots"),withCompatibleParts:a(t=>(Object.entries(t).forEach(([n,a])=>{let i=o.partSlots[n];i&&(i.compatibleParts=a);}),Rr(o)),"withCompatibleParts"),build:a(()=>o,"build")}}a(Rr,"partBuilder");function Ar(e){let{partData:o,model:t,position:n}=e,a=bt(),i=n||new Vector3(0,0,0),s=t.clone();Pi(t,s),o.rotation&&s.rotation.set(o.rotation.x*Math.PI/180,o.rotation.y*Math.PI/180,o.rotation.z*Math.PI/180);let c=o.mirror?.x?-1:1,l=o.mirror?.y?-1:1,p=o.mirror?.z?-1:1,u=o.scale??1;s.scale.set(c*u,l*u,p*u);let d=new Group;d.position.set(i.x,i.y,i.z),d.add(s);let v={id:a,code:o.code??o.name,position:i,model:s,material:void 0,partGroup:d,partSlots:{},ignoreCollision:o.ignoreCollision,collisionGroup:o.collisionGroup??void 0,apiPartId:o.id,partTypeId:o.partTypeId??null,hasConfigurableSurface:o.hasConfigurableSurface,allowedSurfaceGroupIds:o.allowedSurfaceGroupIds,allowedSurfaceIds:o.allowedSurfaceIds,defaultSurfaceId:o.defaultSurfaceId??void 0,wallThickness:o.wallThickness??void 0,wallPositionOffset:o.wallPositionOffset??void 0,surfaceId:o.hasConfigurableSurface?o.defaultSurfaceId??void 0:void 0,isModuleAccessoryPart:o.remoteProductAccessoryId!=null,hideFromConfigurator:o.hideFromConfigurator??false,priceMultiplier:o.priceMultiplier??1};return Rr(v)}a(Ar,"createPartBuilderFromData");var bd=k("CatalogAdapter");function Ci(e){let o={};try{o=typeof e.textureJson=="string"?JSON.parse(e.textureJson):e.textureJson??{};}catch{o={};}let t=new MeshPhysicalMaterial({color:typeof o.color=="string"?o.color:"#b9bcc4",metalness:typeof o.metalness=="number"?o.metalness:0,roughness:typeof o.roughness=="number"?o.roughness:.8});return t.name=`surface-${e.id}`,t}a(Ci,"createColourSurfaceMaterial");function Er(e){let{catalog:o}=e,t=e.invalidate??(()=>{}),n=e.createSurfaceMaterial??Ci,a$1=new Map,i$1=new Map,s=new Map,c=new Map,l=new Map,p=new Map,u=new Map,d=new Map(o.parts.map(m=>[m.id,m])),v=new Map(o.modules.map(m=>[m.id,m])),f=new Map(o.surfaces.map(m=>[m.id,m]));function S(m){return d.get(m)}a(S,"getPartById");function O(m){return v.get(m)}a(O,"getModuleById");function y(m){let k=u.get(m);if(k)return k;let b=f.get(m);if(!b)return null;let A=n(b);return A&&u.set(m,A),A}a(y,"getSurface");async function w(m){let k=c.get(m);if(k)return k.clone();let b=l.get(m);if(b)return (await b).clone();let A=Mr(m).then(h=>(c.set(m,h.clone()),l.delete(m),h));return l.set(m,A),A}a(w,"loadModelByPath");async function P(m){if(!m.model3d)return null;let k=await w(m.model3d.filePath),b=m.fixedSurfaceId?y(m.fixedSurfaceId):null;return k.traverse(A=>{if(Mt(A)){if(A.userData.fixedFinish){A.userData.hasConfigurableSurface=false;return}A.userData.hasConfigurableSurface=m.hasConfigurableSurface,b&&(A.material=b);}}),m.tag&&(k.userData.tag=m.tag),k}a(P,"loadAndTagPartModel");function T(m,k){return new Vector3(k?.x??m.x,k?.y??m.y,k?.z??m.z)}a(T,"resolveCompatiblePartPosition");function R(m,k=new Set){let b=new Set;if(k.has(m))return b;k.add(m);let A=S(m);if(!A)return b;b.add(m);for(let h of A.partSlots??[])for(let{partId:W}of h.compatibleParts??[])for(let B of R(W,k))b.add(B);return b}a(R,"collectNestedPartIds");function z(m,k){return b=>{let A=i$1.get(m.id);if(!A)throw new gt("Part data",m.id);let h=s.get(m.id);if(!h)throw new gt("Part model",m.id);let W=b?.position??k,B=W?new Vector3(W.x,W.y,W.z):new Vector3(0,0,0),Y=Ar({partData:A,model:h,position:B}),Q=p.get(m.id);return Q&&Y.withPartSlots(Q),Y.build()}}a(z,"createPartFactory");function g$1(m,k){return b=>{let A=b?.position??k,h=A?new Vector3(A.x,A.y,A.z):new Vector3(0,0,0);return Ar({partData:m,model:new Group,position:h}).build()}}a(g$1,"createEmptyPartFactory");function x(m){if(!m.partSlots||m.partSlots.length===0)return;let k={},b=new Map;for(let A of m.partSlots)for(let h of A.requiredByPartIds??[])b.has(h)||b.set(h,[]),b.get(h)?.push(A.name);for(let A of m.partSlots){let h=new Object3D;h.position.set(A.pointPosition.x,A.pointPosition.y,A.pointPosition.z);let W=new Object3D;W.position.set(A.addPosition.x,A.addPosition.y,A.addPosition.z);let B=[];for(let{partId:Y,addPosition:Q}of A.compatibleParts??[]){let q=S(Y);if(!q||!q.models||q.models.length===0)continue;let ne=T(A.addPosition,Q),oe={name:q.name,description:q.description??void 0,image:q.image??void 0,createPart:z(q,ne),apiPartId:q.id,partTypeId:q.partTypeId??null,hasConfigurableSurface:q.hasConfigurableSurface,allowedSurfaceGroupIds:q.allowedSurfaceGroupIds,allowedSurfaceIds:q.allowedSurfaceIds,defaultSurfaceId:q.defaultSurfaceId??void 0,hideFromConfigurator:q.hideFromConfigurator},ce=b.get(Y);ce&&ce.length>0&&(oe.dependencies=ce),B.push(oe);}k[A.name]={models:{pointModel:h,addToModel:W},active:false,type:lo.CONFIG,label:A.label??A.name,compatibleParts:B.length>0?B:void 0,slotGroupId:A.slotGroupId??void 0,mandatory:A.mandatory??false,showInPreview:A.showInPreview??false,defaultPartApiId:j(A)};}return Object.keys(k).length>0?k:void 0}a(x,"buildPartSlotsData");async function M(m){a$1.set(m.id,m);let k=new Set;for(let b of m.basePartSlots??[])for(let{partId:A}of b.compatibleParts??[])for(let h of R(A))k.add(h);for(let b of m.moduleSlots??[]){for(let A of b.accessoryPartIds??[])for(let h of R(A))k.add(h);for(let A of b.compatibleModuleIds??[]){let h=O(A);h&&a$1.set(A,h);}}await Promise.all([...k].map(async b=>{let A=S(b);if(A){if(i$1.set(b,A),A.models&&A.models.length>0)if(A.models.length===1){let h=await P(A.models[0]);h&&s.set(b,h);}else {let h=new Group;for(let W of A.models){let B=await P(W);B&&h.add(B);}s.set(b,h);}A.partSlots&&A.partSlots.length>0&&!p.has(b)&&p.set(b,x(A));}}));}a(M,"preloadModelsForModule");function E(m){if(!m.basePartSlots||m.basePartSlots.length===0)return;let k={};for(let b of m.basePartSlots){let A=new Object3D;A.position.set(b.pointPosition.x,b.pointPosition.y,b.pointPosition.z);let h=new Object3D;h.position.set(b.addPosition.x,b.addPosition.y,b.addPosition.z);let W=[];for(let{partId:q,addPosition:ne}of b.compatibleParts??[]){let oe=S(q);if(!oe)continue;let ce=T(b.addPosition,ne),Se=!oe.models||oe.models.length===0,ie=Se?g$1(oe,ce):z(oe,ce);W.push({name:oe.name,description:oe.description??void 0,image:oe.image??void 0,createPart:ie,apiPartId:oe.id,partTypeId:oe.partTypeId??null,hasConfigurableSurface:oe.hasConfigurableSurface,allowedSurfaceGroupIds:oe.allowedSurfaceGroupIds,allowedSurfaceIds:oe.allowedSurfaceIds,defaultSurfaceId:oe.defaultSurfaceId??void 0,hideFromConfigurator:oe.hideFromConfigurator,isEmpty:Se});}let B=i(b,W.flatMap(q=>q.apiPartId??[])),Y=W.find(q=>q.apiPartId===B)?.createPart;if(!Y){bd.warn("No valid parts found for slot",{slotName:b.name});continue}let Q=Y();b.defaultInverted&&(Q.partGroup.scale.z=-1),k[b.name]={models:{pointModel:A,addToModel:h},active:false,type:lo.CONFIG,label:b.label??b.name,part:Q,compatibleParts:W.length>0?W:void 0,slotGroupId:b.slotGroupId??void 0,column:b.column??void 0,row:b.row??void 0,invertible:b.invertible??false,canRotate:b.canRotate??false,order:b.order??0,disabledPartsByNeighborSlots:b.disabledPartsByNeighborSlots??[],enabledPartsByNeighborSlots:b.enabledPartsByNeighborSlots??[],disabledPartsByNeighborParts:b.disabledPartsByNeighborParts??[],backrestBlocksTables:b.backrestBlocksTables??void 0,hiddenBySlotParts:b.hiddenBySlotParts??[],syncWithSlotName:b.syncWithSlotName??void 0,defaultInverted:b.defaultInverted??false,isVariantDiscriminator:b.isVariantDiscriminator??false};}return Object.keys(k).length>0?k:void 0}a(E,"buildBasePartSlotsData");function G(m){if(!m.moduleSlots||m.moduleSlots.length===0)return;let k={};for(let b of m.moduleSlots){let A=new Object3D;A.position.set(b.floatingPointPosition.x,b.floatingPointPosition.y,b.floatingPointPosition.z);let h=new Object3D;if(h.position.set(b.moduleSlotPosition.x,b.moduleSlotPosition.y,b.moduleSlotPosition.z),b.direction)h.lookAt(new Vector3(b.moduleSlotPosition.x+b.direction.x,b.moduleSlotPosition.y+b.direction.y,b.moduleSlotPosition.z+b.direction.z));else {let Y=new Vector3(b.moduleSlotPosition.x,0,b.moduleSlotPosition.z).normalize();Y.length()>0&&h.lookAt(Y);}let W=[],B=b.compatibleModulesWithSlots&&b.compatibleModulesWithSlots.length>0?b.compatibleModulesWithSlots:(b.compatibleModuleIds??[]).map(Y=>({moduleId:Y,allowedSlotNames:void 0}));for(let{moduleId:Y,allowedSlotNames:Q}of B){let q=v.get(Y);if(!q)continue;let ne=a(()=>V(q.id),"createModuleFn");W.push({id:q.id,name:q.name,image:q.image??void 0,createModule:ne,allowedSlotNames:Q});}k[b.name]={models:{pointModel:A,addToModel:h},active:true,type:lo.ADD,label:b.label??b.name,slotGroup:b.slotGroup??void 0,row:b.moduleSlotPosition.z>.05?"front":b.moduleSlotPosition.z<-0.05?"back":"middle",hasBuiltInConnector:b.hasBuiltInConnector,preferConnection:b.preferConnection,compatibleModules:W,disabledBySlotParts:b.disabledBySlotParts??[],enabledBySlotParts:b.enabledBySlotParts??[],disabledByNeighborSlots:b.disabledByNeighborSlots??[],linkedPartSlotName:b.linkedPartSlotName??void 0,autoConfigureParts:b.autoConfigureParts??[]};}return Object.keys(k).length>0?k:void 0}a(G,"buildModuleSlotsData");function V(m){let k=a$1.get(m);if(!k)throw new gt("Module data",m);return Cr({moduleData:k}).build()}a(V,"createModuleSync");async function C(m){await M(m);let k=E(m),b=G(m),A=Cr({moduleData:m});return k&&A.withBasePartSlots({basePartSlotsData:k}),b&&A.withModuleSlots({moduleSlotsData:b}),A.build()}a(C,"createModuleFromApi");async function U(m){let k=O(m);if(!k)throw new co(m);return C(k)}a(U,"createModuleById");function N(){return o.surfaces.filter(m=>m.status!=="deleted")}a(N,"listSurfaces");function H(m){return f.get(m)}a(H,"getSurfaceRow");function j$1(m,k){return g(m,k,f.get(k)?.groupId)}a(j$1,"isSurfaceAllowed");function _(m){function k(b,A){let h$1=h(b,{inherited:A},W=>j$1(b,W));if(b.hasConfigurableSurface&&h$1){let W=y(h$1);W&&(b.model.traverse(B=>{Mt(B)&&B.userData.hasConfigurableSurface&&(B.material=W);}),b.material=W,b.surfaceId=h$1);}for(let W of Object.values(b.partSlots??{}))W.part&&k(W.part,h$1);}a(k,"applyPartSurface");for(let b of Object.values(m.basePartSlots))k(b.part);t();}return a(_,"applyDefaultSurfaces"),{catalog:o,getModuleById:O,getPartById:S,getSurface:y,preloadModelsForModule:M,createModuleSync:V,createModuleFromApi:C,createModuleById:U,applyDefaultSurfaces:_,listSurfaces:N,getSurfaceRow:H,isSurfaceAllowed:j$1}}a(Er,"createCatalogAdapter");var Rd=new TextureLoader;function Ad(e,{repeat:o,anisotropy:t,colorSpace:n}){return new Promise((a,i)=>{Rd.load(e,s=>{s.colorSpace=n,s.wrapS=s.wrapT=RepeatWrapping,s.minFilter=LinearMipmapLinearFilter,s.magFilter=LinearFilter,s.anisotropy=t,s.generateMipmaps=true,s.repeat.set(o,o),a(s);},void 0,s=>i(s));})}a(Ad,"loadSurfaceTexture");var Ti={map:SRGBColorSpace,normalMap:NoColorSpace,roughnessMap:NoColorSpace,metalnessMap:NoColorSpace,aoMap:NoColorSpace};async function Or(e,{repeat:o,anisotropy:t}){let n=await Promise.all(Object.keys(Ti).map(async i=>{let s=e[i];if(!s)return [i,void 0];let c=Ti[i];return [i,await Ad(s,{repeat:o,anisotropy:t,colorSpace:c})]})),a=Object.fromEntries(n.filter(([,i])=>i));return a.aoMap&&(a.aoMap.channel=0),a}a(Or,"loadSurfaceMaps");function mo(e,{map:o,normalMap:t,roughnessMap:n,metalnessMap:a,aoMap:i},s){let{sheen:c,sheenColor:l,sheenRoughness:p,emissive:u,anisotropy:d,anisotropyRotation:v}=e,f=c!==void 0||l!==void 0||p!==void 0||u!==void 0||d!==void 0||v!==void 0,S={...o?{map:o,...e.tint&&{color:new Color(e.color??"#ffffff")},roughness:e.roughness??.8,metalness:e.metalness??.1}:{color:new Color(e.color??"#808080"),metalness:e.metalness??.1,roughness:e.roughness??.8},...e.envMapIntensity!==void 0&&{envMapIntensity:e.envMapIntensity,...s&&{envMap:s}},...t&&{normalMap:t,...e.normalScale!==void 0&&{normalScale:new Vector2(e.normalScale,e.normalScale)}},...n&&{roughnessMap:n},...a&&{metalnessMap:a},...i&&{aoMap:i,...e.aoIntensity!==void 0&&{aoMapIntensity:e.aoIntensity}},...e.doubleSided&&{side:DoubleSide}};return f?new MeshPhysicalMaterial({...S,...c!==void 0&&{sheen:c},...l!==void 0&&{sheenColor:new Color(l)},...p!==void 0&&{sheenRoughness:p},...u!==void 0&&{emissive:new Color(u)},...d!==void 0&&{anisotropy:d},...v!==void 0&&{anisotropyRotation:v}}):new MeshStandardMaterial(S)}a(mo,"createSurfaceMaterial");var Ri=new WeakMap;function Od(e,o){let t=Ri.get(e);t||(t=[],Ri.set(e,t));let n=t.find(a=>a.clip===o);if(!n){let a=new AnimationMixer(e),i=a.clipAction(o);i.play(),n={clip:o,mixer:a,action:i},t.push(n);}return n}a(Od,"scrubberFor");function Ai(e,o){let t=false;return e.traverse(n=>{!t&&n.animations.some(a=>a.name===o)&&(t=true);}),t}a(Ai,"hasClip");function ho(e,o,t){let n=Math.min(1,Math.max(0,t)),a=false;return e.traverse(i=>{for(let s of i.animations){if(s.name!==o)continue;let{mixer:c,action:l}=Od(i,s);l.time=n*s.duration,c.update(0),a=true;}}),a}a(ho,"seekClip");var Oi=[{clip:"unfold",seconds:3.6},{clip:"open",seconds:2.2},{clip:"tilt",seconds:1.8}],Di=.15;function Dr(e){let o=e.poses??Oi,t=e.requestFrame??(typeof requestAnimationFrame=="function"?g=>requestAnimationFrame(g):g=>setTimeout(()=>g(performance.now()),16)),n=null,a$1=0,i=null,s=false,c=0,l=0,p;function u(g){return e.roots().filter(x=>Ai(x,g))}a(u,"posable");function d(){return o.filter(g=>u(g.clip).length>0).map(g=>g.clip)}a(d,"available");function v(g,x){let M=u(g);for(let E of M)ho(E,g,x),E.updateMatrixWorld(true);e.onPose?.(g,x,M);}a(v,"pose");function f(g,x){let M=new Box3;for(let E of u(g))ho(E,g,x),E.updateMatrixWorld(true);for(let E of e.roots())M.expandByObject(E);for(let E of u(g))ho(E,g,n===g?a$1:0),E.updateMatrixWorld(true);return M}a(f,"boundsAt");function S(g,x){if(!e.onFrame)return;let M=f(g,x===1?0:1).getSize(new Vector3),E=f(g,x),G=E.getSize(new Vector3);Math.max(Math.abs(G.x-M.x),Math.abs(G.y-M.y),Math.abs(G.z-M.z))/Math.max(M.x,M.y,M.z,1e-6)<Di||e.onFrame(E);}a(S,"frame");function O(g,x){let M=n===g?a$1:0;n=g;let E=++l;return new Promise(G=>{let V=a(()=>{a$1=x,v(g,x),s=false,e.onSettle?.(g,u(g)),x===0&&(n=null),p=void 0,G(true);},"arrive"),C=o.find(j=>j.clip===g)?.seconds??2;if(e.reducedMotion?.()||M===x)return V();s=true,p=G;let U=C*Math.abs(x-M)*1e3,N,H=a(j=>{if(E!==l)return;N??=j;let _=Math.min(1,(j-N)/U);a$1=M+(x-M)*_,v(g,a$1),_<1?t(H):V();},"step");t(H);})}a(O,"run");function y(){l++,p?.(false),p=void 0;}a(y,"interrupt");async function w(g,x){if(u(g).length===0)return;let M=++c;i=x?g:null,e.onChange?.(),y(),!(n&&n!==g&&(await O(n,0),M!==c))&&(!x&&n!==g||(e.beforeTravel?.(g,u(g)),S(g,x?1:0),await O(g,x?1:0)));}a(w,"setPose");async function P(){i?await w(i,false):n&&await w(n,false);}a(P,"rest");function T(){let g=n;return g?u(g).length===0?false:(a$1===0||(e.beforeTravel?.(g,u(g)),v(g,a$1),s||e.onSettle?.(g,u(g))),true):true}a(T,"reapply");function R(){!s&&(a$1===1?n:null)===i||(c++,y(),s=false,n&&n!==i&&(v(n,0),e.onSettle?.(n,u(n))),i?(n!==i&&S(i,1),n=i,a$1=1,v(i,1),e.onSettle?.(i,u(i))):(n=null,a$1=0));}a(R,"settle");function z(){y(),n=null,i=null,a$1=0,s=false,e.onChange?.();}return a(z,"forget"),{available:d,setPose:w,rest:P,reapply:T,settle:R,forget:z,target:a(()=>i,"target"),current:a(()=>n,"current"),progress:a(()=>a$1,"progress"),moving:a(()=>s,"moving")}}a(Dr,"createPoseController");function _i(e,o){let t=e.geometry.clone();if(t.applyMatrix4(o),o.determinant()<0){let n=t.getIndex();if(n){let a=n.array;for(let i=0;i<a.length;i+=3){let s=a[i+1];a[i+1]=a[i+2],a[i+2]=s;}n.needsUpdate=true;}else {let a=t.getAttribute("position"),i=a.array,s=a.itemSize*3;for(let c=0;c<i.length;c+=s)for(let l=0;l<a.itemSize;l++){let p=c+a.itemSize+l,u=c+2*a.itemSize+l,d=i[p];i[p]=i[u],i[u]=d;}a.needsUpdate=true;}}e.geometry=t;}a(_i,"bakeMatrixIntoGeometry");function Bi(e,o,t){e.model.updateWorldMatrix(true,false);let n=e.model.matrixWorld.clone(),a=t.clone().invert(),i=n.premultiply(a),s=e.model.clone(true),c=i;if(i.determinant()<0){let d=new Matrix4().makeScale(-1,1,1);c=i.clone().multiply(d),s.position.set(0,0,0),s.quaternion.identity(),s.scale.set(1,1,1),s.updateMatrixWorld(true),s.traverse(v=>{let f=v;if(!f.isMesh)return;let S=f.matrixWorld.clone(),O=S.clone().invert().multiply(d).multiply(S);_i(f,O);});}let l=new Vector3,p=new Quaternion,u=new Vector3;c.decompose(l,p,u),s.position.copy(l),s.quaternion.copy(p),s.scale.copy(u),o.add(s);for(let d in e.partSlots){let v=e.partSlots[d];v?.part&&Bi(v.part,o,t);}}a(Bi,"clonePartModel");function kr(e){if(e.length===0)throw new Error("No modules to export");let o=new Group;o.name="ConfiguratorExport";for(let t of e){let n=new Group;n.position.copy(t.moduleGroup.position),n.rotation.copy(t.moduleGroup.rotation),n.scale.copy(t.moduleGroup.scale);let a=new Matrix4;t.moduleGroup.updateWorldMatrix(true,false),a.copy(t.moduleGroup.matrixWorld);for(let i in t.basePartSlots){let s=t.basePartSlots[i];s?.part&&!s.hidden&&!s.cleared&&Bi(s.part,n,a);}o.add(n);}return o.updateMatrixWorld(true),o}a(kr,"buildExportObject3D");var Be=.15,Fi=20,Ld=5;function Ir(e,o){return o==="mm"?`${Math.round(e*1e3)} mm`:`${Math.round(e*100)} cm`}a(Ir,"formatScaleLength");function Lr(e,o,t,n){let a=e.clone().project(o);return a.z>1?null:{x:(a.x*.5+.5)*t,y:(-a.y*.5+.5)*n,zIndex:Math.floor(1e4-a.z*1e4)}}a(Lr,"project");function _r(e,o,t,n){let{min:a,max:i}=e,s=e.getCenter(new Vector3);if(o.position.distanceTo(s)>Fi)return null;let c=o.position.z>s.z,l=o.position.x>s.x,p=c?i.z+Be:a.z-Be,u=l?i.x+Be:a.x-Be,d=a.y-Be,v={x:[new Vector3(a.x,d,p),new Vector3(i.x,d,p)],y:[new Vector3(u,a.y,p),new Vector3(u,i.y,p)],z:[new Vector3(u,d,a.z),new Vector3(u,d,i.z)]},f=[];for(let w of ["x","y","z"]){let P=Lr(v[w][0],o,t,n),T=Lr(v[w][1],o,t,n);P&&T&&f.push({axis:w,x1:P.x,y1:P.y,x2:T.x,y2:T.y});}let S=l?i.x+Be*2:a.x-Be*2,O=[["x",new Vector3((a.x+i.x)/2,a.y-Be*2,p),i.x-a.x],["y",new Vector3(S,(a.y+i.y)/2,p),i.y-a.y],["z",new Vector3(S,d,(a.z+i.z)/2),i.z-a.z]],y=[];for(let[w,P,T]of O){let R=Lr(P,o,t,n);R&&y.push({axis:w,...R,scale:Ld/o.position.distanceTo(P),meters:T});}return {lines:f,labels:y}}a(_r,"computeScaleOverlay");var Wi=.08,zd=.3,Ui=.005;function zi(e){e.sort();let o=[];for(let a of e){let i=o[o.length-1];i&&a-i.to<=Wi?i.to=Math.max(i.to,a):o.push({from:a,to:a});}let t=o.length?o[o.length-1].to-o[0].from:0,n=o.reduce((a,i)=>a+i.to-i.from,0);return {pieces:o,length:t,rigid:n}}a(zi,"measureAxis");function Vi(e){let o=[];return e.traverse(t=>{let n=t;n.isMesh&&n.geometry?.attributes.position&&o.push(n);}),o}a(Vi,"productMeshes");function Br(e){e.updateMatrixWorld(true);let o=e.matrixWorld.clone().invert(),t=new Map;return e.traverse(n=>{n!==e&&t.set(n,o.clone().multiply(n.matrixWorld));}),t}a(Br,"relativeMatrices");function Ni(e){let o=Br(e),t=Vi(e).filter(d=>!d.userData.isCollider),n=[],a$1=[],i=new Vector3,s=new Box3;for(let d of t){let v=o.get(d),f=d.geometry.attributes.position;s.makeEmpty();for(let O=0;O<f.count;O++)i.fromBufferAttribute(f,O).applyMatrix4(v),n.push(i.x),a$1.push(i.y),s.expandByPoint(i);if(s.isEmpty())continue;let S=a((O,y,w)=>{if(!(w-y>zd))for(let P=y;P<w;P+=Wi/2)O.push(P);},"fill");S(n,s.min.x,s.max.x),S(a$1,s.min.y,s.max.y);}if(n.length===0)return null;let c=zi(Float32Array.from(n)),l=zi(Float32Array.from(a$1)),p=a(d=>Math.round(d*1e3),"mm"),u=a(d=>Math.max(0,d.pieces.length-1)*Ui,"runs");return {x:c,y:l,size:{width:p(c.length),height:p(l.length)},minimum:{width:p(c.rigid+u(c)),height:p(l.rigid+u(l))}}}a(Ni,"measureModule");function Gi(e,o,t){let{pieces:n}=e,a=n.slice(1).map((v,f)=>v.from-n[f].to),i=a.reduce((v,f)=>v+f,0),s=o-e.length,c=a.map(v=>Math.max(Ui,i>0?v+s*v/i:v)),l=n[0]?.from??0,p=e.rigid+c.reduce((v,f)=>v+f,0),u=t==="start"?l:l+(e.length-p)/2,d=[];for(let[v,f]of n.entries())d.push(u-f.from),u+=f.to-f.from+(c[v]??0);return v=>{if(n.length===0)return v;if(v<=n[0].to)return v+d[0];for(let f=0;f<n.length;f++){let S=n[f];if(v<=S.to){if(v>=S.from)return v+d[f];let O=n[f-1],y=(v-O.to)/(S.from-O.to),w=O.to+d[f-1],P=S.from+d[f];return w+(P-w)*y}}return v+d[d.length-1]}}a(Gi,"axisMap");function Gd(e,o,t,n){let a$1=e.index,i=a$1?a$1.count:o.length,s=new Uint8Array(o.length),c=n.clone(),l=t.map((S,O)=>S.clone().sub(o[O])),p=new Vector3,u=new Vector3,d=new Vector3,v=new Vector3,f=1e-7;for(let S=0;S+2<i;S+=3){let O=[0,1,2].map(E=>a$1?a$1.getX(S+E):S+E),[y,w,P]=O;if(!(l[y].distanceToSquared(l[w])>f||l[y].distanceToSquared(l[P])>f))continue;p.subVectors(o[w],o[y]),u.subVectors(o[P],o[y]);let R=p.dot(p),z=p.dot(u),g=u.dot(u),x=R*g-z*z;if(Math.abs(x)<1e-14)continue;let M=a((E,G)=>{let V=G(w)-G(y),C=G(P)-G(y),U=(V*g-C*z)/x,N=(C*R-V*z)/x;return E.copy(p).multiplyScalar(U).addScaledVector(u,N)},"gradient");M(d,E=>c.getX(E)),M(v,E=>c.getY(E));for(let E of O)s[E]||(s[E]=1,n.setXY(E,c.getX(E)+d.dot(l[E]),c.getY(E)+v.dot(l[E])));}n.needsUpdate=true;}a(Gd,"respreadUvs");function Wd(e,o){if(Math.abs(o-1)<1e-6)return;let t=new Quaternion,n=new Vector3;e.traverse(a=>{a.animations.length&&(a.animations=a.animations.map(i=>{if(i.name!=="tilt")return i;let s=i.clone();for(let c of s.tracks){if(!(c instanceof QuaternionKeyframeTrack))continue;let l=c.values;for(let p=0;p<l.length;p+=4){t.fromArray(l,p);let u=2*Math.acos(Math.min(1,Math.abs(t.w)));if(u<1e-6)continue;let d=Math.sqrt(1-t.w*t.w);if(n.set(t.x/d,t.y/d,t.z/d),Math.abs(n.x)<.9)continue;let v=t.w<0?-1:1,f=Math.asin(Math.min(1,Math.sin(u)*o));t.setFromAxisAngle(n.multiplyScalar(v),f),t.toArray(l,p);}}return s}));});}a(Wd,"retuneTilt");var Fr="konfigureResized";function zr(e,o){let t=Ni(e);if(!t)return null;let n=Gi(t.x,o.width/1e3,"centre"),a$1=Gi(t.y,o.height/1e3,"start"),i=a(O=>O.set(n(O.x),a$1(O.y),O.z),"map"),s=Br(e),c=Vi(e),l=new Vector3,p=e.matrixWorld.clone().invert(),u=new Matrix4;e.traverse(O=>{let y=O.parent;O===e||!y||(l.setFromMatrixPosition(s.get(O)),i(l),y.updateMatrixWorld(false),y===e?u.identity():u.copy(p).multiply(y.matrixWorld).invert(),O.position.copy(l.applyMatrix4(u)),O.updateMatrix());});let d=Br(e);for(let O of c){let y=O.geometry,w=y.clone();w.userData={...y.userData,[Fr]:true};let P=w.attributes.position,T=s.get(O),R=d.get(O).clone().invert(),z=[],g=[],x=new Vector3;for(let E=0;E<P.count;E++)x.fromBufferAttribute(P,E).applyMatrix4(T),z.push(x.clone()),i(x),g.push(x.clone()),x.applyMatrix4(R),P.setXYZ(E,x.x,x.y,x.z);P.needsUpdate=true;let M=w.attributes.uv;M&&Gd(w,z,g,M),w.computeBoundingBox(),w.computeBoundingSphere(),y.userData[Fr]&&y.dispose(),O.geometry=w;}let v=a((O,y)=>y(O.pieces.at(-1).to)-y(O.pieces[0].from),"drawn"),f=v(t.x,n),S=v(t.y,a$1);return Wd(e,t.y.length/S),{width:Math.round(f*1e3),height:Math.round(S*1e3)}}a(zr,"resizeModule");function Dt(e){e.traverse(o=>{let t=o;t.isMesh&&t.geometry?.userData[Fr]&&t.geometry.dispose();});}a(Dt,"disposeResizedGeometry");var Ud=1200;function ji(e){let{settings:o}=e,t=0,n=-1,a$1=null,i,s=false;function c(){let R=e.module();return R?kr([R]):null}a(c,"exportObject");let l=Eo({object:c,uploadEndpoint:o.uploadEndpoint??(e.instance?`${e.instance}/api/ar/upload-model`:void 0),sceneViewerParams:o.title?{title:o.title}:void 0,messages:a(()=>o.messages,"messages"),onChange(R){R.failed&&!s&&R.failureKind&&e.onFailure({kind:R.failureKind,message:l.failureMessage()}),s=R.failed,e.onChange();}}),p=l.start(),u=a(()=>l.state.mode==="quick-look"||l.state.mode==="scene-viewer","needsFile");function d(){let R=t;return a$1=l.prepare().then(z=>(z&&(n=R),a$1=null,z&&R===t)),a$1}a(d,"prepareNow");let v=false;function f(){clearTimeout(i),!(o.prepareInBackground===false||v)&&(i=setTimeout(()=>{p.then(()=>{v||u()&&n!==t&&!a$1&&d();});},Ud));}a(f,"prepareLater");function S(){t++,f();}a(S,"changed");function O(R){v=R,R?clearTimeout(i):n!==t&&f();}a(O,"suspend");async function y(){await p;let R=l.state.mode;return {supported:R!=="none",mode:R,reason:Ao(R)}}a(y,"support");async function w(){return await p,v?false:u()?n===t&&l.state.prepared||(a$1&&await a$1,n===t&&l.state.prepared)?true:d():l.state.mode!=="none"}a(w,"prepare");function P(){let R=l.state.mode;return R==="none"||v?Promise.resolve(false):R==="webxr"?l.launch():l.state.prepared&&n===t?Promise.resolve(l.launchPrepared()):(async()=>await w()?l.launchPrepared():false)()}a(P,"start");async function T(R){let z=c();if(!z)throw new Error("Nothing to export yet");if(R==="glb")return new Blob([await Gt(z)],{type:"model/gltf-binary"});let{href:g,revoke:x}=await Pt(z);try{return await(await fetch(g)).blob()}finally{x();}}return a(T,"exportFile"),{support:y,prepare:w,start:P,exportFile:T,changed:S,suspend:O,state:a(()=>({mode:l.state.mode,loading:l.state.loading,prepared:!!l.state.prepared&&n===t,failed:l.state.failed}),"state"),dismissFailure:l.dismissFailure,dispose(){clearTimeout(i),l.destroy();}}}a(ji,"createViewAR");var qi="konfigure-dimension-style",Vd=`
|
|
1
|
+
import {k as k$1,c,s,m,n,j,r,o,q,p}from'./chunk-4KQN5AVT.js';export{i as PHOTO_ANGLES,e as PHOTO_SETUPS,d as PHOTO_SETUP_IDS,g as PHOTO_SHOT_PRESET_NAMES,f as clonePhotoSetup}from'./chunk-4KQN5AVT.js';import {a as a$1}from'./chunk-EBEY7ID3.js';import'./chunk-XR6EHOK2.js';import {a}from'./chunk-XUSV3KOD.js';import {BufferGeometry,BufferAttribute,WebGLRenderer,SRGBColorSpace,PCFSoftShadowMap,PMREMGenerator,Scene,PerspectiveCamera,Box3,Vector3,Group,ShadowMaterial,PlaneGeometry,Mesh,DirectionalLight,Quaternion}from'three';import {GLTFExporter}from'three/addons/exporters/GLTFExporter.js';import {USDZExporter}from'three/addons/exporters/USDZExporter.js';import {RoomEnvironment}from'three/addons/environments/RoomEnvironment.js';import {GLTFLoader}from'three/addons/loaders/GLTFLoader.js';var $=typeof window<"u"&&typeof navigator<"u";(()=>{if(!$)return false;let t=navigator.userAgent||navigator.vendor||self.opera,i=false;return (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(t)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(t.substr(0,4)))&&(i=true),i})();var ie=$&&/android/i.test(navigator.userAgent),je=$&&(/iPad|iPhone|iPod/.test(navigator.userAgent)&&!self.MSStream||navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1),mt=$&&/firefox/i.test(navigator.userAgent),ht=$&&/OculusBrowser/.test(navigator.userAgent),He=ie&&!mt&&!ht,Ne=je?"ios":ie?"android":"desktop",gt=$&&!!(window.webkit&&window.webkit.messageHandlers),Xe=(()=>{if(je){if(/KonfigureKiosk\//.test(navigator.userAgent))return true;if(gt)return !!/CriOS\/|EdgiOS\/|GSA\/|DuckDuckGo\//.test(navigator.userAgent);{let t=document.createElement("a");return !!(t.relList&&t.relList.supports&&t.relList.supports("ar"))}}else return false})(),k={QUICK_LOOK:"quick-look",SCENE_VIEWER:"scene-viewer",WEBXR:"webxr",NONE:"none"};var pe="arLaunchFailed",fe=["ar"];function ze(){return typeof location>"u"?new URL("https://localhost/"):new URL(location.href)}a(ze,"currentUrl");function Ke(t=fe){let i=ze();for(let o of t)i.searchParams.delete(o);return i.toString()}a(Ke,"currentUrlWithout");function qe(t=fe){let i=ze();for(let o of t)i.searchParams.delete(o);return i.searchParams.set(pe,"1"),i.toString()}a(qe,"buildFallbackUrl");function Qe(t=fe){if(typeof location>"u"||typeof history>"u")return false;let i=new URL(location.href);if(i.searchParams.get(pe)!=="1")return false;i.searchParams.delete(pe);for(let o of t)i.searchParams.delete(o);return history.replaceState(history.state,"",i.toString()),true}a(Qe,"consumeArLaunchFailureFlag");function $e(t=1500){return new Promise(i=>{if(typeof document>"u"){i(false);return}let o=false,r=a(()=>{document.visibilityState==="hidden"&&a$1(true);},"onVis");function a$1(l){o||(o=true,document.removeEventListener("visibilitychange",r),i(l));}a(a$1,"finish"),document.addEventListener("visibilitychange",r),setTimeout(()=>a$1(false),t);})}a($e,"detectIntentLaunch");function Ye(){return typeof location>"u"?false:new URLSearchParams(location.search).get("arDebugFail")==="true"}a(Ye,"isArDebugFail");function me(t,i={}){let o=document.createElement("a");o.style.display="none",i.quickLook&&(o.setAttribute("rel","ar"),o.appendChild(document.createElement("img"))),o.setAttribute("href",t),document.body.appendChild(o),o.click(),o.remove();}a(me,"launchARAnchor");async function oe(t){let o=await new USDZExporter().parseAsync(t,{ar:{anchoring:{type:"plane"},planeAnchoring:{alignment:"horizontal"}}}),r=new Blob(o?[o]:[],{type:"model/vnd.usdz+zip"}),a$1=URL.createObjectURL(r);return {href:new URL(a$1,self.location.toString()).toString(),revoke:a(()=>URL.revokeObjectURL(a$1),"revoke")}}a(oe,"prepareQuickLook");function Je(t){let i=[],o=new Map;return t.traverse(r=>{let a=r;if(!a.isMesh||a.geometry.getIndex())return;let l=a.geometry,u=o.get(l);if(!u){if(!l.getAttribute("position"))return;u=vt(l),o.set(l,u);}i.push({mesh:a,geometry:l}),a.geometry=u;}),a(function(){for(let{mesh:a,geometry:l}of i)a.geometry=l;for(let a of o.values()){for(let l of Object.keys(a.attributes))a.deleteAttribute(l);a.dispose();}},"restore")}a(Je,"indexGeometriesForExport");function vt(t){let i=new BufferGeometry;i.name=t.name,i.userData=t.userData;for(let[a,l]of Object.entries(t.attributes))i.setAttribute(a,l);i.morphAttributes=t.morphAttributes,i.morphTargetsRelative=t.morphTargetsRelative;for(let{start:a,count:l,materialIndex:u}of t.groups)i.addGroup(a,l,u);i.setDrawRange(t.drawRange.start,t.drawRange.count);let o=t.getAttribute("position").count,r=o>65535?new Uint32Array(o):new Uint16Array(o);for(let a=0;a<o;a++)r[a]=a;return i.setIndex(new BufferAttribute(r,1)),i}a(vt,"withTrivialIndex");async function ae(t){let i=new GLTFExporter,o=Je(t);try{let r=await i.parseAsync(t,{binary:!0});if(!(r instanceof ArrayBuffer))throw new Error("GLTFExporter did not return ArrayBuffer");return r}finally{o();}}a(ae,"exportGLBBuffer");function se(t,i={}){let{version:o="1.0",mode:r="ar_preferred",disableOcclusion:a=true,link:l=Ke(),title:u,extraParams:f}=i,n=self.location?.toString()??"https://localhost/",A=new URL(t,n);A.hash&&(A.hash="");let b=new URLSearchParams(A.search);if(b.set("mode",r),b.set("disable_occlusion",String(a)),l&&b.set("link",l),u&&b.set("title",u),f)for(let[S,R]of Object.entries(f))b.set(S,R);let w=Ye()?"package=com.example.nonexistent;":"";return `intent://arvr.google.com/scene-viewer/${o}?${b.toString()}&file=${encodeURIComponent(A.toString())}#Intent;scheme=https;${w}action=android.intent.action.VIEW;S.browser_fallback_url=${encodeURIComponent(qe())};end;`}a(se,"buildSceneViewerIntentUrl");async function he(t){let i=await ae(t.model),o=new Blob([i],{type:"model/gltf-binary"}),{id:r}=await t.upload(o);return {href:se(r,t.params)}}a(he,"prepareSceneViewer");var we={scanHint:"Point your phone at the floor and move it slowly",placedHint:"Drag to move \xB7 twist with two fingers to rotate",close:"Close AR"},Tt=.9;async function Ze(){if(typeof navigator>"u"||!navigator.xr)return false;try{return await navigator.xr.isSessionSupported("immersive-ar")}catch{return false}}a(Ze,"isWebXRARSupported");function et(){return typeof navigator>"u"?false:navigator.userActivation?.isActive??true}a(et,"hasUserActivation");function tt(t,i=we){let o=typeof navigator<"u"?navigator.xr:void 0;if(!o)return {started:Promise.reject(new Error("WebXR is not available")),ended:Promise.resolve(),end(){}};let r=Promise.resolve(t);r.catch(()=>{});let a$1=Dt(i);document.body.appendChild(a$1.root);let l=o.requestSession("immersive-ar",{requiredFeatures:["hit-test"],optionalFeatures:["dom-overlay"],domOverlay:{root:a$1.root}}),u=null,f=false,n,A=new Promise(S=>n=S);function b(){f=true,u?.end().catch(()=>{});}return a(b,"end"),a$1.onClose=b,{started:(async()=>{try{u=await l;}catch(E){throw a$1.root.remove(),n(),E}let S=null,R=false;u.addEventListener("end",()=>{R=true,S?.dispose(),S=null,a$1.root.remove(),n();}),f&&b();try{let E=await Ut(u,await r,a$1);R?E.dispose():S=E;}catch(E){if(R)return;throw u.end().catch(()=>{}),E}})(),ended:A,end:b}}a(tt,"startWebXRAR");function Dt(t){let i=document.createElement("div");i.setAttribute("data-konfigure-ar-overlay",""),Object.assign(i.style,{position:"fixed",inset:"0",display:"none",background:"transparent",touchAction:"none",userSelect:"none",fontFamily:"system-ui, -apple-system, sans-serif",zIndex:"2147483647"});let o=document.createElement("button");o.type="button",o.setAttribute("aria-label",t.close),o.innerHTML='<svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" aria-hidden="true"><path d="M6 6l12 12M18 6L6 18"/></svg>',Object.assign(o.style,{position:"absolute",top:"max(16px, env(safe-area-inset-top))",right:"16px",width:"48px",height:"48px",border:"none",borderRadius:"50%",background:"rgba(0, 0, 0, 0.55)",color:"#fff",display:"flex",alignItems:"center",justifyContent:"center",padding:"0"});let r=document.createElement("div");r.textContent=t.scanHint,Object.assign(r.style,{position:"absolute",left:"50%",bottom:"calc(32px + env(safe-area-inset-bottom))",transform:"translateX(-50%)",maxWidth:"calc(100% - 32px)",padding:"10px 16px",borderRadius:"999px",background:"rgba(0, 0, 0, 0.6)",color:"#fff",fontSize:"15px",lineHeight:"1.3",textAlign:"center",pointerEvents:"none"}),i.append(o,r);let a$1={root:i,onClose:a(()=>{},"onClose"),show(){i.style.display="block";},setPlaced(){r.textContent=t.placedHint;}};return o.addEventListener("beforexrselect",l=>l.preventDefault()),o.addEventListener("click",()=>a$1.onClose()),a$1}a(Dt,"createOverlay");async function Ft(t,i){let o=typeof XRWebGLBinding<"u"?XRWebGLBinding.prototype:null,r=o?Object.getOwnPropertyDescriptor(o,"createProjectionLayer"):null,a=!!(o&&r?.configurable);a&&delete o.createProjectionLayer;try{await t.xr.setSession(i);}finally{a&&Object.defineProperty(o,"createProjectionLayer",r);}}a(Ft,"setSessionWithoutLayers");async function Ut(t,i,o){let r=new WebGLRenderer({antialias:true,alpha:true});r.setPixelRatio(window.devicePixelRatio),r.outputColorSpace=SRGBColorSpace,r.shadowMap.enabled=true,r.shadowMap.type=PCFSoftShadowMap,r.xr.enabled=true,r.xr.setReferenceSpaceType("local");let a$1=new PMREMGenerator(r),l=a$1.fromScene(new RoomEnvironment,.04).texture;a$1.dispose();let u=new Scene;u.environment=l;let f=new PerspectiveCamera,{model:n,restore:A}=Wt(i,l);n.updateMatrixWorld(true);let b=new Box3().setFromObject(n),w=b.getSize(new Vector3),S=b.getCenter(new Vector3),R=Math.max(w.x,w.z,.2)/2,E=new Group;E.visible=false;let D=new Group,g=new Group;g.position.set(-S.x,-b.min.y,-S.z),g.add(n),D.add(g),E.add(D);let P=new ShadowMaterial({opacity:.3,depthWrite:false}),C=new PlaneGeometry(R*6,R*6);C.rotateX(-Math.PI/2);let y=new Mesh(C,P);y.receiveShadow=true,E.add(y);let p=new DirectionalLight(16777215,1.2);p.position.set(R*.8,Math.max(w.y,1)*2.5,R*1.2),p.castShadow=true,p.shadow.mapSize.set(1024,1024),p.shadow.radius=6,p.shadow.bias=-5e-4;let _=R*2.5;p.shadow.camera.left=-_,p.shadow.camera.right=_,p.shadow.camera.top=_,p.shadow.camera.bottom=-_,p.shadow.camera.near=.05,p.shadow.camera.far=Math.max(w.y,1)*6,E.add(p,p.target),u.add(E);let W,U;function c(){r.setAnimationLoop(null);for(let M of [W,U])try{M?.cancel();}catch{}g.remove(n),A(),C.dispose(),P.dispose(),p.shadow.map?.dispose(),l.dispose(),r.dispose(),r.forceContextLoss();}a(c,"release");try{await Ft(r,t);let M=await t.requestReferenceSpace("viewer");if(W=await t.requestHitTestSource?.({space:M}),!W)throw new Error("WebXR hit testing is not available");U=await t.requestHitTestSourceForTransientInput?.({profile:"generic-touchscreen"})?.catch(()=>{});}catch(M){throw c(),M}let h=W;o.show();let O=false,x=null,F=null,B=null;function Z(M){B===null&&(x=M.inputSource,F=null);}a(Z,"onSelectStart");function ne(M){M.inputSource===x&&(x=null);}a(ne,"onSelectEnd"),t.addEventListener("selectstart",Z),t.addEventListener("selectend",ne);function G(M){let V=M[0],L=M[1];return Math.atan2(L.clientY-V.clientY,L.clientX-V.clientX)}a(G,"touchAngle");function I(M){if(M.touches.length<2){B=null;return}x=null;let V=G(M.touches);if(B!==null){let L=V-B;L>Math.PI&&(L-=Math.PI*2),L<-Math.PI&&(L+=Math.PI*2),D.rotation.y-=L;}B=V;}a(I,"onTouch"),o.root.addEventListener("touchstart",I),o.root.addEventListener("touchmove",I),o.root.addEventListener("touchend",I),o.root.addEventListener("touchcancel",I);let ee=new Vector3,q=new Quaternion,Y=new Vector3;function re(M,V){let L=M?.getPose(V);if(!L)return null;let{position:T,orientation:j}=L.transform;return q.set(j.x,j.y,j.z,j.w),ee.set(0,1,0).applyQuaternion(q),ee.y<Tt?null:Y.set(T.x,T.y,T.z)}return a(re,"floorPoint"),r.setAnimationLoop((M,V)=>{let L=r.xr.getReferenceSpace();if(V&&L)if(O){if(x&&U){let T=V.getHitTestResultsForTransientInput(U),j=T.find(ue=>ue.inputSource===x)??T[0],N=re(j?.results[0],L);N&&(F?E.position.copy(N).add(F):F=E.position.clone().sub(N));}}else {let T=re(V.getHitTestResults(h)[0],L),j=V.getViewerPose(L);if(T&&j){E.position.copy(T);let N=j.transform.position;D.rotation.y=Math.atan2(N.x-T.x,N.z-T.z),E.visible=true,O=true,o.setPlaced();}}r.render(u,f);}),{dispose(){t.removeEventListener("selectstart",Z),t.removeEventListener("selectend",ne),c();}}}a(Ut,"runSession");function Wt(t,i){let o=t.parent?t.clone(true):t,r=new Map,a$1=[];function l(u){let f=r.get(u);if(!f){f=u.clone();let n=f;n.envMap?.isRenderTargetTexture&&(n.envMap=i),r.set(u,f);}return f}return a(l,"adopt"),o.traverse(u=>{let f=u;f.isMesh&&(a$1.push({mesh:f,material:f.material,castShadow:f.castShadow}),f.material=Array.isArray(f.material)?f.material.map(l):l(f.material),f.castShadow=true);}),{model:o,restore(){for(let{mesh:u,material:f,castShadow:n}of a$1)u.material=f,u.castShadow=n;for(let u of r.values())u.dispose();}}}a(Wt,"adoptModel");var ye={quickLook:"AR Quick Look could not be opened. Make sure you are using Safari on iOS 12 or newer, or try another device.",sceneViewer:"This device has no working AR Viewer. Update the Google app from the Play Store, or try another device.",sceneViewerClosed:"Google's AR viewer closed right after opening. Recent Google app updates have a known bug in it - please try again later or on another device.",webxr:"AR could not be started. Make sure Google Play Services for AR is installed and up to date, or try another device.",...we},be=[k.WEBXR,k.SCENE_VIEWER,k.QUICK_LOOK],Gt=6e3;function ot(t,i,o){let r={...ye,...o};return t?r[t]:i===k.QUICK_LOOK?r.quickLook:r.sceneViewer}a(ot,"arFailureMessage");function Se(t){return t!==k.NONE?null:Ne==="desktop"?"device":"browser"}a(Se,"arUnsupportedReason");function ve(t={}){let i=t.uploadEndpoint??"/api/ar/upload-model",o={mode:k.NONE,loading:false,failed:false,failureKind:null,error:null,prepared:null},r=null,a$1=null;function l(c){Object.assign(o,c),t.onChange?.(o);}a(l,"set");function u(){return {...ye,...t.messages?.()}}a(u,"messages");function f(c,h,O){l({failureKind:c,failed:true}),n({type:"failed",mode:h,reason:O});}a(f,"fail");function n(c){try{t.onLaunchEvent?.(c);}catch{}}a(n,"emitLaunchEvent");async function A(){for(let h of t.modes??be){if(h===k.WEBXR&&ie&&await Ze()){l({mode:k.WEBXR});return}if(h===k.SCENE_VIEWER&&He){l({mode:k.SCENE_VIEWER});return}if(h===k.QUICK_LOOK&&Xe){l({mode:k.QUICK_LOOK});return}}let c=navigator;if(c.userAgentData?.getHighEntropyValues)try{let h=await c.userAgentData.getHighEntropyValues(["formFactor"]),O=t.modes??be;if(h.formFactor?.includes("XR")&&O.includes(k.SCENE_VIEWER)){l({mode:k.SCENE_VIEWER});return}}catch{}l({mode:k.NONE});}a(A,"detect");function b(c){return typeof location<"u"?new URL(c,location.href).toString():c}a(b,"absoluteUrl");async function w(c){let h=new FormData;h.append("blob",c,"model.glb");let O=await fetch(i,{method:"POST",body:h});if(!O.ok)throw new Error(`AR model upload failed: ${O.status} ${O.statusText}`);let x=(await O.text()).trim(),F=typeof location<"u"?new URL(i,location.href):void 0;return {id:new URL(x,F).toString()}}a(w,"uploadGLB");async function S(c){return (await new GLTFLoader().loadAsync(c)).scene}a(S,"loadGLB");async function R(c,h){if(c)return await c;if(h)return S(b(h));throw new Error("useAR(): no model source \u2014 pass object, glbUrl, or usdzUrl")}a(R,"resolveModel");async function E(){let c=t.object?.()??null,h=t.glbUrl?.(),O=t.usdzUrl?.();function x(){return R(c,h)}if(a(x,"model"),o.mode===k.WEBXR)return {mode:"webxr",model:await x()};if(o.mode===k.QUICK_LOOK){if(O&&!c)return {mode:"quick-look",href:b(O)};let{href:F,revoke:B}=await oe(await x());return {mode:"quick-look",href:F,revoke:B}}if(o.mode===k.SCENE_VIEWER){if(h&&!c)return {mode:"scene-viewer",href:se(b(h),t.sceneViewerParams)};let{href:F}=await he({model:await x(),upload:w,params:t.sceneViewerParams});return {mode:"scene-viewer",href:F}}return null}a(E,"buildPrepared");async function D(){_(),l({loading:true,error:null});try{return l({prepared:await E()}),!!o.prepared}catch(c){return l({error:c instanceof Error?c.message:String(c)}),false}finally{l({loading:false});}}a(D,"prepare");function g(){let c=o.prepared;return c?c.mode==="webxr"?C(()=>c.model):(p(),me(c.href,{quickLook:c.mode==="quick-look"}),n({type:"attempted",mode:c.mode}),c.mode==="scene-viewer"&&y(),c.mode==="quick-look"&&$e().then(h=>{h?n({type:"succeeded",mode:c.mode}):f("quickLook",c.mode,"quick_look_timeout");}),true):false}a(g,"launchPrepared");async function P(){return o.mode===k.WEBXR?C(()=>R(t.object?.()??null,t.glbUrl?.())):await D()?g():false}a(P,"launch");function C(c){if(!et())return false;if(r)return true;p(),n({type:"attempted",mode:k.WEBXR}),l({loading:true});let h=u(),O=tt(Promise.resolve().then(c),{scanHint:h.scanHint,placedHint:h.placedHint,close:h.close});return r=O,O.started.then(()=>n({type:"succeeded",mode:k.WEBXR}),x=>{l({error:x instanceof Error?x.message:String(x)}),f("webxr",k.WEBXR,x instanceof Error?x.name:"webxr_session_failed");}),O.started.catch(()=>{}).finally(()=>l({loading:false})),O.ended.then(()=>{r===O&&(r=null);}),true}a(C,"startWebXR");function y(){if(typeof document>"u")return;a$1?.();let c=0;function h(){if(document.visibilityState==="hidden"){c=performance.now();return}if(!c)return;let F=performance.now()-c;x(),F<Gt&&f("sceneViewerClosed",k.SCENE_VIEWER,"scene_viewer_closed_early");}a(h,"onVisibility");let O=setTimeout(()=>{c||x();},1e4);function x(){document.removeEventListener("visibilitychange",h),clearTimeout(O),a$1===x&&(a$1=null);}a(x,"stop"),document.addEventListener("visibilitychange",h),a$1=x;}a(y,"watchSceneViewerReturn");function p(){l({failed:false,failureKind:null,error:null});}a(p,"dismissFailure");function _(){o.prepared&&"revoke"in o.prepared&&o.prepared.revoke?.(),l({prepared:null});}a(_,"dispose");function W(){let c=A();return Qe()&&f("sceneViewer",k.SCENE_VIEWER,"scene_viewer_failed"),c}a(W,"start");function U(){_(),a$1?.(),r?.end();}return a(U,"destroy"),{state:o,failureMessage:a(()=>ot(o.failureKind,o.mode,t.messages?.()),"failureMessage"),detect:A,prepare:D,launchPrepared:g,launch:P,dismissFailure:p,dispose:_,start:W,destroy:U}}a(ve,"createARController");var jt=1200;function nt(t){let{settings:i}=t,o=0,r=-1,a$1=null,l,u=false;function f(){let p=t.module();return p?n([p]):null}a(f,"exportObject");let n$1=ve({object:f,uploadEndpoint:i.uploadEndpoint??(t.instance?`${t.instance}/api/ar/upload-model`:void 0),sceneViewerParams:i.title?{title:i.title}:void 0,messages:a(()=>i.messages,"messages"),onChange(p){p.failed&&!u&&p.failureKind&&t.onFailure({kind:p.failureKind,message:n$1.failureMessage()}),u=p.failed,t.onChange();}}),A=n$1.start(),b=a(()=>n$1.state.mode==="quick-look"||n$1.state.mode==="scene-viewer","needsFile");function w(){let p=o;return a$1=n$1.prepare().then(_=>(_&&(r=p),a$1=null,_&&p===o)),a$1}a(w,"prepareNow");let S=false;function R(){clearTimeout(l),!(i.prepareInBackground===false||S)&&(l=setTimeout(()=>{A.then(()=>{S||b()&&r!==o&&!a$1&&w();});},jt));}a(R,"prepareLater");function E(){o++,R();}a(E,"changed");function D(p){S=p,p?clearTimeout(l):r!==o&&R();}a(D,"suspend");async function g(){await A;let p=n$1.state.mode;return {supported:p!=="none",mode:p,reason:Se(p)}}a(g,"support");async function P(){return await A,S?false:b()?r===o&&n$1.state.prepared||(a$1&&await a$1,r===o&&n$1.state.prepared)?true:w():n$1.state.mode!=="none"}a(P,"prepare");function C(){let p=n$1.state.mode;return p==="none"||S?Promise.resolve(false):p==="webxr"?n$1.launch():n$1.state.prepared&&r===o?Promise.resolve(n$1.launchPrepared()):(async()=>await P()?n$1.launchPrepared():false)()}a(C,"start");async function y(p){let _=f();if(!_)throw new Error("Nothing to export yet");if(p==="glb")return new Blob([await ae(_)],{type:"model/gltf-binary"});let{href:W,revoke:U}=await oe(_);try{return await(await fetch(W)).blob()}finally{U();}}return a(y,"exportFile"),{support:g,prepare:P,start:C,exportFile:y,changed:E,suspend:D,state:a(()=>({mode:n$1.state.mode,loading:n$1.state.loading,prepared:!!n$1.state.prepared&&r===o,failed:n$1.state.failed}),"state"),dismissFailure:n$1.dismissFailure,dispose(){clearTimeout(l),n$1.destroy();}}}a(nt,"createViewAR");var it="konfigure-dimension-style",Ht=`
|
|
770
2
|
:where(.kfg-dimensions){position:absolute;inset:0;pointer-events:none;overflow:hidden}
|
|
771
3
|
:where(.kfg-dimensions svg){position:absolute;inset:0;width:100%;height:100%;overflow:visible}
|
|
772
4
|
:where(.kfg-dimension-line){stroke:rgba(0,0,0,.8);stroke-width:2}
|
|
773
5
|
:where(.kfg-dimension-label){position:absolute;border-radius:9999px;background:rgba(0,0,0,.95);color:#fff;padding:.25rem .625rem;font:700 .875rem/1.25rem ui-monospace,SFMono-Regular,Menlo,monospace;white-space:nowrap}
|
|
774
|
-
`,Xi="http://www.w3.org/2000/svg";function Nd(){if(document.getElementById(qi))return;let e=document.createElement("style");e.id=qi,e.textContent=Vd,document.head.appendChild(e);}a(Nd,"injectStyle");function Ki(e){let{host:o,engine:t}=e,n=null,a$1=null,i=0;function s(u){let d=new Box3;for(let v of u.getTrueBoundingBoxes(true))d.union(v);return d.isEmpty()?new Box3().setFromObject(u.moduleGroup):d}a(s,"boxOf");function c(){if(i=requestAnimationFrame(c),!n||!a$1)return;let u=e.module(),d=o.clientWidth,v=o.clientHeight,f=u?_r(s(u),t.camera,d,v):null,S=f?.lines??[];for(;a$1.childNodes.length>S.length;)a$1.lastChild.remove();S.forEach((w,P)=>{let T=a$1.childNodes[P];T||(T=document.createElementNS(Xi,"line"),T.setAttribute("class","kfg-dimension-line"),a$1.appendChild(T)),T.setAttribute("x1",String(w.x1)),T.setAttribute("y1",String(w.y1)),T.setAttribute("x2",String(w.x2)),T.setAttribute("y2",String(w.y2)),T.dataset.axis=w.axis;});let O=f?.labels??[],y=n.querySelectorAll(".kfg-dimension-label");y.forEach((w,P)=>{P>=O.length&&w.remove();}),O.forEach((w,P)=>{let T=y[P];T||(T=document.createElement("div"),T.className="kfg-dimension-label",n.appendChild(T)),T.dataset.axis=w.axis,T.textContent=Ir(w.meters,e.unit),T.style.left=`${w.x}px`,T.style.top=`${w.y}px`,T.style.zIndex=String(w.zIndex),T.style.transform=`translate(-50%, -50%) scale(${w.scale})`;});}a(c,"draw");function l(){n||(Nd(),getComputedStyle(o).position==="static"&&(o.style.position="relative"),n=document.createElement("div"),n.className="kfg-dimensions",n.setAttribute("aria-hidden","true"),a$1=document.createElementNS(Xi,"svg"),n.appendChild(a$1),o.appendChild(n),c());}a(l,"show");function p(){cancelAnimationFrame(i),n?.remove(),n=null,a$1=null;}return a(p,"hide"),{set(u){u?l():p();},visible:a(()=>n!==null,"visible"),dispose:p}}a(Ki,"createDimensions");var Yi={front:"Front",back:"Back",left:"Left",right:"Right",top:"Top",isometric:"Isometric"};function $i(e,o){if(!o)return e;let t=new AbortController,n=a(()=>t.abort(),"abort");return (o.aborted||e.aborted)&&n(),o.addEventListener("abort",n,{once:true}),e.addEventListener("abort",n,{once:true}),t.signal}a($i,"linked");function Qi(e){let o=null;function t(n={}){if(e.disposed())throw new a$2("not_ready","The view was disposed");if(o)throw new a$2("studio_open","A photo studio is already open on this view; dispose() it before opening another");let a$1=e.module();if(!a$1)throw new a$2("not_ready","The view has nothing drawn yet; await view.whenReady() first");let i=e.hold(),s;try{s=wr({scene:e.engine.scene,renderer:e.engine.renderer,modules:[a$1],product:[a$1.moduleGroup],labels:{...Yi,...n.labels}});}catch(d){throw i(),d}let c=new AbortController,l=false;function p(){if(l)throw new a$2("studio_closed","This photo studio was disposed; open a new one")}a(p,"check");let u={get canPathTrace(){return s.canPathTrace},preview(d,v,f){return p(),s.preview(d,v,f)},async refine(d,v,f){return p(),s.refine(d,v,{...f,signal:$i(c.signal,f.signal)})},async capture(d){return p(),s.capture({...d,signal:$i(c.signal,d.signal)})},dispose(){if(!l){l=true,o=null,c.abort();try{s.dispose();}finally{i();}}}};return o=u,u}return a(t,"openStudio"),{openStudio:t,isOpen:a(()=>o!==null,"isOpen"),dispose:a(()=>o?.dispose(),"dispose")}}a(Qi,"createStudioHost");var jd=35.714285714285715;function Zi(e){if(!(!e||e<=0))return jd/e}a(Zi,"textureRepeatForImageSize");var bo={turn:"open",tilt:"tilt"},Ji=Object.keys(bo),Hd="https://www.gstatic.com/draco/versioned/decoders/1.5.7/",qd={front:[0,.08,1],threeQuarter:[.6,.22,1],left:[-0.8,.12,1],right:[.8,.12,1],top:[0,1,.35],back:[0,.08,-1]},Xd=.6,Kd=1.5;function $d(e){let o=e.textureJson;if(!o)return {};if(typeof o=="object")return o;try{return JSON.parse(o)}catch{return {}}}a($d,"textureOptions");function es(e,o=new Set){function t(n){if(n){n.surfaceId!==void 0&&o.add(n.surfaceId);for(let a of Object.values(n.nestedSlots))t(a);}}a(t,"walk");for(let n of Object.values(e.basePartSlots))t(n);for(let n of Object.values(e.children))es(n,o);return o}a(es,"surfaceIdsOf");async function Zb(e,o,t={}){Pr(t.dracoDecoderPath??Hd);let{catalog:n}=o,a$1=!(e instanceof HTMLCanvasElement),i=a$1?document.createElement("canvas"):e;a$1&&(i.style.display="block",i.style.width="100%",i.style.height="100%",e.appendChild(i));let s=a(()=>({width:Math.max(1,e.clientWidth),height:Math.max(1,e.clientHeight)}),"sizeOf"),c=t.scenePreset??n.productLine.scenePreset??null,l=or(i,{...s(),colorMode:t.colorMode??"light",scenePreset:c});t.background&&l.setSceneColor(t.background),l.controls.enabled=t.interactive??true,l.controls.autoRotate=t.autoRotate??false,l.controls.addEventListener("start",()=>{l.controls.autoRotate=false;});let p=c==="wall"||String(c).includes("wall"),u=p&&(t.wall??true);l.setWallVisible(u),l.setWallSurround({side:4,top:1.5}),l.setFloorVisible(t.floor??(!p||u)),l.start();let d=false,v=null,f=a(()=>d?v:l.scene.environment,"environment"),S=new Map(n.surfaces.map(I=>[I.id,I])),O=new Map,y=new Map;function w(I){let X=y.get(I);if(X)return X;let $=S.get(I),re=(async()=>{if(!$)return;let Z=$d($),be=(typeof Z.repeat=="number"?Z.repeat:void 0)??Zi($.imageSizeCm)??1,L=a(K=>typeof Z[K]=="string"?Z[K]:void 0,"path");try{let K=await Or({map:$.texturePath??void 0,normalMap:L("normalPath"),roughnessMap:L("roughnessPath"),metalnessMap:L("metalnessPath"),aoMap:L("aoPath")},{repeat:be,anisotropy:l.renderer.capabilities.getMaxAnisotropy()});O.set(I,mo(Z,K,f()));}catch(K){console.warn(`[konfigure] finish ${I} textures failed; drawing its colour`,K),O.set(I,mo(Z,{},f()));}})();return y.set(I,re),re}a(w,"loadMaterial");let P=Er({catalog:n,createSurfaceMaterial:a(I=>O.get(I.id)??null,"createSurfaceMaterial"),invalidate:a(()=>l.invalidate(),"invalidate")});function T(I,X){if(!I.hasConfigurableSurface||X===void 0)return;let $=P.getSurface(X);$&&(I.model.traverse(re=>{let Z=re;Z.isMesh&&Z.userData.hasConfigurableSurface&&(Z.material=$);}),I.material=$,I.surfaceId=X);}a(T,"paint");function R(I,X){for(let[$,re]of Object.entries(X.nestedSlots)){let Z=I.partSlots?.[$];if(Z){if(!re){Z.part&&I.partGroup.remove(Z.part.partGroup),Z.part=void 0;continue}if(Z.part?.apiPartId!==re.apiPartId){let be=Z.compatibleParts?.find(K=>K.apiPartId===re.apiPartId);if(!be)continue;Z.part&&I.partGroup.remove(Z.part.partGroup);let L=be.createPart();I.partGroup.add(L.partGroup),Z.part=L;}T(Z.part,re.surfaceId),R(Z.part,re);}}}a(R,"applyNested");function z(I,X){for(let[$,re]of Object.entries(X.basePartSlots)){let Z=I.basePartSlots[$];if(Z){if(Z.part?.apiPartId!==re.apiPartId){let be=Z.compatibleParts?.find(K=>K.apiPartId===re.apiPartId);if(!be)continue;let L=be.createPart();Z.part&&I.moduleGroup.remove(Z.part.partGroup),I.moduleGroup.add(L.partGroup),Z.part=L;}Z.part.partGroup.scale.z=X.invertedSlots[$]?-1:1,Z.part.partGroup.rotation.y=X.rotatedSlots[$]?Math.PI:0,T(Z.part,re.surfaceId),R(Z.part,re);}}Je(I.moduleGroup,true,true),I.moduleGroup.userData.updateBoundingBoxes?.();}a(z,"applyState");function g(I){if(!p)return;let X,$;for(let re of Object.values(I.basePartSlots))X??=re.part?.wallThickness??void 0,$===void 0&&re.part?.wallPositionOffset!==void 0&&($=re.part.wallPositionOffset);l.setWallThickness(X),l.setWallPositionOffset($),l.updateLighting(),l.updateWallMesh();}a(g,"syncWall");let x=null,M=t.camera??"front";function E(I){let{camera:X,controls:$}=l,re=I.getSize(new Vector3),Z=Math.max(re.x,re.y,re.z),be=X.fov*Math.PI/180,L=Z/2/Math.tan(be/2);$.minDistance=Math.min($.minDistance,Z*.6);let K=Math.max(L,L/X.aspect)*Kd;return Math.max(K,$.minDistance)}a(E,"fitDistance");function G(I){if(I.isEmpty()||!W.visible())return I;let X=Be*3,$=I.clone();return $.min.x-=X,$.max.x+=X,$.min.z-=X,$.max.z+=X,$.min.y-=X,$}a(G,"framing");let V=0;function C(I=M){if(!x)return;V++,M=I;let X=G(new Box3().setFromObject(x.moduleGroup));if(X.isEmpty())return;let{camera:$,controls:re}=l,Z=X.getCenter(new Vector3),be=new Vector3(...qd[I]).normalize(),L=E(X);re.target.copy(Z),$.position.copy(Z).addScaledVector(be,L),$.updateProjectionMatrix(),re.update(),l.invalidate();}a(C,"frame");function U(I){if(I.isEmpty())return;let{camera:X,controls:$}=l,re=X.position.clone().sub($.target),Z=re.length();if(Z===0)return;re.divideScalar(Z);let be=X.position.clone(),L=$.target.clone(),K=I.getCenter(new Vector3),ee=K.clone().addScaledVector(re,E(I)),ae=++V,se,me=a(ge=>{if(ae!==V||Se)return;se??=ge;let fe=Math.min(1,(ge-se)/(Xd*1e3)),le=fe<.5?2*fe*fe:1-(-2*fe+2)**2/2;X.position.lerpVectors(be,ee,le),$.target.lerpVectors(L,K,le),$.update(),l.invalidate(),fe<1&&requestAnimationFrame(me);},"step");requestAnimationFrame(me);}a(U,"frameBounds");let N=new Map;function H(I,X){for(let $ of N.get(I)??[])try{$(X);}catch(re){console.error(`[konfigure] ${I} listener failed`,re);}}a(H,"emit");let j=Dr({roots:a(()=>x?[x.moduleGroup]:[],"roots"),reducedMotion:a(()=>d||typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches,"reducedMotion"),onPose:a(()=>{x?.moduleGroup.userData.updateBoundingBoxes?.(),l.invalidate();},"onPose"),onSettle:a(()=>B.changed(),"onSettle"),onFrame:a(I=>U(G(I)),"onFrame"),onChange:a(()=>k(),"onChange")});function _(I){return Ji.find(X=>bo[X]===I)??"closed"}a(_,"modeOfClip");let m="closed";function k(){let I=_(j.target());I!==m&&(m=I,H("open",I));}a(k,"emitOpen");function b(){let I=j.available();return Ji.filter(X=>I.includes(bo[X]))}a(b,"openModes");let A="";function h(){let I=b(),X=I.join(",");X!==A&&(A=X,H("openmodes",I));}a(h,"emitOpenModes");let W=Ki({host:a$1?e:i.parentElement??e,engine:l,module:a(()=>x,"module"),unit:t.dimensionUnit??"mm"}),B=ji({module:a(()=>x,"module"),instance:o.instance,settings:t.ar??{},onFailure:a(I=>H("arfailure",I),"onFailure"),onChange:a(()=>{let I=B.state();H("ar",{mode:I.mode,loading:I.loading,prepared:I.prepared});},"onChange")});function Y(I){I!==W.visible()&&(W.set(I),x&&U(G(new Box3().setFromObject(x.moduleGroup))));}a(Y,"showDimensions");let Q=null,q=false;function ne(){j.settle(),V++;let{camera:I,controls:X}=l,$={position:I.position.clone(),target:X.target.clone(),zoom:I.zoom,enabled:X.enabled,autoRotate:X.autoRotate,dimensions:W.visible()};return q=$.dimensions,v=l.scene.environment,d=true,W.set(false),X.enabled=false,X.autoRotate=false,l.setPaused(true),B.suspend(true),()=>{if(d=false,v=null,I.position.copy($.position),I.zoom=$.zoom,I.updateProjectionMatrix(),X.target.copy($.target),X.enabled=$.enabled,X.autoRotate=$.autoRotate,X.update(),l.setPaused(false),Se)return;W.set($.dimensions),Y(q),B.suspend(false);let re=Q;Q=null,re&&ue(re),l.invalidate();}}a(ne,"holdForStudio");let oe=Qi({engine:l,module:a(()=>x,"module"),disposed:a(()=>Se,"disposed"),hold:ne}),ce=0,Se=false,ie=Promise.resolve();async function ct(I){let X=++ce,$=I.rootModule;if(!$){x&&(l.scene.remove(x.moduleGroup),Dt(x.moduleGroup)),x=null,l.invalidate();return}let re=new Set;for(let ee of n.parts)for(let ae of ee.models)ae.fixedSurfaceId&&re.add(ae.fixedSurfaceId);await Promise.all([...es($),...re].map(ee=>w(ee)));let Z=await P.createModuleById($.apiModuleId);if(X!==ce||Se)return;if(d){Q=I;return}if(z(Z,$),$.size){let ee=zr(Z.moduleGroup,$.size);ee&&(Z.size=ee,Z.sizes={...Z.sizes,x:ee.width/1e3}),Z.moduleGroup.userData.updateBoundingBoxes?.();}let be=a(ee=>ee?.size?`${ee.size.width}x${ee.size.height}`:"","sizeKey"),L=!x||x.apiModuleId!==Z.apiModuleId,K=!L&&be(x)!==be(Z);x&&(l.scene.remove(x.moduleGroup),Dt(x.moduleGroup)),l.scene.add(Z.moduleGroup),x=Z,g(Z),j.reapply()||j.forget(),h(),L?C():K&&U(G(new Box3().setFromObject(Z.moduleGroup))),B.changed(),l.invalidate();}a(ct,"rebuild");function ue(I){return ie=ct(I).catch(X=>{t.onError?t.onError(X):console.error("[konfigure] view rebuild failed",X);}),ie}a(ue,"schedule");let ut=o.on("change",({state:I})=>{d?Q=I:ue(I);}),dt=new ResizeObserver(()=>{let{width:I,height:X}=s();l.setSize(I,X),l.invalidate();});return dt.observe(e),t.dimensions&&W.set(true),await ue(o.toJSON()),{whenReady:a(()=>ie,"whenReady"),setCamera(I){C(I);},on(I,X){let $=N.get(I);return $||N.set(I,$=new Set),$.add(X),()=>{$.delete(X);}},openModes:b,openState:a(()=>_(j.target()),"openState"),async setOpen(I){if(d)throw new a$2("studio_open","The window can not move while a photo studio is open; set it before openStudio()");if(I==="closed")return j.rest();if(b().includes(I))return j.setPose(bo[I],true)},setDimensions(I){d?q=I:Y(I);},dimensionsVisible:a(()=>d?q:W.visible(),"dimensionsVisible"),openStudio:a(I=>oe.openStudio(I),"openStudio"),studioOpen:a(()=>oe.isOpen(),"studioOpen"),arSupport:a(()=>B.support(),"arSupport"),prepareAR:a(()=>B.prepare(),"prepareAR"),startAR:a(()=>B.start(),"startAR"),exportModel:a(I=>B.exportFile(I),"exportModel"),capture(){return l.renderNow(),l.renderer.domElement.toDataURL("image/png")},engine:l,dispose(){Se=true,oe.dispose(),ut(),j.forget(),W.dispose(),B.dispose(),N.clear(),dt.disconnect(),x&&(l.scene.remove(x.moduleGroup),Dt(x.moduleGroup)),x=null,l.dispose();for(let I of O.values())I.dispose();a$1&&i.remove();}}}a(Zb,"mountView");/* @license
|
|
6
|
+
`,at="http://www.w3.org/2000/svg";function Nt(){if(document.getElementById(it))return;let t=document.createElement("style");t.id=it,t.textContent=Ht,document.head.appendChild(t);}a(Nt,"injectStyle");function st(t){let{host:i,engine:o}=t,r=null,a$1=null,l=0;function u(b){let w=new Box3;for(let S of b.getTrueBoundingBoxes(true))w.union(S);return w.isEmpty()?new Box3().setFromObject(b.moduleGroup):w}a(u,"boxOf");function f(){if(l=requestAnimationFrame(f),!r||!a$1)return;let b=t.module(),w=i.clientWidth,S=i.clientHeight,R=b?q(u(b),o.camera,w,S):null,E=R?.lines??[];for(;a$1.childNodes.length>E.length;)a$1.lastChild.remove();E.forEach((P,C)=>{let y=a$1.childNodes[C];y||(y=document.createElementNS(at,"line"),y.setAttribute("class","kfg-dimension-line"),a$1.appendChild(y)),y.setAttribute("x1",String(P.x1)),y.setAttribute("y1",String(P.y1)),y.setAttribute("x2",String(P.x2)),y.setAttribute("y2",String(P.y2)),y.dataset.axis=P.axis;});let D=R?.labels??[],g=r.querySelectorAll(".kfg-dimension-label");g.forEach((P,C)=>{C>=D.length&&P.remove();}),D.forEach((P,C)=>{let y=g[C];y||(y=document.createElement("div"),y.className="kfg-dimension-label",r.appendChild(y)),y.dataset.axis=P.axis,y.textContent=p(P.meters,t.unit),y.style.left=`${P.x}px`,y.style.top=`${P.y}px`,y.style.zIndex=String(P.zIndex),y.style.transform=`translate(-50%, -50%) scale(${P.scale})`;});}a(f,"draw");function n(){r||(Nt(),getComputedStyle(i).position==="static"&&(i.style.position="relative"),r=document.createElement("div"),r.className="kfg-dimensions",r.setAttribute("aria-hidden","true"),a$1=document.createElementNS(at,"svg"),r.appendChild(a$1),i.appendChild(r),f());}a(n,"show");function A(){cancelAnimationFrame(l),r?.remove(),r=null,a$1=null;}return a(A,"hide"),{set(b){b?n():A();},visible:a(()=>r!==null,"visible"),dispose:A}}a(st,"createDimensions");var ct={front:"Front",back:"Back",left:"Left",right:"Right",top:"Top",isometric:"Isometric"};function lt(t,i){if(!i)return t;let o=new AbortController,r=a(()=>o.abort(),"abort");return (i.aborted||t.aborted)&&r(),i.addEventListener("abort",r,{once:true}),t.addEventListener("abort",r,{once:true}),o.signal}a(lt,"linked");function dt(t){let i=null;function o(r={}){if(t.disposed())throw new a$1("not_ready","The view was disposed");if(i)throw new a$1("studio_open","A photo studio is already open on this view; dispose() it before opening another");let a$2=t.module();if(!a$2)throw new a$1("not_ready","The view has nothing drawn yet; await view.whenReady() first");let l=t.hold(),u;try{u=j({scene:t.engine.scene,renderer:t.engine.renderer,modules:[a$2],product:[a$2.moduleGroup],labels:{...ct,...r.labels}});}catch(w){throw l(),w}let f=new AbortController,n=false;function A(){if(n)throw new a$1("studio_closed","This photo studio was disposed; open a new one")}a(A,"check");let b={get canPathTrace(){return u.canPathTrace},preview(w,S,R){return A(),u.preview(w,S,R)},async refine(w,S,R){return A(),u.refine(w,S,{...R,signal:lt(f.signal,R.signal)})},async capture(w){return A(),u.capture({...w,signal:lt(f.signal,w.signal)})},dispose(){if(!n){n=true,i=null,f.abort();try{u.dispose();}finally{l();}}}};return i=b,b}return a(o,"openStudio"),{openStudio:o,isOpen:a(()=>i!==null,"isOpen"),dispose:a(()=>i?.dispose(),"dispose")}}a(dt,"createStudioHost");var de={turn:"open",tilt:"tilt"},ut=Object.keys(de),Xt="https://www.gstatic.com/draco/versioned/decoders/1.5.7/",zt={front:[0,.08,1],threeQuarter:[.6,.22,1],left:[-0.8,.12,1],right:[.8,.12,1],top:[0,1,.35],back:[0,.08,-1]},Kt=.6,qt=1.5;async function Xo(t,i,o$1={}){k$1(o$1.dracoDecoderPath??Xt);let{catalog:r$1}=i,a$2=!(t instanceof HTMLCanvasElement),l=a$2?document.createElement("canvas"):t;a$2&&(l.style.display="block",l.style.width="100%",l.style.height="100%",t.appendChild(l));let u=a(()=>({width:Math.max(1,t.clientWidth),height:Math.max(1,t.clientHeight)}),"sizeOf"),f=o$1.scenePreset??r$1.productLine.scenePreset??null,n=c(l,{...u(),colorMode:o$1.colorMode??"light",scenePreset:f});o$1.background&&n.setSceneColor(o$1.background),n.controls.enabled=o$1.interactive??true,n.controls.autoRotate=o$1.autoRotate??false,n.controls.addEventListener("start",()=>{n.controls.autoRotate=false;});let A=f==="wall"||String(f).includes("wall"),b=A&&(o$1.wall??true);n.setWallVisible(b),n.setWallSurround({side:4,top:1.5}),n.setFloorVisible(o$1.floor??(!A||b)),n.start();let w=false,S=null,R=a(()=>w?S:n.scene.environment,"environment"),E=s({catalog:r$1,anisotropy:n.renderer.capabilities.getMaxAnisotropy(),environment:R,invalidate:a(()=>n.invalidate(),"invalidate")});function D(s){if(!A)return;let d,m;for(let v of Object.values(s.basePartSlots))d??=v.part?.wallThickness??void 0,m===void 0&&v.part?.wallPositionOffset!==void 0&&(m=v.part.wallPositionOffset);n.setWallThickness(d),n.setWallPositionOffset(m),n.updateLighting(),n.updateWallMesh();}a(D,"syncWall");let g=null,P=o$1.camera??"front";function C(s){let{camera:d,controls:m}=n,v=s.getSize(new Vector3),H=Math.max(v.x,v.y,v.z),X=d.fov*Math.PI/180,z=H/2/Math.tan(X/2);m.minDistance=Math.min(m.minDistance,H*.6);let K=Math.max(z,z/d.aspect)*qt;return Math.max(K,m.minDistance)}a(C,"fitDistance");function y(s){if(s.isEmpty()||!G.visible())return s;let d=o*3,m=s.clone();return m.min.x-=d,m.max.x+=d,m.min.z-=d,m.max.z+=d,m.min.y-=d,m}a(y,"framing");let p=0;function _(s=P){if(!g)return;p++,P=s;let d=y(new Box3().setFromObject(g.moduleGroup));if(d.isEmpty())return;let{camera:m,controls:v}=n,H=d.getCenter(new Vector3),X=new Vector3(...zt[s]).normalize(),z=C(d);v.target.copy(H),m.position.copy(H).addScaledVector(X,z),m.updateProjectionMatrix(),v.update(),n.invalidate();}a(_,"frame");function W(s){if(s.isEmpty())return;let{camera:d,controls:m}=n,v=d.position.clone().sub(m.target),H=v.length();if(H===0)return;v.divideScalar(H);let X=d.position.clone(),z=m.target.clone(),K=s.getCenter(new Vector3),pt=K.clone().addScaledVector(v,C(s)),ft=++p,Ee,xe=a(Pe=>{if(ft!==p||L)return;Ee??=Pe;let te=Math.min(1,(Pe-Ee)/(Kt*1e3)),Oe=te<.5?2*te*te:1-(-2*te+2)**2/2;d.position.lerpVectors(X,pt,Oe),m.target.lerpVectors(z,K,Oe),m.update(),n.invalidate(),te<1&&requestAnimationFrame(xe);},"step");requestAnimationFrame(xe);}a(W,"frameBounds");let U=new Map;function c$1(s,d){for(let m of U.get(s)??[])try{m(d);}catch(v){console.error(`[konfigure] ${s} listener failed`,v);}}a(c$1,"emit");let h=m({roots:a(()=>g?[g.moduleGroup]:[],"roots"),reducedMotion:a(()=>w||typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches,"reducedMotion"),onPose:a(()=>{g?.moduleGroup.userData.updateBoundingBoxes?.(),n.invalidate();},"onPose"),onSettle:a(()=>I.changed(),"onSettle"),onFrame:a(s=>W(y(s)),"onFrame"),onChange:a(()=>F(),"onChange")});function O(s){return ut.find(d=>de[d]===s)??"closed"}a(O,"modeOfClip");let x="closed";function F(){let s=O(h.target());s!==x&&(x=s,c$1("open",s));}a(F,"emitOpen");function B(){let s=h.available();return ut.filter(d=>s.includes(de[d]))}a(B,"openModes");let Z="";function ne(){let s=B(),d=s.join(",");d!==Z&&(Z=d,c$1("openmodes",s));}a(ne,"emitOpenModes");let G=st({host:a$2?t:l.parentElement??t,engine:n,module:a(()=>g,"module"),unit:o$1.dimensionUnit??"mm"}),I=nt({module:a(()=>g,"module"),instance:i.instance,settings:o$1.ar??{},onFailure:a(s=>c$1("arfailure",s),"onFailure"),onChange:a(()=>{let s=I.state();c$1("ar",{mode:s.mode,loading:s.loading,prepared:s.prepared});},"onChange")});function ee(s){s!==G.visible()&&(G.set(s),g&&W(y(new Box3().setFromObject(g.moduleGroup))));}a(ee,"showDimensions");let q=null,Y=false;function re(){h.settle(),p++;let{camera:s,controls:d}=n,m={position:s.position.clone(),target:d.target.clone(),zoom:s.zoom,enabled:d.enabled,autoRotate:d.autoRotate,dimensions:G.visible()};return Y=m.dimensions,S=n.scene.environment,w=true,G.set(false),d.enabled=false,d.autoRotate=false,n.setPaused(true),I.suspend(true),()=>{if(w=false,S=null,s.position.copy(m.position),s.zoom=m.zoom,s.updateProjectionMatrix(),d.target.copy(m.target),d.enabled=m.enabled,d.autoRotate=m.autoRotate,d.update(),n.setPaused(false),L)return;G.set(m.dimensions),ee(Y),I.suspend(false);let v=q;q=null,v&&N(v),n.invalidate();}}a(re,"holdForStudio");let M=dt({engine:n,module:a(()=>g,"module"),disposed:a(()=>L,"disposed"),hold:re}),V=0,L=false,T=Promise.resolve();async function j(s){let d=++V,m=s.rootModule;if(!m){g&&(n.scene.remove(g.moduleGroup),r(g.moduleGroup)),g=null,n.invalidate();return}let v=await E.build(m);if(d!==V||L){r(v.moduleGroup);return}if(w){r(v.moduleGroup),q=s;return}let H=a(K=>K?.size?`${K.size.width}x${K.size.height}`:"","sizeKey"),X=!g||g.apiModuleId!==v.apiModuleId,z=!X&&H(g)!==H(v);g&&(n.scene.remove(g.moduleGroup),r(g.moduleGroup)),n.scene.add(v.moduleGroup),g=v,D(v),h.reapply()||h.forget(),ne(),X?_():z&&W(y(new Box3().setFromObject(v.moduleGroup))),I.changed(),n.invalidate();}a(j,"rebuild");function N(s){return T=j(s).catch(d=>{o$1.onError?o$1.onError(d):console.error("[konfigure] view rebuild failed",d);}),T}a(N,"schedule");let ue=i.on("change",({state:s})=>{w?q=s:N(s);}),Ae=new ResizeObserver(()=>{let{width:s,height:d}=u();n.setSize(s,d),n.invalidate();});return Ae.observe(t),o$1.dimensions&&G.set(true),await N(i.toJSON()),{whenReady:a(()=>T,"whenReady"),setCamera(s){_(s);},on(s,d){let m=U.get(s);return m||U.set(s,m=new Set),m.add(d),()=>{m.delete(d);}},openModes:B,openState:a(()=>O(h.target()),"openState"),async setOpen(s){if(w)throw new a$1("studio_open","The window can not move while a photo studio is open; set it before openStudio()");if(s==="closed")return h.rest();if(B().includes(s))return h.setPose(de[s],true)},setDimensions(s){w?Y=s:ee(s);},dimensionsVisible:a(()=>w?Y:G.visible(),"dimensionsVisible"),openStudio:a(s=>M.openStudio(s),"openStudio"),studioOpen:a(()=>M.isOpen(),"studioOpen"),arSupport:a(()=>I.support(),"arSupport"),prepareAR:a(()=>I.prepare(),"prepareAR"),startAR:a(()=>I.start(),"startAR"),exportModel:a(s=>I.exportFile(s),"exportModel"),capture(){return n.renderNow(),n.renderer.domElement.toDataURL("image/png")},engine:n,dispose(){L=true,M.dispose(),ue(),h.forget(),G.dispose(),I.dispose(),U.clear(),Ae.disconnect(),g&&(n.scene.remove(g.moduleGroup),r(g.moduleGroup)),g=null,n.dispose(),E.dispose(),a$2&&l.remove();}}}a(Xo,"mountView");/* @license
|
|
775
7
|
* Copyright 2019 Google LLC. All Rights Reserved.
|
|
776
8
|
* Licensed under the Apache License, Version 2.0 (the 'License');
|
|
777
9
|
* you may not use this file except in compliance with the License.
|
|
@@ -784,18 +16,4 @@ diffuseColor.a *= 1.0 - smoothstep(fadeRange.x, fadeRange.y, fromFootprint());`)
|
|
|
784
16
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
785
17
|
* See the License for the specific language governing permissions and
|
|
786
18
|
* limitations under the License.
|
|
787
|
-
*/
|
|
788
|
-
/* @license
|
|
789
|
-
* Original neutral environment data from Google's <model-viewer> project.
|
|
790
|
-
* Copyright 2021 Google LLC. All Rights Reserved.
|
|
791
|
-
* Licensed under the Apache License, Version 2.0 (the 'License');
|
|
792
|
-
* you may obtain a copy of the License at
|
|
793
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
794
|
-
*/
|
|
795
|
-
/* @license
|
|
796
|
-
* Original neutral environment scene from Google's <model-viewer> project.
|
|
797
|
-
* Copyright 2021 Google LLC. All Rights Reserved.
|
|
798
|
-
* Licensed under the Apache License, Version 2.0 (the 'License');
|
|
799
|
-
* you may obtain a copy of the License at
|
|
800
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
801
|
-
*/export{Yi as DEFAULT_PHOTO_LABELS,Sr as PHOTO_ANGLES,ar as PHOTO_SETUPS,nr as PHOTO_SETUP_IDS,lr as PHOTO_SHOT_PRESET_NAMES,ir as clonePhotoSetup,Zb as mountView};
|
|
19
|
+
*/export{ct as DEFAULT_PHOTO_LABELS,Xo as mountView};
|