var gdjs;(function(r){class n extends r.CustomRuntimeObject{constructor(t,i){super(t,i);this._z=0;this._minZ=0;this._maxZ=0;this._scaleZ=1;this._flippedZ=!1;this._rotationX=0;this._rotationY=0;this._customCenterZ=0;this._renderer.reinitialize(this,t)}_createRender(){const t=this._runtimeScene;return new r.CustomRuntimeObject3DRenderer(this,this._instanceContainer,t)}_reinitializeRenderer(){this.getRenderer().reinitialize(this,this.getParent())}getRenderer(){return super.getRenderer()}get3DRendererObject(){return this.getRenderer().get3DRendererObject()}extraInitializationFromInitialInstance(t){super.extraInitializationFromInitialInstance(t),t.depth!==void 0&&this.setDepth(t.depth),t.flippedX&&this.flipX(t.flippedX),t.flippedY&&this.flipY(t.flippedY),t.flippedZ&&this.flipZ(t.flippedZ)}setZ(t){t!==this._z&&(this._z=t,this.getRenderer().updatePosition())}getZ(){return this._z}getDrawableZ(){let t=0;this._innerArea?t=this._innerArea.min[2]:(this._isUntransformedHitBoxesDirty&&this._updateUntransformedHitBoxes(),t=this._minZ);const i=this.getScaleZ();return this._flippedZ?this._z+(-t-this.getUnscaledDepth()+2*this.getUnscaledCenterZ())*i:this._z+t*i}getCenterZ(){return this.getDepth()/2}getCenterZInScene(){return this.getDrawableZ()+this.getCenterZ()}setCenterZInScene(t){this.setZ(t+this._z-(this.getDrawableZ()+this.getCenterZ()))}getUnrotatedAABBMinZ(){return this.getDrawableZ()}getUnrotatedAABBMaxZ(){return this.getDrawableZ()+this.getDepth()}setRotationX(t){this._rotationX=t,this.getRenderer().updateRotation()}setRotationY(t){this._rotationY=t,this.getRenderer().updateRotation()}getRotationX(){return this._rotationX}getRotationY(){return this._rotationY}turnAroundX(t){const i=r.CustomRuntimeObject3D._temporaryVector;i.set(1,0,0);const e=this.get3DRendererObject();e.rotateOnWorldAxis(i,r.toRad(t)),this._rotationX=r.toDegrees(e.rotation.x),this._rotationY=r.toDegrees(e.rotation.y),this.setAngle(r.toDegrees(e.rotation.z))}turnAroundY(t){const i=r.CustomRuntimeObject3D._temporaryVector;i.set(0,1,0);const e=this.get3DRendererObject();e.rotateOnWorldAxis(i,r.toRad(t)),this._rotationX=r.toDegrees(e.rotation.x),this._rotationY=r.toDegrees(e.rotation.y),this.setAngle(r.toDegrees(e.rotation.z))}turnAroundZ(t){const i=r.CustomRuntimeObject3D._temporaryVector;i.set(0,0,1);const e=this.get3DRendererObject();e.rotateOnWorldAxis(i,r.toRad(t)),this._rotationX=r.toDegrees(e.rotation.x),this._rotationY=r.toDegrees(e.rotation.y),this.setAngle(r.toDegrees(e.rotation.z))}getInnerAreaMinZ(){return this._innerArea?this._innerArea.min[2]:(this._isUntransformedHitBoxesDirty&&this._updateUntransformedHitBoxes(),this._minZ)}getInnerAreaMaxZ(){return this._innerArea?this._innerArea.max[2]:(this._isUntransformedHitBoxesDirty&&this._updateUntransformedHitBoxes(),this._maxZ)}getUnscaledDepth(){return this._innerArea?this._innerArea.max[2]-this._innerArea.min[2]:(this._isUntransformedHitBoxesDirty&&this._updateUntransformedHitBoxes(),this._maxZ-this._minZ)}_updateUntransformedHitBoxes(){super._updateUntransformedHitBoxes();let t=Number.MAX_VALUE,i=-Number.MAX_VALUE;for(const e of this._instanceContainer.getAdhocListOfAllInstances())!e.isIncludedInParentCollisionMask()||!r.Base3DHandler.is3D(e)||(t=Math.min(t,e.getUnrotatedAABBMinZ()),i=Math.max(i,e.getUnrotatedAABBMaxZ()));t===Number.MAX_VALUE&&(t=0,i=1),this._minZ=t,this._maxZ=i}getUnscaledCenterZ(){return this.hasCustomRotationCenter()?this._customCenterZ:this._innerArea?(this._innerArea.min[2]+this._innerArea.max[2])/2:(this._isUntransformedHitBoxesDirty&&this._updateUntransformedHitBoxes(),(this._minZ+this._maxZ)/2)}setRotationCenter3D(t,i,e){this._customCenterZ=e,this.setRotationCenter(t,i)}getDepth(){return this.getUnscaledDepth()*this.getScaleZ()}setDepth(t){const i=this.getUnscaledDepth();if(i===0)return;const e=t/i;this._innerArea&&this._isInnerAreaFollowingParentSize?(this._innerArea.min[2]*=e,this._innerArea.max[2]*=e):this.setScaleZ(e)}setScale(t){super.setScale(t),this.setScaleZ(t)}setScaleZ(t){this._innerArea&&this._isInnerAreaFollowingParentSize||(t<0&&(t=0),t!==Math.abs(this._scaleZ)&&(this._scaleZ=t*(this._flippedZ?-1:1),this.getRenderer().updateSize()))}getScale(){const t=this.getScaleX(),i=this.getScaleY(),e=this.getScaleZ();return t===i&&t===e?t:Math.pow(t*i*e,1/3)}getScaleZ(){return Math.abs(this._scaleZ)}flipZ(t){t!==this._flippedZ&&(this._flippedZ=t,this.getRenderer().updateSize())}isFlippedZ(){return this._flippedZ}}n._temporaryVector=new THREE.Vector3,r.CustomRuntimeObject3D=n})(gdjs||(gdjs={})); //# sourceMappingURL=CustomRuntimeObject3D.js.map