diff --git a/demo/dist/CharacterController.js b/demo/dist/CharacterController.js index dd00257..c37b0ef 100644 --- a/demo/dist/CharacterController.js +++ b/demo/dist/CharacterController.js @@ -1,2 +1,2 @@ -!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 t.Ray(t.Vector3.Zero(),t.Vector3.One(),1),this.ut=t.Vector3.Zero(),this.ft=.5,this.ot=new Array,this.ct=!1,this.lt=50,this.vt=!1,this.bt=!0,this.wt=!1,this.kt=!1,this.dt=!0,this.Mt=h,null==this.Mt&&(this.dt=!1,this.setMode(1)),this.jt=n,this.setAvatar(i,u)||console.error("unable to set avatar");null!=e&&this.setActionMap(e),this.wt||null==this.h||this.yt(this.h),this.wt,this.dt&&(this.nt=this.Mt.checkCollisions),this.Ot=new s,this.gt=function(){f.xt()},this.Ct=function(t){f.Ft(t)},this.At=function(t){f.Lt(t)}}return i.prototype.getScene=function(){return this.jt},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.wt=!0,this.setActionMap(t)},i.prototype.setAnimationRanges=function(t){this.wt=!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.Et=function(t){return null==t.parent?t:this.Et(t.parent)},i.prototype.start=function(){this.B||(this.B=!0,this.Ot.reset(),this.Y=0,this.it=.001,this.D=!1,this.Gt(),this.bt&&this.Ht(),this.jt.registerBeforeRender(this.gt))},i.prototype.stop=function(){this.B&&(this.B=!1,this.jt.unregisterBeforeRender(this.gt),this.Kt(),this.J=null)},i.prototype.pauseAnim=function(){this.I=!0,null!=this.J&&this.J.exist&&(this.wt?this.J.ag.stop():this.jt.stopAnimation(this.h),null!=this.J.sound&&this.J.sound.stop(),clearInterval(this.V),this.jt.unregisterBeforeRender(this.gt))},i.prototype.resumeAnim=function(){this.I=!1,this.J=null,this.jt.registerBeforeRender(this.gt)},i.prototype.Nt=function(){return this.dt?t.Vector3.Dot(this.i.forward,this.i.position.subtract(this.Mt.position))<0?1:-1:1},i.prototype.xt=function(){this._.copyFrom(this.i.position);var t=null,i=this.jt.getEngine().getDeltaTime()/1e3;if(this.Ot.Pt&&!this.K?(this.D=!1,this.it=0,t=this.Qt(i)):this.anyMovement()||this.K?(this.D=!1,this.it=0,t=this.Ut(i)):this.K||(t=this.Vt(i)),!this.I&&this.kt&&null!=t&&this.J!==t){if(t.exist){var s=void 0,h=30;if(this.wt)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.Gt()},i.prototype.Qt=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.dt&&1!=this.L&&!this.tt&&(this.i.rotation.y=this.Dt-this.Mt.alpha),this.P||this.N?(this.P?n=this.g.run.speed*i:this.N&&(n=this.g.walk.speed*i),(h=this.Wt.clone()).y=0,(h=h.normalize()).scaleToRef(n,h),e=this.Xt(this.g.runJump.speed,i),h.y=e):(e=this.Xt(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.Yt();else if(this.i.position.y0?this.g.strafeLeftFast:this.g.strafeRightFast):h=-this.Tt*n>0?this.g.strafeLeft:this.g.strafeRight,this.Wt=this.i.calcMovePOV(n*e,-this.T,0),s=!0;break;case this.Ot.ni:n=-this.q*this.Nt(),e=this.g.strafeRight.speed*t,this.Ot.hi?(e=this.g.strafeRightFast.speed*t,h=-this.Tt*n>0?this.g.strafeLeftFast:this.g.strafeRightFast):h=-this.Tt*n>0?this.g.strafeLeft:this.g.strafeRight,this.Wt=this.i.calcMovePOV(n*e,-this.T,0),s=!0;break;case this.Ot.ei||this.tt&&0==this.L:this.Ot.hi?(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.Wt=this.i.calcMovePOV(0,-this.T,this.Tt*e),s=!0;break;case this.Ot.ri:e=this.g.walkBack.speed*t,this.Ot.hi?(e=this.g.walkBackFast.speed*t,h=this.g.walkBackFast):h=this.g.walkBack,this.Wt=this.i.calcMovePOV(0,-this.T,-this.Tt*e),s=!0}}if(s&&this.Wt.length()>.001)if(this.i.moveWithCollisions(this.Wt),this.i.position.y>this._.y){var r=this.i.position.subtract(this._),u=this.$t(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.ui())):(this.i.position.copyFrom(this._),this.ui()):(this.j=0,u>this.k?(this.H=0,this.K=!1):this.ui())}else if(this.i.position.ythis.G&&(h=this.g.fall)):this.$t(r)<=this.k?this.ui():(this.H=0,this.K=!1)}else this.ui();return h},i.prototype.ti=function(){if(this.dt&&1!=this.L){var t=this.dt?this.Dt-this.Mt.alpha:0;if(this.tt)switch(!0){case this.Ot.ei&&this.Ot.fi:this.i.rotation.y=t+this._t*Math.PI/4;break;case this.Ot.ei&&this.Ot.ai:this.i.rotation.y=t-this._t*Math.PI/4;break;case this.Ot.ri&&this.Ot.fi:this.i.rotation.y=t+3*this._t*Math.PI/4;break;case this.Ot.ri&&this.Ot.ai:this.i.rotation.y=t-3*this._t*Math.PI/4;break;case this.Ot.ei:this.i.rotation.y=t;break;case this.Ot.ri:this.i.rotation.y=t+Math.PI;break;case this.Ot.fi:this.i.rotation.y=t+this._t*Math.PI/2;break;case this.Ot.ai:this.i.rotation.y=t-this._t*Math.PI/2}else this.dt&&(this.i.rotation.y=t)}},i.prototype.ii=function(t,i,s){if((!this.tt||0!=this.L)&&!this.Ot.si&&!this.Ot.ni&&(this.Ot.ai||this.Ot.fi)){var h=this.g.turnLeft.speed*s;this.Ot.hi&&(h*=2);var n=void 0;1==this.L?(this.$||(this.Z=-this.Tt*this.Nt(),this.S&&(this.Z=-this.Z),this.$=!0),n=this.Z,this.Ot.ai?this.Ot.ei||(this.Ot.ri?n=-this.Z:t=this.Z>0?this.g.turnRight:this.g.turnLeft):this.Ot.ei?n=-this.Z:this.Ot.ri||(n=-this.Z,t=this.Z>0?this.g.turnLeft:this.g.turnRight)):(n=1,this.Ot.ai?(this.Ot.ri&&(n=-1),i||(t=this.g.turnLeft)):(this.Ot.ei&&(n=-1),i||(n=-1,t=this.g.turnRight)),this.dt&&(this.Mt.alpha=this.Mt.alpha+this._t*h*n)),this.i.rotation.y=this.i.rotation.y+h*n}return t},i.prototype.ui=function(){this.Y=0,this.H=0,this.K=!1},i.prototype.Vt=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.dt&&1!=this.L&&!this.tt&&(this.i.rotation.y=this.Dt-this.Mt.alpha),this.i.moveWithCollisions(n),this.i.position.y>this._.y||this.i.position.y===this._.y)this.oi();else if(this.i.position.ythis.ht&&(this.D=!0,this.it=0)},i.prototype.ci=function(){this.D=!1,this.st=0},i.prototype.Gt=function(){this.dt&&(0==this.j&&this.i.position.addToRef(this.F,this.Mt.target),this.Mt.radius>this.Mt.lowerRadiusLimit&&(this.C||this.ct)&&this.li(),this.Mt.radius<=this.Mt.lowerRadiusLimit?this.A||this.et||(this.i.visibility=0,this.Mt.checkCollisions=!1,this.R=this.L,this.L=0,this.et=!0):(this.et=!1,this.L=this.R,this.i.visibility=1,this.Mt.checkCollisions=this.nt))},i.prototype.li=function(){var t=this;this.Mt.position.subtractToRef(this.Mt.target,this.ut),this.rt.origin=this.Mt.target,this.rt.length=this.ut.length(),this.rt.direction=this.ut.normalize();var i=this.jt.multiPickWithRay(this.rt,(function(i){return i!=t.i}));if(this.ct)if(this.vi=this.ot,i.length>0){this.ot=new Array;for(var s=0,h=i;s0){if(!(1!=i.length||this.bi(i[0].pickedMesh)||i[0].pickedMesh.checkCollisions&&this.Mt.checkCollisions))return;for(var o=null,c=0;c0?h[0].skeleton:null},i.prototype.ki=function(t){return null==t.parent?t:this.ki(t.parent)},i.prototype.setAvatar=function(i,s){void 0===s&&(s=!1);var h=this.ki(i);return h instanceof t.Mesh?(this.i=h,this.h=this.wi(i),this.wt=this.zt(i,this.jt.animationGroups,!0),this.g.reset(),this.wt||null==this.h||this.yt(this.h),this.It(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.di(t)?this.wt=!0:this.wt=!1,this.wt||null==this.h||this.yt(this.h)},i.prototype.di=function(t){var i=this;return t.animations.some((function(t){return i.jt.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.ei=!1,this.ri=!1,this.fi=!1,this.ai=!1,this.ni=!1,this.si=!1,this.Pt=!1,this.hi=!1,this.reset()}return t.prototype.reset=function(){this.ei=!1,this.ri=!1,this.fi=!1,this.ai=!1,this.ni=!1,this.si=!1,this.Pt=!1,this.hi=!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(()=>{"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