@galacean/engine-loader 1.0.0-alpha.6 → 1.0.0-beta.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/dist/main.js +418 -410
- package/dist/main.js.map +1 -1
- package/dist/miniprogram.js +418 -410
- package/dist/module.js +419 -411
- package/dist/module.js.map +1 -1
- package/package.json +5 -5
- package/types/GLTFContentRestorer.d.ts +0 -3
- package/types/GLTFLoader.d.ts +4 -4
- package/types/Texture2DContentRestorer.d.ts +0 -3
- package/types/TextureCubeContentRestorer.d.ts +0 -3
- package/types/gltf/GLTFResource.d.ts +0 -3
- package/types/gltf/GLTFUtil.d.ts +8 -8
- package/types/gltf/GLTFUtils.d.ts +47 -0
- 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/extensions/OASIS_materials_remap.d.ts +0 -1
- /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
|
/**
|
|
@@ -415,9 +397,7 @@ function _createForOfIteratorHelperLoose(o, allowArrayLike) {
|
|
|
415
397
|
return _this;
|
|
416
398
|
}
|
|
417
399
|
var _proto = GLTFContentRestorer.prototype;
|
|
418
|
-
|
|
419
|
-
* @override
|
|
420
|
-
*/ _proto.restoreContent = function restoreContent() {
|
|
400
|
+
_proto.restoreContent = function restoreContent() {
|
|
421
401
|
var _this = this;
|
|
422
402
|
return new engineCore.AssetPromise(function(resolve, reject) {
|
|
423
403
|
Promise.all(_this.bufferRequests.map(function(bufferRequestInfo) {
|
|
@@ -440,16 +420,16 @@ function _createForOfIteratorHelperLoose(o, allowArrayLike) {
|
|
|
440
420
|
var buffer = buffers[bufferView.buffer];
|
|
441
421
|
var _bufferView_byteOffset;
|
|
442
422
|
var bufferData = new Uint8Array(buffer, (_bufferView_byteOffset = bufferView.byteOffset) != null ? _bufferView_byteOffset : 0, bufferView.byteLength);
|
|
443
|
-
return
|
|
423
|
+
return GLTFUtils.loadImageBuffer(bufferData, textureRestoreInfo.mimeType).then(function(image) {
|
|
444
424
|
textureRestoreInfo.texture.setImageSource(image);
|
|
445
425
|
textureRestoreInfo.texture.generateMipmaps();
|
|
446
426
|
});
|
|
447
427
|
})).then(function() {
|
|
448
428
|
// Restore mesh
|
|
449
|
-
for(var _iterator =
|
|
429
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(_this.meshes), _step; !(_step = _iterator()).done;){
|
|
450
430
|
var meshInfo = _step.value;
|
|
451
431
|
var mesh = meshInfo.mesh;
|
|
452
|
-
for(var _iterator1 =
|
|
432
|
+
for(var _iterator1 = _create_for_of_iterator_helper_loose(meshInfo.vertexBuffers), _step1; !(_step1 = _iterator1()).done;){
|
|
453
433
|
var bufferRestoreInfo = _step1.value;
|
|
454
434
|
var vertexData = _this._getBufferData(buffers, bufferRestoreInfo.data);
|
|
455
435
|
bufferRestoreInfo.buffer.setData(vertexData);
|
|
@@ -458,18 +438,18 @@ function _createForOfIteratorHelperLoose(o, allowArrayLike) {
|
|
|
458
438
|
var indexData = _this._getBufferData(buffers, meshInfo.indexBuffer);
|
|
459
439
|
mesh.setIndices(indexData);
|
|
460
440
|
}
|
|
461
|
-
for(var _iterator2 =
|
|
441
|
+
for(var _iterator2 = _create_for_of_iterator_helper_loose(meshInfo.blendShapes), _step2; !(_step2 = _iterator2()).done;){
|
|
462
442
|
var restoreInfo = _step2.value;
|
|
463
443
|
var frame = restoreInfo.blendShape.frames[0];
|
|
464
444
|
var positionData = _this._getBufferData(buffers, restoreInfo.position);
|
|
465
|
-
frame.deltaPositions =
|
|
445
|
+
frame.deltaPositions = GLTFUtils.floatBufferToVector3Array(positionData);
|
|
466
446
|
if (restoreInfo.normal) {
|
|
467
447
|
var normalData = _this._getBufferData(buffers, restoreInfo.normal);
|
|
468
|
-
frame.deltaNormals =
|
|
448
|
+
frame.deltaNormals = GLTFUtils.floatBufferToVector3Array(normalData);
|
|
469
449
|
}
|
|
470
450
|
if (restoreInfo.tangent) {
|
|
471
451
|
var tangentData = _this._getBufferData(buffers, restoreInfo.tangent);
|
|
472
|
-
frame.deltaTangents =
|
|
452
|
+
frame.deltaTangents = GLTFUtils.floatBufferToVector3Array(tangentData);
|
|
473
453
|
}
|
|
474
454
|
}
|
|
475
455
|
mesh.uploadData(true);
|
|
@@ -751,9 +731,9 @@ var TextureWrapMode;
|
|
|
751
731
|
|
|
752
732
|
/**
|
|
753
733
|
* @internal
|
|
754
|
-
*/ var
|
|
755
|
-
function
|
|
756
|
-
|
|
734
|
+
*/ var GLTFUtils = /*#__PURE__*/ function() {
|
|
735
|
+
function GLTFUtils() {}
|
|
736
|
+
GLTFUtils.floatBufferToVector2Array = function floatBufferToVector2Array(buffer) {
|
|
757
737
|
var bufferLen = buffer.length;
|
|
758
738
|
var array = new Array(bufferLen / 2);
|
|
759
739
|
for(var i = 0; i < bufferLen; i += 2){
|
|
@@ -761,7 +741,7 @@ var TextureWrapMode;
|
|
|
761
741
|
}
|
|
762
742
|
return array;
|
|
763
743
|
};
|
|
764
|
-
|
|
744
|
+
GLTFUtils.floatBufferToVector3Array = function floatBufferToVector3Array(buffer) {
|
|
765
745
|
var bufferLen = buffer.length;
|
|
766
746
|
var array = new Array(bufferLen / 3);
|
|
767
747
|
for(var i = 0; i < bufferLen; i += 3){
|
|
@@ -769,7 +749,7 @@ var TextureWrapMode;
|
|
|
769
749
|
}
|
|
770
750
|
return array;
|
|
771
751
|
};
|
|
772
|
-
|
|
752
|
+
GLTFUtils.floatBufferToVector4Array = function floatBufferToVector4Array(buffer) {
|
|
773
753
|
var bufferLen = buffer.length;
|
|
774
754
|
var array = new Array(bufferLen / 4);
|
|
775
755
|
for(var i = 0; i < bufferLen; i += 4){
|
|
@@ -777,7 +757,7 @@ var TextureWrapMode;
|
|
|
777
757
|
}
|
|
778
758
|
return array;
|
|
779
759
|
};
|
|
780
|
-
|
|
760
|
+
GLTFUtils.floatBufferToColorArray = function floatBufferToColorArray(buffer, isColor3) {
|
|
781
761
|
var bufferLen = buffer.length;
|
|
782
762
|
var colors = new Array(bufferLen / (isColor3 ? 3 : 4));
|
|
783
763
|
if (isColor3) {
|
|
@@ -792,21 +772,8 @@ var TextureWrapMode;
|
|
|
792
772
|
return colors;
|
|
793
773
|
};
|
|
794
774
|
/**
|
|
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
775
|
* Get the number of bytes occupied by accessor type.
|
|
809
|
-
*/
|
|
776
|
+
*/ GLTFUtils.getAccessorTypeSize = function getAccessorTypeSize(accessorType) {
|
|
810
777
|
switch(accessorType){
|
|
811
778
|
case AccessorType.SCALAR:
|
|
812
779
|
return 1;
|
|
@@ -826,7 +793,7 @@ var TextureWrapMode;
|
|
|
826
793
|
};
|
|
827
794
|
/**
|
|
828
795
|
* Get the TypedArray corresponding to the component type.
|
|
829
|
-
*/
|
|
796
|
+
*/ GLTFUtils.getComponentType = function getComponentType(componentType) {
|
|
830
797
|
switch(componentType){
|
|
831
798
|
case AccessorComponentType.BYTE:
|
|
832
799
|
return Int8Array;
|
|
@@ -842,7 +809,7 @@ var TextureWrapMode;
|
|
|
842
809
|
return Float32Array;
|
|
843
810
|
}
|
|
844
811
|
};
|
|
845
|
-
|
|
812
|
+
GLTFUtils.getNormalizedComponentScale = function getNormalizedComponentScale(componentType) {
|
|
846
813
|
// Reference: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization#encoding-quantized-data
|
|
847
814
|
switch(componentType){
|
|
848
815
|
case AccessorComponentType.BYTE:
|
|
@@ -857,7 +824,7 @@ var TextureWrapMode;
|
|
|
857
824
|
throw new Error("Galacean.GLTFLoader: Unsupported normalized accessor component type.");
|
|
858
825
|
}
|
|
859
826
|
};
|
|
860
|
-
|
|
827
|
+
GLTFUtils.getAccessorBuffer = function getAccessorBuffer(context, bufferViews, accessor) {
|
|
861
828
|
var buffers = context.buffers;
|
|
862
829
|
var componentType = accessor.componentType;
|
|
863
830
|
var bufferView = bufferViews[accessor.bufferView];
|
|
@@ -865,8 +832,8 @@ var TextureWrapMode;
|
|
|
865
832
|
var buffer = buffers[bufferIndex];
|
|
866
833
|
var bufferByteOffset = bufferView.byteOffset || 0;
|
|
867
834
|
var byteOffset = accessor.byteOffset || 0;
|
|
868
|
-
var TypedArray =
|
|
869
|
-
var dataElementSize =
|
|
835
|
+
var TypedArray = GLTFUtils.getComponentType(componentType);
|
|
836
|
+
var dataElementSize = GLTFUtils.getAccessorTypeSize(accessor.type);
|
|
870
837
|
var dataElementBytes = TypedArray.BYTES_PER_ELEMENT;
|
|
871
838
|
var elementStride = dataElementSize * dataElementBytes;
|
|
872
839
|
var accessorCount = accessor.count;
|
|
@@ -893,25 +860,25 @@ var TextureWrapMode;
|
|
|
893
860
|
bufferInfo.restoreInfo = new BufferDataRestoreInfo(new RestoreDataAccessor(bufferIndex, TypedArray, offset1, count1));
|
|
894
861
|
}
|
|
895
862
|
if (accessor.sparse) {
|
|
896
|
-
|
|
863
|
+
GLTFUtils.processingSparseData(bufferViews, accessor, buffers, bufferInfo);
|
|
897
864
|
}
|
|
898
865
|
return bufferInfo;
|
|
899
866
|
};
|
|
900
867
|
/**
|
|
901
868
|
* @deprecated
|
|
902
869
|
* Get accessor data.
|
|
903
|
-
*/
|
|
870
|
+
*/ GLTFUtils.getAccessorData = function getAccessorData(glTF, accessor, buffers) {
|
|
904
871
|
var bufferViews = glTF.bufferViews;
|
|
905
872
|
var bufferView = bufferViews[accessor.bufferView];
|
|
906
873
|
var arrayBuffer = buffers[bufferView.buffer];
|
|
907
874
|
var accessorByteOffset = accessor.hasOwnProperty("byteOffset") ? accessor.byteOffset : 0;
|
|
908
875
|
var bufferViewByteOffset = bufferView.hasOwnProperty("byteOffset") ? bufferView.byteOffset : 0;
|
|
909
876
|
var byteOffset = accessorByteOffset + bufferViewByteOffset;
|
|
910
|
-
var accessorTypeSize =
|
|
877
|
+
var accessorTypeSize = GLTFUtils.getAccessorTypeSize(accessor.type);
|
|
911
878
|
var length = accessorTypeSize * accessor.count;
|
|
912
879
|
var _bufferView_byteStride;
|
|
913
880
|
var byteStride = (_bufferView_byteStride = bufferView.byteStride) != null ? _bufferView_byteStride : 0;
|
|
914
|
-
var arrayType =
|
|
881
|
+
var arrayType = GLTFUtils.getComponentType(accessor.componentType);
|
|
915
882
|
var uint8Array;
|
|
916
883
|
if (byteStride) {
|
|
917
884
|
var accessorByteSize = accessorTypeSize * arrayType.BYTES_PER_ELEMENT;
|
|
@@ -938,7 +905,7 @@ var TextureWrapMode;
|
|
|
938
905
|
var _values_byteOffset, _valuesBufferView_byteOffset;
|
|
939
906
|
var valuesByteOffset = ((_values_byteOffset = values.byteOffset) != null ? _values_byteOffset : 0) + ((_valuesBufferView_byteOffset = valuesBufferView.byteOffset) != null ? _valuesBufferView_byteOffset : 0);
|
|
940
907
|
var valuesByteLength = valuesBufferView.byteLength;
|
|
941
|
-
var indicesType =
|
|
908
|
+
var indicesType = GLTFUtils.getComponentType(indices.componentType);
|
|
942
909
|
var indicesArray = new indicesType(indicesArrayBuffer, indicesByteOffset, indicesByteLength / indicesType.BYTES_PER_ELEMENT);
|
|
943
910
|
var valuesArray = new arrayType(valuesArrayBuffer, valuesByteOffset, valuesByteLength / arrayType.BYTES_PER_ELEMENT);
|
|
944
911
|
for(var i1 = 0; i1 < count; i1++){
|
|
@@ -950,17 +917,17 @@ var TextureWrapMode;
|
|
|
950
917
|
}
|
|
951
918
|
return typedArray;
|
|
952
919
|
};
|
|
953
|
-
|
|
920
|
+
GLTFUtils.getBufferViewData = function getBufferViewData(bufferView, buffers) {
|
|
954
921
|
var _bufferView_byteOffset = bufferView.byteOffset, byteOffset = _bufferView_byteOffset === void 0 ? 0 : _bufferView_byteOffset;
|
|
955
922
|
var arrayBuffer = buffers[bufferView.buffer];
|
|
956
923
|
return arrayBuffer.slice(byteOffset, byteOffset + bufferView.byteLength);
|
|
957
924
|
};
|
|
958
925
|
/**
|
|
959
926
|
* Get accessor data.
|
|
960
|
-
*/
|
|
927
|
+
*/ GLTFUtils.processingSparseData = function processingSparseData(bufferViews, accessor, buffers, bufferInfo) {
|
|
961
928
|
var restoreInfo = bufferInfo.restoreInfo;
|
|
962
|
-
var accessorTypeSize =
|
|
963
|
-
var TypedArray =
|
|
929
|
+
var accessorTypeSize = GLTFUtils.getAccessorTypeSize(accessor.type);
|
|
930
|
+
var TypedArray = GLTFUtils.getComponentType(accessor.componentType);
|
|
964
931
|
var data = bufferInfo.data.slice();
|
|
965
932
|
var _accessor_sparse = accessor.sparse, count = _accessor_sparse.count, indices = _accessor_sparse.indices, values = _accessor_sparse.values;
|
|
966
933
|
var indicesBufferView = bufferViews[indices.bufferView];
|
|
@@ -977,7 +944,7 @@ var TextureWrapMode;
|
|
|
977
944
|
var valuesByteLength = valuesBufferView.byteLength;
|
|
978
945
|
restoreInfo.typeSize = accessorTypeSize;
|
|
979
946
|
restoreInfo.sparseCount = count;
|
|
980
|
-
var IndexTypeArray =
|
|
947
|
+
var IndexTypeArray = GLTFUtils.getComponentType(indices.componentType);
|
|
981
948
|
var indexLength = indicesByteLength / IndexTypeArray.BYTES_PER_ELEMENT;
|
|
982
949
|
var indicesArray = new IndexTypeArray(indicesArrayBuffer, indicesByteOffset, indexLength);
|
|
983
950
|
restoreInfo.sparseIndices = new RestoreDataAccessor(indicesBufferIndex, IndexTypeArray, indicesByteOffset, indexLength);
|
|
@@ -992,7 +959,7 @@ var TextureWrapMode;
|
|
|
992
959
|
}
|
|
993
960
|
bufferInfo.data = data;
|
|
994
961
|
};
|
|
995
|
-
|
|
962
|
+
GLTFUtils.getIndexFormat = function getIndexFormat(type) {
|
|
996
963
|
switch(type){
|
|
997
964
|
case AccessorComponentType.UNSIGNED_BYTE:
|
|
998
965
|
return engineCore.IndexFormat.UInt8;
|
|
@@ -1002,7 +969,7 @@ var TextureWrapMode;
|
|
|
1002
969
|
return engineCore.IndexFormat.UInt32;
|
|
1003
970
|
}
|
|
1004
971
|
};
|
|
1005
|
-
|
|
972
|
+
GLTFUtils.getElementFormat = function getElementFormat(type, size, normalized) {
|
|
1006
973
|
if (normalized === void 0) normalized = false;
|
|
1007
974
|
if (type == AccessorComponentType.FLOAT) {
|
|
1008
975
|
switch(size){
|
|
@@ -1053,7 +1020,7 @@ var TextureWrapMode;
|
|
|
1053
1020
|
};
|
|
1054
1021
|
/**
|
|
1055
1022
|
* Load image buffer
|
|
1056
|
-
*/
|
|
1023
|
+
*/ GLTFUtils.loadImageBuffer = function loadImageBuffer(imageBuffer, type) {
|
|
1057
1024
|
return new Promise(function(resolve, reject) {
|
|
1058
1025
|
var blob = new window.Blob([
|
|
1059
1026
|
imageBuffer
|
|
@@ -1077,18 +1044,9 @@ var TextureWrapMode;
|
|
|
1077
1044
|
img.src = URL.createObjectURL(blob);
|
|
1078
1045
|
});
|
|
1079
1046
|
};
|
|
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
1047
|
/**
|
|
1090
1048
|
* Parse the glb format.
|
|
1091
|
-
*/
|
|
1049
|
+
*/ GLTFUtils.parseGLB = function parseGLB(context, glb) {
|
|
1092
1050
|
var UINT32_LENGTH = 4;
|
|
1093
1051
|
var GLB_HEADER_MAGIC = 0x46546c67; // 'glTF'
|
|
1094
1052
|
var GLB_HEADER_LENGTH = 12;
|
|
@@ -1116,7 +1074,7 @@ var TextureWrapMode;
|
|
|
1116
1074
|
return null;
|
|
1117
1075
|
}
|
|
1118
1076
|
var glTFData = new Uint8Array(glb, GLB_HEADER_LENGTH + 2 * UINT32_LENGTH, chunkLength);
|
|
1119
|
-
var glTF = JSON.parse(
|
|
1077
|
+
var glTF = JSON.parse(engineCore.Utils.decodeText(glTFData));
|
|
1120
1078
|
// read all buffers
|
|
1121
1079
|
var buffers = [];
|
|
1122
1080
|
var byteOffset = GLB_HEADER_LENGTH + 2 * UINT32_LENGTH + chunkLength;
|
|
@@ -1139,7 +1097,7 @@ var TextureWrapMode;
|
|
|
1139
1097
|
buffers: buffers
|
|
1140
1098
|
};
|
|
1141
1099
|
};
|
|
1142
|
-
|
|
1100
|
+
GLTFUtils._formatRelativePath = function _formatRelativePath(path) {
|
|
1143
1101
|
// For example input is "a/b", "/a/b", "./a/b", "./a/./b", "./a/../a/b", output is "a/b"
|
|
1144
1102
|
return path.split("/").filter(Boolean).reduce(function(acc, cur) {
|
|
1145
1103
|
if (cur === "..") acc.pop();
|
|
@@ -1147,23 +1105,25 @@ var TextureWrapMode;
|
|
|
1147
1105
|
return acc;
|
|
1148
1106
|
}, []).join("/");
|
|
1149
1107
|
};
|
|
1150
|
-
return
|
|
1108
|
+
return GLTFUtils;
|
|
1151
1109
|
}();
|
|
1152
1110
|
|
|
1153
|
-
function
|
|
1154
|
-
|
|
1111
|
+
function _array_without_holes(arr) {
|
|
1112
|
+
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
1155
1113
|
}
|
|
1156
1114
|
|
|
1157
|
-
function
|
|
1158
|
-
|
|
1115
|
+
function _iterable_to_array(iter) {
|
|
1116
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) {
|
|
1117
|
+
return Array.from(iter);
|
|
1118
|
+
}
|
|
1159
1119
|
}
|
|
1160
1120
|
|
|
1161
|
-
function
|
|
1162
|
-
|
|
1121
|
+
function _non_iterable_spread() {
|
|
1122
|
+
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
1123
|
}
|
|
1164
1124
|
|
|
1165
|
-
function
|
|
1166
|
-
|
|
1125
|
+
function _to_consumable_array(arr) {
|
|
1126
|
+
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
1167
1127
|
}
|
|
1168
1128
|
|
|
1169
1129
|
/**
|
|
@@ -1253,7 +1213,7 @@ exports.GLTFExtensionMode = void 0;
|
|
|
1253
1213
|
context,
|
|
1254
1214
|
extensionSchema,
|
|
1255
1215
|
ownerSchema
|
|
1256
|
-
].concat(
|
|
1216
|
+
].concat(_to_consumable_array(extra)));
|
|
1257
1217
|
if (resource) {
|
|
1258
1218
|
return resource;
|
|
1259
1219
|
}
|
|
@@ -1279,7 +1239,7 @@ exports.GLTFExtensionMode = void 0;
|
|
|
1279
1239
|
parseResource,
|
|
1280
1240
|
extensionSchema,
|
|
1281
1241
|
ownerSchema
|
|
1282
|
-
].concat(
|
|
1242
|
+
].concat(_to_consumable_array(extra)));
|
|
1283
1243
|
}
|
|
1284
1244
|
};
|
|
1285
1245
|
/**
|
|
@@ -1327,7 +1287,7 @@ exports.GLTFExtensionMode = void 0;
|
|
|
1327
1287
|
context,
|
|
1328
1288
|
extensionSchema,
|
|
1329
1289
|
ownerSchema
|
|
1330
|
-
].concat(
|
|
1290
|
+
].concat(_to_consumable_array(extra)));
|
|
1331
1291
|
}
|
|
1332
1292
|
};
|
|
1333
1293
|
GLTFParser._additiveParse = function _additiveParse(extensionName, context, parseResource, extensionSchema, ownerSchema) {
|
|
@@ -1342,12 +1302,14 @@ exports.GLTFExtensionMode = void 0;
|
|
|
1342
1302
|
parseResource,
|
|
1343
1303
|
extensionSchema,
|
|
1344
1304
|
ownerSchema
|
|
1345
|
-
].concat(
|
|
1305
|
+
].concat(_to_consumable_array(extra)));
|
|
1346
1306
|
}
|
|
1347
1307
|
};
|
|
1348
1308
|
return GLTFParser;
|
|
1349
1309
|
}();
|
|
1350
|
-
|
|
1310
|
+
(function() {
|
|
1311
|
+
GLTFParser._extensionParsers = {};
|
|
1312
|
+
})();
|
|
1351
1313
|
/**
|
|
1352
1314
|
* Declare ExtensionParser's decorator.
|
|
1353
1315
|
* @param extensionName - Extension name
|
|
@@ -1409,10 +1371,10 @@ var GLTFAnimationParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
1409
1371
|
var gltfSampler = samplers[j];
|
|
1410
1372
|
var inputAccessor = accessors[gltfSampler.input];
|
|
1411
1373
|
var outputAccessor = accessors[gltfSampler.output];
|
|
1412
|
-
var input =
|
|
1413
|
-
var output =
|
|
1374
|
+
var input = GLTFUtils.getAccessorBuffer(context, bufferViews, inputAccessor).data;
|
|
1375
|
+
var output = GLTFUtils.getAccessorBuffer(context, bufferViews, outputAccessor).data;
|
|
1414
1376
|
if (outputAccessor.normalized) {
|
|
1415
|
-
var scale =
|
|
1377
|
+
var scale = GLTFUtils.getNormalizedComponentScale(outputAccessor.componentType);
|
|
1416
1378
|
var scaled = new Float32Array(output.length);
|
|
1417
1379
|
for(var k = 0, v = output.length; k < v; k++){
|
|
1418
1380
|
scaled[k] = output[k] * scale;
|
|
@@ -1566,7 +1528,7 @@ var GLTFBufferParser = /*#__PURE__*/ function(GLTFParser) {
|
|
|
1566
1528
|
if (isGLB) {
|
|
1567
1529
|
return engineCore.request(url, requestConfig).then(function(glb) {
|
|
1568
1530
|
restoreBufferRequests.push(new BufferRequestInfo(url, requestConfig));
|
|
1569
|
-
return
|
|
1531
|
+
return GLTFUtils.parseGLB(context, glb);
|
|
1570
1532
|
}).then(function(param) {
|
|
1571
1533
|
var glTF = param.glTF, buffers = param.buffers;
|
|
1572
1534
|
context.glTF = glTF;
|
|
@@ -1578,7 +1540,7 @@ var GLTFBufferParser = /*#__PURE__*/ function(GLTFParser) {
|
|
|
1578
1540
|
}).then(function(glTF) {
|
|
1579
1541
|
context.glTF = glTF;
|
|
1580
1542
|
return Promise.all(glTF.buffers.map(function(buffer) {
|
|
1581
|
-
var absoluteUrl =
|
|
1543
|
+
var absoluteUrl = engineCore.Utils.resolveAbsoluteUrl(url, buffer.uri);
|
|
1582
1544
|
restoreBufferRequests.push(new BufferRequestInfo(absoluteUrl, requestConfig));
|
|
1583
1545
|
return engineCore.request(absoluteUrl, requestConfig);
|
|
1584
1546
|
})).then(function(buffers) {
|
|
@@ -1668,7 +1630,9 @@ var GLTFEntityParser = /*#__PURE__*/ function(GLTFParser) {
|
|
|
1668
1630
|
};
|
|
1669
1631
|
return GLTFEntityParser;
|
|
1670
1632
|
}(GLTFParser);
|
|
1671
|
-
|
|
1633
|
+
(function() {
|
|
1634
|
+
/** @internal */ GLTFEntityParser._defaultName = "_GLTF_ENTITY_";
|
|
1635
|
+
})();
|
|
1672
1636
|
|
|
1673
1637
|
var GLTFMaterialParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
1674
1638
|
_inherits(GLTFMaterialParser, GLTFParser1);
|
|
@@ -1783,11 +1747,9 @@ var GLTFMaterialParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
1783
1747
|
}(GLTFParser);
|
|
1784
1748
|
|
|
1785
1749
|
function _instanceof(left, right) {
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
return left instanceof right;
|
|
1790
|
-
}
|
|
1750
|
+
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
1751
|
+
return !!right[Symbol.hasInstance](left);
|
|
1752
|
+
} else return left instanceof right;
|
|
1791
1753
|
}
|
|
1792
1754
|
|
|
1793
1755
|
var GLTFMeshParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
@@ -1822,13 +1784,13 @@ var GLTFMeshParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
1822
1784
|
var attributeAccessorIdx = shapeAccessorIdx[attributeName];
|
|
1823
1785
|
if (attributeAccessorIdx) {
|
|
1824
1786
|
var accessor = glTF.accessors[attributeAccessorIdx];
|
|
1825
|
-
return
|
|
1787
|
+
return GLTFUtils.getAccessorBuffer(context, context.glTF.bufferViews, accessor);
|
|
1826
1788
|
} else {
|
|
1827
1789
|
return null;
|
|
1828
1790
|
}
|
|
1829
1791
|
}, function() {
|
|
1830
1792
|
var indexAccessor = glTF.accessors[gltfPrimitive.indices];
|
|
1831
|
-
return
|
|
1793
|
+
return GLTFUtils.getAccessorData(glTF, indexAccessor, buffers);
|
|
1832
1794
|
}, context.keepMeshData).then(resolve);
|
|
1833
1795
|
}
|
|
1834
1796
|
});
|
|
@@ -1860,16 +1822,18 @@ var GLTFMeshParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
1860
1822
|
var vertexElements = new Array();
|
|
1861
1823
|
var vertexCount;
|
|
1862
1824
|
var bufferBindIndex = 0;
|
|
1825
|
+
var positions;
|
|
1826
|
+
keepMeshData && (positions = new Array(vertexCount));
|
|
1863
1827
|
for(var attribute in attributes){
|
|
1864
1828
|
var accessor = accessors[attributes[attribute]];
|
|
1865
|
-
var accessorBuffer =
|
|
1866
|
-
var dataElementSize =
|
|
1829
|
+
var accessorBuffer = GLTFUtils.getAccessorBuffer(context, gltf.bufferViews, accessor);
|
|
1830
|
+
var dataElementSize = GLTFUtils.getAccessorTypeSize(accessor.type);
|
|
1867
1831
|
var attributeCount = accessor.count;
|
|
1868
1832
|
var vertices = accessorBuffer.data;
|
|
1869
1833
|
var vertexElement = void 0;
|
|
1870
1834
|
var meshId = mesh.instanceId;
|
|
1871
1835
|
var vertexBindingInfos = accessorBuffer.vertexBindingInfos;
|
|
1872
|
-
var elementFormat =
|
|
1836
|
+
var elementFormat = GLTFUtils.getElementFormat(accessor.componentType, dataElementSize, accessor.normalized);
|
|
1873
1837
|
if (accessorBuffer.interleaved) {
|
|
1874
1838
|
var byteOffset = accessor.byteOffset || 0;
|
|
1875
1839
|
var stride = accessorBuffer.stride;
|
|
@@ -1903,20 +1867,27 @@ var GLTFMeshParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
1903
1867
|
if (accessor.min && accessor.max) {
|
|
1904
1868
|
min.copyFromArray(accessor.min);
|
|
1905
1869
|
max.copyFromArray(accessor.max);
|
|
1870
|
+
if (keepMeshData) {
|
|
1871
|
+
var stride1 = vertices.length / attributeCount;
|
|
1872
|
+
for(var j = 0; j < attributeCount; j++){
|
|
1873
|
+
var offset = j * stride1;
|
|
1874
|
+
positions[j] = new engineMath.Vector3(vertices[offset], vertices[offset + 1], vertices[offset + 2]);
|
|
1875
|
+
}
|
|
1876
|
+
}
|
|
1906
1877
|
} else {
|
|
1907
1878
|
var position = GLTFMeshParser._tempVector3;
|
|
1908
1879
|
min.set(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
|
|
1909
1880
|
max.set(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
|
|
1910
|
-
var
|
|
1911
|
-
for(var
|
|
1912
|
-
var
|
|
1913
|
-
position.copyFromArray(vertices,
|
|
1881
|
+
var stride2 = vertices.length / attributeCount;
|
|
1882
|
+
for(var j1 = 0; j1 < attributeCount; j1++){
|
|
1883
|
+
var offset1 = j1 * stride2;
|
|
1884
|
+
position.copyFromArray(vertices, offset1);
|
|
1914
1885
|
engineMath.Vector3.min(min, position, min);
|
|
1915
1886
|
engineMath.Vector3.max(max, position, max);
|
|
1916
1887
|
}
|
|
1917
1888
|
}
|
|
1918
1889
|
if (accessor.normalized) {
|
|
1919
|
-
var scaleFactor =
|
|
1890
|
+
var scaleFactor = GLTFUtils.getNormalizedComponentScale(accessor.componentType);
|
|
1920
1891
|
min.scale(scaleFactor);
|
|
1921
1892
|
max.scale(scaleFactor);
|
|
1922
1893
|
}
|
|
@@ -1926,7 +1897,7 @@ var GLTFMeshParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
1926
1897
|
// Indices
|
|
1927
1898
|
if (indices !== undefined) {
|
|
1928
1899
|
var indexAccessor = gltf.accessors[indices];
|
|
1929
|
-
var accessorBuffer1 =
|
|
1900
|
+
var accessorBuffer1 = GLTFUtils.getAccessorBuffer(context, gltf.bufferViews, indexAccessor);
|
|
1930
1901
|
mesh.setIndices(accessorBuffer1.data);
|
|
1931
1902
|
mesh.addSubMesh(0, indexAccessor.count, mode);
|
|
1932
1903
|
meshRestoreInfo.indexBuffer = accessorBuffer1.restoreInfo;
|
|
@@ -1936,6 +1907,8 @@ var GLTFMeshParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
1936
1907
|
// BlendShapes
|
|
1937
1908
|
targets && GLTFMeshParser._createBlendShape(mesh, meshRestoreInfo, gltfMesh, targets, getBlendShapeData);
|
|
1938
1909
|
mesh.uploadData(!keepMeshData);
|
|
1910
|
+
//@ts-ignore
|
|
1911
|
+
mesh._positions = positions;
|
|
1939
1912
|
return Promise.resolve(mesh);
|
|
1940
1913
|
};
|
|
1941
1914
|
/**
|
|
@@ -1947,9 +1920,9 @@ var GLTFMeshParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
1947
1920
|
var deltaPosBufferInfo = getBlendShapeData("POSITION", i);
|
|
1948
1921
|
var deltaNorBufferInfo = getBlendShapeData("NORMAL", i);
|
|
1949
1922
|
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) ?
|
|
1923
|
+
var deltaPositions = deltaPosBufferInfo.data ? GLTFUtils.floatBufferToVector3Array(deltaPosBufferInfo.data) : null;
|
|
1924
|
+
var deltaNormals = (deltaNorBufferInfo == null ? void 0 : deltaNorBufferInfo.data) ? GLTFUtils.floatBufferToVector3Array(deltaNorBufferInfo == null ? void 0 : deltaNorBufferInfo.data) : null;
|
|
1925
|
+
var deltaTangents = (deltaTanBufferInfo == null ? void 0 : deltaTanBufferInfo.data) ? GLTFUtils.floatBufferToVector3Array(deltaTanBufferInfo == null ? void 0 : deltaTanBufferInfo.data) : null;
|
|
1953
1926
|
var blendShape = new engineCore.BlendShape(name);
|
|
1954
1927
|
blendShape.addFrame(1.0, deltaPositions, deltaNormals, deltaTangents);
|
|
1955
1928
|
mesh.addBlendShape(blendShape);
|
|
@@ -1958,7 +1931,9 @@ var GLTFMeshParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
1958
1931
|
};
|
|
1959
1932
|
return GLTFMeshParser;
|
|
1960
1933
|
}(GLTFParser);
|
|
1961
|
-
|
|
1934
|
+
(function() {
|
|
1935
|
+
GLTFMeshParser._tempVector3 = new engineMath.Vector3();
|
|
1936
|
+
})();
|
|
1962
1937
|
|
|
1963
1938
|
var GLTFSceneParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
1964
1939
|
_inherits(GLTFSceneParser, GLTFParser1);
|
|
@@ -2110,7 +2085,7 @@ var GLTFSkinParser = /*#__PURE__*/ function(GLTFParser) {
|
|
|
2110
2085
|
skin.inverseBindMatrices.length = jointCount;
|
|
2111
2086
|
// parse IBM
|
|
2112
2087
|
var accessor = glTF.accessors[inverseBindMatrices];
|
|
2113
|
-
var buffer =
|
|
2088
|
+
var buffer = GLTFUtils.getAccessorBuffer(context, glTF.bufferViews, accessor).data;
|
|
2114
2089
|
for(var i1 = 0; i1 < jointCount; i1++){
|
|
2115
2090
|
var inverseBindMatrix = new engineMath.Matrix();
|
|
2116
2091
|
inverseBindMatrix.copyFromArray(buffer, i1 * 16);
|
|
@@ -2145,7 +2120,7 @@ var GLTFSkinParser = /*#__PURE__*/ function(GLTFParser) {
|
|
|
2145
2120
|
};
|
|
2146
2121
|
_proto._findSkeletonRootBone = function _findSkeletonRootBone(joints, entities) {
|
|
2147
2122
|
var paths = {};
|
|
2148
|
-
for(var _iterator =
|
|
2123
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(joints), _step; !(_step = _iterator()).done;){
|
|
2149
2124
|
var index = _step.value;
|
|
2150
2125
|
var path = new Array();
|
|
2151
2126
|
var entity = entities[index];
|
|
@@ -2195,7 +2170,7 @@ var GLTFTextureParser = /*#__PURE__*/ function(GLTFParser) {
|
|
|
2195
2170
|
var ext = uri.substring(index1 + 1);
|
|
2196
2171
|
var type = ext.startsWith("ktx") ? engineCore.AssetType.KTX : engineCore.AssetType.Texture2D;
|
|
2197
2172
|
return engine.resourceManager.load({
|
|
2198
|
-
url:
|
|
2173
|
+
url: engineCore.Utils.resolveAbsoluteUrl(url, uri),
|
|
2199
2174
|
type: type
|
|
2200
2175
|
}).then(function(texture) {
|
|
2201
2176
|
if (!texture.name) {
|
|
@@ -2210,7 +2185,7 @@ var GLTFTextureParser = /*#__PURE__*/ function(GLTFParser) {
|
|
|
2210
2185
|
var bufferView = glTF.bufferViews[bufferViewIndex];
|
|
2211
2186
|
var buffer = buffers[bufferView.buffer];
|
|
2212
2187
|
var imageBuffer = new Uint8Array(buffer, bufferView.byteOffset, bufferView.byteLength);
|
|
2213
|
-
return
|
|
2188
|
+
return GLTFUtils.loadImageBuffer(imageBuffer, mimeType).then(function(image) {
|
|
2214
2189
|
var texture = new engineCore.Texture2D(engine, image.width, image.height);
|
|
2215
2190
|
texture.setImageSource(image);
|
|
2216
2191
|
texture.generateMipmaps();
|
|
@@ -2250,8 +2225,10 @@ var GLTFTextureParser = /*#__PURE__*/ function(GLTFParser) {
|
|
|
2250
2225
|
};
|
|
2251
2226
|
return GLTFTextureParser;
|
|
2252
2227
|
}(GLTFParser);
|
|
2253
|
-
|
|
2254
|
-
|
|
2228
|
+
(function() {
|
|
2229
|
+
var _obj;
|
|
2230
|
+
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);
|
|
2231
|
+
})();
|
|
2255
2232
|
|
|
2256
2233
|
var GLTFValidator = /*#__PURE__*/ function(GLTFParser1) {
|
|
2257
2234
|
_inherits(GLTFValidator, GLTFParser1);
|
|
@@ -2333,9 +2310,11 @@ var GLTFValidator = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
2333
2310
|
};
|
|
2334
2311
|
return GLTFPipeline;
|
|
2335
2312
|
}();
|
|
2336
|
-
|
|
2313
|
+
(function() {
|
|
2314
|
+
/**
|
|
2337
2315
|
* Default pipeline.
|
|
2338
2316
|
*/ GLTFPipeline.defaultPipeline = new GLTFPipeline(GLTFBufferParser, GLTFValidator, GLTFTextureParser, GLTFMaterialParser, GLTFMeshParser, GLTFEntityParser, GLTFSkinParser, GLTFAnimationParser, GLTFSceneParser);
|
|
2317
|
+
})();
|
|
2339
2318
|
|
|
2340
2319
|
/**
|
|
2341
2320
|
* Product after glTF parser, usually, `defaultSceneRoot` is only needed to use.
|
|
@@ -2348,9 +2327,7 @@ var GLTFValidator = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
2348
2327
|
return _this;
|
|
2349
2328
|
}
|
|
2350
2329
|
var _proto = GLTFResource.prototype;
|
|
2351
|
-
|
|
2352
|
-
* @override
|
|
2353
|
-
*/ _proto._onDestroy = function _onDestroy() {
|
|
2330
|
+
_proto._onDestroy = function _onDestroy() {
|
|
2354
2331
|
EngineObject.prototype._onDestroy.call(this);
|
|
2355
2332
|
this.defaultSceneRoot.destroy();
|
|
2356
2333
|
this.textures = null;
|
|
@@ -2373,9 +2350,7 @@ var GLTFLoader = /*#__PURE__*/ function(Loader) {
|
|
|
2373
2350
|
return Loader.apply(this, arguments);
|
|
2374
2351
|
}
|
|
2375
2352
|
var _proto = GLTFLoader.prototype;
|
|
2376
|
-
|
|
2377
|
-
* @override
|
|
2378
|
-
*/ _proto.load = function load(item, resourceManager) {
|
|
2353
|
+
_proto.load = function load(item, resourceManager) {
|
|
2379
2354
|
var url = item.url;
|
|
2380
2355
|
var params = item.params;
|
|
2381
2356
|
var context = new GLTFParserContext(url);
|
|
@@ -2388,7 +2363,7 @@ var GLTFLoader = /*#__PURE__*/ function(Loader) {
|
|
|
2388
2363
|
context.keepMeshData = (_params_keepMeshData = params == null ? void 0 : params.keepMeshData) != null ? _params_keepMeshData : false;
|
|
2389
2364
|
masterPromiseInfo.onCancel(function() {
|
|
2390
2365
|
var chainPromises = context.chainPromises;
|
|
2391
|
-
for(var _iterator =
|
|
2366
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(chainPromises), _step; !(_step = _iterator()).done;){
|
|
2392
2367
|
var promise = _step.value;
|
|
2393
2368
|
promise.cancel();
|
|
2394
2369
|
}
|
|
@@ -2491,7 +2466,7 @@ var HDRLoader = (_HDRLoader = /*#__PURE__*/ function(Loader) {
|
|
|
2491
2466
|
return textureArray;
|
|
2492
2467
|
};
|
|
2493
2468
|
HDRLoader1._calcProjectionSpherical = function _calcProjectionSpherical(vDir, pixels, inputWidth, inputHeight) {
|
|
2494
|
-
var theta = Math.atan2(vDir.z,
|
|
2469
|
+
var theta = Math.atan2(vDir.z, vDir.x);
|
|
2495
2470
|
var phi = Math.acos(vDir.y);
|
|
2496
2471
|
while(theta < -PI){
|
|
2497
2472
|
theta += 2 * PI;
|
|
@@ -2652,37 +2627,75 @@ var HDRLoader = (_HDRLoader = /*#__PURE__*/ function(Loader) {
|
|
|
2652
2627
|
color.a *= M;
|
|
2653
2628
|
};
|
|
2654
2629
|
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
|
-
|
|
2630
|
+
}(engineCore.Loader), function() {
|
|
2631
|
+
_HDRLoader._rightBottomBack = new engineMath.Vector3(1.0, -1.0, -1.0);
|
|
2632
|
+
}(), function() {
|
|
2633
|
+
_HDRLoader._rightBottomFront = new engineMath.Vector3(1.0, -1.0, 1.0);
|
|
2634
|
+
}(), function() {
|
|
2635
|
+
_HDRLoader._rightUpBack = new engineMath.Vector3(1.0, 1.0, -1.0);
|
|
2636
|
+
}(), function() {
|
|
2637
|
+
_HDRLoader._rightUpFront = new engineMath.Vector3(1.0, 1.0, 1.0);
|
|
2638
|
+
}(), function() {
|
|
2639
|
+
_HDRLoader._leftBottomBack = new engineMath.Vector3(-1.0, -1.0, -1.0);
|
|
2640
|
+
}(), function() {
|
|
2641
|
+
_HDRLoader._leftBottomFront = new engineMath.Vector3(-1.0, -1.0, 1.0);
|
|
2642
|
+
}(), function() {
|
|
2643
|
+
_HDRLoader._leftUpBack = new engineMath.Vector3(-1.0, 1.0, -1.0);
|
|
2644
|
+
}(), function() {
|
|
2645
|
+
_HDRLoader._leftUpFront = new engineMath.Vector3(-1.0, 1.0, 1.0);
|
|
2646
|
+
}(), function() {
|
|
2647
|
+
_HDRLoader._faceRight = [
|
|
2648
|
+
_HDRLoader._rightBottomBack,
|
|
2649
|
+
_HDRLoader._rightBottomFront,
|
|
2650
|
+
_HDRLoader._rightUpBack,
|
|
2651
|
+
_HDRLoader._rightUpFront
|
|
2652
|
+
];
|
|
2653
|
+
}(), function() {
|
|
2654
|
+
_HDRLoader._faceLeft = [
|
|
2655
|
+
_HDRLoader._leftBottomFront,
|
|
2656
|
+
_HDRLoader._leftBottomBack,
|
|
2657
|
+
_HDRLoader._leftUpFront,
|
|
2658
|
+
_HDRLoader._leftUpBack
|
|
2659
|
+
];
|
|
2660
|
+
}(), function() {
|
|
2661
|
+
_HDRLoader._faceUp = [
|
|
2662
|
+
_HDRLoader._leftBottomFront,
|
|
2663
|
+
_HDRLoader._rightBottomFront,
|
|
2664
|
+
_HDRLoader._leftBottomBack,
|
|
2665
|
+
_HDRLoader._rightBottomBack
|
|
2666
|
+
];
|
|
2667
|
+
}(), function() {
|
|
2668
|
+
_HDRLoader._faceBottom = [
|
|
2669
|
+
_HDRLoader._leftUpBack,
|
|
2670
|
+
_HDRLoader._rightUpBack,
|
|
2671
|
+
_HDRLoader._leftUpFront,
|
|
2672
|
+
_HDRLoader._rightUpFront
|
|
2673
|
+
];
|
|
2674
|
+
}(), function() {
|
|
2675
|
+
_HDRLoader._faceFront = [
|
|
2676
|
+
_HDRLoader._leftBottomBack,
|
|
2677
|
+
_HDRLoader._rightBottomBack,
|
|
2678
|
+
_HDRLoader._leftUpBack,
|
|
2679
|
+
_HDRLoader._rightUpBack
|
|
2680
|
+
];
|
|
2681
|
+
}(), function() {
|
|
2682
|
+
_HDRLoader._faceBack = [
|
|
2683
|
+
_HDRLoader._rightBottomFront,
|
|
2684
|
+
_HDRLoader._leftBottomFront,
|
|
2685
|
+
_HDRLoader._rightUpFront,
|
|
2686
|
+
_HDRLoader._leftUpFront
|
|
2687
|
+
];
|
|
2688
|
+
}(), function() {
|
|
2689
|
+
_HDRLoader._tempVector3 = new engineMath.Vector3();
|
|
2690
|
+
}(), function() {
|
|
2691
|
+
_HDRLoader._temp2Vector3 = new engineMath.Vector3();
|
|
2692
|
+
}(), function() {
|
|
2693
|
+
_HDRLoader._temp3Vector3 = new engineMath.Vector3();
|
|
2694
|
+
}(), function() {
|
|
2695
|
+
_HDRLoader._temp4Vector3 = new engineMath.Vector3();
|
|
2696
|
+
}(), function() {
|
|
2697
|
+
_HDRLoader._temp5Vector3 = new engineMath.Vector3();
|
|
2698
|
+
}(), _HDRLoader);
|
|
2686
2699
|
HDRLoader = __decorate([
|
|
2687
2700
|
engineCore.resourceLoader(engineCore.AssetType.HDR, [
|
|
2688
2701
|
"hdr"
|
|
@@ -3052,19 +3065,21 @@ MaterialLoader = __decorate([
|
|
|
3052
3065
|
], MaterialLoader);
|
|
3053
3066
|
|
|
3054
3067
|
function _defineProperties(target, props) {
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
|
|
3068
|
+
for (var i = 0; i < props.length; i++) {
|
|
3069
|
+
var descriptor = props[i];
|
|
3070
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
3071
|
+
descriptor.configurable = true;
|
|
3072
|
+
|
|
3073
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
3074
|
+
|
|
3075
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
3076
|
+
}
|
|
3062
3077
|
}
|
|
3078
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
3079
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
3080
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
3063
3081
|
|
|
3064
|
-
|
|
3065
|
-
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
3066
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
3067
|
-
return Constructor;
|
|
3082
|
+
return Constructor;
|
|
3068
3083
|
}
|
|
3069
3084
|
|
|
3070
3085
|
var BufferReader = /*#__PURE__*/ function() {
|
|
@@ -3134,7 +3149,7 @@ var BufferReader = /*#__PURE__*/ function() {
|
|
|
3134
3149
|
var strByteLength = this.nextUint16();
|
|
3135
3150
|
var uint8Array = new Uint8Array(this.buffer, this._offset, strByteLength);
|
|
3136
3151
|
this._offset += strByteLength;
|
|
3137
|
-
return
|
|
3152
|
+
return engineCore.Utils.decodeText(uint8Array);
|
|
3138
3153
|
};
|
|
3139
3154
|
/**
|
|
3140
3155
|
* image data 放在最后
|
|
@@ -3173,7 +3188,7 @@ var BufferReader = /*#__PURE__*/ function() {
|
|
|
3173
3188
|
if (byteLength < maxByteLength) this._offset++;
|
|
3174
3189
|
return new Uint8Array(this._dataView.buffer, this._dataView.byteOffset + byteOffset, byteLength);
|
|
3175
3190
|
};
|
|
3176
|
-
|
|
3191
|
+
_create_class(BufferReader, [
|
|
3177
3192
|
{
|
|
3178
3193
|
key: "offset",
|
|
3179
3194
|
get: function get() {
|
|
@@ -3183,12 +3198,14 @@ var BufferReader = /*#__PURE__*/ function() {
|
|
|
3183
3198
|
]);
|
|
3184
3199
|
return BufferReader;
|
|
3185
3200
|
}();
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3201
|
+
(function() {
|
|
3202
|
+
BufferReader.imageMapping = {
|
|
3203
|
+
0: "image/png",
|
|
3204
|
+
1: "image/jpg",
|
|
3205
|
+
2: "image/webp",
|
|
3206
|
+
3: "ktx"
|
|
3207
|
+
};
|
|
3208
|
+
})();
|
|
3192
3209
|
|
|
3193
3210
|
var decoderMap = {};
|
|
3194
3211
|
/**
|
|
@@ -3217,8 +3234,8 @@ var FileHeader = /*#__PURE__*/ function() {
|
|
|
3217
3234
|
var typeUint8Array = new Uint8Array(arrayBuffer, 7, typeLen);
|
|
3218
3235
|
var nameLen = dataView.getUint16(7 + typeLen, true);
|
|
3219
3236
|
var nameUint8Array = new Uint8Array(arrayBuffer, 9 + typeLen, nameLen);
|
|
3220
|
-
var name =
|
|
3221
|
-
var type =
|
|
3237
|
+
var name = engineCore.Utils.decodeText(nameUint8Array);
|
|
3238
|
+
var type = engineCore.Utils.decodeText(typeUint8Array);
|
|
3222
3239
|
var header = new FileHeader();
|
|
3223
3240
|
header.totalLength = totalLen;
|
|
3224
3241
|
header.name = name;
|
|
@@ -3227,7 +3244,7 @@ var FileHeader = /*#__PURE__*/ function() {
|
|
|
3227
3244
|
header.headerLength = nameUint8Array.byteLength + typeUint8Array.byteLength + 9;
|
|
3228
3245
|
return header;
|
|
3229
3246
|
};
|
|
3230
|
-
|
|
3247
|
+
_create_class(FileHeader, [
|
|
3231
3248
|
{
|
|
3232
3249
|
key: "dataLength",
|
|
3233
3250
|
get: function get() {
|
|
@@ -3446,38 +3463,36 @@ exports.Texture2DDecoder = __decorate([
|
|
|
3446
3463
|
decoder("Texture2D")
|
|
3447
3464
|
], exports.Texture2DDecoder);
|
|
3448
3465
|
|
|
3449
|
-
function
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
|
|
3453
|
-
|
|
3454
|
-
try {
|
|
3455
|
-
Date.prototype.toString.call(Reflect.construct(Date, [], function () { }));
|
|
3456
|
-
return true;
|
|
3457
|
-
} catch (e) {
|
|
3458
|
-
return false;
|
|
3459
|
-
}
|
|
3460
|
-
}
|
|
3466
|
+
function _is_native_reflect_construct() {
|
|
3467
|
+
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
3468
|
+
if (Reflect.construct.sham) return false;
|
|
3469
|
+
if (typeof Proxy === "function") return true;
|
|
3461
3470
|
|
|
3462
|
-
|
|
3463
|
-
|
|
3464
|
-
construct = Reflect.construct;
|
|
3465
|
-
} else {
|
|
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
|
-
}
|
|
3471
|
+
try {
|
|
3472
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
3475
3473
|
|
|
3476
|
-
|
|
3474
|
+
return true;
|
|
3475
|
+
} catch (e) {
|
|
3476
|
+
return false;
|
|
3477
|
+
}
|
|
3477
3478
|
}
|
|
3478
3479
|
|
|
3479
3480
|
function _construct(Parent, args, Class) {
|
|
3480
|
-
|
|
3481
|
+
if (_is_native_reflect_construct()) _construct = Reflect.construct;
|
|
3482
|
+
else {
|
|
3483
|
+
_construct = function construct(Parent, args, Class) {
|
|
3484
|
+
var a = [null];
|
|
3485
|
+
a.push.apply(a, args);
|
|
3486
|
+
var Constructor = Function.bind.apply(Parent, a);
|
|
3487
|
+
var instance = new Constructor();
|
|
3488
|
+
|
|
3489
|
+
if (Class) _set_prototype_of(instance, Class.prototype);
|
|
3490
|
+
|
|
3491
|
+
return instance;
|
|
3492
|
+
};
|
|
3493
|
+
}
|
|
3494
|
+
|
|
3495
|
+
return _construct.apply(null, arguments);
|
|
3481
3496
|
}
|
|
3482
3497
|
|
|
3483
3498
|
var ReflectionParser = /*#__PURE__*/ function() {
|
|
@@ -3592,7 +3607,9 @@ var ReflectionParser = /*#__PURE__*/ function() {
|
|
|
3592
3607
|
};
|
|
3593
3608
|
return ReflectionParser;
|
|
3594
3609
|
}();
|
|
3595
|
-
|
|
3610
|
+
(function() {
|
|
3611
|
+
ReflectionParser.customParseComponentHandles = new Map();
|
|
3612
|
+
})();
|
|
3596
3613
|
|
|
3597
3614
|
var PrefabParser = /*#__PURE__*/ function() {
|
|
3598
3615
|
function PrefabParser() {}
|
|
@@ -3846,7 +3863,7 @@ var SceneParserContext = /*#__PURE__*/ function() {
|
|
|
3846
3863
|
};
|
|
3847
3864
|
_proto._organizeEntities = function _organizeEntities() {
|
|
3848
3865
|
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 =
|
|
3866
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(rootIds), _step; !(_step = _iterator()).done;){
|
|
3850
3867
|
var rootId = _step.value;
|
|
3851
3868
|
PrefabParser.parseChildren(entityConfigMap, entityMap, rootId);
|
|
3852
3869
|
}
|
|
@@ -4010,7 +4027,7 @@ var SourceFontLoader = /*#__PURE__*/ function(Loader) {
|
|
|
4010
4027
|
});
|
|
4011
4028
|
};
|
|
4012
4029
|
_proto._registerFont = function _registerFont(fontName, fontUrl) {
|
|
4013
|
-
return
|
|
4030
|
+
return _async_to_generator(function() {
|
|
4014
4031
|
var fontFace;
|
|
4015
4032
|
return __generator(this, function(_state) {
|
|
4016
4033
|
switch(_state.label){
|
|
@@ -4047,6 +4064,7 @@ var SpriteAtlasLoader = /*#__PURE__*/ function(Loader) {
|
|
|
4047
4064
|
_this = Loader.apply(this, arguments) || this;
|
|
4048
4065
|
_this._tempRect = new engineMath.Rect();
|
|
4049
4066
|
_this._tempVec2 = new engineMath.Vector2();
|
|
4067
|
+
_this._tempVec4 = new engineMath.Vector4();
|
|
4050
4068
|
return _this;
|
|
4051
4069
|
}
|
|
4052
4070
|
var _proto = SpriteAtlasLoader.prototype;
|
|
@@ -4064,57 +4082,65 @@ var SpriteAtlasLoader = /*#__PURE__*/ function(Loader) {
|
|
|
4064
4082
|
}));
|
|
4065
4083
|
chainPromises.push(configPromise);
|
|
4066
4084
|
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);
|
|
4085
|
+
var _loop = function(i) {
|
|
4086
|
+
var atlasItem = atlasItems[i];
|
|
4087
|
+
if (atlasItem.img) {
|
|
4088
|
+
chainPromises.push(resourceManager.load({
|
|
4089
|
+
url: atlasItem.img,
|
|
4090
|
+
type: engineCore.AssetType.Texture2D,
|
|
4091
|
+
params: {
|
|
4092
|
+
format: format,
|
|
4093
|
+
mipmap: mipmap
|
|
4102
4094
|
}
|
|
4103
|
-
|
|
4095
|
+
}).then(function(texture) {
|
|
4096
|
+
anisoLevel && (texture.anisoLevel = anisoLevel);
|
|
4097
|
+
filterMode !== undefined && (texture.filterMode = filterMode);
|
|
4098
|
+
wrapModeU !== undefined && (texture.wrapModeU = wrapModeU);
|
|
4099
|
+
wrapModeV !== undefined && (texture.wrapModeV = wrapModeV);
|
|
4100
|
+
for(var i = 0; i < atlasItem.sprites.length; i++){
|
|
4104
4101
|
// @ts-ignore
|
|
4105
|
-
|
|
4102
|
+
spriteAtlas._addSprite(_this._makeSprite(engine, atlasItem.sprites[i], texture));
|
|
4106
4103
|
}
|
|
4104
|
+
}).catch(reject));
|
|
4105
|
+
} else {
|
|
4106
|
+
for(var i1 = 0; i1 < atlasItem.sprites.length; i1++){
|
|
4107
4107
|
// @ts-ignore
|
|
4108
|
-
spriteAtlas._addSprite(
|
|
4108
|
+
spriteAtlas._addSprite(_this._makeSprite(engine, atlasItem.sprites[i1]));
|
|
4109
4109
|
}
|
|
4110
4110
|
}
|
|
4111
|
+
};
|
|
4112
|
+
var atlasItems = atlasData.atlasItems, mipmap = atlasData.mipmap, anisoLevel = atlasData.anisoLevel, filterMode = atlasData.filterMode, wrapModeU = atlasData.wrapModeU, wrapModeV = atlasData.wrapModeV, format = atlasData.format;
|
|
4113
|
+
var atlasItemsLen = atlasItems ? atlasItems.length : 0;
|
|
4114
|
+
var engine = resourceManager.engine;
|
|
4115
|
+
var spriteAtlas = new engineCore.SpriteAtlas(engine);
|
|
4116
|
+
if (atlasItemsLen < 0) {
|
|
4111
4117
|
resolve(spriteAtlas);
|
|
4112
|
-
|
|
4113
|
-
|
|
4114
|
-
|
|
4115
|
-
|
|
4118
|
+
return;
|
|
4119
|
+
}
|
|
4120
|
+
chainPromises.length = 0;
|
|
4121
|
+
for(var i = 0; i < atlasItems.length; i++)_loop(i);
|
|
4122
|
+
engineCore.AssetPromise.all(chainPromises).then(function() {
|
|
4123
|
+
resolve(spriteAtlas);
|
|
4124
|
+
}).catch(reject);
|
|
4125
|
+
}).catch(reject);
|
|
4116
4126
|
});
|
|
4117
4127
|
};
|
|
4128
|
+
_proto._makeSprite = function _makeSprite(engine, config, texture) {
|
|
4129
|
+
// Generate a SpriteAtlas object.
|
|
4130
|
+
var region = config.region, atlasRegionOffset = config.atlasRegionOffset, atlasRegion = config.atlasRegion, pivot = config.pivot, border = config.border;
|
|
4131
|
+
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);
|
|
4132
|
+
if (texture) {
|
|
4133
|
+
var invW = 1 / texture.width;
|
|
4134
|
+
var invH = 1 / texture.height;
|
|
4135
|
+
sprite.atlasRegion.set(atlasRegion.x * invW, atlasRegion.y * invH, atlasRegion.w * invW, atlasRegion.h * invH);
|
|
4136
|
+
if (atlasRegionOffset) {
|
|
4137
|
+
var offsetLeft = atlasRegionOffset.x, offsetTop = atlasRegionOffset.y, offsetRight = atlasRegionOffset.z, offsetBottom = atlasRegionOffset.w;
|
|
4138
|
+
sprite.atlasRegionOffset.set(offsetLeft * invW, offsetTop * invH, offsetRight * invW, offsetBottom * invH);
|
|
4139
|
+
}
|
|
4140
|
+
config.atlasRotated && (sprite.atlasRotated = true);
|
|
4141
|
+
}
|
|
4142
|
+
return sprite;
|
|
4143
|
+
};
|
|
4118
4144
|
return SpriteAtlasLoader;
|
|
4119
4145
|
}(engineCore.Loader);
|
|
4120
4146
|
SpriteAtlasLoader = __decorate([
|
|
@@ -4135,13 +4161,19 @@ var SpriteLoader = /*#__PURE__*/ function(Loader) {
|
|
|
4135
4161
|
_this.request(item.url, _extends({}, item, {
|
|
4136
4162
|
type: "json"
|
|
4137
4163
|
})).then(function(data) {
|
|
4138
|
-
|
|
4139
|
-
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
|
|
4143
|
-
|
|
4144
|
-
|
|
4164
|
+
if (data.belongToAtlas) {
|
|
4165
|
+
resourceManager// @ts-ignore
|
|
4166
|
+
.getResourceByRef(data.belongToAtlas).then(function(atlas) {
|
|
4167
|
+
resolve(atlas.getSprite(data.fullPath));
|
|
4168
|
+
}).catch(reject);
|
|
4169
|
+
} else if (data.texture) {
|
|
4170
|
+
resourceManager// @ts-ignore
|
|
4171
|
+
.getResourceByRef(data.texture).then(function(texture) {
|
|
4172
|
+
resolve(new engineCore.Sprite(resourceManager.engine, texture, data.region, data.pivot, data.border));
|
|
4173
|
+
}).catch(reject);
|
|
4174
|
+
} else {
|
|
4175
|
+
resolve(new engineCore.Sprite(resourceManager.engine, null, data.region, data.pivot, data.border));
|
|
4176
|
+
}
|
|
4145
4177
|
}).catch(reject);
|
|
4146
4178
|
});
|
|
4147
4179
|
};
|
|
@@ -4165,9 +4197,7 @@ SpriteLoader = __decorate([
|
|
|
4165
4197
|
return _this;
|
|
4166
4198
|
}
|
|
4167
4199
|
var _proto = Texture2DContentRestorer.prototype;
|
|
4168
|
-
|
|
4169
|
-
* @override
|
|
4170
|
-
*/ _proto.restoreContent = function restoreContent() {
|
|
4200
|
+
_proto.restoreContent = function restoreContent() {
|
|
4171
4201
|
var _this = this;
|
|
4172
4202
|
return engineCore.request(this.url, this.requestConfig).then(function(image) {
|
|
4173
4203
|
var resource = _this.resource;
|
|
@@ -4185,9 +4215,7 @@ var Texture2DLoader = /*#__PURE__*/ function(Loader) {
|
|
|
4185
4215
|
return Loader.apply(this, arguments);
|
|
4186
4216
|
}
|
|
4187
4217
|
var _proto = Texture2DLoader.prototype;
|
|
4188
|
-
|
|
4189
|
-
* @override
|
|
4190
|
-
*/ _proto.load = function load(item, resourceManager) {
|
|
4218
|
+
_proto.load = function load(item, resourceManager) {
|
|
4191
4219
|
var _this = this;
|
|
4192
4220
|
return new engineCore.AssetPromise(function(resolve, reject) {
|
|
4193
4221
|
var url = item.url;
|
|
@@ -4233,9 +4261,7 @@ Texture2DLoader = __decorate([
|
|
|
4233
4261
|
return _this;
|
|
4234
4262
|
}
|
|
4235
4263
|
var _proto = TextureCubeContentRestorer.prototype;
|
|
4236
|
-
|
|
4237
|
-
* @override
|
|
4238
|
-
*/ _proto.restoreContent = function restoreContent() {
|
|
4264
|
+
_proto.restoreContent = function restoreContent() {
|
|
4239
4265
|
var _this = this;
|
|
4240
4266
|
return new engineCore.AssetPromise(function(resolve, reject) {
|
|
4241
4267
|
Promise.all(_this.urls.map(function(url) {
|
|
@@ -4261,9 +4287,7 @@ var TextureCubeLoader = /*#__PURE__*/ function(Loader) {
|
|
|
4261
4287
|
return Loader.apply(this, arguments);
|
|
4262
4288
|
}
|
|
4263
4289
|
var _proto = TextureCubeLoader.prototype;
|
|
4264
|
-
|
|
4265
|
-
* @override
|
|
4266
|
-
*/ _proto.load = function load(item, resourceManager) {
|
|
4290
|
+
_proto.load = function load(item, resourceManager) {
|
|
4267
4291
|
var _this = this;
|
|
4268
4292
|
return new engineCore.AssetPromise(function(resolve, reject) {
|
|
4269
4293
|
var urls = item.urls;
|
|
@@ -4366,7 +4390,7 @@ var SceneLoader = /*#__PURE__*/ function(Loader) {
|
|
|
4366
4390
|
backgroundPromise = resourceManager.getResourceByRef(background.sky).then(function(light) {
|
|
4367
4391
|
var sky = scene.background.sky;
|
|
4368
4392
|
var skyMaterial = new engineCore.SkyBoxMaterial(engine);
|
|
4369
|
-
skyMaterial.
|
|
4393
|
+
skyMaterial.texture = light.specularTexture;
|
|
4370
4394
|
skyMaterial.textureDecodeRGBM = true;
|
|
4371
4395
|
sky.material = skyMaterial;
|
|
4372
4396
|
sky.mesh = engineCore.PrimitiveMesh.createCuboid(engine, 1, 1, 1);
|
|
@@ -4407,7 +4431,7 @@ SceneLoader = __decorate([
|
|
|
4407
4431
|
"prefab"
|
|
4408
4432
|
], true)
|
|
4409
4433
|
], SceneLoader);
|
|
4410
|
-
ReflectionParser.registerCustomParseComponent("TextRenderer", /*#__PURE__*/
|
|
4434
|
+
ReflectionParser.registerCustomParseComponent("TextRenderer", /*#__PURE__*/ _async_to_generator(function(instance, item, engine) {
|
|
4411
4435
|
var props;
|
|
4412
4436
|
return __generator(this, function(_state) {
|
|
4413
4437
|
props = item.props;
|
|
@@ -4429,16 +4453,12 @@ var KHR_draco_mesh_compression = (_KHR_draco_mesh_compression = /*#__PURE__*/ fu
|
|
|
4429
4453
|
return GLTFExtensionParser.apply(this, arguments);
|
|
4430
4454
|
}
|
|
4431
4455
|
var _proto = KHR_draco_mesh_compression1.prototype;
|
|
4432
|
-
|
|
4433
|
-
* @override
|
|
4434
|
-
*/ _proto.initialize = function initialize() {
|
|
4456
|
+
_proto.initialize = function initialize() {
|
|
4435
4457
|
if (!KHR_draco_mesh_compression._decoder) {
|
|
4436
4458
|
KHR_draco_mesh_compression._decoder = new engineDraco.DRACODecoder();
|
|
4437
4459
|
}
|
|
4438
4460
|
};
|
|
4439
|
-
|
|
4440
|
-
* @override
|
|
4441
|
-
*/ _proto.createAndParse = function createAndParse(context, schema, glTFPrimitive, glTFMesh) {
|
|
4461
|
+
_proto.createAndParse = function createAndParse(context, schema, glTFPrimitive, glTFMesh) {
|
|
4442
4462
|
var _this = this;
|
|
4443
4463
|
var glTF = context.glTF, buffers = context.buffers, engine = context.glTFResource.engine;
|
|
4444
4464
|
var bufferViews = glTF.bufferViews, accessors = glTF.accessors;
|
|
@@ -4451,18 +4471,18 @@ var KHR_draco_mesh_compression = (_KHR_draco_mesh_compression = /*#__PURE__*/ fu
|
|
|
4451
4471
|
for(var attributeName1 in glTFPrimitive.attributes){
|
|
4452
4472
|
if (gltfAttributeMap[attributeName1] !== undefined) {
|
|
4453
4473
|
var accessorDef = accessors[glTFPrimitive.attributes[attributeName1]];
|
|
4454
|
-
attributeTypeMap[attributeName1] =
|
|
4474
|
+
attributeTypeMap[attributeName1] = GLTFUtils.getComponentType(accessorDef.componentType).name;
|
|
4455
4475
|
}
|
|
4456
4476
|
}
|
|
4457
4477
|
var indexAccessor = accessors[glTFPrimitive.indices];
|
|
4458
|
-
var indexType =
|
|
4478
|
+
var indexType = GLTFUtils.getComponentType(indexAccessor.componentType).name;
|
|
4459
4479
|
var taskConfig = {
|
|
4460
4480
|
attributeIDs: attributeMap,
|
|
4461
4481
|
attributeTypes: attributeTypeMap,
|
|
4462
4482
|
useUniqueIDs: true,
|
|
4463
4483
|
indexType: indexType
|
|
4464
4484
|
};
|
|
4465
|
-
var buffer =
|
|
4485
|
+
var buffer = GLTFUtils.getBufferViewData(bufferViews[bufferViewIndex], buffers);
|
|
4466
4486
|
return KHR_draco_mesh_compression._decoder.decode(buffer, taskConfig).then(function(decodedGeometry) {
|
|
4467
4487
|
var mesh = new engineCore.ModelMesh(engine, glTFMesh.name);
|
|
4468
4488
|
return _this._parseMeshFromGLTFPrimitiveDraco(mesh, glTFMesh, glTFPrimitive, glTF, function(attributeSemantic) {
|
|
@@ -4485,7 +4505,7 @@ var KHR_draco_mesh_compression = (_KHR_draco_mesh_compression = /*#__PURE__*/ fu
|
|
|
4485
4505
|
var accessors = gltf.accessors;
|
|
4486
4506
|
var accessor = accessors[attributes["POSITION"]];
|
|
4487
4507
|
var positionBuffer = getVertexBufferData("POSITION");
|
|
4488
|
-
var positions =
|
|
4508
|
+
var positions = GLTFUtils.floatBufferToVector3Array(positionBuffer);
|
|
4489
4509
|
mesh.setPositions(positions);
|
|
4490
4510
|
var bounds = mesh.bounds;
|
|
4491
4511
|
vertexCount = accessor.count;
|
|
@@ -4512,55 +4532,55 @@ var KHR_draco_mesh_compression = (_KHR_draco_mesh_compression = /*#__PURE__*/ fu
|
|
|
4512
4532
|
var bufferData = getVertexBufferData(attributeSemantic);
|
|
4513
4533
|
switch(attributeSemantic){
|
|
4514
4534
|
case "NORMAL":
|
|
4515
|
-
var normals =
|
|
4535
|
+
var normals = GLTFUtils.floatBufferToVector3Array(bufferData);
|
|
4516
4536
|
mesh.setNormals(normals);
|
|
4517
4537
|
break;
|
|
4518
4538
|
case "TEXCOORD_0":
|
|
4519
|
-
var texturecoords =
|
|
4539
|
+
var texturecoords = GLTFUtils.floatBufferToVector2Array(bufferData);
|
|
4520
4540
|
mesh.setUVs(texturecoords, 0);
|
|
4521
4541
|
break;
|
|
4522
4542
|
case "TEXCOORD_1":
|
|
4523
|
-
var texturecoords1 =
|
|
4543
|
+
var texturecoords1 = GLTFUtils.floatBufferToVector2Array(bufferData);
|
|
4524
4544
|
mesh.setUVs(texturecoords1, 1);
|
|
4525
4545
|
break;
|
|
4526
4546
|
case "TEXCOORD_2":
|
|
4527
|
-
var texturecoords2 =
|
|
4547
|
+
var texturecoords2 = GLTFUtils.floatBufferToVector2Array(bufferData);
|
|
4528
4548
|
mesh.setUVs(texturecoords2, 2);
|
|
4529
4549
|
break;
|
|
4530
4550
|
case "TEXCOORD_3":
|
|
4531
|
-
var texturecoords3 =
|
|
4551
|
+
var texturecoords3 = GLTFUtils.floatBufferToVector2Array(bufferData);
|
|
4532
4552
|
mesh.setUVs(texturecoords3, 3);
|
|
4533
4553
|
break;
|
|
4534
4554
|
case "TEXCOORD_4":
|
|
4535
|
-
var texturecoords4 =
|
|
4555
|
+
var texturecoords4 = GLTFUtils.floatBufferToVector2Array(bufferData);
|
|
4536
4556
|
mesh.setUVs(texturecoords4, 4);
|
|
4537
4557
|
break;
|
|
4538
4558
|
case "TEXCOORD_5":
|
|
4539
|
-
var texturecoords5 =
|
|
4559
|
+
var texturecoords5 = GLTFUtils.floatBufferToVector2Array(bufferData);
|
|
4540
4560
|
mesh.setUVs(texturecoords5, 5);
|
|
4541
4561
|
break;
|
|
4542
4562
|
case "TEXCOORD_6":
|
|
4543
|
-
var texturecoords6 =
|
|
4563
|
+
var texturecoords6 = GLTFUtils.floatBufferToVector2Array(bufferData);
|
|
4544
4564
|
mesh.setUVs(texturecoords6, 6);
|
|
4545
4565
|
break;
|
|
4546
4566
|
case "TEXCOORD_7":
|
|
4547
|
-
var texturecoords7 =
|
|
4567
|
+
var texturecoords7 = GLTFUtils.floatBufferToVector2Array(bufferData);
|
|
4548
4568
|
mesh.setUVs(texturecoords7, 7);
|
|
4549
4569
|
break;
|
|
4550
4570
|
case "COLOR_0":
|
|
4551
|
-
var colors =
|
|
4571
|
+
var colors = GLTFUtils.floatBufferToColorArray(bufferData, accessors[attributes["COLOR_0"]].type === AccessorType.VEC3);
|
|
4552
4572
|
mesh.setColors(colors);
|
|
4553
4573
|
break;
|
|
4554
4574
|
case "TANGENT":
|
|
4555
|
-
var tangents =
|
|
4575
|
+
var tangents = GLTFUtils.floatBufferToVector4Array(bufferData);
|
|
4556
4576
|
mesh.setTangents(tangents);
|
|
4557
4577
|
break;
|
|
4558
4578
|
case "JOINTS_0":
|
|
4559
|
-
var joints =
|
|
4579
|
+
var joints = GLTFUtils.floatBufferToVector4Array(bufferData);
|
|
4560
4580
|
mesh.setBoneIndices(joints);
|
|
4561
4581
|
break;
|
|
4562
4582
|
case "WEIGHTS_0":
|
|
4563
|
-
var weights =
|
|
4583
|
+
var weights = GLTFUtils.floatBufferToVector4Array(bufferData);
|
|
4564
4584
|
mesh.setBoneWeights(weights);
|
|
4565
4585
|
break;
|
|
4566
4586
|
}
|
|
@@ -4580,7 +4600,9 @@ var KHR_draco_mesh_compression = (_KHR_draco_mesh_compression = /*#__PURE__*/ fu
|
|
|
4580
4600
|
return Promise.resolve(mesh);
|
|
4581
4601
|
};
|
|
4582
4602
|
return KHR_draco_mesh_compression1;
|
|
4583
|
-
}(GLTFExtensionParser),
|
|
4603
|
+
}(GLTFExtensionParser), function() {
|
|
4604
|
+
_KHR_draco_mesh_compression._tempVector3 = new engineMath.Vector3();
|
|
4605
|
+
}(), _KHR_draco_mesh_compression);
|
|
4584
4606
|
KHR_draco_mesh_compression = __decorate([
|
|
4585
4607
|
registerGLTFExtension("KHR_draco_mesh_compression", exports.GLTFExtensionMode.CreateAndParse)
|
|
4586
4608
|
], KHR_draco_mesh_compression);
|
|
@@ -4591,9 +4613,7 @@ var KHR_lights_punctual = /*#__PURE__*/ function(GLTFExtensionParser) {
|
|
|
4591
4613
|
return GLTFExtensionParser.apply(this, arguments);
|
|
4592
4614
|
}
|
|
4593
4615
|
var _proto = KHR_lights_punctual.prototype;
|
|
4594
|
-
|
|
4595
|
-
* @override
|
|
4596
|
-
*/ _proto.additiveParse = function additiveParse(context, entity, extensionSchema) {
|
|
4616
|
+
_proto.additiveParse = function additiveParse(context, entity, extensionSchema) {
|
|
4597
4617
|
var lightsSchema = context.glTF.extensions.KHR_lights_punctual.lights;
|
|
4598
4618
|
var lightSchema = lightsSchema[extensionSchema.light];
|
|
4599
4619
|
var color = lightSchema.color, _lightSchema_intensity = lightSchema.intensity, intensity = _lightSchema_intensity === void 0 ? 1 : _lightSchema_intensity, type = lightSchema.type, range = lightSchema.range, spot = lightSchema.spot;
|
|
@@ -4633,9 +4653,7 @@ var KHR_materials_clearcoat = /*#__PURE__*/ function(GLTFExtensionParser) {
|
|
|
4633
4653
|
return GLTFExtensionParser.apply(this, arguments);
|
|
4634
4654
|
}
|
|
4635
4655
|
var _proto = KHR_materials_clearcoat.prototype;
|
|
4636
|
-
|
|
4637
|
-
* @override
|
|
4638
|
-
*/ _proto.additiveParse = function additiveParse(context, material, schema) {
|
|
4656
|
+
_proto.additiveParse = function additiveParse(context, material, schema) {
|
|
4639
4657
|
var textures = context.glTFResource.textures;
|
|
4640
4658
|
var _schema_clearcoatFactor = schema.clearcoatFactor, clearcoatFactor = _schema_clearcoatFactor === void 0 ? 0 : _schema_clearcoatFactor, clearcoatTexture = schema.clearcoatTexture, _schema_clearcoatRoughnessFactor = schema.clearcoatRoughnessFactor, clearcoatRoughnessFactor = _schema_clearcoatRoughnessFactor === void 0 ? 0 : _schema_clearcoatRoughnessFactor, clearcoatRoughnessTexture = schema.clearcoatRoughnessTexture, clearcoatNormalTexture = schema.clearcoatNormalTexture;
|
|
4641
4659
|
material.clearCoat = clearcoatFactor;
|
|
@@ -4665,9 +4683,7 @@ var KHR_materials_pbrSpecularGlossiness = /*#__PURE__*/ function(GLTFExtensionPa
|
|
|
4665
4683
|
return GLTFExtensionParser.apply(this, arguments);
|
|
4666
4684
|
}
|
|
4667
4685
|
var _proto = KHR_materials_pbrSpecularGlossiness.prototype;
|
|
4668
|
-
|
|
4669
|
-
* @override
|
|
4670
|
-
*/ _proto.createAndParse = function createAndParse(context, schema, ownerSchema) {
|
|
4686
|
+
_proto.createAndParse = function createAndParse(context, schema, ownerSchema) {
|
|
4671
4687
|
var _context_glTFResource = context.glTFResource, engine = _context_glTFResource.engine, textures = _context_glTFResource.textures;
|
|
4672
4688
|
var material = new engineCore.PBRSpecularMaterial(engine);
|
|
4673
4689
|
var diffuseFactor = schema.diffuseFactor, diffuseTexture = schema.diffuseTexture, specularFactor = schema.specularFactor, glossinessFactor = schema.glossinessFactor, specularGlossinessTexture = schema.specularGlossinessTexture;
|
|
@@ -4704,9 +4720,7 @@ var KHR_materials_unlit = /*#__PURE__*/ function(GLTFExtensionParser) {
|
|
|
4704
4720
|
return GLTFExtensionParser.apply(this, arguments);
|
|
4705
4721
|
}
|
|
4706
4722
|
var _proto = KHR_materials_unlit.prototype;
|
|
4707
|
-
|
|
4708
|
-
* @override
|
|
4709
|
-
*/ _proto.createAndParse = function createAndParse(context, _, ownerSchema) {
|
|
4723
|
+
_proto.createAndParse = function createAndParse(context, _, ownerSchema) {
|
|
4710
4724
|
var engine = context.glTFResource.engine;
|
|
4711
4725
|
var material = new engineCore.UnlitMaterial(engine);
|
|
4712
4726
|
material.name = ownerSchema.name;
|
|
@@ -4736,9 +4750,7 @@ var KHR_texture_transform = /*#__PURE__*/ function(GLTFExtensionParser) {
|
|
|
4736
4750
|
return GLTFExtensionParser.apply(this, arguments);
|
|
4737
4751
|
}
|
|
4738
4752
|
var _proto = KHR_texture_transform.prototype;
|
|
4739
|
-
|
|
4740
|
-
* @override
|
|
4741
|
-
*/ _proto.additiveParse = function additiveParse(context, material, schema) {
|
|
4753
|
+
_proto.additiveParse = function additiveParse(context, material, schema) {
|
|
4742
4754
|
var offset = schema.offset, rotation = schema.rotation, scale = schema.scale, texCoord = schema.texCoord;
|
|
4743
4755
|
if (offset) {
|
|
4744
4756
|
material.tilingOffset.z = offset[0];
|
|
@@ -4761,34 +4773,30 @@ KHR_texture_transform = __decorate([
|
|
|
4761
4773
|
registerGLTFExtension("KHR_texture_transform", exports.GLTFExtensionMode.AdditiveParse)
|
|
4762
4774
|
], KHR_texture_transform);
|
|
4763
4775
|
|
|
4764
|
-
var
|
|
4765
|
-
_inherits(
|
|
4766
|
-
function
|
|
4776
|
+
var GALACEAN_materials_remap = /*#__PURE__*/ function(GLTFExtensionParser) {
|
|
4777
|
+
_inherits(GALACEAN_materials_remap, GLTFExtensionParser);
|
|
4778
|
+
function GALACEAN_materials_remap() {
|
|
4767
4779
|
return GLTFExtensionParser.apply(this, arguments);
|
|
4768
4780
|
}
|
|
4769
|
-
var _proto =
|
|
4770
|
-
|
|
4771
|
-
* @override
|
|
4772
|
-
*/ _proto.createAndParse = function createAndParse(context, schema) {
|
|
4781
|
+
var _proto = GALACEAN_materials_remap.prototype;
|
|
4782
|
+
_proto.createAndParse = function createAndParse(context, schema) {
|
|
4773
4783
|
var engine = context.glTFResource.engine;
|
|
4774
4784
|
// @ts-ignore
|
|
4775
4785
|
return engine.resourceManager.getResourceByRef(schema);
|
|
4776
4786
|
};
|
|
4777
|
-
return
|
|
4787
|
+
return GALACEAN_materials_remap;
|
|
4778
4788
|
}(GLTFExtensionParser);
|
|
4779
|
-
|
|
4780
|
-
registerGLTFExtension("
|
|
4781
|
-
],
|
|
4789
|
+
GALACEAN_materials_remap = __decorate([
|
|
4790
|
+
registerGLTFExtension("GALACEAN_materials_remap", exports.GLTFExtensionMode.CreateAndParse)
|
|
4791
|
+
], GALACEAN_materials_remap);
|
|
4782
4792
|
|
|
4783
|
-
var
|
|
4784
|
-
_inherits(
|
|
4785
|
-
function
|
|
4793
|
+
var GALACEAN_animation_event = /*#__PURE__*/ function(GLTFExtensionParser) {
|
|
4794
|
+
_inherits(GALACEAN_animation_event, GLTFExtensionParser);
|
|
4795
|
+
function GALACEAN_animation_event() {
|
|
4786
4796
|
return GLTFExtensionParser.apply(this, arguments);
|
|
4787
4797
|
}
|
|
4788
|
-
var _proto =
|
|
4789
|
-
|
|
4790
|
-
* @override
|
|
4791
|
-
*/ _proto.additiveParse = function additiveParse(context, animationClip, schema) {
|
|
4798
|
+
var _proto = GALACEAN_animation_event.prototype;
|
|
4799
|
+
_proto.additiveParse = function additiveParse(context, animationClip, schema) {
|
|
4792
4800
|
context.glTFResource.engine;
|
|
4793
4801
|
var events = schema.events;
|
|
4794
4802
|
events.map(function(eventData) {
|
|
@@ -4799,11 +4807,11 @@ var OASIS_animation_event = /*#__PURE__*/ function(GLTFExtensionParser) {
|
|
|
4799
4807
|
animationClip.addEvent(event);
|
|
4800
4808
|
});
|
|
4801
4809
|
};
|
|
4802
|
-
return
|
|
4810
|
+
return GALACEAN_animation_event;
|
|
4803
4811
|
}(GLTFExtensionParser);
|
|
4804
|
-
|
|
4805
|
-
registerGLTFExtension("
|
|
4806
|
-
],
|
|
4812
|
+
GALACEAN_animation_event = __decorate([
|
|
4813
|
+
registerGLTFExtension("GALACEAN_animation_event", exports.GLTFExtensionMode.AdditiveParse)
|
|
4814
|
+
], GALACEAN_animation_event);
|
|
4807
4815
|
|
|
4808
4816
|
exports.ComponentMap = ComponentMap;
|
|
4809
4817
|
exports.GLTFAnimationParser = GLTFAnimationParser;
|
|
@@ -4819,7 +4827,7 @@ exports.GLTFResource = GLTFResource;
|
|
|
4819
4827
|
exports.GLTFSceneParser = GLTFSceneParser;
|
|
4820
4828
|
exports.GLTFSkinParser = GLTFSkinParser;
|
|
4821
4829
|
exports.GLTFTextureParser = GLTFTextureParser;
|
|
4822
|
-
exports.
|
|
4830
|
+
exports.GLTFUtils = GLTFUtils;
|
|
4823
4831
|
exports.GLTFValidator = GLTFValidator;
|
|
4824
4832
|
exports.PrefabParser = PrefabParser;
|
|
4825
4833
|
exports.ReflectionParser = ReflectionParser;
|