var gdjs;(function(l){const g={3:0,2:1,5:2,4:3,0:4,1:5},M={0:3,1:2,2:5,3:4,4:0,5:1},h={0:[0,0],1:[1,0],2:[0,1],3:[1,1]},R={0:[0,1],1:[0,0],2:[1,1],3:[1,0]};let x;const T=()=>(x||(x=new THREE.MeshBasicMaterial({transparent:!0,opacity:0,alphaTest:1})),x),_=(n,i)=>n.isFaceAtIndexVisible(i)?n.getInstanceContainer().getGame().getImageManager().getThreeMaterial(n.getFaceAtIndexResourceName(i),{useTransparentTexture:n.shouldUseTransparentTexture(),forceBasicMaterial:n._materialType===l.Cube3DRuntimeObject.MaterialType.Basic,vertexColors:!0}):T();class f extends l.RuntimeObject3DRenderer{constructor(i,t){const r=new THREE.BoxGeometry(1,1,1),m=new Array(6).fill(0).map((e,b)=>_(i,M[b])),c=new THREE.Mesh(r,m);super(i,t,c);this._boxMesh=c,this._cube3DRuntimeObject=i,c.receiveShadow=this._cube3DRuntimeObject._isReceivingShadow,c.castShadow=this._cube3DRuntimeObject._isCastingShadow,this.updateSize(),this.updatePosition(),this.updateRotation(),this.updateTint()}updateTint(){const i=[],t=l.rgbOrHexToRGBColor(this._cube3DRuntimeObject.getColor()).map(r=>r/255);for(let r=0;r<this._boxMesh.geometry.attributes.position.count;r++)i.push(...t);this._boxMesh.geometry.setAttribute("color",new THREE.BufferAttribute(new Float32Array(i),3))}updateShadowCasting(){this._boxMesh.castShadow=this._cube3DRuntimeObject._isCastingShadow}updateShadowReceiving(){this._boxMesh.receiveShadow=this._cube3DRuntimeObject._isReceivingShadow}updateFace(i){const t=g[i];t!==void 0&&(this._boxMesh.material[t]=_(this._cube3DRuntimeObject,i),this._cube3DRuntimeObject.isFaceAtIndexVisible(i)&&this.updateTextureUvMapping(i))}updateSize(){super.updateSize(),this.updateTextureUvMapping()}updateTextureUvMapping(i){const t=this._boxMesh.geometry.getAttribute("position"),r=this._boxMesh.geometry.getAttribute("uv"),m=i===void 0?0:g[i]*4,c=i===void 0?23:g[i]*4+3;for(let e=m;e<=c;e++){const b=Math.floor(e/4),o=this._boxMesh.material[b];if(!o||!o.map)continue;const u=this._cube3DRuntimeObject.shouldRepeatTextureOnFaceAtIndex(M[b]),d=this._cube3DRuntimeObject.getFacesOrientation()==="Y";let a,s;switch(b){case 0:u?d?(a=-(this._boxMesh.scale.z/o.map.source.data.width)*(t.getZ(e)-.5),s=-(this._boxMesh.scale.y/o.map.source.data.height)*(t.getY(e)+.5)):(a=-(this._boxMesh.scale.y/o.map.source.data.width)*(t.getY(e)-.5),s=this._boxMesh.scale.z/o.map.source.data.height*(t.getZ(e)-.5)):d?[a,s]=h[e%4]:[a,s]=R[e%4];break;case 1:u?d?(a=this._boxMesh.scale.z/o.map.source.data.width*(t.getZ(e)+.5),s=-(this._boxMesh.scale.y/o.map.source.data.height)*(t.getY(e)+.5)):(a=this._boxMesh.scale.y/o.map.source.data.width*(t.getY(e)+.5),s=this._boxMesh.scale.z/o.map.source.data.height*(t.getZ(e)-.5)):d?[a,s]=h[e%4]:([a,s]=R[e%4],a=-a,s=-s);break;case 2:u?(a=this._boxMesh.scale.x/o.map.source.data.width*(t.getX(e)+.5),s=this._boxMesh.scale.z/o.map.source.data.height*(t.getZ(e)-.5)):[a,s]=h[e%4];break;case 3:u?d?(a=this._boxMesh.scale.x/o.map.source.data.width*(t.getX(e)+.5),s=-(this._boxMesh.scale.z/o.map.source.data.height)*(t.getZ(e)+.5)):(a=-(this._boxMesh.scale.x/o.map.source.data.width)*(t.getX(e)-.5),s=this._boxMesh.scale.z/o.map.source.data.height*(t.getZ(e)-.5)):([a,s]=h[e%4],d||(a=-a,s=-s));break;case 4:u?(a=this._boxMesh.scale.x/o.map.source.data.width*(t.getX(e)+.5),s=-(this._boxMesh.scale.y/o.map.source.data.height)*(t.getY(e)+.5)):[a,s]=h[e%4];break;case 5:const p=this._cube3DRuntimeObject.getBackFaceUpThroughWhichAxisRotation()==="X";u?(a=(p?1:-1)*(this._boxMesh.scale.x/o.map.source.data.width)*(t.getX(e)+(p?1:-1)*.5),s=(p?1:-1)*(this._boxMesh.scale.y/o.map.source.data.height)*(t.getY(e)+(p?-1:1)*.5)):([a,s]=h[e%4],p&&(a=-a,s=-s));break;default:[a,s]=h[e%4]}r.setXY(e,a,s)}r.needsUpdate=!0}_updateMaterials(){for(let i=0;i<6;i++)this.updateFace(i)}}l.Cube3DRuntimeObjectRenderer=f})(gdjs||(gdjs={}));
//# sourceMappingURL=Cube3DRuntimeObjectPixiRenderer.js.map
