diff --git a/dist-old/CharacterController.d.ts b/dist-old/CharacterController.d.ts deleted file mode 100644 index 37d5039..0000000 --- a/dist-old/CharacterController.d.ts +++ /dev/null @@ -1,244 +0,0 @@ -import { Skeleton, ArcRotateCamera, Vector3, Mesh, Scene, AnimationGroup, Sound } from "babylonjs"; -export declare class CharacterController { - private _avatar; - private _skeleton; - private _camera; - private _scene; - getScene(): Scene; - private _gravity; - private _minSlopeLimit; - private _maxSlopeLimit; - private _sl1; - private _sl2; - private _stepOffset; - private _vMoveTot; - private _vMovStartPos; - private _actionMap; - private _cameraElastic; - private _cameraTarget; - private _noFirstPerson; - setSlopeLimit(minSlopeLimit: number, maxSlopeLimit: number): void; - setStepOffset(stepOffset: number): void; - setWalkSpeed(n: number): void; - setRunSpeed(n: number): void; - setBackSpeed(n: number): void; - setBackFastSpeed(n: number): void; - setJumpSpeed(n: number): void; - setLeftSpeed(n: number): void; - setLeftFastSpeed(n: number): void; - setRightSpeed(n: number): void; - setRightFastSpeed(n: number): void; - setTurnSpeed(n: number): void; - setTurnFastSpeed(n: number): void; - setGravity(n: number): void; - setAnimationGroups(agMap: {}): void; - setAnimationRanges(arMap: {}): void; - setActionMap(inActMap: ActionMap): string; - getActionMap(): ActionMap; - getSettings(): CCSettings; - setSettings(ccs: CCSettings): void; - private _setAnim; - enableBlending(n: number): void; - disableBlending(): void; - setWalkAnim(rangeName: string | AnimationGroup, rate: number, loop: boolean): void; - setRunAnim(rangeName: string | AnimationGroup, rate: number, loop: boolean): void; - setWalkBackAnim(rangeName: string | AnimationGroup, rate: number, loop: boolean): void; - setWalkBackFastAnim(rangeName: string | AnimationGroup, rate: number, loop: boolean): void; - setSlideBackAnim(rangeName: string | AnimationGroup, rate: number, loop: boolean): void; - setIdleAnim(rangeName: string | AnimationGroup, rate: number, loop: boolean): void; - setTurnRightAnim(rangeName: string | AnimationGroup, rate: number, loop: boolean): void; - setTurnRightFastAnim(rangeName: string | AnimationGroup, rate: number, loop: boolean): void; - setTurnLeftAnim(rangeName: string | AnimationGroup, rate: number, loop: boolean): void; - setTurnLeftFastAnim(rangeName: string | AnimationGroup, rate: number, loop: boolean): void; - setStrafeRightAnim(rangeName: string | AnimationGroup, rate: number, loop: boolean): void; - setStrafeRightFastAnim(rangeName: string | AnimationGroup, rate: number, loop: boolean): void; - setStrafeLeftAnim(rangeName: string | AnimationGroup, rate: number, loop: boolean): void; - setStrafeLeftFastAnim(rangeName: string | AnimationGroup, rate: number, loop: boolean): void; - setIdleJumpAnim(rangeName: string | AnimationGroup, rate: number, loop: boolean): void; - setRunJumpAnim(rangeName: string | AnimationGroup, rate: number, loop: boolean): void; - setFallAnim(rangeName: string | AnimationGroup, rate: number, loop: boolean): void; - _stepSound: Sound; - setSound(sound: Sound): void; - setWalkKey(key: string): void; - setWalkBackKey(key: string): void; - setTurnLeftKey(key: string): void; - setTurnRightKey(key: string): void; - setStrafeLeftKey(key: string): void; - setStrafeRightKey(key: string): void; - setJumpKey(key: string): void; - setCameraElasticity(b: boolean): void; - setElasticiSteps(n: number): void; - makeObstructionInvisible(b: boolean): void; - setCameraTarget(v: Vector3): void; - cameraCollisionChanged(): void; - setNoFirstPerson(b: boolean): void; - private _checkAnimRanges; - private _checkFastAnims; - private _copySlowAnims; - private _mode; - private _saveMode; - setMode(n: number): void; - getMode(): number; - setTurningOff(b: boolean): void; - isTurningOff(): boolean; - private _isLHS_RHS; - private _signLHS_RHS; - private _setRHS; - private _ffSign; - private _rhsSign; - private _ff; - private _av2cam; - setFaceForward(b: boolean): void; - isFaceForward(): boolean; - private checkAGs; - private _containsAG; - private _getRoot; - private _started; - start(): void; - stop(): void; - private _stopAnim; - pauseAnim(): void; - resumeAnim(): void; - private _prevActData; - private _avStartPos; - private _grounded; - private _freeFallDist; - private _fallFrameCountMin; - private _fallFrameCount; - private _inFreeFall; - private _wasWalking; - private _wasRunning; - private _moveVector; - private _isAvFacingCamera; - private _moveAVandCamera; - private _soundLoopTime; - private _sndId; - private _jumpStartPosY; - private _jumpTime; - private _doJump; - private _calcJumpDist; - private _endJump; - private _areVectorsEqual; - private _verticalSlope; - private _movFallTime; - private _sign; - private _isTurning; - private _noRot; - private _doMove; - private _rotateAV2C; - private _rotateAVnC; - private _endFreeFall; - private _idleFallTime; - private _doIdle; - private _groundFrameCount; - private _groundFrameMax; - private _groundIt; - private _unGroundIt; - private _savedCameraCollision; - private _inFP; - private _updateTargetValue; - private _makeMeshInvisible; - private _visiblityMap; - private _restoreVisiblity; - private _ray; - private _rayDir; - private _cameraSkin; - private _prevPickedMeshes; - private _pickedMeshes; - private _makeInvisible; - private _elasticSteps; - private _alreadyInvisible; - private _handleObstruction; - private _isSeeAble; - private _move; - anyMovement(): boolean; - private _onKeyDown; - private _onKeyUp; - private _ekb; - isKeyBoardEnabled(): boolean; - enableKeyBoard(b: boolean): void; - private _addkeylistener; - private _removekeylistener; - walk(b: boolean): void; - walkBack(b: boolean): void; - walkBackFast(b: boolean): void; - run(b: boolean): void; - turnLeft(b: boolean): void; - turnLeftFast(b: boolean): void; - turnRight(b: boolean): void; - turnRightFast(b: boolean): void; - strafeLeft(b: boolean): void; - strafeLeftFast(b: boolean): void; - strafeRight(b: boolean): void; - strafeRightFast(b: boolean): void; - jump(): void; - fall(): void; - idle(): void; - private _act; - private _renderer; - private _handleKeyUp; - private _handleKeyDown; - private _isAG; - isAg(): boolean; - private _findSkel; - private _root; - setAvatar(avatar: Mesh, faceForward?: boolean): boolean; - getAvatar(): Mesh; - setAvatarSkeleton(skeleton: Skeleton): void; - private _skelDrivenByAG; - getSkeleton(): Skeleton; - private _hasAnims; - private _hasCam; - constructor(avatar: Mesh, camera: ArcRotateCamera, scene: Scene, actionMap?: {}, faceForward?: boolean); -} -export declare class ActionData { - id: string; - speed: number; - ds: number; - sound: Sound; - key: string; - dk: string; - name: string; - ag: AnimationGroup; - loop: boolean; - rate: number; - exist: boolean; - constructor(id?: string, speed?: number, key?: string); - reset(): void; -} -export declare class ActionMap { - walk: ActionData; - walkBack: ActionData; - walkBackFast: ActionData; - idle: ActionData; - idleJump: ActionData; - run: ActionData; - runJump: ActionData; - fall: ActionData; - turnLeft: ActionData; - turnLeftFast: ActionData; - turnRight: ActionData; - turnRightFast: ActionData; - strafeLeft: ActionData; - strafeLeftFast: ActionData; - strafeRight: ActionData; - strafeRightFast: ActionData; - slideBack: ActionData; - reset(): void; -} -export declare class CCSettings { - faceForward: boolean; - gravity: number; - minSlopeLimit: number; - maxSlopeLimit: number; - stepOffset: number; - cameraElastic: boolean; - elasticSteps: number; - makeInvisble: boolean; - cameraTarget: Vector3; - noFirstPerson: boolean; - topDown: boolean; - turningOff: boolean; - keyboard: boolean; - sound: Sound; -} diff --git a/dist-old/CharacterController.js b/dist-old/CharacterController.js deleted file mode 100644 index c37b0ef..0000000 --- a/dist-old/CharacterController.js +++ /dev/null @@ -1,2 +0,0 @@ -!function(t,i){if("object"==typeof exports&&"object"==typeof module)module.exports=i(require("babylonjs"));else if("function"==typeof define&&define.amd)define(["babylonjs"],i);else{var s="object"==typeof exports?i(require("babylonjs")):i(t.BABYLON);for(var h in s)("object"==typeof exports?exports:t)[h]=s[h]}}(self,(t=>(()=>{"use strict";var i={247:i=>{i.exports=t}},s={};function h(t){var n=s[t];if(void 0!==n)return n.exports;var e=s[t]={exports:{}};return i[t](e,e.exports,h),e.exports}h.n=t=>{var i=t&&t.t?()=>t.default:()=>t;return h.d(i,{a:i}),i},h.d=(t,i)=>{for(var s in i)h.o(i,s)&&!h.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:i[s]})},h.o=(t,i)=>Object.prototype.hasOwnProperty.call(t,i),h.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"t",{value:!0})};var n={};return(()=>{h.r(n),h.d(n,{ActionData:()=>e,ActionMap:()=>r,CCSettings:()=>u,CharacterController:()=>i});var t=h(247),i=function(){function i(i,h,n,e,u){void 0===u&&(u=!1);var f=this;this.i=null,this.h=null,this.u=9.8,this.l=30,this.v=45,this.k=Math.PI*this.l/180,this.M=Math.PI*this.v/180,this.p=.25,this.j=0,this.O=t.Vector3.Zero(),this.g=new r,this.C=!0,this.F=t.Vector3.Zero(),this.A=!1,this.L=0,this.R=0,this.S=!1,this.q=-1,this.B=!1,this.I=!1,this.J=null,this._=t.Vector3.Zero(),this.D=!1,this.T=0,this.G=50,this.H=0,this.K=!1,this.N=!1,this.P=!1,this.U=700,this.V=null,this.W=0,this.X=0,this.Y=0,this.Z=1,this.$=!1,this.tt=!1,this.it=0,this.st=0,this.ht=10,this.nt=!0,this.et=!1,this.rt=new Map,this.ut=new t.Ray(t.Vector3.Zero(),t.Vector3.One(),1),this.ft=t.Vector3.Zero(),this.ot=.5,this.ct=new Array,this.lt=!1,this.vt=50,this.bt=!1,this.wt=!0,this.kt=!1,this.Mt=!1,this.dt=!0,this.jt=h,null==this.jt&&(this.dt=!1,this.setMode(1)),this.yt=n,this.setAvatar(i,u)||console.error("unable to set avatar");null!=e&&this.setActionMap(e),this.kt||null==this.h||this.Ot(this.h),this.kt,this.dt&&(this.nt=this.jt.checkCollisions),this.gt=new s,this.xt=function(){f.Ct()},this.Ft=function(t){f.At(t)},this.Lt=function(t){f.Rt(t)}}return i.prototype.getScene=function(){return this.yt},i.prototype.setSlopeLimit=function(t,i){this.l=t,this.v=i,this.k=Math.PI*this.l/180,this.M=Math.PI*this.v/180},i.prototype.setStepOffset=function(t){this.p=t},i.prototype.setWalkSpeed=function(t){this.g.walk.speed=t},i.prototype.setRunSpeed=function(t){this.g.run.speed=t},i.prototype.setBackSpeed=function(t){this.g.walkBack.speed=t},i.prototype.setBackFastSpeed=function(t){this.g.walkBackFast.speed=t},i.prototype.setJumpSpeed=function(t){this.g.idleJump.speed=t,this.g.runJump.speed=t},i.prototype.setLeftSpeed=function(t){this.g.strafeLeft.speed=t},i.prototype.setLeftFastSpeed=function(t){this.g.strafeLeftFast.speed=t},i.prototype.setRightSpeed=function(t){this.g.strafeRight.speed=t},i.prototype.setRightFastSpeed=function(t){this.g.strafeLeftFast.speed=t},i.prototype.setTurnSpeed=function(t){this.g.turnLeft.speed=t*Math.PI/180,this.g.turnRight.speed=t*Math.PI/180},i.prototype.setTurnFastSpeed=function(t){this.g.turnLeftFast.speed=t*Math.PI/180,this.g.turnRightFast.speed=t*Math.PI/180},i.prototype.setGravity=function(t){this.u=t},i.prototype.setAnimationGroups=function(t){null!=this.J&&this.J.exist&&this.J.ag.stop(),this.kt=!0,this.setActionMap(t)},i.prototype.setAnimationRanges=function(t){this.kt=!1,this.setActionMap(t)},i.prototype.setActionMap=function(i){for(var s,h=!1,n=0,r=Object.keys(this.g);n-1)return!0}return!1},i.prototype.Gt=function(t){return null==t.parent?t:this.Gt(t.parent)},i.prototype.start=function(){this.B||(this.B=!0,this.gt.reset(),this.Y=0,this.it=.001,this.D=!1,this.Ht(),this.wt&&this.Kt(),this.yt.registerBeforeRender(this.xt))},i.prototype.stop=function(){this.B&&(this.B=!1,this.yt.unregisterBeforeRender(this.xt),this.Nt(),this.J=null)},i.prototype.pauseAnim=function(){this.I=!0,null!=this.J&&this.J.exist&&(this.kt?this.J.ag.stop():this.yt.stopAnimation(this.h),null!=this.J.sound&&this.J.sound.stop(),clearInterval(this.V),this.yt.unregisterBeforeRender(this.xt))},i.prototype.resumeAnim=function(){this.I=!1,this.J=null,this.yt.registerBeforeRender(this.xt)},i.prototype.Pt=function(){return this.dt?t.Vector3.Dot(this.i.forward,this.i.position.subtract(this.jt.position))<0?1:-1:1},i.prototype.Ct=function(){this._.copyFrom(this.i.position);var t=null,i=this.yt.getEngine().getDeltaTime()/1e3;if(this.gt.Qt&&!this.K?(this.D=!1,this.it=0,t=this.Ut(i)):this.anyMovement()||this.K?(this.D=!1,this.it=0,t=this.Vt(i)):this.K||(t=this.Wt(i)),!this.I&&this.Mt&&null!=t&&this.J!==t){if(t.exist){var s=void 0,h=30;if(this.kt)null!=this.J&&this.J.exist&&this.J.ag.stop(),t.ag.start(t.loop,t.rate),h=t.ag.targetedAnimations[0].animation.framePerSecond,s=t.ag.to-t.ag.from;else h=this.h.beginAnimation(t.name,t.loop,t.rate).getAnimations()[0].animation.framePerSecond,s=this.h.getAnimationRange(t.name).to-this.h.getAnimationRange(t.name).from;null!=this.J&&null!=this.J.sound&&this.J.sound.stop(),clearInterval(this.V),null!=t.sound&&(t.sound.play(),this.V=setInterval((function(){t.sound.play()}),1e3*s/(h*Math.abs(t.rate)*2)))}this.J=t}this.Ht()},i.prototype.Ut=function(i){var s=null;s=this.g.runJump,0===this.X&&(this.W=this.i.position.y),this.X=this.X+i;var h,n=0,e=0;if(this.P||this.N?(this.P?n=this.g.run.speed*i:this.N&&(n=this.g.walk.speed*i),(h=this.Xt.clone()).y=0,(h=h.normalize()).scaleToRef(n,h),e=this.Yt(this.g.runJump.speed,i),h.y=e):(e=this.Yt(this.g.idleJump.speed,i),h=new t.Vector3(0,e,0),s=this.g.idleJump),this.i.moveWithCollisions(h),e<0)if(this.i.position.y>this._.y||this.i.position.y===this._.y&&h.length()>.001)this.Zt();else if(this.i.position.y0?this.g.strafeLeftFast:this.g.strafeRightFast):h=-this.zt*n>0?this.g.strafeLeft:this.g.strafeRight,this.Xt=this.i.calcMovePOV(n*e,-this.T,0),s=!0;break;case this.gt.ei:n=-this.q*this.Pt(),e=this.g.strafeRight.speed*t,this.gt.ni?(e=this.g.strafeRightFast.speed*t,h=-this.zt*n>0?this.g.strafeLeftFast:this.g.strafeRightFast):h=-this.zt*n>0?this.g.strafeLeft:this.g.strafeRight,this.Xt=this.i.calcMovePOV(n*e,-this.T,0),s=!0;break;case this.gt.ri||this.tt&&0==this.L:this.gt.ni?(this.P=!0,e=this.g.run.speed*t,h=this.g.run):(this.N=!0,e=this.g.walk.speed*t,h=this.g.walk),this.Xt=this.i.calcMovePOV(0,-this.T,this.zt*e),s=!0;break;case this.gt.ui:e=this.g.walkBack.speed*t,this.gt.ni?(e=this.g.walkBackFast.speed*t,h=this.g.walkBackFast):h=this.g.walkBack,this.Xt=this.i.calcMovePOV(0,-this.T,-this.zt*e),s=!0}}if(s&&this.Xt.length()>.001)if(this.i.moveWithCollisions(this.Xt),this.i.position.y>this._.y){var r=this.i.position.subtract(this._),u=this.ti(r);u>=this.M?this.p>0?(0==this.j&&this.O.copyFrom(this._),this.j=this.j+(this.i.position.y-this._.y),this.j>this.p&&(this.j=0,this.i.position.copyFrom(this.O),this.fi())):(this.i.position.copyFrom(this._),this.fi()):(this.j=0,u>this.k?(this.H=0,this.K=!1):this.fi())}else if(this.i.position.ythis.G&&(h=this.g.fall)):this.ti(r)<=this.k?this.fi():(this.H=0,this.K=!1)}else this.fi();return h},i.prototype.ii=function(){if(this.dt&&1!=this.L){var t=this.dt?this.Tt-this.jt.alpha:0;if(this.tt)switch(!0){case this.gt.ri&&this.gt.ai:this.i.rotation.y=t+this.Dt*Math.PI/4;break;case this.gt.ri&&this.gt.oi:this.i.rotation.y=t-this.Dt*Math.PI/4;break;case this.gt.ui&&this.gt.ai:this.i.rotation.y=t+3*this.Dt*Math.PI/4;break;case this.gt.ui&&this.gt.oi:this.i.rotation.y=t-3*this.Dt*Math.PI/4;break;case this.gt.ri:this.i.rotation.y=t;break;case this.gt.ui:this.i.rotation.y=t+Math.PI;break;case this.gt.ai:this.i.rotation.y=t+this.Dt*Math.PI/2;break;case this.gt.oi:this.i.rotation.y=t-this.Dt*Math.PI/2}else this.dt&&(this.i.rotation.y=t)}},i.prototype.si=function(t,i,s){if((!this.tt||0!=this.L)&&!this.gt.hi&&!this.gt.ei&&(this.gt.oi||this.gt.ai)){var h=this.g.turnLeft.speed*s;this.gt.ni&&(h*=2);var n=void 0;1==this.L?(this.$||(this.Z=-this.zt*this.Pt(),this.S&&(this.Z=-this.Z),this.$=!0),n=this.Z,this.gt.oi?this.gt.ri||(this.gt.ui?n=-this.Z:t=this.Z>0?this.g.turnRight:this.g.turnLeft):this.gt.ri?n=-this.Z:this.gt.ui||(n=-this.Z,t=this.Z>0?this.g.turnLeft:this.g.turnRight)):(n=1,this.gt.oi?(this.gt.ui&&(n=-1),i||(t=this.g.turnLeft)):(this.gt.ri&&(n=-1),i||(n=-1,t=this.g.turnRight)),this.dt&&(this.jt.alpha=this.jt.alpha+this.Dt*h*n)),this.i.rotation.y=this.i.rotation.y+h*n}return t},i.prototype.fi=function(){this.Y=0,this.H=0,this.K=!1},i.prototype.Wt=function(i){if(this.D)return this.g.idle;this.N=!1,this.P=!1,this.Y=0;var s=this.g.idle;if(this.H=0,0===i)this.T=5;else{var h=this.it*this.u;this.T=h*i+this.u*i*i/2,this.it=this.it+i}if(this.T<.01)return s;var n=new t.Vector3(0,-this.T,0);if(this.i.moveWithCollisions(n),this.i.position.y>this._.y||this.i.position.y===this._.y)this.ci();else if(this.i.position.ythis.ht&&(this.D=!0,this.it=0)},i.prototype.li=function(){this.D=!1,this.st=0},i.prototype.Ht=function(){this.dt&&(0==this.j&&this.i.position.addToRef(this.F,this.jt.target),this.jt.radius>this.jt.lowerRadiusLimit&&(this.C||this.lt)&&this.vi(),this.jt.radius<=this.jt.lowerRadiusLimit?this.A||this.et||(this.bi(this.i),this.jt.checkCollisions=!1,this.R=this.L,this.L=0,this.et=!0):this.et&&(this.et=!1,this.L=this.R,this.wi(this.i),this.jt.checkCollisions=this.nt))},i.prototype.bi=function(i){var s=this;this.rt.set(i,i.visibility),i.visibility=0,i.getChildMeshes(!1,(function(i){return i instanceof t.Mesh&&(s.rt.set(i,i.visibility),i.visibility=0),!1}))},i.prototype.wi=function(i){var s=this;i.visibility=this.rt.get(i),i.getChildMeshes(!1,(function(i){return i instanceof t.Mesh&&(i.visibility=s.rt.get(i)),!1}))},i.prototype.vi=function(){var t=this;this.jt.position.subtractToRef(this.jt.target,this.ft),this.ut.origin=this.jt.target,this.ut.length=this.ft.length(),this.ut.direction=this.ft.normalize();var i=this.yt.multiPickWithRay(this.ut,(function(i){return i!=t.i}));if(this.lt)if(this.ki=this.ct,i.length>0){this.ct=new Array;for(var s=0,h=i;s0){if(!(1!=i.length||this.Mi(i[0].pickedMesh)||i[0].pickedMesh.checkCollisions&&this.jt.checkCollisions))return;for(var o=null,c=0;c0?h[0].skeleton:null},i.prototype.pi=function(t){return null==t.parent?t:this.pi(t.parent)},i.prototype.setAvatar=function(i,s){void 0===s&&(s=!1);var h=this.pi(i);return h instanceof t.Mesh?(this.i=h,this.h=this.di(i),this.kt=this.Et(i,this.yt.animationGroups,!0),this.g.reset(),this.kt||null==this.h||this.Ot(this.h),this.Jt(i),this.setFaceForward(s),!0):(console.error("Cannot move this mesh. The root node of the mesh provided is not a mesh"),!1)},i.prototype.getAvatar=function(){return this.i},i.prototype.setAvatarSkeleton=function(t){this.h=t,null!=this.h&&this.ji(t)?this.kt=!0:this.kt=!1,this.kt||null==this.h||this.Ot(this.h)},i.prototype.ji=function(t){var i=this;return t.animations.some((function(t){return i.yt.animationGroups.some((function(i){return i.children.some((function(i){return i.animation==t}))}))}))},i.prototype.getSkeleton=function(){return this.h},i}(),s=function(){function t(){this.ri=!1,this.ui=!1,this.ai=!1,this.oi=!1,this.ei=!1,this.hi=!1,this.Qt=!1,this.ni=!1,this.reset()}return t.prototype.reset=function(){this.ri=!1,this.ui=!1,this.ai=!1,this.oi=!1,this.ei=!1,this.hi=!1,this.Qt=!1,this.ni=!1},t}(),e=function(){function t(t,i,s){void 0===i&&(i=1),this.name="",this.loop=!0,this.rate=1,this.exist=!1,this.id=t,this.speed=i,this.ds=i,this.key=s,this.dk=s}return t.prototype.reset=function(){this.name="",this.speed=this.ds,this.key=this.dk,this.loop=!0,this.rate=1,this.sound=null,this.exist=!1},t}(),r=function(){function t(){this.walk=new e("walk",3,"w"),this.walkBack=new e("walkBack",1.5,"s"),this.walkBackFast=new e("walkBackFast",3,"na"),this.idle=new e("idle",0,"na"),this.idleJump=new e("idleJump",6," "),this.run=new e("run",6,"na"),this.runJump=new e("runJump",6,"na"),this.fall=new e("fall",0,"na"),this.turnLeft=new e("turnLeft",Math.PI/8,"a"),this.turnLeftFast=new e("turnLeftFast",Math.PI/4,"na"),this.turnRight=new e("turnRight",Math.PI/8,"d"),this.turnRightFast=new e("turnRightFast",Math.PI/4,"na"),this.strafeLeft=new e("strafeLeft",1.5,"q"),this.strafeLeftFast=new e("strafeLeftFast",3,"na"),this.strafeRight=new e("strafeRight",1.5,"e"),this.strafeRightFast=new e("strafeRightFast",3,"na"),this.slideBack=new e("slideBack",0,"na")}return t.prototype.reset=function(){for(var t=0,i=Object.keys(this);t {\nreturn ","module.exports = __WEBPACK_EXTERNAL_MODULE__247__;","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import {\r\n Skeleton,\r\n ArcRotateCamera,\r\n Vector3,\r\n Mesh,\r\n Node,\r\n Scene,\r\n Ray,\r\n PickingInfo,\r\n AnimationGroup,\r\n TransformNode,\r\n TargetedAnimation,\r\n Matrix,\r\n DeepImmutable,\r\n AbstractMesh,\r\n PlaySoundAction,\r\n InstancedMesh,\r\n Sound,\r\n AnimationRange,\r\n Animatable,\r\n AnimationEvent,\r\n int\r\n} from \"babylonjs\";\r\n\r\n\r\nexport class CharacterController {\r\n\r\n private _avatar: Mesh = null;\r\n private _skeleton: Skeleton = null;\r\n private _camera: ArcRotateCamera;\r\n private _scene: Scene;\r\n public getScene(): Scene {\r\n return this._scene;\r\n }\r\n\r\n\r\n private _gravity: number = 9.8;\r\n //slopeLimit in degrees\r\n private _minSlopeLimit: number = 30;\r\n private _maxSlopeLimit: number = 45;\r\n //slopeLimit in radians\r\n private _sl1: number = Math.PI * this._minSlopeLimit / 180;\r\n private _sl2: number = Math.PI * this._maxSlopeLimit / 180;\r\n\r\n //The av will step up a stair only if it is closer to the ground than the indicated value.\r\n private _stepOffset: number = 0.25;\r\n //toal amount by which the av has moved up\r\n private _vMoveTot: number = 0;\r\n //position of av when it started moving up\r\n private _vMovStartPos: Vector3 = Vector3.Zero();\r\n\r\n\r\n private _actionMap: ActionMap = new ActionMap();\r\n\r\n private _cameraElastic: boolean = true;\r\n private _cameraTarget: Vector3 = Vector3.Zero();\r\n //should we go into first person view when camera is near avatar (radius is lowerradius limit)\r\n private _noFirstPerson: boolean = false;\r\n\r\n\r\n\r\n public setSlopeLimit(minSlopeLimit: number, maxSlopeLimit: number) {\r\n this._minSlopeLimit = minSlopeLimit;\r\n this._maxSlopeLimit = maxSlopeLimit;\r\n\r\n this._sl1 = Math.PI * this._minSlopeLimit / 180;\r\n this._sl2 = Math.PI * this._maxSlopeLimit / 180;\r\n }\r\n\r\n /**\r\n * The av will step up a stair only if it is closer to the ground than the indicated value.\r\n * Default value is 0.25 m\r\n */\r\n public setStepOffset(stepOffset: number) {\r\n this._stepOffset = stepOffset;\r\n }\r\n\r\n public setWalkSpeed(n: number) {\r\n this._actionMap.walk.speed = n;\r\n }\r\n public setRunSpeed(n: number) {\r\n this._actionMap.run.speed = n;\r\n }\r\n public setBackSpeed(n: number) {\r\n this._actionMap.walkBack.speed = n;\r\n }\r\n public setBackFastSpeed(n: number) {\r\n this._actionMap.walkBackFast.speed = n;\r\n }\r\n public setJumpSpeed(n: number) {\r\n this._actionMap.idleJump.speed = n;\r\n this._actionMap.runJump.speed = n;\r\n }\r\n public setLeftSpeed(n: number) {\r\n this._actionMap.strafeLeft.speed = n;\r\n }\r\n public setLeftFastSpeed(n: number) {\r\n this._actionMap.strafeLeftFast.speed = n;\r\n }\r\n public setRightSpeed(n: number) {\r\n this._actionMap.strafeRight.speed = n;\r\n }\r\n public setRightFastSpeed(n: number) {\r\n this._actionMap.strafeLeftFast.speed = n;\r\n }\r\n // get turnSpeed in degrees per second.\r\n // store in radians per second\r\n public setTurnSpeed(n: number) {\r\n this._actionMap.turnLeft.speed = n * Math.PI / 180;\r\n this._actionMap.turnRight.speed = n * Math.PI / 180;\r\n }\r\n public setTurnFastSpeed(n: number) {\r\n this._actionMap.turnLeftFast.speed = n * Math.PI / 180;\r\n this._actionMap.turnRightFast.speed = n * Math.PI / 180;\r\n }\r\n public setGravity(n: number) {\r\n this._gravity = n;\r\n }\r\n\r\n /**\r\n * Use this to provide animationGroups to the character controller.\r\n * Provide the AnimationGroups using a Map\r\n * In this Map the key would be the character controller animation name and\r\n * the key value would be the animationGroup.\r\n * Example:\r\n * let myWalkAnimationGroup:AnimationGroup = ...;\r\n * let agMap:{} = {\r\n * \"walk\":myWalkAnimationGroup,\r\n * \"run\" : {\"ag\":myRunAnimationGroup,\"rate\":1},\r\n * \"idle\" : {\"ag\":myIdleAnimationGroup,\"loop\":true,\"rate\":1},\r\n * ....\r\n * ....\r\n * }\r\n * \r\n * @param agMap a map of character controller animation name to animationGroup\r\n */\r\n public setAnimationGroups(agMap: {}) {\r\n if (this._prevActData != null && this._prevActData.exist) this._prevActData.ag.stop();\r\n this._isAG = true;\r\n this.setActionMap(agMap);\r\n }\r\n\r\n /**\r\n * Use this to provide AnimationRanges to the character controller.\r\n * Provide the AnimationRanges using a Map\r\n * In this Map the key would be the character controller animation name and\r\n * the key value would be the animation range name or an object with animation range data.\r\n * example:\r\n * let arMap = {\r\n * \"walk\":\"myWalk\",\r\n * \"run\" : {\"name\":\"myRun\",\"rate\":1},\r\n * \"idle\" : {\"name\":\"myIdle\",\"loop\":true,\"rate\":1},\r\n * ....\r\n * }\r\n * \r\n * @param arMap a map of character controller animation name to animationRange data\r\n */\r\n\r\n public setAnimationRanges(arMap: {}) {\r\n this._isAG = false;\r\n this.setActionMap(arMap);\r\n }\r\n\r\n /**\r\n * updates action data in the cc actionMap\r\n * with action data from the provided/input actionMap \r\n * \r\n * \r\n * return \"ar\" or \"ag\" depending on if the data provided\r\n * was animation range or animation group data respt.\r\n * \r\n * TODO should validate provided data.\r\n * In other words if animation range provided make sure\r\n * the range exist in the skeleton\r\n * or if animation group provided make sure the animation group\r\n * can be played on this avataor\r\n * \r\n * @param inActMap \r\n * @returns \r\n */\r\n public setActionMap(inActMap: ActionMap): string {\r\n let agMap: boolean = false;\r\n let inActData: ActionData;\r\n\r\n\r\n let ccActionNames: string[] = Object.keys(this._actionMap);\r\n for (let ccActionName of ccActionNames) {\r\n let ccActData = this._actionMap[ccActionName];\r\n //some keys could map to functions (like reset())\r\n if (!(ccActData instanceof ActionData)) continue;\r\n ccActData.exist = false;\r\n\r\n inActData = inActMap[ccActData.id];\r\n //in previous version of cc the key value was AnimationGroup rather than ActionData\r\n //lets accomodate that for backward compatibility\r\n if (inActData != null) {\r\n if (inActData instanceof AnimationGroup) {\r\n ccActData.ag = inActData;\r\n ccActData.name = ccActData.ag.name;\r\n ccActData.exist = true;\r\n agMap = true;\r\n this._hasAnims = true;\r\n } else if (inActData.exist) {\r\n this._hasAnims = true;\r\n ccActData.exist = true;\r\n if (inActData instanceof Object) {\r\n if (inActData.ag) {\r\n ccActData.ag = inActData.ag;\r\n agMap = true;\r\n }\r\n if (inActData.name) {\r\n ccActData.name = inActData.name;\r\n }\r\n if (inActData.loop != null) ccActData.loop = inActData.loop;\r\n if (inActData.rate) ccActData.rate = inActData.rate;\r\n if (inActData.speed) ccActData.speed = inActData.speed;\r\n // if (actDataI.key) actDataO.key = actDataI.key;\r\n if (inActData.sound) ccActData.sound = inActData.sound;\r\n } else {\r\n ccActData.name = inActData;\r\n }\r\n }\r\n }\r\n }\r\n this._checkFastAnims();\r\n //force to play new anims\r\n this._prevActData = null;\r\n if (agMap) return \"ag\"; else return \"ar\";\r\n }\r\n\r\n public getActionMap(): ActionMap {\r\n let map: ActionMap = new ActionMap();\r\n\r\n let keys: string[] = Object.keys(this._actionMap);\r\n for (let key of keys) {\r\n let actDataI = this._actionMap[key];\r\n\r\n if (!(actDataI instanceof ActionData)) continue;\r\n if (!actDataI.exist) continue;\r\n\r\n let actDataO: ActionData = map[actDataI.id];\r\n actDataO.ag = actDataI.ag;\r\n actDataO.name = actDataI.name;\r\n actDataO.loop = actDataI.loop;\r\n actDataO.rate = actDataI.rate;\r\n actDataO.speed = actDataI.speed;\r\n actDataO.key = actDataI.key;\r\n actDataO.sound = actDataI.sound;\r\n actDataO.exist = actDataI.exist;\r\n }\r\n\r\n return map;\r\n }\r\n\r\n public getSettings(): CCSettings {\r\n let ccs: CCSettings = new CCSettings();\r\n ccs.faceForward = this.isFaceForward();\r\n ccs.topDown = this.getMode() == 1 ? true : false;\r\n ccs.turningOff = this.isTurningOff();\r\n ccs.cameraTarget = this._cameraTarget.clone();\r\n ccs.cameraElastic = this._cameraElastic;\r\n ccs.elasticSteps = this._elasticSteps;\r\n ccs.makeInvisble = this._makeInvisible;\r\n ccs.gravity = this._gravity;\r\n ccs.keyboard = this._ekb;\r\n ccs.maxSlopeLimit = this._maxSlopeLimit;\r\n ccs.minSlopeLimit = this._minSlopeLimit;\r\n ccs.noFirstPerson = this._noFirstPerson;\r\n ccs.stepOffset = this._stepOffset;\r\n ccs.sound = this._stepSound;\r\n\r\n return ccs;\r\n }\r\n\r\n public setSettings(ccs: CCSettings) {\r\n this.setFaceForward(ccs.faceForward);\r\n this.setMode(ccs.topDown ? 1 : 0);\r\n this.setTurningOff(ccs.turningOff);\r\n this.setCameraTarget(ccs.cameraTarget);\r\n this.setCameraElasticity(ccs.cameraElastic);\r\n this.setElasticiSteps(ccs.elasticSteps);\r\n this.makeObstructionInvisible(ccs.makeInvisble);\r\n this.setGravity(ccs.gravity);\r\n this.enableKeyBoard(ccs.keyboard);\r\n this.setSlopeLimit(ccs.minSlopeLimit, ccs.maxSlopeLimit);\r\n this.setNoFirstPerson(ccs.noFirstPerson);\r\n this.setStepOffset(ccs.stepOffset);\r\n this.setSound(ccs.sound);\r\n\r\n }\r\n\r\n private _setAnim(anim: ActionData, animName?: string | AnimationGroup, rate?: number, loop?: boolean) {\r\n\r\n //animation range need skeleton\r\n if (!this._isAG && this._skeleton == null) return;\r\n\r\n if (animName != null) {\r\n if (this._isAG) {\r\n if (!(animName instanceof AnimationGroup)) return;\r\n anim.ag = animName;\r\n anim.exist = true;\r\n } else {\r\n if (this._skeleton.getAnimationRange(anim.name) != null) {\r\n anim.name = animName;\r\n anim.exist = true;\r\n } else {\r\n anim.exist = false;\r\n return;\r\n }\r\n }\r\n }\r\n\r\n if (loop != null) anim.loop = loop;\r\n if (rate != null) anim.rate = rate;\r\n }\r\n\r\n public enableBlending(n: number) {\r\n if (this._isAG) {\r\n let keys: string[] = Object.keys(this._actionMap);\r\n for (let key of keys) {\r\n let act = this._actionMap[key];\r\n if (!(act instanceof ActionData)) continue;\r\n if (act.exist) {\r\n let ar: AnimationGroup = act.ag;\r\n for (let ta of ar.targetedAnimations) {\r\n ta.animation.enableBlending = true;\r\n ta.animation.blendingSpeed = n;\r\n }\r\n }\r\n }\r\n } else {\r\n if (this._skeleton !== null)\r\n this._skeleton.enableBlending(n);\r\n }\r\n }\r\n\r\n public disableBlending() {\r\n if (this._isAG) {\r\n let keys: string[] = Object.keys(this._actionMap);\r\n for (let key of keys) {\r\n let anim = this._actionMap[key];\r\n if (!(anim instanceof ActionData)) continue;\r\n if (anim.exist) {\r\n let ar: AnimationGroup = anim.ag;\r\n for (let ta of ar.targetedAnimations) {\r\n ta.animation.enableBlending = false;\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n //setters for animations\r\n public setWalkAnim(rangeName: string | AnimationGroup, rate: number, loop: boolean) {\r\n this._setAnim(this._actionMap.walk, rangeName, rate, loop);\r\n }\r\n public setRunAnim(rangeName: string | AnimationGroup, rate: number, loop: boolean) {\r\n this._setAnim(this._actionMap.run, rangeName, rate, loop);\r\n }\r\n public setWalkBackAnim(rangeName: string | AnimationGroup, rate: number, loop: boolean) {\r\n this._setAnim(this._actionMap.walkBack, rangeName, rate, loop);\r\n this._copySlowAnims(this._actionMap.walkBackFast, this._actionMap.walkBack);\r\n }\r\n public setWalkBackFastAnim(rangeName: string | AnimationGroup, rate: number, loop: boolean) {\r\n this._setAnim(this._actionMap.walkBackFast, rangeName, rate, loop);\r\n }\r\n public setSlideBackAnim(rangeName: string | AnimationGroup, rate: number, loop: boolean) {\r\n this._setAnim(this._actionMap.slideBack, rangeName, rate, loop);\r\n }\r\n public setIdleAnim(rangeName: string | AnimationGroup, rate: number, loop: boolean) {\r\n this._setAnim(this._actionMap.idle, rangeName, rate, loop);\r\n }\r\n public setTurnRightAnim(rangeName: string | AnimationGroup, rate: number, loop: boolean) {\r\n this._setAnim(this._actionMap.turnRight, rangeName, rate, loop);\r\n this._copySlowAnims(this._actionMap.turnRightFast, this._actionMap.turnRight);\r\n }\r\n public setTurnRightFastAnim(rangeName: string | AnimationGroup, rate: number, loop: boolean) {\r\n this._setAnim(this._actionMap.turnRightFast, rangeName, rate, loop);\r\n }\r\n public setTurnLeftAnim(rangeName: string | AnimationGroup, rate: number, loop: boolean) {\r\n this._setAnim(this._actionMap.turnLeft, rangeName, rate, loop);\r\n this._copySlowAnims(this._actionMap.turnLeftFast, this._actionMap.turnLeft);\r\n }\r\n public setTurnLeftFastAnim(rangeName: string | AnimationGroup, rate: number, loop: boolean) {\r\n this._setAnim(this._actionMap.turnLeftFast, rangeName, rate, loop);\r\n }\r\n public setStrafeRightAnim(rangeName: string | AnimationGroup, rate: number, loop: boolean) {\r\n this._setAnim(this._actionMap.strafeRight, rangeName, rate, loop);\r\n this._copySlowAnims(this._actionMap.strafeRightFast, this._actionMap.strafeRight);\r\n }\r\n public setStrafeRightFastAnim(rangeName: string | AnimationGroup, rate: number, loop: boolean) {\r\n this._setAnim(this._actionMap.strafeRightFast, rangeName, rate, loop);\r\n }\r\n public setStrafeLeftAnim(rangeName: string | AnimationGroup, rate: number, loop: boolean) {\r\n this._setAnim(this._actionMap.strafeLeft, rangeName, rate, loop);\r\n this._copySlowAnims(this._actionMap.strafeLeftFast, this._actionMap.strafeLeft);\r\n }\r\n public setStrafeLeftFastAnim(rangeName: string | AnimationGroup, rate: number, loop: boolean) {\r\n this._setAnim(this._actionMap.strafeLeftFast, rangeName, rate, loop);\r\n }\r\n public setIdleJumpAnim(rangeName: string | AnimationGroup, rate: number, loop: boolean) {\r\n this._setAnim(this._actionMap.idleJump, rangeName, rate, loop);\r\n }\r\n public setRunJumpAnim(rangeName: string | AnimationGroup, rate: number, loop: boolean) {\r\n this._setAnim(this._actionMap.runJump, rangeName, rate, loop);\r\n }\r\n public setFallAnim(rangeName: string | AnimationGroup, rate: number, loop: boolean) {\r\n this._setAnim(this._actionMap.fall, rangeName, rate, loop);\r\n }\r\n\r\n\r\n _stepSound: Sound;\r\n // setters for sound\r\n public setSound(sound: Sound) {\r\n if (sound == null) return;\r\n this._stepSound = sound;\r\n let ccActionNames: string[] = Object.keys(this._actionMap);\r\n sound.loop = false;\r\n for (let ccActionName of ccActionNames) {\r\n let ccActData = this._actionMap[ccActionName];\r\n //some keys could map to functions (like reset())\r\n if (!(ccActData instanceof ActionData)) continue;\r\n ccActData.sound = sound;\r\n ccActData.sound.attachToMesh(this._avatar);\r\n }\r\n this._actionMap.idle.sound = null;\r\n this._actionMap.fall.sound = null;\r\n this._actionMap.slideBack.sound = null;\r\n }\r\n\r\n\r\n // setters for keys\r\n public setWalkKey(key: string) {\r\n this._actionMap.walk.key = key.toLowerCase();\r\n }\r\n public setWalkBackKey(key: string) {\r\n this._actionMap.walkBack.key = key.toLowerCase();\r\n }\r\n public setTurnLeftKey(key: string) {\r\n this._actionMap.turnLeft.key = key.toLowerCase();\r\n }\r\n public setTurnRightKey(key: string) {\r\n this._actionMap.turnRight.key = key.toLowerCase();\r\n }\r\n public setStrafeLeftKey(key: string) {\r\n this._actionMap.strafeLeft.key = key.toLowerCase();\r\n }\r\n public setStrafeRightKey(key: string) {\r\n this._actionMap.strafeRight.key = key.toLowerCase();\r\n }\r\n public setJumpKey(key: string) {\r\n this._actionMap.idleJump.key = key.toLowerCase();\r\n }\r\n\r\n public setCameraElasticity(b: boolean) {\r\n this._cameraElastic = b;\r\n }\r\n\r\n public setElasticiSteps(n: number) {\r\n this._elasticSteps = n;\r\n }\r\n\r\n public makeObstructionInvisible(b: boolean) {\r\n this._makeInvisible = b;\r\n }\r\n public setCameraTarget(v: Vector3) {\r\n this._cameraTarget.copyFrom(v);\r\n }\r\n\r\n\r\n /**\r\n * user should call this whenever the user changes the camera checkCollision \r\n * property\r\n * \r\n */\r\n public cameraCollisionChanged() {\r\n this._savedCameraCollision = this._camera.checkCollisions;\r\n }\r\n public setNoFirstPerson(b: boolean) {\r\n this._noFirstPerson = b;\r\n }\r\n\r\n /**\r\n * if av has the required anim (walk, run etc) then \r\n * mark that anim as existing\r\n * \r\n * @param skel \r\n */\r\n\r\n private _checkAnimRanges(skel: Skeleton) {\r\n let keys: string[] = Object.keys(this._actionMap);\r\n for (let key of keys) {\r\n let anim = this._actionMap[key];\r\n if (!(anim instanceof ActionData)) continue;\r\n if (skel != null) {\r\n if (skel.getAnimationRange(anim.id) != null) {\r\n anim.name = anim.id;\r\n anim.exist = true;\r\n this._hasAnims = true;\r\n }\r\n } else {\r\n anim.exist = false;\r\n }\r\n }\r\n this._checkFastAnims();\r\n }\r\n\r\n /**\r\n * if fast anims do not exist then use their slow counterpart as them but double the rate at which they play\r\n */\r\n private _checkFastAnims() {\r\n this._copySlowAnims(this._actionMap.walkBackFast, this._actionMap.walkBack)\r\n this._copySlowAnims(this._actionMap.turnRightFast, this._actionMap.turnRight);\r\n this._copySlowAnims(this._actionMap.turnLeftFast, this._actionMap.turnLeft);\r\n this._copySlowAnims(this._actionMap.strafeRightFast, this._actionMap.strafeRight);\r\n this._copySlowAnims(this._actionMap.strafeLeftFast, this._actionMap.strafeLeft);\r\n }\r\n\r\n private _copySlowAnims(f: ActionData, s: ActionData) {\r\n if (f.exist) return;\r\n if (!s.exist) return;\r\n f.exist = true;\r\n f.ag = s.ag;\r\n f.name = s.name;\r\n f.rate = s.rate * 2;\r\n }\r\n\r\n /**\r\n * Use this to make the character controller suitable for a isometeric/top down games or fps/third person game.\r\n * 1 In isometric/top down games the camera direction has no bearing on avatar movement.\r\n * 0 In fps/third person game rotating the camera around the avatar , rotates the avatar too.\r\n * \r\n * cannot switch mode to 0 if no camera avaiable.\r\n */\r\n private _mode = 0;\r\n private _saveMode = 0;\r\n public setMode(n: number) {\r\n //cannot switch mode to 0 if no camera avaiable.\r\n if (this._hasCam) {\r\n this._mode = n;\r\n this._saveMode = n;\r\n } else {\r\n this._mode = 1;\r\n this._saveMode = 1;\r\n }\r\n }\r\n public getMode() {\r\n return this._mode;\r\n }\r\n /**\r\n * Use this to set turning off.\r\n * When turining is off \r\n * a) turn left or turn right keys result in avatar facing and moving left or right with respect to camera.\r\n * b) walkback/runback key results in avatar facing back and walking/running towards camera.\r\n * \r\n * This setting has no effect when mode is 1.\r\n * \r\n * @param b \r\n */\r\n public setTurningOff(b: boolean) {\r\n this._noRot = b;\r\n }\r\n public isTurningOff() {\r\n return this._noRot;\r\n }\r\n\r\n /**\r\n * checks if a have left hand , right hand issue.\r\n * In other words if a mesh is a LHS mesh in RHS system or \r\n * a RHS mesh in LHS system\r\n * The X axis will be reversed in such cases.\r\n * thus Cross product of X and Y should be inverse of Z.\r\n * BABYLONJS GLB models are RHS and exhibit this behavior\r\n * \r\n */\r\n private _isLHS_RHS = false;\r\n private _signLHS_RHS = -1;\r\n private _setRHS(mesh: TransformNode) {\r\n const meshMatrix: Matrix = mesh.getWorldMatrix();\r\n const _localX = Vector3.FromArray(meshMatrix.m, 0);\r\n const _localY = Vector3.FromArray(meshMatrix.m, 4);\r\n const _localZ = Vector3.FromArray(meshMatrix.m, 8);\r\n const actualZ = Vector3.Cross(_localX, _localY);\r\n //same direction or opposite direction of Z\r\n if (Vector3.Dot(actualZ, _localZ) < 0) {\r\n this._isLHS_RHS = true;\r\n this._signLHS_RHS = 1;\r\n }\r\n else {\r\n this._isLHS_RHS = false;\r\n this._signLHS_RHS = -1;\r\n }\r\n }\r\n\r\n /**\r\n * Use setFaceForward(true|false) to indicate that the avatar's face points forward (true) or backward (false).\r\n * The avatar's face points forward if its face is looking in positive local Z axis direction\r\n */\r\n private _ffSign: number;\r\n private _rhsSign: number;\r\n private _ff: boolean;\r\n //in mode 0, av2cam is used to align avatar with camera , with camera always facing avatar's back\r\n //note:camera alpha is measured anti-clockwise , avatar rotation is measured clockwise \r\n private _av2cam;\r\n public setFaceForward(b: boolean) {\r\n this._ff = b;\r\n\r\n this._rhsSign = this._scene.useRightHandedSystem ? -1 : 1;\r\n\r\n if (!this._hasCam) {\r\n this._av2cam = 0;\r\n this._ffSign = 1;\r\n return;\r\n }\r\n\r\n if (this._isLHS_RHS) {\r\n this._av2cam = b ? Math.PI / 2 : 3 * Math.PI / 2;\r\n this._ffSign = b ? 1 : -1;\r\n } else {\r\n this._av2cam = b ? 3 * Math.PI / 2 : Math.PI / 2;\r\n this._ffSign = b ? -1 : 1;\r\n }\r\n\r\n }\r\n\r\n public isFaceForward() {\r\n return this._ff;\r\n }\r\n\r\n private checkAGs(agMap: {}) {\r\n let keys: string[] = Object.keys(this._actionMap);\r\n for (let key of keys) {\r\n let anim = this._actionMap[key];\r\n if (!(anim instanceof ActionData)) continue;\r\n if (agMap[anim.name] != null) {\r\n anim.ag = agMap[anim.name];\r\n anim.exist = true;\r\n }\r\n }\r\n }\r\n\r\n // check if any of the mesh on the node tree is refrenced by any animation group\r\n private _containsAG(node: Node, ags: AnimationGroup[], fromRoot: boolean) {\r\n let r: Node;\r\n let ns: Node[];\r\n\r\n if (fromRoot) {\r\n r = this._getRoot(node);\r\n ns = r.getChildren((n) => { return (n instanceof TransformNode) }, false);\r\n } else {\r\n r = node;\r\n ns = [r];\r\n }\r\n\r\n for (let ag of ags) {\r\n let tas: TargetedAnimation[] = ag.targetedAnimations;\r\n for (let ta of tas) {\r\n if (ns.indexOf(ta.target) > -1) {\r\n return true;\r\n }\r\n }\r\n }\r\n return false;\r\n }\r\n\r\n //get the root of Node\r\n private _getRoot(tn: Node): Node {\r\n if (tn.parent == null) return tn;\r\n return this._getRoot(tn.parent);\r\n }\r\n\r\n private _started: boolean = false;\r\n public start() {\r\n if (this._started) return;\r\n this._started = true;\r\n this._act.reset();\r\n this._movFallTime = 0;\r\n //first time we enter render loop, delta time is zero\r\n this._idleFallTime = 0.001;\r\n this._grounded = false;\r\n this._updateTargetValue();\r\n if (this._ekb) this._addkeylistener();\r\n this._scene.registerBeforeRender(this._renderer);\r\n }\r\n\r\n public stop() {\r\n if (!this._started) return;\r\n this._started = false;\r\n this._scene.unregisterBeforeRender(this._renderer);\r\n this._removekeylistener();\r\n this._prevActData = null;\r\n }\r\n\r\n /**\r\n * use pauseAnim to stop the charactere controller from playing\r\n * any animation on the character\r\n * use this when you want to play your animation instead\r\n * see also resumeAnim()\r\n */\r\n private _stopAnim: boolean = false;\r\n public pauseAnim() {\r\n this._stopAnim = true;\r\n\r\n if (this._prevActData != null && this._prevActData.exist) {\r\n //stop current animation\r\n if (this._isAG) {\r\n this._prevActData.ag.stop();\r\n } else {\r\n //this._scene.stopAnimation(this._skeleton, this._prevActData.name);\r\n this._scene.stopAnimation(this._skeleton);\r\n //this._scene.stopAllAnimations();\r\n }\r\n //stop current sound\r\n if (this._prevActData.sound != null) {\r\n this._prevActData.sound.stop();\r\n }\r\n clearInterval(this._sndId);\r\n\r\n this._scene.unregisterBeforeRender(this._renderer);\r\n }\r\n }\r\n\r\n /**\r\n * use resumeAnim to resume the character controller playing\r\n * animations on the character.\r\n * see also pauseAnim()\r\n */\r\n public resumeAnim() {\r\n this._stopAnim = false;\r\n this._prevActData = null;\r\n this._scene.registerBeforeRender(this._renderer);\r\n }\r\n\r\n private _prevActData: ActionData = null;\r\n private _avStartPos: Vector3 = Vector3.Zero();\r\n private _grounded: boolean = false;\r\n //distance by which AV would move down if in freefall\r\n private _freeFallDist: number = 0;\r\n\r\n //how many minimum contiguos frames should the AV have been in free fall\r\n //before we assume AV is in big freefall.\r\n //we will use this to remove animation flicker during move down a slope (fall, move, fall move etc)\r\n //TODO: base this on slope - large slope large count\r\n private _fallFrameCountMin: number = 50;\r\n private _fallFrameCount: number = 0;\r\n\r\n private _inFreeFall: boolean = false;\r\n private _wasWalking: boolean = false;\r\n private _wasRunning: boolean = false;\r\n private _moveVector: Vector3;\r\n\r\n //used only in mode 1\r\n //value 1 or -1 , -1 if avatar is facing camera\r\n //private _notFacingCamera = 1;\r\n\r\n private _isAvFacingCamera(): number {\r\n if (!this._hasCam) return 1;\r\n if (Vector3.Dot(this._avatar.forward, this._avatar.position.subtract(this._camera.position)) < 0) return 1\r\n else return -1;\r\n }\r\n\r\n private _moveAVandCamera() {\r\n this._avStartPos.copyFrom(this._avatar.position);\r\n let actData: ActionData = null;\r\n const dt: number = this._scene.getEngine().getDeltaTime() / 1000;\r\n\r\n if (this._act._jump && !this._inFreeFall) {\r\n this._grounded = false;\r\n this._idleFallTime = 0;\r\n actData = this._doJump(dt);\r\n } else if (this.anyMovement() || this._inFreeFall) {\r\n this._grounded = false;\r\n this._idleFallTime = 0;\r\n actData = this._doMove(dt);\r\n } else if (!this._inFreeFall) {\r\n actData = this._doIdle(dt);\r\n }\r\n if (!this._stopAnim && this._hasAnims && actData != null) {\r\n if (this._prevActData !== actData) {\r\n if (actData.exist) {\r\n\r\n //animation frame counts\r\n let c: number;\r\n let fps: number = 30;\r\n\r\n if (this._isAG) {\r\n if (this._prevActData != null && this._prevActData.exist) this._prevActData.ag.stop();\r\n actData.ag.start(actData.loop, actData.rate);\r\n fps = actData.ag.targetedAnimations[0].animation.framePerSecond;\r\n c = (actData.ag.to - actData.ag.from);\r\n } else {\r\n let a: Animatable = this._skeleton.beginAnimation(actData.name, actData.loop, actData.rate);\r\n fps = a.getAnimations()[0].animation.framePerSecond;\r\n c = this._skeleton.getAnimationRange(actData.name).to - this._skeleton.getAnimationRange(actData.name).from;\r\n }\r\n\r\n //SOUND\r\n //TODO do sound as animationevent.\r\n if (this._prevActData != null && this._prevActData.sound != null) {\r\n this._prevActData.sound.stop();\r\n }\r\n clearInterval(this._sndId);\r\n if (actData.sound != null) {\r\n actData.sound.play();\r\n //play sound twice during the animation\r\n this._sndId = setInterval(() => { actData.sound.play(); }, c * 1000 / (fps * Math.abs(actData.rate) * 2));\r\n }\r\n }\r\n this._prevActData = actData;\r\n }\r\n }\r\n this._updateTargetValue();\r\n return;\r\n }\r\n\r\n private _soundLoopTime = 700;\r\n private _sndId = null;\r\n\r\n //verical position of AV when it is about to start a jump\r\n private _jumpStartPosY: number = 0;\r\n //for how long the AV has been in the jump\r\n private _jumpTime: number = 0;\r\n private _doJump(dt: number): ActionData {\r\n\r\n let actData: ActionData = null;\r\n actData = this._actionMap.runJump;\r\n if (this._jumpTime === 0) {\r\n this._jumpStartPosY = this._avatar.position.y;\r\n }\r\n\r\n this._jumpTime = this._jumpTime + dt;\r\n\r\n let forwardDist: number = 0;\r\n let jumpDist: number = 0;\r\n let disp: Vector3;\r\n\r\n // if (this._hasCam && this._mode != 1 && !this._noRot) this._avatar.rotation.y = this._av2cam - this._camera.alpha;\r\n if (this._wasRunning || this._wasWalking) {\r\n if (this._wasRunning) {\r\n forwardDist = this._actionMap.run.speed * dt;\r\n } else if (this._wasWalking) {\r\n forwardDist = this._actionMap.walk.speed * dt;\r\n }\r\n //find out in which horizontal direction the AV was moving when it started the jump\r\n disp = this._moveVector.clone();\r\n disp.y = 0;\r\n disp = disp.normalize();\r\n disp.scaleToRef(forwardDist, disp);\r\n jumpDist = this._calcJumpDist(this._actionMap.runJump.speed, dt);\r\n disp.y = jumpDist;\r\n } else {\r\n jumpDist = this._calcJumpDist(this._actionMap.idleJump.speed, dt);\r\n disp = new Vector3(0, jumpDist, 0);\r\n actData = this._actionMap.idleJump;\r\n //this.avatar.ellipsoid.y=this._ellipsoid.y/2;\r\n }\r\n //moveWithCollision only seems to happen if length of displacment is atleast 0.001\r\n this._avatar.moveWithCollisions(disp);\r\n if (jumpDist < 0) {\r\n //this.avatar.ellipsoid.y=this._ellipsoid.y;\r\n //check if going up a slope or back on flat ground \r\n if ((this._avatar.position.y > this._avStartPos.y) || ((this._avatar.position.y === this._avStartPos.y) && (disp.length() > 0.001))) {\r\n this._endJump();\r\n } else if (this._avatar.position.y < this._jumpStartPosY) {\r\n //the avatar is below the point from where it started the jump\r\n //so it is either in free fall or is sliding along a downward slope\r\n //\r\n //if the actual displacemnt is same as the desired displacement then AV is in freefall\r\n //else it is on a slope\r\n const actDisp: Vector3 = this._avatar.position.subtract(this._avStartPos);\r\n if (!(this._areVectorsEqual(actDisp, disp, 0.001))) {\r\n //AV is on slope\r\n //Should AV continue to slide or stop?\r\n //if slope is less steeper than acceptable then stop else slide\r\n if (this._verticalSlope(actDisp) <= this._sl1) {\r\n this._endJump();\r\n }\r\n } else {\r\n actData = this._actionMap.fall;\r\n }\r\n }\r\n }\r\n return actData;\r\n }\r\n\r\n private _calcJumpDist(speed: number, dt: number): number {\r\n //up velocity at the begining of the lastt frame (v=u+at)\r\n let js: number = speed - this._gravity * this._jumpTime;\r\n //distance travelled up since last frame to this frame (s=ut+1/2*at^2)\r\n let jumpDist: number = js * dt - 0.5 * this._gravity * dt * dt;\r\n return jumpDist;\r\n }\r\n\r\n /**\r\n * does cleanup at the end of a jump\r\n */\r\n private _endJump() {\r\n this._act._jump = false;\r\n this._jumpTime = 0;\r\n this._wasWalking = false;\r\n this._wasRunning = false;\r\n }\r\n\r\n /**\r\n * checks if two vectors v1 and v2 are equal within a precision of p\r\n */\r\n private _areVectorsEqual(v1: Vector3, v2: Vector3, p: number) {\r\n return ((Math.abs(v1.x - v2.x) < p) && (Math.abs(v1.y - v2.y) < p) && (Math.abs(v1.z - v2.z) < p));\r\n }\r\n\r\n /*\r\n * returns the slope (in radians) of a vector in the vertical plane\r\n */\r\n private _verticalSlope(v: Vector3): number {\r\n return Math.atan(Math.abs(v.y / Math.sqrt(v.x * v.x + v.z * v.z)));\r\n }\r\n\r\n //for how long has the av been falling while moving\r\n private _movFallTime: number = 0;\r\n private _sign = 1;\r\n private _isTurning = false;\r\n private _noRot = false;\r\n private _doMove(dt: number): ActionData {\r\n\r\n //initial down velocity\r\n const u: number = this._movFallTime * this._gravity\r\n //calculate the distance by which av should fall down since last frame\r\n //assuming it is in freefall\r\n this._freeFallDist = u * dt + this._gravity * dt * dt / 2;\r\n\r\n this._movFallTime = this._movFallTime + dt;\r\n\r\n let moving: boolean = false;\r\n let actdata: ActionData = null;\r\n\r\n if (this._inFreeFall) {\r\n this._moveVector.y = -this._freeFallDist;\r\n moving = true;\r\n }\r\n\r\n\r\n //rotate avatar with respect to camera direction. \r\n this._rotateAV2C();\r\n\r\n //rotate the avatar in case player is trying to rotate the avatar. rotate the camera too if camera turning is on\r\n actdata = this._rotateAVnC(actdata, moving, dt);\r\n\r\n //now that avatar is rotated properly, construct the vector to move the avatar \r\n //donot move the avatar if avatar is in freefall\r\n\r\n if (!this._inFreeFall) {\r\n this._wasWalking = false;\r\n this._wasRunning = false;\r\n\r\n let sign: number;\r\n let horizDist: number = 0;\r\n switch (true) {\r\n case (this._act._stepLeft):\r\n sign = this._signLHS_RHS * this._isAvFacingCamera();\r\n horizDist = this._actionMap.strafeLeft.speed * dt;\r\n if (this._act._speedMod) {\r\n horizDist = this._actionMap.strafeLeftFast.speed * dt;\r\n actdata = (-this._ffSign * sign > 0) ? this._actionMap.strafeLeftFast : this._actionMap.strafeRightFast;\r\n } else {\r\n actdata = (-this._ffSign * sign > 0) ? this._actionMap.strafeLeft : this._actionMap.strafeRight;\r\n }\r\n this._moveVector = this._avatar.calcMovePOV(sign * horizDist, -this._freeFallDist, 0);\r\n moving = true;\r\n break;\r\n case (this._act._stepRight):\r\n sign = -this._signLHS_RHS * this._isAvFacingCamera();\r\n horizDist = this._actionMap.strafeRight.speed * dt;\r\n if (this._act._speedMod) {\r\n horizDist = this._actionMap.strafeRightFast.speed * dt;\r\n actdata = (-this._ffSign * sign > 0) ? this._actionMap.strafeLeftFast : this._actionMap.strafeRightFast;\r\n } else {\r\n actdata = (-this._ffSign * sign > 0) ? this._actionMap.strafeLeft : this._actionMap.strafeRight;\r\n }\r\n this._moveVector = this._avatar.calcMovePOV(sign * horizDist, -this._freeFallDist, 0);\r\n moving = true;\r\n break;\r\n case (this._act._walk || (this._noRot && this._mode == 0)):\r\n if (this._act._speedMod) {\r\n this._wasRunning = true;\r\n horizDist = this._actionMap.run.speed * dt;\r\n actdata = this._actionMap.run;\r\n } else {\r\n this._wasWalking = true;\r\n horizDist = this._actionMap.walk.speed * dt;\r\n actdata = this._actionMap.walk;\r\n }\r\n this._moveVector = this._avatar.calcMovePOV(0, -this._freeFallDist, this._ffSign * horizDist);\r\n moving = true;\r\n break;\r\n case (this._act._walkback):\r\n horizDist = this._actionMap.walkBack.speed * dt;\r\n if (this._act._speedMod) {\r\n horizDist = this._actionMap.walkBackFast.speed * dt;\r\n actdata = this._actionMap.walkBackFast;\r\n } else {\r\n actdata = this._actionMap.walkBack;\r\n }\r\n this._moveVector = this._avatar.calcMovePOV(0, -this._freeFallDist, -this._ffSign * horizDist);\r\n moving = true;\r\n break;\r\n }\r\n }\r\n\r\n // move the avatar\r\n\r\n if (moving) {\r\n if (this._moveVector.length() > 0.001) {\r\n this._avatar.moveWithCollisions(this._moveVector);\r\n //walking up a slope\r\n if (this._avatar.position.y > this._avStartPos.y) {\r\n const actDisp: Vector3 = this._avatar.position.subtract(this._avStartPos);\r\n const _slp: number = this._verticalSlope(actDisp);\r\n if (_slp >= this._sl2) {\r\n //this._climbingSteps=true;\r\n //is av trying to go up steps\r\n if (this._stepOffset > 0) {\r\n if (this._vMoveTot == 0) {\r\n //if just started climbing note down the position\r\n this._vMovStartPos.copyFrom(this._avStartPos);\r\n }\r\n this._vMoveTot = this._vMoveTot + (this._avatar.position.y - this._avStartPos.y);\r\n if (this._vMoveTot > this._stepOffset) {\r\n //move av back to its position at begining of steps\r\n this._vMoveTot = 0;\r\n this._avatar.position.copyFrom(this._vMovStartPos);\r\n this._endFreeFall();\r\n }\r\n } else {\r\n //move av back to old position\r\n this._avatar.position.copyFrom(this._avStartPos);\r\n this._endFreeFall();\r\n }\r\n } else {\r\n this._vMoveTot = 0;\r\n if (_slp > this._sl1) {\r\n //av is on a steep slope , continue increasing the moveFallTIme to deaccelerate it\r\n this._fallFrameCount = 0;\r\n this._inFreeFall = false;\r\n } else {\r\n //continue walking\r\n this._endFreeFall();\r\n }\r\n }\r\n } else if ((this._avatar.position.y) < this._avStartPos.y) {\r\n const actDisp: Vector3 = this._avatar.position.subtract(this._avStartPos);\r\n if (!(this._areVectorsEqual(actDisp, this._moveVector, 0.001))) {\r\n //AV is on slope\r\n //Should AV continue to slide or walk?\r\n //if slope is less steeper than acceptable then walk else slide\r\n if (this._verticalSlope(actDisp) <= this._sl1) {\r\n this._endFreeFall();\r\n } else {\r\n //av is on a steep slope , continue increasing the moveFallTIme to deaccelerate it\r\n this._fallFrameCount = 0;\r\n this._inFreeFall = false;\r\n }\r\n } else {\r\n this._inFreeFall = true;\r\n this._fallFrameCount++;\r\n //AV could be running down a slope which mean freefall,run,frefall run ...\r\n //to remove anim flicker, check if AV has been falling down continously for last few consecutive frames\r\n //before changing to free fall animation\r\n if (this._fallFrameCount > this._fallFrameCountMin) {\r\n actdata = this._actionMap.fall;\r\n }\r\n }\r\n } else {\r\n this._endFreeFall();\r\n }\r\n }\r\n }\r\n return actdata;\r\n }\r\n\r\n /**\r\n * rotate avatar with respect to camera direction. \r\n */\r\n private _rotateAV2C() {\r\n if (this._hasCam)\r\n if (this._mode != 1) {\r\n let ca = (this._hasCam) ? (this._av2cam - this._camera.alpha) : 0;\r\n if (this._noRot) {\r\n switch (true) {\r\n case (this._act._walk && this._act._turnRight):\r\n this._avatar.rotation.y = ca + this._rhsSign * Math.PI / 4;\r\n break;\r\n case (this._act._walk && this._act._turnLeft):\r\n this._avatar.rotation.y = ca - this._rhsSign * Math.PI / 4;\r\n break;\r\n case (this._act._walkback && this._act._turnRight):\r\n this._avatar.rotation.y = ca + this._rhsSign * 3 * Math.PI / 4;\r\n break;\r\n case (this._act._walkback && this._act._turnLeft):\r\n this._avatar.rotation.y = ca - this._rhsSign * 3 * Math.PI / 4;\r\n break;\r\n case (this._act._walk):\r\n this._avatar.rotation.y = ca;\r\n break;\r\n case (this._act._walkback):\r\n this._avatar.rotation.y = ca + Math.PI;\r\n break;\r\n case (this._act._turnRight):\r\n this._avatar.rotation.y = ca + this._rhsSign * Math.PI / 2;\r\n break;\r\n case (this._act._turnLeft):\r\n this._avatar.rotation.y = ca - this._rhsSign * Math.PI / 2;\r\n break;\r\n }\r\n } else {\r\n if (this._hasCam)\r\n this._avatar.rotation.y = ca;\r\n }\r\n }\r\n }\r\n\r\n //rotate the avatar in case player is trying to rotate the avatar. rotate the camera too if camera turning is on\r\n private _rotateAVnC(anim: ActionData, moving: boolean, dt: number): ActionData {\r\n if (!(this._noRot && this._mode == 0) && (!this._act._stepLeft && !this._act._stepRight) && (this._act._turnLeft || this._act._turnRight)) {\r\n let turnAngle = this._actionMap.turnLeft.speed * dt;\r\n if (this._act._speedMod) {\r\n turnAngle = 2 * turnAngle;\r\n }\r\n let a;\r\n if (this._mode == 1) {\r\n // while turining, the avatar could start facing away from camera and end up facing camera.\r\n // we should not switch turning direction during this transition\r\n if (!this._isTurning) {\r\n // if (this._act.name != this._act.prevName) {\r\n // this._act.prevName = this._act.name;\r\n this._sign = -this._ffSign * this._isAvFacingCamera();\r\n if (this._isLHS_RHS) this._sign = - this._sign;\r\n this._isTurning = true;\r\n }\r\n a = this._sign;\r\n if (this._act._turnLeft) {\r\n if (this._act._walk) { }\r\n else if (this._act._walkback) a = -this._sign;\r\n else {\r\n anim = (this._sign > 0) ? this._actionMap.turnRight : this._actionMap.turnLeft;\r\n }\r\n } else {\r\n if (this._act._walk) a = -this._sign;\r\n else if (this._act._walkback) { }\r\n else {\r\n a = -this._sign;\r\n anim = (this._sign > 0) ? this._actionMap.turnLeft : this._actionMap.turnRight;\r\n }\r\n }\r\n } else {\r\n a = 1;\r\n if (this._act._turnLeft) {\r\n if (this._act._walkback) a = -1;\r\n if (!moving) anim = this._actionMap.turnLeft;\r\n } else {\r\n if (this._act._walk) a = -1;\r\n if (!moving) { a = -1; anim = this._actionMap.turnRight; }\r\n }\r\n if (this._hasCam)\r\n this._camera.alpha = this._camera.alpha + this._rhsSign * turnAngle * a;\r\n }\r\n\r\n this._avatar.rotation.y = this._avatar.rotation.y + turnAngle * a;\r\n }\r\n return anim;\r\n }\r\n\r\n private _endFreeFall(): void {\r\n this._movFallTime = 0;\r\n this._fallFrameCount = 0;\r\n this._inFreeFall = false;\r\n }\r\n\r\n //for how long has the av been falling while idle (not moving)\r\n private _idleFallTime: number = 0;\r\n private _doIdle(dt: number): ActionData {\r\n if (this._grounded) {\r\n return this._actionMap.idle;\r\n }\r\n this._wasWalking = false;\r\n this._wasRunning = false;\r\n this._movFallTime = 0;\r\n let anim: ActionData = this._actionMap.idle;\r\n this._fallFrameCount = 0;\r\n\r\n\r\n if (dt === 0) {\r\n this._freeFallDist = 5;\r\n } else {\r\n const u: number = this._idleFallTime * this._gravity\r\n this._freeFallDist = u * dt + this._gravity * dt * dt / 2;\r\n this._idleFallTime = this._idleFallTime + dt;\r\n }\r\n //if displacement is less than 0.01(? need to verify further) then \r\n //moveWithDisplacement down against a surface seems to push the AV up by a small amount!!\r\n if (this._freeFallDist < 0.01) return anim;\r\n const disp: Vector3 = new Vector3(0, -this._freeFallDist, 0);\r\n // if (this._hasCam && this._mode != 1 && !this._noRot) this._avatar.rotation.y = this._av2cam - this._camera.alpha;\r\n this._avatar.moveWithCollisions(disp);\r\n if ((this._avatar.position.y > this._avStartPos.y) || (this._avatar.position.y === this._avStartPos.y)) {\r\n // this.grounded = true;\r\n // this.idleFallTime = 0;\r\n this._groundIt();\r\n } else if (this._avatar.position.y < this._avStartPos.y) {\r\n //AV is going down. \r\n //AV is either in free fall or is sliding along a downward slope\r\n //\r\n //if the actual displacemnt is same as the desired displacement then AV is in freefall\r\n //else it is on a slope\r\n const actDisp: Vector3 = this._avatar.position.subtract(this._avStartPos);\r\n if (!(this._areVectorsEqual(actDisp, disp, 0.001))) {\r\n //AV is on slope\r\n //Should AV continue to slide or stop?\r\n //if slope is less steeper than accebtable then stop else slide\r\n if (this._verticalSlope(actDisp) <= this._sl1) {\r\n // this.grounded = true;\r\n // this.idleFallTime = 0;\r\n this._groundIt();\r\n this._avatar.position.copyFrom(this._avStartPos);\r\n } else {\r\n this._unGroundIt();\r\n anim = this._actionMap.slideBack;\r\n }\r\n } else {\r\n anim = this._actionMap.fall;\r\n }\r\n }\r\n return anim;\r\n }\r\n\r\n private _groundFrameCount = 0;\r\n private _groundFrameMax = 10;\r\n /**\r\n * donot ground immediately\r\n * wait few more frames\r\n */\r\n private _groundIt(): void {\r\n this._groundFrameCount++;\r\n if (this._groundFrameCount > this._groundFrameMax) {\r\n this._grounded = true;\r\n this._idleFallTime = 0;\r\n }\r\n }\r\n private _unGroundIt() {\r\n this._grounded = false;\r\n this._groundFrameCount = 0;\r\n }\r\n\r\n private _savedCameraCollision: boolean = true;\r\n private _inFP = false;\r\n private _updateTargetValue() {\r\n if (!this._hasCam) return;\r\n //donot move camera if av is trying to clinb steps\r\n if (this._vMoveTot == 0)\r\n this._avatar.position.addToRef(this._cameraTarget, this._camera.target);\r\n\r\n if (this._camera.radius > this._camera.lowerRadiusLimit) { if (this._cameraElastic || this._makeInvisible) this._handleObstruction(); }\r\n\r\n //if user so desire, make the AV invisible if camera comes close to it\r\n if (this._camera.radius <= this._camera.lowerRadiusLimit) {\r\n if (!this._noFirstPerson && !this._inFP) {\r\n this._makeMeshInvisible(this._avatar);\r\n this._camera.checkCollisions = false;\r\n this._saveMode = this._mode;\r\n this._mode = 0;\r\n this._inFP = true;\r\n }\r\n } else {\r\n if (this._inFP) {\r\n this._inFP = false;\r\n this._mode = this._saveMode;\r\n this._restoreVisiblity(this._avatar);\r\n this._camera.checkCollisions = this._savedCameraCollision;\r\n }\r\n }\r\n }\r\n\r\n // make mesh and all its children invisible\r\n // store their current visibility state so that we can restore them later on\r\n private _makeMeshInvisible(mesh: Mesh) {\r\n\r\n this._visiblityMap.set(mesh, mesh.visibility);\r\n mesh.visibility = 0;\r\n\r\n mesh.getChildMeshes(false, (n) => {\r\n if (n instanceof Mesh) {\r\n this._visiblityMap.set(n, n.visibility);\r\n n.visibility = 0;\r\n }\r\n return false;\r\n });\r\n }\r\n\r\n private _visiblityMap: Map = new Map();\r\n\r\n //restore mesh visibility to previous state\r\n private _restoreVisiblity(mesh: Mesh) {\r\n mesh.visibility = this._visiblityMap.get(mesh);\r\n mesh.getChildMeshes(false, (n) => {\r\n if (n instanceof Mesh) n.visibility = this._visiblityMap.get(n);\r\n return false;\r\n });\r\n }\r\n\r\n private _ray: Ray = new Ray(Vector3.Zero(), Vector3.One(), 1);\r\n private _rayDir: Vector3 = Vector3.Zero();\r\n //camera seems to get stuck into things\r\n //should move camera away from things by a value of cameraSkin\r\n private _cameraSkin: number = 0.5;\r\n private _prevPickedMeshes: AbstractMesh[];\r\n private _pickedMeshes: AbstractMesh[] = new Array();;\r\n private _makeInvisible = false;\r\n private _elasticSteps = 50;\r\n private _alreadyInvisible: AbstractMesh[];\r\n\r\n /**\r\n * The following method handles the use case wherein some mesh\r\n * comes between the avatar and the camera thus obstructing the view\r\n * of the avatar.\r\n * Two ways this can be handled\r\n * a) make the obstructing mesh invisible\r\n * instead of invisible a better option would have been to make semi transparent.\r\n * Unfortunately, unlike mesh, mesh instances do not \"visibility\" setting)\r\n * Every alternate frame make mesh visible and invisible to give the impression of semi-transparent.\r\n * b) move the camera in front of the obstructing mesh\r\n */\r\n private _handleObstruction() {\r\n\r\n //get vector from av (camera.target) to camera\r\n this._camera.position.subtractToRef(this._camera.target, this._rayDir);\r\n //start ray from av to camera\r\n this._ray.origin = this._camera.target;\r\n this._ray.length = this._rayDir.length();\r\n this._ray.direction = this._rayDir.normalize();\r\n\r\n //TODO \r\n //handle case were pick is with a child of avatar, avatar atatchment. etc\r\n const pis: PickingInfo[] = this._scene.multiPickWithRay(this._ray, (mesh) => {\r\n if (mesh == this._avatar) return false;\r\n else return true;\r\n });\r\n\r\n\r\n if (this._makeInvisible) {\r\n this._prevPickedMeshes = this._pickedMeshes;\r\n if (pis.length > 0) {\r\n this._pickedMeshes = new Array();\r\n for (let pi of pis) {\r\n if (pi.pickedMesh.isVisible || this._prevPickedMeshes.includes(pi.pickedMesh)) {\r\n pi.pickedMesh.isVisible = false;\r\n this._pickedMeshes.push(pi.pickedMesh);\r\n }\r\n }\r\n for (let pm of this._prevPickedMeshes) {\r\n if (!this._pickedMeshes.includes(pm)) {\r\n pm.isVisible = true;\r\n }\r\n }\r\n } else {\r\n for (let pm of this._prevPickedMeshes) {\r\n pm.isVisible = true;\r\n }\r\n this._prevPickedMeshes.length = 0;\r\n }\r\n }\r\n\r\n if (this._cameraElastic) {\r\n if (pis.length > 0) {\r\n // postion the camera in front of the mesh that is obstructing camera\r\n\r\n //if only one obstruction and it is invisible then if it is not collidable or our camera is not collidable then do nothing\r\n if ((pis.length == 1 && !this._isSeeAble(pis[0].pickedMesh)) && (!pis[0].pickedMesh.checkCollisions || !this._camera.checkCollisions)) return;\r\n\r\n //if our camera is collidable then we donot want it to get stuck behind another collidable obsrtucting mesh\r\n let pp: Vector3 = null;\r\n\r\n //we will asume the order of picked meshes is from closest to avatar to furthest\r\n //we should get the first one which is visible or invisible and collidable\r\n for (let i = 0; i < pis.length; i++) {\r\n let pm = pis[i].pickedMesh;\r\n if (this._isSeeAble(pm)) {\r\n pp = pis[i].pickedPoint;\r\n break;\r\n } else if (pm.checkCollisions) {\r\n pp = pis[i].pickedPoint;\r\n break;\r\n }\r\n }\r\n if (pp == null) return;\r\n\r\n const c2p: Vector3 = this._camera.position.subtract(pp);\r\n //note that when camera is collidable, changing the orbital camera radius may not work.\r\n //changing the radius moves the camera forward (with collision?) and collision can interfere with movement\r\n //\r\n //in every cylce we are dividing the distance to tarvel by same number of steps.\r\n //as we get closer to destination the speed will thus slow down.\r\n //when just 1 unit distance left, lets snap to the final position.\r\n //when calculating final position make sure the camera does not get stuck at the pickposition especially\r\n //if collision is on\r\n\r\n const l: number = c2p.length();\r\n if (this._camera.checkCollisions) {\r\n let step: Vector3;\r\n if (l <= 1) {\r\n step = c2p.addInPlace(c2p.normalizeToNew().scaleInPlace(this._cameraSkin));\r\n } else {\r\n step = c2p.normalize().scaleInPlace(l / this._elasticSteps);\r\n }\r\n this._camera.position = this._camera.position.subtract(step);\r\n } else {\r\n let step: number;\r\n if (l <= 1) step = l + this._cameraSkin; else step = l / this._elasticSteps;\r\n this._camera.radius = this._camera.radius - (step);\r\n }\r\n }\r\n }\r\n }\r\n\r\n //how many ways can a mesh be invisible?\r\n private _isSeeAble(mesh: AbstractMesh): boolean {\r\n if (!mesh.isVisible) return false;\r\n if (mesh.visibility == 0) return false;\r\n if (mesh.material != null && mesh.material.alphaMode != 0 && mesh.material.alpha == 0) return false;\r\n return true;\r\n //what about vertex color? groan!\r\n }\r\n\r\n\r\n private _move: boolean = false;\r\n public anyMovement(): boolean {\r\n return (this._act._walk || this._act._walkback || this._act._turnLeft || this._act._turnRight || this._act._stepLeft || this._act._stepRight);\r\n }\r\n\r\n private _onKeyDown(e: KeyboardEvent) {\r\n if (!e.key) return;\r\n if (e.repeat) return;\r\n switch (e.key.toLowerCase()) {\r\n case this._actionMap.idleJump.key:\r\n this._act._jump = true;\r\n break;\r\n case \"capslock\":\r\n this._act._speedMod = !this._act._speedMod;\r\n break;\r\n case \"shift\":\r\n this._act._speedMod = true;\r\n break;\r\n case \"up\":\r\n case \"arrowup\":\r\n case this._actionMap.walk.key:\r\n this._act._walk = true;\r\n break;\r\n case \"left\":\r\n case \"arrowleft\":\r\n case this._actionMap.turnLeft.key:\r\n this._act._turnLeft = true;\r\n break;\r\n case \"right\":\r\n case \"arrowright\":\r\n case this._actionMap.turnRight.key:\r\n this._act._turnRight = true;\r\n break;\r\n case \"down\":\r\n case \"arrowdown\":\r\n case this._actionMap.walkBack.key:\r\n this._act._walkback = true;\r\n break;\r\n case this._actionMap.strafeLeft.key:\r\n this._act._stepLeft = true;\r\n break;\r\n case this._actionMap.strafeRight.key:\r\n this._act._stepRight = true;\r\n break;\r\n }\r\n this._move = this.anyMovement();\r\n }\r\n\r\n private _onKeyUp(e: KeyboardEvent) {\r\n if (!e.key) return;\r\n switch (e.key.toLowerCase()) {\r\n case \"shift\":\r\n this._act._speedMod = false;\r\n break;\r\n case \"up\":\r\n case \"arrowup\":\r\n case this._actionMap.walk.key:\r\n this._act._walk = false;\r\n break;\r\n case \"left\":\r\n case \"arrowleft\":\r\n case this._actionMap.turnLeft.key:\r\n this._act._turnLeft = false;\r\n this._isTurning = false;\r\n break;\r\n case \"right\":\r\n case \"arrowright\":\r\n case this._actionMap.turnRight.key:\r\n this._act._turnRight = false;\r\n this._isTurning = false;\r\n break;\r\n case \"down\":\r\n case \"arrowdown\":\r\n case this._actionMap.walkBack.key:\r\n this._act._walkback = false;\r\n break;\r\n case this._actionMap.strafeLeft.key:\r\n this._act._stepLeft = false;\r\n break;\r\n case this._actionMap.strafeRight.key:\r\n this._act._stepRight = false;\r\n break;\r\n }\r\n this._move = this.anyMovement();\r\n }\r\n\r\n private _ekb: boolean = true;\r\n public isKeyBoardEnabled(): boolean {\r\n return this._ekb;\r\n }\r\n public enableKeyBoard(b: boolean) {\r\n this._ekb = b;\r\n if (b) {\r\n this._addkeylistener();\r\n } else {\r\n this._removekeylistener();\r\n }\r\n }\r\n\r\n private _addkeylistener() {\r\n let canvas: HTMLCanvasElement = this._scene.getEngine().getRenderingCanvas();\r\n canvas.addEventListener(\"keyup\", this._handleKeyUp, false);\r\n canvas.addEventListener(\"keydown\", this._handleKeyDown, false);\r\n }\r\n\r\n private _removekeylistener() {\r\n let canvas: HTMLCanvasElement = this._scene.getEngine().getRenderingCanvas();\r\n canvas.removeEventListener(\"keyup\", this._handleKeyUp, false);\r\n canvas.removeEventListener(\"keydown\", this._handleKeyDown, false);\r\n }\r\n\r\n // control movement by commands rather than keyboard.\r\n public walk(b: boolean) {\r\n this._act._walk = b;\r\n }\r\n public walkBack(b: boolean) {\r\n this._act._walkback = b;\r\n }\r\n public walkBackFast(b: boolean) {\r\n this._act._walkback = b;\r\n this._act._speedMod = b;\r\n }\r\n public run(b: boolean) {\r\n this._act._walk = b;\r\n this._act._speedMod = b;\r\n }\r\n public turnLeft(b: boolean) {\r\n this._act._turnLeft = b;\r\n if (!b) this._isTurning = b;\r\n }\r\n public turnLeftFast(b: boolean) {\r\n this._act._turnLeft = b;\r\n if (!b) this._isTurning = b;\r\n this._act._speedMod = b;\r\n }\r\n public turnRight(b: boolean) {\r\n this._act._turnRight = b;\r\n if (!b) this._isTurning = b;\r\n }\r\n public turnRightFast(b: boolean) {\r\n this._act._turnRight = b;\r\n if (!b) this._isTurning = b;\r\n this._act._speedMod = b;\r\n }\r\n public strafeLeft(b: boolean) {\r\n this._act._stepLeft = b;\r\n }\r\n public strafeLeftFast(b: boolean) {\r\n this._act._stepLeft = b;\r\n this._act._speedMod = b;\r\n }\r\n public strafeRight(b: boolean) {\r\n this._act._stepRight = b;\r\n }\r\n public strafeRightFast(b: boolean) {\r\n this._act._stepRight = b;\r\n this._act._speedMod = b;\r\n }\r\n public jump() {\r\n this._act._jump = true;\r\n }\r\n\r\n public fall() {\r\n this._grounded = false;\r\n }\r\n\r\n public idle() {\r\n this._act.reset();\r\n }\r\n\r\n private _act: _Action;\r\n private _renderer: () => void;\r\n private _handleKeyUp: (e) => void;\r\n private _handleKeyDown: (e) => void;\r\n private _isAG: boolean = false;\r\n public isAg() {\r\n return this._isAG;\r\n }\r\n\r\n\r\n\r\n\r\n private _findSkel(n: Node): Skeleton {\r\n let root = this._root(n);\r\n\r\n if (root instanceof Mesh && root.skeleton) return root.skeleton;\r\n\r\n //find all child meshes which have skeletons\r\n let ms = root.getChildMeshes(\r\n false,\r\n (cm) => {\r\n if (cm instanceof Mesh) {\r\n if (cm.skeleton) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n });\r\n\r\n //return the skeleton of the first child mesh\r\n if (ms.length > 0) return ms[0].skeleton; else return null;\r\n\r\n }\r\n\r\n private _root(tn: Node): Node {\r\n if (tn.parent == null) return tn;\r\n return this._root(tn.parent);\r\n }\r\n\r\n public setAvatar(avatar: Mesh, faceForward: boolean = false): boolean {\r\n\r\n let rootNode = this._root(avatar);\r\n if (rootNode instanceof Mesh) {\r\n this._avatar = rootNode;\r\n } else {\r\n console.error(\"Cannot move this mesh. The root node of the mesh provided is not a mesh\");\r\n return false;\r\n }\r\n\r\n this._skeleton = this._findSkel(avatar);\r\n this._isAG = this._containsAG(avatar, this._scene.animationGroups, true);\r\n\r\n this._actionMap.reset();\r\n\r\n //animation ranges\r\n if (!this._isAG && this._skeleton != null) this._checkAnimRanges(this._skeleton);\r\n\r\n this._setRHS(avatar);\r\n this.setFaceForward(faceForward);\r\n\r\n return true;\r\n }\r\n\r\n public getAvatar() {\r\n return this._avatar;\r\n }\r\n\r\n // force a skeleton to be the avatar skeleton\r\n // should not be calling this normally\r\n public setAvatarSkeleton(skeleton: Skeleton) {\r\n this._skeleton = skeleton;\r\n\r\n\r\n if (this._skeleton != null && this._skelDrivenByAG(skeleton)) this._isAG = true; else this._isAG = false;\r\n\r\n if (!this._isAG && this._skeleton != null) this._checkAnimRanges(this._skeleton);\r\n }\r\n\r\n\r\n // this check if any of this skeleton animations is referenced by any targetedAnimation in any of the animationgroup in the scene.\r\n private _skelDrivenByAG(skeleton: Skeleton) {\r\n return skeleton.animations.some(sa => this._scene.animationGroups.some(ag => ag.children.some(ta => ta.animation == sa)));\r\n }\r\n\r\n public getSkeleton() {\r\n return this._skeleton;\r\n }\r\n\r\n // does this character have any animations ?\r\n // remember we can use meshes without anims as characters too\r\n private _hasAnims: boolean = false;\r\n private _hasCam: boolean = true;\r\n\r\n /**\r\n * The avatar/character can be made up of multiple meshes arranged in a hierarchy.\r\n * As such we will pick the root of the hierarchy as the avatar.\r\n * The root should be a mesh as otherwise we cannot move it with moveWithCollision() method.\r\n * \r\n * Mutiple meshes in the hierarchy may have skeletons (if two or more meshes have skeleton then\r\n * the skeleton will mostly likely be the same). \r\n * So we will pick as avatar skeleton, the skeleton of the first mesh in the hierachy which has\r\n * a skeleton \r\n * \r\n * @param avatar \r\n * @param camera \r\n * @param scene \r\n * @param actionMap/animationGroupMap \r\n * maps actions to animations and other data like speed,sound etc \r\n * or \r\n * for backward compatibility could be AnimationGroup Map\r\n * @param faceForward \r\n */\r\n constructor(avatar: Mesh, camera: ArcRotateCamera, scene: Scene, actionMap?: {}, faceForward = false) {\r\n\r\n this._camera = camera;\r\n\r\n //if camera is null assume this would be used to control an NPC\r\n //we cannot use mode 0 as that is dependent on camera being present. so force mode 1\r\n if (this._camera == null) {\r\n this._hasCam = false;\r\n this.setMode(1);\r\n }\r\n this._scene = scene;\r\n\r\n let success = this.setAvatar(avatar, faceForward);\r\n if (!success) {\r\n console.error(\"unable to set avatar\");\r\n }\r\n\r\n\r\n let dataType: string = null;\r\n if (actionMap != null) {\r\n dataType = this.setActionMap(actionMap);\r\n }\r\n\r\n //try to use the existing avatar animations\r\n\r\n //animation ranges\r\n if (!this._isAG && this._skeleton != null) this._checkAnimRanges(this._skeleton);\r\n //animation groups\r\n if (this._isAG) {\r\n //TODO\r\n }\r\n\r\n if (this._hasCam) this._savedCameraCollision = this._camera.checkCollisions;\r\n\r\n this._act = new _Action();\r\n\r\n this._renderer = () => { this._moveAVandCamera() };\r\n this._handleKeyUp = (e) => { this._onKeyUp(e) };\r\n this._handleKeyDown = (e) => { this._onKeyDown(e) };\r\n }\r\n}\r\n\r\n\r\n\r\nclass _Action {\r\n\r\n public _walk: boolean = false;\r\n public _walkback: boolean = false;\r\n public _turnRight: boolean = false;\r\n public _turnLeft: boolean = false;\r\n public _stepRight: boolean = false;\r\n public _stepLeft: boolean = false;\r\n public _jump: boolean = false;\r\n\r\n // speed modifier - changes speed of movement\r\n public _speedMod: boolean = false;\r\n\r\n\r\n constructor() {\r\n this.reset();\r\n }\r\n\r\n reset() {\r\n this._walk = false;\r\n this._walkback = false;\r\n this._turnRight = false;\r\n this._turnLeft = false;\r\n this._stepRight = false;\r\n this._stepLeft = false;\r\n this._jump = false;\r\n this._speedMod = false;\r\n }\r\n}\r\n\r\nexport class ActionData {\r\n public id: string;\r\n public speed: number;\r\n //_ds default speed. speed is set to this on reset\r\n public ds: number;\r\n public sound: Sound;\r\n public key: string;\r\n //_dk defailt key\r\n public dk: string;\r\n\r\n //animation data\r\n //if _ag is null then assuming animation range and use _name to play animationrange\r\n //instead of name maybe call it arName?\r\n public name: string = \"\";\r\n public ag: AnimationGroup;\r\n public loop: boolean = true;\r\n public rate: number = 1;\r\n\r\n public exist: boolean = false;\r\n\r\n public constructor(id?: string, speed = 1, key?: string) {\r\n this.id = id;\r\n this.speed = speed;\r\n this.ds = speed;\r\n this.key = key;\r\n this.dk = key;\r\n }\r\n\r\n public reset() {\r\n this.name = \"\";\r\n this.speed = this.ds;\r\n this.key = this.dk;\r\n this.loop = true;\r\n this.rate = 1;\r\n this.sound = null;\r\n this.exist = false;\r\n }\r\n\r\n}\r\n\r\n//not really a \"Map\"\r\nexport class ActionMap {\r\n public walk = new ActionData(\"walk\", 3, \"w\");\r\n public walkBack = new ActionData(\"walkBack\", 1.5, \"s\");\r\n public walkBackFast = new ActionData(\"walkBackFast\", 3, \"na\");\r\n public idle = new ActionData(\"idle\", 0, \"na\");\r\n public idleJump = new ActionData(\"idleJump\", 6, \" \");\r\n public run = new ActionData(\"run\", 6, \"na\");\r\n public runJump = new ActionData(\"runJump\", 6, \"na\");\r\n public fall = new ActionData(\"fall\", 0, \"na\");\r\n public turnLeft = new ActionData(\"turnLeft\", Math.PI / 8, \"a\");\r\n public turnLeftFast = new ActionData(\"turnLeftFast\", Math.PI / 4, \"na\");\r\n public turnRight = new ActionData(\"turnRight\", Math.PI / 8, \"d\");\r\n public turnRightFast = new ActionData(\"turnRightFast\", Math.PI / 4, \"na\");\r\n public strafeLeft = new ActionData(\"strafeLeft\", 1.5, \"q\");\r\n public strafeLeftFast = new ActionData(\"strafeLeftFast\", 3, \"na\");\r\n public strafeRight = new ActionData(\"strafeRight\", 1.5, \"e\");\r\n public strafeRightFast = new ActionData(\"strafeRightFast\", 3, \"na\");\r\n public slideBack = new ActionData(\"slideBack\", 0, \"na\");\r\n\r\n public reset() {\r\n let keys: string[] = Object.keys(this);\r\n for (let key of keys) {\r\n let act = this[key];\r\n if (!(act instanceof ActionData)) continue;\r\n act.reset()\r\n }\r\n }\r\n};\r\n\r\nexport class CCSettings {\r\n public faceForward: boolean;\r\n public gravity: number;\r\n public minSlopeLimit: number;\r\n public maxSlopeLimit: number;\r\n public stepOffset: number;\r\n public cameraElastic: boolean = true;\r\n public elasticSteps: number;\r\n public makeInvisble: boolean = true;\r\n public cameraTarget: Vector3 = Vector3.Zero();\r\n public noFirstPerson: boolean = false;\r\n public topDown: boolean = true;\r\n //turningOff takes effect only when topDown is false\r\n public turningOff: boolean = true;\r\n public keyboard: boolean = true;\r\n public sound: Sound;\r\n}\r\n"],"names":["root","factory","exports","module","require","define","amd","a","i","self","__WEBPACK_EXTERNAL_MODULE__247__","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__","n","getter","__esModule","d","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","r","Symbol","toStringTag","value","avatar","camera","scene","actionMap","faceForward","_avatar","_skeleton","_gravity","_minSlopeLimit","_maxSlopeLimit","_sl1","Math","PI","this","_sl2","_stepOffset","_vMoveTot","_vMovStartPos","Vector3","_actionMap","ActionMap","_cameraElastic","_cameraTarget","_noFirstPerson","_mode","_saveMode","_isLHS_RHS","_signLHS_RHS","_started","_stopAnim","_prevActData","_avStartPos","_grounded","_freeFallDist","_fallFrameCountMin","_fallFrameCount","_inFreeFall","_wasWalking","_wasRunning","_soundLoopTime","_sndId","_jumpStartPosY","_jumpTime","_movFallTime","_sign","_isTurning","_noRot","_idleFallTime","_groundFrameCount","_groundFrameMax","_savedCameraCollision","_inFP","_visiblityMap","Map","_ray","Ray","_rayDir","_cameraSkin","_pickedMeshes","Array","_makeInvisible","_elasticSteps","_move","_ekb","_isAG","_hasAnims","_hasCam","_camera","setMode","_scene","setAvatar","console","error","setActionMap","_checkAnimRanges","checkCollisions","_act","_Action","_renderer","_moveAVandCamera","_handleKeyUp","e","_onKeyUp","_handleKeyDown","_onKeyDown","getScene","setSlopeLimit","minSlopeLimit","maxSlopeLimit","setStepOffset","stepOffset","setWalkSpeed","walk","speed","setRunSpeed","run","setBackSpeed","walkBack","setBackFastSpeed","walkBackFast","setJumpSpeed","idleJump","runJump","setLeftSpeed","strafeLeft","setLeftFastSpeed","strafeLeftFast","setRightSpeed","strafeRight","setRightFastSpeed","setTurnSpeed","turnLeft","turnRight","setTurnFastSpeed","turnLeftFast","turnRightFast","setGravity","setAnimationGroups","agMap","exist","ag","stop","setAnimationRanges","arMap","inActMap","inActData","keys","ccActionName","ccActData","ActionData","id","AnimationGroup","name","loop","rate","sound","_checkFastAnims","getActionMap","map","actDataI","actDataO","getSettings","ccs","CCSettings","isFaceForward","topDown","getMode","turningOff","isTurningOff","cameraTarget","clone","cameraElastic","elasticSteps","makeInvisble","gravity","keyboard","noFirstPerson","_stepSound","setSettings","setFaceForward","setTurningOff","setCameraTarget","setCameraElasticity","setElasticiSteps","makeObstructionInvisible","enableKeyBoard","setNoFirstPerson","setSound","_setAnim","anim","animName","getAnimationRange","enableBlending","act","targetedAnimations","ta","animation","blendingSpeed","disableBlending","setWalkAnim","rangeName","setRunAnim","setWalkBackAnim","_copySlowAnims","setWalkBackFastAnim","setSlideBackAnim","slideBack","setIdleAnim","idle","setTurnRightAnim","setTurnRightFastAnim","setTurnLeftAnim","setTurnLeftFastAnim","setStrafeRightAnim","strafeRightFast","setStrafeRightFastAnim","setStrafeLeftAnim","setStrafeLeftFastAnim","setIdleJumpAnim","setRunJumpAnim","setFallAnim","fall","ccActionNames","attachToMesh","setWalkKey","toLowerCase","setWalkBackKey","setTurnLeftKey","setTurnRightKey","setStrafeLeftKey","setStrafeRightKey","setJumpKey","b","v","copyFrom","cameraCollisionChanged","skel","f","s","_setRHS","mesh","meshMatrix","getWorldMatrix","_localX","m","_localY","_localZ","actualZ","_ff","_rhsSign","useRightHandedSystem","_av2cam","_ffSign","checkAGs","_containsAG","node","ags","fromRoot","ns","_getRoot","getChildren","TransformNode","indexOf","target","tn","parent","start","reset","_updateTargetValue","_addkeylistener","registerBeforeRender","unregisterBeforeRender","_removekeylistener","pauseAnim","stopAnimation","clearInterval","resumeAnim","_isAvFacingCamera","forward","position","subtract","actData","dt","getEngine","getDeltaTime","_jump","_doJump","anyMovement","_doMove","_doIdle","c","fps","framePerSecond","to","from","beginAnimation","getAnimations","play","setInterval","abs","y","disp","forwardDist","jumpDist","_moveVector","normalize","scaleToRef","_calcJumpDist","moveWithCollisions","length","_endJump","actDisp","_areVectorsEqual","_verticalSlope","v1","v2","p","x","z","atan","sqrt","u","moving","actdata","_rotateAV2C","_rotateAVnC","sign","horizDist","_speedMod","calcMovePOV","_walk","_slp","_endFreeFall","ca","alpha","_turnRight","rotation","_turnLeft","_walkback","_stepLeft","_stepRight","turnAngle","_groundIt","_unGroundIt","addToRef","radius","lowerRadiusLimit","_handleObstruction","_makeMeshInvisible","_restoreVisiblity","set","visibility","getChildMeshes","Mesh","subtractToRef","origin","direction","pis","multiPickWithRay","_prevPickedMeshes","pi","pickedMesh","isVisible","includes","push","pm","_isSeeAble","pp","pickedPoint","c2p","l","step","addInPlace","normalizeToNew","scaleInPlace","material","alphaMode","repeat","isKeyBoardEnabled","canvas","getRenderingCanvas","addEventListener","removeEventListener","jump","isAg","_findSkel","_root","skeleton","ms","cm","rootNode","animationGroups","getAvatar","setAvatarSkeleton","_skelDrivenByAG","animations","some","sa","children","getSkeleton","ds","dk"],"sourceRoot":""} \ No newline at end of file diff --git a/dist-old/CharacterController.max.js b/dist-old/CharacterController.max.js deleted file mode 100644 index a4c7b08..0000000 --- a/dist-old/CharacterController.max.js +++ /dev/null @@ -1,1592 +0,0 @@ -(function webpackUniversalModuleDefinition(root, factory) { - if(typeof exports === 'object' && typeof module === 'object') - module.exports = factory(require("babylonjs")); - else if(typeof define === 'function' && define.amd) - define(["babylonjs"], factory); - else { - var a = typeof exports === 'object' ? factory(require("babylonjs")) : factory(root["BABYLON"]); - for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i]; - } -})(self, (__WEBPACK_EXTERNAL_MODULE_babylonjs__) => { -return /******/ (() => { // webpackBootstrap -/******/ "use strict"; -/******/ var __webpack_modules__ = ({ - -/***/ "babylonjs": -/*!****************************************************************************************************!*\ - !*** external {"commonjs":"babylonjs","commonjs2":"babylonjs","amd":"babylonjs","root":"BABYLON"} ***! - \****************************************************************************************************/ -/***/ ((module) => { - -module.exports = __WEBPACK_EXTERNAL_MODULE_babylonjs__; - -/***/ }) - -/******/ }); -/************************************************************************/ -/******/ // The module cache -/******/ var __webpack_module_cache__ = {}; -/******/ -/******/ // The require function -/******/ function __webpack_require__(moduleId) { -/******/ // Check if module is in cache -/******/ var cachedModule = __webpack_module_cache__[moduleId]; -/******/ if (cachedModule !== undefined) { -/******/ return cachedModule.exports; -/******/ } -/******/ // Create a new module (and put it into the cache) -/******/ var module = __webpack_module_cache__[moduleId] = { -/******/ // no module.id needed -/******/ // no module.loaded needed -/******/ exports: {} -/******/ }; -/******/ -/******/ // Execute the module function -/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); -/******/ -/******/ // Return the exports of the module -/******/ return module.exports; -/******/ } -/******/ -/************************************************************************/ -/******/ /* webpack/runtime/compat get default export */ -/******/ (() => { -/******/ // getDefaultExport function for compatibility with non-harmony modules -/******/ __webpack_require__.n = (module) => { -/******/ var getter = module && module.__esModule ? -/******/ () => (module['default']) : -/******/ () => (module); -/******/ __webpack_require__.d(getter, { a: getter }); -/******/ return getter; -/******/ }; -/******/ })(); -/******/ -/******/ /* webpack/runtime/define property getters */ -/******/ (() => { -/******/ // define getter functions for harmony exports -/******/ __webpack_require__.d = (exports, definition) => { -/******/ for(var key in definition) { -/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { -/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); -/******/ } -/******/ } -/******/ }; -/******/ })(); -/******/ -/******/ /* webpack/runtime/hasOwnProperty shorthand */ -/******/ (() => { -/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) -/******/ })(); -/******/ -/******/ /* webpack/runtime/make namespace object */ -/******/ (() => { -/******/ // define __esModule on exports -/******/ __webpack_require__.r = (exports) => { -/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { -/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); -/******/ } -/******/ Object.defineProperty(exports, '__esModule', { value: true }); -/******/ }; -/******/ })(); -/******/ -/************************************************************************/ -var __webpack_exports__ = {}; -// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk. -(() => { -/*!************************************!*\ - !*** ./src/CharacterController.ts ***! - \************************************/ -__webpack_require__.r(__webpack_exports__); -/* harmony export */ __webpack_require__.d(__webpack_exports__, { -/* harmony export */ "ActionData": () => (/* binding */ ActionData), -/* harmony export */ "ActionMap": () => (/* binding */ ActionMap), -/* harmony export */ "CCSettings": () => (/* binding */ CCSettings), -/* harmony export */ "CharacterController": () => (/* binding */ CharacterController) -/* harmony export */ }); -/* harmony import */ var babylonjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs */ "babylonjs"); -/* harmony import */ var babylonjs__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs__WEBPACK_IMPORTED_MODULE_0__); - -var CharacterController = (function () { - function CharacterController(avatar, camera, scene, actionMap, faceForward) { - if (faceForward === void 0) { faceForward = false; } - var _this = this; - this._avatar = null; - this._skeleton = null; - this._gravity = 9.8; - this._minSlopeLimit = 30; - this._maxSlopeLimit = 45; - this._sl1 = Math.PI * this._minSlopeLimit / 180; - this._sl2 = Math.PI * this._maxSlopeLimit / 180; - this._stepOffset = 0.25; - this._vMoveTot = 0; - this._vMovStartPos = babylonjs__WEBPACK_IMPORTED_MODULE_0__.Vector3.Zero(); - this._actionMap = new ActionMap(); - this._cameraElastic = true; - this._cameraTarget = babylonjs__WEBPACK_IMPORTED_MODULE_0__.Vector3.Zero(); - this._noFirstPerson = false; - this._mode = 0; - this._saveMode = 0; - this._isLHS_RHS = false; - this._signLHS_RHS = -1; - this._started = false; - this._stopAnim = false; - this._prevActData = null; - this._avStartPos = babylonjs__WEBPACK_IMPORTED_MODULE_0__.Vector3.Zero(); - this._grounded = false; - this._freeFallDist = 0; - this._fallFrameCountMin = 50; - this._fallFrameCount = 0; - this._inFreeFall = false; - this._wasWalking = false; - this._wasRunning = false; - this._soundLoopTime = 700; - this._sndId = null; - this._jumpStartPosY = 0; - this._jumpTime = 0; - this._movFallTime = 0; - this._sign = 1; - this._isTurning = false; - this._noRot = false; - this._idleFallTime = 0; - this._groundFrameCount = 0; - this._groundFrameMax = 10; - this._savedCameraCollision = true; - this._inFP = false; - this._visiblityMap = new Map(); - this._ray = new babylonjs__WEBPACK_IMPORTED_MODULE_0__.Ray(babylonjs__WEBPACK_IMPORTED_MODULE_0__.Vector3.Zero(), babylonjs__WEBPACK_IMPORTED_MODULE_0__.Vector3.One(), 1); - this._rayDir = babylonjs__WEBPACK_IMPORTED_MODULE_0__.Vector3.Zero(); - this._cameraSkin = 0.5; - this._pickedMeshes = new Array(); - this._makeInvisible = false; - this._elasticSteps = 50; - this._move = false; - this._ekb = true; - this._isAG = false; - this._hasAnims = false; - this._hasCam = true; - this._camera = camera; - if (this._camera == null) { - this._hasCam = false; - this.setMode(1); - } - this._scene = scene; - var success = this.setAvatar(avatar, faceForward); - if (!success) { - console.error("unable to set avatar"); - } - var dataType = null; - if (actionMap != null) { - dataType = this.setActionMap(actionMap); - } - if (!this._isAG && this._skeleton != null) - this._checkAnimRanges(this._skeleton); - if (this._isAG) { - } - if (this._hasCam) - this._savedCameraCollision = this._camera.checkCollisions; - this._act = new _Action(); - this._renderer = function () { _this._moveAVandCamera(); }; - this._handleKeyUp = function (e) { _this._onKeyUp(e); }; - this._handleKeyDown = function (e) { _this._onKeyDown(e); }; - } - CharacterController.prototype.getScene = function () { - return this._scene; - }; - CharacterController.prototype.setSlopeLimit = function (minSlopeLimit, maxSlopeLimit) { - this._minSlopeLimit = minSlopeLimit; - this._maxSlopeLimit = maxSlopeLimit; - this._sl1 = Math.PI * this._minSlopeLimit / 180; - this._sl2 = Math.PI * this._maxSlopeLimit / 180; - }; - CharacterController.prototype.setStepOffset = function (stepOffset) { - this._stepOffset = stepOffset; - }; - CharacterController.prototype.setWalkSpeed = function (n) { - this._actionMap.walk.speed = n; - }; - CharacterController.prototype.setRunSpeed = function (n) { - this._actionMap.run.speed = n; - }; - CharacterController.prototype.setBackSpeed = function (n) { - this._actionMap.walkBack.speed = n; - }; - CharacterController.prototype.setBackFastSpeed = function (n) { - this._actionMap.walkBackFast.speed = n; - }; - CharacterController.prototype.setJumpSpeed = function (n) { - this._actionMap.idleJump.speed = n; - this._actionMap.runJump.speed = n; - }; - CharacterController.prototype.setLeftSpeed = function (n) { - this._actionMap.strafeLeft.speed = n; - }; - CharacterController.prototype.setLeftFastSpeed = function (n) { - this._actionMap.strafeLeftFast.speed = n; - }; - CharacterController.prototype.setRightSpeed = function (n) { - this._actionMap.strafeRight.speed = n; - }; - CharacterController.prototype.setRightFastSpeed = function (n) { - this._actionMap.strafeLeftFast.speed = n; - }; - CharacterController.prototype.setTurnSpeed = function (n) { - this._actionMap.turnLeft.speed = n * Math.PI / 180; - this._actionMap.turnRight.speed = n * Math.PI / 180; - }; - CharacterController.prototype.setTurnFastSpeed = function (n) { - this._actionMap.turnLeftFast.speed = n * Math.PI / 180; - this._actionMap.turnRightFast.speed = n * Math.PI / 180; - }; - CharacterController.prototype.setGravity = function (n) { - this._gravity = n; - }; - CharacterController.prototype.setAnimationGroups = function (agMap) { - if (this._prevActData != null && this._prevActData.exist) - this._prevActData.ag.stop(); - this._isAG = true; - this.setActionMap(agMap); - }; - CharacterController.prototype.setAnimationRanges = function (arMap) { - this._isAG = false; - this.setActionMap(arMap); - }; - CharacterController.prototype.setActionMap = function (inActMap) { - var agMap = false; - var inActData; - var ccActionNames = Object.keys(this._actionMap); - for (var _i = 0, ccActionNames_1 = ccActionNames; _i < ccActionNames_1.length; _i++) { - var ccActionName = ccActionNames_1[_i]; - var ccActData = this._actionMap[ccActionName]; - if (!(ccActData instanceof ActionData)) - continue; - ccActData.exist = false; - inActData = inActMap[ccActData.id]; - if (inActData != null) { - if (inActData instanceof babylonjs__WEBPACK_IMPORTED_MODULE_0__.AnimationGroup) { - ccActData.ag = inActData; - ccActData.name = ccActData.ag.name; - ccActData.exist = true; - agMap = true; - this._hasAnims = true; - } - else if (inActData.exist) { - this._hasAnims = true; - ccActData.exist = true; - if (inActData instanceof Object) { - if (inActData.ag) { - ccActData.ag = inActData.ag; - agMap = true; - } - if (inActData.name) { - ccActData.name = inActData.name; - } - if (inActData.loop != null) - ccActData.loop = inActData.loop; - if (inActData.rate) - ccActData.rate = inActData.rate; - if (inActData.speed) - ccActData.speed = inActData.speed; - if (inActData.sound) - ccActData.sound = inActData.sound; - } - else { - ccActData.name = inActData; - } - } - } - } - this._checkFastAnims(); - this._prevActData = null; - if (agMap) - return "ag"; - else - return "ar"; - }; - CharacterController.prototype.getActionMap = function () { - var map = new ActionMap(); - var keys = Object.keys(this._actionMap); - for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) { - var key = keys_1[_i]; - var actDataI = this._actionMap[key]; - if (!(actDataI instanceof ActionData)) - continue; - if (!actDataI.exist) - continue; - var actDataO = map[actDataI.id]; - actDataO.ag = actDataI.ag; - actDataO.name = actDataI.name; - actDataO.loop = actDataI.loop; - actDataO.rate = actDataI.rate; - actDataO.speed = actDataI.speed; - actDataO.key = actDataI.key; - actDataO.sound = actDataI.sound; - actDataO.exist = actDataI.exist; - } - return map; - }; - CharacterController.prototype.getSettings = function () { - var ccs = new CCSettings(); - ccs.faceForward = this.isFaceForward(); - ccs.topDown = this.getMode() == 1 ? true : false; - ccs.turningOff = this.isTurningOff(); - ccs.cameraTarget = this._cameraTarget.clone(); - ccs.cameraElastic = this._cameraElastic; - ccs.elasticSteps = this._elasticSteps; - ccs.makeInvisble = this._makeInvisible; - ccs.gravity = this._gravity; - ccs.keyboard = this._ekb; - ccs.maxSlopeLimit = this._maxSlopeLimit; - ccs.minSlopeLimit = this._minSlopeLimit; - ccs.noFirstPerson = this._noFirstPerson; - ccs.stepOffset = this._stepOffset; - ccs.sound = this._stepSound; - return ccs; - }; - CharacterController.prototype.setSettings = function (ccs) { - this.setFaceForward(ccs.faceForward); - this.setMode(ccs.topDown ? 1 : 0); - this.setTurningOff(ccs.turningOff); - this.setCameraTarget(ccs.cameraTarget); - this.setCameraElasticity(ccs.cameraElastic); - this.setElasticiSteps(ccs.elasticSteps); - this.makeObstructionInvisible(ccs.makeInvisble); - this.setGravity(ccs.gravity); - this.enableKeyBoard(ccs.keyboard); - this.setSlopeLimit(ccs.minSlopeLimit, ccs.maxSlopeLimit); - this.setNoFirstPerson(ccs.noFirstPerson); - this.setStepOffset(ccs.stepOffset); - this.setSound(ccs.sound); - }; - CharacterController.prototype._setAnim = function (anim, animName, rate, loop) { - if (!this._isAG && this._skeleton == null) - return; - if (animName != null) { - if (this._isAG) { - if (!(animName instanceof babylonjs__WEBPACK_IMPORTED_MODULE_0__.AnimationGroup)) - return; - anim.ag = animName; - anim.exist = true; - } - else { - if (this._skeleton.getAnimationRange(anim.name) != null) { - anim.name = animName; - anim.exist = true; - } - else { - anim.exist = false; - return; - } - } - } - if (loop != null) - anim.loop = loop; - if (rate != null) - anim.rate = rate; - }; - CharacterController.prototype.enableBlending = function (n) { - if (this._isAG) { - var keys = Object.keys(this._actionMap); - for (var _i = 0, keys_2 = keys; _i < keys_2.length; _i++) { - var key = keys_2[_i]; - var act = this._actionMap[key]; - if (!(act instanceof ActionData)) - continue; - if (act.exist) { - var ar = act.ag; - for (var _a = 0, _b = ar.targetedAnimations; _a < _b.length; _a++) { - var ta = _b[_a]; - ta.animation.enableBlending = true; - ta.animation.blendingSpeed = n; - } - } - } - } - else { - if (this._skeleton !== null) - this._skeleton.enableBlending(n); - } - }; - CharacterController.prototype.disableBlending = function () { - if (this._isAG) { - var keys = Object.keys(this._actionMap); - for (var _i = 0, keys_3 = keys; _i < keys_3.length; _i++) { - var key = keys_3[_i]; - var anim = this._actionMap[key]; - if (!(anim instanceof ActionData)) - continue; - if (anim.exist) { - var ar = anim.ag; - for (var _a = 0, _b = ar.targetedAnimations; _a < _b.length; _a++) { - var ta = _b[_a]; - ta.animation.enableBlending = false; - } - } - } - } - }; - CharacterController.prototype.setWalkAnim = function (rangeName, rate, loop) { - this._setAnim(this._actionMap.walk, rangeName, rate, loop); - }; - CharacterController.prototype.setRunAnim = function (rangeName, rate, loop) { - this._setAnim(this._actionMap.run, rangeName, rate, loop); - }; - CharacterController.prototype.setWalkBackAnim = function (rangeName, rate, loop) { - this._setAnim(this._actionMap.walkBack, rangeName, rate, loop); - this._copySlowAnims(this._actionMap.walkBackFast, this._actionMap.walkBack); - }; - CharacterController.prototype.setWalkBackFastAnim = function (rangeName, rate, loop) { - this._setAnim(this._actionMap.walkBackFast, rangeName, rate, loop); - }; - CharacterController.prototype.setSlideBackAnim = function (rangeName, rate, loop) { - this._setAnim(this._actionMap.slideBack, rangeName, rate, loop); - }; - CharacterController.prototype.setIdleAnim = function (rangeName, rate, loop) { - this._setAnim(this._actionMap.idle, rangeName, rate, loop); - }; - CharacterController.prototype.setTurnRightAnim = function (rangeName, rate, loop) { - this._setAnim(this._actionMap.turnRight, rangeName, rate, loop); - this._copySlowAnims(this._actionMap.turnRightFast, this._actionMap.turnRight); - }; - CharacterController.prototype.setTurnRightFastAnim = function (rangeName, rate, loop) { - this._setAnim(this._actionMap.turnRightFast, rangeName, rate, loop); - }; - CharacterController.prototype.setTurnLeftAnim = function (rangeName, rate, loop) { - this._setAnim(this._actionMap.turnLeft, rangeName, rate, loop); - this._copySlowAnims(this._actionMap.turnLeftFast, this._actionMap.turnLeft); - }; - CharacterController.prototype.setTurnLeftFastAnim = function (rangeName, rate, loop) { - this._setAnim(this._actionMap.turnLeftFast, rangeName, rate, loop); - }; - CharacterController.prototype.setStrafeRightAnim = function (rangeName, rate, loop) { - this._setAnim(this._actionMap.strafeRight, rangeName, rate, loop); - this._copySlowAnims(this._actionMap.strafeRightFast, this._actionMap.strafeRight); - }; - CharacterController.prototype.setStrafeRightFastAnim = function (rangeName, rate, loop) { - this._setAnim(this._actionMap.strafeRightFast, rangeName, rate, loop); - }; - CharacterController.prototype.setStrafeLeftAnim = function (rangeName, rate, loop) { - this._setAnim(this._actionMap.strafeLeft, rangeName, rate, loop); - this._copySlowAnims(this._actionMap.strafeLeftFast, this._actionMap.strafeLeft); - }; - CharacterController.prototype.setStrafeLeftFastAnim = function (rangeName, rate, loop) { - this._setAnim(this._actionMap.strafeLeftFast, rangeName, rate, loop); - }; - CharacterController.prototype.setIdleJumpAnim = function (rangeName, rate, loop) { - this._setAnim(this._actionMap.idleJump, rangeName, rate, loop); - }; - CharacterController.prototype.setRunJumpAnim = function (rangeName, rate, loop) { - this._setAnim(this._actionMap.runJump, rangeName, rate, loop); - }; - CharacterController.prototype.setFallAnim = function (rangeName, rate, loop) { - this._setAnim(this._actionMap.fall, rangeName, rate, loop); - }; - CharacterController.prototype.setSound = function (sound) { - if (sound == null) - return; - this._stepSound = sound; - var ccActionNames = Object.keys(this._actionMap); - sound.loop = false; - for (var _i = 0, ccActionNames_2 = ccActionNames; _i < ccActionNames_2.length; _i++) { - var ccActionName = ccActionNames_2[_i]; - var ccActData = this._actionMap[ccActionName]; - if (!(ccActData instanceof ActionData)) - continue; - ccActData.sound = sound; - ccActData.sound.attachToMesh(this._avatar); - } - this._actionMap.idle.sound = null; - this._actionMap.fall.sound = null; - this._actionMap.slideBack.sound = null; - }; - CharacterController.prototype.setWalkKey = function (key) { - this._actionMap.walk.key = key.toLowerCase(); - }; - CharacterController.prototype.setWalkBackKey = function (key) { - this._actionMap.walkBack.key = key.toLowerCase(); - }; - CharacterController.prototype.setTurnLeftKey = function (key) { - this._actionMap.turnLeft.key = key.toLowerCase(); - }; - CharacterController.prototype.setTurnRightKey = function (key) { - this._actionMap.turnRight.key = key.toLowerCase(); - }; - CharacterController.prototype.setStrafeLeftKey = function (key) { - this._actionMap.strafeLeft.key = key.toLowerCase(); - }; - CharacterController.prototype.setStrafeRightKey = function (key) { - this._actionMap.strafeRight.key = key.toLowerCase(); - }; - CharacterController.prototype.setJumpKey = function (key) { - this._actionMap.idleJump.key = key.toLowerCase(); - }; - CharacterController.prototype.setCameraElasticity = function (b) { - this._cameraElastic = b; - }; - CharacterController.prototype.setElasticiSteps = function (n) { - this._elasticSteps = n; - }; - CharacterController.prototype.makeObstructionInvisible = function (b) { - this._makeInvisible = b; - }; - CharacterController.prototype.setCameraTarget = function (v) { - this._cameraTarget.copyFrom(v); - }; - CharacterController.prototype.cameraCollisionChanged = function () { - this._savedCameraCollision = this._camera.checkCollisions; - }; - CharacterController.prototype.setNoFirstPerson = function (b) { - this._noFirstPerson = b; - }; - CharacterController.prototype._checkAnimRanges = function (skel) { - var keys = Object.keys(this._actionMap); - for (var _i = 0, keys_4 = keys; _i < keys_4.length; _i++) { - var key = keys_4[_i]; - var anim = this._actionMap[key]; - if (!(anim instanceof ActionData)) - continue; - if (skel != null) { - if (skel.getAnimationRange(anim.id) != null) { - anim.name = anim.id; - anim.exist = true; - this._hasAnims = true; - } - } - else { - anim.exist = false; - } - } - this._checkFastAnims(); - }; - CharacterController.prototype._checkFastAnims = function () { - this._copySlowAnims(this._actionMap.walkBackFast, this._actionMap.walkBack); - this._copySlowAnims(this._actionMap.turnRightFast, this._actionMap.turnRight); - this._copySlowAnims(this._actionMap.turnLeftFast, this._actionMap.turnLeft); - this._copySlowAnims(this._actionMap.strafeRightFast, this._actionMap.strafeRight); - this._copySlowAnims(this._actionMap.strafeLeftFast, this._actionMap.strafeLeft); - }; - CharacterController.prototype._copySlowAnims = function (f, s) { - if (f.exist) - return; - if (!s.exist) - return; - f.exist = true; - f.ag = s.ag; - f.name = s.name; - f.rate = s.rate * 2; - }; - CharacterController.prototype.setMode = function (n) { - if (this._hasCam) { - this._mode = n; - this._saveMode = n; - } - else { - this._mode = 1; - this._saveMode = 1; - } - }; - CharacterController.prototype.getMode = function () { - return this._mode; - }; - CharacterController.prototype.setTurningOff = function (b) { - this._noRot = b; - }; - CharacterController.prototype.isTurningOff = function () { - return this._noRot; - }; - CharacterController.prototype._setRHS = function (mesh) { - var meshMatrix = mesh.getWorldMatrix(); - var _localX = babylonjs__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArray(meshMatrix.m, 0); - var _localY = babylonjs__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArray(meshMatrix.m, 4); - var _localZ = babylonjs__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArray(meshMatrix.m, 8); - var actualZ = babylonjs__WEBPACK_IMPORTED_MODULE_0__.Vector3.Cross(_localX, _localY); - if (babylonjs__WEBPACK_IMPORTED_MODULE_0__.Vector3.Dot(actualZ, _localZ) < 0) { - this._isLHS_RHS = true; - this._signLHS_RHS = 1; - } - else { - this._isLHS_RHS = false; - this._signLHS_RHS = -1; - } - }; - CharacterController.prototype.setFaceForward = function (b) { - this._ff = b; - this._rhsSign = this._scene.useRightHandedSystem ? -1 : 1; - if (!this._hasCam) { - this._av2cam = 0; - this._ffSign = 1; - return; - } - if (this._isLHS_RHS) { - this._av2cam = b ? Math.PI / 2 : 3 * Math.PI / 2; - this._ffSign = b ? 1 : -1; - } - else { - this._av2cam = b ? 3 * Math.PI / 2 : Math.PI / 2; - this._ffSign = b ? -1 : 1; - } - }; - CharacterController.prototype.isFaceForward = function () { - return this._ff; - }; - CharacterController.prototype.checkAGs = function (agMap) { - var keys = Object.keys(this._actionMap); - for (var _i = 0, keys_5 = keys; _i < keys_5.length; _i++) { - var key = keys_5[_i]; - var anim = this._actionMap[key]; - if (!(anim instanceof ActionData)) - continue; - if (agMap[anim.name] != null) { - anim.ag = agMap[anim.name]; - anim.exist = true; - } - } - }; - CharacterController.prototype._containsAG = function (node, ags, fromRoot) { - var r; - var ns; - if (fromRoot) { - r = this._getRoot(node); - ns = r.getChildren(function (n) { return (n instanceof babylonjs__WEBPACK_IMPORTED_MODULE_0__.TransformNode); }, false); - } - else { - r = node; - ns = [r]; - } - for (var _i = 0, ags_1 = ags; _i < ags_1.length; _i++) { - var ag = ags_1[_i]; - var tas = ag.targetedAnimations; - for (var _a = 0, tas_1 = tas; _a < tas_1.length; _a++) { - var ta = tas_1[_a]; - if (ns.indexOf(ta.target) > -1) { - return true; - } - } - } - return false; - }; - CharacterController.prototype._getRoot = function (tn) { - if (tn.parent == null) - return tn; - return this._getRoot(tn.parent); - }; - CharacterController.prototype.start = function () { - if (this._started) - return; - this._started = true; - this._act.reset(); - this._movFallTime = 0; - this._idleFallTime = 0.001; - this._grounded = false; - this._updateTargetValue(); - if (this._ekb) - this._addkeylistener(); - this._scene.registerBeforeRender(this._renderer); - }; - CharacterController.prototype.stop = function () { - if (!this._started) - return; - this._started = false; - this._scene.unregisterBeforeRender(this._renderer); - this._removekeylistener(); - this._prevActData = null; - }; - CharacterController.prototype.pauseAnim = function () { - this._stopAnim = true; - if (this._prevActData != null && this._prevActData.exist) { - if (this._isAG) { - this._prevActData.ag.stop(); - } - else { - this._scene.stopAnimation(this._skeleton); - } - if (this._prevActData.sound != null) { - this._prevActData.sound.stop(); - } - clearInterval(this._sndId); - this._scene.unregisterBeforeRender(this._renderer); - } - }; - CharacterController.prototype.resumeAnim = function () { - this._stopAnim = false; - this._prevActData = null; - this._scene.registerBeforeRender(this._renderer); - }; - CharacterController.prototype._isAvFacingCamera = function () { - if (!this._hasCam) - return 1; - if (babylonjs__WEBPACK_IMPORTED_MODULE_0__.Vector3.Dot(this._avatar.forward, this._avatar.position.subtract(this._camera.position)) < 0) - return 1; - else - return -1; - }; - CharacterController.prototype._moveAVandCamera = function () { - this._avStartPos.copyFrom(this._avatar.position); - var actData = null; - var dt = this._scene.getEngine().getDeltaTime() / 1000; - if (this._act._jump && !this._inFreeFall) { - this._grounded = false; - this._idleFallTime = 0; - actData = this._doJump(dt); - } - else if (this.anyMovement() || this._inFreeFall) { - this._grounded = false; - this._idleFallTime = 0; - actData = this._doMove(dt); - } - else if (!this._inFreeFall) { - actData = this._doIdle(dt); - } - if (!this._stopAnim && this._hasAnims && actData != null) { - if (this._prevActData !== actData) { - if (actData.exist) { - var c = void 0; - var fps = 30; - if (this._isAG) { - if (this._prevActData != null && this._prevActData.exist) - this._prevActData.ag.stop(); - actData.ag.start(actData.loop, actData.rate); - fps = actData.ag.targetedAnimations[0].animation.framePerSecond; - c = (actData.ag.to - actData.ag.from); - } - else { - var a = this._skeleton.beginAnimation(actData.name, actData.loop, actData.rate); - fps = a.getAnimations()[0].animation.framePerSecond; - c = this._skeleton.getAnimationRange(actData.name).to - this._skeleton.getAnimationRange(actData.name).from; - } - if (this._prevActData != null && this._prevActData.sound != null) { - this._prevActData.sound.stop(); - } - clearInterval(this._sndId); - if (actData.sound != null) { - actData.sound.play(); - this._sndId = setInterval(function () { actData.sound.play(); }, c * 1000 / (fps * Math.abs(actData.rate) * 2)); - } - } - this._prevActData = actData; - } - } - this._updateTargetValue(); - return; - }; - CharacterController.prototype._doJump = function (dt) { - var actData = null; - actData = this._actionMap.runJump; - if (this._jumpTime === 0) { - this._jumpStartPosY = this._avatar.position.y; - } - this._jumpTime = this._jumpTime + dt; - var forwardDist = 0; - var jumpDist = 0; - var disp; - if (this._wasRunning || this._wasWalking) { - if (this._wasRunning) { - forwardDist = this._actionMap.run.speed * dt; - } - else if (this._wasWalking) { - forwardDist = this._actionMap.walk.speed * dt; - } - disp = this._moveVector.clone(); - disp.y = 0; - disp = disp.normalize(); - disp.scaleToRef(forwardDist, disp); - jumpDist = this._calcJumpDist(this._actionMap.runJump.speed, dt); - disp.y = jumpDist; - } - else { - jumpDist = this._calcJumpDist(this._actionMap.idleJump.speed, dt); - disp = new babylonjs__WEBPACK_IMPORTED_MODULE_0__.Vector3(0, jumpDist, 0); - actData = this._actionMap.idleJump; - } - this._avatar.moveWithCollisions(disp); - if (jumpDist < 0) { - if ((this._avatar.position.y > this._avStartPos.y) || ((this._avatar.position.y === this._avStartPos.y) && (disp.length() > 0.001))) { - this._endJump(); - } - else if (this._avatar.position.y < this._jumpStartPosY) { - var actDisp = this._avatar.position.subtract(this._avStartPos); - if (!(this._areVectorsEqual(actDisp, disp, 0.001))) { - if (this._verticalSlope(actDisp) <= this._sl1) { - this._endJump(); - } - } - else { - actData = this._actionMap.fall; - } - } - } - return actData; - }; - CharacterController.prototype._calcJumpDist = function (speed, dt) { - var js = speed - this._gravity * this._jumpTime; - var jumpDist = js * dt - 0.5 * this._gravity * dt * dt; - return jumpDist; - }; - CharacterController.prototype._endJump = function () { - this._act._jump = false; - this._jumpTime = 0; - this._wasWalking = false; - this._wasRunning = false; - }; - CharacterController.prototype._areVectorsEqual = function (v1, v2, p) { - return ((Math.abs(v1.x - v2.x) < p) && (Math.abs(v1.y - v2.y) < p) && (Math.abs(v1.z - v2.z) < p)); - }; - CharacterController.prototype._verticalSlope = function (v) { - return Math.atan(Math.abs(v.y / Math.sqrt(v.x * v.x + v.z * v.z))); - }; - CharacterController.prototype._doMove = function (dt) { - var u = this._movFallTime * this._gravity; - this._freeFallDist = u * dt + this._gravity * dt * dt / 2; - this._movFallTime = this._movFallTime + dt; - var moving = false; - var actdata = null; - if (this._inFreeFall) { - this._moveVector.y = -this._freeFallDist; - moving = true; - } - this._rotateAV2C(); - actdata = this._rotateAVnC(actdata, moving, dt); - if (!this._inFreeFall) { - this._wasWalking = false; - this._wasRunning = false; - var sign = void 0; - var horizDist = 0; - switch (true) { - case (this._act._stepLeft): - sign = this._signLHS_RHS * this._isAvFacingCamera(); - horizDist = this._actionMap.strafeLeft.speed * dt; - if (this._act._speedMod) { - horizDist = this._actionMap.strafeLeftFast.speed * dt; - actdata = (-this._ffSign * sign > 0) ? this._actionMap.strafeLeftFast : this._actionMap.strafeRightFast; - } - else { - actdata = (-this._ffSign * sign > 0) ? this._actionMap.strafeLeft : this._actionMap.strafeRight; - } - this._moveVector = this._avatar.calcMovePOV(sign * horizDist, -this._freeFallDist, 0); - moving = true; - break; - case (this._act._stepRight): - sign = -this._signLHS_RHS * this._isAvFacingCamera(); - horizDist = this._actionMap.strafeRight.speed * dt; - if (this._act._speedMod) { - horizDist = this._actionMap.strafeRightFast.speed * dt; - actdata = (-this._ffSign * sign > 0) ? this._actionMap.strafeLeftFast : this._actionMap.strafeRightFast; - } - else { - actdata = (-this._ffSign * sign > 0) ? this._actionMap.strafeLeft : this._actionMap.strafeRight; - } - this._moveVector = this._avatar.calcMovePOV(sign * horizDist, -this._freeFallDist, 0); - moving = true; - break; - case (this._act._walk || (this._noRot && this._mode == 0)): - if (this._act._speedMod) { - this._wasRunning = true; - horizDist = this._actionMap.run.speed * dt; - actdata = this._actionMap.run; - } - else { - this._wasWalking = true; - horizDist = this._actionMap.walk.speed * dt; - actdata = this._actionMap.walk; - } - this._moveVector = this._avatar.calcMovePOV(0, -this._freeFallDist, this._ffSign * horizDist); - moving = true; - break; - case (this._act._walkback): - horizDist = this._actionMap.walkBack.speed * dt; - if (this._act._speedMod) { - horizDist = this._actionMap.walkBackFast.speed * dt; - actdata = this._actionMap.walkBackFast; - } - else { - actdata = this._actionMap.walkBack; - } - this._moveVector = this._avatar.calcMovePOV(0, -this._freeFallDist, -this._ffSign * horizDist); - moving = true; - break; - } - } - if (moving) { - if (this._moveVector.length() > 0.001) { - this._avatar.moveWithCollisions(this._moveVector); - if (this._avatar.position.y > this._avStartPos.y) { - var actDisp = this._avatar.position.subtract(this._avStartPos); - var _slp = this._verticalSlope(actDisp); - if (_slp >= this._sl2) { - if (this._stepOffset > 0) { - if (this._vMoveTot == 0) { - this._vMovStartPos.copyFrom(this._avStartPos); - } - this._vMoveTot = this._vMoveTot + (this._avatar.position.y - this._avStartPos.y); - if (this._vMoveTot > this._stepOffset) { - this._vMoveTot = 0; - this._avatar.position.copyFrom(this._vMovStartPos); - this._endFreeFall(); - } - } - else { - this._avatar.position.copyFrom(this._avStartPos); - this._endFreeFall(); - } - } - else { - this._vMoveTot = 0; - if (_slp > this._sl1) { - this._fallFrameCount = 0; - this._inFreeFall = false; - } - else { - this._endFreeFall(); - } - } - } - else if ((this._avatar.position.y) < this._avStartPos.y) { - var actDisp = this._avatar.position.subtract(this._avStartPos); - if (!(this._areVectorsEqual(actDisp, this._moveVector, 0.001))) { - if (this._verticalSlope(actDisp) <= this._sl1) { - this._endFreeFall(); - } - else { - this._fallFrameCount = 0; - this._inFreeFall = false; - } - } - else { - this._inFreeFall = true; - this._fallFrameCount++; - if (this._fallFrameCount > this._fallFrameCountMin) { - actdata = this._actionMap.fall; - } - } - } - else { - this._endFreeFall(); - } - } - } - return actdata; - }; - CharacterController.prototype._rotateAV2C = function () { - if (this._hasCam) - if (this._mode != 1) { - var ca = (this._hasCam) ? (this._av2cam - this._camera.alpha) : 0; - if (this._noRot) { - switch (true) { - case (this._act._walk && this._act._turnRight): - this._avatar.rotation.y = ca + this._rhsSign * Math.PI / 4; - break; - case (this._act._walk && this._act._turnLeft): - this._avatar.rotation.y = ca - this._rhsSign * Math.PI / 4; - break; - case (this._act._walkback && this._act._turnRight): - this._avatar.rotation.y = ca + this._rhsSign * 3 * Math.PI / 4; - break; - case (this._act._walkback && this._act._turnLeft): - this._avatar.rotation.y = ca - this._rhsSign * 3 * Math.PI / 4; - break; - case (this._act._walk): - this._avatar.rotation.y = ca; - break; - case (this._act._walkback): - this._avatar.rotation.y = ca + Math.PI; - break; - case (this._act._turnRight): - this._avatar.rotation.y = ca + this._rhsSign * Math.PI / 2; - break; - case (this._act._turnLeft): - this._avatar.rotation.y = ca - this._rhsSign * Math.PI / 2; - break; - } - } - else { - if (this._hasCam) - this._avatar.rotation.y = ca; - } - } - }; - CharacterController.prototype._rotateAVnC = function (anim, moving, dt) { - if (!(this._noRot && this._mode == 0) && (!this._act._stepLeft && !this._act._stepRight) && (this._act._turnLeft || this._act._turnRight)) { - var turnAngle = this._actionMap.turnLeft.speed * dt; - if (this._act._speedMod) { - turnAngle = 2 * turnAngle; - } - var a = void 0; - if (this._mode == 1) { - if (!this._isTurning) { - this._sign = -this._ffSign * this._isAvFacingCamera(); - if (this._isLHS_RHS) - this._sign = -this._sign; - this._isTurning = true; - } - a = this._sign; - if (this._act._turnLeft) { - if (this._act._walk) { } - else if (this._act._walkback) - a = -this._sign; - else { - anim = (this._sign > 0) ? this._actionMap.turnRight : this._actionMap.turnLeft; - } - } - else { - if (this._act._walk) - a = -this._sign; - else if (this._act._walkback) { } - else { - a = -this._sign; - anim = (this._sign > 0) ? this._actionMap.turnLeft : this._actionMap.turnRight; - } - } - } - else { - a = 1; - if (this._act._turnLeft) { - if (this._act._walkback) - a = -1; - if (!moving) - anim = this._actionMap.turnLeft; - } - else { - if (this._act._walk) - a = -1; - if (!moving) { - a = -1; - anim = this._actionMap.turnRight; - } - } - if (this._hasCam) - this._camera.alpha = this._camera.alpha + this._rhsSign * turnAngle * a; - } - this._avatar.rotation.y = this._avatar.rotation.y + turnAngle * a; - } - return anim; - }; - CharacterController.prototype._endFreeFall = function () { - this._movFallTime = 0; - this._fallFrameCount = 0; - this._inFreeFall = false; - }; - CharacterController.prototype._doIdle = function (dt) { - if (this._grounded) { - return this._actionMap.idle; - } - this._wasWalking = false; - this._wasRunning = false; - this._movFallTime = 0; - var anim = this._actionMap.idle; - this._fallFrameCount = 0; - if (dt === 0) { - this._freeFallDist = 5; - } - else { - var u = this._idleFallTime * this._gravity; - this._freeFallDist = u * dt + this._gravity * dt * dt / 2; - this._idleFallTime = this._idleFallTime + dt; - } - if (this._freeFallDist < 0.01) - return anim; - var disp = new babylonjs__WEBPACK_IMPORTED_MODULE_0__.Vector3(0, -this._freeFallDist, 0); - this._avatar.moveWithCollisions(disp); - if ((this._avatar.position.y > this._avStartPos.y) || (this._avatar.position.y === this._avStartPos.y)) { - this._groundIt(); - } - else if (this._avatar.position.y < this._avStartPos.y) { - var actDisp = this._avatar.position.subtract(this._avStartPos); - if (!(this._areVectorsEqual(actDisp, disp, 0.001))) { - if (this._verticalSlope(actDisp) <= this._sl1) { - this._groundIt(); - this._avatar.position.copyFrom(this._avStartPos); - } - else { - this._unGroundIt(); - anim = this._actionMap.slideBack; - } - } - else { - anim = this._actionMap.fall; - } - } - return anim; - }; - CharacterController.prototype._groundIt = function () { - this._groundFrameCount++; - if (this._groundFrameCount > this._groundFrameMax) { - this._grounded = true; - this._idleFallTime = 0; - } - }; - CharacterController.prototype._unGroundIt = function () { - this._grounded = false; - this._groundFrameCount = 0; - }; - CharacterController.prototype._updateTargetValue = function () { - if (!this._hasCam) - return; - if (this._vMoveTot == 0) - this._avatar.position.addToRef(this._cameraTarget, this._camera.target); - if (this._camera.radius > this._camera.lowerRadiusLimit) { - if (this._cameraElastic || this._makeInvisible) - this._handleObstruction(); - } - if (this._camera.radius <= this._camera.lowerRadiusLimit) { - if (!this._noFirstPerson && !this._inFP) { - this._makeMeshInvisible(this._avatar); - this._camera.checkCollisions = false; - this._saveMode = this._mode; - this._mode = 0; - this._inFP = true; - } - } - else { - if (this._inFP) { - this._inFP = false; - this._mode = this._saveMode; - this._restoreVisiblity(this._avatar); - this._camera.checkCollisions = this._savedCameraCollision; - } - } - }; - CharacterController.prototype._makeMeshInvisible = function (mesh) { - var _this = this; - this._visiblityMap.set(mesh, mesh.visibility); - mesh.visibility = 0; - mesh.getChildMeshes(false, function (n) { - if (n instanceof babylonjs__WEBPACK_IMPORTED_MODULE_0__.Mesh) { - _this._visiblityMap.set(n, n.visibility); - n.visibility = 0; - } - return false; - }); - }; - CharacterController.prototype._restoreVisiblity = function (mesh) { - var _this = this; - mesh.visibility = this._visiblityMap.get(mesh); - mesh.getChildMeshes(false, function (n) { - if (n instanceof babylonjs__WEBPACK_IMPORTED_MODULE_0__.Mesh) - n.visibility = _this._visiblityMap.get(n); - return false; - }); - }; - ; - CharacterController.prototype._handleObstruction = function () { - var _this = this; - this._camera.position.subtractToRef(this._camera.target, this._rayDir); - this._ray.origin = this._camera.target; - this._ray.length = this._rayDir.length(); - this._ray.direction = this._rayDir.normalize(); - var pis = this._scene.multiPickWithRay(this._ray, function (mesh) { - if (mesh == _this._avatar) - return false; - else - return true; - }); - if (this._makeInvisible) { - this._prevPickedMeshes = this._pickedMeshes; - if (pis.length > 0) { - this._pickedMeshes = new Array(); - for (var _i = 0, pis_1 = pis; _i < pis_1.length; _i++) { - var pi = pis_1[_i]; - if (pi.pickedMesh.isVisible || this._prevPickedMeshes.includes(pi.pickedMesh)) { - pi.pickedMesh.isVisible = false; - this._pickedMeshes.push(pi.pickedMesh); - } - } - for (var _a = 0, _b = this._prevPickedMeshes; _a < _b.length; _a++) { - var pm = _b[_a]; - if (!this._pickedMeshes.includes(pm)) { - pm.isVisible = true; - } - } - } - else { - for (var _c = 0, _d = this._prevPickedMeshes; _c < _d.length; _c++) { - var pm = _d[_c]; - pm.isVisible = true; - } - this._prevPickedMeshes.length = 0; - } - } - if (this._cameraElastic) { - if (pis.length > 0) { - if ((pis.length == 1 && !this._isSeeAble(pis[0].pickedMesh)) && (!pis[0].pickedMesh.checkCollisions || !this._camera.checkCollisions)) - return; - var pp = null; - for (var i = 0; i < pis.length; i++) { - var pm = pis[i].pickedMesh; - if (this._isSeeAble(pm)) { - pp = pis[i].pickedPoint; - break; - } - else if (pm.checkCollisions) { - pp = pis[i].pickedPoint; - break; - } - } - if (pp == null) - return; - var c2p = this._camera.position.subtract(pp); - var l = c2p.length(); - if (this._camera.checkCollisions) { - var step = void 0; - if (l <= 1) { - step = c2p.addInPlace(c2p.normalizeToNew().scaleInPlace(this._cameraSkin)); - } - else { - step = c2p.normalize().scaleInPlace(l / this._elasticSteps); - } - this._camera.position = this._camera.position.subtract(step); - } - else { - var step = void 0; - if (l <= 1) - step = l + this._cameraSkin; - else - step = l / this._elasticSteps; - this._camera.radius = this._camera.radius - (step); - } - } - } - }; - CharacterController.prototype._isSeeAble = function (mesh) { - if (!mesh.isVisible) - return false; - if (mesh.visibility == 0) - return false; - if (mesh.material != null && mesh.material.alphaMode != 0 && mesh.material.alpha == 0) - return false; - return true; - }; - CharacterController.prototype.anyMovement = function () { - return (this._act._walk || this._act._walkback || this._act._turnLeft || this._act._turnRight || this._act._stepLeft || this._act._stepRight); - }; - CharacterController.prototype._onKeyDown = function (e) { - if (!e.key) - return; - if (e.repeat) - return; - switch (e.key.toLowerCase()) { - case this._actionMap.idleJump.key: - this._act._jump = true; - break; - case "capslock": - this._act._speedMod = !this._act._speedMod; - break; - case "shift": - this._act._speedMod = true; - break; - case "up": - case "arrowup": - case this._actionMap.walk.key: - this._act._walk = true; - break; - case "left": - case "arrowleft": - case this._actionMap.turnLeft.key: - this._act._turnLeft = true; - break; - case "right": - case "arrowright": - case this._actionMap.turnRight.key: - this._act._turnRight = true; - break; - case "down": - case "arrowdown": - case this._actionMap.walkBack.key: - this._act._walkback = true; - break; - case this._actionMap.strafeLeft.key: - this._act._stepLeft = true; - break; - case this._actionMap.strafeRight.key: - this._act._stepRight = true; - break; - } - this._move = this.anyMovement(); - }; - CharacterController.prototype._onKeyUp = function (e) { - if (!e.key) - return; - switch (e.key.toLowerCase()) { - case "shift": - this._act._speedMod = false; - break; - case "up": - case "arrowup": - case this._actionMap.walk.key: - this._act._walk = false; - break; - case "left": - case "arrowleft": - case this._actionMap.turnLeft.key: - this._act._turnLeft = false; - this._isTurning = false; - break; - case "right": - case "arrowright": - case this._actionMap.turnRight.key: - this._act._turnRight = false; - this._isTurning = false; - break; - case "down": - case "arrowdown": - case this._actionMap.walkBack.key: - this._act._walkback = false; - break; - case this._actionMap.strafeLeft.key: - this._act._stepLeft = false; - break; - case this._actionMap.strafeRight.key: - this._act._stepRight = false; - break; - } - this._move = this.anyMovement(); - }; - CharacterController.prototype.isKeyBoardEnabled = function () { - return this._ekb; - }; - CharacterController.prototype.enableKeyBoard = function (b) { - this._ekb = b; - if (b) { - this._addkeylistener(); - } - else { - this._removekeylistener(); - } - }; - CharacterController.prototype._addkeylistener = function () { - var canvas = this._scene.getEngine().getRenderingCanvas(); - canvas.addEventListener("keyup", this._handleKeyUp, false); - canvas.addEventListener("keydown", this._handleKeyDown, false); - }; - CharacterController.prototype._removekeylistener = function () { - var canvas = this._scene.getEngine().getRenderingCanvas(); - canvas.removeEventListener("keyup", this._handleKeyUp, false); - canvas.removeEventListener("keydown", this._handleKeyDown, false); - }; - CharacterController.prototype.walk = function (b) { - this._act._walk = b; - }; - CharacterController.prototype.walkBack = function (b) { - this._act._walkback = b; - }; - CharacterController.prototype.walkBackFast = function (b) { - this._act._walkback = b; - this._act._speedMod = b; - }; - CharacterController.prototype.run = function (b) { - this._act._walk = b; - this._act._speedMod = b; - }; - CharacterController.prototype.turnLeft = function (b) { - this._act._turnLeft = b; - if (!b) - this._isTurning = b; - }; - CharacterController.prototype.turnLeftFast = function (b) { - this._act._turnLeft = b; - if (!b) - this._isTurning = b; - this._act._speedMod = b; - }; - CharacterController.prototype.turnRight = function (b) { - this._act._turnRight = b; - if (!b) - this._isTurning = b; - }; - CharacterController.prototype.turnRightFast = function (b) { - this._act._turnRight = b; - if (!b) - this._isTurning = b; - this._act._speedMod = b; - }; - CharacterController.prototype.strafeLeft = function (b) { - this._act._stepLeft = b; - }; - CharacterController.prototype.strafeLeftFast = function (b) { - this._act._stepLeft = b; - this._act._speedMod = b; - }; - CharacterController.prototype.strafeRight = function (b) { - this._act._stepRight = b; - }; - CharacterController.prototype.strafeRightFast = function (b) { - this._act._stepRight = b; - this._act._speedMod = b; - }; - CharacterController.prototype.jump = function () { - this._act._jump = true; - }; - CharacterController.prototype.fall = function () { - this._grounded = false; - }; - CharacterController.prototype.idle = function () { - this._act.reset(); - }; - CharacterController.prototype.isAg = function () { - return this._isAG; - }; - CharacterController.prototype._findSkel = function (n) { - var root = this._root(n); - if (root instanceof babylonjs__WEBPACK_IMPORTED_MODULE_0__.Mesh && root.skeleton) - return root.skeleton; - var ms = root.getChildMeshes(false, function (cm) { - if (cm instanceof babylonjs__WEBPACK_IMPORTED_MODULE_0__.Mesh) { - if (cm.skeleton) { - return true; - } - } - return false; - }); - if (ms.length > 0) - return ms[0].skeleton; - else - return null; - }; - CharacterController.prototype._root = function (tn) { - if (tn.parent == null) - return tn; - return this._root(tn.parent); - }; - CharacterController.prototype.setAvatar = function (avatar, faceForward) { - if (faceForward === void 0) { faceForward = false; } - var rootNode = this._root(avatar); - if (rootNode instanceof babylonjs__WEBPACK_IMPORTED_MODULE_0__.Mesh) { - this._avatar = rootNode; - } - else { - console.error("Cannot move this mesh. The root node of the mesh provided is not a mesh"); - return false; - } - this._skeleton = this._findSkel(avatar); - this._isAG = this._containsAG(avatar, this._scene.animationGroups, true); - this._actionMap.reset(); - if (!this._isAG && this._skeleton != null) - this._checkAnimRanges(this._skeleton); - this._setRHS(avatar); - this.setFaceForward(faceForward); - return true; - }; - CharacterController.prototype.getAvatar = function () { - return this._avatar; - }; - CharacterController.prototype.setAvatarSkeleton = function (skeleton) { - this._skeleton = skeleton; - if (this._skeleton != null && this._skelDrivenByAG(skeleton)) - this._isAG = true; - else - this._isAG = false; - if (!this._isAG && this._skeleton != null) - this._checkAnimRanges(this._skeleton); - }; - CharacterController.prototype._skelDrivenByAG = function (skeleton) { - var _this = this; - return skeleton.animations.some(function (sa) { return _this._scene.animationGroups.some(function (ag) { return ag.children.some(function (ta) { return ta.animation == sa; }); }); }); - }; - CharacterController.prototype.getSkeleton = function () { - return this._skeleton; - }; - return CharacterController; -}()); - -var _Action = (function () { - function _Action() { - this._walk = false; - this._walkback = false; - this._turnRight = false; - this._turnLeft = false; - this._stepRight = false; - this._stepLeft = false; - this._jump = false; - this._speedMod = false; - this.reset(); - } - _Action.prototype.reset = function () { - this._walk = false; - this._walkback = false; - this._turnRight = false; - this._turnLeft = false; - this._stepRight = false; - this._stepLeft = false; - this._jump = false; - this._speedMod = false; - }; - return _Action; -}()); -var ActionData = (function () { - function ActionData(id, speed, key) { - if (speed === void 0) { speed = 1; } - this.name = ""; - this.loop = true; - this.rate = 1; - this.exist = false; - this.id = id; - this.speed = speed; - this.ds = speed; - this.key = key; - this.dk = key; - } - ActionData.prototype.reset = function () { - this.name = ""; - this.speed = this.ds; - this.key = this.dk; - this.loop = true; - this.rate = 1; - this.sound = null; - this.exist = false; - }; - return ActionData; -}()); - -var ActionMap = (function () { - function ActionMap() { - this.walk = new ActionData("walk", 3, "w"); - this.walkBack = new ActionData("walkBack", 1.5, "s"); - this.walkBackFast = new ActionData("walkBackFast", 3, "na"); - this.idle = new ActionData("idle", 0, "na"); - this.idleJump = new ActionData("idleJump", 6, " "); - this.run = new ActionData("run", 6, "na"); - this.runJump = new ActionData("runJump", 6, "na"); - this.fall = new ActionData("fall", 0, "na"); - this.turnLeft = new ActionData("turnLeft", Math.PI / 8, "a"); - this.turnLeftFast = new ActionData("turnLeftFast", Math.PI / 4, "na"); - this.turnRight = new ActionData("turnRight", Math.PI / 8, "d"); - this.turnRightFast = new ActionData("turnRightFast", Math.PI / 4, "na"); - this.strafeLeft = new ActionData("strafeLeft", 1.5, "q"); - this.strafeLeftFast = new ActionData("strafeLeftFast", 3, "na"); - this.strafeRight = new ActionData("strafeRight", 1.5, "e"); - this.strafeRightFast = new ActionData("strafeRightFast", 3, "na"); - this.slideBack = new ActionData("slideBack", 0, "na"); - } - ActionMap.prototype.reset = function () { - var keys = Object.keys(this); - for (var _i = 0, keys_6 = keys; _i < keys_6.length; _i++) { - var key = keys_6[_i]; - var act = this[key]; - if (!(act instanceof ActionData)) - continue; - act.reset(); - } - }; - return ActionMap; -}()); - -; -var CCSettings = (function () { - function CCSettings() { - this.cameraElastic = true; - this.makeInvisble = true; - this.cameraTarget = babylonjs__WEBPACK_IMPORTED_MODULE_0__.Vector3.Zero(); - this.noFirstPerson = false; - this.topDown = true; - this.turningOff = true; - this.keyboard = true; - } - return CCSettings; -}()); - - -})(); - -/******/ return __webpack_exports__; -/******/ })() -; -}); -//# sourceMappingURL=CharacterController.max.js.map \ No newline at end of file diff --git a/dist-old/CharacterController.max.js.map b/dist-old/CharacterController.max.js.map deleted file mode 100644 index 899c19b..0000000 --- a/dist-old/CharacterController.max.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"CharacterController.max.js","mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,O;;;;;;;;;;ACVA;;;;;;UCAA;UACA;;UAEA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;;UAEA;UACA;;UAEA;UACA;UACA;;;;;WCtBA;WACA;WACA;WACA;WACA;WACA,iCAAiC,WAAW;WAC5C;WACA;;;;;WCPA;WACA;WACA;WACA;WACA,yCAAyC,wCAAwC;WACjF;WACA;WACA;;;;;WCPA;;;;;WCAA;WACA;W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;YACR,IAAI,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;YACpB,IAAI,CAAC,CAAC,GAAG,YAAY,UAAU,CAAC;gBAAE,SAAS;YAC3C,GAAG,CAAC,KAAK,EAAE;SACd;IACL,CAAC;IACL,gBAAC;AAAD,CAAC;;AAAA,CAAC;AAEF;IAAA;QAMW,kBAAa,GAAY,IAAI,CAAC;QAE9B,iBAAY,GAAY,IAAI,CAAC;QAC7B,iBAAY,GAAY,mDAAY,EAAE,CAAC;QACvC,kBAAa,GAAY,KAAK,CAAC;QAC/B,YAAO,GAAY,IAAI,CAAC;QAExB,eAAU,GAAY,IAAI,CAAC;QAC3B,aAAQ,GAAY,IAAI,CAAC;IAEpC,CAAC;IAAD,iBAAC;AAAD,CAAC","sources":["webpack://babylonjs-charactercontroller/webpack/universalModuleDefinition","webpack://babylonjs-charactercontroller/external umd {\"commonjs\":\"babylonjs\",\"commonjs2\":\"babylonjs\",\"amd\":\"babylonjs\",\"root\":\"BABYLON\"}","webpack://babylonjs-charactercontroller/webpack/bootstrap","webpack://babylonjs-charactercontroller/webpack/runtime/compat get default export","webpack://babylonjs-charactercontroller/webpack/runtime/define property getters","webpack://babylonjs-charactercontroller/webpack/runtime/hasOwnProperty shorthand","webpack://babylonjs-charactercontroller/webpack/runtime/make namespace object","webpack://babylonjs-charactercontroller/./src/CharacterController.ts"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"babylonjs\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([\"babylonjs\"], factory);\n\telse {\n\t\tvar a = typeof exports === 'object' ? factory(require(\"babylonjs\")) : factory(root[\"BABYLON\"]);\n\t\tfor(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];\n\t}\n})(self, (__WEBPACK_EXTERNAL_MODULE_babylonjs__) => {\nreturn ","module.exports = __WEBPACK_EXTERNAL_MODULE_babylonjs__;","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import {\r\n Skeleton,\r\n ArcRotateCamera,\r\n Vector3,\r\n Mesh,\r\n Node,\r\n Scene,\r\n Ray,\r\n PickingInfo,\r\n AnimationGroup,\r\n TransformNode,\r\n TargetedAnimation,\r\n Matrix,\r\n DeepImmutable,\r\n AbstractMesh,\r\n PlaySoundAction,\r\n InstancedMesh,\r\n Sound,\r\n AnimationRange,\r\n Animatable,\r\n AnimationEvent,\r\n int\r\n} from \"babylonjs\";\r\n\r\n\r\nexport class CharacterController {\r\n\r\n private _avatar: Mesh = null;\r\n private _skeleton: Skeleton = null;\r\n private _camera: ArcRotateCamera;\r\n private _scene: Scene;\r\n public getScene(): Scene {\r\n return this._scene;\r\n }\r\n\r\n\r\n private _gravity: number = 9.8;\r\n //slopeLimit in degrees\r\n private _minSlopeLimit: number = 30;\r\n private _maxSlopeLimit: number = 45;\r\n //slopeLimit in radians\r\n private _sl1: number = Math.PI * this._minSlopeLimit / 180;\r\n private _sl2: number = Math.PI * this._maxSlopeLimit / 180;\r\n\r\n //The av will step up a stair only if it is closer to the ground than the indicated value.\r\n private _stepOffset: number = 0.25;\r\n //toal amount by which the av has moved up\r\n private _vMoveTot: number = 0;\r\n //position of av when it started moving up\r\n private _vMovStartPos: Vector3 = Vector3.Zero();\r\n\r\n\r\n private _actionMap: ActionMap = new ActionMap();\r\n\r\n private _cameraElastic: boolean = true;\r\n private _cameraTarget: Vector3 = Vector3.Zero();\r\n //should we go into first person view when camera is near avatar (radius is lowerradius limit)\r\n private _noFirstPerson: boolean = false;\r\n\r\n\r\n\r\n public setSlopeLimit(minSlopeLimit: number, maxSlopeLimit: number) {\r\n this._minSlopeLimit = minSlopeLimit;\r\n this._maxSlopeLimit = maxSlopeLimit;\r\n\r\n this._sl1 = Math.PI * this._minSlopeLimit / 180;\r\n this._sl2 = Math.PI * this._maxSlopeLimit / 180;\r\n }\r\n\r\n /**\r\n * The av will step up a stair only if it is closer to the ground than the indicated value.\r\n * Default value is 0.25 m\r\n */\r\n public setStepOffset(stepOffset: number) {\r\n this._stepOffset = stepOffset;\r\n }\r\n\r\n public setWalkSpeed(n: number) {\r\n this._actionMap.walk.speed = n;\r\n }\r\n public setRunSpeed(n: number) {\r\n this._actionMap.run.speed = n;\r\n }\r\n public setBackSpeed(n: number) {\r\n this._actionMap.walkBack.speed = n;\r\n }\r\n public setBackFastSpeed(n: number) {\r\n this._actionMap.walkBackFast.speed = n;\r\n }\r\n public setJumpSpeed(n: number) {\r\n this._actionMap.idleJump.speed = n;\r\n this._actionMap.runJump.speed = n;\r\n }\r\n public setLeftSpeed(n: number) {\r\n this._actionMap.strafeLeft.speed = n;\r\n }\r\n public setLeftFastSpeed(n: number) {\r\n this._actionMap.strafeLeftFast.speed = n;\r\n }\r\n public setRightSpeed(n: number) {\r\n this._actionMap.strafeRight.speed = n;\r\n }\r\n public setRightFastSpeed(n: number) {\r\n this._actionMap.strafeLeftFast.speed = n;\r\n }\r\n // get turnSpeed in degrees per second.\r\n // store in radians per second\r\n public setTurnSpeed(n: number) {\r\n this._actionMap.turnLeft.speed = n * Math.PI / 180;\r\n this._actionMap.turnRight.speed = n * Math.PI / 180;\r\n }\r\n public setTurnFastSpeed(n: number) {\r\n this._actionMap.turnLeftFast.speed = n * Math.PI / 180;\r\n this._actionMap.turnRightFast.speed = n * Math.PI / 180;\r\n }\r\n public setGravity(n: number) {\r\n this._gravity = n;\r\n }\r\n\r\n /**\r\n * Use this to provide animationGroups to the character controller.\r\n * Provide the AnimationGroups using a Map\r\n * In this Map the key would be the character controller animation name and\r\n * the key value would be the animationGroup.\r\n * Example:\r\n * let myWalkAnimationGroup:AnimationGroup = ...;\r\n * let agMap:{} = {\r\n * \"walk\":myWalkAnimationGroup,\r\n * \"run\" : {\"ag\":myRunAnimationGroup,\"rate\":1},\r\n * \"idle\" : {\"ag\":myIdleAnimationGroup,\"loop\":true,\"rate\":1},\r\n * ....\r\n * ....\r\n * }\r\n * \r\n * @param agMap a map of character controller animation name to animationGroup\r\n */\r\n public setAnimationGroups(agMap: {}) {\r\n if (this._prevActData != null && this._prevActData.exist) this._prevActData.ag.stop();\r\n this._isAG = true;\r\n this.setActionMap(agMap);\r\n }\r\n\r\n /**\r\n * Use this to provide AnimationRanges to the character controller.\r\n * Provide the AnimationRanges using a Map\r\n * In this Map the key would be the character controller animation name and\r\n * the key value would be the animation range name or an object with animation range data.\r\n * example:\r\n * let arMap = {\r\n * \"walk\":\"myWalk\",\r\n * \"run\" : {\"name\":\"myRun\",\"rate\":1},\r\n * \"idle\" : {\"name\":\"myIdle\",\"loop\":true,\"rate\":1},\r\n * ....\r\n * }\r\n * \r\n * @param arMap a map of character controller animation name to animationRange data\r\n */\r\n\r\n public setAnimationRanges(arMap: {}) {\r\n this._isAG = false;\r\n this.setActionMap(arMap);\r\n }\r\n\r\n /**\r\n * updates action data in the cc actionMap\r\n * with action data from the provided/input actionMap \r\n * \r\n * \r\n * return \"ar\" or \"ag\" depending on if the data provided\r\n * was animation range or animation group data respt.\r\n * \r\n * TODO should validate provided data.\r\n * In other words if animation range provided make sure\r\n * the range exist in the skeleton\r\n * or if animation group provided make sure the animation group\r\n * can be played on this avataor\r\n * \r\n * @param inActMap \r\n * @returns \r\n */\r\n public setActionMap(inActMap: ActionMap): string {\r\n let agMap: boolean = false;\r\n let inActData: ActionData;\r\n\r\n\r\n let ccActionNames: string[] = Object.keys(this._actionMap);\r\n for (let ccActionName of ccActionNames) {\r\n let ccActData = this._actionMap[ccActionName];\r\n //some keys could map to functions (like reset())\r\n if (!(ccActData instanceof ActionData)) continue;\r\n ccActData.exist = false;\r\n\r\n inActData = inActMap[ccActData.id];\r\n //in previous version of cc the key value was AnimationGroup rather than ActionData\r\n //lets accomodate that for backward compatibility\r\n if (inActData != null) {\r\n if (inActData instanceof AnimationGroup) {\r\n ccActData.ag = inActData;\r\n ccActData.name = ccActData.ag.name;\r\n ccActData.exist = true;\r\n agMap = true;\r\n this._hasAnims = true;\r\n } else if (inActData.exist) {\r\n this._hasAnims = true;\r\n ccActData.exist = true;\r\n if (inActData instanceof Object) {\r\n if (inActData.ag) {\r\n ccActData.ag = inActData.ag;\r\n agMap = true;\r\n }\r\n if (inActData.name) {\r\n ccActData.name = inActData.name;\r\n }\r\n if (inActData.loop != null) ccActData.loop = inActData.loop;\r\n if (inActData.rate) ccActData.rate = inActData.rate;\r\n if (inActData.speed) ccActData.speed = inActData.speed;\r\n // if (actDataI.key) actDataO.key = actDataI.key;\r\n if (inActData.sound) ccActData.sound = inActData.sound;\r\n } else {\r\n ccActData.name = inActData;\r\n }\r\n }\r\n }\r\n }\r\n this._checkFastAnims();\r\n //force to play new anims\r\n this._prevActData = null;\r\n if (agMap) return \"ag\"; else return \"ar\";\r\n }\r\n\r\n public getActionMap(): ActionMap {\r\n let map: ActionMap = new ActionMap();\r\n\r\n let keys: string[] = Object.keys(this._actionMap);\r\n for (let key of keys) {\r\n let actDataI = this._actionMap[key];\r\n\r\n if (!(actDataI instanceof ActionData)) continue;\r\n if (!actDataI.exist) continue;\r\n\r\n let actDataO: ActionData = map[actDataI.id];\r\n actDataO.ag = actDataI.ag;\r\n actDataO.name = actDataI.name;\r\n actDataO.loop = actDataI.loop;\r\n actDataO.rate = actDataI.rate;\r\n actDataO.speed = actDataI.speed;\r\n actDataO.key = actDataI.key;\r\n actDataO.sound = actDataI.sound;\r\n actDataO.exist = actDataI.exist;\r\n }\r\n\r\n return map;\r\n }\r\n\r\n public getSettings(): CCSettings {\r\n let ccs: CCSettings = new CCSettings();\r\n ccs.faceForward = this.isFaceForward();\r\n ccs.topDown = this.getMode() == 1 ? true : false;\r\n ccs.turningOff = this.isTurningOff();\r\n ccs.cameraTarget = this._cameraTarget.clone();\r\n ccs.cameraElastic = this._cameraElastic;\r\n ccs.elasticSteps = this._elasticSteps;\r\n ccs.makeInvisble = this._makeInvisible;\r\n ccs.gravity = this._gravity;\r\n ccs.keyboard = this._ekb;\r\n ccs.maxSlopeLimit = this._maxSlopeLimit;\r\n ccs.minSlopeLimit = this._minSlopeLimit;\r\n ccs.noFirstPerson = this._noFirstPerson;\r\n ccs.stepOffset = this._stepOffset;\r\n ccs.sound = this._stepSound;\r\n\r\n return ccs;\r\n }\r\n\r\n public setSettings(ccs: CCSettings) {\r\n this.setFaceForward(ccs.faceForward);\r\n this.setMode(ccs.topDown ? 1 : 0);\r\n this.setTurningOff(ccs.turningOff);\r\n this.setCameraTarget(ccs.cameraTarget);\r\n this.setCameraElasticity(ccs.cameraElastic);\r\n this.setElasticiSteps(ccs.elasticSteps);\r\n this.makeObstructionInvisible(ccs.makeInvisble);\r\n this.setGravity(ccs.gravity);\r\n this.enableKeyBoard(ccs.keyboard);\r\n this.setSlopeLimit(ccs.minSlopeLimit, ccs.maxSlopeLimit);\r\n this.setNoFirstPerson(ccs.noFirstPerson);\r\n this.setStepOffset(ccs.stepOffset);\r\n this.setSound(ccs.sound);\r\n\r\n }\r\n\r\n private _setAnim(anim: ActionData, animName?: string | AnimationGroup, rate?: number, loop?: boolean) {\r\n\r\n //animation range need skeleton\r\n if (!this._isAG && this._skeleton == null) return;\r\n\r\n if (animName != null) {\r\n if (this._isAG) {\r\n if (!(animName instanceof AnimationGroup)) return;\r\n anim.ag = animName;\r\n anim.exist = true;\r\n } else {\r\n if (this._skeleton.getAnimationRange(anim.name) != null) {\r\n anim.name = animName;\r\n anim.exist = true;\r\n } else {\r\n anim.exist = false;\r\n return;\r\n }\r\n }\r\n }\r\n\r\n if (loop != null) anim.loop = loop;\r\n if (rate != null) anim.rate = rate;\r\n }\r\n\r\n public enableBlending(n: number) {\r\n if (this._isAG) {\r\n let keys: string[] = Object.keys(this._actionMap);\r\n for (let key of keys) {\r\n let act = this._actionMap[key];\r\n if (!(act instanceof ActionData)) continue;\r\n if (act.exist) {\r\n let ar: AnimationGroup = act.ag;\r\n for (let ta of ar.targetedAnimations) {\r\n ta.animation.enableBlending = true;\r\n ta.animation.blendingSpeed = n;\r\n }\r\n }\r\n }\r\n } else {\r\n if (this._skeleton !== null)\r\n this._skeleton.enableBlending(n);\r\n }\r\n }\r\n\r\n public disableBlending() {\r\n if (this._isAG) {\r\n let keys: string[] = Object.keys(this._actionMap);\r\n for (let key of keys) {\r\n let anim = this._actionMap[key];\r\n if (!(anim instanceof ActionData)) continue;\r\n if (anim.exist) {\r\n let ar: AnimationGroup = anim.ag;\r\n for (let ta of ar.targetedAnimations) {\r\n ta.animation.enableBlending = false;\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n //setters for animations\r\n public setWalkAnim(rangeName: string | AnimationGroup, rate: number, loop: boolean) {\r\n this._setAnim(this._actionMap.walk, rangeName, rate, loop);\r\n }\r\n public setRunAnim(rangeName: string | AnimationGroup, rate: number, loop: boolean) {\r\n this._setAnim(this._actionMap.run, rangeName, rate, loop);\r\n }\r\n public setWalkBackAnim(rangeName: string | AnimationGroup, rate: number, loop: boolean) {\r\n this._setAnim(this._actionMap.walkBack, rangeName, rate, loop);\r\n this._copySlowAnims(this._actionMap.walkBackFast, this._actionMap.walkBack);\r\n }\r\n public setWalkBackFastAnim(rangeName: string | AnimationGroup, rate: number, loop: boolean) {\r\n this._setAnim(this._actionMap.walkBackFast, rangeName, rate, loop);\r\n }\r\n public setSlideBackAnim(rangeName: string | AnimationGroup, rate: number, loop: boolean) {\r\n this._setAnim(this._actionMap.slideBack, rangeName, rate, loop);\r\n }\r\n public setIdleAnim(rangeName: string | AnimationGroup, rate: number, loop: boolean) {\r\n this._setAnim(this._actionMap.idle, rangeName, rate, loop);\r\n }\r\n public setTurnRightAnim(rangeName: string | AnimationGroup, rate: number, loop: boolean) {\r\n this._setAnim(this._actionMap.turnRight, rangeName, rate, loop);\r\n this._copySlowAnims(this._actionMap.turnRightFast, this._actionMap.turnRight);\r\n }\r\n public setTurnRightFastAnim(rangeName: string | AnimationGroup, rate: number, loop: boolean) {\r\n this._setAnim(this._actionMap.turnRightFast, rangeName, rate, loop);\r\n }\r\n public setTurnLeftAnim(rangeName: string | AnimationGroup, rate: number, loop: boolean) {\r\n this._setAnim(this._actionMap.turnLeft, rangeName, rate, loop);\r\n this._copySlowAnims(this._actionMap.turnLeftFast, this._actionMap.turnLeft);\r\n }\r\n public setTurnLeftFastAnim(rangeName: string | AnimationGroup, rate: number, loop: boolean) {\r\n this._setAnim(this._actionMap.turnLeftFast, rangeName, rate, loop);\r\n }\r\n public setStrafeRightAnim(rangeName: string | AnimationGroup, rate: number, loop: boolean) {\r\n this._setAnim(this._actionMap.strafeRight, rangeName, rate, loop);\r\n this._copySlowAnims(this._actionMap.strafeRightFast, this._actionMap.strafeRight);\r\n }\r\n public setStrafeRightFastAnim(rangeName: string | AnimationGroup, rate: number, loop: boolean) {\r\n this._setAnim(this._actionMap.strafeRightFast, rangeName, rate, loop);\r\n }\r\n public setStrafeLeftAnim(rangeName: string | AnimationGroup, rate: number, loop: boolean) {\r\n this._setAnim(this._actionMap.strafeLeft, rangeName, rate, loop);\r\n this._copySlowAnims(this._actionMap.strafeLeftFast, this._actionMap.strafeLeft);\r\n }\r\n public setStrafeLeftFastAnim(rangeName: string | AnimationGroup, rate: number, loop: boolean) {\r\n this._setAnim(this._actionMap.strafeLeftFast, rangeName, rate, loop);\r\n }\r\n public setIdleJumpAnim(rangeName: string | AnimationGroup, rate: number, loop: boolean) {\r\n this._setAnim(this._actionMap.idleJump, rangeName, rate, loop);\r\n }\r\n public setRunJumpAnim(rangeName: string | AnimationGroup, rate: number, loop: boolean) {\r\n this._setAnim(this._actionMap.runJump, rangeName, rate, loop);\r\n }\r\n public setFallAnim(rangeName: string | AnimationGroup, rate: number, loop: boolean) {\r\n this._setAnim(this._actionMap.fall, rangeName, rate, loop);\r\n }\r\n\r\n\r\n _stepSound: Sound;\r\n // setters for sound\r\n public setSound(sound: Sound) {\r\n if (sound == null) return;\r\n this._stepSound = sound;\r\n let ccActionNames: string[] = Object.keys(this._actionMap);\r\n sound.loop = false;\r\n for (let ccActionName of ccActionNames) {\r\n let ccActData = this._actionMap[ccActionName];\r\n //some keys could map to functions (like reset())\r\n if (!(ccActData instanceof ActionData)) continue;\r\n ccActData.sound = sound;\r\n ccActData.sound.attachToMesh(this._avatar);\r\n }\r\n this._actionMap.idle.sound = null;\r\n this._actionMap.fall.sound = null;\r\n this._actionMap.slideBack.sound = null;\r\n }\r\n\r\n\r\n // setters for keys\r\n public setWalkKey(key: string) {\r\n this._actionMap.walk.key = key.toLowerCase();\r\n }\r\n public setWalkBackKey(key: string) {\r\n this._actionMap.walkBack.key = key.toLowerCase();\r\n }\r\n public setTurnLeftKey(key: string) {\r\n this._actionMap.turnLeft.key = key.toLowerCase();\r\n }\r\n public setTurnRightKey(key: string) {\r\n this._actionMap.turnRight.key = key.toLowerCase();\r\n }\r\n public setStrafeLeftKey(key: string) {\r\n this._actionMap.strafeLeft.key = key.toLowerCase();\r\n }\r\n public setStrafeRightKey(key: string) {\r\n this._actionMap.strafeRight.key = key.toLowerCase();\r\n }\r\n public setJumpKey(key: string) {\r\n this._actionMap.idleJump.key = key.toLowerCase();\r\n }\r\n\r\n public setCameraElasticity(b: boolean) {\r\n this._cameraElastic = b;\r\n }\r\n\r\n public setElasticiSteps(n: number) {\r\n this._elasticSteps = n;\r\n }\r\n\r\n public makeObstructionInvisible(b: boolean) {\r\n this._makeInvisible = b;\r\n }\r\n public setCameraTarget(v: Vector3) {\r\n this._cameraTarget.copyFrom(v);\r\n }\r\n\r\n\r\n /**\r\n * user should call this whenever the user changes the camera checkCollision \r\n * property\r\n * \r\n */\r\n public cameraCollisionChanged() {\r\n this._savedCameraCollision = this._camera.checkCollisions;\r\n }\r\n public setNoFirstPerson(b: boolean) {\r\n this._noFirstPerson = b;\r\n }\r\n\r\n /**\r\n * if av has the required anim (walk, run etc) then \r\n * mark that anim as existing\r\n * \r\n * @param skel \r\n */\r\n\r\n private _checkAnimRanges(skel: Skeleton) {\r\n let keys: string[] = Object.keys(this._actionMap);\r\n for (let key of keys) {\r\n let anim = this._actionMap[key];\r\n if (!(anim instanceof ActionData)) continue;\r\n if (skel != null) {\r\n if (skel.getAnimationRange(anim.id) != null) {\r\n anim.name = anim.id;\r\n anim.exist = true;\r\n this._hasAnims = true;\r\n }\r\n } else {\r\n anim.exist = false;\r\n }\r\n }\r\n this._checkFastAnims();\r\n }\r\n\r\n /**\r\n * if fast anims do not exist then use their slow counterpart as them but double the rate at which they play\r\n */\r\n private _checkFastAnims() {\r\n this._copySlowAnims(this._actionMap.walkBackFast, this._actionMap.walkBack)\r\n this._copySlowAnims(this._actionMap.turnRightFast, this._actionMap.turnRight);\r\n this._copySlowAnims(this._actionMap.turnLeftFast, this._actionMap.turnLeft);\r\n this._copySlowAnims(this._actionMap.strafeRightFast, this._actionMap.strafeRight);\r\n this._copySlowAnims(this._actionMap.strafeLeftFast, this._actionMap.strafeLeft);\r\n }\r\n\r\n private _copySlowAnims(f: ActionData, s: ActionData) {\r\n if (f.exist) return;\r\n if (!s.exist) return;\r\n f.exist = true;\r\n f.ag = s.ag;\r\n f.name = s.name;\r\n f.rate = s.rate * 2;\r\n }\r\n\r\n /**\r\n * Use this to make the character controller suitable for a isometeric/top down games or fps/third person game.\r\n * 1 In isometric/top down games the camera direction has no bearing on avatar movement.\r\n * 0 In fps/third person game rotating the camera around the avatar , rotates the avatar too.\r\n * \r\n * cannot switch mode to 0 if no camera avaiable.\r\n */\r\n private _mode = 0;\r\n private _saveMode = 0;\r\n public setMode(n: number) {\r\n //cannot switch mode to 0 if no camera avaiable.\r\n if (this._hasCam) {\r\n this._mode = n;\r\n this._saveMode = n;\r\n } else {\r\n this._mode = 1;\r\n this._saveMode = 1;\r\n }\r\n }\r\n public getMode() {\r\n return this._mode;\r\n }\r\n /**\r\n * Use this to set turning off.\r\n * When turining is off \r\n * a) turn left or turn right keys result in avatar facing and moving left or right with respect to camera.\r\n * b) walkback/runback key results in avatar facing back and walking/running towards camera.\r\n * \r\n * This setting has no effect when mode is 1.\r\n * \r\n * @param b \r\n */\r\n public setTurningOff(b: boolean) {\r\n this._noRot = b;\r\n }\r\n public isTurningOff() {\r\n return this._noRot;\r\n }\r\n\r\n /**\r\n * checks if a have left hand , right hand issue.\r\n * In other words if a mesh is a LHS mesh in RHS system or \r\n * a RHS mesh in LHS system\r\n * The X axis will be reversed in such cases.\r\n * thus Cross product of X and Y should be inverse of Z.\r\n * BABYLONJS GLB models are RHS and exhibit this behavior\r\n * \r\n */\r\n private _isLHS_RHS = false;\r\n private _signLHS_RHS = -1;\r\n private _setRHS(mesh: TransformNode) {\r\n const meshMatrix: Matrix = mesh.getWorldMatrix();\r\n const _localX = Vector3.FromArray(meshMatrix.m, 0);\r\n const _localY = Vector3.FromArray(meshMatrix.m, 4);\r\n const _localZ = Vector3.FromArray(meshMatrix.m, 8);\r\n const actualZ = Vector3.Cross(_localX, _localY);\r\n //same direction or opposite direction of Z\r\n if (Vector3.Dot(actualZ, _localZ) < 0) {\r\n this._isLHS_RHS = true;\r\n this._signLHS_RHS = 1;\r\n }\r\n else {\r\n this._isLHS_RHS = false;\r\n this._signLHS_RHS = -1;\r\n }\r\n }\r\n\r\n /**\r\n * Use setFaceForward(true|false) to indicate that the avatar's face points forward (true) or backward (false).\r\n * The avatar's face points forward if its face is looking in positive local Z axis direction\r\n */\r\n private _ffSign: number;\r\n private _rhsSign: number;\r\n private _ff: boolean;\r\n //in mode 0, av2cam is used to align avatar with camera , with camera always facing avatar's back\r\n //note:camera alpha is measured anti-clockwise , avatar rotation is measured clockwise \r\n private _av2cam;\r\n public setFaceForward(b: boolean) {\r\n this._ff = b;\r\n\r\n this._rhsSign = this._scene.useRightHandedSystem ? -1 : 1;\r\n\r\n if (!this._hasCam) {\r\n this._av2cam = 0;\r\n this._ffSign = 1;\r\n return;\r\n }\r\n\r\n if (this._isLHS_RHS) {\r\n this._av2cam = b ? Math.PI / 2 : 3 * Math.PI / 2;\r\n this._ffSign = b ? 1 : -1;\r\n } else {\r\n this._av2cam = b ? 3 * Math.PI / 2 : Math.PI / 2;\r\n this._ffSign = b ? -1 : 1;\r\n }\r\n\r\n }\r\n\r\n public isFaceForward() {\r\n return this._ff;\r\n }\r\n\r\n private checkAGs(agMap: {}) {\r\n let keys: string[] = Object.keys(this._actionMap);\r\n for (let key of keys) {\r\n let anim = this._actionMap[key];\r\n if (!(anim instanceof ActionData)) continue;\r\n if (agMap[anim.name] != null) {\r\n anim.ag = agMap[anim.name];\r\n anim.exist = true;\r\n }\r\n }\r\n }\r\n\r\n // check if any of the mesh on the node tree is refrenced by any animation group\r\n private _containsAG(node: Node, ags: AnimationGroup[], fromRoot: boolean) {\r\n let r: Node;\r\n let ns: Node[];\r\n\r\n if (fromRoot) {\r\n r = this._getRoot(node);\r\n ns = r.getChildren((n) => { return (n instanceof TransformNode) }, false);\r\n } else {\r\n r = node;\r\n ns = [r];\r\n }\r\n\r\n for (let ag of ags) {\r\n let tas: TargetedAnimation[] = ag.targetedAnimations;\r\n for (let ta of tas) {\r\n if (ns.indexOf(ta.target) > -1) {\r\n return true;\r\n }\r\n }\r\n }\r\n return false;\r\n }\r\n\r\n //get the root of Node\r\n private _getRoot(tn: Node): Node {\r\n if (tn.parent == null) return tn;\r\n return this._getRoot(tn.parent);\r\n }\r\n\r\n private _started: boolean = false;\r\n public start() {\r\n if (this._started) return;\r\n this._started = true;\r\n this._act.reset();\r\n this._movFallTime = 0;\r\n //first time we enter render loop, delta time is zero\r\n this._idleFallTime = 0.001;\r\n this._grounded = false;\r\n this._updateTargetValue();\r\n if (this._ekb) this._addkeylistener();\r\n this._scene.registerBeforeRender(this._renderer);\r\n }\r\n\r\n public stop() {\r\n if (!this._started) return;\r\n this._started = false;\r\n this._scene.unregisterBeforeRender(this._renderer);\r\n this._removekeylistener();\r\n this._prevActData = null;\r\n }\r\n\r\n /**\r\n * use pauseAnim to stop the charactere controller from playing\r\n * any animation on the character\r\n * use this when you want to play your animation instead\r\n * see also resumeAnim()\r\n */\r\n private _stopAnim: boolean = false;\r\n public pauseAnim() {\r\n this._stopAnim = true;\r\n\r\n if (this._prevActData != null && this._prevActData.exist) {\r\n //stop current animation\r\n if (this._isAG) {\r\n this._prevActData.ag.stop();\r\n } else {\r\n //this._scene.stopAnimation(this._skeleton, this._prevActData.name);\r\n this._scene.stopAnimation(this._skeleton);\r\n //this._scene.stopAllAnimations();\r\n }\r\n //stop current sound\r\n if (this._prevActData.sound != null) {\r\n this._prevActData.sound.stop();\r\n }\r\n clearInterval(this._sndId);\r\n\r\n this._scene.unregisterBeforeRender(this._renderer);\r\n }\r\n }\r\n\r\n /**\r\n * use resumeAnim to resume the character controller playing\r\n * animations on the character.\r\n * see also pauseAnim()\r\n */\r\n public resumeAnim() {\r\n this._stopAnim = false;\r\n this._prevActData = null;\r\n this._scene.registerBeforeRender(this._renderer);\r\n }\r\n\r\n private _prevActData: ActionData = null;\r\n private _avStartPos: Vector3 = Vector3.Zero();\r\n private _grounded: boolean = false;\r\n //distance by which AV would move down if in freefall\r\n private _freeFallDist: number = 0;\r\n\r\n //how many minimum contiguos frames should the AV have been in free fall\r\n //before we assume AV is in big freefall.\r\n //we will use this to remove animation flicker during move down a slope (fall, move, fall move etc)\r\n //TODO: base this on slope - large slope large count\r\n private _fallFrameCountMin: number = 50;\r\n private _fallFrameCount: number = 0;\r\n\r\n private _inFreeFall: boolean = false;\r\n private _wasWalking: boolean = false;\r\n private _wasRunning: boolean = false;\r\n private _moveVector: Vector3;\r\n\r\n //used only in mode 1\r\n //value 1 or -1 , -1 if avatar is facing camera\r\n //private _notFacingCamera = 1;\r\n\r\n private _isAvFacingCamera(): number {\r\n if (!this._hasCam) return 1;\r\n if (Vector3.Dot(this._avatar.forward, this._avatar.position.subtract(this._camera.position)) < 0) return 1\r\n else return -1;\r\n }\r\n\r\n private _moveAVandCamera() {\r\n this._avStartPos.copyFrom(this._avatar.position);\r\n let actData: ActionData = null;\r\n const dt: number = this._scene.getEngine().getDeltaTime() / 1000;\r\n\r\n if (this._act._jump && !this._inFreeFall) {\r\n this._grounded = false;\r\n this._idleFallTime = 0;\r\n actData = this._doJump(dt);\r\n } else if (this.anyMovement() || this._inFreeFall) {\r\n this._grounded = false;\r\n this._idleFallTime = 0;\r\n actData = this._doMove(dt);\r\n } else if (!this._inFreeFall) {\r\n actData = this._doIdle(dt);\r\n }\r\n if (!this._stopAnim && this._hasAnims && actData != null) {\r\n if (this._prevActData !== actData) {\r\n if (actData.exist) {\r\n\r\n //animation frame counts\r\n let c: number;\r\n let fps: number = 30;\r\n\r\n if (this._isAG) {\r\n if (this._prevActData != null && this._prevActData.exist) this._prevActData.ag.stop();\r\n actData.ag.start(actData.loop, actData.rate);\r\n fps = actData.ag.targetedAnimations[0].animation.framePerSecond;\r\n c = (actData.ag.to - actData.ag.from);\r\n } else {\r\n let a: Animatable = this._skeleton.beginAnimation(actData.name, actData.loop, actData.rate);\r\n fps = a.getAnimations()[0].animation.framePerSecond;\r\n c = this._skeleton.getAnimationRange(actData.name).to - this._skeleton.getAnimationRange(actData.name).from;\r\n }\r\n\r\n //SOUND\r\n //TODO do sound as animationevent.\r\n if (this._prevActData != null && this._prevActData.sound != null) {\r\n this._prevActData.sound.stop();\r\n }\r\n clearInterval(this._sndId);\r\n if (actData.sound != null) {\r\n actData.sound.play();\r\n //play sound twice during the animation\r\n this._sndId = setInterval(() => { actData.sound.play(); }, c * 1000 / (fps * Math.abs(actData.rate) * 2));\r\n }\r\n }\r\n this._prevActData = actData;\r\n }\r\n }\r\n this._updateTargetValue();\r\n return;\r\n }\r\n\r\n private _soundLoopTime = 700;\r\n private _sndId = null;\r\n\r\n //verical position of AV when it is about to start a jump\r\n private _jumpStartPosY: number = 0;\r\n //for how long the AV has been in the jump\r\n private _jumpTime: number = 0;\r\n private _doJump(dt: number): ActionData {\r\n\r\n let actData: ActionData = null;\r\n actData = this._actionMap.runJump;\r\n if (this._jumpTime === 0) {\r\n this._jumpStartPosY = this._avatar.position.y;\r\n }\r\n\r\n this._jumpTime = this._jumpTime + dt;\r\n\r\n let forwardDist: number = 0;\r\n let jumpDist: number = 0;\r\n let disp: Vector3;\r\n\r\n // if (this._hasCam && this._mode != 1 && !this._noRot) this._avatar.rotation.y = this._av2cam - this._camera.alpha;\r\n if (this._wasRunning || this._wasWalking) {\r\n if (this._wasRunning) {\r\n forwardDist = this._actionMap.run.speed * dt;\r\n } else if (this._wasWalking) {\r\n forwardDist = this._actionMap.walk.speed * dt;\r\n }\r\n //find out in which horizontal direction the AV was moving when it started the jump\r\n disp = this._moveVector.clone();\r\n disp.y = 0;\r\n disp = disp.normalize();\r\n disp.scaleToRef(forwardDist, disp);\r\n jumpDist = this._calcJumpDist(this._actionMap.runJump.speed, dt);\r\n disp.y = jumpDist;\r\n } else {\r\n jumpDist = this._calcJumpDist(this._actionMap.idleJump.speed, dt);\r\n disp = new Vector3(0, jumpDist, 0);\r\n actData = this._actionMap.idleJump;\r\n //this.avatar.ellipsoid.y=this._ellipsoid.y/2;\r\n }\r\n //moveWithCollision only seems to happen if length of displacment is atleast 0.001\r\n this._avatar.moveWithCollisions(disp);\r\n if (jumpDist < 0) {\r\n //this.avatar.ellipsoid.y=this._ellipsoid.y;\r\n //check if going up a slope or back on flat ground \r\n if ((this._avatar.position.y > this._avStartPos.y) || ((this._avatar.position.y === this._avStartPos.y) && (disp.length() > 0.001))) {\r\n this._endJump();\r\n } else if (this._avatar.position.y < this._jumpStartPosY) {\r\n //the avatar is below the point from where it started the jump\r\n //so it is either in free fall or is sliding along a downward slope\r\n //\r\n //if the actual displacemnt is same as the desired displacement then AV is in freefall\r\n //else it is on a slope\r\n const actDisp: Vector3 = this._avatar.position.subtract(this._avStartPos);\r\n if (!(this._areVectorsEqual(actDisp, disp, 0.001))) {\r\n //AV is on slope\r\n //Should AV continue to slide or stop?\r\n //if slope is less steeper than acceptable then stop else slide\r\n if (this._verticalSlope(actDisp) <= this._sl1) {\r\n this._endJump();\r\n }\r\n } else {\r\n actData = this._actionMap.fall;\r\n }\r\n }\r\n }\r\n return actData;\r\n }\r\n\r\n private _calcJumpDist(speed: number, dt: number): number {\r\n //up velocity at the begining of the lastt frame (v=u+at)\r\n let js: number = speed - this._gravity * this._jumpTime;\r\n //distance travelled up since last frame to this frame (s=ut+1/2*at^2)\r\n let jumpDist: number = js * dt - 0.5 * this._gravity * dt * dt;\r\n return jumpDist;\r\n }\r\n\r\n /**\r\n * does cleanup at the end of a jump\r\n */\r\n private _endJump() {\r\n this._act._jump = false;\r\n this._jumpTime = 0;\r\n this._wasWalking = false;\r\n this._wasRunning = false;\r\n }\r\n\r\n /**\r\n * checks if two vectors v1 and v2 are equal within a precision of p\r\n */\r\n private _areVectorsEqual(v1: Vector3, v2: Vector3, p: number) {\r\n return ((Math.abs(v1.x - v2.x) < p) && (Math.abs(v1.y - v2.y) < p) && (Math.abs(v1.z - v2.z) < p));\r\n }\r\n\r\n /*\r\n * returns the slope (in radians) of a vector in the vertical plane\r\n */\r\n private _verticalSlope(v: Vector3): number {\r\n return Math.atan(Math.abs(v.y / Math.sqrt(v.x * v.x + v.z * v.z)));\r\n }\r\n\r\n //for how long has the av been falling while moving\r\n private _movFallTime: number = 0;\r\n private _sign = 1;\r\n private _isTurning = false;\r\n private _noRot = false;\r\n private _doMove(dt: number): ActionData {\r\n\r\n //initial down velocity\r\n const u: number = this._movFallTime * this._gravity\r\n //calculate the distance by which av should fall down since last frame\r\n //assuming it is in freefall\r\n this._freeFallDist = u * dt + this._gravity * dt * dt / 2;\r\n\r\n this._movFallTime = this._movFallTime + dt;\r\n\r\n let moving: boolean = false;\r\n let actdata: ActionData = null;\r\n\r\n if (this._inFreeFall) {\r\n this._moveVector.y = -this._freeFallDist;\r\n moving = true;\r\n }\r\n\r\n\r\n //rotate avatar with respect to camera direction. \r\n this._rotateAV2C();\r\n\r\n //rotate the avatar in case player is trying to rotate the avatar. rotate the camera too if camera turning is on\r\n actdata = this._rotateAVnC(actdata, moving, dt);\r\n\r\n //now that avatar is rotated properly, construct the vector to move the avatar \r\n //donot move the avatar if avatar is in freefall\r\n\r\n if (!this._inFreeFall) {\r\n this._wasWalking = false;\r\n this._wasRunning = false;\r\n\r\n let sign: number;\r\n let horizDist: number = 0;\r\n switch (true) {\r\n case (this._act._stepLeft):\r\n sign = this._signLHS_RHS * this._isAvFacingCamera();\r\n horizDist = this._actionMap.strafeLeft.speed * dt;\r\n if (this._act._speedMod) {\r\n horizDist = this._actionMap.strafeLeftFast.speed * dt;\r\n actdata = (-this._ffSign * sign > 0) ? this._actionMap.strafeLeftFast : this._actionMap.strafeRightFast;\r\n } else {\r\n actdata = (-this._ffSign * sign > 0) ? this._actionMap.strafeLeft : this._actionMap.strafeRight;\r\n }\r\n this._moveVector = this._avatar.calcMovePOV(sign * horizDist, -this._freeFallDist, 0);\r\n moving = true;\r\n break;\r\n case (this._act._stepRight):\r\n sign = -this._signLHS_RHS * this._isAvFacingCamera();\r\n horizDist = this._actionMap.strafeRight.speed * dt;\r\n if (this._act._speedMod) {\r\n horizDist = this._actionMap.strafeRightFast.speed * dt;\r\n actdata = (-this._ffSign * sign > 0) ? this._actionMap.strafeLeftFast : this._actionMap.strafeRightFast;\r\n } else {\r\n actdata = (-this._ffSign * sign > 0) ? this._actionMap.strafeLeft : this._actionMap.strafeRight;\r\n }\r\n this._moveVector = this._avatar.calcMovePOV(sign * horizDist, -this._freeFallDist, 0);\r\n moving = true;\r\n break;\r\n case (this._act._walk || (this._noRot && this._mode == 0)):\r\n if (this._act._speedMod) {\r\n this._wasRunning = true;\r\n horizDist = this._actionMap.run.speed * dt;\r\n actdata = this._actionMap.run;\r\n } else {\r\n this._wasWalking = true;\r\n horizDist = this._actionMap.walk.speed * dt;\r\n actdata = this._actionMap.walk;\r\n }\r\n this._moveVector = this._avatar.calcMovePOV(0, -this._freeFallDist, this._ffSign * horizDist);\r\n moving = true;\r\n break;\r\n case (this._act._walkback):\r\n horizDist = this._actionMap.walkBack.speed * dt;\r\n if (this._act._speedMod) {\r\n horizDist = this._actionMap.walkBackFast.speed * dt;\r\n actdata = this._actionMap.walkBackFast;\r\n } else {\r\n actdata = this._actionMap.walkBack;\r\n }\r\n this._moveVector = this._avatar.calcMovePOV(0, -this._freeFallDist, -this._ffSign * horizDist);\r\n moving = true;\r\n break;\r\n }\r\n }\r\n\r\n // move the avatar\r\n\r\n if (moving) {\r\n if (this._moveVector.length() > 0.001) {\r\n this._avatar.moveWithCollisions(this._moveVector);\r\n //walking up a slope\r\n if (this._avatar.position.y > this._avStartPos.y) {\r\n const actDisp: Vector3 = this._avatar.position.subtract(this._avStartPos);\r\n const _slp: number = this._verticalSlope(actDisp);\r\n if (_slp >= this._sl2) {\r\n //this._climbingSteps=true;\r\n //is av trying to go up steps\r\n if (this._stepOffset > 0) {\r\n if (this._vMoveTot == 0) {\r\n //if just started climbing note down the position\r\n this._vMovStartPos.copyFrom(this._avStartPos);\r\n }\r\n this._vMoveTot = this._vMoveTot + (this._avatar.position.y - this._avStartPos.y);\r\n if (this._vMoveTot > this._stepOffset) {\r\n //move av back to its position at begining of steps\r\n this._vMoveTot = 0;\r\n this._avatar.position.copyFrom(this._vMovStartPos);\r\n this._endFreeFall();\r\n }\r\n } else {\r\n //move av back to old position\r\n this._avatar.position.copyFrom(this._avStartPos);\r\n this._endFreeFall();\r\n }\r\n } else {\r\n this._vMoveTot = 0;\r\n if (_slp > this._sl1) {\r\n //av is on a steep slope , continue increasing the moveFallTIme to deaccelerate it\r\n this._fallFrameCount = 0;\r\n this._inFreeFall = false;\r\n } else {\r\n //continue walking\r\n this._endFreeFall();\r\n }\r\n }\r\n } else if ((this._avatar.position.y) < this._avStartPos.y) {\r\n const actDisp: Vector3 = this._avatar.position.subtract(this._avStartPos);\r\n if (!(this._areVectorsEqual(actDisp, this._moveVector, 0.001))) {\r\n //AV is on slope\r\n //Should AV continue to slide or walk?\r\n //if slope is less steeper than acceptable then walk else slide\r\n if (this._verticalSlope(actDisp) <= this._sl1) {\r\n this._endFreeFall();\r\n } else {\r\n //av is on a steep slope , continue increasing the moveFallTIme to deaccelerate it\r\n this._fallFrameCount = 0;\r\n this._inFreeFall = false;\r\n }\r\n } else {\r\n this._inFreeFall = true;\r\n this._fallFrameCount++;\r\n //AV could be running down a slope which mean freefall,run,frefall run ...\r\n //to remove anim flicker, check if AV has been falling down continously for last few consecutive frames\r\n //before changing to free fall animation\r\n if (this._fallFrameCount > this._fallFrameCountMin) {\r\n actdata = this._actionMap.fall;\r\n }\r\n }\r\n } else {\r\n this._endFreeFall();\r\n }\r\n }\r\n }\r\n return actdata;\r\n }\r\n\r\n /**\r\n * rotate avatar with respect to camera direction. \r\n */\r\n private _rotateAV2C() {\r\n if (this._hasCam)\r\n if (this._mode != 1) {\r\n let ca = (this._hasCam) ? (this._av2cam - this._camera.alpha) : 0;\r\n if (this._noRot) {\r\n switch (true) {\r\n case (this._act._walk && this._act._turnRight):\r\n this._avatar.rotation.y = ca + this._rhsSign * Math.PI / 4;\r\n break;\r\n case (this._act._walk && this._act._turnLeft):\r\n this._avatar.rotation.y = ca - this._rhsSign * Math.PI / 4;\r\n break;\r\n case (this._act._walkback && this._act._turnRight):\r\n this._avatar.rotation.y = ca + this._rhsSign * 3 * Math.PI / 4;\r\n break;\r\n case (this._act._walkback && this._act._turnLeft):\r\n this._avatar.rotation.y = ca - this._rhsSign * 3 * Math.PI / 4;\r\n break;\r\n case (this._act._walk):\r\n this._avatar.rotation.y = ca;\r\n break;\r\n case (this._act._walkback):\r\n this._avatar.rotation.y = ca + Math.PI;\r\n break;\r\n case (this._act._turnRight):\r\n this._avatar.rotation.y = ca + this._rhsSign * Math.PI / 2;\r\n break;\r\n case (this._act._turnLeft):\r\n this._avatar.rotation.y = ca - this._rhsSign * Math.PI / 2;\r\n break;\r\n }\r\n } else {\r\n if (this._hasCam)\r\n this._avatar.rotation.y = ca;\r\n }\r\n }\r\n }\r\n\r\n //rotate the avatar in case player is trying to rotate the avatar. rotate the camera too if camera turning is on\r\n private _rotateAVnC(anim: ActionData, moving: boolean, dt: number): ActionData {\r\n if (!(this._noRot && this._mode == 0) && (!this._act._stepLeft && !this._act._stepRight) && (this._act._turnLeft || this._act._turnRight)) {\r\n let turnAngle = this._actionMap.turnLeft.speed * dt;\r\n if (this._act._speedMod) {\r\n turnAngle = 2 * turnAngle;\r\n }\r\n let a;\r\n if (this._mode == 1) {\r\n // while turining, the avatar could start facing away from camera and end up facing camera.\r\n // we should not switch turning direction during this transition\r\n if (!this._isTurning) {\r\n // if (this._act.name != this._act.prevName) {\r\n // this._act.prevName = this._act.name;\r\n this._sign = -this._ffSign * this._isAvFacingCamera();\r\n if (this._isLHS_RHS) this._sign = - this._sign;\r\n this._isTurning = true;\r\n }\r\n a = this._sign;\r\n if (this._act._turnLeft) {\r\n if (this._act._walk) { }\r\n else if (this._act._walkback) a = -this._sign;\r\n else {\r\n anim = (this._sign > 0) ? this._actionMap.turnRight : this._actionMap.turnLeft;\r\n }\r\n } else {\r\n if (this._act._walk) a = -this._sign;\r\n else if (this._act._walkback) { }\r\n else {\r\n a = -this._sign;\r\n anim = (this._sign > 0) ? this._actionMap.turnLeft : this._actionMap.turnRight;\r\n }\r\n }\r\n } else {\r\n a = 1;\r\n if (this._act._turnLeft) {\r\n if (this._act._walkback) a = -1;\r\n if (!moving) anim = this._actionMap.turnLeft;\r\n } else {\r\n if (this._act._walk) a = -1;\r\n if (!moving) { a = -1; anim = this._actionMap.turnRight; }\r\n }\r\n if (this._hasCam)\r\n this._camera.alpha = this._camera.alpha + this._rhsSign * turnAngle * a;\r\n }\r\n\r\n this._avatar.rotation.y = this._avatar.rotation.y + turnAngle * a;\r\n }\r\n return anim;\r\n }\r\n\r\n private _endFreeFall(): void {\r\n this._movFallTime = 0;\r\n this._fallFrameCount = 0;\r\n this._inFreeFall = false;\r\n }\r\n\r\n //for how long has the av been falling while idle (not moving)\r\n private _idleFallTime: number = 0;\r\n private _doIdle(dt: number): ActionData {\r\n if (this._grounded) {\r\n return this._actionMap.idle;\r\n }\r\n this._wasWalking = false;\r\n this._wasRunning = false;\r\n this._movFallTime = 0;\r\n let anim: ActionData = this._actionMap.idle;\r\n this._fallFrameCount = 0;\r\n\r\n\r\n if (dt === 0) {\r\n this._freeFallDist = 5;\r\n } else {\r\n const u: number = this._idleFallTime * this._gravity\r\n this._freeFallDist = u * dt + this._gravity * dt * dt / 2;\r\n this._idleFallTime = this._idleFallTime + dt;\r\n }\r\n //if displacement is less than 0.01(? need to verify further) then \r\n //moveWithDisplacement down against a surface seems to push the AV up by a small amount!!\r\n if (this._freeFallDist < 0.01) return anim;\r\n const disp: Vector3 = new Vector3(0, -this._freeFallDist, 0);\r\n // if (this._hasCam && this._mode != 1 && !this._noRot) this._avatar.rotation.y = this._av2cam - this._camera.alpha;\r\n this._avatar.moveWithCollisions(disp);\r\n if ((this._avatar.position.y > this._avStartPos.y) || (this._avatar.position.y === this._avStartPos.y)) {\r\n // this.grounded = true;\r\n // this.idleFallTime = 0;\r\n this._groundIt();\r\n } else if (this._avatar.position.y < this._avStartPos.y) {\r\n //AV is going down. \r\n //AV is either in free fall or is sliding along a downward slope\r\n //\r\n //if the actual displacemnt is same as the desired displacement then AV is in freefall\r\n //else it is on a slope\r\n const actDisp: Vector3 = this._avatar.position.subtract(this._avStartPos);\r\n if (!(this._areVectorsEqual(actDisp, disp, 0.001))) {\r\n //AV is on slope\r\n //Should AV continue to slide or stop?\r\n //if slope is less steeper than accebtable then stop else slide\r\n if (this._verticalSlope(actDisp) <= this._sl1) {\r\n // this.grounded = true;\r\n // this.idleFallTime = 0;\r\n this._groundIt();\r\n this._avatar.position.copyFrom(this._avStartPos);\r\n } else {\r\n this._unGroundIt();\r\n anim = this._actionMap.slideBack;\r\n }\r\n } else {\r\n anim = this._actionMap.fall;\r\n }\r\n }\r\n return anim;\r\n }\r\n\r\n private _groundFrameCount = 0;\r\n private _groundFrameMax = 10;\r\n /**\r\n * donot ground immediately\r\n * wait few more frames\r\n */\r\n private _groundIt(): void {\r\n this._groundFrameCount++;\r\n if (this._groundFrameCount > this._groundFrameMax) {\r\n this._grounded = true;\r\n this._idleFallTime = 0;\r\n }\r\n }\r\n private _unGroundIt() {\r\n this._grounded = false;\r\n this._groundFrameCount = 0;\r\n }\r\n\r\n private _savedCameraCollision: boolean = true;\r\n private _inFP = false;\r\n private _updateTargetValue() {\r\n if (!this._hasCam) return;\r\n //donot move camera if av is trying to clinb steps\r\n if (this._vMoveTot == 0)\r\n this._avatar.position.addToRef(this._cameraTarget, this._camera.target);\r\n\r\n if (this._camera.radius > this._camera.lowerRadiusLimit) { if (this._cameraElastic || this._makeInvisible) this._handleObstruction(); }\r\n\r\n //if user so desire, make the AV invisible if camera comes close to it\r\n if (this._camera.radius <= this._camera.lowerRadiusLimit) {\r\n if (!this._noFirstPerson && !this._inFP) {\r\n this._makeMeshInvisible(this._avatar);\r\n this._camera.checkCollisions = false;\r\n this._saveMode = this._mode;\r\n this._mode = 0;\r\n this._inFP = true;\r\n }\r\n } else {\r\n if (this._inFP) {\r\n this._inFP = false;\r\n this._mode = this._saveMode;\r\n this._restoreVisiblity(this._avatar);\r\n this._camera.checkCollisions = this._savedCameraCollision;\r\n }\r\n }\r\n }\r\n\r\n // make mesh and all its children invisible\r\n // store their current visibility state so that we can restore them later on\r\n private _makeMeshInvisible(mesh: Mesh) {\r\n\r\n this._visiblityMap.set(mesh, mesh.visibility);\r\n mesh.visibility = 0;\r\n\r\n mesh.getChildMeshes(false, (n) => {\r\n if (n instanceof Mesh) {\r\n this._visiblityMap.set(n, n.visibility);\r\n n.visibility = 0;\r\n }\r\n return false;\r\n });\r\n }\r\n\r\n private _visiblityMap: Map = new Map();\r\n\r\n //restore mesh visibility to previous state\r\n private _restoreVisiblity(mesh: Mesh) {\r\n mesh.visibility = this._visiblityMap.get(mesh);\r\n mesh.getChildMeshes(false, (n) => {\r\n if (n instanceof Mesh) n.visibility = this._visiblityMap.get(n);\r\n return false;\r\n });\r\n }\r\n\r\n private _ray: Ray = new Ray(Vector3.Zero(), Vector3.One(), 1);\r\n private _rayDir: Vector3 = Vector3.Zero();\r\n //camera seems to get stuck into things\r\n //should move camera away from things by a value of cameraSkin\r\n private _cameraSkin: number = 0.5;\r\n private _prevPickedMeshes: AbstractMesh[];\r\n private _pickedMeshes: AbstractMesh[] = new Array();;\r\n private _makeInvisible = false;\r\n private _elasticSteps = 50;\r\n private _alreadyInvisible: AbstractMesh[];\r\n\r\n /**\r\n * The following method handles the use case wherein some mesh\r\n * comes between the avatar and the camera thus obstructing the view\r\n * of the avatar.\r\n * Two ways this can be handled\r\n * a) make the obstructing mesh invisible\r\n * instead of invisible a better option would have been to make semi transparent.\r\n * Unfortunately, unlike mesh, mesh instances do not \"visibility\" setting)\r\n * Every alternate frame make mesh visible and invisible to give the impression of semi-transparent.\r\n * b) move the camera in front of the obstructing mesh\r\n */\r\n private _handleObstruction() {\r\n\r\n //get vector from av (camera.target) to camera\r\n this._camera.position.subtractToRef(this._camera.target, this._rayDir);\r\n //start ray from av to camera\r\n this._ray.origin = this._camera.target;\r\n this._ray.length = this._rayDir.length();\r\n this._ray.direction = this._rayDir.normalize();\r\n\r\n //TODO \r\n //handle case were pick is with a child of avatar, avatar atatchment. etc\r\n const pis: PickingInfo[] = this._scene.multiPickWithRay(this._ray, (mesh) => {\r\n if (mesh == this._avatar) return false;\r\n else return true;\r\n });\r\n\r\n\r\n if (this._makeInvisible) {\r\n this._prevPickedMeshes = this._pickedMeshes;\r\n if (pis.length > 0) {\r\n this._pickedMeshes = new Array();\r\n for (let pi of pis) {\r\n if (pi.pickedMesh.isVisible || this._prevPickedMeshes.includes(pi.pickedMesh)) {\r\n pi.pickedMesh.isVisible = false;\r\n this._pickedMeshes.push(pi.pickedMesh);\r\n }\r\n }\r\n for (let pm of this._prevPickedMeshes) {\r\n if (!this._pickedMeshes.includes(pm)) {\r\n pm.isVisible = true;\r\n }\r\n }\r\n } else {\r\n for (let pm of this._prevPickedMeshes) {\r\n pm.isVisible = true;\r\n }\r\n this._prevPickedMeshes.length = 0;\r\n }\r\n }\r\n\r\n if (this._cameraElastic) {\r\n if (pis.length > 0) {\r\n // postion the camera in front of the mesh that is obstructing camera\r\n\r\n //if only one obstruction and it is invisible then if it is not collidable or our camera is not collidable then do nothing\r\n if ((pis.length == 1 && !this._isSeeAble(pis[0].pickedMesh)) && (!pis[0].pickedMesh.checkCollisions || !this._camera.checkCollisions)) return;\r\n\r\n //if our camera is collidable then we donot want it to get stuck behind another collidable obsrtucting mesh\r\n let pp: Vector3 = null;\r\n\r\n //we will asume the order of picked meshes is from closest to avatar to furthest\r\n //we should get the first one which is visible or invisible and collidable\r\n for (let i = 0; i < pis.length; i++) {\r\n let pm = pis[i].pickedMesh;\r\n if (this._isSeeAble(pm)) {\r\n pp = pis[i].pickedPoint;\r\n break;\r\n } else if (pm.checkCollisions) {\r\n pp = pis[i].pickedPoint;\r\n break;\r\n }\r\n }\r\n if (pp == null) return;\r\n\r\n const c2p: Vector3 = this._camera.position.subtract(pp);\r\n //note that when camera is collidable, changing the orbital camera radius may not work.\r\n //changing the radius moves the camera forward (with collision?) and collision can interfere with movement\r\n //\r\n //in every cylce we are dividing the distance to tarvel by same number of steps.\r\n //as we get closer to destination the speed will thus slow down.\r\n //when just 1 unit distance left, lets snap to the final position.\r\n //when calculating final position make sure the camera does not get stuck at the pickposition especially\r\n //if collision is on\r\n\r\n const l: number = c2p.length();\r\n if (this._camera.checkCollisions) {\r\n let step: Vector3;\r\n if (l <= 1) {\r\n step = c2p.addInPlace(c2p.normalizeToNew().scaleInPlace(this._cameraSkin));\r\n } else {\r\n step = c2p.normalize().scaleInPlace(l / this._elasticSteps);\r\n }\r\n this._camera.position = this._camera.position.subtract(step);\r\n } else {\r\n let step: number;\r\n if (l <= 1) step = l + this._cameraSkin; else step = l / this._elasticSteps;\r\n this._camera.radius = this._camera.radius - (step);\r\n }\r\n }\r\n }\r\n }\r\n\r\n //how many ways can a mesh be invisible?\r\n private _isSeeAble(mesh: AbstractMesh): boolean {\r\n if (!mesh.isVisible) return false;\r\n if (mesh.visibility == 0) return false;\r\n if (mesh.material != null && mesh.material.alphaMode != 0 && mesh.material.alpha == 0) return false;\r\n return true;\r\n //what about vertex color? groan!\r\n }\r\n\r\n\r\n private _move: boolean = false;\r\n public anyMovement(): boolean {\r\n return (this._act._walk || this._act._walkback || this._act._turnLeft || this._act._turnRight || this._act._stepLeft || this._act._stepRight);\r\n }\r\n\r\n private _onKeyDown(e: KeyboardEvent) {\r\n if (!e.key) return;\r\n if (e.repeat) return;\r\n switch (e.key.toLowerCase()) {\r\n case this._actionMap.idleJump.key:\r\n this._act._jump = true;\r\n break;\r\n case \"capslock\":\r\n this._act._speedMod = !this._act._speedMod;\r\n break;\r\n case \"shift\":\r\n this._act._speedMod = true;\r\n break;\r\n case \"up\":\r\n case \"arrowup\":\r\n case this._actionMap.walk.key:\r\n this._act._walk = true;\r\n break;\r\n case \"left\":\r\n case \"arrowleft\":\r\n case this._actionMap.turnLeft.key:\r\n this._act._turnLeft = true;\r\n break;\r\n case \"right\":\r\n case \"arrowright\":\r\n case this._actionMap.turnRight.key:\r\n this._act._turnRight = true;\r\n break;\r\n case \"down\":\r\n case \"arrowdown\":\r\n case this._actionMap.walkBack.key:\r\n this._act._walkback = true;\r\n break;\r\n case this._actionMap.strafeLeft.key:\r\n this._act._stepLeft = true;\r\n break;\r\n case this._actionMap.strafeRight.key:\r\n this._act._stepRight = true;\r\n break;\r\n }\r\n this._move = this.anyMovement();\r\n }\r\n\r\n private _onKeyUp(e: KeyboardEvent) {\r\n if (!e.key) return;\r\n switch (e.key.toLowerCase()) {\r\n case \"shift\":\r\n this._act._speedMod = false;\r\n break;\r\n case \"up\":\r\n case \"arrowup\":\r\n case this._actionMap.walk.key:\r\n this._act._walk = false;\r\n break;\r\n case \"left\":\r\n case \"arrowleft\":\r\n case this._actionMap.turnLeft.key:\r\n this._act._turnLeft = false;\r\n this._isTurning = false;\r\n break;\r\n case \"right\":\r\n case \"arrowright\":\r\n case this._actionMap.turnRight.key:\r\n this._act._turnRight = false;\r\n this._isTurning = false;\r\n break;\r\n case \"down\":\r\n case \"arrowdown\":\r\n case this._actionMap.walkBack.key:\r\n this._act._walkback = false;\r\n break;\r\n case this._actionMap.strafeLeft.key:\r\n this._act._stepLeft = false;\r\n break;\r\n case this._actionMap.strafeRight.key:\r\n this._act._stepRight = false;\r\n break;\r\n }\r\n this._move = this.anyMovement();\r\n }\r\n\r\n private _ekb: boolean = true;\r\n public isKeyBoardEnabled(): boolean {\r\n return this._ekb;\r\n }\r\n public enableKeyBoard(b: boolean) {\r\n this._ekb = b;\r\n if (b) {\r\n this._addkeylistener();\r\n } else {\r\n this._removekeylistener();\r\n }\r\n }\r\n\r\n private _addkeylistener() {\r\n let canvas: HTMLCanvasElement = this._scene.getEngine().getRenderingCanvas();\r\n canvas.addEventListener(\"keyup\", this._handleKeyUp, false);\r\n canvas.addEventListener(\"keydown\", this._handleKeyDown, false);\r\n }\r\n\r\n private _removekeylistener() {\r\n let canvas: HTMLCanvasElement = this._scene.getEngine().getRenderingCanvas();\r\n canvas.removeEventListener(\"keyup\", this._handleKeyUp, false);\r\n canvas.removeEventListener(\"keydown\", this._handleKeyDown, false);\r\n }\r\n\r\n // control movement by commands rather than keyboard.\r\n public walk(b: boolean) {\r\n this._act._walk = b;\r\n }\r\n public walkBack(b: boolean) {\r\n this._act._walkback = b;\r\n }\r\n public walkBackFast(b: boolean) {\r\n this._act._walkback = b;\r\n this._act._speedMod = b;\r\n }\r\n public run(b: boolean) {\r\n this._act._walk = b;\r\n this._act._speedMod = b;\r\n }\r\n public turnLeft(b: boolean) {\r\n this._act._turnLeft = b;\r\n if (!b) this._isTurning = b;\r\n }\r\n public turnLeftFast(b: boolean) {\r\n this._act._turnLeft = b;\r\n if (!b) this._isTurning = b;\r\n this._act._speedMod = b;\r\n }\r\n public turnRight(b: boolean) {\r\n this._act._turnRight = b;\r\n if (!b) this._isTurning = b;\r\n }\r\n public turnRightFast(b: boolean) {\r\n this._act._turnRight = b;\r\n if (!b) this._isTurning = b;\r\n this._act._speedMod = b;\r\n }\r\n public strafeLeft(b: boolean) {\r\n this._act._stepLeft = b;\r\n }\r\n public strafeLeftFast(b: boolean) {\r\n this._act._stepLeft = b;\r\n this._act._speedMod = b;\r\n }\r\n public strafeRight(b: boolean) {\r\n this._act._stepRight = b;\r\n }\r\n public strafeRightFast(b: boolean) {\r\n this._act._stepRight = b;\r\n this._act._speedMod = b;\r\n }\r\n public jump() {\r\n this._act._jump = true;\r\n }\r\n\r\n public fall() {\r\n this._grounded = false;\r\n }\r\n\r\n public idle() {\r\n this._act.reset();\r\n }\r\n\r\n private _act: _Action;\r\n private _renderer: () => void;\r\n private _handleKeyUp: (e) => void;\r\n private _handleKeyDown: (e) => void;\r\n private _isAG: boolean = false;\r\n public isAg() {\r\n return this._isAG;\r\n }\r\n\r\n\r\n\r\n\r\n private _findSkel(n: Node): Skeleton {\r\n let root = this._root(n);\r\n\r\n if (root instanceof Mesh && root.skeleton) return root.skeleton;\r\n\r\n //find all child meshes which have skeletons\r\n let ms = root.getChildMeshes(\r\n false,\r\n (cm) => {\r\n if (cm instanceof Mesh) {\r\n if (cm.skeleton) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n });\r\n\r\n //return the skeleton of the first child mesh\r\n if (ms.length > 0) return ms[0].skeleton; else return null;\r\n\r\n }\r\n\r\n private _root(tn: Node): Node {\r\n if (tn.parent == null) return tn;\r\n return this._root(tn.parent);\r\n }\r\n\r\n public setAvatar(avatar: Mesh, faceForward: boolean = false): boolean {\r\n\r\n let rootNode = this._root(avatar);\r\n if (rootNode instanceof Mesh) {\r\n this._avatar = rootNode;\r\n } else {\r\n console.error(\"Cannot move this mesh. The root node of the mesh provided is not a mesh\");\r\n return false;\r\n }\r\n\r\n this._skeleton = this._findSkel(avatar);\r\n this._isAG = this._containsAG(avatar, this._scene.animationGroups, true);\r\n\r\n this._actionMap.reset();\r\n\r\n //animation ranges\r\n if (!this._isAG && this._skeleton != null) this._checkAnimRanges(this._skeleton);\r\n\r\n this._setRHS(avatar);\r\n this.setFaceForward(faceForward);\r\n\r\n return true;\r\n }\r\n\r\n public getAvatar() {\r\n return this._avatar;\r\n }\r\n\r\n // force a skeleton to be the avatar skeleton\r\n // should not be calling this normally\r\n public setAvatarSkeleton(skeleton: Skeleton) {\r\n this._skeleton = skeleton;\r\n\r\n\r\n if (this._skeleton != null && this._skelDrivenByAG(skeleton)) this._isAG = true; else this._isAG = false;\r\n\r\n if (!this._isAG && this._skeleton != null) this._checkAnimRanges(this._skeleton);\r\n }\r\n\r\n\r\n // this check if any of this skeleton animations is referenced by any targetedAnimation in any of the animationgroup in the scene.\r\n private _skelDrivenByAG(skeleton: Skeleton) {\r\n return skeleton.animations.some(sa => this._scene.animationGroups.some(ag => ag.children.some(ta => ta.animation == sa)));\r\n }\r\n\r\n public getSkeleton() {\r\n return this._skeleton;\r\n }\r\n\r\n // does this character have any animations ?\r\n // remember we can use meshes without anims as characters too\r\n private _hasAnims: boolean = false;\r\n private _hasCam: boolean = true;\r\n\r\n /**\r\n * The avatar/character can be made up of multiple meshes arranged in a hierarchy.\r\n * As such we will pick the root of the hierarchy as the avatar.\r\n * The root should be a mesh as otherwise we cannot move it with moveWithCollision() method.\r\n * \r\n * Mutiple meshes in the hierarchy may have skeletons (if two or more meshes have skeleton then\r\n * the skeleton will mostly likely be the same). \r\n * So we will pick as avatar skeleton, the skeleton of the first mesh in the hierachy which has\r\n * a skeleton \r\n * \r\n * @param avatar \r\n * @param camera \r\n * @param scene \r\n * @param actionMap/animationGroupMap \r\n * maps actions to animations and other data like speed,sound etc \r\n * or \r\n * for backward compatibility could be AnimationGroup Map\r\n * @param faceForward \r\n */\r\n constructor(avatar: Mesh, camera: ArcRotateCamera, scene: Scene, actionMap?: {}, faceForward = false) {\r\n\r\n this._camera = camera;\r\n\r\n //if camera is null assume this would be used to control an NPC\r\n //we cannot use mode 0 as that is dependent on camera being present. so force mode 1\r\n if (this._camera == null) {\r\n this._hasCam = false;\r\n this.setMode(1);\r\n }\r\n this._scene = scene;\r\n\r\n let success = this.setAvatar(avatar, faceForward);\r\n if (!success) {\r\n console.error(\"unable to set avatar\");\r\n }\r\n\r\n\r\n let dataType: string = null;\r\n if (actionMap != null) {\r\n dataType = this.setActionMap(actionMap);\r\n }\r\n\r\n //try to use the existing avatar animations\r\n\r\n //animation ranges\r\n if (!this._isAG && this._skeleton != null) this._checkAnimRanges(this._skeleton);\r\n //animation groups\r\n if (this._isAG) {\r\n //TODO\r\n }\r\n\r\n if (this._hasCam) this._savedCameraCollision = this._camera.checkCollisions;\r\n\r\n this._act = new _Action();\r\n\r\n this._renderer = () => { this._moveAVandCamera() };\r\n this._handleKeyUp = (e) => { this._onKeyUp(e) };\r\n this._handleKeyDown = (e) => { this._onKeyDown(e) };\r\n }\r\n}\r\n\r\n\r\n\r\nclass _Action {\r\n\r\n public _walk: boolean = false;\r\n public _walkback: boolean = false;\r\n public _turnRight: boolean = false;\r\n public _turnLeft: boolean = false;\r\n public _stepRight: boolean = false;\r\n public _stepLeft: boolean = false;\r\n public _jump: boolean = false;\r\n\r\n // speed modifier - changes speed of movement\r\n public _speedMod: boolean = false;\r\n\r\n\r\n constructor() {\r\n this.reset();\r\n }\r\n\r\n reset() {\r\n this._walk = false;\r\n this._walkback = false;\r\n this._turnRight = false;\r\n this._turnLeft = false;\r\n this._stepRight = false;\r\n this._stepLeft = false;\r\n this._jump = false;\r\n this._speedMod = false;\r\n }\r\n}\r\n\r\nexport class ActionData {\r\n public id: string;\r\n public speed: number;\r\n //_ds default speed. speed is set to this on reset\r\n public ds: number;\r\n public sound: Sound;\r\n public key: string;\r\n //_dk defailt key\r\n public dk: string;\r\n\r\n //animation data\r\n //if _ag is null then assuming animation range and use _name to play animationrange\r\n //instead of name maybe call it arName?\r\n public name: string = \"\";\r\n public ag: AnimationGroup;\r\n public loop: boolean = true;\r\n public rate: number = 1;\r\n\r\n public exist: boolean = false;\r\n\r\n public constructor(id?: string, speed = 1, key?: string) {\r\n this.id = id;\r\n this.speed = speed;\r\n this.ds = speed;\r\n this.key = key;\r\n this.dk = key;\r\n }\r\n\r\n public reset() {\r\n this.name = \"\";\r\n this.speed = this.ds;\r\n this.key = this.dk;\r\n this.loop = true;\r\n this.rate = 1;\r\n this.sound = null;\r\n this.exist = false;\r\n }\r\n\r\n}\r\n\r\n//not really a \"Map\"\r\nexport class ActionMap {\r\n public walk = new ActionData(\"walk\", 3, \"w\");\r\n public walkBack = new ActionData(\"walkBack\", 1.5, \"s\");\r\n public walkBackFast = new ActionData(\"walkBackFast\", 3, \"na\");\r\n public idle = new ActionData(\"idle\", 0, \"na\");\r\n public idleJump = new ActionData(\"idleJump\", 6, \" \");\r\n public run = new ActionData(\"run\", 6, \"na\");\r\n public runJump = new ActionData(\"runJump\", 6, \"na\");\r\n public fall = new ActionData(\"fall\", 0, \"na\");\r\n public turnLeft = new ActionData(\"turnLeft\", Math.PI / 8, \"a\");\r\n public turnLeftFast = new ActionData(\"turnLeftFast\", Math.PI / 4, \"na\");\r\n public turnRight = new ActionData(\"turnRight\", Math.PI / 8, \"d\");\r\n public turnRightFast = new ActionData(\"turnRightFast\", Math.PI / 4, \"na\");\r\n public strafeLeft = new ActionData(\"strafeLeft\", 1.5, \"q\");\r\n public strafeLeftFast = new ActionData(\"strafeLeftFast\", 3, \"na\");\r\n public strafeRight = new ActionData(\"strafeRight\", 1.5, \"e\");\r\n public strafeRightFast = new ActionData(\"strafeRightFast\", 3, \"na\");\r\n public slideBack = new ActionData(\"slideBack\", 0, \"na\");\r\n\r\n public reset() {\r\n let keys: string[] = Object.keys(this);\r\n for (let key of keys) {\r\n let act = this[key];\r\n if (!(act instanceof ActionData)) continue;\r\n act.reset()\r\n }\r\n }\r\n};\r\n\r\nexport class CCSettings {\r\n public faceForward: boolean;\r\n public gravity: number;\r\n public minSlopeLimit: number;\r\n public maxSlopeLimit: number;\r\n public stepOffset: number;\r\n public cameraElastic: boolean = true;\r\n public elasticSteps: number;\r\n public makeInvisble: boolean = true;\r\n public cameraTarget: Vector3 = Vector3.Zero();\r\n public noFirstPerson: boolean = false;\r\n public topDown: boolean = true;\r\n //turningOff takes effect only when topDown is false\r\n public turningOff: boolean = true;\r\n public keyboard: boolean = true;\r\n public sound: Sound;\r\n}\r\n"],"names":[],"sourceRoot":""} \ No newline at end of file