Three.js 3D rendering library for javascript #gamedev #game-engine #rendering #javascript
|
|
13 anni fa | |
|---|---|---|
| build | 13 anni fa | |
| docs | 13 anni fa | |
| examples | 13 anni fa | |
| gui | 13 anni fa | |
| src | 13 anni fa | |
| utils | 13 anni fa | |
| .gitignore | 13 anni fa | |
| LICENSE | 14 anni fa | |
| README.md | 13 anni fa |
The aim of the project is to create a lightweight 3D library with a very low level of complexity — in other words, for dummies. The library provides <canvas>, <svg> and WebGL renderers.
Contributors — Getting Started — API Reference
More? #three.js on irc.freenode.net
Download the minified library and include it in your html. Alternatively see how to build the library yourself.
<script src="js/Three.js"></script>
This code creates a camera, then creates a scene, adds a cube on it, creates a <canvas> renderer and adds its viewport in the document.body element.
<script>
var camera, scene, renderer,
geometry, material, mesh;
init();
animate();
function init() {
scene = new THREE.Scene();
camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 1, 10000 );
camera.position.z = 1000;
scene.add( camera );
geometry = new THREE.CubeGeometry( 200, 200, 200 );
material = new THREE.MeshBasicMaterial( { color: 0xff0000, wireframe: true } );
mesh = new THREE.Mesh( geometry, material );
scene.add( mesh );
renderer = new THREE.CanvasRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
document.body.appendChild( renderer.domElement );
}
function animate() {
// note: three.js includes requestAnimationFrame shim
requestAnimationFrame( animate );
render();
}
function render() {
mesh.rotation.x += 0.01;
mesh.rotation.y += 0.02;
renderer.render( scene, camera );
}
</script>
2012 03 04 - r48 (393,626 KB, gzip: 99,395 KB)
ColladaLoader. (jbaicoianu)ColladaLoader improvements. (mrdoob, AddictArts, kduong)IcosahedronGeometry and OctahedronGeometry with timothypratley's PolyhedronGeometry code which also brings TetrahedronGeometry. (mrdoob)LOD should now behave as expected from anywhere in the scene graph. (mrdoob)THREE.REVISION. (mrdoob)Geometry's .computeBoundingBox and .computeBoundingSphere. (alteredq)SceneLoader. (alteredq)Material's default ambient color to 0xffffff. (alteredq)MorphTarget. (alteredq).setFrameRange and .setAnimationLabel to MorphAnimMesh. (alteredq)MorphAnimMesh. (alteredq)MorphAnimMesh to be able to play animations backwards. (alteredq).generateDataTexture to ImageUtils. (alteredq).intersectScene() from Ray. (mrdoob).triangulateQuads to GeometryUtils. (alteredq)Projector and WebGLRenderer now handles doubleSided lighting properly. (mrdoob and alteredq)MorphAnimMesh playback bug where the last frame didn't display. (alteredq)TrackballControls implements EventTarget. (mrdoob).clone to Vertex, Face3 and Face4. (alteredq).explode and .tessellate to GeometryUtils. (alteredq).lerpSelf to Vector2, Vector3 and UV. (alteredq)DOMRenderer by using single-materials. (ajorkowski ).setPrecision to Ray. (mrdoob)NoBlending to Material and WebGLRenderer. (kovleouf).applyMatrix to Object3D. (mrdoob and alteredq).attach and .detach to SceneUtils to retain position in space. (alteredq).sign to Math. (alteredq)Mesh, Line and ParticleSystem. (mrdoob)2012 01 14 - r47 (378,169 KB, gzip: 96,015 KB)
WebGLRenderer plugin. (alteredq)Matrix4's transpose() and getInverse(). (ekitson)Frustrum class. (alteredq)ColladaLoader improvements. (ekitson, jterrace, mrdoob and alteredq)WebGLRenderer. (alteredq)/doc (using sphinx). (jterrace)mediump. (mrdoob)BufferGeometry for direct rendering from typed arrays. (alteredq)Texture class with format and type parameters. (alteredq)WebGLRenderer's Shadow Map code. (alteredq)xhr.overrideMimeType before using it (fixing IE support). (mrdoob and alteredq)WebGLRenderer shaders. (alteredq)generateMipmaps property to Texture and RenderTarget. (alteredq)Frustum properly handling children with scaled parents. (avinoamr)Ray when dealing with big polygons. (WestLangley)WebGLRenderer bug where depth buffer was not cleared. (ekitson)CameraHelper objects for visualising both Perspective and Orthographic cameras. (alteredq)Path. (zz85)DirectionalLights. (alteredq)Gyroscope object. (alteredq)alpha and premultipliedAlpha parameters to WebGLRenderer. (mrdoob)Ray properly handling children with scaled parents. (mrdoob)Axes object to AxisHelper. (mrdoob)2011 11 17 - r46 (343.383 KB, gzip: 87.468 KB)
Ray now checks also object children. (mrdoob)*Loader.load( parameters ) to *Loader( url, callback, texturePath ). (mrdoob and alteredq)CanvasRenderer's SphericalReflectionMapping rendering. (mrdoob)SubdivisionModifier. (zz85)*Controls to use externally supplied time delta. (alteredq)CombinedCamera. (zz85)ColladaLoader doesn't create extra Object3D. (mrdoob)Ray not considering edges. (mrdoob)WebGLRenderer. (alteredq)Ray optimisations. (mrdoob and alteredq)CubeGeometry, PlaneGeometry, IcosahedronGeometry and SphereGeometry. (mrdoob)Curve. (zz85)Collisions code and focusing on Ray. (mrdoob)cloneObject() method to SceneUtils. (alteredq)2011 10 06 - r45 (340.863 KB, gzip: 86.568 KB)
Object/Scene.add*() and Object/Scene.remove*() are now Object/Scene.add() and Object/Scene.remove(). (mrdoob)LOD.add() is now LOD.addLevel(). (mrdoob)CylinderGeometry. (mrdoob).depthWrite and .fog to Material. (alteredq).applyMatrix to Geometry. (mrdoob)/examples/js/postprocessing. (alteredq).center() to GeometryUtils. (alteredq)MeshShaderMaterial to ShaderMaterial. (alteredq)CanvasRenderer ignoring color of SmoothShadinged MeshLambertMaterial. (mrdoob)renderer.data to renderer.info. (mrdoob)Loader's extractUrlbase() incorrect output for short urls. (rectalogic and alteredq).color and .visible support to Sprite. (alteredq)Face4, Vertex Colors and Maya support to ColladaLoader. (mrdoob)WebGLRenderer performance improvements. (alteredq)WebGLRenderer. (NINE78 and alteredq)CubeCamera for rendering cubemaps. (alteredq)GeometryUtils's .mergeVertices() performance. (zz85)Camera's .target. (mrdoob)WebGLRenderer's .clear() is now .clear( color, depth, stencil ). (mrdoob).autoClearColor, .autoClearDepth and .autoClearStencil to WebGLRenderer. (mrdoob and alteredq)OctahedronGeometry. (clockworkgeek)Camera into PerspectiveCamera and OrthographicCamera. (mrdoob and alteredq)*Controls. (alteredq and mrdoob)SubdivisionModifier. (zz85)Projector's unprojectVector() now also works with OrthographicCamera. (jsermeno).setLens() method to PerspectiveCamera. (zz85)Texture's .offset and .repeat and reflections support to Normal Map shader. (alteredq)2011 09 04 - r44 (330.356 KB, gzip: 84.039 KB)
ColladaLoader. (timknip2)ExtrudeGeometry. (zz85)CylinderGeometry normals. (alteredq)WebGLRenderer.setTexture (rectalogic)TorusGeometry normals. (mrdoob)Ray behind-ray intersects. (mrdoob)OrthoCamera. (alteredq).deallocateObject() and .deallocateTexture() methods to WebGLRenderer. (mrdoob).frustumCulled property to Object3D. (alteredq and mrdoob)2011 08 14 - r43 (298.199 KB, gzip: 74.805 KB)
ImageUtils. (mrdoob)TextGeometry and added Shape, Curve, Path, ExtrudeGeometry, TextPath. (zz85 and alteredq)ParticleSystems. (alteredq)CanvasRenderer.setClearColor. (mrdoob, StephenHopkins and sebleedelisle)WebGLRenderer. (alteredq)WebGLRenderer. (alteredq)Spotlight light type. (alteredq)DataTexture. (alteredq)WebGLRenderer opaque pass now renders from front to back. (alteredq)Color. (mrdoob)preserveDrawingBuffer option to WebGLRenderer. (jeromeetienne)UTF8Loader for loading the new, uber compressed, UTF8 format. (alteredq)CanvasRenderer now supports RepeatWrapping, texture.offset and texture.repeat. (mrdoob)2011 07 06 - r42 (277.852 KB, gzip: 69.469 KB)
AnaglypWebGLRenderer and CrosseyedWebGLRenderer. (mrdoob, alteredq and marklundin)TextGeometry. (zz85 and alteredq)setViewOffset method to Camera. (greggman)*Geometry. (mrdoob)Matrix4.multiply(). (thanks lukem1)Matrix4. (rectalogic)QuakeCamera to FirstPersonCamera. (chriskillpack)Collision now supports Object3D.flipSided and Object3D.doubleSided. (NINE78)SceneUtils methods. (mrdoob)Sound object and SoundRenderer. (mrdoob)2011 05 31 - r41/ROME (265.317 KB, gzip: 64.849 KB)
(Up to this point, some RO.ME specific features managed to get in the lib. The aim is to clean this up in next revisions.)
Face4 support to CollisionSystem. (NINE78)Particle support to Ray. (mrdoob and jaycrossler)Ray.intersectObject performance by checking boundingSphere first. (mrdoob)TrackballCamera. (egraether)repeat and offset properties to Texture. (mrdoob and alteredq)Vector2, Vector3 and Vector4. (egraether)2011 04 24 - r40 (263.774 KB, gzip: 64.320 KB)
Object3D.lookAt. (mrdoob)CollisionSystem. (drojdjou and alteredq)Trident object. (sroucheray)data object to Renderers for getting number of vertices/faces/callDraws from last render. (mrdoob)Projector handling Particles with hierarchies. (mrdoob)2011 04 09 - r39 (249.048 KB, gzip: 61.020 KB)
Collisions classes. (drojdjou)Sprite object. (empaempa)*Loader issue where Workers were kept alive and next loads were delayed. (alteredq)THREE namespace to all the classes that missed it. (mrdoob)2011 03 31 - r38 (225.442 KB, gzip: 55.908 KB)
LensFlare light. (empaempa)ShadowVolume object (stencil shadows). (empaempa)Loader (mrdoob)material.transparent define whether material is transparent or not (before we were guessing). (mrdoob)2011 03 22 - r37 (208.495 KB, gzip: 51.376 KB)
Geometry.uvs is now a multidimensional array (allowing infinite uv sets) (alteredq)CanvasRenderer renders Face4 again (without spliting to 2 Face3) (mrdoob)ParticleCircleMaterial > ParticleCanvasMaterial. Allowing injecting any canvas.context code! (mrdoob)2011 03 14 - r36 (194.547 KB, gzip: 48.608 KB)
WebGLRenderer aspect ratio bug when scene had only one material. (mrdoob)sizeAttenuation property to ParticleBasicMaterial. (mrdoob)PathCamera. (alteredq)WebGLRenderer bug when Camera has a parent. CameraCamera.updateMatrix method. (empaempa)Camera.updateMatrix method and Object3D.updateMatrix. (mrdoob)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)