Connecting the camera and avatar:

After scouring the internet, I found a useful StackOverflow post of someone who had a similar problem and an example of a chaseCam (http://stemkoski.github.io/Three.js/Chase-Camera.html). The solution turned out to be easy enough, by adding the camera to the movingCube object “movingCube.add(camera);” instead of the scene and positioning it back slightly the camera becomes a child of the cube and inherits its global positioning. It is also required to set the camera to look at the cube object through a useful function provided by three.js “camera.lookAt(movingCube .position);”. This means that although you set the camera position to be further back than the movingCube, as the parent object (being the cube) moves the child’s (camera) position will stay relative to it, whilst always looking at the cube.

Image

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s