Commit Graph
129 Commits
Author SHA1 Message Date
alteredq 0610f5734f Fixed vertex shader to work in Mac. 2010-11-18 04:55:05 +01:00
alteredq 3ee99dc4c5 Added cube mapping to WebGLRenderer. Also added cube map example. Finally ;)
TODO:

  - maybe image array loader should go into TextureCube.js so that people could just reuse the code

  - it may be worth to be able to specify different combination of environment map and underlying material (in single render pass),
    currently color/color map/environment map are multiplied, though addition also produces very interesting looking materials
2010-11-18 02:00:11 +01:00
alteredq 5535f71130 Added checks for nonexisting face materials if MeshFaceMaterial is used.
Cloned materials.html -> materials_gl.html to have easier test for WebGLRenderer.

TODO:

Investigate why this test is so slow. It shouldn't be, materials_shaders.html is more complex and yet it is much faster (36 vs 60 fps).

MeshFaceMaterial with every face different is pretty bad use case for WebGLRenderer, but this still doesn't fully explain slowdown :(.
2010-11-17 21:19:27 +01:00
Mr.doob c174157925 Compiled lib with julianwa's Line clipping fix. 2010-11-17 07:43:19 +00:00
Mr.doob 9637daef88 Seems like the new Particle projection code got lost in the merge. Fixed. 2010-11-17 06:02:11 +00:00
Mr.doob c16394d2ec Updated README.
Pushed REVISION to 29.
2010-11-17 05:45:35 +00:00
Mr.doob b025a6176d Projector merged succesfully. 2010-11-17 05:18:57 +00:00
Mr.doob 2b92a824c2 Added FaceMaterial example in materials demo. 2010-11-17 04:56:47 +00:00
Mr.doob 7dd33d6df6 Merging with alteredq branch 2010-11-17 04:51:43 +00:00
alteredq 3d3708919b Added support to "shading" materials parameter in WebGLRenderer.
This is actually tricky due to multimaterials and vertex normals.

The practical effects of "shading" parameter in WebGLRenderer are currently following:

- if your model has vertex normals, now you can "dumb down" its shading by specifying THREE.FlatShading for MeshLambertMaterial and MeshPhongMaterial
- if your model has only face normals, it will always have just flat shading, no matter which shading you set, no escape from this
- if your model has multiple materials, smooth shading always "wins", meaning if there is at least one smooth shaded material in multimaterial group, all other materials in this group will be also smooth shaded (this is solvable by having multiple normal buffers, but seems wasteful, at least for the moment, till there are no practical use cases)

Currently implemented shading / material combinations:

  - MeshNormalMaterial: FlatShading [default], GouradShading
  - MeshDepthMaterial:  no shading parameter in material, uses own specific shading
  - MeshBasicMaterial: no shading parameter in material, uses own specific shading
  - MeshLambertMaterial: FlatShading, GouraudShading [default]
  - MeshPhongMaterial: FlatShading, PhongShading [default]
2010-11-16 22:38:06 +01:00
Mr.doob 23688daf08 Added WIP materials example (showing all at once). 2010-11-16 14:57:06 +00:00
Mr.doob fbfa375d2c src/io/Loader.js ⟶ src/extras/io/Loader.js
Removed Loader.js from compiled lib
Fixed examples
2010-11-16 14:04:54 +00:00
Mr.doob 5e4476bde8 Now using Closure Compiler (~2kbytes) 2010-11-16 12:53:00 +00:00
Mr.doob dc6e335dc9 Color: Nicer way to check whether the hex has the alpha component or not. Removed unused methods.
CanvasRenderer/SVGRenderer: More code clean up and optimisations.
2010-11-16 12:27:25 +00:00
Mr.doob fe82bdbda9 Came up with a crazy approach to get Vertex Colors. Gouraud yet on step closer.
Changed the DepthMaterial to use this approach instead.
2010-11-16 11:02:45 +00:00
Mr.doob c6d69d8286 Refactored the CanvasRenderer a bit. 2010-11-16 05:54:37 +00:00
alteredq 007ee285fa Added MeshNormalMaterial support to WebGLRenderer. 2010-11-16 02:50:46 +01:00
Mr.doob 7b58b806d3 Fixed NormalToComponent function (it was over saturated). 2010-11-15 17:04:10 +00:00
Mr.doob bf3dede88a Implemented MeshNormalMaterial in SVGRenderer
SubstractiveBlending ⟶ SubtractiveBlending
2010-11-15 16:56:14 +00:00
Mr.doob 4d209ac433 Implemented material blendings (THREE.NormalBlending, THREE.AdditiveBlending, THREE.SubtractiveBlending) in CanvasRenderer
Added MeshNormalMaterial (per face)
2010-11-15 16:52:22 +00:00
Mr.doob 7d8fd5f874 CanvasRenderer now renders MeshDepthMaterial properly (per vertex). Gouraud is one step closer :)
Cleaned up CanvasRenderer and SVGRenderer code a bit.
2010-11-15 08:50:31 +00:00
alteredq 0163e4f2f5 Added (commented out) MeshDepthMaterial support to WebGLRenderer.
It's commented out, as it breaks shader validation in current Chrome :(.

There seems to be some bug in Chrome / ANGLE making it barf when using "gl_FragCoord" in fragment shader.

Curiously, while it breaks both 9.0.576.0 dev channel and latest continuous build 9.0.583.0, it does work fine in canary build with the same version as dev channel (9.0.576.0).

Go figure. Also in Firefox 4 beta 7 it works fine.

It seems there were some recent changes in handling of "gl_FragCoord" on Windows which probably broke something when fixing other bug:

http://code.google.com/p/chromium/issues/detail?id=59762
http://code.google.com/p/angleproject/issues/detail?id=71

TODO: make isolated test case and submit bug report (if this doesn't go away in next Chrome update).
2010-11-15 04:49:28 +01:00
alteredq b6e42d54d9 Added missing MeshDepthMaterial.js 2010-11-15 02:59:04 +01:00
alteredq b09308c238 Synced with mrdoob's materials branch.
Have to commit broken build (missing MeshDepthMaterial.js) as git doesn't want to proceed with new merge till the old one is not committed :(
2010-11-15 02:54:42 +01:00
Mr.doob aebe898625 Forgot to commit MeshDepthMaterial 2010-11-15 01:48:36 +00:00
alteredq bfb8242928 WebGLRenderer also working.
Not all features from the new material format are implemented yet, though already now it's more powerful than the old format (you can now use  texture also in Basic and Phong materials).

Also started to retire old model format: removed old OBJ converter and meshes that it generated.

TODO:
 - take into account shading and blending parameters
 - transplant cube map support from experimental material
2010-11-15 02:29:03 +01:00
Mr.doob 98dc841aab Added MeshDepthMaterial.
Optimised Particles projection in CanvasRenderer.
2010-11-15 01:17:41 +00:00
Mr.doob 64df690cc0 SVGRenderer also working. 2010-11-13 08:20:35 +00:00
Mr.doob 22f48a731b CanvasRenderer handles textures again.
Most of the examples working.
2010-11-13 07:11:57 +00:00
Mr.doob 237f165555 ParticleCircleMaterial working again with CanvasRenderer 2010-11-13 03:42:13 +00:00
Mr.doob ce3d641ff2 Changed materials format a bit.
Almost done porting CanvasRenderer to the new material system (plus some performance gains on the way :D)
`Color` now handles hex with no alpha byte (probably there is a nicer way of doing it...)
2010-11-13 02:39:27 +00:00
Mr.doob b978e9e592 * Minor tweaks on Rectangle.js 2010-11-12 04:19:21 +00:00
Mr.doob a35b35fde9 * examples/geometry/primitivessrc/extras/primitives
* THREE.Rectangle: `_x1`, ` _x2`, `_y1`, `_y2` ⟶ `_left`, `_right`, `_top`, `_bottom`
2010-11-12 04:02:30 +00:00
alteredq 94e77e4cb4 Added caching of element offsets optimization to binary loader. 2010-11-12 01:09:48 +01:00
alteredq 1e36ddee47 Applied mrdoob's optimizations from ascii loader also to binary loader.
TODO: still could save some more multiplication by precomputing offsets for individual components of the elements.
2010-11-11 21:49:29 +01:00
Mr.doob 453c6efc0d At Loader.js, as far as I can see we don't need all that stride stuff. Removed/Simplified from createModel() by now. That saves *a lot* of multiplications at init of the geometry. 2010-11-11 13:01:40 +00:00
Mr.doob a7d70a0eff * Builders clean up 2010-11-09 06:27:44 +00:00
alteredq 7c26e04c7a Refactored common functionality out of ascii and binary loaders. 2010-11-09 02:19:34 +01:00
alteredq a0fa2ae3dd Optimized binary model format to use indexed UVs. Updated OBJ slim converter and Loader accordingly.
This saves about 10% from size of textured binary models.
2010-11-08 23:20:25 +01:00
alteredq ecf97e0d4c Synced with sole's branch. 2010-11-08 20:10:32 +01:00
alteredq 188f36be5d Optimized ASCII model format to use indexed UVs. Updated OBJ slim converter and Loader accordingly.
This saves ~22% from size of textured ASCII models.

TODO: make the same for binary model format.
2010-11-08 18:10:43 +01:00
alteredq 514a2e6135 Merged with latest changes in mrdoob's branch. All hex colors should be now without baked opacity. 2010-11-06 18:59:03 +01:00
alteredq 0cb79310e5 Added experimental binary mesh loader. Updated OBJ converter and examples accordingly.
If you want to use binary format, convert OBJ models using "convert_obj_threejs_slim.py" with "-t binary" option.

This will now create two files:
    JS part with materials
    BIN part with binary buffers

Binary models are loaded like this:

loader.loadBinary( 'obj/lucy/Lucy250k_bin.js', function( geometry ) { createScene( geometry, s ) }, "obj/lucy" );

(difference to ascii format is that url root must be always specified so loader can find binary buffers file, like it already was for textures)

Good news:

- raw binary files are quite smaller than raw ascii files (about half size)
- loading times went down about 20-25%
- now also Firefox can handle 250k triangle mesh (it just bugs about long running script), with ascii format it threw "array initialiser too large" exception

Mixed news:

- gzipped binary files are only about 25% smaller than gzipped ascii files so actual benefits are smaller,
  also it's more likely server will have JS gzipping on by default, while you need to set it up for
  other formats (could be hacked around by naming binary files with JS extension instead of BIN?)

Bad news:

- browser blocking is back :( Not that it ever went completely away (for large models object creation is more costly than loading and it is blocking), but it was slightly better with ascii loader (where data is loaded as worker's JS body).

    - this comes from having to use Ajax to load binary data
    - loading binary data by Ajax from within worker didn't really help, it was in fact slightly slower and browser did freeze :(
    - can't easily embed binary data in JSON (would need to encode it which would make it bigger, defying the purpose)

- Loader got fatter

Also in this commit: renamed Loader.loadAsync() => Loader.loadAsciiOld() and Loader.loadWorker() = Loader.loadAscii() so that names correspond to model formats instead of underlying implementation.

loadAsciiOld - JS exported by Blender and old OBJ converter
loadAscii    - JSON created by slim OBJ converter (-t ascii)
loadBinary   - JSON + BIN created by slim OBJ converter (-t binary)

TODO:

 - look into UV coordinates, should be indexed the same way as vertices, normals and faces are (instead of unrolled per each face)
 - look into HTML5 File API, binary blobs could help
2010-11-06 17:24:58 +01:00
Mr.doob 3cdc007b90 * Fixed some minor issues handling opacity in hex colors 2010-11-06 12:51:09 +00:00
alteredq f6e829ca21 Synced with mrdoob's branch. 2010-11-05 00:25:03 +01:00
alteredq 49d1bd170b Made JSON model format slimmer by flattening arrays. Modified Loader and OBJ converter accordingly.
This is a first step towards eventual binary model format.
2010-11-04 21:18:08 +01:00
Mr.doob 8d198002d1 * Fixed a bug in Ray.intersectObject: face.normal needs to be transformed using matrixRotation otherwise rotated objects fail
* A bit nicer example
2010-11-04 20:11:37 +00:00
alteredq bae0a2e06b Synced with mrdoob's branch. 2010-11-04 11:59:06 +01:00
Mr.doob 9a62d1173a Refactored ClickResolver to Ray and Projector.unprojectVector` working.
Unimpressive example added `interactive_spheres.html`
2010-11-04 03:35:08 +00:00
alteredq 5192428f25 Added Loader class providing both asynchronous JS and web worker based loading of models.
The idea is that later there will be more loaders which would load different formats (like OBJLoader, ColladaLoader).

Usage (async JS):

var loader = new THREE.Loader();
loader.loadAsync( "obj/torus/Torus.js", function() { createScene( new Torus() ) } );

Usage (web worker):

var loader = new THREE.Loader();
loader.loadWorker( "obj/torus/Torus_slim.js", function( geometry ) { createScene( geometry ) } );

Web worker loader is useful for large meshes, where it allows browser to stay responsive for longer time and also it can handle larger meshes than async JS loader.

Web worker loader needs a simpler format of the model. Web workers can communicate with the main application only via message passing, where messages are JSON objects.

There is a new version of OBJ -> Three.js converter (convert_obj_threejs_slim.py) which can produce model in format needed for web workers.

All examples which were using models from OBJ converter were refactored to use Loader.

Except large mesh example, all examples are using just async JS loading. Web worker loading is there, it's just commented out, as it's a bit pain for local development.

Chrome doesn't allow to run web workers from pages accessed via file://, so you need either to run it with "--allow-file-access-from-files" flag, or access examples via local server (http://localhost/example.html).
2010-11-03 18:12:31 +01:00