@woosh/meep-engine 2.99.2 → 2.100.1
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/build/meep.cjs +556 -18
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +556 -18
- package/package.json +1 -1
- package/src/core/collection/list/List.d.ts.map +1 -1
- package/src/core/collection/list/List.js +3 -1
- package/src/core/color/Color.d.ts.map +1 -1
- package/src/core/color/Color.js +39 -8
- package/src/core/model/node-graph/DataType.d.ts.map +1 -1
- package/src/core/model/node-graph/DataType.js +3 -2
- package/src/core/model/node-graph/node/NodeInstance.d.ts.map +1 -1
- package/src/core/model/node-graph/node/NodeInstance.js +11 -12
- package/src/core/model/node-graph/node/NodeInstancePortReference.d.ts.map +1 -1
- package/src/core/model/node-graph/node/NodeInstancePortReference.js +5 -2
- package/src/core/model/node-graph/node/Port.d.ts.map +1 -1
- package/src/core/model/node-graph/node/Port.js +5 -0
- package/src/engine/animation/async/prototypeAsyncAnimation.d.ts +2 -0
- package/src/engine/animation/async/prototypeAsyncAnimation.d.ts.map +1 -0
- package/src/engine/animation/async/prototypeAsyncAnimation.js +344 -0
- package/src/engine/asset/AssetManager.d.ts.map +1 -1
- package/src/engine/asset/AssetManager.js +17 -0
- package/src/engine/ecs/Entity.d.ts.map +1 -1
- package/src/engine/ecs/Entity.js +1 -0
- package/src/engine/ecs/terrain/ecs/TerrainSystem.d.ts.map +1 -1
- package/src/engine/ecs/terrain/ecs/TerrainSystem.js +3 -3
- package/src/engine/input/ecs/systems/InputControllerSystem.d.ts.map +1 -1
- package/src/engine/input/ecs/systems/InputControllerSystem.js +4 -8
- package/src/engine/intelligence/behavior/util/RandomDelayBehavior.d.ts +46 -0
- package/src/engine/intelligence/behavior/util/RandomDelayBehavior.d.ts.map +1 -0
- package/src/engine/intelligence/behavior/util/RandomDelayBehavior.js +85 -0
package/build/meep.module.js
CHANGED
|
@@ -41384,6 +41384,133 @@ class FileLoader extends Loader {
|
|
|
41384
41384
|
|
|
41385
41385
|
}
|
|
41386
41386
|
|
|
41387
|
+
/**
|
|
41388
|
+
* Abstract Base class to block based textures loader (dds, pvr, ...)
|
|
41389
|
+
*
|
|
41390
|
+
* Sub classes have to implement the parse() method which will be used in load().
|
|
41391
|
+
*/
|
|
41392
|
+
|
|
41393
|
+
class CompressedTextureLoader extends Loader {
|
|
41394
|
+
|
|
41395
|
+
constructor( manager ) {
|
|
41396
|
+
|
|
41397
|
+
super( manager );
|
|
41398
|
+
|
|
41399
|
+
}
|
|
41400
|
+
|
|
41401
|
+
load( url, onLoad, onProgress, onError ) {
|
|
41402
|
+
|
|
41403
|
+
const scope = this;
|
|
41404
|
+
|
|
41405
|
+
const images = [];
|
|
41406
|
+
|
|
41407
|
+
const texture = new CompressedTexture();
|
|
41408
|
+
|
|
41409
|
+
const loader = new FileLoader( this.manager );
|
|
41410
|
+
loader.setPath( this.path );
|
|
41411
|
+
loader.setResponseType( 'arraybuffer' );
|
|
41412
|
+
loader.setRequestHeader( this.requestHeader );
|
|
41413
|
+
loader.setWithCredentials( scope.withCredentials );
|
|
41414
|
+
|
|
41415
|
+
let loaded = 0;
|
|
41416
|
+
|
|
41417
|
+
function loadTexture( i ) {
|
|
41418
|
+
|
|
41419
|
+
loader.load( url[ i ], function ( buffer ) {
|
|
41420
|
+
|
|
41421
|
+
const texDatas = scope.parse( buffer, true );
|
|
41422
|
+
|
|
41423
|
+
images[ i ] = {
|
|
41424
|
+
width: texDatas.width,
|
|
41425
|
+
height: texDatas.height,
|
|
41426
|
+
format: texDatas.format,
|
|
41427
|
+
mipmaps: texDatas.mipmaps
|
|
41428
|
+
};
|
|
41429
|
+
|
|
41430
|
+
loaded += 1;
|
|
41431
|
+
|
|
41432
|
+
if ( loaded === 6 ) {
|
|
41433
|
+
|
|
41434
|
+
if ( texDatas.mipmapCount === 1 ) texture.minFilter = LinearFilter;
|
|
41435
|
+
|
|
41436
|
+
texture.image = images;
|
|
41437
|
+
texture.format = texDatas.format;
|
|
41438
|
+
texture.needsUpdate = true;
|
|
41439
|
+
|
|
41440
|
+
if ( onLoad ) onLoad( texture );
|
|
41441
|
+
|
|
41442
|
+
}
|
|
41443
|
+
|
|
41444
|
+
}, onProgress, onError );
|
|
41445
|
+
|
|
41446
|
+
}
|
|
41447
|
+
|
|
41448
|
+
if ( Array.isArray( url ) ) {
|
|
41449
|
+
|
|
41450
|
+
for ( let i = 0, il = url.length; i < il; ++ i ) {
|
|
41451
|
+
|
|
41452
|
+
loadTexture( i );
|
|
41453
|
+
|
|
41454
|
+
}
|
|
41455
|
+
|
|
41456
|
+
} else {
|
|
41457
|
+
|
|
41458
|
+
// compressed cubemap texture stored in a single DDS file
|
|
41459
|
+
|
|
41460
|
+
loader.load( url, function ( buffer ) {
|
|
41461
|
+
|
|
41462
|
+
const texDatas = scope.parse( buffer, true );
|
|
41463
|
+
|
|
41464
|
+
if ( texDatas.isCubemap ) {
|
|
41465
|
+
|
|
41466
|
+
const faces = texDatas.mipmaps.length / texDatas.mipmapCount;
|
|
41467
|
+
|
|
41468
|
+
for ( let f = 0; f < faces; f ++ ) {
|
|
41469
|
+
|
|
41470
|
+
images[ f ] = { mipmaps: [] };
|
|
41471
|
+
|
|
41472
|
+
for ( let i = 0; i < texDatas.mipmapCount; i ++ ) {
|
|
41473
|
+
|
|
41474
|
+
images[ f ].mipmaps.push( texDatas.mipmaps[ f * texDatas.mipmapCount + i ] );
|
|
41475
|
+
images[ f ].format = texDatas.format;
|
|
41476
|
+
images[ f ].width = texDatas.width;
|
|
41477
|
+
images[ f ].height = texDatas.height;
|
|
41478
|
+
|
|
41479
|
+
}
|
|
41480
|
+
|
|
41481
|
+
}
|
|
41482
|
+
|
|
41483
|
+
texture.image = images;
|
|
41484
|
+
|
|
41485
|
+
} else {
|
|
41486
|
+
|
|
41487
|
+
texture.image.width = texDatas.width;
|
|
41488
|
+
texture.image.height = texDatas.height;
|
|
41489
|
+
texture.mipmaps = texDatas.mipmaps;
|
|
41490
|
+
|
|
41491
|
+
}
|
|
41492
|
+
|
|
41493
|
+
if ( texDatas.mipmapCount === 1 ) {
|
|
41494
|
+
|
|
41495
|
+
texture.minFilter = LinearFilter;
|
|
41496
|
+
|
|
41497
|
+
}
|
|
41498
|
+
|
|
41499
|
+
texture.format = texDatas.format;
|
|
41500
|
+
texture.needsUpdate = true;
|
|
41501
|
+
|
|
41502
|
+
if ( onLoad ) onLoad( texture );
|
|
41503
|
+
|
|
41504
|
+
}, onProgress, onError );
|
|
41505
|
+
|
|
41506
|
+
}
|
|
41507
|
+
|
|
41508
|
+
return texture;
|
|
41509
|
+
|
|
41510
|
+
}
|
|
41511
|
+
|
|
41512
|
+
}
|
|
41513
|
+
|
|
41387
41514
|
class ImageLoader extends Loader {
|
|
41388
41515
|
|
|
41389
41516
|
constructor( manager ) {
|
|
@@ -53659,14 +53786,15 @@ function sRGB_to_linear(
|
|
|
53659
53786
|
}
|
|
53660
53787
|
|
|
53661
53788
|
/**
|
|
53789
|
+
* @extends {Array.<number>}
|
|
53662
53790
|
* @class
|
|
53663
53791
|
*/
|
|
53664
53792
|
class Color {
|
|
53665
53793
|
/**
|
|
53666
53794
|
*
|
|
53667
|
-
* @param {number} r
|
|
53668
|
-
* @param {number} g
|
|
53669
|
-
* @param {number} b
|
|
53795
|
+
* @param {number} [r] Red from 0 to 1
|
|
53796
|
+
* @param {number} [g] Green from 0 to 1
|
|
53797
|
+
* @param {number} [b] Blue from 0 to 1
|
|
53670
53798
|
* @param {number} [a] value from 0 to 1 Alpha channel (transparency)
|
|
53671
53799
|
*/
|
|
53672
53800
|
constructor(r = 0, g = 0, b = 0, a = 1) {
|
|
@@ -53786,6 +53914,20 @@ class Color {
|
|
|
53786
53914
|
this.set(r, g, b, this.a);
|
|
53787
53915
|
}
|
|
53788
53916
|
|
|
53917
|
+
/**
|
|
53918
|
+
*
|
|
53919
|
+
* @param {number} r
|
|
53920
|
+
* @param {number} g
|
|
53921
|
+
* @param {number} b
|
|
53922
|
+
*/
|
|
53923
|
+
setRGBUint8(r, g, b) {
|
|
53924
|
+
this.setRGB(
|
|
53925
|
+
uint82float(r),
|
|
53926
|
+
uint82float(g),
|
|
53927
|
+
uint82float(b),
|
|
53928
|
+
);
|
|
53929
|
+
}
|
|
53930
|
+
|
|
53789
53931
|
/**
|
|
53790
53932
|
* set alpha
|
|
53791
53933
|
* @param {number} a
|
|
@@ -53803,11 +53945,23 @@ class Color {
|
|
|
53803
53945
|
*/
|
|
53804
53946
|
set(r, g, b, a) {
|
|
53805
53947
|
|
|
53948
|
+
// remember old values
|
|
53806
53949
|
const _r = this.r;
|
|
53807
53950
|
const _g = this.g;
|
|
53808
53951
|
const _b = this.b;
|
|
53809
53952
|
const _a = this.a;
|
|
53810
53953
|
|
|
53954
|
+
if (
|
|
53955
|
+
_r === r
|
|
53956
|
+
&& _g === g
|
|
53957
|
+
&& _b === b
|
|
53958
|
+
&& _a === a
|
|
53959
|
+
) {
|
|
53960
|
+
// no change
|
|
53961
|
+
return;
|
|
53962
|
+
}
|
|
53963
|
+
|
|
53964
|
+
// set new values
|
|
53811
53965
|
this.r = r;
|
|
53812
53966
|
this.g = g;
|
|
53813
53967
|
this.b = b;
|
|
@@ -54049,7 +54203,7 @@ class Color {
|
|
|
54049
54203
|
const g = (value >> 8) & 0xFF;
|
|
54050
54204
|
const b = (value) & 0xFF;
|
|
54051
54205
|
|
|
54052
|
-
this.
|
|
54206
|
+
this.setRGBUint8(r, g, b);
|
|
54053
54207
|
}
|
|
54054
54208
|
|
|
54055
54209
|
/**
|
|
@@ -54114,8 +54268,7 @@ class Color {
|
|
|
54114
54268
|
}
|
|
54115
54269
|
|
|
54116
54270
|
fromJSON({ r, g, b, a = 1 }) {
|
|
54117
|
-
this.
|
|
54118
|
-
this.a = a;
|
|
54271
|
+
this.set(r, g, b, a);
|
|
54119
54272
|
}
|
|
54120
54273
|
|
|
54121
54274
|
toJSON() {
|
|
@@ -54169,8 +54322,7 @@ class Color {
|
|
|
54169
54322
|
const b = buffer.readFloat32();
|
|
54170
54323
|
const a = buffer.readFloat32();
|
|
54171
54324
|
|
|
54172
|
-
this.
|
|
54173
|
-
this.a = a;
|
|
54325
|
+
this.set(r, g, b, a);
|
|
54174
54326
|
}
|
|
54175
54327
|
|
|
54176
54328
|
/**
|
|
@@ -61332,12 +61484,14 @@ class List {
|
|
|
61332
61484
|
};
|
|
61333
61485
|
|
|
61334
61486
|
/**
|
|
61335
|
-
* @param {
|
|
61487
|
+
* @param {[]} [array]
|
|
61336
61488
|
* @constructor
|
|
61337
61489
|
*/
|
|
61338
61490
|
constructor(array) {
|
|
61339
61491
|
|
|
61340
61492
|
/**
|
|
61493
|
+
* @private
|
|
61494
|
+
* @readonly
|
|
61341
61495
|
* @type {T[]}
|
|
61342
61496
|
*/
|
|
61343
61497
|
this.data = array !== undefined ? array.slice() : [];
|
|
@@ -68172,6 +68326,377 @@ class ImageRGBADataLoader extends AssetLoader {
|
|
|
68172
68326
|
}
|
|
68173
68327
|
}
|
|
68174
68328
|
|
|
68329
|
+
class DDSLoader extends CompressedTextureLoader {
|
|
68330
|
+
|
|
68331
|
+
constructor( manager ) {
|
|
68332
|
+
|
|
68333
|
+
super( manager );
|
|
68334
|
+
|
|
68335
|
+
}
|
|
68336
|
+
|
|
68337
|
+
parse( buffer, loadMipmaps ) {
|
|
68338
|
+
|
|
68339
|
+
const dds = { mipmaps: [], width: 0, height: 0, format: null, mipmapCount: 1 };
|
|
68340
|
+
|
|
68341
|
+
// Adapted from @toji's DDS utils
|
|
68342
|
+
// https://github.com/toji/webgl-texture-utils/blob/master/texture-util/dds.js
|
|
68343
|
+
|
|
68344
|
+
// All values and structures referenced from:
|
|
68345
|
+
// http://msdn.microsoft.com/en-us/library/bb943991.aspx/
|
|
68346
|
+
|
|
68347
|
+
const DDS_MAGIC = 0x20534444;
|
|
68348
|
+
|
|
68349
|
+
// let DDSD_CAPS = 0x1;
|
|
68350
|
+
// let DDSD_HEIGHT = 0x2;
|
|
68351
|
+
// let DDSD_WIDTH = 0x4;
|
|
68352
|
+
// let DDSD_PITCH = 0x8;
|
|
68353
|
+
// let DDSD_PIXELFORMAT = 0x1000;
|
|
68354
|
+
const DDSD_MIPMAPCOUNT = 0x20000;
|
|
68355
|
+
// let DDSD_LINEARSIZE = 0x80000;
|
|
68356
|
+
// let DDSD_DEPTH = 0x800000;
|
|
68357
|
+
|
|
68358
|
+
// let DDSCAPS_COMPLEX = 0x8;
|
|
68359
|
+
// let DDSCAPS_MIPMAP = 0x400000;
|
|
68360
|
+
// let DDSCAPS_TEXTURE = 0x1000;
|
|
68361
|
+
|
|
68362
|
+
const DDSCAPS2_CUBEMAP = 0x200;
|
|
68363
|
+
const DDSCAPS2_CUBEMAP_POSITIVEX = 0x400;
|
|
68364
|
+
const DDSCAPS2_CUBEMAP_NEGATIVEX = 0x800;
|
|
68365
|
+
const DDSCAPS2_CUBEMAP_POSITIVEY = 0x1000;
|
|
68366
|
+
const DDSCAPS2_CUBEMAP_NEGATIVEY = 0x2000;
|
|
68367
|
+
const DDSCAPS2_CUBEMAP_POSITIVEZ = 0x4000;
|
|
68368
|
+
const DDSCAPS2_CUBEMAP_NEGATIVEZ = 0x8000;
|
|
68369
|
+
// let DDSCAPS2_VOLUME = 0x200000;
|
|
68370
|
+
|
|
68371
|
+
// let DDPF_ALPHAPIXELS = 0x1;
|
|
68372
|
+
// let DDPF_ALPHA = 0x2;
|
|
68373
|
+
const DDPF_FOURCC = 0x4;
|
|
68374
|
+
// let DDPF_RGB = 0x40;
|
|
68375
|
+
// let DDPF_YUV = 0x200;
|
|
68376
|
+
// let DDPF_LUMINANCE = 0x20000;
|
|
68377
|
+
|
|
68378
|
+
function fourCCToInt32( value ) {
|
|
68379
|
+
|
|
68380
|
+
return value.charCodeAt( 0 ) +
|
|
68381
|
+
( value.charCodeAt( 1 ) << 8 ) +
|
|
68382
|
+
( value.charCodeAt( 2 ) << 16 ) +
|
|
68383
|
+
( value.charCodeAt( 3 ) << 24 );
|
|
68384
|
+
|
|
68385
|
+
}
|
|
68386
|
+
|
|
68387
|
+
function loadARGBMip( buffer, dataOffset, width, height ) {
|
|
68388
|
+
|
|
68389
|
+
const dataLength = width * height * 4;
|
|
68390
|
+
const srcBuffer = new Uint8Array( buffer, dataOffset, dataLength );
|
|
68391
|
+
const byteArray = new Uint8Array( dataLength );
|
|
68392
|
+
let dst = 0;
|
|
68393
|
+
let src = 0;
|
|
68394
|
+
for ( let y = 0; y < height; y ++ ) {
|
|
68395
|
+
|
|
68396
|
+
for ( let x = 0; x < width; x ++ ) {
|
|
68397
|
+
|
|
68398
|
+
const b = srcBuffer[ src ]; src ++;
|
|
68399
|
+
const g = srcBuffer[ src ]; src ++;
|
|
68400
|
+
const r = srcBuffer[ src ]; src ++;
|
|
68401
|
+
const a = srcBuffer[ src ]; src ++;
|
|
68402
|
+
byteArray[ dst ] = r; dst ++; //r
|
|
68403
|
+
byteArray[ dst ] = g; dst ++; //g
|
|
68404
|
+
byteArray[ dst ] = b; dst ++; //b
|
|
68405
|
+
byteArray[ dst ] = a; dst ++; //a
|
|
68406
|
+
|
|
68407
|
+
}
|
|
68408
|
+
|
|
68409
|
+
}
|
|
68410
|
+
|
|
68411
|
+
return byteArray;
|
|
68412
|
+
|
|
68413
|
+
}
|
|
68414
|
+
|
|
68415
|
+
const FOURCC_DXT1 = fourCCToInt32( 'DXT1' );
|
|
68416
|
+
const FOURCC_DXT3 = fourCCToInt32( 'DXT3' );
|
|
68417
|
+
const FOURCC_DXT5 = fourCCToInt32( 'DXT5' );
|
|
68418
|
+
const FOURCC_ETC1 = fourCCToInt32( 'ETC1' );
|
|
68419
|
+
|
|
68420
|
+
const headerLengthInt = 31; // The header length in 32 bit ints
|
|
68421
|
+
|
|
68422
|
+
// Offsets into the header array
|
|
68423
|
+
|
|
68424
|
+
const off_magic = 0;
|
|
68425
|
+
|
|
68426
|
+
const off_size = 1;
|
|
68427
|
+
const off_flags = 2;
|
|
68428
|
+
const off_height = 3;
|
|
68429
|
+
const off_width = 4;
|
|
68430
|
+
|
|
68431
|
+
const off_mipmapCount = 7;
|
|
68432
|
+
|
|
68433
|
+
const off_pfFlags = 20;
|
|
68434
|
+
const off_pfFourCC = 21;
|
|
68435
|
+
const off_RGBBitCount = 22;
|
|
68436
|
+
const off_RBitMask = 23;
|
|
68437
|
+
const off_GBitMask = 24;
|
|
68438
|
+
const off_BBitMask = 25;
|
|
68439
|
+
const off_ABitMask = 26;
|
|
68440
|
+
|
|
68441
|
+
// let off_caps = 27;
|
|
68442
|
+
const off_caps2 = 28;
|
|
68443
|
+
// let off_caps3 = 29;
|
|
68444
|
+
// let off_caps4 = 30;
|
|
68445
|
+
|
|
68446
|
+
// Parse header
|
|
68447
|
+
|
|
68448
|
+
const header = new Int32Array( buffer, 0, headerLengthInt );
|
|
68449
|
+
|
|
68450
|
+
if ( header[ off_magic ] !== DDS_MAGIC ) {
|
|
68451
|
+
return dds;
|
|
68452
|
+
|
|
68453
|
+
}
|
|
68454
|
+
|
|
68455
|
+
if ( ! header[ off_pfFlags ] & DDPF_FOURCC ) {
|
|
68456
|
+
return dds;
|
|
68457
|
+
|
|
68458
|
+
}
|
|
68459
|
+
|
|
68460
|
+
let blockBytes;
|
|
68461
|
+
|
|
68462
|
+
const fourCC = header[ off_pfFourCC ];
|
|
68463
|
+
|
|
68464
|
+
let isRGBAUncompressed = false;
|
|
68465
|
+
|
|
68466
|
+
switch ( fourCC ) {
|
|
68467
|
+
|
|
68468
|
+
case FOURCC_DXT1:
|
|
68469
|
+
|
|
68470
|
+
blockBytes = 8;
|
|
68471
|
+
dds.format = RGB_S3TC_DXT1_Format;
|
|
68472
|
+
break;
|
|
68473
|
+
|
|
68474
|
+
case FOURCC_DXT3:
|
|
68475
|
+
|
|
68476
|
+
blockBytes = 16;
|
|
68477
|
+
dds.format = RGBA_S3TC_DXT3_Format;
|
|
68478
|
+
break;
|
|
68479
|
+
|
|
68480
|
+
case FOURCC_DXT5:
|
|
68481
|
+
|
|
68482
|
+
blockBytes = 16;
|
|
68483
|
+
dds.format = RGBA_S3TC_DXT5_Format;
|
|
68484
|
+
break;
|
|
68485
|
+
|
|
68486
|
+
case FOURCC_ETC1:
|
|
68487
|
+
|
|
68488
|
+
blockBytes = 8;
|
|
68489
|
+
dds.format = RGB_ETC1_Format;
|
|
68490
|
+
break;
|
|
68491
|
+
|
|
68492
|
+
default:
|
|
68493
|
+
|
|
68494
|
+
if ( header[ off_RGBBitCount ] === 32
|
|
68495
|
+
&& header[ off_RBitMask ] & 0xff0000
|
|
68496
|
+
&& header[ off_GBitMask ] & 0xff00
|
|
68497
|
+
&& header[ off_BBitMask ] & 0xff
|
|
68498
|
+
&& header[ off_ABitMask ] & 0xff000000 ) {
|
|
68499
|
+
|
|
68500
|
+
isRGBAUncompressed = true;
|
|
68501
|
+
blockBytes = 64;
|
|
68502
|
+
dds.format = RGBAFormat;
|
|
68503
|
+
|
|
68504
|
+
} else {
|
|
68505
|
+
return dds;
|
|
68506
|
+
|
|
68507
|
+
}
|
|
68508
|
+
|
|
68509
|
+
}
|
|
68510
|
+
|
|
68511
|
+
dds.mipmapCount = 1;
|
|
68512
|
+
|
|
68513
|
+
if ( header[ off_flags ] & DDSD_MIPMAPCOUNT && loadMipmaps !== false ) {
|
|
68514
|
+
|
|
68515
|
+
dds.mipmapCount = Math.max( 1, header[ off_mipmapCount ] );
|
|
68516
|
+
|
|
68517
|
+
}
|
|
68518
|
+
|
|
68519
|
+
const caps2 = header[ off_caps2 ];
|
|
68520
|
+
dds.isCubemap = caps2 & DDSCAPS2_CUBEMAP ? true : false;
|
|
68521
|
+
if ( dds.isCubemap && (
|
|
68522
|
+
! ( caps2 & DDSCAPS2_CUBEMAP_POSITIVEX ) ||
|
|
68523
|
+
! ( caps2 & DDSCAPS2_CUBEMAP_NEGATIVEX ) ||
|
|
68524
|
+
! ( caps2 & DDSCAPS2_CUBEMAP_POSITIVEY ) ||
|
|
68525
|
+
! ( caps2 & DDSCAPS2_CUBEMAP_NEGATIVEY ) ||
|
|
68526
|
+
! ( caps2 & DDSCAPS2_CUBEMAP_POSITIVEZ ) ||
|
|
68527
|
+
! ( caps2 & DDSCAPS2_CUBEMAP_NEGATIVEZ )
|
|
68528
|
+
) ) {
|
|
68529
|
+
return dds;
|
|
68530
|
+
|
|
68531
|
+
}
|
|
68532
|
+
|
|
68533
|
+
dds.width = header[ off_width ];
|
|
68534
|
+
dds.height = header[ off_height ];
|
|
68535
|
+
|
|
68536
|
+
let dataOffset = header[ off_size ] + 4;
|
|
68537
|
+
|
|
68538
|
+
// Extract mipmaps buffers
|
|
68539
|
+
|
|
68540
|
+
const faces = dds.isCubemap ? 6 : 1;
|
|
68541
|
+
|
|
68542
|
+
for ( let face = 0; face < faces; face ++ ) {
|
|
68543
|
+
|
|
68544
|
+
let width = dds.width;
|
|
68545
|
+
let height = dds.height;
|
|
68546
|
+
|
|
68547
|
+
for ( let i = 0; i < dds.mipmapCount; i ++ ) {
|
|
68548
|
+
|
|
68549
|
+
let byteArray, dataLength;
|
|
68550
|
+
|
|
68551
|
+
if ( isRGBAUncompressed ) {
|
|
68552
|
+
|
|
68553
|
+
byteArray = loadARGBMip( buffer, dataOffset, width, height );
|
|
68554
|
+
dataLength = byteArray.length;
|
|
68555
|
+
|
|
68556
|
+
} else {
|
|
68557
|
+
|
|
68558
|
+
dataLength = Math.max( 4, width ) / 4 * Math.max( 4, height ) / 4 * blockBytes;
|
|
68559
|
+
byteArray = new Uint8Array( buffer, dataOffset, dataLength );
|
|
68560
|
+
|
|
68561
|
+
}
|
|
68562
|
+
|
|
68563
|
+
const mipmap = { 'data': byteArray, 'width': width, 'height': height };
|
|
68564
|
+
dds.mipmaps.push( mipmap );
|
|
68565
|
+
|
|
68566
|
+
dataOffset += dataLength;
|
|
68567
|
+
|
|
68568
|
+
width = Math.max( width >> 1, 1 );
|
|
68569
|
+
height = Math.max( height >> 1, 1 );
|
|
68570
|
+
|
|
68571
|
+
}
|
|
68572
|
+
|
|
68573
|
+
}
|
|
68574
|
+
|
|
68575
|
+
return dds;
|
|
68576
|
+
|
|
68577
|
+
}
|
|
68578
|
+
|
|
68579
|
+
}
|
|
68580
|
+
|
|
68581
|
+
/**
|
|
68582
|
+
*
|
|
68583
|
+
* @param {Texture} t
|
|
68584
|
+
* @returns {Texture}
|
|
68585
|
+
*/
|
|
68586
|
+
function cloneTexture(t) {
|
|
68587
|
+
const clone = t.clone();
|
|
68588
|
+
|
|
68589
|
+
//apparently cloned textures need this trick to work
|
|
68590
|
+
clone.needsUpdate = true;
|
|
68591
|
+
|
|
68592
|
+
return clone;
|
|
68593
|
+
}
|
|
68594
|
+
|
|
68595
|
+
function loadDDSTexture(path, success, failure, progress) {
|
|
68596
|
+
function computeByteSize(texture) {
|
|
68597
|
+
let result = 0;
|
|
68598
|
+
const images = texture.image;
|
|
68599
|
+
for (let i = 0; i < images.length; i++) {
|
|
68600
|
+
const image = images[i];
|
|
68601
|
+
const mipmaps = image.mipmaps;
|
|
68602
|
+
for (let j = 0; j < mipmaps.length; j++) {
|
|
68603
|
+
const mipmap = mipmaps[j];
|
|
68604
|
+
/**
|
|
68605
|
+
* @type {Uint8Array}
|
|
68606
|
+
*/
|
|
68607
|
+
const data = mipmap.data;
|
|
68608
|
+
result += data.length;
|
|
68609
|
+
}
|
|
68610
|
+
}
|
|
68611
|
+
return result;
|
|
68612
|
+
}
|
|
68613
|
+
|
|
68614
|
+
const loader = new DDSLoader();
|
|
68615
|
+
loader.load(path, function (texture) {
|
|
68616
|
+
const byteSize = computeByteSize(texture);
|
|
68617
|
+
|
|
68618
|
+
function factory() {
|
|
68619
|
+
return cloneTexture(texture);
|
|
68620
|
+
}
|
|
68621
|
+
|
|
68622
|
+
const asset = new Asset(factory, byteSize);
|
|
68623
|
+
|
|
68624
|
+
success(asset);
|
|
68625
|
+
|
|
68626
|
+
}, progress, failure);
|
|
68627
|
+
}
|
|
68628
|
+
|
|
68629
|
+
const textureLoader = new TextureLoader();
|
|
68630
|
+
|
|
68631
|
+
/**
|
|
68632
|
+
*
|
|
68633
|
+
* @param {Texture} texture
|
|
68634
|
+
* @return {number}
|
|
68635
|
+
*/
|
|
68636
|
+
function computeTextureByteSize(texture) {
|
|
68637
|
+
const image = texture.image;
|
|
68638
|
+
if (image instanceof ImageData) {
|
|
68639
|
+
return image.array.length;
|
|
68640
|
+
} else {
|
|
68641
|
+
//TODO do actual computation
|
|
68642
|
+
//don't know
|
|
68643
|
+
return 1;
|
|
68644
|
+
}
|
|
68645
|
+
}
|
|
68646
|
+
function loadStandardImageTexture(path, success, failure, progress) {
|
|
68647
|
+
|
|
68648
|
+
|
|
68649
|
+
|
|
68650
|
+
textureLoader.load(path, function (texture) {
|
|
68651
|
+
|
|
68652
|
+
texture.flipY = false;
|
|
68653
|
+
|
|
68654
|
+
const byteSize = computeTextureByteSize(texture);
|
|
68655
|
+
|
|
68656
|
+
const asset = new Asset(function () {
|
|
68657
|
+
return cloneTexture(texture);
|
|
68658
|
+
}, byteSize);
|
|
68659
|
+
|
|
68660
|
+
success(asset);
|
|
68661
|
+
}, progress, failure);
|
|
68662
|
+
}
|
|
68663
|
+
|
|
68664
|
+
class TextureAssetLoader extends AssetLoader {
|
|
68665
|
+
load(scope, path, success, failure, progress) {
|
|
68666
|
+
//figure out what kind of a texture it is
|
|
68667
|
+
let fileExtension = computeFileExtension(path);
|
|
68668
|
+
|
|
68669
|
+
if (fileExtension === null) {
|
|
68670
|
+
//check if it's a data path
|
|
68671
|
+
|
|
68672
|
+
const match = path.match(/^data\:image\/([a-zA-Z0-9]+)\;/);
|
|
68673
|
+
|
|
68674
|
+
if (match === null) {
|
|
68675
|
+
throw new Error(`no file extension on path '${path}'`);
|
|
68676
|
+
|
|
68677
|
+
} else {
|
|
68678
|
+
//seems ok
|
|
68679
|
+
fileExtension = match[1];
|
|
68680
|
+
}
|
|
68681
|
+
|
|
68682
|
+
}
|
|
68683
|
+
|
|
68684
|
+
const lowerCaseExtension = fileExtension.toLowerCase();
|
|
68685
|
+
switch (lowerCaseExtension) {
|
|
68686
|
+
case 'dds':
|
|
68687
|
+
loadDDSTexture(path, success, failure, progress);
|
|
68688
|
+
break;
|
|
68689
|
+
case 'png':
|
|
68690
|
+
case 'jpg':
|
|
68691
|
+
loadStandardImageTexture(path, success, failure, progress);
|
|
68692
|
+
break;
|
|
68693
|
+
default:
|
|
68694
|
+
throw new Error(`Unsupported texture file format: '${lowerCaseExtension}'`);
|
|
68695
|
+
|
|
68696
|
+
}
|
|
68697
|
+
}
|
|
68698
|
+
}
|
|
68699
|
+
|
|
68175
68700
|
/**
|
|
68176
68701
|
* Utility class for managing connection between listeners to signals
|
|
68177
68702
|
*/
|
|
@@ -69742,9 +70267,8 @@ class TerrainSystem extends System {
|
|
|
69742
70267
|
|
|
69743
70268
|
const am = this.assetManager;
|
|
69744
70269
|
|
|
69745
|
-
|
|
69746
|
-
|
|
69747
|
-
}
|
|
70270
|
+
await am.tryRegisterLoader('image', new ImageRGBADataLoader());
|
|
70271
|
+
await am.tryRegisterLoader('texture', new TextureAssetLoader());
|
|
69748
70272
|
|
|
69749
70273
|
readyCallback();
|
|
69750
70274
|
}
|
|
@@ -72771,6 +73295,7 @@ class Entity {
|
|
|
72771
73295
|
|
|
72772
73296
|
/**
|
|
72773
73297
|
* Similar to {@link #getComponent}, instead of returning null - throws an exception
|
|
73298
|
+
* @template T
|
|
72774
73299
|
* @param {Class<T>} klass
|
|
72775
73300
|
* @returns {T}
|
|
72776
73301
|
*/
|
|
@@ -85821,6 +86346,23 @@ class AssetManager {
|
|
|
85821
86346
|
return true;
|
|
85822
86347
|
}
|
|
85823
86348
|
|
|
86349
|
+
/**
|
|
86350
|
+
* Will register loader only if none exists for this type
|
|
86351
|
+
* @template T
|
|
86352
|
+
* @param {string} type
|
|
86353
|
+
* @param {AssetLoader<T>} loader
|
|
86354
|
+
* @returns {Promise<boolean>} true if registered , false otherwise
|
|
86355
|
+
*/
|
|
86356
|
+
async tryRegisterLoader(type, loader) {
|
|
86357
|
+
if (this.hasLoaderForType(type)) {
|
|
86358
|
+
return false;
|
|
86359
|
+
}
|
|
86360
|
+
|
|
86361
|
+
await this.registerLoader(type, loader);
|
|
86362
|
+
|
|
86363
|
+
return true;
|
|
86364
|
+
}
|
|
86365
|
+
|
|
85824
86366
|
/**
|
|
85825
86367
|
* @template T
|
|
85826
86368
|
* @param {string} type
|
|
@@ -114118,12 +114660,8 @@ function getOrCreateProxy(proxies, path, signal) {
|
|
|
114118
114660
|
* @param {InputControllerBinding} binding
|
|
114119
114661
|
*/
|
|
114120
114662
|
Proxy.prototype.add = function (binding) {
|
|
114121
|
-
|
|
114122
|
-
|
|
114123
|
-
this.deferred.push(binding);
|
|
114124
|
-
} else {
|
|
114125
|
-
this.registerBinding(binding);
|
|
114126
|
-
}
|
|
114663
|
+
//TODO handle case where binding is added mid-dispatch
|
|
114664
|
+
this.registerBinding(binding);
|
|
114127
114665
|
};
|
|
114128
114666
|
|
|
114129
114667
|
/**
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"List.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/list/List.js"],"names":[],"mappings":";AAaA;;;;GAIG;AACH;IAeI;;;OAGG;IACH,oBAHW,
|
|
1
|
+
{"version":3,"file":"List.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/list/List.js"],"names":[],"mappings":"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"}
|
|
@@ -32,12 +32,14 @@ class List {
|
|
|
32
32
|
};
|
|
33
33
|
|
|
34
34
|
/**
|
|
35
|
-
* @param {
|
|
35
|
+
* @param {[]} [array]
|
|
36
36
|
* @constructor
|
|
37
37
|
*/
|
|
38
38
|
constructor(array) {
|
|
39
39
|
|
|
40
40
|
/**
|
|
41
|
+
* @private
|
|
42
|
+
* @readonly
|
|
41
43
|
* @type {T[]}
|
|
42
44
|
*/
|
|
43
45
|
this.data = array !== undefined ? array.slice() : [];
|