@dcl/wearable-preview 1.28.2-16155802308.commit-53348f0 → 1.28.2-16170279969.commit-9d54b69
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/assets/{index-FGLz5LIk.js → index-BA0swxZO.js} +2 -2
- package/index.html +3 -3
- package/package.json +3 -3
- package/static-local/assets/{index-DT7hJy32.js → index-CiNxdWy7.js} +1 -1
- package/static-local/index.html +1 -1
- package/static-local/package.json +1 -1
- package/static-local/unity/Build/aang-renderer.data.br +0 -0
- package/static-local/unity/Build/aang-renderer.loader.js +1 -1
- package/static-local/unity/Build/aang-renderer.wasm.br +0 -0
- package/unity/Build/aang-renderer.data.br +0 -0
- package/unity/Build/aang-renderer.loader.js +1 -1
- package/unity/Build/aang-renderer.wasm.br +0 -0
|
@@ -16063,7 +16063,7 @@ vReflectionMapTexCoord.z=worldPos.w;
|
|
|
16063
16063
|
#endif
|
|
16064
16064
|
#include<logDepthVertex>
|
|
16065
16065
|
}
|
|
16066
|
-
`;ce.ShadersStore[FY]=BY;var VY=function(n){j(t,n);function t(){var e=n.call(this)||this;return e.BUMP=!1,e.REFLECTION=!1,e.CLIPPLANE=!1,e.CLIPPLANE2=!1,e.CLIPPLANE3=!1,e.CLIPPLANE4=!1,e.CLIPPLANE5=!1,e.CLIPPLANE6=!1,e.ALPHATEST=!1,e.DEPTHPREPASS=!1,e.POINTSIZE=!1,e.FOG=!1,e.NORMAL=!1,e.UV1=!1,e.UV2=!1,e.VERTEXCOLOR=!1,e.VERTEXALPHA=!1,e.NUM_BONE_INFLUENCERS=0,e.BonesPerMesh=0,e.INSTANCES=!1,e.SPECULARTERM=!1,e.LOGARITHMICDEPTH=!1,e.FRESNELSEPARATE=!1,e.BUMPSUPERIMPOSE=!1,e.BUMPAFFECTSREFLECTION=!1,e.IMAGEPROCESSING=!1,e.VIGNETTE=!1,e.VIGNETTEBLENDMODEMULTIPLY=!1,e.VIGNETTEBLENDMODEOPAQUE=!1,e.TONEMAPPING=!1,e.TONEMAPPING_ACES=!1,e.CONTRAST=!1,e.EXPOSURE=!1,e.COLORCURVES=!1,e.COLORGRADING=!1,e.COLORGRADING3D=!1,e.SAMPLER3DGREENDEPTH=!1,e.SAMPLER3DBGRMAP=!1,e.IMAGEPROCESSINGPOSTPROCESS=!1,e.rebuild(),e}return t}(br),UY=function(n){j(t,n);function t(e,i,r){r===void 0&&(r=new Be(512,512));var o=n.call(this,e,i)||this;return o.renderTargetSize=r,o.diffuseColor=new me(1,1,1),o.specularColor=new me(0,0,0),o.specularPower=64,o._disableLighting=!1,o._maxSimultaneousLights=4,o.windForce=6,o.windDirection=new Be(0,1),o.waveHeight=.4,o.bumpHeight=.4,o._bumpSuperimpose=!1,o._fresnelSeparate=!1,o._bumpAffectsReflection=!1,o.waterColor=new me(.1,.1,.6),o.colorBlendFactor=.2,o.waterColor2=new me(.1,.1,.6),o.colorBlendFactor2=.2,o.waveLength=.1,o.waveSpeed=1,o.waveCount=20,o.disableClipPlane=!1,o._renderTargets=new vr(16),o._mesh=null,o._reflectionTransform=te.Zero(),o._lastTime=0,o._lastDeltaTime=0,o._createRenderTargets(i,r),o.getRenderTargetTextures=function(){return o._renderTargets.reset(),o._renderTargets.push(o._reflectionRTT),o._renderTargets.push(o._refractionRTT),o._renderTargets},o._imageProcessingConfiguration=o.getScene().imageProcessingConfiguration,o._imageProcessingConfiguration&&(o._imageProcessingObserver=o._imageProcessingConfiguration.onUpdateParameters.add(function(){o._markAllSubMeshesAsImageProcessingDirty()})),o}return Object.defineProperty(t.prototype,"hasRenderTargetTextures",{get:function(){return!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"useLogarithmicDepth",{get:function(){return this._useLogarithmicDepth},set:function(e){this._useLogarithmicDepth=e&&this.getScene().getEngine().getCaps().fragmentDepthSupported,this._markAllSubMeshesAsMiscDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"refractionTexture",{get:function(){return this._refractionRTT},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"reflectionTexture",{get:function(){return this._reflectionRTT},enumerable:!1,configurable:!0}),t.prototype.addToRenderList=function(e){this._refractionRTT&&this._refractionRTT.renderList&&this._refractionRTT.renderList.push(e),this._reflectionRTT&&this._reflectionRTT.renderList&&this._reflectionRTT.renderList.push(e)},t.prototype.enableRenderTargets=function(e){var i=e?1:0;this._refractionRTT&&(this._refractionRTT.refreshRate=i),this._reflectionRTT&&(this._reflectionRTT.refreshRate=i)},t.prototype.getRenderList=function(){return this._refractionRTT?this._refractionRTT.renderList:[]},Object.defineProperty(t.prototype,"renderTargetsEnabled",{get:function(){return!(this._refractionRTT&&this._refractionRTT.refreshRate===0)},enumerable:!1,configurable:!0}),t.prototype.needAlphaBlending=function(){return this.alpha<1},t.prototype.needAlphaTesting=function(){return!1},t.prototype.getAlphaTestTexture=function(){return null},t.prototype.isReadyForSubMesh=function(e,i,r){if(this.isFrozen&&i.effect&&i.effect._wasPreviouslyReady)return!0;i._materialDefines||(i._materialDefines=new VY);var o=i._materialDefines,a=this.getScene();if(this._isReadyForSubMesh(i))return!0;var s=a.getEngine();if(o._areTexturesDirty&&(o._needUVs=!1,a.texturesEnabled)){if(this.bumpTexture&&ke.BumpTextureEnabled)if(this.bumpTexture.isReady())o._needUVs=!0,o.BUMP=!0;else return!1;ke.ReflectionTextureEnabled&&(o.REFLECTION=!0)}if(ne.PrepareDefinesForFrameBoundValues(a,s,o,!!r),ne.PrepareDefinesForMisc(e,a,this._useLogarithmicDepth,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e),o),o._areMiscDirty&&(this._fresnelSeparate&&(o.FRESNELSEPARATE=!0),this._bumpSuperimpose&&(o.BUMPSUPERIMPOSE=!0),this._bumpAffectsReflection&&(o.BUMPAFFECTSREFLECTION=!0)),o._needNormals=ne.PrepareDefinesForLights(a,e,o,!0,this._maxSimultaneousLights,this._disableLighting),o._areImageProcessingDirty&&this._imageProcessingConfiguration){if(!this._imageProcessingConfiguration.isReady())return!1;this._imageProcessingConfiguration.prepareDefines(o),o.IS_REFLECTION_LINEAR=this.reflectionTexture!=null&&!this.reflectionTexture.gammaSpace,o.IS_REFRACTION_LINEAR=this.refractionTexture!=null&&!this.refractionTexture.gammaSpace}if(ne.PrepareDefinesForAttributes(e,o,!0,!0),this._mesh=e,this._waitingRenderList){for(var l=0;l<this._waitingRenderList.length;l++)this.addToRenderList(a.getNodeByID(this._waitingRenderList[l]));this._waitingRenderList=null}if(o.isDirty){o.markAsProcessed(),a.resetCachedMaterial();var u=new Er;o.FOG&&u.addFallback(1,"FOG"),o.LOGARITHMICDEPTH&&u.addFallback(0,"LOGARITHMICDEPTH"),ne.HandleFallbacksForShadows(o,u,this.maxSimultaneousLights),o.NUM_BONE_INFLUENCERS>0&&u.addCPUSkinningFallback(0,e);var f=[I.PositionKind];o.NORMAL&&f.push(I.NormalKind),o.UV1&&f.push(I.UVKind),o.UV2&&f.push(I.UV2Kind),o.VERTEXCOLOR&&f.push(I.ColorKind),ne.PrepareAttributesForBones(f,e,o,u),ne.PrepareAttributesForInstances(f,o);var c="water",h=o.toString(),p=["world","view","viewProjection","vEyePosition","vLightsType","vDiffuseColor","vSpecularColor","vFogInfos","vFogColor","pointSize","vNormalInfos","mBones","vClipPlane","vClipPlane2","vClipPlane3","vClipPlane4","vClipPlane5","vClipPlane6","normalMatrix","logarithmicDepthConstant","worldReflectionViewProjection","windDirection","waveLength","time","windForce","cameraPosition","bumpHeight","waveHeight","waterColor","waterColor2","colorBlendFactor","colorBlendFactor2","waveSpeed","waveCount"],_=["normalSampler","refractionSampler","reflectionSampler"],g=new Array;Wi&&(Wi.PrepareUniforms(p,o),Wi.PrepareSamplers(_,o)),ne.PrepareUniformsAndSamplersList({uniformsNames:p,uniformBuffersNames:g,samplers:_,defines:o,maxSimultaneousLights:this.maxSimultaneousLights}),i.setEffect(a.getEngine().createEffect(c,{attributes:f,uniformsNames:p,uniformBuffersNames:g,samplers:_,defines:h,fallbacks:u,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:this._maxSimultaneousLights}},s),o)}return!i.effect||!i.effect.isReady()?!1:(o._renderId=a.getRenderId(),i.effect._wasPreviouslyReady=!0,!0)},t.prototype.bindForSubMesh=function(e,i,r){var o=this.getScene(),a=r._materialDefines;if(a){var s=r.effect;if(!(!s||!this._mesh)){this._activeEffect=s,this.bindOnlyWorldMatrix(e),this._activeEffect.setMatrix("viewProjection",o.getTransformMatrix()),ne.BindBonesParameters(i,this._activeEffect),this._mustRebind(o,s)&&(this.bumpTexture&&ke.BumpTextureEnabled&&(this._activeEffect.setTexture("normalSampler",this.bumpTexture),this._activeEffect.setFloat2("vNormalInfos",this.bumpTexture.coordinatesIndex,this.bumpTexture.level),this._activeEffect.setMatrix("normalMatrix",this.bumpTexture.getTextureMatrix())),ne.BindClipPlane(this._activeEffect,o),this.pointsCloud&&this._activeEffect.setFloat("pointSize",this.pointSize),ne.BindEyePosition(s,o)),this._activeEffect.setColor4("vDiffuseColor",this.diffuseColor,this.alpha*i.visibility),a.SPECULARTERM&&this._activeEffect.setColor4("vSpecularColor",this.specularColor,this.specularPower),o.lightsEnabled&&!this.disableLighting&&ne.BindLights(o,i,this._activeEffect,a,this.maxSimultaneousLights),o.fogEnabled&&i.applyFog&&o.fogMode!==Ke.FOGMODE_NONE&&this._activeEffect.setMatrix("view",o.getViewMatrix()),ne.BindFogParameters(o,i,this._activeEffect),ne.BindLogDepth(a,this._activeEffect,o),ke.ReflectionTextureEnabled&&(this._activeEffect.setTexture("refractionSampler",this._refractionRTT),this._activeEffect.setTexture("reflectionSampler",this._reflectionRTT));var l=this._mesh.getWorldMatrix().multiply(this._reflectionTransform).multiply(o.getProjectionMatrix()),u=o.getEngine().getDeltaTime();u!==this._lastDeltaTime&&(this._lastDeltaTime=u,this._lastTime+=this._lastDeltaTime),this._activeEffect.setMatrix("worldReflectionViewProjection",l),this._activeEffect.setVector2("windDirection",this.windDirection),this._activeEffect.setFloat("waveLength",this.waveLength),this._activeEffect.setFloat("time",this._lastTime/1e5),this._activeEffect.setFloat("windForce",this.windForce),this._activeEffect.setFloat("waveHeight",this.waveHeight),this._activeEffect.setFloat("bumpHeight",this.bumpHeight),this._activeEffect.setColor4("waterColor",this.waterColor,1),this._activeEffect.setFloat("colorBlendFactor",this.colorBlendFactor),this._activeEffect.setColor4("waterColor2",this.waterColor2,1),this._activeEffect.setFloat("colorBlendFactor2",this.colorBlendFactor2),this._activeEffect.setFloat("waveSpeed",this.waveSpeed),this._activeEffect.setFloat("waveCount",this.waveCount),this._imageProcessingConfiguration&&!this._imageProcessingConfiguration.applyByPostProcess&&this._imageProcessingConfiguration.bind(this._activeEffect),this._afterBind(i,this._activeEffect)}}},t.prototype._createRenderTargets=function(e,i){var r=this;this._refractionRTT=new $i(name+"_refraction",{width:i.x,height:i.y},e,!1,!0),this._refractionRTT.wrapU=vo.TEXTURE_MIRROR_ADDRESSMODE,this._refractionRTT.wrapV=vo.TEXTURE_MIRROR_ADDRESSMODE,this._refractionRTT.ignoreCameraViewport=!0,this._reflectionRTT=new $i(name+"_reflection",{width:i.x,height:i.y},e,!1,!0),this._reflectionRTT.wrapU=vo.TEXTURE_MIRROR_ADDRESSMODE,this._reflectionRTT.wrapV=vo.TEXTURE_MIRROR_ADDRESSMODE,this._reflectionRTT.ignoreCameraViewport=!0;var o,a=null,s,l=te.Zero();this._refractionRTT.onBeforeRender=function(){if(r._mesh&&(o=r._mesh.isVisible,r._mesh.isVisible=!1),!r.disableClipPlane){a=e.clipPlane;var u=r._mesh?r._mesh.position.y:0;e.clipPlane=Bo.FromPositionAndNormal(new b(0,u+.05,0),new b(0,1,0))}},this._refractionRTT.onAfterRender=function(){r._mesh&&(r._mesh.isVisible=o),r.disableClipPlane||(e.clipPlane=a)},this._reflectionRTT.onBeforeRender=function(){if(r._mesh&&(o=r._mesh.isVisible,r._mesh.isVisible=!1),!r.disableClipPlane){a=e.clipPlane;var u=r._mesh?r._mesh.position.y:0;e.clipPlane=Bo.FromPositionAndNormal(new b(0,u-.05,0),new b(0,-1,0)),te.ReflectionToRef(e.clipPlane,l)}s=e.getViewMatrix(),l.multiplyToRef(s,r._reflectionTransform),e.setTransformMatrix(r._reflectionTransform,e.getProjectionMatrix()),e.getEngine().cullBackFaces=!1,e._mirroredCameraPosition=b.TransformCoordinates(e.activeCamera.position,l)},this._reflectionRTT.onAfterRender=function(){r._mesh&&(r._mesh.isVisible=o),e.clipPlane=a,e.setTransformMatrix(s,e.getProjectionMatrix()),e.getEngine().cullBackFaces=!0,e._mirroredCameraPosition=null}},t.prototype.getAnimatables=function(){var e=[];return this.bumpTexture&&this.bumpTexture.animations&&this.bumpTexture.animations.length>0&&e.push(this.bumpTexture),this._reflectionRTT&&this._reflectionRTT.animations&&this._reflectionRTT.animations.length>0&&e.push(this._reflectionRTT),this._refractionRTT&&this._refractionRTT.animations&&this._refractionRTT.animations.length>0&&e.push(this._refractionRTT),e},t.prototype.getActiveTextures=function(){var e=n.prototype.getActiveTextures.call(this);return this._bumpTexture&&e.push(this._bumpTexture),e},t.prototype.hasTexture=function(e){return!!(n.prototype.hasTexture.call(this,e)||this._bumpTexture===e)},t.prototype.dispose=function(e){this.bumpTexture&&this.bumpTexture.dispose();var i=this.getScene().customRenderTargets.indexOf(this._refractionRTT);i!=-1&&this.getScene().customRenderTargets.splice(i,1),i=-1,i=this.getScene().customRenderTargets.indexOf(this._reflectionRTT),i!=-1&&this.getScene().customRenderTargets.splice(i,1),this._reflectionRTT&&this._reflectionRTT.dispose(),this._refractionRTT&&this._refractionRTT.dispose(),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),n.prototype.dispose.call(this,e)},t.prototype.clone=function(e){var i=this;return Fe.Clone(function(){return new t(e,i.getScene())},this)},t.prototype.serialize=function(){var e=Fe.Serialize(this);if(e.customType="BABYLON.WaterMaterial",e.renderList=[],this._refractionRTT&&this._refractionRTT.renderList)for(var i=0;i<this._refractionRTT.renderList.length;i++)e.renderList.push(this._refractionRTT.renderList[i].id);return e},t.prototype.getClassName=function(){return"WaterMaterial"},t.Parse=function(e,i,r){var o=Fe.Parse(function(){return new t(e.name,i)},e,i,r);return o._waitingRenderList=e.renderList,o},t.CreateDefaultMesh=function(e,i){var r=oe.CreateGround(e,512,512,32,i,!1);return r},A([at("bumpTexture")],t.prototype,"_bumpTexture",void 0),A([ye("_markAllSubMeshesAsTexturesDirty")],t.prototype,"bumpTexture",void 0),A([Ft()],t.prototype,"diffuseColor",void 0),A([Ft()],t.prototype,"specularColor",void 0),A([w()],t.prototype,"specularPower",void 0),A([w("disableLighting")],t.prototype,"_disableLighting",void 0),A([ye("_markAllSubMeshesAsLightsDirty")],t.prototype,"disableLighting",void 0),A([w("maxSimultaneousLights")],t.prototype,"_maxSimultaneousLights",void 0),A([ye("_markAllSubMeshesAsLightsDirty")],t.prototype,"maxSimultaneousLights",void 0),A([w()],t.prototype,"windForce",void 0),A([nb()],t.prototype,"windDirection",void 0),A([w()],t.prototype,"waveHeight",void 0),A([w()],t.prototype,"bumpHeight",void 0),A([w("bumpSuperimpose")],t.prototype,"_bumpSuperimpose",void 0),A([ye("_markAllSubMeshesAsMiscDirty")],t.prototype,"bumpSuperimpose",void 0),A([w("fresnelSeparate")],t.prototype,"_fresnelSeparate",void 0),A([ye("_markAllSubMeshesAsMiscDirty")],t.prototype,"fresnelSeparate",void 0),A([w("bumpAffectsReflection")],t.prototype,"_bumpAffectsReflection",void 0),A([ye("_markAllSubMeshesAsMiscDirty")],t.prototype,"bumpAffectsReflection",void 0),A([Ft()],t.prototype,"waterColor",void 0),A([w()],t.prototype,"colorBlendFactor",void 0),A([Ft()],t.prototype,"waterColor2",void 0),A([w()],t.prototype,"colorBlendFactor2",void 0),A([w()],t.prototype,"waveLength",void 0),A([w()],t.prototype,"waveSpeed",void 0),A([w()],t.prototype,"waveCount",void 0),A([w()],t.prototype,"disableClipPlane",void 0),A([w()],t.prototype,"useLogarithmicDepth",null),t}(Ir);Pe.RegisteredTypes["BABYLON.WaterMaterial"]=UY;function kY(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)}const zY=["data:EnvironmentBRDFTexture0","GlowLayerBlurRTT","GlowLayerBlurRTT2","HighlightLayerMainRTT"];function GY(n,t,e){async function i(u,f){return Te.CreateScreenshotUsingRenderTargetAsync(n,e,{width:u,height:f},void 0,void 0,!0)}async function r(u){e.inertialRadiusOffset=e.inertialRadiusOffset+u}async function o(u){const{x:f,y:c,z:h}=u;e.target.x=f||0,e.target.y=c||0,e.target.z=h||0}async function a(u){const{alpha:f,beta:c,radius:h}=u;f&&(e.alpha=e.alpha+f),c&&(e.beta=e.beta+c),h&&(e.radius=e.radius+h)}async function s(){const u=t.meshes.filter(p=>!p.name.toLowerCase().includes("collider")).reduce((p,_)=>p+Math.floor(_.getTotalIndices()/3),0),f=t.materials.length,c=t.meshes.length,h=t.textures.filter(p=>p.name&&!zY.includes(p.name)).length;return{triangles:u,materials:f,meshes:c,textures:h,bodies:c,entities:1}}async function l(){}return{getScreenshot:i,getMetrics:s,panCamera:o,changeZoom:r,changeCameraPosition:a,cleanup:l}}var WY={};const yI=WY.REACT_APP_DEBUG;yI&&require("@babylonjs/inspector");function HY(n){const t=n.getChildren().filter(e=>e.id!=="__root__");if(t.length>0){const e=t[0];let i=e.getBoundingInfo(),r=i.boundingBox.minimumWorld.add(e.position),o=i.boundingBox.maximumWorld.add(e.position);for(let a=1;a<t.length;a++){const s=t[a];i=s.getBoundingInfo();const l=i.boundingBox.minimumWorld.add(s.position),u=i.boundingBox.maximumWorld.add(s.position);r=b.Minimize(r,l),o=b.Maximize(o,u)}n.setBoundingInfo(new cr(r,o))}}let Nl;async function jY(n,t){Nl&&Nl.dispose(),Nl=new xe(n,!0,{preserveDrawingBuffer:!0,stencil:!0,antialias:!0});const e=new Ke(Nl);if(e.autoClear=!0,e.clearColor=t.background.transparent?new it(0,0,0,0):py(t.background.color).toColor4(),e.ambientColor=new me(1,1,1),e.preventDefaultOnPointerDown=!1,t.showSceneBoundaries){const s=yv.CreateGround("ground",{width:6,height:6},e),l=yv.CreateGround("ground",{width:6,height:6},e);l.rotate(Oi.Z,Math.PI),l.position.y=-.05;const u=new vI("groundMaterial",e);u.mainColor=new me(1,1,1),u.lineColor=new me(0,0,0),u.majorUnitFrequency=0,s.material=u,l.material=u;const f=yv.CreateCylinder("boundaries",{diameter:2,height:3}),c=new Mt("boundariesMaterial",e);c.alpha=.3,c.diffuseColor=new me(1,45/255,85/255),f.material=c,f.position.y=1.51}if(t.showThumbnailBoundaries){const s=Ib.CreateFullscreenUI("UI"),l=new no;l.width=.5,l.height=1,l.color="#736E7D",l.thickness=2,s.addControl(l)}const i=new Js("camera",0,0,0,new b(0,0,0),e);switch(i.position=new b(t.cameraX,t.cameraY,t.cameraZ),i.minZ=.1,t.projection){case Ae.PreviewProjection.PERSPECTIVE:{i.mode=dt.PERSPECTIVE_CAMERA;break}case Ae.PreviewProjection.ORTHOGRAPHIC:{i.mode=dt.ORTHOGRAPHIC_CAMERA,i.orthoTop=1,i.orthoBottom=-1,i.orthoLeft=-1,i.orthoRight=1;break}}t.type===Ae.PreviewType.WEARABLE&&lI(i,t),t.camera===Ae.PreviewCamera.INTERACTIVE&&i.attachControl(n,!0);const r=new b(t.offsetX,t.offsetY,t.offsetZ);if(i.position.addInPlace(r),i.setTarget(r),i.lowerRadiusLimit=i.radius/t.zoom,i.upperRadiusLimit=i.lowerRadiusLimit*t.wheelZoom,i.radius=i.lowerRadiusLimit+(i.upperRadiusLimit-i.lowerRadiusLimit)*t.wheelStart/100,i.wheelPrecision=t.wheelPrecision,t.panning||(i.panningSensibility=0),t.lockBeta&&(i.lowerBetaLimit=i.beta,i.upperBetaLimit=i.beta),t.lockAlpha&&(i.lowerAlphaLimit=i.alpha,i.upperAlphaLimit=i.alpha),t.lockRadius&&(i.lowerRadiusLimit=i.radius,i.upperRadiusLimit=i.radius),t.type===Ae.PreviewType.WEARABLE){const s=new su("directional",new b(0,0,1),e);s.intensity=1;const l=new lu("spot",new b(-2,2,2),new b(2,-2,-2),Math.PI/2,1e3,e);l.intensity=1}const o=new ko("top",new b(0,-1,0),e);o.intensity=1;const a=new ko("bottom",new b(0,1,0),e);if(a.intensity=1,!kY()){const s=new np("glow",e);s.intensity=2}return Nl.runRenderLoop(()=>{e.render()}),yI&&e.debugLayer.show({showExplorer:!0,embedMode:!0}),[e,GY(Nl,e,i)]}async function XY(n,t,e){const i=t.id,o=uu(t,e).contents.find(a=>a.key.toLowerCase().endsWith("_mask.png"));return o?new Promise((a,s)=>{const l=new Kx(i,o.url,!0,!1);l.onError=()=>s(l.errorObject),l.onSuccess=()=>{a(l.texture)},l.run(n,()=>a(l.texture),s)}):null}async function YY(n,t,e){const i=t.id,o=uu(t,e).contents.find(a=>a.key.toLowerCase().endsWith(".png")&&!a.key.toLowerCase().endsWith("_mask.png"));return o?new Promise((a,s)=>{const l=new Kx(i,o.url,!0,!1);l.onError=()=>s(l.errorObject),l.onSuccess=()=>{a(l.texture)},l.run(n,()=>a(l.texture),s)}):null}function KY(n,t){return new Promise((e,i)=>{var l;const r=(l=t.contents.find(u=>u.key.toLowerCase().endsWith(".mp3")||u.key.toLowerCase().endsWith("ogg")))==null?void 0:l.url;if(!r)return e(null);const o=new sj("Sound task",r),a=()=>e(new Ql("music",o.data,n,null,{spatialSound:!0})),s=u=>i(u);o.run(n,a,s)})}async function bI(n,t){const e=async(i,r)=>$t.LoadAssetContainerAsync(i,"",n,null,r);try{return await e(t,".glb")}catch{return await e(t,".gltf")}}function qY(n){const t=new oe("parent",n);for(const a of n.meshes)a!==t&&a.setParent(t);HY(t);const i=t.getBoundingInfo().boundingBox.extendSize.length(),r=new b(1/i,1/i,1/i);t.scaling=r;const o=t.getBoundingInfo().boundingBox.center.multiply(r);t.position.subtractInPlace(o)}var QY={VITE_BASE_URL:"https://cdn.decentraland.org/@dcl/wearable-preview/1.28.2-16155802308.commit-53348f0"};const $Y=[Ae.PreviewEmote.IDLE,Ae.PreviewEmote.MONEY,Ae.PreviewEmote.CLAP,Ae.PreviewEmote.WALK,Ae.PreviewEmote.RUN,Ae.PreviewEmote.JUMP];let _d;function ZY(n){return $Y.includes(n)}function JY(n){let t=QY.VITE_BASE_URL;t.endsWith("/")||(t+="/");const e=`./emotes/${n}.glb`;return t.startsWith("http")?new URL(e,t).href:e}async function EI(n,t){const e=await bI(n,t);if(e.animationGroups.length===0)throw new Error(`No animation groups found for emote with url=${t}`);return e}async function e6(n,t,e){const i=Ab(t,e.bodyShape),r=i.contents.find(o=>o.key===i.mainFile);if(!r)throw new Error(`Could not find a valid content in representation for emote=${t.id} and bodyShape=${e.bodyShape}`);return EI(n,r.url)}function t6(n,t,e){const i=Ab(t,e.bodyShape);return KY(n,i)}async function i6(n,t,e){let i,r=!!e.emote&&ZY(e.emote),o=null;if(e.item&&Fo(e.item))try{i=await e6(n,e.item,e),r=e.item.emoteDataADR74.loop,o=await t6(n,e.item,e)}catch{console.warn(`Could not load emote=${e.item.id}`)}if(!i&&e.emote){const l=JY(e.emote);i=await EI(n,l)}i&&i.animationGroups.length>1&&(i.addAllToScene(),n.stopAllAnimations());const a=new ab("emote",n);function s(){if(e.camera!==Ae.PreviewCamera.STATIC){const l=n.cameras[0];lI(l,e)}}try{for(const u of t){const f=new Map,c=[...u.container.transformNodes,...u.container.meshes];for(const h of c){const p=h.name.replace(/\.\d+$/,""),_=f.get(p)||[];_.push(h),f.set(p,_)}if(i&&i.animationGroups.length>0)for(const h of i.animationGroups)for(const p of h.targetedAnimations){const _=p.animation.clone(),g=p.target,v=p.animation.getKeys();if(_.setKeys([...v]),i.animationGroups.length===1||h.name.toLowerCase().includes("avatar")||g.name.startsWith("Avatar_")){const T=g.name.replace(/\.\d+$/,""),S=f.get(T)||[];if(S.length>0)for(const C of S){const O=_.clone();O.setKeys([...v]),a.addTargetedAnimation(O,C)}else console.warn("No matching bone found for",g.name)}else a.addTargetedAnimation(_,g)}}a.onAnimationGroupEndObservable.addOnce(s);const l=r6(a,r,o);return e.camera===Ae.PreviewCamera.STATIC&&l.stop(),l}catch(l){console.warn(`Could not play emote=${e.emote}`,l)}}function r6(n,t,e){xe.audioEngine.useCustomUnlockedButton=!0,xe.audioEngine.setGlobalVolume(0);let i,r=!1;async function o(){return Math.max(n.to,0)}async function a(){return n.isPlaying}async function s(){return!!e}async function l(E){r=!0;const T=await a();T&&n.pause(),n.stop(),n.start(!1,1,E,E,!1),i=E,r=!0,T&&u()}async function u(){await a()||(i?(n.start(t,1,i,await o(),!1),e&&(e.stop(),e._startOffset=i,e.play()),i=0):(n.play(t),e==null||e.play()))}async function f(){await a()&&(n.pause(),e==null||e.pause())}async function c(){n.goToFrame(0),n.stop(),e==null||e.stop()}async function h(){e&&(xe.audioEngine.unlock(),xe.audioEngine.setGlobalVolume(1),n.isPlaying&&!e.isPlaying&&e.play(void 0,n.targetedAnimations[0].animation.runtimeAnimations[0].currentFrame))}async function p(){e&&xe.audioEngine.setGlobalVolume(0)}const _=ib(),g=()=>(_d&&clearInterval(_d),window.setInterval(async()=>{var E;if(await a()&&n.animatables[0].masterFrame>0)return _.emit(Ae.PreviewEmoteEventType.ANIMATION_PLAYING,{length:(E=n.animatables[0])==null?void 0:E.masterFrame})},10)),v=()=>{clearInterval(_d),r||_.emit(Ae.PreviewEmoteEventType.ANIMATION_PLAYING,{length:n.to})};return n.onAnimationGroupPlayObservable.add(()=>(_d=g(),_.emit(Ae.PreviewEmoteEventType.ANIMATION_PLAY))),n.onAnimationGroupPauseObservable.add(()=>{_.emit(Ae.PreviewEmoteEventType.ANIMATION_PAUSE)}),n.onAnimationGroupLoopObservable.add(()=>(e==null||e.stop(),e==null||e.play(),r&&(c(),u(),r=!1),_.emit(Ae.PreviewEmoteEventType.ANIMATION_LOOP))),n.onAnimationGroupEndObservable.add(()=>(v(),t||(r=!1),_.emit(Ae.PreviewEmoteEventType.ANIMATION_END))),{getLength:o,isPlaying:a,goTo:l,play:u,pause:f,stop:c,enableSound:h,disableSound:p,hasSound:s,events:_}}function n6(n,t,e){return async i=>{const r=t.find(Hj(i));return r?Promise.all([YY(n,r,e),XY(n,r,e)]):[null,null]}}async function o6(n,t,e){const i=n6(n,t,e),[r,o,a]=await Promise.all([i(Ae.WearableCategory.EYES),i(Ae.WearableCategory.EYEBROWS),i(Ae.WearableCategory.MOUTH)]);return{eyes:r,eyebrows:o,mouth:a}}async function a6(n,t,e,i,r,o){for(const a of t.container.meshes){if(a.name.toLowerCase().endsWith("mask_eyes")){const[s,l]=e;s?Hv(n,"eyes",a,s,o.eyes,l,"#ffffff"):a.setEnabled(!1)}if(a.name.toLowerCase().endsWith("mask_eyebrows")){const[s,l]=i;s?Hv(n,"eyebrows",a,s,o.hair,l,o.hair):a.setEnabled(!1)}if(a.name.toLowerCase().endsWith("mask_mouth")){const[s,l]=r;s?Hv(n,"mouth",a,s,o.skin,l,o.skin):a.setEnabled(!1)}}}function Hv(n,t,e,i,r,o,a){const s=new Mt(`${t}_standard_material`,n);s.alphaMode=Pi.PBRMATERIAL_ALPHABLEND,s.backFaceCulling=!0,s.specularColor=me.Black(),i.hasAlpha=!0,s.sideOrientation=Ys.CW,s.diffuseTexture=i,s.diffuseColor=o?me.Black():py(a),o&&(s.emissiveTexture=o,s.diffuseColor=py(r)),e.material=s}function s6(n,t,e=Ae.BodyShape.MALE){const i={};for(const r of n)try{const o=uu(r,e);for(const a of o.contents)i[a.key]=a.url}catch{console.warn(`Skipping generation of mappings for wearable="${r.id}" since it lacks a representation for bodyShape="${e}"`);continue}if(t){const r=Ab(t,e);for(const o of r.contents)i[o.key]=o.url}return i}function l6(n){const t=is(n.item)?[n.item,...n.wearables]:n.wearables,e=Fo(n.item)?n.item:void 0,i=s6(t,e,n.bodyShape);$t.OnPluginActivatedObservable.add(r=>{if(r.name==="gltf"){const o=r;o.preprocessUrlAsync=async a=>{const l=a.split("/").pop();if(!l)return a;const f=Object.keys(i).find(c=>c.endsWith(l));return i[f]||a}}})}const u6=`float angleY = 3.14 / 2.0;
|
|
16066
|
+
`;ce.ShadersStore[FY]=BY;var VY=function(n){j(t,n);function t(){var e=n.call(this)||this;return e.BUMP=!1,e.REFLECTION=!1,e.CLIPPLANE=!1,e.CLIPPLANE2=!1,e.CLIPPLANE3=!1,e.CLIPPLANE4=!1,e.CLIPPLANE5=!1,e.CLIPPLANE6=!1,e.ALPHATEST=!1,e.DEPTHPREPASS=!1,e.POINTSIZE=!1,e.FOG=!1,e.NORMAL=!1,e.UV1=!1,e.UV2=!1,e.VERTEXCOLOR=!1,e.VERTEXALPHA=!1,e.NUM_BONE_INFLUENCERS=0,e.BonesPerMesh=0,e.INSTANCES=!1,e.SPECULARTERM=!1,e.LOGARITHMICDEPTH=!1,e.FRESNELSEPARATE=!1,e.BUMPSUPERIMPOSE=!1,e.BUMPAFFECTSREFLECTION=!1,e.IMAGEPROCESSING=!1,e.VIGNETTE=!1,e.VIGNETTEBLENDMODEMULTIPLY=!1,e.VIGNETTEBLENDMODEOPAQUE=!1,e.TONEMAPPING=!1,e.TONEMAPPING_ACES=!1,e.CONTRAST=!1,e.EXPOSURE=!1,e.COLORCURVES=!1,e.COLORGRADING=!1,e.COLORGRADING3D=!1,e.SAMPLER3DGREENDEPTH=!1,e.SAMPLER3DBGRMAP=!1,e.IMAGEPROCESSINGPOSTPROCESS=!1,e.rebuild(),e}return t}(br),UY=function(n){j(t,n);function t(e,i,r){r===void 0&&(r=new Be(512,512));var o=n.call(this,e,i)||this;return o.renderTargetSize=r,o.diffuseColor=new me(1,1,1),o.specularColor=new me(0,0,0),o.specularPower=64,o._disableLighting=!1,o._maxSimultaneousLights=4,o.windForce=6,o.windDirection=new Be(0,1),o.waveHeight=.4,o.bumpHeight=.4,o._bumpSuperimpose=!1,o._fresnelSeparate=!1,o._bumpAffectsReflection=!1,o.waterColor=new me(.1,.1,.6),o.colorBlendFactor=.2,o.waterColor2=new me(.1,.1,.6),o.colorBlendFactor2=.2,o.waveLength=.1,o.waveSpeed=1,o.waveCount=20,o.disableClipPlane=!1,o._renderTargets=new vr(16),o._mesh=null,o._reflectionTransform=te.Zero(),o._lastTime=0,o._lastDeltaTime=0,o._createRenderTargets(i,r),o.getRenderTargetTextures=function(){return o._renderTargets.reset(),o._renderTargets.push(o._reflectionRTT),o._renderTargets.push(o._refractionRTT),o._renderTargets},o._imageProcessingConfiguration=o.getScene().imageProcessingConfiguration,o._imageProcessingConfiguration&&(o._imageProcessingObserver=o._imageProcessingConfiguration.onUpdateParameters.add(function(){o._markAllSubMeshesAsImageProcessingDirty()})),o}return Object.defineProperty(t.prototype,"hasRenderTargetTextures",{get:function(){return!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"useLogarithmicDepth",{get:function(){return this._useLogarithmicDepth},set:function(e){this._useLogarithmicDepth=e&&this.getScene().getEngine().getCaps().fragmentDepthSupported,this._markAllSubMeshesAsMiscDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"refractionTexture",{get:function(){return this._refractionRTT},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"reflectionTexture",{get:function(){return this._reflectionRTT},enumerable:!1,configurable:!0}),t.prototype.addToRenderList=function(e){this._refractionRTT&&this._refractionRTT.renderList&&this._refractionRTT.renderList.push(e),this._reflectionRTT&&this._reflectionRTT.renderList&&this._reflectionRTT.renderList.push(e)},t.prototype.enableRenderTargets=function(e){var i=e?1:0;this._refractionRTT&&(this._refractionRTT.refreshRate=i),this._reflectionRTT&&(this._reflectionRTT.refreshRate=i)},t.prototype.getRenderList=function(){return this._refractionRTT?this._refractionRTT.renderList:[]},Object.defineProperty(t.prototype,"renderTargetsEnabled",{get:function(){return!(this._refractionRTT&&this._refractionRTT.refreshRate===0)},enumerable:!1,configurable:!0}),t.prototype.needAlphaBlending=function(){return this.alpha<1},t.prototype.needAlphaTesting=function(){return!1},t.prototype.getAlphaTestTexture=function(){return null},t.prototype.isReadyForSubMesh=function(e,i,r){if(this.isFrozen&&i.effect&&i.effect._wasPreviouslyReady)return!0;i._materialDefines||(i._materialDefines=new VY);var o=i._materialDefines,a=this.getScene();if(this._isReadyForSubMesh(i))return!0;var s=a.getEngine();if(o._areTexturesDirty&&(o._needUVs=!1,a.texturesEnabled)){if(this.bumpTexture&&ke.BumpTextureEnabled)if(this.bumpTexture.isReady())o._needUVs=!0,o.BUMP=!0;else return!1;ke.ReflectionTextureEnabled&&(o.REFLECTION=!0)}if(ne.PrepareDefinesForFrameBoundValues(a,s,o,!!r),ne.PrepareDefinesForMisc(e,a,this._useLogarithmicDepth,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e),o),o._areMiscDirty&&(this._fresnelSeparate&&(o.FRESNELSEPARATE=!0),this._bumpSuperimpose&&(o.BUMPSUPERIMPOSE=!0),this._bumpAffectsReflection&&(o.BUMPAFFECTSREFLECTION=!0)),o._needNormals=ne.PrepareDefinesForLights(a,e,o,!0,this._maxSimultaneousLights,this._disableLighting),o._areImageProcessingDirty&&this._imageProcessingConfiguration){if(!this._imageProcessingConfiguration.isReady())return!1;this._imageProcessingConfiguration.prepareDefines(o),o.IS_REFLECTION_LINEAR=this.reflectionTexture!=null&&!this.reflectionTexture.gammaSpace,o.IS_REFRACTION_LINEAR=this.refractionTexture!=null&&!this.refractionTexture.gammaSpace}if(ne.PrepareDefinesForAttributes(e,o,!0,!0),this._mesh=e,this._waitingRenderList){for(var l=0;l<this._waitingRenderList.length;l++)this.addToRenderList(a.getNodeByID(this._waitingRenderList[l]));this._waitingRenderList=null}if(o.isDirty){o.markAsProcessed(),a.resetCachedMaterial();var u=new Er;o.FOG&&u.addFallback(1,"FOG"),o.LOGARITHMICDEPTH&&u.addFallback(0,"LOGARITHMICDEPTH"),ne.HandleFallbacksForShadows(o,u,this.maxSimultaneousLights),o.NUM_BONE_INFLUENCERS>0&&u.addCPUSkinningFallback(0,e);var f=[I.PositionKind];o.NORMAL&&f.push(I.NormalKind),o.UV1&&f.push(I.UVKind),o.UV2&&f.push(I.UV2Kind),o.VERTEXCOLOR&&f.push(I.ColorKind),ne.PrepareAttributesForBones(f,e,o,u),ne.PrepareAttributesForInstances(f,o);var c="water",h=o.toString(),p=["world","view","viewProjection","vEyePosition","vLightsType","vDiffuseColor","vSpecularColor","vFogInfos","vFogColor","pointSize","vNormalInfos","mBones","vClipPlane","vClipPlane2","vClipPlane3","vClipPlane4","vClipPlane5","vClipPlane6","normalMatrix","logarithmicDepthConstant","worldReflectionViewProjection","windDirection","waveLength","time","windForce","cameraPosition","bumpHeight","waveHeight","waterColor","waterColor2","colorBlendFactor","colorBlendFactor2","waveSpeed","waveCount"],_=["normalSampler","refractionSampler","reflectionSampler"],g=new Array;Wi&&(Wi.PrepareUniforms(p,o),Wi.PrepareSamplers(_,o)),ne.PrepareUniformsAndSamplersList({uniformsNames:p,uniformBuffersNames:g,samplers:_,defines:o,maxSimultaneousLights:this.maxSimultaneousLights}),i.setEffect(a.getEngine().createEffect(c,{attributes:f,uniformsNames:p,uniformBuffersNames:g,samplers:_,defines:h,fallbacks:u,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:this._maxSimultaneousLights}},s),o)}return!i.effect||!i.effect.isReady()?!1:(o._renderId=a.getRenderId(),i.effect._wasPreviouslyReady=!0,!0)},t.prototype.bindForSubMesh=function(e,i,r){var o=this.getScene(),a=r._materialDefines;if(a){var s=r.effect;if(!(!s||!this._mesh)){this._activeEffect=s,this.bindOnlyWorldMatrix(e),this._activeEffect.setMatrix("viewProjection",o.getTransformMatrix()),ne.BindBonesParameters(i,this._activeEffect),this._mustRebind(o,s)&&(this.bumpTexture&&ke.BumpTextureEnabled&&(this._activeEffect.setTexture("normalSampler",this.bumpTexture),this._activeEffect.setFloat2("vNormalInfos",this.bumpTexture.coordinatesIndex,this.bumpTexture.level),this._activeEffect.setMatrix("normalMatrix",this.bumpTexture.getTextureMatrix())),ne.BindClipPlane(this._activeEffect,o),this.pointsCloud&&this._activeEffect.setFloat("pointSize",this.pointSize),ne.BindEyePosition(s,o)),this._activeEffect.setColor4("vDiffuseColor",this.diffuseColor,this.alpha*i.visibility),a.SPECULARTERM&&this._activeEffect.setColor4("vSpecularColor",this.specularColor,this.specularPower),o.lightsEnabled&&!this.disableLighting&&ne.BindLights(o,i,this._activeEffect,a,this.maxSimultaneousLights),o.fogEnabled&&i.applyFog&&o.fogMode!==Ke.FOGMODE_NONE&&this._activeEffect.setMatrix("view",o.getViewMatrix()),ne.BindFogParameters(o,i,this._activeEffect),ne.BindLogDepth(a,this._activeEffect,o),ke.ReflectionTextureEnabled&&(this._activeEffect.setTexture("refractionSampler",this._refractionRTT),this._activeEffect.setTexture("reflectionSampler",this._reflectionRTT));var l=this._mesh.getWorldMatrix().multiply(this._reflectionTransform).multiply(o.getProjectionMatrix()),u=o.getEngine().getDeltaTime();u!==this._lastDeltaTime&&(this._lastDeltaTime=u,this._lastTime+=this._lastDeltaTime),this._activeEffect.setMatrix("worldReflectionViewProjection",l),this._activeEffect.setVector2("windDirection",this.windDirection),this._activeEffect.setFloat("waveLength",this.waveLength),this._activeEffect.setFloat("time",this._lastTime/1e5),this._activeEffect.setFloat("windForce",this.windForce),this._activeEffect.setFloat("waveHeight",this.waveHeight),this._activeEffect.setFloat("bumpHeight",this.bumpHeight),this._activeEffect.setColor4("waterColor",this.waterColor,1),this._activeEffect.setFloat("colorBlendFactor",this.colorBlendFactor),this._activeEffect.setColor4("waterColor2",this.waterColor2,1),this._activeEffect.setFloat("colorBlendFactor2",this.colorBlendFactor2),this._activeEffect.setFloat("waveSpeed",this.waveSpeed),this._activeEffect.setFloat("waveCount",this.waveCount),this._imageProcessingConfiguration&&!this._imageProcessingConfiguration.applyByPostProcess&&this._imageProcessingConfiguration.bind(this._activeEffect),this._afterBind(i,this._activeEffect)}}},t.prototype._createRenderTargets=function(e,i){var r=this;this._refractionRTT=new $i(name+"_refraction",{width:i.x,height:i.y},e,!1,!0),this._refractionRTT.wrapU=vo.TEXTURE_MIRROR_ADDRESSMODE,this._refractionRTT.wrapV=vo.TEXTURE_MIRROR_ADDRESSMODE,this._refractionRTT.ignoreCameraViewport=!0,this._reflectionRTT=new $i(name+"_reflection",{width:i.x,height:i.y},e,!1,!0),this._reflectionRTT.wrapU=vo.TEXTURE_MIRROR_ADDRESSMODE,this._reflectionRTT.wrapV=vo.TEXTURE_MIRROR_ADDRESSMODE,this._reflectionRTT.ignoreCameraViewport=!0;var o,a=null,s,l=te.Zero();this._refractionRTT.onBeforeRender=function(){if(r._mesh&&(o=r._mesh.isVisible,r._mesh.isVisible=!1),!r.disableClipPlane){a=e.clipPlane;var u=r._mesh?r._mesh.position.y:0;e.clipPlane=Bo.FromPositionAndNormal(new b(0,u+.05,0),new b(0,1,0))}},this._refractionRTT.onAfterRender=function(){r._mesh&&(r._mesh.isVisible=o),r.disableClipPlane||(e.clipPlane=a)},this._reflectionRTT.onBeforeRender=function(){if(r._mesh&&(o=r._mesh.isVisible,r._mesh.isVisible=!1),!r.disableClipPlane){a=e.clipPlane;var u=r._mesh?r._mesh.position.y:0;e.clipPlane=Bo.FromPositionAndNormal(new b(0,u-.05,0),new b(0,-1,0)),te.ReflectionToRef(e.clipPlane,l)}s=e.getViewMatrix(),l.multiplyToRef(s,r._reflectionTransform),e.setTransformMatrix(r._reflectionTransform,e.getProjectionMatrix()),e.getEngine().cullBackFaces=!1,e._mirroredCameraPosition=b.TransformCoordinates(e.activeCamera.position,l)},this._reflectionRTT.onAfterRender=function(){r._mesh&&(r._mesh.isVisible=o),e.clipPlane=a,e.setTransformMatrix(s,e.getProjectionMatrix()),e.getEngine().cullBackFaces=!0,e._mirroredCameraPosition=null}},t.prototype.getAnimatables=function(){var e=[];return this.bumpTexture&&this.bumpTexture.animations&&this.bumpTexture.animations.length>0&&e.push(this.bumpTexture),this._reflectionRTT&&this._reflectionRTT.animations&&this._reflectionRTT.animations.length>0&&e.push(this._reflectionRTT),this._refractionRTT&&this._refractionRTT.animations&&this._refractionRTT.animations.length>0&&e.push(this._refractionRTT),e},t.prototype.getActiveTextures=function(){var e=n.prototype.getActiveTextures.call(this);return this._bumpTexture&&e.push(this._bumpTexture),e},t.prototype.hasTexture=function(e){return!!(n.prototype.hasTexture.call(this,e)||this._bumpTexture===e)},t.prototype.dispose=function(e){this.bumpTexture&&this.bumpTexture.dispose();var i=this.getScene().customRenderTargets.indexOf(this._refractionRTT);i!=-1&&this.getScene().customRenderTargets.splice(i,1),i=-1,i=this.getScene().customRenderTargets.indexOf(this._reflectionRTT),i!=-1&&this.getScene().customRenderTargets.splice(i,1),this._reflectionRTT&&this._reflectionRTT.dispose(),this._refractionRTT&&this._refractionRTT.dispose(),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),n.prototype.dispose.call(this,e)},t.prototype.clone=function(e){var i=this;return Fe.Clone(function(){return new t(e,i.getScene())},this)},t.prototype.serialize=function(){var e=Fe.Serialize(this);if(e.customType="BABYLON.WaterMaterial",e.renderList=[],this._refractionRTT&&this._refractionRTT.renderList)for(var i=0;i<this._refractionRTT.renderList.length;i++)e.renderList.push(this._refractionRTT.renderList[i].id);return e},t.prototype.getClassName=function(){return"WaterMaterial"},t.Parse=function(e,i,r){var o=Fe.Parse(function(){return new t(e.name,i)},e,i,r);return o._waitingRenderList=e.renderList,o},t.CreateDefaultMesh=function(e,i){var r=oe.CreateGround(e,512,512,32,i,!1);return r},A([at("bumpTexture")],t.prototype,"_bumpTexture",void 0),A([ye("_markAllSubMeshesAsTexturesDirty")],t.prototype,"bumpTexture",void 0),A([Ft()],t.prototype,"diffuseColor",void 0),A([Ft()],t.prototype,"specularColor",void 0),A([w()],t.prototype,"specularPower",void 0),A([w("disableLighting")],t.prototype,"_disableLighting",void 0),A([ye("_markAllSubMeshesAsLightsDirty")],t.prototype,"disableLighting",void 0),A([w("maxSimultaneousLights")],t.prototype,"_maxSimultaneousLights",void 0),A([ye("_markAllSubMeshesAsLightsDirty")],t.prototype,"maxSimultaneousLights",void 0),A([w()],t.prototype,"windForce",void 0),A([nb()],t.prototype,"windDirection",void 0),A([w()],t.prototype,"waveHeight",void 0),A([w()],t.prototype,"bumpHeight",void 0),A([w("bumpSuperimpose")],t.prototype,"_bumpSuperimpose",void 0),A([ye("_markAllSubMeshesAsMiscDirty")],t.prototype,"bumpSuperimpose",void 0),A([w("fresnelSeparate")],t.prototype,"_fresnelSeparate",void 0),A([ye("_markAllSubMeshesAsMiscDirty")],t.prototype,"fresnelSeparate",void 0),A([w("bumpAffectsReflection")],t.prototype,"_bumpAffectsReflection",void 0),A([ye("_markAllSubMeshesAsMiscDirty")],t.prototype,"bumpAffectsReflection",void 0),A([Ft()],t.prototype,"waterColor",void 0),A([w()],t.prototype,"colorBlendFactor",void 0),A([Ft()],t.prototype,"waterColor2",void 0),A([w()],t.prototype,"colorBlendFactor2",void 0),A([w()],t.prototype,"waveLength",void 0),A([w()],t.prototype,"waveSpeed",void 0),A([w()],t.prototype,"waveCount",void 0),A([w()],t.prototype,"disableClipPlane",void 0),A([w()],t.prototype,"useLogarithmicDepth",null),t}(Ir);Pe.RegisteredTypes["BABYLON.WaterMaterial"]=UY;function kY(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)}const zY=["data:EnvironmentBRDFTexture0","GlowLayerBlurRTT","GlowLayerBlurRTT2","HighlightLayerMainRTT"];function GY(n,t,e){async function i(u,f){return Te.CreateScreenshotUsingRenderTargetAsync(n,e,{width:u,height:f},void 0,void 0,!0)}async function r(u){e.inertialRadiusOffset=e.inertialRadiusOffset+u}async function o(u){const{x:f,y:c,z:h}=u;e.target.x=f||0,e.target.y=c||0,e.target.z=h||0}async function a(u){const{alpha:f,beta:c,radius:h}=u;f&&(e.alpha=e.alpha+f),c&&(e.beta=e.beta+c),h&&(e.radius=e.radius+h)}async function s(){const u=t.meshes.filter(p=>!p.name.toLowerCase().includes("collider")).reduce((p,_)=>p+Math.floor(_.getTotalIndices()/3),0),f=t.materials.length,c=t.meshes.length,h=t.textures.filter(p=>p.name&&!zY.includes(p.name)).length;return{triangles:u,materials:f,meshes:c,textures:h,bodies:c,entities:1}}async function l(){}return{getScreenshot:i,getMetrics:s,panCamera:o,changeZoom:r,changeCameraPosition:a,cleanup:l}}var WY={};const yI=WY.REACT_APP_DEBUG;yI&&require("@babylonjs/inspector");function HY(n){const t=n.getChildren().filter(e=>e.id!=="__root__");if(t.length>0){const e=t[0];let i=e.getBoundingInfo(),r=i.boundingBox.minimumWorld.add(e.position),o=i.boundingBox.maximumWorld.add(e.position);for(let a=1;a<t.length;a++){const s=t[a];i=s.getBoundingInfo();const l=i.boundingBox.minimumWorld.add(s.position),u=i.boundingBox.maximumWorld.add(s.position);r=b.Minimize(r,l),o=b.Maximize(o,u)}n.setBoundingInfo(new cr(r,o))}}let Nl;async function jY(n,t){Nl&&Nl.dispose(),Nl=new xe(n,!0,{preserveDrawingBuffer:!0,stencil:!0,antialias:!0});const e=new Ke(Nl);if(e.autoClear=!0,e.clearColor=t.background.transparent?new it(0,0,0,0):py(t.background.color).toColor4(),e.ambientColor=new me(1,1,1),e.preventDefaultOnPointerDown=!1,t.showSceneBoundaries){const s=yv.CreateGround("ground",{width:6,height:6},e),l=yv.CreateGround("ground",{width:6,height:6},e);l.rotate(Oi.Z,Math.PI),l.position.y=-.05;const u=new vI("groundMaterial",e);u.mainColor=new me(1,1,1),u.lineColor=new me(0,0,0),u.majorUnitFrequency=0,s.material=u,l.material=u;const f=yv.CreateCylinder("boundaries",{diameter:2,height:3}),c=new Mt("boundariesMaterial",e);c.alpha=.3,c.diffuseColor=new me(1,45/255,85/255),f.material=c,f.position.y=1.51}if(t.showThumbnailBoundaries){const s=Ib.CreateFullscreenUI("UI"),l=new no;l.width=.5,l.height=1,l.color="#736E7D",l.thickness=2,s.addControl(l)}const i=new Js("camera",0,0,0,new b(0,0,0),e);switch(i.position=new b(t.cameraX,t.cameraY,t.cameraZ),i.minZ=.1,t.projection){case Ae.PreviewProjection.PERSPECTIVE:{i.mode=dt.PERSPECTIVE_CAMERA;break}case Ae.PreviewProjection.ORTHOGRAPHIC:{i.mode=dt.ORTHOGRAPHIC_CAMERA,i.orthoTop=1,i.orthoBottom=-1,i.orthoLeft=-1,i.orthoRight=1;break}}t.type===Ae.PreviewType.WEARABLE&&lI(i,t),t.camera===Ae.PreviewCamera.INTERACTIVE&&i.attachControl(n,!0);const r=new b(t.offsetX,t.offsetY,t.offsetZ);if(i.position.addInPlace(r),i.setTarget(r),i.lowerRadiusLimit=i.radius/t.zoom,i.upperRadiusLimit=i.lowerRadiusLimit*t.wheelZoom,i.radius=i.lowerRadiusLimit+(i.upperRadiusLimit-i.lowerRadiusLimit)*t.wheelStart/100,i.wheelPrecision=t.wheelPrecision,t.panning||(i.panningSensibility=0),t.lockBeta&&(i.lowerBetaLimit=i.beta,i.upperBetaLimit=i.beta),t.lockAlpha&&(i.lowerAlphaLimit=i.alpha,i.upperAlphaLimit=i.alpha),t.lockRadius&&(i.lowerRadiusLimit=i.radius,i.upperRadiusLimit=i.radius),t.type===Ae.PreviewType.WEARABLE){const s=new su("directional",new b(0,0,1),e);s.intensity=1;const l=new lu("spot",new b(-2,2,2),new b(2,-2,-2),Math.PI/2,1e3,e);l.intensity=1}const o=new ko("top",new b(0,-1,0),e);o.intensity=1;const a=new ko("bottom",new b(0,1,0),e);if(a.intensity=1,!kY()){const s=new np("glow",e);s.intensity=2}return Nl.runRenderLoop(()=>{e.render()}),yI&&e.debugLayer.show({showExplorer:!0,embedMode:!0}),[e,GY(Nl,e,i)]}async function XY(n,t,e){const i=t.id,o=uu(t,e).contents.find(a=>a.key.toLowerCase().endsWith("_mask.png"));return o?new Promise((a,s)=>{const l=new Kx(i,o.url,!0,!1);l.onError=()=>s(l.errorObject),l.onSuccess=()=>{a(l.texture)},l.run(n,()=>a(l.texture),s)}):null}async function YY(n,t,e){const i=t.id,o=uu(t,e).contents.find(a=>a.key.toLowerCase().endsWith(".png")&&!a.key.toLowerCase().endsWith("_mask.png"));return o?new Promise((a,s)=>{const l=new Kx(i,o.url,!0,!1);l.onError=()=>s(l.errorObject),l.onSuccess=()=>{a(l.texture)},l.run(n,()=>a(l.texture),s)}):null}function KY(n,t){return new Promise((e,i)=>{var l;const r=(l=t.contents.find(u=>u.key.toLowerCase().endsWith(".mp3")||u.key.toLowerCase().endsWith("ogg")))==null?void 0:l.url;if(!r)return e(null);const o=new sj("Sound task",r),a=()=>e(new Ql("music",o.data,n,null,{spatialSound:!0})),s=u=>i(u);o.run(n,a,s)})}async function bI(n,t){const e=async(i,r)=>$t.LoadAssetContainerAsync(i,"",n,null,r);try{return await e(t,".glb")}catch{return await e(t,".gltf")}}function qY(n){const t=new oe("parent",n);for(const a of n.meshes)a!==t&&a.setParent(t);HY(t);const i=t.getBoundingInfo().boundingBox.extendSize.length(),r=new b(1/i,1/i,1/i);t.scaling=r;const o=t.getBoundingInfo().boundingBox.center.multiply(r);t.position.subtractInPlace(o)}var QY={VITE_BASE_URL:"https://cdn.decentraland.org/@dcl/wearable-preview/1.28.2-16170279969.commit-9d54b69"};const $Y=[Ae.PreviewEmote.IDLE,Ae.PreviewEmote.MONEY,Ae.PreviewEmote.CLAP,Ae.PreviewEmote.WALK,Ae.PreviewEmote.RUN,Ae.PreviewEmote.JUMP];let _d;function ZY(n){return $Y.includes(n)}function JY(n){let t=QY.VITE_BASE_URL;t.endsWith("/")||(t+="/");const e=`./emotes/${n}.glb`;return t.startsWith("http")?new URL(e,t).href:e}async function EI(n,t){const e=await bI(n,t);if(e.animationGroups.length===0)throw new Error(`No animation groups found for emote with url=${t}`);return e}async function e6(n,t,e){const i=Ab(t,e.bodyShape),r=i.contents.find(o=>o.key===i.mainFile);if(!r)throw new Error(`Could not find a valid content in representation for emote=${t.id} and bodyShape=${e.bodyShape}`);return EI(n,r.url)}function t6(n,t,e){const i=Ab(t,e.bodyShape);return KY(n,i)}async function i6(n,t,e){let i,r=!!e.emote&&ZY(e.emote),o=null;if(e.item&&Fo(e.item))try{i=await e6(n,e.item,e),r=e.item.emoteDataADR74.loop,o=await t6(n,e.item,e)}catch{console.warn(`Could not load emote=${e.item.id}`)}if(!i&&e.emote){const l=JY(e.emote);i=await EI(n,l)}i&&i.animationGroups.length>1&&(i.addAllToScene(),n.stopAllAnimations());const a=new ab("emote",n);function s(){if(e.camera!==Ae.PreviewCamera.STATIC){const l=n.cameras[0];lI(l,e)}}try{for(const u of t){const f=new Map,c=[...u.container.transformNodes,...u.container.meshes];for(const h of c){const p=h.name.replace(/\.\d+$/,""),_=f.get(p)||[];_.push(h),f.set(p,_)}if(i&&i.animationGroups.length>0)for(const h of i.animationGroups)for(const p of h.targetedAnimations){const _=p.animation.clone(),g=p.target,v=p.animation.getKeys();if(_.setKeys([...v]),i.animationGroups.length===1||h.name.toLowerCase().includes("avatar")||g.name.startsWith("Avatar_")){const T=g.name.replace(/\.\d+$/,""),S=f.get(T)||[];if(S.length>0)for(const C of S){const O=_.clone();O.setKeys([...v]),a.addTargetedAnimation(O,C)}else console.warn("No matching bone found for",g.name)}else a.addTargetedAnimation(_,g)}}a.onAnimationGroupEndObservable.addOnce(s);const l=r6(a,r,o);return e.camera===Ae.PreviewCamera.STATIC&&l.stop(),l}catch(l){console.warn(`Could not play emote=${e.emote}`,l)}}function r6(n,t,e){xe.audioEngine.useCustomUnlockedButton=!0,xe.audioEngine.setGlobalVolume(0);let i,r=!1;async function o(){return Math.max(n.to,0)}async function a(){return n.isPlaying}async function s(){return!!e}async function l(E){r=!0;const T=await a();T&&n.pause(),n.stop(),n.start(!1,1,E,E,!1),i=E,r=!0,T&&u()}async function u(){await a()||(i?(n.start(t,1,i,await o(),!1),e&&(e.stop(),e._startOffset=i,e.play()),i=0):(n.play(t),e==null||e.play()))}async function f(){await a()&&(n.pause(),e==null||e.pause())}async function c(){n.goToFrame(0),n.stop(),e==null||e.stop()}async function h(){e&&(xe.audioEngine.unlock(),xe.audioEngine.setGlobalVolume(1),n.isPlaying&&!e.isPlaying&&e.play(void 0,n.targetedAnimations[0].animation.runtimeAnimations[0].currentFrame))}async function p(){e&&xe.audioEngine.setGlobalVolume(0)}const _=ib(),g=()=>(_d&&clearInterval(_d),window.setInterval(async()=>{var E;if(await a()&&n.animatables[0].masterFrame>0)return _.emit(Ae.PreviewEmoteEventType.ANIMATION_PLAYING,{length:(E=n.animatables[0])==null?void 0:E.masterFrame})},10)),v=()=>{clearInterval(_d),r||_.emit(Ae.PreviewEmoteEventType.ANIMATION_PLAYING,{length:n.to})};return n.onAnimationGroupPlayObservable.add(()=>(_d=g(),_.emit(Ae.PreviewEmoteEventType.ANIMATION_PLAY))),n.onAnimationGroupPauseObservable.add(()=>{_.emit(Ae.PreviewEmoteEventType.ANIMATION_PAUSE)}),n.onAnimationGroupLoopObservable.add(()=>(e==null||e.stop(),e==null||e.play(),r&&(c(),u(),r=!1),_.emit(Ae.PreviewEmoteEventType.ANIMATION_LOOP))),n.onAnimationGroupEndObservable.add(()=>(v(),t||(r=!1),_.emit(Ae.PreviewEmoteEventType.ANIMATION_END))),{getLength:o,isPlaying:a,goTo:l,play:u,pause:f,stop:c,enableSound:h,disableSound:p,hasSound:s,events:_}}function n6(n,t,e){return async i=>{const r=t.find(Hj(i));return r?Promise.all([YY(n,r,e),XY(n,r,e)]):[null,null]}}async function o6(n,t,e){const i=n6(n,t,e),[r,o,a]=await Promise.all([i(Ae.WearableCategory.EYES),i(Ae.WearableCategory.EYEBROWS),i(Ae.WearableCategory.MOUTH)]);return{eyes:r,eyebrows:o,mouth:a}}async function a6(n,t,e,i,r,o){for(const a of t.container.meshes){if(a.name.toLowerCase().endsWith("mask_eyes")){const[s,l]=e;s?Hv(n,"eyes",a,s,o.eyes,l,"#ffffff"):a.setEnabled(!1)}if(a.name.toLowerCase().endsWith("mask_eyebrows")){const[s,l]=i;s?Hv(n,"eyebrows",a,s,o.hair,l,o.hair):a.setEnabled(!1)}if(a.name.toLowerCase().endsWith("mask_mouth")){const[s,l]=r;s?Hv(n,"mouth",a,s,o.skin,l,o.skin):a.setEnabled(!1)}}}function Hv(n,t,e,i,r,o,a){const s=new Mt(`${t}_standard_material`,n);s.alphaMode=Pi.PBRMATERIAL_ALPHABLEND,s.backFaceCulling=!0,s.specularColor=me.Black(),i.hasAlpha=!0,s.sideOrientation=Ys.CW,s.diffuseTexture=i,s.diffuseColor=o?me.Black():py(a),o&&(s.emissiveTexture=o,s.diffuseColor=py(r)),e.material=s}function s6(n,t,e=Ae.BodyShape.MALE){const i={};for(const r of n)try{const o=uu(r,e);for(const a of o.contents)i[a.key]=a.url}catch{console.warn(`Skipping generation of mappings for wearable="${r.id}" since it lacks a representation for bodyShape="${e}"`);continue}if(t){const r=Ab(t,e);for(const o of r.contents)i[o.key]=o.url}return i}function l6(n){const t=is(n.item)?[n.item,...n.wearables]:n.wearables,e=Fo(n.item)?n.item:void 0,i=s6(t,e,n.bodyShape);$t.OnPluginActivatedObservable.add(r=>{if(r.name==="gltf"){const o=r;o.preprocessUrlAsync=async a=>{const l=a.split("/").pop();if(!l)return a;const f=Object.keys(i).find(c=>c.endsWith(l));return i[f]||a}}})}const u6=`float angleY = 3.14 / 2.0;
|
|
16067
16067
|
|
|
16068
16068
|
mat3 rotateY = mat3(
|
|
16069
16069
|
cos(angleY), 0, sin(angleY),
|
|
@@ -16105,4 +16105,4 @@ else
|
|
|
16105
16105
|
}
|
|
16106
16106
|
`,jv="#include<pbrBlockFinalColorComposition>",bO="#include<customToonShading>";if(ce.ShadersStore.pbrPixelShader.includes(jv))ce.ShadersStore.pbrPixelShader.includes(bO)||(ce.ShadersStore.pbrPixelShader=ce.ShadersStore.pbrPixelShader.replace(jv,jv+`
|
|
16107
16107
|
`+bO+`
|
|
16108
|
-
`));else throw new Error("could not patch the pbrPixelShader");ce.IncludesShadersStore.customToonShading=u6;async function Xv(n,t,e=Ae.BodyShape.MALE,i,r){const o=uu(t,e);if(lp(o))throw new Error(`The wearable="${t.id}" is a texture`);const a=bj(o),s=await bI(n,a);for(const l of s.meshes)l.name.toLowerCase().includes("collider")&&(l.isVisible=!1,n.removeMesh(l));for(const l of s.materials)if(l instanceof Pi){const u=l;u.specularIntensity=0,u.metallic&&(u.metallic=0,u.metallicF0Factor=0),u.name.toLowerCase().includes("hair")&&(r?(u.albedoColor=me.FromHexString(r).toLinearSpace(),u.specularIntensity=0,u.alpha=1):(u.alpha=0,n.removeMaterial(u))),u.name.toLowerCase().includes("skin")&&(i?(u.albedoColor=me.FromHexString(i).toLinearSpace(),u.specularIntensity=0,u.alpha=1):(u.alpha=0,n.removeMaterial(u)))}for(const l of s.animationGroups)l.stop(),l.reset(),l.dispose();return{container:s,wearable:t}}async function f6(n,t){const[e,i]=await jY(n,t);try{l6(t);let r;const o=[];if(t.type===Ae.PreviewType.AVATAR){const s=$j(t),l=Array.from(s.values());for(const c of l.filter(aI)){const h=Xv(e,c,t.bodyShape,t.skin,t.hair).catch(p=>{console.warn(p.message)});o.push(h)}const u=(await Promise.all(o)).filter(Xj);for(const c of u)c.container.addAllToScene();const f=Kj(u);if(f){const c=l.filter(Yj),{eyes:h,eyebrows:p,mouth:_}=await o6(e,c,t.bodyShape);a6(e,f,h,p,_,t)}r=await i6(e,u,t)||YA()}else{const s=t.item;if(s&&!Fo(s))try{(await Xv(e,s,t.bodyShape,t.skin,t.hair)).container.addAllToScene()}catch{(await Xv(e,s,t.bodyShape===Ae.BodyShape.MALE?Ae.BodyShape.FEMALE:Ae.BodyShape.MALE,t.skin,t.hair)).container.addAllToScene()}r=YA()}return t.centerBoundingBox&&qY(e),{scene:i,emote:r}}catch(r){throw e.clearColor=new it(0,0,0,0),r}}function c6(n){const t=()=>{Ae.sendMessage(kn(),Ae.PreviewMessageType.EMOTE_EVENT,{type:Ae.PreviewEmoteEventType.ANIMATION_PLAY,payload:void 0})},e=()=>{Ae.sendMessage(kn(),Ae.PreviewMessageType.EMOTE_EVENT,{type:Ae.PreviewEmoteEventType.ANIMATION_PAUSE,payload:void 0})},i=()=>{Ae.sendMessage(kn(),Ae.PreviewMessageType.EMOTE_EVENT,{type:Ae.PreviewEmoteEventType.ANIMATION_LOOP,payload:void 0})},r=()=>{Ae.sendMessage(kn(),Ae.PreviewMessageType.EMOTE_EVENT,{type:Ae.PreviewEmoteEventType.ANIMATION_END,payload:void 0})},o=a=>{Ae.sendMessage(kn(),Ae.PreviewMessageType.EMOTE_EVENT,{type:Ae.PreviewEmoteEventType.ANIMATION_PLAYING,payload:a})};return n.emote.events.on(Ae.PreviewEmoteEventType.ANIMATION_PLAY,t),n.emote.events.on(Ae.PreviewEmoteEventType.ANIMATION_PAUSE,e),n.emote.events.on(Ae.PreviewEmoteEventType.ANIMATION_LOOP,i),n.emote.events.on(Ae.PreviewEmoteEventType.ANIMATION_END,r),n.emote.events.on(Ae.PreviewEmoteEventType.ANIMATION_PLAYING,o),()=>{n.emote.events.off(Ae.PreviewEmoteEventType.ANIMATION_PLAY,t),n.emote.events.off(Ae.PreviewEmoteEventType.ANIMATION_PAUSE,e),n.emote.events.off(Ae.PreviewEmoteEventType.ANIMATION_LOOP,i),n.emote.events.off(Ae.PreviewEmoteEventType.ANIMATION_END,r),n.emote.events.off(Ae.PreviewEmoteEventType.ANIMATION_PLAYING,o)}}const h6=()=>{const[n,t]=Ct.useState(""),{width:e,height:i}=oM(),[r,o]=Ct.useState({}),[a,s]=Ct.useState(!1),[l,u]=Ct.useState(!0),[f,c]=Ct.useState(!1),h=Ct.useRef(null),p=oI(),[_,g,v]=Gj(),[E,T]=Ct.useState(""),[S,C]=Ct.useState(!0),[O,R]=Ct.useState(!1),M=n||v,D=(l||g)&&!M,U=!!E&&!S&&!D,V=S&&!D;return Ct.useEffect(()=>{let B=()=>{};if(h.current&&_){let G={opacity:1};_.background.image&&(T(_.background.image),G.opacity=1,!_.background.transparent&&_.type===Ae.PreviewType.TEXTURE&&(G.backgroundColor=_.background.color)),o(G),_.type===Ae.PreviewType.TEXTURE?(C(!1),u(!1),c(!0)):f6(h.current,_).then(ee=>{p.current=ee,B=c6(p.current)}).catch(ee=>t(ee.message)).finally(()=>{u(!1),c(!0)})}return()=>{B()}},[h.current,_]),Ct.useEffect(()=>{var B;O||(f?(Ae.sendMessage(kn(),Ae.PreviewMessageType.LOAD,{renderer:Ae.PreviewRenderer.BABYLON}),R(!0),((_==null?void 0:_.type)===Ae.PreviewType.AVATAR||_!=null&&_.emote&&_.emote!==Ae.PreviewEmote.IDLE)&&((B=p.current)==null||B.emote.play())):M&&(Ae.sendMessage(kn(),Ae.PreviewMessageType.ERROR,{message:M}),R(!0)))},[f,M,O,p,_==null?void 0:_.type,_==null?void 0:_.emote]),Ct.useEffect(()=>{if(g){let B=!1;l||(u(!0),B=!0),O&&(R(!1),B=!0),B&&f&&c(!1)}},[g,l,O,f]),nI(),An.jsxs("div",{className:Xl("Preview",{"is-dragging":a,"is-loading":D,"is-loaded":f,"is-3d":S&&(_==null?void 0:_.camera)===Ae.PreviewCamera.INTERACTIVE,"has-error":!!M,"no-fade-effect":_&&!_.fadeEffect}),style:r,children:[An.jsx("img",{src:E,className:Xl("thumbnail",{"is-visible":U}),alt:"preview"}),An.jsx("canvas",{id:"wearable-preview",className:Xl({"is-visible":V}),width:e,height:i,ref:h,onMouseDown:()=>s(S&&!M),onMouseUp:()=>s(!1)}),M&&An.jsx("div",{className:"error",children:M})]})},d6=SO.memo(h6);var TI=(n=>(n.SET_MODE="SetMode",n.SET_PROFILE="SetProfile",n.SET_EMOTE="SetEmote",n.SET_URNS="SetUrns",n.SET_BACKGROUND="SetBackground",n.SET_SKIN_COLOR="SetSkinColor",n.SET_HAIR_COLOR="SetHairColor",n.SET_EYE_COLOR="SetEyeColor",n.SET_BODY_SHAPE="SetBodyShape",n.SET_SHOW_ANIMATION_REFERENCE="SetShowAnimationReference",n.SET_PROJECTION="SetProjection",n.ADD_BASE64="AddBase64",n.CLEAR_BASE64="ClearBase64",n.SET_CONTRACT="SetContract",n.SET_ITEM_ID="SetItemID",n.SET_TOKEN_ID="SetTokenID",n.SET_DISABLE_LOADER="SetDisableLoader",n.RELOAD="Reload",n.CLEANUP="Cleanup",n))(TI||{});const p6={unityMode:"SetMode",profile:"SetProfile",emote:"SetEmote",urns:"SetUrns",background:"SetBackground",skin:"SetSkinColor",hair:"SetHairColor",eyes:"SetEyeColor",bodyShape:"SetBodyShape",showAnimationReference:"SetShowAnimationReference",projection:"SetProjection",base64s:"AddBase64",contractAddress:"SetContract",itemId:"SetItemID",tokenId:"SetTokenID",disableLoader:"SetDisableLoader"},_6={unityMode:n=>String(n),profile:n=>String(n),emote:n=>String(n),urns:n=>Array.isArray(n)?n.join(","):String(n),background:n=>typeof n=="string"?n.replace("#",""):String(n),skin:n=>typeof n=="string"?n.replace("#",""):String(n),hair:n=>typeof n=="string"?n.replace("#",""):String(n),eyes:n=>typeof n=="string"?n.replace("#",""):String(n),bodyShape:n=>String(n),showAnimationReference:n=>String(n),projection:n=>String(n),contractAddress:n=>String(n),itemId:n=>String(n),tokenId:n=>String(n),disableLoader:n=>String(n)},md=(n,t,e)=>{if(n)try{const i=String(t);Object.values(TI).includes(i)||console.warn(`Unknown Unity method: ${i}. Sending anyway...`),e!==void 0?n.SendMessage("JSBridge",i,e):n.SendMessage("JSBridge",i)}catch(i){console.error(`Failed to send Unity message ${t}:`,i)}else console.warn(`Unity instance not ready, cannot send message: ${t}`)},m6=(n,t,e)=>{if(!n){console.warn("Unity instance not available, cannot send override messages");return}let i=0;t.base64s!==void 0&&e.base64s&&(md(n,"ClearBase64"),i++,Array.isArray(t.base64s)&&t.base64s.length>0&&t.base64s.forEach(r=>{md(n,"AddBase64",r),i++})),Object.entries(t).forEach(([r,o])=>{if(r!=="base64s"&&e[r]&&o!==void 0){const a=p6[r];if(a){const s=_6[r],l=s?s(o):String(o);md(n,a,l),i++}else console.warn(`No Unity method mapping found for property: ${r}`)}}),i>0&&md(n,"Reload")};var g6={VITE_BASE_URL:"https://cdn.decentraland.org/@dcl/wearable-preview/1.28.2-16155802308.commit-53348f0"};const Yv=new Map,rf=(n,t)=>{if(!t)return n;const e=n.replace(/\/$/,""),i=t.replace(/^\//,"");return`${e}/${i}`};function v6(n){if(Yv.has(n))return Yv.get(n);const t=new Promise((e,i)=>{const r=document.querySelector(`script[src="${n}"]`);if(r){r.addEventListener("load",()=>e(r)),r.addEventListener("error",a=>i(a));return}const o=document.createElement("script");o.src=n,o.async=!0,o.onload=()=>e(o),o.onerror=a=>i(a),document.body.appendChild(o)});return Yv.set(n,t),t}const y6=async(n,t,e,i,r,o,a,s,l,u,f)=>{try{const c=g6.VITE_BASE_URL||"";return await v6(rf(c,t)),await createUnityInstance(n,{dataUrl:rf(c,e),frameworkUrl:rf(c,i),codeUrl:rf(c,r),streamingAssetsUrl:rf(c,o),companyName:a,productName:s,productVersion:l,matchWebGLToCanvasSize:u,arguments:f})}catch(c){throw console.error("❌ Failed to load Unity instance:",c),c}};function b6(n){return{getScreenshot:()=>new Promise(t=>{if(!n){t("");return}n.SendMessage("JSBridge","TakeScreenshot",""),window.addEventListener("message",function e(i){if(i.data.type==="unity-renderer"){const{type:r,payload:o}=i.data.payload;r==="screenshot"&&(window.removeEventListener("message",e),t(o))}})}),getMetrics:()=>new Promise(t=>{if(!n){t({triangles:0,materials:0,textures:0,meshes:0,bodies:0,entities:0});return}n.SendMessage("JSBridge","GetMetrics",""),window.addEventListener("message",function e(i){if(i.data.type==="unity-renderer"){const{type:r,payload:o}=i.data.payload;r==="metrics"&&(window.removeEventListener("message",e),t(o))}})}),changeZoom:async t=>{n&&n.SendMessage("JSBridge","SetZoom",t.toString())},panCamera:async t=>{if(!n)return;const e=t.x??0,i=t.y??0,r=t.z??0;n.SendMessage("JSBridge","SetOffset",`${e},${i},${r}`)},changeCameraPosition:async t=>{if(!n)return;const e=t.alpha??0,i=t.beta??0,r=t.radius??0;n.SendMessage("JSBridge","SetCameraPosition",`${e},${i},${r}`)},cleanup:async()=>{n&&n.SendMessage("JSBridge","Cleanup","")}}}function E6(n){const t=ib();return{getLength:async()=>new Promise(e=>{if(!n){e(0);return}n.SendMessage("JSBridge","GetEmoteLength",""),window.addEventListener("message",function i(r){if(r.data.type==="unity-renderer"){const{type:o,payload:a}=r.data.payload;o==="emoteLength"&&(window.removeEventListener("message",i),e(a))}})}),isPlaying:async()=>new Promise(e=>{if(!n){e(!1);return}n.SendMessage("JSBridge","IsEmotePlaying",""),window.addEventListener("message",function i(r){if(r.data.type==="unity-renderer"){const{type:o,payload:a}=r.data.payload;o==="isEmotePlaying"&&(window.removeEventListener("message",i),e(a))}})}),goTo:async e=>{n&&(n.SendMessage("JSBridge","GoToEmote",e.toString()),t.emit(Ae.PreviewEmoteEventType.ANIMATION_PLAYING,{length:e}))},play:async()=>{n&&(n.SendMessage("JSBridge","PlayEmote",""),t.emit(Ae.PreviewEmoteEventType.ANIMATION_PLAY))},pause:async()=>{n&&(n.SendMessage("JSBridge","PauseEmote",""),t.emit(Ae.PreviewEmoteEventType.ANIMATION_PAUSE))},stop:async()=>{n&&(n.SendMessage("JSBridge","StopEmote",""),t.emit(Ae.PreviewEmoteEventType.ANIMATION_END))},enableSound:async()=>{n&&n.SendMessage("JSBridge","EnableSound","")},disableSound:async()=>{n&&n.SendMessage("JSBridge","DisableSound","")},hasSound:async()=>new Promise(e=>{if(!n){e(!1);return}n.SendMessage("JSBridge","HasSound",""),window.addEventListener("message",function i(r){if(r.data.type==="unity-renderer"){const{type:o,payload:a}=r.data.payload;o==="hasSound"&&(window.removeEventListener("message",i),e(a))}})}),events:t}}async function T6(n){let t=null;try{if(t=await y6(n,"/unity/Build/aang-renderer.loader.js","/unity/Build/aang-renderer.data.br","/unity/Build/aang-renderer.framework.js.br","/unity/Build/aang-renderer.wasm.br","/emotes","Decentraland","AangRenderer","1.3.5",!0,[]),!t)throw new Error("Failed to load Unity instance");const e=b6(t),i=E6(t);return{scene:e,emote:i,unity:t}}catch(e){if(console.error("Unity render failed:",e),t!=null&&t.Quit)try{t.Quit()}catch(i){console.error("Error quitting Unity instance:",i)}throw e}}const S6=()=>Math.floor(Math.random()*159)+1,SI=()=>`default${S6()}`,C6=(n,t)=>{var e,i,r,o,a,s;return{eyes:Jl(t.eyes||((i=(e=n==null?void 0:n.avatar)==null?void 0:e.eyes)==null?void 0:i.color)&&eu(n.avatar.eyes.color)||"#000000"),hair:Jl(t.hair||((o=(r=n==null?void 0:n.avatar)==null?void 0:r.hair)==null?void 0:o.color)&&eu(n.avatar.hair.color)||"#000000"),skin:Jl(t.skin||((s=(a=n==null?void 0:n.avatar)==null?void 0:a.skin)==null?void 0:s.color)&&eu(n.avatar.skin.color)||"#cc9b76")}},gd=n=>n||"",EO=n=>n||[],vd=n=>n.replace("#","");function P6(n){const t=new URL(window.location.href);Object.entries(n).forEach(([e,i])=>{t.searchParams.delete(e),Array.isArray(i)?i.forEach(r=>{r!==""&&t.searchParams.append(e,r)}):i!==""&&t.searchParams.set(e,i)}),window.history.replaceState({},"",t.toString())}function A6(){const{options:n,overrideSources:t}=Mb(),[e,i]=Ct.useState(null),[r,o]=Ct.useState(!0),[a,s]=Ct.useState(null),l=Ct.useRef(null),u=Ct.useRef(n),f=Ct.useRef(!0);return Ct.useEffect(()=>{const c=JSON.stringify(n),h=JSON.stringify(u.current);if(!f.current&&c===h)return;f.current=!1,u.current=n,(async()=>{var _,g;try{o(!0),s(null);const v=n.peerUrl||Nf.get("PEER_URL"),E=n.nftServerUrl||Nf.get("NFT_SERVER_URL");let T=Ae.PreviewType.WEARABLE,S={color:n.background||"#4b4852",transparent:n.disableBackground===!0};const C=Zx(n.profile);let O=C==null?void 0:C.value;O==="default"&&(O=SI());const R=O&&C?C.type==="address"?await eI(O,v):await tI(O,v):null,M=n.bodyShape||((_=R==null?void 0:R.avatar)==null?void 0:_.bodyShape)||Ae.BodyShape.MALE;let D=null;if(n.contractAddress&&(D=await iI({contractAddress:n.contractAddress,tokenId:n.tokenId,itemId:n.itemId,peerUrl:v,nftServerUrl:E}),D&&is(D))){S={...S,image:D.thumbnail};const Z=Rb(D);lp(Z)&&(T=Ae.PreviewType.TEXTURE)}const{eyes:U,hair:V,skin:B}=C6(R,{eyes:n.eyes,hair:n.hair,skin:n.skin}),G=n.mode||null,ee=n.camera&&Object.values(Ae.PreviewCamera).includes(n.camera)?n.camera:Ae.PreviewCamera.INTERACTIVE,q=n.projection&&Object.values(Ae.PreviewProjection).includes(n.projection)?n.projection:Ae.PreviewProjection.PERSPECTIVE,re=n.disableDefaultEmotes?null:n.emote&&Object.values(Ae.PreviewEmote).includes(n.emote)?n.emote:Ae.PreviewEmote.IDLE,se={background:S,bodyShape:M,mode:G,projection:q,type:T,base64:((g=n.base64s)==null?void 0:g[0])||null,contract:n.contractAddress||null,disableLoader:n.disableLoader||!1,emote:(re==null?void 0:re.toString())||null,eyeColor:U.replace("#",""),hairColor:V.replace("#",""),item:n.itemId||null,profile:O||null,skinColor:B.replace("#",""),token:n.tokenId||null,urn:n.urns||null,showAnimationReference:null},ue=JSON.stringify(se),H=JSON.stringify(l.current);if(ue!==H){if(l.current=se,Object.keys(t).length===0){const Z=EO(n.urns),K=EO(n.base64s),F={background:S.transparent?"":vd(S.color),disableLoader:n.disableLoader?"true":"",profile:gd(O||""),bodyShape:gd(M||""),eyeColor:vd(U||""),hairColor:vd(V||""),skinColor:vd(B||""),mode:gd(G||""),camera:ee,projection:q,emote:gd((re==null?void 0:re.toString())||""),urn:Z.length>0?Z:[""],base64:K.length>0?K:[""]};P6(F)}i(se)}o(!1)}catch(v){console.error("[useUnityConfig] Failed to load config:",v),s(v instanceof Error?v.message:"Failed to load config"),o(!1)}})()},[n,t]),[e,r,a]}const R6="unity-renderer",O6="unity-canvas",TO=1,M6="Failed to load Unity",x6=(n,t,e,i)=>{const[r,o]=Ct.useState({isLoaded:!1,isInitialized:!1,error:null}),a=Ct.useCallback(l=>{if(l.data.type===R6){const{type:u,payload:f}=l.data.payload;u==="loaded"&&(f===!0||f==="true")?(o(c=>({...c,isLoaded:!0,isInitialized:!0})),Ae.sendMessage(kn(),Ae.PreviewMessageType.LOAD,{renderer:Ae.PreviewRenderer.UNITY})):u==="error"&&(o(c=>({...c,error:f})),Ae.sendMessage(kn(),Ae.PreviewMessageType.ERROR,{message:"Error loading the wearable. Please try again."}))}},[]),s=Ct.useCallback(async()=>{if(!(!n.canvas.current||n.isInitializing.current||n.unityInstance.current)){n.isInitializing.current=!0,o(l=>({...l,isLoaded:!1,error:null}));try{const{unity:l,scene:u,emote:f}=await T6(n.canvas.current);n.unityInstance.current=l,t.current={scene:u,emote:f}}catch(l){const u=l instanceof Error?l.message:M6;console.error("Unity init failed:",l),o(f=>({...f,error:u})),Ae.sendMessage(kn(),Ae.PreviewMessageType.ERROR,{message:u})}finally{n.isInitializing.current=!1}}},[n,t]);return Ct.useEffect(()=>{r.isInitialized||i||!e||s()},[e,i,r.isInitialized,s]),Ct.useEffect(()=>{if(e)return window.addEventListener("message",a,!1),()=>{window.removeEventListener("message",a,!1)}},[e,a]),r},I6=n=>{const[t,e]=Ct.useState({pixelRatio:window.devicePixelRatio||TO,is3D:!0,backgroundImage:""});return Ct.useEffect(()=>{const i=()=>{e(o=>({...o,pixelRatio:window.devicePixelRatio||TO}))},r=window.matchMedia(`(resolution: ${t.pixelRatio}dppx)`);return r.addEventListener("change",i),()=>{r.removeEventListener("change",i)}},[t.pixelRatio]),Ct.useEffect(()=>{n&&e(i=>({...i,backgroundImage:n.background.image||"",is3D:n.type!==Ae.PreviewType.TEXTURE}))},[n]),t},D6=(n,t,e,i,r)=>{const o=Ct.useMemo(()=>{const a={};for(const s of Object.keys(r))r[s]&&i[s]!==void 0&&(a[s]=i[s]);return a},[r,i]);Ct.useEffect(()=>{if(!(!e.isInitialized||!e.isLoaded||!n.current)){if(o.profile==="default"){const a=t.current.profile;o.profile=a!=null&&a.match(/^default\d+$/)?a:SI()}Object.keys(o).length>0&&(m6(n.current,o,r),t.current=o)}},[e.isInitialized,e.isLoaded,o,r,n,t])},w6=()=>{const{width:n=window.innerWidth,height:t=window.innerHeight}=oM(),e=Ct.useRef(null),i=Ct.useRef(null),r=Ct.useRef(!1),o=Ct.useRef({}),a=oI(),[s,l,u]=A6(),{options:f,overrideSources:c}=Mb(),h=Ct.useMemo(()=>({canvas:e,unityInstance:i,isInitializing:r,lastSentOverrides:o}),[]),p=x6(h,a,s,l),_=I6(s);D6(h.unityInstance,h.lastSentOverrides,p,f,c),nI();const g=Ct.useMemo(()=>{const R=p.error||u,M=!p.isLoaded&&!R,D=!!_.backgroundImage&&!_.is3D&&!M,U=_.is3D&&!M;return{error:R,isLoading:M,showImage:D,showCanvas:U}},[p.error,p.isLoaded,u,_.backgroundImage,_.is3D]),v=Ct.useMemo(()=>({opacity:1,backgroundColor:!(s!=null&&s.background.transparent)&&(s==null?void 0:s.type)===Ae.PreviewType.TEXTURE?s.background.color:void 0}),[s]),E=Ct.useMemo(()=>({width:`${n}px`,height:`${t}px`}),[n,t]),T=Ct.useMemo(()=>({width:Math.round(n*_.pixelRatio),height:Math.round(t*_.pixelRatio)}),[n,t,_.pixelRatio]),S=Ct.useMemo(()=>Xl("Preview",{"is-loading":g.isLoading,"is-loaded":p.isLoaded,"is-3d":_.is3D,"has-error":!!g.error}),[g.isLoading,p.isLoaded,_.is3D,g.error]),C=Ct.useMemo(()=>Xl("thumbnail",{"is-visible":g.showImage}),[g.showImage]),O=Ct.useMemo(()=>Xl({"is-visible":g.showCanvas}),[g.showCanvas]);return An.jsxs("div",{className:S,style:v,children:[An.jsx("img",{src:_.backgroundImage,className:C,alt:"preview"}),An.jsx("canvas",{ref:h.canvas,id:O6,className:O,width:T.width,height:T.height,style:E}),g.error&&An.jsx("div",{className:"error",children:g.error})]})},L6=SO.memo(w6),CI=Ct.createContext(null),N6=({children:n,value:t})=>{const e={webGPUSupport:t,isSupported:t.isSupported,isAvailable:t.isAvailable};return An.jsx(CI.Provider,{value:e,children:n})},F6=()=>{const n=Ct.useContext(CI);if(!n)throw new Error("useWebGPUContext must be used within a WebGPUProvider");return n},B6=()=>F6(),V6=()=>{const n=navigator.userAgent.toLowerCase();let t="Unknown",e="Unknown",i="Unknown";if(/android/.test(n)){t="Android";const r=n.match(/android\s*([0-9.]+)/);r&&(i=r[1])}else if(/iphone|ipad|ipod/.test(n)){t="iOS";const r=n.match(/os\s*([0-9_]+)/);r&&(i=r[1].replace(/_/g,"."))}else if(/macintosh|mac os x/.test(n)){t="macOS";const r=n.match(/mac os x\s*([0-9_]+)/);r&&(i=r[1].replace(/_/g,"."))}else if(/windows/.test(n)){t="Windows";const r=n.match(/windows nt\s*([0-9.]+)/);r&&(i=r[1])}else if(/linux/.test(n)){t="Linux";const r=n.match(/\(([^)]+)\)/);r&&(i=r[1])}if(/chrome|crios/.test(n)){e="Chrome";const r=n.match(/(?:chrome|crios)\/([0-9.]+)/);r&&(i=r[1])}else if(/firefox|fxios/.test(n)){e="Firefox";const r=n.match(/(?:firefox|fxios)\/([0-9.]+)/);r&&(i=r[1])}else if(/safari/.test(n)&&!/chrome|crios|android/.test(n)){e="Safari";const r=n.match(/version\/([0-9.]+)/);r&&(i=r[1])}else if(/edg/.test(n)){e="Edge";const r=n.match(/edg\/([0-9.]+)/);r&&(i=r[1])}return{platform:t,browser:e,version:i}},U6=async()=>{const{platform:n,browser:t,version:e}=V6();if(!navigator.gpu)return console.warn("❌ navigator.gpu is not available"),{isSupported:!1,isAvailable:!1,error:"WebGPU is not supported in this browser. Please use a compatible browser.",platform:n,browser:t,platformVersion:e,browserVersion:e};try{const i=await navigator.gpu.requestAdapter();return i?await i.requestDevice()?{isSupported:!0,isAvailable:!0,platform:n,browser:t,platformVersion:e,browserVersion:e}:(console.warn("❌ Failed to create WebGPU device"),{isSupported:!0,isAvailable:!1,error:"WebGPU adapter found but failed to create device. This might be due to hardware limitations or driver issues.",platform:n,browser:t,platformVersion:e,browserVersion:e}):(console.warn("❌ No WebGPU adapter available"),{isSupported:!0,isAvailable:!1,error:"WebGPU is supported but no adapter is available. This might be due to hardware limitations or driver issues.",platform:n,browser:t,platformVersion:e,browserVersion:e})}catch(i){return console.error("❌ WebGPU detection error:",i),{isSupported:!0,isAvailable:!1,error:`WebGPU is supported but failed to initialize: ${i instanceof Error?i.message:"Unknown error"}`,platform:n,browser:t,platformVersion:e,browserVersion:e}}},k6=()=>{const t=new URLSearchParams(window.location.search).get("unity")==="true",{isAvailable:e}=B6();return t&&e?An.jsx(L6,{}):An.jsx(d6,{})},z6=async()=>{const n=await U6();pw.createRoot(document.getElementById("root")).render(An.jsx(Ct.StrictMode,{children:An.jsx(N6,{value:n,children:An.jsx(k6,{})})}))};z6();
|
|
16108
|
+
`));else throw new Error("could not patch the pbrPixelShader");ce.IncludesShadersStore.customToonShading=u6;async function Xv(n,t,e=Ae.BodyShape.MALE,i,r){const o=uu(t,e);if(lp(o))throw new Error(`The wearable="${t.id}" is a texture`);const a=bj(o),s=await bI(n,a);for(const l of s.meshes)l.name.toLowerCase().includes("collider")&&(l.isVisible=!1,n.removeMesh(l));for(const l of s.materials)if(l instanceof Pi){const u=l;u.specularIntensity=0,u.metallic&&(u.metallic=0,u.metallicF0Factor=0),u.name.toLowerCase().includes("hair")&&(r?(u.albedoColor=me.FromHexString(r).toLinearSpace(),u.specularIntensity=0,u.alpha=1):(u.alpha=0,n.removeMaterial(u))),u.name.toLowerCase().includes("skin")&&(i?(u.albedoColor=me.FromHexString(i).toLinearSpace(),u.specularIntensity=0,u.alpha=1):(u.alpha=0,n.removeMaterial(u)))}for(const l of s.animationGroups)l.stop(),l.reset(),l.dispose();return{container:s,wearable:t}}async function f6(n,t){const[e,i]=await jY(n,t);try{l6(t);let r;const o=[];if(t.type===Ae.PreviewType.AVATAR){const s=$j(t),l=Array.from(s.values());for(const c of l.filter(aI)){const h=Xv(e,c,t.bodyShape,t.skin,t.hair).catch(p=>{console.warn(p.message)});o.push(h)}const u=(await Promise.all(o)).filter(Xj);for(const c of u)c.container.addAllToScene();const f=Kj(u);if(f){const c=l.filter(Yj),{eyes:h,eyebrows:p,mouth:_}=await o6(e,c,t.bodyShape);a6(e,f,h,p,_,t)}r=await i6(e,u,t)||YA()}else{const s=t.item;if(s&&!Fo(s))try{(await Xv(e,s,t.bodyShape,t.skin,t.hair)).container.addAllToScene()}catch{(await Xv(e,s,t.bodyShape===Ae.BodyShape.MALE?Ae.BodyShape.FEMALE:Ae.BodyShape.MALE,t.skin,t.hair)).container.addAllToScene()}r=YA()}return t.centerBoundingBox&&qY(e),{scene:i,emote:r}}catch(r){throw e.clearColor=new it(0,0,0,0),r}}function c6(n){const t=()=>{Ae.sendMessage(kn(),Ae.PreviewMessageType.EMOTE_EVENT,{type:Ae.PreviewEmoteEventType.ANIMATION_PLAY,payload:void 0})},e=()=>{Ae.sendMessage(kn(),Ae.PreviewMessageType.EMOTE_EVENT,{type:Ae.PreviewEmoteEventType.ANIMATION_PAUSE,payload:void 0})},i=()=>{Ae.sendMessage(kn(),Ae.PreviewMessageType.EMOTE_EVENT,{type:Ae.PreviewEmoteEventType.ANIMATION_LOOP,payload:void 0})},r=()=>{Ae.sendMessage(kn(),Ae.PreviewMessageType.EMOTE_EVENT,{type:Ae.PreviewEmoteEventType.ANIMATION_END,payload:void 0})},o=a=>{Ae.sendMessage(kn(),Ae.PreviewMessageType.EMOTE_EVENT,{type:Ae.PreviewEmoteEventType.ANIMATION_PLAYING,payload:a})};return n.emote.events.on(Ae.PreviewEmoteEventType.ANIMATION_PLAY,t),n.emote.events.on(Ae.PreviewEmoteEventType.ANIMATION_PAUSE,e),n.emote.events.on(Ae.PreviewEmoteEventType.ANIMATION_LOOP,i),n.emote.events.on(Ae.PreviewEmoteEventType.ANIMATION_END,r),n.emote.events.on(Ae.PreviewEmoteEventType.ANIMATION_PLAYING,o),()=>{n.emote.events.off(Ae.PreviewEmoteEventType.ANIMATION_PLAY,t),n.emote.events.off(Ae.PreviewEmoteEventType.ANIMATION_PAUSE,e),n.emote.events.off(Ae.PreviewEmoteEventType.ANIMATION_LOOP,i),n.emote.events.off(Ae.PreviewEmoteEventType.ANIMATION_END,r),n.emote.events.off(Ae.PreviewEmoteEventType.ANIMATION_PLAYING,o)}}const h6=()=>{const[n,t]=Ct.useState(""),{width:e,height:i}=oM(),[r,o]=Ct.useState({}),[a,s]=Ct.useState(!1),[l,u]=Ct.useState(!0),[f,c]=Ct.useState(!1),h=Ct.useRef(null),p=oI(),[_,g,v]=Gj(),[E,T]=Ct.useState(""),[S,C]=Ct.useState(!0),[O,R]=Ct.useState(!1),M=n||v,D=(l||g)&&!M,U=!!E&&!S&&!D,V=S&&!D;return Ct.useEffect(()=>{let B=()=>{};if(h.current&&_){let G={opacity:1};_.background.image&&(T(_.background.image),G.opacity=1,!_.background.transparent&&_.type===Ae.PreviewType.TEXTURE&&(G.backgroundColor=_.background.color)),o(G),_.type===Ae.PreviewType.TEXTURE?(C(!1),u(!1),c(!0)):f6(h.current,_).then(ee=>{p.current=ee,B=c6(p.current)}).catch(ee=>t(ee.message)).finally(()=>{u(!1),c(!0)})}return()=>{B()}},[h.current,_]),Ct.useEffect(()=>{var B;O||(f?(Ae.sendMessage(kn(),Ae.PreviewMessageType.LOAD,{renderer:Ae.PreviewRenderer.BABYLON}),R(!0),((_==null?void 0:_.type)===Ae.PreviewType.AVATAR||_!=null&&_.emote&&_.emote!==Ae.PreviewEmote.IDLE)&&((B=p.current)==null||B.emote.play())):M&&(Ae.sendMessage(kn(),Ae.PreviewMessageType.ERROR,{message:M}),R(!0)))},[f,M,O,p,_==null?void 0:_.type,_==null?void 0:_.emote]),Ct.useEffect(()=>{if(g){let B=!1;l||(u(!0),B=!0),O&&(R(!1),B=!0),B&&f&&c(!1)}},[g,l,O,f]),nI(),An.jsxs("div",{className:Xl("Preview",{"is-dragging":a,"is-loading":D,"is-loaded":f,"is-3d":S&&(_==null?void 0:_.camera)===Ae.PreviewCamera.INTERACTIVE,"has-error":!!M,"no-fade-effect":_&&!_.fadeEffect}),style:r,children:[An.jsx("img",{src:E,className:Xl("thumbnail",{"is-visible":U}),alt:"preview"}),An.jsx("canvas",{id:"wearable-preview",className:Xl({"is-visible":V}),width:e,height:i,ref:h,onMouseDown:()=>s(S&&!M),onMouseUp:()=>s(!1)}),M&&An.jsx("div",{className:"error",children:M})]})},d6=SO.memo(h6);var TI=(n=>(n.SET_MODE="SetMode",n.SET_PROFILE="SetProfile",n.SET_EMOTE="SetEmote",n.SET_URNS="SetUrns",n.SET_BACKGROUND="SetBackground",n.SET_SKIN_COLOR="SetSkinColor",n.SET_HAIR_COLOR="SetHairColor",n.SET_EYE_COLOR="SetEyeColor",n.SET_BODY_SHAPE="SetBodyShape",n.SET_SHOW_ANIMATION_REFERENCE="SetShowAnimationReference",n.SET_PROJECTION="SetProjection",n.ADD_BASE64="AddBase64",n.CLEAR_BASE64="ClearBase64",n.SET_CONTRACT="SetContract",n.SET_ITEM_ID="SetItemID",n.SET_TOKEN_ID="SetTokenID",n.SET_DISABLE_LOADER="SetDisableLoader",n.RELOAD="Reload",n.CLEANUP="Cleanup",n))(TI||{});const p6={unityMode:"SetMode",profile:"SetProfile",emote:"SetEmote",urns:"SetUrns",background:"SetBackground",skin:"SetSkinColor",hair:"SetHairColor",eyes:"SetEyeColor",bodyShape:"SetBodyShape",showAnimationReference:"SetShowAnimationReference",projection:"SetProjection",base64s:"AddBase64",contractAddress:"SetContract",itemId:"SetItemID",tokenId:"SetTokenID",disableLoader:"SetDisableLoader"},_6={unityMode:n=>String(n),profile:n=>String(n),emote:n=>String(n),urns:n=>Array.isArray(n)?n.join(","):String(n),background:n=>typeof n=="string"?n.replace("#",""):String(n),skin:n=>typeof n=="string"?n.replace("#",""):String(n),hair:n=>typeof n=="string"?n.replace("#",""):String(n),eyes:n=>typeof n=="string"?n.replace("#",""):String(n),bodyShape:n=>String(n),showAnimationReference:n=>String(n),projection:n=>String(n),contractAddress:n=>String(n),itemId:n=>String(n),tokenId:n=>String(n),disableLoader:n=>String(n)},md=(n,t,e)=>{if(n)try{const i=String(t);Object.values(TI).includes(i)||console.warn(`Unknown Unity method: ${i}. Sending anyway...`),e!==void 0?n.SendMessage("JSBridge",i,e):n.SendMessage("JSBridge",i)}catch(i){console.error(`Failed to send Unity message ${t}:`,i)}else console.warn(`Unity instance not ready, cannot send message: ${t}`)},m6=(n,t,e)=>{if(!n){console.warn("Unity instance not available, cannot send override messages");return}let i=0;t.base64s!==void 0&&e.base64s&&(md(n,"ClearBase64"),i++,Array.isArray(t.base64s)&&t.base64s.length>0&&t.base64s.forEach(r=>{md(n,"AddBase64",r),i++})),Object.entries(t).forEach(([r,o])=>{if(r!=="base64s"&&e[r]&&o!==void 0){const a=p6[r];if(a){const s=_6[r],l=s?s(o):String(o);md(n,a,l),i++}else console.warn(`No Unity method mapping found for property: ${r}`)}}),i>0&&md(n,"Reload")};var g6={VITE_BASE_URL:"https://cdn.decentraland.org/@dcl/wearable-preview/1.28.2-16170279969.commit-9d54b69"};const Yv=new Map,rf=(n,t)=>{if(!t)return n;const e=n.replace(/\/$/,""),i=t.replace(/^\//,"");return`${e}/${i}`};function v6(n){if(Yv.has(n))return Yv.get(n);const t=new Promise((e,i)=>{const r=document.querySelector(`script[src="${n}"]`);if(r){r.addEventListener("load",()=>e(r)),r.addEventListener("error",a=>i(a));return}const o=document.createElement("script");o.src=n,o.async=!0,o.onload=()=>e(o),o.onerror=a=>i(a),document.body.appendChild(o)});return Yv.set(n,t),t}const y6=async(n,t,e,i,r,o,a,s,l,u,f)=>{try{const c=g6.VITE_BASE_URL||"";return await v6(rf(c,t)),await createUnityInstance(n,{dataUrl:rf(c,e),frameworkUrl:rf(c,i),codeUrl:rf(c,r),streamingAssetsUrl:rf(c,o),companyName:a,productName:s,productVersion:l,matchWebGLToCanvasSize:u,arguments:f})}catch(c){throw console.error("❌ Failed to load Unity instance:",c),c}};function b6(n){return{getScreenshot:()=>new Promise(t=>{if(!n){t("");return}n.SendMessage("JSBridge","TakeScreenshot",""),window.addEventListener("message",function e(i){if(i.data.type==="unity-renderer"){const{type:r,payload:o}=i.data.payload;r==="screenshot"&&(window.removeEventListener("message",e),t(o))}})}),getMetrics:()=>new Promise(t=>{if(!n){t({triangles:0,materials:0,textures:0,meshes:0,bodies:0,entities:0});return}n.SendMessage("JSBridge","GetMetrics",""),window.addEventListener("message",function e(i){if(i.data.type==="unity-renderer"){const{type:r,payload:o}=i.data.payload;r==="metrics"&&(window.removeEventListener("message",e),t(o))}})}),changeZoom:async t=>{n&&n.SendMessage("JSBridge","SetZoom",t.toString())},panCamera:async t=>{if(!n)return;const e=t.x??0,i=t.y??0,r=t.z??0;n.SendMessage("JSBridge","SetOffset",`${e},${i},${r}`)},changeCameraPosition:async t=>{if(!n)return;const e=t.alpha??0,i=t.beta??0,r=t.radius??0;n.SendMessage("JSBridge","SetCameraPosition",`${e},${i},${r}`)},cleanup:async()=>{n&&n.SendMessage("JSBridge","Cleanup","")}}}function E6(n){const t=ib();return{getLength:async()=>new Promise(e=>{if(!n){e(0);return}n.SendMessage("JSBridge","GetEmoteLength",""),window.addEventListener("message",function i(r){if(r.data.type==="unity-renderer"){const{type:o,payload:a}=r.data.payload;o==="emoteLength"&&(window.removeEventListener("message",i),e(a))}})}),isPlaying:async()=>new Promise(e=>{if(!n){e(!1);return}n.SendMessage("JSBridge","IsEmotePlaying",""),window.addEventListener("message",function i(r){if(r.data.type==="unity-renderer"){const{type:o,payload:a}=r.data.payload;o==="isEmotePlaying"&&(window.removeEventListener("message",i),e(a))}})}),goTo:async e=>{n&&(n.SendMessage("JSBridge","GoToEmote",e.toString()),t.emit(Ae.PreviewEmoteEventType.ANIMATION_PLAYING,{length:e}))},play:async()=>{n&&(n.SendMessage("JSBridge","PlayEmote",""),t.emit(Ae.PreviewEmoteEventType.ANIMATION_PLAY))},pause:async()=>{n&&(n.SendMessage("JSBridge","PauseEmote",""),t.emit(Ae.PreviewEmoteEventType.ANIMATION_PAUSE))},stop:async()=>{n&&(n.SendMessage("JSBridge","StopEmote",""),t.emit(Ae.PreviewEmoteEventType.ANIMATION_END))},enableSound:async()=>{n&&n.SendMessage("JSBridge","EnableSound","")},disableSound:async()=>{n&&n.SendMessage("JSBridge","DisableSound","")},hasSound:async()=>new Promise(e=>{if(!n){e(!1);return}n.SendMessage("JSBridge","HasSound",""),window.addEventListener("message",function i(r){if(r.data.type==="unity-renderer"){const{type:o,payload:a}=r.data.payload;o==="hasSound"&&(window.removeEventListener("message",i),e(a))}})}),events:t}}async function T6(n){let t=null;try{if(t=await y6(n,"/unity/Build/aang-renderer.loader.js","/unity/Build/aang-renderer.data.br","/unity/Build/aang-renderer.framework.js.br","/unity/Build/aang-renderer.wasm.br","/emotes","Decentraland","AangRenderer","1.3.6",!0,[]),!t)throw new Error("Failed to load Unity instance");const e=b6(t),i=E6(t);return{scene:e,emote:i,unity:t}}catch(e){if(console.error("Unity render failed:",e),t!=null&&t.Quit)try{t.Quit()}catch(i){console.error("Error quitting Unity instance:",i)}throw e}}const S6=()=>Math.floor(Math.random()*159)+1,SI=()=>`default${S6()}`,C6=(n,t)=>{var e,i,r,o,a,s;return{eyes:Jl(t.eyes||((i=(e=n==null?void 0:n.avatar)==null?void 0:e.eyes)==null?void 0:i.color)&&eu(n.avatar.eyes.color)||"#000000"),hair:Jl(t.hair||((o=(r=n==null?void 0:n.avatar)==null?void 0:r.hair)==null?void 0:o.color)&&eu(n.avatar.hair.color)||"#000000"),skin:Jl(t.skin||((s=(a=n==null?void 0:n.avatar)==null?void 0:a.skin)==null?void 0:s.color)&&eu(n.avatar.skin.color)||"#cc9b76")}},gd=n=>n||"",EO=n=>n||[],vd=n=>n.replace("#","");function P6(n){const t=new URL(window.location.href);Object.entries(n).forEach(([e,i])=>{t.searchParams.delete(e),Array.isArray(i)?i.forEach(r=>{r!==""&&t.searchParams.append(e,r)}):i!==""&&t.searchParams.set(e,i)}),window.history.replaceState({},"",t.toString())}function A6(){const{options:n,overrideSources:t}=Mb(),[e,i]=Ct.useState(null),[r,o]=Ct.useState(!0),[a,s]=Ct.useState(null),l=Ct.useRef(null),u=Ct.useRef(n),f=Ct.useRef(!0);return Ct.useEffect(()=>{const c=JSON.stringify(n),h=JSON.stringify(u.current);if(!f.current&&c===h)return;f.current=!1,u.current=n,(async()=>{var _,g;try{o(!0),s(null);const v=n.peerUrl||Nf.get("PEER_URL"),E=n.nftServerUrl||Nf.get("NFT_SERVER_URL");let T=Ae.PreviewType.WEARABLE,S={color:n.background||"#4b4852",transparent:n.disableBackground===!0};const C=Zx(n.profile);let O=C==null?void 0:C.value;O==="default"&&(O=SI());const R=O&&C?C.type==="address"?await eI(O,v):await tI(O,v):null,M=n.bodyShape||((_=R==null?void 0:R.avatar)==null?void 0:_.bodyShape)||Ae.BodyShape.MALE;let D=null;if(n.contractAddress&&(D=await iI({contractAddress:n.contractAddress,tokenId:n.tokenId,itemId:n.itemId,peerUrl:v,nftServerUrl:E}),D&&is(D))){S={...S,image:D.thumbnail};const Z=Rb(D);lp(Z)&&(T=Ae.PreviewType.TEXTURE)}const{eyes:U,hair:V,skin:B}=C6(R,{eyes:n.eyes,hair:n.hair,skin:n.skin}),G=n.mode||null,ee=n.camera&&Object.values(Ae.PreviewCamera).includes(n.camera)?n.camera:Ae.PreviewCamera.INTERACTIVE,q=n.projection&&Object.values(Ae.PreviewProjection).includes(n.projection)?n.projection:Ae.PreviewProjection.PERSPECTIVE,re=n.disableDefaultEmotes?null:n.emote&&Object.values(Ae.PreviewEmote).includes(n.emote)?n.emote:Ae.PreviewEmote.IDLE,se={background:S,bodyShape:M,mode:G,projection:q,type:T,base64:((g=n.base64s)==null?void 0:g[0])||null,contract:n.contractAddress||null,disableLoader:n.disableLoader||!1,emote:(re==null?void 0:re.toString())||null,eyeColor:U.replace("#",""),hairColor:V.replace("#",""),item:n.itemId||null,profile:O||null,skinColor:B.replace("#",""),token:n.tokenId||null,urn:n.urns||null,showAnimationReference:null},ue=JSON.stringify(se),H=JSON.stringify(l.current);if(ue!==H){if(l.current=se,Object.keys(t).length===0){const Z=EO(n.urns),K=EO(n.base64s),F={background:S.transparent?"":vd(S.color),disableLoader:n.disableLoader?"true":"",profile:gd(O||""),bodyShape:gd(M||""),eyeColor:vd(U||""),hairColor:vd(V||""),skinColor:vd(B||""),mode:gd(G||""),camera:ee,projection:q,emote:gd((re==null?void 0:re.toString())||""),urn:Z.length>0?Z:[""],base64:K.length>0?K:[""]};P6(F)}i(se)}o(!1)}catch(v){console.error("[useUnityConfig] Failed to load config:",v),s(v instanceof Error?v.message:"Failed to load config"),o(!1)}})()},[n,t]),[e,r,a]}const R6="unity-renderer",O6="unity-canvas",TO=1,M6="Failed to load Unity",x6=(n,t,e,i)=>{const[r,o]=Ct.useState({isLoaded:!1,isInitialized:!1,error:null}),a=Ct.useCallback(l=>{if(l.data.type===R6){const{type:u,payload:f}=l.data.payload;u==="loaded"&&(f===!0||f==="true")?(o(c=>({...c,isLoaded:!0,isInitialized:!0})),Ae.sendMessage(kn(),Ae.PreviewMessageType.LOAD,{renderer:Ae.PreviewRenderer.UNITY})):u==="error"&&(o(c=>({...c,error:f})),Ae.sendMessage(kn(),Ae.PreviewMessageType.ERROR,{message:"Error loading the wearable. Please try again."}))}},[]),s=Ct.useCallback(async()=>{if(!(!n.canvas.current||n.isInitializing.current||n.unityInstance.current)){n.isInitializing.current=!0,o(l=>({...l,isLoaded:!1,error:null}));try{const{unity:l,scene:u,emote:f}=await T6(n.canvas.current);n.unityInstance.current=l,t.current={scene:u,emote:f}}catch(l){const u=l instanceof Error?l.message:M6;console.error("Unity init failed:",l),o(f=>({...f,error:u})),Ae.sendMessage(kn(),Ae.PreviewMessageType.ERROR,{message:u})}finally{n.isInitializing.current=!1}}},[n,t]);return Ct.useEffect(()=>{r.isInitialized||i||!e||s()},[e,i,r.isInitialized,s]),Ct.useEffect(()=>{if(e)return window.addEventListener("message",a,!1),()=>{window.removeEventListener("message",a,!1)}},[e,a]),r},I6=n=>{const[t,e]=Ct.useState({pixelRatio:window.devicePixelRatio||TO,is3D:!0,backgroundImage:""});return Ct.useEffect(()=>{const i=()=>{e(o=>({...o,pixelRatio:window.devicePixelRatio||TO}))},r=window.matchMedia(`(resolution: ${t.pixelRatio}dppx)`);return r.addEventListener("change",i),()=>{r.removeEventListener("change",i)}},[t.pixelRatio]),Ct.useEffect(()=>{n&&e(i=>({...i,backgroundImage:n.background.image||"",is3D:n.type!==Ae.PreviewType.TEXTURE}))},[n]),t},D6=(n,t,e,i,r)=>{const o=Ct.useMemo(()=>{const a={};for(const s of Object.keys(r))r[s]&&i[s]!==void 0&&(a[s]=i[s]);return a},[r,i]);Ct.useEffect(()=>{if(!(!e.isInitialized||!e.isLoaded||!n.current)){if(o.profile==="default"){const a=t.current.profile;o.profile=a!=null&&a.match(/^default\d+$/)?a:SI()}Object.keys(o).length>0&&(m6(n.current,o,r),t.current=o)}},[e.isInitialized,e.isLoaded,o,r,n,t])},w6=()=>{const{width:n=window.innerWidth,height:t=window.innerHeight}=oM(),e=Ct.useRef(null),i=Ct.useRef(null),r=Ct.useRef(!1),o=Ct.useRef({}),a=oI(),[s,l,u]=A6(),{options:f,overrideSources:c}=Mb(),h=Ct.useMemo(()=>({canvas:e,unityInstance:i,isInitializing:r,lastSentOverrides:o}),[]),p=x6(h,a,s,l),_=I6(s);D6(h.unityInstance,h.lastSentOverrides,p,f,c),nI();const g=Ct.useMemo(()=>{const R=p.error||u,M=!p.isLoaded&&!R,D=!!_.backgroundImage&&!_.is3D&&!M,U=_.is3D&&!M;return{error:R,isLoading:M,showImage:D,showCanvas:U}},[p.error,p.isLoaded,u,_.backgroundImage,_.is3D]),v=Ct.useMemo(()=>({opacity:1,backgroundColor:!(s!=null&&s.background.transparent)&&(s==null?void 0:s.type)===Ae.PreviewType.TEXTURE?s.background.color:void 0}),[s]),E=Ct.useMemo(()=>({width:`${n}px`,height:`${t}px`}),[n,t]),T=Ct.useMemo(()=>({width:Math.round(n*_.pixelRatio),height:Math.round(t*_.pixelRatio)}),[n,t,_.pixelRatio]),S=Ct.useMemo(()=>Xl("Preview",{"is-loading":g.isLoading,"is-loaded":p.isLoaded,"is-3d":_.is3D,"has-error":!!g.error}),[g.isLoading,p.isLoaded,_.is3D,g.error]),C=Ct.useMemo(()=>Xl("thumbnail",{"is-visible":g.showImage}),[g.showImage]),O=Ct.useMemo(()=>Xl({"is-visible":g.showCanvas}),[g.showCanvas]);return An.jsxs("div",{className:S,style:v,children:[An.jsx("img",{src:_.backgroundImage,className:C,alt:"preview"}),An.jsx("canvas",{ref:h.canvas,id:O6,className:O,width:T.width,height:T.height,style:E}),g.error&&An.jsx("div",{className:"error",children:g.error})]})},L6=SO.memo(w6),CI=Ct.createContext(null),N6=({children:n,value:t})=>{const e={webGPUSupport:t,isSupported:t.isSupported,isAvailable:t.isAvailable};return An.jsx(CI.Provider,{value:e,children:n})},F6=()=>{const n=Ct.useContext(CI);if(!n)throw new Error("useWebGPUContext must be used within a WebGPUProvider");return n},B6=()=>F6(),V6=()=>{const n=navigator.userAgent.toLowerCase();let t="Unknown",e="Unknown",i="Unknown";if(/android/.test(n)){t="Android";const r=n.match(/android\s*([0-9.]+)/);r&&(i=r[1])}else if(/iphone|ipad|ipod/.test(n)){t="iOS";const r=n.match(/os\s*([0-9_]+)/);r&&(i=r[1].replace(/_/g,"."))}else if(/macintosh|mac os x/.test(n)){t="macOS";const r=n.match(/mac os x\s*([0-9_]+)/);r&&(i=r[1].replace(/_/g,"."))}else if(/windows/.test(n)){t="Windows";const r=n.match(/windows nt\s*([0-9.]+)/);r&&(i=r[1])}else if(/linux/.test(n)){t="Linux";const r=n.match(/\(([^)]+)\)/);r&&(i=r[1])}if(/chrome|crios/.test(n)){e="Chrome";const r=n.match(/(?:chrome|crios)\/([0-9.]+)/);r&&(i=r[1])}else if(/firefox|fxios/.test(n)){e="Firefox";const r=n.match(/(?:firefox|fxios)\/([0-9.]+)/);r&&(i=r[1])}else if(/safari/.test(n)&&!/chrome|crios|android/.test(n)){e="Safari";const r=n.match(/version\/([0-9.]+)/);r&&(i=r[1])}else if(/edg/.test(n)){e="Edge";const r=n.match(/edg\/([0-9.]+)/);r&&(i=r[1])}return{platform:t,browser:e,version:i}},U6=async()=>{const{platform:n,browser:t,version:e}=V6();if(!navigator.gpu)return console.warn("❌ navigator.gpu is not available"),{isSupported:!1,isAvailable:!1,error:"WebGPU is not supported in this browser. Please use a compatible browser.",platform:n,browser:t,platformVersion:e,browserVersion:e};try{const i=await navigator.gpu.requestAdapter();return i?await i.requestDevice()?{isSupported:!0,isAvailable:!0,platform:n,browser:t,platformVersion:e,browserVersion:e}:(console.warn("❌ Failed to create WebGPU device"),{isSupported:!0,isAvailable:!1,error:"WebGPU adapter found but failed to create device. This might be due to hardware limitations or driver issues.",platform:n,browser:t,platformVersion:e,browserVersion:e}):(console.warn("❌ No WebGPU adapter available"),{isSupported:!0,isAvailable:!1,error:"WebGPU is supported but no adapter is available. This might be due to hardware limitations or driver issues.",platform:n,browser:t,platformVersion:e,browserVersion:e})}catch(i){return console.error("❌ WebGPU detection error:",i),{isSupported:!0,isAvailable:!1,error:`WebGPU is supported but failed to initialize: ${i instanceof Error?i.message:"Unknown error"}`,platform:n,browser:t,platformVersion:e,browserVersion:e}}},k6=()=>{const t=new URLSearchParams(window.location.search).get("unity")==="true",{isAvailable:e}=B6();return t&&e?An.jsx(L6,{}):An.jsx(d6,{})},z6=async()=>{const n=await U6();pw.createRoot(document.getElementById("root")).render(An.jsx(Ct.StrictMode,{children:An.jsx(N6,{value:n,children:An.jsx(k6,{})})}))};z6();
|
package/index.html
CHANGED
|
@@ -7,10 +7,10 @@
|
|
|
7
7
|
<meta name="theme-color" content="#000000" />
|
|
8
8
|
<meta name="description" content="Preview wearables from Decentraland" />
|
|
9
9
|
<link rel="apple-touch-icon" href="/logo192.png" />
|
|
10
|
-
<link rel="manifest" href="https://cdn.decentraland.org/@dcl/wearable-preview/1.28.2-
|
|
10
|
+
<link rel="manifest" href="https://cdn.decentraland.org/@dcl/wearable-preview/1.28.2-16170279969.commit-9d54b69/manifest.json" />
|
|
11
11
|
<title>Decentraland | Wearable Preview</title>
|
|
12
|
-
<script type="module" crossorigin src="https://cdn.decentraland.org/@dcl/wearable-preview/1.28.2-
|
|
13
|
-
<link rel="stylesheet" crossorigin href="https://cdn.decentraland.org/@dcl/wearable-preview/1.28.2-
|
|
12
|
+
<script type="module" crossorigin src="https://cdn.decentraland.org/@dcl/wearable-preview/1.28.2-16170279969.commit-9d54b69/assets/index-BA0swxZO.js"></script>
|
|
13
|
+
<link rel="stylesheet" crossorigin href="https://cdn.decentraland.org/@dcl/wearable-preview/1.28.2-16170279969.commit-9d54b69/assets/index-DrFxbJ99.css">
|
|
14
14
|
</head>
|
|
15
15
|
<body>
|
|
16
16
|
<noscript>You need to enable JavaScript to run this app.</noscript>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dcl/wearable-preview",
|
|
3
|
-
"version": "1.28.2-
|
|
3
|
+
"version": "1.28.2-16170279969.commit-9d54b69",
|
|
4
4
|
"description": "Static website for the wearable preview",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -13,6 +13,6 @@
|
|
|
13
13
|
"keywords": [],
|
|
14
14
|
"author": "",
|
|
15
15
|
"license": "Apache-2.0",
|
|
16
|
-
"homepage": "https://cdn.decentraland.org/@dcl/wearable-preview/1.28.2-
|
|
17
|
-
"commit": "
|
|
16
|
+
"homepage": "https://cdn.decentraland.org/@dcl/wearable-preview/1.28.2-16170279969.commit-9d54b69",
|
|
17
|
+
"commit": "9d54b69fd08b4d5bdf1eca31825250ea93230c19"
|
|
18
18
|
}
|
|
@@ -16105,4 +16105,4 @@ else
|
|
|
16105
16105
|
}
|
|
16106
16106
|
`,jv="#include<pbrBlockFinalColorComposition>",bO="#include<customToonShading>";if(ce.ShadersStore.pbrPixelShader.includes(jv))ce.ShadersStore.pbrPixelShader.includes(bO)||(ce.ShadersStore.pbrPixelShader=ce.ShadersStore.pbrPixelShader.replace(jv,jv+`
|
|
16107
16107
|
`+bO+`
|
|
16108
|
-
`));else throw new Error("could not patch the pbrPixelShader");ce.IncludesShadersStore.customToonShading=l6;async function Xv(n,t,e=Ae.BodyShape.MALE,i,r){const o=uu(t,e);if(lp(o))throw new Error(`The wearable="${t.id}" is a texture`);const a=bj(o),s=await bI(n,a);for(const l of s.meshes)l.name.toLowerCase().includes("collider")&&(l.isVisible=!1,n.removeMesh(l));for(const l of s.materials)if(l instanceof Pi){const u=l;u.specularIntensity=0,u.metallic&&(u.metallic=0,u.metallicF0Factor=0),u.name.toLowerCase().includes("hair")&&(r?(u.albedoColor=me.FromHexString(r).toLinearSpace(),u.specularIntensity=0,u.alpha=1):(u.alpha=0,n.removeMaterial(u))),u.name.toLowerCase().includes("skin")&&(i?(u.albedoColor=me.FromHexString(i).toLinearSpace(),u.specularIntensity=0,u.alpha=1):(u.alpha=0,n.removeMaterial(u)))}for(const l of s.animationGroups)l.stop(),l.reset(),l.dispose();return{container:s,wearable:t}}async function u6(n,t){const[e,i]=await jY(n,t);try{s6(t);let r;const o=[];if(t.type===Ae.PreviewType.AVATAR){const s=$j(t),l=Array.from(s.values());for(const c of l.filter(aI)){const h=Xv(e,c,t.bodyShape,t.skin,t.hair).catch(p=>{console.warn(p.message)});o.push(h)}const u=(await Promise.all(o)).filter(Xj);for(const c of u)c.container.addAllToScene();const f=Kj(u);if(f){const c=l.filter(Yj),{eyes:h,eyebrows:p,mouth:_}=await n6(e,c,t.bodyShape);o6(e,f,h,p,_,t)}r=await t6(e,u,t)||YA()}else{const s=t.item;if(s&&!Fo(s))try{(await Xv(e,s,t.bodyShape,t.skin,t.hair)).container.addAllToScene()}catch{(await Xv(e,s,t.bodyShape===Ae.BodyShape.MALE?Ae.BodyShape.FEMALE:Ae.BodyShape.MALE,t.skin,t.hair)).container.addAllToScene()}r=YA()}return t.centerBoundingBox&&qY(e),{scene:i,emote:r}}catch(r){throw e.clearColor=new it(0,0,0,0),r}}function f6(n){const t=()=>{Ae.sendMessage(kn(),Ae.PreviewMessageType.EMOTE_EVENT,{type:Ae.PreviewEmoteEventType.ANIMATION_PLAY,payload:void 0})},e=()=>{Ae.sendMessage(kn(),Ae.PreviewMessageType.EMOTE_EVENT,{type:Ae.PreviewEmoteEventType.ANIMATION_PAUSE,payload:void 0})},i=()=>{Ae.sendMessage(kn(),Ae.PreviewMessageType.EMOTE_EVENT,{type:Ae.PreviewEmoteEventType.ANIMATION_LOOP,payload:void 0})},r=()=>{Ae.sendMessage(kn(),Ae.PreviewMessageType.EMOTE_EVENT,{type:Ae.PreviewEmoteEventType.ANIMATION_END,payload:void 0})},o=a=>{Ae.sendMessage(kn(),Ae.PreviewMessageType.EMOTE_EVENT,{type:Ae.PreviewEmoteEventType.ANIMATION_PLAYING,payload:a})};return n.emote.events.on(Ae.PreviewEmoteEventType.ANIMATION_PLAY,t),n.emote.events.on(Ae.PreviewEmoteEventType.ANIMATION_PAUSE,e),n.emote.events.on(Ae.PreviewEmoteEventType.ANIMATION_LOOP,i),n.emote.events.on(Ae.PreviewEmoteEventType.ANIMATION_END,r),n.emote.events.on(Ae.PreviewEmoteEventType.ANIMATION_PLAYING,o),()=>{n.emote.events.off(Ae.PreviewEmoteEventType.ANIMATION_PLAY,t),n.emote.events.off(Ae.PreviewEmoteEventType.ANIMATION_PAUSE,e),n.emote.events.off(Ae.PreviewEmoteEventType.ANIMATION_LOOP,i),n.emote.events.off(Ae.PreviewEmoteEventType.ANIMATION_END,r),n.emote.events.off(Ae.PreviewEmoteEventType.ANIMATION_PLAYING,o)}}const c6=()=>{const[n,t]=Ct.useState(""),{width:e,height:i}=oM(),[r,o]=Ct.useState({}),[a,s]=Ct.useState(!1),[l,u]=Ct.useState(!0),[f,c]=Ct.useState(!1),h=Ct.useRef(null),p=oI(),[_,g,v]=Gj(),[E,T]=Ct.useState(""),[S,C]=Ct.useState(!0),[O,R]=Ct.useState(!1),M=n||v,D=(l||g)&&!M,U=!!E&&!S&&!D,V=S&&!D;return Ct.useEffect(()=>{let B=()=>{};if(h.current&&_){let G={opacity:1};_.background.image&&(T(_.background.image),G.opacity=1,!_.background.transparent&&_.type===Ae.PreviewType.TEXTURE&&(G.backgroundColor=_.background.color)),o(G),_.type===Ae.PreviewType.TEXTURE?(C(!1),u(!1),c(!0)):u6(h.current,_).then(ee=>{p.current=ee,B=f6(p.current)}).catch(ee=>t(ee.message)).finally(()=>{u(!1),c(!0)})}return()=>{B()}},[h.current,_]),Ct.useEffect(()=>{var B;O||(f?(Ae.sendMessage(kn(),Ae.PreviewMessageType.LOAD,{renderer:Ae.PreviewRenderer.BABYLON}),R(!0),((_==null?void 0:_.type)===Ae.PreviewType.AVATAR||_!=null&&_.emote&&_.emote!==Ae.PreviewEmote.IDLE)&&((B=p.current)==null||B.emote.play())):M&&(Ae.sendMessage(kn(),Ae.PreviewMessageType.ERROR,{message:M}),R(!0)))},[f,M,O,p,_==null?void 0:_.type,_==null?void 0:_.emote]),Ct.useEffect(()=>{if(g){let B=!1;l||(u(!0),B=!0),O&&(R(!1),B=!0),B&&f&&c(!1)}},[g,l,O,f]),nI(),An.jsxs("div",{className:Xl("Preview",{"is-dragging":a,"is-loading":D,"is-loaded":f,"is-3d":S&&(_==null?void 0:_.camera)===Ae.PreviewCamera.INTERACTIVE,"has-error":!!M,"no-fade-effect":_&&!_.fadeEffect}),style:r,children:[An.jsx("img",{src:E,className:Xl("thumbnail",{"is-visible":U}),alt:"preview"}),An.jsx("canvas",{id:"wearable-preview",className:Xl({"is-visible":V}),width:e,height:i,ref:h,onMouseDown:()=>s(S&&!M),onMouseUp:()=>s(!1)}),M&&An.jsx("div",{className:"error",children:M})]})},h6=SO.memo(c6);var TI=(n=>(n.SET_MODE="SetMode",n.SET_PROFILE="SetProfile",n.SET_EMOTE="SetEmote",n.SET_URNS="SetUrns",n.SET_BACKGROUND="SetBackground",n.SET_SKIN_COLOR="SetSkinColor",n.SET_HAIR_COLOR="SetHairColor",n.SET_EYE_COLOR="SetEyeColor",n.SET_BODY_SHAPE="SetBodyShape",n.SET_SHOW_ANIMATION_REFERENCE="SetShowAnimationReference",n.SET_PROJECTION="SetProjection",n.ADD_BASE64="AddBase64",n.CLEAR_BASE64="ClearBase64",n.SET_CONTRACT="SetContract",n.SET_ITEM_ID="SetItemID",n.SET_TOKEN_ID="SetTokenID",n.SET_DISABLE_LOADER="SetDisableLoader",n.RELOAD="Reload",n.CLEANUP="Cleanup",n))(TI||{});const d6={unityMode:"SetMode",profile:"SetProfile",emote:"SetEmote",urns:"SetUrns",background:"SetBackground",skin:"SetSkinColor",hair:"SetHairColor",eyes:"SetEyeColor",bodyShape:"SetBodyShape",showAnimationReference:"SetShowAnimationReference",projection:"SetProjection",base64s:"AddBase64",contractAddress:"SetContract",itemId:"SetItemID",tokenId:"SetTokenID",disableLoader:"SetDisableLoader"},p6={unityMode:n=>String(n),profile:n=>String(n),emote:n=>String(n),urns:n=>Array.isArray(n)?n.join(","):String(n),background:n=>typeof n=="string"?n.replace("#",""):String(n),skin:n=>typeof n=="string"?n.replace("#",""):String(n),hair:n=>typeof n=="string"?n.replace("#",""):String(n),eyes:n=>typeof n=="string"?n.replace("#",""):String(n),bodyShape:n=>String(n),showAnimationReference:n=>String(n),projection:n=>String(n),contractAddress:n=>String(n),itemId:n=>String(n),tokenId:n=>String(n),disableLoader:n=>String(n)},md=(n,t,e)=>{if(n)try{const i=String(t);Object.values(TI).includes(i)||console.warn(`Unknown Unity method: ${i}. Sending anyway...`),e!==void 0?n.SendMessage("JSBridge",i,e):n.SendMessage("JSBridge",i)}catch(i){console.error(`Failed to send Unity message ${t}:`,i)}else console.warn(`Unity instance not ready, cannot send message: ${t}`)},_6=(n,t,e)=>{if(!n){console.warn("Unity instance not available, cannot send override messages");return}let i=0;t.base64s!==void 0&&e.base64s&&(md(n,"ClearBase64"),i++,Array.isArray(t.base64s)&&t.base64s.length>0&&t.base64s.forEach(r=>{md(n,"AddBase64",r),i++})),Object.entries(t).forEach(([r,o])=>{if(r!=="base64s"&&e[r]&&o!==void 0){const a=d6[r];if(a){const s=p6[r],l=s?s(o):String(o);md(n,a,l),i++}else console.warn(`No Unity method mapping found for property: ${r}`)}}),i>0&&md(n,"Reload")};var m6={VITE_BASE_URL:""};const Yv=new Map,rf=(n,t)=>t;function g6(n){if(Yv.has(n))return Yv.get(n);const t=new Promise((e,i)=>{const r=document.querySelector(`script[src="${n}"]`);if(r){r.addEventListener("load",()=>e(r)),r.addEventListener("error",a=>i(a));return}const o=document.createElement("script");o.src=n,o.async=!0,o.onload=()=>e(o),o.onerror=a=>i(a),document.body.appendChild(o)});return Yv.set(n,t),t}const v6=async(n,t,e,i,r,o,a,s,l,u,f)=>{try{const c=m6.VITE_BASE_URL||"";return await g6(rf(c,t)),await createUnityInstance(n,{dataUrl:rf(c,e),frameworkUrl:rf(c,i),codeUrl:rf(c,r),streamingAssetsUrl:rf(c,o),companyName:a,productName:s,productVersion:l,matchWebGLToCanvasSize:u,arguments:f})}catch(c){throw console.error("❌ Failed to load Unity instance:",c),c}};function y6(n){return{getScreenshot:()=>new Promise(t=>{if(!n){t("");return}n.SendMessage("JSBridge","TakeScreenshot",""),window.addEventListener("message",function e(i){if(i.data.type==="unity-renderer"){const{type:r,payload:o}=i.data.payload;r==="screenshot"&&(window.removeEventListener("message",e),t(o))}})}),getMetrics:()=>new Promise(t=>{if(!n){t({triangles:0,materials:0,textures:0,meshes:0,bodies:0,entities:0});return}n.SendMessage("JSBridge","GetMetrics",""),window.addEventListener("message",function e(i){if(i.data.type==="unity-renderer"){const{type:r,payload:o}=i.data.payload;r==="metrics"&&(window.removeEventListener("message",e),t(o))}})}),changeZoom:async t=>{n&&n.SendMessage("JSBridge","SetZoom",t.toString())},panCamera:async t=>{if(!n)return;const e=t.x??0,i=t.y??0,r=t.z??0;n.SendMessage("JSBridge","SetOffset",`${e},${i},${r}`)},changeCameraPosition:async t=>{if(!n)return;const e=t.alpha??0,i=t.beta??0,r=t.radius??0;n.SendMessage("JSBridge","SetCameraPosition",`${e},${i},${r}`)},cleanup:async()=>{n&&n.SendMessage("JSBridge","Cleanup","")}}}function b6(n){const t=ib();return{getLength:async()=>new Promise(e=>{if(!n){e(0);return}n.SendMessage("JSBridge","GetEmoteLength",""),window.addEventListener("message",function i(r){if(r.data.type==="unity-renderer"){const{type:o,payload:a}=r.data.payload;o==="emoteLength"&&(window.removeEventListener("message",i),e(a))}})}),isPlaying:async()=>new Promise(e=>{if(!n){e(!1);return}n.SendMessage("JSBridge","IsEmotePlaying",""),window.addEventListener("message",function i(r){if(r.data.type==="unity-renderer"){const{type:o,payload:a}=r.data.payload;o==="isEmotePlaying"&&(window.removeEventListener("message",i),e(a))}})}),goTo:async e=>{n&&(n.SendMessage("JSBridge","GoToEmote",e.toString()),t.emit(Ae.PreviewEmoteEventType.ANIMATION_PLAYING,{length:e}))},play:async()=>{n&&(n.SendMessage("JSBridge","PlayEmote",""),t.emit(Ae.PreviewEmoteEventType.ANIMATION_PLAY))},pause:async()=>{n&&(n.SendMessage("JSBridge","PauseEmote",""),t.emit(Ae.PreviewEmoteEventType.ANIMATION_PAUSE))},stop:async()=>{n&&(n.SendMessage("JSBridge","StopEmote",""),t.emit(Ae.PreviewEmoteEventType.ANIMATION_END))},enableSound:async()=>{n&&n.SendMessage("JSBridge","EnableSound","")},disableSound:async()=>{n&&n.SendMessage("JSBridge","DisableSound","")},hasSound:async()=>new Promise(e=>{if(!n){e(!1);return}n.SendMessage("JSBridge","HasSound",""),window.addEventListener("message",function i(r){if(r.data.type==="unity-renderer"){const{type:o,payload:a}=r.data.payload;o==="hasSound"&&(window.removeEventListener("message",i),e(a))}})}),events:t}}async function E6(n){let t=null;try{if(t=await v6(n,"/unity/Build/aang-renderer.loader.js","/unity/Build/aang-renderer.data.br","/unity/Build/aang-renderer.framework.js.br","/unity/Build/aang-renderer.wasm.br","/emotes","Decentraland","AangRenderer","1.3.5",!0,[]),!t)throw new Error("Failed to load Unity instance");const e=y6(t),i=b6(t);return{scene:e,emote:i,unity:t}}catch(e){if(console.error("Unity render failed:",e),t!=null&&t.Quit)try{t.Quit()}catch(i){console.error("Error quitting Unity instance:",i)}throw e}}const T6=()=>Math.floor(Math.random()*159)+1,SI=()=>`default${T6()}`,S6=(n,t)=>{var e,i,r,o,a,s;return{eyes:Jl(t.eyes||((i=(e=n==null?void 0:n.avatar)==null?void 0:e.eyes)==null?void 0:i.color)&&eu(n.avatar.eyes.color)||"#000000"),hair:Jl(t.hair||((o=(r=n==null?void 0:n.avatar)==null?void 0:r.hair)==null?void 0:o.color)&&eu(n.avatar.hair.color)||"#000000"),skin:Jl(t.skin||((s=(a=n==null?void 0:n.avatar)==null?void 0:a.skin)==null?void 0:s.color)&&eu(n.avatar.skin.color)||"#cc9b76")}},gd=n=>n||"",EO=n=>n||[],vd=n=>n.replace("#","");function C6(n){const t=new URL(window.location.href);Object.entries(n).forEach(([e,i])=>{t.searchParams.delete(e),Array.isArray(i)?i.forEach(r=>{r!==""&&t.searchParams.append(e,r)}):i!==""&&t.searchParams.set(e,i)}),window.history.replaceState({},"",t.toString())}function P6(){const{options:n,overrideSources:t}=Mb(),[e,i]=Ct.useState(null),[r,o]=Ct.useState(!0),[a,s]=Ct.useState(null),l=Ct.useRef(null),u=Ct.useRef(n),f=Ct.useRef(!0);return Ct.useEffect(()=>{const c=JSON.stringify(n),h=JSON.stringify(u.current);if(!f.current&&c===h)return;f.current=!1,u.current=n,(async()=>{var _,g;try{o(!0),s(null);const v=n.peerUrl||Nf.get("PEER_URL"),E=n.nftServerUrl||Nf.get("NFT_SERVER_URL");let T=Ae.PreviewType.WEARABLE,S={color:n.background||"#4b4852",transparent:n.disableBackground===!0};const C=Zx(n.profile);let O=C==null?void 0:C.value;O==="default"&&(O=SI());const R=O&&C?C.type==="address"?await eI(O,v):await tI(O,v):null,M=n.bodyShape||((_=R==null?void 0:R.avatar)==null?void 0:_.bodyShape)||Ae.BodyShape.MALE;let D=null;if(n.contractAddress&&(D=await iI({contractAddress:n.contractAddress,tokenId:n.tokenId,itemId:n.itemId,peerUrl:v,nftServerUrl:E}),D&&is(D))){S={...S,image:D.thumbnail};const Z=Rb(D);lp(Z)&&(T=Ae.PreviewType.TEXTURE)}const{eyes:U,hair:V,skin:B}=S6(R,{eyes:n.eyes,hair:n.hair,skin:n.skin}),G=n.mode||null,ee=n.camera&&Object.values(Ae.PreviewCamera).includes(n.camera)?n.camera:Ae.PreviewCamera.INTERACTIVE,q=n.projection&&Object.values(Ae.PreviewProjection).includes(n.projection)?n.projection:Ae.PreviewProjection.PERSPECTIVE,re=n.disableDefaultEmotes?null:n.emote&&Object.values(Ae.PreviewEmote).includes(n.emote)?n.emote:Ae.PreviewEmote.IDLE,se={background:S,bodyShape:M,mode:G,projection:q,type:T,base64:((g=n.base64s)==null?void 0:g[0])||null,contract:n.contractAddress||null,disableLoader:n.disableLoader||!1,emote:(re==null?void 0:re.toString())||null,eyeColor:U.replace("#",""),hairColor:V.replace("#",""),item:n.itemId||null,profile:O||null,skinColor:B.replace("#",""),token:n.tokenId||null,urn:n.urns||null,showAnimationReference:null},ue=JSON.stringify(se),H=JSON.stringify(l.current);if(ue!==H){if(l.current=se,Object.keys(t).length===0){const Z=EO(n.urns),K=EO(n.base64s),F={background:S.transparent?"":vd(S.color),disableLoader:n.disableLoader?"true":"",profile:gd(O||""),bodyShape:gd(M||""),eyeColor:vd(U||""),hairColor:vd(V||""),skinColor:vd(B||""),mode:gd(G||""),camera:ee,projection:q,emote:gd((re==null?void 0:re.toString())||""),urn:Z.length>0?Z:[""],base64:K.length>0?K:[""]};C6(F)}i(se)}o(!1)}catch(v){console.error("[useUnityConfig] Failed to load config:",v),s(v instanceof Error?v.message:"Failed to load config"),o(!1)}})()},[n,t]),[e,r,a]}const A6="unity-renderer",R6="unity-canvas",TO=1,O6="Failed to load Unity",M6=(n,t,e,i)=>{const[r,o]=Ct.useState({isLoaded:!1,isInitialized:!1,error:null}),a=Ct.useCallback(l=>{if(l.data.type===A6){const{type:u,payload:f}=l.data.payload;u==="loaded"&&(f===!0||f==="true")?(o(c=>({...c,isLoaded:!0,isInitialized:!0})),Ae.sendMessage(kn(),Ae.PreviewMessageType.LOAD,{renderer:Ae.PreviewRenderer.UNITY})):u==="error"&&(o(c=>({...c,error:f})),Ae.sendMessage(kn(),Ae.PreviewMessageType.ERROR,{message:"Error loading the wearable. Please try again."}))}},[]),s=Ct.useCallback(async()=>{if(!(!n.canvas.current||n.isInitializing.current||n.unityInstance.current)){n.isInitializing.current=!0,o(l=>({...l,isLoaded:!1,error:null}));try{const{unity:l,scene:u,emote:f}=await E6(n.canvas.current);n.unityInstance.current=l,t.current={scene:u,emote:f}}catch(l){const u=l instanceof Error?l.message:O6;console.error("Unity init failed:",l),o(f=>({...f,error:u})),Ae.sendMessage(kn(),Ae.PreviewMessageType.ERROR,{message:u})}finally{n.isInitializing.current=!1}}},[n,t]);return Ct.useEffect(()=>{r.isInitialized||i||!e||s()},[e,i,r.isInitialized,s]),Ct.useEffect(()=>{if(e)return window.addEventListener("message",a,!1),()=>{window.removeEventListener("message",a,!1)}},[e,a]),r},x6=n=>{const[t,e]=Ct.useState({pixelRatio:window.devicePixelRatio||TO,is3D:!0,backgroundImage:""});return Ct.useEffect(()=>{const i=()=>{e(o=>({...o,pixelRatio:window.devicePixelRatio||TO}))},r=window.matchMedia(`(resolution: ${t.pixelRatio}dppx)`);return r.addEventListener("change",i),()=>{r.removeEventListener("change",i)}},[t.pixelRatio]),Ct.useEffect(()=>{n&&e(i=>({...i,backgroundImage:n.background.image||"",is3D:n.type!==Ae.PreviewType.TEXTURE}))},[n]),t},I6=(n,t,e,i,r)=>{const o=Ct.useMemo(()=>{const a={};for(const s of Object.keys(r))r[s]&&i[s]!==void 0&&(a[s]=i[s]);return a},[r,i]);Ct.useEffect(()=>{if(!(!e.isInitialized||!e.isLoaded||!n.current)){if(o.profile==="default"){const a=t.current.profile;o.profile=a!=null&&a.match(/^default\d+$/)?a:SI()}Object.keys(o).length>0&&(_6(n.current,o,r),t.current=o)}},[e.isInitialized,e.isLoaded,o,r,n,t])},D6=()=>{const{width:n=window.innerWidth,height:t=window.innerHeight}=oM(),e=Ct.useRef(null),i=Ct.useRef(null),r=Ct.useRef(!1),o=Ct.useRef({}),a=oI(),[s,l,u]=P6(),{options:f,overrideSources:c}=Mb(),h=Ct.useMemo(()=>({canvas:e,unityInstance:i,isInitializing:r,lastSentOverrides:o}),[]),p=M6(h,a,s,l),_=x6(s);I6(h.unityInstance,h.lastSentOverrides,p,f,c),nI();const g=Ct.useMemo(()=>{const R=p.error||u,M=!p.isLoaded&&!R,D=!!_.backgroundImage&&!_.is3D&&!M,U=_.is3D&&!M;return{error:R,isLoading:M,showImage:D,showCanvas:U}},[p.error,p.isLoaded,u,_.backgroundImage,_.is3D]),v=Ct.useMemo(()=>({opacity:1,backgroundColor:!(s!=null&&s.background.transparent)&&(s==null?void 0:s.type)===Ae.PreviewType.TEXTURE?s.background.color:void 0}),[s]),E=Ct.useMemo(()=>({width:`${n}px`,height:`${t}px`}),[n,t]),T=Ct.useMemo(()=>({width:Math.round(n*_.pixelRatio),height:Math.round(t*_.pixelRatio)}),[n,t,_.pixelRatio]),S=Ct.useMemo(()=>Xl("Preview",{"is-loading":g.isLoading,"is-loaded":p.isLoaded,"is-3d":_.is3D,"has-error":!!g.error}),[g.isLoading,p.isLoaded,_.is3D,g.error]),C=Ct.useMemo(()=>Xl("thumbnail",{"is-visible":g.showImage}),[g.showImage]),O=Ct.useMemo(()=>Xl({"is-visible":g.showCanvas}),[g.showCanvas]);return An.jsxs("div",{className:S,style:v,children:[An.jsx("img",{src:_.backgroundImage,className:C,alt:"preview"}),An.jsx("canvas",{ref:h.canvas,id:R6,className:O,width:T.width,height:T.height,style:E}),g.error&&An.jsx("div",{className:"error",children:g.error})]})},w6=SO.memo(D6),CI=Ct.createContext(null),L6=({children:n,value:t})=>{const e={webGPUSupport:t,isSupported:t.isSupported,isAvailable:t.isAvailable};return An.jsx(CI.Provider,{value:e,children:n})},N6=()=>{const n=Ct.useContext(CI);if(!n)throw new Error("useWebGPUContext must be used within a WebGPUProvider");return n},F6=()=>N6(),B6=()=>{const n=navigator.userAgent.toLowerCase();let t="Unknown",e="Unknown",i="Unknown";if(/android/.test(n)){t="Android";const r=n.match(/android\s*([0-9.]+)/);r&&(i=r[1])}else if(/iphone|ipad|ipod/.test(n)){t="iOS";const r=n.match(/os\s*([0-9_]+)/);r&&(i=r[1].replace(/_/g,"."))}else if(/macintosh|mac os x/.test(n)){t="macOS";const r=n.match(/mac os x\s*([0-9_]+)/);r&&(i=r[1].replace(/_/g,"."))}else if(/windows/.test(n)){t="Windows";const r=n.match(/windows nt\s*([0-9.]+)/);r&&(i=r[1])}else if(/linux/.test(n)){t="Linux";const r=n.match(/\(([^)]+)\)/);r&&(i=r[1])}if(/chrome|crios/.test(n)){e="Chrome";const r=n.match(/(?:chrome|crios)\/([0-9.]+)/);r&&(i=r[1])}else if(/firefox|fxios/.test(n)){e="Firefox";const r=n.match(/(?:firefox|fxios)\/([0-9.]+)/);r&&(i=r[1])}else if(/safari/.test(n)&&!/chrome|crios|android/.test(n)){e="Safari";const r=n.match(/version\/([0-9.]+)/);r&&(i=r[1])}else if(/edg/.test(n)){e="Edge";const r=n.match(/edg\/([0-9.]+)/);r&&(i=r[1])}return{platform:t,browser:e,version:i}},V6=async()=>{const{platform:n,browser:t,version:e}=B6();if(!navigator.gpu)return console.warn("❌ navigator.gpu is not available"),{isSupported:!1,isAvailable:!1,error:"WebGPU is not supported in this browser. Please use a compatible browser.",platform:n,browser:t,platformVersion:e,browserVersion:e};try{const i=await navigator.gpu.requestAdapter();return i?await i.requestDevice()?{isSupported:!0,isAvailable:!0,platform:n,browser:t,platformVersion:e,browserVersion:e}:(console.warn("❌ Failed to create WebGPU device"),{isSupported:!0,isAvailable:!1,error:"WebGPU adapter found but failed to create device. This might be due to hardware limitations or driver issues.",platform:n,browser:t,platformVersion:e,browserVersion:e}):(console.warn("❌ No WebGPU adapter available"),{isSupported:!0,isAvailable:!1,error:"WebGPU is supported but no adapter is available. This might be due to hardware limitations or driver issues.",platform:n,browser:t,platformVersion:e,browserVersion:e})}catch(i){return console.error("❌ WebGPU detection error:",i),{isSupported:!0,isAvailable:!1,error:`WebGPU is supported but failed to initialize: ${i instanceof Error?i.message:"Unknown error"}`,platform:n,browser:t,platformVersion:e,browserVersion:e}}},U6=()=>{const t=new URLSearchParams(window.location.search).get("unity")==="true",{isAvailable:e}=F6();return t&&e?An.jsx(w6,{}):An.jsx(h6,{})},k6=async()=>{const n=await V6();pw.createRoot(document.getElementById("root")).render(An.jsx(Ct.StrictMode,{children:An.jsx(L6,{value:n,children:An.jsx(U6,{})})}))};k6();
|
|
16108
|
+
`));else throw new Error("could not patch the pbrPixelShader");ce.IncludesShadersStore.customToonShading=l6;async function Xv(n,t,e=Ae.BodyShape.MALE,i,r){const o=uu(t,e);if(lp(o))throw new Error(`The wearable="${t.id}" is a texture`);const a=bj(o),s=await bI(n,a);for(const l of s.meshes)l.name.toLowerCase().includes("collider")&&(l.isVisible=!1,n.removeMesh(l));for(const l of s.materials)if(l instanceof Pi){const u=l;u.specularIntensity=0,u.metallic&&(u.metallic=0,u.metallicF0Factor=0),u.name.toLowerCase().includes("hair")&&(r?(u.albedoColor=me.FromHexString(r).toLinearSpace(),u.specularIntensity=0,u.alpha=1):(u.alpha=0,n.removeMaterial(u))),u.name.toLowerCase().includes("skin")&&(i?(u.albedoColor=me.FromHexString(i).toLinearSpace(),u.specularIntensity=0,u.alpha=1):(u.alpha=0,n.removeMaterial(u)))}for(const l of s.animationGroups)l.stop(),l.reset(),l.dispose();return{container:s,wearable:t}}async function u6(n,t){const[e,i]=await jY(n,t);try{s6(t);let r;const o=[];if(t.type===Ae.PreviewType.AVATAR){const s=$j(t),l=Array.from(s.values());for(const c of l.filter(aI)){const h=Xv(e,c,t.bodyShape,t.skin,t.hair).catch(p=>{console.warn(p.message)});o.push(h)}const u=(await Promise.all(o)).filter(Xj);for(const c of u)c.container.addAllToScene();const f=Kj(u);if(f){const c=l.filter(Yj),{eyes:h,eyebrows:p,mouth:_}=await n6(e,c,t.bodyShape);o6(e,f,h,p,_,t)}r=await t6(e,u,t)||YA()}else{const s=t.item;if(s&&!Fo(s))try{(await Xv(e,s,t.bodyShape,t.skin,t.hair)).container.addAllToScene()}catch{(await Xv(e,s,t.bodyShape===Ae.BodyShape.MALE?Ae.BodyShape.FEMALE:Ae.BodyShape.MALE,t.skin,t.hair)).container.addAllToScene()}r=YA()}return t.centerBoundingBox&&qY(e),{scene:i,emote:r}}catch(r){throw e.clearColor=new it(0,0,0,0),r}}function f6(n){const t=()=>{Ae.sendMessage(kn(),Ae.PreviewMessageType.EMOTE_EVENT,{type:Ae.PreviewEmoteEventType.ANIMATION_PLAY,payload:void 0})},e=()=>{Ae.sendMessage(kn(),Ae.PreviewMessageType.EMOTE_EVENT,{type:Ae.PreviewEmoteEventType.ANIMATION_PAUSE,payload:void 0})},i=()=>{Ae.sendMessage(kn(),Ae.PreviewMessageType.EMOTE_EVENT,{type:Ae.PreviewEmoteEventType.ANIMATION_LOOP,payload:void 0})},r=()=>{Ae.sendMessage(kn(),Ae.PreviewMessageType.EMOTE_EVENT,{type:Ae.PreviewEmoteEventType.ANIMATION_END,payload:void 0})},o=a=>{Ae.sendMessage(kn(),Ae.PreviewMessageType.EMOTE_EVENT,{type:Ae.PreviewEmoteEventType.ANIMATION_PLAYING,payload:a})};return n.emote.events.on(Ae.PreviewEmoteEventType.ANIMATION_PLAY,t),n.emote.events.on(Ae.PreviewEmoteEventType.ANIMATION_PAUSE,e),n.emote.events.on(Ae.PreviewEmoteEventType.ANIMATION_LOOP,i),n.emote.events.on(Ae.PreviewEmoteEventType.ANIMATION_END,r),n.emote.events.on(Ae.PreviewEmoteEventType.ANIMATION_PLAYING,o),()=>{n.emote.events.off(Ae.PreviewEmoteEventType.ANIMATION_PLAY,t),n.emote.events.off(Ae.PreviewEmoteEventType.ANIMATION_PAUSE,e),n.emote.events.off(Ae.PreviewEmoteEventType.ANIMATION_LOOP,i),n.emote.events.off(Ae.PreviewEmoteEventType.ANIMATION_END,r),n.emote.events.off(Ae.PreviewEmoteEventType.ANIMATION_PLAYING,o)}}const c6=()=>{const[n,t]=Ct.useState(""),{width:e,height:i}=oM(),[r,o]=Ct.useState({}),[a,s]=Ct.useState(!1),[l,u]=Ct.useState(!0),[f,c]=Ct.useState(!1),h=Ct.useRef(null),p=oI(),[_,g,v]=Gj(),[E,T]=Ct.useState(""),[S,C]=Ct.useState(!0),[O,R]=Ct.useState(!1),M=n||v,D=(l||g)&&!M,U=!!E&&!S&&!D,V=S&&!D;return Ct.useEffect(()=>{let B=()=>{};if(h.current&&_){let G={opacity:1};_.background.image&&(T(_.background.image),G.opacity=1,!_.background.transparent&&_.type===Ae.PreviewType.TEXTURE&&(G.backgroundColor=_.background.color)),o(G),_.type===Ae.PreviewType.TEXTURE?(C(!1),u(!1),c(!0)):u6(h.current,_).then(ee=>{p.current=ee,B=f6(p.current)}).catch(ee=>t(ee.message)).finally(()=>{u(!1),c(!0)})}return()=>{B()}},[h.current,_]),Ct.useEffect(()=>{var B;O||(f?(Ae.sendMessage(kn(),Ae.PreviewMessageType.LOAD,{renderer:Ae.PreviewRenderer.BABYLON}),R(!0),((_==null?void 0:_.type)===Ae.PreviewType.AVATAR||_!=null&&_.emote&&_.emote!==Ae.PreviewEmote.IDLE)&&((B=p.current)==null||B.emote.play())):M&&(Ae.sendMessage(kn(),Ae.PreviewMessageType.ERROR,{message:M}),R(!0)))},[f,M,O,p,_==null?void 0:_.type,_==null?void 0:_.emote]),Ct.useEffect(()=>{if(g){let B=!1;l||(u(!0),B=!0),O&&(R(!1),B=!0),B&&f&&c(!1)}},[g,l,O,f]),nI(),An.jsxs("div",{className:Xl("Preview",{"is-dragging":a,"is-loading":D,"is-loaded":f,"is-3d":S&&(_==null?void 0:_.camera)===Ae.PreviewCamera.INTERACTIVE,"has-error":!!M,"no-fade-effect":_&&!_.fadeEffect}),style:r,children:[An.jsx("img",{src:E,className:Xl("thumbnail",{"is-visible":U}),alt:"preview"}),An.jsx("canvas",{id:"wearable-preview",className:Xl({"is-visible":V}),width:e,height:i,ref:h,onMouseDown:()=>s(S&&!M),onMouseUp:()=>s(!1)}),M&&An.jsx("div",{className:"error",children:M})]})},h6=SO.memo(c6);var TI=(n=>(n.SET_MODE="SetMode",n.SET_PROFILE="SetProfile",n.SET_EMOTE="SetEmote",n.SET_URNS="SetUrns",n.SET_BACKGROUND="SetBackground",n.SET_SKIN_COLOR="SetSkinColor",n.SET_HAIR_COLOR="SetHairColor",n.SET_EYE_COLOR="SetEyeColor",n.SET_BODY_SHAPE="SetBodyShape",n.SET_SHOW_ANIMATION_REFERENCE="SetShowAnimationReference",n.SET_PROJECTION="SetProjection",n.ADD_BASE64="AddBase64",n.CLEAR_BASE64="ClearBase64",n.SET_CONTRACT="SetContract",n.SET_ITEM_ID="SetItemID",n.SET_TOKEN_ID="SetTokenID",n.SET_DISABLE_LOADER="SetDisableLoader",n.RELOAD="Reload",n.CLEANUP="Cleanup",n))(TI||{});const d6={unityMode:"SetMode",profile:"SetProfile",emote:"SetEmote",urns:"SetUrns",background:"SetBackground",skin:"SetSkinColor",hair:"SetHairColor",eyes:"SetEyeColor",bodyShape:"SetBodyShape",showAnimationReference:"SetShowAnimationReference",projection:"SetProjection",base64s:"AddBase64",contractAddress:"SetContract",itemId:"SetItemID",tokenId:"SetTokenID",disableLoader:"SetDisableLoader"},p6={unityMode:n=>String(n),profile:n=>String(n),emote:n=>String(n),urns:n=>Array.isArray(n)?n.join(","):String(n),background:n=>typeof n=="string"?n.replace("#",""):String(n),skin:n=>typeof n=="string"?n.replace("#",""):String(n),hair:n=>typeof n=="string"?n.replace("#",""):String(n),eyes:n=>typeof n=="string"?n.replace("#",""):String(n),bodyShape:n=>String(n),showAnimationReference:n=>String(n),projection:n=>String(n),contractAddress:n=>String(n),itemId:n=>String(n),tokenId:n=>String(n),disableLoader:n=>String(n)},md=(n,t,e)=>{if(n)try{const i=String(t);Object.values(TI).includes(i)||console.warn(`Unknown Unity method: ${i}. Sending anyway...`),e!==void 0?n.SendMessage("JSBridge",i,e):n.SendMessage("JSBridge",i)}catch(i){console.error(`Failed to send Unity message ${t}:`,i)}else console.warn(`Unity instance not ready, cannot send message: ${t}`)},_6=(n,t,e)=>{if(!n){console.warn("Unity instance not available, cannot send override messages");return}let i=0;t.base64s!==void 0&&e.base64s&&(md(n,"ClearBase64"),i++,Array.isArray(t.base64s)&&t.base64s.length>0&&t.base64s.forEach(r=>{md(n,"AddBase64",r),i++})),Object.entries(t).forEach(([r,o])=>{if(r!=="base64s"&&e[r]&&o!==void 0){const a=d6[r];if(a){const s=p6[r],l=s?s(o):String(o);md(n,a,l),i++}else console.warn(`No Unity method mapping found for property: ${r}`)}}),i>0&&md(n,"Reload")};var m6={VITE_BASE_URL:""};const Yv=new Map,rf=(n,t)=>t;function g6(n){if(Yv.has(n))return Yv.get(n);const t=new Promise((e,i)=>{const r=document.querySelector(`script[src="${n}"]`);if(r){r.addEventListener("load",()=>e(r)),r.addEventListener("error",a=>i(a));return}const o=document.createElement("script");o.src=n,o.async=!0,o.onload=()=>e(o),o.onerror=a=>i(a),document.body.appendChild(o)});return Yv.set(n,t),t}const v6=async(n,t,e,i,r,o,a,s,l,u,f)=>{try{const c=m6.VITE_BASE_URL||"";return await g6(rf(c,t)),await createUnityInstance(n,{dataUrl:rf(c,e),frameworkUrl:rf(c,i),codeUrl:rf(c,r),streamingAssetsUrl:rf(c,o),companyName:a,productName:s,productVersion:l,matchWebGLToCanvasSize:u,arguments:f})}catch(c){throw console.error("❌ Failed to load Unity instance:",c),c}};function y6(n){return{getScreenshot:()=>new Promise(t=>{if(!n){t("");return}n.SendMessage("JSBridge","TakeScreenshot",""),window.addEventListener("message",function e(i){if(i.data.type==="unity-renderer"){const{type:r,payload:o}=i.data.payload;r==="screenshot"&&(window.removeEventListener("message",e),t(o))}})}),getMetrics:()=>new Promise(t=>{if(!n){t({triangles:0,materials:0,textures:0,meshes:0,bodies:0,entities:0});return}n.SendMessage("JSBridge","GetMetrics",""),window.addEventListener("message",function e(i){if(i.data.type==="unity-renderer"){const{type:r,payload:o}=i.data.payload;r==="metrics"&&(window.removeEventListener("message",e),t(o))}})}),changeZoom:async t=>{n&&n.SendMessage("JSBridge","SetZoom",t.toString())},panCamera:async t=>{if(!n)return;const e=t.x??0,i=t.y??0,r=t.z??0;n.SendMessage("JSBridge","SetOffset",`${e},${i},${r}`)},changeCameraPosition:async t=>{if(!n)return;const e=t.alpha??0,i=t.beta??0,r=t.radius??0;n.SendMessage("JSBridge","SetCameraPosition",`${e},${i},${r}`)},cleanup:async()=>{n&&n.SendMessage("JSBridge","Cleanup","")}}}function b6(n){const t=ib();return{getLength:async()=>new Promise(e=>{if(!n){e(0);return}n.SendMessage("JSBridge","GetEmoteLength",""),window.addEventListener("message",function i(r){if(r.data.type==="unity-renderer"){const{type:o,payload:a}=r.data.payload;o==="emoteLength"&&(window.removeEventListener("message",i),e(a))}})}),isPlaying:async()=>new Promise(e=>{if(!n){e(!1);return}n.SendMessage("JSBridge","IsEmotePlaying",""),window.addEventListener("message",function i(r){if(r.data.type==="unity-renderer"){const{type:o,payload:a}=r.data.payload;o==="isEmotePlaying"&&(window.removeEventListener("message",i),e(a))}})}),goTo:async e=>{n&&(n.SendMessage("JSBridge","GoToEmote",e.toString()),t.emit(Ae.PreviewEmoteEventType.ANIMATION_PLAYING,{length:e}))},play:async()=>{n&&(n.SendMessage("JSBridge","PlayEmote",""),t.emit(Ae.PreviewEmoteEventType.ANIMATION_PLAY))},pause:async()=>{n&&(n.SendMessage("JSBridge","PauseEmote",""),t.emit(Ae.PreviewEmoteEventType.ANIMATION_PAUSE))},stop:async()=>{n&&(n.SendMessage("JSBridge","StopEmote",""),t.emit(Ae.PreviewEmoteEventType.ANIMATION_END))},enableSound:async()=>{n&&n.SendMessage("JSBridge","EnableSound","")},disableSound:async()=>{n&&n.SendMessage("JSBridge","DisableSound","")},hasSound:async()=>new Promise(e=>{if(!n){e(!1);return}n.SendMessage("JSBridge","HasSound",""),window.addEventListener("message",function i(r){if(r.data.type==="unity-renderer"){const{type:o,payload:a}=r.data.payload;o==="hasSound"&&(window.removeEventListener("message",i),e(a))}})}),events:t}}async function E6(n){let t=null;try{if(t=await v6(n,"/unity/Build/aang-renderer.loader.js","/unity/Build/aang-renderer.data.br","/unity/Build/aang-renderer.framework.js.br","/unity/Build/aang-renderer.wasm.br","/emotes","Decentraland","AangRenderer","1.3.6",!0,[]),!t)throw new Error("Failed to load Unity instance");const e=y6(t),i=b6(t);return{scene:e,emote:i,unity:t}}catch(e){if(console.error("Unity render failed:",e),t!=null&&t.Quit)try{t.Quit()}catch(i){console.error("Error quitting Unity instance:",i)}throw e}}const T6=()=>Math.floor(Math.random()*159)+1,SI=()=>`default${T6()}`,S6=(n,t)=>{var e,i,r,o,a,s;return{eyes:Jl(t.eyes||((i=(e=n==null?void 0:n.avatar)==null?void 0:e.eyes)==null?void 0:i.color)&&eu(n.avatar.eyes.color)||"#000000"),hair:Jl(t.hair||((o=(r=n==null?void 0:n.avatar)==null?void 0:r.hair)==null?void 0:o.color)&&eu(n.avatar.hair.color)||"#000000"),skin:Jl(t.skin||((s=(a=n==null?void 0:n.avatar)==null?void 0:a.skin)==null?void 0:s.color)&&eu(n.avatar.skin.color)||"#cc9b76")}},gd=n=>n||"",EO=n=>n||[],vd=n=>n.replace("#","");function C6(n){const t=new URL(window.location.href);Object.entries(n).forEach(([e,i])=>{t.searchParams.delete(e),Array.isArray(i)?i.forEach(r=>{r!==""&&t.searchParams.append(e,r)}):i!==""&&t.searchParams.set(e,i)}),window.history.replaceState({},"",t.toString())}function P6(){const{options:n,overrideSources:t}=Mb(),[e,i]=Ct.useState(null),[r,o]=Ct.useState(!0),[a,s]=Ct.useState(null),l=Ct.useRef(null),u=Ct.useRef(n),f=Ct.useRef(!0);return Ct.useEffect(()=>{const c=JSON.stringify(n),h=JSON.stringify(u.current);if(!f.current&&c===h)return;f.current=!1,u.current=n,(async()=>{var _,g;try{o(!0),s(null);const v=n.peerUrl||Nf.get("PEER_URL"),E=n.nftServerUrl||Nf.get("NFT_SERVER_URL");let T=Ae.PreviewType.WEARABLE,S={color:n.background||"#4b4852",transparent:n.disableBackground===!0};const C=Zx(n.profile);let O=C==null?void 0:C.value;O==="default"&&(O=SI());const R=O&&C?C.type==="address"?await eI(O,v):await tI(O,v):null,M=n.bodyShape||((_=R==null?void 0:R.avatar)==null?void 0:_.bodyShape)||Ae.BodyShape.MALE;let D=null;if(n.contractAddress&&(D=await iI({contractAddress:n.contractAddress,tokenId:n.tokenId,itemId:n.itemId,peerUrl:v,nftServerUrl:E}),D&&is(D))){S={...S,image:D.thumbnail};const Z=Rb(D);lp(Z)&&(T=Ae.PreviewType.TEXTURE)}const{eyes:U,hair:V,skin:B}=S6(R,{eyes:n.eyes,hair:n.hair,skin:n.skin}),G=n.mode||null,ee=n.camera&&Object.values(Ae.PreviewCamera).includes(n.camera)?n.camera:Ae.PreviewCamera.INTERACTIVE,q=n.projection&&Object.values(Ae.PreviewProjection).includes(n.projection)?n.projection:Ae.PreviewProjection.PERSPECTIVE,re=n.disableDefaultEmotes?null:n.emote&&Object.values(Ae.PreviewEmote).includes(n.emote)?n.emote:Ae.PreviewEmote.IDLE,se={background:S,bodyShape:M,mode:G,projection:q,type:T,base64:((g=n.base64s)==null?void 0:g[0])||null,contract:n.contractAddress||null,disableLoader:n.disableLoader||!1,emote:(re==null?void 0:re.toString())||null,eyeColor:U.replace("#",""),hairColor:V.replace("#",""),item:n.itemId||null,profile:O||null,skinColor:B.replace("#",""),token:n.tokenId||null,urn:n.urns||null,showAnimationReference:null},ue=JSON.stringify(se),H=JSON.stringify(l.current);if(ue!==H){if(l.current=se,Object.keys(t).length===0){const Z=EO(n.urns),K=EO(n.base64s),F={background:S.transparent?"":vd(S.color),disableLoader:n.disableLoader?"true":"",profile:gd(O||""),bodyShape:gd(M||""),eyeColor:vd(U||""),hairColor:vd(V||""),skinColor:vd(B||""),mode:gd(G||""),camera:ee,projection:q,emote:gd((re==null?void 0:re.toString())||""),urn:Z.length>0?Z:[""],base64:K.length>0?K:[""]};C6(F)}i(se)}o(!1)}catch(v){console.error("[useUnityConfig] Failed to load config:",v),s(v instanceof Error?v.message:"Failed to load config"),o(!1)}})()},[n,t]),[e,r,a]}const A6="unity-renderer",R6="unity-canvas",TO=1,O6="Failed to load Unity",M6=(n,t,e,i)=>{const[r,o]=Ct.useState({isLoaded:!1,isInitialized:!1,error:null}),a=Ct.useCallback(l=>{if(l.data.type===A6){const{type:u,payload:f}=l.data.payload;u==="loaded"&&(f===!0||f==="true")?(o(c=>({...c,isLoaded:!0,isInitialized:!0})),Ae.sendMessage(kn(),Ae.PreviewMessageType.LOAD,{renderer:Ae.PreviewRenderer.UNITY})):u==="error"&&(o(c=>({...c,error:f})),Ae.sendMessage(kn(),Ae.PreviewMessageType.ERROR,{message:"Error loading the wearable. Please try again."}))}},[]),s=Ct.useCallback(async()=>{if(!(!n.canvas.current||n.isInitializing.current||n.unityInstance.current)){n.isInitializing.current=!0,o(l=>({...l,isLoaded:!1,error:null}));try{const{unity:l,scene:u,emote:f}=await E6(n.canvas.current);n.unityInstance.current=l,t.current={scene:u,emote:f}}catch(l){const u=l instanceof Error?l.message:O6;console.error("Unity init failed:",l),o(f=>({...f,error:u})),Ae.sendMessage(kn(),Ae.PreviewMessageType.ERROR,{message:u})}finally{n.isInitializing.current=!1}}},[n,t]);return Ct.useEffect(()=>{r.isInitialized||i||!e||s()},[e,i,r.isInitialized,s]),Ct.useEffect(()=>{if(e)return window.addEventListener("message",a,!1),()=>{window.removeEventListener("message",a,!1)}},[e,a]),r},x6=n=>{const[t,e]=Ct.useState({pixelRatio:window.devicePixelRatio||TO,is3D:!0,backgroundImage:""});return Ct.useEffect(()=>{const i=()=>{e(o=>({...o,pixelRatio:window.devicePixelRatio||TO}))},r=window.matchMedia(`(resolution: ${t.pixelRatio}dppx)`);return r.addEventListener("change",i),()=>{r.removeEventListener("change",i)}},[t.pixelRatio]),Ct.useEffect(()=>{n&&e(i=>({...i,backgroundImage:n.background.image||"",is3D:n.type!==Ae.PreviewType.TEXTURE}))},[n]),t},I6=(n,t,e,i,r)=>{const o=Ct.useMemo(()=>{const a={};for(const s of Object.keys(r))r[s]&&i[s]!==void 0&&(a[s]=i[s]);return a},[r,i]);Ct.useEffect(()=>{if(!(!e.isInitialized||!e.isLoaded||!n.current)){if(o.profile==="default"){const a=t.current.profile;o.profile=a!=null&&a.match(/^default\d+$/)?a:SI()}Object.keys(o).length>0&&(_6(n.current,o,r),t.current=o)}},[e.isInitialized,e.isLoaded,o,r,n,t])},D6=()=>{const{width:n=window.innerWidth,height:t=window.innerHeight}=oM(),e=Ct.useRef(null),i=Ct.useRef(null),r=Ct.useRef(!1),o=Ct.useRef({}),a=oI(),[s,l,u]=P6(),{options:f,overrideSources:c}=Mb(),h=Ct.useMemo(()=>({canvas:e,unityInstance:i,isInitializing:r,lastSentOverrides:o}),[]),p=M6(h,a,s,l),_=x6(s);I6(h.unityInstance,h.lastSentOverrides,p,f,c),nI();const g=Ct.useMemo(()=>{const R=p.error||u,M=!p.isLoaded&&!R,D=!!_.backgroundImage&&!_.is3D&&!M,U=_.is3D&&!M;return{error:R,isLoading:M,showImage:D,showCanvas:U}},[p.error,p.isLoaded,u,_.backgroundImage,_.is3D]),v=Ct.useMemo(()=>({opacity:1,backgroundColor:!(s!=null&&s.background.transparent)&&(s==null?void 0:s.type)===Ae.PreviewType.TEXTURE?s.background.color:void 0}),[s]),E=Ct.useMemo(()=>({width:`${n}px`,height:`${t}px`}),[n,t]),T=Ct.useMemo(()=>({width:Math.round(n*_.pixelRatio),height:Math.round(t*_.pixelRatio)}),[n,t,_.pixelRatio]),S=Ct.useMemo(()=>Xl("Preview",{"is-loading":g.isLoading,"is-loaded":p.isLoaded,"is-3d":_.is3D,"has-error":!!g.error}),[g.isLoading,p.isLoaded,_.is3D,g.error]),C=Ct.useMemo(()=>Xl("thumbnail",{"is-visible":g.showImage}),[g.showImage]),O=Ct.useMemo(()=>Xl({"is-visible":g.showCanvas}),[g.showCanvas]);return An.jsxs("div",{className:S,style:v,children:[An.jsx("img",{src:_.backgroundImage,className:C,alt:"preview"}),An.jsx("canvas",{ref:h.canvas,id:R6,className:O,width:T.width,height:T.height,style:E}),g.error&&An.jsx("div",{className:"error",children:g.error})]})},w6=SO.memo(D6),CI=Ct.createContext(null),L6=({children:n,value:t})=>{const e={webGPUSupport:t,isSupported:t.isSupported,isAvailable:t.isAvailable};return An.jsx(CI.Provider,{value:e,children:n})},N6=()=>{const n=Ct.useContext(CI);if(!n)throw new Error("useWebGPUContext must be used within a WebGPUProvider");return n},F6=()=>N6(),B6=()=>{const n=navigator.userAgent.toLowerCase();let t="Unknown",e="Unknown",i="Unknown";if(/android/.test(n)){t="Android";const r=n.match(/android\s*([0-9.]+)/);r&&(i=r[1])}else if(/iphone|ipad|ipod/.test(n)){t="iOS";const r=n.match(/os\s*([0-9_]+)/);r&&(i=r[1].replace(/_/g,"."))}else if(/macintosh|mac os x/.test(n)){t="macOS";const r=n.match(/mac os x\s*([0-9_]+)/);r&&(i=r[1].replace(/_/g,"."))}else if(/windows/.test(n)){t="Windows";const r=n.match(/windows nt\s*([0-9.]+)/);r&&(i=r[1])}else if(/linux/.test(n)){t="Linux";const r=n.match(/\(([^)]+)\)/);r&&(i=r[1])}if(/chrome|crios/.test(n)){e="Chrome";const r=n.match(/(?:chrome|crios)\/([0-9.]+)/);r&&(i=r[1])}else if(/firefox|fxios/.test(n)){e="Firefox";const r=n.match(/(?:firefox|fxios)\/([0-9.]+)/);r&&(i=r[1])}else if(/safari/.test(n)&&!/chrome|crios|android/.test(n)){e="Safari";const r=n.match(/version\/([0-9.]+)/);r&&(i=r[1])}else if(/edg/.test(n)){e="Edge";const r=n.match(/edg\/([0-9.]+)/);r&&(i=r[1])}return{platform:t,browser:e,version:i}},V6=async()=>{const{platform:n,browser:t,version:e}=B6();if(!navigator.gpu)return console.warn("❌ navigator.gpu is not available"),{isSupported:!1,isAvailable:!1,error:"WebGPU is not supported in this browser. Please use a compatible browser.",platform:n,browser:t,platformVersion:e,browserVersion:e};try{const i=await navigator.gpu.requestAdapter();return i?await i.requestDevice()?{isSupported:!0,isAvailable:!0,platform:n,browser:t,platformVersion:e,browserVersion:e}:(console.warn("❌ Failed to create WebGPU device"),{isSupported:!0,isAvailable:!1,error:"WebGPU adapter found but failed to create device. This might be due to hardware limitations or driver issues.",platform:n,browser:t,platformVersion:e,browserVersion:e}):(console.warn("❌ No WebGPU adapter available"),{isSupported:!0,isAvailable:!1,error:"WebGPU is supported but no adapter is available. This might be due to hardware limitations or driver issues.",platform:n,browser:t,platformVersion:e,browserVersion:e})}catch(i){return console.error("❌ WebGPU detection error:",i),{isSupported:!0,isAvailable:!1,error:`WebGPU is supported but failed to initialize: ${i instanceof Error?i.message:"Unknown error"}`,platform:n,browser:t,platformVersion:e,browserVersion:e}}},U6=()=>{const t=new URLSearchParams(window.location.search).get("unity")==="true",{isAvailable:e}=F6();return t&&e?An.jsx(w6,{}):An.jsx(h6,{})},k6=async()=>{const n=await V6();pw.createRoot(document.getElementById("root")).render(An.jsx(Ct.StrictMode,{children:An.jsx(L6,{value:n,children:An.jsx(U6,{})})}))};k6();
|
package/static-local/index.html
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
<link rel="apple-touch-icon" href="/logo192.png" />
|
|
10
10
|
<link rel="manifest" href="./manifest.json" />
|
|
11
11
|
<title>Decentraland | Wearable Preview</title>
|
|
12
|
-
<script type="module" crossorigin src="./assets/index-
|
|
12
|
+
<script type="module" crossorigin src="./assets/index-CiNxdWy7.js"></script>
|
|
13
13
|
<link rel="stylesheet" crossorigin href="./assets/index-DrFxbJ99.css">
|
|
14
14
|
</head>
|
|
15
15
|
<body>
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function createUnityInstance(t,n,d){function c(e,t){if(!c.aborted&&n.showBanner)return"error"==t&&(c.aborted=!0),n.showBanner(e,t);switch(t){case"error":console.error(e);break;case"warning":console.warn(e);break;default:console.log(e)}}function r(e){var t=e.reason||e.error,n=t?t.toString():e.message||e.reason||"",r=t&&t.stack?t.stack.toString():"";(n+="\n"+(r=r.startsWith(n)?r.substring(n.length):r).trim())&&m.stackTraceRegExp&&m.stackTraceRegExp.test(n)&&P(n,e.filename||t&&(t.fileName||t.sourceURL)||"",e.lineno||t&&(t.lineNumber||t.line)||0)}function e(e,t,n){var r=e[t];void 0!==r&&r||(console.warn('Config option "'+t+'" is missing or empty. Falling back to default value: "'+n+'". Consider updating your WebGL template to include the missing config option.'),e[t]=n)}d=d||function(){};var o,m={canvas:t,webglContextAttributes:{preserveDrawingBuffer:!1,powerPreference:2},wasmFileSize:44136431,cacheControl:function(e){return e==m.dataUrl||e.match(/\.bundle/)?"must-revalidate":"no-store"},streamingAssetsUrl:"StreamingAssets",downloadProgress:{},deinitializers:[],intervals:{},setInterval:function(e,t){e=window.setInterval(e,t);return this.intervals[e]=!0,e},clearInterval:function(e){delete this.intervals[e],window.clearInterval(e)},preRun:[],postRun:[],print:function(e){console.log(e)},printErr:function(e){console.error(e),"string"==typeof e&&-1!=e.indexOf("wasm streaming compile failed")&&(-1!=e.toLowerCase().indexOf("mime")?c('HTTP Response Header "Content-Type" configured incorrectly on the server for file '+m.codeUrl+' , should be "application/wasm". Startup time performance will suffer.',"warning"):c('WebAssembly streaming compilation failed! This can happen for example if "Content-Encoding" HTTP header is incorrectly enabled on the server for file '+m.codeUrl+", but the file is not pre-compressed on disk (or vice versa). Check the Network tab in browser Devtools to debug server header configuration.","warning"))},locateFile:function(e){return"build.wasm"==e?this.codeUrl:e},disabledCanvasEvents:["contextmenu","dragstart"]};for(o in e(n,"companyName","Unity"),e(n,"productName","WebGL Player"),e(n,"productVersion","1.0"),n)m[o]=n[o];m.streamingAssetsUrl=new URL(m.streamingAssetsUrl,document.URL).href;var a=m.disabledCanvasEvents.slice();function i(e){e.preventDefault()}a.forEach(function(e){t.addEventListener(e,i)}),window.addEventListener("error",r),window.addEventListener("unhandledrejection",r);var s="",l="";function u(e){document.webkitCurrentFullScreenElement===t?t.style.width&&(s=t.style.width,l=t.style.height,t.style.width="100%",t.style.height="100%"):s&&(t.style.width=s,t.style.height=l,l=s="")}document.addEventListener("webkitfullscreenchange",u),m.deinitializers.push(function(){for(var e in m.disableAccessToMediaDevices(),a.forEach(function(e){t.removeEventListener(e,i)}),window.removeEventListener("error",r),window.removeEventListener("unhandledrejection",r),document.removeEventListener("webkitfullscreenchange",u),m.intervals)window.clearInterval(e);m.intervals={}}),m.QuitCleanup=function(){for(var e=0;e<m.deinitializers.length;e++)m.deinitializers[e]();m.deinitializers=[],"function"==typeof m.onQuit&&m.onQuit()};var h,f,p,g,b,w,y,v,S,C={Module:m,SetFullscreen:function(){if(m.SetFullscreen)return m.SetFullscreen.apply(m,arguments);m.print("Failed to set Fullscreen mode: Player not loaded yet.")},SendMessage:function(){if(m.SendMessage)return m.SendMessage.apply(m,arguments);m.print("Failed to execute SendMessage: Player not loaded yet.")},Quit:function(){return new Promise(function(e,t){m.shouldQuit=!0,m.onQuit=e})},GetMetricsInfo:function(){var e=Number(m._getMetricsInfo())>>>0,t=4+e,n=4+t,r=8+n,o=8+r,a=4+o,i=4+a,s=8+i,d=8+s,c=4+d,l=4+c,u=4+l;return{totalWASMHeapSize:m.HEAPU32[e>>2],usedWASMHeapSize:m.HEAPU32[t>>2],totalJSHeapSize:m.HEAPF64[n>>3],usedJSHeapSize:m.HEAPF64[r>>3],pageLoadTime:m.HEAPU32[o>>2],pageLoadTimeToFrame1:m.HEAPU32[a>>2],fps:m.HEAPF64[i>>3],movingAverageFps:m.HEAPF64[s>>3],assetLoadTime:m.HEAPU32[d>>2],webAssemblyStartupTime:m.HEAPU32[c>>2]-(m.webAssemblyTimeStart||0),codeDownloadTime:m.HEAPU32[l>>2],gameStartupTime:m.HEAPU32[u>>2],numJankedFrames:m.HEAPU32[4+u>>2]}}};function P(e,t,n){-1==e.indexOf("fullscreen error")&&(m.startupErrorHandler?m.startupErrorHandler(e,t,n):m.errorHandler&&m.errorHandler(e,t,n)||(console.log("Invoking error handler due to\n"+e),"function"==typeof dump&&dump("Invoking error handler due to\n"+e),P.didShowErrorMessage||(-1!=(e="An error occurred running the Unity content on this page. See your browser JavaScript console for more info. The error was:\n"+e).indexOf("DISABLE_EXCEPTION_CATCHING")?e="An exception has occurred, but exception handling has been disabled in this build. If you are the developer of this content, enable exceptions in your project WebGL player settings to be able to catch the exception or see the stack trace.":-1!=e.indexOf("Cannot enlarge memory arrays")?e="Out of memory. If you are the developer of this content, try allocating more memory to your WebGL build in the WebGL player settings.":-1==e.indexOf("Invalid array buffer length")&&-1==e.indexOf("Invalid typed array length")&&-1==e.indexOf("out of memory")&&-1==e.indexOf("could not allocate memory")||(e="The browser could not allocate enough memory for the WebGL content. If you are the developer of this content, try allocating less memory to your WebGL build in the WebGL player settings."),alert(e),P.didShowErrorMessage=!0)))}function T(e,t){if("symbolsUrl"!=e){var n=m.downloadProgress[e],r=(n=n||(m.downloadProgress[e]={started:!1,finished:!1,lengthComputable:!1,total:0,loaded:0}),"object"!=typeof t||"progress"!=t.type&&"load"!=t.type||(n.started||(n.started=!0,n.lengthComputable=t.lengthComputable),n.total=t.total,n.loaded=t.loaded,"load"==t.type&&(n.finished=!0)),0),o=0,a=0,i=0,s=0;for(e in m.downloadProgress){if(!(n=m.downloadProgress[e]).started)return;a++,n.lengthComputable?(r+=n.loaded,o+=n.total,i++):n.finished||s++}d(.9*(a?(a-s-(o?i*(o-r)/o:0))/a:0))}}function E(){var e=this;this.isConnected=this.connect().then(function(){return e.cleanUpCache()}),this.isConnected.catch(function(e){e="Error when initializing cache: "+e,console.log("[UnityCache] "+e)})}function U(e){console.log("[UnityCache] "+e)}function k(e){return k.link=k.link||document.createElement("a"),k.link.href=e,k.link.href}m.SystemInfo=function(){var e,t,n,r,o,a=navigator.userAgent+" ",i=[["Firefox","Firefox"],["OPR","Opera"],["Edg","Edge"],["SamsungBrowser","Samsung Browser"],["Trident","Internet Explorer"],["MSIE","Internet Explorer"],["Chrome","Chrome"],["CriOS","Chrome on iOS Safari"],["FxiOS","Firefox on iOS Safari"],["Safari","Safari"]];function s(e,t,n){return(e=RegExp(e,"i").exec(t))&&e[n]}for(var d=0;d<i.length;++d)if(t=s(i[d][0]+"[/ ](.*?)[ \\)]",a,1)){e=i[d][1];break}"Safari"==e&&(t=s("Version/(.*?) ",a,1)),"Internet Explorer"==e&&(t=s("rv:(.*?)\\)? ",a,1)||t);for(var c=[["Windows (.*?)[;)]","Windows"],["Android ([0-9_.]+)","Android"],["iPhone OS ([0-9_.]+)","iPhoneOS"],["iPad.*? OS ([0-9_.]+)","iPadOS"],["FreeBSD( )","FreeBSD"],["OpenBSD( )","OpenBSD"],["Linux|X11()","Linux"],["Mac OS X ([0-9_\\.]+)","MacOS"],["bot|google|baidu|bing|msn|teoma|slurp|yandex","Search Bot"]],l=0;l<c.length;++l)if(r=s(c[l][0],a,1)){n=c[l][1],r=r.replace(/_/g,".");break}var u;function h(){try{return window.WebAssembly?WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,3,1,0,1,10,13,1,11,0,65,0,65,0,65,1,252,11,0,11]))?WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,11,1,9,1,1,125,32,0,252,0,26,11]))?WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,10,1,8,1,1,126,32,0,194,26,11]))?WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,9,1,7,0,65,0,253,15,26,11]))?!!WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,10,1,8,0,6,64,1,25,1,11,11]))||"wasm-exceptions":"wasm-simd128":"sign-extend":"non-trapping fp-to-int":"bulk-memory":"WebAssembly"}catch(e){return"Exception: "+e}}r={"NT 5.0":"2000","NT 5.1":"XP","NT 5.2":"Server 2003","NT 6.0":"Vista","NT 6.1":"7","NT 6.2":"8","NT 6.3":"8.1","NT 10.0":"10"}[r]||r,webgpuVersion=0,(f=document.createElement("canvas"))&&(u=(p=f.getContext("webgl2"))?2:0,p||(p=f&&f.getContext("webgl"))&&(u=1),p&&(o=p.getExtension("WEBGL_debug_renderer_info")&&p.getParameter(37446)||p.getParameter(7937)),webgpuVersion=navigator.gpu?1:0);var f="undefined"!=typeof SharedArrayBuffer,p="object"==typeof WebAssembly&&"function"==typeof WebAssembly.compile,m=p&&!0===h();return{width:screen.width,height:screen.height,userAgent:a.trim(),browser:e||"Unknown browser",browserVersion:t||"Unknown version",mobile:/Mobile|Android|iP(ad|hone)/.test(navigator.appVersion),os:n||"Unknown OS",osVersion:r||"Unknown OS Version",gpu:o||"Unknown GPU",language:navigator.userLanguage||navigator.language,hasWebGL:u,hasWebGPU:webgpuVersion,hasCursorLock:!!document.body.requestPointerLock,hasFullscreen:!!document.body.requestFullscreen||!!document.body.webkitRequestFullscreen,hasThreads:f,hasWasm:p,hasWasm2023:m,missingWasm2023Feature:m?null:h(),hasWasmThreads:!1}}(),m.abortHandler=function(e){return P(e,"",0),!0},Error.stackTraceLimit=Math.max(Error.stackTraceLimit||0,50),m.readBodyWithProgress=function(a,i,s){var e=a.body?a.body.getReader():void 0,d=void 0!==a.headers.get("Content-Length"),c=function(e,t){if(!t)return 0;var t=e.headers.get("Content-Encoding"),n=parseInt(e.headers.get("Content-Length")),r=536870912;switch(t){case"br":return Math.min(Math.round(2*n),r);case"gzip":return Math.min(Math.round(1.6*n),r);default:return n}}(a,d),l=new Uint8Array(c),u=[],h=0,f=0;return d||console.warn("[UnityCache] Response is served without Content-Length header. Please reconfigure server to include valid Content-Length for better download performance."),function o(){return void 0===e?a.arrayBuffer().then(function(e){var t=new Uint8Array(e);return i({type:"progress",response:a,total:e.length,loaded:0,lengthComputable:d,chunk:s?t:null}),t}):e.read().then(function(e){if(e.done){if(h===c)return l;if(h<c)return l.slice(0,h);for(var t=new Uint8Array(h),n=(t.set(l,0),f),r=0;r<u.length;++r)t.set(u[r],n),n+=u[r].length;return t}return h+e.value.length<=l.length?(l.set(e.value,h),f=h+e.value.length):u.push(e.value),h+=e.value.length,i({type:"progress",response:a,total:Math.max(c,h),loaded:h,lengthComputable:d,chunk:s?e.value:null}),o()})}().then(function(e){return i({type:"load",response:a,total:e.length,loaded:e.length,lengthComputable:d,chunk:null}),a.parsedBody=e,a})},m.fetchWithProgress=function(e,t){var n=function(){};return t&&t.onProgress&&(n=t.onProgress),fetch(e,t).then(function(e){return m.readBodyWithProgress(e,n,t.enableStreamingDownload)})},m.UnityCache=(h={name:"UnityCache",version:4},f={name:"RequestMetaDataStore",version:1},p="RequestStore",g="WebAssembly",b=window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB,w=null,E.getInstance=function(){return w=w||new E},E.destroyInstance=function(){return w?w.close().then(function(){w=null}):Promise.resolve()},E.prototype.clearCache=function(){var r=this;return this.isConnected.then(function(){return r.execute(f.name,"clear",[])}).then(function(){return r.cache.keys()}).then(function e(t){var n;return 0===t.length?Promise.resolve():(n=t.pop(),r.cache.delete(n).then(function(){return e(t)}))})},E.UnityCacheDatabase=h,E.RequestMetaDataStore=f,E.MaximumCacheSize=1073741824,E.prototype.loadRequest=function(e){var t=this;return t.isConnected.then(function(){return Promise.all([t.cache.match(e),t.loadRequestMetaData(e)])}).then(function(e){if(void 0!==e[0]&&void 0!==e[1])return{response:e[0],metaData:e[1]}})},E.prototype.loadRequestMetaData=function(e){e="string"==typeof e?e:e.url;return this.execute(f.name,"get",[e])},E.prototype.updateRequestMetaData=function(e){return this.execute(f.name,"put",[e])},E.prototype.storeRequest=function(e,t){var n=this;return n.isConnected.then(function(){return n.cache.put(e,t)})},E.prototype.close=function(){return this.isConnected.then(function(){this.database&&(this.database.close(),this.database=null),this.cache&&(this.cache=null)}.bind(this))},E.prototype.connect=function(){var o=this;return void 0===b?Promise.reject(new Error("Could not connect to cache: IndexedDB is not supported.")):void 0===window.caches?Promise.reject(new Error("Could not connect to cache: Cache API is not supported.")):new Promise(function(t,n){try{function r(){o.openDBTimeout&&(clearTimeout(o.openDBTimeout),o.openDBTimeout=null)}o.openDBTimeout=setTimeout(function(){void 0===o.database&&n(new Error("Could not connect to cache: Database timeout."))},2e4);var e=b.open(h.name,h.version);e.onupgradeneeded=o.upgradeDatabase.bind(o),e.onsuccess=function(e){r(),o.database=e.target.result,t()},e.onerror=function(e){r(),o.database=null,n(new Error("Could not connect to database."))}}catch(e){r(),o.database=null,o.cache=null,n(new Error("Could not connect to cache: Could not connect to database."))}}).then(function(){var e=h.name+"_"+m.companyName+"_"+m.productName;return caches.open(e)}).then(function(e){o.cache=e})},E.prototype.upgradeDatabase=function(e){var t,e=e.target.result;e.objectStoreNames.contains(f.name)||(t=e.createObjectStore(f.name,{keyPath:"url"}),["accessedAt","updatedAt"].forEach(function(e){t.createIndex(e,e)})),e.objectStoreNames.contains(p)&&e.deleteObjectStore(p),e.objectStoreNames.contains(g)&&e.deleteObjectStore(g)},E.prototype.execute=function(a,i,s){return this.isConnected.then(function(){return new Promise(function(t,n){try{var e,r,o;null===this.database?n(new Error("indexedDB access denied")):(e=-1!=["put","delete","clear"].indexOf(i)?"readwrite":"readonly",r=this.database.transaction([a],e).objectStore(a),"openKeyCursor"==i&&(r=r.index(s[0]),s=s.slice(1)),(o=r[i].apply(r,s)).onsuccess=function(e){t(e.target.result)},o.onerror=function(e){n(e)})}catch(e){n(e)}}.bind(this))}.bind(this))},E.prototype.getMetaDataEntries=function(){var r=this,o=0,a=[];return new Promise(function(t,n){var e=r.database.transaction([f.name],"readonly").objectStore(f.name).openCursor();e.onsuccess=function(e){e=e.target.result;e?(o+=e.value.size,a.push(e.value),e.continue()):t({metaDataEntries:a,cacheSize:o})},e.onerror=function(e){n(e)}})},E.prototype.cleanUpCache=function(){var i=this;return this.getMetaDataEntries().then(function(e){for(var t=e.metaDataEntries,n=e.cacheSize,r=[],o=[],a=0;a<t.length;++a)t[a].version==m.productVersion?o.push(t[a]):(r.push(t[a]),n-=t[a].size);o.sort(function(e,t){return e.accessedAt-t.accessedAt});for(a=0;a<o.length&&!(n<E.MaximumCacheSize);++a)r.push(o[a]),n-=o[a].size;return function e(){var t;return 0===r.length?Promise.resolve():(t=r.pop(),i.cache.delete(t.url).then(function(e){if(e)return r=t.url,new Promise(function(e,t){var n=i.database.transaction([f.name],"readwrite");n.objectStore(f.name).delete(r),n.oncomplete=e,n.onerror=t});var r}).then(e))}()})},E),m.cachedFetch=(y=m.UnityCache,v=m.fetchWithProgress,S=m.readBodyWithProgress,function(o,a){var e,t,i=y.getInstance(),s=k("string"==typeof o?o:o.url),d={enabled:(e=s,(!(t=a)||!t.method||"GET"===t.method)&&((!t||-1!=["must-revalidate","immutable"].indexOf(t.control))&&!!e.match("^https?://")))};function c(n,r){return fetch(n,r).then(function(e){var t;return!d.enabled||d.revalidated?e:304===e.status?(d.revalidated=!0,i.updateRequestMetaData(d.metaData).then(function(){U("'"+d.metaData.url+"' successfully revalidated and served from the browser cache")}).catch(function(e){U("'"+d.metaData.url+"' successfully revalidated but not stored in the browser cache due to the error: "+e)}),S(d.response,r.onProgress,r.enableStreamingDownload)):200==e.status?(d.response=e,d.metaData.updatedAt=d.metaData.accessedAt,d.revalidated=!0,t=e.clone(),S(e,r.onProgress,r.enableStreamingDownload).then(function(e){return d.metaData.size=e.parsedBody.length,Promise.all([i.storeRequest(n,t),i.updateRequestMetaData(d.metaData)]).then(function(){U("'"+s+"' successfully downloaded and stored in the browser cache")}).catch(function(e){U("'"+s+"' successfully downloaded but not stored in the browser cache due to the error: "+e)}),e})):(U("'"+s+"' request failed with status: "+e.status+" "+e.statusText),S(e,r.onProgress,r.enableStreamingDownload))})}return a&&(d.control=a.control,d.companyName=a.companyName,d.productName=a.productName,d.productVersion=a.productVersion),d.revalidated=!1,d.metaData={url:s,accessedAt:Date.now(),version:d.productVersion},d.response=null,d.enabled?i.loadRequest(s).then(function(e){var n,r,t;return e?(n=e.response,r=e.metaData,d.response=n,d.metaData.size=r.size,d.metaData.updatedAt=r.updatedAt,"immutable"==d.control?(d.revalidated=!0,i.updateRequestMetaData(r).then(function(){U("'"+d.metaData.url+"' served from the browser cache without revalidation")}),S(n,a.onProgress,a.enableStreamingDownload)):(e=s,(t=window.location.href.match(/^[a-z]+:\/\/[^\/]+/))&&!e.lastIndexOf(t[0],0)||!n.headers.get("Last-Modified")&&!n.headers.get("ETag")?(e=(a=a||{}).headers||{},a.headers=e,n.headers.get("Last-Modified")?(e["If-Modified-Since"]=n.headers.get("Last-Modified"),e["Cache-Control"]="no-cache"):n.headers.get("ETag")&&(e["If-None-Match"]=n.headers.get("ETag"),e["Cache-Control"]="no-cache"),c(o,a)):fetch(s,{method:"HEAD"}).then(function(t){return d.revalidated=["Last-Modified","ETag"].every(function(e){return!n.headers.get(e)||n.headers.get(e)==t.headers.get(e)}),d.revalidated?(i.updateRequestMetaData(r).then(function(){U("'"+d.metaData.url+"' successfully revalidated and served from the browser cache")}),S(d.response,a.onProgress,a.enableStreamingDownload)):c(o,a)}))):c(o,a)}).catch(function(e){return U("Failed to load '"+d.metaData.url+"' from browser cache due to the error: "+e),v(o,a)}):v(o,a)});var A={gzip:{hasUnityMarker:function(e){var t=10,n="UnityWeb Compressed Content (gzip)";if(t>e.length||31!=e[0]||139!=e[1])return!1;var r=e[3];if(4&r){if(t+2>e.length)return!1;if((t+=2+e[t]+(e[t+1]<<8))>e.length)return!1}if(8&r){for(;t<e.length&&e[t];)t++;if(t+1>e.length)return!1;t++}return 16&r&&String.fromCharCode.apply(null,e.subarray(t,t+n.length+1))==n+"\0"}},br:{hasUnityMarker:function(e){var t="UnityWeb Compressed Content (brotli)";if(!e.length)return!1;var n=1&e[0]?14&e[0]?4:7:1,r=e[0]&(1<<n)-1,o=1+(Math.log(t.length-1)/Math.log(2)>>3);if(commentOffset=1+n+2+1+2+(o<<3)+7>>3,17==r||commentOffset>e.length)return!1;for(var a=r+(6+(o<<4)+(t.length-1<<6)<<n),i=0;i<commentOffset;i++,a>>>=8)if(e[i]!=(255&a))return!1;return String.fromCharCode.apply(null,e.subarray(commentOffset,commentOffset+t.length))==t}}};function D(){var t,e,n,s,r,o=performance.now(),p=(new Promise(function(a,e){var i=document.createElement("script");i.src=m.frameworkUrl,i.onload=function(){if("undefined"==typeof unityFramework||!unityFramework){var e,t=[["br","br"],["gz","gzip"]];for(e in t){var n,r=t[e];if(m.frameworkUrl.endsWith("."+r[0]))return n="Unable to parse "+m.frameworkUrl+"!","file:"==location.protocol?void c(n+" Loading pre-compressed (brotli or gzip) content via a file:// URL without a web server is not supported by this browser. Please use a local development web server to host compressed Unity content, or use the Unity Build and Run option.","error"):(n+=' This can happen if build compression was enabled but web server hosting the content was misconfigured to not serve the file with HTTP Response Header "Content-Encoding: '+r[1]+'" present. Check browser Console and Devtools Network tab to debug.',"br"==r[0]&&"http:"==location.protocol&&(r=-1!=["localhost","127.0.0.1"].indexOf(location.hostname)?"":"Migrate your server to use HTTPS.",n=/Firefox/.test(navigator.userAgent)?"Unable to parse "+m.frameworkUrl+'!<br>If using custom web server, verify that web server is sending .br files with HTTP Response Header "Content-Encoding: br". Brotli compression may not be supported in Firefox over HTTP connections. '+r+' See <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1670675">https://bugzilla.mozilla.org/show_bug.cgi?id=1670675</a> for more information.':"Unable to parse "+m.frameworkUrl+'!<br>If using custom web server, verify that web server is sending .br files with HTTP Response Header "Content-Encoding: br". Brotli compression may not be supported over HTTP connections. Migrate your server to use HTTPS.'),void c(n,"error"))}c("Unable to parse "+m.frameworkUrl+"! The file is corrupt, or compression was misconfigured? (check Content-Encoding HTTP Response Header on web server)","error")}var o=unityFramework;unityFramework=null,i.onload=null,a(o)},i.onerror=function(e){c("Unable to load file "+m.frameworkUrl+"! Check that the file exists on the remote server. (also check browser Console and Devtools Network tab to debug)","error")},document.body.appendChild(i),m.deinitializers.push(function(){document.body.removeChild(i)})}).then(function(e){m.webAssemblyTimeStart=performance.now(),e(m),m.codeDownloadTimeEnd=performance.now()-o}),performance.now()),a=(T(t="dataUrl"),e=m.cacheControl(m[t]),n=m.companyName&&m.productName?m.cachedFetch:m.fetchWithProgress,s=m[t],r=/file:\/\//.exec(s)?"same-origin":void 0,n(m[t],{method:"GET",companyName:m.companyName,productName:m.productName,productVersion:m.productVersion,control:e,mode:r,onProgress:function(e){T(t,e)}}).then(function(e){var t,n,r,o,a,i;return A.gzip.hasUnityMarker(e.parsedBody)&&(t=["gzip","gzip"]),(t=A.br.hasUnityMarker(e.parsedBody)?["brotli","br"]:t)&&(n=e.headers.get("Content-Type"),r=e.headers.get("Content-Encoding"),a=0<(o=e.headers.get("Content-Length"))&&e.parsedBody.length!=o,i=0<o&&e.parsedBody.length==o,r!=t[1]?c("Failed to parse binary data file "+s+' (with "Content-Type: '+n+'"), because it is still '+t[0]+'-compressed. It should have been uncompressed by the browser, but it was unable to do so since the web server provided the compressed content without specifying the HTTP Response Header "Content-Encoding: '+t[1]+'" that would have informed the browser that decompression is needed. Please verify your web server hosting configuration to add the missing "Content-Encoding: '+t[1]+'" HTTP Response Header.',"error"):c(a?"Web server configuration error: it looks like the web server has been misconfigured to double-compress the data file "+s+"! That is, it looks like the web browser has decompressed the file, but it is still in compressed form, suggesting that an already compressed file was compressed a second time. (Content-Length: "+o+", obtained length: "+e.parsedBody.length+")":i?/^((?!chrome|android).)*safari/i.test(navigator.userAgent)&&"gzip"==r&&"application/octet-stream"==n?"Unable to load content due to Apple Safari bug https://bugs.webkit.org/show_bug.cgi?id=247421 . To work around this issue, please reconfigure your web server to serve "+s+" with Content-Type: application/gzip instead of Content-Type: application/octet-stream":"Malformed binary data? Received compressed data file "+s+', with "Content-Type: '+n+'", "Content-Encoding: '+t[1]+'", "Content-Length: '+o+'", which the web browser should have decompressed, but it seemingly did not (received file size is the same as compressed file size was). Double check that the integrity of the file is intact.':"Malformed binary data URL "+s+'. No "Content-Length" HTTP Response header present. Check browser console for more information.',"error"),console.error("Malformed data? Downloaded binary data file "+s+" (ArrayBuffer size: "+e.parsedBody.length+") and browser should have decompressed it, but it might have not. Dumping raw HTTP Response Headers if it might help debug:"),e.headers.forEach(function(e,t){console.error(t+": "+e)})),e.parsedBody}).catch(function(e){var t="Failed to download file "+s;"file:"==location.protocol?c(t+". Loading web pages via a file:// URL without a web server is not supported by this browser. Please use a local development web server to host Unity content, or use the Unity Build and Run option.","error"):console.error(t)}));m.preRun.push(function(){m.addRunDependency("dataUrl"),a.then(function(t){var e=new TextDecoder("utf-8"),n=0;function r(){var e=(t[n]|t[n+1]<<8|t[n+2]<<16|t[n+3]<<24)>>>0;return n+=4,e}function o(e){if(A.gzip.hasUnityMarker(t))throw e+'. Failed to parse binary data file, because it is still gzip-compressed and should have been uncompressed by the browser. Web server has likely provided gzip-compressed data without specifying the HTTP Response Header "Content-Encoding: gzip" with it to instruct the browser to decompress it. Please verify your web server hosting configuration.';if(A.br.hasUnityMarker(t))throw e+'. Failed to parse binary data file, because it is still brotli-compressed and should have been uncompressed by the browser. Web server has likely provided brotli-compressed data without specifying the HTTP Response Header "Content-Encoding: br" with it to instruct the browser to decompress it. Please verify your web server hosting configuration.';throw e}var a="UnityWebData1.0\0",i=e.decode(t.subarray(0,a.length)),s=(i!=a&&o('Unknown data format (id="'+i+'")'),n+=a.length,r());for(n+s>t.length&&o("Invalid binary data file header! (pos="+n+", headerSize="+s+", file length="+t.length+")");n<s;){var d=r(),c=r(),l=(d+c>t.length&&o("Invalid binary data file size! (offset="+d+", size="+c+", file length="+t.length+")"),r()),u=(n+l>t.length&&o("Invalid binary data file path name! (pos="+n+", length="+l+", file length="+t.length+")"),e.decode(t.subarray(n,n+l)));n+=l;for(var h=0,f=u.indexOf("/",h)+1;0<f;h=f,f=u.indexOf("/",h)+1)m.FS_createPath(u.substring(0,h),u.substring(h,f-1),!0,!0);m.FS_createDataFile(u,null,t.subarray(d,d+c),!0,!0,!0)}m.removeRunDependency("dataUrl"),m.dataUrlLoadEndTime=performance.now()-p})})}return new Promise(function(e,t){var n;m.SystemInfo.hasWebGL?1==m.SystemInfo.hasWebGL?(n='Your browser does not support graphics API "WebGL 2" which is required for this content.',"Safari"==m.SystemInfo.browser&&parseInt(m.SystemInfo.browserVersion)<15&&(m.SystemInfo.mobile||1<navigator.maxTouchPoints?n+="\nUpgrade to iOS 15 or later.":n+="\nUpgrade to Safari 15 or later."),t(n)):m.SystemInfo.hasWasm?m.SystemInfo.hasWasm2023?(m.startupErrorHandler=t,d(0),m.postRun.push(function(){d(1),m.WebPlayer.WaitForInitialization().then(function(){delete m.startupErrorHandler,e(C),m.pageStartupTime=performance.now()})}),new Promise(function(t,e){navigator.gpu?navigator.gpu.requestAdapter().then(function(e){m.SystemInfo.hasWebGPU=!!e,t(m.SystemInfo.hasWebGPU)}):t(!1)}).then(function(){D()})):t("Your browser does not support WebAssembly 2023. Please update to Chrome \u2265 91 (May 2021), Firefox \u2265 89 (June 2021) or Safari \u2265 16.4 (March 2023). (failed "+m.SystemInfo.missingWasm2023Feature+")"):t("Your browser does not support WebAssembly."):t("Your browser does not support WebGL.")})}
|
|
1
|
+
function createUnityInstance(t,n,d){function c(e,t){if(!c.aborted&&n.showBanner)return"error"==t&&(c.aborted=!0),n.showBanner(e,t);switch(t){case"error":console.error(e);break;case"warning":console.warn(e);break;default:console.log(e)}}function r(e){var t=e.reason||e.error,n=t?t.toString():e.message||e.reason||"",r=t&&t.stack?t.stack.toString():"";(n+="\n"+(r=r.startsWith(n)?r.substring(n.length):r).trim())&&m.stackTraceRegExp&&m.stackTraceRegExp.test(n)&&P(n,e.filename||t&&(t.fileName||t.sourceURL)||"",e.lineno||t&&(t.lineNumber||t.line)||0)}function e(e,t,n){var r=e[t];void 0!==r&&r||(console.warn('Config option "'+t+'" is missing or empty. Falling back to default value: "'+n+'". Consider updating your WebGL template to include the missing config option.'),e[t]=n)}d=d||function(){};var o,m={canvas:t,webglContextAttributes:{preserveDrawingBuffer:!1,powerPreference:2},wasmFileSize:44137915,cacheControl:function(e){return e==m.dataUrl||e.match(/\.bundle/)?"must-revalidate":"no-store"},streamingAssetsUrl:"StreamingAssets",downloadProgress:{},deinitializers:[],intervals:{},setInterval:function(e,t){e=window.setInterval(e,t);return this.intervals[e]=!0,e},clearInterval:function(e){delete this.intervals[e],window.clearInterval(e)},preRun:[],postRun:[],print:function(e){console.log(e)},printErr:function(e){console.error(e),"string"==typeof e&&-1!=e.indexOf("wasm streaming compile failed")&&(-1!=e.toLowerCase().indexOf("mime")?c('HTTP Response Header "Content-Type" configured incorrectly on the server for file '+m.codeUrl+' , should be "application/wasm". Startup time performance will suffer.',"warning"):c('WebAssembly streaming compilation failed! This can happen for example if "Content-Encoding" HTTP header is incorrectly enabled on the server for file '+m.codeUrl+", but the file is not pre-compressed on disk (or vice versa). Check the Network tab in browser Devtools to debug server header configuration.","warning"))},locateFile:function(e){return"build.wasm"==e?this.codeUrl:e},disabledCanvasEvents:["contextmenu","dragstart"]};for(o in e(n,"companyName","Unity"),e(n,"productName","WebGL Player"),e(n,"productVersion","1.0"),n)m[o]=n[o];m.streamingAssetsUrl=new URL(m.streamingAssetsUrl,document.URL).href;var a=m.disabledCanvasEvents.slice();function i(e){e.preventDefault()}a.forEach(function(e){t.addEventListener(e,i)}),window.addEventListener("error",r),window.addEventListener("unhandledrejection",r);var s="",l="";function u(e){document.webkitCurrentFullScreenElement===t?t.style.width&&(s=t.style.width,l=t.style.height,t.style.width="100%",t.style.height="100%"):s&&(t.style.width=s,t.style.height=l,l=s="")}document.addEventListener("webkitfullscreenchange",u),m.deinitializers.push(function(){for(var e in m.disableAccessToMediaDevices(),a.forEach(function(e){t.removeEventListener(e,i)}),window.removeEventListener("error",r),window.removeEventListener("unhandledrejection",r),document.removeEventListener("webkitfullscreenchange",u),m.intervals)window.clearInterval(e);m.intervals={}}),m.QuitCleanup=function(){for(var e=0;e<m.deinitializers.length;e++)m.deinitializers[e]();m.deinitializers=[],"function"==typeof m.onQuit&&m.onQuit()};var h,f,p,g,b,w,y,v,S,C={Module:m,SetFullscreen:function(){if(m.SetFullscreen)return m.SetFullscreen.apply(m,arguments);m.print("Failed to set Fullscreen mode: Player not loaded yet.")},SendMessage:function(){if(m.SendMessage)return m.SendMessage.apply(m,arguments);m.print("Failed to execute SendMessage: Player not loaded yet.")},Quit:function(){return new Promise(function(e,t){m.shouldQuit=!0,m.onQuit=e})},GetMetricsInfo:function(){var e=Number(m._getMetricsInfo())>>>0,t=4+e,n=4+t,r=8+n,o=8+r,a=4+o,i=4+a,s=8+i,d=8+s,c=4+d,l=4+c,u=4+l;return{totalWASMHeapSize:m.HEAPU32[e>>2],usedWASMHeapSize:m.HEAPU32[t>>2],totalJSHeapSize:m.HEAPF64[n>>3],usedJSHeapSize:m.HEAPF64[r>>3],pageLoadTime:m.HEAPU32[o>>2],pageLoadTimeToFrame1:m.HEAPU32[a>>2],fps:m.HEAPF64[i>>3],movingAverageFps:m.HEAPF64[s>>3],assetLoadTime:m.HEAPU32[d>>2],webAssemblyStartupTime:m.HEAPU32[c>>2]-(m.webAssemblyTimeStart||0),codeDownloadTime:m.HEAPU32[l>>2],gameStartupTime:m.HEAPU32[u>>2],numJankedFrames:m.HEAPU32[4+u>>2]}}};function P(e,t,n){-1==e.indexOf("fullscreen error")&&(m.startupErrorHandler?m.startupErrorHandler(e,t,n):m.errorHandler&&m.errorHandler(e,t,n)||(console.log("Invoking error handler due to\n"+e),"function"==typeof dump&&dump("Invoking error handler due to\n"+e),P.didShowErrorMessage||(-1!=(e="An error occurred running the Unity content on this page. See your browser JavaScript console for more info. The error was:\n"+e).indexOf("DISABLE_EXCEPTION_CATCHING")?e="An exception has occurred, but exception handling has been disabled in this build. If you are the developer of this content, enable exceptions in your project WebGL player settings to be able to catch the exception or see the stack trace.":-1!=e.indexOf("Cannot enlarge memory arrays")?e="Out of memory. If you are the developer of this content, try allocating more memory to your WebGL build in the WebGL player settings.":-1==e.indexOf("Invalid array buffer length")&&-1==e.indexOf("Invalid typed array length")&&-1==e.indexOf("out of memory")&&-1==e.indexOf("could not allocate memory")||(e="The browser could not allocate enough memory for the WebGL content. If you are the developer of this content, try allocating less memory to your WebGL build in the WebGL player settings."),alert(e),P.didShowErrorMessage=!0)))}function T(e,t){if("symbolsUrl"!=e){var n=m.downloadProgress[e],r=(n=n||(m.downloadProgress[e]={started:!1,finished:!1,lengthComputable:!1,total:0,loaded:0}),"object"!=typeof t||"progress"!=t.type&&"load"!=t.type||(n.started||(n.started=!0,n.lengthComputable=t.lengthComputable),n.total=t.total,n.loaded=t.loaded,"load"==t.type&&(n.finished=!0)),0),o=0,a=0,i=0,s=0;for(e in m.downloadProgress){if(!(n=m.downloadProgress[e]).started)return;a++,n.lengthComputable?(r+=n.loaded,o+=n.total,i++):n.finished||s++}d(.9*(a?(a-s-(o?i*(o-r)/o:0))/a:0))}}function E(){var e=this;this.isConnected=this.connect().then(function(){return e.cleanUpCache()}),this.isConnected.catch(function(e){e="Error when initializing cache: "+e,console.log("[UnityCache] "+e)})}function U(e){console.log("[UnityCache] "+e)}function k(e){return k.link=k.link||document.createElement("a"),k.link.href=e,k.link.href}m.SystemInfo=function(){var e,t,n,r,o,a=navigator.userAgent+" ",i=[["Firefox","Firefox"],["OPR","Opera"],["Edg","Edge"],["SamsungBrowser","Samsung Browser"],["Trident","Internet Explorer"],["MSIE","Internet Explorer"],["Chrome","Chrome"],["CriOS","Chrome on iOS Safari"],["FxiOS","Firefox on iOS Safari"],["Safari","Safari"]];function s(e,t,n){return(e=RegExp(e,"i").exec(t))&&e[n]}for(var d=0;d<i.length;++d)if(t=s(i[d][0]+"[/ ](.*?)[ \\)]",a,1)){e=i[d][1];break}"Safari"==e&&(t=s("Version/(.*?) ",a,1)),"Internet Explorer"==e&&(t=s("rv:(.*?)\\)? ",a,1)||t);for(var c=[["Windows (.*?)[;)]","Windows"],["Android ([0-9_.]+)","Android"],["iPhone OS ([0-9_.]+)","iPhoneOS"],["iPad.*? OS ([0-9_.]+)","iPadOS"],["FreeBSD( )","FreeBSD"],["OpenBSD( )","OpenBSD"],["Linux|X11()","Linux"],["Mac OS X ([0-9_\\.]+)","MacOS"],["bot|google|baidu|bing|msn|teoma|slurp|yandex","Search Bot"]],l=0;l<c.length;++l)if(r=s(c[l][0],a,1)){n=c[l][1],r=r.replace(/_/g,".");break}var u;function h(){try{return window.WebAssembly?WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,3,1,0,1,10,13,1,11,0,65,0,65,0,65,1,252,11,0,11]))?WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,11,1,9,1,1,125,32,0,252,0,26,11]))?WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,10,1,8,1,1,126,32,0,194,26,11]))?WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,9,1,7,0,65,0,253,15,26,11]))?!!WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,10,1,8,0,6,64,1,25,1,11,11]))||"wasm-exceptions":"wasm-simd128":"sign-extend":"non-trapping fp-to-int":"bulk-memory":"WebAssembly"}catch(e){return"Exception: "+e}}r={"NT 5.0":"2000","NT 5.1":"XP","NT 5.2":"Server 2003","NT 6.0":"Vista","NT 6.1":"7","NT 6.2":"8","NT 6.3":"8.1","NT 10.0":"10"}[r]||r,webgpuVersion=0,(f=document.createElement("canvas"))&&(u=(p=f.getContext("webgl2"))?2:0,p||(p=f&&f.getContext("webgl"))&&(u=1),p&&(o=p.getExtension("WEBGL_debug_renderer_info")&&p.getParameter(37446)||p.getParameter(7937)),webgpuVersion=navigator.gpu?1:0);var f="undefined"!=typeof SharedArrayBuffer,p="object"==typeof WebAssembly&&"function"==typeof WebAssembly.compile,m=p&&!0===h();return{width:screen.width,height:screen.height,userAgent:a.trim(),browser:e||"Unknown browser",browserVersion:t||"Unknown version",mobile:/Mobile|Android|iP(ad|hone)/.test(navigator.appVersion),os:n||"Unknown OS",osVersion:r||"Unknown OS Version",gpu:o||"Unknown GPU",language:navigator.userLanguage||navigator.language,hasWebGL:u,hasWebGPU:webgpuVersion,hasCursorLock:!!document.body.requestPointerLock,hasFullscreen:!!document.body.requestFullscreen||!!document.body.webkitRequestFullscreen,hasThreads:f,hasWasm:p,hasWasm2023:m,missingWasm2023Feature:m?null:h(),hasWasmThreads:!1}}(),m.abortHandler=function(e){return P(e,"",0),!0},Error.stackTraceLimit=Math.max(Error.stackTraceLimit||0,50),m.readBodyWithProgress=function(a,i,s){var e=a.body?a.body.getReader():void 0,d=void 0!==a.headers.get("Content-Length"),c=function(e,t){if(!t)return 0;var t=e.headers.get("Content-Encoding"),n=parseInt(e.headers.get("Content-Length")),r=536870912;switch(t){case"br":return Math.min(Math.round(2*n),r);case"gzip":return Math.min(Math.round(1.6*n),r);default:return n}}(a,d),l=new Uint8Array(c),u=[],h=0,f=0;return d||console.warn("[UnityCache] Response is served without Content-Length header. Please reconfigure server to include valid Content-Length for better download performance."),function o(){return void 0===e?a.arrayBuffer().then(function(e){var t=new Uint8Array(e);return i({type:"progress",response:a,total:e.length,loaded:0,lengthComputable:d,chunk:s?t:null}),t}):e.read().then(function(e){if(e.done){if(h===c)return l;if(h<c)return l.slice(0,h);for(var t=new Uint8Array(h),n=(t.set(l,0),f),r=0;r<u.length;++r)t.set(u[r],n),n+=u[r].length;return t}return h+e.value.length<=l.length?(l.set(e.value,h),f=h+e.value.length):u.push(e.value),h+=e.value.length,i({type:"progress",response:a,total:Math.max(c,h),loaded:h,lengthComputable:d,chunk:s?e.value:null}),o()})}().then(function(e){return i({type:"load",response:a,total:e.length,loaded:e.length,lengthComputable:d,chunk:null}),a.parsedBody=e,a})},m.fetchWithProgress=function(e,t){var n=function(){};return t&&t.onProgress&&(n=t.onProgress),fetch(e,t).then(function(e){return m.readBodyWithProgress(e,n,t.enableStreamingDownload)})},m.UnityCache=(h={name:"UnityCache",version:4},f={name:"RequestMetaDataStore",version:1},p="RequestStore",g="WebAssembly",b=window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB,w=null,E.getInstance=function(){return w=w||new E},E.destroyInstance=function(){return w?w.close().then(function(){w=null}):Promise.resolve()},E.prototype.clearCache=function(){var r=this;return this.isConnected.then(function(){return r.execute(f.name,"clear",[])}).then(function(){return r.cache.keys()}).then(function e(t){var n;return 0===t.length?Promise.resolve():(n=t.pop(),r.cache.delete(n).then(function(){return e(t)}))})},E.UnityCacheDatabase=h,E.RequestMetaDataStore=f,E.MaximumCacheSize=1073741824,E.prototype.loadRequest=function(e){var t=this;return t.isConnected.then(function(){return Promise.all([t.cache.match(e),t.loadRequestMetaData(e)])}).then(function(e){if(void 0!==e[0]&&void 0!==e[1])return{response:e[0],metaData:e[1]}})},E.prototype.loadRequestMetaData=function(e){e="string"==typeof e?e:e.url;return this.execute(f.name,"get",[e])},E.prototype.updateRequestMetaData=function(e){return this.execute(f.name,"put",[e])},E.prototype.storeRequest=function(e,t){var n=this;return n.isConnected.then(function(){return n.cache.put(e,t)})},E.prototype.close=function(){return this.isConnected.then(function(){this.database&&(this.database.close(),this.database=null),this.cache&&(this.cache=null)}.bind(this))},E.prototype.connect=function(){var o=this;return void 0===b?Promise.reject(new Error("Could not connect to cache: IndexedDB is not supported.")):void 0===window.caches?Promise.reject(new Error("Could not connect to cache: Cache API is not supported.")):new Promise(function(t,n){try{function r(){o.openDBTimeout&&(clearTimeout(o.openDBTimeout),o.openDBTimeout=null)}o.openDBTimeout=setTimeout(function(){void 0===o.database&&n(new Error("Could not connect to cache: Database timeout."))},2e4);var e=b.open(h.name,h.version);e.onupgradeneeded=o.upgradeDatabase.bind(o),e.onsuccess=function(e){r(),o.database=e.target.result,t()},e.onerror=function(e){r(),o.database=null,n(new Error("Could not connect to database."))}}catch(e){r(),o.database=null,o.cache=null,n(new Error("Could not connect to cache: Could not connect to database."))}}).then(function(){var e=h.name+"_"+m.companyName+"_"+m.productName;return caches.open(e)}).then(function(e){o.cache=e})},E.prototype.upgradeDatabase=function(e){var t,e=e.target.result;e.objectStoreNames.contains(f.name)||(t=e.createObjectStore(f.name,{keyPath:"url"}),["accessedAt","updatedAt"].forEach(function(e){t.createIndex(e,e)})),e.objectStoreNames.contains(p)&&e.deleteObjectStore(p),e.objectStoreNames.contains(g)&&e.deleteObjectStore(g)},E.prototype.execute=function(a,i,s){return this.isConnected.then(function(){return new Promise(function(t,n){try{var e,r,o;null===this.database?n(new Error("indexedDB access denied")):(e=-1!=["put","delete","clear"].indexOf(i)?"readwrite":"readonly",r=this.database.transaction([a],e).objectStore(a),"openKeyCursor"==i&&(r=r.index(s[0]),s=s.slice(1)),(o=r[i].apply(r,s)).onsuccess=function(e){t(e.target.result)},o.onerror=function(e){n(e)})}catch(e){n(e)}}.bind(this))}.bind(this))},E.prototype.getMetaDataEntries=function(){var r=this,o=0,a=[];return new Promise(function(t,n){var e=r.database.transaction([f.name],"readonly").objectStore(f.name).openCursor();e.onsuccess=function(e){e=e.target.result;e?(o+=e.value.size,a.push(e.value),e.continue()):t({metaDataEntries:a,cacheSize:o})},e.onerror=function(e){n(e)}})},E.prototype.cleanUpCache=function(){var i=this;return this.getMetaDataEntries().then(function(e){for(var t=e.metaDataEntries,n=e.cacheSize,r=[],o=[],a=0;a<t.length;++a)t[a].version==m.productVersion?o.push(t[a]):(r.push(t[a]),n-=t[a].size);o.sort(function(e,t){return e.accessedAt-t.accessedAt});for(a=0;a<o.length&&!(n<E.MaximumCacheSize);++a)r.push(o[a]),n-=o[a].size;return function e(){var t;return 0===r.length?Promise.resolve():(t=r.pop(),i.cache.delete(t.url).then(function(e){if(e)return r=t.url,new Promise(function(e,t){var n=i.database.transaction([f.name],"readwrite");n.objectStore(f.name).delete(r),n.oncomplete=e,n.onerror=t});var r}).then(e))}()})},E),m.cachedFetch=(y=m.UnityCache,v=m.fetchWithProgress,S=m.readBodyWithProgress,function(o,a){var e,t,i=y.getInstance(),s=k("string"==typeof o?o:o.url),d={enabled:(e=s,(!(t=a)||!t.method||"GET"===t.method)&&((!t||-1!=["must-revalidate","immutable"].indexOf(t.control))&&!!e.match("^https?://")))};function c(n,r){return fetch(n,r).then(function(e){var t;return!d.enabled||d.revalidated?e:304===e.status?(d.revalidated=!0,i.updateRequestMetaData(d.metaData).then(function(){U("'"+d.metaData.url+"' successfully revalidated and served from the browser cache")}).catch(function(e){U("'"+d.metaData.url+"' successfully revalidated but not stored in the browser cache due to the error: "+e)}),S(d.response,r.onProgress,r.enableStreamingDownload)):200==e.status?(d.response=e,d.metaData.updatedAt=d.metaData.accessedAt,d.revalidated=!0,t=e.clone(),S(e,r.onProgress,r.enableStreamingDownload).then(function(e){return d.metaData.size=e.parsedBody.length,Promise.all([i.storeRequest(n,t),i.updateRequestMetaData(d.metaData)]).then(function(){U("'"+s+"' successfully downloaded and stored in the browser cache")}).catch(function(e){U("'"+s+"' successfully downloaded but not stored in the browser cache due to the error: "+e)}),e})):(U("'"+s+"' request failed with status: "+e.status+" "+e.statusText),S(e,r.onProgress,r.enableStreamingDownload))})}return a&&(d.control=a.control,d.companyName=a.companyName,d.productName=a.productName,d.productVersion=a.productVersion),d.revalidated=!1,d.metaData={url:s,accessedAt:Date.now(),version:d.productVersion},d.response=null,d.enabled?i.loadRequest(s).then(function(e){var n,r,t;return e?(n=e.response,r=e.metaData,d.response=n,d.metaData.size=r.size,d.metaData.updatedAt=r.updatedAt,"immutable"==d.control?(d.revalidated=!0,i.updateRequestMetaData(r).then(function(){U("'"+d.metaData.url+"' served from the browser cache without revalidation")}),S(n,a.onProgress,a.enableStreamingDownload)):(e=s,(t=window.location.href.match(/^[a-z]+:\/\/[^\/]+/))&&!e.lastIndexOf(t[0],0)||!n.headers.get("Last-Modified")&&!n.headers.get("ETag")?(e=(a=a||{}).headers||{},a.headers=e,n.headers.get("Last-Modified")?(e["If-Modified-Since"]=n.headers.get("Last-Modified"),e["Cache-Control"]="no-cache"):n.headers.get("ETag")&&(e["If-None-Match"]=n.headers.get("ETag"),e["Cache-Control"]="no-cache"),c(o,a)):fetch(s,{method:"HEAD"}).then(function(t){return d.revalidated=["Last-Modified","ETag"].every(function(e){return!n.headers.get(e)||n.headers.get(e)==t.headers.get(e)}),d.revalidated?(i.updateRequestMetaData(r).then(function(){U("'"+d.metaData.url+"' successfully revalidated and served from the browser cache")}),S(d.response,a.onProgress,a.enableStreamingDownload)):c(o,a)}))):c(o,a)}).catch(function(e){return U("Failed to load '"+d.metaData.url+"' from browser cache due to the error: "+e),v(o,a)}):v(o,a)});var A={gzip:{hasUnityMarker:function(e){var t=10,n="UnityWeb Compressed Content (gzip)";if(t>e.length||31!=e[0]||139!=e[1])return!1;var r=e[3];if(4&r){if(t+2>e.length)return!1;if((t+=2+e[t]+(e[t+1]<<8))>e.length)return!1}if(8&r){for(;t<e.length&&e[t];)t++;if(t+1>e.length)return!1;t++}return 16&r&&String.fromCharCode.apply(null,e.subarray(t,t+n.length+1))==n+"\0"}},br:{hasUnityMarker:function(e){var t="UnityWeb Compressed Content (brotli)";if(!e.length)return!1;var n=1&e[0]?14&e[0]?4:7:1,r=e[0]&(1<<n)-1,o=1+(Math.log(t.length-1)/Math.log(2)>>3);if(commentOffset=1+n+2+1+2+(o<<3)+7>>3,17==r||commentOffset>e.length)return!1;for(var a=r+(6+(o<<4)+(t.length-1<<6)<<n),i=0;i<commentOffset;i++,a>>>=8)if(e[i]!=(255&a))return!1;return String.fromCharCode.apply(null,e.subarray(commentOffset,commentOffset+t.length))==t}}};function D(){var t,e,n,s,r,o=performance.now(),p=(new Promise(function(a,e){var i=document.createElement("script");i.src=m.frameworkUrl,i.onload=function(){if("undefined"==typeof unityFramework||!unityFramework){var e,t=[["br","br"],["gz","gzip"]];for(e in t){var n,r=t[e];if(m.frameworkUrl.endsWith("."+r[0]))return n="Unable to parse "+m.frameworkUrl+"!","file:"==location.protocol?void c(n+" Loading pre-compressed (brotli or gzip) content via a file:// URL without a web server is not supported by this browser. Please use a local development web server to host compressed Unity content, or use the Unity Build and Run option.","error"):(n+=' This can happen if build compression was enabled but web server hosting the content was misconfigured to not serve the file with HTTP Response Header "Content-Encoding: '+r[1]+'" present. Check browser Console and Devtools Network tab to debug.',"br"==r[0]&&"http:"==location.protocol&&(r=-1!=["localhost","127.0.0.1"].indexOf(location.hostname)?"":"Migrate your server to use HTTPS.",n=/Firefox/.test(navigator.userAgent)?"Unable to parse "+m.frameworkUrl+'!<br>If using custom web server, verify that web server is sending .br files with HTTP Response Header "Content-Encoding: br". Brotli compression may not be supported in Firefox over HTTP connections. '+r+' See <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1670675">https://bugzilla.mozilla.org/show_bug.cgi?id=1670675</a> for more information.':"Unable to parse "+m.frameworkUrl+'!<br>If using custom web server, verify that web server is sending .br files with HTTP Response Header "Content-Encoding: br". Brotli compression may not be supported over HTTP connections. Migrate your server to use HTTPS.'),void c(n,"error"))}c("Unable to parse "+m.frameworkUrl+"! The file is corrupt, or compression was misconfigured? (check Content-Encoding HTTP Response Header on web server)","error")}var o=unityFramework;unityFramework=null,i.onload=null,a(o)},i.onerror=function(e){c("Unable to load file "+m.frameworkUrl+"! Check that the file exists on the remote server. (also check browser Console and Devtools Network tab to debug)","error")},document.body.appendChild(i),m.deinitializers.push(function(){document.body.removeChild(i)})}).then(function(e){m.webAssemblyTimeStart=performance.now(),e(m),m.codeDownloadTimeEnd=performance.now()-o}),performance.now()),a=(T(t="dataUrl"),e=m.cacheControl(m[t]),n=m.companyName&&m.productName?m.cachedFetch:m.fetchWithProgress,s=m[t],r=/file:\/\//.exec(s)?"same-origin":void 0,n(m[t],{method:"GET",companyName:m.companyName,productName:m.productName,productVersion:m.productVersion,control:e,mode:r,onProgress:function(e){T(t,e)}}).then(function(e){var t,n,r,o,a,i;return A.gzip.hasUnityMarker(e.parsedBody)&&(t=["gzip","gzip"]),(t=A.br.hasUnityMarker(e.parsedBody)?["brotli","br"]:t)&&(n=e.headers.get("Content-Type"),r=e.headers.get("Content-Encoding"),a=0<(o=e.headers.get("Content-Length"))&&e.parsedBody.length!=o,i=0<o&&e.parsedBody.length==o,r!=t[1]?c("Failed to parse binary data file "+s+' (with "Content-Type: '+n+'"), because it is still '+t[0]+'-compressed. It should have been uncompressed by the browser, but it was unable to do so since the web server provided the compressed content without specifying the HTTP Response Header "Content-Encoding: '+t[1]+'" that would have informed the browser that decompression is needed. Please verify your web server hosting configuration to add the missing "Content-Encoding: '+t[1]+'" HTTP Response Header.',"error"):c(a?"Web server configuration error: it looks like the web server has been misconfigured to double-compress the data file "+s+"! That is, it looks like the web browser has decompressed the file, but it is still in compressed form, suggesting that an already compressed file was compressed a second time. (Content-Length: "+o+", obtained length: "+e.parsedBody.length+")":i?/^((?!chrome|android).)*safari/i.test(navigator.userAgent)&&"gzip"==r&&"application/octet-stream"==n?"Unable to load content due to Apple Safari bug https://bugs.webkit.org/show_bug.cgi?id=247421 . To work around this issue, please reconfigure your web server to serve "+s+" with Content-Type: application/gzip instead of Content-Type: application/octet-stream":"Malformed binary data? Received compressed data file "+s+', with "Content-Type: '+n+'", "Content-Encoding: '+t[1]+'", "Content-Length: '+o+'", which the web browser should have decompressed, but it seemingly did not (received file size is the same as compressed file size was). Double check that the integrity of the file is intact.':"Malformed binary data URL "+s+'. No "Content-Length" HTTP Response header present. Check browser console for more information.',"error"),console.error("Malformed data? Downloaded binary data file "+s+" (ArrayBuffer size: "+e.parsedBody.length+") and browser should have decompressed it, but it might have not. Dumping raw HTTP Response Headers if it might help debug:"),e.headers.forEach(function(e,t){console.error(t+": "+e)})),e.parsedBody}).catch(function(e){var t="Failed to download file "+s;"file:"==location.protocol?c(t+". Loading web pages via a file:// URL without a web server is not supported by this browser. Please use a local development web server to host Unity content, or use the Unity Build and Run option.","error"):console.error(t)}));m.preRun.push(function(){m.addRunDependency("dataUrl"),a.then(function(t){var e=new TextDecoder("utf-8"),n=0;function r(){var e=(t[n]|t[n+1]<<8|t[n+2]<<16|t[n+3]<<24)>>>0;return n+=4,e}function o(e){if(A.gzip.hasUnityMarker(t))throw e+'. Failed to parse binary data file, because it is still gzip-compressed and should have been uncompressed by the browser. Web server has likely provided gzip-compressed data without specifying the HTTP Response Header "Content-Encoding: gzip" with it to instruct the browser to decompress it. Please verify your web server hosting configuration.';if(A.br.hasUnityMarker(t))throw e+'. Failed to parse binary data file, because it is still brotli-compressed and should have been uncompressed by the browser. Web server has likely provided brotli-compressed data without specifying the HTTP Response Header "Content-Encoding: br" with it to instruct the browser to decompress it. Please verify your web server hosting configuration.';throw e}var a="UnityWebData1.0\0",i=e.decode(t.subarray(0,a.length)),s=(i!=a&&o('Unknown data format (id="'+i+'")'),n+=a.length,r());for(n+s>t.length&&o("Invalid binary data file header! (pos="+n+", headerSize="+s+", file length="+t.length+")");n<s;){var d=r(),c=r(),l=(d+c>t.length&&o("Invalid binary data file size! (offset="+d+", size="+c+", file length="+t.length+")"),r()),u=(n+l>t.length&&o("Invalid binary data file path name! (pos="+n+", length="+l+", file length="+t.length+")"),e.decode(t.subarray(n,n+l)));n+=l;for(var h=0,f=u.indexOf("/",h)+1;0<f;h=f,f=u.indexOf("/",h)+1)m.FS_createPath(u.substring(0,h),u.substring(h,f-1),!0,!0);m.FS_createDataFile(u,null,t.subarray(d,d+c),!0,!0,!0)}m.removeRunDependency("dataUrl"),m.dataUrlLoadEndTime=performance.now()-p})})}return new Promise(function(e,t){var n;m.SystemInfo.hasWebGL?1==m.SystemInfo.hasWebGL?(n='Your browser does not support graphics API "WebGL 2" which is required for this content.',"Safari"==m.SystemInfo.browser&&parseInt(m.SystemInfo.browserVersion)<15&&(m.SystemInfo.mobile||1<navigator.maxTouchPoints?n+="\nUpgrade to iOS 15 or later.":n+="\nUpgrade to Safari 15 or later."),t(n)):m.SystemInfo.hasWasm?m.SystemInfo.hasWasm2023?(m.startupErrorHandler=t,d(0),m.postRun.push(function(){d(1),m.WebPlayer.WaitForInitialization().then(function(){delete m.startupErrorHandler,e(C),m.pageStartupTime=performance.now()})}),new Promise(function(t,e){navigator.gpu?navigator.gpu.requestAdapter().then(function(e){m.SystemInfo.hasWebGPU=!!e,t(m.SystemInfo.hasWebGPU)}):t(!1)}).then(function(){D()})):t("Your browser does not support WebAssembly 2023. Please update to Chrome \u2265 91 (May 2021), Firefox \u2265 89 (June 2021) or Safari \u2265 16.4 (March 2023). (failed "+m.SystemInfo.missingWasm2023Feature+")"):t("Your browser does not support WebAssembly."):t("Your browser does not support WebGL.")})}
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function createUnityInstance(t,n,d){function c(e,t){if(!c.aborted&&n.showBanner)return"error"==t&&(c.aborted=!0),n.showBanner(e,t);switch(t){case"error":console.error(e);break;case"warning":console.warn(e);break;default:console.log(e)}}function r(e){var t=e.reason||e.error,n=t?t.toString():e.message||e.reason||"",r=t&&t.stack?t.stack.toString():"";(n+="\n"+(r=r.startsWith(n)?r.substring(n.length):r).trim())&&m.stackTraceRegExp&&m.stackTraceRegExp.test(n)&&P(n,e.filename||t&&(t.fileName||t.sourceURL)||"",e.lineno||t&&(t.lineNumber||t.line)||0)}function e(e,t,n){var r=e[t];void 0!==r&&r||(console.warn('Config option "'+t+'" is missing or empty. Falling back to default value: "'+n+'". Consider updating your WebGL template to include the missing config option.'),e[t]=n)}d=d||function(){};var o,m={canvas:t,webglContextAttributes:{preserveDrawingBuffer:!1,powerPreference:2},wasmFileSize:44136431,cacheControl:function(e){return e==m.dataUrl||e.match(/\.bundle/)?"must-revalidate":"no-store"},streamingAssetsUrl:"StreamingAssets",downloadProgress:{},deinitializers:[],intervals:{},setInterval:function(e,t){e=window.setInterval(e,t);return this.intervals[e]=!0,e},clearInterval:function(e){delete this.intervals[e],window.clearInterval(e)},preRun:[],postRun:[],print:function(e){console.log(e)},printErr:function(e){console.error(e),"string"==typeof e&&-1!=e.indexOf("wasm streaming compile failed")&&(-1!=e.toLowerCase().indexOf("mime")?c('HTTP Response Header "Content-Type" configured incorrectly on the server for file '+m.codeUrl+' , should be "application/wasm". Startup time performance will suffer.',"warning"):c('WebAssembly streaming compilation failed! This can happen for example if "Content-Encoding" HTTP header is incorrectly enabled on the server for file '+m.codeUrl+", but the file is not pre-compressed on disk (or vice versa). Check the Network tab in browser Devtools to debug server header configuration.","warning"))},locateFile:function(e){return"build.wasm"==e?this.codeUrl:e},disabledCanvasEvents:["contextmenu","dragstart"]};for(o in e(n,"companyName","Unity"),e(n,"productName","WebGL Player"),e(n,"productVersion","1.0"),n)m[o]=n[o];m.streamingAssetsUrl=new URL(m.streamingAssetsUrl,document.URL).href;var a=m.disabledCanvasEvents.slice();function i(e){e.preventDefault()}a.forEach(function(e){t.addEventListener(e,i)}),window.addEventListener("error",r),window.addEventListener("unhandledrejection",r);var s="",l="";function u(e){document.webkitCurrentFullScreenElement===t?t.style.width&&(s=t.style.width,l=t.style.height,t.style.width="100%",t.style.height="100%"):s&&(t.style.width=s,t.style.height=l,l=s="")}document.addEventListener("webkitfullscreenchange",u),m.deinitializers.push(function(){for(var e in m.disableAccessToMediaDevices(),a.forEach(function(e){t.removeEventListener(e,i)}),window.removeEventListener("error",r),window.removeEventListener("unhandledrejection",r),document.removeEventListener("webkitfullscreenchange",u),m.intervals)window.clearInterval(e);m.intervals={}}),m.QuitCleanup=function(){for(var e=0;e<m.deinitializers.length;e++)m.deinitializers[e]();m.deinitializers=[],"function"==typeof m.onQuit&&m.onQuit()};var h,f,p,g,b,w,y,v,S,C={Module:m,SetFullscreen:function(){if(m.SetFullscreen)return m.SetFullscreen.apply(m,arguments);m.print("Failed to set Fullscreen mode: Player not loaded yet.")},SendMessage:function(){if(m.SendMessage)return m.SendMessage.apply(m,arguments);m.print("Failed to execute SendMessage: Player not loaded yet.")},Quit:function(){return new Promise(function(e,t){m.shouldQuit=!0,m.onQuit=e})},GetMetricsInfo:function(){var e=Number(m._getMetricsInfo())>>>0,t=4+e,n=4+t,r=8+n,o=8+r,a=4+o,i=4+a,s=8+i,d=8+s,c=4+d,l=4+c,u=4+l;return{totalWASMHeapSize:m.HEAPU32[e>>2],usedWASMHeapSize:m.HEAPU32[t>>2],totalJSHeapSize:m.HEAPF64[n>>3],usedJSHeapSize:m.HEAPF64[r>>3],pageLoadTime:m.HEAPU32[o>>2],pageLoadTimeToFrame1:m.HEAPU32[a>>2],fps:m.HEAPF64[i>>3],movingAverageFps:m.HEAPF64[s>>3],assetLoadTime:m.HEAPU32[d>>2],webAssemblyStartupTime:m.HEAPU32[c>>2]-(m.webAssemblyTimeStart||0),codeDownloadTime:m.HEAPU32[l>>2],gameStartupTime:m.HEAPU32[u>>2],numJankedFrames:m.HEAPU32[4+u>>2]}}};function P(e,t,n){-1==e.indexOf("fullscreen error")&&(m.startupErrorHandler?m.startupErrorHandler(e,t,n):m.errorHandler&&m.errorHandler(e,t,n)||(console.log("Invoking error handler due to\n"+e),"function"==typeof dump&&dump("Invoking error handler due to\n"+e),P.didShowErrorMessage||(-1!=(e="An error occurred running the Unity content on this page. See your browser JavaScript console for more info. The error was:\n"+e).indexOf("DISABLE_EXCEPTION_CATCHING")?e="An exception has occurred, but exception handling has been disabled in this build. If you are the developer of this content, enable exceptions in your project WebGL player settings to be able to catch the exception or see the stack trace.":-1!=e.indexOf("Cannot enlarge memory arrays")?e="Out of memory. If you are the developer of this content, try allocating more memory to your WebGL build in the WebGL player settings.":-1==e.indexOf("Invalid array buffer length")&&-1==e.indexOf("Invalid typed array length")&&-1==e.indexOf("out of memory")&&-1==e.indexOf("could not allocate memory")||(e="The browser could not allocate enough memory for the WebGL content. If you are the developer of this content, try allocating less memory to your WebGL build in the WebGL player settings."),alert(e),P.didShowErrorMessage=!0)))}function T(e,t){if("symbolsUrl"!=e){var n=m.downloadProgress[e],r=(n=n||(m.downloadProgress[e]={started:!1,finished:!1,lengthComputable:!1,total:0,loaded:0}),"object"!=typeof t||"progress"!=t.type&&"load"!=t.type||(n.started||(n.started=!0,n.lengthComputable=t.lengthComputable),n.total=t.total,n.loaded=t.loaded,"load"==t.type&&(n.finished=!0)),0),o=0,a=0,i=0,s=0;for(e in m.downloadProgress){if(!(n=m.downloadProgress[e]).started)return;a++,n.lengthComputable?(r+=n.loaded,o+=n.total,i++):n.finished||s++}d(.9*(a?(a-s-(o?i*(o-r)/o:0))/a:0))}}function E(){var e=this;this.isConnected=this.connect().then(function(){return e.cleanUpCache()}),this.isConnected.catch(function(e){e="Error when initializing cache: "+e,console.log("[UnityCache] "+e)})}function U(e){console.log("[UnityCache] "+e)}function k(e){return k.link=k.link||document.createElement("a"),k.link.href=e,k.link.href}m.SystemInfo=function(){var e,t,n,r,o,a=navigator.userAgent+" ",i=[["Firefox","Firefox"],["OPR","Opera"],["Edg","Edge"],["SamsungBrowser","Samsung Browser"],["Trident","Internet Explorer"],["MSIE","Internet Explorer"],["Chrome","Chrome"],["CriOS","Chrome on iOS Safari"],["FxiOS","Firefox on iOS Safari"],["Safari","Safari"]];function s(e,t,n){return(e=RegExp(e,"i").exec(t))&&e[n]}for(var d=0;d<i.length;++d)if(t=s(i[d][0]+"[/ ](.*?)[ \\)]",a,1)){e=i[d][1];break}"Safari"==e&&(t=s("Version/(.*?) ",a,1)),"Internet Explorer"==e&&(t=s("rv:(.*?)\\)? ",a,1)||t);for(var c=[["Windows (.*?)[;)]","Windows"],["Android ([0-9_.]+)","Android"],["iPhone OS ([0-9_.]+)","iPhoneOS"],["iPad.*? OS ([0-9_.]+)","iPadOS"],["FreeBSD( )","FreeBSD"],["OpenBSD( )","OpenBSD"],["Linux|X11()","Linux"],["Mac OS X ([0-9_\\.]+)","MacOS"],["bot|google|baidu|bing|msn|teoma|slurp|yandex","Search Bot"]],l=0;l<c.length;++l)if(r=s(c[l][0],a,1)){n=c[l][1],r=r.replace(/_/g,".");break}var u;function h(){try{return window.WebAssembly?WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,3,1,0,1,10,13,1,11,0,65,0,65,0,65,1,252,11,0,11]))?WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,11,1,9,1,1,125,32,0,252,0,26,11]))?WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,10,1,8,1,1,126,32,0,194,26,11]))?WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,9,1,7,0,65,0,253,15,26,11]))?!!WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,10,1,8,0,6,64,1,25,1,11,11]))||"wasm-exceptions":"wasm-simd128":"sign-extend":"non-trapping fp-to-int":"bulk-memory":"WebAssembly"}catch(e){return"Exception: "+e}}r={"NT 5.0":"2000","NT 5.1":"XP","NT 5.2":"Server 2003","NT 6.0":"Vista","NT 6.1":"7","NT 6.2":"8","NT 6.3":"8.1","NT 10.0":"10"}[r]||r,webgpuVersion=0,(f=document.createElement("canvas"))&&(u=(p=f.getContext("webgl2"))?2:0,p||(p=f&&f.getContext("webgl"))&&(u=1),p&&(o=p.getExtension("WEBGL_debug_renderer_info")&&p.getParameter(37446)||p.getParameter(7937)),webgpuVersion=navigator.gpu?1:0);var f="undefined"!=typeof SharedArrayBuffer,p="object"==typeof WebAssembly&&"function"==typeof WebAssembly.compile,m=p&&!0===h();return{width:screen.width,height:screen.height,userAgent:a.trim(),browser:e||"Unknown browser",browserVersion:t||"Unknown version",mobile:/Mobile|Android|iP(ad|hone)/.test(navigator.appVersion),os:n||"Unknown OS",osVersion:r||"Unknown OS Version",gpu:o||"Unknown GPU",language:navigator.userLanguage||navigator.language,hasWebGL:u,hasWebGPU:webgpuVersion,hasCursorLock:!!document.body.requestPointerLock,hasFullscreen:!!document.body.requestFullscreen||!!document.body.webkitRequestFullscreen,hasThreads:f,hasWasm:p,hasWasm2023:m,missingWasm2023Feature:m?null:h(),hasWasmThreads:!1}}(),m.abortHandler=function(e){return P(e,"",0),!0},Error.stackTraceLimit=Math.max(Error.stackTraceLimit||0,50),m.readBodyWithProgress=function(a,i,s){var e=a.body?a.body.getReader():void 0,d=void 0!==a.headers.get("Content-Length"),c=function(e,t){if(!t)return 0;var t=e.headers.get("Content-Encoding"),n=parseInt(e.headers.get("Content-Length")),r=536870912;switch(t){case"br":return Math.min(Math.round(2*n),r);case"gzip":return Math.min(Math.round(1.6*n),r);default:return n}}(a,d),l=new Uint8Array(c),u=[],h=0,f=0;return d||console.warn("[UnityCache] Response is served without Content-Length header. Please reconfigure server to include valid Content-Length for better download performance."),function o(){return void 0===e?a.arrayBuffer().then(function(e){var t=new Uint8Array(e);return i({type:"progress",response:a,total:e.length,loaded:0,lengthComputable:d,chunk:s?t:null}),t}):e.read().then(function(e){if(e.done){if(h===c)return l;if(h<c)return l.slice(0,h);for(var t=new Uint8Array(h),n=(t.set(l,0),f),r=0;r<u.length;++r)t.set(u[r],n),n+=u[r].length;return t}return h+e.value.length<=l.length?(l.set(e.value,h),f=h+e.value.length):u.push(e.value),h+=e.value.length,i({type:"progress",response:a,total:Math.max(c,h),loaded:h,lengthComputable:d,chunk:s?e.value:null}),o()})}().then(function(e){return i({type:"load",response:a,total:e.length,loaded:e.length,lengthComputable:d,chunk:null}),a.parsedBody=e,a})},m.fetchWithProgress=function(e,t){var n=function(){};return t&&t.onProgress&&(n=t.onProgress),fetch(e,t).then(function(e){return m.readBodyWithProgress(e,n,t.enableStreamingDownload)})},m.UnityCache=(h={name:"UnityCache",version:4},f={name:"RequestMetaDataStore",version:1},p="RequestStore",g="WebAssembly",b=window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB,w=null,E.getInstance=function(){return w=w||new E},E.destroyInstance=function(){return w?w.close().then(function(){w=null}):Promise.resolve()},E.prototype.clearCache=function(){var r=this;return this.isConnected.then(function(){return r.execute(f.name,"clear",[])}).then(function(){return r.cache.keys()}).then(function e(t){var n;return 0===t.length?Promise.resolve():(n=t.pop(),r.cache.delete(n).then(function(){return e(t)}))})},E.UnityCacheDatabase=h,E.RequestMetaDataStore=f,E.MaximumCacheSize=1073741824,E.prototype.loadRequest=function(e){var t=this;return t.isConnected.then(function(){return Promise.all([t.cache.match(e),t.loadRequestMetaData(e)])}).then(function(e){if(void 0!==e[0]&&void 0!==e[1])return{response:e[0],metaData:e[1]}})},E.prototype.loadRequestMetaData=function(e){e="string"==typeof e?e:e.url;return this.execute(f.name,"get",[e])},E.prototype.updateRequestMetaData=function(e){return this.execute(f.name,"put",[e])},E.prototype.storeRequest=function(e,t){var n=this;return n.isConnected.then(function(){return n.cache.put(e,t)})},E.prototype.close=function(){return this.isConnected.then(function(){this.database&&(this.database.close(),this.database=null),this.cache&&(this.cache=null)}.bind(this))},E.prototype.connect=function(){var o=this;return void 0===b?Promise.reject(new Error("Could not connect to cache: IndexedDB is not supported.")):void 0===window.caches?Promise.reject(new Error("Could not connect to cache: Cache API is not supported.")):new Promise(function(t,n){try{function r(){o.openDBTimeout&&(clearTimeout(o.openDBTimeout),o.openDBTimeout=null)}o.openDBTimeout=setTimeout(function(){void 0===o.database&&n(new Error("Could not connect to cache: Database timeout."))},2e4);var e=b.open(h.name,h.version);e.onupgradeneeded=o.upgradeDatabase.bind(o),e.onsuccess=function(e){r(),o.database=e.target.result,t()},e.onerror=function(e){r(),o.database=null,n(new Error("Could not connect to database."))}}catch(e){r(),o.database=null,o.cache=null,n(new Error("Could not connect to cache: Could not connect to database."))}}).then(function(){var e=h.name+"_"+m.companyName+"_"+m.productName;return caches.open(e)}).then(function(e){o.cache=e})},E.prototype.upgradeDatabase=function(e){var t,e=e.target.result;e.objectStoreNames.contains(f.name)||(t=e.createObjectStore(f.name,{keyPath:"url"}),["accessedAt","updatedAt"].forEach(function(e){t.createIndex(e,e)})),e.objectStoreNames.contains(p)&&e.deleteObjectStore(p),e.objectStoreNames.contains(g)&&e.deleteObjectStore(g)},E.prototype.execute=function(a,i,s){return this.isConnected.then(function(){return new Promise(function(t,n){try{var e,r,o;null===this.database?n(new Error("indexedDB access denied")):(e=-1!=["put","delete","clear"].indexOf(i)?"readwrite":"readonly",r=this.database.transaction([a],e).objectStore(a),"openKeyCursor"==i&&(r=r.index(s[0]),s=s.slice(1)),(o=r[i].apply(r,s)).onsuccess=function(e){t(e.target.result)},o.onerror=function(e){n(e)})}catch(e){n(e)}}.bind(this))}.bind(this))},E.prototype.getMetaDataEntries=function(){var r=this,o=0,a=[];return new Promise(function(t,n){var e=r.database.transaction([f.name],"readonly").objectStore(f.name).openCursor();e.onsuccess=function(e){e=e.target.result;e?(o+=e.value.size,a.push(e.value),e.continue()):t({metaDataEntries:a,cacheSize:o})},e.onerror=function(e){n(e)}})},E.prototype.cleanUpCache=function(){var i=this;return this.getMetaDataEntries().then(function(e){for(var t=e.metaDataEntries,n=e.cacheSize,r=[],o=[],a=0;a<t.length;++a)t[a].version==m.productVersion?o.push(t[a]):(r.push(t[a]),n-=t[a].size);o.sort(function(e,t){return e.accessedAt-t.accessedAt});for(a=0;a<o.length&&!(n<E.MaximumCacheSize);++a)r.push(o[a]),n-=o[a].size;return function e(){var t;return 0===r.length?Promise.resolve():(t=r.pop(),i.cache.delete(t.url).then(function(e){if(e)return r=t.url,new Promise(function(e,t){var n=i.database.transaction([f.name],"readwrite");n.objectStore(f.name).delete(r),n.oncomplete=e,n.onerror=t});var r}).then(e))}()})},E),m.cachedFetch=(y=m.UnityCache,v=m.fetchWithProgress,S=m.readBodyWithProgress,function(o,a){var e,t,i=y.getInstance(),s=k("string"==typeof o?o:o.url),d={enabled:(e=s,(!(t=a)||!t.method||"GET"===t.method)&&((!t||-1!=["must-revalidate","immutable"].indexOf(t.control))&&!!e.match("^https?://")))};function c(n,r){return fetch(n,r).then(function(e){var t;return!d.enabled||d.revalidated?e:304===e.status?(d.revalidated=!0,i.updateRequestMetaData(d.metaData).then(function(){U("'"+d.metaData.url+"' successfully revalidated and served from the browser cache")}).catch(function(e){U("'"+d.metaData.url+"' successfully revalidated but not stored in the browser cache due to the error: "+e)}),S(d.response,r.onProgress,r.enableStreamingDownload)):200==e.status?(d.response=e,d.metaData.updatedAt=d.metaData.accessedAt,d.revalidated=!0,t=e.clone(),S(e,r.onProgress,r.enableStreamingDownload).then(function(e){return d.metaData.size=e.parsedBody.length,Promise.all([i.storeRequest(n,t),i.updateRequestMetaData(d.metaData)]).then(function(){U("'"+s+"' successfully downloaded and stored in the browser cache")}).catch(function(e){U("'"+s+"' successfully downloaded but not stored in the browser cache due to the error: "+e)}),e})):(U("'"+s+"' request failed with status: "+e.status+" "+e.statusText),S(e,r.onProgress,r.enableStreamingDownload))})}return a&&(d.control=a.control,d.companyName=a.companyName,d.productName=a.productName,d.productVersion=a.productVersion),d.revalidated=!1,d.metaData={url:s,accessedAt:Date.now(),version:d.productVersion},d.response=null,d.enabled?i.loadRequest(s).then(function(e){var n,r,t;return e?(n=e.response,r=e.metaData,d.response=n,d.metaData.size=r.size,d.metaData.updatedAt=r.updatedAt,"immutable"==d.control?(d.revalidated=!0,i.updateRequestMetaData(r).then(function(){U("'"+d.metaData.url+"' served from the browser cache without revalidation")}),S(n,a.onProgress,a.enableStreamingDownload)):(e=s,(t=window.location.href.match(/^[a-z]+:\/\/[^\/]+/))&&!e.lastIndexOf(t[0],0)||!n.headers.get("Last-Modified")&&!n.headers.get("ETag")?(e=(a=a||{}).headers||{},a.headers=e,n.headers.get("Last-Modified")?(e["If-Modified-Since"]=n.headers.get("Last-Modified"),e["Cache-Control"]="no-cache"):n.headers.get("ETag")&&(e["If-None-Match"]=n.headers.get("ETag"),e["Cache-Control"]="no-cache"),c(o,a)):fetch(s,{method:"HEAD"}).then(function(t){return d.revalidated=["Last-Modified","ETag"].every(function(e){return!n.headers.get(e)||n.headers.get(e)==t.headers.get(e)}),d.revalidated?(i.updateRequestMetaData(r).then(function(){U("'"+d.metaData.url+"' successfully revalidated and served from the browser cache")}),S(d.response,a.onProgress,a.enableStreamingDownload)):c(o,a)}))):c(o,a)}).catch(function(e){return U("Failed to load '"+d.metaData.url+"' from browser cache due to the error: "+e),v(o,a)}):v(o,a)});var A={gzip:{hasUnityMarker:function(e){var t=10,n="UnityWeb Compressed Content (gzip)";if(t>e.length||31!=e[0]||139!=e[1])return!1;var r=e[3];if(4&r){if(t+2>e.length)return!1;if((t+=2+e[t]+(e[t+1]<<8))>e.length)return!1}if(8&r){for(;t<e.length&&e[t];)t++;if(t+1>e.length)return!1;t++}return 16&r&&String.fromCharCode.apply(null,e.subarray(t,t+n.length+1))==n+"\0"}},br:{hasUnityMarker:function(e){var t="UnityWeb Compressed Content (brotli)";if(!e.length)return!1;var n=1&e[0]?14&e[0]?4:7:1,r=e[0]&(1<<n)-1,o=1+(Math.log(t.length-1)/Math.log(2)>>3);if(commentOffset=1+n+2+1+2+(o<<3)+7>>3,17==r||commentOffset>e.length)return!1;for(var a=r+(6+(o<<4)+(t.length-1<<6)<<n),i=0;i<commentOffset;i++,a>>>=8)if(e[i]!=(255&a))return!1;return String.fromCharCode.apply(null,e.subarray(commentOffset,commentOffset+t.length))==t}}};function D(){var t,e,n,s,r,o=performance.now(),p=(new Promise(function(a,e){var i=document.createElement("script");i.src=m.frameworkUrl,i.onload=function(){if("undefined"==typeof unityFramework||!unityFramework){var e,t=[["br","br"],["gz","gzip"]];for(e in t){var n,r=t[e];if(m.frameworkUrl.endsWith("."+r[0]))return n="Unable to parse "+m.frameworkUrl+"!","file:"==location.protocol?void c(n+" Loading pre-compressed (brotli or gzip) content via a file:// URL without a web server is not supported by this browser. Please use a local development web server to host compressed Unity content, or use the Unity Build and Run option.","error"):(n+=' This can happen if build compression was enabled but web server hosting the content was misconfigured to not serve the file with HTTP Response Header "Content-Encoding: '+r[1]+'" present. Check browser Console and Devtools Network tab to debug.',"br"==r[0]&&"http:"==location.protocol&&(r=-1!=["localhost","127.0.0.1"].indexOf(location.hostname)?"":"Migrate your server to use HTTPS.",n=/Firefox/.test(navigator.userAgent)?"Unable to parse "+m.frameworkUrl+'!<br>If using custom web server, verify that web server is sending .br files with HTTP Response Header "Content-Encoding: br". Brotli compression may not be supported in Firefox over HTTP connections. '+r+' See <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1670675">https://bugzilla.mozilla.org/show_bug.cgi?id=1670675</a> for more information.':"Unable to parse "+m.frameworkUrl+'!<br>If using custom web server, verify that web server is sending .br files with HTTP Response Header "Content-Encoding: br". Brotli compression may not be supported over HTTP connections. Migrate your server to use HTTPS.'),void c(n,"error"))}c("Unable to parse "+m.frameworkUrl+"! The file is corrupt, or compression was misconfigured? (check Content-Encoding HTTP Response Header on web server)","error")}var o=unityFramework;unityFramework=null,i.onload=null,a(o)},i.onerror=function(e){c("Unable to load file "+m.frameworkUrl+"! Check that the file exists on the remote server. (also check browser Console and Devtools Network tab to debug)","error")},document.body.appendChild(i),m.deinitializers.push(function(){document.body.removeChild(i)})}).then(function(e){m.webAssemblyTimeStart=performance.now(),e(m),m.codeDownloadTimeEnd=performance.now()-o}),performance.now()),a=(T(t="dataUrl"),e=m.cacheControl(m[t]),n=m.companyName&&m.productName?m.cachedFetch:m.fetchWithProgress,s=m[t],r=/file:\/\//.exec(s)?"same-origin":void 0,n(m[t],{method:"GET",companyName:m.companyName,productName:m.productName,productVersion:m.productVersion,control:e,mode:r,onProgress:function(e){T(t,e)}}).then(function(e){var t,n,r,o,a,i;return A.gzip.hasUnityMarker(e.parsedBody)&&(t=["gzip","gzip"]),(t=A.br.hasUnityMarker(e.parsedBody)?["brotli","br"]:t)&&(n=e.headers.get("Content-Type"),r=e.headers.get("Content-Encoding"),a=0<(o=e.headers.get("Content-Length"))&&e.parsedBody.length!=o,i=0<o&&e.parsedBody.length==o,r!=t[1]?c("Failed to parse binary data file "+s+' (with "Content-Type: '+n+'"), because it is still '+t[0]+'-compressed. It should have been uncompressed by the browser, but it was unable to do so since the web server provided the compressed content without specifying the HTTP Response Header "Content-Encoding: '+t[1]+'" that would have informed the browser that decompression is needed. Please verify your web server hosting configuration to add the missing "Content-Encoding: '+t[1]+'" HTTP Response Header.',"error"):c(a?"Web server configuration error: it looks like the web server has been misconfigured to double-compress the data file "+s+"! That is, it looks like the web browser has decompressed the file, but it is still in compressed form, suggesting that an already compressed file was compressed a second time. (Content-Length: "+o+", obtained length: "+e.parsedBody.length+")":i?/^((?!chrome|android).)*safari/i.test(navigator.userAgent)&&"gzip"==r&&"application/octet-stream"==n?"Unable to load content due to Apple Safari bug https://bugs.webkit.org/show_bug.cgi?id=247421 . To work around this issue, please reconfigure your web server to serve "+s+" with Content-Type: application/gzip instead of Content-Type: application/octet-stream":"Malformed binary data? Received compressed data file "+s+', with "Content-Type: '+n+'", "Content-Encoding: '+t[1]+'", "Content-Length: '+o+'", which the web browser should have decompressed, but it seemingly did not (received file size is the same as compressed file size was). Double check that the integrity of the file is intact.':"Malformed binary data URL "+s+'. No "Content-Length" HTTP Response header present. Check browser console for more information.',"error"),console.error("Malformed data? Downloaded binary data file "+s+" (ArrayBuffer size: "+e.parsedBody.length+") and browser should have decompressed it, but it might have not. Dumping raw HTTP Response Headers if it might help debug:"),e.headers.forEach(function(e,t){console.error(t+": "+e)})),e.parsedBody}).catch(function(e){var t="Failed to download file "+s;"file:"==location.protocol?c(t+". Loading web pages via a file:// URL without a web server is not supported by this browser. Please use a local development web server to host Unity content, or use the Unity Build and Run option.","error"):console.error(t)}));m.preRun.push(function(){m.addRunDependency("dataUrl"),a.then(function(t){var e=new TextDecoder("utf-8"),n=0;function r(){var e=(t[n]|t[n+1]<<8|t[n+2]<<16|t[n+3]<<24)>>>0;return n+=4,e}function o(e){if(A.gzip.hasUnityMarker(t))throw e+'. Failed to parse binary data file, because it is still gzip-compressed and should have been uncompressed by the browser. Web server has likely provided gzip-compressed data without specifying the HTTP Response Header "Content-Encoding: gzip" with it to instruct the browser to decompress it. Please verify your web server hosting configuration.';if(A.br.hasUnityMarker(t))throw e+'. Failed to parse binary data file, because it is still brotli-compressed and should have been uncompressed by the browser. Web server has likely provided brotli-compressed data without specifying the HTTP Response Header "Content-Encoding: br" with it to instruct the browser to decompress it. Please verify your web server hosting configuration.';throw e}var a="UnityWebData1.0\0",i=e.decode(t.subarray(0,a.length)),s=(i!=a&&o('Unknown data format (id="'+i+'")'),n+=a.length,r());for(n+s>t.length&&o("Invalid binary data file header! (pos="+n+", headerSize="+s+", file length="+t.length+")");n<s;){var d=r(),c=r(),l=(d+c>t.length&&o("Invalid binary data file size! (offset="+d+", size="+c+", file length="+t.length+")"),r()),u=(n+l>t.length&&o("Invalid binary data file path name! (pos="+n+", length="+l+", file length="+t.length+")"),e.decode(t.subarray(n,n+l)));n+=l;for(var h=0,f=u.indexOf("/",h)+1;0<f;h=f,f=u.indexOf("/",h)+1)m.FS_createPath(u.substring(0,h),u.substring(h,f-1),!0,!0);m.FS_createDataFile(u,null,t.subarray(d,d+c),!0,!0,!0)}m.removeRunDependency("dataUrl"),m.dataUrlLoadEndTime=performance.now()-p})})}return new Promise(function(e,t){var n;m.SystemInfo.hasWebGL?1==m.SystemInfo.hasWebGL?(n='Your browser does not support graphics API "WebGL 2" which is required for this content.',"Safari"==m.SystemInfo.browser&&parseInt(m.SystemInfo.browserVersion)<15&&(m.SystemInfo.mobile||1<navigator.maxTouchPoints?n+="\nUpgrade to iOS 15 or later.":n+="\nUpgrade to Safari 15 or later."),t(n)):m.SystemInfo.hasWasm?m.SystemInfo.hasWasm2023?(m.startupErrorHandler=t,d(0),m.postRun.push(function(){d(1),m.WebPlayer.WaitForInitialization().then(function(){delete m.startupErrorHandler,e(C),m.pageStartupTime=performance.now()})}),new Promise(function(t,e){navigator.gpu?navigator.gpu.requestAdapter().then(function(e){m.SystemInfo.hasWebGPU=!!e,t(m.SystemInfo.hasWebGPU)}):t(!1)}).then(function(){D()})):t("Your browser does not support WebAssembly 2023. Please update to Chrome \u2265 91 (May 2021), Firefox \u2265 89 (June 2021) or Safari \u2265 16.4 (March 2023). (failed "+m.SystemInfo.missingWasm2023Feature+")"):t("Your browser does not support WebAssembly."):t("Your browser does not support WebGL.")})}
|
|
1
|
+
function createUnityInstance(t,n,d){function c(e,t){if(!c.aborted&&n.showBanner)return"error"==t&&(c.aborted=!0),n.showBanner(e,t);switch(t){case"error":console.error(e);break;case"warning":console.warn(e);break;default:console.log(e)}}function r(e){var t=e.reason||e.error,n=t?t.toString():e.message||e.reason||"",r=t&&t.stack?t.stack.toString():"";(n+="\n"+(r=r.startsWith(n)?r.substring(n.length):r).trim())&&m.stackTraceRegExp&&m.stackTraceRegExp.test(n)&&P(n,e.filename||t&&(t.fileName||t.sourceURL)||"",e.lineno||t&&(t.lineNumber||t.line)||0)}function e(e,t,n){var r=e[t];void 0!==r&&r||(console.warn('Config option "'+t+'" is missing or empty. Falling back to default value: "'+n+'". Consider updating your WebGL template to include the missing config option.'),e[t]=n)}d=d||function(){};var o,m={canvas:t,webglContextAttributes:{preserveDrawingBuffer:!1,powerPreference:2},wasmFileSize:44137915,cacheControl:function(e){return e==m.dataUrl||e.match(/\.bundle/)?"must-revalidate":"no-store"},streamingAssetsUrl:"StreamingAssets",downloadProgress:{},deinitializers:[],intervals:{},setInterval:function(e,t){e=window.setInterval(e,t);return this.intervals[e]=!0,e},clearInterval:function(e){delete this.intervals[e],window.clearInterval(e)},preRun:[],postRun:[],print:function(e){console.log(e)},printErr:function(e){console.error(e),"string"==typeof e&&-1!=e.indexOf("wasm streaming compile failed")&&(-1!=e.toLowerCase().indexOf("mime")?c('HTTP Response Header "Content-Type" configured incorrectly on the server for file '+m.codeUrl+' , should be "application/wasm". Startup time performance will suffer.',"warning"):c('WebAssembly streaming compilation failed! This can happen for example if "Content-Encoding" HTTP header is incorrectly enabled on the server for file '+m.codeUrl+", but the file is not pre-compressed on disk (or vice versa). Check the Network tab in browser Devtools to debug server header configuration.","warning"))},locateFile:function(e){return"build.wasm"==e?this.codeUrl:e},disabledCanvasEvents:["contextmenu","dragstart"]};for(o in e(n,"companyName","Unity"),e(n,"productName","WebGL Player"),e(n,"productVersion","1.0"),n)m[o]=n[o];m.streamingAssetsUrl=new URL(m.streamingAssetsUrl,document.URL).href;var a=m.disabledCanvasEvents.slice();function i(e){e.preventDefault()}a.forEach(function(e){t.addEventListener(e,i)}),window.addEventListener("error",r),window.addEventListener("unhandledrejection",r);var s="",l="";function u(e){document.webkitCurrentFullScreenElement===t?t.style.width&&(s=t.style.width,l=t.style.height,t.style.width="100%",t.style.height="100%"):s&&(t.style.width=s,t.style.height=l,l=s="")}document.addEventListener("webkitfullscreenchange",u),m.deinitializers.push(function(){for(var e in m.disableAccessToMediaDevices(),a.forEach(function(e){t.removeEventListener(e,i)}),window.removeEventListener("error",r),window.removeEventListener("unhandledrejection",r),document.removeEventListener("webkitfullscreenchange",u),m.intervals)window.clearInterval(e);m.intervals={}}),m.QuitCleanup=function(){for(var e=0;e<m.deinitializers.length;e++)m.deinitializers[e]();m.deinitializers=[],"function"==typeof m.onQuit&&m.onQuit()};var h,f,p,g,b,w,y,v,S,C={Module:m,SetFullscreen:function(){if(m.SetFullscreen)return m.SetFullscreen.apply(m,arguments);m.print("Failed to set Fullscreen mode: Player not loaded yet.")},SendMessage:function(){if(m.SendMessage)return m.SendMessage.apply(m,arguments);m.print("Failed to execute SendMessage: Player not loaded yet.")},Quit:function(){return new Promise(function(e,t){m.shouldQuit=!0,m.onQuit=e})},GetMetricsInfo:function(){var e=Number(m._getMetricsInfo())>>>0,t=4+e,n=4+t,r=8+n,o=8+r,a=4+o,i=4+a,s=8+i,d=8+s,c=4+d,l=4+c,u=4+l;return{totalWASMHeapSize:m.HEAPU32[e>>2],usedWASMHeapSize:m.HEAPU32[t>>2],totalJSHeapSize:m.HEAPF64[n>>3],usedJSHeapSize:m.HEAPF64[r>>3],pageLoadTime:m.HEAPU32[o>>2],pageLoadTimeToFrame1:m.HEAPU32[a>>2],fps:m.HEAPF64[i>>3],movingAverageFps:m.HEAPF64[s>>3],assetLoadTime:m.HEAPU32[d>>2],webAssemblyStartupTime:m.HEAPU32[c>>2]-(m.webAssemblyTimeStart||0),codeDownloadTime:m.HEAPU32[l>>2],gameStartupTime:m.HEAPU32[u>>2],numJankedFrames:m.HEAPU32[4+u>>2]}}};function P(e,t,n){-1==e.indexOf("fullscreen error")&&(m.startupErrorHandler?m.startupErrorHandler(e,t,n):m.errorHandler&&m.errorHandler(e,t,n)||(console.log("Invoking error handler due to\n"+e),"function"==typeof dump&&dump("Invoking error handler due to\n"+e),P.didShowErrorMessage||(-1!=(e="An error occurred running the Unity content on this page. See your browser JavaScript console for more info. The error was:\n"+e).indexOf("DISABLE_EXCEPTION_CATCHING")?e="An exception has occurred, but exception handling has been disabled in this build. If you are the developer of this content, enable exceptions in your project WebGL player settings to be able to catch the exception or see the stack trace.":-1!=e.indexOf("Cannot enlarge memory arrays")?e="Out of memory. If you are the developer of this content, try allocating more memory to your WebGL build in the WebGL player settings.":-1==e.indexOf("Invalid array buffer length")&&-1==e.indexOf("Invalid typed array length")&&-1==e.indexOf("out of memory")&&-1==e.indexOf("could not allocate memory")||(e="The browser could not allocate enough memory for the WebGL content. If you are the developer of this content, try allocating less memory to your WebGL build in the WebGL player settings."),alert(e),P.didShowErrorMessage=!0)))}function T(e,t){if("symbolsUrl"!=e){var n=m.downloadProgress[e],r=(n=n||(m.downloadProgress[e]={started:!1,finished:!1,lengthComputable:!1,total:0,loaded:0}),"object"!=typeof t||"progress"!=t.type&&"load"!=t.type||(n.started||(n.started=!0,n.lengthComputable=t.lengthComputable),n.total=t.total,n.loaded=t.loaded,"load"==t.type&&(n.finished=!0)),0),o=0,a=0,i=0,s=0;for(e in m.downloadProgress){if(!(n=m.downloadProgress[e]).started)return;a++,n.lengthComputable?(r+=n.loaded,o+=n.total,i++):n.finished||s++}d(.9*(a?(a-s-(o?i*(o-r)/o:0))/a:0))}}function E(){var e=this;this.isConnected=this.connect().then(function(){return e.cleanUpCache()}),this.isConnected.catch(function(e){e="Error when initializing cache: "+e,console.log("[UnityCache] "+e)})}function U(e){console.log("[UnityCache] "+e)}function k(e){return k.link=k.link||document.createElement("a"),k.link.href=e,k.link.href}m.SystemInfo=function(){var e,t,n,r,o,a=navigator.userAgent+" ",i=[["Firefox","Firefox"],["OPR","Opera"],["Edg","Edge"],["SamsungBrowser","Samsung Browser"],["Trident","Internet Explorer"],["MSIE","Internet Explorer"],["Chrome","Chrome"],["CriOS","Chrome on iOS Safari"],["FxiOS","Firefox on iOS Safari"],["Safari","Safari"]];function s(e,t,n){return(e=RegExp(e,"i").exec(t))&&e[n]}for(var d=0;d<i.length;++d)if(t=s(i[d][0]+"[/ ](.*?)[ \\)]",a,1)){e=i[d][1];break}"Safari"==e&&(t=s("Version/(.*?) ",a,1)),"Internet Explorer"==e&&(t=s("rv:(.*?)\\)? ",a,1)||t);for(var c=[["Windows (.*?)[;)]","Windows"],["Android ([0-9_.]+)","Android"],["iPhone OS ([0-9_.]+)","iPhoneOS"],["iPad.*? OS ([0-9_.]+)","iPadOS"],["FreeBSD( )","FreeBSD"],["OpenBSD( )","OpenBSD"],["Linux|X11()","Linux"],["Mac OS X ([0-9_\\.]+)","MacOS"],["bot|google|baidu|bing|msn|teoma|slurp|yandex","Search Bot"]],l=0;l<c.length;++l)if(r=s(c[l][0],a,1)){n=c[l][1],r=r.replace(/_/g,".");break}var u;function h(){try{return window.WebAssembly?WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,3,1,0,1,10,13,1,11,0,65,0,65,0,65,1,252,11,0,11]))?WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,11,1,9,1,1,125,32,0,252,0,26,11]))?WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,10,1,8,1,1,126,32,0,194,26,11]))?WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,9,1,7,0,65,0,253,15,26,11]))?!!WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,10,1,8,0,6,64,1,25,1,11,11]))||"wasm-exceptions":"wasm-simd128":"sign-extend":"non-trapping fp-to-int":"bulk-memory":"WebAssembly"}catch(e){return"Exception: "+e}}r={"NT 5.0":"2000","NT 5.1":"XP","NT 5.2":"Server 2003","NT 6.0":"Vista","NT 6.1":"7","NT 6.2":"8","NT 6.3":"8.1","NT 10.0":"10"}[r]||r,webgpuVersion=0,(f=document.createElement("canvas"))&&(u=(p=f.getContext("webgl2"))?2:0,p||(p=f&&f.getContext("webgl"))&&(u=1),p&&(o=p.getExtension("WEBGL_debug_renderer_info")&&p.getParameter(37446)||p.getParameter(7937)),webgpuVersion=navigator.gpu?1:0);var f="undefined"!=typeof SharedArrayBuffer,p="object"==typeof WebAssembly&&"function"==typeof WebAssembly.compile,m=p&&!0===h();return{width:screen.width,height:screen.height,userAgent:a.trim(),browser:e||"Unknown browser",browserVersion:t||"Unknown version",mobile:/Mobile|Android|iP(ad|hone)/.test(navigator.appVersion),os:n||"Unknown OS",osVersion:r||"Unknown OS Version",gpu:o||"Unknown GPU",language:navigator.userLanguage||navigator.language,hasWebGL:u,hasWebGPU:webgpuVersion,hasCursorLock:!!document.body.requestPointerLock,hasFullscreen:!!document.body.requestFullscreen||!!document.body.webkitRequestFullscreen,hasThreads:f,hasWasm:p,hasWasm2023:m,missingWasm2023Feature:m?null:h(),hasWasmThreads:!1}}(),m.abortHandler=function(e){return P(e,"",0),!0},Error.stackTraceLimit=Math.max(Error.stackTraceLimit||0,50),m.readBodyWithProgress=function(a,i,s){var e=a.body?a.body.getReader():void 0,d=void 0!==a.headers.get("Content-Length"),c=function(e,t){if(!t)return 0;var t=e.headers.get("Content-Encoding"),n=parseInt(e.headers.get("Content-Length")),r=536870912;switch(t){case"br":return Math.min(Math.round(2*n),r);case"gzip":return Math.min(Math.round(1.6*n),r);default:return n}}(a,d),l=new Uint8Array(c),u=[],h=0,f=0;return d||console.warn("[UnityCache] Response is served without Content-Length header. Please reconfigure server to include valid Content-Length for better download performance."),function o(){return void 0===e?a.arrayBuffer().then(function(e){var t=new Uint8Array(e);return i({type:"progress",response:a,total:e.length,loaded:0,lengthComputable:d,chunk:s?t:null}),t}):e.read().then(function(e){if(e.done){if(h===c)return l;if(h<c)return l.slice(0,h);for(var t=new Uint8Array(h),n=(t.set(l,0),f),r=0;r<u.length;++r)t.set(u[r],n),n+=u[r].length;return t}return h+e.value.length<=l.length?(l.set(e.value,h),f=h+e.value.length):u.push(e.value),h+=e.value.length,i({type:"progress",response:a,total:Math.max(c,h),loaded:h,lengthComputable:d,chunk:s?e.value:null}),o()})}().then(function(e){return i({type:"load",response:a,total:e.length,loaded:e.length,lengthComputable:d,chunk:null}),a.parsedBody=e,a})},m.fetchWithProgress=function(e,t){var n=function(){};return t&&t.onProgress&&(n=t.onProgress),fetch(e,t).then(function(e){return m.readBodyWithProgress(e,n,t.enableStreamingDownload)})},m.UnityCache=(h={name:"UnityCache",version:4},f={name:"RequestMetaDataStore",version:1},p="RequestStore",g="WebAssembly",b=window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB,w=null,E.getInstance=function(){return w=w||new E},E.destroyInstance=function(){return w?w.close().then(function(){w=null}):Promise.resolve()},E.prototype.clearCache=function(){var r=this;return this.isConnected.then(function(){return r.execute(f.name,"clear",[])}).then(function(){return r.cache.keys()}).then(function e(t){var n;return 0===t.length?Promise.resolve():(n=t.pop(),r.cache.delete(n).then(function(){return e(t)}))})},E.UnityCacheDatabase=h,E.RequestMetaDataStore=f,E.MaximumCacheSize=1073741824,E.prototype.loadRequest=function(e){var t=this;return t.isConnected.then(function(){return Promise.all([t.cache.match(e),t.loadRequestMetaData(e)])}).then(function(e){if(void 0!==e[0]&&void 0!==e[1])return{response:e[0],metaData:e[1]}})},E.prototype.loadRequestMetaData=function(e){e="string"==typeof e?e:e.url;return this.execute(f.name,"get",[e])},E.prototype.updateRequestMetaData=function(e){return this.execute(f.name,"put",[e])},E.prototype.storeRequest=function(e,t){var n=this;return n.isConnected.then(function(){return n.cache.put(e,t)})},E.prototype.close=function(){return this.isConnected.then(function(){this.database&&(this.database.close(),this.database=null),this.cache&&(this.cache=null)}.bind(this))},E.prototype.connect=function(){var o=this;return void 0===b?Promise.reject(new Error("Could not connect to cache: IndexedDB is not supported.")):void 0===window.caches?Promise.reject(new Error("Could not connect to cache: Cache API is not supported.")):new Promise(function(t,n){try{function r(){o.openDBTimeout&&(clearTimeout(o.openDBTimeout),o.openDBTimeout=null)}o.openDBTimeout=setTimeout(function(){void 0===o.database&&n(new Error("Could not connect to cache: Database timeout."))},2e4);var e=b.open(h.name,h.version);e.onupgradeneeded=o.upgradeDatabase.bind(o),e.onsuccess=function(e){r(),o.database=e.target.result,t()},e.onerror=function(e){r(),o.database=null,n(new Error("Could not connect to database."))}}catch(e){r(),o.database=null,o.cache=null,n(new Error("Could not connect to cache: Could not connect to database."))}}).then(function(){var e=h.name+"_"+m.companyName+"_"+m.productName;return caches.open(e)}).then(function(e){o.cache=e})},E.prototype.upgradeDatabase=function(e){var t,e=e.target.result;e.objectStoreNames.contains(f.name)||(t=e.createObjectStore(f.name,{keyPath:"url"}),["accessedAt","updatedAt"].forEach(function(e){t.createIndex(e,e)})),e.objectStoreNames.contains(p)&&e.deleteObjectStore(p),e.objectStoreNames.contains(g)&&e.deleteObjectStore(g)},E.prototype.execute=function(a,i,s){return this.isConnected.then(function(){return new Promise(function(t,n){try{var e,r,o;null===this.database?n(new Error("indexedDB access denied")):(e=-1!=["put","delete","clear"].indexOf(i)?"readwrite":"readonly",r=this.database.transaction([a],e).objectStore(a),"openKeyCursor"==i&&(r=r.index(s[0]),s=s.slice(1)),(o=r[i].apply(r,s)).onsuccess=function(e){t(e.target.result)},o.onerror=function(e){n(e)})}catch(e){n(e)}}.bind(this))}.bind(this))},E.prototype.getMetaDataEntries=function(){var r=this,o=0,a=[];return new Promise(function(t,n){var e=r.database.transaction([f.name],"readonly").objectStore(f.name).openCursor();e.onsuccess=function(e){e=e.target.result;e?(o+=e.value.size,a.push(e.value),e.continue()):t({metaDataEntries:a,cacheSize:o})},e.onerror=function(e){n(e)}})},E.prototype.cleanUpCache=function(){var i=this;return this.getMetaDataEntries().then(function(e){for(var t=e.metaDataEntries,n=e.cacheSize,r=[],o=[],a=0;a<t.length;++a)t[a].version==m.productVersion?o.push(t[a]):(r.push(t[a]),n-=t[a].size);o.sort(function(e,t){return e.accessedAt-t.accessedAt});for(a=0;a<o.length&&!(n<E.MaximumCacheSize);++a)r.push(o[a]),n-=o[a].size;return function e(){var t;return 0===r.length?Promise.resolve():(t=r.pop(),i.cache.delete(t.url).then(function(e){if(e)return r=t.url,new Promise(function(e,t){var n=i.database.transaction([f.name],"readwrite");n.objectStore(f.name).delete(r),n.oncomplete=e,n.onerror=t});var r}).then(e))}()})},E),m.cachedFetch=(y=m.UnityCache,v=m.fetchWithProgress,S=m.readBodyWithProgress,function(o,a){var e,t,i=y.getInstance(),s=k("string"==typeof o?o:o.url),d={enabled:(e=s,(!(t=a)||!t.method||"GET"===t.method)&&((!t||-1!=["must-revalidate","immutable"].indexOf(t.control))&&!!e.match("^https?://")))};function c(n,r){return fetch(n,r).then(function(e){var t;return!d.enabled||d.revalidated?e:304===e.status?(d.revalidated=!0,i.updateRequestMetaData(d.metaData).then(function(){U("'"+d.metaData.url+"' successfully revalidated and served from the browser cache")}).catch(function(e){U("'"+d.metaData.url+"' successfully revalidated but not stored in the browser cache due to the error: "+e)}),S(d.response,r.onProgress,r.enableStreamingDownload)):200==e.status?(d.response=e,d.metaData.updatedAt=d.metaData.accessedAt,d.revalidated=!0,t=e.clone(),S(e,r.onProgress,r.enableStreamingDownload).then(function(e){return d.metaData.size=e.parsedBody.length,Promise.all([i.storeRequest(n,t),i.updateRequestMetaData(d.metaData)]).then(function(){U("'"+s+"' successfully downloaded and stored in the browser cache")}).catch(function(e){U("'"+s+"' successfully downloaded but not stored in the browser cache due to the error: "+e)}),e})):(U("'"+s+"' request failed with status: "+e.status+" "+e.statusText),S(e,r.onProgress,r.enableStreamingDownload))})}return a&&(d.control=a.control,d.companyName=a.companyName,d.productName=a.productName,d.productVersion=a.productVersion),d.revalidated=!1,d.metaData={url:s,accessedAt:Date.now(),version:d.productVersion},d.response=null,d.enabled?i.loadRequest(s).then(function(e){var n,r,t;return e?(n=e.response,r=e.metaData,d.response=n,d.metaData.size=r.size,d.metaData.updatedAt=r.updatedAt,"immutable"==d.control?(d.revalidated=!0,i.updateRequestMetaData(r).then(function(){U("'"+d.metaData.url+"' served from the browser cache without revalidation")}),S(n,a.onProgress,a.enableStreamingDownload)):(e=s,(t=window.location.href.match(/^[a-z]+:\/\/[^\/]+/))&&!e.lastIndexOf(t[0],0)||!n.headers.get("Last-Modified")&&!n.headers.get("ETag")?(e=(a=a||{}).headers||{},a.headers=e,n.headers.get("Last-Modified")?(e["If-Modified-Since"]=n.headers.get("Last-Modified"),e["Cache-Control"]="no-cache"):n.headers.get("ETag")&&(e["If-None-Match"]=n.headers.get("ETag"),e["Cache-Control"]="no-cache"),c(o,a)):fetch(s,{method:"HEAD"}).then(function(t){return d.revalidated=["Last-Modified","ETag"].every(function(e){return!n.headers.get(e)||n.headers.get(e)==t.headers.get(e)}),d.revalidated?(i.updateRequestMetaData(r).then(function(){U("'"+d.metaData.url+"' successfully revalidated and served from the browser cache")}),S(d.response,a.onProgress,a.enableStreamingDownload)):c(o,a)}))):c(o,a)}).catch(function(e){return U("Failed to load '"+d.metaData.url+"' from browser cache due to the error: "+e),v(o,a)}):v(o,a)});var A={gzip:{hasUnityMarker:function(e){var t=10,n="UnityWeb Compressed Content (gzip)";if(t>e.length||31!=e[0]||139!=e[1])return!1;var r=e[3];if(4&r){if(t+2>e.length)return!1;if((t+=2+e[t]+(e[t+1]<<8))>e.length)return!1}if(8&r){for(;t<e.length&&e[t];)t++;if(t+1>e.length)return!1;t++}return 16&r&&String.fromCharCode.apply(null,e.subarray(t,t+n.length+1))==n+"\0"}},br:{hasUnityMarker:function(e){var t="UnityWeb Compressed Content (brotli)";if(!e.length)return!1;var n=1&e[0]?14&e[0]?4:7:1,r=e[0]&(1<<n)-1,o=1+(Math.log(t.length-1)/Math.log(2)>>3);if(commentOffset=1+n+2+1+2+(o<<3)+7>>3,17==r||commentOffset>e.length)return!1;for(var a=r+(6+(o<<4)+(t.length-1<<6)<<n),i=0;i<commentOffset;i++,a>>>=8)if(e[i]!=(255&a))return!1;return String.fromCharCode.apply(null,e.subarray(commentOffset,commentOffset+t.length))==t}}};function D(){var t,e,n,s,r,o=performance.now(),p=(new Promise(function(a,e){var i=document.createElement("script");i.src=m.frameworkUrl,i.onload=function(){if("undefined"==typeof unityFramework||!unityFramework){var e,t=[["br","br"],["gz","gzip"]];for(e in t){var n,r=t[e];if(m.frameworkUrl.endsWith("."+r[0]))return n="Unable to parse "+m.frameworkUrl+"!","file:"==location.protocol?void c(n+" Loading pre-compressed (brotli or gzip) content via a file:// URL without a web server is not supported by this browser. Please use a local development web server to host compressed Unity content, or use the Unity Build and Run option.","error"):(n+=' This can happen if build compression was enabled but web server hosting the content was misconfigured to not serve the file with HTTP Response Header "Content-Encoding: '+r[1]+'" present. Check browser Console and Devtools Network tab to debug.',"br"==r[0]&&"http:"==location.protocol&&(r=-1!=["localhost","127.0.0.1"].indexOf(location.hostname)?"":"Migrate your server to use HTTPS.",n=/Firefox/.test(navigator.userAgent)?"Unable to parse "+m.frameworkUrl+'!<br>If using custom web server, verify that web server is sending .br files with HTTP Response Header "Content-Encoding: br". Brotli compression may not be supported in Firefox over HTTP connections. '+r+' See <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1670675">https://bugzilla.mozilla.org/show_bug.cgi?id=1670675</a> for more information.':"Unable to parse "+m.frameworkUrl+'!<br>If using custom web server, verify that web server is sending .br files with HTTP Response Header "Content-Encoding: br". Brotli compression may not be supported over HTTP connections. Migrate your server to use HTTPS.'),void c(n,"error"))}c("Unable to parse "+m.frameworkUrl+"! The file is corrupt, or compression was misconfigured? (check Content-Encoding HTTP Response Header on web server)","error")}var o=unityFramework;unityFramework=null,i.onload=null,a(o)},i.onerror=function(e){c("Unable to load file "+m.frameworkUrl+"! Check that the file exists on the remote server. (also check browser Console and Devtools Network tab to debug)","error")},document.body.appendChild(i),m.deinitializers.push(function(){document.body.removeChild(i)})}).then(function(e){m.webAssemblyTimeStart=performance.now(),e(m),m.codeDownloadTimeEnd=performance.now()-o}),performance.now()),a=(T(t="dataUrl"),e=m.cacheControl(m[t]),n=m.companyName&&m.productName?m.cachedFetch:m.fetchWithProgress,s=m[t],r=/file:\/\//.exec(s)?"same-origin":void 0,n(m[t],{method:"GET",companyName:m.companyName,productName:m.productName,productVersion:m.productVersion,control:e,mode:r,onProgress:function(e){T(t,e)}}).then(function(e){var t,n,r,o,a,i;return A.gzip.hasUnityMarker(e.parsedBody)&&(t=["gzip","gzip"]),(t=A.br.hasUnityMarker(e.parsedBody)?["brotli","br"]:t)&&(n=e.headers.get("Content-Type"),r=e.headers.get("Content-Encoding"),a=0<(o=e.headers.get("Content-Length"))&&e.parsedBody.length!=o,i=0<o&&e.parsedBody.length==o,r!=t[1]?c("Failed to parse binary data file "+s+' (with "Content-Type: '+n+'"), because it is still '+t[0]+'-compressed. It should have been uncompressed by the browser, but it was unable to do so since the web server provided the compressed content without specifying the HTTP Response Header "Content-Encoding: '+t[1]+'" that would have informed the browser that decompression is needed. Please verify your web server hosting configuration to add the missing "Content-Encoding: '+t[1]+'" HTTP Response Header.',"error"):c(a?"Web server configuration error: it looks like the web server has been misconfigured to double-compress the data file "+s+"! That is, it looks like the web browser has decompressed the file, but it is still in compressed form, suggesting that an already compressed file was compressed a second time. (Content-Length: "+o+", obtained length: "+e.parsedBody.length+")":i?/^((?!chrome|android).)*safari/i.test(navigator.userAgent)&&"gzip"==r&&"application/octet-stream"==n?"Unable to load content due to Apple Safari bug https://bugs.webkit.org/show_bug.cgi?id=247421 . To work around this issue, please reconfigure your web server to serve "+s+" with Content-Type: application/gzip instead of Content-Type: application/octet-stream":"Malformed binary data? Received compressed data file "+s+', with "Content-Type: '+n+'", "Content-Encoding: '+t[1]+'", "Content-Length: '+o+'", which the web browser should have decompressed, but it seemingly did not (received file size is the same as compressed file size was). Double check that the integrity of the file is intact.':"Malformed binary data URL "+s+'. No "Content-Length" HTTP Response header present. Check browser console for more information.',"error"),console.error("Malformed data? Downloaded binary data file "+s+" (ArrayBuffer size: "+e.parsedBody.length+") and browser should have decompressed it, but it might have not. Dumping raw HTTP Response Headers if it might help debug:"),e.headers.forEach(function(e,t){console.error(t+": "+e)})),e.parsedBody}).catch(function(e){var t="Failed to download file "+s;"file:"==location.protocol?c(t+". Loading web pages via a file:// URL without a web server is not supported by this browser. Please use a local development web server to host Unity content, or use the Unity Build and Run option.","error"):console.error(t)}));m.preRun.push(function(){m.addRunDependency("dataUrl"),a.then(function(t){var e=new TextDecoder("utf-8"),n=0;function r(){var e=(t[n]|t[n+1]<<8|t[n+2]<<16|t[n+3]<<24)>>>0;return n+=4,e}function o(e){if(A.gzip.hasUnityMarker(t))throw e+'. Failed to parse binary data file, because it is still gzip-compressed and should have been uncompressed by the browser. Web server has likely provided gzip-compressed data without specifying the HTTP Response Header "Content-Encoding: gzip" with it to instruct the browser to decompress it. Please verify your web server hosting configuration.';if(A.br.hasUnityMarker(t))throw e+'. Failed to parse binary data file, because it is still brotli-compressed and should have been uncompressed by the browser. Web server has likely provided brotli-compressed data without specifying the HTTP Response Header "Content-Encoding: br" with it to instruct the browser to decompress it. Please verify your web server hosting configuration.';throw e}var a="UnityWebData1.0\0",i=e.decode(t.subarray(0,a.length)),s=(i!=a&&o('Unknown data format (id="'+i+'")'),n+=a.length,r());for(n+s>t.length&&o("Invalid binary data file header! (pos="+n+", headerSize="+s+", file length="+t.length+")");n<s;){var d=r(),c=r(),l=(d+c>t.length&&o("Invalid binary data file size! (offset="+d+", size="+c+", file length="+t.length+")"),r()),u=(n+l>t.length&&o("Invalid binary data file path name! (pos="+n+", length="+l+", file length="+t.length+")"),e.decode(t.subarray(n,n+l)));n+=l;for(var h=0,f=u.indexOf("/",h)+1;0<f;h=f,f=u.indexOf("/",h)+1)m.FS_createPath(u.substring(0,h),u.substring(h,f-1),!0,!0);m.FS_createDataFile(u,null,t.subarray(d,d+c),!0,!0,!0)}m.removeRunDependency("dataUrl"),m.dataUrlLoadEndTime=performance.now()-p})})}return new Promise(function(e,t){var n;m.SystemInfo.hasWebGL?1==m.SystemInfo.hasWebGL?(n='Your browser does not support graphics API "WebGL 2" which is required for this content.',"Safari"==m.SystemInfo.browser&&parseInt(m.SystemInfo.browserVersion)<15&&(m.SystemInfo.mobile||1<navigator.maxTouchPoints?n+="\nUpgrade to iOS 15 or later.":n+="\nUpgrade to Safari 15 or later."),t(n)):m.SystemInfo.hasWasm?m.SystemInfo.hasWasm2023?(m.startupErrorHandler=t,d(0),m.postRun.push(function(){d(1),m.WebPlayer.WaitForInitialization().then(function(){delete m.startupErrorHandler,e(C),m.pageStartupTime=performance.now()})}),new Promise(function(t,e){navigator.gpu?navigator.gpu.requestAdapter().then(function(e){m.SystemInfo.hasWebGPU=!!e,t(m.SystemInfo.hasWebGPU)}):t(!1)}).then(function(){D()})):t("Your browser does not support WebAssembly 2023. Please update to Chrome \u2265 91 (May 2021), Firefox \u2265 89 (June 2021) or Safari \u2265 16.4 (March 2023). (failed "+m.SystemInfo.missingWasm2023Feature+")"):t("Your browser does not support WebAssembly."):t("Your browser does not support WebGL.")})}
|
|
Binary file
|