Three.js 3D rendering library for javascript #gamedev #game-engine #rendering #javascript
|
|
пре 14 година | |
|---|---|---|
| build | пре 14 година | |
| examples | пре 14 година | |
| src | пре 14 година | |
| utils | пре 14 година | |
| .gitignore | пре 15 година | |
| LICENSE | пре 15 година | |
| README.md | пре 14 година | |
| TODO | пре 15 година |
The aim of this project is to create a lightweight 3D engine with a very low level of abstraction — in other words, for dummies. The engine can render using <canvas>, <svg> and WebGL.
API Reference — be aware that the API may change from revision to revision breaking backwards compatibility.
More? #three.js on irc.freenode.net
Download the minified library and include it in your html.
<script src="js/Three.js"></script>
This code creates a camera, then creates a scene object, adds a bunch of random particles in it, creates a <canvas> renderer and adds its viewport in the document.body element.
<script>
var camera, scene, renderer;
init();
animate();
function init() {
camera = new THREE.Camera( 75, window.innerWidth / window.innerHeight, 1, 10000 );
camera.position.z = 1000;
scene = new THREE.Scene();
for ( var i = 0; i < 1000; i ++ ) {
var particle = new THREE.Particle( new THREE.ParticleCircleMaterial( { color: Math.random() * 0xffffff } ) );
particle.position.x = Math.random() * 2000 - 1000;
particle.position.y = Math.random() * 2000 - 1000;
particle.position.z = Math.random() * 2000 - 1000;
particle.scale.x = particle.scale.y = Math.random() * 10 + 5;
scene.addObject( particle );
}
renderer = new THREE.CanvasRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
document.body.appendChild( renderer.domElement );
}
function animate() {
// Include examples/js/RequestAnimationFrame.js for cross-browser compatibility.
requestAnimationFrame( animate );
render();
}
function render() {
renderer.render( scene, camera );
}
</script>
2011 03 06 - r35 (187.875 KB, gzip: 46.433 KB)
translate, translateX, translateY, translateZ and lookAt methods to Object3D. (mrdoob)setViewport and setScissor to WebGLRenderer. (alteredq)2011 03 02 - r34 (186.045 KB, gzip: 45.953 KB)
QuakeCamera for easy fly-bys (alteredq)LOD example (alteredq)2011 02 26 - r33 (184.483 KB, gzip: 45.580 KB)
ParticleSystem object to WebGLRenderer (alteredq)Line support to WebGLRenderer (alteredq)WebGLRenderer (alteredq)Ribbon object. (alteredq)WebGLRenderer (alteredq)Sound object and SoundRenderer. (empaempa)LOD, Bone, SkinnedMesh objects and hierarchy being developed. (empaempa)2010 12 31 - r32 (89.301 KB, gzip: 21.351 KB)
Scene now supports Fog and FogExp2. WebGLRenderer only right now. (alteredq)setClearColor( hex, opacity ) to WebGLRenderer and CanvasRenderer (alteredq & mrdoob)WebGLRenderer shader system refactored improving performance. (alteredq)Projector now does frustum culling of all the objects using their sphereBoundingBox. (thx errynp)material property changed to materials globaly.2010 12 06 - r31 (79.479 KB, gzip: 18.788 KB)
WebGLRendererpython build.py --includes generates includes string2010 11 30 - r30 (77.809 KB, gzip: 18.336 KB)
WebGLRenderer (alteredq)SmoothShading support on CanvasRenderer/MeshLambertMaterialMeshShaderMaterial for WebGLRenderer (alteredq)RenderableFace4 from Projector/CanvasRenderer (maybe just temporary).GeometryUtils, ImageUtils, SceneUtils and ShaderUtils (alteredq & mrdoob)2010 11 17 - r29 (69.563 KB)
CanvasRenderer (julianwa)CanvasRenderer and SVGRenderer. (mrdoob)2010 11 04 - r28 (62.802 KB)
Loader class allows load geometry asynchronously at runtime. (alteredq)MeshPhongMaterial working with WebGLRenderer. (alteredq)Projector.unprojectVector and Ray class to check intersections with faces (based on mindlapse work)Projector z-sorting (not as jumpy anymore).2010 10 28 - r25 (54.480 KB)
WebGLRenderer now up to date with other renderers! (alteredq)MeshFaceMaterial (multipass per face)CanvasRenderer and SVGRenderer material handling2010 10 06 - r18 (44.420 KB)
PointLightCanvasRenderer and SVGRenderer basic lighting support (ColorStroke/ColorFill only)Renderer > Projector. CanvasRenderer, SVGRenderer and DOMRenderer do not extend anymorecomputeCentroids method to Geometry2010 09 17 - r17 (39.487 KB)
Light, AmbientLight and DirectionalLight (philogb)WebGLRenderer basic lighting support (philogb)2010 08 21 - r16 (35.592 KB)
Matrix4 and Vector3 methods2010 07 23 - r15 (32.440 KB)
UV instead of Vector2 where it should be usedMesh.flipSided boolean (false by default)CanvasRenderer was handling UVs at 1,1 as bitmapWidth, bitmapHeight (instead of bitmapWidth - 1, bitmapHeight - 1)ParticleBitmapMaterial.offset addedFace4 with MeshBitmapUVMappingMaterial2010 07 17 - r14 (32.144 KB)
CanvasRenderer (more duplicated code, but easier to handle)Face4 now supports MeshBitmapUVMappingMaterial*StrokeMaterial parameters. Now it's color, opacity, lineWidth.BitmapUVMappingMaterial > MeshBitmapUVMappingMaterialColorFillMaterial > MeshColorFillMaterialColorStrokeMaterial > MeshColorStrokeMaterialFaceColorFillMaterial > MeshFaceColorFillMaterialFaceColorStrokeMaterial > MeshFaceColorStrokeMaterialColorStrokeMaterial > LineColorMaterialRectangle.instersects returned false with rectangles with 0px witdh or height2010 07 12 - r13 (29.492 KB)
ParticleCircleMaterial and ParticleBitmapMaterialParticle now use ParticleCircleMaterial instead of ColorFillMaterialParticle.size > Particle.scale.x and Particle.scale.yParticle.rotation.z for rotating the particleSVGRenderer currently out of sync2010 07 07 - r12 (28.494 KB)
WebGLRenderer (ColorFillMaterial and FaceColorFillMaterial by now)Matrix4.lookAt fix (CanvasRenderer and SVGRenderer now handle the -Y)Color now using 0-1 floats instead of 0-255 integers2010 07 03 - r11 (23.541 KB)
Scene.add > Scene.addObjectScene.removeObject2010 06 22 - r10 (23.959 KB)
Object3D.overdraw = true to enable CanvasRenderer screen space point expansion hack.2010 06 20 - r9 (23.753 KB)
autoClear property for renderers.2010 06 06 - r8 (23.496 KB)
Geometry.CanvasRenderer expands screen space points (workaround for antialias gaps).CanvasRenderer supports BitmapUVMappingMaterial.2010 06 05 - r7 (22.387 KB)
2010 05 17 - r6 (21.003 KB)
CanvasRenderer and SVGRendererclearRect optimisations on CanvasRenderer2010 05 16 - r5 (19.026 KB)
THREE namespaceCamera.x -> Camera.position.xCamera.target.x > Camera.target.position.xColorMaterial > ColorFillMaterialFaceColorMaterial > FaceColorFillMaterialColorStrokeMaterial and FaceColorStrokeMaterialgeometry.faces.a are now indexes instead of references2010 04 26 - r4 (16.274 KB)
SVGRenderer Particle renderingCanvasRenderer uses context.setTransform to avoid extra calculations2010 04 24 - r3 (16.392 KB)
Plane and Cube primitives2010 04 24 - r2 (15.724 KB)
Color handling2010 04 24 - r1 (15.25 KB)