@splinetool/runtime 0.6.14 → 0.6.15
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/build/runtime.js +1 -1
- package/package.json +1 -1
package/build/runtime.js
CHANGED
|
@@ -4390,6 +4390,6 @@ vec2 coord=(uv-center)*vec2(offset);color=mix(color,vec3(1.0-darkness),dot(coord
|
|
|
4390
4390
|
#else
|
|
4391
4391
|
float d=distance(uv,center);color*=smoothstep(0.8,offset*0.799,d*(darkness+offset));
|
|
4392
4392
|
#endif
|
|
4393
|
-
outputColor=vec4(color,inputColor.a);}`,AM=class extends Mr{constructor(r={}){let e=Object.assign({blendFunction:ut.NORMAL,eskil:!1,offset:.5,darkness:.5},r);super("VignetteEffect",bF,{blendFunction:e.blendFunction,uniforms:new Map([["offset",new Ae(e.offset)],["darkness",new Ae(e.darkness)]])});this.eskil=e.eskil}get eskil(){return this.defines.has("ESKIL")}set eskil(r){this.eskil!==r&&(r?this.defines.set("ESKIL","1"):this.defines.delete("ESKIL"),this.setChanged())}},j$=[new Float32Array(3),new Float32Array(3)],W$=[new Float32Array(3),new Float32Array(3),new Float32Array(3),new Float32Array(3)],J$=[[new Float32Array([0,0,0]),new Float32Array([1,0,0]),new Float32Array([1,1,0]),new Float32Array([1,1,1])],[new Float32Array([0,0,0]),new Float32Array([1,0,0]),new Float32Array([1,0,1]),new Float32Array([1,1,1])],[new Float32Array([0,0,0]),new Float32Array([0,0,1]),new Float32Array([1,0,1]),new Float32Array([1,1,1])],[new Float32Array([0,0,0]),new Float32Array([0,1,0]),new Float32Array([1,1,0]),new Float32Array([1,1,1])],[new Float32Array([0,0,0]),new Float32Array([0,1,0]),new Float32Array([0,1,1]),new Float32Array([1,1,1])],[new Float32Array([0,0,0]),new Float32Array([0,0,1]),new Float32Array([0,1,1]),new Float32Array([1,1,1])]];var X$=[new Float32Array(2),new Float32Array(2)];var q$=new Float32Array([0,-.25,.25,-.125,.125,-.375,.375]),Y$=[new Float32Array([0,0]),new Float32Array([.25,-.25]),new Float32Array([-.25,.25]),new Float32Array([.125,-.125]),new Float32Array([-.125,.125])],K$=[new Uint8Array([0,0]),new Uint8Array([3,0]),new Uint8Array([0,3]),new Uint8Array([3,3]),new Uint8Array([1,0]),new Uint8Array([4,0]),new Uint8Array([1,3]),new Uint8Array([4,3]),new Uint8Array([0,1]),new Uint8Array([3,1]),new Uint8Array([0,4]),new Uint8Array([3,4]),new Uint8Array([1,1]),new Uint8Array([4,1]),new Uint8Array([1,4]),new Uint8Array([4,4])],Q$=[new Uint8Array([0,0]),new Uint8Array([1,0]),new Uint8Array([0,2]),new Uint8Array([1,2]),new Uint8Array([2,0]),new Uint8Array([3,0]),new Uint8Array([2,2]),new Uint8Array([3,2]),new Uint8Array([0,1]),new Uint8Array([1,1]),new Uint8Array([0,3]),new Uint8Array([1,3]),new Uint8Array([2,1]),new Uint8Array([3,1]),new Uint8Array([2,3]),new Uint8Array([3,3])];var Z$=new Map([[Hn(0,0,0,0),new Float32Array([0,0,0,0])],[Hn(0,0,0,1),new Float32Array([0,0,0,1])],[Hn(0,0,1,0),new Float32Array([0,0,1,0])],[Hn(0,0,1,1),new Float32Array([0,0,1,1])],[Hn(0,1,0,0),new Float32Array([0,1,0,0])],[Hn(0,1,0,1),new Float32Array([0,1,0,1])],[Hn(0,1,1,0),new Float32Array([0,1,1,0])],[Hn(0,1,1,1),new Float32Array([0,1,1,1])],[Hn(1,0,0,0),new Float32Array([1,0,0,0])],[Hn(1,0,0,1),new Float32Array([1,0,0,1])],[Hn(1,0,1,0),new Float32Array([1,0,1,0])],[Hn(1,0,1,1),new Float32Array([1,0,1,1])],[Hn(1,1,0,0),new Float32Array([1,1,0,0])],[Hn(1,1,0,1),new Float32Array([1,1,0,1])],[Hn(1,1,1,0),new Float32Array([1,1,1,0])],[Hn(1,1,1,1),new Float32Array([1,1,1,1])]]);function ag(r,e,t){return r+(e-r)*t}function Hn(r,e,t,n){let i=ag(r,e,1-.25),s=ag(t,n,1-.25);return ag(i,s,1-.125)}var _M=class extends fn{load(r=()=>{},e=null){arguments.length===4?(r=arguments[1],e=arguments[3]):(arguments.length===3||typeof arguments[0]!="function")&&(r=arguments[1],e=null);let t=this.manager,n=new yo;return new Promise((i,s)=>{let o=new Image,a=new Image;n.onError=l=>{t.itemError(l),e!==null?(e(`Failed to load ${l}`),i()):s(`Failed to load ${l}`)},n.onLoad=()=>{let l=[o,a];r(l),i(l)},o.addEventListener("error",l=>{n.itemError("smaa-search")}),a.addEventListener("error",l=>{n.itemError("smaa-area")}),o.addEventListener("load",()=>{t.itemEnd("smaa-search"),n.itemEnd("smaa-search")}),a.addEventListener("load",()=>{t.itemEnd("smaa-area"),n.itemEnd("smaa-area")}),t.itemStart("smaa-search"),t.itemStart("smaa-area"),n.itemStart("smaa-search"),n.itemStart("smaa-area"),o.src=wM,a.src=SM})}};var hn=class{constructor(e,t){this.enabled=!1;this.effect=new e(t),Object.defineProperty(this,"opacity",{enumerable:!0,set(n){this.effect.blendMode.opacity.value=n},get(){return this.effect.blendMode.opacity.value}}),Object.defineProperty(this,"blendFunction",{enumerable:!0,set(n){this.effect.blendMode.setBlendFunction(Number(n))},get(){return this.effect.blendMode.blendFunction}}),this.blendFunction=ut.NORMAL}toJSON(){let e=["constructor","effect","subscriptions"],t=Ue({},this),n=Object.getPrototypeOf(this),i=Object.getOwnPropertyNames(n);for(let s of i){let o=Object.getOwnPropertyDescriptor(n,s);o&&typeof o.get=="function"&&(t[s]=this[s])}return e.forEach(s=>delete t[s]),t}};var ru=class extends hn{constructor(){super(fM);this.blendFunction=ut.SCREEN}set intensity(e){this.effect.intensity=e}get intensity(){return this.effect.intensity}set luminanceThreshold(e){this.effect.luminanceMaterial.threshold=e}get luminanceThreshold(){return this.effect.luminanceMaterial.threshold}set luminanceSmoothing(e){this.effect.luminanceMaterial.smoothing=e}get luminanceSmoothing(){return this.effect.luminanceMaterial.smoothing}set blurScale(e){this.effect.blurPass.scale=e}get blurScale(){return this.effect.blurPass.scale}set kernelSize(e){this.effect.blurPass.kernelSize=e}get kernelSize(){return this.effect.blurPass.kernelSize}};var su=class extends hn{constructor(){super(pM)}set contrast(e){this.effect.uniforms.get("contrast").value=e}get contrast(){return this.effect.uniforms.get("contrast").value}set brightness(e){this.effect.uniforms.get("brightness").value=e}get brightness(){return this.effect.uniforms.get("brightness").value}};var ou=class extends hn{constructor(){super(gM);this.effect.offset=new O(.01,.01)}set offset(e){this.effect.offset.set(e[0]/1e3,e[1]/1e3)}get offset(){return[this.effect.offset.x*1e3,this.effect.offset.y*1e3]}};var au=class extends hn{constructor(){super(mM)}};var lu=class extends hn{constructor(){super(vM);this._hue=0}set hue(e){this._hue=e,this.effect.setHue(e)}get hue(){return this._hue}set saturation(e){this.effect.uniforms.get("saturation").value=e}get saturation(){return this.effect.uniforms.get("saturation").value}};var cu=class extends hn{constructor(){super(xM);this.blendFunction=ut.OVERLAY}};var uu=class extends hn{constructor(){super(AM)}get eskil(){return this.effect.eskil}set eskil(e){this.effect.eskil=e}get darkness(){return this.effect.uniforms.get("darkness").value}set darkness(e){this.effect.uniforms.get("darkness").value=e}get offset(){return this.effect.uniforms.get("offset").value}set offset(e){this.effect.uniforms.get("offset").value=e}};var hu=class extends hn{constructor(e){super(yM,e)}set focalLength(e){this.effect.circleOfConfusionMaterial.uniforms.focalLength.value=e}get focalLength(){return this.effect.circleOfConfusionMaterial.uniforms.focalLength.value}set focusDistance(e){this.effect.circleOfConfusionMaterial.uniforms.focusDistance.value=e}get focusDistance(){return this.effect.circleOfConfusionMaterial.uniforms.focusDistance.value}get bokehScale(){return this.effect.bokehScale}set bokehScale(e){this.effect.bokehScale=e}};var du=class extends hn{constructor(){super(bM)}get granularity(){return this.effect.getGranularity()}set granularity(e){this.effect.setGranularity(e)}};function TM(r,e){return e&&e.enabled&&r.push(e.effect),r}var fu=class{constructor(){this._scene=new An;this._camera=new Sr;this.effects=new Map;this.loadingManager=new yo;this.smaaImageLoader=new _M(this.loadingManager);this.renderPass=new sg;this._renderToScreen=!0;this.clock=new Ep,this.enabled=!1,this.debug=!1,this.effects.set("bloom",new ru),this.effects.set("chromaticAberration",new ou),this.effects.set("vignette",new uu),this.effects.set("noise",new cu),this.effects.set("colorAverage",new au),this.effects.set("hueSaturation",new lu),this.effects.set("brightnessContrast",new su),this.effects.set("depthOfField",new hu),this.effects.set("pixelation",new du)}get scene(){return this._scene}set scene(e){this._scene=e,this._initPasses()}get camera(){return this._camera}set camera(e){this._camera=e,this._initPasses()}_initSmaa(){let e=this.effectComposer.passes.length;this.smaaImageLoader.load(([t,n])=>{if(!this.effectComposer)return;let i=new MM(t,n,Uo.ULTRA,Vd.COLOR);i.edgeDetectionMaterial.setPredicationMode(oM.DEPTH),i.edgeDetectionMaterial.setEdgeDetectionThreshold(.05),i.edgeDetectionMaterial.setPredicationThreshold(.002),i.edgeDetectionMaterial.setPredicationScale(1),this.effectComposer.addPass(new Hd(this.camera,i),e)})}_initPasses(){if(!(!this.effectComposer||!this.renderer))if(this.effectComposer.removeAllPasses(),this.renderPass=new sg(this.scene,this.camera),this.enabled){this.effectComposer.addPass(this.renderPass),this._initSmaa();let e=[this.effects.get("chromaticAberration"),this.effects.get("bloom"),this.effects.get("colorAverage"),this.effects.get("hueSaturation"),this.effects.get("brightnessContrast"),this.effects.get("vignette"),this.effects.get("noise")].reduce(TM,[]),t=[this.effects.get("pixelation")].reduce(TM,[]);t.length>0&&this.effectComposer.addPass(new Hd(this.camera,...t)),this.effectComposer.addPass(new Hd(this.camera,...e))}else this.effectComposer.addPass(this.renderPass)}reinit(){!this.renderer||(this.effectComposer=new dM(this.renderer),this._initPasses())}init({renderer:e,camera:t,scene:n}){this.renderer=e,this.scene=n,this.camera=t,this._initSavePass(),this.reinit()}_initSavePass(){if(this._savePass)return;let e=new O;this.renderer.getDrawingBufferSize(e);let t=this.renderer.capabilities.isWebGL2?Zr:bt;this._rt=new t(e.x,e.y,{depthBuffer:!1,stencilBuffer:!1,wrapS:di,wrapT:di}),this._savePass=new lM(this._rt,!1),this._savePass.renderToScreen=!1}get renderToScreen(){return this._renderToScreen}set renderToScreen(e){var n,i;let t=this.effectComposer;!t||(e===!0?(((n=this.renderer)==null?void 0:n.capabilities.isWebGL2)&&(t.multisampling=0),t.removePass(this._savePass),t.passes[t.passes.length-1].renderToScreen=!0,t.autoRenderToScreen=!0):(((i=this.renderer)==null?void 0:i.capabilities.isWebGL2)&&(t.multisampling=4),t.autoRenderToScreen=!1,t.passes[t.passes.length-1].renderToScreen=!1,this._savePass.renderToScreen=!1,t.addPass(this._savePass)),this._renderToScreen=e)}get texture(){return this._rt&&this._rt.texture}get renderTarget(){return this._rt}fromJSON(e){e&&(Object.keys(e).forEach(t=>{let n=e[t],i=this.effects.get(t);Object.keys(n).forEach(s=>{i[s]=n[s]})}),this.enabled=e.enabled)}toJSON(){let e={};return this.effects.forEach((t,n)=>{e[n]=t.toJSON()},e),Ue({enabled:this.enabled},e)}render(){var e;(e=this.effectComposer)==null||e.render(this.clock.getDelta())}setScissor(e,t,n,i){if(!this.effectComposer||!this.renderer)return;e instanceof Qe?(this.effectComposer.inputBuffer.scissor.set(e.x,e.y,e.z,e.w),this.effectComposer.outputBuffer.scissor.set(e.x,e.y,e.z,e.w)):(this.effectComposer.inputBuffer.scissor.set(e,t,n,i),this.effectComposer.outputBuffer.scissor.set(e,t,n,i));let s=this.renderer.getPixelRatio();this.effectComposer.inputBuffer.scissor.multiplyScalar(s),this.effectComposer.outputBuffer.scissor.multiplyScalar(s),this.renderer.setScissor(e,t,n,i)}setScissorTest(e){!this.effectComposer||!this.renderer||(this.effectComposer.inputBuffer.scissorTest=e,this.effectComposer.outputBuffer.scissorTest=e,this.renderer.setScissorTest(e))}setViewport(e,t,n,i){!this.effectComposer||(e instanceof Qe?(this.effectComposer.inputBuffer.viewport.copy(e),this.effectComposer.outputBuffer.viewport.copy(e)):(this.effectComposer.inputBuffer.viewport.set(e,t,n,i),this.effectComposer.outputBuffer.viewport.set(e,t,n,i)))}resize(e,t){var n,i;if((n=this.effectComposer)==null||n.setSize(e,t),this._rt){let s=((i=this.renderer)==null?void 0:i.getPixelRatio())||window.devicePixelRatio;this._rt.setSize(e*s,t*s)}}};var EM;(function(e){function r(t){new Qe(t.r/255,t.g/255,t.b/255,t.a)}e.getThreeVector4=r})(EM||(EM={}));var jd;(function(t){function r(n,i){n.setRGB(i.r/255,i.g/255,i.b/255)}t.setThreeColor=r;function e(n){return new fe(n.r/255,n.g/255,n.b/255).getHex()}t.getHex=e})(jd||(jd={}));var zs=class extends Ld(An){constructor(){super();this.objectType="Scene";this.alpha=1;this.backupFog=new hs(16777215,.1,2e3);this.fogUseBGColor=!1;this.directionalLightState=!0;this.ambientLightState=!0;this.wireframeState=!1;this._color=new fe(1644825);this.canvas={mode:1,preset:"fullscreen",size:{width:512,height:512},editorSize:{width:1,height:1},color:[0,0,0,.5]};this.name="Untitled",this.postprocessing=new fu}get color(){return this._color}set color(e){this.fogUseBGColor===!0&&this.backupFog.color.copy(e),this._color.copy(e)}get enableFog(){return this.fog!==null}set enableFog(e){this.fog=e===!0?this.backupFog:null}init(e,t){this.camera=new Sr(e,t),this.camera.setDefault(),this.camera.orthoCamera.near=-5e4,this.camera.perspCamera.near=50,this.camera.orthoCamera.far=1e5,this.camera.perspCamera.far=1e5,this.camera.updateProjectionMatrix(),this.camera.position.set(0,0,Sr.DefaultTargetOffset),this.camera.lookAt(new M(0,0,-1)),this.add(this.camera),this.canvas.size.width=e,this.canvas.size.height=t,this.ambientLight=new uc(13882323,8553090,.75),this.ambientLight.name="Default Ambient Light",this.add(this.ambientLight),this.directionalLight=new Fr(16777215,.75),this.directionalLight.name="Default Directional Light",this.directionalLight.position.set(85e4,13e5,1e6),this.activeCamera=this.camera,this.activeCamera.add(this.directionalLight)}initFromObjectLoader(e){return this.traverse(t=>{t.uuid===e.ambientLight?this.ambientLight=t:t.uuid===e.directionalLight?this.directionalLight=t:(t.uuid===e.activeCamera&&(this.activeCamera=t),t.uuid===e.camera&&(this.camera=t,this.camera.setDefault()))}),this}raycast(e){let t=[],n=i=>{for(let s of i.children)ei(s)&&!s.raycastLock&&s.visible&&((ai(s)||Hh(s)&&s.enableHelper&&s.objectHelper.parent)&&e.intersectObject(s,!1,t),n(s))};return n(this),t}traverseEntity(e){for(let t of this.children)ei(t)&&this.camera!==t&&t.traverseEntity(e)}updateFog(e){this.enableFog=e.enabled,this.fogUseBGColor=e.useBackgroundColor,e.useBackgroundColor?this.backupFog.color.set(this.color):jd.setThreeColor(this.backupFog.color,e.color),this.backupFog.near=e.near,this.backupFog.far=e.far}toJSON(e){var i,s,o,a,l;let t=super.toJSON(e),n=t.object;return n.objectType="Scene",n.activeCamera=(i=this.activeCamera)==null?void 0:i.uuid,n.camera=(s=this.camera)==null?void 0:s.uuid,n.directionalLight=(o=this.directionalLight)==null?void 0:o.uuid,n.ambientLight=(a=this.ambientLight)==null?void 0:a.uuid,n.color=this.color.toArray(),n.alpha=this.alpha,this.background instanceof xt?n.background=this.background.toJSON(e):this.background instanceof fe&&(n.background=this.background.toArray()),this.environment!==null&&(n.environment=this.environment.toJSON(e)),this.enableFog===!0&&(n.enableFog=!0,this.fogUseBGColor===!0&&(n.fogUseBGColor=!0),this.fog!==null&&(n.fog=this.fog.toJSON())),this.directionalLightState===!0&&(n.directionalLightState=!0),this.ambientLightState===!0&&(n.ambientLightState=!0),this.wireframeState===!0&&(n.wireframeState=!0),n.canvas={mode:this.canvas.mode,preset:this.canvas.preset,editorSize:{width:window.innerWidth,height:window.innerHeight},color:this.canvas.color},this.canvas.mode!==1&&(n.canvas.size={width:this.canvas.size.width,height:this.canvas.size.height}),n.postprocessing=(l=this.postprocessing)==null?void 0:l.toJSON(),t}fromJSON(e){var n,i,s,o,a;super.fromJSON(e),this.postprocessing=new fu,this.color.fromArray(e.color),this.alpha=e.alpha,e.background!==void 0&&Array.isArray(e.background)&&(this.background=new fe().fromArray(e.background)),e.fog!==void 0&&(e.fog.type==="FogExp2"?this.backupFog=new io(e.fog.color,e.fog.density):this.backupFog=new hs(e.fog.color,e.fog.near,e.fog.far)),this.fogUseBGColor=(n=e.fogUseBGColor)!=null?n:!1,this.enableFog=(i=e.enableFog)!=null?i:!1,this.directionalLightState=(s=e.directionalLightState)!=null?s:!1,this.ambientLightState=(o=e.ambientLightState)!=null?o:!1,this.wireframeState=(a=e.wireframeState)!=null?a:!1;let t=e.canvas;return this.canvas.mode=t.mode,this.canvas.preset=t.preset,t.size&&(this.canvas.size={width:t.size.width,height:t.size.height}),this.canvas.editorSize=t.editorSize?{width:t.editorSize.width,height:t.editorSize.height}:{width:window.innerWidth,height:window.innerHeight},t.color&&(this.canvas.color=[...t.color]),this.postprocessing.fromJSON(e.postprocessing),this}dispose(){this.traverseEntity(e=>{"geometry"in e&&e.geometry.dispose(),"material"in e&&(e.material instanceof Array?e.material.forEach(t=>t.dispose()):e.material.dispose())})}};var lg=class extends je{constructor(e="",t){super(t);this.nodeType="Attribute";this.name=e}getAttributeType(e){return typeof this.type=="number"?e.getConstructorFromLength(this.type):this.type}getType(e){let t=this.getAttributeType(e);return e.getTypeByFormat(t)}generate(e,t,n,i,s){i=this.getAttributeType(e);let o=e.getAttribute(this.name,i),a=e.isShader("vertex")?this.name:o.varying.name;return e.format(a,this.getType(e),t)}toJSON(e){let t=super.toJSON(e);return t.nodeType=this.nodeType,t.name=this.name,t}fromJSON(e,t){return super.fromJSON(e,t),e.scope&&(this.scope=e.scope),e.name&&(this.name=e.name),this}};var cg=class extends ze{constructor(e="",t=0){super(e);this.nodeType="Varying";this.value=t}getType(e){return e.getTypeByFormat(this.type)}generate(e,t,n,i,s){let o=e.getVar(this.uuid,this.type);return this.value&&e.isShader("vertex")&&e.addNodeCode(o.name+" = "+this.value.build(e,this.getType(e))+";"),e.format(o.name,this.getType(e),t)}copy(e){return super.copy(e),this.value=e.value,this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),this.value&&(t.value=this.value)),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.value&&(this.value=e.value),this}};var ug=class extends Ct{constructor(e){super("m4");this.nodeType="Matrix4";this.value=e!=null?e:new me}generateReadonly(e,t,n,i,s,o){return e.format("mat4("+this.value.elements.join(", ")+")",i,t)}copy(e){return super.copy(e),this.elements=e.elements,this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.elements=this.value.elements.concat()),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.elements&&(this.elements=e.elements),this}get elements(){return this.value.elements}set elements(e){this.value.fromArray(e)}};var Ar;(function(l){l.EQUAL="==",l.NOT_EQUAL="!=",l.GREATER=">",l.GREATER_EQUAL=">=",l.LESS="<",l.LESS_EQUAL="<=",l.AND="&&",l.OR="||"})(Ar||(Ar={}));var hg=class extends je{constructor(e=new ze,t=new ze,n=hg.GREATER,i=new ze,s=new ze){super();this.nodeType="Cond";this.a=e,this.b=t,this.op=n,this.ifNode=i,this.elseNode=s}getType(e){if(this.ifNode){let t=this.ifNode.getType(e),n=this.elseNode.getType(e);return e.getTypeLength(n)>e.getTypeLength(t)?n:t}return"b"}getCondType(e){return e.getTypeLength(this.b.getType(e))>e.getTypeLength(this.a.getType(e))?this.b.getType(e):this.a.getType(e)}generate(e,t){let n=this.getType(e),i=this.getCondType(e),s=this.a.build(e,i),o=this.b.build(e,i),a;if(this.type=n,this.ifNode){let l=this.ifNode.build(e,n),c=this.elseNode.build(e,n);a="( "+[s,this.op,o,"?",l,":",c].join(" ")+" )"}else a="( "+s+" "+this.op+" "+o+" )";return e.format(a,this.getType(e),t)}copy(e){return super.copy(e),this.a.copy(e.a),this.b.copy(e.b),this.op=e.op,this.ifNode.copy(e.ifNode),this.elseNode.copy(e.elseNode),this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.a=this.a.toJSON(e).uuid,t.b=this.b.toJSON(e).uuid,t.op=this.op,this.ifNode&&(t.ifNode=this.ifNode.toJSON(e).uuid),this.elseNode&&(t.elseNode=this.elseNode.toJSON(e).uuid)),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.a&&(this.a=t.getNode(e.a)),e.b&&(this.b=t.getNode(e.b)),e.op&&(this.op=e.op),e.ifNode&&(this.ifNode=t.getNode(e.ifNode)),e.elseNode&&(this.elseNode=t.getNode(e.elseNode)),this}},rr=hg;rr.EQUAL=Ar.EQUAL,rr.NOT_EQUAL=Ar.NOT_EQUAL,rr.GREATER=Ar.GREATER,rr.GREATER_EQUAL=Ar.GREATER_EQUAL,rr.LESS=Ar.LESS,rr.LESS_EQUAL=Ar.LESS_EQUAL,rr.AND=Ar.AND,rr.OR=Ar.OR;var Tl=class extends Te{constructor(e){super();this.nodeType="MaxMIPLevel";this.texture=e,this.maxMIPLevel=0}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),this.texture&&(t.texture=this.texture.toJSON(e).uuid),t.maxMIPLevel=this.maxMIPLevel),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.texture&&(this.texture=t.getNode(e.texture)),e.maxMIPLevel!==void 0&&(this.maxMIPLevel=e.maxMIPLevel),this}};Object.defineProperties(Tl.prototype,{value:{get:function(){if(this.maxMIPLevel===0){let r=this.texture.value.image;Array.isArray(r)&&(r=r[0]),this.maxMIPLevel=r!==void 0?Math.log(Math.max(r.width,r.height))*Math.LOG2E:0}return this.maxMIPLevel},set:function(){}}});var dg=class extends je{constructor(e=new ze,t){super("f");this.nodeType="SpecularMIPLevel";this.roughness=e,this.texture=t}setTexture(e){return this.texture=e,this}generate(e,t){var n;if(e.isShader("fragment")){this.maxMIPLevel=(n=this.maxMIPLevel)!=null?n:new Tl,this.maxMIPLevel.texture=this.texture;let i=e.include(dg.Nodes.getSpecularMIPLevel);return e.format(i+"( "+this.roughness.build(e,"f")+", "+this.maxMIPLevel.build(e,"f")+" )",this.type,t)}else return console.warn("SpecularMIPLevelNode is not compatible with "+e.shader+" shader."),e.format("0.0",this.type,t)}copy(e){return super.copy(e),this.roughness=e.roughness,e.texture?this.texture?this.texture.copy(e.texture):this.texture=e.texture.clone():this.texture=void 0,e.maxMIPLevel?this.maxMIPLevel?this.maxMIPLevel.copy(e.maxMIPLevel):this.maxMIPLevel=e.maxMIPLevel.clone():this.maxMIPLevel=void 0,this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),this.texture&&(t.texture=this.texture.toJSON(e).uuid),this.roughness&&(t.roughness=this.roughness.toJSON(e).uuid),this.maxMIPLevel&&(t.maxMIPLevel=this.maxMIPLevel.toJSON(e).uuid)),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.roughness&&(this.roughness=t.getNode(e.roughness)),e.texture&&(this.texture=t.getNode(e.texture)),e.maxMIPLevel&&(this.maxMIPLevel=t.getNode(e.maxMIPLevel)),this}},Wd=dg;Wd.Nodes=function(){return{getSpecularMIPLevel:new Le(["float getSpecularMIPLevel( const in float roughness, const in float maxMIPLevelScalar ) {"," float sigma = PI * roughness * roughness / ( 1.0 + roughness );"," float desiredMIPLevel = maxMIPLevelScalar + log2( sigma );"," return clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );","}"].join(`
|
|
4393
|
+
outputColor=vec4(color,inputColor.a);}`,AM=class extends Mr{constructor(r={}){let e=Object.assign({blendFunction:ut.NORMAL,eskil:!1,offset:.5,darkness:.5},r);super("VignetteEffect",bF,{blendFunction:e.blendFunction,uniforms:new Map([["offset",new Ae(e.offset)],["darkness",new Ae(e.darkness)]])});this.eskil=e.eskil}get eskil(){return this.defines.has("ESKIL")}set eskil(r){this.eskil!==r&&(r?this.defines.set("ESKIL","1"):this.defines.delete("ESKIL"),this.setChanged())}},j$=[new Float32Array(3),new Float32Array(3)],W$=[new Float32Array(3),new Float32Array(3),new Float32Array(3),new Float32Array(3)],J$=[[new Float32Array([0,0,0]),new Float32Array([1,0,0]),new Float32Array([1,1,0]),new Float32Array([1,1,1])],[new Float32Array([0,0,0]),new Float32Array([1,0,0]),new Float32Array([1,0,1]),new Float32Array([1,1,1])],[new Float32Array([0,0,0]),new Float32Array([0,0,1]),new Float32Array([1,0,1]),new Float32Array([1,1,1])],[new Float32Array([0,0,0]),new Float32Array([0,1,0]),new Float32Array([1,1,0]),new Float32Array([1,1,1])],[new Float32Array([0,0,0]),new Float32Array([0,1,0]),new Float32Array([0,1,1]),new Float32Array([1,1,1])],[new Float32Array([0,0,0]),new Float32Array([0,0,1]),new Float32Array([0,1,1]),new Float32Array([1,1,1])]];var X$=[new Float32Array(2),new Float32Array(2)];var q$=new Float32Array([0,-.25,.25,-.125,.125,-.375,.375]),Y$=[new Float32Array([0,0]),new Float32Array([.25,-.25]),new Float32Array([-.25,.25]),new Float32Array([.125,-.125]),new Float32Array([-.125,.125])],K$=[new Uint8Array([0,0]),new Uint8Array([3,0]),new Uint8Array([0,3]),new Uint8Array([3,3]),new Uint8Array([1,0]),new Uint8Array([4,0]),new Uint8Array([1,3]),new Uint8Array([4,3]),new Uint8Array([0,1]),new Uint8Array([3,1]),new Uint8Array([0,4]),new Uint8Array([3,4]),new Uint8Array([1,1]),new Uint8Array([4,1]),new Uint8Array([1,4]),new Uint8Array([4,4])],Q$=[new Uint8Array([0,0]),new Uint8Array([1,0]),new Uint8Array([0,2]),new Uint8Array([1,2]),new Uint8Array([2,0]),new Uint8Array([3,0]),new Uint8Array([2,2]),new Uint8Array([3,2]),new Uint8Array([0,1]),new Uint8Array([1,1]),new Uint8Array([0,3]),new Uint8Array([1,3]),new Uint8Array([2,1]),new Uint8Array([3,1]),new Uint8Array([2,3]),new Uint8Array([3,3])];var Z$=new Map([[Hn(0,0,0,0),new Float32Array([0,0,0,0])],[Hn(0,0,0,1),new Float32Array([0,0,0,1])],[Hn(0,0,1,0),new Float32Array([0,0,1,0])],[Hn(0,0,1,1),new Float32Array([0,0,1,1])],[Hn(0,1,0,0),new Float32Array([0,1,0,0])],[Hn(0,1,0,1),new Float32Array([0,1,0,1])],[Hn(0,1,1,0),new Float32Array([0,1,1,0])],[Hn(0,1,1,1),new Float32Array([0,1,1,1])],[Hn(1,0,0,0),new Float32Array([1,0,0,0])],[Hn(1,0,0,1),new Float32Array([1,0,0,1])],[Hn(1,0,1,0),new Float32Array([1,0,1,0])],[Hn(1,0,1,1),new Float32Array([1,0,1,1])],[Hn(1,1,0,0),new Float32Array([1,1,0,0])],[Hn(1,1,0,1),new Float32Array([1,1,0,1])],[Hn(1,1,1,0),new Float32Array([1,1,1,0])],[Hn(1,1,1,1),new Float32Array([1,1,1,1])]]);function ag(r,e,t){return r+(e-r)*t}function Hn(r,e,t,n){let i=ag(r,e,1-.25),s=ag(t,n,1-.25);return ag(i,s,1-.125)}var _M=class extends fn{load(r=()=>{},e=null){arguments.length===4?(r=arguments[1],e=arguments[3]):(arguments.length===3||typeof arguments[0]!="function")&&(r=arguments[1],e=null);let t=this.manager,n=new yo;return new Promise((i,s)=>{let o=new Image,a=new Image;n.onError=l=>{t.itemError(l),e!==null?(e(`Failed to load ${l}`),i()):s(`Failed to load ${l}`)},n.onLoad=()=>{let l=[o,a];r(l),i(l)},o.addEventListener("error",l=>{n.itemError("smaa-search")}),a.addEventListener("error",l=>{n.itemError("smaa-area")}),o.addEventListener("load",()=>{t.itemEnd("smaa-search"),n.itemEnd("smaa-search")}),a.addEventListener("load",()=>{t.itemEnd("smaa-area"),n.itemEnd("smaa-area")}),t.itemStart("smaa-search"),t.itemStart("smaa-area"),n.itemStart("smaa-search"),n.itemStart("smaa-area"),o.src=wM,a.src=SM})}};var hn=class{constructor(e,t){this.enabled=!1;this.effect=new e(t),Object.defineProperty(this,"opacity",{enumerable:!0,set(n){this.effect.blendMode.opacity.value=n},get(){return this.effect.blendMode.opacity.value}}),Object.defineProperty(this,"blendFunction",{enumerable:!0,set(n){this.effect.blendMode.setBlendFunction(Number(n))},get(){return this.effect.blendMode.blendFunction}}),this.blendFunction=ut.NORMAL}toJSON(){let e=["constructor","effect","subscriptions"],t=Ue({},this),n=Object.getPrototypeOf(this),i=Object.getOwnPropertyNames(n);for(let s of i){let o=Object.getOwnPropertyDescriptor(n,s);o&&typeof o.get=="function"&&(t[s]=this[s])}return e.forEach(s=>delete t[s]),t}};var ru=class extends hn{constructor(){super(fM);this.blendFunction=ut.SCREEN}set intensity(e){this.effect.intensity=e}get intensity(){return this.effect.intensity}set luminanceThreshold(e){this.effect.luminanceMaterial.threshold=e}get luminanceThreshold(){return this.effect.luminanceMaterial.threshold}set luminanceSmoothing(e){this.effect.luminanceMaterial.smoothing=e}get luminanceSmoothing(){return this.effect.luminanceMaterial.smoothing}set blurScale(e){this.effect.blurPass.scale=e}get blurScale(){return this.effect.blurPass.scale}set kernelSize(e){this.effect.blurPass.kernelSize=e}get kernelSize(){return this.effect.blurPass.kernelSize}};var su=class extends hn{constructor(){super(pM)}set contrast(e){this.effect.uniforms.get("contrast").value=e}get contrast(){return this.effect.uniforms.get("contrast").value}set brightness(e){this.effect.uniforms.get("brightness").value=e}get brightness(){return this.effect.uniforms.get("brightness").value}};var ou=class extends hn{constructor(){super(gM);this.effect.offset=new O(.01,.01)}set offset(e){this.effect.offset.set(e[0]/1e3,e[1]/1e3)}get offset(){return[this.effect.offset.x*1e3,this.effect.offset.y*1e3]}};var au=class extends hn{constructor(){super(mM)}};var lu=class extends hn{constructor(){super(vM);this._hue=0}set hue(e){this._hue=e,this.effect.setHue(e)}get hue(){return this._hue}set saturation(e){this.effect.uniforms.get("saturation").value=e}get saturation(){return this.effect.uniforms.get("saturation").value}};var cu=class extends hn{constructor(){super(xM);this.blendFunction=ut.OVERLAY}};var uu=class extends hn{constructor(){super(AM)}get eskil(){return this.effect.eskil}set eskil(e){this.effect.eskil=e}get darkness(){return this.effect.uniforms.get("darkness").value}set darkness(e){this.effect.uniforms.get("darkness").value=e}get offset(){return this.effect.uniforms.get("offset").value}set offset(e){this.effect.uniforms.get("offset").value=e}};var hu=class extends hn{constructor(e){super(yM,e)}set focalLength(e){this.effect.circleOfConfusionMaterial.uniforms.focalLength.value=e}get focalLength(){return this.effect.circleOfConfusionMaterial.uniforms.focalLength.value}set focusDistance(e){this.effect.circleOfConfusionMaterial.uniforms.focusDistance.value=e}get focusDistance(){return this.effect.circleOfConfusionMaterial.uniforms.focusDistance.value}get bokehScale(){return this.effect.bokehScale}set bokehScale(e){this.effect.bokehScale=e}};var du=class extends hn{constructor(){super(bM)}get granularity(){return this.effect.getGranularity()}set granularity(e){this.effect.setGranularity(e)}};function TM(r,e){return e&&e.enabled&&r.push(e.effect),r}var fu=class{constructor(){this._scene=new An;this._camera=new Sr;this.effects=new Map;this.loadingManager=new yo;this.smaaImageLoader=new _M(this.loadingManager);this.renderPass=new sg;this._renderToScreen=!0;this._hasSmaa=!1;this.clock=new Ep,this.enabled=!1,this.debug=!1,this.effects.set("bloom",new ru),this.effects.set("chromaticAberration",new ou),this.effects.set("vignette",new uu),this.effects.set("noise",new cu),this.effects.set("colorAverage",new au),this.effects.set("hueSaturation",new lu),this.effects.set("brightnessContrast",new su),this.effects.set("depthOfField",new hu),this.effects.set("pixelation",new du)}get scene(){return this._scene}set scene(e){this._scene=e,this._initPasses()}get camera(){return this._camera}set camera(e){this._camera=e,this._initPasses()}_initSmaa(){let e=this.effectComposer.passes.length;this.smaaImageLoader.load(([t,n])=>{if(!this.effectComposer)return;let i=new MM(t,n,Uo.ULTRA,Vd.COLOR);i.edgeDetectionMaterial.setPredicationMode(oM.DEPTH),i.edgeDetectionMaterial.setEdgeDetectionThreshold(.05),i.edgeDetectionMaterial.setPredicationThreshold(.002),i.edgeDetectionMaterial.setPredicationScale(1),this.effectComposer.addPass(new Hd(this.camera,i),e),this._hasSmaa=!0})}_initPasses(){if(!(!this.effectComposer||!this.renderer))if(this.effectComposer.removeAllPasses(),this._hasSmaa=!1,this.renderPass=new sg(this.scene,this.camera),this.enabled){this.effectComposer.addPass(this.renderPass),this._initSmaa();let e=[this.effects.get("chromaticAberration"),this.effects.get("bloom"),this.effects.get("colorAverage"),this.effects.get("hueSaturation"),this.effects.get("brightnessContrast"),this.effects.get("vignette"),this.effects.get("noise")].reduce(TM,[]),t=[this.effects.get("pixelation")].reduce(TM,[]);t.length>0&&this.effectComposer.addPass(new Hd(this.camera,...t)),this.effectComposer.addPass(new Hd(this.camera,...e))}else this.effectComposer.addPass(this.renderPass)}reinit(){!this.renderer||(this.effectComposer=new dM(this.renderer),this._initPasses())}init({renderer:e,camera:t,scene:n}){this.renderer=e,this.scene=n,this.camera=t,this._initSavePass(),this.reinit()}_initSavePass(){if(this._savePass)return;let e=new O;this.renderer.getDrawingBufferSize(e);let t=this.renderer.capabilities.isWebGL2?Zr:bt;this._rt=new t(e.x,e.y,{depthBuffer:!1,stencilBuffer:!1,wrapS:di,wrapT:di}),this._savePass=new lM(this._rt,!1),this._savePass.renderToScreen=!1}get renderToScreen(){return this._renderToScreen}set renderToScreen(e){var n,i;let t=this.effectComposer;!t||(e===!0?(((n=this.renderer)==null?void 0:n.capabilities.isWebGL2)&&(t.multisampling=0),t.removePass(this._savePass),t.passes[t.passes.length-1].renderToScreen=!0,t.autoRenderToScreen=!0):(((i=this.renderer)==null?void 0:i.capabilities.isWebGL2)&&!this._hasSmaa&&(t.multisampling=4),t.autoRenderToScreen=!1,t.passes[t.passes.length-1].renderToScreen=!1,this._savePass.renderToScreen=!1,t.addPass(this._savePass)),this._renderToScreen=e)}get texture(){return this._rt&&this._rt.texture}get renderTarget(){return this._rt}fromJSON(e){e&&(Object.keys(e).forEach(t=>{let n=e[t],i=this.effects.get(t);Object.keys(n).forEach(s=>{i[s]=n[s]})}),this.enabled=e.enabled)}toJSON(){let e={};return this.effects.forEach((t,n)=>{e[n]=t.toJSON()},e),Ue({enabled:this.enabled},e)}render(){var e;(e=this.effectComposer)==null||e.render(this.clock.getDelta())}setScissor(e,t,n,i){if(!this.effectComposer||!this.renderer)return;e instanceof Qe?(this.effectComposer.inputBuffer.scissor.set(e.x,e.y,e.z,e.w),this.effectComposer.outputBuffer.scissor.set(e.x,e.y,e.z,e.w)):(this.effectComposer.inputBuffer.scissor.set(e,t,n,i),this.effectComposer.outputBuffer.scissor.set(e,t,n,i));let s=this.renderer.getPixelRatio();this.effectComposer.inputBuffer.scissor.multiplyScalar(s),this.effectComposer.outputBuffer.scissor.multiplyScalar(s),this.renderer.setScissor(e,t,n,i)}setScissorTest(e){!this.effectComposer||!this.renderer||(this.effectComposer.inputBuffer.scissorTest=e,this.effectComposer.outputBuffer.scissorTest=e,this.renderer.setScissorTest(e))}setViewport(e,t,n,i){!this.effectComposer||(e instanceof Qe?(this.effectComposer.inputBuffer.viewport.copy(e),this.effectComposer.outputBuffer.viewport.copy(e)):(this.effectComposer.inputBuffer.viewport.set(e,t,n,i),this.effectComposer.outputBuffer.viewport.set(e,t,n,i)))}resize(e,t){var n,i;if((n=this.effectComposer)==null||n.setSize(e,t),this._rt){let s=((i=this.renderer)==null?void 0:i.getPixelRatio())||window.devicePixelRatio;this._rt.setSize(e*s,t*s)}}};var EM;(function(e){function r(t){new Qe(t.r/255,t.g/255,t.b/255,t.a)}e.getThreeVector4=r})(EM||(EM={}));var jd;(function(t){function r(n,i){n.setRGB(i.r/255,i.g/255,i.b/255)}t.setThreeColor=r;function e(n){return new fe(n.r/255,n.g/255,n.b/255).getHex()}t.getHex=e})(jd||(jd={}));var zs=class extends Ld(An){constructor(){super();this.objectType="Scene";this.alpha=1;this.backupFog=new hs(16777215,.1,2e3);this.fogUseBGColor=!1;this.directionalLightState=!0;this.ambientLightState=!0;this.wireframeState=!1;this._color=new fe(1644825);this.canvas={mode:1,preset:"fullscreen",size:{width:512,height:512},editorSize:{width:1,height:1},color:[0,0,0,.5]};this.name="Untitled",this.postprocessing=new fu}get color(){return this._color}set color(e){this.fogUseBGColor===!0&&this.backupFog.color.copy(e),this._color.copy(e)}get enableFog(){return this.fog!==null}set enableFog(e){this.fog=e===!0?this.backupFog:null}init(e,t){this.camera=new Sr(e,t),this.camera.setDefault(),this.camera.orthoCamera.near=-5e4,this.camera.perspCamera.near=50,this.camera.orthoCamera.far=1e5,this.camera.perspCamera.far=1e5,this.camera.updateProjectionMatrix(),this.camera.position.set(0,0,Sr.DefaultTargetOffset),this.camera.lookAt(new M(0,0,-1)),this.add(this.camera),this.canvas.size.width=e,this.canvas.size.height=t,this.ambientLight=new uc(13882323,8553090,.75),this.ambientLight.name="Default Ambient Light",this.add(this.ambientLight),this.directionalLight=new Fr(16777215,.75),this.directionalLight.name="Default Directional Light",this.directionalLight.position.set(85e4,13e5,1e6),this.activeCamera=this.camera,this.activeCamera.add(this.directionalLight)}initFromObjectLoader(e){return this.traverse(t=>{t.uuid===e.ambientLight?this.ambientLight=t:t.uuid===e.directionalLight?this.directionalLight=t:(t.uuid===e.activeCamera&&(this.activeCamera=t),t.uuid===e.camera&&(this.camera=t,this.camera.setDefault()))}),this}raycast(e){let t=[],n=i=>{for(let s of i.children)ei(s)&&!s.raycastLock&&s.visible&&((ai(s)||Hh(s)&&s.enableHelper&&s.objectHelper.parent)&&e.intersectObject(s,!1,t),n(s))};return n(this),t}traverseEntity(e){for(let t of this.children)ei(t)&&this.camera!==t&&t.traverseEntity(e)}updateFog(e){this.enableFog=e.enabled,this.fogUseBGColor=e.useBackgroundColor,e.useBackgroundColor?this.backupFog.color.set(this.color):jd.setThreeColor(this.backupFog.color,e.color),this.backupFog.near=e.near,this.backupFog.far=e.far}toJSON(e){var i,s,o,a,l;let t=super.toJSON(e),n=t.object;return n.objectType="Scene",n.activeCamera=(i=this.activeCamera)==null?void 0:i.uuid,n.camera=(s=this.camera)==null?void 0:s.uuid,n.directionalLight=(o=this.directionalLight)==null?void 0:o.uuid,n.ambientLight=(a=this.ambientLight)==null?void 0:a.uuid,n.color=this.color.toArray(),n.alpha=this.alpha,this.background instanceof xt?n.background=this.background.toJSON(e):this.background instanceof fe&&(n.background=this.background.toArray()),this.environment!==null&&(n.environment=this.environment.toJSON(e)),this.enableFog===!0&&(n.enableFog=!0,this.fogUseBGColor===!0&&(n.fogUseBGColor=!0),this.fog!==null&&(n.fog=this.fog.toJSON())),this.directionalLightState===!0&&(n.directionalLightState=!0),this.ambientLightState===!0&&(n.ambientLightState=!0),this.wireframeState===!0&&(n.wireframeState=!0),n.canvas={mode:this.canvas.mode,preset:this.canvas.preset,editorSize:{width:window.innerWidth,height:window.innerHeight},color:this.canvas.color},this.canvas.mode!==1&&(n.canvas.size={width:this.canvas.size.width,height:this.canvas.size.height}),n.postprocessing=(l=this.postprocessing)==null?void 0:l.toJSON(),t}fromJSON(e){var n,i,s,o,a;super.fromJSON(e),this.postprocessing=new fu,this.color.fromArray(e.color),this.alpha=e.alpha,e.background!==void 0&&Array.isArray(e.background)&&(this.background=new fe().fromArray(e.background)),e.fog!==void 0&&(e.fog.type==="FogExp2"?this.backupFog=new io(e.fog.color,e.fog.density):this.backupFog=new hs(e.fog.color,e.fog.near,e.fog.far)),this.fogUseBGColor=(n=e.fogUseBGColor)!=null?n:!1,this.enableFog=(i=e.enableFog)!=null?i:!1,this.directionalLightState=(s=e.directionalLightState)!=null?s:!1,this.ambientLightState=(o=e.ambientLightState)!=null?o:!1,this.wireframeState=(a=e.wireframeState)!=null?a:!1;let t=e.canvas;return this.canvas.mode=t.mode,this.canvas.preset=t.preset,t.size&&(this.canvas.size={width:t.size.width,height:t.size.height}),this.canvas.editorSize=t.editorSize?{width:t.editorSize.width,height:t.editorSize.height}:{width:window.innerWidth,height:window.innerHeight},t.color&&(this.canvas.color=[...t.color]),this.postprocessing.fromJSON(e.postprocessing),this}dispose(){this.traverseEntity(e=>{"geometry"in e&&e.geometry.dispose(),"material"in e&&(e.material instanceof Array?e.material.forEach(t=>t.dispose()):e.material.dispose())})}};var lg=class extends je{constructor(e="",t){super(t);this.nodeType="Attribute";this.name=e}getAttributeType(e){return typeof this.type=="number"?e.getConstructorFromLength(this.type):this.type}getType(e){let t=this.getAttributeType(e);return e.getTypeByFormat(t)}generate(e,t,n,i,s){i=this.getAttributeType(e);let o=e.getAttribute(this.name,i),a=e.isShader("vertex")?this.name:o.varying.name;return e.format(a,this.getType(e),t)}toJSON(e){let t=super.toJSON(e);return t.nodeType=this.nodeType,t.name=this.name,t}fromJSON(e,t){return super.fromJSON(e,t),e.scope&&(this.scope=e.scope),e.name&&(this.name=e.name),this}};var cg=class extends ze{constructor(e="",t=0){super(e);this.nodeType="Varying";this.value=t}getType(e){return e.getTypeByFormat(this.type)}generate(e,t,n,i,s){let o=e.getVar(this.uuid,this.type);return this.value&&e.isShader("vertex")&&e.addNodeCode(o.name+" = "+this.value.build(e,this.getType(e))+";"),e.format(o.name,this.getType(e),t)}copy(e){return super.copy(e),this.value=e.value,this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),this.value&&(t.value=this.value)),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.value&&(this.value=e.value),this}};var ug=class extends Ct{constructor(e){super("m4");this.nodeType="Matrix4";this.value=e!=null?e:new me}generateReadonly(e,t,n,i,s,o){return e.format("mat4("+this.value.elements.join(", ")+")",i,t)}copy(e){return super.copy(e),this.elements=e.elements,this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.elements=this.value.elements.concat()),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.elements&&(this.elements=e.elements),this}get elements(){return this.value.elements}set elements(e){this.value.fromArray(e)}};var Ar;(function(l){l.EQUAL="==",l.NOT_EQUAL="!=",l.GREATER=">",l.GREATER_EQUAL=">=",l.LESS="<",l.LESS_EQUAL="<=",l.AND="&&",l.OR="||"})(Ar||(Ar={}));var hg=class extends je{constructor(e=new ze,t=new ze,n=hg.GREATER,i=new ze,s=new ze){super();this.nodeType="Cond";this.a=e,this.b=t,this.op=n,this.ifNode=i,this.elseNode=s}getType(e){if(this.ifNode){let t=this.ifNode.getType(e),n=this.elseNode.getType(e);return e.getTypeLength(n)>e.getTypeLength(t)?n:t}return"b"}getCondType(e){return e.getTypeLength(this.b.getType(e))>e.getTypeLength(this.a.getType(e))?this.b.getType(e):this.a.getType(e)}generate(e,t){let n=this.getType(e),i=this.getCondType(e),s=this.a.build(e,i),o=this.b.build(e,i),a;if(this.type=n,this.ifNode){let l=this.ifNode.build(e,n),c=this.elseNode.build(e,n);a="( "+[s,this.op,o,"?",l,":",c].join(" ")+" )"}else a="( "+s+" "+this.op+" "+o+" )";return e.format(a,this.getType(e),t)}copy(e){return super.copy(e),this.a.copy(e.a),this.b.copy(e.b),this.op=e.op,this.ifNode.copy(e.ifNode),this.elseNode.copy(e.elseNode),this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.a=this.a.toJSON(e).uuid,t.b=this.b.toJSON(e).uuid,t.op=this.op,this.ifNode&&(t.ifNode=this.ifNode.toJSON(e).uuid),this.elseNode&&(t.elseNode=this.elseNode.toJSON(e).uuid)),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.a&&(this.a=t.getNode(e.a)),e.b&&(this.b=t.getNode(e.b)),e.op&&(this.op=e.op),e.ifNode&&(this.ifNode=t.getNode(e.ifNode)),e.elseNode&&(this.elseNode=t.getNode(e.elseNode)),this}},rr=hg;rr.EQUAL=Ar.EQUAL,rr.NOT_EQUAL=Ar.NOT_EQUAL,rr.GREATER=Ar.GREATER,rr.GREATER_EQUAL=Ar.GREATER_EQUAL,rr.LESS=Ar.LESS,rr.LESS_EQUAL=Ar.LESS_EQUAL,rr.AND=Ar.AND,rr.OR=Ar.OR;var Tl=class extends Te{constructor(e){super();this.nodeType="MaxMIPLevel";this.texture=e,this.maxMIPLevel=0}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),this.texture&&(t.texture=this.texture.toJSON(e).uuid),t.maxMIPLevel=this.maxMIPLevel),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.texture&&(this.texture=t.getNode(e.texture)),e.maxMIPLevel!==void 0&&(this.maxMIPLevel=e.maxMIPLevel),this}};Object.defineProperties(Tl.prototype,{value:{get:function(){if(this.maxMIPLevel===0){let r=this.texture.value.image;Array.isArray(r)&&(r=r[0]),this.maxMIPLevel=r!==void 0?Math.log(Math.max(r.width,r.height))*Math.LOG2E:0}return this.maxMIPLevel},set:function(){}}});var dg=class extends je{constructor(e=new ze,t){super("f");this.nodeType="SpecularMIPLevel";this.roughness=e,this.texture=t}setTexture(e){return this.texture=e,this}generate(e,t){var n;if(e.isShader("fragment")){this.maxMIPLevel=(n=this.maxMIPLevel)!=null?n:new Tl,this.maxMIPLevel.texture=this.texture;let i=e.include(dg.Nodes.getSpecularMIPLevel);return e.format(i+"( "+this.roughness.build(e,"f")+", "+this.maxMIPLevel.build(e,"f")+" )",this.type,t)}else return console.warn("SpecularMIPLevelNode is not compatible with "+e.shader+" shader."),e.format("0.0",this.type,t)}copy(e){return super.copy(e),this.roughness=e.roughness,e.texture?this.texture?this.texture.copy(e.texture):this.texture=e.texture.clone():this.texture=void 0,e.maxMIPLevel?this.maxMIPLevel?this.maxMIPLevel.copy(e.maxMIPLevel):this.maxMIPLevel=e.maxMIPLevel.clone():this.maxMIPLevel=void 0,this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),this.texture&&(t.texture=this.texture.toJSON(e).uuid),this.roughness&&(t.roughness=this.roughness.toJSON(e).uuid),this.maxMIPLevel&&(t.maxMIPLevel=this.maxMIPLevel.toJSON(e).uuid)),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.roughness&&(this.roughness=t.getNode(e.roughness)),e.texture&&(this.texture=t.getNode(e.texture)),e.maxMIPLevel&&(this.maxMIPLevel=t.getNode(e.maxMIPLevel)),this}},Wd=dg;Wd.Nodes=function(){return{getSpecularMIPLevel:new Le(["float getSpecularMIPLevel( const in float roughness, const in float maxMIPLevelScalar ) {"," float sigma = PI * roughness * roughness / ( 1.0 + roughness );"," float desiredMIPLevel = maxMIPLevelScalar + log2( sigma );"," return clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );","}"].join(`
|
|
4394
4394
|
`))}}();var NM={Int:it,Float:Te,Bool:mc,Vector2:In,Vector3:Un,Vector4:yc,Matrix3:zr,Matrix4:ug,FloatArray:Ba,Vector4Array:Ra,Normal:mn,Position:_n,Reflect:Qi,UV:bo,Attribute:lg,Const:rt,Struct:Ao,Varying:cg,SpecularMIPLevel:Wd,MaxMIPLevel:Tl,ColorSpace:Bt,Noise:Wa,TextureCubeUV:_o,TextureCube:vc,Operator:Yn,Math:Ye,Cond:rr,Fresnel:Ga,Rainbow:ka,Transmission:Va,Depth:qa,Blend:Xa,Raw:Qa,CubeTexture:xc,Texture:kn,CustomTexture:za,VertexDisplacement:Mo,CustomNormal:Ha,Gradient:ja,Matcap:Ya,Expression:yt,Color:ct,Phong:wc,Basic:bc,Lambert:Sc,Standard:Tc,Toon:Ac};var Jd=class{constructor(){this._nodes={};this._dataNodes={};this._textures={};this.uuid=Ee.generateUUID()}init(e,t){this._dataNodes=e,this._textures=t}clear(){this._nodes={},this._dataNodes={},this._textures={}}getNode(e){let t=this._nodes[e];return t||(t=this.createNode(e)),t}getNodeData(e){return this._dataNodes[e]}getTexture(e){let t=this._textures[e];return t||new bi}createNode(e){let t=this._dataNodes[e];if(!t)throw new Error("Failed to create Node from uuid: "+e+", its data does not seem to exist");let n=NM[t.nodeType];if(!n)throw new Error("Failed to create Node from uuid: "+e+" and nodeType: "+t.nodeType+", constructor for this not is not registered");let i=new n().fromJSON(t,this);return this._nodes[e]=i,i}};function CM(r){wF(r.geometries),SF(r.interactionStates),LM(r.object),MF(r.materials)}function wF(r){var e;if(r!==void 0){for(let t of r)if(((e=t.userData)==null?void 0:e.type)!==void 0){let n=t.userData.parameters;"extrudeDepth"in n||Object.assign(n,{extrudeDepth:0}),"extrudeBevelSize"in n||Object.assign(n,{extrudeBevelSize:0}),"extrudeBevelSegments"in n||Object.assign(n,{extrudeBevelSegments:1})}}}function SF(r){if(r!==void 0){for(let e of r)if(e.quaternion!==void 0){let t=new Tt().fromArray(e.quaternion);Object.assign(e,{rotation:new On().setFromQuaternion(t).toArray()})}}}function LM(r){var e,t,n,i;if(((e=r.userData)==null?void 0:e.type)===void 0)if(r.type==="OrthographicCamera"||r.type==="PerspectiveCamera"){let s=r;Object.assign(r,{objectType:"CombinedCamera",cameraType:s.type,isDefaultCamera:!0,hiddenMatrix:new me().toArray(),name:"Default Camera",far:1e5,zoomOrtho:s.zoom,zoomPersp:1,nearOrtho:-5e4,nearPersp:50}),delete r.type,s.typeCamera!==void 0&&(Object.assign(r,{cameraType:s.typeCamera}),delete r.typeCamera)}else r.type==="Scene"?(Object.assign(r,{objectType:r.type}),delete r.type):r.type==="HemisphereLight"?Object.assign(r,{isDefaultAmbientLight:!0}):r.type==="DirectionalLight"&&Object.assign(r,{isDefaultDirectionalLight:!0});if(r.userData!==void 0){let s=r.userData;s.type!==void 0&&(Object.assign(r,{objectType:s.type}),delete s.type),s.interaction!==void 0&&(Object.assign(r,{interaction:s.interaction}),delete s.interaction),s.isDefaultAmbientLight===!0?(Object.assign(r,{isDefaultAmbientLight:!0}),delete s.isDefaultAmbientLight):s.isDefaultDirectionalLight===!0?(Object.assign(r,{isDefaultDirectionalLight:!0}),delete s.isDefaultDirectionalLight):s.isDefaultCamera===!0&&(Object.assign(r,{isDefaultCamera:!0}),delete s.isDefaultCamera),Object.assign(r,{raycastLock:s.lock,scaleLock:s.scaleLock,hiddenMatrix:(n=(t=s.hiddenMatrix)==null?void 0:t.elements)!=null?n:new me().toArray()}),delete s.lock,delete s.scaleLock,delete s.hiddenMatrix,delete s.isEntity}if(((i=r.interaction)==null?void 0:i.events)!==void 0){for(let s of r.interaction.events)if(s.targets!==void 0)for(let o of s.targets)o.springControls!==void 0&&(Object.assign(o,{springParameters:{mass:o.springControls[0],stiffness:o.springControls[1],damping:o.springControls[2],velocity:o.springControls[3]}}),delete o.springControls)}if(r.children!==void 0)for(let s of r.children)LM(s)}function MF(r){if(r!==void 0)for(let e of r){let n=e.userData.layers.head;for(;n;){for(let i in n.uniforms){let s=`f${n.id}_tex`,o=`f${n.id}_texture`;i===s&&(n.uniforms[o]=n.uniforms[s],delete n.uniforms[s])}n=n.next}}}function IM(r){PM(r.object,r.object)}function PM(r,e){var t;if(r.type==="HemisphereLight"||r.isDefaultAmbientLight===!0?e.ambientLight=r.uuid:((t=r.userData)==null?void 0:t.isDefaultDirectionalLight)===!0||r.isDefaultDirectionalLight===!0?e.directionalLight=r.uuid:r.isDefaultCamera===!0&&(e.camera=r.uuid,e.activeCamera=r.uuid,Object.assign(r,{name:"Default Camera"})),r.children!==void 0)for(let n of r.children)PM(n,e)}function DM(r){AF(r.object)}function AF(r){var e,t,n,i,s,o,a;if(r.objectType==="Scene"){let l=r.userData,c=(e=l.rgb)!=null?e:{r:25,g:25,b:25},u=(t=l.fogColor)!=null?t:{r:25,g:25,b:25};Object.assign(r,{color:[c.r/255,c.g/255,c.b/255],alpha:l.alpha,enableFog:l.fogEnable,fogUseBGColor:l.fogUseBGColor,fog:{color:new fe().setRGB(u.r/255,u.g/255,u.b/255).getHex(),near:l.fogNear,far:l.fogFar},directionalLightState:l.directionalLightState,ambientLightState:l.ambientLightState,shadowsState:l.shadowsState,wireframeState:l.wireframeState,canvas:{mode:(n=l.canvasMode)!=null?n:1,size:{width:(s=(i=l.canvasCustomSize)==null?void 0:i.width)!=null?s:512,height:(a=(o=l.canvasCustomSize)==null?void 0:o.height)!=null?a:512}}}),delete l.rgb,delete l.alpha,delete l.fogEnable,delete l.fogUseBGColor,delete l.fogColor,delete l.fogNear,delete l.fogFar,delete l.directionalLightState,delete l.ambientLightState,delete l.shadowsState,delete l.wireframeState,delete l.canvasMode,delete l.canvasFullScreen,delete l.canvasCustomSize}}function RM(r){return{uuid:Ee.generateUUID(),type:"b",value:r,nodeType:"Bool"}}function Si(r,e){let t=new fe().set(r);return{uuid:Ee.generateUUID(),type:"c",r:t.r,g:t.g,b:t.b,value:r,alpha:e==null?void 0:e.uuid,nodeType:"Color"}}function BM(r,e){return{uuid:Ee.generateUUID(),type:"f[]",size:r,value:e,nodeType:"FloatArray"}}function mt(r){return{uuid:Ee.generateUUID(),type:"f",value:r,nodeType:"Float"}}function an(r){return{uuid:Ee.generateUUID(),type:"i",value:r,nodeType:"Int"}}function El(r){let{x:e,y:t}=r;return{uuid:Ee.generateUUID(),type:"v2",x:e,y:t,nodeType:"Vector2"}}function fg(r){let{x:e,y:t,z:n}=r;return{uuid:Ee.generateUUID(),type:"v3",x:e,y:t,z:n,nodeType:"Vector3"}}function OM(r,e){return{uuid:Ee.generateUUID(),type:"v4[]",size:r,value:e,nodeType:"Vector4Array"}}function FM(r){return{uuid:Ee.generateUUID(),type:"m3",elements:r.elements,nodeType:"Matrix3"}}function zM(r,e){return{uuid:Ee.generateUUID(),type:"v4",value:r,uv:e.uuid,project:!1,nodeType:"Texture"}}function GM(r){return{uuid:Ee.generateUUID(),type:"v2",index:r,nodeType:"UV"}}function pg(r,e){let t={uuid:Ee.generateUUID(),type:"v3",nodeType:"Blend",a:r==null?void 0:r.uuid,b:e.uuid};return"mode"in e&&(t.mode=e.mode),t}function UM(r,e){let t=r.uniforms,n=r.id,i=mt(t[`f${n}_alpha`].value),s=an(t[`f${n}_mode`].value);return[i,s].forEach(o=>e[o.uuid]=o),Object.assign(r,{uniforms:{[`f${n}_alpha`]:i.uuid,[`f${n}_mode`]:s.uuid}}),{uuid:Ee.generateUUID(),type:"v3",nodeType:"CustomTexture",alpha:i.uuid,mode:s.uuid}}function mg(r,e){let t=r.uniforms,n=r.id,i=an(t[`f${n}_mode`].value),s=mt(t[`f${n}_alpha`].value),o=Si(t[`f${n}_color`].value,s);return[o,s,i].forEach(a=>e[a.uuid]=a),Object.assign(r,{uniforms:{[`f${n}_color`]:o.uuid,[`f${n}_alpha`]:s.uuid,[`f${n}_mode`]:i.uuid}}),o}function kM(r,e){let t=r.uniforms,n=r.id,i=an(t[`f${n}_mode`].value),s=mt(t[`f${n}_alpha`].value),o=fg(t[`f${n}_cnormal`].value);return[o,s,i].forEach(a=>e[a.uuid]=a),Object.assign(r,{uniforms:{[`f${n}_cnormal`]:o.uuid,[`f${n}_alpha`]:s.uuid,[`f${n}_mode`]:i.uuid}}),{uuid:Ee.generateUUID(),type:"v3",nodeType:"CustomNormal",cnormal:o.uuid,alpha:s.uuid,mode:i.uuid}}function VM(r,e){let t=r.uniforms,n=r.id,i=an(t[`f${n}_mode`].value),s=mt(t[`f${n}_alpha`].value),o=mt(t[`f${n}_near`].value),a=mt(t[`f${n}_far`].value),l=mt(t[`f${n}_isVector`].value),c=fg(t[`f${n}_origin`].value),u=Si(t[`f${n}_colorA`].value),h=Si(t[`f${n}_colorB`].value);return[o,a,l,c,u,h,s,i].forEach(d=>e[d.uuid]=d),Object.assign(r,{uniforms:{[`f${n}_near`]:o.uuid,[`f${n}_far`]:a.uuid,[`f${n}_isVector`]:l.uuid,[`f${n}_origin`]:c.uuid,[`f${n}_colorA`]:u.uuid,[`f${n}_colorB`]:h.uuid,[`f${n}_alpha`]:s.uuid,[`f${n}_mode`]:i.uuid}}),{uuid:Ee.generateUUID(),type:"v3",nodeType:"Depth",near:o.uuid,far:a.uuid,isVector:l.uuid,origin:c.uuid,colorA:u.uuid,colorB:h.uuid,alpha:s.uuid,mode:i.uuid}}function HM(r,e){let t=r.uniforms,n=r.id,i=an(t[`f${n}_mode`].value),s=mt(t[`f${n}_alpha`].value),o=Si(t[`f${n}_color`].value),a=mt(t[`f${n}_bias`].value),l=mt(t[`f${n}_scale`].value),c=mt(t[`f${n}_intensity`].value),u=mt(t[`f${n}_factor`].value);return[o,a,l,c,u,s,i].forEach(h=>e[h.uuid]=h),Object.assign(r,{uniforms:{[`f${n}_color`]:o.uuid,[`f${n}_bias`]:a.uuid,[`f${n}_scale`]:l.uuid,[`f${n}_intensity`]:c.uuid,[`f${n}_factor`]:u.uuid,[`f${n}_alpha`]:s.uuid,[`f${n}_mode`]:i.uuid}}),{uuid:Ee.generateUUID(),type:"v3",nodeType:"Fresnel",color:o.uuid,bias:a.uuid,scale:l.uuid,intensity:c.uuid,factor:u.uuid,alpha:s.uuid,mode:i.uuid}}function jM(r,e){let t=r.uniforms,n=r.id,i=an(t[`f${n}_mode`].value),s=mt(t[`f${n}_alpha`].value),o=an(t[`f${n}_gl_type`].value),a=an(t[`f${n}_num`].value),l=RM(t[`f${n}_smooth`].value),c=OM(10,t[`f${n}_colors`].value),u=BM(10,t[`f${n}_steps`].value),h=El(t[`f${n}_offset`].value),d=El(t[`f${n}_morph`].value),f=mt(t[`f${n}_angle`].value);return[o,a,l,c,u,h,d,f,s,i].forEach(p=>e[p.uuid]=p),Object.assign(r,{uniforms:{[`f${n}_gl_type`]:o.uuid,[`f${n}_num`]:a.uuid,[`f${n}_smooth`]:l.uuid,[`f${n}_colors`]:c.uuid,[`f${n}_steps`]:u.uuid,[`f${n}_offset`]:h.uuid,[`f${n}_morph`]:d.uuid,[`f${n}_angle`]:f.uuid,[`f${n}_alpha`]:s.uuid,[`f${n}_mode`]:i.uuid}}),{uuid:Ee.generateUUID(),type:"v3",nodeType:"Gradient",gl_type:o.uuid,num:a.uuid,smooth:l.uuid,colors:c.uuid,steps:u.uuid,offset:h.uuid,morph:d.uuid,angle:f.uuid,alpha:s.uuid,mode:i.uuid}}function WM(r,e){let t=r.uniforms,n=r.id,i=Ee.generateUUID(),s=an(t[`f${n}_mode`].value),o=mt(t[`f${n}_alpha`].value),a=mt(t[`f${n}_crop`].value),l=GM(0),c=zM(t[`f${n}_texture`].value,l),u=FM(t[`f${n}_mat`].value);return[c,l,u,a,o,s].forEach(h=>e[h.uuid]=h),Object.assign(r,{uniforms:{[`f${n}_texture`]:c.uuid,[`f${n}_mat`]:u.uuid,[`f${n}_crop`]:a.uuid,[`f${n}_alpha`]:o.uuid,[`f${n}_mode`]:s.uuid}}),{uuid:i,type:"v3",nodeType:"CustomTexture",texture:c.uuid,crop:a.uuid,alpha:o.uuid,mode:s.uuid}}function JM(r,e){let t=r.uniforms,n=r.id,i=an(t[`f${n}_mode`].value),s=mt(t[`f${n}_alpha`].value),o=mt(t[`f${n}_scale`].value),a=mt(t[`f${n}_move`].value),l=El(t[`f${n}_fA`].value),c=El(t[`f${n}_fB`].value),u=El(t[`f${n}_distortion`].value),h=Si(t[`f${n}_colorA`].value),d=Si(t[`f${n}_colorB`].value),f=Si(t[`f${n}_colorC`].value),p=Si(t[`f${n}_colorD`].value),m=an(t[`f${n}_intA`].value),v=an(t[`f${n}_intB`].value),g=an(t[`f${n}_intC`].value),y=an(t[`f${n}_intD`].value);return[o,a,l,c,u,h,d,f,p,m,v,g,y,s,i].forEach(x=>e[x.uuid]=x),Object.assign(r,{uniforms:{[`f${n}_scale`]:o.uuid,[`f${n}_move`]:a.uuid,[`f${n}_fA`]:l.uuid,[`f${n}_fB`]:c.uuid,[`f${n}_distortion`]:u.uuid,[`f${n}_colorA`]:h.uuid,[`f${n}_colorB`]:d.uuid,[`f${n}_colorC`]:f.uuid,[`f${n}_colorD`]:p.uuid,[`f${n}_intA`]:m.uuid,[`f${n}_intB`]:v.uuid,[`f${n}_intC`]:g.uuid,[`f${n}_intD`]:y.uuid,[`f${n}_alpha`]:s.uuid,[`f${n}_mode`]:i.uuid}}),{uuid:Ee.generateUUID(),type:"v3",nodeType:"Noise",scale:o.uuid,move:a.uuid,fA:l.uuid,fB:c.uuid,distortion:u.uuid,colorA:h.uuid,colorB:d.uuid,colorC:f.uuid,colorD:p.uuid,intA:m.uuid,intB:v.uuid,intC:g.uuid,intD:y.uuid,alpha:s.uuid,mode:i.uuid}}function gg(r,e,t){let n=e.uniforms,i=e.id,s=mt(n[`f${i}_alpha`].value),o=an(n[`f${i}_mode`].value);return[s,o].forEach(a=>t[a.uuid]=a),Object.assign(e,{uniforms:{[`f${i}_alpha`]:s.uuid,[`f${i}_mode`]:o.uuid}}),{uuid:Ee.generateUUID(),type:"basic",nodeType:"Basic",shadingAlpha:s.uuid,shadingBlend:o.uuid}}function XM(r,e,t){var c,u;let n=e.uniforms,i=e.id,s=Si((c=r.specular)!=null?c:69905),o=mt((u=r.shininess)!=null?u:30),a=mt(n[`f${i}_alpha`].value),l=an(n[`f${i}_mode`].value);return[s,o,a,l].forEach(h=>t[h.uuid]=h),Object.assign(e,{uniforms:{[`f${i}_alpha`]:a.uuid,[`f${i}_mode`]:l.uuid}}),{uuid:Ee.generateUUID(),type:"phong",nodeType:"Phong",specular:s.uuid,shininess:o.uuid,shadingAlpha:a.uuid,shadingBlend:l.uuid}}function qM(r,e,t){var c,u;let n=e.uniforms,i=e.id,s=Si((c=r.emissive)!=null?c:0),o=mt((u=r.emissiveIntensity)!=null?u:1),a=mt(n[`f${i}_alpha`].value),l=an(n[`f${i}_mode`].value);return[o,s,a,l].forEach(h=>t[h.uuid]=h),Object.assign(e,{uniforms:{[`f${i}_alpha`]:a.uuid,[`f${i}_mode`]:l.uuid}}),{uuid:Ee.generateUUID(),type:"lambert",nodeType:"Lambert",emissiveIntensity:o.uuid,emissive:s.uuid,shadingAlpha:a.uuid,shadingBlend:l.uuid}}function YM(r,e,t){var c,u;let n=e.uniforms,i=e.id,s=Si((c=r.specular)!=null?c:69905),o=mt((u=r.shininess)!=null?u:30),a=mt(n[`f${i}_alpha`].value),l=an(n[`f${i}_mode`].value);return[s,o,a,l].forEach(h=>t[h.uuid]=h),Object.assign(e,{uniforms:{[`f${i}_alpha`]:a.uuid,[`f${i}_mode`]:l.uuid}}),{uuid:Ee.generateUUID(),type:"toon",nodeType:"Toon",specular:s.uuid,shininess:o.uuid,shadingAlpha:a.uuid,shadingBlend:l.uuid}}function KM(r,e,t){var u,h,d;let n=e.uniforms,i=e.id,s=mt((u=r.roughness)!=null?u:.3),o=mt((h=r.metalness)!=null?h:0),a=mt((d=r.reflectivity)!=null?d:.5),l=mt(n[`f${i}_alpha`].value),c=an(n[`f${i}_mode`].value);return[s,o,a,l,c].forEach(f=>t[f.uuid]=f),Object.assign(e,{uniforms:{[`f${i}_alpha`]:l.uuid,[`f${i}_mode`]:c.uuid}}),{uuid:Ee.generateUUID(),type:"standard",nodeType:"Standard",roughness:s.uuid,metalness:o.uuid,reflectivity:a.uuid,shadingAlpha:l.uuid,shadingBlend:c.uuid}}var QM=new me,_F=["RectangleGeometry","TriangleGeometry","PolygonGeometry","StarGeometry"];function ZM(r){let e={};NF(r.materials,e),EF(r.interactionStates,e),TF(r.geometries,r.object),Object.keys(e).length&&(r.nodes=IF(e))}function $M(r,e){let t=r.geometry;if(t&&t===e)return r;let n=r.children;if(n)for(let i=0,s=n.length;i<s;i++){let o=n[i],a=$M(o,e);if(a!==void 0)return a}}function TF(r,e){var t;if(r!==void 0){for(let n of r)if(n.userData&&_F.includes((t=n.userData)==null?void 0:t.type)){let i=n.userData.parameters,s=i.extrudeBevelSize;if(s>0){i.width+=s*2,i.height+=s*2,i.extrudeDepth+=s*2;let o=$M(e,n.uuid);if(o!==void 0){let a=new Ke;QM.fromArray(o.matrix),a.applyMatrix4(QM),a.position.z-=s,a.updateMatrix(),o.matrix=a.matrix.toArray()}}}}}function EF(r,e){if(r!==void 0){for(let t of r)if(t.material)if(Array.isArray(t.material))for(let n of t.material)for(let i of n.layersList)pu(i,e);else for(let n of t.material.layersList)pu(n,e)}}function NF(r,e){if(r!==void 0)for(let t of r){let{beforeLayers:n,lightingLayer:i,afterLayers:s}=CF(t.userData.layers);if(!i){console.error("Material upgrade: could not find a ligthing layer");continue}let o=LF(t,i,e);if(e[o.uuid]=o,n.length>0){let a=pu(n[0],e);e[a.uuid]=a;for(let l=1,c=n.length;l<c;++l){let u=n[l],h=pu(u,e),d=pg(a,h);e[d.uuid]=d,e[h.uuid]=h,a=d}o.color=a.uuid}if(s.length>0){let a;for(let l of s){let c=pu(l,e),u=pg(a,c);e[u.uuid]=u,e[c.uuid]=c,a=u}o.afterColor=a==null?void 0:a.uuid}Object.assign(t,{type:"ShaderMaterial",wireframeLinecap:"",wireframeLinejoin:"",vertex:o==null?void 0:o.uuid,fragment:o==null?void 0:o.uuid}),delete t.color,delete t.emissive,delete t.specular,delete t.shininess,delete t.roughness,delete t.metalness}}function CF(r){let e=[],t=[],n,i=r.head;for(;i;){if(i.type==="light"){n=i,i=i.next;break}e.push(i),i=i.next}for(;i;)t.unshift(i),i=i.next;return{beforeLayers:e,lightingLayer:n,afterLayers:t}}function LF(r,e,t){let n,i;switch(r.userData.type){case"BasicMaterial":n=gg(r,e,t),i="BasicNodeMaterial";break;case"PhongMaterial":n=XM(r,e,t),i="PhongNodeMaterial";break;case"LambertMaterial":n=qM(r,e,t),i="LambertNodeMaterial";break;case"ToonMaterial":n=YM(r,e,t),i="ToonNodeMaterial";break;case"PhysicalMaterial":n=KM(r,e,t),i="StandardNodeMaterial";break;default:console.warn(`Material upgrade: could not find a properly material node to ${r.userData.type}`),n=gg(r,e,t),i="BasicNodeMaterial"}return Object.assign(r.userData,{nodeType:i}),n}function pu(r,e){switch(r.type){case"light":return UM(r,e);case"color":return mg(r,e);case"depth":return VM(r,e);case"fresnel":return HM(r,e);case"gradient":return jM(r,e);case"noise":return JM(r,e);case"normal":return kM(r,e);case"texture":return WM(r,e);default:return console.warn(`Material upgrade: could not find a properly "layer" node to ${r.type}`),mg(r,e)}}function IF(r){let e=[];for(let t in r)e.push(r[t]);return e}function yg(r){let e=r.metadata;return console.info(`File format version ${e==null?void 0:e.version}`),(e==null?void 0:e.version)===void 0?(console.warn("Unknow file version"),!1):((e.version<=1.1||e.version===4.5)&&(CM(r),e.version=1.2,console.warn("File upgraded from v1.1 or inferior to v1.2")),e.version===1.2&&(IM(r),e.version=1.3,console.warn("File upgraded from v1.2 to v1.3")),e.version===1.3&&(DM(r),e.version=1.4,console.warn("File upgraded from v1.3 to v1.4")),e.version===1.4&&(ZM(r),e.version=1.5,console.warn("File upgraded from v1.4 to v1.5")),!0)}var nA=Cg(tA()),iA=new me,PF=new me,DF=new me,RF=new me,Nl=class extends Vn{constructor(e=Qn.create({}),t=new Ci){super(e,t);this.objectType="SubdivObject";this.resized=!1;this.newlyPasted=!1;this.matrixWorldRigid=new me;this.scaleMatrix=new me;this.hiddenMatrixOld=new me;this.isNegativeDeterminant=!1;this.isUniformScaling=!0;this.castShadow=!0,this.receiveShadow=!0,this.forceComputeSize=!1,this.subdivPointer=Qn.activeSubdivPtr}toJSON(e){let t=super.toJSON(e);return t.object.objectType="SubdivObject",t}updateGeometry(e){let t=this.geometry,n=Uc[t.userData.type],i=this.objectType==="SubdivObject"?Object.assign({},t.userData,{geometry:t,subdivPointer:this.subdivPointer,smoothShading:this.smoothShading}):t.userData,s=n.build(n.normalizeInputs(e,i));this.geometry.dispose(),this.geometry=s}clone(e){var a,l;if(this.resized){this.resized=!1;let c;this.geometry.userData.parameters.subdivisions>0?c=this.geometry.originalGeometry:c=this.geometry,Qn.allocate(c),this.subdivPointer=Qn.activeSubdivPtr}let t=this.material.clone(),n=Qn.clone(Ue({},this.geometry.userData.parameters),this.subdivPointer,this.smoothShading),i=(a=this.geometry.originalGeometry)!=null?a:this.geometry,s=(l=n.originalGeometry)!=null?l:n;s.boundingSphere=i.boundingSphere.clone();let o=new Nl(n,t).copy(this,e);return o.subdivPointer=Qn.activeSubdivPtr,o}raycast(e,t){let n=this.geometry.originalGeometry;if(n){let i=this.geometry;this.geometry=n,Vn.prototype.raycast.call(this,e,t),this.geometry=i}else Vn.prototype.raycast.call(this,e,t)}applySVDScaling(){let e=this.matrixWorld.elements,t=[[e[0],e[4],e[8]],[e[1],e[5],e[9]],[e[2],e[6],e[10]]],{u:n,v:i,q:s}=(0,nA.SVD)(t);this.isNegativeDeterminant=this.matrixWorld.determinant()<0,this.isUniformScaling=s.every(h=>Math.abs(s[0]-h)<.01);let o,a,l=iA.set(n[0][0],n[0][1],n[0][2],0,n[1][0],n[1][1],n[1][2],0,n[2][0],n[2][1],n[2][2],0,0,0,0,1),c=PF.set(i[0][0],i[0][1],i[0][2],0,i[1][0],i[1][1],i[1][2],0,i[2][0],i[2][1],i[2][2],0,0,0,0,1),u=DF.copy(c).transpose();if(o=RF.makeScale(s[0],s[1],s[2]).multiply(u).premultiply(c),a=l.multiply(u),!this.isUniformScaling){this.geometry.applyMatrix4(o);let h=this.geometry.originalGeometry;h?(h.applyMatrix4(o),h.getAttribute("positionWASM").applyMatrix4(o)):this.geometry.getAttribute("positionWASM").applyMatrix4(o),this.resized=!0}return{scaleMatrix:o,matrixWorldRigid:a}}revertSVDScaling(e){let t=this.geometry.originalGeometry;t?Qn.getTopologicalMesh(t):Qn.getTopologicalMesh(this.geometry);let n=e.elements,i=[n[0],n[5],n[10]];if(!i.every(o=>Math.abs(i[0]-o)<.01)){let o=iA.copy(this.scaleMatrix).invert();this.geometry.applyMatrix4(o),t?(t.applyMatrix4(o),t.getAttribute("positionWASM").applyMatrix4(o)):this.geometry.getAttribute("positionWASM").applyMatrix4(o),this.resized=!0}}};var vg=class{constructor(){this._buffers=[]}parse(e){var n;let t=new we;if(this._vertexData=e.vertexData,this._loadBuffers(this._vertexData.buffers),t.uuid=e.uuid,this._vertexData.accessors)for(let i=0,s=this._vertexData.accessors.length;i<s;++i){let o=this._vertexData.accessors[i].attributeName;o==="indices"?t.setIndex(this._loadAccessor(i)):t.setAttribute(o,this._loadAccessor(i))}if((n=e.data)==null?void 0:n.groups)for(let i of e.data.groups)t.addGroup(i.start,i.count,i.materialIndex);return t}_loadAccessor(e){let t=this._vertexData.accessors[e],n=this._loadBufferView(t.bufferView),i=OF[t.type],s=BF[t.componentType],o=new s(n.buffer);return new Re(o,i)}_loadBufferView(e){let t=this._vertexData.bufferViews[e],n=this._buffers[t.buffer],i=t.byteLength||0,s=t.byteOffset||0;return n.slice(s,s+i)}_loadBuffers(e){for(let t of e){if(!t.uri)continue;let n=t.uri.slice(t.uri.indexOf("base64")+7),i=atob(n),s=new Uint8Array(i.length);for(let o=0;o<i.length;o++)s[o]=i.charCodeAt(o);this._buffers.push(s)}}},BF={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},OF={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16};var xg=new WeakMap,bg=class extends fn{constructor(e){super(e);this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,n,i){let s=new Xn(this.manager);s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,o=>{let a={attributeIDs:this.defaultAttributeIDs,attributeTypes:this.defaultAttributeTypes,useUniqueIDs:!1};this.decodeGeometry(o,a).then(t).catch(i)},n,i)}decodeDracoFile(e,t,n,i){let s={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:i||this.defaultAttributeTypes,useUniqueIDs:!!n};this.decodeGeometry(e,s).then(t)}decodeGeometry(e,t){for(let l in t.attributeTypes){let c=t.attributeTypes[l];c.BYTES_PER_ELEMENT!==void 0&&(t.attributeTypes[l]=c.name)}let n=JSON.stringify(t);if(xg.has(e)){let l=xg.get(e);if(l.key===n)return l.promise;if(e.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let i,s=this.workerNextTaskID++,o=e.byteLength,a=this._getWorker(s,o).then(l=>(i=l,new Promise((c,u)=>{i._callbacks[s]={resolve:c,reject:u},i.postMessage({type:"decode",id:s,taskConfig:t,buffer:e},[e])}))).then(l=>this._createGeometry(l.geometry));return a.catch(()=>!0).then(()=>{i&&s&&this._releaseTask(i,s)}),xg.set(e,{key:n,promise:a}),a}_createGeometry(e){let t=new we;e.index&&t.setIndex(new Re(e.index.array,1));for(let n=0;n<e.attributes.length;n++){let i=e.attributes[n],s=i.name,o=i.array,a=i.itemSize;t.setAttribute(s,new Re(o,a))}return t}_loadLibrary(e,t){let n=new Xn(this.manager);return n.setPath(this.decoderPath),n.setResponseType(t),n.setWithCredentials(this.withCredentials),new Promise((i,s)=>{n.load(e,i,void 0,s)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;let e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(n=>{let i=n[0];e||(this.decoderConfig.wasmBinary=n[1]);let s=FF.toString(),o=["/* draco decoder */",i,"","/* worker */",s.substring(s.indexOf("{")+1,s.lastIndexOf("}"))].join(`
|
|
4395
4395
|
`);this.workerSourceURL=URL.createObjectURL(new Blob([o]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){let i=new Worker(this.workerSourceURL);i._callbacks={},i._taskCosts={},i._taskLoad=0,i.postMessage({type:"init",decoderConfig:this.decoderConfig}),i.onmessage=function(s){let o=s.data;switch(o.type){case"decode":i._callbacks[o.id].resolve(o);break;case"error":i._callbacks[o.id].reject(o);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+o.type+'"')}},this.workerPool.push(i)}else this.workerPool.sort(function(i,s){return i._taskLoad>s._taskLoad?-1:1});let n=this.workerPool[this.workerPool.length-1];return n._taskCosts[e]=t,n._taskLoad+=t,n})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this}};function FF(){let r,e;onmessage=function(o){let a=o.data;switch(a.type){case"init":r=a.decoderConfig,e=new Promise(function(u){r.onModuleLoaded=function(h){u({draco:h})},DracoDecoderModule(r)});break;case"decode":let l=a.buffer,c=a.taskConfig;e.then(u=>{let h=u.draco,d=new h.Decoder,f=new h.DecoderBuffer;f.Init(new Int8Array(l),l.byteLength);try{let p=t(h,d,f,c),m=p.attributes.map(v=>v.array.buffer);p.index&&m.push(p.index.array.buffer),self.postMessage({type:"decode",id:a.id,geometry:p},m)}catch(p){console.error(p),self.postMessage({type:"error",id:a.id,error:p.message})}finally{h.destroy(f),h.destroy(d)}});break}};function t(o,a,l,c){let u=c.attributeIDs,h=c.attributeTypes,d,f,p=a.GetEncodedGeometryType(l);if(p===o.TRIANGULAR_MESH)d=new o.Mesh,f=a.DecodeBufferToMesh(l,d);else if(p===o.POINT_CLOUD)d=new o.PointCloud,f=a.DecodeBufferToPointCloud(l,d);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!f.ok()||d.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+f.error_msg());let m={index:null,attributes:[]};for(let v in u){let g=self[h[v]],y,x;if(c.useUniqueIDs)x=u[v],y=a.GetAttributeByUniqueId(d,x);else{if(x=a.GetAttributeId(d,o[u[v]]),x===-1)continue;y=a.GetAttribute(d,x)}m.attributes.push(i(o,a,d,v,g,y))}return p===o.TRIANGULAR_MESH&&(m.index=n(o,a,d)),o.destroy(d),m}function n(o,a,l){let u=l.num_faces()*3,h=u*4,d=o._malloc(h);a.GetTrianglesUInt32Array(l,h,d);let f=new Uint32Array(o.HEAPF32.buffer,d,u).slice();return o._free(d),{array:f,itemSize:1}}function i(o,a,l,c,u,h){let d=h.num_components(),p=l.num_points()*d,m=p*u.BYTES_PER_ELEMENT,v=s(o,u),g=o._malloc(m);a.GetAttributeDataArrayForAllPoints(l,h,v,m,g);let y=new u(o.HEAPF32.buffer,g,p).slice();return o._free(g),{name:c,array:y,itemSize:d}}function s(o,a){switch(a){case Float32Array:return o.DT_FLOAT32;case Int8Array:return o.DT_INT8;case Int16Array:return o.DT_INT16;case Int32Array:return o.DT_INT32;case Uint8Array:return o.DT_UINT8;case Uint16Array:return o.DT_UINT16;case Uint32Array:return o.DT_UINT32}}}function Cl(r){let e;return r instanceof Array?(e={},r.forEach(t=>{e[t.uuid]=t})):e=r,e}function rA(r,e){return r[e]===void 0&&console.warn("ObjectLoader > getGeometry: undefined geometry",e),r[e]}function sA(r,e){if(e!==void 0){if(e instanceof Array){let t=[];for(let n=0,i=e.length;n<i;n++){let s=e[n];r[s]===void 0&&console.warn("ObjectLoader > getMaterial: undefined material",s),t.push(r[s])}return t}return r[e]===void 0&&console.warn("ObjectLoader > getMaterial: undefined material",e),r[e]}}var wg=class extends gx(Ap){constructor(){super(...arguments);this.path="";this.resourcePath=""}async loadFromFile(e){var s;let t=await LS(e,this.manager,Ds.TEXT),{object:n,materials:i}=this.parse(JSON.parse(t));return n.name=(s=e.name.split(".").shift())!=null?s:e.name,this.manager.itemEnd(e.name),{scene:n,materials:i}}load(e,t,n,i){let s=this.path===""?Ei.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||s;let o=new Xn(this.manager);o.setPath(this.path),o.load(e,a=>{let l=null;try{l=JSON.parse(a)}catch(u){i!==void 0&&i(u),console.warn(`ObjectLoader > load: can't parse ${e}.`),console.error(u);return}let c=l.metadata;if(c===void 0||c.type===void 0||c.type.toLowerCase()==="geometry"){console.error("ObjectLoader: Can't load "+e);return}this.parse(l,t)},n,i)}parse(e,t){var d;if(yg(e)===!1)return console.error("File can not be parser"),{object:new zs,materials:{}};let n={},i=this.parseGeometries(e.geometries),s=this.loader.parseImages(e.images,()=>{t!==void 0&&t(u)}),o=this.parseTextures(e.textures,s),a=new Jd;a.init(Cl((d=e.nodes)!=null?d:[]),Cl(o));let l=Cl(this.loader.parseMaterials(e.materials,o)),c=this.customParseMaterials(l,e.materials,a),u=this.parseObject(e.object,i,c,n);this.upgradeNoise(u);let h=this.parseInteractionStates(e.interactionStates,a);return this.parseInteractions(e.object,n,h),(e.images===void 0||e.images.length===0)&&t!==void 0&&t(u),{object:u,materials:c}}upgradeNoise(e){e.traverseEntity(t=>{var n;if(t.type==="Mesh"){let i=t,s=i.material;if(!s.userData)return;let o=(n=s.userData.layers)==null?void 0:n.head;for(;o;){if(o.type===lt.NOISE&&o.uniforms[`f${o.id}_size`].value.equals(new M(-1,-1,-1))&&(i.geometry.boundingBox||i.geometry.computeBoundingBox(),i.geometry.boundingBox)){let a=o.uniforms[`f${o.id}_scale`].value,{x:l,y:c,z:u}=i.geometry.boundingBox.max,h=Math.max(l,Math.max(c,u))/(a*a);o.uniforms[`f${o.id}_size`].value.x=h,o.uniforms[`f${o.id}_size`].value.y=h,o.uniforms[`f${o.id}_size`].value.z=h}o=o.next}}})}parseGeometries(e){var n,i;let t={};if(e!==void 0)for(let s=0,o=e.length;s<o;s++){let a=e[s],l;try{switch((n=a.userData)==null?void 0:n.type){case void 0:l=this.loader.parseGeometries([a])[a.uuid];break;case"NonParametricGeometry":a.vertexData?l=new vg().parse(a):l=this.loader.parseGeometries([a])[a.uuid],l.userData={};let c=Object.assign({},a.userData,{geometry:l});l=Lo.create(c);break;case"SubdivGeometry":l=this.loader.parseGeometries([a])[a.uuid],l=Qn.create({parameters:a.userData.parameters,geometry:l}),Qn.activeSubdivPtr=void 0;break;default:l=kc(a.userData)}l.uuid=a.uuid,a.name!==void 0&&(l.name=a.name),t[a.uuid]=l}catch(c){console.warn("ObjectLoader > parseGeometries: error parsing geometry of type .",(i=a.userData)==null?void 0:i.type),console.error(c)}}return t}async parseAsync(e){var h;if(yg(e)===!1)return console.error("File can not be parser"),new zs;let t=new Jd,n={},i=await this.parseGeometriesAsync(e.geometries),s=this.loader.parseImages(e.images,()=>{}),o=this.parseTextures(e.textures,s);t.init(Cl((h=e.nodes)!=null?h:[]),Cl(o));let a=Cl(this.loader.parseMaterials(e.materials,o)),l=this.customParseMaterials(a,e.materials,t),c=await this.parseObjectAsync(e.object,i,l,n),u=this.parseInteractionStates(e.interactionStates,t);return this.parseInteractions(e.object,n,u),c}async parseGeometriesAsync(e){var n,i;let t={};if(e!==void 0)for(let s=0,o=e.length;s<o;s++){let a=e[s],l;try{switch((n=a.userData)==null?void 0:n.type){case void 0:l=this.loader.parseGeometries([a])[a.uuid];break;case"NonParametricGeometry":if(a.gltf){if(!this.gltfLoader){this.gltfLoader=new Zm;let d=new bg;d.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.4.2/"),this.gltfLoader.setDRACOLoader(d)}let u=await new Promise(d=>{this.gltfLoader.parse(JSON.stringify(a.gltf),"",d)}),h=[];u.scene.traverse(d=>{let f=d;f.isMesh&&h.push(f.geometry)}),h.length===1?l=h[0]:(h=Jm(h,d=>d.userData.groupIndex),l=tl.mergeBufferGeometries(h,!0),l.groups.forEach((d,f)=>{d.materialIndex=h[f].userData.materialIndex}))}else l=this.loader.parseGeometries([a])[a.uuid];l.userData={};let c=Object.assign({},a.userData,{geometry:l});l=Lo.create(c);break;default:l=kc(a.userData)}l.uuid=a.uuid,a.name!==void 0&&(l.name=a.name),t[a.uuid]=l}catch(c){console.warn("ObjectLoader > parseGeometries: error parsing geometry of type .",(i=a.userData)==null?void 0:i.type),console.error(c)}}return t}parseTextures(e,t){let n=this.loader.parseTextures(e,t);return Object.keys(n).forEach(i=>{let s=new bi().copy(n[i]);s.uuid=i,n[i]=s}),n}customParseMaterials(e,t,n){let i={};if(t!==void 0)for(let s=0,o=t.length;s<o;s++){let a=t[s],l=e[a.uuid],c=l.userData;if(c.type!==void 0){let u=wx[c.type];i[a.uuid]=u.fromJSON(l,a,n)}}return i}parseObject(e,t,n,i){let s;if(e.geometry!==void 0){let o=rA(t,e.geometry),a=sA(n,e.material);if(o){switch(e.objectType){case"Mesh2D":s=new Ml(o,a).fromJSON(e);break;case"Mesh3D":s=new Al(o,a).fromJSON(e);break;case"NonParametric":s=new Fd(o,a).fromJSON(e);break;case"TextFrame":s=new Os(o,a),s.fromJSONasync(e).then(()=>{}).catch(()=>{});break;case"VectorObject":s=new Ps(o,a).fromJSON(e);break;case"SubdivObject":s=new Nl(o,a).fromJSON(e),s.subdivPointer=o.subdivPointer;break;default:console.warn("ObjectLoader > parseObject: unsupported object type",e.objectType);return}a||(s.name+=" (Recovered)")}else s=new Pi().fromJSON(e),s.name+=" (Recovered)",console.warn("An empty object is created instead")}else switch(e.objectType){case"Scene":s=new zs().fromJSON(e);break;case"CombinedCamera":s=new Sr().fromJSON(e);break;case"LightDirectional":s=new Rd().fromJSON(e);break;case"LightPoint":s=new Bd().fromJSON(e);break;case"LightSpot":s=new Od().fromJSON(e);break;case"EmptyObject":s=new Pi().fromJSON(e);break;default:if(e.type==="HemisphereLight"||e.type==="DirectionalLight")s=this.loader.parseObject(e,t,n);else{console.warn("ObjectLoader > parseObject: unsupported object type",e.objectType);return}}if(ei(s)&&(i[e.uuid]=s),e.children!==void 0)for(let o of e.children){let a=this.parseObject(o,t,n,i);a!==void 0&&s.add(a)}return s instanceof zs&&s.initFromObjectLoader(e),s}async parseObjectAsync(e,t,n,i){let s;if(e.geometry!==void 0){let o=rA(t,e.geometry),a=sA(n,e.material);if(o){switch(e.objectType){case"Mesh2D":s=new Ml(o,a).fromJSON(e);break;case"Mesh3D":s=new Al(o,a).fromJSON(e);break;case"NonParametric":s=new Fd(o,a).fromJSON(e);break;case"TextFrame":s=new Os(o,a);try{await s.fromJSONasync(e)}catch(l){console.log(l)}break;case"VectorObject":s=new Ps(o,a).fromJSON(e);break;case"SubdivObject":s=new Nl(o,a).fromJSON(e),s.subdivPointer=o.subdivPointer;break;default:console.warn("ObjectLoader > parseObject: unsupported object type",e.objectType);return}a||(s.name+=" (Recovered)")}else s=new Pi().fromJSON(e),s.name+=" (Recovered)",console.warn("An empty object is created instead")}else switch(e.objectType){case"Scene":s=new zs().fromJSON(e);break;case"CombinedCamera":s=new Sr().fromJSON(e);break;case"LightDirectional":s=new Rd().fromJSON(e);break;case"LightPoint":s=new Bd().fromJSON(e);break;case"LightSpot":s=new Od().fromJSON(e);break;case"EmptyObject":s=new Pi().fromJSON(e);break;default:if(e.type==="HemisphereLight"||e.type==="DirectionalLight")s=this.loader.parseObject(e,t,n);else{console.warn("ObjectLoader > parseObject: unsupported object type",e.objectType);return}}if(ei(s)&&(i[e.uuid]=s),e.children!==void 0)for(let o of e.children){let a=await this.parseObjectAsync(o,t,n,i);a!==void 0&&s.add(a)}return s instanceof zs&&s.initFromObjectLoader(e),s}parseInteractionStates(e,t){let n={};if(e!==void 0)for(let i=0,s=e.length;i<s;i++){let o=new bs().fromJSON(e[i],t);n[o.uuid]=o}return n}parseInteractions(e,t,n){let i=t[e.uuid];if(e.interaction!==void 0&&i!==void 0&&(i.interaction=new Ls(i).fromJSON(e.interaction,t,n)),e.children!==void 0)for(let s of e.children)this.parseInteractions(s,t,n)}};var Sg=class{constructor(e,t,n,i){this.isEnable=!1;this._enableEvent={};this._map={};this._prevAncestors=[];this._raycaster=new Up;this._intersection=new M;this._plane=new ni;this._normal=new M;this._position=new M;this._onMouseDown=e=>{this._raycaster.setFromCamera(this._getPointer(e.clientX,e.clientY),this._camera),this._handleMouseDownEvent()};this._onMouseUp=e=>{this._raycaster.setFromCamera(this._getPointer(e.clientX,e.clientY),this._camera),this._handleMouseUpEvent()};this._onMouseMove=e=>{this._raycaster.setFromCamera(this._getPointer(e.clientX,e.clientY),this._camera),this._camera.getWorldDirection(this._normal),this._normal.negate(),this._handleMouseHoverEvent(),this._handleLookAtEvent(),this._handleFollowEvent()};this._onTouchStart=e=>{e.touches.length===1&&(e.preventDefault(),this._raycaster.setFromCamera(this._getPointer(e.touches[0].clientX,e.touches[0].clientY),this._camera),this._camera.getWorldDirection(this._normal),this._normal.negate(),this._handleMouseDownEvent(),this._handleMouseHoverEvent(),this._handleLookAtEvent(),this._handleFollowEvent())};this._onTouchEnd=()=>{this._handleMouseUpEvent(),this._handleMouseHoverEvent(!0)};this._onTouchMove=e=>{e.touches.length===1&&(e.preventDefault(),e.stopPropagation(),this._raycaster.setFromCamera(this._getPointer(e.touches[0].clientX,e.touches[0].clientY),this._camera),this._camera.getWorldDirection(this._normal),this._normal.negate(),this._handleMouseHoverEvent(),this._handleLookAtEvent(),this._handleFollowEvent())};this._onKeyDown=e=>{this._handleKeyDownEvent(e.key)};this._onKeyUp=e=>{this._handleKeyUpEvent(e.key)};this._domElement=e,this._scene=t,this._camera=n,this._app=i}activate(){this.isEnable=!0,this._scene.traverseEntity(e=>{if(e.interaction!==void 0){e.interaction.start();for(let t of e.interaction.events){let n=t.type;this._enableEvent[n]=!0,(n===Ze.KEY_DOWN||n===Ze.KEY_UP||n===Ze.START||n===Ze.LOOK_AT||n===Ze.FOLLOW)&&(this._map[n]===void 0&&(this._map[n]=[]),this._map[n].push(e))}}}),this._enableEvent[Ze.START]!==void 0&&this._handleStartEvent(),this._enableEvent[Ze.MOUSE_DOWN]!==void 0&&(this._domElement.addEventListener("pointerdown",this._onMouseDown,!1),this._domElement.addEventListener("touchstart",this._onTouchStart,!1)),this._enableEvent[Ze.MOUSE_UP]!==void 0&&(this._domElement.addEventListener("pointerup",this._onMouseUp,!1),this._domElement.addEventListener("touchend",this._onTouchEnd,!1)),(this._enableEvent[Ze.MOUSE_HOVER]!==void 0||this._enableEvent[Ze.LOOK_AT]!==void 0||this._enableEvent[Ze.FOLLOW]!==void 0)&&(this._domElement.addEventListener("pointermove",this._onMouseMove,!1),this._domElement.addEventListener("touchstart",this._onTouchStart,!1),this._domElement.addEventListener("touchend",this._onTouchEnd,!1),this._domElement.addEventListener("touchmove",this._onTouchMove,!1)),this._enableEvent[Ze.KEY_DOWN]!==void 0&&document.addEventListener("keydown",this._onKeyDown,!1),this._enableEvent[Ze.KEY_UP]!==void 0&&document.addEventListener("keyup",this._onKeyUp,!1)}deactivate(){this._scene.traverseEntity(e=>{e.interaction!==void 0&&e.interaction.end(),e.interaction.cache=void 0}),this._domElement.removeEventListener("pointerdown",this._onMouseDown),this._domElement.removeEventListener("pointerup",this._onMouseUp),this._domElement.removeEventListener("pointermove",this._onMouseMove),this._domElement.removeEventListener("touchstart",this._onTouchStart),this._domElement.removeEventListener("touchend",this._onTouchEnd),this._domElement.removeEventListener("touchmove",this._onTouchMove),document.removeEventListener("keydown",this._onKeyDown),document.removeEventListener("keyup",this._onKeyUp),this._enableEvent={},this._map={},this.isEnable=!1}reset(){this._scene.traverseEntity(e=>{e.interaction.start()}),this._handleStartEvent()}_getPointer(e,t){let n=this._domElement.getBoundingClientRect();return{x:(e-n.left)/n.width*2-1,y:-((t-n.top)/n.height)*2+1}}_handleStartEvent(){var e;(e=this._map[Ze.START])==null||e.forEach(t=>{var n;(n=t.interactionCache.start)==null||n.dispatch()})}_handleMouseDownEvent(){var t;let e=this._raycastMesh(this._raycaster);for(let n=0,i=e.length;n<i;++n){let s=e[n].object;if((t=s.interactionCache.mouseDown)==null||t.dispatch(),s.traverseAncestors(o=>{var a;o instanceof Pi&&((a=o.interactionCache.mouseDown)==null||a.dispatch())}),!s.interactionCache.follow)break}}_handleMouseUpEvent(){var t;let e=this._raycastMesh(this._raycaster);for(let n=0,i=e.length;n<i;++n){let s=e[n].object;if((t=s.interactionCache.mouseUp)==null||t.dispatch(),s.traverseAncestors(o=>{var a;o instanceof Pi&&((a=o.interactionCache.mouseUp)==null||a.dispatch())}),!s.interactionCache.follow)break}}_handleMouseHoverEvent(e=!1){var t,n;if(this._enableEvent[Ze.MOUSE_HOVER]!==void 0){let i;if(!e){let o=this._raycastMesh(this._raycaster).find(a=>!a.object.interactionCache.follow);i=o?o.object:void 0}if(this._prevObject!==i){this._prevObject!==void 0&&((t=this._prevObject.interactionCache.mouseHover)==null||t.dispatchReverse()),i!==void 0&&((n=i.interactionCache.mouseHover)==null||n.dispatch());let s=[];i==null||i.traverseAncestors(l=>{l instanceof Pi&&l.interactionCache.mouseHover&&s.push(l)}),this._prevAncestors.filter(l=>{var c;return s.includes(l)?!1:((c=l.interactionCache.mouseHover)==null||c.dispatchReverse(),!0)});let o=s.filter(l=>{var c;return this._prevAncestors.includes(l)?!1:((c=l.interactionCache.mouseHover)==null||c.dispatch(),!0)}),a=this._prevAncestors.filter(l=>s.includes(l));this._prevAncestors=[...a,...o]}this._prevObject=i}}_handleLookAtEvent(){var e;(e=this._map[Ze.LOOK_AT])==null||e.forEach(t=>{var i;let n=(i=t.interactionCache.lookAt)==null?void 0:i.distance;n!==void 0&&(this._plane.set(this._normal,-n),this._raycaster.ray.intersectPlane(this._plane,this._intersection),t.interaction.lookAt(this._intersection))}),this._app.skipRender=!1}_handleFollowEvent(){var e;(e=this._map[Ze.FOLLOW])==null||e.forEach(t=>{this._plane.setFromNormalAndCoplanarPoint(this._normal,t.getWorldPosition(this._position)),this._raycaster.ray.intersectPlane(this._plane,this._intersection),t.interaction.follow(this._intersection)}),this._app.skipRender=!1}_handleKeyDownEvent(e){var t;(t=this._map[Ze.KEY_DOWN])==null||t.forEach(n=>{var s;let i=(s=n.interactionCache.keyDown)==null?void 0:s.find(o=>o.key===e);i==null||i.dispatch()})}_handleKeyUpEvent(e){var t;(t=this._map[Ze.KEY_UP])==null||t.forEach(n=>{var s;let i=(s=n.interactionCache.keyUp)==null?void 0:s.find(o=>o.key===e);i==null||i.dispatch()})}_raycastMesh(e){let t=[],n=i=>{for(let s of i.children)ei(s)&&!s.raycastLock&&s.visible&&(wS(s)&&e.intersectObject(s,!1,t),n(s))};return n(this._scene),t}};var Mg=class{constructor(e,t,n,i,s){this._aspect=1;this._renderer=e,this._camera=t,this._frameSize=new O().copy(n),this._editorSize=new O().copy(i),this._aspect=t.aspect,this._fov=s!=null?s:t.fov}set frameSize(e){this._frameSize.copy(e)}updateRenderer(){!this._renderer||this._renderer.setSize(this._frameSize.x,this._frameSize.y)}updateViewport(){if(!this._renderer||!this._camera||this._camera.cameraType!=="PerspectiveCamera")return;let e=this._frameSize.x,t=this._frameSize.y,n=this._editorSize.x,i=this._editorSize.y,s=0,o=0,a=e,l=t;e<n&&(s=(n-e)*.5,s=-s,a=n),t<i&&(o=(i-t)*.5,o=-o,l=i),this._aspect=a/l,this._renderer.setViewport(s,o,a,l)}updateCamera(){if(!!this._camera)if(this._camera.cameraType==="PerspectiveCamera"){let e=this._frameSize.y,t=this._editorSize.y,n=this._fov;if(e>t){let i=zF(e,1080,2160,1,15)/100;n*=e/t,n*=1-i}this._camera.aspect=this._aspect,this._camera.fov=n,this._camera.updateProjectionMatrix()}else this._camera.setViewplaneSize(this._frameSize.x,this._frameSize.y)}revert(){let e=window.innerWidth,t=window.innerHeight;this._renderer&&(this._renderer.setViewport(0,0,e,t),this._renderer.setSize(e,t)),this._camera&&(this._camera.aspect=e/t,this._camera.fov=this._fov,this._camera.setViewplaneSize(e,t),this._camera.updateProjectionMatrix())}};function zF(r,e,t,n,i){return(r-e)/(t-e)*(i-n)+n}var ko;(function(t){t[t.FULLSCREEN=1]="FULLSCREEN",t[t.CUSTOM=2]="CUSTOM"})(ko||(ko={}));var GF=class{constructor(){this._needsTransmission=!0;this._viewportMode=1;this._viewportWidth=window.innerWidth;this._viewportHeight=window.innerHeight;this.skipRender=!0;this.render=()=>{var t;requestAnimationFrame(this.render);let e=Ls.isAllAnimationsEnded;if(!(this.skipRender&&(e===void 0||e))){if(!this._renderer){console.error("Application::render >>> tried to renderer without a renderer");return}this._controls&&(this._controls.enableDamping||this._controls.autoRotate)?this.skipRender=!this._controls.update():this.skipRender=!0,this._playmode&&!this._playmode.isEnable&&this._playmode.activate(),this._scene&&this._camera&&(this._renderer.autoClear=!1,this._needsTransmission&&this.renderTransmissionTarget(),((t=this._scene.postprocessing)==null?void 0:t.enabled)?(this._renderer.autoClear=!1,this._scene.postprocessing.render()):(this._renderer.autoClear=!0,this._renderer.render(this._scene,this._camera)))}};this.resize=()=>{var e,t,n,i;this.skipRender=!1,!!this._renderer&&(this._viewportMode===1&&(this._viewportWidth=window.innerWidth,this._viewportHeight=window.innerHeight,this._frameView&&(this._frameView.frameSize=new O(this._viewportWidth,this._viewportHeight))),(e=this._frameView)==null||e.updateRenderer(),((t=this._scene)==null?void 0:t.postprocessing)&&this._scene.postprocessing.resize(this._viewportWidth,this._viewportHeight),this._viewportMode!==1&&((n=this._frameView)==null||n.updateViewport()),this._camera&&((i=this._frameView)==null||i.updateCamera(),this._camera.cameraType==="PerspectiveCamera"&&this._viewportMode===1&&(this._camera.aspect=this._viewportWidth/this._viewportHeight),this._camera.updateProjectionMatrix()))};window.addEventListener("resize",Wm(this.resize,200))}async load(e){let n=await(await fetch(e,{credentials:"include",mode:"no-cors"})).json();await this.start(n)}async start(e){this._editorData=e.editor,this._needsTransmission=e.needsTransmission!==void 0?e.needsTransmission:!0;let n=await new wg().parseAsync(e);this._scene=n,this._camera=this._scene.activeCamera,this.init(),this.resize(),this.render()}renderTransmissionTarget(){!this._renderer||!this._transmissionRenderTarget||!this._scene||!this._camera||(this._renderer.setRenderTarget(this._transmissionRenderTarget),this._renderer.clear(),this._camera.layers.enable(0),this._camera.layers.disable(3),this._renderer.render(this._scene,this._camera),this._renderer.setRenderTarget(null),this._camera.layers.enable(3))}init(){var n,i,s,o;let e=document.getElementById("canvas3d");if(!this._scene||!this._camera)return;((n=this._scene.postprocessing)==null?void 0:n.enabled)?(this._renderer=new wt({canvas:e,antialias:!1,alpha:!0,stencil:!1,depth:!1,powerPreference:"high-performance"}),this._scene.postprocessing.init({renderer:this._renderer,camera:this._camera,scene:this._scene})):this._renderer=new wt({canvas:e,antialias:!0,alpha:!0,stencil:!0,depth:!0,powerPreference:"high-performance"}),this._needsTransmission&&(this._transmissionRenderTarget=new bt(2048,2048,{generateMipmaps:!0,minFilter:Ai,magFilter:$e,wrapS:Zt,wrapT:Zt}),this._transmissionRenderTarget.depthTexture=new so(2048,2048),this._scene.traverseEntity(a=>{if(!(!(a instanceof Vn)||!this._transmissionRenderTarget)&&!Array.isArray(a.material)){let l=a.material.userData.layers.getLayersOfType(lt.TRANSMISSION);for(let c of l)c.uniforms[`f${c.id}_transmissionSamplerMap`].value=this._transmissionRenderTarget.texture,c.uniforms[`f${c.id}_transmissionDepthMap`].value=this._transmissionRenderTarget.depthTexture}})),this._viewportMode=(i=this._scene.canvas.mode)!=null?i:1,this._viewportWidth=(s=this._scene.canvas.size.width)!=null?s:window.innerWidth,this._viewportHeight=(o=this._scene.canvas.size.height)!=null?o:window.innerHeight,this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.setSize(this._viewportWidth,this._viewportHeight),this._scene.postprocessing&&this._scene.postprocessing.resize(this._viewportWidth,this._viewportHeight),this._renderer.shadowMap.enabled=!0,this._renderer.shadowMap.type=qd,this._renderer.setClearColor(this._scene.color,this._scene.alpha),this._frameView=new Mg(this._renderer,this._camera,new O(this._viewportWidth,this._viewportHeight),new O(this._scene.canvas.editorSize.width,this._scene.canvas.editorSize.height)),!0&&(this._controls=new Gp(this._camera,this._renderer.domElement),this._editorData&&(this._controls.fromJSON(this._editorData.orbitControls),this._controls.useKeyEvents=!1),this._controls.addEventListener("change",()=>this.skipRender=!1),this._controls.addEventListener("start",()=>this.skipRender=!1)),this._playmode=new Sg(this._renderer.domElement,this._scene,this._camera,this)}};ui.FONTS_PATH="_assets/_fonts/";export{GF as Application};
|