"use strict";var Entity=function(t,i){this.name=Util.isInitialized(i)?i:"unnamed",this.camera=t,this.camera.setOwnerEntity(this),this.heightmapCoord=new THREE.Vector2,this._heightmapCoordComputedInFrame=-1,this.lastHeightmapHeight=null,this.currentGroundMap=null,this._avatarMode=Entity.AvatarModes.WALK,this.freefallStart=0,this.jumping=!1,this.inTunnel=!1,this.timeInTunnel=0,Entity.entityList.push(this)};Entity.entityList=[],Entity.prototype.getViewpointTextDefinition=function(){return"Preferences.Viewpoint.VIEWPOINT_XXX = new Viewpoint (new THREE.Vector3 ("+this.getPosition().x+", "+this.getPosition().y+", "+this.getPosition().z+"), "+this.getCamera().angleHorizontal+", "+this.getCamera().angleVertical+");"},Entity.prototype.getPosition=function(){return this.camera.position},Entity.prototype.getY=function(){return this.camera.position.y},Entity.AvatarModes={WALK:0,FLY:1},Entity.prototype.turnWalkMode=function(){var t=collision.getAirStatus(this);t!==Collision.AirStatus.IN_AIR_FOR_LONG_TIME&&t!==Collision.AirStatus.JUST_GOT_INTO_AIR||this.updateFreefallStartTime(),this._avatarMode=Entity.AvatarModes.WALK},Entity.prototype.turnFlyMode=function(){this._avatarMode=Entity.AvatarModes.FLY,collision.fallAcceleration=Preferences.Collision.FALL_ACCELERATION,this.resetFreefallStartTime()},Entity.prototype.switchWalkFlyMode=function(){this.inWalkMode()?this.turnFlyMode():this.turnWalkMode()},Entity.prototype.inWalkMode=function(){return this._avatarMode===Entity.AvatarModes.WALK},Entity.prototype.inFlyMode=function(){return this._avatarMode===Entity.AvatarModes.FLY},Entity.prototype.inAir=function(){return 0!==this.freefallStart},Entity.prototype.updateFreefallStartTime=function(){this.freefallStart=clock.elapsedFrames,this.camera.positionFallStart=this.getY()},Entity.prototype.resetFreefallStartTime=function(){this.freefallStart=0},Entity.prototype.getFreefallDuration=function(){return 16*(clock.elapsedFrames-this.freefallStart)},Entity.prototype.jump=function(){this.inAir()||heightmapWorld.isInTunnel(this)||this.turnJumpMode()},Entity.prototype.turnJumpMode=function(){this.jumping?(collision.fallAcceleration=Preferences.Collision.FALL_ACCELERATION,this.updateFreefallStartTime()):collision.fallAcceleration=Preferences.Collision.JUMP_ACCELERATION,this.jumping=!this.jumping},Entity.prototype.getCamera=function(){return this.camera},Entity.prototype.setPosition=function(t){this.camera.setPosition(t)},Entity.prototype.computeHeightmapCoordinates=function(t){(this._heightmapCoordComputedInFrame!==clock.elapsedFrames||t)&&(heightmapWorld.map.computeScreenCoordinates(this.getPosition(),this.heightmapCoord),this._heightmapCoordComputedInFrame=clock.elapsedFrames)},Entity.prototype.updateLastHeightmapHeight=function(){this.computeHeightmapCoordinates(!0),this.lastHeightmapHeight=heightmapWorld.getMain().getWorldHeightAt(this.heightmapCoord.x,this.heightmapCoord.y,this)};