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).
Fixed Blender importer to work with Blender 2.60, add option for importing workers or non-worker models.
Fixed more examples to use worker-less format. All examples should work now.
Only Max exporter should be left to change.
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)
Slightly modified ro.me buffalo test - using alpha test instead of alpha transparency to get rid of artefacts, also increased number of buffaloes to 375.
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.
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.
Work-in-progress.
So close yet so far. Test scene almost works, just two things are not rotated properly (which means maybe everything will need to be reworked :(
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;
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
Changed materials a bit to look better with lighter environment map.
Added space to buttons HTML so that Firefox don't draw them sticked together.
Also re-added htaccess for BIN files.