elation-engine 0.9.124 → 0.9.125
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
package/scripts/assets.js
CHANGED
|
@@ -629,6 +629,15 @@ if (!ENV_IS_BROWSER) return;
|
|
|
629
629
|
|
|
630
630
|
});
|
|
631
631
|
}
|
|
632
|
+
} else if (imagetype == 'dds') {
|
|
633
|
+
let loader = new THREE.DDSLoader();
|
|
634
|
+
loader.load(this.getProxiedURL(this.src), data => {
|
|
635
|
+
data.encoding = THREE.sRGBEncoding;
|
|
636
|
+
this._texture = data;
|
|
637
|
+
this.loaded = true;
|
|
638
|
+
this.uploaded = false;
|
|
639
|
+
this.sendLoadEvents();
|
|
640
|
+
});
|
|
632
641
|
} else {
|
|
633
642
|
let blob = xhr.response;
|
|
634
643
|
if (typeof createImageBitmap == 'function' && type != 'image/gif') {
|
|
@@ -964,6 +973,20 @@ newcanvas.style.left = 0;
|
|
|
964
973
|
this._texture.dispose();
|
|
965
974
|
}
|
|
966
975
|
this.loaded = false;
|
|
976
|
+
},
|
|
977
|
+
toCubemap(texture) {
|
|
978
|
+
let pmremGenerator = new THREE.PMREMGenerator( elation.engine.assets.rendersystem.renderer );
|
|
979
|
+
pmremGenerator.compileEquirectangularShader();
|
|
980
|
+
if (!texture) texture = this._texture;
|
|
981
|
+
|
|
982
|
+
let cubeRenderTarget = pmremGenerator.fromEquirectangular( texture );
|
|
983
|
+
let cubemap = cubeRenderTarget.texture;
|
|
984
|
+
|
|
985
|
+
//texture.dispose();
|
|
986
|
+
|
|
987
|
+
this._texture = cubemap;
|
|
988
|
+
this.loaded = true;
|
|
989
|
+
this.uploaded = false;
|
|
967
990
|
}
|
|
968
991
|
}, elation.engine.assets.base);
|
|
969
992
|
|
|
@@ -1432,7 +1455,7 @@ console.log('set up hls', hlsConfig);
|
|
|
1432
1455
|
if (this.object) {
|
|
1433
1456
|
this.loading = false;
|
|
1434
1457
|
this.loaded = true;
|
|
1435
|
-
this.state = '
|
|
1458
|
+
this.state = 'processing';
|
|
1436
1459
|
this._model = new THREE.Group();
|
|
1437
1460
|
setTimeout(() => this.complete(this.object), 0);
|
|
1438
1461
|
} else if (this.src) {
|
package/scripts/engine.js
CHANGED
|
@@ -267,7 +267,7 @@ elation.require(deps, function() {
|
|
|
267
267
|
this.defineAttributes({
|
|
268
268
|
name: { type: 'string', default: 'default' },
|
|
269
269
|
resolution: { type: 'string' },
|
|
270
|
-
fullsize: { type: 'boolean', default:
|
|
270
|
+
fullsize: { type: 'boolean', default: false },
|
|
271
271
|
crosshair: { type: 'boolean', default: false },
|
|
272
272
|
picking: { type: 'boolean', default: false },
|
|
273
273
|
stats: { type: 'boolean', default: false },
|
|
@@ -276,6 +276,10 @@ elation.require(deps, function() {
|
|
|
276
276
|
});
|
|
277
277
|
if (this.fullsize == 'false') this.fullsize = false; // FIXME - the type coersion should be doing this for us
|
|
278
278
|
//this.name = this.args.name || 'default';
|
|
279
|
+
//this.setEngineConfig(this.args);
|
|
280
|
+
}
|
|
281
|
+
create() {
|
|
282
|
+
super.create();
|
|
279
283
|
this.enginecfg = {
|
|
280
284
|
systems: [
|
|
281
285
|
"physics",
|
|
@@ -290,14 +294,10 @@ elation.require(deps, function() {
|
|
|
290
294
|
stats: false,
|
|
291
295
|
picking: true,
|
|
292
296
|
fullsize: this.fullsize && this.fullsize != 'false',
|
|
293
|
-
resolution:
|
|
297
|
+
resolution: this.resolution.split('x'),
|
|
294
298
|
useWebVRPolyfill: true,
|
|
295
299
|
enablePostprocessing: true
|
|
296
300
|
};
|
|
297
|
-
//this.setEngineConfig(this.args);
|
|
298
|
-
}
|
|
299
|
-
create() {
|
|
300
|
-
super.create();
|
|
301
301
|
this.initEngine();
|
|
302
302
|
this.loadEngine();
|
|
303
303
|
}
|
|
@@ -16920,3 +16920,247 @@ THREE.MMDLoader = ( function () {
|
|
|
16920
16920
|
THREE.KTX2Loader = KTX2Loader;
|
|
16921
16921
|
|
|
16922
16922
|
} )();
|
|
16923
|
+
( function () {
|
|
16924
|
+
|
|
16925
|
+
class DDSLoader extends THREE.CompressedTextureLoader {
|
|
16926
|
+
|
|
16927
|
+
constructor( manager ) {
|
|
16928
|
+
|
|
16929
|
+
super( manager );
|
|
16930
|
+
|
|
16931
|
+
}
|
|
16932
|
+
parse( buffer, loadMipmaps ) {
|
|
16933
|
+
|
|
16934
|
+
const dds = {
|
|
16935
|
+
mipmaps: [],
|
|
16936
|
+
width: 0,
|
|
16937
|
+
height: 0,
|
|
16938
|
+
format: null,
|
|
16939
|
+
mipmapCount: 1
|
|
16940
|
+
};
|
|
16941
|
+
|
|
16942
|
+
// Adapted from @toji's DDS utils
|
|
16943
|
+
// https://github.com/toji/webgl-texture-utils/blob/master/texture-util/dds.js
|
|
16944
|
+
|
|
16945
|
+
// All values and structures referenced from:
|
|
16946
|
+
// http://msdn.microsoft.com/en-us/library/bb943991.aspx/
|
|
16947
|
+
|
|
16948
|
+
const DDS_MAGIC = 0x20534444;
|
|
16949
|
+
|
|
16950
|
+
// const DDSD_CAPS = 0x1;
|
|
16951
|
+
// const DDSD_HEIGHT = 0x2;
|
|
16952
|
+
// const DDSD_WIDTH = 0x4;
|
|
16953
|
+
// const DDSD_PITCH = 0x8;
|
|
16954
|
+
// const DDSD_PIXELFORMAT = 0x1000;
|
|
16955
|
+
const DDSD_MIPMAPCOUNT = 0x20000;
|
|
16956
|
+
// const DDSD_LINEARSIZE = 0x80000;
|
|
16957
|
+
// const DDSD_DEPTH = 0x800000;
|
|
16958
|
+
|
|
16959
|
+
// const DDSCAPS_COMPLEX = 0x8;
|
|
16960
|
+
// const DDSCAPS_MIPMAP = 0x400000;
|
|
16961
|
+
// const DDSCAPS_TEXTURE = 0x1000;
|
|
16962
|
+
|
|
16963
|
+
const DDSCAPS2_CUBEMAP = 0x200;
|
|
16964
|
+
const DDSCAPS2_CUBEMAP_POSITIVEX = 0x400;
|
|
16965
|
+
const DDSCAPS2_CUBEMAP_NEGATIVEX = 0x800;
|
|
16966
|
+
const DDSCAPS2_CUBEMAP_POSITIVEY = 0x1000;
|
|
16967
|
+
const DDSCAPS2_CUBEMAP_NEGATIVEY = 0x2000;
|
|
16968
|
+
const DDSCAPS2_CUBEMAP_POSITIVEZ = 0x4000;
|
|
16969
|
+
const DDSCAPS2_CUBEMAP_NEGATIVEZ = 0x8000;
|
|
16970
|
+
// const DDSCAPS2_VOLUME = 0x200000;
|
|
16971
|
+
|
|
16972
|
+
// const DDPF_ALPHAPIXELS = 0x1;
|
|
16973
|
+
// const DDPF_ALPHA = 0x2;
|
|
16974
|
+
// const DDPF_FOURCC = 0x4;
|
|
16975
|
+
// const DDPF_RGB = 0x40;
|
|
16976
|
+
// const DDPF_YUV = 0x200;
|
|
16977
|
+
// const DDPF_LUMINANCE = 0x20000;
|
|
16978
|
+
|
|
16979
|
+
function fourCCToInt32( value ) {
|
|
16980
|
+
|
|
16981
|
+
return value.charCodeAt( 0 ) + ( value.charCodeAt( 1 ) << 8 ) + ( value.charCodeAt( 2 ) << 16 ) + ( value.charCodeAt( 3 ) << 24 );
|
|
16982
|
+
|
|
16983
|
+
}
|
|
16984
|
+
|
|
16985
|
+
function int32ToFourCC( value ) {
|
|
16986
|
+
|
|
16987
|
+
return String.fromCharCode( value & 0xff, value >> 8 & 0xff, value >> 16 & 0xff, value >> 24 & 0xff );
|
|
16988
|
+
|
|
16989
|
+
}
|
|
16990
|
+
|
|
16991
|
+
function loadARGBMip( buffer, dataOffset, width, height ) {
|
|
16992
|
+
|
|
16993
|
+
const dataLength = width * height * 4;
|
|
16994
|
+
const srcBuffer = new Uint8Array( buffer, dataOffset, dataLength );
|
|
16995
|
+
const byteArray = new Uint8Array( dataLength );
|
|
16996
|
+
let dst = 0;
|
|
16997
|
+
let src = 0;
|
|
16998
|
+
for ( let y = 0; y < height; y ++ ) {
|
|
16999
|
+
|
|
17000
|
+
for ( let x = 0; x < width; x ++ ) {
|
|
17001
|
+
|
|
17002
|
+
const b = srcBuffer[ src ];
|
|
17003
|
+
src ++;
|
|
17004
|
+
const g = srcBuffer[ src ];
|
|
17005
|
+
src ++;
|
|
17006
|
+
const r = srcBuffer[ src ];
|
|
17007
|
+
src ++;
|
|
17008
|
+
const a = srcBuffer[ src ];
|
|
17009
|
+
src ++;
|
|
17010
|
+
byteArray[ dst ] = r;
|
|
17011
|
+
dst ++; //r
|
|
17012
|
+
byteArray[ dst ] = g;
|
|
17013
|
+
dst ++; //g
|
|
17014
|
+
byteArray[ dst ] = b;
|
|
17015
|
+
dst ++; //b
|
|
17016
|
+
byteArray[ dst ] = a;
|
|
17017
|
+
dst ++; //a
|
|
17018
|
+
|
|
17019
|
+
}
|
|
17020
|
+
|
|
17021
|
+
}
|
|
17022
|
+
|
|
17023
|
+
return byteArray;
|
|
17024
|
+
|
|
17025
|
+
}
|
|
17026
|
+
|
|
17027
|
+
const FOURCC_DXT1 = fourCCToInt32( 'DXT1' );
|
|
17028
|
+
const FOURCC_DXT3 = fourCCToInt32( 'DXT3' );
|
|
17029
|
+
const FOURCC_DXT5 = fourCCToInt32( 'DXT5' );
|
|
17030
|
+
const FOURCC_ETC1 = fourCCToInt32( 'ETC1' );
|
|
17031
|
+
const headerLengthInt = 31; // The header length in 32 bit ints
|
|
17032
|
+
|
|
17033
|
+
// Offsets into the header array
|
|
17034
|
+
|
|
17035
|
+
const off_magic = 0;
|
|
17036
|
+
const off_size = 1;
|
|
17037
|
+
const off_flags = 2;
|
|
17038
|
+
const off_height = 3;
|
|
17039
|
+
const off_width = 4;
|
|
17040
|
+
const off_mipmapCount = 7;
|
|
17041
|
+
|
|
17042
|
+
// const off_pfFlags = 20;
|
|
17043
|
+
const off_pfFourCC = 21;
|
|
17044
|
+
const off_RGBBitCount = 22;
|
|
17045
|
+
const off_RBitMask = 23;
|
|
17046
|
+
const off_GBitMask = 24;
|
|
17047
|
+
const off_BBitMask = 25;
|
|
17048
|
+
const off_ABitMask = 26;
|
|
17049
|
+
|
|
17050
|
+
// const off_caps = 27;
|
|
17051
|
+
const off_caps2 = 28;
|
|
17052
|
+
// const off_caps3 = 29;
|
|
17053
|
+
// const off_caps4 = 30;
|
|
17054
|
+
|
|
17055
|
+
// Parse header
|
|
17056
|
+
|
|
17057
|
+
const header = new Int32Array( buffer, 0, headerLengthInt );
|
|
17058
|
+
if ( header[ off_magic ] !== DDS_MAGIC ) {
|
|
17059
|
+
|
|
17060
|
+
console.error( 'THREE.DDSLoader.parse: Invalid magic number in DDS header.' );
|
|
17061
|
+
return dds;
|
|
17062
|
+
|
|
17063
|
+
}
|
|
17064
|
+
|
|
17065
|
+
let blockBytes;
|
|
17066
|
+
const fourCC = header[ off_pfFourCC ];
|
|
17067
|
+
let isRGBAUncompressed = false;
|
|
17068
|
+
switch ( fourCC ) {
|
|
17069
|
+
|
|
17070
|
+
case FOURCC_DXT1:
|
|
17071
|
+
blockBytes = 8;
|
|
17072
|
+
dds.format = THREE.RGB_S3TC_DXT1_Format;
|
|
17073
|
+
break;
|
|
17074
|
+
case FOURCC_DXT3:
|
|
17075
|
+
blockBytes = 16;
|
|
17076
|
+
dds.format = THREE.RGBA_S3TC_DXT3_Format;
|
|
17077
|
+
break;
|
|
17078
|
+
case FOURCC_DXT5:
|
|
17079
|
+
blockBytes = 16;
|
|
17080
|
+
dds.format = THREE.RGBA_S3TC_DXT5_Format;
|
|
17081
|
+
break;
|
|
17082
|
+
case FOURCC_ETC1:
|
|
17083
|
+
blockBytes = 8;
|
|
17084
|
+
dds.format = THREE.RGB_ETC1_Format;
|
|
17085
|
+
break;
|
|
17086
|
+
default:
|
|
17087
|
+
if ( header[ off_RGBBitCount ] === 32 && header[ off_RBitMask ] & 0xff0000 && header[ off_GBitMask ] & 0xff00 && header[ off_BBitMask ] & 0xff && header[ off_ABitMask ] & 0xff000000 ) {
|
|
17088
|
+
|
|
17089
|
+
isRGBAUncompressed = true;
|
|
17090
|
+
blockBytes = 64;
|
|
17091
|
+
dds.format = THREE.RGBAFormat;
|
|
17092
|
+
|
|
17093
|
+
} else {
|
|
17094
|
+
|
|
17095
|
+
console.error( 'THREE.DDSLoader.parse: Unsupported FourCC code ', int32ToFourCC( fourCC ) );
|
|
17096
|
+
return dds;
|
|
17097
|
+
|
|
17098
|
+
}
|
|
17099
|
+
|
|
17100
|
+
}
|
|
17101
|
+
|
|
17102
|
+
dds.mipmapCount = 1;
|
|
17103
|
+
if ( header[ off_flags ] & DDSD_MIPMAPCOUNT && loadMipmaps !== false ) {
|
|
17104
|
+
|
|
17105
|
+
dds.mipmapCount = Math.max( 1, header[ off_mipmapCount ] );
|
|
17106
|
+
|
|
17107
|
+
}
|
|
17108
|
+
|
|
17109
|
+
const caps2 = header[ off_caps2 ];
|
|
17110
|
+
dds.isCubemap = caps2 & DDSCAPS2_CUBEMAP ? true : false;
|
|
17111
|
+
if ( dds.isCubemap && ( ! ( caps2 & DDSCAPS2_CUBEMAP_POSITIVEX ) || ! ( caps2 & DDSCAPS2_CUBEMAP_NEGATIVEX ) || ! ( caps2 & DDSCAPS2_CUBEMAP_POSITIVEY ) || ! ( caps2 & DDSCAPS2_CUBEMAP_NEGATIVEY ) || ! ( caps2 & DDSCAPS2_CUBEMAP_POSITIVEZ ) || ! ( caps2 & DDSCAPS2_CUBEMAP_NEGATIVEZ ) ) ) {
|
|
17112
|
+
|
|
17113
|
+
console.error( 'THREE.DDSLoader.parse: Incomplete cubemap faces' );
|
|
17114
|
+
return dds;
|
|
17115
|
+
|
|
17116
|
+
}
|
|
17117
|
+
|
|
17118
|
+
dds.width = header[ off_width ];
|
|
17119
|
+
dds.height = header[ off_height ];
|
|
17120
|
+
let dataOffset = header[ off_size ] + 4;
|
|
17121
|
+
|
|
17122
|
+
// Extract mipmaps buffers
|
|
17123
|
+
|
|
17124
|
+
const faces = dds.isCubemap ? 6 : 1;
|
|
17125
|
+
for ( let face = 0; face < faces; face ++ ) {
|
|
17126
|
+
|
|
17127
|
+
let width = dds.width;
|
|
17128
|
+
let height = dds.height;
|
|
17129
|
+
for ( let i = 0; i < dds.mipmapCount; i ++ ) {
|
|
17130
|
+
|
|
17131
|
+
let byteArray, dataLength;
|
|
17132
|
+
if ( isRGBAUncompressed ) {
|
|
17133
|
+
|
|
17134
|
+
byteArray = loadARGBMip( buffer, dataOffset, width, height );
|
|
17135
|
+
dataLength = byteArray.length;
|
|
17136
|
+
|
|
17137
|
+
} else {
|
|
17138
|
+
|
|
17139
|
+
dataLength = Math.max( 4, width ) / 4 * Math.max( 4, height ) / 4 * blockBytes;
|
|
17140
|
+
byteArray = new Uint8Array( buffer, dataOffset, dataLength );
|
|
17141
|
+
|
|
17142
|
+
}
|
|
17143
|
+
|
|
17144
|
+
const mipmap = {
|
|
17145
|
+
'data': byteArray,
|
|
17146
|
+
'width': width,
|
|
17147
|
+
'height': height
|
|
17148
|
+
};
|
|
17149
|
+
dds.mipmaps.push( mipmap );
|
|
17150
|
+
dataOffset += dataLength;
|
|
17151
|
+
width = Math.max( width >> 1, 1 );
|
|
17152
|
+
height = Math.max( height >> 1, 1 );
|
|
17153
|
+
|
|
17154
|
+
}
|
|
17155
|
+
|
|
17156
|
+
}
|
|
17157
|
+
|
|
17158
|
+
return dds;
|
|
17159
|
+
|
|
17160
|
+
}
|
|
17161
|
+
|
|
17162
|
+
}
|
|
17163
|
+
|
|
17164
|
+
THREE.DDSLoader = DDSLoader;
|
|
17165
|
+
|
|
17166
|
+
} )();
|
|
@@ -810,7 +810,7 @@ elation.require(['ui.window', 'ui.panel', 'ui.toggle', 'ui.slider', 'ui.label',
|
|
|
810
810
|
this.state[bindid] = 0;
|
|
811
811
|
this.changes.push(bindid);
|
|
812
812
|
}, 10);
|
|
813
|
-
ev.preventDefault();
|
|
813
|
+
//ev.preventDefault();
|
|
814
814
|
}
|
|
815
815
|
this.keydown = function(ev) {
|
|
816
816
|
// Send key events for both keyboard_<key> and keyboard_<modname>_<key>
|
|
@@ -1327,7 +1327,7 @@ console.log('toggle render mode: ' + this.rendermode + ' => ' + mode, passidx, l
|
|
|
1327
1327
|
fakeev.stopPropagation = ev.stopPropagation.bind(ev);
|
|
1328
1328
|
this.mousedown(fakeev);
|
|
1329
1329
|
// }
|
|
1330
|
-
ev.preventDefault();
|
|
1330
|
+
//ev.preventDefault();
|
|
1331
1331
|
}
|
|
1332
1332
|
touchmove(ev) {
|
|
1333
1333
|
this.mousepos = [ev.touches[0].clientX, ev.touches[0].clientY, document.body.scrollTop];
|