Now you can add keyboard + mouse camera control with a single line, just change camera type and add parameters:
camera = new THREE.QuakeCamera( { fov: 50, aspect: window.innerWidth / window.innerHeight, near: 1, far: 10000,
movement_speed: 1, look_speed: 0.002, nofly: true, look_vertical: false } );
Thanks to mrdoob for suggestions ;)
That was much tougher than expected. No wonder other WebGL video demos around the web are broken.
Firefox OpenGL / ANGLE and Chrome OpenGL were ok, getting it to work in Chrome ANGLE was rather tricky.
Please report if something got broken. I tried to go through all textured examples but I may have missed something.
If you want to refresh texture on WebGL side, you just set "texture.needsUpdate" flag (if you use Loader or ImageUtils.loadTexture / loadTextureCube everything is taken care of).
Flag has to be set also for canvas-based textures, sorry no escaping this :(. I tried and it lead to ugly problems (e.g. AO minecraft demo mixes several asynchronously loaded and generated images into one texture, with autodetect always something was broken).
"needsUpdate" should work also on cube textures, though it's not tested yet (also there I didn't put hack for Chrome ANGLE).
build/Three.js - Includes all renderers + extras
build/custom/ThreeCanvas.js - Canvas renderer only
build/custom/ThreeDOM.js - DOM renderer only
build/custom/ThreeSVG.js - SVG renderer only
build/custom/ThreeWebGL.js - WebGL renderer only
build/custom/ThreeExtras.js - Extras only
Moved `THREE.Detector.js` to `examples/js/Detector.js`.
Updated examples to reflect these changes.
There don't seem to be any effects on performance (though I'm not sure this was actually used in any example/test code path - so far quaternions are used just for animation interpolation and even there they were always dirty, and also just updated during JIT baking).
Also some more code cleanup - no need for Mesh to have own "update" as now it was exactly the same as its parent Object3D.
I need to look at this objectMatrix::extractRotationMatrix() thing. I don't think this works like that... isn't the scale applied to the rotation in the matrix?
It provides a lean way how to render TRIANGLE_STRIP primitives: needs just n+2 vertices for n triangles (one Ribbon = one strip). There are no faces, no indices, everything is rendered in one simple drawArray call.
Vertex colors are supported, normals not yet.
- removed unnecessary normal matrix computation in hierarchies (this is already done in renderer)
- removed unnecessary enabling of attribute arrays in every frame (it's enough to do it when shader program is created)
- depth test is now only set if it changed
- getters/setters are no more in Vector3
- object hierarchies thus don't use "isDirty"
- this was completely killing performance for anything that was touching a lot of Vector3 like creation of meshes and dynamic buffers
- even without this, performance of hierarchies went up (a lot)
- objects do not get passed renderer anymore
- camera was almost also removed, but this is useful for LOD (though there may be some cleaner way to do this?)
- material ids are now unified, this makes "geometry.sortFacesByMaterial" faster (thus scene init / GUI blocking is shorter)
- all WebGL examples should work now (render-to-texture has weird lights and in some camera control feels different)
- CanvasRender still broken, despite many efforts :(
- currently only points and lines work, faces don't show up. I think this may need assistance from mrdoob.
We have been very lucky - setters / getters were not supported till just 2 hours ago (so fresh, I had to build Closure myself from their repo ;).
http://code.google.com/p/closure-compiler/issues/detail?id=249
Also some refactoring plus added hackish animation offset feature.
That was painful; hopefully since now it should be easier to have it in every WebGL example.
It's enough to add one line (ideally as the first thing that gets executed):
if ( ! THREE.Supports.webgl ) THREE.Supports.addGetWebGLMessage();
This will add message box with default styling centered near top of the window. Optional parameters "parent" and "id" can be specified for further customization and integration with the document, also message DOM element is returned for easier access.
var messageElement = THREE.Supports.addGetWebGLMessage( { parent: container, id: "my_message" } );
By default, message is added to document.body and has id "oldie" (can be styled with CSS).
Created "THREE.Supports" object, which should centralize this stuff. So far it detects <canvas>, WebGL and WebWorkers; later it could detect for example GPU capabilities.
Not sure about name or location, but it's pretty tiring go through all examples when something changes, so it should be somewhere in the library.
Code duplication is bad: even html snippets with error message should be centralized somewhere, so that when new browsers arrive we wouldn't have to keep changing them in many places.