1

So I have a flat plane, and I'm using up, down, right and left to roll a sphere along it using Physi.js. I want to apply a chase camera to the sphere, but I can't prevent the camera to follow the sphere's rotation? I want the camera to stay behind the sphere, following it's z.axis but prevent it to rotate every time the sphere spins.

Anyone's got a clue?

gyllensand
  • 21
  • 3

2 Answers2

1
function chaseMesh(camera, mesh){
    camera.position.z = mesh.position.z;
    camera.lookAt(mesh.position);
}

Just call that every time you want to reposition your camera with the parameters.

0

Create a generic THREE.Object3D(), and add both the sphere and the camera to it. Do your translations on the parent object, and only use the sphere itself when doing rotations.

Joey
  • 10,504
  • 16
  • 39
  • 54
  • It seems that when using Object3D() in Physi.js the object is no longer part of the gravity scene anymore. It just hovers in the air with no collision detection at all. I used applyCentralForce before to move the sphere, and adding friction to the ground/plane to make it roll naturally. Is there anyway to use Object3D in Physi, letting the parent keep the gravitational pull, or maybe solving this in another way? – gyllensand Apr 16 '15 at 10:27