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