Euler Angle Rotation Demo
Er, JavaScript doesn't seem to be running, so basically all you're going to see is the bare code...
// Make a bunch of spheres var g=new THREE.SphereGeometry(1, 3, 3); var m=new THREE.MeshLambertMaterial( {color: 0xffffff}) sim.nspheres=5; sim.spheres=[]; for (var i=0;i
/** s: sphere object, with s.P position and s.V velocity. N: surface normal, facing out of region. P: point on surface of boundary region. */ function boundaryBounce(s,N,P) { N.normalize(); var rP=s.P.m(P); // sphere position, relative to boundary var d=rP.dot(N); if (d>0.0) { // we hit the boundary s.P.pe(N.t(-d)); // move inside var dV=s.V.dot(N); if (dV>0.0) { // flip velocity s.V.pe(N.t(-2.0*dV )); } s.V.te(0.6); // bounce friction (inelastic) if (dV>0.3) { // CLANG! the camera camera.position.pe(N.t(-dV*0.005)); } } } //camera.position.set(0,-10,1.7); // default: assume no "clang!". for (var i=0;i
// User Interface and camera control var move=new vec3(); // we'll sum motion here // X control via A and D if (lib.key['a']) move.pe(new vec3(-1,0,0)); if (lib.key['d']) move.pe(new vec3(+1,0,0)); // Y control via W and S if (lib.key['w']) move.pe(new vec3(0,+1,0)); if (lib.key['s']) move.pe(new vec3(0,-1,0)); // Z control via Q and Z if (lib.key['q']) move.pe(new vec3(0,0,+1)); if (lib.key['z']) move.pe(new vec3(0,0,-1)); for (var i=0;i