49 Commits
Author SHA1 Message Date
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 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
Mr.doob fb4935d35b Trying to avoid merge conflicts :S 2010-11-02 19:38:04 +00:00
Mr.doob f30216ff8e Applying alteredq's CanvasRenderer fix re Ambient Light calculation to SVGRenderer. 2010-11-01 18:30:05 +00:00
alteredq a8ff77e1d4 Fixed ambient light computation in CanvasRenderer to get correct lighting when there is no ambient light specified in the scene. 2010-11-01 13:47:10 +01:00
alteredq 9d2aaf4e4c Synced with mrdoob's branch. 2010-11-01 13:12:18 +01:00
Mr.doob daf2700ccb * Projector.js: Rather than calculating the screen space centrium of each face per render, seemed smarter to just project the precomputed centrium. Side effect: Polygon shaking is gone \o/ 2010-10-31 02:31:14 +00:00
alteredq 8e31bbb165 Synced with mrdoob's branch. 2010-10-31 03:07:31 +01:00
alteredq b150a74755 Synced with mrdoob's branch. 2010-10-31 01:40:25 +02:00
alteredq 1c35d90fd7 Added handling of multiple lights to WebGLRenderer.
Limitations:

 - Chrome can handle up to 5 lights in total (directional + point)
 - Firefox seems to handle up to 29 lights

These number are GPU specific (mine is ATI Mobility Radeon 3650).

This turned out to be quite tricky. The number of varying vectors in shaders is limited. Additionally Chrome and Firefox have different limitations (at least on Windows, probably due to Chrome using ANGLE as rendering backend).

Hence WebGLRenderer has hardcoded limit of maximum 5 lights.

WebGLRenderer constructor now takes (optional) scene argument, so that numbers and types of lights present in the scene can be used to generate minimal possible shader.

If no scene is passed, shader allowing 1 directional + 4 point lights will be generated.
2010-10-31 00:45:04 +02:00
Mr.doob 5b1a64e747 * Matrix4.makeOrtho() fixed 2010-10-30 05:05:02 +01:00
Mr.doob 7eacf2ae0e * Fixed Matrix4.makeOrtho(). bottom - top -> top - bottom
* Added `camera_orthographic` example.
2010-10-30 05:00:42 +01:00
alteredq 45f7464793 Synced with mrdoob's branch. 2010-10-29 09:43:18 +02:00
Mr.doob a0e9935a0f * Minor change to SVGRenderer 2010-10-28 21:48:32 +01:00
Mr.doob 1b1fb7affe * Code clean up (yuicompressor doesn't throw a single warning :D) and some reformating
* Minor fixes (Geometry normal calculation)
* Isolated Matrix3 code into `Matrix3.js`
* README and TODO updated
2010-10-28 21:27:58 +01:00
alteredq 79ab4bf2e6 Merged with mrdoob's branch. Got WebGLRenderer working again :)
Changed OBJ -> Three.js converter to use new materials system (eventual old models need to be reconverted).

Limitations:

  - one use case is now much slower
    - when a mesh has each face with different color (e.g. polyfield in examples/test.html)
    - before this used FaceColorFill material and in WebGLRenderer it was rendered fast with color attribute array
    - now when FaceColorFill material is gone, each face gets own VBO :(

  - material sorting uses Materials "toString" methods for hashing, so it's very important to keep these in a good shape
2010-10-28 19:35:13 +02:00
alteredq b6904f3d72 Added Blinn-Phong material for WebGLRenderer.
In Chrome it looks more or less ok, but it has some problem in Firefox 4 (with some camera angles there are black areas around edges).

Also updated Python builder scripts and examples to include this new material.
2010-10-27 21:16:11 +02:00
Mr.doob 7464f5ff97 * MeshBitmapUVMappingMaterial -> MeshBitmapMaterial. Second param is mode, which is THREE.MeshBitmapMaterialMode.UVMAPPING by default.
* Removed MeshFaceColorFillMaterial and MeshFaceColorStrokeMaterial
* Added MeshFaceMaterial ( it uses the face.material for that pass )
* CanvasRenderer and SVGRenderer per face material logic changed.
* SVGRenderer supports particles again.
* WebGLRenderer currently broken :/
* Code clean up
2010-10-27 08:49:00 +01:00
alteredq 277d117b3d Refactored multimaterials to also work with non-textured models composed from multiple material groups.
Old version was doing massive overdraw (whole mesh was drawn for each material).

Even current solution is still quite messy: there is a different behavior for stroke and fill materials (when used as secondary materials).

Stroke materials are applied to the complete mesh (as most common use case seems to be wireframe) while fill materials now apply only to faces within single material group (when "decalIndex" property of secondary fill material is set).
2010-10-26 12:18:30 +02:00
alteredq 4a7082165a Synced with mrdoob's branch. 2010-10-24 19:53:36 +02:00
alteredq 2f1bf335c6 Forgot to build single file libraries and bump up version number. 2010-10-24 18:55:31 +02:00
Mr.doob 369a8661dc * WebGLRenderer: update camera and object matrices if autoUpdateMatrix == true 2010-10-23 16:57:10 +02:00
Mr.doob 836f1b878f * CanvasRenderer light per particle and lines 2010-10-23 02:22:52 +02:00
alteredq 69d93317c8 Forgot to build single file libraries. 2010-10-22 02:49:58 +02:00
alteredq ce000d482f Merged remote branch 'upstream/master' (original mrdoob's version) 2010-10-21 02:00:52 +02:00
alteredq dde831bf6f Extended CanvasRenderer to be able to handle decals (MeshBitmapUVMappingMaterials as secondary materials).
For decals you need to set "decalIndex" property of the material (corresponding to materials index of the original mesh UV material).

Added multimaterials example.

Fixed forgotten sphere smoothing in OBJ converter example.
2010-10-21 01:38:29 +02:00
Mr.doob db7003e88a * CanvasRenderer and SVGRenderer calculating light only when needed. 2010-10-20 05:14:45 +01:00
unknown 60c2354424 Added OBJ -> Three.js converter.
Added OBJ converter test example.

Modified Three.js to handle converted models:

 - extended WebGL renderer to use texturing
   - broke down model into multiple VBOs according to materials
   - textures are lazy created when images get loaded
     (converter takes care of resizing images to nearest power of 2
      dimensions using 2d canvas)

 - changed material array semantics in Mesh object
    - before: multiple materials were applied to all faces (broken in WebGL, needs multitexturing shader)
    - now: there is only single material per face, but one mesh can have faces with different materials

 - added per vertex normals (to get smooth shading in WebGL)
2010-10-18 11:33:32 +02:00
Mr.doob 647b4a57b8 * Added PointLight
* `CanvasRenderer` and `SVGRenderer` basic lighting support (`*ColorStroke`/`*ColorFill` only)
* `Renderer` > `Projector`. `CanvasRenderer`, `SVGRenderer` and `DOMRenderer` do not extend anymore
* Interactivity base code (hdi folder). To be refactored... ([mindlapse](http://github.com/mindlapse))
* Added `computeCentroids` method to `Geometry`
* Included `Stats.js` directly in the `/examples` folder to avoid the need of internet for playing around
2010-10-06 03:36:21 +01:00
Mr.doob 5ce7a10bbb - Added TODO
- Minor tweaks
2010-09-21 06:59:06 +01:00
Mr.doob e68109fdb2 - Clean up 2010-09-17 02:52:29 +01:00
Mr.doob 216b4eeee2 * Workaround for Opera bug (clearRect not working with context with negative scale)
* Additional `Matrix4` and `Vector3` methods
2010-08-21 02:58:07 +01:00
Mr.doob 8b18eafc78 - Added "Or so they say..." demo to featured projects.
- Camelcased the minified files (it feels weird both ways anyway...)
2010-07-25 03:34:29 +01:00