Graphics Reference
In-Depth Information
1. The first thing we need to do is create the object that we want to follow. For
this recipe, we create a simple THREE.SphereGeometry object and add it
to the scene like this:
var sphereGeometry = new
THREE.SphereGeometry(1.5,20,20);
var matProps = {
specular: '#a9fcff',
color: '#00abb1',
emissive: '#006063',
shininess: 10
}
var sphereMaterial = new
THREE.MeshPhongMaterial(matProps);
var sphereMesh = new
THREE.Mesh(sphereGeometry,
sphereMaterial);
sphereMesh.name = 'sphere';
scene.add(sphereMesh);
As you can see in this short code snippet, we don't need to do anything spe-
cial with the object we want to follow.
2. The next step is that we need a camera that renders the scene and stays fo-
cused on the object we want to follow. The following JavaScript creates and
positions this camera:
// create a camera, which defines where
we're looking at.
camera = new
THREE.PerspectiveCamera(45,
window.innerWidth / window.innerHeight,
0.1, 1000);
// position and point the camera to the
center of the scene
camera.position.x = 15;
camera.position.y = 6;
camera.position.z = 15;
Search WWH ::




Custom Search