How to setup?
You need:
scene
camera
renderer
var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera( 75, w/ h, 0.1, 1000 );
var renderer = new THREE.WebGLRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
document.body.appendChild( renderer.domElement );
function render() {
requestAnimationFrame( render );
renderer.render( scene, camera );
}
render();
FORK THIS
Perspective vs Ortho
x,y,z
rotate(x,y,z)
lookAt
FOV
zoom
AmbientLight
PointLight
SpotLight
... (init)
var renderer = new THREE.WebGLRenderer();
renderer.shadowMap.enabled = true;
renderer.shadowMapType = THREE.PCFSoftShadowMap; //Optional
var plane = new THREE.Mesh(geo, mat);
plane.receiveShadow = true;
var cube = new THREE.Mesh(cubeGeo, cubeMat);
cube.castShadow = true;
var spotLight = new THREE.SpotLight(0xffffff);
... //Move up
spotLight.castShadow = true;
- PointLightHelper
- SpotLightHelper!
- check near/far
- disable ambient:)
spotLight.shadowCameraNear = 10;
spotLight.shadowMapWidth = 2048;
spotLight.shadowMapHeight = 2048;
Object3D base class
- "universal" parent for every object.
- also helps grouping objects.
- position, rotation, scale, matrix
- add, remove, parent, children
http://threejs.org/docs/index.html#Reference/Core/Object3D
Geometry base class
- describe 3D model
- vertices
- colors (Points, Lines)
- faces
- verticesNeedUpdate = true
BoxGeometry,
SphereGeometry,
TextGeometry,
....
Describe appearance of objects.
- opacity, transparent
- side ( Front, Back, DoubleSide)
MeshBasicMaterial,
MeshLambertMaterial,
MeshPongMaterial
ShaderMaterial
var geometry = new THREE.BoxGeometry( 1, 1, 1 );
var material = new THREE.MeshBasicMaterial( { color: 0xffff00 } );
var mesh = new THREE.Mesh( geometry, material );
scene.add( mesh );
Don't implement your own camera controller
controls = new THREE.OrbitControls( camera, renderer.domElement );
Helps you controlling values/property/everything
ArrowHelper
AxisHelper
LightHelpers
CameraHelpers
...