@dcl/wearable-preview 2.3.1-17408385203.commit-ca7430e → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -16063,7 +16063,7 @@ vReflectionMapTexCoord.z=worldPos.w;
|
|
|
16063
16063
|
#endif
|
|
16064
16064
|
#include<logDepthVertex>
|
|
16065
16065
|
}
|
|
16066
|
-
`;ce.ShadersStore[kY]=zY;var GY=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),WY=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 GY);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([ob()],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);Ae.RegisteredTypes["BABYLON.WaterMaterial"]=WY;function HY(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)}const jY=["data:EnvironmentBRDFTexture0","GlowLayerBlurRTT","GlowLayerBlurRTT2","HighlightLayerMainRTT"];function XY(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&&!jY.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 YY={};const TI=YY.REACT_APP_DEBUG;TI&&require("@babylonjs/inspector");function KY(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 qY(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):_y(t.background.color).toColor4(),e.ambientColor=new me(1,1,1),e.preventDefaultOnPointerDown=!1,t.showSceneBoundaries){const s=bv.CreateGround("ground",{width:6,height:6},e),l=bv.CreateGround("ground",{width:6,height:6},e);l.rotate(Oi.Z,Math.PI),l.position.y=-.05;const u=new EI("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=bv.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=Db.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 Ce.PreviewProjection.PERSPECTIVE:{i.mode=dt.PERSPECTIVE_CAMERA;break}case Ce.PreviewProjection.ORTHOGRAPHIC:{i.mode=dt.ORTHOGRAPHIC_CAMERA,i.orthoTop=1,i.orthoBottom=-1,i.orthoLeft=-1,i.orthoRight=1;break}}t.type===Ce.PreviewType.WEARABLE&&cI(i,t),t.camera===Ce.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===Ce.PreviewType.WEARABLE){const s=new lu("directional",new b(0,0,1),e);s.intensity=1;const l=new uu("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,!HY()){const s=new np("glow",e);s.intensity=2}return Nl.runRenderLoop(()=>{e.render()}),TI&&e.debugLayer.show({showExplorer:!0,embedMode:!0}),[e,XY(Nl,e,i)]}async function QY(n,t,e){const i=t.id,o=fu(t,e).contents.find(a=>a.key.toLowerCase().endsWith("_mask.png"));return o?new Promise((a,s)=>{const l=new $x(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 $Y(n,t,e){const i=t.id,o=fu(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 $x(i,o.url,!0,!1);l.onError=()=>s(l.errorObject),l.onSuccess=()=>{a(l.texture)},l.run(n,()=>a(l.texture),s)}):null}function ZY(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 cj("Sound task",r),a=()=>e(new $l("music",o.data,n,null,{spatialSound:!0})),s=u=>i(u);o.run(n,a,s)})}async function SI(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 JY(n){const t=new oe("parent",n);for(const a of n.meshes)a!==t&&a.setParent(t);KY(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 e6={VITE_BASE_URL:"https://cdn.decentraland.org/@dcl/wearable-preview/2.3.1-17408385203.commit-ca7430e"};const t6=[Ce.PreviewEmote.IDLE,Ce.PreviewEmote.MONEY,Ce.PreviewEmote.CLAP,Ce.PreviewEmote.WALK,Ce.PreviewEmote.RUN,Ce.PreviewEmote.JUMP];let md;function i6(n){return t6.includes(n)}function r6(n){let t=e6.VITE_BASE_URL;t.endsWith("/")||(t+="/");const e=`./emotes/${n}.glb`;return t.startsWith("http")?new URL(e,t).href:e}async function CI(n,t){const e=await SI(n,t);if(e.animationGroups.length===0)throw new Error(`No animation groups found for emote with url=${t}`);return e}async function n6(n,t,e){const i=Rb(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 CI(n,r.url)}function o6(n,t,e){const i=Rb(t,e.bodyShape);return ZY(n,i)}async function a6(n,t,e){let i,r=!!e.emote&&i6(e.emote),o=null;if(e.item&&Fo(e.item))try{i=await n6(n,e.item,e),r=e.item.emoteDataADR74.loop,o=await o6(n,e.item,e)}catch{console.warn(`Could not load emote=${e.item.id}`)}if(!i&&e.emote){const l=r6(e.emote);i=await CI(n,l)}i&&i.animationGroups.length>1&&(i.addAllToScene(),n.stopAllAnimations());const a=new sb("emote",n);function s(){if(e.camera!==Ce.PreviewCamera.STATIC){const l=n.cameras[0];cI(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=s6(a,r,o);return e.camera===Ce.PreviewCamera.STATIC&&l.stop(),l}catch(l){console.warn(`Could not play emote=${e.emote}`,l)}}function s6(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 _=rb(),g=()=>(md&&clearInterval(md),window.setInterval(async()=>{var E;if(await a()&&n.animatables[0].masterFrame>0)return _.emit(Ce.PreviewEmoteEventType.ANIMATION_PLAYING,{length:(E=n.animatables[0])==null?void 0:E.masterFrame})},10)),v=()=>{clearInterval(md),r||_.emit(Ce.PreviewEmoteEventType.ANIMATION_PLAYING,{length:n.to})};return n.onAnimationGroupPlayObservable.add(()=>(md=g(),_.emit(Ce.PreviewEmoteEventType.ANIMATION_PLAY))),n.onAnimationGroupPauseObservable.add(()=>{_.emit(Ce.PreviewEmoteEventType.ANIMATION_PAUSE)}),n.onAnimationGroupLoopObservable.add(()=>(e==null||e.stop(),e==null||e.play(),r&&(c(),u(),r=!1),_.emit(Ce.PreviewEmoteEventType.ANIMATION_LOOP))),n.onAnimationGroupEndObservable.add(()=>(v(),t||(r=!1),_.emit(Ce.PreviewEmoteEventType.ANIMATION_END))),{getLength:o,isPlaying:a,goTo:l,play:u,pause:f,stop:c,enableSound:h,disableSound:p,hasSound:s,events:_}}function l6(n,t,e){return async i=>{const r=t.find(Kj(i));return r?Promise.all([$Y(n,r,e),QY(n,r,e)]):[null,null]}}async function u6(n,t,e){const i=l6(n,t,e),[r,o,a]=await Promise.all([i(Ce.WearableCategory.EYES),i(Ce.WearableCategory.EYEBROWS),i(Ce.WearableCategory.MOUTH)]);return{eyes:r,eyebrows:o,mouth:a}}async function f6(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?jv(n,"eyes",a,s,o.eyes,l,"#ffffff"):a.setEnabled(!1)}if(a.name.toLowerCase().endsWith("mask_eyebrows")){const[s,l]=i;s?jv(n,"eyebrows",a,s,o.hair,l,o.hair):a.setEnabled(!1)}if(a.name.toLowerCase().endsWith("mask_mouth")){const[s,l]=r;s?jv(n,"mouth",a,s,o.skin,l,o.skin):a.setEnabled(!1)}}}function jv(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():_y(a),o&&(s.emissiveTexture=o,s.diffuseColor=_y(r)),e.material=s}function c6(n,t,e=Ce.BodyShape.MALE){const i={};for(const r of n)try{const o=fu(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=Rb(t,e);for(const o of r.contents)i[o.key]=o.url}return i}function h6(n){const t=is(n.item)?[n.item,...n.wearables]:n.wearables,e=Fo(n.item)?n.item:void 0,i=c6(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 d6=`float angleY = 3.14 / 2.0;
|
|
16066
|
+
`;ce.ShadersStore[kY]=zY;var GY=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),WY=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 GY);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([ob()],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);Ae.RegisteredTypes["BABYLON.WaterMaterial"]=WY;function HY(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)}const jY=["data:EnvironmentBRDFTexture0","GlowLayerBlurRTT","GlowLayerBlurRTT2","HighlightLayerMainRTT"];function XY(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&&!jY.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 YY={};const TI=YY.REACT_APP_DEBUG;TI&&require("@babylonjs/inspector");function KY(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 qY(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):_y(t.background.color).toColor4(),e.ambientColor=new me(1,1,1),e.preventDefaultOnPointerDown=!1,t.showSceneBoundaries){const s=bv.CreateGround("ground",{width:6,height:6},e),l=bv.CreateGround("ground",{width:6,height:6},e);l.rotate(Oi.Z,Math.PI),l.position.y=-.05;const u=new EI("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=bv.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=Db.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 Ce.PreviewProjection.PERSPECTIVE:{i.mode=dt.PERSPECTIVE_CAMERA;break}case Ce.PreviewProjection.ORTHOGRAPHIC:{i.mode=dt.ORTHOGRAPHIC_CAMERA,i.orthoTop=1,i.orthoBottom=-1,i.orthoLeft=-1,i.orthoRight=1;break}}t.type===Ce.PreviewType.WEARABLE&&cI(i,t),t.camera===Ce.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===Ce.PreviewType.WEARABLE){const s=new lu("directional",new b(0,0,1),e);s.intensity=1;const l=new uu("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,!HY()){const s=new np("glow",e);s.intensity=2}return Nl.runRenderLoop(()=>{e.render()}),TI&&e.debugLayer.show({showExplorer:!0,embedMode:!0}),[e,XY(Nl,e,i)]}async function QY(n,t,e){const i=t.id,o=fu(t,e).contents.find(a=>a.key.toLowerCase().endsWith("_mask.png"));return o?new Promise((a,s)=>{const l=new $x(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 $Y(n,t,e){const i=t.id,o=fu(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 $x(i,o.url,!0,!1);l.onError=()=>s(l.errorObject),l.onSuccess=()=>{a(l.texture)},l.run(n,()=>a(l.texture),s)}):null}function ZY(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 cj("Sound task",r),a=()=>e(new $l("music",o.data,n,null,{spatialSound:!0})),s=u=>i(u);o.run(n,a,s)})}async function SI(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 JY(n){const t=new oe("parent",n);for(const a of n.meshes)a!==t&&a.setParent(t);KY(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 e6={VITE_BASE_URL:"https://cdn.decentraland.org/@dcl/wearable-preview/2.4.0"};const t6=[Ce.PreviewEmote.IDLE,Ce.PreviewEmote.MONEY,Ce.PreviewEmote.CLAP,Ce.PreviewEmote.WALK,Ce.PreviewEmote.RUN,Ce.PreviewEmote.JUMP];let md;function i6(n){return t6.includes(n)}function r6(n){let t=e6.VITE_BASE_URL;t.endsWith("/")||(t+="/");const e=`./emotes/${n}.glb`;return t.startsWith("http")?new URL(e,t).href:e}async function CI(n,t){const e=await SI(n,t);if(e.animationGroups.length===0)throw new Error(`No animation groups found for emote with url=${t}`);return e}async function n6(n,t,e){const i=Rb(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 CI(n,r.url)}function o6(n,t,e){const i=Rb(t,e.bodyShape);return ZY(n,i)}async function a6(n,t,e){let i,r=!!e.emote&&i6(e.emote),o=null;if(e.item&&Fo(e.item))try{i=await n6(n,e.item,e),r=e.item.emoteDataADR74.loop,o=await o6(n,e.item,e)}catch{console.warn(`Could not load emote=${e.item.id}`)}if(!i&&e.emote){const l=r6(e.emote);i=await CI(n,l)}i&&i.animationGroups.length>1&&(i.addAllToScene(),n.stopAllAnimations());const a=new sb("emote",n);function s(){if(e.camera!==Ce.PreviewCamera.STATIC){const l=n.cameras[0];cI(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=s6(a,r,o);return e.camera===Ce.PreviewCamera.STATIC&&l.stop(),l}catch(l){console.warn(`Could not play emote=${e.emote}`,l)}}function s6(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 _=rb(),g=()=>(md&&clearInterval(md),window.setInterval(async()=>{var E;if(await a()&&n.animatables[0].masterFrame>0)return _.emit(Ce.PreviewEmoteEventType.ANIMATION_PLAYING,{length:(E=n.animatables[0])==null?void 0:E.masterFrame})},10)),v=()=>{clearInterval(md),r||_.emit(Ce.PreviewEmoteEventType.ANIMATION_PLAYING,{length:n.to})};return n.onAnimationGroupPlayObservable.add(()=>(md=g(),_.emit(Ce.PreviewEmoteEventType.ANIMATION_PLAY))),n.onAnimationGroupPauseObservable.add(()=>{_.emit(Ce.PreviewEmoteEventType.ANIMATION_PAUSE)}),n.onAnimationGroupLoopObservable.add(()=>(e==null||e.stop(),e==null||e.play(),r&&(c(),u(),r=!1),_.emit(Ce.PreviewEmoteEventType.ANIMATION_LOOP))),n.onAnimationGroupEndObservable.add(()=>(v(),t||(r=!1),_.emit(Ce.PreviewEmoteEventType.ANIMATION_END))),{getLength:o,isPlaying:a,goTo:l,play:u,pause:f,stop:c,enableSound:h,disableSound:p,hasSound:s,events:_}}function l6(n,t,e){return async i=>{const r=t.find(Kj(i));return r?Promise.all([$Y(n,r,e),QY(n,r,e)]):[null,null]}}async function u6(n,t,e){const i=l6(n,t,e),[r,o,a]=await Promise.all([i(Ce.WearableCategory.EYES),i(Ce.WearableCategory.EYEBROWS),i(Ce.WearableCategory.MOUTH)]);return{eyes:r,eyebrows:o,mouth:a}}async function f6(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?jv(n,"eyes",a,s,o.eyes,l,"#ffffff"):a.setEnabled(!1)}if(a.name.toLowerCase().endsWith("mask_eyebrows")){const[s,l]=i;s?jv(n,"eyebrows",a,s,o.hair,l,o.hair):a.setEnabled(!1)}if(a.name.toLowerCase().endsWith("mask_mouth")){const[s,l]=r;s?jv(n,"mouth",a,s,o.skin,l,o.skin):a.setEnabled(!1)}}}function jv(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():_y(a),o&&(s.emissiveTexture=o,s.diffuseColor=_y(r)),e.material=s}function c6(n,t,e=Ce.BodyShape.MALE){const i={};for(const r of n)try{const o=fu(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=Rb(t,e);for(const o of r.contents)i[o.key]=o.url}return i}function h6(n){const t=is(n.item)?[n.item,...n.wearables]:n.wearables,e=Fo(n.item)?n.item:void 0,i=c6(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 d6=`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
|
`,Xv="#include<pbrBlockFinalColorComposition>",TO="#include<customToonShading>";if(ce.ShadersStore.pbrPixelShader.includes(Xv))ce.ShadersStore.pbrPixelShader.includes(TO)||(ce.ShadersStore.pbrPixelShader=ce.ShadersStore.pbrPixelShader.replace(Xv,Xv+`
|
|
16107
16107
|
`+TO+`
|
|
16108
|
-
`));else throw new Error("could not patch the pbrPixelShader");ce.IncludesShadersStore.customToonShading=d6;async function Yv(n,t,e=Ce.BodyShape.MALE,i,r){const o=fu(t,e);if(lp(o))throw new Error(`The wearable="${t.id}" is a texture`);const a=Cj(o),s=await SI(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 p6(n,t){const[e,i]=await qY(n,t);try{h6(t);let r;const o=[];if(t.type===Ce.PreviewType.AVATAR){const s=t5(t),l=Array.from(s.values());for(const c of l.filter(uI)){const h=Yv(e,c,t.bodyShape,t.skin,t.hair).catch(p=>{console.warn(p.message)});o.push(h)}const u=(await Promise.all(o)).filter(Qj);for(const c of u)c.container.addAllToScene();const f=Zj(u);if(f){const c=l.filter($j),{eyes:h,eyebrows:p,mouth:_}=await u6(e,c,t.bodyShape);f6(e,f,h,p,_,t)}r=await a6(e,u,t)||qA()}else{const s=t.item;if(s&&!Fo(s))try{(await Yv(e,s,t.bodyShape,t.skin,t.hair)).container.addAllToScene()}catch{(await Yv(e,s,t.bodyShape===Ce.BodyShape.MALE?Ce.BodyShape.FEMALE:Ce.BodyShape.MALE,t.skin,t.hair)).container.addAllToScene()}r=qA()}return t.centerBoundingBox&&JY(e),{scene:i,emote:r}}catch(r){throw e.clearColor=new it(0,0,0,0),r}}function _6(n){const t=()=>{Ce.sendMessage(un(),Ce.PreviewMessageType.EMOTE_EVENT,{type:Ce.PreviewEmoteEventType.ANIMATION_PLAY,payload:void 0})},e=()=>{Ce.sendMessage(un(),Ce.PreviewMessageType.EMOTE_EVENT,{type:Ce.PreviewEmoteEventType.ANIMATION_PAUSE,payload:void 0})},i=()=>{Ce.sendMessage(un(),Ce.PreviewMessageType.EMOTE_EVENT,{type:Ce.PreviewEmoteEventType.ANIMATION_LOOP,payload:void 0})},r=()=>{Ce.sendMessage(un(),Ce.PreviewMessageType.EMOTE_EVENT,{type:Ce.PreviewEmoteEventType.ANIMATION_END,payload:void 0})},o=a=>{Ce.sendMessage(un(),Ce.PreviewMessageType.EMOTE_EVENT,{type:Ce.PreviewEmoteEventType.ANIMATION_PLAYING,payload:a})};return n.emote.events.on(Ce.PreviewEmoteEventType.ANIMATION_PLAY,t),n.emote.events.on(Ce.PreviewEmoteEventType.ANIMATION_PAUSE,e),n.emote.events.on(Ce.PreviewEmoteEventType.ANIMATION_LOOP,i),n.emote.events.on(Ce.PreviewEmoteEventType.ANIMATION_END,r),n.emote.events.on(Ce.PreviewEmoteEventType.ANIMATION_PLAYING,o),()=>{n.emote.events.off(Ce.PreviewEmoteEventType.ANIMATION_PLAY,t),n.emote.events.off(Ce.PreviewEmoteEventType.ANIMATION_PAUSE,e),n.emote.events.off(Ce.PreviewEmoteEventType.ANIMATION_LOOP,i),n.emote.events.off(Ce.PreviewEmoteEventType.ANIMATION_END,r),n.emote.events.off(Ce.PreviewEmoteEventType.ANIMATION_PLAYING,o)}}const m6=()=>{const[n,t]=Ct.useState(""),{width:e,height:i}=lM(),[r,o]=Ct.useState({}),[a,s]=Ct.useState(!1),[l,u]=Ct.useState(!0),[f,c]=Ct.useState(!1),h=Ct.useRef(null),p=lI(),[_,g,v]=Xj(),[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===Ce.PreviewType.TEXTURE&&(G.backgroundColor=_.background.color)),o(G),_.type===Ce.PreviewType.TEXTURE?(C(!1),u(!1),c(!0)):p6(h.current,_).then(ee=>{p.current=ee,B=_6(p.current)}).catch(ee=>t(ee.message)).finally(()=>{u(!1),c(!0)})}return()=>{B()}},[h.current,_]),Ct.useEffect(()=>{var B;O||(f?(Ce.sendMessage(un(),Ce.PreviewMessageType.LOAD,{renderer:Ce.PreviewRenderer.BABYLON}),R(!0),((_==null?void 0:_.type)===Ce.PreviewType.AVATAR||_!=null&&_.emote&&_.emote!==Ce.PreviewEmote.IDLE)&&((B=p.current)==null||B.emote.play())):M&&(Ce.sendMessage(un(),Ce.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]),sI(),Rn.jsxs("div",{className:Yl("Preview",{"is-dragging":a,"is-loading":D,"is-loaded":f,"is-3d":S&&(_==null?void 0:_.camera)===Ce.PreviewCamera.INTERACTIVE,"has-error":!!M,"no-fade-effect":_&&!_.fadeEffect}),style:r,children:[Rn.jsx("img",{src:E,className:Yl("thumbnail",{"is-visible":U}),alt:"preview"}),Rn.jsx("canvas",{id:"wearable-preview",className:Yl({"is-visible":V}),width:e,height:i,ref:h,onMouseDown:()=>s(S&&!M),onMouseUp:()=>s(!1)}),M&&Rn.jsx("div",{className:"error",children:M})]})},g6=AO.memo(m6);var PI=(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))(PI||{});const v6={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"},y6={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)},gd=(n,t,e)=>{if(n)try{const i=String(t);Object.values(PI).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}`)},b6=(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&&(gd(n,"ClearBase64"),i++,Array.isArray(t.base64s)&&t.base64s.length>0&&t.base64s.forEach(r=>{gd(n,"AddBase64",r),i++})),Object.entries(t).forEach(([r,o])=>{if(r!=="base64s"&&e[r]&&o!==void 0){const a=v6[r];if(a){const s=y6[r],l=s?s(o):String(o);gd(n,a,l),i++}else console.warn(`No Unity method mapping found for property: ${r}`)}}),i>0&&gd(n,"Reload")};var E6={VITE_BASE_URL:"https://cdn.decentraland.org/@dcl/wearable-preview/2.3.1-17408385203.commit-ca7430e"};const Kv=new Map,Fl=(n,t)=>{if(!t)return n;const e=n.replace(/\/$/,""),i=t.replace(/^\//,"");return`${e}/${i}`};function T6(n){if(Kv.has(n))return Kv.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 Kv.set(n,t),t}const S6=async(n,t,e,i,r,o,a,s,l,u,f,c)=>{try{const h=E6.VITE_BASE_URL||"";return await T6(Fl(h,t)),await createUnityInstance(n,{dataUrl:Fl(h,e),frameworkUrl:Fl(h,i),codeUrl:Fl(h,r),streamingAssetsUrl:Fl(h,a),symbolUrl:Fl(h,o),companyName:s,productName:l,productVersion:u,matchWebGLToCanvasSize:f,arguments:c})}catch(h){throw console.error("❌ Failed to load Unity instance:",h),h}};function C6(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}`)},setUsername:async t=>{n&&n.SendMessage("JSBridge","SetUsername",t)},cleanup:async()=>{n&&n.SendMessage("JSBridge","Cleanup","")}}}function P6(n){const t=rb();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(Ce.PreviewEmoteEventType.ANIMATION_PLAYING,{length:e}))},play:async()=>{n&&(n.SendMessage("JSBridge","PlayEmote",""),t.emit(Ce.PreviewEmoteEventType.ANIMATION_PLAY))},pause:async()=>{n&&(n.SendMessage("JSBridge","PauseEmote",""),t.emit(Ce.PreviewEmoteEventType.ANIMATION_PAUSE))},stop:async()=>{n&&(n.SendMessage("JSBridge","StopEmote",""),t.emit(Ce.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 A6(n){let t=null;try{if(t=await S6(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","/unity/Build/aang-renderer.symbols.json.br","/emotes","Decentraland","AangRenderer","2.0.3",!0,[]),!t)throw new Error("Failed to load Unity instance");const e=C6(t),i=P6(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 R6=()=>Math.floor(Math.random()*159)+1,AI=()=>`default${R6()}`,O6=(n,t)=>{var e,i,r,o,a,s;return{eyes:eu(t.eyes||((i=(e=n==null?void 0:n.avatar)==null?void 0:e.eyes)==null?void 0:i.color)&&tu(n.avatar.eyes.color)||"#000000"),hair:eu(t.hair||((o=(r=n==null?void 0:n.avatar)==null?void 0:r.hair)==null?void 0:o.color)&&tu(n.avatar.hair.color)||"#000000"),skin:eu(t.skin||((s=(a=n==null?void 0:n.avatar)==null?void 0:a.skin)==null?void 0:s.color)&&tu(n.avatar.skin.color)||"#cc9b76")}},nf=n=>n||"",SO=n=>n||[],vd=n=>n.replace("#","");function CO(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 M6(){const{options:n,overrideSources:t}=xb(),[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||Ff.get("PEER_URL"),E=n.nftServerUrl||Ff.get("NFT_SERVER_URL");let T=Ce.PreviewType.WEARABLE,S={color:n.background||"#4b4852",transparent:n.disableBackground===!0};const C=tI(n.profile);let O=C==null?void 0:C.value;O==="default"&&(O=AI());const R=O&&C?C.type==="address"?await rI(O,v):await nI(O,v):null,M=n.bodyShape||((_=R==null?void 0:R.avatar)==null?void 0:_.bodyShape)||Ce.BodyShape.MALE;let D=null;if(n.contractAddress&&(D=await oI({contractAddress:n.contractAddress,tokenId:n.tokenId,itemId:n.itemId,peerUrl:v,nftServerUrl:E}),D&&is(D))){S={...S,image:D.thumbnail};const Z=Ob(D);lp(Z)&&(T=Ce.PreviewType.TEXTURE)}const{eyes:U,hair:V,skin:B}=O6(R,{eyes:n.eyes,hair:n.hair,skin:n.skin}),G=n.mode||null,ee=n.camera&&Object.values(Ce.PreviewCamera).includes(n.camera)?n.camera:Ce.PreviewCamera.INTERACTIVE,q=n.projection&&Object.values(Ce.PreviewProjection).includes(n.projection)?n.projection:Ce.PreviewProjection.PERSPECTIVE,re=n.disableDefaultEmotes?null:n.emote&&Object.values(Ce.PreviewEmote).includes(n.emote)?n.emote:Ce.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=SO(n.urns),K=SO(n.base64s);if(G==="configurator"){const F={mode:nf(G||"")};CO(F)}else{const F={background:S.transparent?"":vd(S.color),disableLoader:n.disableLoader?"true":"",profile:nf(O||""),bodyShape:nf(M||""),eyeColor:vd(U||""),hairColor:vd(V||""),skinColor:vd(B||""),mode:nf(G||""),camera:ee,projection:q,emote:nf((re==null?void 0:re.toString())||""),urn:Z.length>0?Z:[""],base64:K.length>0?K:[""]};CO(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 x6="unity-renderer",I6="unity-canvas",PO=1,D6="Failed to load Unity",w6=(n,t,e,i)=>{const[r,o]=Ct.useState({isLoaded:!1,isInitialized:!1,error:null}),a=Ct.useCallback(l=>{if(l.data.type===x6){const{type:u,payload:f}=l.data.payload;u==="loaded"&&(f===!0||f==="true")?(o(c=>({...c,isLoaded:!0,isInitialized:!0})),Ce.sendMessage(un(),Ce.PreviewMessageType.LOAD,{renderer:Ce.PreviewRenderer.UNITY})):u==="customization-done"?Ce.sendMessage(un(),Ce.PreviewMessageType.CONTROLLER_RESPONSE,{id:"customization-done",ok:!0,result:JSON.parse(l.data.payload.payload)}):u==="error"&&(o(c=>({...c,error:f})),Ce.sendMessage(un(),Ce.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 A6(n.canvas.current);n.unityInstance.current=l,t.current={scene:u,emote:f},o(c=>({...c,isLoaded:!0,isInitialized:!0})),Ce.sendMessage(un(),Ce.PreviewMessageType.LOAD,{renderer:Ce.PreviewRenderer.UNITY})}catch(l){const u=l instanceof Error?l.message:D6;console.error("Unity init failed:",l),o(f=>({...f,error:u})),Ce.sendMessage(un(),Ce.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},L6=n=>{const[t,e]=Ct.useState({pixelRatio:window.devicePixelRatio||PO,is3D:!0,backgroundImage:""});return Ct.useEffect(()=>{const i=()=>{e(o=>({...o,pixelRatio:window.devicePixelRatio||PO}))},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!==Ce.PreviewType.TEXTURE}))},[n]),t},N6=(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:AI()}Object.keys(o).length>0&&(b6(n.current,o,r),t.current=o)}},[e.isInitialized,e.isLoaded,o,r,n,t])},F6=()=>{const{width:n=window.innerWidth,height:t=window.innerHeight}=lM(),e=Ct.useRef(null),i=Ct.useRef(null),r=Ct.useRef(!1),o=Ct.useRef({}),a=lI(),[s,l,u]=M6(),{options:f,overrideSources:c}=xb(),h=Ct.useMemo(()=>({canvas:e,unityInstance:i,isInitializing:r,lastSentOverrides:o}),[]),p=w6(h,a,s,l),_=L6(s);N6(h.unityInstance,h.lastSentOverrides,p,f,c),sI();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)===Ce.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(()=>Yl("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(()=>Yl("thumbnail",{"is-visible":g.showImage}),[g.showImage]),O=Ct.useMemo(()=>Yl({"is-visible":g.showCanvas}),[g.showCanvas]);return Rn.jsxs("div",{className:S,style:v,children:[Rn.jsx("img",{src:_.backgroundImage,className:C,alt:"preview"}),Rn.jsx("canvas",{ref:h.canvas,id:I6,className:O,width:T.width,height:T.height,style:E}),g.error&&Rn.jsx("div",{className:"error",children:g.error})]})},B6=AO.memo(F6),RI=Ct.createContext(null),V6=({children:n,value:t})=>{const e={webGPUSupport:t,isSupported:t.isSupported,isAvailable:t.isAvailable};return Rn.jsx(RI.Provider,{value:e,children:n})},U6=()=>{const n=Ct.useContext(RI);if(!n)throw new Error("useWebGPUContext must be used within a WebGPUProvider");return n},k6=()=>U6(),z6=()=>{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}},G6=async()=>{const{platform:n,browser:t,version:e}=z6();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}}},W6=()=>{const t=new URLSearchParams(window.location.search).get("unity")==="true",{isAvailable:e}=k6();return t&&e?Rn.jsx(B6,{}):Rn.jsx(g6,{})},H6=async()=>{const n=await G6();gw.createRoot(document.getElementById("root")).render(Rn.jsx(Ct.StrictMode,{children:Rn.jsx(V6,{value:n,children:Rn.jsx(W6,{})})}))};H6();
|
|
16108
|
+
`));else throw new Error("could not patch the pbrPixelShader");ce.IncludesShadersStore.customToonShading=d6;async function Yv(n,t,e=Ce.BodyShape.MALE,i,r){const o=fu(t,e);if(lp(o))throw new Error(`The wearable="${t.id}" is a texture`);const a=Cj(o),s=await SI(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 p6(n,t){const[e,i]=await qY(n,t);try{h6(t);let r;const o=[];if(t.type===Ce.PreviewType.AVATAR){const s=t5(t),l=Array.from(s.values());for(const c of l.filter(uI)){const h=Yv(e,c,t.bodyShape,t.skin,t.hair).catch(p=>{console.warn(p.message)});o.push(h)}const u=(await Promise.all(o)).filter(Qj);for(const c of u)c.container.addAllToScene();const f=Zj(u);if(f){const c=l.filter($j),{eyes:h,eyebrows:p,mouth:_}=await u6(e,c,t.bodyShape);f6(e,f,h,p,_,t)}r=await a6(e,u,t)||qA()}else{const s=t.item;if(s&&!Fo(s))try{(await Yv(e,s,t.bodyShape,t.skin,t.hair)).container.addAllToScene()}catch{(await Yv(e,s,t.bodyShape===Ce.BodyShape.MALE?Ce.BodyShape.FEMALE:Ce.BodyShape.MALE,t.skin,t.hair)).container.addAllToScene()}r=qA()}return t.centerBoundingBox&&JY(e),{scene:i,emote:r}}catch(r){throw e.clearColor=new it(0,0,0,0),r}}function _6(n){const t=()=>{Ce.sendMessage(un(),Ce.PreviewMessageType.EMOTE_EVENT,{type:Ce.PreviewEmoteEventType.ANIMATION_PLAY,payload:void 0})},e=()=>{Ce.sendMessage(un(),Ce.PreviewMessageType.EMOTE_EVENT,{type:Ce.PreviewEmoteEventType.ANIMATION_PAUSE,payload:void 0})},i=()=>{Ce.sendMessage(un(),Ce.PreviewMessageType.EMOTE_EVENT,{type:Ce.PreviewEmoteEventType.ANIMATION_LOOP,payload:void 0})},r=()=>{Ce.sendMessage(un(),Ce.PreviewMessageType.EMOTE_EVENT,{type:Ce.PreviewEmoteEventType.ANIMATION_END,payload:void 0})},o=a=>{Ce.sendMessage(un(),Ce.PreviewMessageType.EMOTE_EVENT,{type:Ce.PreviewEmoteEventType.ANIMATION_PLAYING,payload:a})};return n.emote.events.on(Ce.PreviewEmoteEventType.ANIMATION_PLAY,t),n.emote.events.on(Ce.PreviewEmoteEventType.ANIMATION_PAUSE,e),n.emote.events.on(Ce.PreviewEmoteEventType.ANIMATION_LOOP,i),n.emote.events.on(Ce.PreviewEmoteEventType.ANIMATION_END,r),n.emote.events.on(Ce.PreviewEmoteEventType.ANIMATION_PLAYING,o),()=>{n.emote.events.off(Ce.PreviewEmoteEventType.ANIMATION_PLAY,t),n.emote.events.off(Ce.PreviewEmoteEventType.ANIMATION_PAUSE,e),n.emote.events.off(Ce.PreviewEmoteEventType.ANIMATION_LOOP,i),n.emote.events.off(Ce.PreviewEmoteEventType.ANIMATION_END,r),n.emote.events.off(Ce.PreviewEmoteEventType.ANIMATION_PLAYING,o)}}const m6=()=>{const[n,t]=Ct.useState(""),{width:e,height:i}=lM(),[r,o]=Ct.useState({}),[a,s]=Ct.useState(!1),[l,u]=Ct.useState(!0),[f,c]=Ct.useState(!1),h=Ct.useRef(null),p=lI(),[_,g,v]=Xj(),[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===Ce.PreviewType.TEXTURE&&(G.backgroundColor=_.background.color)),o(G),_.type===Ce.PreviewType.TEXTURE?(C(!1),u(!1),c(!0)):p6(h.current,_).then(ee=>{p.current=ee,B=_6(p.current)}).catch(ee=>t(ee.message)).finally(()=>{u(!1),c(!0)})}return()=>{B()}},[h.current,_]),Ct.useEffect(()=>{var B;O||(f?(Ce.sendMessage(un(),Ce.PreviewMessageType.LOAD,{renderer:Ce.PreviewRenderer.BABYLON}),R(!0),((_==null?void 0:_.type)===Ce.PreviewType.AVATAR||_!=null&&_.emote&&_.emote!==Ce.PreviewEmote.IDLE)&&((B=p.current)==null||B.emote.play())):M&&(Ce.sendMessage(un(),Ce.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]),sI(),Rn.jsxs("div",{className:Yl("Preview",{"is-dragging":a,"is-loading":D,"is-loaded":f,"is-3d":S&&(_==null?void 0:_.camera)===Ce.PreviewCamera.INTERACTIVE,"has-error":!!M,"no-fade-effect":_&&!_.fadeEffect}),style:r,children:[Rn.jsx("img",{src:E,className:Yl("thumbnail",{"is-visible":U}),alt:"preview"}),Rn.jsx("canvas",{id:"wearable-preview",className:Yl({"is-visible":V}),width:e,height:i,ref:h,onMouseDown:()=>s(S&&!M),onMouseUp:()=>s(!1)}),M&&Rn.jsx("div",{className:"error",children:M})]})},g6=AO.memo(m6);var PI=(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))(PI||{});const v6={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"},y6={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)},gd=(n,t,e)=>{if(n)try{const i=String(t);Object.values(PI).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}`)},b6=(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&&(gd(n,"ClearBase64"),i++,Array.isArray(t.base64s)&&t.base64s.length>0&&t.base64s.forEach(r=>{gd(n,"AddBase64",r),i++})),Object.entries(t).forEach(([r,o])=>{if(r!=="base64s"&&e[r]&&o!==void 0){const a=v6[r];if(a){const s=y6[r],l=s?s(o):String(o);gd(n,a,l),i++}else console.warn(`No Unity method mapping found for property: ${r}`)}}),i>0&&gd(n,"Reload")};var E6={VITE_BASE_URL:"https://cdn.decentraland.org/@dcl/wearable-preview/2.4.0"};const Kv=new Map,Fl=(n,t)=>{if(!t)return n;const e=n.replace(/\/$/,""),i=t.replace(/^\//,"");return`${e}/${i}`};function T6(n){if(Kv.has(n))return Kv.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 Kv.set(n,t),t}const S6=async(n,t,e,i,r,o,a,s,l,u,f,c)=>{try{const h=E6.VITE_BASE_URL||"";return await T6(Fl(h,t)),await createUnityInstance(n,{dataUrl:Fl(h,e),frameworkUrl:Fl(h,i),codeUrl:Fl(h,r),streamingAssetsUrl:Fl(h,a),symbolUrl:Fl(h,o),companyName:s,productName:l,productVersion:u,matchWebGLToCanvasSize:f,arguments:c})}catch(h){throw console.error("❌ Failed to load Unity instance:",h),h}};function C6(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}`)},setUsername:async t=>{n&&n.SendMessage("JSBridge","SetUsername",t)},cleanup:async()=>{n&&n.SendMessage("JSBridge","Cleanup","")}}}function P6(n){const t=rb();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(Ce.PreviewEmoteEventType.ANIMATION_PLAYING,{length:e}))},play:async()=>{n&&(n.SendMessage("JSBridge","PlayEmote",""),t.emit(Ce.PreviewEmoteEventType.ANIMATION_PLAY))},pause:async()=>{n&&(n.SendMessage("JSBridge","PauseEmote",""),t.emit(Ce.PreviewEmoteEventType.ANIMATION_PAUSE))},stop:async()=>{n&&(n.SendMessage("JSBridge","StopEmote",""),t.emit(Ce.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 A6(n){let t=null;try{if(t=await S6(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","/unity/Build/aang-renderer.symbols.json.br","/emotes","Decentraland","AangRenderer","2.0.3",!0,[]),!t)throw new Error("Failed to load Unity instance");const e=C6(t),i=P6(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 R6=()=>Math.floor(Math.random()*159)+1,AI=()=>`default${R6()}`,O6=(n,t)=>{var e,i,r,o,a,s;return{eyes:eu(t.eyes||((i=(e=n==null?void 0:n.avatar)==null?void 0:e.eyes)==null?void 0:i.color)&&tu(n.avatar.eyes.color)||"#000000"),hair:eu(t.hair||((o=(r=n==null?void 0:n.avatar)==null?void 0:r.hair)==null?void 0:o.color)&&tu(n.avatar.hair.color)||"#000000"),skin:eu(t.skin||((s=(a=n==null?void 0:n.avatar)==null?void 0:a.skin)==null?void 0:s.color)&&tu(n.avatar.skin.color)||"#cc9b76")}},nf=n=>n||"",SO=n=>n||[],vd=n=>n.replace("#","");function CO(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 M6(){const{options:n,overrideSources:t}=xb(),[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||Ff.get("PEER_URL"),E=n.nftServerUrl||Ff.get("NFT_SERVER_URL");let T=Ce.PreviewType.WEARABLE,S={color:n.background||"#4b4852",transparent:n.disableBackground===!0};const C=tI(n.profile);let O=C==null?void 0:C.value;O==="default"&&(O=AI());const R=O&&C?C.type==="address"?await rI(O,v):await nI(O,v):null,M=n.bodyShape||((_=R==null?void 0:R.avatar)==null?void 0:_.bodyShape)||Ce.BodyShape.MALE;let D=null;if(n.contractAddress&&(D=await oI({contractAddress:n.contractAddress,tokenId:n.tokenId,itemId:n.itemId,peerUrl:v,nftServerUrl:E}),D&&is(D))){S={...S,image:D.thumbnail};const Z=Ob(D);lp(Z)&&(T=Ce.PreviewType.TEXTURE)}const{eyes:U,hair:V,skin:B}=O6(R,{eyes:n.eyes,hair:n.hair,skin:n.skin}),G=n.mode||null,ee=n.camera&&Object.values(Ce.PreviewCamera).includes(n.camera)?n.camera:Ce.PreviewCamera.INTERACTIVE,q=n.projection&&Object.values(Ce.PreviewProjection).includes(n.projection)?n.projection:Ce.PreviewProjection.PERSPECTIVE,re=n.disableDefaultEmotes?null:n.emote&&Object.values(Ce.PreviewEmote).includes(n.emote)?n.emote:Ce.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=SO(n.urns),K=SO(n.base64s);if(G==="configurator"){const F={mode:nf(G||"")};CO(F)}else{const F={background:S.transparent?"":vd(S.color),disableLoader:n.disableLoader?"true":"",profile:nf(O||""),bodyShape:nf(M||""),eyeColor:vd(U||""),hairColor:vd(V||""),skinColor:vd(B||""),mode:nf(G||""),camera:ee,projection:q,emote:nf((re==null?void 0:re.toString())||""),urn:Z.length>0?Z:[""],base64:K.length>0?K:[""]};CO(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 x6="unity-renderer",I6="unity-canvas",PO=1,D6="Failed to load Unity",w6=(n,t,e,i)=>{const[r,o]=Ct.useState({isLoaded:!1,isInitialized:!1,error:null}),a=Ct.useCallback(l=>{if(l.data.type===x6){const{type:u,payload:f}=l.data.payload;u==="loaded"&&(f===!0||f==="true")?(o(c=>({...c,isLoaded:!0,isInitialized:!0})),Ce.sendMessage(un(),Ce.PreviewMessageType.LOAD,{renderer:Ce.PreviewRenderer.UNITY})):u==="customization-done"?Ce.sendMessage(un(),Ce.PreviewMessageType.CONTROLLER_RESPONSE,{id:"customization-done",ok:!0,result:JSON.parse(l.data.payload.payload)}):u==="error"&&(o(c=>({...c,error:f})),Ce.sendMessage(un(),Ce.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 A6(n.canvas.current);n.unityInstance.current=l,t.current={scene:u,emote:f},o(c=>({...c,isLoaded:!0,isInitialized:!0})),Ce.sendMessage(un(),Ce.PreviewMessageType.LOAD,{renderer:Ce.PreviewRenderer.UNITY})}catch(l){const u=l instanceof Error?l.message:D6;console.error("Unity init failed:",l),o(f=>({...f,error:u})),Ce.sendMessage(un(),Ce.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},L6=n=>{const[t,e]=Ct.useState({pixelRatio:window.devicePixelRatio||PO,is3D:!0,backgroundImage:""});return Ct.useEffect(()=>{const i=()=>{e(o=>({...o,pixelRatio:window.devicePixelRatio||PO}))},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!==Ce.PreviewType.TEXTURE}))},[n]),t},N6=(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:AI()}Object.keys(o).length>0&&(b6(n.current,o,r),t.current=o)}},[e.isInitialized,e.isLoaded,o,r,n,t])},F6=()=>{const{width:n=window.innerWidth,height:t=window.innerHeight}=lM(),e=Ct.useRef(null),i=Ct.useRef(null),r=Ct.useRef(!1),o=Ct.useRef({}),a=lI(),[s,l,u]=M6(),{options:f,overrideSources:c}=xb(),h=Ct.useMemo(()=>({canvas:e,unityInstance:i,isInitializing:r,lastSentOverrides:o}),[]),p=w6(h,a,s,l),_=L6(s);N6(h.unityInstance,h.lastSentOverrides,p,f,c),sI();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)===Ce.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(()=>Yl("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(()=>Yl("thumbnail",{"is-visible":g.showImage}),[g.showImage]),O=Ct.useMemo(()=>Yl({"is-visible":g.showCanvas}),[g.showCanvas]);return Rn.jsxs("div",{className:S,style:v,children:[Rn.jsx("img",{src:_.backgroundImage,className:C,alt:"preview"}),Rn.jsx("canvas",{ref:h.canvas,id:I6,className:O,width:T.width,height:T.height,style:E}),g.error&&Rn.jsx("div",{className:"error",children:g.error})]})},B6=AO.memo(F6),RI=Ct.createContext(null),V6=({children:n,value:t})=>{const e={webGPUSupport:t,isSupported:t.isSupported,isAvailable:t.isAvailable};return Rn.jsx(RI.Provider,{value:e,children:n})},U6=()=>{const n=Ct.useContext(RI);if(!n)throw new Error("useWebGPUContext must be used within a WebGPUProvider");return n},k6=()=>U6(),z6=()=>{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}},G6=async()=>{const{platform:n,browser:t,version:e}=z6();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}}},W6=()=>{const t=new URLSearchParams(window.location.search).get("unity")==="true",{isAvailable:e}=k6();return t&&e?Rn.jsx(B6,{}):Rn.jsx(g6,{})},H6=async()=>{const n=await G6();gw.createRoot(document.getElementById("root")).render(Rn.jsx(Ct.StrictMode,{children:Rn.jsx(V6,{value:n,children:Rn.jsx(W6,{})})}))};H6();
|
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/2.
|
|
10
|
+
<link rel="manifest" href="https://cdn.decentraland.org/@dcl/wearable-preview/2.4.0/manifest.json" />
|
|
11
11
|
<title>Decentraland | Wearable Preview</title>
|
|
12
|
-
<script type="module" crossorigin src="https://cdn.decentraland.org/@dcl/wearable-preview/2.
|
|
13
|
-
<link rel="stylesheet" crossorigin href="https://cdn.decentraland.org/@dcl/wearable-preview/2.
|
|
12
|
+
<script type="module" crossorigin src="https://cdn.decentraland.org/@dcl/wearable-preview/2.4.0/assets/index-hZuvUoiO.js"></script>
|
|
13
|
+
<link rel="stylesheet" crossorigin href="https://cdn.decentraland.org/@dcl/wearable-preview/2.4.0/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": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
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/2.
|
|
16
|
+
"homepage": "https://cdn.decentraland.org/@dcl/wearable-preview/2.4.0",
|
|
17
17
|
"commit": "ca7430efa330c7068cb7cdd4008c35c789d3552a"
|
|
18
18
|
}
|