Commit Graph
9 Commits
Author SHA1 Message Date
alteredq 082da28c8e Renamed THREE.Supports to THREE.Detector, moved it to extras. Also cleaned up example title tags. 2011-02-13 19:19:55 +01:00
alteredq 29cf97eee7 Added centralized message for non-WebGL-compatible browser to majority of examples.
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).
2011-02-13 00:09:09 +01:00
alteredq 8e2f8c8b13 Fixed broken WebGL support detection.
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.
2011-02-12 20:02:05 +01:00
alteredq 771674d705 Refactored Loader parameters to allow optional separate paths for texture and binary files.
loader.loadAscii and loader.loadBinary now take just one parameter with following properties:

    - model (required)
    - callback (required)
    - texture_path (optional: if not specified, textures will be assumed to be in the same folder as JS model file)
    - bin_path (optional: if not specified, binary file will be assumed to be in the same folder as JS model file)

Example use:

    loader.loadBinary( { model: "model.js", bin_path: "path/bin", texture_path: "path/img",
                         callback: function( geometry ) { createScene( geometry ) } } );
2011-01-02 19:52:40 +01:00
alteredq ecad27eb11 Moved MeshPhongMaterial onto common shader builder machinery, ubershader is no more.
Code is still rough around edges (it can be made nicer), though it should already produce one-to-one results with ubershader.

Side-effect is that scene is no longer required as WebGLRenderer constructor parameter. Shader programs are now constructed upon first frame render and only then scene lights are examined.
2010-12-31 00:33:39 +01:00
alteredq 0fe464c97a Refactored uniforms cloning into separate file so that it can be reused also for MeshShaderMaterials.
Also changed MeshShaderMaterial demos to show how to use cloning. For these particular demos uniforms cloning is not really necessary as they use only one instance of shader material, but for example, if there were two normal mapped models in one scene, each model would need separate material with own uniforms.
2010-12-28 17:11:50 +01:00
alteredq 6e91de5d8a Added diffuse map to normal map shader. Changed Lee Perry-Smith demo to use normal map shader.
Diffuse map and ambient occlusion maps are now optional in normal map shader.

By default, both are disabled, so they need to be enabled explicitly like this:

    uniforms[ "enableAO" ].value = true;
    uniforms[ "enableDiffuse" ].value = true;
2010-12-26 03:03:28 +01:00
alteredq 255c042b1e Added clear color parameter to WebGLRenderer constructor, also added setClearColor API call.
This allows to work around ANGLE antialiasing issue appearing when compositing WebGL framebuffer with transparent background color with HTML canvas element background (while keeping antialiasing on).

WebGLRenderer constructor now takes JSON object with few optional parameters:

    renderer = new THREE.WebGLRenderer { scene: scene,
                                         antialias: true,
                                         clearColor: 0x000000,
                                         clearAlpha: 0 };

Here is how to change clear color in runtime:

    renderer.setClearColor( 0xff0000, 1 );
2010-12-25 22:32:26 +01:00
alteredq ac5276b41f Added normal + ambient occlusion + displacement mapping demo.
A lot of things going on in this commit:

- added tangents computation for geometries
    - mesh must have UV coordinates
    - to be called explicitly once geometry is loaded like this: geometry.computeTangents()
    - tangents are stored in Vertex objects
    - quads are not solved properly (though workaround hack seems to work at least somehow, as far as each vertex appears at least somewhere)

- extended VBOs in WebGLRenderer to include tangent streams (when available)

- added "normal" shader to ShaderUtils (to be used with MeshShaderMaterial)
   - Blinn-Phong with one directional and one point light (7 varyings gone, just one spare)
   - normal maps are in tangent space
   - displacement maps use simple luminance value (could be changed if better precision is needed)

- displacement mapping uses vertex texture fetch
    - this requires GPU with Shader Model 3.0
    - not currently supported in ANGLE
    - for this, added "supportsVertexTextures" method to WebGLRenderer API, so that application can handle this
2010-12-09 12:27:49 +01:00