@galacean/engine-loader 1.0.0-alpha.6 → 1.0.0-beta.0
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/dist/main.js +402 -362
- package/dist/main.js.map +1 -1
- package/dist/miniprogram.js +402 -362
- package/dist/module.js +403 -363
- package/dist/module.js.map +1 -1
- package/package.json +5 -5
- package/types/GLTFLoader.d.ts +4 -1
- package/types/gltf/{GLTFUtil.d.ts → GLTFUtils.d.ts} +1 -7
- package/types/gltf/extensions/GLTFExtensionSchema.d.ts +2 -2
- package/types/gltf/extensions/index.d.ts +2 -2
- package/types/gltf/index.d.ts +1 -1
- package/types/gltf/GLTFParser.d.ts +0 -9
- package/types/gltf/Schema.d.ts +0 -814
- package/types/gltf/extensions/ExtensionParser.d.ts +0 -8
- package/types/gltf/extensions/OASIS_materials_remap.d.ts +0 -1
- package/types/gltf/extensions/Schema.d.ts +0 -142
- package/types/gltf/parser/AnimationParser.d.ts +0 -7
- package/types/gltf/parser/BufferParser.d.ts +0 -7
- package/types/gltf/parser/EntityParser.d.ts +0 -9
- package/types/gltf/parser/MaterialParser.d.ts +0 -8
- package/types/gltf/parser/MeshParser.d.ts +0 -13
- package/types/gltf/parser/Parser.d.ts +0 -21
- package/types/gltf/parser/ParserContext.d.ts +0 -46
- package/types/gltf/parser/SceneParser.d.ts +0 -11
- package/types/gltf/parser/SkinParser.d.ts +0 -6
- package/types/gltf/parser/TextureParser.d.ts +0 -8
- package/types/gltf/parser/Validator.d.ts +0 -5
- /package/types/gltf/extensions/{OASIS_animation_event.d.ts → GALACEAN_animation_event.d.ts} +0 -0
package/dist/main.js
CHANGED
|
@@ -7,54 +7,37 @@ var engineMath = require('@galacean/engine-math');
|
|
|
7
7
|
var engineRhiWebgl = require('@galacean/engine-rhi-webgl');
|
|
8
8
|
var engineDraco = require('@galacean/engine-draco');
|
|
9
9
|
|
|
10
|
-
function
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
for (var key in source) {
|
|
16
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
17
|
-
target[key] = source[key];
|
|
10
|
+
function _extends() {
|
|
11
|
+
_extends = Object.assign || function assign(target) {
|
|
12
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
13
|
+
var source = arguments[i];
|
|
14
|
+
for (var key in source) if (Object.prototype.hasOwnProperty.call(source, key)) target[key] = source[key];
|
|
18
15
|
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
16
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return extends_.apply(this, arguments);
|
|
26
|
-
}
|
|
17
|
+
return target;
|
|
18
|
+
};
|
|
27
19
|
|
|
28
|
-
|
|
29
|
-
return extends_.apply(this, arguments);
|
|
20
|
+
return _extends.apply(this, arguments);
|
|
30
21
|
}
|
|
31
22
|
|
|
32
|
-
function
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
return o;
|
|
36
|
-
};
|
|
23
|
+
function _set_prototype_of(o, p) {
|
|
24
|
+
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
|
|
25
|
+
o.__proto__ = p;
|
|
37
26
|
|
|
38
|
-
|
|
39
|
-
}
|
|
27
|
+
return o;
|
|
28
|
+
};
|
|
40
29
|
|
|
41
|
-
|
|
42
|
-
return setPrototypeOf(o, p);
|
|
30
|
+
return _set_prototype_of(o, p);
|
|
43
31
|
}
|
|
44
32
|
|
|
45
33
|
function _inherits(subClass, superClass) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
51
|
-
constructor: {
|
|
52
|
-
value: subClass,
|
|
53
|
-
writable: true,
|
|
54
|
-
configurable: true
|
|
34
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
35
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
55
36
|
}
|
|
56
|
-
|
|
57
|
-
|
|
37
|
+
|
|
38
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } });
|
|
39
|
+
|
|
40
|
+
if (superClass) _set_prototype_of(subClass, superClass);
|
|
58
41
|
}
|
|
59
42
|
|
|
60
43
|
/******************************************************************************
|
|
@@ -273,39 +256,34 @@ EnvLoader = __decorate([
|
|
|
273
256
|
], EnvLoader);
|
|
274
257
|
|
|
275
258
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
resolve(value);
|
|
286
|
-
} else {
|
|
287
|
-
Promise.resolve(value).then(_next, _throw);
|
|
288
|
-
}
|
|
259
|
+
try {
|
|
260
|
+
var info = gen[key](arg);
|
|
261
|
+
var value = info.value;
|
|
262
|
+
} catch (error) {
|
|
263
|
+
reject(error);
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
if (info.done) resolve(value);
|
|
267
|
+
else Promise.resolve(value).then(_next, _throw);
|
|
289
268
|
}
|
|
269
|
+
function _async_to_generator(fn) {
|
|
270
|
+
return function() {
|
|
271
|
+
var self = this, args = arguments;
|
|
290
272
|
|
|
291
|
-
function
|
|
292
|
-
|
|
293
|
-
var self = this,
|
|
294
|
-
args = arguments;
|
|
295
|
-
return new Promise(function (resolve, reject) {
|
|
296
|
-
var gen = fn.apply(self, args);
|
|
273
|
+
return new Promise(function(resolve, reject) {
|
|
274
|
+
var gen = fn.apply(self, args);
|
|
297
275
|
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
276
|
+
function _next(value) {
|
|
277
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
278
|
+
}
|
|
301
279
|
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
280
|
+
function _throw(err) {
|
|
281
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
282
|
+
}
|
|
305
283
|
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
284
|
+
_next(undefined);
|
|
285
|
+
});
|
|
286
|
+
};
|
|
309
287
|
}
|
|
310
288
|
|
|
311
289
|
var FontLoader = /*#__PURE__*/ function(Loader) {
|
|
@@ -338,7 +316,7 @@ var FontLoader = /*#__PURE__*/ function(Loader) {
|
|
|
338
316
|
});
|
|
339
317
|
};
|
|
340
318
|
_proto._registerFont = function _registerFont(fontName, fontUrl) {
|
|
341
|
-
return
|
|
319
|
+
return _async_to_generator(function() {
|
|
342
320
|
var fontFace;
|
|
343
321
|
return __generator(this, function(_state) {
|
|
344
322
|
switch(_state.label){
|
|
@@ -366,39 +344,43 @@ FontLoader = __decorate([
|
|
|
366
344
|
], false)
|
|
367
345
|
], FontLoader);
|
|
368
346
|
|
|
369
|
-
function
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
347
|
+
function _array_like_to_array(arr, len) {
|
|
348
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
349
|
+
|
|
350
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
351
|
+
|
|
352
|
+
return arr2;
|
|
373
353
|
}
|
|
374
354
|
|
|
375
|
-
function
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
355
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
356
|
+
if (!o) return;
|
|
357
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
358
|
+
|
|
359
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
360
|
+
|
|
361
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
362
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
363
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
383
364
|
}
|
|
384
365
|
|
|
385
|
-
function
|
|
366
|
+
function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
|
|
386
367
|
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
368
|
+
|
|
387
369
|
if (it) return (it = it.call(o)).next.bind(it);
|
|
388
370
|
// Fallback for engines without symbol support
|
|
389
|
-
if (
|
|
390
|
-
Array.isArray(o) ||
|
|
391
|
-
(it = _unsupportedIterableToArray(o)) ||
|
|
392
|
-
(allowArrayLike && o && typeof o.length === "number")
|
|
393
|
-
) {
|
|
371
|
+
if (Array.isArray(o) || (it = _unsupported_iterable_to_array(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
394
372
|
if (it) o = it;
|
|
373
|
+
|
|
395
374
|
var i = 0;
|
|
396
|
-
|
|
375
|
+
|
|
376
|
+
return function() {
|
|
397
377
|
if (i >= o.length) return { done: true };
|
|
378
|
+
|
|
398
379
|
return { done: false, value: o[i++] };
|
|
399
|
-
}
|
|
380
|
+
};
|
|
400
381
|
}
|
|
401
|
-
|
|
382
|
+
|
|
383
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
402
384
|
}
|
|
403
385
|
|
|
404
386
|
/**
|
|
@@ -440,16 +422,16 @@ function _createForOfIteratorHelperLoose(o, allowArrayLike) {
|
|
|
440
422
|
var buffer = buffers[bufferView.buffer];
|
|
441
423
|
var _bufferView_byteOffset;
|
|
442
424
|
var bufferData = new Uint8Array(buffer, (_bufferView_byteOffset = bufferView.byteOffset) != null ? _bufferView_byteOffset : 0, bufferView.byteLength);
|
|
443
|
-
return
|
|
425
|
+
return GLTFUtils.loadImageBuffer(bufferData, textureRestoreInfo.mimeType).then(function(image) {
|
|
444
426
|
textureRestoreInfo.texture.setImageSource(image);
|
|
445
427
|
textureRestoreInfo.texture.generateMipmaps();
|
|
446
428
|
});
|
|
447
429
|
})).then(function() {
|
|
448
430
|
// Restore mesh
|
|
449
|
-
for(var _iterator =
|
|
431
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(_this.meshes), _step; !(_step = _iterator()).done;){
|
|
450
432
|
var meshInfo = _step.value;
|
|
451
433
|
var mesh = meshInfo.mesh;
|
|
452
|
-
for(var _iterator1 =
|
|
434
|
+
for(var _iterator1 = _create_for_of_iterator_helper_loose(meshInfo.vertexBuffers), _step1; !(_step1 = _iterator1()).done;){
|
|
453
435
|
var bufferRestoreInfo = _step1.value;
|
|
454
436
|
var vertexData = _this._getBufferData(buffers, bufferRestoreInfo.data);
|
|
455
437
|
bufferRestoreInfo.buffer.setData(vertexData);
|
|
@@ -458,18 +440,18 @@ function _createForOfIteratorHelperLoose(o, allowArrayLike) {
|
|
|
458
440
|
var indexData = _this._getBufferData(buffers, meshInfo.indexBuffer);
|
|
459
441
|
mesh.setIndices(indexData);
|
|
460
442
|
}
|
|
461
|
-
for(var _iterator2 =
|
|
443
|
+
for(var _iterator2 = _create_for_of_iterator_helper_loose(meshInfo.blendShapes), _step2; !(_step2 = _iterator2()).done;){
|
|
462
444
|
var restoreInfo = _step2.value;
|
|
463
445
|
var frame = restoreInfo.blendShape.frames[0];
|
|
464
446
|
var positionData = _this._getBufferData(buffers, restoreInfo.position);
|
|
465
|
-
frame.deltaPositions =
|
|
447
|
+
frame.deltaPositions = GLTFUtils.floatBufferToVector3Array(positionData);
|
|
466
448
|
if (restoreInfo.normal) {
|
|
467
449
|
var normalData = _this._getBufferData(buffers, restoreInfo.normal);
|
|
468
|
-
frame.deltaNormals =
|
|
450
|
+
frame.deltaNormals = GLTFUtils.floatBufferToVector3Array(normalData);
|
|
469
451
|
}
|
|
470
452
|
if (restoreInfo.tangent) {
|
|
471
453
|
var tangentData = _this._getBufferData(buffers, restoreInfo.tangent);
|
|
472
|
-
frame.deltaTangents =
|
|
454
|
+
frame.deltaTangents = GLTFUtils.floatBufferToVector3Array(tangentData);
|
|
473
455
|
}
|
|
474
456
|
}
|
|
475
457
|
mesh.uploadData(true);
|
|
@@ -751,9 +733,9 @@ var TextureWrapMode;
|
|
|
751
733
|
|
|
752
734
|
/**
|
|
753
735
|
* @internal
|
|
754
|
-
*/ var
|
|
755
|
-
function
|
|
756
|
-
|
|
736
|
+
*/ var GLTFUtils = /*#__PURE__*/ function() {
|
|
737
|
+
function GLTFUtils() {}
|
|
738
|
+
GLTFUtils.floatBufferToVector2Array = function floatBufferToVector2Array(buffer) {
|
|
757
739
|
var bufferLen = buffer.length;
|
|
758
740
|
var array = new Array(bufferLen / 2);
|
|
759
741
|
for(var i = 0; i < bufferLen; i += 2){
|
|
@@ -761,7 +743,7 @@ var TextureWrapMode;
|
|
|
761
743
|
}
|
|
762
744
|
return array;
|
|
763
745
|
};
|
|
764
|
-
|
|
746
|
+
GLTFUtils.floatBufferToVector3Array = function floatBufferToVector3Array(buffer) {
|
|
765
747
|
var bufferLen = buffer.length;
|
|
766
748
|
var array = new Array(bufferLen / 3);
|
|
767
749
|
for(var i = 0; i < bufferLen; i += 3){
|
|
@@ -769,7 +751,7 @@ var TextureWrapMode;
|
|
|
769
751
|
}
|
|
770
752
|
return array;
|
|
771
753
|
};
|
|
772
|
-
|
|
754
|
+
GLTFUtils.floatBufferToVector4Array = function floatBufferToVector4Array(buffer) {
|
|
773
755
|
var bufferLen = buffer.length;
|
|
774
756
|
var array = new Array(bufferLen / 4);
|
|
775
757
|
for(var i = 0; i < bufferLen; i += 4){
|
|
@@ -777,7 +759,7 @@ var TextureWrapMode;
|
|
|
777
759
|
}
|
|
778
760
|
return array;
|
|
779
761
|
};
|
|
780
|
-
|
|
762
|
+
GLTFUtils.floatBufferToColorArray = function floatBufferToColorArray(buffer, isColor3) {
|
|
781
763
|
var bufferLen = buffer.length;
|
|
782
764
|
var colors = new Array(bufferLen / (isColor3 ? 3 : 4));
|
|
783
765
|
if (isColor3) {
|
|
@@ -792,21 +774,8 @@ var TextureWrapMode;
|
|
|
792
774
|
return colors;
|
|
793
775
|
};
|
|
794
776
|
/**
|
|
795
|
-
* Parse binary text for glb loader.
|
|
796
|
-
*/ GLTFUtil.decodeText = function decodeText(array) {
|
|
797
|
-
if (typeof TextDecoder !== "undefined") {
|
|
798
|
-
return new TextDecoder().decode(array);
|
|
799
|
-
}
|
|
800
|
-
// TextDecoder polyfill
|
|
801
|
-
var s = "";
|
|
802
|
-
for(var i = 0, il = array.length; i < il; i++){
|
|
803
|
-
s += String.fromCharCode(array[i]);
|
|
804
|
-
}
|
|
805
|
-
return decodeURIComponent(encodeURIComponent(s));
|
|
806
|
-
};
|
|
807
|
-
/**
|
|
808
777
|
* Get the number of bytes occupied by accessor type.
|
|
809
|
-
*/
|
|
778
|
+
*/ GLTFUtils.getAccessorTypeSize = function getAccessorTypeSize(accessorType) {
|
|
810
779
|
switch(accessorType){
|
|
811
780
|
case AccessorType.SCALAR:
|
|
812
781
|
return 1;
|
|
@@ -826,7 +795,7 @@ var TextureWrapMode;
|
|
|
826
795
|
};
|
|
827
796
|
/**
|
|
828
797
|
* Get the TypedArray corresponding to the component type.
|
|
829
|
-
*/
|
|
798
|
+
*/ GLTFUtils.getComponentType = function getComponentType(componentType) {
|
|
830
799
|
switch(componentType){
|
|
831
800
|
case AccessorComponentType.BYTE:
|
|
832
801
|
return Int8Array;
|
|
@@ -842,7 +811,7 @@ var TextureWrapMode;
|
|
|
842
811
|
return Float32Array;
|
|
843
812
|
}
|
|
844
813
|
};
|
|
845
|
-
|
|
814
|
+
GLTFUtils.getNormalizedComponentScale = function getNormalizedComponentScale(componentType) {
|
|
846
815
|
// Reference: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization#encoding-quantized-data
|
|
847
816
|
switch(componentType){
|
|
848
817
|
case AccessorComponentType.BYTE:
|
|
@@ -857,7 +826,7 @@ var TextureWrapMode;
|
|
|
857
826
|
throw new Error("Galacean.GLTFLoader: Unsupported normalized accessor component type.");
|
|
858
827
|
}
|
|
859
828
|
};
|
|
860
|
-
|
|
829
|
+
GLTFUtils.getAccessorBuffer = function getAccessorBuffer(context, bufferViews, accessor) {
|
|
861
830
|
var buffers = context.buffers;
|
|
862
831
|
var componentType = accessor.componentType;
|
|
863
832
|
var bufferView = bufferViews[accessor.bufferView];
|
|
@@ -865,8 +834,8 @@ var TextureWrapMode;
|
|
|
865
834
|
var buffer = buffers[bufferIndex];
|
|
866
835
|
var bufferByteOffset = bufferView.byteOffset || 0;
|
|
867
836
|
var byteOffset = accessor.byteOffset || 0;
|
|
868
|
-
var TypedArray =
|
|
869
|
-
var dataElementSize =
|
|
837
|
+
var TypedArray = GLTFUtils.getComponentType(componentType);
|
|
838
|
+
var dataElementSize = GLTFUtils.getAccessorTypeSize(accessor.type);
|
|
870
839
|
var dataElementBytes = TypedArray.BYTES_PER_ELEMENT;
|
|
871
840
|
var elementStride = dataElementSize * dataElementBytes;
|
|
872
841
|
var accessorCount = accessor.count;
|
|
@@ -893,25 +862,25 @@ var TextureWrapMode;
|
|
|
893
862
|
bufferInfo.restoreInfo = new BufferDataRestoreInfo(new RestoreDataAccessor(bufferIndex, TypedArray, offset1, count1));
|
|
894
863
|
}
|
|
895
864
|
if (accessor.sparse) {
|
|
896
|
-
|
|
865
|
+
GLTFUtils.processingSparseData(bufferViews, accessor, buffers, bufferInfo);
|
|
897
866
|
}
|
|
898
867
|
return bufferInfo;
|
|
899
868
|
};
|
|
900
869
|
/**
|
|
901
870
|
* @deprecated
|
|
902
871
|
* Get accessor data.
|
|
903
|
-
*/
|
|
872
|
+
*/ GLTFUtils.getAccessorData = function getAccessorData(glTF, accessor, buffers) {
|
|
904
873
|
var bufferViews = glTF.bufferViews;
|
|
905
874
|
var bufferView = bufferViews[accessor.bufferView];
|
|
906
875
|
var arrayBuffer = buffers[bufferView.buffer];
|
|
907
876
|
var accessorByteOffset = accessor.hasOwnProperty("byteOffset") ? accessor.byteOffset : 0;
|
|
908
877
|
var bufferViewByteOffset = bufferView.hasOwnProperty("byteOffset") ? bufferView.byteOffset : 0;
|
|
909
878
|
var byteOffset = accessorByteOffset + bufferViewByteOffset;
|
|
910
|
-
var accessorTypeSize =
|
|
879
|
+
var accessorTypeSize = GLTFUtils.getAccessorTypeSize(accessor.type);
|
|
911
880
|
var length = accessorTypeSize * accessor.count;
|
|
912
881
|
var _bufferView_byteStride;
|
|
913
882
|
var byteStride = (_bufferView_byteStride = bufferView.byteStride) != null ? _bufferView_byteStride : 0;
|
|
914
|
-
var arrayType =
|
|
883
|
+
var arrayType = GLTFUtils.getComponentType(accessor.componentType);
|
|
915
884
|
var uint8Array;
|
|
916
885
|
if (byteStride) {
|
|
917
886
|
var accessorByteSize = accessorTypeSize * arrayType.BYTES_PER_ELEMENT;
|
|
@@ -938,7 +907,7 @@ var TextureWrapMode;
|
|
|
938
907
|
var _values_byteOffset, _valuesBufferView_byteOffset;
|
|
939
908
|
var valuesByteOffset = ((_values_byteOffset = values.byteOffset) != null ? _values_byteOffset : 0) + ((_valuesBufferView_byteOffset = valuesBufferView.byteOffset) != null ? _valuesBufferView_byteOffset : 0);
|
|
940
909
|
var valuesByteLength = valuesBufferView.byteLength;
|
|
941
|
-
var indicesType =
|
|
910
|
+
var indicesType = GLTFUtils.getComponentType(indices.componentType);
|
|
942
911
|
var indicesArray = new indicesType(indicesArrayBuffer, indicesByteOffset, indicesByteLength / indicesType.BYTES_PER_ELEMENT);
|
|
943
912
|
var valuesArray = new arrayType(valuesArrayBuffer, valuesByteOffset, valuesByteLength / arrayType.BYTES_PER_ELEMENT);
|
|
944
913
|
for(var i1 = 0; i1 < count; i1++){
|
|
@@ -950,17 +919,17 @@ var TextureWrapMode;
|
|
|
950
919
|
}
|
|
951
920
|
return typedArray;
|
|
952
921
|
};
|
|
953
|
-
|
|
922
|
+
GLTFUtils.getBufferViewData = function getBufferViewData(bufferView, buffers) {
|
|
954
923
|
var _bufferView_byteOffset = bufferView.byteOffset, byteOffset = _bufferView_byteOffset === void 0 ? 0 : _bufferView_byteOffset;
|
|
955
924
|
var arrayBuffer = buffers[bufferView.buffer];
|
|
956
925
|
return arrayBuffer.slice(byteOffset, byteOffset + bufferView.byteLength);
|
|
957
926
|
};
|
|
958
927
|
/**
|
|
959
928
|
* Get accessor data.
|
|
960
|
-
*/
|
|
929
|
+
*/ GLTFUtils.processingSparseData = function processingSparseData(bufferViews, accessor, buffers, bufferInfo) {
|
|
961
930
|
var restoreInfo = bufferInfo.restoreInfo;
|
|
962
|
-
var accessorTypeSize =
|
|
963
|
-
var TypedArray =
|
|
931
|
+
var accessorTypeSize = GLTFUtils.getAccessorTypeSize(accessor.type);
|
|
932
|
+
var TypedArray = GLTFUtils.getComponentType(accessor.componentType);
|
|
964
933
|
var data = bufferInfo.data.slice();
|
|
965
934
|
var _accessor_sparse = accessor.sparse, count = _accessor_sparse.count, indices = _accessor_sparse.indices, values = _accessor_sparse.values;
|
|
966
935
|
var indicesBufferView = bufferViews[indices.bufferView];
|
|
@@ -977,7 +946,7 @@ var TextureWrapMode;
|
|
|
977
946
|
var valuesByteLength = valuesBufferView.byteLength;
|
|
978
947
|
restoreInfo.typeSize = accessorTypeSize;
|
|
979
948
|
restoreInfo.sparseCount = count;
|
|
980
|
-
var IndexTypeArray =
|
|
949
|
+
var IndexTypeArray = GLTFUtils.getComponentType(indices.componentType);
|
|
981
950
|
var indexLength = indicesByteLength / IndexTypeArray.BYTES_PER_ELEMENT;
|
|
982
951
|
var indicesArray = new IndexTypeArray(indicesArrayBuffer, indicesByteOffset, indexLength);
|
|
983
952
|
restoreInfo.sparseIndices = new RestoreDataAccessor(indicesBufferIndex, IndexTypeArray, indicesByteOffset, indexLength);
|
|
@@ -992,7 +961,7 @@ var TextureWrapMode;
|
|
|
992
961
|
}
|
|
993
962
|
bufferInfo.data = data;
|
|
994
963
|
};
|
|
995
|
-
|
|
964
|
+
GLTFUtils.getIndexFormat = function getIndexFormat(type) {
|
|
996
965
|
switch(type){
|
|
997
966
|
case AccessorComponentType.UNSIGNED_BYTE:
|
|
998
967
|
return engineCore.IndexFormat.UInt8;
|
|
@@ -1002,7 +971,7 @@ var TextureWrapMode;
|
|
|
1002
971
|
return engineCore.IndexFormat.UInt32;
|
|
1003
972
|
}
|
|
1004
973
|
};
|
|
1005
|
-
|
|
974
|
+
GLTFUtils.getElementFormat = function getElementFormat(type, size, normalized) {
|
|
1006
975
|
if (normalized === void 0) normalized = false;
|
|
1007
976
|
if (type == AccessorComponentType.FLOAT) {
|
|
1008
977
|
switch(size){
|
|
@@ -1053,7 +1022,7 @@ var TextureWrapMode;
|
|
|
1053
1022
|
};
|
|
1054
1023
|
/**
|
|
1055
1024
|
* Load image buffer
|
|
1056
|
-
*/
|
|
1025
|
+
*/ GLTFUtils.loadImageBuffer = function loadImageBuffer(imageBuffer, type) {
|
|
1057
1026
|
return new Promise(function(resolve, reject) {
|
|
1058
1027
|
var blob = new window.Blob([
|
|
1059
1028
|
imageBuffer
|
|
@@ -1077,18 +1046,9 @@ var TextureWrapMode;
|
|
|
1077
1046
|
img.src = URL.createObjectURL(blob);
|
|
1078
1047
|
});
|
|
1079
1048
|
};
|
|
1080
|
-
GLTFUtil.isAbsoluteUrl = function isAbsoluteUrl(url) {
|
|
1081
|
-
return /^(?:http|blob|data:|\/)/.test(url);
|
|
1082
|
-
};
|
|
1083
|
-
GLTFUtil.parseRelativeUrl = function parseRelativeUrl(baseUrl, relativeUrl) {
|
|
1084
|
-
if (GLTFUtil.isAbsoluteUrl(relativeUrl)) {
|
|
1085
|
-
return relativeUrl;
|
|
1086
|
-
}
|
|
1087
|
-
return baseUrl.substring(0, baseUrl.lastIndexOf("/") + 1) + GLTFUtil._formatRelativePath(relativeUrl);
|
|
1088
|
-
};
|
|
1089
1049
|
/**
|
|
1090
1050
|
* Parse the glb format.
|
|
1091
|
-
*/
|
|
1051
|
+
*/ GLTFUtils.parseGLB = function parseGLB(context, glb) {
|
|
1092
1052
|
var UINT32_LENGTH = 4;
|
|
1093
1053
|
var GLB_HEADER_MAGIC = 0x46546c67; // 'glTF'
|
|
1094
1054
|
var GLB_HEADER_LENGTH = 12;
|
|
@@ -1116,7 +1076,7 @@ var TextureWrapMode;
|
|
|
1116
1076
|
return null;
|
|
1117
1077
|
}
|
|
1118
1078
|
var glTFData = new Uint8Array(glb, GLB_HEADER_LENGTH + 2 * UINT32_LENGTH, chunkLength);
|
|
1119
|
-
var glTF = JSON.parse(
|
|
1079
|
+
var glTF = JSON.parse(engineCore.Utils.decodeText(glTFData));
|
|
1120
1080
|
// read all buffers
|
|
1121
1081
|
var buffers = [];
|
|
1122
1082
|
var byteOffset = GLB_HEADER_LENGTH + 2 * UINT32_LENGTH + chunkLength;
|
|
@@ -1139,7 +1099,7 @@ var TextureWrapMode;
|
|
|
1139
1099
|
buffers: buffers
|
|
1140
1100
|
};
|
|
1141
1101
|
};
|
|
1142
|
-
|
|
1102
|
+
GLTFUtils._formatRelativePath = function _formatRelativePath(path) {
|
|
1143
1103
|
// For example input is "a/b", "/a/b", "./a/b", "./a/./b", "./a/../a/b", output is "a/b"
|
|
1144
1104
|
return path.split("/").filter(Boolean).reduce(function(acc, cur) {
|
|
1145
1105
|
if (cur === "..") acc.pop();
|
|
@@ -1147,23 +1107,25 @@ var TextureWrapMode;
|
|
|
1147
1107
|
return acc;
|
|
1148
1108
|
}, []).join("/");
|
|
1149
1109
|
};
|
|
1150
|
-
return
|
|
1110
|
+
return GLTFUtils;
|
|
1151
1111
|
}();
|
|
1152
1112
|
|
|
1153
|
-
function
|
|
1154
|
-
|
|
1113
|
+
function _array_without_holes(arr) {
|
|
1114
|
+
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
1155
1115
|
}
|
|
1156
1116
|
|
|
1157
|
-
function
|
|
1158
|
-
|
|
1117
|
+
function _iterable_to_array(iter) {
|
|
1118
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) {
|
|
1119
|
+
return Array.from(iter);
|
|
1120
|
+
}
|
|
1159
1121
|
}
|
|
1160
1122
|
|
|
1161
|
-
function
|
|
1162
|
-
|
|
1123
|
+
function _non_iterable_spread() {
|
|
1124
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
1163
1125
|
}
|
|
1164
1126
|
|
|
1165
|
-
function
|
|
1166
|
-
|
|
1127
|
+
function _to_consumable_array(arr) {
|
|
1128
|
+
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
1167
1129
|
}
|
|
1168
1130
|
|
|
1169
1131
|
/**
|
|
@@ -1253,7 +1215,7 @@ exports.GLTFExtensionMode = void 0;
|
|
|
1253
1215
|
context,
|
|
1254
1216
|
extensionSchema,
|
|
1255
1217
|
ownerSchema
|
|
1256
|
-
].concat(
|
|
1218
|
+
].concat(_to_consumable_array(extra)));
|
|
1257
1219
|
if (resource) {
|
|
1258
1220
|
return resource;
|
|
1259
1221
|
}
|
|
@@ -1279,7 +1241,7 @@ exports.GLTFExtensionMode = void 0;
|
|
|
1279
1241
|
parseResource,
|
|
1280
1242
|
extensionSchema,
|
|
1281
1243
|
ownerSchema
|
|
1282
|
-
].concat(
|
|
1244
|
+
].concat(_to_consumable_array(extra)));
|
|
1283
1245
|
}
|
|
1284
1246
|
};
|
|
1285
1247
|
/**
|
|
@@ -1327,7 +1289,7 @@ exports.GLTFExtensionMode = void 0;
|
|
|
1327
1289
|
context,
|
|
1328
1290
|
extensionSchema,
|
|
1329
1291
|
ownerSchema
|
|
1330
|
-
].concat(
|
|
1292
|
+
].concat(_to_consumable_array(extra)));
|
|
1331
1293
|
}
|
|
1332
1294
|
};
|
|
1333
1295
|
GLTFParser._additiveParse = function _additiveParse(extensionName, context, parseResource, extensionSchema, ownerSchema) {
|
|
@@ -1342,12 +1304,14 @@ exports.GLTFExtensionMode = void 0;
|
|
|
1342
1304
|
parseResource,
|
|
1343
1305
|
extensionSchema,
|
|
1344
1306
|
ownerSchema
|
|
1345
|
-
].concat(
|
|
1307
|
+
].concat(_to_consumable_array(extra)));
|
|
1346
1308
|
}
|
|
1347
1309
|
};
|
|
1348
1310
|
return GLTFParser;
|
|
1349
1311
|
}();
|
|
1350
|
-
|
|
1312
|
+
(function() {
|
|
1313
|
+
GLTFParser._extensionParsers = {};
|
|
1314
|
+
})();
|
|
1351
1315
|
/**
|
|
1352
1316
|
* Declare ExtensionParser's decorator.
|
|
1353
1317
|
* @param extensionName - Extension name
|
|
@@ -1409,10 +1373,10 @@ var GLTFAnimationParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
1409
1373
|
var gltfSampler = samplers[j];
|
|
1410
1374
|
var inputAccessor = accessors[gltfSampler.input];
|
|
1411
1375
|
var outputAccessor = accessors[gltfSampler.output];
|
|
1412
|
-
var input =
|
|
1413
|
-
var output =
|
|
1376
|
+
var input = GLTFUtils.getAccessorBuffer(context, bufferViews, inputAccessor).data;
|
|
1377
|
+
var output = GLTFUtils.getAccessorBuffer(context, bufferViews, outputAccessor).data;
|
|
1414
1378
|
if (outputAccessor.normalized) {
|
|
1415
|
-
var scale =
|
|
1379
|
+
var scale = GLTFUtils.getNormalizedComponentScale(outputAccessor.componentType);
|
|
1416
1380
|
var scaled = new Float32Array(output.length);
|
|
1417
1381
|
for(var k = 0, v = output.length; k < v; k++){
|
|
1418
1382
|
scaled[k] = output[k] * scale;
|
|
@@ -1566,7 +1530,7 @@ var GLTFBufferParser = /*#__PURE__*/ function(GLTFParser) {
|
|
|
1566
1530
|
if (isGLB) {
|
|
1567
1531
|
return engineCore.request(url, requestConfig).then(function(glb) {
|
|
1568
1532
|
restoreBufferRequests.push(new BufferRequestInfo(url, requestConfig));
|
|
1569
|
-
return
|
|
1533
|
+
return GLTFUtils.parseGLB(context, glb);
|
|
1570
1534
|
}).then(function(param) {
|
|
1571
1535
|
var glTF = param.glTF, buffers = param.buffers;
|
|
1572
1536
|
context.glTF = glTF;
|
|
@@ -1578,7 +1542,7 @@ var GLTFBufferParser = /*#__PURE__*/ function(GLTFParser) {
|
|
|
1578
1542
|
}).then(function(glTF) {
|
|
1579
1543
|
context.glTF = glTF;
|
|
1580
1544
|
return Promise.all(glTF.buffers.map(function(buffer) {
|
|
1581
|
-
var absoluteUrl =
|
|
1545
|
+
var absoluteUrl = engineCore.Utils.resolveAbsoluteUrl(url, buffer.uri);
|
|
1582
1546
|
restoreBufferRequests.push(new BufferRequestInfo(absoluteUrl, requestConfig));
|
|
1583
1547
|
return engineCore.request(absoluteUrl, requestConfig);
|
|
1584
1548
|
})).then(function(buffers) {
|
|
@@ -1668,7 +1632,9 @@ var GLTFEntityParser = /*#__PURE__*/ function(GLTFParser) {
|
|
|
1668
1632
|
};
|
|
1669
1633
|
return GLTFEntityParser;
|
|
1670
1634
|
}(GLTFParser);
|
|
1671
|
-
|
|
1635
|
+
(function() {
|
|
1636
|
+
/** @internal */ GLTFEntityParser._defaultName = "_GLTF_ENTITY_";
|
|
1637
|
+
})();
|
|
1672
1638
|
|
|
1673
1639
|
var GLTFMaterialParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
1674
1640
|
_inherits(GLTFMaterialParser, GLTFParser1);
|
|
@@ -1783,11 +1749,9 @@ var GLTFMaterialParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
1783
1749
|
}(GLTFParser);
|
|
1784
1750
|
|
|
1785
1751
|
function _instanceof(left, right) {
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
return left instanceof right;
|
|
1790
|
-
}
|
|
1752
|
+
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
1753
|
+
return !!right[Symbol.hasInstance](left);
|
|
1754
|
+
} else return left instanceof right;
|
|
1791
1755
|
}
|
|
1792
1756
|
|
|
1793
1757
|
var GLTFMeshParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
@@ -1822,13 +1786,13 @@ var GLTFMeshParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
1822
1786
|
var attributeAccessorIdx = shapeAccessorIdx[attributeName];
|
|
1823
1787
|
if (attributeAccessorIdx) {
|
|
1824
1788
|
var accessor = glTF.accessors[attributeAccessorIdx];
|
|
1825
|
-
return
|
|
1789
|
+
return GLTFUtils.getAccessorBuffer(context, context.glTF.bufferViews, accessor);
|
|
1826
1790
|
} else {
|
|
1827
1791
|
return null;
|
|
1828
1792
|
}
|
|
1829
1793
|
}, function() {
|
|
1830
1794
|
var indexAccessor = glTF.accessors[gltfPrimitive.indices];
|
|
1831
|
-
return
|
|
1795
|
+
return GLTFUtils.getAccessorData(glTF, indexAccessor, buffers);
|
|
1832
1796
|
}, context.keepMeshData).then(resolve);
|
|
1833
1797
|
}
|
|
1834
1798
|
});
|
|
@@ -1860,16 +1824,18 @@ var GLTFMeshParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
1860
1824
|
var vertexElements = new Array();
|
|
1861
1825
|
var vertexCount;
|
|
1862
1826
|
var bufferBindIndex = 0;
|
|
1827
|
+
var positions;
|
|
1828
|
+
keepMeshData && (positions = new Array(vertexCount));
|
|
1863
1829
|
for(var attribute in attributes){
|
|
1864
1830
|
var accessor = accessors[attributes[attribute]];
|
|
1865
|
-
var accessorBuffer =
|
|
1866
|
-
var dataElementSize =
|
|
1831
|
+
var accessorBuffer = GLTFUtils.getAccessorBuffer(context, gltf.bufferViews, accessor);
|
|
1832
|
+
var dataElementSize = GLTFUtils.getAccessorTypeSize(accessor.type);
|
|
1867
1833
|
var attributeCount = accessor.count;
|
|
1868
1834
|
var vertices = accessorBuffer.data;
|
|
1869
1835
|
var vertexElement = void 0;
|
|
1870
1836
|
var meshId = mesh.instanceId;
|
|
1871
1837
|
var vertexBindingInfos = accessorBuffer.vertexBindingInfos;
|
|
1872
|
-
var elementFormat =
|
|
1838
|
+
var elementFormat = GLTFUtils.getElementFormat(accessor.componentType, dataElementSize, accessor.normalized);
|
|
1873
1839
|
if (accessorBuffer.interleaved) {
|
|
1874
1840
|
var byteOffset = accessor.byteOffset || 0;
|
|
1875
1841
|
var stride = accessorBuffer.stride;
|
|
@@ -1903,20 +1869,27 @@ var GLTFMeshParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
1903
1869
|
if (accessor.min && accessor.max) {
|
|
1904
1870
|
min.copyFromArray(accessor.min);
|
|
1905
1871
|
max.copyFromArray(accessor.max);
|
|
1872
|
+
if (keepMeshData) {
|
|
1873
|
+
var stride1 = vertices.length / attributeCount;
|
|
1874
|
+
for(var j = 0; j < attributeCount; j++){
|
|
1875
|
+
var offset = j * stride1;
|
|
1876
|
+
positions[j] = new engineMath.Vector3(vertices[offset], vertices[offset + 1], vertices[offset + 2]);
|
|
1877
|
+
}
|
|
1878
|
+
}
|
|
1906
1879
|
} else {
|
|
1907
1880
|
var position = GLTFMeshParser._tempVector3;
|
|
1908
1881
|
min.set(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
|
|
1909
1882
|
max.set(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
|
|
1910
|
-
var
|
|
1911
|
-
for(var
|
|
1912
|
-
var
|
|
1913
|
-
position.copyFromArray(vertices,
|
|
1883
|
+
var stride2 = vertices.length / attributeCount;
|
|
1884
|
+
for(var j1 = 0; j1 < attributeCount; j1++){
|
|
1885
|
+
var offset1 = j1 * stride2;
|
|
1886
|
+
position.copyFromArray(vertices, offset1);
|
|
1914
1887
|
engineMath.Vector3.min(min, position, min);
|
|
1915
1888
|
engineMath.Vector3.max(max, position, max);
|
|
1916
1889
|
}
|
|
1917
1890
|
}
|
|
1918
1891
|
if (accessor.normalized) {
|
|
1919
|
-
var scaleFactor =
|
|
1892
|
+
var scaleFactor = GLTFUtils.getNormalizedComponentScale(accessor.componentType);
|
|
1920
1893
|
min.scale(scaleFactor);
|
|
1921
1894
|
max.scale(scaleFactor);
|
|
1922
1895
|
}
|
|
@@ -1926,7 +1899,7 @@ var GLTFMeshParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
1926
1899
|
// Indices
|
|
1927
1900
|
if (indices !== undefined) {
|
|
1928
1901
|
var indexAccessor = gltf.accessors[indices];
|
|
1929
|
-
var accessorBuffer1 =
|
|
1902
|
+
var accessorBuffer1 = GLTFUtils.getAccessorBuffer(context, gltf.bufferViews, indexAccessor);
|
|
1930
1903
|
mesh.setIndices(accessorBuffer1.data);
|
|
1931
1904
|
mesh.addSubMesh(0, indexAccessor.count, mode);
|
|
1932
1905
|
meshRestoreInfo.indexBuffer = accessorBuffer1.restoreInfo;
|
|
@@ -1936,6 +1909,8 @@ var GLTFMeshParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
1936
1909
|
// BlendShapes
|
|
1937
1910
|
targets && GLTFMeshParser._createBlendShape(mesh, meshRestoreInfo, gltfMesh, targets, getBlendShapeData);
|
|
1938
1911
|
mesh.uploadData(!keepMeshData);
|
|
1912
|
+
//@ts-ignore
|
|
1913
|
+
mesh._positions = positions;
|
|
1939
1914
|
return Promise.resolve(mesh);
|
|
1940
1915
|
};
|
|
1941
1916
|
/**
|
|
@@ -1947,9 +1922,9 @@ var GLTFMeshParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
1947
1922
|
var deltaPosBufferInfo = getBlendShapeData("POSITION", i);
|
|
1948
1923
|
var deltaNorBufferInfo = getBlendShapeData("NORMAL", i);
|
|
1949
1924
|
var deltaTanBufferInfo = getBlendShapeData("TANGENT", i);
|
|
1950
|
-
var deltaPositions = deltaPosBufferInfo.data ?
|
|
1951
|
-
var deltaNormals = (deltaNorBufferInfo == null ? void 0 : deltaNorBufferInfo.data) ?
|
|
1952
|
-
var deltaTangents = (deltaTanBufferInfo == null ? void 0 : deltaTanBufferInfo.data) ?
|
|
1925
|
+
var deltaPositions = deltaPosBufferInfo.data ? GLTFUtils.floatBufferToVector3Array(deltaPosBufferInfo.data) : null;
|
|
1926
|
+
var deltaNormals = (deltaNorBufferInfo == null ? void 0 : deltaNorBufferInfo.data) ? GLTFUtils.floatBufferToVector3Array(deltaNorBufferInfo == null ? void 0 : deltaNorBufferInfo.data) : null;
|
|
1927
|
+
var deltaTangents = (deltaTanBufferInfo == null ? void 0 : deltaTanBufferInfo.data) ? GLTFUtils.floatBufferToVector3Array(deltaTanBufferInfo == null ? void 0 : deltaTanBufferInfo.data) : null;
|
|
1953
1928
|
var blendShape = new engineCore.BlendShape(name);
|
|
1954
1929
|
blendShape.addFrame(1.0, deltaPositions, deltaNormals, deltaTangents);
|
|
1955
1930
|
mesh.addBlendShape(blendShape);
|
|
@@ -1958,7 +1933,9 @@ var GLTFMeshParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
1958
1933
|
};
|
|
1959
1934
|
return GLTFMeshParser;
|
|
1960
1935
|
}(GLTFParser);
|
|
1961
|
-
|
|
1936
|
+
(function() {
|
|
1937
|
+
GLTFMeshParser._tempVector3 = new engineMath.Vector3();
|
|
1938
|
+
})();
|
|
1962
1939
|
|
|
1963
1940
|
var GLTFSceneParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
1964
1941
|
_inherits(GLTFSceneParser, GLTFParser1);
|
|
@@ -2110,7 +2087,7 @@ var GLTFSkinParser = /*#__PURE__*/ function(GLTFParser) {
|
|
|
2110
2087
|
skin.inverseBindMatrices.length = jointCount;
|
|
2111
2088
|
// parse IBM
|
|
2112
2089
|
var accessor = glTF.accessors[inverseBindMatrices];
|
|
2113
|
-
var buffer =
|
|
2090
|
+
var buffer = GLTFUtils.getAccessorBuffer(context, glTF.bufferViews, accessor).data;
|
|
2114
2091
|
for(var i1 = 0; i1 < jointCount; i1++){
|
|
2115
2092
|
var inverseBindMatrix = new engineMath.Matrix();
|
|
2116
2093
|
inverseBindMatrix.copyFromArray(buffer, i1 * 16);
|
|
@@ -2145,7 +2122,7 @@ var GLTFSkinParser = /*#__PURE__*/ function(GLTFParser) {
|
|
|
2145
2122
|
};
|
|
2146
2123
|
_proto._findSkeletonRootBone = function _findSkeletonRootBone(joints, entities) {
|
|
2147
2124
|
var paths = {};
|
|
2148
|
-
for(var _iterator =
|
|
2125
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(joints), _step; !(_step = _iterator()).done;){
|
|
2149
2126
|
var index = _step.value;
|
|
2150
2127
|
var path = new Array();
|
|
2151
2128
|
var entity = entities[index];
|
|
@@ -2195,7 +2172,7 @@ var GLTFTextureParser = /*#__PURE__*/ function(GLTFParser) {
|
|
|
2195
2172
|
var ext = uri.substring(index1 + 1);
|
|
2196
2173
|
var type = ext.startsWith("ktx") ? engineCore.AssetType.KTX : engineCore.AssetType.Texture2D;
|
|
2197
2174
|
return engine.resourceManager.load({
|
|
2198
|
-
url:
|
|
2175
|
+
url: engineCore.Utils.resolveAbsoluteUrl(url, uri),
|
|
2199
2176
|
type: type
|
|
2200
2177
|
}).then(function(texture) {
|
|
2201
2178
|
if (!texture.name) {
|
|
@@ -2210,7 +2187,7 @@ var GLTFTextureParser = /*#__PURE__*/ function(GLTFParser) {
|
|
|
2210
2187
|
var bufferView = glTF.bufferViews[bufferViewIndex];
|
|
2211
2188
|
var buffer = buffers[bufferView.buffer];
|
|
2212
2189
|
var imageBuffer = new Uint8Array(buffer, bufferView.byteOffset, bufferView.byteLength);
|
|
2213
|
-
return
|
|
2190
|
+
return GLTFUtils.loadImageBuffer(imageBuffer, mimeType).then(function(image) {
|
|
2214
2191
|
var texture = new engineCore.Texture2D(engine, image.width, image.height);
|
|
2215
2192
|
texture.setImageSource(image);
|
|
2216
2193
|
texture.generateMipmaps();
|
|
@@ -2250,8 +2227,10 @@ var GLTFTextureParser = /*#__PURE__*/ function(GLTFParser) {
|
|
|
2250
2227
|
};
|
|
2251
2228
|
return GLTFTextureParser;
|
|
2252
2229
|
}(GLTFParser);
|
|
2253
|
-
|
|
2254
|
-
|
|
2230
|
+
(function() {
|
|
2231
|
+
var _obj;
|
|
2232
|
+
GLTFTextureParser._wrapMap = (_obj = {}, _obj[TextureWrapMode.CLAMP_TO_EDGE] = engineCore.TextureWrapMode.Clamp, _obj[TextureWrapMode.MIRRORED_REPEAT] = engineCore.TextureWrapMode.Mirror, _obj[TextureWrapMode.REPEAT] = engineCore.TextureWrapMode.Repeat, _obj);
|
|
2233
|
+
})();
|
|
2255
2234
|
|
|
2256
2235
|
var GLTFValidator = /*#__PURE__*/ function(GLTFParser1) {
|
|
2257
2236
|
_inherits(GLTFValidator, GLTFParser1);
|
|
@@ -2333,9 +2312,11 @@ var GLTFValidator = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
2333
2312
|
};
|
|
2334
2313
|
return GLTFPipeline;
|
|
2335
2314
|
}();
|
|
2336
|
-
|
|
2315
|
+
(function() {
|
|
2316
|
+
/**
|
|
2337
2317
|
* Default pipeline.
|
|
2338
2318
|
*/ GLTFPipeline.defaultPipeline = new GLTFPipeline(GLTFBufferParser, GLTFValidator, GLTFTextureParser, GLTFMaterialParser, GLTFMeshParser, GLTFEntityParser, GLTFSkinParser, GLTFAnimationParser, GLTFSceneParser);
|
|
2319
|
+
})();
|
|
2339
2320
|
|
|
2340
2321
|
/**
|
|
2341
2322
|
* Product after glTF parser, usually, `defaultSceneRoot` is only needed to use.
|
|
@@ -2388,7 +2369,7 @@ var GLTFLoader = /*#__PURE__*/ function(Loader) {
|
|
|
2388
2369
|
context.keepMeshData = (_params_keepMeshData = params == null ? void 0 : params.keepMeshData) != null ? _params_keepMeshData : false;
|
|
2389
2370
|
masterPromiseInfo.onCancel(function() {
|
|
2390
2371
|
var chainPromises = context.chainPromises;
|
|
2391
|
-
for(var _iterator =
|
|
2372
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(chainPromises), _step; !(_step = _iterator()).done;){
|
|
2392
2373
|
var promise = _step.value;
|
|
2393
2374
|
promise.cancel();
|
|
2394
2375
|
}
|
|
@@ -2491,7 +2472,7 @@ var HDRLoader = (_HDRLoader = /*#__PURE__*/ function(Loader) {
|
|
|
2491
2472
|
return textureArray;
|
|
2492
2473
|
};
|
|
2493
2474
|
HDRLoader1._calcProjectionSpherical = function _calcProjectionSpherical(vDir, pixels, inputWidth, inputHeight) {
|
|
2494
|
-
var theta = Math.atan2(vDir.z,
|
|
2475
|
+
var theta = Math.atan2(vDir.z, vDir.x);
|
|
2495
2476
|
var phi = Math.acos(vDir.y);
|
|
2496
2477
|
while(theta < -PI){
|
|
2497
2478
|
theta += 2 * PI;
|
|
@@ -2652,37 +2633,75 @@ var HDRLoader = (_HDRLoader = /*#__PURE__*/ function(Loader) {
|
|
|
2652
2633
|
color.a *= M;
|
|
2653
2634
|
};
|
|
2654
2635
|
return HDRLoader1;
|
|
2655
|
-
}(engineCore.Loader),
|
|
2656
|
-
_HDRLoader._rightBottomBack,
|
|
2657
|
-
|
|
2658
|
-
_HDRLoader.
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
_HDRLoader.
|
|
2663
|
-
|
|
2664
|
-
_HDRLoader.
|
|
2665
|
-
|
|
2666
|
-
_HDRLoader._leftBottomFront,
|
|
2667
|
-
|
|
2668
|
-
_HDRLoader.
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
_HDRLoader.
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
_HDRLoader.
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2636
|
+
}(engineCore.Loader), function() {
|
|
2637
|
+
_HDRLoader._rightBottomBack = new engineMath.Vector3(1.0, -1.0, -1.0);
|
|
2638
|
+
}(), function() {
|
|
2639
|
+
_HDRLoader._rightBottomFront = new engineMath.Vector3(1.0, -1.0, 1.0);
|
|
2640
|
+
}(), function() {
|
|
2641
|
+
_HDRLoader._rightUpBack = new engineMath.Vector3(1.0, 1.0, -1.0);
|
|
2642
|
+
}(), function() {
|
|
2643
|
+
_HDRLoader._rightUpFront = new engineMath.Vector3(1.0, 1.0, 1.0);
|
|
2644
|
+
}(), function() {
|
|
2645
|
+
_HDRLoader._leftBottomBack = new engineMath.Vector3(-1.0, -1.0, -1.0);
|
|
2646
|
+
}(), function() {
|
|
2647
|
+
_HDRLoader._leftBottomFront = new engineMath.Vector3(-1.0, -1.0, 1.0);
|
|
2648
|
+
}(), function() {
|
|
2649
|
+
_HDRLoader._leftUpBack = new engineMath.Vector3(-1.0, 1.0, -1.0);
|
|
2650
|
+
}(), function() {
|
|
2651
|
+
_HDRLoader._leftUpFront = new engineMath.Vector3(-1.0, 1.0, 1.0);
|
|
2652
|
+
}(), function() {
|
|
2653
|
+
_HDRLoader._faceRight = [
|
|
2654
|
+
_HDRLoader._rightBottomBack,
|
|
2655
|
+
_HDRLoader._rightBottomFront,
|
|
2656
|
+
_HDRLoader._rightUpBack,
|
|
2657
|
+
_HDRLoader._rightUpFront
|
|
2658
|
+
];
|
|
2659
|
+
}(), function() {
|
|
2660
|
+
_HDRLoader._faceLeft = [
|
|
2661
|
+
_HDRLoader._leftBottomFront,
|
|
2662
|
+
_HDRLoader._leftBottomBack,
|
|
2663
|
+
_HDRLoader._leftUpFront,
|
|
2664
|
+
_HDRLoader._leftUpBack
|
|
2665
|
+
];
|
|
2666
|
+
}(), function() {
|
|
2667
|
+
_HDRLoader._faceUp = [
|
|
2668
|
+
_HDRLoader._leftBottomFront,
|
|
2669
|
+
_HDRLoader._rightBottomFront,
|
|
2670
|
+
_HDRLoader._leftBottomBack,
|
|
2671
|
+
_HDRLoader._rightBottomBack
|
|
2672
|
+
];
|
|
2673
|
+
}(), function() {
|
|
2674
|
+
_HDRLoader._faceBottom = [
|
|
2675
|
+
_HDRLoader._leftUpBack,
|
|
2676
|
+
_HDRLoader._rightUpBack,
|
|
2677
|
+
_HDRLoader._leftUpFront,
|
|
2678
|
+
_HDRLoader._rightUpFront
|
|
2679
|
+
];
|
|
2680
|
+
}(), function() {
|
|
2681
|
+
_HDRLoader._faceFront = [
|
|
2682
|
+
_HDRLoader._leftBottomBack,
|
|
2683
|
+
_HDRLoader._rightBottomBack,
|
|
2684
|
+
_HDRLoader._leftUpBack,
|
|
2685
|
+
_HDRLoader._rightUpBack
|
|
2686
|
+
];
|
|
2687
|
+
}(), function() {
|
|
2688
|
+
_HDRLoader._faceBack = [
|
|
2689
|
+
_HDRLoader._rightBottomFront,
|
|
2690
|
+
_HDRLoader._leftBottomFront,
|
|
2691
|
+
_HDRLoader._rightUpFront,
|
|
2692
|
+
_HDRLoader._leftUpFront
|
|
2693
|
+
];
|
|
2694
|
+
}(), function() {
|
|
2695
|
+
_HDRLoader._tempVector3 = new engineMath.Vector3();
|
|
2696
|
+
}(), function() {
|
|
2697
|
+
_HDRLoader._temp2Vector3 = new engineMath.Vector3();
|
|
2698
|
+
}(), function() {
|
|
2699
|
+
_HDRLoader._temp3Vector3 = new engineMath.Vector3();
|
|
2700
|
+
}(), function() {
|
|
2701
|
+
_HDRLoader._temp4Vector3 = new engineMath.Vector3();
|
|
2702
|
+
}(), function() {
|
|
2703
|
+
_HDRLoader._temp5Vector3 = new engineMath.Vector3();
|
|
2704
|
+
}(), _HDRLoader);
|
|
2686
2705
|
HDRLoader = __decorate([
|
|
2687
2706
|
engineCore.resourceLoader(engineCore.AssetType.HDR, [
|
|
2688
2707
|
"hdr"
|
|
@@ -3052,19 +3071,21 @@ MaterialLoader = __decorate([
|
|
|
3052
3071
|
], MaterialLoader);
|
|
3053
3072
|
|
|
3054
3073
|
function _defineProperties(target, props) {
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
|
|
3074
|
+
for (var i = 0; i < props.length; i++) {
|
|
3075
|
+
var descriptor = props[i];
|
|
3076
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
3077
|
+
descriptor.configurable = true;
|
|
3078
|
+
|
|
3079
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
3080
|
+
|
|
3081
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
3082
|
+
}
|
|
3062
3083
|
}
|
|
3084
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
3085
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
3086
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
3063
3087
|
|
|
3064
|
-
|
|
3065
|
-
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
3066
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
3067
|
-
return Constructor;
|
|
3088
|
+
return Constructor;
|
|
3068
3089
|
}
|
|
3069
3090
|
|
|
3070
3091
|
var BufferReader = /*#__PURE__*/ function() {
|
|
@@ -3134,7 +3155,7 @@ var BufferReader = /*#__PURE__*/ function() {
|
|
|
3134
3155
|
var strByteLength = this.nextUint16();
|
|
3135
3156
|
var uint8Array = new Uint8Array(this.buffer, this._offset, strByteLength);
|
|
3136
3157
|
this._offset += strByteLength;
|
|
3137
|
-
return
|
|
3158
|
+
return engineCore.Utils.decodeText(uint8Array);
|
|
3138
3159
|
};
|
|
3139
3160
|
/**
|
|
3140
3161
|
* image data 放在最后
|
|
@@ -3173,7 +3194,7 @@ var BufferReader = /*#__PURE__*/ function() {
|
|
|
3173
3194
|
if (byteLength < maxByteLength) this._offset++;
|
|
3174
3195
|
return new Uint8Array(this._dataView.buffer, this._dataView.byteOffset + byteOffset, byteLength);
|
|
3175
3196
|
};
|
|
3176
|
-
|
|
3197
|
+
_create_class(BufferReader, [
|
|
3177
3198
|
{
|
|
3178
3199
|
key: "offset",
|
|
3179
3200
|
get: function get() {
|
|
@@ -3183,12 +3204,14 @@ var BufferReader = /*#__PURE__*/ function() {
|
|
|
3183
3204
|
]);
|
|
3184
3205
|
return BufferReader;
|
|
3185
3206
|
}();
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3207
|
+
(function() {
|
|
3208
|
+
BufferReader.imageMapping = {
|
|
3209
|
+
0: "image/png",
|
|
3210
|
+
1: "image/jpg",
|
|
3211
|
+
2: "image/webp",
|
|
3212
|
+
3: "ktx"
|
|
3213
|
+
};
|
|
3214
|
+
})();
|
|
3192
3215
|
|
|
3193
3216
|
var decoderMap = {};
|
|
3194
3217
|
/**
|
|
@@ -3217,8 +3240,8 @@ var FileHeader = /*#__PURE__*/ function() {
|
|
|
3217
3240
|
var typeUint8Array = new Uint8Array(arrayBuffer, 7, typeLen);
|
|
3218
3241
|
var nameLen = dataView.getUint16(7 + typeLen, true);
|
|
3219
3242
|
var nameUint8Array = new Uint8Array(arrayBuffer, 9 + typeLen, nameLen);
|
|
3220
|
-
var name =
|
|
3221
|
-
var type =
|
|
3243
|
+
var name = engineCore.Utils.decodeText(nameUint8Array);
|
|
3244
|
+
var type = engineCore.Utils.decodeText(typeUint8Array);
|
|
3222
3245
|
var header = new FileHeader();
|
|
3223
3246
|
header.totalLength = totalLen;
|
|
3224
3247
|
header.name = name;
|
|
@@ -3227,7 +3250,7 @@ var FileHeader = /*#__PURE__*/ function() {
|
|
|
3227
3250
|
header.headerLength = nameUint8Array.byteLength + typeUint8Array.byteLength + 9;
|
|
3228
3251
|
return header;
|
|
3229
3252
|
};
|
|
3230
|
-
|
|
3253
|
+
_create_class(FileHeader, [
|
|
3231
3254
|
{
|
|
3232
3255
|
key: "dataLength",
|
|
3233
3256
|
get: function get() {
|
|
@@ -3446,38 +3469,36 @@ exports.Texture2DDecoder = __decorate([
|
|
|
3446
3469
|
decoder("Texture2D")
|
|
3447
3470
|
], exports.Texture2DDecoder);
|
|
3448
3471
|
|
|
3449
|
-
function
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
|
|
3472
|
+
function _is_native_reflect_construct() {
|
|
3473
|
+
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
3474
|
+
if (Reflect.construct.sham) return false;
|
|
3475
|
+
if (typeof Proxy === "function") return true;
|
|
3453
3476
|
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
return true;
|
|
3457
|
-
} catch (e) {
|
|
3458
|
-
return false;
|
|
3459
|
-
}
|
|
3460
|
-
}
|
|
3477
|
+
try {
|
|
3478
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
3461
3479
|
|
|
3462
|
-
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
|
|
3466
|
-
construct = function construct(Parent, args, Class) {
|
|
3467
|
-
var a = [null];
|
|
3468
|
-
a.push.apply(a, args);
|
|
3469
|
-
var Constructor = Function.bind.apply(Parent, a);
|
|
3470
|
-
var instance = new Constructor();
|
|
3471
|
-
if (Class) _setPrototypeOf(instance, Class.prototype);
|
|
3472
|
-
return instance;
|
|
3473
|
-
};
|
|
3474
|
-
}
|
|
3475
|
-
|
|
3476
|
-
return construct.apply(null, arguments);
|
|
3480
|
+
return true;
|
|
3481
|
+
} catch (e) {
|
|
3482
|
+
return false;
|
|
3483
|
+
}
|
|
3477
3484
|
}
|
|
3478
3485
|
|
|
3479
3486
|
function _construct(Parent, args, Class) {
|
|
3480
|
-
|
|
3487
|
+
if (_is_native_reflect_construct()) _construct = Reflect.construct;
|
|
3488
|
+
else {
|
|
3489
|
+
_construct = function construct(Parent, args, Class) {
|
|
3490
|
+
var a = [null];
|
|
3491
|
+
a.push.apply(a, args);
|
|
3492
|
+
var Constructor = Function.bind.apply(Parent, a);
|
|
3493
|
+
var instance = new Constructor();
|
|
3494
|
+
|
|
3495
|
+
if (Class) _set_prototype_of(instance, Class.prototype);
|
|
3496
|
+
|
|
3497
|
+
return instance;
|
|
3498
|
+
};
|
|
3499
|
+
}
|
|
3500
|
+
|
|
3501
|
+
return _construct.apply(null, arguments);
|
|
3481
3502
|
}
|
|
3482
3503
|
|
|
3483
3504
|
var ReflectionParser = /*#__PURE__*/ function() {
|
|
@@ -3592,7 +3613,9 @@ var ReflectionParser = /*#__PURE__*/ function() {
|
|
|
3592
3613
|
};
|
|
3593
3614
|
return ReflectionParser;
|
|
3594
3615
|
}();
|
|
3595
|
-
|
|
3616
|
+
(function() {
|
|
3617
|
+
ReflectionParser.customParseComponentHandles = new Map();
|
|
3618
|
+
})();
|
|
3596
3619
|
|
|
3597
3620
|
var PrefabParser = /*#__PURE__*/ function() {
|
|
3598
3621
|
function PrefabParser() {}
|
|
@@ -3846,7 +3869,7 @@ var SceneParserContext = /*#__PURE__*/ function() {
|
|
|
3846
3869
|
};
|
|
3847
3870
|
_proto._organizeEntities = function _organizeEntities() {
|
|
3848
3871
|
var _this_context = this.context, entityConfigMap = _this_context.entityConfigMap, entityMap = _this_context.entityMap, scene = _this_context.scene, rootIds = _this_context.rootIds;
|
|
3849
|
-
for(var _iterator =
|
|
3872
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(rootIds), _step; !(_step = _iterator()).done;){
|
|
3850
3873
|
var rootId = _step.value;
|
|
3851
3874
|
PrefabParser.parseChildren(entityConfigMap, entityMap, rootId);
|
|
3852
3875
|
}
|
|
@@ -4010,7 +4033,7 @@ var SourceFontLoader = /*#__PURE__*/ function(Loader) {
|
|
|
4010
4033
|
});
|
|
4011
4034
|
};
|
|
4012
4035
|
_proto._registerFont = function _registerFont(fontName, fontUrl) {
|
|
4013
|
-
return
|
|
4036
|
+
return _async_to_generator(function() {
|
|
4014
4037
|
var fontFace;
|
|
4015
4038
|
return __generator(this, function(_state) {
|
|
4016
4039
|
switch(_state.label){
|
|
@@ -4047,6 +4070,7 @@ var SpriteAtlasLoader = /*#__PURE__*/ function(Loader) {
|
|
|
4047
4070
|
_this = Loader.apply(this, arguments) || this;
|
|
4048
4071
|
_this._tempRect = new engineMath.Rect();
|
|
4049
4072
|
_this._tempVec2 = new engineMath.Vector2();
|
|
4073
|
+
_this._tempVec4 = new engineMath.Vector4();
|
|
4050
4074
|
return _this;
|
|
4051
4075
|
}
|
|
4052
4076
|
var _proto = SpriteAtlasLoader.prototype;
|
|
@@ -4064,57 +4088,65 @@ var SpriteAtlasLoader = /*#__PURE__*/ function(Loader) {
|
|
|
4064
4088
|
}));
|
|
4065
4089
|
chainPromises.push(configPromise);
|
|
4066
4090
|
configPromise.then(function(atlasData) {
|
|
4067
|
-
var
|
|
4068
|
-
|
|
4069
|
-
|
|
4070
|
-
|
|
4071
|
-
|
|
4072
|
-
|
|
4073
|
-
|
|
4074
|
-
|
|
4075
|
-
|
|
4076
|
-
return imagePromises.then(function(imgs) {
|
|
4077
|
-
var engine = resourceManager.engine;
|
|
4078
|
-
// Generate a SpriteAtlas object.
|
|
4079
|
-
var tempRect = _this._tempRect, tempVec2 = _this._tempVec2;
|
|
4080
|
-
var spriteAtlas = new engineCore.SpriteAtlas(engine);
|
|
4081
|
-
for(var i = 0; i < atlasItemsLen; i++){
|
|
4082
|
-
// Generate Texture2D according to configuration.
|
|
4083
|
-
var originalImg = imgs[i];
|
|
4084
|
-
var width = originalImg.width, height = originalImg.height;
|
|
4085
|
-
var texture = new engineCore.Texture2D(engine, width, height, format);
|
|
4086
|
-
texture.setImageSource(originalImg);
|
|
4087
|
-
texture.generateMipmaps();
|
|
4088
|
-
// Generate all the sprites on this texture.
|
|
4089
|
-
var atlasItem = atlasItems[i];
|
|
4090
|
-
var sprites = atlasItem.sprites;
|
|
4091
|
-
var sourceWidthReciprocal = 1.0 / width;
|
|
4092
|
-
var sourceHeightReciprocal = 1.0 / height;
|
|
4093
|
-
for(var j = sprites.length - 1; j >= 0; j--){
|
|
4094
|
-
var atlasSprite = sprites[j];
|
|
4095
|
-
var region = atlasSprite.region, atlasRegionOffset = atlasSprite.atlasRegionOffset, atlasRegion = atlasSprite.atlasRegion, id = atlasSprite.id, pivot = atlasSprite.pivot;
|
|
4096
|
-
var sprite = new engineCore.Sprite(engine, texture, region ? tempRect.set(region.x, region.y, region.w, region.h) : undefined, pivot ? tempVec2.set(pivot.x, pivot.y) : undefined, undefined, atlasSprite.name);
|
|
4097
|
-
sprite.atlasRegion.set(atlasRegion.x * sourceWidthReciprocal, atlasRegion.y * sourceHeightReciprocal, atlasRegion.w * sourceWidthReciprocal, atlasRegion.h * sourceHeightReciprocal);
|
|
4098
|
-
atlasSprite.atlasRotated && (sprite.atlasRotated = true);
|
|
4099
|
-
if (atlasRegionOffset) {
|
|
4100
|
-
var offsetLeft = atlasRegionOffset.x, offsetTop = atlasRegionOffset.y, offsetRight = atlasRegionOffset.z, offsetBottom = atlasRegionOffset.w;
|
|
4101
|
-
sprite.atlasRegionOffset.set(offsetLeft * sourceWidthReciprocal, offsetTop * sourceHeightReciprocal, offsetRight * sourceWidthReciprocal, offsetBottom * sourceHeightReciprocal);
|
|
4091
|
+
var _loop = function(i) {
|
|
4092
|
+
var atlasItem = atlasItems[i];
|
|
4093
|
+
if (atlasItem.img) {
|
|
4094
|
+
chainPromises.push(resourceManager.load({
|
|
4095
|
+
url: atlasItem.img,
|
|
4096
|
+
type: engineCore.AssetType.Texture2D,
|
|
4097
|
+
params: {
|
|
4098
|
+
format: format,
|
|
4099
|
+
mipmap: mipmap
|
|
4102
4100
|
}
|
|
4103
|
-
|
|
4101
|
+
}).then(function(texture) {
|
|
4102
|
+
anisoLevel && (texture.anisoLevel = anisoLevel);
|
|
4103
|
+
filterMode !== undefined && (texture.filterMode = filterMode);
|
|
4104
|
+
wrapModeU !== undefined && (texture.wrapModeU = wrapModeU);
|
|
4105
|
+
wrapModeV !== undefined && (texture.wrapModeV = wrapModeV);
|
|
4106
|
+
for(var i = 0; i < atlasItem.sprites.length; i++){
|
|
4104
4107
|
// @ts-ignore
|
|
4105
|
-
|
|
4108
|
+
spriteAtlas._addSprite(_this._makeSprite(engine, atlasItem.sprites[i], texture));
|
|
4106
4109
|
}
|
|
4110
|
+
}).catch(reject));
|
|
4111
|
+
} else {
|
|
4112
|
+
for(var i1 = 0; i1 < atlasItem.sprites.length; i1++){
|
|
4107
4113
|
// @ts-ignore
|
|
4108
|
-
spriteAtlas._addSprite(
|
|
4114
|
+
spriteAtlas._addSprite(_this._makeSprite(engine, atlasItem.sprites[i1]));
|
|
4109
4115
|
}
|
|
4110
4116
|
}
|
|
4117
|
+
};
|
|
4118
|
+
var atlasItems = atlasData.atlasItems, mipmap = atlasData.mipmap, anisoLevel = atlasData.anisoLevel, filterMode = atlasData.filterMode, wrapModeU = atlasData.wrapModeU, wrapModeV = atlasData.wrapModeV, format = atlasData.format;
|
|
4119
|
+
var atlasItemsLen = atlasItems ? atlasItems.length : 0;
|
|
4120
|
+
var engine = resourceManager.engine;
|
|
4121
|
+
var spriteAtlas = new engineCore.SpriteAtlas(engine);
|
|
4122
|
+
if (atlasItemsLen < 0) {
|
|
4111
4123
|
resolve(spriteAtlas);
|
|
4112
|
-
|
|
4113
|
-
|
|
4114
|
-
|
|
4115
|
-
|
|
4124
|
+
return;
|
|
4125
|
+
}
|
|
4126
|
+
chainPromises.length = 0;
|
|
4127
|
+
for(var i = 0; i < atlasItems.length; i++)_loop(i);
|
|
4128
|
+
engineCore.AssetPromise.all(chainPromises).then(function() {
|
|
4129
|
+
resolve(spriteAtlas);
|
|
4130
|
+
}).catch(reject);
|
|
4131
|
+
}).catch(reject);
|
|
4116
4132
|
});
|
|
4117
4133
|
};
|
|
4134
|
+
_proto._makeSprite = function _makeSprite(engine, config, texture) {
|
|
4135
|
+
// Generate a SpriteAtlas object.
|
|
4136
|
+
var region = config.region, atlasRegionOffset = config.atlasRegionOffset, atlasRegion = config.atlasRegion, pivot = config.pivot, border = config.border;
|
|
4137
|
+
var sprite = new engineCore.Sprite(engine, texture, region ? this._tempRect.set(region.x, region.y, region.w, region.h) : undefined, pivot ? this._tempVec2.set(pivot.x, pivot.y) : undefined, border ? this._tempVec4.set(border.x, border.y, border.z, border.w) : undefined, config.name);
|
|
4138
|
+
if (texture) {
|
|
4139
|
+
var invW = 1 / texture.width;
|
|
4140
|
+
var invH = 1 / texture.height;
|
|
4141
|
+
sprite.atlasRegion.set(atlasRegion.x * invW, atlasRegion.y * invH, atlasRegion.w * invW, atlasRegion.h * invH);
|
|
4142
|
+
if (atlasRegionOffset) {
|
|
4143
|
+
var offsetLeft = atlasRegionOffset.x, offsetTop = atlasRegionOffset.y, offsetRight = atlasRegionOffset.z, offsetBottom = atlasRegionOffset.w;
|
|
4144
|
+
sprite.atlasRegionOffset.set(offsetLeft * invW, offsetTop * invH, offsetRight * invW, offsetBottom * invH);
|
|
4145
|
+
}
|
|
4146
|
+
config.atlasRotated && (sprite.atlasRotated = true);
|
|
4147
|
+
}
|
|
4148
|
+
return sprite;
|
|
4149
|
+
};
|
|
4118
4150
|
return SpriteAtlasLoader;
|
|
4119
4151
|
}(engineCore.Loader);
|
|
4120
4152
|
SpriteAtlasLoader = __decorate([
|
|
@@ -4135,13 +4167,19 @@ var SpriteLoader = /*#__PURE__*/ function(Loader) {
|
|
|
4135
4167
|
_this.request(item.url, _extends({}, item, {
|
|
4136
4168
|
type: "json"
|
|
4137
4169
|
})).then(function(data) {
|
|
4138
|
-
|
|
4139
|
-
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
|
|
4143
|
-
|
|
4144
|
-
|
|
4170
|
+
if (data.belongToAtlas) {
|
|
4171
|
+
resourceManager// @ts-ignore
|
|
4172
|
+
.getResourceByRef(data.belongToAtlas).then(function(atlas) {
|
|
4173
|
+
resolve(atlas.getSprite(data.fullPath));
|
|
4174
|
+
}).catch(reject);
|
|
4175
|
+
} else if (data.texture) {
|
|
4176
|
+
resourceManager// @ts-ignore
|
|
4177
|
+
.getResourceByRef(data.texture).then(function(texture) {
|
|
4178
|
+
resolve(new engineCore.Sprite(resourceManager.engine, texture, data.region, data.pivot, data.border));
|
|
4179
|
+
}).catch(reject);
|
|
4180
|
+
} else {
|
|
4181
|
+
resolve(new engineCore.Sprite(resourceManager.engine, null, data.region, data.pivot, data.border));
|
|
4182
|
+
}
|
|
4145
4183
|
}).catch(reject);
|
|
4146
4184
|
});
|
|
4147
4185
|
};
|
|
@@ -4366,7 +4404,7 @@ var SceneLoader = /*#__PURE__*/ function(Loader) {
|
|
|
4366
4404
|
backgroundPromise = resourceManager.getResourceByRef(background.sky).then(function(light) {
|
|
4367
4405
|
var sky = scene.background.sky;
|
|
4368
4406
|
var skyMaterial = new engineCore.SkyBoxMaterial(engine);
|
|
4369
|
-
skyMaterial.
|
|
4407
|
+
skyMaterial.texture = light.specularTexture;
|
|
4370
4408
|
skyMaterial.textureDecodeRGBM = true;
|
|
4371
4409
|
sky.material = skyMaterial;
|
|
4372
4410
|
sky.mesh = engineCore.PrimitiveMesh.createCuboid(engine, 1, 1, 1);
|
|
@@ -4407,7 +4445,7 @@ SceneLoader = __decorate([
|
|
|
4407
4445
|
"prefab"
|
|
4408
4446
|
], true)
|
|
4409
4447
|
], SceneLoader);
|
|
4410
|
-
ReflectionParser.registerCustomParseComponent("TextRenderer", /*#__PURE__*/
|
|
4448
|
+
ReflectionParser.registerCustomParseComponent("TextRenderer", /*#__PURE__*/ _async_to_generator(function(instance, item, engine) {
|
|
4411
4449
|
var props;
|
|
4412
4450
|
return __generator(this, function(_state) {
|
|
4413
4451
|
props = item.props;
|
|
@@ -4451,18 +4489,18 @@ var KHR_draco_mesh_compression = (_KHR_draco_mesh_compression = /*#__PURE__*/ fu
|
|
|
4451
4489
|
for(var attributeName1 in glTFPrimitive.attributes){
|
|
4452
4490
|
if (gltfAttributeMap[attributeName1] !== undefined) {
|
|
4453
4491
|
var accessorDef = accessors[glTFPrimitive.attributes[attributeName1]];
|
|
4454
|
-
attributeTypeMap[attributeName1] =
|
|
4492
|
+
attributeTypeMap[attributeName1] = GLTFUtils.getComponentType(accessorDef.componentType).name;
|
|
4455
4493
|
}
|
|
4456
4494
|
}
|
|
4457
4495
|
var indexAccessor = accessors[glTFPrimitive.indices];
|
|
4458
|
-
var indexType =
|
|
4496
|
+
var indexType = GLTFUtils.getComponentType(indexAccessor.componentType).name;
|
|
4459
4497
|
var taskConfig = {
|
|
4460
4498
|
attributeIDs: attributeMap,
|
|
4461
4499
|
attributeTypes: attributeTypeMap,
|
|
4462
4500
|
useUniqueIDs: true,
|
|
4463
4501
|
indexType: indexType
|
|
4464
4502
|
};
|
|
4465
|
-
var buffer =
|
|
4503
|
+
var buffer = GLTFUtils.getBufferViewData(bufferViews[bufferViewIndex], buffers);
|
|
4466
4504
|
return KHR_draco_mesh_compression._decoder.decode(buffer, taskConfig).then(function(decodedGeometry) {
|
|
4467
4505
|
var mesh = new engineCore.ModelMesh(engine, glTFMesh.name);
|
|
4468
4506
|
return _this._parseMeshFromGLTFPrimitiveDraco(mesh, glTFMesh, glTFPrimitive, glTF, function(attributeSemantic) {
|
|
@@ -4485,7 +4523,7 @@ var KHR_draco_mesh_compression = (_KHR_draco_mesh_compression = /*#__PURE__*/ fu
|
|
|
4485
4523
|
var accessors = gltf.accessors;
|
|
4486
4524
|
var accessor = accessors[attributes["POSITION"]];
|
|
4487
4525
|
var positionBuffer = getVertexBufferData("POSITION");
|
|
4488
|
-
var positions =
|
|
4526
|
+
var positions = GLTFUtils.floatBufferToVector3Array(positionBuffer);
|
|
4489
4527
|
mesh.setPositions(positions);
|
|
4490
4528
|
var bounds = mesh.bounds;
|
|
4491
4529
|
vertexCount = accessor.count;
|
|
@@ -4512,55 +4550,55 @@ var KHR_draco_mesh_compression = (_KHR_draco_mesh_compression = /*#__PURE__*/ fu
|
|
|
4512
4550
|
var bufferData = getVertexBufferData(attributeSemantic);
|
|
4513
4551
|
switch(attributeSemantic){
|
|
4514
4552
|
case "NORMAL":
|
|
4515
|
-
var normals =
|
|
4553
|
+
var normals = GLTFUtils.floatBufferToVector3Array(bufferData);
|
|
4516
4554
|
mesh.setNormals(normals);
|
|
4517
4555
|
break;
|
|
4518
4556
|
case "TEXCOORD_0":
|
|
4519
|
-
var texturecoords =
|
|
4557
|
+
var texturecoords = GLTFUtils.floatBufferToVector2Array(bufferData);
|
|
4520
4558
|
mesh.setUVs(texturecoords, 0);
|
|
4521
4559
|
break;
|
|
4522
4560
|
case "TEXCOORD_1":
|
|
4523
|
-
var texturecoords1 =
|
|
4561
|
+
var texturecoords1 = GLTFUtils.floatBufferToVector2Array(bufferData);
|
|
4524
4562
|
mesh.setUVs(texturecoords1, 1);
|
|
4525
4563
|
break;
|
|
4526
4564
|
case "TEXCOORD_2":
|
|
4527
|
-
var texturecoords2 =
|
|
4565
|
+
var texturecoords2 = GLTFUtils.floatBufferToVector2Array(bufferData);
|
|
4528
4566
|
mesh.setUVs(texturecoords2, 2);
|
|
4529
4567
|
break;
|
|
4530
4568
|
case "TEXCOORD_3":
|
|
4531
|
-
var texturecoords3 =
|
|
4569
|
+
var texturecoords3 = GLTFUtils.floatBufferToVector2Array(bufferData);
|
|
4532
4570
|
mesh.setUVs(texturecoords3, 3);
|
|
4533
4571
|
break;
|
|
4534
4572
|
case "TEXCOORD_4":
|
|
4535
|
-
var texturecoords4 =
|
|
4573
|
+
var texturecoords4 = GLTFUtils.floatBufferToVector2Array(bufferData);
|
|
4536
4574
|
mesh.setUVs(texturecoords4, 4);
|
|
4537
4575
|
break;
|
|
4538
4576
|
case "TEXCOORD_5":
|
|
4539
|
-
var texturecoords5 =
|
|
4577
|
+
var texturecoords5 = GLTFUtils.floatBufferToVector2Array(bufferData);
|
|
4540
4578
|
mesh.setUVs(texturecoords5, 5);
|
|
4541
4579
|
break;
|
|
4542
4580
|
case "TEXCOORD_6":
|
|
4543
|
-
var texturecoords6 =
|
|
4581
|
+
var texturecoords6 = GLTFUtils.floatBufferToVector2Array(bufferData);
|
|
4544
4582
|
mesh.setUVs(texturecoords6, 6);
|
|
4545
4583
|
break;
|
|
4546
4584
|
case "TEXCOORD_7":
|
|
4547
|
-
var texturecoords7 =
|
|
4585
|
+
var texturecoords7 = GLTFUtils.floatBufferToVector2Array(bufferData);
|
|
4548
4586
|
mesh.setUVs(texturecoords7, 7);
|
|
4549
4587
|
break;
|
|
4550
4588
|
case "COLOR_0":
|
|
4551
|
-
var colors =
|
|
4589
|
+
var colors = GLTFUtils.floatBufferToColorArray(bufferData, accessors[attributes["COLOR_0"]].type === AccessorType.VEC3);
|
|
4552
4590
|
mesh.setColors(colors);
|
|
4553
4591
|
break;
|
|
4554
4592
|
case "TANGENT":
|
|
4555
|
-
var tangents =
|
|
4593
|
+
var tangents = GLTFUtils.floatBufferToVector4Array(bufferData);
|
|
4556
4594
|
mesh.setTangents(tangents);
|
|
4557
4595
|
break;
|
|
4558
4596
|
case "JOINTS_0":
|
|
4559
|
-
var joints =
|
|
4597
|
+
var joints = GLTFUtils.floatBufferToVector4Array(bufferData);
|
|
4560
4598
|
mesh.setBoneIndices(joints);
|
|
4561
4599
|
break;
|
|
4562
4600
|
case "WEIGHTS_0":
|
|
4563
|
-
var weights =
|
|
4601
|
+
var weights = GLTFUtils.floatBufferToVector4Array(bufferData);
|
|
4564
4602
|
mesh.setBoneWeights(weights);
|
|
4565
4603
|
break;
|
|
4566
4604
|
}
|
|
@@ -4580,7 +4618,9 @@ var KHR_draco_mesh_compression = (_KHR_draco_mesh_compression = /*#__PURE__*/ fu
|
|
|
4580
4618
|
return Promise.resolve(mesh);
|
|
4581
4619
|
};
|
|
4582
4620
|
return KHR_draco_mesh_compression1;
|
|
4583
|
-
}(GLTFExtensionParser),
|
|
4621
|
+
}(GLTFExtensionParser), function() {
|
|
4622
|
+
_KHR_draco_mesh_compression._tempVector3 = new engineMath.Vector3();
|
|
4623
|
+
}(), _KHR_draco_mesh_compression);
|
|
4584
4624
|
KHR_draco_mesh_compression = __decorate([
|
|
4585
4625
|
registerGLTFExtension("KHR_draco_mesh_compression", exports.GLTFExtensionMode.CreateAndParse)
|
|
4586
4626
|
], KHR_draco_mesh_compression);
|
|
@@ -4761,12 +4801,12 @@ KHR_texture_transform = __decorate([
|
|
|
4761
4801
|
registerGLTFExtension("KHR_texture_transform", exports.GLTFExtensionMode.AdditiveParse)
|
|
4762
4802
|
], KHR_texture_transform);
|
|
4763
4803
|
|
|
4764
|
-
var
|
|
4765
|
-
_inherits(
|
|
4766
|
-
function
|
|
4804
|
+
var GALACEAN_materials_remap = /*#__PURE__*/ function(GLTFExtensionParser) {
|
|
4805
|
+
_inherits(GALACEAN_materials_remap, GLTFExtensionParser);
|
|
4806
|
+
function GALACEAN_materials_remap() {
|
|
4767
4807
|
return GLTFExtensionParser.apply(this, arguments);
|
|
4768
4808
|
}
|
|
4769
|
-
var _proto =
|
|
4809
|
+
var _proto = GALACEAN_materials_remap.prototype;
|
|
4770
4810
|
/**
|
|
4771
4811
|
* @override
|
|
4772
4812
|
*/ _proto.createAndParse = function createAndParse(context, schema) {
|
|
@@ -4774,18 +4814,18 @@ var GalaceanMaterialsRemap = /*#__PURE__*/ function(GLTFExtensionParser) {
|
|
|
4774
4814
|
// @ts-ignore
|
|
4775
4815
|
return engine.resourceManager.getResourceByRef(schema);
|
|
4776
4816
|
};
|
|
4777
|
-
return
|
|
4817
|
+
return GALACEAN_materials_remap;
|
|
4778
4818
|
}(GLTFExtensionParser);
|
|
4779
|
-
|
|
4780
|
-
registerGLTFExtension("
|
|
4781
|
-
],
|
|
4819
|
+
GALACEAN_materials_remap = __decorate([
|
|
4820
|
+
registerGLTFExtension("GALACEAN_materials_remap", exports.GLTFExtensionMode.CreateAndParse)
|
|
4821
|
+
], GALACEAN_materials_remap);
|
|
4782
4822
|
|
|
4783
|
-
var
|
|
4784
|
-
_inherits(
|
|
4785
|
-
function
|
|
4823
|
+
var GALACEAN_animation_event = /*#__PURE__*/ function(GLTFExtensionParser) {
|
|
4824
|
+
_inherits(GALACEAN_animation_event, GLTFExtensionParser);
|
|
4825
|
+
function GALACEAN_animation_event() {
|
|
4786
4826
|
return GLTFExtensionParser.apply(this, arguments);
|
|
4787
4827
|
}
|
|
4788
|
-
var _proto =
|
|
4828
|
+
var _proto = GALACEAN_animation_event.prototype;
|
|
4789
4829
|
/**
|
|
4790
4830
|
* @override
|
|
4791
4831
|
*/ _proto.additiveParse = function additiveParse(context, animationClip, schema) {
|
|
@@ -4799,11 +4839,11 @@ var OASIS_animation_event = /*#__PURE__*/ function(GLTFExtensionParser) {
|
|
|
4799
4839
|
animationClip.addEvent(event);
|
|
4800
4840
|
});
|
|
4801
4841
|
};
|
|
4802
|
-
return
|
|
4842
|
+
return GALACEAN_animation_event;
|
|
4803
4843
|
}(GLTFExtensionParser);
|
|
4804
|
-
|
|
4805
|
-
registerGLTFExtension("
|
|
4806
|
-
],
|
|
4844
|
+
GALACEAN_animation_event = __decorate([
|
|
4845
|
+
registerGLTFExtension("GALACEAN_animation_event", exports.GLTFExtensionMode.AdditiveParse)
|
|
4846
|
+
], GALACEAN_animation_event);
|
|
4807
4847
|
|
|
4808
4848
|
exports.ComponentMap = ComponentMap;
|
|
4809
4849
|
exports.GLTFAnimationParser = GLTFAnimationParser;
|
|
@@ -4819,7 +4859,7 @@ exports.GLTFResource = GLTFResource;
|
|
|
4819
4859
|
exports.GLTFSceneParser = GLTFSceneParser;
|
|
4820
4860
|
exports.GLTFSkinParser = GLTFSkinParser;
|
|
4821
4861
|
exports.GLTFTextureParser = GLTFTextureParser;
|
|
4822
|
-
exports.
|
|
4862
|
+
exports.GLTFUtils = GLTFUtils;
|
|
4823
4863
|
exports.GLTFValidator = GLTFValidator;
|
|
4824
4864
|
exports.PrefabParser = PrefabParser;
|
|
4825
4865
|
exports.ReflectionParser = ReflectionParser;
|