22 Commits
Author SHA1 Message Date
alteredq e08434c183 Reworked binary format / BinaryLoader / OBJ converter to use binary ajax fetch.
It was quite a pain - ArrayBuffers / Typed Arrays are fussy about byte alignment - but seems to be worth it.

Parsing times are down (modest gains for small objects / Firefox, bigger gains for large objects / Chrome, performance gains from 10% - 200%).

Also as a positive side effect, changing interleaved face arrays into uniform arrays seems to have helped a bit with gzip compression (about 6% smaller size for gzipped 526K Lucy).
2011-11-03 20:30:10 +01:00
alteredq d2cad69664 Started to remove workers from the asset pipeline.
Work-in-progress => do not merge yet.

OBJ converter, JSONLoader, BinaryLoader and some examples are done. Still need to do Blender exporter, SceneLoader and more examples.

Advantages:

- faster parse times
- bypass array initializer size limit in Firefox
- no more crashes in Chrome 15 (caused by too many concurrently active workers)

Disadvantages:

- more browser UI freezing
- multiple models tend to appear all at once with the last one (instead of popping up progressively)
2011-10-30 22:09:55 +01:00
alteredq a60595b3f7 Removed edges handling from asset pipeline (Blender exporter, OBJ converter, JSONLoader). 2011-10-02 16:13:44 +02:00
alteredq 023024f520 Updated Blender scene exporter to output proper JSON. Changed OBJ converter to dump less digits for floats. 2011-05-07 21:31:16 +02:00
alteredq 7ee6cc33eb OBJ converter: add option for scaling and truncating vertex coordinates (flag "-x scale").
To be used like this:

python convert_obj_three.py -i lucy100k.obj -o Lucy100k_slim.js -a center -s flat -x 100

It should work also for morph vertices.
2011-04-21 14:36:53 +02:00
alteredq 5fa19e8460 Fixed delays when loading multiple models.
Problem was having too many concurrent workers opened at once. Garbage collection apparently works very slowly on workers. Solution was to close them manually, after model data is sent to main thread.

Also some progress with Blender scene exporter. Some scenes now export correctly, though monkey test scene got worse, even with less hacky code.
2011-04-07 02:59:49 +02:00
alteredq f7e3a80d70 Added edges computation to OBJ converter.
If you want to get edges, run converter like with "-e" flag:

python convert_obj_three.py -i model.obj -o model.js -e

Output seems to match Blender exporter.
2011-04-05 03:37:13 +02:00
Mr.doob abb4a774cd Merging with alteredq. 2011-04-04 05:00:21 +01:00
alteredq b31b8eebcd Changed exporters, converters and example models to use more proper JSON.
Single quote property names and hex numbers are not valid in JSON.
2011-03-26 06:05:46 +01:00
alteredq 2989defcc8 First version that is at least partially working with the new model format ;).
Tons of things still broken.
2011-03-21 00:58:12 +01:00
alteredq a230b659ab More fixes.
Getting closer though still having some junk data poping out here and there.
2011-03-20 22:25:41 +01:00
alteredq bdc19a15c2 Updated OBJ converter to create new JSON model format.
Not tested yet, as the rest of the engine doesn't work yet.
2011-03-20 20:14:23 +01:00
alteredq ccdff87382 Changed also JSON model files and exporters/converters to use CamelCase property names.
Only Blender 2.56 exporter and OBJ converter were tested. If somebody is using other ones, please reexport some files to be sure they work.
2011-03-02 05:55:29 +01:00
alteredq bc11316ae9 Back at master branch.
Hooray. So long materials branch, you served us well ;)
2010-11-17 20:31:39 +01:00
Mr.doob 5feee3839f Trying to merge... 2010-11-15 01:56:10 +00: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
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
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
alteredq f32fc45541 Added WebGL version of pointlights example (including Walt's head mesh with vertex normals). 2010-10-31 01:46:20 +02:00