Three.js 3D rendering library for javascript #gamedev #game-engine #rendering #javascript
|
|
14 lat temu | |
|---|---|---|
| build | 14 lat temu | |
| examples | 14 lat temu | |
| src | 14 lat temu | |
| utils | 14 lat temu | |
| .gitignore | 15 lat temu | |
| LICENSE | 14 lat temu | |
| README.md | 14 lat temu | |
| TODO | 14 lat temu |
The aim of this project is to create a lightweight 3D engine with a very low level of abstraction (aka for dummies). Currently the examples are the documentation. Be aware that the API may change from revision to revision breaking backwards compatibility.
The engine can render using <canvas>, <svg> and WebGL.
More? #three.js on irc.freenode.net
Download the minified library and include it in your html.
<script type="text/javascript" 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 type="text/javascript">
var camera, scene, renderer;
init();
setInterval( loop, 1000 / 60 );
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 loop() {
renderer.render( scene, camera );
}
</script>
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)