Also moved loadImageArray utility function from examples into TextureCube.js
To be used like this:
var urls = [ "px.jpg", "nx.jpg", "py.jpg", "ny.jpg", "pz.jpg", "nz.jpg" ];
var images = THREE.loadImageArray( urls );
var textureCube = new THREE.TextureCube( images );
// create scene
var objectMaterial = new THREE.MeshBasicMaterial( { color: 0xffffff, env_map: textureCube } )
createScene( objectMaterial );
// create panorama
var size = 100000;
var panoMaterial = new THREE.MeshCubeMaterial( { env_map: textureCube } );
var mesh = new THREE.Mesh( new Cube( size, size, size, 1, 1, null, true ), panoMaterial );
sceneCube.addObject( mesh );
Warning: this functionality is currently changing a lot, expect things to get broken before stabilization.
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
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...)
Models exported by this version should be loaded like this (the same as for slim OBJ converter):
var loader = new THREE.Loader();
loader.loadAscii( "path/to/model/Model.js", function( geometry ) { createScene( geometry ) }, "path/to/model" );
Compared to OBJ converter, currently only single mesh is exported (many models are composed of several meshes).
TODO
- model alignment
- copy used images to folder where exported file goes
- export all selected meshes / all meshes in the scene?
- binary format
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