Permalink
Browse files

Update build.

  • Loading branch information...
1 parent fea5fd7 commit 46d750d5beb412401825ca47763b1ceeb6c3c60f @tapio committed Jan 18, 2013
Showing with 24 additions and 24 deletions.
  1. +24 −24 build/libs.min.js
View
48 build/libs.min.js
@@ -599,27 +599,27 @@ this.endNode.y,o,u,f,l,c,h=e.x,p=e.y,d,v,m,g,y,b,w,E=Math.abs,S=Math.max;o=this.
,e.style.textAlign="center",e.style.background="#fff",e.style.color="#000",e.style.padding="1.5em",e.style.width="400px",e.style.margin="5em auto 0",this.webgl||(e.innerHTML=window.WebGLRenderingContext?['Your graphics card does not seem to support <a href="http://khronos.org/webgl/wiki/Getting_a_WebGL_Implementation" style="color:#000">WebGL</a>.<br />','Find out how to get it <a href="http://get.webgl.org/" style="color:#000">here</a>.'].join("\n"):['Your browser does not seem to support <a href="http://khronos.org/webgl/wiki/Getting_a_WebGL_Implementation" style="color:#000">WebGL</a>.<br/>','Find out how to get it <a href="http://get.webgl.org/" style="color:#000">here</a>.'].join("\n")),e},addGetWebGLMessage:function(e){var t,n,r;e=e||{},t=e.parent!==undefined?e.parent:document.body,n=e.id!==undefined?e.id:"oldie",r=Detector.getWebGLErrorMessage(),r.id=n,t.appendChild(r)}};var Stats=function(){var e=Date.now(),t=e,n=0,r=Infinity,i=0,s=0,o=Infinity,u=0,a=0,f=0,l=document.createElement("div");l.id="stats",l
.addEventListener("mousedown",function(e){e.preventDefault(),y(++f%2)},!1),l.style.cssText="width:80px;opacity:0.9;cursor:pointer";var c=document.createElement("div");c.id="fps",c.style.cssText="padding:0 0 3px 3px;text-align:left;background-color:#002",l.appendChild(c);var h=document.createElement("div");h.id="fpsText",h.style.cssText="color:#0ff;font-family:Helvetica,Arial,sans-serif;font-size:9px;font-weight:bold;line-height:15px",h.innerHTML="FPS",c.appendChild(h);var p=document.createElement("div");p.id="fpsGraph",p.style.cssText="position:relative;width:74px;height:30px;background-color:#0ff";for(c.appendChild(p);74>p.children.length;){var d=document.createElement("span");d.style.cssText="width:1px;height:30px;float:left;background-color:#113",p.appendChild(d)}var v=document.createElement("div");v.id="ms",v.style.cssText="padding:0 0 3px 3px;text-align:left;background-color:#020;display:none",l.appendChild(v);var m=document.createElement("div");m.id="msText",m.style.cssText="color:#0f0;font-family:Helvetica,Arial,sans-serif;font-size:9px;font-weight:bold;line-height:15px"
,m.innerHTML="MS",v.appendChild(m);var g=document.createElement("div");g.id="msGraph",g.style.cssText="position:relative;width:74px;height:30px;background-color:#0f0";for(v.appendChild(g);74>g.children.length;)d=document.createElement("span"),d.style.cssText="width:1px;height:30px;float:left;background-color:#131",g.appendChild(d);var y=function(e){f=e;switch(f){case 0:c.style.display="block",v.style.display="none";break;case 1:c.style.display="none",v.style.display="block"}};return{REVISION:11,domElement:l,setMode:y,begin:function(){e=Date.now()},end:function(){var f=Date.now();n=f-e,r=Math.min(r,n),i=Math.max(i,n),m.textContent=n+" MS ("+r+"-"+i+")";var l=Math.min(30,30-30*(n/200));return g.appendChild(g.firstChild).style.height=l+"px",a++,f>t+1e3&&(s=Math.round(1e3*a/(f-t)),o=Math.min(o,s),u=Math.max(u,s),h.textContent=s+" FPS ("+o+"-"+u+")",l=Math.min(30,30-30*(s/100)),p.appendChild(p.firstChild).style.height=l+"px",t=f,a=0),f},update:function(){e=this.end()}}};"use strict",window.Physijs=function(){var e=
-parseInt(THREE.REVISION,10),t=new THREE.Matrix4,n=!1,r=i,i={},s,o,u,a,f,l,c,h,p=new THREE.Vector3,d=new THREE.Vector3,v=new THREE.Matrix4,m=new THREE.Quaternion,g={WORLDREPORT:0,COLLISIONREPORT:1,VEHICLEREPORT:2,CONSTRAINTREPORT:3},y=14,b=9,w=6;return i.scripts={},s=function(){this._eventListeners={}},s.prototype.addEventListener=function(e,t){this._eventListeners.hasOwnProperty(e)||(this._eventListeners[e]=[]),this._eventListeners[e].push(t)},s.prototype.removeEventListener=function(e,t){var n;return this._eventListeners.hasOwnProperty(e)?(n=this._eventListeners[e].indexOf(t))>=0?(this._eventListeners[e].splice(n,1),!0):!1:!1},s.prototype.dispatchEvent=function(e){var t,n=Array.prototype.splice.call(arguments,1);if(this._eventListeners.hasOwnProperty(e))for(t=0;t<this._eventListeners[e].length;t++)this._eventListeners[e][t].apply(this,n)},s.make=function(e){e.prototype.addEventListener=s.prototype.addEventListener,e.prototype.removeEventListener=s.prototype.removeEventListener,e.prototype.dispatchEvent=s.prototype
-.dispatchEvent},o=function(){var e=0;return function(){return e++}}(),u=function(e,t,n,r){return new THREE.Vector3(Math.atan2(2*(e*r-t*n),r*r-e*e-t*t+n*n),Math.asin(2*(e*n+t*r)),Math.atan2(2*(n*r-e*t),r*r+e*e-t*t-n*n))},a=function(e,t,n){var r,i,s,o,u,a,f,l;return r=Math.cos(t),i=Math.sin(t),s=Math.cos(-n),o=Math.sin(-n),u=Math.cos(e),a=Math.sin(e),f=r*s,l=i*o,{w:f*u-l*a,x:f*a+l*u,y:i*s*u+r*o*a,z:r*o*u-i*s*a}},f=function(e,t){return v.identity(),t.useQuaternion?v.identity().setRotationFromQuaternion(t.quaternion):v.identity().setRotationFromEuler(t.rotation),v.getInverse(v),p.copy(e),d.copy(t.position),v.multiplyVector3(p.subSelf(d))},i.noConflict=function(){return window.Physijs=r,i},i.createMaterial=function(e,t,n){var r=function(){};return r.prototype=e,r=new r,r._physijs={id:e.id,friction:t===undefined?.8:t,restitution:n===undefined?.2:n},r},i.PointConstraint=function(e,t,n){n===undefined&&(n=t,t=undefined),this.type="point",this.appliedImpulse=0,this.id=o(),this.objecta=e._physijs.id,this.positiona=f(n,e)
-.clone(),t&&(this.objectb=t._physijs.id,this.positionb=f(n,t).clone())},i.PointConstraint.prototype.getDefinition=function(){return{type:this.type,id:this.id,objecta:this.objecta,objectb:this.objectb,positiona:this.positiona,positionb:this.positionb}},i.HingeConstraint=function(e,t,n,r){r===undefined&&(r=n,n=t,t=undefined),this.type="hinge",this.appliedImpulse=0,this.id=o(),this.scene=e.parent,this.objecta=e._physijs.id,this.positiona=f(n,e).clone(),this.position=n.clone(),this.axis=r,t&&(this.objectb=t._physijs.id,this.positionb=f(n,t).clone())},i.HingeConstraint.prototype.getDefinition=function(){return{type:this.type,id:this.id,objecta:this.objecta,objectb:this.objectb,positiona:this.positiona,positionb:this.positionb,axis:this.axis}},i.HingeConstraint.prototype.setLimits=function(e,t,n,r){this.scene.execute("hinge_setLimits",{constraint:this.id,low:e,high:t,bias_factor:n,relaxation_factor:r})},i.HingeConstraint.prototype.enableAngularMotor=function(e,t){this.scene.execute("hinge_enableAngularMotor",{constraint
-:this.id,velocity:e,acceleration:t})},i.HingeConstraint.prototype.disableMotor=function(e,t){this.scene.execute("hinge_disableMotor",{constraint:this.id})},i.SliderConstraint=function(e,t,n,r){r===undefined&&(r=n,n=t,t=undefined),this.type="slider",this.appliedImpulse=0,this.id=o(),this.scene=e.parent,this.objecta=e._physijs.id,this.positiona=f(n,e).clone(),this.axis=r,t&&(this.objectb=t._physijs.id,this.positionb=f(n,t).clone())},i.SliderConstraint.prototype.getDefinition=function(){return{type:this.type,id:this.id,objecta:this.objecta,objectb:this.objectb,positiona:this.positiona,positionb:this.positionb,axis:this.axis}},i.SliderConstraint.prototype.setLimits=function(e,t,n,r){this.scene.execute("slider_setLimits",{constraint:this.id,lin_lower:e,lin_upper:t,ang_lower:n,ang_upper:r})},i.SliderConstraint.prototype.setRestitution=function(e,t){this.scene.execute("slider_setRestitution",{constraint:this.id,linear:e,angular:t})},i.SliderConstraint.prototype.enableLinearMotor=function(e,t){this.scene.execute("slider_enableLinearMotor"
-,{constraint:this.id,velocity:e,acceleration:t})},i.SliderConstraint.prototype.disableLinearMotor=function(){this.scene.execute("slider_disableLinearMotor",{constraint:this.id})},i.SliderConstraint.prototype.enableAngularMotor=function(e,t){this.scene.execute("slider_enableAngularMotor",{constraint:this.id,velocity:e,acceleration:t})},i.SliderConstraint.prototype.disableAngularMotor=function(){this.scene.execute("slider_disableAngularMotor",{constraint:this.id})},i.ConeTwistConstraint=function(e,t,n){if(n===undefined)throw"Both objects must be defined in a ConeTwistConstraint.";this.type="conetwist",this.appliedImpulse=0,this.id=o(),this.scene=e.parent,this.objecta=e._physijs.id,this.positiona=f(n,e).clone(),this.objectb=t._physijs.id,this.positionb=f(n,t).clone(),this.axisa={x:e.rotation.x,y:e.rotation.y,z:e.rotation.z},this.axisb={x:t.rotation.x,y:t.rotation.y,z:t.rotation.z}},i.ConeTwistConstraint.prototype.getDefinition=function(){return{type:this.type,id:this.id,objecta:this.objecta,objectb:this.objectb,positiona
-:this.positiona,positionb:this.positionb,axisa:this.axisa,axisb:this.axisb}},i.ConeTwistConstraint.prototype.setLimit=function(e,t,n){this.scene.execute("conetwist_setLimit",{constraint:this.id,x:e,y:t,z:n})},i.ConeTwistConstraint.prototype.enableMotor=function(){this.scene.execute("conetwist_enableMotor",{constraint:this.id})},i.ConeTwistConstraint.prototype.setMaxMotorImpulse=function(e){this.scene.execute("conetwist_setMaxMotorImpulse",{constraint:this.id,max_impulse:e})},i.ConeTwistConstraint.prototype.setMotorTarget=function(e){if(e instanceof THREE.Vector3)throw"Wait for Three.js r50 to setMotorTarget from Vector3 - use Matrix4 or Quaternion instead";e instanceof THREE.Matrix4&&(e=(new THREE.Quaternion).setFromRotationMatrix(e)),this.scene.execute("conetwist_setMotorTarget",{constraint:this.id,x:e.x,y:e.y,z:e.z,w:e.w})},i.ConeTwistConstraint.prototype.disableMotor=function(){this.scene.execute("conetwist_disableMotor",{constraint:this.id})},i.DOFConstraint=function(e,t,n){n===undefined&&(n=t,t=undefined)
-,this.type="dof",this.appliedImpulse=0,this.id=o(),this.scene=e.parent,this.objecta=e._physijs.id,this.positiona=f(n,e).clone(),this.axisa={x:e.rotation.x,y:e.rotation.y,z:e.rotation.z},t&&(this.objectb=t._physijs.id,this.positionb=f(n,t).clone(),this.axisb={x:t.rotation.x,y:t.rotation.y,z:t.rotation.z})},i.DOFConstraint.prototype.getDefinition=function(){return{type:this.type,id:this.id,objecta:this.objecta,objectb:this.objectb,positiona:this.positiona,positionb:this.positionb,axisa:this.axisa,axisb:this.axisb}},i.DOFConstraint.prototype.setLinearLowerLimit=function(e){this.scene.execute("dof_setLinearLowerLimit",{constraint:this.id,x:e.x,y:e.y,z:e.z})},i.DOFConstraint.prototype.setLinearUpperLimit=function(e){this.scene.execute("dof_setLinearUpperLimit",{constraint:this.id,x:e.x,y:e.y,z:e.z})},i.DOFConstraint.prototype.setAngularLowerLimit=function(e){this.scene.execute("dof_setAngularLowerLimit",{constraint:this.id,x:e.x,y:e.y,z:e.z})},i.DOFConstraint.prototype.setAngularUpperLimit=function(e){this.scene.execute
-("dof_setAngularUpperLimit",{constraint:this.id,x:e.x,y:e.y,z:e.z})},i.DOFConstraint.prototype.enableAngularMotor=function(e){this.scene.execute("dof_enableAngularMotor",{constraint:this.id,which:e})},i.DOFConstraint.prototype.configureAngularMotor=function(e,t,n,r,i){this.scene.execute("dof_configureAngularMotor",{constraint:this.id,which:e,low_angle:t,high_angle:n,velocity:r,max_force:i})},i.DOFConstraint.prototype.disableAngularMotor=function(e){this.scene.execute("dof_disableAngularMotor",{constraint:this.id,which:e})},i.Scene=function(e){var t=this;s.call(this),THREE.Scene.call(this),this._worker=new Worker(i.scripts.worker||"physijs_worker.js"),this._materials={},this._objects={},this._vehicles={},this._constraints={},this._worker.onmessage=function(e){var n;if(e.data instanceof Float32Array)switch(e.data[0]){case g.WORLDREPORT:t._updateScene(e.data);break;case g.COLLISIONREPORT:t._updateCollisions(e.data);break;case g.VEHICLEREPORT:t._updateVehicles(e.data);break;case g.CONSTRAINTREPORT:t._updateConstraints
-(e.data)}else if(e.data.cmd)switch(e.data.cmd){case"objectReady":n=e.data.params,t._objects[n]&&t._objects[n].dispatchEvent("ready");break;case"worldReady":t.dispatchEvent("ready");break;case"vehicle":window.test=e.data;break;default:console.debug("Received: "+e.data.cmd),console.dir(e.data.params)}else switch(e.data[0]){case g.WORLDREPORT:t._updateScene(e.data);break;case g.COLLISIONREPORT:t._updateCollisions(e.data);break;case g.VEHICLEREPORT:t._updateVehicles(e.data);break;case g.CONSTRAINTREPORT:t._updateConstraints(e.data)}},e=e||{},e.ammo=i.scripts.ammo||"ammo.js",e.fixedTimeStep=e.fixedTimeStep||1/60,e.rateLimit=e.rateLimit||!0,this.execute("init",e)},i.Scene.prototype=new THREE.Scene,i.Scene.prototype.constructor=i.Scene,s.make(i.Scene),i.Scene.prototype._updateScene=function(e){var t=e[1],r,i,s;for(i=0;i<t;i++){s=2+i*y,r=this._objects[e[s]];if(r===undefined)continue;r.__dirtyPosition===!1&&r.position.set(e[s+1],e[s+2],e[s+3]),r.__dirtyRotation===!1&&(r.useQuaternion?r.quaternion.set(e[s+4],e[s+5],e[s+6
-],e[s+7]):r.rotation=u(e[s+4],e[s+5],e[s+6],e[s+7])),r._physijs.linearVelocity.set(e[s+8],e[s+9],e[s+10]),r._physijs.angularVelocity.set(e[s+11],e[s+12],e[s+13])}this._worker.webkitPostMessage&&this._worker.webkitPostMessage(e,[e.buffer]),n=!1,this.dispatchEvent("update")},i.Scene.prototype._updateVehicles=function(e){var t,n,r,i;for(r=0;r<(e.length-1)/b;r++){i=1+r*b,t=this._vehicles[e[i]];if(t===undefined)continue;n=t.wheels[e[i+1]],n.position.set(e[i+2],e[i+3],e[i+4]),n.useQuaternion?n.quaternion.set(e[i+5],e[i+6],e[i+7],e[i+8]):n.rotation=u(e[i+5],e[i+6],e[i+7],e[i+8])}this._worker.webkitPostMessage&&this._worker.webkitPostMessage(e,[e.buffer])},i.Scene.prototype._updateConstraints=function(e){var t,n,r,i;for(r=0;r<(e.length-1)/w;r++){i=1+r*w,t=this._constraints[e[i]],n=this._objects[e[i+1]];if(t===undefined||n===undefined)continue;p.set(e[i+2],e[i+3],e[i+4]),v.extractRotation(n.matrix),v.multiplyVector3(p),t.positiona.add(n.position,p),t.appliedImpulse=e[i+5]}this._worker.webkitPostMessage&&this._worker.webkitPostMessage
-(e,[e.buffer])},i.Scene.prototype._updateCollisions=function(e){var t,n,r,i,s,o={},u=[];for(t=0;t<e[1];t++)r=2+t*2,i=e[r],s=e[r+1],o[i]||(o[i]=[]),o[i].push(s);for(i in this._objects){if(!this._objects.hasOwnProperty(i))return;i=this._objects[i];if(o[i._physijs.id]){u.length=0;for(n=0;n<o[i._physijs.id].length;n++)s=this._objects[o[i._physijs.id][n]],i._physijs.touches.indexOf(s._physijs.id)===-1&&(i._physijs.touches.push(s._physijs.id),p.sub(i.getLinearVelocity(),s.getLinearVelocity()),c=p.clone(),p.sub(i.getAngularVelocity(),s.getAngularVelocity()),h=p,i.dispatchEvent("collision",s,c,h),s.dispatchEvent("collision",i,c,h)),u.push(s._physijs.id);for(n=0;n<i._physijs.touches.length;n++)u.indexOf(i._physijs.touches[n])===-1&&i._physijs.touches.splice(n--,1)}else i._physijs.touches.length=0}this._worker.webkitPostMessage&&this._worker.webkitPostMessage(e,[e.buffer])},i.Scene.prototype.addConstraint=function(e,t){this._constraints[e.id]=e,this.execute("addConstraint",e.getDefinition());if(t){var n;switch(e.type){case"point"
-:n=new THREE.Mesh(new THREE.SphereGeometry(1.5),new THREE.MeshNormalMaterial),n.position.copy(e.positiona),this._objects[e.objecta].add(n);break;case"hinge":n=new THREE.Mesh(new THREE.SphereGeometry(1.5),new THREE.MeshNormalMaterial),n.position.copy(e.positiona),this._objects[e.objecta].add(n);break;case"slider":n=new THREE.Mesh(new THREE.CubeGeometry(10,1,1),new THREE.MeshNormalMaterial),n.position.copy(e.positiona),n.rotation.set(e.axis.y,e.axis.x,e.axis.z),this._objects[e.objecta].add(n);break;case"conetwist":n=new THREE.Mesh(new THREE.SphereGeometry(1.5),new THREE.MeshNormalMaterial),n.position.copy(e.positiona),this._objects[e.objecta].add(n);break;case"dof":n=new THREE.Mesh(new THREE.SphereGeometry(1.5),new THREE.MeshNormalMaterial),n.position.copy(e.positiona),this._objects[e.objecta].add(n)}}return e},i.Scene.prototype.removeConstraint=function(e){this._constraints[e.id]!==undefined&&(this.execute("removeConstraint",{id:e.id}),delete this._constraints[e.id])},i.Scene.prototype.execute=function(e,t){this
-._worker.postMessage({cmd:e,params:t})},l=function(e,t){var n;for(n=0;n<t.children.length;n++)t.children[n]._physijs&&(t.children[n].updateMatrix(),t.children[n].updateMatrixWorld(),p.getPositionFromMatrix(t.children[n].matrixWorld),m.setFromRotationMatrix(t.children[n].matrixWorld),t.children[n]._physijs.position_offset={x:p.x,y:p.y,z:p.z},t.children[n]._physijs.rotation={x:m.x,y:m.y,z:m.z,w:m.w},e._physijs.children.push(t.children[n]._physijs)),l(e,t.children[n])},i.Scene.prototype.add=function(e){THREE.Mesh.prototype.add.call(this,e);if(e._physijs){e.world=this;if(e instanceof i.Vehicle)this.add(e.mesh),this._vehicles[e._physijs.id]=e,this.execute("addVehicle",e._physijs);else{e.__dirtyPosition=!1,e.__dirtyRotation=!1,this._objects[e._physijs.id]=e,e.children.length&&(e._physijs.children=[],l(e,e)),e.material._physijs&&(this._materials.hasOwnProperty(e.material._physijs.id)||(this.execute("registerMaterial",e.material._physijs),e._physijs.materialId=e.material._physijs.id)),e._physijs.position={x:e.position
-.x,y:e.position.y,z:e.position.z},e.useQuaternion||(t.identity().setRotationFromEuler(e.rotation),e.quaternion.setFromRotationMatrix(t)),e._physijs.rotation={x:e.quaternion.x,y:e.quaternion.y,z:e.quaternion.z,w:e.quaternion.w};var n=new THREE.Vector3(1,1,1);e._physijs.width&&(e._physijs.width*=e.scale.x),e._physijs.height&&(e._physijs.height*=e.scale.y),e._physijs.depth&&(e._physijs.depth*=e.scale.z),this.execute("addObject",e._physijs)}}},i.Scene.prototype.remove=function(e){if(e instanceof i.Vehicle){this.execute("removeVehicle",{id:e._physijs.id});while(e.wheels.length)this.remove(e.wheels.pop());this.remove(e.mesh),delete this._vehicles[e._physijs.id]}else THREE.Mesh.prototype.remove.call(this,e),e._physijs&&(delete this._objects[e._physijs.id],this.execute("removeObject",{id:e._physijs.id}))},i.Scene.prototype.setFixedTimeStep=function(e){e&&this.execute("setFixedTimeStep",e)},i.Scene.prototype.setGravity=function(e){e&&this.execute("setGravity",e)},i.Scene.prototype.simulate=function(e,r){var i,s,o;if(n)
-return!1;n=!0;for(i in this._objects){if(!this._objects.hasOwnProperty(i))continue;s=this._objects[i];if(s.__dirtyPosition||s.__dirtyRotation)o={id:s._physijs.id},s.__dirtyPosition&&(o.pos={x:s.position.x,y:s.position.y,z:s.position.z},s.__dirtyPosition=!1),s.__dirtyRotation&&(s.useQuaternion||(t.identity().setRotationFromEuler(s.rotation),s.quaternion.setFromRotationMatrix(t)),o.quat={x:s.quaternion.x,y:s.quaternion.y,z:s.quaternion.z,w:s.quaternion.w},s.__dirtyRotation=!1),this.execute("updateTransform",o)}return this.execute("simulate",{timeStep:e,maxSubSteps:r}),!0},i.Mesh=function(e,t,n){var r;if(!e)return;s.call(this),THREE.Mesh.call(this,e,t),e.boundingBox||e.computeBoundingBox(),this._physijs={type:null,id:o(),mass:n||0,touches:[],linearVelocity:new THREE.Vector3,angularVelocity:new THREE.Vector3}},i.Mesh.prototype=new THREE.Mesh,i.Mesh.prototype.constructor=i.Mesh,s.make(i.Mesh),i.Mesh.prototype.__defineGetter__("mass",function(){return this._physijs.mass}),i.Mesh.prototype.__defineSetter__("mass",function(
-e){this._physijs.mass=e,this.world&&this.world.execute("updateMass",{id:this._physijs.id,mass:e})}),i.Mesh.prototype.applyCentralImpulse=function(e){this.world&&this.world.execute("applyCentralImpulse",{id:this._physijs.id,x:e.x,y:e.y,z:e.z})},i.Mesh.prototype.applyImpulse=function(e,t){this.world&&this.world.execute("applyImpulse",{id:this._physijs.id,impulse_x:e.x,impulse_y:e.y,impulse_z:e.z,x:t.x,y:t.y,z:t.z})},i.Mesh.prototype.applyCentralForce=function(e){this.world&&this.world.execute("applyCentralForce",{id:this._physijs.id,x:e.x,y:e.y,z:e.z})},i.Mesh.prototype.applyForce=function(e,t){this.world&&this.world.execute("applyForce",{id:this._physijs.id,force_x:e.x,force_y:e.y,force_z:e.z,x:t.x,y:t.y,z:t.z})},i.Mesh.prototype.getAngularVelocity=function(){return this._physijs.angularVelocity},i.Mesh.prototype.setAngularVelocity=function(e){this.world&&this.world.execute("setAngularVelocity",{id:this._physijs.id,x:e.x,y:e.y,z:e.z})},i.Mesh.prototype.getLinearVelocity=function(){return this._physijs.linearVelocity
-},i.Mesh.prototype.setLinearVelocity=function(e){this.world&&this.world.execute("setLinearVelocity",{id:this._physijs.id,x:e.x,y:e.y,z:e.z})},i.Mesh.prototype.setAngularFactor=function(e){this.world&&this.world.execute("setAngularFactor",{id:this._physijs.id,x:e.x,y:e.y,z:e.z})},i.Mesh.prototype.setLinearFactor=function(e){this.world&&this.world.execute("setLinearFactor",{id:this._physijs.id,x:e.x,y:e.y,z:e.z})},i.Mesh.prototype.setDamping=function(e,t){this.world&&this.world.execute("setDamping",{id:this._physijs.id,linear:e,angular:t})},i.Mesh.prototype.setCcdMotionThreshold=function(e){this.world&&this.world.execute("setCcdMotionThreshold",{id:this._physijs.id,threshold:e})},i.Mesh.prototype.setCcdSweptSphereRadius=function(e){this.world&&this.world.execute("setCcdSweptSphereRadius",{id:this._physijs.id,radius:e})},i.PlaneMesh=function(e,t,n){var r,s;i.Mesh.call(this,e,t,n),e.boundingBox||e.computeBoundingBox(),r=e.boundingBox.max.x-e.boundingBox.min.x,s=e.boundingBox.max.y-e.boundingBox.min.y,this._physijs
-.type="plane",this._physijs.normal=e.faces[0].normal.clone(),this._physijs.mass=typeof n=="undefined"?r*s:n},i.PlaneMesh.prototype=new i.Mesh,i.PlaneMesh.prototype.constructor=i.PlaneMesh,i.HeightfieldMesh=function(e,t,n,r,s){i.Mesh.call(this,e,t,n),this._physijs.type="heightfield",this._physijs.xsize=e.boundingBox.max.x-e.boundingBox.min.x,this._physijs.ysize=e.boundingBox.max.y-e.boundingBox.min.y,this._physijs.xpts=typeof r=="undefined"?Math.sqrt(e.vertices.length):r+1,this._physijs.ypts=typeof s=="undefined"?Math.sqrt(e.vertices.length):s+1,this._physijs.absMaxHeight=Math.max(e.boundingBox.max.z,Math.abs(e.boundingBox.min.z));var o=[],u,a;for(var f=0;f<e.vertices.length;f++)u=f%this._physijs.xpts,a=Math.round(f/this._physijs.xpts-f%this._physijs.xpts/this._physijs.xpts),o[f]=e.vertices[u+(this._physijs.ypts-a-1)*this._physijs.ypts].z;this._physijs.points=o},i.HeightfieldMesh.prototype=new i.Mesh,i.HeightfieldMesh.prototype.constructor=i.HeightfieldMesh,i.BoxMesh=function(e,t,n){var r,s,o;i.Mesh.call(this,e
-,t,n),e.boundingBox||e.computeBoundingBox(),r=e.boundingBox.max.x-e.boundingBox.min.x,s=e.boundingBox.max.y-e.boundingBox.min.y,o=e.boundingBox.max.z-e.boundingBox.min.z,this._physijs.type="box",this._physijs.width=r,this._physijs.height=s,this._physijs.depth=o,this._physijs.mass=typeof n=="undefined"?r*s*o:n},i.BoxMesh.prototype=new i.Mesh,i.BoxMesh.prototype.constructor=i.BoxMesh,i.SphereMesh=function(e,t,n){i.Mesh.call(this,e,t,n),e.boundingSphere||e.computeBoundingSphere(),this._physijs.type="sphere",this._physijs.radius=e.boundingSphere.radius,this._physijs.mass=typeof n=="undefined"?4/3*Math.PI*Math.pow(this._physijs.radius,3):n},i.SphereMesh.prototype=new i.Mesh,i.SphereMesh.prototype.constructor=i.SphereMesh,i.CylinderMesh=function(e,t,n){var r,s,o;i.Mesh.call(this,e,t,n),e.boundingBox||e.computeBoundingBox(),r=e.boundingBox.max.x-e.boundingBox.min.x,s=e.boundingBox.max.y-e.boundingBox.min.y,o=e.boundingBox.max.z-e.boundingBox.min.z,this._physijs.type="cylinder",this._physijs.width=r,this._physijs.height=
-s,this._physijs.depth=o,this._physijs.mass=typeof n=="undefined"?r*s*o:n},i.CylinderMesh.prototype=new i.Mesh,i.CylinderMesh.prototype.constructor=i.CylinderMesh,i.CapsuleMesh=function(e,t,n){var r,s,o;i.Mesh.call(this,e,t,n),e.boundingBox||e.computeBoundingBox(),r=e.boundingBox.max.x-e.boundingBox.min.x,s=e.boundingBox.max.y-e.boundingBox.min.y,o=e.boundingBox.max.z-e.boundingBox.min.z,this._physijs.type="capsule",this._physijs.radius=Math.max(r/2,o/2),this._physijs.height=s,this._physijs.mass=typeof n=="undefined"?r*s*o:n},i.CapsuleMesh.prototype=new i.Mesh,i.CapsuleMesh.prototype.constructor=i.CapsuleMesh,i.ConeMesh=function(e,t,n){var r,s,o;i.Mesh.call(this,e,t,n),e.boundingBox||e.computeBoundingBox(),r=e.boundingBox.max.x-e.boundingBox.min.x,s=e.boundingBox.max.y-e.boundingBox.min.y,this._physijs.type="cone",this._physijs.radius=r/2,this._physijs.height=s,this._physijs.mass=typeof n=="undefined"?r*s:n},i.ConeMesh.prototype=new i.Mesh,i.ConeMesh.prototype.constructor=i.ConeMesh,i.ConcaveMesh=function(e,t,n
-){var r,s,o,u,a,f,l=[];i.Mesh.call(this,e,t,n),e.boundingBox||e.computeBoundingBox(),a=e.vertices;for(r=0;r<e.faces.length;r++)f=e.faces[r],f instanceof THREE.Face3?l.push([{x:a[f.a].x,y:a[f.a].y,z:a[f.a].z},{x:a[f.b].x,y:a[f.b].y,z:a[f.b].z},{x:a[f.c].x,y:a[f.c].y,z:a[f.c].z}]):f instanceof THREE.Face4&&(l.push([{x:a[f.a].x,y:a[f.a].y,z:a[f.a].z},{x:a[f.b].x,y:a[f.b].y,z:a[f.b].z},{x:a[f.d].x,y:a[f.d].y,z:a[f.d].z}]),l.push([{x:a[f.b].x,y:a[f.b].y,z:a[f.b].z},{x:a[f.c].x,y:a[f.c].y,z:a[f.c].z},{x:a[f.d].x,y:a[f.d].y,z:a[f.d].z}]));s=e.boundingBox.max.x-e.boundingBox.min.x,o=e.boundingBox.max.y-e.boundingBox.min.y,u=e.boundingBox.max.z-e.boundingBox.min.z,this._physijs.type="concave",this._physijs.triangles=l,this._physijs.mass=typeof n=="undefined"?s*o*u:n},i.ConcaveMesh.prototype=new i.Mesh,i.ConcaveMesh.prototype.constructor=i.ConcaveMesh,i.ConvexMesh=function(t,n,r){var s,o,u,a,f=[];i.Mesh.call(this,t,n,r),t.boundingBox||t.computeBoundingBox();for(s=0;s<t.vertices.length;s++)e>=49?f.push({x:t.vertices[s].x
-,y:t.vertices[s].y,z:t.vertices[s].z}):f.push({x:t.vertices[s].position.x,y:t.vertices[s].position.y,z:t.vertices[s].position.z});o=t.boundingBox.max.x-t.boundingBox.min.x,u=t.boundingBox.max.y-t.boundingBox.min.y,a=t.boundingBox.max.z-t.boundingBox.min.z,this._physijs.type="convex",this._physijs.points=f,this._physijs.mass=typeof r=="undefined"?o*u*a:r},i.ConvexMesh.prototype=new i.Mesh,i.ConvexMesh.prototype.constructor=i.ConvexMesh,i.Vehicle=function(e,t){t=t||new i.VehicleTuning,this.mesh=e,this.wheels=[],this._physijs={id:o(),rigidBody:e._physijs.id,suspension_stiffness:t.suspension_stiffness,suspension_compression:t.suspension_compression,suspension_damping:t.suspension_damping,max_suspension_travel:t.max_suspension_travel,friction_slip:t.friction_slip,max_suspension_force:t.max_suspension_force}},i.Vehicle.prototype.addWheel=function(e,t,n,r,i,s,o,u,a){var f=new THREE.Mesh(e,t);f.castShadow=f.receiveShadow=!0,f.position.copy(r).multiplyScalar(s/100).addSelf(n),this.world.add(f),this.wheels.push(f),this.
-world.execute("addWheel",{id:this._physijs.id,connection_point:{x:n.x,y:n.y,z:n.z},wheel_direction:{x:r.x,y:r.y,z:r.z},wheel_axle:{x:i.x,y:i.y,z:i.z},suspension_rest_length:s,wheel_radius:o,is_front_wheel:u,tuning:a})},i.Vehicle.prototype.setSteering=function(e,t){if(t!==undefined&&this.wheels[t]!==undefined)this.world.execute("setSteering",{id:this._physijs.id,wheel:t,steering:e});else if(this.wheels.length>0)for(var n=0;n<this.wheels.length;n++)this.world.execute("setSteering",{id:this._physijs.id,wheel:n,steering:e})},i.Vehicle.prototype.setBrake=function(e,t){if(t!==undefined&&this.wheels[t]!==undefined)this.world.execute("setBrake",{id:this._physijs.id,wheel:t,brake:e});else if(this.wheels.length>0)for(var n=0;n<this.wheels.length;n++)this.world.execute("setBrake",{id:this._physijs.id,wheel:n,brake:e})},i.Vehicle.prototype.applyEngineForce=function(e,t){if(t!==undefined&&this.wheels[t]!==undefined)this.world.execute("applyEngineForce",{id:this._physijs.id,wheel:t,force:e});else if(this.wheels.length>0)for(
-var n=0;n<this.wheels.length;n++)this.world.execute("applyEngineForce",{id:this._physijs.id,wheel:n,force:e})},i.VehicleTuning=function(e,t,n,r,i,s){this.suspension_stiffness=e!==undefined?e:5.88,this.suspension_compression=t!==undefined?t:.83,this.suspension_damping=n!==undefined?n:.88,this.max_suspension_travel=r!==undefined?r:500,this.friction_slip=i!==undefined?i:10.5,this.max_suspension_force=s!==undefined?s:6e3},i}();
+parseInt(THREE.REVISION,10),t,n=new THREE.Matrix4,r=!1,i=s,s={},o,u,a,f,l,c,h,p,d=new THREE.Vector3,v=new THREE.Vector3,m=new THREE.Matrix4,g=new THREE.Quaternion,y={WORLDREPORT:0,COLLISIONREPORT:1,VEHICLEREPORT:2,CONSTRAINTREPORT:3},b=14,w=9,E=6;return s.scripts={},o=function(){this._eventListeners={}},o.prototype.addEventListener=function(e,t){this._eventListeners.hasOwnProperty(e)||(this._eventListeners[e]=[]),this._eventListeners[e].push(t)},o.prototype.removeEventListener=function(e,t){var n;return this._eventListeners.hasOwnProperty(e)?(n=this._eventListeners[e].indexOf(t))>=0?(this._eventListeners[e].splice(n,1),!0):!1:!1},o.prototype.dispatchEvent=function(e){var t,n=Array.prototype.splice.call(arguments,1);if(this._eventListeners.hasOwnProperty(e))for(t=0;t<this._eventListeners[e].length;t++)this._eventListeners[e][t].apply(this,n)},o.make=function(e){e.prototype.addEventListener=o.prototype.addEventListener,e.prototype.removeEventListener=o.prototype.removeEventListener,e.prototype.dispatchEvent=o.prototype
+.dispatchEvent},u=function(){var e=0;return function(){return e++}}(),a=function(e,t,n,r){return new THREE.Vector3(Math.atan2(2*(e*r-t*n),r*r-e*e-t*t+n*n),Math.asin(2*(e*n+t*r)),Math.atan2(2*(n*r-e*t),r*r+e*e-t*t-n*n))},f=function(e,t,n){var r,i,s,o,u,a,f,l;return r=Math.cos(t),i=Math.sin(t),s=Math.cos(-n),o=Math.sin(-n),u=Math.cos(e),a=Math.sin(e),f=r*s,l=i*o,{w:f*u-l*a,x:f*a+l*u,y:i*s*u+r*o*a,z:r*o*u-i*s*a}},l=function(e,t){return m.identity(),t.useQuaternion?m.identity().setRotationFromQuaternion(t.quaternion):m.identity().setRotationFromEuler(t.rotation),m.getInverse(m),d.copy(e),v.copy(t.position),m.multiplyVector3(d.subSelf(v))},s.noConflict=function(){return window.Physijs=i,s},s.createMaterial=function(e,t,n){var r=function(){};return r.prototype=e,r=new r,r._physijs={id:e.id,friction:t===undefined?.8:t,restitution:n===undefined?.2:n},r},s.PointConstraint=function(e,t,n){n===undefined&&(n=t,t=undefined),this.type="point",this.appliedImpulse=0,this.id=u(),this.objecta=e._physijs.id,this.positiona=l(n,e)
+.clone(),t&&(this.objectb=t._physijs.id,this.positionb=l(n,t).clone())},s.PointConstraint.prototype.getDefinition=function(){return{type:this.type,id:this.id,objecta:this.objecta,objectb:this.objectb,positiona:this.positiona,positionb:this.positionb}},s.HingeConstraint=function(e,t,n,r){r===undefined&&(r=n,n=t,t=undefined),this.type="hinge",this.appliedImpulse=0,this.id=u(),this.scene=e.parent,this.objecta=e._physijs.id,this.positiona=l(n,e).clone(),this.position=n.clone(),this.axis=r,t&&(this.objectb=t._physijs.id,this.positionb=l(n,t).clone())},s.HingeConstraint.prototype.getDefinition=function(){return{type:this.type,id:this.id,objecta:this.objecta,objectb:this.objectb,positiona:this.positiona,positionb:this.positionb,axis:this.axis}},s.HingeConstraint.prototype.setLimits=function(e,t,n,r){this.scene.execute("hinge_setLimits",{constraint:this.id,low:e,high:t,bias_factor:n,relaxation_factor:r})},s.HingeConstraint.prototype.enableAngularMotor=function(e,t){this.scene.execute("hinge_enableAngularMotor",{constraint
+:this.id,velocity:e,acceleration:t})},s.HingeConstraint.prototype.disableMotor=function(e,t){this.scene.execute("hinge_disableMotor",{constraint:this.id})},s.SliderConstraint=function(e,t,n,r){r===undefined&&(r=n,n=t,t=undefined),this.type="slider",this.appliedImpulse=0,this.id=u(),this.scene=e.parent,this.objecta=e._physijs.id,this.positiona=l(n,e).clone(),this.axis=r,t&&(this.objectb=t._physijs.id,this.positionb=l(n,t).clone())},s.SliderConstraint.prototype.getDefinition=function(){return{type:this.type,id:this.id,objecta:this.objecta,objectb:this.objectb,positiona:this.positiona,positionb:this.positionb,axis:this.axis}},s.SliderConstraint.prototype.setLimits=function(e,t,n,r){this.scene.execute("slider_setLimits",{constraint:this.id,lin_lower:e,lin_upper:t,ang_lower:n,ang_upper:r})},s.SliderConstraint.prototype.setRestitution=function(e,t){this.scene.execute("slider_setRestitution",{constraint:this.id,linear:e,angular:t})},s.SliderConstraint.prototype.enableLinearMotor=function(e,t){this.scene.execute("slider_enableLinearMotor"
+,{constraint:this.id,velocity:e,acceleration:t})},s.SliderConstraint.prototype.disableLinearMotor=function(){this.scene.execute("slider_disableLinearMotor",{constraint:this.id})},s.SliderConstraint.prototype.enableAngularMotor=function(e,t){this.scene.execute("slider_enableAngularMotor",{constraint:this.id,velocity:e,acceleration:t})},s.SliderConstraint.prototype.disableAngularMotor=function(){this.scene.execute("slider_disableAngularMotor",{constraint:this.id})},s.ConeTwistConstraint=function(e,t,n){if(n===undefined)throw"Both objects must be defined in a ConeTwistConstraint.";this.type="conetwist",this.appliedImpulse=0,this.id=u(),this.scene=e.parent,this.objecta=e._physijs.id,this.positiona=l(n,e).clone(),this.objectb=t._physijs.id,this.positionb=l(n,t).clone(),this.axisa={x:e.rotation.x,y:e.rotation.y,z:e.rotation.z},this.axisb={x:t.rotation.x,y:t.rotation.y,z:t.rotation.z}},s.ConeTwistConstraint.prototype.getDefinition=function(){return{type:this.type,id:this.id,objecta:this.objecta,objectb:this.objectb,positiona
+:this.positiona,positionb:this.positionb,axisa:this.axisa,axisb:this.axisb}},s.ConeTwistConstraint.prototype.setLimit=function(e,t,n){this.scene.execute("conetwist_setLimit",{constraint:this.id,x:e,y:t,z:n})},s.ConeTwistConstraint.prototype.enableMotor=function(){this.scene.execute("conetwist_enableMotor",{constraint:this.id})},s.ConeTwistConstraint.prototype.setMaxMotorImpulse=function(e){this.scene.execute("conetwist_setMaxMotorImpulse",{constraint:this.id,max_impulse:e})},s.ConeTwistConstraint.prototype.setMotorTarget=function(e){if(e instanceof THREE.Vector3)throw"Wait for Three.js r50 to setMotorTarget from Vector3 - use Matrix4 or Quaternion instead";e instanceof THREE.Matrix4&&(e=(new THREE.Quaternion).setFromRotationMatrix(e)),this.scene.execute("conetwist_setMotorTarget",{constraint:this.id,x:e.x,y:e.y,z:e.z,w:e.w})},s.ConeTwistConstraint.prototype.disableMotor=function(){this.scene.execute("conetwist_disableMotor",{constraint:this.id})},s.DOFConstraint=function(e,t,n){n===undefined&&(n=t,t=undefined)
+,this.type="dof",this.appliedImpulse=0,this.id=u(),this.scene=e.parent,this.objecta=e._physijs.id,this.positiona=l(n,e).clone(),this.axisa={x:e.rotation.x,y:e.rotation.y,z:e.rotation.z},t&&(this.objectb=t._physijs.id,this.positionb=l(n,t).clone(),this.axisb={x:t.rotation.x,y:t.rotation.y,z:t.rotation.z})},s.DOFConstraint.prototype.getDefinition=function(){return{type:this.type,id:this.id,objecta:this.objecta,objectb:this.objectb,positiona:this.positiona,positionb:this.positionb,axisa:this.axisa,axisb:this.axisb}},s.DOFConstraint.prototype.setLinearLowerLimit=function(e){this.scene.execute("dof_setLinearLowerLimit",{constraint:this.id,x:e.x,y:e.y,z:e.z})},s.DOFConstraint.prototype.setLinearUpperLimit=function(e){this.scene.execute("dof_setLinearUpperLimit",{constraint:this.id,x:e.x,y:e.y,z:e.z})},s.DOFConstraint.prototype.setAngularLowerLimit=function(e){this.scene.execute("dof_setAngularLowerLimit",{constraint:this.id,x:e.x,y:e.y,z:e.z})},s.DOFConstraint.prototype.setAngularUpperLimit=function(e){this.scene.execute
+("dof_setAngularUpperLimit",{constraint:this.id,x:e.x,y:e.y,z:e.z})},s.DOFConstraint.prototype.enableAngularMotor=function(e){this.scene.execute("dof_enableAngularMotor",{constraint:this.id,which:e})},s.DOFConstraint.prototype.configureAngularMotor=function(e,t,n,r,i){this.scene.execute("dof_configureAngularMotor",{constraint:this.id,which:e,low_angle:t,high_angle:n,velocity:r,max_force:i})},s.DOFConstraint.prototype.disableAngularMotor=function(e){this.scene.execute("dof_disableAngularMotor",{constraint:this.id,which:e})},s.Scene=function(e){var n=this;o.call(this),THREE.Scene.call(this),this._worker=new Worker(s.scripts.worker||"physijs_worker.js"),this._worker.transferableMessage=this._worker.webkitPostMessage||this._worker.postMessage,this._materials={},this._objects={},this._vehicles={},this._constraints={};var r=new ArrayBuffer(1);this._worker.transferableMessage(r,[r]),t=r.byteLength===0,this._worker.onmessage=function(e){var t,r=e.data;r instanceof ArrayBuffer&&r.byteLength!==1&&(r=new Float32Array(r))
+;if(r instanceof Float32Array)switch(r[0]){case y.WORLDREPORT:n._updateScene(r);break;case y.COLLISIONREPORT:n._updateCollisions(r);break;case y.VEHICLEREPORT:n._updateVehicles(r);break;case y.CONSTRAINTREPORT:n._updateConstraints(r)}else if(r.cmd)switch(r.cmd){case"objectReady":t=r.params,n._objects[t]&&n._objects[t].dispatchEvent("ready");break;case"worldReady":n.dispatchEvent("ready");break;case"vehicle":window.test=r;break;default:console.debug("Received: "+r.cmd),console.dir(r.params)}else switch(r[0]){case y.WORLDREPORT:n._updateScene(r);break;case y.COLLISIONREPORT:n._updateCollisions(r);break;case y.VEHICLEREPORT:n._updateVehicles(r);break;case y.CONSTRAINTREPORT:n._updateConstraints(r)}},e=e||{},e.ammo=s.scripts.ammo||"ammo.js",e.fixedTimeStep=e.fixedTimeStep||1/60,e.rateLimit=e.rateLimit||!0,this.execute("init",e)},s.Scene.prototype=new THREE.Scene,s.Scene.prototype.constructor=s.Scene,o.make(s.Scene),s.Scene.prototype._updateScene=function(e){var n=e[1],i,s,o;for(s=0;s<n;s++){o=2+s*b,i=this._objects
+[e[o]];if(i===undefined)continue;i.__dirtyPosition===!1&&i.position.set(e[o+1],e[o+2],e[o+3]),i.__dirtyRotation===!1&&(i.useQuaternion?i.quaternion.set(e[o+4],e[o+5],e[o+6],e[o+7]):i.rotation=a(e[o+4],e[o+5],e[o+6],e[o+7])),i._physijs.linearVelocity.set(e[o+8],e[o+9],e[o+10]),i._physijs.angularVelocity.set(e[o+11],e[o+12],e[o+13])}t&&this._worker.transferableMessage(e.buffer,[e.buffer]),r=!1,this.dispatchEvent("update")},s.Scene.prototype._updateVehicles=function(e){var n,r,i,s;for(i=0;i<(e.length-1)/w;i++){s=1+i*w,n=this._vehicles[e[s]];if(n===undefined)continue;r=n.wheels[e[s+1]],r.position.set(e[s+2],e[s+3],e[s+4]),r.useQuaternion?r.quaternion.set(e[s+5],e[s+6],e[s+7],e[s+8]):r.rotation=a(e[s+5],e[s+6],e[s+7],e[s+8])}t&&this._worker.transferableMessage(e.buffer,[e.buffer])},s.Scene.prototype._updateConstraints=function(e){var n,r,i,s;for(i=0;i<(e.length-1)/E;i++){s=1+i*E,n=this._constraints[e[s]],r=this._objects[e[s+1]];if(n===undefined||r===undefined)continue;d.set(e[s+2],e[s+3],e[s+4]),m.extractRotation(r
+.matrix),m.multiplyVector3(d),n.positiona.add(r.position,d),n.appliedImpulse=e[s+5]}t&&this._worker.transferableMessage(e.buffer,[e.buffer])},s.Scene.prototype._updateCollisions=function(e){var n,r,i,s,o,u={},a=[];for(n=0;n<e[1];n++)i=2+n*2,s=e[i],o=e[i+1],u[s]||(u[s]=[]),u[s].push(o);for(s in this._objects){if(!this._objects.hasOwnProperty(s))return;s=this._objects[s];if(u[s._physijs.id]){a.length=0;for(r=0;r<u[s._physijs.id].length;r++)o=this._objects[u[s._physijs.id][r]],s._physijs.touches.indexOf(o._physijs.id)===-1&&(s._physijs.touches.push(o._physijs.id),d.sub(s.getLinearVelocity(),o.getLinearVelocity()),h=d.clone(),d.sub(s.getAngularVelocity(),o.getAngularVelocity()),p=d,s.dispatchEvent("collision",o,h,p),o.dispatchEvent("collision",s,h,p)),a.push(o._physijs.id);for(r=0;r<s._physijs.touches.length;r++)a.indexOf(s._physijs.touches[r])===-1&&s._physijs.touches.splice(r--,1)}else s._physijs.touches.length=0}t&&this._worker.transferableMessage(e.buffer,[e.buffer])},s.Scene.prototype.addConstraint=function(e
+,t){this._constraints[e.id]=e,this.execute("addConstraint",e.getDefinition());if(t){var n;switch(e.type){case"point":n=new THREE.Mesh(new THREE.SphereGeometry(1.5),new THREE.MeshNormalMaterial),n.position.copy(e.positiona),this._objects[e.objecta].add(n);break;case"hinge":n=new THREE.Mesh(new THREE.SphereGeometry(1.5),new THREE.MeshNormalMaterial),n.position.copy(e.positiona),this._objects[e.objecta].add(n);break;case"slider":n=new THREE.Mesh(new THREE.CubeGeometry(10,1,1),new THREE.MeshNormalMaterial),n.position.copy(e.positiona),n.rotation.set(e.axis.y,e.axis.x,e.axis.z),this._objects[e.objecta].add(n);break;case"conetwist":n=new THREE.Mesh(new THREE.SphereGeometry(1.5),new THREE.MeshNormalMaterial),n.position.copy(e.positiona),this._objects[e.objecta].add(n);break;case"dof":n=new THREE.Mesh(new THREE.SphereGeometry(1.5),new THREE.MeshNormalMaterial),n.position.copy(e.positiona),this._objects[e.objecta].add(n)}}return e},s.Scene.prototype.removeConstraint=function(e){this._constraints[e.id]!==undefined&&(this
+.execute("removeConstraint",{id:e.id}),delete this._constraints[e.id])},s.Scene.prototype.execute=function(e,t){this._worker.postMessage({cmd:e,params:t})},c=function(e,t){var n;for(n=0;n<t.children.length;n++)t.children[n]._physijs&&(t.children[n].updateMatrix(),t.children[n].updateMatrixWorld(),d.getPositionFromMatrix(t.children[n].matrixWorld),g.setFromRotationMatrix(t.children[n].matrixWorld),t.children[n]._physijs.position_offset={x:d.x,y:d.y,z:d.z},t.children[n]._physijs.rotation={x:g.x,y:g.y,z:g.z,w:g.w},e._physijs.children.push(t.children[n]._physijs)),c(e,t.children[n])},s.Scene.prototype.add=function(e){THREE.Mesh.prototype.add.call(this,e);if(e._physijs){e.world=this;if(e instanceof s.Vehicle)this.add(e.mesh),this._vehicles[e._physijs.id]=e,this.execute("addVehicle",e._physijs);else{e.__dirtyPosition=!1,e.__dirtyRotation=!1,this._objects[e._physijs.id]=e,e.children.length&&(e._physijs.children=[],c(e,e)),e.material._physijs&&(this._materials.hasOwnProperty(e.material._physijs.id)||(this.execute("registerMaterial"
+,e.material._physijs),e._physijs.materialId=e.material._physijs.id)),e._physijs.position={x:e.position.x,y:e.position.y,z:e.position.z},e.useQuaternion||(n.identity().setRotationFromEuler(e.rotation),e.quaternion.setFromRotationMatrix(n)),e._physijs.rotation={x:e.quaternion.x,y:e.quaternion.y,z:e.quaternion.z,w:e.quaternion.w};var t=new THREE.Vector3(1,1,1);e._physijs.width&&(e._physijs.width*=e.scale.x),e._physijs.height&&(e._physijs.height*=e.scale.y),e._physijs.depth&&(e._physijs.depth*=e.scale.z),this.execute("addObject",e._physijs)}}},s.Scene.prototype.remove=function(e){if(e instanceof s.Vehicle){this.execute("removeVehicle",{id:e._physijs.id});while(e.wheels.length)this.remove(e.wheels.pop());this.remove(e.mesh),delete this._vehicles[e._physijs.id]}else THREE.Mesh.prototype.remove.call(this,e),e._physijs&&(delete this._objects[e._physijs.id],this.execute("removeObject",{id:e._physijs.id}))},s.Scene.prototype.setFixedTimeStep=function(e){e&&this.execute("setFixedTimeStep",e)},s.Scene.prototype.setGravity=
+function(e){e&&this.execute("setGravity",e)},s.Scene.prototype.simulate=function(e,t){var i,s,o;if(r)return!1;r=!0;for(i in this._objects){if(!this._objects.hasOwnProperty(i))continue;s=this._objects[i];if(s.__dirtyPosition||s.__dirtyRotation)o={id:s._physijs.id},s.__dirtyPosition&&(o.pos={x:s.position.x,y:s.position.y,z:s.position.z},s.__dirtyPosition=!1),s.__dirtyRotation&&(s.useQuaternion||(n.identity().setRotationFromEuler(s.rotation),s.quaternion.setFromRotationMatrix(n)),o.quat={x:s.quaternion.x,y:s.quaternion.y,z:s.quaternion.z,w:s.quaternion.w},s.__dirtyRotation=!1),this.execute("updateTransform",o)}return this.execute("simulate",{timeStep:e,maxSubSteps:t}),!0},s.Mesh=function(e,t,n){var r;if(!e)return;o.call(this),THREE.Mesh.call(this,e,t),e.boundingBox||e.computeBoundingBox(),this._physijs={type:null,id:u(),mass:n||0,touches:[],linearVelocity:new THREE.Vector3,angularVelocity:new THREE.Vector3}},s.Mesh.prototype=new THREE.Mesh,s.Mesh.prototype.constructor=s.Mesh,o.make(s.Mesh),s.Mesh.prototype.__defineGetter__
+("mass",function(){return this._physijs.mass}),s.Mesh.prototype.__defineSetter__("mass",function(e){this._physijs.mass=e,this.world&&this.world.execute("updateMass",{id:this._physijs.id,mass:e})}),s.Mesh.prototype.applyCentralImpulse=function(e){this.world&&this.world.execute("applyCentralImpulse",{id:this._physijs.id,x:e.x,y:e.y,z:e.z})},s.Mesh.prototype.applyImpulse=function(e,t){this.world&&this.world.execute("applyImpulse",{id:this._physijs.id,impulse_x:e.x,impulse_y:e.y,impulse_z:e.z,x:t.x,y:t.y,z:t.z})},s.Mesh.prototype.applyCentralForce=function(e){this.world&&this.world.execute("applyCentralForce",{id:this._physijs.id,x:e.x,y:e.y,z:e.z})},s.Mesh.prototype.applyForce=function(e,t){this.world&&this.world.execute("applyForce",{id:this._physijs.id,force_x:e.x,force_y:e.y,force_z:e.z,x:t.x,y:t.y,z:t.z})},s.Mesh.prototype.getAngularVelocity=function(){return this._physijs.angularVelocity},s.Mesh.prototype.setAngularVelocity=function(e){this.world&&this.world.execute("setAngularVelocity",{id:this._physijs.id,
+x:e.x,y:e.y,z:e.z})},s.Mesh.prototype.getLinearVelocity=function(){return this._physijs.linearVelocity},s.Mesh.prototype.setLinearVelocity=function(e){this.world&&this.world.execute("setLinearVelocity",{id:this._physijs.id,x:e.x,y:e.y,z:e.z})},s.Mesh.prototype.setAngularFactor=function(e){this.world&&this.world.execute("setAngularFactor",{id:this._physijs.id,x:e.x,y:e.y,z:e.z})},s.Mesh.prototype.setLinearFactor=function(e){this.world&&this.world.execute("setLinearFactor",{id:this._physijs.id,x:e.x,y:e.y,z:e.z})},s.Mesh.prototype.setDamping=function(e,t){this.world&&this.world.execute("setDamping",{id:this._physijs.id,linear:e,angular:t})},s.Mesh.prototype.setCcdMotionThreshold=function(e){this.world&&this.world.execute("setCcdMotionThreshold",{id:this._physijs.id,threshold:e})},s.Mesh.prototype.setCcdSweptSphereRadius=function(e){this.world&&this.world.execute("setCcdSweptSphereRadius",{id:this._physijs.id,radius:e})},s.PlaneMesh=function(e,t,n){var r,i;s.Mesh.call(this,e,t,n),e.boundingBox||e.computeBoundingBox
+(),r=e.boundingBox.max.x-e.boundingBox.min.x,i=e.boundingBox.max.y-e.boundingBox.min.y,this._physijs.type="plane",this._physijs.normal=e.faces[0].normal.clone(),this._physijs.mass=typeof n=="undefined"?r*i:n},s.PlaneMesh.prototype=new s.Mesh,s.PlaneMesh.prototype.constructor=s.PlaneMesh,s.HeightfieldMesh=function(e,t,n,r,i){s.Mesh.call(this,e,t,n),this._physijs.type="heightfield",this._physijs.xsize=e.boundingBox.max.x-e.boundingBox.min.x,this._physijs.ysize=e.boundingBox.max.y-e.boundingBox.min.y,this._physijs.xpts=typeof r=="undefined"?Math.sqrt(e.vertices.length):r+1,this._physijs.ypts=typeof i=="undefined"?Math.sqrt(e.vertices.length):i+1,this._physijs.absMaxHeight=Math.max(e.boundingBox.max.z,Math.abs(e.boundingBox.min.z));var o=[],u,a;for(var f=0;f<e.vertices.length;f++)u=f%this._physijs.xpts,a=Math.round(f/this._physijs.xpts-f%this._physijs.xpts/this._physijs.xpts),o[f]=e.vertices[u+(this._physijs.ypts-a-1)*this._physijs.ypts].z;this._physijs.points=o},s.HeightfieldMesh.prototype=new s.Mesh,s.HeightfieldMesh
+.prototype.constructor=s.HeightfieldMesh,s.BoxMesh=function(e,t,n){var r,i,o;s.Mesh.call(this,e,t,n),e.boundingBox||e.computeBoundingBox(),r=e.boundingBox.max.x-e.boundingBox.min.x,i=e.boundingBox.max.y-e.boundingBox.min.y,o=e.boundingBox.max.z-e.boundingBox.min.z,this._physijs.type="box",this._physijs.width=r,this._physijs.height=i,this._physijs.depth=o,this._physijs.mass=typeof n=="undefined"?r*i*o:n},s.BoxMesh.prototype=new s.Mesh,s.BoxMesh.prototype.constructor=s.BoxMesh,s.SphereMesh=function(e,t,n){s.Mesh.call(this,e,t,n),e.boundingSphere||e.computeBoundingSphere(),this._physijs.type="sphere",this._physijs.radius=e.boundingSphere.radius,this._physijs.mass=typeof n=="undefined"?4/3*Math.PI*Math.pow(this._physijs.radius,3):n},s.SphereMesh.prototype=new s.Mesh,s.SphereMesh.prototype.constructor=s.SphereMesh,s.CylinderMesh=function(e,t,n){var r,i,o;s.Mesh.call(this,e,t,n),e.boundingBox||e.computeBoundingBox(),r=e.boundingBox.max.x-e.boundingBox.min.x,i=e.boundingBox.max.y-e.boundingBox.min.y,o=e.boundingBox.max
+.z-e.boundingBox.min.z,this._physijs.type="cylinder",this._physijs.width=r,this._physijs.height=i,this._physijs.depth=o,this._physijs.mass=typeof n=="undefined"?r*i*o:n},s.CylinderMesh.prototype=new s.Mesh,s.CylinderMesh.prototype.constructor=s.CylinderMesh,s.CapsuleMesh=function(e,t,n){var r,i,o;s.Mesh.call(this,e,t,n),e.boundingBox||e.computeBoundingBox(),r=e.boundingBox.max.x-e.boundingBox.min.x,i=e.boundingBox.max.y-e.boundingBox.min.y,o=e.boundingBox.max.z-e.boundingBox.min.z,this._physijs.type="capsule",this._physijs.radius=Math.max(r/2,o/2),this._physijs.height=i,this._physijs.mass=typeof n=="undefined"?r*i*o:n},s.CapsuleMesh.prototype=new s.Mesh,s.CapsuleMesh.prototype.constructor=s.CapsuleMesh,s.ConeMesh=function(e,t,n){var r,i,o;s.Mesh.call(this,e,t,n),e.boundingBox||e.computeBoundingBox(),r=e.boundingBox.max.x-e.boundingBox.min.x,i=e.boundingBox.max.y-e.boundingBox.min.y,this._physijs.type="cone",this._physijs.radius=r/2,this._physijs.height=i,this._physijs.mass=typeof n=="undefined"?r*i:n},s.ConeMesh
+.prototype=new s.Mesh,s.ConeMesh.prototype.constructor=s.ConeMesh,s.ConcaveMesh=function(e,t,n){var r,i,o,u,a,f,l=[];s.Mesh.call(this,e,t,n),e.boundingBox||e.computeBoundingBox(),a=e.vertices;for(r=0;r<e.faces.length;r++)f=e.faces[r],f instanceof THREE.Face3?l.push([{x:a[f.a].x,y:a[f.a].y,z:a[f.a].z},{x:a[f.b].x,y:a[f.b].y,z:a[f.b].z},{x:a[f.c].x,y:a[f.c].y,z:a[f.c].z}]):f instanceof THREE.Face4&&(l.push([{x:a[f.a].x,y:a[f.a].y,z:a[f.a].z},{x:a[f.b].x,y:a[f.b].y,z:a[f.b].z},{x:a[f.d].x,y:a[f.d].y,z:a[f.d].z}]),l.push([{x:a[f.b].x,y:a[f.b].y,z:a[f.b].z},{x:a[f.c].x,y:a[f.c].y,z:a[f.c].z},{x:a[f.d].x,y:a[f.d].y,z:a[f.d].z}]));i=e.boundingBox.max.x-e.boundingBox.min.x,o=e.boundingBox.max.y-e.boundingBox.min.y,u=e.boundingBox.max.z-e.boundingBox.min.z,this._physijs.type="concave",this._physijs.triangles=l,this._physijs.mass=typeof n=="undefined"?i*o*u:n},s.ConcaveMesh.prototype=new s.Mesh,s.ConcaveMesh.prototype.constructor=s.ConcaveMesh,s.ConvexMesh=function(t,n,r){var i,o,u,a,f=[];s.Mesh.call(this,t,n,r),t.boundingBox||
+t.computeBoundingBox();for(i=0;i<t.vertices.length;i++)e>=49?f.push({x:t.vertices[i].x,y:t.vertices[i].y,z:t.vertices[i].z}):f.push({x:t.vertices[i].position.x,y:t.vertices[i].position.y,z:t.vertices[i].position.z});o=t.boundingBox.max.x-t.boundingBox.min.x,u=t.boundingBox.max.y-t.boundingBox.min.y,a=t.boundingBox.max.z-t.boundingBox.min.z,this._physijs.type="convex",this._physijs.points=f,this._physijs.mass=typeof r=="undefined"?o*u*a:r},s.ConvexMesh.prototype=new s.Mesh,s.ConvexMesh.prototype.constructor=s.ConvexMesh,s.Vehicle=function(e,t){t=t||new s.VehicleTuning,this.mesh=e,this.wheels=[],this._physijs={id:u(),rigidBody:e._physijs.id,suspension_stiffness:t.suspension_stiffness,suspension_compression:t.suspension_compression,suspension_damping:t.suspension_damping,max_suspension_travel:t.max_suspension_travel,friction_slip:t.friction_slip,max_suspension_force:t.max_suspension_force}},s.Vehicle.prototype.addWheel=function(e,t,n,r,i,s,o,u,a){var f=new THREE.Mesh(e,t);f.castShadow=f.receiveShadow=!0,f.position
+.copy(r).multiplyScalar(s/100).addSelf(n),this.world.add(f),this.wheels.push(f),this.world.execute("addWheel",{id:this._physijs.id,connection_point:{x:n.x,y:n.y,z:n.z},wheel_direction:{x:r.x,y:r.y,z:r.z},wheel_axle:{x:i.x,y:i.y,z:i.z},suspension_rest_length:s,wheel_radius:o,is_front_wheel:u,tuning:a})},s.Vehicle.prototype.setSteering=function(e,t){if(t!==undefined&&this.wheels[t]!==undefined)this.world.execute("setSteering",{id:this._physijs.id,wheel:t,steering:e});else if(this.wheels.length>0)for(var n=0;n<this.wheels.length;n++)this.world.execute("setSteering",{id:this._physijs.id,wheel:n,steering:e})},s.Vehicle.prototype.setBrake=function(e,t){if(t!==undefined&&this.wheels[t]!==undefined)this.world.execute("setBrake",{id:this._physijs.id,wheel:t,brake:e});else if(this.wheels.length>0)for(var n=0;n<this.wheels.length;n++)this.world.execute("setBrake",{id:this._physijs.id,wheel:n,brake:e})},s.Vehicle.prototype.applyEngineForce=function(e,t){if(t!==undefined&&this.wheels[t]!==undefined)this.world.execute("applyEngineForce"
+,{id:this._physijs.id,wheel:t,force:e});else if(this.wheels.length>0)for(var n=0;n<this.wheels.length;n++)this.world.execute("applyEngineForce",{id:this._physijs.id,wheel:n,force:e})},s.VehicleTuning=function(e,t,n,r,i,s){this.suspension_stiffness=e!==undefined?e:5.88,this.suspension_compression=t!==undefined?t:.83,this.suspension_damping=n!==undefined?n:.88,this.max_suspension_travel=r!==undefined?r:500,this.friction_slip=i!==undefined?i:10.5,this.max_suspension_force=s!==undefined?s:6e3},s}();

0 comments on commit 46d750d

Please sign in to comment.