Closed df257 closed 8 years ago
You could use the angular factor:
scene.addEventListener("update", function(){
if(mesh.getAngularVelocity().length() < 0.001){
mesh.setAngularFactor(new THREE.Vector3(0, 0, 0));
}
});
This code performs a check after every scene update. If the angular velocity is lower than 0.001
, it disables rolling completely. Now, if you want to make the ball roll again, I suggest:
mesh.setAngularVelocity(/* Your speed vector here */);
mesh.setAngularFactor(new THREE.Vector3(1, 1, 1));
If you don't add that last line, I think the ball won't have any movement.
//ground var geo=new THREE.PlaneGeometry(100,100); var mat=new Physijs.createMaterial(new THREE.MeshLambertMaterial({color:'#86FBC6',side:THREE.DoubleSide},1,1)); var mesh=new Physijs.PlaneMesh(geo,mat,0); mesh.rotation.x=-.45_Math.PI; mesh.rotation.y=.01_Math.PI; scene.add(mesh);
//sphere var mat=new Physijs.createMaterial(new THREE.MeshLambertMaterial({color:'#fff',map:texture}),1,1); var mesh=new Physijs.SphereMesh(geo,mat,100); mesh.position.set(0,30,0); scene.add(mesh); mesh.setDamping(0,0.9); //this code just make sphere rolling very slowly, but not stop