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.
This is to be able to control depth buffer writing / testing on per geometry chunk level (before it was possible just to hack it on per scene level via exposed GL context).
Disabling depth test is useful for example for additively blended particles, handling of transparency or for having background textured quad.
Another option would be to have it on per object level, but then this could prevent different handling of objects with both transparent and opaque parts.
Also in this commit:
- more progress towards mesh vertex colors
- less matrix multiplications in render call
- fixed ugly bug in doubleSided / flipSided handling
- cleanup of materials
- added a lot of missing stuff in debug strings and parameters handlers
- normal and depth materials now have opacity parameter
- wrote comments for non-obvious things
For this had to extend WebGLRenderer a bit:
- MeshShaderMaterial now can take non-specific float array uniforms as "fv1"
(there is already "fv" type for array of 3-item-vectors, which probably should be renamed to "fv3" to be consistent)
- render method has yet another parameter "clear" for clearing newly set framebuffer (defaults to true).
This is a bit hackish but it seems necessary to control this somehow. I didn't manage to replicate
desired behavior just with autoClear.
- another dirty thing is accessing GL context from the application side:
renderer.context.disable( renderer.context.DEPTH_TEST );
This should be refactored somehow, wrapped in some API call.