Launch Week Day 5: Introducing Reachability for PHP.Learn More
Socket
Book a DemoSign in
Socket

jbb

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jbb - npm Package Compare versions

Comparing version
1.3.0
to
1.3.2
doc/table_OP_BULK_KNOWN.png

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

+39
{
"normals": [0.577349,-0.577349,-0.577349,0.577349,-0.577349,0.577349,-0.577349,-0.577349,0.577349,-0.577349,-0.577349,-0.577349,0.577349,0.577349,-0.577349,-0.577349,0.577349,-0.577349,-0.577349,0.577349,0.577349,0.577349,0.577349,0.577349],
"uvs": [[0,0,1,0,1,1,0,1]],
"name": "CubeGeometry.1",
"materials": [{
"colorDiffuse": [0.64,0.64,0.64],
"DbgIndex": 0,
"colorEmissive": [0,0,0],
"wireframe": false,
"mapDiffuseWrap": ["RepeatWrapping","RepeatWrapping"],
"colorAmbient": [0.64,0.64,0.64],
"specularCoef": 50,
"transparent": false,
"colorSpecular": [0,0,0],
"mapDiffuseAnisotropy": 1,
"opacity": 1,
"blending": "NormalBlending",
"visible": true,
"depthWrite": true,
"DbgName": "Material",
"depthTest": true,
"DbgColor": 15658734,
"mapDiffuse": "crate.png",
"mapDiffuseRepeat": [1,1],
"shading": "phong"
}],
"vertices": [1,-1,-1,1,-1,1,-1,-1,1,-1,-1,-1,1,1,-1,0.999999,1,1,-1,1,1,-1,1,-1],
"faces": [43,0,1,2,3,0,0,1,2,3,0,1,2,3,43,4,7,6,5,0,0,1,2,3,4,5,6,7,43,0,4,5,1,0,0,1,2,3,0,4,7,1,43,1,5,6,2,0,0,1,2,3,1,7,6,2,43,2,6,7,3,0,0,1,2,3,2,6,5,3,43,4,0,3,7,0,0,1,2,3,4,0,3,5],
"metadata": {
"normals": 8,
"uvs": 1,
"materials": 1,
"faces": 6,
"generator": "io_three",
"type": "Geometry",
"vertices": 8,
"version": 3
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

# Using `jbb` with `THREE.js`
The JBB Project was initially started in order to optimally store resources for THREE.js scenes. Therefore it's only natural to have a dedicated guide on how to use it with three.js.
You can integrate jbb in your pipeline in various ways. In this tutorial we are going to use `gulp-jbb` for steering the creation of bundles, but we are not going to create a gulp-based binary project.
## 1. Getting Started
For the bare minimum requirements you will need to install `node` and a few packages. Start by creating a new directory for our project and install the following packages locally:
```
npm install jbb jbb-profile-three gulp gulp-jbb three
```
Then create two directories:
* `bundles` - Were the bundle sources are located.
* `build` - Were the built files will be placed.
```
mkdir bundles build
```
## 3. Creating a THREE.js scene
Let's start by creating a new page for our three.js scene. Create a new file `index.html` in the root directory with the following contents:
```html
<!DOCTYPE html>
<html lang="en">
<head>
<title>three.js + jbb.js</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<style>
body {
font-family: Monospace;
background-color: #000000;
margin: 0px;
overflow: hidden;
}
</style>
</head>
<body>
<script src="node_modules/three/three.min.js"></script>
<script src="node_modules/jbb/dist/jbb.min.js"></script>
<script src="node_modules/jbb-profile-three/dist/jbb-profile-three.min.js"></script>
<script>
var container;
var camera, scene, renderer;
var pointLight;
init();
animate();
function init() {
container = document.createElement( 'div' );
document.body.appendChild( container );
camera = new THREE.PerspectiveCamera( 35, window.innerWidth / window.innerHeight, 1, 2000 );
camera.position.set( 2, 4, 5 );
scene = new THREE.Scene();
scene.fog = new THREE.FogExp2( 0x000000, 0.035 );
// Lights
scene.add( new THREE.AmbientLight( 0xcccccc ) );
pointLight = new THREE.PointLight( 0xffffff, 5, 30 );
pointLight.position.set( 15, 15, 0 );
scene.add( pointLight );
// Renderer
renderer = new THREE.WebGLRenderer();
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( window.innerWidth, window.innerHeight );
container.appendChild( renderer.domElement );
// Events
window.addEventListener( 'resize', onWindowResize, false );
// TODO : Add something on the scene
}
function onWindowResize( event ) {
renderer.setSize( window.innerWidth, window.innerHeight );
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
}
function animate() {
render();
requestAnimationFrame( animate );
}
function render() {
// Rotate camera around center
var timer = Date.now() * 0.0005;
camera.position.x = Math.cos( timer ) * 10;
camera.position.y = 4;
camera.position.z = Math.sin( timer ) * 10;
camera.lookAt( scene.position );
renderer.render( scene, camera );
}
</script>
</body>
</html>
```
Open your `index.html` file and check your javascript console. If you see no errors you are ready to continue. Don't worry about the empty black content for now...
## 2. Creating a bundle
For our example we are going to bundle a textured cube. We used [Blender](https://www.blender.org/) and [THREE.js exporter](https://github.com/mrdoob/three.js/tree/master/utils/exporters/blender) to create a very simple crate:
<img src="https://raw.githubusercontent.com/wavesoft/jbb/master/doc/Tutorial 1 - THREEjs/img/1-blender.png" />
After exporting the cube, we have two files: `crate.json` and `crate.png`. The first contains the cube mesh and the second the diffuse map for the texture. You can find the files [here](https://github.com/wavesoft/jbb/tree/master/doc/Tutorial 1 - THREEjs/files).
To create a new bundle, we are going to create a new bundle directory in the `bundles` folder and a new specifications file.
```
mkdir bundles/crate.jbbsrc
```
Move the two files in the `crate.jbbsrc` directory and create an additional new file called `bundle.json` with the following contents:
```json
{
"name": "crate",
"exports": {
"THREE.JSONLoader": {
"crate" : "crate.json",
}
}
}
```
This is the _index_ file of the bundle and instructs jbb to first load `crate.json` using the `THREE.JSONLoader` and to export it under the name `crate/crate`. The first, `name` argument should be the same as the bundle folder name (without the extension).
## 3. Creating a Gulpfile.js
In order to build our bundles we can either use the `jbb` command-line, or we can create a gulpfile to automate the build process using `gulp`.
Create a new file called `gulpfile.js` in your root directory with the following contents:
```javascript
var gulp = require('gulp');
var jbb = require('gulp-jbb');
//
// Compile the binary bundles
//
gulp.task('bundles', function() {
return gulp
.src([ "bundles/*.jbbsrc" ])
.pipe(jbb({
profile: 'three'
}))
.pipe(gulp.dest('build/bundles'));
});
// By default build bundles
gulp.task('default', ['bundles' ]);
```
Note the `profile` parameter in the `jbb` group. It instructs jbb to use the [jbb-profile-three](github.com/wavesoft/jbb-profile-three) in order to correctly handle THREE.js objects. Without it `jbb` will complain about unknown object instances.
You can now build your bundle just by running `gulp`
```
$ gulp
[21:07:10] Using gulpfile .. /gulpfile.js
[21:07:10] Starting 'bundles'...
Loader.createMaterial: Unsupported colorAmbient [ 0.64, 0.64, 0.64 ]
Loading .. /bundles/crate.jbbsrc/crate.png
[21:07:10] Finished 'bundles' after
[21:07:10] Starting 'default'...
[21:07:10] Finished 'default' after 115 μs
```
You can confirm that `crate.jbb` exists in your `build/bundles` directory.
## 4. Loading the bundle in the scene
Now that we have our bundle, it's time to load it into our THREE.js scene. To do so, we are going to use the `JBBBundleLoader` that was made available when we included the `jbb.min.js` file.
Change the last part of the init() function like this:
```javascript
// TODO : Add something on the scene
var bundleLoader = new JBBBinaryLoader();
bundleLoader.addProfile( JBBProfileThree );
// Get model from bundle
bundleLoader.add("build/bundles/crate.jbb");
bundleLoader.load( function(error, database) {
var geometry = database['crate/crate'];
var materials = database['crate/crate:extra'];
var mesh = new THREE.Mesh( geometry, materials[0] );
scene.add(mesh);
});
```
Let's see this step-by-step: First, we are creating a new instance to the `JBBBinaryLoader` class. This is responsible for loading and parsing the bundles.
```javascript
var bundleLoader = new JBBBinaryLoader();
```
Right after, we are adding a decoding profile to the loader using the `.addProfile()` method. Similar to the encoding process, a profile contains the decoding information for the objects.
We have already loaded `jbb-profile-three.min.js`, that exposes the `JBBProfileThree` global variable, so we can use it right-away:
```javascript
bundleLoader.addProfile( JBBProfileThree );
```
Then, we request jbb loader to load our crate bundle. We can add more bundles if needed. Additional bundles might also be loaded if a dependency is encountered.
```javascript
bundleLoader.add("build/bundles/crate.jbb");
```
To actually start loading the bundle we are calling the `.load` function. This will trigger a callback when the operation has completed.
```javascript
bundleLoader.load( function(error, database) {
...
});
```
If there was no error while loading the bundle, the `error` argument will be `null` and the `database` argument will be a dictionary-like object with all the loaded objects.
Therefore, we can easily access the encoded crate like this:
```javascript
var geometry = database['crate/crate'];
```
Since the cube stored in `crate.json` file is not an object, but just the geometry to the cube, the `THREE.JSONLoader` will create a `THREE.Geometry` object. Since that's the loader's default return value, this geometry will be accessible as `<bundle name>/<export name>`.
However `THREE.JSONLoader` also returns an array of `THREE.Material` instances as a separate argument. Such 'extra' information is available under the `<bundle name>/<export name>:extra` name.
Therefore we have enough information to create a new textured mesh:
```javascript
var materials = database['crate/crate:extra'];
var mesh = new THREE.Mesh( geometry, materials[0] );
scene.add(mesh);
```
If everything went as expected, you will see something like this:
<img src="https://raw.githubusercontent.com/wavesoft/jbb/master/doc/Tutorial 1 - THREEjs/img/2-result.png" />
If you are using `Chrome` you will need to see this page over `http:`. You can use the minimalistic http server from node to serve your resources locally:
```
~$ npm install http-server
~$ ./node_modules/http-server/bin/http-server
Starting up http-server, serving ./
Available on:
http://127.0.0.1:8080
```
And you can now see your results on [http://127.0.0.1:8080](http://127.0.0.1:8080).
+17
-4

@@ -1034,3 +1034,3 @@ "use strict";

*/
var BinaryLoader = function( profile, baseDir, database ) {
var BinaryLoader = function( baseDir, database ) {

@@ -1053,3 +1053,3 @@ // Check for missing baseDir

// Keep object table
this.profile = profile;
this.profile = null;

@@ -1069,2 +1069,11 @@ // References for delayed GC

/**
* Add profile information to the decoder
*/
'addProfile': function( profile ) {
if (this.profile !== null)
throw new Errors.AssertError('You can currently add only one profile!');
this.profile = profile;
},
/**
* Load the specified bundle from URL and call the onsuccess callback.

@@ -1078,2 +1087,6 @@ * If an error occures, call the onerror callback.

// Check for profile
if (this.profile === null)
throw new Errors.AssertError('You must first add a profile!');
// Check for base dir

@@ -1150,3 +1163,3 @@ var prefix = "";

if (this.queuedRequests.length === 0) {
callback( null, this );
callback( null, this.database );
return;

@@ -1259,3 +1272,3 @@ }

this.queuedRequests = [];
callback( null, this );
callback( null, this.database );

@@ -1262,0 +1275,0 @@ // GC After a delay

@@ -1082,3 +1082,3 @@ /* JBB Binary Bundle Loader - https://github.com/wavesoft/jbb */

*/
var BinaryLoader = function( profile, baseDir, database ) {
var BinaryLoader = function( baseDir, database ) {

@@ -1101,3 +1101,3 @@ // Check for missing baseDir

// Keep object table
this.profile = profile;
this.profile = null;

@@ -1117,2 +1117,11 @@ // References for delayed GC

/**
* Add profile information to the decoder
*/
'addProfile': function( profile ) {
if (this.profile !== null)
throw new Errors.AssertError('You can currently add only one profile!');
this.profile = profile;
},
/**
* Load the specified bundle from URL and call the onsuccess callback.

@@ -1126,2 +1135,6 @@ * If an error occures, call the onerror callback.

// Check for profile
if (this.profile === null)
throw new Errors.AssertError('You must first add a profile!');
// Check for base dir

@@ -1198,3 +1211,3 @@ var prefix = "";

if (this.queuedRequests.length === 0) {
callback( null, this );
callback( null, this.database );
return;

@@ -1307,3 +1320,3 @@ }

this.queuedRequests = [];
callback( null, this );
callback( null, this.database );

@@ -1310,0 +1323,0 @@ // GC After a delay

+1
-1
/* JBB Binary Bundle Loader - https://github.com/wavesoft/jbb */
var JBBBinaryLoader=function(r){function t(i){if(e[i])return e[i].exports;var s=e[i]={exports:{},id:i,loaded:!1};return r[i].call(s.exports,s,s.exports,t),s.loaded=!0,s.exports}var e={};return t.m=r,t.c=e,t.p="",t(0)}([function(r,t,e){"use strict";function i(r,t){var e=r.readStringLT(),i=new Blob([r.readTypedArray(T.UINT8,t)],{type:e});return URL.createObjectURL(i)}function s(r,t,e){var s=0,n="";switch(t){case 0:s=r.u8[r.i8++];break;case 1:s=r.u16[r.i16++];break;case 2:s=r.u32[r.i32++];break;case 3:s=r.f64[r.i64++]}if(0===e)return n=String.fromCharCode.apply(null,r.readTypedArray(T.UINT8,s));if(1===e)return n=String.fromCharCode.apply(null,r.readTypedArray(T.UINT16,s));if(2===e){var a=document.createElement("img");return a.src=i(r,s),a}if(4===e){var a=document.createElement("script");return a.src=i(r,s),a}if(7===e)return i(r,s);throw new w.AssertError("Unknown buffer type #"+e+"!")}function n(r,t,e){if(!(32&e&&32!==(48&e))){var i=e;32&e&&(i=r.u8[r.i8++]|(15&e)<<8);var s=r.profile.decode(i);if(void 0===s)throw new w.AssertError("Could not found known object entity #"+i+"!");var n=s.create();r.iref_table.push(n);var a=d(r,t);return s.init(n,a),n}if(56!==(60&e)){if(48===(56&e)){var i=(7&e)<<8|r.u8[r.i8++],o=d(r,t),u=r.factory_plain[i];if(void 0===u)throw new w.AssertError("Could not found simple object signature with id #"+i+"!");return u(o)}throw new w.AssertError("Unexpected object opcode 0x"+e.toString(16)+"!")}var h=3&e;switch(h){case 0:var c=r.f64[r.i64++];10*r.s8[r.i8++];return new Date(c);default:throw new w.AssertError("Unknown primitive object with POID #"+h+"!")}}function a(r,t,e,i){for(var s=new I[m.FROM[i]](e),n=r.readTypedNum(m.FROM[i]),a=r.readFloat64(),o=r.readTypedArray(m.TO[i],e),u=0;e>u;++u)s[u]=n+o[u]*a,console.log("<<<",o[u],"->",s[u]);return s}function o(r,t,e,i){var s=A.FROM[i],n=new I[s](e),a=0;switch(s){case 0:a=r.u8[r.i8++];break;case 1:a=r.s8[r.i8++];break;case 2:a=r.u16[r.i16++];break;case 3:a=r.s16[r.i16++];break;case 4:a=r.u32[r.i32++];break;case 5:a=r.s32[r.i32++];break;case 6:a=r.f32[r.i32++];break;case 7:a=r.f64[r.i64++]}var o=r.readTypedArray(A.TO[i],e-1);n[0]=a;for(var u=0,h=o.length;h>u;++u)a+=o[u],n[u+1]=a;return n}function u(r,t){var e=r.u16[r.i16++],i=r.signature_table[e],s=r.factory_plain_bulk[e];if(void 0===s)throw new w.AssertError("Could not found simple object signature with id #"+e+"!");for(var n=d(r,t),a=n.length/i.length,o=new Array(a),u=0;a>u;++u)o[u]=s(n,u);return o}function h(r,t,e,i){for(var s=new Array(r),n=r-1;n>=0;--n)s[n]=e[i+t*n];return s}function c(r,t,e){var i=!1,s=r.u16[r.i16++],n=r.profile.decode(s),a=n.props,o=0,u=[],c=0,f=0,l=0,p=null,y=0,v=0,b=[],g=[];for(65536>e?(l=r.u16[r.i16++],i&&console.log("-<- HINT16="+l)):(l=r.u32[r.i32++],i&&console.log("-<- HINT32="+l)),u=Array(l),c=0;l>c;++c)r.iref_table.push(u[c]=n.create());if(l){if(b=d(r,t),void 0===b.length)throw new w.AssertError("Decoded known bulk primitive is not array!");o=b.length/a}var T=new Array(e),E=0,A=void 0;for(c=0;e>c;)if(v=r.u8[r.i8++],(128&v)===_.LREF_7)f=127&v,i&&console.log("-<- LREF_7(",f,"), i=",c),T[c++]=A=g[f];else if((192&v)===_.DEFINE){for(f=(63&v)+1,i&&console.log("-<- DEFINE(",f,"), i=",c),y=0;f>y;y++)p=u[E],n.init(p,h(a,o,b,E)),T[c++]=p,E++;A=p}else if((224&v)===_.REPEAT)for(f=(31&v)+1,i&&console.log("-<- REPEAT(",f,"), i=",c),y=0;f>y;y++)T[c++]=A;else if((240&v)===_.IREF){if(f=(15&v)<<16|r.u16[r.i16++],i&&console.log("-<- IREF(",f,"), i=",c),f>=r.iref_table.length)throw new w.IRefError("Invalid IREF #"+f+"!");T[c++]=A=r.iref_table[f],g.push(r.iref_table[f])}else if((248&v)===_.LREF_11)f=(7&v)<<8|r.u8[r.i8++],i&&console.log("-<- LREF_11(",f,"), i=",c),T[c++]=A=g[f];else if(v===_.LREF_16)f=r.u16[r.i16++],i&&console.log("-<- LREF_16(",f,"), i=",c),T[c++]=A=g[f];else if(v===_.XREF){if(f=r.readStringLT(),i&&console.log("-<- XREF(",f,"), i=",c),void 0===t[f])throw new w.XRefError("Cannot import undefined external reference "+f+"!");T[c++]=A=t[f]}return T}function f(r,t,e,i){for(var s,n,a=r.u8[r.i8++],o=[],u=0,h=!0,c=0,f=0,d=0,p=0,y=0,v=0;e>u;){if(i)if(64===(240&a)){switch(d=1&a,p=a>>1&7,y=d?r.u32[r.i32++]:r.u16[r.i16++],h&&(n=new I[p](e),h=!1),p){case 0:v=r.u8[r.i8++];break;case 1:v=r.s8[r.i8++];break;case 2:v=r.u16[r.i16++];break;case 3:v=r.s16[r.i16++];break;case 4:v=r.u32[r.i32++];break;case 5:v=r.s32[r.i32++];break;case 6:v=r.f32[r.i32++];break;case 7:v=r.f64[r.i64++]}n.fill(v,u,u+y),u+=y}else{if(s=l(r,t,a),void 0===s.length)throw new w.AssertError("Encountered non-array chunk as part of chunked array!");if(h&&(n=new s.constructor(e),h=!1),!(s instanceof n.constructor))throw new w.AssertError("Got is_numeric flag, but chunks are not of the same type (op was "+a+"!");n.set(s,u),u+=s.length}else{if(s=l(r,t,a),void 0===s.length)throw new w.AssertError("Encountered non-array chunk as part of chunked array!");for(h&&(o=new Array(e),h=!1),c=0,f=s.length;f>c;c++,u++)o[u]=s[c]}if(!(e>u))break;a=r.u8[r.i8++]}return i?n:o}function l(r,t,e){var i,s=0,n=0,h=0,l=0,p=[];if(e=255&e,110===e)return u(r,t);if(111===e){for(l=r.u8[r.i8++],p[l-1]=null,s=0;l>s;++s)p[s]=d(r,t);return p}if(126===e)return[];if(127===e)throw new w.AssertError("Encountered PRIM_CHUNK_END outside of chunked array!");if(0===(224&e)){h=1&e,n=e>>1&15,l=h?r.u32[r.i32++]:r.u16[r.i16++],i=r.readTypedArray(E.TO[n],l);var y=new I[E.FROM[n]](i);return y}if(32===(240&e))return h=1&e,n=e>>1&7,l=h?r.u32[r.i32++]:r.u16[r.i16++],o(r,t,l,n);if(48===(240&e))return h=1&e,n=e>>1&7,l=h?r.u32[r.i32++]:r.u16[r.i16++],a(r,t,l,n);if(64===(240&e)){switch(h=1&e,n=e>>1&7,l=h?r.u32[r.i32++]:r.u16[r.i16++],n){case 0:i=r.u8[r.i8++];break;case 1:i=r.s8[r.i8++];break;case 2:i=r.u16[r.i16++];break;case 3:i=r.s16[r.i16++];break;case 4:i=r.u32[r.i32++];break;case 5:i=r.s32[r.i32++];break;case 6:i=r.f32[r.i32++];break;case 7:i=r.f64[r.i64++]}var y=new I[n](l);for(s=0;l>s;++s)y[s]=i;return y}if(80===(240&e))return h=1&e,n=e>>1&7,l=h?r.u32[r.i32++]:r.u16[r.i16++],p=r.readTypedArray(n,l);if(96===(248&e))return n=7&e,l=r.u8[r.i8++],p=r.readTypedArray(n,l);if(104===(254&e)){for(h=1&e,l=h?r.u32[r.i32++]:r.u16[r.i16++],i=d(r,t),p[l-1]=null,s=0;l>s;s++)p[s]=i;return p}if(106===(254&e)){for(h=1&e,l=h?r.u32[r.i32++]:r.u16[r.i16++],p[l-1]=null,s=0;l>s;++s)p[s]=d(r,t);return p}if(120===(252&e))return h=1&e,n=e>>1&1,l=h?r.u32[r.i32++]:r.u16[r.i16++],f(r,t,l,n);if(124===(254&e))return h=1&e,l=h?r.u32[r.i32++]:r.u16[r.i16++],c(r,t,l);throw new w.AssertError("Unknown array op-code 0x"+e.toString(16)+" at offset @"+(r.i8-r.ofs8)+"!")}function d(r,t){var e=r.u8[r.i8++];if(0===(128&e))return l(r,t,127&e);if(128===(192&e))return n(r,t,63&e);if(192===(224&e))return s(r,(24&e)>>3,7&e);if(224===(240&e)){var i=r.u16[r.i16++];if(i=(15&e)<<16|i,i>=r.iref_table.length)throw new w.IRefError("Invalid IREF #"+i+"!");return r.iref_table[i]}if(240===(248&e))switch(7&e){case 0:return r.u8[r.i8++];case 1:return r.s8[r.i8++];case 2:return r.u16[r.i16++];case 3:return r.s16[r.i16++];case 4:return r.u32[r.i32++];case 5:return r.s32[r.i32++];case 6:return r.f32[r.i32++];case 7:return r.f64[r.i64++]}else{if(248===(252&e))return k[3&e];if(252===(254&e))return F[2&e];if(254===(255&e)){var a=r.readStringLT();if(void 0===t[a])throw new w.XRefError("Cannot import undefined external reference "+a+"!");return t[a]}if(255===(255&e))throw new w.AssertError("Encountered RESERVED primitive operator!")}}function p(r,t){for(;!r.eof();){var e=r.u8[r.i8++];switch(e){case 248:var i=r.prefix+r.readStringLT();t[i]=d(r,t);break;default:throw new w.AssertError("Unknown control operator 0x"+e.toString(16)+" at @"+r.i8+"!")}}}function y(r,t){var e=r.length,i=Array(e),s=!1;return r.forEach(function(n,a){var o=new XMLHttpRequest;o.open("GET",r[a]),o.responseType="arraybuffer",o.send(),o.addEventListener("readystatechange",function(){if(4===o.readyState)if(200===o.status)i[a]=o.response,0===--e&&t(null);else{if(s)return;t("Error loading "+r[a]+": "+o.statusText),s=!0}})}),i}var v=e(1),w=e(2);const b=0,g=1,T={UINT8:0,INT8:1,UINT16:2,INT16:3,UINT32:4,INT32:5,FLOAT32:6,FLOAT64:7},E={FROM:[T.UINT16,T.INT16,T.UINT32,T.INT32,T.UINT32,T.INT32,T.FLOAT32,T.FLOAT32,T.FLOAT32,T.FLOAT32,T.FLOAT64,T.FLOAT64,T.FLOAT64,T.FLOAT64,T.FLOAT64],TO:[T.UINT8,T.INT8,T.UINT8,T.INT8,T.UINT16,T.INT16,T.UINT8,T.INT8,T.UINT16,T.INT16,T.UINT8,T.INT8,T.UINT16,T.INT16,T.FLOAT32]},A={FROM:[T.UINT16,T.INT16,T.UINT32,T.INT32,T.UINT32,T.INT32],TO:[T.INT8,T.INT8,T.INT8,T.INT8,T.INT16,T.INT16]},m={FROM:[T.FLOAT32,T.FLOAT32,T.FLOAT64,T.FLOAT64],TO:[T.INT8,T.INT16,T.INT8,T.INT16]},I=[Uint8Array,Int8Array,Uint16Array,Int16Array,Uint32Array,Int32Array,Float32Array,Float64Array],_=([T.UINT16,T.UINT32],[T.UINT8,T.UINT16,T.UINT32,T.FLOAT64],{LREF_7:0,LREF_11:240,LREF_16:254,IREF:224,XREF:255,DEFINE:128,REPEAT:192}),k=[void 0,null,!1,!0],F=[NaN];var N=function(r,t,e){"object"==typeof t&&(e=t,t=""),this.database=e||{},this.baseDir=t||"",this.queuedRequests=[],this.profile=r,this.__delayGC=[]};N.prototype={constructor:N,add:function(r,t){var e="";this.baseDir&&(e=this.baseDir+"/");var i=r.split("?"),s="",n=[];if(i.length>1&&(s="?"+i[1]),".jbbp"===i[0].substr(i[0].length-5).toLowerCase()){var a=e+i[0].substr(0,i[0].length-5);n=[a+".jbbp",a+"_b16.jbbp",a+"_b32.jbbp",a+"_b64.jbbp"]}else{var r=i[0];".jbb"!=r.substr(r.length-4)&&(r+=".jbb"),n=[e+r+s]}var o={callback:t,status:b,buffer:void 0,url:n};this.queuedRequests.push(o)},addByBuffer:function(r){var t={callback:void 0,status:g,buffer:r,url:void 0};this.queuedRequests.push(t)},load:function(r){this.__process(r)},__process:function(r){var t=this;if(r||(r=function(){}),0===this.queuedRequests.length)return void r(null,this);for(var e=!1,i=0;i<this.queuedRequests.length;++i)if(this.queuedRequests[i].status===b){e=!0;break}if(e)for(var s={counter:0},n=function(){0===--this.counter&&t.__process(r)}.bind(s),a=!1,i=0;i<this.queuedRequests.length;++i){var o=this.queuedRequests[i];o.status===b&&(s.counter++,o.buffer=y(o.url,function(t){return function(e){if(e){if(a)return;var i="Error downloading bundle: "+e;return t.callback&&t.callback(i,null),r&&r(i,null),void(a=!0)}t.status=g,n()}}(o)))}else{for(var i=0;i<this.queuedRequests.length;++i){var o=this.queuedRequests[i];if(o.status===g){var u;u=1===o.buffer.length?new v(o.buffer[0],t.profile):new v(o.buffer,t.profile),p(u,t.database),o.callback&&o.callback(null,o.bundle)}}this.queuedRequests=[],r(null,this),setTimeout(function(){this.__delayGC=[]}.bind(this),500)}}},r.exports=N},function(r,t){"use strict";function e(r){for(var t="",e=0;r>e;++e)0!==e&&(t+=","),t+="p[i+c*"+e+"]";return new Function("p","i","var c=p.length/"+r+";return ["+t+"]")}var i=function(r,t){this.profile=t,this.prefix="",this.sparse=r instanceof Array;var i,s,n,a=32;if(this.sparse?(this.u8=new Uint8Array(r[0]),this.s8=new Int8Array(r[0]),this.u16=new Uint16Array(r[1]),this.s16=new Int16Array(r[1]),this.u32=new Uint32Array(r[2]),this.s32=new Int32Array(r[2]),this.f32=new Float32Array(r[2]),this.f64=new Float64Array(r[3]),i=new Uint16Array(r[0],0,a/2),s=new Uint32Array(r[0],0,a/4),n=r[0].byteLength):(this.u8=new Uint8Array(r),this.s8=new Int8Array(r),this.u16=new Uint16Array(r),this.s16=new Int16Array(r),this.u32=new Uint32Array(r),this.s32=new Int32Array(r),this.f32=new Float32Array(r),this.f64=new Float64Array(r),i=new Uint16Array(r),s=new Uint32Array(r),n=r.byteLength),this.magic=i[0],this.table_id=i[1],this.version=i[2],this.ver_major=255&this.version,this.ver_minor=(65280&this.version)>>8,this.max64=s[2],this.max32=s[3],this.max16=s[4],this.max8=s[5],this.lenST=s[6],this.lenOT=s[7],12610==this.magic)throw{name:"EndianessError",message:"Unfortunately the JBB format is currently only compatible with Little-Endian CPUs",toString:function(){return this.name+": "+this.message}};if(16945!=this.magic)throw{name:"DecodingError",message:"This does not look like a JBB archive! (Magic is 0x"+this.magic.toString(16)+")",toString:function(){return this.name+": "+this.message}};if(258!=this.version)throw{name:"DecodingError",message:"Unsupported bundle version v"+this.ver_minor+"."+this.ver_minor,toString:function(){return this.name+": "+this.message}};if(this.table_id!=this.profile.id)throw{name:"DecodingError",message:"The profile ID (0x"+this.profile.id.toString(16)+") does not match the object table in the binary bundle (0x"+this.table_id.toString(16)+")",toString:function(){return this.name+": "+this.message}};this.sparse?(this.i64=0,this.i32=0,this.i16=0,this.i8=a,this.iEnd=this.i8+this.max8-this.lenST,this.ofs8=this.i8,this.ofs16=this.i16,this.ofs32=this.i32,this.ofs64=this.i64):(this.i64=a,this.i32=this.i64+this.max64,this.i16=this.i32+this.max32,this.i8=this.i16+this.max16,this.iEnd=this.i8+this.max8-this.lenST,this.ofs8=this.i8,this.ofs16=this.i16,this.ofs32=this.i32,this.ofs64=this.i64,this.i16/=2,this.i32/=4,this.i64/=8),this.iref_table=[];var o="",u=!1;if(this.string_table=[],this.lenST>0){for(var h=this.i8+this.max8,c=h-this.lenST;h>c;++c){var f=this.u8[c];0===f?(this.string_table.push(o),o="",u=!1):(o+=String.fromCharCode(f),u=!0)}u&&this.string_table.push(o)}var l=[],d=0,p=!1;if(this.signature_table=[],this.lenOT>0){for(var h=2*this.i16+this.max16,c=h-this.lenOT;h>c;c+=2){var f=this.u16[c/2];d--?l.push(this.string_table[f]):(p&&this.signature_table.push(l),l=[],d=f,p=!0)}p&&this.signature_table.push(l)}this.sparse?this.readTypedArray=function(t,e){var i=this.i8,s=2*this.i16,n=4*this.i32,a=8*this.i64;switch(t){case 0:return this.i8+=e,new Uint8Array(r[0],i,e);case 1:return this.i8+=e,new Int8Array(r[0],i,e);case 2:return this.i16+=e,new Uint16Array(r[1],s,e);case 3:return this.i16+=e,new Int16Array(r[1],s,e);case 4:return this.i32+=e,new Uint32Array(r[2],n,e);case 5:return this.i32+=e,new Int32Array(r[2],n,e);case 6:return this.i32+=e,new Float32Array(r[2],n,e);case 7:return this.i64+=e,new Float64Array(r[3],a,e)}}:this.readTypedArray=function(t,e){var i=this.i8,s=2*this.i16,n=4*this.i32,a=8*this.i64;switch(t){case 0:return this.i8+=e,new Uint8Array(r,i,e);case 1:return this.i8+=e,new Int8Array(r,i,e);case 2:return this.i16+=e,new Uint16Array(r,s,e);case 3:return this.i16+=e,new Int16Array(r,s,e);case 4:return this.i32+=e,new Uint32Array(r,n,e);case 5:return this.i32+=e,new Int32Array(r,n,e);case 6:return this.i32+=e,new Float32Array(r,n,e);case 7:return this.i64+=e,new Float64Array(r,a,e)}},this.factory_plain=[],this.factory_plain_bulk=[];for(var c=0;c<this.signature_table.length;++c){for(var y=this.signature_table[c],v=y.length,w="return {",b="var c=values.length/"+v+";"+w,g=0;v>g;++g)w+="'"+y[g]+"': values["+g+"],",b+="'"+y[g]+"': values[i+c*"+g+"],";w+="}",b+="}",this.factory_plain.push(new Function("values",w)),this.factory_plain_bulk.push(new Function("values","i",b))}this.factory_weave=[function(r,t){return[]}];for(var c=1;16>c;++c)this.factory_weave.push(e(c))};i.prototype.getWeavePropertyFunction=function(r){return void 0!==this.factory_weave[r]?this.factory_weave[r]:(this.factory_weave[r]=e(r),this.factory_weave[r])},i.prototype.readStringLT=function(){var r=this.u16[this.i16++];if(r>=this.string_table.length)throw{name:"RangeError",message:"String ID is outside than the range of the string lookup table!",toString:function(){return this.name+": "+this.message}};return this.string_table[r]},i.prototype.eof=function(){return this.i8>=this.iEnd},i.prototype.where=function(){console.log("i8=",this.i8-this.ofs8," [U:",this.u8[this.i8],"0x"+this.u8[this.i8].toString(16),"/ S:",this.s8[this.i8],"]"),console.log("i16=",this.i16-this.ofs16/2," [U:",this.u16[this.i16],"/ S:",this.s16[this.i16],"]"),console.log("i32=",this.i32-this.ofs32/4," [U:",this.u32[this.i32],"/ S:",this.s32[this.i32],"/ F:",this.f32[this.i32],"]"),console.log("i64=",this.i64-this.ofs64/8," [F:",this.f64[this.i64],"]")},r.exports=i},function(r,t){"use strict";var e=function(r){var t=Error.call(this,r);t.name=this.name="EncodeError",this.stack=t.stack,this.message=t.message};e.prototype=Object.create(Error.prototype);var i=function(r){var t=Error.call(this,r);t.name=this.name="AssertError",this.stack=t.stack,this.message=t.message};i.prototype=Object.create(Error.prototype);var s=function(r){var t=Error.call(this,r);t.name=this.name="PackError",this.stack=t.stack,this.message=t.message};s.prototype=Object.create(Error.prototype);var n=function(r){var t=Error.call(this,r);t.name=this.name="RangeError",this.stack=t.stack,this.message=t.message};n.prototype=Object.create(Error.prototype);var a=function(r){var t=Error.call(this,r);t.name=this.name="IRefError",this.stack=t.stack,this.message=t.message};a.prototype=Object.create(Error.prototype);var o=function(r){var t=Error.call(this,r);t.name=this.name="XRefError",this.stack=t.stack,this.message=t.message};o.prototype=Object.create(Error.prototype),r.exports={EncodeError:e,AssertError:i,PackError:s,RangeError:n,IRefError:a,XRefError:o}}]);
var JBBBinaryLoader=function(r){function t(i){if(e[i])return e[i].exports;var s=e[i]={exports:{},id:i,loaded:!1};return r[i].call(s.exports,s,s.exports,t),s.loaded=!0,s.exports}var e={};return t.m=r,t.c=e,t.p="",t(0)}([function(r,t,e){"use strict";function i(r,t){var e=r.readStringLT(),i=new Blob([r.readTypedArray(T.UINT8,t)],{type:e});return URL.createObjectURL(i)}function s(r,t,e){var s=0,n="";switch(t){case 0:s=r.u8[r.i8++];break;case 1:s=r.u16[r.i16++];break;case 2:s=r.u32[r.i32++];break;case 3:s=r.f64[r.i64++]}if(0===e)return n=String.fromCharCode.apply(null,r.readTypedArray(T.UINT8,s));if(1===e)return n=String.fromCharCode.apply(null,r.readTypedArray(T.UINT16,s));if(2===e){var a=document.createElement("img");return a.src=i(r,s),a}if(4===e){var a=document.createElement("script");return a.src=i(r,s),a}if(7===e)return i(r,s);throw new v.AssertError("Unknown buffer type #"+e+"!")}function n(r,t,e){if(!(32&e&&32!==(48&e))){var i=e;32&e&&(i=r.u8[r.i8++]|(15&e)<<8);var s=r.profile.decode(i);if(void 0===s)throw new v.AssertError("Could not found known object entity #"+i+"!");var n=s.create();r.iref_table.push(n);var a=d(r,t);return s.init(n,a),n}if(56!==(60&e)){if(48===(56&e)){var i=(7&e)<<8|r.u8[r.i8++],o=d(r,t),u=r.factory_plain[i];if(void 0===u)throw new v.AssertError("Could not found simple object signature with id #"+i+"!");return u(o)}throw new v.AssertError("Unexpected object opcode 0x"+e.toString(16)+"!")}var h=3&e;switch(h){case 0:var f=r.f64[r.i64++];10*r.s8[r.i8++];return new Date(f);default:throw new v.AssertError("Unknown primitive object with POID #"+h+"!")}}function a(r,t,e,i){for(var s=new I[m.FROM[i]](e),n=r.readTypedNum(m.FROM[i]),a=r.readFloat64(),o=r.readTypedArray(m.TO[i],e),u=0;e>u;++u)s[u]=n+o[u]*a,console.log("<<<",o[u],"->",s[u]);return s}function o(r,t,e,i){var s=A.FROM[i],n=new I[s](e),a=0;switch(s){case 0:a=r.u8[r.i8++];break;case 1:a=r.s8[r.i8++];break;case 2:a=r.u16[r.i16++];break;case 3:a=r.s16[r.i16++];break;case 4:a=r.u32[r.i32++];break;case 5:a=r.s32[r.i32++];break;case 6:a=r.f32[r.i32++];break;case 7:a=r.f64[r.i64++]}var o=r.readTypedArray(A.TO[i],e-1);n[0]=a;for(var u=0,h=o.length;h>u;++u)a+=o[u],n[u+1]=a;return n}function u(r,t){var e=r.u16[r.i16++],i=r.signature_table[e],s=r.factory_plain_bulk[e];if(void 0===s)throw new v.AssertError("Could not found simple object signature with id #"+e+"!");for(var n=d(r,t),a=n.length/i.length,o=new Array(a),u=0;a>u;++u)o[u]=s(n,u);return o}function h(r,t,e,i){for(var s=new Array(r),n=r-1;n>=0;--n)s[n]=e[i+t*n];return s}function f(r,t,e){var i=!1,s=r.u16[r.i16++],n=r.profile.decode(s),a=n.props,o=0,u=[],f=0,c=0,l=0,p=null,y=0,w=0,b=[],g=[];for(65536>e?(l=r.u16[r.i16++],i&&console.log("-<- HINT16="+l)):(l=r.u32[r.i32++],i&&console.log("-<- HINT32="+l)),u=Array(l),f=0;l>f;++f)r.iref_table.push(u[f]=n.create());if(l){if(b=d(r,t),void 0===b.length)throw new v.AssertError("Decoded known bulk primitive is not array!");o=b.length/a}var T=new Array(e),E=0,A=void 0;for(f=0;e>f;)if(w=r.u8[r.i8++],(128&w)===_.LREF_7)c=127&w,i&&console.log("-<- LREF_7(",c,"), i=",f),T[f++]=A=g[c];else if((192&w)===_.DEFINE){for(c=(63&w)+1,i&&console.log("-<- DEFINE(",c,"), i=",f),y=0;c>y;y++)p=u[E],n.init(p,h(a,o,b,E)),T[f++]=p,E++;A=p}else if((224&w)===_.REPEAT)for(c=(31&w)+1,i&&console.log("-<- REPEAT(",c,"), i=",f),y=0;c>y;y++)T[f++]=A;else if((240&w)===_.IREF){if(c=(15&w)<<16|r.u16[r.i16++],i&&console.log("-<- IREF(",c,"), i=",f),c>=r.iref_table.length)throw new v.IRefError("Invalid IREF #"+c+"!");T[f++]=A=r.iref_table[c],g.push(r.iref_table[c])}else if((248&w)===_.LREF_11)c=(7&w)<<8|r.u8[r.i8++],i&&console.log("-<- LREF_11(",c,"), i=",f),T[f++]=A=g[c];else if(w===_.LREF_16)c=r.u16[r.i16++],i&&console.log("-<- LREF_16(",c,"), i=",f),T[f++]=A=g[c];else if(w===_.XREF){if(c=r.readStringLT(),i&&console.log("-<- XREF(",c,"), i=",f),void 0===t[c])throw new v.XRefError("Cannot import undefined external reference "+c+"!");T[f++]=A=t[c]}return T}function c(r,t,e,i){for(var s,n,a=r.u8[r.i8++],o=[],u=0,h=!0,f=0,c=0,d=0,p=0,y=0,w=0;e>u;){if(i)if(64===(240&a)){switch(d=1&a,p=a>>1&7,y=d?r.u32[r.i32++]:r.u16[r.i16++],h&&(n=new I[p](e),h=!1),p){case 0:w=r.u8[r.i8++];break;case 1:w=r.s8[r.i8++];break;case 2:w=r.u16[r.i16++];break;case 3:w=r.s16[r.i16++];break;case 4:w=r.u32[r.i32++];break;case 5:w=r.s32[r.i32++];break;case 6:w=r.f32[r.i32++];break;case 7:w=r.f64[r.i64++]}n.fill(w,u,u+y),u+=y}else{if(s=l(r,t,a),void 0===s.length)throw new v.AssertError("Encountered non-array chunk as part of chunked array!");if(h&&(n=new s.constructor(e),h=!1),!(s instanceof n.constructor))throw new v.AssertError("Got is_numeric flag, but chunks are not of the same type (op was "+a+"!");n.set(s,u),u+=s.length}else{if(s=l(r,t,a),void 0===s.length)throw new v.AssertError("Encountered non-array chunk as part of chunked array!");for(h&&(o=new Array(e),h=!1),f=0,c=s.length;c>f;f++,u++)o[u]=s[f]}if(!(e>u))break;a=r.u8[r.i8++]}return i?n:o}function l(r,t,e){var i,s=0,n=0,h=0,l=0,p=[];if(e=255&e,110===e)return u(r,t);if(111===e){for(l=r.u8[r.i8++],p[l-1]=null,s=0;l>s;++s)p[s]=d(r,t);return p}if(126===e)return[];if(127===e)throw new v.AssertError("Encountered PRIM_CHUNK_END outside of chunked array!");if(0===(224&e)){h=1&e,n=e>>1&15,l=h?r.u32[r.i32++]:r.u16[r.i16++],i=r.readTypedArray(E.TO[n],l);var y=new I[E.FROM[n]](i);return y}if(32===(240&e))return h=1&e,n=e>>1&7,l=h?r.u32[r.i32++]:r.u16[r.i16++],o(r,t,l,n);if(48===(240&e))return h=1&e,n=e>>1&7,l=h?r.u32[r.i32++]:r.u16[r.i16++],a(r,t,l,n);if(64===(240&e)){switch(h=1&e,n=e>>1&7,l=h?r.u32[r.i32++]:r.u16[r.i16++],n){case 0:i=r.u8[r.i8++];break;case 1:i=r.s8[r.i8++];break;case 2:i=r.u16[r.i16++];break;case 3:i=r.s16[r.i16++];break;case 4:i=r.u32[r.i32++];break;case 5:i=r.s32[r.i32++];break;case 6:i=r.f32[r.i32++];break;case 7:i=r.f64[r.i64++]}var y=new I[n](l);for(s=0;l>s;++s)y[s]=i;return y}if(80===(240&e))return h=1&e,n=e>>1&7,l=h?r.u32[r.i32++]:r.u16[r.i16++],p=r.readTypedArray(n,l);if(96===(248&e))return n=7&e,l=r.u8[r.i8++],p=r.readTypedArray(n,l);if(104===(254&e)){for(h=1&e,l=h?r.u32[r.i32++]:r.u16[r.i16++],i=d(r,t),p[l-1]=null,s=0;l>s;s++)p[s]=i;return p}if(106===(254&e)){for(h=1&e,l=h?r.u32[r.i32++]:r.u16[r.i16++],p[l-1]=null,s=0;l>s;++s)p[s]=d(r,t);return p}if(120===(252&e))return h=1&e,n=e>>1&1,l=h?r.u32[r.i32++]:r.u16[r.i16++],c(r,t,l,n);if(124===(254&e))return h=1&e,l=h?r.u32[r.i32++]:r.u16[r.i16++],f(r,t,l);throw new v.AssertError("Unknown array op-code 0x"+e.toString(16)+" at offset @"+(r.i8-r.ofs8)+"!")}function d(r,t){var e=r.u8[r.i8++];if(0===(128&e))return l(r,t,127&e);if(128===(192&e))return n(r,t,63&e);if(192===(224&e))return s(r,(24&e)>>3,7&e);if(224===(240&e)){var i=r.u16[r.i16++];if(i=(15&e)<<16|i,i>=r.iref_table.length)throw new v.IRefError("Invalid IREF #"+i+"!");return r.iref_table[i]}if(240===(248&e))switch(7&e){case 0:return r.u8[r.i8++];case 1:return r.s8[r.i8++];case 2:return r.u16[r.i16++];case 3:return r.s16[r.i16++];case 4:return r.u32[r.i32++];case 5:return r.s32[r.i32++];case 6:return r.f32[r.i32++];case 7:return r.f64[r.i64++]}else{if(248===(252&e))return k[3&e];if(252===(254&e))return F[2&e];if(254===(255&e)){var a=r.readStringLT();if(void 0===t[a])throw new v.XRefError("Cannot import undefined external reference "+a+"!");return t[a]}if(255===(255&e))throw new v.AssertError("Encountered RESERVED primitive operator!")}}function p(r,t){for(;!r.eof();){var e=r.u8[r.i8++];switch(e){case 248:var i=r.prefix+r.readStringLT();t[i]=d(r,t);break;default:throw new v.AssertError("Unknown control operator 0x"+e.toString(16)+" at @"+r.i8+"!")}}}function y(r,t){var e=r.length,i=Array(e),s=!1;return r.forEach(function(n,a){var o=new XMLHttpRequest;o.open("GET",r[a]),o.responseType="arraybuffer",o.send(),o.addEventListener("readystatechange",function(){if(4===o.readyState)if(200===o.status)i[a]=o.response,0===--e&&t(null);else{if(s)return;t("Error loading "+r[a]+": "+o.statusText),s=!0}})}),i}var w=e(1),v=e(2);const b=0,g=1,T={UINT8:0,INT8:1,UINT16:2,INT16:3,UINT32:4,INT32:5,FLOAT32:6,FLOAT64:7},E={FROM:[T.UINT16,T.INT16,T.UINT32,T.INT32,T.UINT32,T.INT32,T.FLOAT32,T.FLOAT32,T.FLOAT32,T.FLOAT32,T.FLOAT64,T.FLOAT64,T.FLOAT64,T.FLOAT64,T.FLOAT64],TO:[T.UINT8,T.INT8,T.UINT8,T.INT8,T.UINT16,T.INT16,T.UINT8,T.INT8,T.UINT16,T.INT16,T.UINT8,T.INT8,T.UINT16,T.INT16,T.FLOAT32]},A={FROM:[T.UINT16,T.INT16,T.UINT32,T.INT32,T.UINT32,T.INT32],TO:[T.INT8,T.INT8,T.INT8,T.INT8,T.INT16,T.INT16]},m={FROM:[T.FLOAT32,T.FLOAT32,T.FLOAT64,T.FLOAT64],TO:[T.INT8,T.INT16,T.INT8,T.INT16]},I=[Uint8Array,Int8Array,Uint16Array,Int16Array,Uint32Array,Int32Array,Float32Array,Float64Array],_=([T.UINT16,T.UINT32],[T.UINT8,T.UINT16,T.UINT32,T.FLOAT64],{LREF_7:0,LREF_11:240,LREF_16:254,IREF:224,XREF:255,DEFINE:128,REPEAT:192}),k=[void 0,null,!1,!0],F=[NaN];var N=function(r,t){"object"==typeof r&&(t=r,r=""),this.database=t||{},this.baseDir=r||"",this.queuedRequests=[],this.profile=null,this.__delayGC=[]};N.prototype={constructor:N,addProfile:function(r){if(null!==this.profile)throw new v.AssertError("You can currently add only one profile!");this.profile=r},add:function(r,t){if(null===this.profile)throw new v.AssertError("You must first add a profile!");var e="";this.baseDir&&(e=this.baseDir+"/");var i=r.split("?"),s="",n=[];if(i.length>1&&(s="?"+i[1]),".jbbp"===i[0].substr(i[0].length-5).toLowerCase()){var a=e+i[0].substr(0,i[0].length-5);n=[a+".jbbp",a+"_b16.jbbp",a+"_b32.jbbp",a+"_b64.jbbp"]}else{var r=i[0];".jbb"!=r.substr(r.length-4)&&(r+=".jbb"),n=[e+r+s]}var o={callback:t,status:b,buffer:void 0,url:n};this.queuedRequests.push(o)},addByBuffer:function(r){var t={callback:void 0,status:g,buffer:r,url:void 0};this.queuedRequests.push(t)},load:function(r){this.__process(r)},__process:function(r){var t=this;if(r||(r=function(){}),0===this.queuedRequests.length)return void r(null,this.database);for(var e=!1,i=0;i<this.queuedRequests.length;++i)if(this.queuedRequests[i].status===b){e=!0;break}if(e)for(var s={counter:0},n=function(){0===--this.counter&&t.__process(r)}.bind(s),a=!1,i=0;i<this.queuedRequests.length;++i){var o=this.queuedRequests[i];o.status===b&&(s.counter++,o.buffer=y(o.url,function(t){return function(e){if(e){if(a)return;var i="Error downloading bundle: "+e;return t.callback&&t.callback(i,null),r&&r(i,null),void(a=!0)}t.status=g,n()}}(o)))}else{for(var i=0;i<this.queuedRequests.length;++i){var o=this.queuedRequests[i];if(o.status===g){var u;u=1===o.buffer.length?new w(o.buffer[0],t.profile):new w(o.buffer,t.profile),p(u,t.database),o.callback&&o.callback(null,o.bundle)}}this.queuedRequests=[],r(null,this.database),setTimeout(function(){this.__delayGC=[]}.bind(this),500)}}},r.exports=N},function(r,t){"use strict";function e(r){for(var t="",e=0;r>e;++e)0!==e&&(t+=","),t+="p[i+c*"+e+"]";return new Function("p","i","var c=p.length/"+r+";return ["+t+"]")}var i=function(r,t){this.profile=t,this.prefix="",this.sparse=r instanceof Array;var i,s,n,a=32;if(this.sparse?(this.u8=new Uint8Array(r[0]),this.s8=new Int8Array(r[0]),this.u16=new Uint16Array(r[1]),this.s16=new Int16Array(r[1]),this.u32=new Uint32Array(r[2]),this.s32=new Int32Array(r[2]),this.f32=new Float32Array(r[2]),this.f64=new Float64Array(r[3]),i=new Uint16Array(r[0],0,a/2),s=new Uint32Array(r[0],0,a/4),n=r[0].byteLength):(this.u8=new Uint8Array(r),this.s8=new Int8Array(r),this.u16=new Uint16Array(r),this.s16=new Int16Array(r),this.u32=new Uint32Array(r),this.s32=new Int32Array(r),this.f32=new Float32Array(r),this.f64=new Float64Array(r),i=new Uint16Array(r),s=new Uint32Array(r),n=r.byteLength),this.magic=i[0],this.table_id=i[1],this.version=i[2],this.ver_major=255&this.version,this.ver_minor=(65280&this.version)>>8,this.max64=s[2],this.max32=s[3],this.max16=s[4],this.max8=s[5],this.lenST=s[6],this.lenOT=s[7],12610==this.magic)throw{name:"EndianessError",message:"Unfortunately the JBB format is currently only compatible with Little-Endian CPUs",toString:function(){return this.name+": "+this.message}};if(16945!=this.magic)throw{name:"DecodingError",message:"This does not look like a JBB archive! (Magic is 0x"+this.magic.toString(16)+")",toString:function(){return this.name+": "+this.message}};if(258!=this.version)throw{name:"DecodingError",message:"Unsupported bundle version v"+this.ver_minor+"."+this.ver_minor,toString:function(){return this.name+": "+this.message}};if(this.table_id!=this.profile.id)throw{name:"DecodingError",message:"The profile ID (0x"+this.profile.id.toString(16)+") does not match the object table in the binary bundle (0x"+this.table_id.toString(16)+")",toString:function(){return this.name+": "+this.message}};this.sparse?(this.i64=0,this.i32=0,this.i16=0,this.i8=a,this.iEnd=this.i8+this.max8-this.lenST,this.ofs8=this.i8,this.ofs16=this.i16,this.ofs32=this.i32,this.ofs64=this.i64):(this.i64=a,this.i32=this.i64+this.max64,this.i16=this.i32+this.max32,this.i8=this.i16+this.max16,this.iEnd=this.i8+this.max8-this.lenST,this.ofs8=this.i8,this.ofs16=this.i16,this.ofs32=this.i32,this.ofs64=this.i64,this.i16/=2,this.i32/=4,this.i64/=8),this.iref_table=[];var o="",u=!1;if(this.string_table=[],this.lenST>0){for(var h=this.i8+this.max8,f=h-this.lenST;h>f;++f){var c=this.u8[f];0===c?(this.string_table.push(o),o="",u=!1):(o+=String.fromCharCode(c),u=!0)}u&&this.string_table.push(o)}var l=[],d=0,p=!1;if(this.signature_table=[],this.lenOT>0){for(var h=2*this.i16+this.max16,f=h-this.lenOT;h>f;f+=2){var c=this.u16[f/2];d--?l.push(this.string_table[c]):(p&&this.signature_table.push(l),l=[],d=c,p=!0)}p&&this.signature_table.push(l)}this.sparse?this.readTypedArray=function(t,e){var i=this.i8,s=2*this.i16,n=4*this.i32,a=8*this.i64;switch(t){case 0:return this.i8+=e,new Uint8Array(r[0],i,e);case 1:return this.i8+=e,new Int8Array(r[0],i,e);case 2:return this.i16+=e,new Uint16Array(r[1],s,e);case 3:return this.i16+=e,new Int16Array(r[1],s,e);case 4:return this.i32+=e,new Uint32Array(r[2],n,e);case 5:return this.i32+=e,new Int32Array(r[2],n,e);case 6:return this.i32+=e,new Float32Array(r[2],n,e);case 7:return this.i64+=e,new Float64Array(r[3],a,e)}}:this.readTypedArray=function(t,e){var i=this.i8,s=2*this.i16,n=4*this.i32,a=8*this.i64;switch(t){case 0:return this.i8+=e,new Uint8Array(r,i,e);case 1:return this.i8+=e,new Int8Array(r,i,e);case 2:return this.i16+=e,new Uint16Array(r,s,e);case 3:return this.i16+=e,new Int16Array(r,s,e);case 4:return this.i32+=e,new Uint32Array(r,n,e);case 5:return this.i32+=e,new Int32Array(r,n,e);case 6:return this.i32+=e,new Float32Array(r,n,e);case 7:return this.i64+=e,new Float64Array(r,a,e)}},this.factory_plain=[],this.factory_plain_bulk=[];for(var f=0;f<this.signature_table.length;++f){for(var y=this.signature_table[f],w=y.length,v="return {",b="var c=values.length/"+w+";"+v,g=0;w>g;++g)v+="'"+y[g]+"': values["+g+"],",b+="'"+y[g]+"': values[i+c*"+g+"],";v+="}",b+="}",this.factory_plain.push(new Function("values",v)),this.factory_plain_bulk.push(new Function("values","i",b))}this.factory_weave=[function(r,t){return[]}];for(var f=1;16>f;++f)this.factory_weave.push(e(f))};i.prototype.getWeavePropertyFunction=function(r){return void 0!==this.factory_weave[r]?this.factory_weave[r]:(this.factory_weave[r]=e(r),this.factory_weave[r])},i.prototype.readStringLT=function(){var r=this.u16[this.i16++];if(r>=this.string_table.length)throw{name:"RangeError",message:"String ID is outside than the range of the string lookup table!",toString:function(){return this.name+": "+this.message}};return this.string_table[r]},i.prototype.eof=function(){return this.i8>=this.iEnd},i.prototype.where=function(){console.log("i8=",this.i8-this.ofs8," [U:",this.u8[this.i8],"0x"+this.u8[this.i8].toString(16),"/ S:",this.s8[this.i8],"]"),console.log("i16=",this.i16-this.ofs16/2," [U:",this.u16[this.i16],"/ S:",this.s16[this.i16],"]"),console.log("i32=",this.i32-this.ofs32/4," [U:",this.u32[this.i32],"/ S:",this.s32[this.i32],"/ F:",this.f32[this.i32],"]"),console.log("i64=",this.i64-this.ofs64/8," [F:",this.f64[this.i64],"]")},r.exports=i},function(r,t){"use strict";var e=function(r){var t=Error.call(this,r);t.name=this.name="EncodeError",this.stack=t.stack,this.message=t.message};e.prototype=Object.create(Error.prototype);var i=function(r){var t=Error.call(this,r);t.name=this.name="AssertError",this.stack=t.stack,this.message=t.message};i.prototype=Object.create(Error.prototype);var s=function(r){var t=Error.call(this,r);t.name=this.name="PackError",this.stack=t.stack,this.message=t.message};s.prototype=Object.create(Error.prototype);var n=function(r){var t=Error.call(this,r);t.name=this.name="RangeError",this.stack=t.stack,this.message=t.message};n.prototype=Object.create(Error.prototype);var a=function(r){var t=Error.call(this,r);t.name=this.name="IRefError",this.stack=t.stack,this.message=t.message};a.prototype=Object.create(Error.prototype);var o=function(r){var t=Error.call(this,r);t.name=this.name="XRefError",this.stack=t.stack,this.message=t.message};o.prototype=Object.create(Error.prototype),r.exports={EncodeError:e,AssertError:i,PackError:s,RangeError:n,IRefError:a,XRefError:o}}]);
# Bundle Format Specifications
:warning: **This document is slightly outdated and is not reflecting the v1.2.0 version of the bundle.**
:warning: **This document is slightly outdated and is not reflecting the v1.3.0 version of the bundle.**

@@ -176,2 +176,7 @@ The bundle format is optimised for use in conjunction with javascript `TypedArray`. Therefore, it's contents are laid out appropriately in order to minimise alignment padding.

### Object Opcodes
This is a specialisation of the OBJECT primitive.
<img src="https://raw.githubusercontent.com/wavesoft/jbb/master/doc/table_OP_OBJECT.png" />
### Array Opcodes

@@ -182,2 +187,7 @@ This is a specialisation of the ARRAY primitive.

### PRIM_BULK_KNOWN Steering OP-Codes
This is a set of steering instructions for the `PRIM_BULK_KNOWN` array.
<img src="https://raw.githubusercontent.com/wavesoft/jbb/master/doc/table_OP_BULK_KNOWN.png" />
### Other Types

@@ -184,0 +194,0 @@ The following tables contain the values of other properties of the opcodes.

{
"name": "jbb",
"version": "1.3.0",
"version": "1.3.2",
"description": "Javascript Binary Bundle",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -9,3 +9,3 @@ # Javascript Binary Bundles (.jbb)

:thumbsup: This is NOT an archiving format! Even though it can store arbitrary binary blobs, it is designed to optimally serialize javascript structures!
:thumbsup: This is NOT a plain archiving format for binary blobs! Even though it can store arbitrary binary data, it is designed to optimally serialize javascript structures!

@@ -16,4 +16,5 @@ :warning: This format is Architecture-Dependant: This means if you are compiling a binary bundle in little-endian machine it will *only* work on little-endian machines! _(We are not using `DataView`, but rather raw TypedArrays for performance purposes)._

Curious to see some tests? [Timing Example](http://cdn.rawgit.com/wavesoft/jbb-tests/bf678cfe78a6f037744cee76ff41acde202e500e/jbb_test_timing.html) - [Example 1](http://cdn.rawgit.com/wavesoft/jbb-tests/bf678cfe78a6f037744cee76ff41acde202e500e/jbb_test_loader_1.html) - [Example 2](http://cdn.rawgit.com/wavesoft/jbb-tests/bf678cfe78a6f037744cee76ff41acde202e500e/jbb_test_loader_2.html)
Curious to see some tests? [Timing Example](http://cdn.rawgit.com/wavesoft/jbb-tests/0a09dc1ac1bc4e4bb79d119dc3975f5f274bff96/jbb_test_timing.html) - [Example 1](http://cdn.rawgit.com/wavesoft/jbb-tests/0a09dc1ac1bc4e4bb79d119dc3975f5f274bff96/jbb_test_loader_1.html) - [Example 2](http://cdn.rawgit.com/wavesoft/jbb-tests/0a09dc1ac1bc4e4bb79d119dc3975f5f274bff96/jbb_test_loader_2.html)
Or you can read the [Using JBB with THREE.js](https://github.com/wavesoft/jbb/blob/master/doc/Tutorial%201%20-%20THREEjs/Using%20with%20THREEjs.md) tutoral.

@@ -48,4 +49,7 @@ ## Installation

<script>
var jbbLoader = new JBBBinaryLoader( JBBProfileThree, "base/dir/to/bundles" );
var jbbLoader = new JBBBinaryLoader( "base/dir/to/bundles" );
// Specify which profile to use
jbbLoader.addProfile(JBBProfileThree);
// Specify bundles to load

@@ -181,4 +185,7 @@ jbbLoader.add("bundle.jbb");

// Create a decoder
var loader = new BinaryDecoder( profile, "bundle/base/dir" );
var loader = new BinaryDecoder( "bundle/base/dir" );
// Specify the decoding profile
loader.addProfile( profile );
// Schedule one or more budles to load

@@ -185,0 +192,0 @@ binaryLoader.add( 'bundle1.jbb');

@@ -129,4 +129,5 @@ /**

var unmute = mute();
var binaryLoader = new JBBBinaryLoader( THREEDecodeProfile, path.dirname(tmpFile) );
var binaryLoader = new JBBBinaryLoader( path.dirname(tmpFile) );
binaryLoadingTime = Date.now();
binaryLoader.addProfile( THREEDecodeProfile );
binaryLoader.addByBuffer( common.readChunk(tmpFile) );

@@ -133,0 +134,0 @@ binaryLoader.load(function( err ) {

@@ -67,3 +67,4 @@ /**

// Create a decoder & Parse
var decoder = new BinaryLoader( profile, db );
var decoder = new BinaryLoader( db );
decoder.addProfile(profile);
decoder.addByBuffer(buf);

@@ -90,3 +91,4 @@ decoder.load();

// Create a decoder & Parse
var decoder = new BinaryLoader( profile, db );
var decoder = new BinaryLoader( db );
decoder.addProfile( profile );
decoder.addByBuffer( chunks );

@@ -185,3 +187,4 @@ decoder.load();

// Create a decoder & Parse
var decoder = new BinaryLoader( decodeProfile );
var decoder = new BinaryLoader();
decoder.addProfile(decodeProfile);
decoder.addByBuffer(buf);

@@ -188,0 +191,0 @@ decoder.load();

@@ -32,5 +32,8 @@ /**

if ( ((actual === undefined) && (expected !== undefined)) ||
((actual !== undefined) && (expected === undefined))) {
assert.equal( actual, expected, path + ' mismatch ' + message );
if ((actual === undefined) || (expected === undefined)) {
if ( ((actual === undefined) && (expected !== undefined)) ||
((actual !== undefined) && (expected === undefined))) {
assert.equal( actual, expected, path + ' mismatch ' + message );
}
return;
}

@@ -37,0 +40,0 @@

# Using `jbb` with `THREE.js`
The JBB Project was initially started in order to optimally store resources for THREE.js scenes. Therefore it's only natural to have a dedicated guide on how to use it with three.js.
You can integrate jbb in your pipeline in various ways. In this tutorial we are going to use `gulp-jbb` for steering the creation of bundles, but we are not going to create a gulp-based binary project.
## Getting Started
For the bare minimum requirements you will need to install `node` and a few packages. Start by creating a new directory for our project and install the following packages locally:
```
npm install jbb jbb-profile-three gulp gulp-jbb
```
Then create two directories:
* `bundles` - Were the bundle sources are located.
* `dist` - Were the built files will be placed.
```
mkdir bundles dist
```
## Creating a Gulpfile.js
In order to build our bundles we can either use the `jbb` command-line, or we can create a gulpfile to automate the build process using `gulp`.
Create a new file called `gulpfile.js` in your root directory with the following contents:
```javascript
var gulp = require('gulp');
var jbb = require('gulp-jbb');
//
// Compile the binary bundles
//
gulp.task('bundles', function() {
return gulp
.src([ "bundles/*.jbbsrc" ])
.pipe(jbb({
profile: 'three',
sparse: false
}))
.pipe(gulp.dest('build/bundles'));
});
// By default build bundles
gulp.task('default', ['bundles' ]);
```

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display