@galacean/engine-loader 0.9.0 → 1.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.js +1449 -1050
- package/dist/main.js.map +1 -1
- package/dist/miniprogram.js +1470 -1071
- package/dist/module.js +1436 -1052
- package/dist/module.js.map +1 -1
- package/package.json +5 -5
- package/types/AnimationClipLoader.d.ts +1 -0
- package/types/GLTFContentRestorer.d.ts +85 -0
- package/types/GLTFLoader.d.ts +6 -0
- package/types/Texture2DContentRestorer.d.ts +14 -0
- package/types/TextureCubeContentRestorer.d.ts +14 -0
- package/types/gltf/GLTFPipeline.d.ts +23 -0
- package/types/gltf/GLTFResource.d.ts +7 -11
- package/types/gltf/{Schema.d.ts → GLTFSchema.d.ts} +2 -0
- package/types/gltf/{GLTFUtil.d.ts → GLTFUtils.d.ts} +9 -15
- package/types/gltf/extensions/GALACEAN_animation_event.d.ts +1 -0
- package/types/gltf/extensions/GLTFExtensionParser.d.ts +52 -0
- package/types/gltf/extensions/{Schema.d.ts → GLTFExtensionSchema.d.ts} +9 -2
- package/types/gltf/extensions/KHR_materials_variants.d.ts +6 -1
- package/types/gltf/extensions/index.d.ts +4 -1
- package/types/gltf/index.d.ts +6 -0
- package/types/gltf/parser/GLTFAnimationParser.d.ts +12 -0
- package/types/gltf/parser/GLTFBufferParser.d.ts +7 -0
- package/types/gltf/parser/GLTFEntityParser.d.ts +9 -0
- package/types/gltf/parser/GLTFMaterialParser.d.ts +15 -0
- package/types/gltf/parser/GLTFMeshParser.d.ts +19 -0
- package/types/gltf/parser/GLTFParser.d.ts +63 -0
- package/types/gltf/parser/{ParserContext.d.ts → GLTFParserContext.d.ts} +6 -4
- package/types/gltf/parser/GLTFSceneParser.d.ts +11 -0
- package/types/gltf/parser/GLTFSkinParser.d.ts +6 -0
- package/types/gltf/parser/GLTFTextureParser.d.ts +8 -0
- package/types/gltf/parser/GLTFValidator.d.ts +6 -0
- package/types/gltf/parser/index.d.ts +11 -0
- package/types/index.d.ts +2 -2
- package/types/resource-deserialize/resources/prefab/PrefabDesign.d.ts +4 -4
- package/types/gltf/GLTFParser.d.ts +0 -9
- package/types/gltf/extensions/ExtensionParser.d.ts +0 -8
- package/types/gltf/parser/AnimationParser.d.ts +0 -7
- package/types/gltf/parser/BufferParser.d.ts +0 -7
- package/types/gltf/parser/EntityParser.d.ts +0 -9
- package/types/gltf/parser/MaterialParser.d.ts +0 -8
- package/types/gltf/parser/MeshParser.d.ts +0 -13
- package/types/gltf/parser/Parser.d.ts +0 -21
- package/types/gltf/parser/SceneParser.d.ts +0 -11
- package/types/gltf/parser/SkinParser.d.ts +0 -6
- package/types/gltf/parser/TextureParser.d.ts +0 -8
- package/types/gltf/parser/Validator.d.ts +0 -5
package/dist/miniprogram.js
CHANGED
|
@@ -5,8 +5,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var miniprogram = require('@galacean/engine-core/dist/miniprogram');
|
|
6
6
|
var engineMiniprogramAdapter = require('@galacean/engine-miniprogram-adapter');
|
|
7
7
|
var miniprogram$1 = require('@galacean/engine-math/dist/miniprogram');
|
|
8
|
-
var miniprogram$2 = require('@galacean/engine-
|
|
9
|
-
var miniprogram$3 = require('@galacean/engine-
|
|
8
|
+
var miniprogram$2 = require('@galacean/engine-rhi-webgl/dist/miniprogram');
|
|
9
|
+
var miniprogram$3 = require('@galacean/engine-draco/dist/miniprogram');
|
|
10
10
|
|
|
11
11
|
function _extends() {
|
|
12
12
|
_extends = Object.assign || function assign(target) {
|
|
@@ -91,10 +91,10 @@ function __generator(thisArg, body) {
|
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
var AnimatorControllerLoader = /*#__PURE__*/ function(
|
|
95
|
-
_inherits(AnimatorControllerLoader,
|
|
94
|
+
var AnimatorControllerLoader = /*#__PURE__*/ function(Loader1) {
|
|
95
|
+
_inherits(AnimatorControllerLoader, Loader1);
|
|
96
96
|
function AnimatorControllerLoader() {
|
|
97
|
-
return
|
|
97
|
+
return Loader1.apply(this, arguments);
|
|
98
98
|
}
|
|
99
99
|
var _proto = AnimatorControllerLoader.prototype;
|
|
100
100
|
_proto.load = function load(item, resourceManager) {
|
|
@@ -115,13 +115,16 @@ var AnimatorControllerLoader = /*#__PURE__*/ function(Loader) {
|
|
|
115
115
|
var states = stateMachineData.states;
|
|
116
116
|
var stateMachine = layer.stateMachine = new miniprogram.AnimatorStateMachine();
|
|
117
117
|
states.forEach(function(stateData, stateIndex) {
|
|
118
|
-
var name = stateData.name, speed = stateData.speed, wrapMode = stateData.wrapMode, clipStartNormalizedTime = stateData.clipStartNormalizedTime, clipEndNormalizedTime = stateData.clipEndNormalizedTime, isDefaultState = stateData.isDefaultState, clipData = stateData.clip;
|
|
118
|
+
var name = stateData.name, speed = stateData.speed, wrapMode = stateData.wrapMode, clipStartNormalizedTime = stateData.clipStartNormalizedTime, clipEndNormalizedTime = stateData.clipEndNormalizedTime, isDefaultState = stateData.isDefaultState, clipData = stateData.clip, scripts = stateData.scripts;
|
|
119
119
|
var state = stateMachine.addState(name);
|
|
120
120
|
isDefaultState && (stateMachine.defaultState = state);
|
|
121
121
|
state.speed = speed;
|
|
122
122
|
state.wrapMode = wrapMode;
|
|
123
123
|
state.clipStartTime = clipStartNormalizedTime;
|
|
124
124
|
state.clipEndTime = clipEndNormalizedTime;
|
|
125
|
+
scripts == null ? void 0 : scripts.forEach(function(script) {
|
|
126
|
+
state.addStateMachineScript(miniprogram.Loader.getClass(script));
|
|
127
|
+
});
|
|
125
128
|
if (clipData) {
|
|
126
129
|
promises.push(new Promise(function(resolve) {
|
|
127
130
|
//@ts-ignore
|
|
@@ -342,52 +345,196 @@ FontLoader = __decorate([
|
|
|
342
345
|
], false)
|
|
343
346
|
], FontLoader);
|
|
344
347
|
|
|
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;
|
|
354
|
+
}
|
|
355
|
+
|
|
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);
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
|
|
368
|
+
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
369
|
+
|
|
370
|
+
if (it) return (it = it.call(o)).next.bind(it);
|
|
371
|
+
// Fallback for engines without symbol support
|
|
372
|
+
if (Array.isArray(o) || (it = _unsupported_iterable_to_array(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
373
|
+
if (it) o = it;
|
|
374
|
+
|
|
375
|
+
var i = 0;
|
|
376
|
+
|
|
377
|
+
return function() {
|
|
378
|
+
if (i >= o.length) return { done: true };
|
|
379
|
+
|
|
380
|
+
return { done: false, value: o[i++] };
|
|
381
|
+
};
|
|
382
|
+
}
|
|
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.");
|
|
385
|
+
}
|
|
386
|
+
|
|
345
387
|
/**
|
|
346
388
|
* @internal
|
|
347
|
-
*/ var
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
this.masterPromiseInfo = new PromiseInfo();
|
|
358
|
-
this.promiseMap = {};
|
|
359
|
-
var promiseMap = this.promiseMap;
|
|
360
|
-
promiseMap["" + url + "?q=textures"] = this._initPromiseInfo(this.texturesPromiseInfo);
|
|
361
|
-
promiseMap["" + url + "?q=materials"] = this._initPromiseInfo(this.materialsPromiseInfo);
|
|
362
|
-
promiseMap["" + url + "?q=meshes"] = this._initPromiseInfo(this.meshesPromiseInfo);
|
|
363
|
-
promiseMap["" + url + "?q=animations"] = this._initPromiseInfo(this.animationClipsPromiseInfo);
|
|
364
|
-
promiseMap["" + url + "?q=defaultSceneRoot"] = this._initPromiseInfo(this.defaultSceneRootPromiseInfo);
|
|
365
|
-
promiseMap["" + url] = this._initPromiseInfo(this.masterPromiseInfo);
|
|
389
|
+
*/ var GLTFContentRestorer = /*#__PURE__*/ function(ContentRestorer) {
|
|
390
|
+
_inherits(GLTFContentRestorer, ContentRestorer);
|
|
391
|
+
function GLTFContentRestorer() {
|
|
392
|
+
var _this;
|
|
393
|
+
_this = ContentRestorer.apply(this, arguments) || this;
|
|
394
|
+
_this.bufferRequests = [];
|
|
395
|
+
_this.glbBufferSlices = [];
|
|
396
|
+
_this.bufferTextures = [];
|
|
397
|
+
_this.meshes = [];
|
|
398
|
+
return _this;
|
|
366
399
|
}
|
|
367
|
-
var _proto =
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
400
|
+
var _proto = GLTFContentRestorer.prototype;
|
|
401
|
+
/**
|
|
402
|
+
* @override
|
|
403
|
+
*/ _proto.restoreContent = function restoreContent() {
|
|
404
|
+
var _this = this;
|
|
405
|
+
return new miniprogram.AssetPromise(function(resolve, reject) {
|
|
406
|
+
Promise.all(_this.bufferRequests.map(function(bufferRequestInfo) {
|
|
407
|
+
return miniprogram.request(bufferRequestInfo.url, bufferRequestInfo.config);
|
|
408
|
+
})).then(function(buffers) {
|
|
409
|
+
// Buffer parse
|
|
410
|
+
if (_this.isGLB) {
|
|
411
|
+
var glbBufferSlice = _this.glbBufferSlices;
|
|
412
|
+
var bigBuffer = buffers[0];
|
|
413
|
+
var bufferCount = glbBufferSlice.length;
|
|
414
|
+
buffers.length = bufferCount;
|
|
415
|
+
for(var i = 0; i < bufferCount; i++){
|
|
416
|
+
var slice = glbBufferSlice[i];
|
|
417
|
+
buffers[i] = bigBuffer.slice(slice.x, slice.x + slice.y);
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
// Restore texture
|
|
421
|
+
miniprogram.AssetPromise.all(_this.bufferTextures.map(function(textureRestoreInfo) {
|
|
422
|
+
var bufferView = textureRestoreInfo.bufferView;
|
|
423
|
+
var buffer = buffers[bufferView.buffer];
|
|
424
|
+
var _bufferView_byteOffset;
|
|
425
|
+
var bufferData = new Uint8Array(buffer, (_bufferView_byteOffset = bufferView.byteOffset) != null ? _bufferView_byteOffset : 0, bufferView.byteLength);
|
|
426
|
+
return GLTFUtils.loadImageBuffer(bufferData, textureRestoreInfo.mimeType).then(function(image) {
|
|
427
|
+
textureRestoreInfo.texture.setImageSource(image);
|
|
428
|
+
textureRestoreInfo.texture.generateMipmaps();
|
|
429
|
+
});
|
|
430
|
+
})).then(function() {
|
|
431
|
+
// Restore mesh
|
|
432
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(_this.meshes), _step; !(_step = _iterator()).done;){
|
|
433
|
+
var meshInfo = _step.value;
|
|
434
|
+
var mesh = meshInfo.mesh;
|
|
435
|
+
for(var _iterator1 = _create_for_of_iterator_helper_loose(meshInfo.vertexBuffers), _step1; !(_step1 = _iterator1()).done;){
|
|
436
|
+
var bufferRestoreInfo = _step1.value;
|
|
437
|
+
var vertexData = _this._getBufferData(buffers, bufferRestoreInfo.data);
|
|
438
|
+
bufferRestoreInfo.buffer.setData(vertexData);
|
|
439
|
+
}
|
|
440
|
+
if (meshInfo.indexBuffer) {
|
|
441
|
+
var indexData = _this._getBufferData(buffers, meshInfo.indexBuffer);
|
|
442
|
+
mesh.setIndices(indexData);
|
|
443
|
+
}
|
|
444
|
+
for(var _iterator2 = _create_for_of_iterator_helper_loose(meshInfo.blendShapes), _step2; !(_step2 = _iterator2()).done;){
|
|
445
|
+
var restoreInfo = _step2.value;
|
|
446
|
+
var frame = restoreInfo.blendShape.frames[0];
|
|
447
|
+
var positionData = _this._getBufferData(buffers, restoreInfo.position);
|
|
448
|
+
frame.deltaPositions = GLTFUtils.floatBufferToVector3Array(positionData);
|
|
449
|
+
if (restoreInfo.normal) {
|
|
450
|
+
var normalData = _this._getBufferData(buffers, restoreInfo.normal);
|
|
451
|
+
frame.deltaNormals = GLTFUtils.floatBufferToVector3Array(normalData);
|
|
452
|
+
}
|
|
453
|
+
if (restoreInfo.tangent) {
|
|
454
|
+
var tangentData = _this._getBufferData(buffers, restoreInfo.tangent);
|
|
455
|
+
frame.deltaTangents = GLTFUtils.floatBufferToVector3Array(tangentData);
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
mesh.uploadData(true);
|
|
459
|
+
}
|
|
460
|
+
resolve(_this.resource);
|
|
461
|
+
}).catch(reject);
|
|
462
|
+
}).catch(reject);
|
|
374
463
|
});
|
|
375
|
-
promiseInfo.promise = promise;
|
|
376
|
-
return promise;
|
|
377
464
|
};
|
|
378
|
-
|
|
379
|
-
|
|
465
|
+
_proto._getBufferData = function _getBufferData(buffers, restoreInfo) {
|
|
466
|
+
var main = restoreInfo.main;
|
|
467
|
+
var buffer = buffers[main.bufferIndex];
|
|
468
|
+
var data = new main.TypedArray(buffer, main.byteOffset, main.length);
|
|
469
|
+
var sparseCount = restoreInfo.sparseCount;
|
|
470
|
+
if (sparseCount) {
|
|
471
|
+
var sparseIndex = restoreInfo.sparseIndices;
|
|
472
|
+
var sparseIndexBuffer = buffers[sparseIndex.bufferIndex];
|
|
473
|
+
var sparseIndexData = new sparseIndex.TypedArray(sparseIndexBuffer, sparseIndex.byteOffset, sparseIndex.length);
|
|
474
|
+
var sparseValue = restoreInfo.sparseValues;
|
|
475
|
+
var sparseValueBuffer = buffers[sparseValue.bufferIndex];
|
|
476
|
+
var sparseValueData = new sparseValue.TypedArray(sparseValueBuffer, sparseValue.byteOffset, sparseValue.length);
|
|
477
|
+
var typeSize = restoreInfo.typeSize;
|
|
478
|
+
for(var i = 0; i < sparseCount; i++){
|
|
479
|
+
var replaceIndex = sparseIndexData[i];
|
|
480
|
+
for(var j = 0; j < typeSize; j++){
|
|
481
|
+
data[replaceIndex * typeSize + j] = sparseValueData[i * typeSize + j];
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
return data;
|
|
486
|
+
};
|
|
487
|
+
return GLTFContentRestorer;
|
|
488
|
+
}(miniprogram.ContentRestorer);
|
|
380
489
|
/**
|
|
381
490
|
* @internal
|
|
382
|
-
*/ var
|
|
491
|
+
*/ var BufferRequestInfo = function BufferRequestInfo(url, config) {
|
|
492
|
+
this.url = url;
|
|
493
|
+
this.config = config;
|
|
494
|
+
};
|
|
495
|
+
/**
|
|
496
|
+
* @internal
|
|
497
|
+
*/ var BufferTextureRestoreInfo = function BufferTextureRestoreInfo(texture, bufferView, mimeType) {
|
|
498
|
+
this.texture = texture;
|
|
499
|
+
this.bufferView = bufferView;
|
|
500
|
+
this.mimeType = mimeType;
|
|
501
|
+
};
|
|
502
|
+
/**
|
|
503
|
+
* @internal
|
|
504
|
+
*/ var ModelMeshRestoreInfo = function ModelMeshRestoreInfo() {
|
|
505
|
+
this.vertexBuffers = [];
|
|
506
|
+
this.blendShapes = [];
|
|
507
|
+
};
|
|
508
|
+
/**
|
|
509
|
+
* @internal
|
|
510
|
+
*/ var BufferRestoreInfo = function BufferRestoreInfo(buffer, data) {
|
|
511
|
+
this.buffer = buffer;
|
|
383
512
|
this.data = data;
|
|
384
|
-
this.interleaved = interleaved;
|
|
385
|
-
this.stride = stride;
|
|
386
|
-
this.vertexBindingInfos = {};
|
|
387
513
|
};
|
|
388
514
|
/**
|
|
389
515
|
* @internal
|
|
390
|
-
*/ var
|
|
516
|
+
*/ var BufferDataRestoreInfo = function BufferDataRestoreInfo(main, typeSize, sparseCount, sparseIndices, sparseValues) {
|
|
517
|
+
this.main = main;
|
|
518
|
+
this.typeSize = typeSize;
|
|
519
|
+
this.sparseCount = sparseCount;
|
|
520
|
+
this.sparseIndices = sparseIndices;
|
|
521
|
+
this.sparseValues = sparseValues;
|
|
522
|
+
};
|
|
523
|
+
/**
|
|
524
|
+
* @internal
|
|
525
|
+
*/ var RestoreDataAccessor = function RestoreDataAccessor(bufferIndex, TypedArray, byteOffset, length) {
|
|
526
|
+
this.bufferIndex = bufferIndex;
|
|
527
|
+
this.TypedArray = TypedArray;
|
|
528
|
+
this.byteOffset = byteOffset;
|
|
529
|
+
this.length = length;
|
|
530
|
+
};
|
|
531
|
+
/**
|
|
532
|
+
* @internal
|
|
533
|
+
*/ var BlendShapeRestoreInfo = function BlendShapeRestoreInfo(blendShape, position, normal, tangent) {
|
|
534
|
+
this.blendShape = blendShape;
|
|
535
|
+
this.position = position;
|
|
536
|
+
this.normal = normal;
|
|
537
|
+
this.tangent = tangent;
|
|
391
538
|
};
|
|
392
539
|
|
|
393
540
|
/**
|
|
@@ -539,9 +686,57 @@ var TextureWrapMode;
|
|
|
539
686
|
|
|
540
687
|
/**
|
|
541
688
|
* @internal
|
|
542
|
-
*/ var
|
|
543
|
-
function
|
|
544
|
-
|
|
689
|
+
*/ var GLTFParserContext = /*#__PURE__*/ function() {
|
|
690
|
+
function GLTFParserContext(url) {
|
|
691
|
+
this.hasSkinned = false;
|
|
692
|
+
this.chainPromises = [];
|
|
693
|
+
this.accessorBufferCache = {};
|
|
694
|
+
this.texturesPromiseInfo = new PromiseInfo();
|
|
695
|
+
this.materialsPromiseInfo = new PromiseInfo();
|
|
696
|
+
this.meshesPromiseInfo = new PromiseInfo();
|
|
697
|
+
this.animationClipsPromiseInfo = new PromiseInfo();
|
|
698
|
+
this.defaultSceneRootPromiseInfo = new PromiseInfo();
|
|
699
|
+
this.masterPromiseInfo = new PromiseInfo();
|
|
700
|
+
this.promiseMap = {};
|
|
701
|
+
var promiseMap = this.promiseMap;
|
|
702
|
+
promiseMap["" + url + "?q=textures"] = this._initPromiseInfo(this.texturesPromiseInfo);
|
|
703
|
+
promiseMap["" + url + "?q=materials"] = this._initPromiseInfo(this.materialsPromiseInfo);
|
|
704
|
+
promiseMap["" + url + "?q=meshes"] = this._initPromiseInfo(this.meshesPromiseInfo);
|
|
705
|
+
promiseMap["" + url + "?q=animations"] = this._initPromiseInfo(this.animationClipsPromiseInfo);
|
|
706
|
+
promiseMap["" + url + "?q=defaultSceneRoot"] = this._initPromiseInfo(this.defaultSceneRootPromiseInfo);
|
|
707
|
+
promiseMap["" + url] = this._initPromiseInfo(this.masterPromiseInfo);
|
|
708
|
+
}
|
|
709
|
+
var _proto = GLTFParserContext.prototype;
|
|
710
|
+
_proto._initPromiseInfo = function _initPromiseInfo(promiseInfo) {
|
|
711
|
+
var promise = new miniprogram.AssetPromise(function(resolve, reject, setProgress, onCancel) {
|
|
712
|
+
promiseInfo.resolve = resolve;
|
|
713
|
+
promiseInfo.reject = reject;
|
|
714
|
+
promiseInfo.setProgress = setProgress;
|
|
715
|
+
promiseInfo.onCancel = onCancel;
|
|
716
|
+
});
|
|
717
|
+
promiseInfo.promise = promise;
|
|
718
|
+
return promise;
|
|
719
|
+
};
|
|
720
|
+
return GLTFParserContext;
|
|
721
|
+
}();
|
|
722
|
+
/**
|
|
723
|
+
* @internal
|
|
724
|
+
*/ var BufferInfo = function BufferInfo(data, interleaved, stride) {
|
|
725
|
+
this.data = data;
|
|
726
|
+
this.interleaved = interleaved;
|
|
727
|
+
this.stride = stride;
|
|
728
|
+
this.vertexBindingInfos = {};
|
|
729
|
+
};
|
|
730
|
+
/**
|
|
731
|
+
* @internal
|
|
732
|
+
*/ var PromiseInfo = function PromiseInfo() {
|
|
733
|
+
};
|
|
734
|
+
|
|
735
|
+
/**
|
|
736
|
+
* @internal
|
|
737
|
+
*/ var GLTFUtils = /*#__PURE__*/ function() {
|
|
738
|
+
function GLTFUtils() {}
|
|
739
|
+
GLTFUtils.floatBufferToVector2Array = function floatBufferToVector2Array(buffer) {
|
|
545
740
|
var bufferLen = buffer.length;
|
|
546
741
|
var array = new Array(bufferLen / 2);
|
|
547
742
|
for(var i = 0; i < bufferLen; i += 2){
|
|
@@ -549,7 +744,7 @@ var TextureWrapMode;
|
|
|
549
744
|
}
|
|
550
745
|
return array;
|
|
551
746
|
};
|
|
552
|
-
|
|
747
|
+
GLTFUtils.floatBufferToVector3Array = function floatBufferToVector3Array(buffer) {
|
|
553
748
|
var bufferLen = buffer.length;
|
|
554
749
|
var array = new Array(bufferLen / 3);
|
|
555
750
|
for(var i = 0; i < bufferLen; i += 3){
|
|
@@ -557,7 +752,7 @@ var TextureWrapMode;
|
|
|
557
752
|
}
|
|
558
753
|
return array;
|
|
559
754
|
};
|
|
560
|
-
|
|
755
|
+
GLTFUtils.floatBufferToVector4Array = function floatBufferToVector4Array(buffer) {
|
|
561
756
|
var bufferLen = buffer.length;
|
|
562
757
|
var array = new Array(bufferLen / 4);
|
|
563
758
|
for(var i = 0; i < bufferLen; i += 4){
|
|
@@ -565,7 +760,7 @@ var TextureWrapMode;
|
|
|
565
760
|
}
|
|
566
761
|
return array;
|
|
567
762
|
};
|
|
568
|
-
|
|
763
|
+
GLTFUtils.floatBufferToColorArray = function floatBufferToColorArray(buffer, isColor3) {
|
|
569
764
|
var bufferLen = buffer.length;
|
|
570
765
|
var colors = new Array(bufferLen / (isColor3 ? 3 : 4));
|
|
571
766
|
if (isColor3) {
|
|
@@ -580,21 +775,8 @@ var TextureWrapMode;
|
|
|
580
775
|
return colors;
|
|
581
776
|
};
|
|
582
777
|
/**
|
|
583
|
-
* Parse binary text for glb loader.
|
|
584
|
-
*/ GLTFUtil.decodeText = function decodeText(array) {
|
|
585
|
-
if (typeof TextDecoder !== "undefined") {
|
|
586
|
-
return new TextDecoder().decode(array);
|
|
587
|
-
}
|
|
588
|
-
// TextDecoder polyfill
|
|
589
|
-
var s = "";
|
|
590
|
-
for(var i = 0, il = array.length; i < il; i++){
|
|
591
|
-
s += String.fromCharCode(array[i]);
|
|
592
|
-
}
|
|
593
|
-
return decodeURIComponent(encodeURIComponent(s));
|
|
594
|
-
};
|
|
595
|
-
/**
|
|
596
778
|
* Get the number of bytes occupied by accessor type.
|
|
597
|
-
*/
|
|
779
|
+
*/ GLTFUtils.getAccessorTypeSize = function getAccessorTypeSize(accessorType) {
|
|
598
780
|
switch(accessorType){
|
|
599
781
|
case AccessorType.SCALAR:
|
|
600
782
|
return 1;
|
|
@@ -614,7 +796,7 @@ var TextureWrapMode;
|
|
|
614
796
|
};
|
|
615
797
|
/**
|
|
616
798
|
* Get the TypedArray corresponding to the component type.
|
|
617
|
-
*/
|
|
799
|
+
*/ GLTFUtils.getComponentType = function getComponentType(componentType) {
|
|
618
800
|
switch(componentType){
|
|
619
801
|
case AccessorComponentType.BYTE:
|
|
620
802
|
return Int8Array;
|
|
@@ -630,7 +812,7 @@ var TextureWrapMode;
|
|
|
630
812
|
return Float32Array;
|
|
631
813
|
}
|
|
632
814
|
};
|
|
633
|
-
|
|
815
|
+
GLTFUtils.getNormalizedComponentScale = function getNormalizedComponentScale(componentType) {
|
|
634
816
|
// Reference: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization#encoding-quantized-data
|
|
635
817
|
switch(componentType){
|
|
636
818
|
case AccessorComponentType.BYTE:
|
|
@@ -645,18 +827,18 @@ var TextureWrapMode;
|
|
|
645
827
|
throw new Error("Galacean.GLTFLoader: Unsupported normalized accessor component type.");
|
|
646
828
|
}
|
|
647
829
|
};
|
|
648
|
-
|
|
830
|
+
GLTFUtils.getAccessorBuffer = function getAccessorBuffer(context, bufferViews, accessor) {
|
|
649
831
|
var buffers = context.buffers;
|
|
650
|
-
var bufferViews = gltf.bufferViews;
|
|
651
832
|
var componentType = accessor.componentType;
|
|
652
833
|
var bufferView = bufferViews[accessor.bufferView];
|
|
653
|
-
var
|
|
834
|
+
var bufferIndex = bufferView.buffer;
|
|
835
|
+
var buffer = buffers[bufferIndex];
|
|
654
836
|
var bufferByteOffset = bufferView.byteOffset || 0;
|
|
655
837
|
var byteOffset = accessor.byteOffset || 0;
|
|
656
|
-
var TypedArray =
|
|
657
|
-
var
|
|
838
|
+
var TypedArray = GLTFUtils.getComponentType(componentType);
|
|
839
|
+
var dataElementSize = GLTFUtils.getAccessorTypeSize(accessor.type);
|
|
658
840
|
var dataElementBytes = TypedArray.BYTES_PER_ELEMENT;
|
|
659
|
-
var elementStride =
|
|
841
|
+
var elementStride = dataElementSize * dataElementBytes;
|
|
660
842
|
var accessorCount = accessor.count;
|
|
661
843
|
var bufferStride = bufferView.byteStride;
|
|
662
844
|
var bufferInfo;
|
|
@@ -671,34 +853,35 @@ var TextureWrapMode;
|
|
|
671
853
|
var count = accessorCount * (bufferStride / dataElementBytes);
|
|
672
854
|
var data = new TypedArray(buffer, offset, count);
|
|
673
855
|
accessorBufferCache[bufferCacheKey] = bufferInfo = new BufferInfo(data, true, bufferStride);
|
|
856
|
+
bufferInfo.restoreInfo = new BufferDataRestoreInfo(new RestoreDataAccessor(bufferIndex, TypedArray, offset, count));
|
|
674
857
|
}
|
|
675
858
|
} else {
|
|
676
859
|
var offset1 = bufferByteOffset + byteOffset;
|
|
677
|
-
var count1 = accessorCount *
|
|
860
|
+
var count1 = accessorCount * dataElementSize;
|
|
678
861
|
var data1 = new TypedArray(buffer, offset1, count1);
|
|
679
862
|
bufferInfo = new BufferInfo(data1, false, elementStride);
|
|
863
|
+
bufferInfo.restoreInfo = new BufferDataRestoreInfo(new RestoreDataAccessor(bufferIndex, TypedArray, offset1, count1));
|
|
680
864
|
}
|
|
681
865
|
if (accessor.sparse) {
|
|
682
|
-
|
|
683
|
-
bufferInfo = new BufferInfo(data2, false, bufferInfo.stride);
|
|
866
|
+
GLTFUtils.processingSparseData(bufferViews, accessor, buffers, bufferInfo);
|
|
684
867
|
}
|
|
685
868
|
return bufferInfo;
|
|
686
869
|
};
|
|
687
870
|
/**
|
|
688
871
|
* @deprecated
|
|
689
872
|
* Get accessor data.
|
|
690
|
-
*/
|
|
691
|
-
var bufferViews =
|
|
873
|
+
*/ GLTFUtils.getAccessorData = function getAccessorData(glTF, accessor, buffers) {
|
|
874
|
+
var bufferViews = glTF.bufferViews;
|
|
692
875
|
var bufferView = bufferViews[accessor.bufferView];
|
|
693
876
|
var arrayBuffer = buffers[bufferView.buffer];
|
|
694
877
|
var accessorByteOffset = accessor.hasOwnProperty("byteOffset") ? accessor.byteOffset : 0;
|
|
695
878
|
var bufferViewByteOffset = bufferView.hasOwnProperty("byteOffset") ? bufferView.byteOffset : 0;
|
|
696
879
|
var byteOffset = accessorByteOffset + bufferViewByteOffset;
|
|
697
|
-
var accessorTypeSize =
|
|
880
|
+
var accessorTypeSize = GLTFUtils.getAccessorTypeSize(accessor.type);
|
|
698
881
|
var length = accessorTypeSize * accessor.count;
|
|
699
882
|
var _bufferView_byteStride;
|
|
700
883
|
var byteStride = (_bufferView_byteStride = bufferView.byteStride) != null ? _bufferView_byteStride : 0;
|
|
701
|
-
var arrayType =
|
|
884
|
+
var arrayType = GLTFUtils.getComponentType(accessor.componentType);
|
|
702
885
|
var uint8Array;
|
|
703
886
|
if (byteStride) {
|
|
704
887
|
var accessorByteSize = accessorTypeSize * arrayType.BYTES_PER_ELEMENT;
|
|
@@ -725,7 +908,7 @@ var TextureWrapMode;
|
|
|
725
908
|
var _values_byteOffset, _valuesBufferView_byteOffset;
|
|
726
909
|
var valuesByteOffset = ((_values_byteOffset = values.byteOffset) != null ? _values_byteOffset : 0) + ((_valuesBufferView_byteOffset = valuesBufferView.byteOffset) != null ? _valuesBufferView_byteOffset : 0);
|
|
727
910
|
var valuesByteLength = valuesBufferView.byteLength;
|
|
728
|
-
var indicesType =
|
|
911
|
+
var indicesType = GLTFUtils.getComponentType(indices.componentType);
|
|
729
912
|
var indicesArray = new indicesType(indicesArrayBuffer, indicesByteOffset, indicesByteLength / indicesType.BYTES_PER_ELEMENT);
|
|
730
913
|
var valuesArray = new arrayType(valuesArrayBuffer, valuesByteOffset, valuesByteLength / arrayType.BYTES_PER_ELEMENT);
|
|
731
914
|
for(var i1 = 0; i1 < count; i1++){
|
|
@@ -737,41 +920,49 @@ var TextureWrapMode;
|
|
|
737
920
|
}
|
|
738
921
|
return typedArray;
|
|
739
922
|
};
|
|
740
|
-
|
|
741
|
-
var
|
|
742
|
-
var arrayBuffer = buffers[buffer];
|
|
743
|
-
return arrayBuffer.slice(byteOffset, byteOffset + byteLength);
|
|
923
|
+
GLTFUtils.getBufferViewData = function getBufferViewData(bufferView, buffers) {
|
|
924
|
+
var _bufferView_byteOffset = bufferView.byteOffset, byteOffset = _bufferView_byteOffset === void 0 ? 0 : _bufferView_byteOffset;
|
|
925
|
+
var arrayBuffer = buffers[bufferView.buffer];
|
|
926
|
+
return arrayBuffer.slice(byteOffset, byteOffset + bufferView.byteLength);
|
|
744
927
|
};
|
|
745
928
|
/**
|
|
746
929
|
* Get accessor data.
|
|
747
|
-
*/
|
|
748
|
-
var
|
|
749
|
-
var accessorTypeSize =
|
|
750
|
-
var TypedArray =
|
|
751
|
-
var data =
|
|
930
|
+
*/ GLTFUtils.processingSparseData = function processingSparseData(bufferViews, accessor, buffers, bufferInfo) {
|
|
931
|
+
var restoreInfo = bufferInfo.restoreInfo;
|
|
932
|
+
var accessorTypeSize = GLTFUtils.getAccessorTypeSize(accessor.type);
|
|
933
|
+
var TypedArray = GLTFUtils.getComponentType(accessor.componentType);
|
|
934
|
+
var data = bufferInfo.data.slice();
|
|
752
935
|
var _accessor_sparse = accessor.sparse, count = _accessor_sparse.count, indices = _accessor_sparse.indices, values = _accessor_sparse.values;
|
|
753
936
|
var indicesBufferView = bufferViews[indices.bufferView];
|
|
754
937
|
var valuesBufferView = bufferViews[values.bufferView];
|
|
755
|
-
var
|
|
756
|
-
var
|
|
938
|
+
var indicesBufferIndex = indicesBufferView.buffer;
|
|
939
|
+
var valuesBufferIndex = valuesBufferView.buffer;
|
|
940
|
+
var indicesArrayBuffer = buffers[indicesBufferIndex];
|
|
941
|
+
var valuesArrayBuffer = buffers[valuesBufferIndex];
|
|
757
942
|
var _indices_byteOffset, _indicesBufferView_byteOffset;
|
|
758
943
|
var indicesByteOffset = ((_indices_byteOffset = indices.byteOffset) != null ? _indices_byteOffset : 0) + ((_indicesBufferView_byteOffset = indicesBufferView.byteOffset) != null ? _indicesBufferView_byteOffset : 0);
|
|
759
944
|
var indicesByteLength = indicesBufferView.byteLength;
|
|
760
945
|
var _values_byteOffset, _valuesBufferView_byteOffset;
|
|
761
946
|
var valuesByteOffset = ((_values_byteOffset = values.byteOffset) != null ? _values_byteOffset : 0) + ((_valuesBufferView_byteOffset = valuesBufferView.byteOffset) != null ? _valuesBufferView_byteOffset : 0);
|
|
762
947
|
var valuesByteLength = valuesBufferView.byteLength;
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
var
|
|
948
|
+
restoreInfo.typeSize = accessorTypeSize;
|
|
949
|
+
restoreInfo.sparseCount = count;
|
|
950
|
+
var IndexTypeArray = GLTFUtils.getComponentType(indices.componentType);
|
|
951
|
+
var indexLength = indicesByteLength / IndexTypeArray.BYTES_PER_ELEMENT;
|
|
952
|
+
var indicesArray = new IndexTypeArray(indicesArrayBuffer, indicesByteOffset, indexLength);
|
|
953
|
+
restoreInfo.sparseIndices = new RestoreDataAccessor(indicesBufferIndex, IndexTypeArray, indicesByteOffset, indexLength);
|
|
954
|
+
var valueLength = valuesByteLength / TypedArray.BYTES_PER_ELEMENT;
|
|
955
|
+
var valuesArray = new TypedArray(valuesArrayBuffer, valuesByteOffset, valueLength);
|
|
956
|
+
restoreInfo.sparseValues = new RestoreDataAccessor(valuesBufferIndex, TypedArray, valuesByteOffset, valueLength);
|
|
766
957
|
for(var i = 0; i < count; i++){
|
|
767
958
|
var replaceIndex = indicesArray[i];
|
|
768
959
|
for(var j = 0; j < accessorTypeSize; j++){
|
|
769
960
|
data[replaceIndex * accessorTypeSize + j] = valuesArray[i * accessorTypeSize + j];
|
|
770
961
|
}
|
|
771
962
|
}
|
|
772
|
-
|
|
963
|
+
bufferInfo.data = data;
|
|
773
964
|
};
|
|
774
|
-
|
|
965
|
+
GLTFUtils.getIndexFormat = function getIndexFormat(type) {
|
|
775
966
|
switch(type){
|
|
776
967
|
case AccessorComponentType.UNSIGNED_BYTE:
|
|
777
968
|
return miniprogram.IndexFormat.UInt8;
|
|
@@ -781,7 +972,7 @@ var TextureWrapMode;
|
|
|
781
972
|
return miniprogram.IndexFormat.UInt32;
|
|
782
973
|
}
|
|
783
974
|
};
|
|
784
|
-
|
|
975
|
+
GLTFUtils.getElementFormat = function getElementFormat(type, size, normalized) {
|
|
785
976
|
if (normalized === void 0) normalized = false;
|
|
786
977
|
if (type == AccessorComponentType.FLOAT) {
|
|
787
978
|
switch(size){
|
|
@@ -832,7 +1023,7 @@ var TextureWrapMode;
|
|
|
832
1023
|
};
|
|
833
1024
|
/**
|
|
834
1025
|
* Load image buffer
|
|
835
|
-
*/
|
|
1026
|
+
*/ GLTFUtils.loadImageBuffer = function loadImageBuffer(imageBuffer, type) {
|
|
836
1027
|
return new Promise(function(resolve, reject) {
|
|
837
1028
|
var blob = new engineMiniprogramAdapter.window.Blob([
|
|
838
1029
|
imageBuffer
|
|
@@ -856,18 +1047,9 @@ var TextureWrapMode;
|
|
|
856
1047
|
img.src = engineMiniprogramAdapter.URL.createObjectURL(blob);
|
|
857
1048
|
});
|
|
858
1049
|
};
|
|
859
|
-
GLTFUtil.isAbsoluteUrl = function isAbsoluteUrl(url) {
|
|
860
|
-
return /^(?:http|blob|data:|\/)/.test(url);
|
|
861
|
-
};
|
|
862
|
-
GLTFUtil.parseRelativeUrl = function parseRelativeUrl(baseUrl, relativeUrl) {
|
|
863
|
-
if (GLTFUtil.isAbsoluteUrl(relativeUrl)) {
|
|
864
|
-
return relativeUrl;
|
|
865
|
-
}
|
|
866
|
-
return baseUrl.substring(0, baseUrl.lastIndexOf("/") + 1) + GLTFUtil._formatRelativePath(relativeUrl);
|
|
867
|
-
};
|
|
868
1050
|
/**
|
|
869
1051
|
* Parse the glb format.
|
|
870
|
-
*/
|
|
1052
|
+
*/ GLTFUtils.parseGLB = function parseGLB(context, glb) {
|
|
871
1053
|
var UINT32_LENGTH = 4;
|
|
872
1054
|
var GLB_HEADER_MAGIC = 0x46546c67; // 'glTF'
|
|
873
1055
|
var GLB_HEADER_LENGTH = 12;
|
|
@@ -895,10 +1077,11 @@ var TextureWrapMode;
|
|
|
895
1077
|
return null;
|
|
896
1078
|
}
|
|
897
1079
|
var glTFData = new Uint8Array(glb, GLB_HEADER_LENGTH + 2 * UINT32_LENGTH, chunkLength);
|
|
898
|
-
var
|
|
1080
|
+
var glTF = JSON.parse(miniprogram.Utils.decodeText(glTFData));
|
|
899
1081
|
// read all buffers
|
|
900
1082
|
var buffers = [];
|
|
901
1083
|
var byteOffset = GLB_HEADER_LENGTH + 2 * UINT32_LENGTH + chunkLength;
|
|
1084
|
+
var restoreGLBBufferSlice = context.contentRestorer.glbBufferSlices;
|
|
902
1085
|
while(byteOffset < header.length){
|
|
903
1086
|
chunkLength = dataView.getUint32(byteOffset, true);
|
|
904
1087
|
chunkType = dataView.getUint32(byteOffset + UINT32_LENGTH, true);
|
|
@@ -909,14 +1092,15 @@ var TextureWrapMode;
|
|
|
909
1092
|
var currentOffset = byteOffset + 2 * UINT32_LENGTH;
|
|
910
1093
|
var buffer = glb.slice(currentOffset, currentOffset + chunkLength);
|
|
911
1094
|
buffers.push(buffer);
|
|
1095
|
+
restoreGLBBufferSlice.push(new miniprogram$1.Vector2(currentOffset, chunkLength));
|
|
912
1096
|
byteOffset += chunkLength + 2 * UINT32_LENGTH;
|
|
913
1097
|
}
|
|
914
1098
|
return {
|
|
915
|
-
|
|
1099
|
+
glTF: glTF,
|
|
916
1100
|
buffers: buffers
|
|
917
1101
|
};
|
|
918
1102
|
};
|
|
919
|
-
|
|
1103
|
+
GLTFUtils._formatRelativePath = function _formatRelativePath(path) {
|
|
920
1104
|
// For example input is "a/b", "/a/b", "./a/b", "./a/./b", "./a/../a/b", output is "a/b"
|
|
921
1105
|
return path.split("/").filter(Boolean).reduce(function(acc, cur) {
|
|
922
1106
|
if (cur === "..") acc.pop();
|
|
@@ -924,17 +1108,9 @@ var TextureWrapMode;
|
|
|
924
1108
|
return acc;
|
|
925
1109
|
}, []).join("/");
|
|
926
1110
|
};
|
|
927
|
-
return
|
|
1111
|
+
return GLTFUtils;
|
|
928
1112
|
}();
|
|
929
1113
|
|
|
930
|
-
function _array_like_to_array(arr, len) {
|
|
931
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
932
|
-
|
|
933
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
934
|
-
|
|
935
|
-
return arr2;
|
|
936
|
-
}
|
|
937
|
-
|
|
938
1114
|
function _array_without_holes(arr) {
|
|
939
1115
|
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
940
1116
|
}
|
|
@@ -949,606 +1125,327 @@ function _non_iterable_spread() {
|
|
|
949
1125
|
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
950
1126
|
}
|
|
951
1127
|
|
|
952
|
-
function _unsupported_iterable_to_array(o, minLen) {
|
|
953
|
-
if (!o) return;
|
|
954
|
-
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
955
|
-
|
|
956
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
957
|
-
|
|
958
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
959
|
-
if (n === "Map" || n === "Set") return Array.from(n);
|
|
960
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
961
|
-
}
|
|
962
|
-
|
|
963
1128
|
function _to_consumable_array(arr) {
|
|
964
1129
|
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
965
1130
|
}
|
|
966
1131
|
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
1132
|
+
/**
|
|
1133
|
+
* Base class of glTF extension parser.
|
|
1134
|
+
*/ var GLTFExtensionParser = /*#__PURE__*/ function() {
|
|
1135
|
+
function GLTFExtensionParser() {}
|
|
1136
|
+
var _proto = GLTFExtensionParser.prototype;
|
|
1137
|
+
/**
|
|
1138
|
+
* Initialize the parser.
|
|
1139
|
+
* @remarks Some plugins require initialization.
|
|
1140
|
+
* @returns The void or promise
|
|
1141
|
+
*/ _proto.initialize = function initialize() {};
|
|
1142
|
+
/**
|
|
1143
|
+
* Create and parse the resource.
|
|
1144
|
+
* @remarks This method overrides the default resource creation.
|
|
1145
|
+
* @param context - The parser context
|
|
1146
|
+
* @param extensionSchema - The extension schema
|
|
1147
|
+
* @param extensionOwnerSchema - The extension owner schema
|
|
1148
|
+
* @returns The resource or promise
|
|
1149
|
+
*/ _proto.createAndParse = function createAndParse(context, extensionSchema, extensionOwnerSchema) {
|
|
1150
|
+
for(var _len = arguments.length, extra = new Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++){
|
|
1151
|
+
extra[_key - 3] = arguments[_key];
|
|
1152
|
+
}
|
|
1153
|
+
throw "Not implemented.";
|
|
1154
|
+
};
|
|
1155
|
+
/**
|
|
1156
|
+
* Additive parse to the resource.
|
|
1157
|
+
* @param context - The parser context
|
|
1158
|
+
* @param parseResource - The parsed resource
|
|
1159
|
+
* @param extensionSchema - The extension schema
|
|
1160
|
+
* @param extensionOwnerSchema - The extension owner schema
|
|
1161
|
+
* @returns The void or promise
|
|
1162
|
+
*/ _proto.additiveParse = function additiveParse(context, parseResource, extensionSchema, extensionOwnerSchema) {
|
|
970
1163
|
for(var _len = arguments.length, extra = new Array(_len > 4 ? _len - 4 : 0), _key = 4; _key < _len; _key++){
|
|
971
1164
|
extra[_key - 4] = arguments[_key];
|
|
972
1165
|
}
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
1166
|
+
throw "Not implemented.";
|
|
1167
|
+
};
|
|
1168
|
+
return GLTFExtensionParser;
|
|
1169
|
+
}();
|
|
1170
|
+
exports.GLTFExtensionMode = void 0;
|
|
1171
|
+
(function(GLTFExtensionMode) {
|
|
1172
|
+
GLTFExtensionMode[GLTFExtensionMode[/**
|
|
1173
|
+
* Cerate instance and parse mode.
|
|
1174
|
+
* @remarks
|
|
1175
|
+
* If the glTF property has multiple extensions of `CreateAndParse` mode, only execute the last one.
|
|
1176
|
+
* If this method is registered, the default pipeline processing will be ignored.
|
|
1177
|
+
*/ "CreateAndParse"] = 0] = "CreateAndParse";
|
|
1178
|
+
GLTFExtensionMode[GLTFExtensionMode[/** Additive parse mode. */ "AdditiveParse"] = 1] = "AdditiveParse";
|
|
1179
|
+
})(exports.GLTFExtensionMode || (exports.GLTFExtensionMode = {}));
|
|
1180
|
+
|
|
1181
|
+
/**
|
|
1182
|
+
* Base class of glTF parser.
|
|
1183
|
+
*/ var GLTFParser = /*#__PURE__*/ function() {
|
|
1184
|
+
function GLTFParser() {}
|
|
1185
|
+
/**
|
|
1186
|
+
* Execute all parses of extension to initialize plugin.
|
|
1187
|
+
* @remarks Some plugins require initialization.
|
|
1188
|
+
* @returns The void or promise
|
|
1189
|
+
*/ GLTFParser.executeExtensionsInitialize = function executeExtensionsInitialize(extensionName) {
|
|
1190
|
+
var parsers = GLTFParser._extensionParsers[extensionName];
|
|
1191
|
+
var length = parsers == null ? void 0 : parsers.length;
|
|
1192
|
+
if (length) {
|
|
1193
|
+
return parsers[length - 1].initialize();
|
|
983
1194
|
}
|
|
984
1195
|
};
|
|
985
|
-
|
|
1196
|
+
/**
|
|
1197
|
+
* Execute all parses of extension to create resource.
|
|
1198
|
+
* @param extensions - Related extensions field
|
|
1199
|
+
* @param context - The parser context
|
|
1200
|
+
* @param ownerSchema - The extension owner schema
|
|
1201
|
+
* @param extra - Extra params
|
|
1202
|
+
* @returns
|
|
1203
|
+
*/ GLTFParser.executeExtensionsCreateAndParse = function executeExtensionsCreateAndParse(extensions, context, ownerSchema) {
|
|
1204
|
+
if (extensions === void 0) extensions = {};
|
|
986
1205
|
for(var _len = arguments.length, extra = new Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++){
|
|
987
1206
|
extra[_key - 3] = arguments[_key];
|
|
988
1207
|
}
|
|
989
|
-
var
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
1208
|
+
var resource = null;
|
|
1209
|
+
var extensionArray = Object.keys(extensions);
|
|
1210
|
+
for(var i = extensionArray.length - 1; i >= 0; --i){
|
|
1211
|
+
var _GLTFParser;
|
|
1212
|
+
var extensionName = extensionArray[i];
|
|
1213
|
+
var extensionSchema = extensions[extensionName];
|
|
1214
|
+
resource = (_GLTFParser = GLTFParser)._createAndParse.apply(_GLTFParser, [
|
|
1215
|
+
extensionName,
|
|
1216
|
+
context,
|
|
1217
|
+
extensionSchema,
|
|
1218
|
+
ownerSchema
|
|
1219
|
+
].concat(_to_consumable_array(extra)));
|
|
1220
|
+
if (resource) {
|
|
1221
|
+
return resource;
|
|
1222
|
+
}
|
|
1223
|
+
}
|
|
1224
|
+
};
|
|
1225
|
+
/**
|
|
1226
|
+
* Execute all parses of extension to parse resource.
|
|
1227
|
+
* @param extensions - Related extensions field
|
|
1228
|
+
* @param context - The parser context
|
|
1229
|
+
* @param parseResource - The parsed resource
|
|
1230
|
+
* @param ownerSchema - The extension owner schema
|
|
1231
|
+
* @param extra - Extra params
|
|
1232
|
+
*/ GLTFParser.executeExtensionsAdditiveAndParse = function executeExtensionsAdditiveAndParse(extensions, context, parseResource, ownerSchema) {
|
|
1233
|
+
for(var _len = arguments.length, extra = new Array(_len > 4 ? _len - 4 : 0), _key = 4; _key < _len; _key++){
|
|
1234
|
+
extra[_key - 4] = arguments[_key];
|
|
1235
|
+
}
|
|
1236
|
+
for(var extensionName in extensions){
|
|
1237
|
+
var _GLTFParser;
|
|
1238
|
+
var extensionSchema = extensions[extensionName];
|
|
1239
|
+
(_GLTFParser = GLTFParser)._additiveParse.apply(_GLTFParser, [
|
|
1240
|
+
extensionName,
|
|
1241
|
+
context,
|
|
1242
|
+
parseResource,
|
|
993
1243
|
extensionSchema,
|
|
994
|
-
|
|
1244
|
+
ownerSchema
|
|
995
1245
|
].concat(_to_consumable_array(extra)));
|
|
996
1246
|
}
|
|
997
1247
|
};
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1248
|
+
/**
|
|
1249
|
+
* Whether the plugin is registered.
|
|
1250
|
+
* @param extensionName - Extension name
|
|
1251
|
+
* @returns Boolean
|
|
1252
|
+
*/ GLTFParser.hasExtensionParser = function hasExtensionParser(extensionName) {
|
|
1253
|
+
var _GLTFParser__extensionParsers_extensionName;
|
|
1254
|
+
return !!((_GLTFParser__extensionParsers_extensionName = GLTFParser._extensionParsers[extensionName]) == null ? void 0 : _GLTFParser__extensionParsers_extensionName.length);
|
|
1001
1255
|
};
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1256
|
+
/**
|
|
1257
|
+
* Get the last plugin by glTF extension mode.
|
|
1258
|
+
* @param extensionName - Extension name
|
|
1259
|
+
* @param mode - GLTF extension mode
|
|
1260
|
+
* @returns GLTF extension parser
|
|
1261
|
+
*/ GLTFParser.getExtensionParser = function getExtensionParser(extensionName, mode) {
|
|
1262
|
+
var parsers = GLTFParser._extensionParsers[extensionName];
|
|
1263
|
+
var length = parsers == null ? void 0 : parsers.length;
|
|
1264
|
+
if (length) {
|
|
1265
|
+
// only use the last parser.
|
|
1266
|
+
for(var i = length - 1; i >= 0; --i){
|
|
1267
|
+
var currentParser = parsers[i];
|
|
1268
|
+
if (currentParser._mode === mode) {
|
|
1269
|
+
return currentParser;
|
|
1270
|
+
}
|
|
1007
1271
|
}
|
|
1008
1272
|
}
|
|
1009
1273
|
};
|
|
1010
1274
|
/**
|
|
1011
1275
|
* @internal
|
|
1012
|
-
*/
|
|
1013
|
-
if (!
|
|
1014
|
-
|
|
1276
|
+
*/ GLTFParser._addExtensionParser = function _addExtensionParser(extensionName, extensionParser) {
|
|
1277
|
+
if (!GLTFParser._extensionParsers[extensionName]) {
|
|
1278
|
+
GLTFParser._extensionParsers[extensionName] = [];
|
|
1279
|
+
}
|
|
1280
|
+
GLTFParser._extensionParsers[extensionName].push(extensionParser);
|
|
1281
|
+
};
|
|
1282
|
+
GLTFParser._createAndParse = function _createAndParse(extensionName, context, extensionSchema, ownerSchema) {
|
|
1283
|
+
for(var _len = arguments.length, extra = new Array(_len > 4 ? _len - 4 : 0), _key = 4; _key < _len; _key++){
|
|
1284
|
+
extra[_key - 4] = arguments[_key];
|
|
1285
|
+
}
|
|
1286
|
+
var parser = GLTFParser.getExtensionParser(extensionName, exports.GLTFExtensionMode.CreateAndParse);
|
|
1287
|
+
if (parser) {
|
|
1288
|
+
var _parser;
|
|
1289
|
+
return (_parser = parser).createAndParse.apply(_parser, [
|
|
1290
|
+
context,
|
|
1291
|
+
extensionSchema,
|
|
1292
|
+
ownerSchema
|
|
1293
|
+
].concat(_to_consumable_array(extra)));
|
|
1294
|
+
}
|
|
1295
|
+
};
|
|
1296
|
+
GLTFParser._additiveParse = function _additiveParse(extensionName, context, parseResource, extensionSchema, ownerSchema) {
|
|
1297
|
+
for(var _len = arguments.length, extra = new Array(_len > 5 ? _len - 5 : 0), _key = 5; _key < _len; _key++){
|
|
1298
|
+
extra[_key - 5] = arguments[_key];
|
|
1299
|
+
}
|
|
1300
|
+
var parser = GLTFParser.getExtensionParser(extensionName, exports.GLTFExtensionMode.AdditiveParse);
|
|
1301
|
+
if (parser) {
|
|
1302
|
+
var _parser;
|
|
1303
|
+
(_parser = parser).additiveParse.apply(_parser, [
|
|
1304
|
+
context,
|
|
1305
|
+
parseResource,
|
|
1306
|
+
extensionSchema,
|
|
1307
|
+
ownerSchema
|
|
1308
|
+
].concat(_to_consumable_array(extra)));
|
|
1015
1309
|
}
|
|
1016
|
-
Parser._extensionParsers[extensionName].push(extensionParser);
|
|
1017
1310
|
};
|
|
1018
|
-
return
|
|
1311
|
+
return GLTFParser;
|
|
1019
1312
|
}();
|
|
1020
1313
|
(function() {
|
|
1021
|
-
|
|
1314
|
+
GLTFParser._extensionParsers = {};
|
|
1022
1315
|
})();
|
|
1023
1316
|
/**
|
|
1024
1317
|
* Declare ExtensionParser's decorator.
|
|
1025
1318
|
* @param extensionName - Extension name
|
|
1026
|
-
*/ function
|
|
1319
|
+
*/ function registerGLTFExtension(extensionName, mode) {
|
|
1027
1320
|
return function(parser) {
|
|
1028
1321
|
var extensionParser = new parser();
|
|
1029
|
-
|
|
1322
|
+
extensionParser._mode = mode;
|
|
1323
|
+
GLTFParser._addExtensionParser(extensionName, extensionParser);
|
|
1030
1324
|
};
|
|
1031
1325
|
}
|
|
1032
1326
|
|
|
1033
|
-
var
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
_proto.parseEngineResource = function parseEngineResource(schema, parseResource, context) {
|
|
1038
|
-
for(var _len = arguments.length, extra = new Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++){
|
|
1039
|
-
extra[_key - 3] = arguments[_key];
|
|
1040
|
-
}
|
|
1041
|
-
};
|
|
1042
|
-
_proto.createEngineResource = function createEngineResource(schema, context) {
|
|
1043
|
-
for(var _len = arguments.length, extra = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++){
|
|
1044
|
-
extra[_key - 2] = arguments[_key];
|
|
1045
|
-
}
|
|
1046
|
-
return null;
|
|
1047
|
-
};
|
|
1048
|
-
return ExtensionParser;
|
|
1049
|
-
}();
|
|
1050
|
-
|
|
1051
|
-
var KHR_draco_mesh_compression = /*#__PURE__*/ function(ExtensionParser) {
|
|
1052
|
-
_inherits(KHR_draco_mesh_compression1, ExtensionParser);
|
|
1053
|
-
function KHR_draco_mesh_compression1() {
|
|
1054
|
-
return ExtensionParser.apply(this, arguments);
|
|
1327
|
+
var GLTFAnimationParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
1328
|
+
_inherits(GLTFAnimationParser, GLTFParser1);
|
|
1329
|
+
function GLTFAnimationParser() {
|
|
1330
|
+
return GLTFParser1.apply(this, arguments);
|
|
1055
1331
|
}
|
|
1056
|
-
var _proto =
|
|
1057
|
-
_proto.
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
var gltf = context.gltf, buffers = context.buffers;
|
|
1064
|
-
var bufferViews = gltf.bufferViews, accessors = gltf.accessors;
|
|
1065
|
-
var bufferViewIndex = schema.bufferView, gltfAttributeMap = schema.attributes;
|
|
1066
|
-
var attributeMap = {};
|
|
1067
|
-
var attributeTypeMap = {};
|
|
1068
|
-
for(var attributeName in gltfAttributeMap){
|
|
1069
|
-
attributeMap[attributeName] = gltfAttributeMap[attributeName];
|
|
1332
|
+
var _proto = GLTFAnimationParser.prototype;
|
|
1333
|
+
_proto.parse = function parse(context) {
|
|
1334
|
+
var glTF = context.glTF; context.buffers; var glTFResource = context.glTFResource;
|
|
1335
|
+
glTFResource.entities;
|
|
1336
|
+
var animations = glTF.animations; glTF.accessors; glTF.bufferViews;
|
|
1337
|
+
if (!animations) {
|
|
1338
|
+
return;
|
|
1070
1339
|
}
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1340
|
+
var animationClipsPromiseInfo = context.animationClipsPromiseInfo;
|
|
1341
|
+
var animationClipCount = animations.length;
|
|
1342
|
+
var animationClipPromises = [];
|
|
1343
|
+
new Array(animationClipCount);
|
|
1344
|
+
for(var i = 0; i < animationClipCount; i++){
|
|
1345
|
+
var animationInfo = animations[i];
|
|
1346
|
+
var _animationInfo_name = animationInfo.name, name = _animationInfo_name === void 0 ? "AnimationClip" + i : _animationInfo_name;
|
|
1347
|
+
var animationClip = GLTFParser.executeExtensionsCreateAndParse(animationInfo.extensions, context, animationInfo);
|
|
1348
|
+
if (!animationClip) {
|
|
1349
|
+
animationClip = new miniprogram.AnimationClip(name);
|
|
1350
|
+
GLTFAnimationParser._parseStandardProperty(context, animationClip, animationInfo);
|
|
1075
1351
|
}
|
|
1352
|
+
animationClipPromises.push(animationClip);
|
|
1076
1353
|
}
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
var buffer = GLTFUtil.getBufferViewData(bufferViews[bufferViewIndex], buffers);
|
|
1086
|
-
return KHR_draco_mesh_compression._decoder.decode(buffer, taskConfig).then(function(parsedGeometry) {
|
|
1087
|
-
return parsedGeometry;
|
|
1354
|
+
return miniprogram.AssetPromise.all(animationClipPromises).then(function(animationClips) {
|
|
1355
|
+
glTFResource.animations = animationClips;
|
|
1356
|
+
for(var i = 0; i < glTF.animations.length; i++){
|
|
1357
|
+
var animationInfo = glTF.animations[i];
|
|
1358
|
+
GLTFParser.executeExtensionsAdditiveAndParse(animationInfo.extensions, context, animationClips[i], animationInfo);
|
|
1359
|
+
}
|
|
1360
|
+
animationClipsPromiseInfo.resolve(animationClips);
|
|
1361
|
+
return animationClipsPromiseInfo.promise;
|
|
1088
1362
|
});
|
|
1089
1363
|
};
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
var
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
var glTFResource = context.glTFResource;
|
|
1111
|
-
var light;
|
|
1112
|
-
if (type === "directional") {
|
|
1113
|
-
light = entity.addComponent(miniprogram.DirectLight);
|
|
1114
|
-
} else if (type === "point") {
|
|
1115
|
-
light = entity.addComponent(miniprogram.PointLight);
|
|
1116
|
-
} else if (type === "spot") {
|
|
1117
|
-
light = entity.addComponent(miniprogram.SpotLight);
|
|
1118
|
-
}
|
|
1119
|
-
if (color) {
|
|
1120
|
-
light.color.set(color[0], color[1], color[2], 1);
|
|
1121
|
-
}
|
|
1122
|
-
light.intensity = intensity;
|
|
1123
|
-
if (range && !_instanceof(light, miniprogram.DirectLight)) {
|
|
1124
|
-
light.distance = range;
|
|
1125
|
-
}
|
|
1126
|
-
if (spot && _instanceof(light, miniprogram.SpotLight)) {
|
|
1127
|
-
var _spot_innerConeAngle = spot.innerConeAngle, innerConeAngle = _spot_innerConeAngle === void 0 ? 0 : _spot_innerConeAngle, _spot_outerConeAngle = spot.outerConeAngle, outerConeAngle = _spot_outerConeAngle === void 0 ? Math.PI / 4 : _spot_outerConeAngle;
|
|
1128
|
-
light.angle = innerConeAngle;
|
|
1129
|
-
light.penumbra = outerConeAngle - innerConeAngle;
|
|
1130
|
-
}
|
|
1131
|
-
if (!glTFResource.lights) glTFResource.lights = [];
|
|
1132
|
-
glTFResource.lights.push(light);
|
|
1133
|
-
};
|
|
1134
|
-
return KHR_lights_punctual;
|
|
1135
|
-
}(ExtensionParser);
|
|
1136
|
-
KHR_lights_punctual = __decorate([
|
|
1137
|
-
registerExtension("KHR_lights_punctual")
|
|
1138
|
-
], KHR_lights_punctual);
|
|
1139
|
-
|
|
1140
|
-
var MaterialParser = /*#__PURE__*/ function(Parser1) {
|
|
1141
|
-
_inherits(MaterialParser, Parser1);
|
|
1142
|
-
function MaterialParser() {
|
|
1143
|
-
return Parser1.apply(this, arguments);
|
|
1144
|
-
}
|
|
1145
|
-
var _proto = MaterialParser.prototype;
|
|
1146
|
-
_proto.parse = function parse(context) {
|
|
1147
|
-
var gltf = context.gltf, glTFResource = context.glTFResource;
|
|
1148
|
-
var engine = glTFResource.engine, textures = glTFResource.textures;
|
|
1149
|
-
if (!gltf.materials) return;
|
|
1150
|
-
var materialsPromiseInfo = context.materialsPromiseInfo;
|
|
1151
|
-
var materials = [];
|
|
1152
|
-
for(var i = 0; i < gltf.materials.length; i++){
|
|
1153
|
-
var _gltf_materials_i = gltf.materials[i], _gltf_materials_i_extensions = _gltf_materials_i.extensions, extensions = _gltf_materials_i_extensions === void 0 ? {} : _gltf_materials_i_extensions, pbrMetallicRoughness = _gltf_materials_i.pbrMetallicRoughness, normalTexture = _gltf_materials_i.normalTexture, occlusionTexture = _gltf_materials_i.occlusionTexture, emissiveTexture = _gltf_materials_i.emissiveTexture, emissiveFactor = _gltf_materials_i.emissiveFactor, alphaMode = _gltf_materials_i.alphaMode, alphaCutoff = _gltf_materials_i.alphaCutoff, doubleSided = _gltf_materials_i.doubleSided, _gltf_materials_i_name = _gltf_materials_i.name, name = _gltf_materials_i_name === void 0 ? "" : _gltf_materials_i_name;
|
|
1154
|
-
var KHR_materials_unlit = extensions.KHR_materials_unlit, KHR_materials_pbrSpecularGlossiness = extensions.KHR_materials_pbrSpecularGlossiness, KHR_materials_clearcoat = extensions.KHR_materials_clearcoat, OASIS_materials_remap = extensions.OASIS_materials_remap;
|
|
1155
|
-
var material = null;
|
|
1156
|
-
if (KHR_materials_unlit) {
|
|
1157
|
-
material = Parser.createEngineResource("KHR_materials_unlit", KHR_materials_unlit, context);
|
|
1158
|
-
} else if (KHR_materials_pbrSpecularGlossiness) {
|
|
1159
|
-
material = Parser.createEngineResource("KHR_materials_pbrSpecularGlossiness", KHR_materials_pbrSpecularGlossiness, context);
|
|
1160
|
-
} else {
|
|
1161
|
-
material = new miniprogram.PBRMaterial(engine);
|
|
1162
|
-
}
|
|
1163
|
-
material.name = name;
|
|
1164
|
-
if (KHR_materials_clearcoat) {
|
|
1165
|
-
Parser.parseEngineResource("KHR_materials_clearcoat", KHR_materials_clearcoat, material, context);
|
|
1166
|
-
}
|
|
1167
|
-
if (pbrMetallicRoughness) {
|
|
1168
|
-
var baseColorFactor = pbrMetallicRoughness.baseColorFactor, baseColorTexture = pbrMetallicRoughness.baseColorTexture, metallicFactor = pbrMetallicRoughness.metallicFactor, roughnessFactor = pbrMetallicRoughness.roughnessFactor, metallicRoughnessTexture = pbrMetallicRoughness.metallicRoughnessTexture;
|
|
1169
|
-
if (baseColorFactor) {
|
|
1170
|
-
material.baseColor = new miniprogram$1.Color(miniprogram$1.Color.linearToGammaSpace(baseColorFactor[0]), miniprogram$1.Color.linearToGammaSpace(baseColorFactor[1]), miniprogram$1.Color.linearToGammaSpace(baseColorFactor[2]), baseColorFactor[3]);
|
|
1171
|
-
}
|
|
1172
|
-
if (baseColorTexture) {
|
|
1173
|
-
material.baseTexture = textures[baseColorTexture.index];
|
|
1174
|
-
MaterialParser._parseTextureTransform(material, baseColorTexture.extensions, context);
|
|
1175
|
-
}
|
|
1176
|
-
if (!KHR_materials_unlit && !KHR_materials_pbrSpecularGlossiness) {
|
|
1177
|
-
var m = material;
|
|
1178
|
-
m.metallic = metallicFactor != null ? metallicFactor : 1;
|
|
1179
|
-
m.roughness = roughnessFactor != null ? roughnessFactor : 1;
|
|
1180
|
-
if (metallicRoughnessTexture) {
|
|
1181
|
-
m.roughnessMetallicTexture = textures[metallicRoughnessTexture.index];
|
|
1182
|
-
MaterialParser._parseTextureTransform(material, metallicRoughnessTexture.extensions, context);
|
|
1183
|
-
}
|
|
1184
|
-
}
|
|
1185
|
-
}
|
|
1186
|
-
if (!KHR_materials_unlit) {
|
|
1187
|
-
var m1 = material;
|
|
1188
|
-
if (emissiveTexture) {
|
|
1189
|
-
m1.emissiveTexture = textures[emissiveTexture.index];
|
|
1190
|
-
MaterialParser._parseTextureTransform(material, emissiveTexture.extensions, context);
|
|
1191
|
-
}
|
|
1192
|
-
if (emissiveFactor) {
|
|
1193
|
-
m1.emissiveColor = new miniprogram$1.Color(miniprogram$1.Color.linearToGammaSpace(emissiveFactor[0]), miniprogram$1.Color.linearToGammaSpace(emissiveFactor[1]), miniprogram$1.Color.linearToGammaSpace(emissiveFactor[2]));
|
|
1194
|
-
}
|
|
1195
|
-
if (normalTexture) {
|
|
1196
|
-
var index = normalTexture.index, scale = normalTexture.scale;
|
|
1197
|
-
m1.normalTexture = textures[index];
|
|
1198
|
-
MaterialParser._parseTextureTransform(material, normalTexture.extensions, context);
|
|
1199
|
-
if (scale !== undefined) {
|
|
1200
|
-
m1.normalTextureIntensity = scale;
|
|
1201
|
-
}
|
|
1202
|
-
}
|
|
1203
|
-
if (occlusionTexture) {
|
|
1204
|
-
var index1 = occlusionTexture.index, strength = occlusionTexture.strength, texCoord = occlusionTexture.texCoord;
|
|
1205
|
-
m1.occlusionTexture = textures[index1];
|
|
1206
|
-
MaterialParser._parseTextureTransform(material, occlusionTexture.extensions, context);
|
|
1207
|
-
if (strength !== undefined) {
|
|
1208
|
-
m1.occlusionTextureIntensity = strength;
|
|
1209
|
-
}
|
|
1210
|
-
if (texCoord === miniprogram.TextureCoordinate.UV1) {
|
|
1211
|
-
m1.occlusionTextureCoord = miniprogram.TextureCoordinate.UV1;
|
|
1212
|
-
} else if (texCoord > miniprogram.TextureCoordinate.UV1) {
|
|
1213
|
-
miniprogram.Logger.warn("Occlusion texture uv coordinate must be UV0 or UV1.");
|
|
1214
|
-
}
|
|
1364
|
+
/**
|
|
1365
|
+
* @internal
|
|
1366
|
+
*/ GLTFAnimationParser._parseStandardProperty = function _parseStandardProperty(context, animationClip, animationInfo) {
|
|
1367
|
+
var glTF = context.glTF, glTFResource = context.glTFResource;
|
|
1368
|
+
var entities = glTFResource.entities;
|
|
1369
|
+
var accessors = glTF.accessors, bufferViews = glTF.bufferViews;
|
|
1370
|
+
var channels = animationInfo.channels, samplers = animationInfo.samplers;
|
|
1371
|
+
var sampleDataCollection = new Array();
|
|
1372
|
+
// parse samplers
|
|
1373
|
+
for(var j = 0, m = samplers.length; j < m; j++){
|
|
1374
|
+
var gltfSampler = samplers[j];
|
|
1375
|
+
var inputAccessor = accessors[gltfSampler.input];
|
|
1376
|
+
var outputAccessor = accessors[gltfSampler.output];
|
|
1377
|
+
var input = GLTFUtils.getAccessorBuffer(context, bufferViews, inputAccessor).data;
|
|
1378
|
+
var output = GLTFUtils.getAccessorBuffer(context, bufferViews, outputAccessor).data;
|
|
1379
|
+
if (outputAccessor.normalized) {
|
|
1380
|
+
var scale = GLTFUtils.getNormalizedComponentScale(outputAccessor.componentType);
|
|
1381
|
+
var scaled = new Float32Array(output.length);
|
|
1382
|
+
for(var k = 0, v = output.length; k < v; k++){
|
|
1383
|
+
scaled[k] = output[k] * scale;
|
|
1215
1384
|
}
|
|
1385
|
+
output = scaled;
|
|
1216
1386
|
}
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
if (doubleSided) {
|
|
1225
|
-
material.renderFace = miniprogram.RenderFace.Double;
|
|
1226
|
-
} else {
|
|
1227
|
-
material.renderFace = miniprogram.RenderFace.Front;
|
|
1228
|
-
}
|
|
1229
|
-
switch(alphaMode){
|
|
1230
|
-
case MaterialAlphaMode.OPAQUE:
|
|
1231
|
-
material.isTransparent = false;
|
|
1387
|
+
var outputStride = output.length / input.length;
|
|
1388
|
+
var _gltfSampler_interpolation;
|
|
1389
|
+
var interpolation = (_gltfSampler_interpolation = gltfSampler.interpolation) != null ? _gltfSampler_interpolation : AnimationSamplerInterpolation.Linear;
|
|
1390
|
+
var samplerInterpolation = void 0;
|
|
1391
|
+
switch(interpolation){
|
|
1392
|
+
case AnimationSamplerInterpolation.CubicSpine:
|
|
1393
|
+
samplerInterpolation = miniprogram.InterpolationType.CubicSpine;
|
|
1232
1394
|
break;
|
|
1233
|
-
case
|
|
1234
|
-
|
|
1395
|
+
case AnimationSamplerInterpolation.Step:
|
|
1396
|
+
samplerInterpolation = miniprogram.InterpolationType.Step;
|
|
1235
1397
|
break;
|
|
1236
|
-
case
|
|
1237
|
-
|
|
1398
|
+
case AnimationSamplerInterpolation.Linear:
|
|
1399
|
+
samplerInterpolation = miniprogram.InterpolationType.Linear;
|
|
1238
1400
|
break;
|
|
1239
1401
|
}
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
if (extensions === void 0) extensions = {};
|
|
1248
|
-
var schema = extensions.KHR_texture_transform;
|
|
1249
|
-
if (schema) {
|
|
1250
|
-
Parser.parseEngineResource("KHR_texture_transform", schema, material, context);
|
|
1251
|
-
}
|
|
1252
|
-
};
|
|
1253
|
-
return MaterialParser;
|
|
1254
|
-
}(Parser);
|
|
1255
|
-
|
|
1256
|
-
var KHR_materials_clearcoat = /*#__PURE__*/ function(ExtensionParser) {
|
|
1257
|
-
_inherits(KHR_materials_clearcoat, ExtensionParser);
|
|
1258
|
-
function KHR_materials_clearcoat() {
|
|
1259
|
-
return ExtensionParser.apply(this, arguments);
|
|
1260
|
-
}
|
|
1261
|
-
var _proto = KHR_materials_clearcoat.prototype;
|
|
1262
|
-
_proto.parseEngineResource = function parseEngineResource(schema, material, context) {
|
|
1263
|
-
var textures = context.glTFResource.textures;
|
|
1264
|
-
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;
|
|
1265
|
-
material.clearCoat = clearcoatFactor;
|
|
1266
|
-
material.clearCoatRoughness = clearcoatRoughnessFactor;
|
|
1267
|
-
if (clearcoatTexture) {
|
|
1268
|
-
material.clearCoatTexture = textures[clearcoatTexture.index];
|
|
1269
|
-
MaterialParser._parseTextureTransform(material, clearcoatTexture.extensions, context);
|
|
1270
|
-
}
|
|
1271
|
-
if (clearcoatRoughnessTexture) {
|
|
1272
|
-
material.clearCoatRoughnessTexture = textures[clearcoatRoughnessTexture.index];
|
|
1273
|
-
MaterialParser._parseTextureTransform(material, clearcoatRoughnessTexture.extensions, context);
|
|
1274
|
-
}
|
|
1275
|
-
if (clearcoatNormalTexture) {
|
|
1276
|
-
material.clearCoatNormalTexture = textures[clearcoatNormalTexture.index];
|
|
1277
|
-
MaterialParser._parseTextureTransform(material, clearcoatNormalTexture.extensions, context);
|
|
1278
|
-
}
|
|
1279
|
-
};
|
|
1280
|
-
return KHR_materials_clearcoat;
|
|
1281
|
-
}(ExtensionParser);
|
|
1282
|
-
KHR_materials_clearcoat = __decorate([
|
|
1283
|
-
registerExtension("KHR_materials_clearcoat")
|
|
1284
|
-
], KHR_materials_clearcoat);
|
|
1285
|
-
|
|
1286
|
-
var KHR_materials_pbrSpecularGlossiness = /*#__PURE__*/ function(ExtensionParser) {
|
|
1287
|
-
_inherits(KHR_materials_pbrSpecularGlossiness, ExtensionParser);
|
|
1288
|
-
function KHR_materials_pbrSpecularGlossiness() {
|
|
1289
|
-
return ExtensionParser.apply(this, arguments);
|
|
1290
|
-
}
|
|
1291
|
-
var _proto = KHR_materials_pbrSpecularGlossiness.prototype;
|
|
1292
|
-
_proto.createEngineResource = function createEngineResource(schema, context) {
|
|
1293
|
-
var _context_glTFResource = context.glTFResource, engine = _context_glTFResource.engine, textures = _context_glTFResource.textures;
|
|
1294
|
-
var material = new miniprogram.PBRSpecularMaterial(engine);
|
|
1295
|
-
var diffuseFactor = schema.diffuseFactor, diffuseTexture = schema.diffuseTexture, specularFactor = schema.specularFactor, glossinessFactor = schema.glossinessFactor, specularGlossinessTexture = schema.specularGlossinessTexture;
|
|
1296
|
-
if (diffuseFactor) {
|
|
1297
|
-
material.baseColor = new miniprogram$1.Color(miniprogram$1.Color.linearToGammaSpace(diffuseFactor[0]), miniprogram$1.Color.linearToGammaSpace(diffuseFactor[1]), miniprogram$1.Color.linearToGammaSpace(diffuseFactor[2]), diffuseFactor[3]);
|
|
1298
|
-
}
|
|
1299
|
-
if (diffuseTexture) {
|
|
1300
|
-
material.baseTexture = textures[diffuseTexture.index];
|
|
1301
|
-
MaterialParser._parseTextureTransform(material, diffuseTexture.extensions, context);
|
|
1302
|
-
}
|
|
1303
|
-
if (specularFactor) {
|
|
1304
|
-
material.specularColor = new miniprogram$1.Color(miniprogram$1.Color.linearToGammaSpace(specularFactor[0]), miniprogram$1.Color.linearToGammaSpace(specularFactor[1]), miniprogram$1.Color.linearToGammaSpace(specularFactor[2]));
|
|
1305
|
-
}
|
|
1306
|
-
if (glossinessFactor !== undefined) {
|
|
1307
|
-
material.glossiness = glossinessFactor;
|
|
1308
|
-
}
|
|
1309
|
-
if (specularGlossinessTexture) {
|
|
1310
|
-
material.specularGlossinessTexture = textures[specularGlossinessTexture.index];
|
|
1311
|
-
MaterialParser._parseTextureTransform(material, specularGlossinessTexture.extensions, context);
|
|
1312
|
-
}
|
|
1313
|
-
return material;
|
|
1314
|
-
};
|
|
1315
|
-
return KHR_materials_pbrSpecularGlossiness;
|
|
1316
|
-
}(ExtensionParser);
|
|
1317
|
-
KHR_materials_pbrSpecularGlossiness = __decorate([
|
|
1318
|
-
registerExtension("KHR_materials_pbrSpecularGlossiness")
|
|
1319
|
-
], KHR_materials_pbrSpecularGlossiness);
|
|
1320
|
-
|
|
1321
|
-
var KHR_materials_unlit = /*#__PURE__*/ function(ExtensionParser) {
|
|
1322
|
-
_inherits(KHR_materials_unlit, ExtensionParser);
|
|
1323
|
-
function KHR_materials_unlit() {
|
|
1324
|
-
return ExtensionParser.apply(this, arguments);
|
|
1325
|
-
}
|
|
1326
|
-
var _proto = KHR_materials_unlit.prototype;
|
|
1327
|
-
_proto.createEngineResource = function createEngineResource(schema, context) {
|
|
1328
|
-
var engine = context.glTFResource.engine;
|
|
1329
|
-
var material = new miniprogram.UnlitMaterial(engine);
|
|
1330
|
-
return material;
|
|
1331
|
-
};
|
|
1332
|
-
return KHR_materials_unlit;
|
|
1333
|
-
}(ExtensionParser);
|
|
1334
|
-
KHR_materials_unlit = __decorate([
|
|
1335
|
-
registerExtension("KHR_materials_unlit")
|
|
1336
|
-
], KHR_materials_unlit);
|
|
1337
|
-
|
|
1338
|
-
var KHR_materials_variants = /*#__PURE__*/ function(ExtensionParser) {
|
|
1339
|
-
_inherits(KHR_materials_variants, ExtensionParser);
|
|
1340
|
-
function KHR_materials_variants() {
|
|
1341
|
-
return ExtensionParser.apply(this, arguments);
|
|
1342
|
-
}
|
|
1343
|
-
var _proto = KHR_materials_variants.prototype;
|
|
1344
|
-
_proto.parseEngineResource = function parseEngineResource(schema, renderer, context) {
|
|
1345
|
-
var _context_gltf = context.gltf, _context_gltf_extensions = _context_gltf.extensions, _context_gltf_extensions_KHR_materials_variants = _context_gltf_extensions.KHR_materials_variants, variantNames = _context_gltf_extensions_KHR_materials_variants.variants, glTFResource = context.glTFResource;
|
|
1346
|
-
var mappings = schema.mappings;
|
|
1347
|
-
for(var i = 0; i < mappings.length; i++){
|
|
1348
|
-
var _mappings_i = mappings[i], material = _mappings_i.material, variants = _mappings_i.variants;
|
|
1349
|
-
if (!glTFResource.variants) glTFResource.variants = [];
|
|
1350
|
-
glTFResource.variants.push({
|
|
1351
|
-
renderer: renderer,
|
|
1352
|
-
material: glTFResource.materials[material],
|
|
1353
|
-
variants: variants.map(function(index) {
|
|
1354
|
-
return variantNames[index].name;
|
|
1355
|
-
})
|
|
1402
|
+
input[input.length - 1];
|
|
1403
|
+
sampleDataCollection.push({
|
|
1404
|
+
type: outputAccessor.type,
|
|
1405
|
+
interpolation: samplerInterpolation,
|
|
1406
|
+
input: input,
|
|
1407
|
+
output: output,
|
|
1408
|
+
outputSize: outputStride
|
|
1356
1409
|
});
|
|
1357
1410
|
}
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
function KHR_mesh_quantization() {
|
|
1368
|
-
return ExtensionParser.apply(this, arguments);
|
|
1369
|
-
}
|
|
1370
|
-
return KHR_mesh_quantization;
|
|
1371
|
-
}(ExtensionParser);
|
|
1372
|
-
KHR_mesh_quantization = __decorate([
|
|
1373
|
-
registerExtension("KHR_mesh_quantization")
|
|
1374
|
-
], KHR_mesh_quantization);
|
|
1375
|
-
|
|
1376
|
-
var KHR_texture_transform = /*#__PURE__*/ function(ExtensionParser) {
|
|
1377
|
-
_inherits(KHR_texture_transform, ExtensionParser);
|
|
1378
|
-
function KHR_texture_transform() {
|
|
1379
|
-
return ExtensionParser.apply(this, arguments);
|
|
1380
|
-
}
|
|
1381
|
-
var _proto = KHR_texture_transform.prototype;
|
|
1382
|
-
_proto.parseEngineResource = function parseEngineResource(schema, material, context) {
|
|
1383
|
-
var offset = schema.offset, rotation = schema.rotation, scale = schema.scale, texCoord = schema.texCoord;
|
|
1384
|
-
if (offset) {
|
|
1385
|
-
material.tilingOffset.z = offset[0];
|
|
1386
|
-
material.tilingOffset.w = offset[1];
|
|
1387
|
-
}
|
|
1388
|
-
if (scale) {
|
|
1389
|
-
material.tilingOffset.x = scale[0];
|
|
1390
|
-
material.tilingOffset.y = scale[1];
|
|
1391
|
-
}
|
|
1392
|
-
if (rotation) {
|
|
1393
|
-
miniprogram.Logger.warn("rotation in KHR_texture_transform is not supported now");
|
|
1394
|
-
}
|
|
1395
|
-
if (texCoord) {
|
|
1396
|
-
miniprogram.Logger.warn("texCoord in KHR_texture_transform is not supported now");
|
|
1397
|
-
}
|
|
1398
|
-
};
|
|
1399
|
-
return KHR_texture_transform;
|
|
1400
|
-
}(ExtensionParser);
|
|
1401
|
-
KHR_texture_transform = __decorate([
|
|
1402
|
-
registerExtension("KHR_texture_transform")
|
|
1403
|
-
], KHR_texture_transform);
|
|
1404
|
-
|
|
1405
|
-
var GalaceanMaterialsRemap = /*#__PURE__*/ function(ExtensionParser) {
|
|
1406
|
-
_inherits(GalaceanMaterialsRemap, ExtensionParser);
|
|
1407
|
-
function GalaceanMaterialsRemap() {
|
|
1408
|
-
return ExtensionParser.apply(this, arguments);
|
|
1409
|
-
}
|
|
1410
|
-
var _proto = GalaceanMaterialsRemap.prototype;
|
|
1411
|
-
_proto.createEngineResource = function createEngineResource(schema, context) {
|
|
1412
|
-
var engine = context.glTFResource.engine;
|
|
1413
|
-
// @ts-ignore
|
|
1414
|
-
return engine.resourceManager.getResourceByRef(schema);
|
|
1415
|
-
};
|
|
1416
|
-
return GalaceanMaterialsRemap;
|
|
1417
|
-
}(ExtensionParser);
|
|
1418
|
-
GalaceanMaterialsRemap = __decorate([
|
|
1419
|
-
registerExtension("OASIS_materials_remap")
|
|
1420
|
-
], GalaceanMaterialsRemap);
|
|
1421
|
-
|
|
1422
|
-
function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
|
|
1423
|
-
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
1424
|
-
|
|
1425
|
-
if (it) return (it = it.call(o)).next.bind(it);
|
|
1426
|
-
// Fallback for engines without symbol support
|
|
1427
|
-
if (Array.isArray(o) || (it = _unsupported_iterable_to_array(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
1428
|
-
if (it) o = it;
|
|
1429
|
-
|
|
1430
|
-
var i = 0;
|
|
1431
|
-
|
|
1432
|
-
return function() {
|
|
1433
|
-
if (i >= o.length) return { done: true };
|
|
1434
|
-
|
|
1435
|
-
return { done: false, value: o[i++] };
|
|
1436
|
-
};
|
|
1437
|
-
}
|
|
1438
|
-
|
|
1439
|
-
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
1440
|
-
}
|
|
1441
|
-
|
|
1442
|
-
var AnimationParser = /*#__PURE__*/ function(Parser) {
|
|
1443
|
-
_inherits(AnimationParser, Parser);
|
|
1444
|
-
function AnimationParser() {
|
|
1445
|
-
return Parser.apply(this, arguments);
|
|
1446
|
-
}
|
|
1447
|
-
var _proto = AnimationParser.prototype;
|
|
1448
|
-
_proto.parse = function parse(context) {
|
|
1449
|
-
var gltf = context.gltf; context.buffers; var glTFResource = context.glTFResource;
|
|
1450
|
-
var entities = glTFResource.entities;
|
|
1451
|
-
var animations = gltf.animations, accessors = gltf.accessors;
|
|
1452
|
-
if (!animations) {
|
|
1453
|
-
return;
|
|
1454
|
-
}
|
|
1455
|
-
var animationClipsPromiseInfo = context.animationClipsPromiseInfo;
|
|
1456
|
-
var animationClipCount = animations.length;
|
|
1457
|
-
var animationClips = new Array(animationClipCount);
|
|
1458
|
-
var animationsIndices = new Array(animationClipCount);
|
|
1459
|
-
for(var i = 0; i < animationClipCount; i++){
|
|
1460
|
-
var gltfAnimation = animations[i];
|
|
1461
|
-
var channels = gltfAnimation.channels, samplers = gltfAnimation.samplers, _gltfAnimation_name = gltfAnimation.name, name = _gltfAnimation_name === void 0 ? "AnimationClip" + i : _gltfAnimation_name;
|
|
1462
|
-
var animationClip = new miniprogram.AnimationClip(name);
|
|
1463
|
-
var sampleDataCollection = new Array();
|
|
1464
|
-
// parse samplers
|
|
1465
|
-
for(var j = 0, m = samplers.length; j < m; j++){
|
|
1466
|
-
var gltfSampler = samplers[j];
|
|
1467
|
-
var inputAccessor = accessors[gltfSampler.input];
|
|
1468
|
-
var outputAccessor = accessors[gltfSampler.output];
|
|
1469
|
-
var input = GLTFUtil.getAccessorBuffer(context, gltf, inputAccessor).data;
|
|
1470
|
-
var output = GLTFUtil.getAccessorBuffer(context, gltf, outputAccessor).data;
|
|
1471
|
-
if (outputAccessor.normalized) {
|
|
1472
|
-
var scale = GLTFUtil.getNormalizedComponentScale(outputAccessor.componentType);
|
|
1473
|
-
var scaled = new Float32Array(output.length);
|
|
1474
|
-
for(var k = 0, v = output.length; k < v; k++){
|
|
1475
|
-
scaled[k] = output[k] * scale;
|
|
1476
|
-
}
|
|
1477
|
-
output = scaled;
|
|
1478
|
-
}
|
|
1479
|
-
var outputStride = output.length / input.length;
|
|
1480
|
-
var _gltfSampler_interpolation;
|
|
1481
|
-
var interpolation = (_gltfSampler_interpolation = gltfSampler.interpolation) != null ? _gltfSampler_interpolation : AnimationSamplerInterpolation.Linear;
|
|
1482
|
-
var samplerInterpolation = void 0;
|
|
1483
|
-
switch(interpolation){
|
|
1484
|
-
case AnimationSamplerInterpolation.CubicSpine:
|
|
1485
|
-
samplerInterpolation = miniprogram.InterpolationType.CubicSpine;
|
|
1486
|
-
break;
|
|
1487
|
-
case AnimationSamplerInterpolation.Step:
|
|
1488
|
-
samplerInterpolation = miniprogram.InterpolationType.Step;
|
|
1489
|
-
break;
|
|
1490
|
-
case AnimationSamplerInterpolation.Linear:
|
|
1491
|
-
samplerInterpolation = miniprogram.InterpolationType.Linear;
|
|
1492
|
-
break;
|
|
1493
|
-
}
|
|
1494
|
-
input[input.length - 1];
|
|
1495
|
-
sampleDataCollection.push({
|
|
1496
|
-
type: outputAccessor.type,
|
|
1497
|
-
interpolation: samplerInterpolation,
|
|
1498
|
-
input: input,
|
|
1499
|
-
output: output,
|
|
1500
|
-
outputSize: outputStride
|
|
1501
|
-
});
|
|
1411
|
+
for(var j1 = 0, m1 = channels.length; j1 < m1; j1++){
|
|
1412
|
+
var gltfChannel = channels[j1];
|
|
1413
|
+
var target = gltfChannel.target;
|
|
1414
|
+
var channelTargetEntity = entities[target.node];
|
|
1415
|
+
var relativePath = "";
|
|
1416
|
+
var entity = channelTargetEntity;
|
|
1417
|
+
while(entity.parent){
|
|
1418
|
+
relativePath = relativePath === "" ? "" + entity.name : entity.name + "/" + relativePath;
|
|
1419
|
+
entity = entity.parent;
|
|
1502
1420
|
}
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
propertyName = "rotationQuaternion";
|
|
1523
|
-
break;
|
|
1524
|
-
case AnimationChannelTargetPath.SCALE:
|
|
1525
|
-
ComponentType = miniprogram.Transform;
|
|
1526
|
-
propertyName = "scale";
|
|
1527
|
-
break;
|
|
1528
|
-
case AnimationChannelTargetPath.WEIGHTS:
|
|
1529
|
-
ComponentType = miniprogram.SkinnedMeshRenderer;
|
|
1530
|
-
propertyName = "blendShapeWeights";
|
|
1531
|
-
break;
|
|
1532
|
-
}
|
|
1533
|
-
var curve = this._addCurve(target.path, gltfChannel, sampleDataCollection);
|
|
1534
|
-
animationClip.addCurveBinding(relativePath, ComponentType, propertyName, curve);
|
|
1421
|
+
var ComponentType = void 0;
|
|
1422
|
+
var propertyName = void 0;
|
|
1423
|
+
switch(target.path){
|
|
1424
|
+
case AnimationChannelTargetPath.TRANSLATION:
|
|
1425
|
+
ComponentType = miniprogram.Transform;
|
|
1426
|
+
propertyName = "position";
|
|
1427
|
+
break;
|
|
1428
|
+
case AnimationChannelTargetPath.ROTATION:
|
|
1429
|
+
ComponentType = miniprogram.Transform;
|
|
1430
|
+
propertyName = "rotationQuaternion";
|
|
1431
|
+
break;
|
|
1432
|
+
case AnimationChannelTargetPath.SCALE:
|
|
1433
|
+
ComponentType = miniprogram.Transform;
|
|
1434
|
+
propertyName = "scale";
|
|
1435
|
+
break;
|
|
1436
|
+
case AnimationChannelTargetPath.WEIGHTS:
|
|
1437
|
+
ComponentType = miniprogram.SkinnedMeshRenderer;
|
|
1438
|
+
propertyName = "blendShapeWeights";
|
|
1439
|
+
break;
|
|
1535
1440
|
}
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
name: name,
|
|
1539
|
-
index: i
|
|
1540
|
-
};
|
|
1441
|
+
var curve = this._addCurve(target.path, gltfChannel, sampleDataCollection);
|
|
1442
|
+
animationClip.addCurveBinding(relativePath, ComponentType, propertyName, curve);
|
|
1541
1443
|
}
|
|
1542
|
-
glTFResource.animations = animationClips;
|
|
1543
|
-
// @ts-ignore for editor
|
|
1544
|
-
glTFResource._animationsIndices = animationsIndices;
|
|
1545
|
-
animationClipsPromiseInfo.resolve(animationClips);
|
|
1546
|
-
return animationClipsPromiseInfo.promise;
|
|
1547
1444
|
};
|
|
1548
|
-
|
|
1445
|
+
GLTFAnimationParser._addCurve = function _addCurve(animationChannelTargetPath, gltfChannel, sampleDataCollection) {
|
|
1549
1446
|
var sampleData = sampleDataCollection[gltfChannel.sampler];
|
|
1550
1447
|
var input = sampleData.input, output = sampleData.output, outputSize = sampleData.outputSize;
|
|
1551
|
-
switch(
|
|
1448
|
+
switch(animationChannelTargetPath){
|
|
1552
1449
|
case AnimationChannelTargetPath.TRANSLATION:
|
|
1553
1450
|
case AnimationChannelTargetPath.SCALE:
|
|
1554
1451
|
{
|
|
@@ -1613,35 +1510,42 @@ var AnimationParser = /*#__PURE__*/ function(Parser) {
|
|
|
1613
1510
|
}
|
|
1614
1511
|
}
|
|
1615
1512
|
};
|
|
1616
|
-
return
|
|
1617
|
-
}(
|
|
1513
|
+
return GLTFAnimationParser;
|
|
1514
|
+
}(GLTFParser);
|
|
1618
1515
|
|
|
1619
|
-
var
|
|
1620
|
-
_inherits(
|
|
1621
|
-
function
|
|
1622
|
-
return
|
|
1516
|
+
var GLTFBufferParser = /*#__PURE__*/ function(GLTFParser) {
|
|
1517
|
+
_inherits(GLTFBufferParser, GLTFParser);
|
|
1518
|
+
function GLTFBufferParser() {
|
|
1519
|
+
return GLTFParser.apply(this, arguments);
|
|
1623
1520
|
}
|
|
1624
|
-
var _proto =
|
|
1521
|
+
var _proto = GLTFBufferParser.prototype;
|
|
1625
1522
|
_proto.parse = function parse(context) {
|
|
1626
|
-
var glTFResource = context.glTFResource;
|
|
1523
|
+
var glTFResource = context.glTFResource, contentRestorer = context.contentRestorer;
|
|
1627
1524
|
var url = glTFResource.url;
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1525
|
+
var restoreBufferRequests = contentRestorer.bufferRequests;
|
|
1526
|
+
var requestConfig = {
|
|
1527
|
+
type: "arraybuffer"
|
|
1528
|
+
};
|
|
1529
|
+
var isGLB = this._isGLB(url);
|
|
1530
|
+
contentRestorer.isGLB = isGLB;
|
|
1531
|
+
if (isGLB) {
|
|
1532
|
+
return miniprogram.request(url, requestConfig).then(function(glb) {
|
|
1533
|
+
restoreBufferRequests.push(new BufferRequestInfo(url, requestConfig));
|
|
1534
|
+
return GLTFUtils.parseGLB(context, glb);
|
|
1535
|
+
}).then(function(param) {
|
|
1536
|
+
var glTF = param.glTF, buffers = param.buffers;
|
|
1537
|
+
context.glTF = glTF;
|
|
1634
1538
|
context.buffers = buffers;
|
|
1635
1539
|
});
|
|
1636
1540
|
} else {
|
|
1637
1541
|
return miniprogram.request(url, {
|
|
1638
1542
|
type: "json"
|
|
1639
|
-
}).then(function(
|
|
1640
|
-
context.
|
|
1641
|
-
return Promise.all(
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1543
|
+
}).then(function(glTF) {
|
|
1544
|
+
context.glTF = glTF;
|
|
1545
|
+
return Promise.all(glTF.buffers.map(function(buffer) {
|
|
1546
|
+
var absoluteUrl = miniprogram.Utils.resolveAbsoluteUrl(url, buffer.uri);
|
|
1547
|
+
restoreBufferRequests.push(new BufferRequestInfo(absoluteUrl, requestConfig));
|
|
1548
|
+
return miniprogram.request(absoluteUrl, requestConfig);
|
|
1645
1549
|
})).then(function(buffers) {
|
|
1646
1550
|
context.buffers = buffers;
|
|
1647
1551
|
});
|
|
@@ -1652,24 +1556,24 @@ var BufferParser = /*#__PURE__*/ function(Parser) {
|
|
|
1652
1556
|
var index = url.lastIndexOf(".");
|
|
1653
1557
|
return url.substring(index + 1, index + 4) === "glb";
|
|
1654
1558
|
};
|
|
1655
|
-
return
|
|
1656
|
-
}(
|
|
1559
|
+
return GLTFBufferParser;
|
|
1560
|
+
}(GLTFParser);
|
|
1657
1561
|
|
|
1658
|
-
var
|
|
1659
|
-
_inherits(
|
|
1660
|
-
function
|
|
1661
|
-
return
|
|
1562
|
+
var GLTFEntityParser = /*#__PURE__*/ function(GLTFParser) {
|
|
1563
|
+
_inherits(GLTFEntityParser, GLTFParser);
|
|
1564
|
+
function GLTFEntityParser() {
|
|
1565
|
+
return GLTFParser.apply(this, arguments);
|
|
1662
1566
|
}
|
|
1663
|
-
var _proto =
|
|
1567
|
+
var _proto = GLTFEntityParser.prototype;
|
|
1664
1568
|
_proto.parse = function parse(context) {
|
|
1665
|
-
var glTFResource = context.glTFResource, nodes = context.
|
|
1569
|
+
var glTFResource = context.glTFResource, nodes = context.glTF.nodes;
|
|
1666
1570
|
var engine = glTFResource.engine;
|
|
1667
1571
|
if (!nodes) return;
|
|
1668
1572
|
var entities = [];
|
|
1669
1573
|
for(var i = 0; i < nodes.length; i++){
|
|
1670
1574
|
var gltfNode = nodes[i];
|
|
1671
1575
|
var matrix = gltfNode.matrix, translation = gltfNode.translation, rotation = gltfNode.rotation, scale = gltfNode.scale;
|
|
1672
|
-
var entity = new miniprogram.Entity(engine, gltfNode.name || "" +
|
|
1576
|
+
var entity = new miniprogram.Entity(engine, gltfNode.name || "" + GLTFEntityParser._defaultName + i);
|
|
1673
1577
|
var transform = entity.transform;
|
|
1674
1578
|
if (matrix) {
|
|
1675
1579
|
var localMatrix = transform.localMatrix;
|
|
@@ -1693,7 +1597,7 @@ var EntityParser = /*#__PURE__*/ function(Parser) {
|
|
|
1693
1597
|
this._createSceneRoots(context, glTFResource);
|
|
1694
1598
|
};
|
|
1695
1599
|
_proto._buildEntityTree = function _buildEntityTree(context, glTFResource) {
|
|
1696
|
-
var nodes = context.
|
|
1600
|
+
var nodes = context.glTF.nodes;
|
|
1697
1601
|
var entities = glTFResource.entities;
|
|
1698
1602
|
for(var i = 0; i < nodes.length; i++){
|
|
1699
1603
|
var children = nodes[i].children;
|
|
@@ -1707,7 +1611,7 @@ var EntityParser = /*#__PURE__*/ function(Parser) {
|
|
|
1707
1611
|
}
|
|
1708
1612
|
};
|
|
1709
1613
|
_proto._createSceneRoots = function _createSceneRoots(context, glTFResource) {
|
|
1710
|
-
var
|
|
1614
|
+
var _context_glTF = context.glTF, tmp = _context_glTF.scene, sceneID = tmp === void 0 ? 0 : tmp, scenes = _context_glTF.scenes;
|
|
1711
1615
|
var engine = glTFResource.engine, entities = glTFResource.entities;
|
|
1712
1616
|
if (!scenes) return;
|
|
1713
1617
|
var sceneRoots = [];
|
|
@@ -1727,82 +1631,196 @@ var EntityParser = /*#__PURE__*/ function(Parser) {
|
|
|
1727
1631
|
glTFResource.sceneRoots = sceneRoots;
|
|
1728
1632
|
glTFResource.defaultSceneRoot = sceneRoots[sceneID];
|
|
1729
1633
|
};
|
|
1730
|
-
return
|
|
1731
|
-
}(
|
|
1634
|
+
return GLTFEntityParser;
|
|
1635
|
+
}(GLTFParser);
|
|
1732
1636
|
(function() {
|
|
1733
|
-
/** @internal */
|
|
1637
|
+
/** @internal */ GLTFEntityParser._defaultName = "_GLTF_ENTITY_";
|
|
1734
1638
|
})();
|
|
1735
1639
|
|
|
1736
|
-
var
|
|
1737
|
-
_inherits(
|
|
1738
|
-
function
|
|
1739
|
-
return
|
|
1640
|
+
var GLTFMaterialParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
1641
|
+
_inherits(GLTFMaterialParser, GLTFParser1);
|
|
1642
|
+
function GLTFMaterialParser() {
|
|
1643
|
+
return GLTFParser1.apply(this, arguments);
|
|
1740
1644
|
}
|
|
1741
|
-
var _proto =
|
|
1645
|
+
var _proto = GLTFMaterialParser.prototype;
|
|
1742
1646
|
_proto.parse = function parse(context) {
|
|
1743
|
-
var
|
|
1744
|
-
|
|
1745
|
-
var gltfPrimitive = gltfMesh.primitives[j];
|
|
1746
|
-
var _gltfPrimitive_extensions = gltfPrimitive.extensions, extensions = _gltfPrimitive_extensions === void 0 ? {} : _gltfPrimitive_extensions;
|
|
1747
|
-
var KHR_draco_mesh_compression = extensions.KHR_draco_mesh_compression;
|
|
1748
|
-
primitivePromises[j] = new Promise(function(resolve) {
|
|
1749
|
-
var mesh = new miniprogram.ModelMesh(engine, gltfMesh.name || j + "");
|
|
1750
|
-
if (KHR_draco_mesh_compression) {
|
|
1751
|
-
Parser.createEngineResource("KHR_draco_mesh_compression", KHR_draco_mesh_compression, context, gltfPrimitive).then(function(decodedGeometry) {
|
|
1752
|
-
return _this._parseMeshFromGLTFPrimitiveDraco(mesh, gltfMesh, gltfPrimitive, gltf, function(attributeSemantic) {
|
|
1753
|
-
for(var j = 0; j < decodedGeometry.attributes.length; j++){
|
|
1754
|
-
if (decodedGeometry.attributes[j].name === attributeSemantic) {
|
|
1755
|
-
return decodedGeometry.attributes[j].array;
|
|
1756
|
-
}
|
|
1757
|
-
}
|
|
1758
|
-
return null;
|
|
1759
|
-
}, function(attributeSemantic, shapeIndex) {
|
|
1760
|
-
throw "BlendShape animation is not supported when using draco.";
|
|
1761
|
-
}, function() {
|
|
1762
|
-
return decodedGeometry.index.array;
|
|
1763
|
-
}, context.keepMeshData);
|
|
1764
|
-
}).then(resolve);
|
|
1765
|
-
} else {
|
|
1766
|
-
_this._parseMeshFromGLTFPrimitive(context, mesh, gltfMesh, gltfPrimitive, gltf, function(attributeSemantic) {
|
|
1767
|
-
return null;
|
|
1768
|
-
}, function(attributeName, shapeIndex) {
|
|
1769
|
-
var shapeAccessorIdx = gltfPrimitive.targets[shapeIndex];
|
|
1770
|
-
var attributeAccessorIdx = shapeAccessorIdx[attributeName];
|
|
1771
|
-
if (attributeAccessorIdx) {
|
|
1772
|
-
var accessor = gltf.accessors[attributeAccessorIdx];
|
|
1773
|
-
return GLTFUtil.getAccessorData(gltf, accessor, buffers);
|
|
1774
|
-
} else {
|
|
1775
|
-
return null;
|
|
1776
|
-
}
|
|
1777
|
-
}, function() {
|
|
1778
|
-
var indexAccessor = gltf.accessors[gltfPrimitive.indices];
|
|
1779
|
-
return GLTFUtil.getAccessorData(gltf, indexAccessor, buffers);
|
|
1780
|
-
}, context.keepMeshData).then(resolve);
|
|
1781
|
-
}
|
|
1782
|
-
});
|
|
1783
|
-
};
|
|
1784
|
-
var gltfMesh = gltf.meshes[i];
|
|
1785
|
-
var primitivePromises = [];
|
|
1786
|
-
for(var j = 0; j < gltfMesh.primitives.length; j++)_loop(j);
|
|
1787
|
-
meshPromises[i] = Promise.all(primitivePromises);
|
|
1788
|
-
};
|
|
1789
|
-
var _this = this;
|
|
1790
|
-
var gltf = context.gltf, buffers = context.buffers, glTFResource = context.glTFResource;
|
|
1647
|
+
var glTF = context.glTF, glTFResource = context.glTFResource, materialsPromiseInfo = context.materialsPromiseInfo;
|
|
1648
|
+
if (!glTF.materials) return;
|
|
1791
1649
|
var engine = glTFResource.engine;
|
|
1792
|
-
|
|
1793
|
-
var
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1650
|
+
var materialPromises = [];
|
|
1651
|
+
for(var i = 0; i < glTF.materials.length; i++){
|
|
1652
|
+
var materialInfo = glTF.materials[i];
|
|
1653
|
+
var material = GLTFParser.executeExtensionsCreateAndParse(materialInfo.extensions, context, materialInfo);
|
|
1654
|
+
if (!material) {
|
|
1655
|
+
material = new miniprogram.PBRMaterial(engine);
|
|
1656
|
+
material.name = materialInfo.name;
|
|
1657
|
+
GLTFMaterialParser._parseStandardProperty(context, material, materialInfo);
|
|
1658
|
+
}
|
|
1659
|
+
materialPromises.push(material);
|
|
1660
|
+
}
|
|
1661
|
+
return miniprogram.AssetPromise.all(materialPromises).then(function(materials) {
|
|
1662
|
+
glTFResource.materials = materials;
|
|
1663
|
+
for(var i = 0; i < glTF.materials.length; i++){
|
|
1664
|
+
var materialInfo = glTF.materials[i];
|
|
1665
|
+
GLTFParser.executeExtensionsAdditiveAndParse(materialInfo.extensions, context, materials[i], materialInfo);
|
|
1666
|
+
}
|
|
1667
|
+
materialsPromiseInfo.resolve(materials);
|
|
1668
|
+
return materialsPromiseInfo.promise;
|
|
1669
|
+
});
|
|
1801
1670
|
};
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
var
|
|
1671
|
+
/**
|
|
1672
|
+
* @internal
|
|
1673
|
+
*/ GLTFMaterialParser._checkOtherTextureTransform = function _checkOtherTextureTransform(texture, textureName) {
|
|
1674
|
+
var _texture_extensions;
|
|
1675
|
+
if ((_texture_extensions = texture.extensions) == null ? void 0 : _texture_extensions.KHR_texture_transform) {
|
|
1676
|
+
miniprogram.Logger.warn("" + textureName + " texture always use the KHR_texture_transform of the base texture.");
|
|
1677
|
+
}
|
|
1678
|
+
};
|
|
1679
|
+
/**
|
|
1680
|
+
* @internal
|
|
1681
|
+
*/ GLTFMaterialParser._parseStandardProperty = function _parseStandardProperty(context, material, materialInfo) {
|
|
1682
|
+
var textures = context.glTFResource.textures;
|
|
1683
|
+
var pbrMetallicRoughness = materialInfo.pbrMetallicRoughness, normalTexture = materialInfo.normalTexture, occlusionTexture = materialInfo.occlusionTexture, emissiveTexture = materialInfo.emissiveTexture, emissiveFactor = materialInfo.emissiveFactor, alphaMode = materialInfo.alphaMode, alphaCutoff = materialInfo.alphaCutoff, doubleSided = materialInfo.doubleSided;
|
|
1684
|
+
if (pbrMetallicRoughness) {
|
|
1685
|
+
var baseColorFactor = pbrMetallicRoughness.baseColorFactor, baseColorTexture = pbrMetallicRoughness.baseColorTexture, metallicFactor = pbrMetallicRoughness.metallicFactor, roughnessFactor = pbrMetallicRoughness.roughnessFactor, metallicRoughnessTexture = pbrMetallicRoughness.metallicRoughnessTexture;
|
|
1686
|
+
if (baseColorFactor) {
|
|
1687
|
+
material.baseColor = new miniprogram$1.Color(miniprogram$1.Color.linearToGammaSpace(baseColorFactor[0]), miniprogram$1.Color.linearToGammaSpace(baseColorFactor[1]), miniprogram$1.Color.linearToGammaSpace(baseColorFactor[2]), baseColorFactor[3]);
|
|
1688
|
+
}
|
|
1689
|
+
if (baseColorTexture) {
|
|
1690
|
+
material.baseTexture = textures[baseColorTexture.index];
|
|
1691
|
+
GLTFParser.executeExtensionsAdditiveAndParse(baseColorTexture.extensions, context, material, baseColorTexture);
|
|
1692
|
+
}
|
|
1693
|
+
if (material.constructor === miniprogram.PBRMaterial) {
|
|
1694
|
+
material.metallic = metallicFactor != null ? metallicFactor : 1;
|
|
1695
|
+
material.roughness = roughnessFactor != null ? roughnessFactor : 1;
|
|
1696
|
+
if (metallicRoughnessTexture) {
|
|
1697
|
+
material.roughnessMetallicTexture = textures[metallicRoughnessTexture.index];
|
|
1698
|
+
GLTFMaterialParser._checkOtherTextureTransform(metallicRoughnessTexture, "Roughness metallic");
|
|
1699
|
+
}
|
|
1700
|
+
}
|
|
1701
|
+
}
|
|
1702
|
+
if (material.constructor === miniprogram.PBRMaterial || material.constructor === miniprogram.PBRSpecularMaterial) {
|
|
1703
|
+
if (emissiveTexture) {
|
|
1704
|
+
material.emissiveTexture = textures[emissiveTexture.index];
|
|
1705
|
+
GLTFMaterialParser._checkOtherTextureTransform(emissiveTexture, "Emissive");
|
|
1706
|
+
}
|
|
1707
|
+
if (emissiveFactor) {
|
|
1708
|
+
material.emissiveColor = new miniprogram$1.Color(miniprogram$1.Color.linearToGammaSpace(emissiveFactor[0]), miniprogram$1.Color.linearToGammaSpace(emissiveFactor[1]), miniprogram$1.Color.linearToGammaSpace(emissiveFactor[2]));
|
|
1709
|
+
}
|
|
1710
|
+
if (normalTexture) {
|
|
1711
|
+
var index = normalTexture.index, scale = normalTexture.scale;
|
|
1712
|
+
material.normalTexture = textures[index];
|
|
1713
|
+
GLTFMaterialParser._checkOtherTextureTransform(normalTexture, "Normal");
|
|
1714
|
+
if (scale !== undefined) {
|
|
1715
|
+
material.normalTextureIntensity = scale;
|
|
1716
|
+
}
|
|
1717
|
+
}
|
|
1718
|
+
if (occlusionTexture) {
|
|
1719
|
+
var index1 = occlusionTexture.index, strength = occlusionTexture.strength, texCoord = occlusionTexture.texCoord;
|
|
1720
|
+
material.occlusionTexture = textures[index1];
|
|
1721
|
+
GLTFMaterialParser._checkOtherTextureTransform(occlusionTexture, "Occlusion");
|
|
1722
|
+
if (strength !== undefined) {
|
|
1723
|
+
material.occlusionTextureIntensity = strength;
|
|
1724
|
+
}
|
|
1725
|
+
if (texCoord === miniprogram.TextureCoordinate.UV1) {
|
|
1726
|
+
material.occlusionTextureCoord = miniprogram.TextureCoordinate.UV1;
|
|
1727
|
+
} else if (texCoord > miniprogram.TextureCoordinate.UV1) {
|
|
1728
|
+
miniprogram.Logger.warn("Occlusion texture uv coordinate must be UV0 or UV1.");
|
|
1729
|
+
}
|
|
1730
|
+
}
|
|
1731
|
+
}
|
|
1732
|
+
if (doubleSided) {
|
|
1733
|
+
material.renderFace = miniprogram.RenderFace.Double;
|
|
1734
|
+
} else {
|
|
1735
|
+
material.renderFace = miniprogram.RenderFace.Front;
|
|
1736
|
+
}
|
|
1737
|
+
switch(alphaMode){
|
|
1738
|
+
case MaterialAlphaMode.OPAQUE:
|
|
1739
|
+
material.isTransparent = false;
|
|
1740
|
+
break;
|
|
1741
|
+
case MaterialAlphaMode.BLEND:
|
|
1742
|
+
material.isTransparent = true;
|
|
1743
|
+
break;
|
|
1744
|
+
case MaterialAlphaMode.MASK:
|
|
1745
|
+
material.alphaCutoff = alphaCutoff != null ? alphaCutoff : 0.5;
|
|
1746
|
+
break;
|
|
1747
|
+
}
|
|
1748
|
+
};
|
|
1749
|
+
return GLTFMaterialParser;
|
|
1750
|
+
}(GLTFParser);
|
|
1751
|
+
|
|
1752
|
+
function _instanceof(left, right) {
|
|
1753
|
+
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
1754
|
+
return !!right[Symbol.hasInstance](left);
|
|
1755
|
+
} else return left instanceof right;
|
|
1756
|
+
}
|
|
1757
|
+
|
|
1758
|
+
var GLTFMeshParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
1759
|
+
_inherits(GLTFMeshParser, GLTFParser1);
|
|
1760
|
+
function GLTFMeshParser() {
|
|
1761
|
+
return GLTFParser1.apply(this, arguments);
|
|
1762
|
+
}
|
|
1763
|
+
var _proto = GLTFMeshParser.prototype;
|
|
1764
|
+
_proto.parse = function parse(context) {
|
|
1765
|
+
var _loop = function(i) {
|
|
1766
|
+
var _loop = function(j) {
|
|
1767
|
+
var gltfPrimitive = gltfMesh.primitives[j];
|
|
1768
|
+
primitivePromises[j] = new Promise(function(resolve) {
|
|
1769
|
+
var mesh = GLTFParser.executeExtensionsCreateAndParse(gltfPrimitive.extensions, context, gltfPrimitive, gltfMesh);
|
|
1770
|
+
if (mesh) {
|
|
1771
|
+
if (_instanceof(mesh, miniprogram.ModelMesh)) {
|
|
1772
|
+
resolve(mesh);
|
|
1773
|
+
} else {
|
|
1774
|
+
mesh.then(function(mesh) {
|
|
1775
|
+
return resolve(mesh);
|
|
1776
|
+
});
|
|
1777
|
+
}
|
|
1778
|
+
} else {
|
|
1779
|
+
var mesh1 = new miniprogram.ModelMesh(engine, gltfMesh.name || j + "");
|
|
1780
|
+
var meshRestoreInfo = new ModelMeshRestoreInfo();
|
|
1781
|
+
meshRestoreInfo.mesh = mesh1;
|
|
1782
|
+
context.contentRestorer.meshes.push(meshRestoreInfo);
|
|
1783
|
+
GLTFMeshParser._parseMeshFromGLTFPrimitive(context, mesh1, meshRestoreInfo, gltfMesh, gltfPrimitive, glTF, function(attributeSemantic) {
|
|
1784
|
+
return null;
|
|
1785
|
+
}, function(attributeName, shapeIndex) {
|
|
1786
|
+
var shapeAccessorIdx = gltfPrimitive.targets[shapeIndex];
|
|
1787
|
+
var attributeAccessorIdx = shapeAccessorIdx[attributeName];
|
|
1788
|
+
if (attributeAccessorIdx) {
|
|
1789
|
+
var accessor = glTF.accessors[attributeAccessorIdx];
|
|
1790
|
+
return GLTFUtils.getAccessorBuffer(context, context.glTF.bufferViews, accessor);
|
|
1791
|
+
} else {
|
|
1792
|
+
return null;
|
|
1793
|
+
}
|
|
1794
|
+
}, function() {
|
|
1795
|
+
var indexAccessor = glTF.accessors[gltfPrimitive.indices];
|
|
1796
|
+
return GLTFUtils.getAccessorData(glTF, indexAccessor, buffers);
|
|
1797
|
+
}, context.keepMeshData).then(resolve);
|
|
1798
|
+
}
|
|
1799
|
+
});
|
|
1800
|
+
};
|
|
1801
|
+
var gltfMesh = glTF.meshes[i];
|
|
1802
|
+
var primitivePromises = [];
|
|
1803
|
+
for(var j = 0; j < gltfMesh.primitives.length; j++)_loop(j);
|
|
1804
|
+
meshPromises[i] = Promise.all(primitivePromises);
|
|
1805
|
+
};
|
|
1806
|
+
var glTF = context.glTF, buffers = context.buffers, glTFResource = context.glTFResource;
|
|
1807
|
+
var engine = glTFResource.engine;
|
|
1808
|
+
if (!glTF.meshes) return;
|
|
1809
|
+
var meshesPromiseInfo = context.meshesPromiseInfo;
|
|
1810
|
+
var meshPromises = [];
|
|
1811
|
+
for(var i = 0; i < glTF.meshes.length; i++)_loop(i);
|
|
1812
|
+
miniprogram.AssetPromise.all(meshPromises).then(function(meshes) {
|
|
1813
|
+
glTFResource.meshes = meshes;
|
|
1814
|
+
meshesPromiseInfo.resolve(meshes);
|
|
1815
|
+
}).catch(meshesPromiseInfo.reject);
|
|
1816
|
+
return meshesPromiseInfo.promise;
|
|
1817
|
+
};
|
|
1818
|
+
/**
|
|
1819
|
+
* @internal
|
|
1820
|
+
*/ GLTFMeshParser._parseMeshFromGLTFPrimitive = function _parseMeshFromGLTFPrimitive(context, mesh, meshRestoreInfo, gltfMesh, gltfPrimitive, gltf, getVertexBufferData, getBlendShapeData, getIndexBufferData, keepMeshData) {
|
|
1821
|
+
var accessors = gltf.accessors;
|
|
1822
|
+
context.buffers;
|
|
1823
|
+
var attributes = gltfPrimitive.attributes, targets = gltfPrimitive.targets, indices = gltfPrimitive.indices, mode = gltfPrimitive.mode;
|
|
1806
1824
|
var engine = mesh.engine;
|
|
1807
1825
|
var vertexElements = new Array();
|
|
1808
1826
|
var vertexCount;
|
|
@@ -1811,14 +1829,14 @@ var MeshParser = /*#__PURE__*/ function(Parser1) {
|
|
|
1811
1829
|
keepMeshData && (positions = new Array(vertexCount));
|
|
1812
1830
|
for(var attribute in attributes){
|
|
1813
1831
|
var accessor = accessors[attributes[attribute]];
|
|
1814
|
-
var accessorBuffer =
|
|
1815
|
-
var
|
|
1832
|
+
var accessorBuffer = GLTFUtils.getAccessorBuffer(context, gltf.bufferViews, accessor);
|
|
1833
|
+
var dataElementSize = GLTFUtils.getAccessorTypeSize(accessor.type);
|
|
1816
1834
|
var attributeCount = accessor.count;
|
|
1817
1835
|
var vertices = accessorBuffer.data;
|
|
1818
1836
|
var vertexElement = void 0;
|
|
1819
1837
|
var meshId = mesh.instanceId;
|
|
1820
1838
|
var vertexBindingInfos = accessorBuffer.vertexBindingInfos;
|
|
1821
|
-
var elementFormat =
|
|
1839
|
+
var elementFormat = GLTFUtils.getElementFormat(accessor.componentType, dataElementSize, accessor.normalized);
|
|
1822
1840
|
if (accessorBuffer.interleaved) {
|
|
1823
1841
|
var byteOffset = accessor.byteOffset || 0;
|
|
1824
1842
|
var stride = accessorBuffer.stride;
|
|
@@ -1830,6 +1848,7 @@ var MeshParser = /*#__PURE__*/ function(Parser1) {
|
|
|
1830
1848
|
vertexBuffer = new miniprogram.Buffer(engine, miniprogram.BufferBindFlag.VertexBuffer, vertices.byteLength, miniprogram.BufferUsage.Static);
|
|
1831
1849
|
vertexBuffer.setData(vertices);
|
|
1832
1850
|
accessorBuffer.vertexBuffer = vertexBuffer;
|
|
1851
|
+
meshRestoreInfo.vertexBuffers.push(new BufferRestoreInfo(vertexBuffer, accessorBuffer.restoreInfo));
|
|
1833
1852
|
}
|
|
1834
1853
|
mesh.setVertexBufferBinding(vertexBuffer, stride, bufferBindIndex);
|
|
1835
1854
|
vertexBindingInfos[meshId] = bufferBindIndex++;
|
|
@@ -1840,6 +1859,7 @@ var MeshParser = /*#__PURE__*/ function(Parser1) {
|
|
|
1840
1859
|
vertexElement = new miniprogram.VertexElement(attribute, 0, elementFormat, bufferBindIndex);
|
|
1841
1860
|
var vertexBuffer1 = new miniprogram.Buffer(engine, miniprogram.BufferBindFlag.VertexBuffer, vertices.byteLength, miniprogram.BufferUsage.Static);
|
|
1842
1861
|
vertexBuffer1.setData(vertices);
|
|
1862
|
+
meshRestoreInfo.vertexBuffers.push(new BufferRestoreInfo(vertexBuffer1, accessorBuffer.restoreInfo));
|
|
1843
1863
|
mesh.setVertexBufferBinding(vertexBuffer1, accessorBuffer.stride, bufferBindIndex);
|
|
1844
1864
|
vertexBindingInfos[meshId] = bufferBindIndex++;
|
|
1845
1865
|
}
|
|
@@ -1858,7 +1878,7 @@ var MeshParser = /*#__PURE__*/ function(Parser1) {
|
|
|
1858
1878
|
}
|
|
1859
1879
|
}
|
|
1860
1880
|
} else {
|
|
1861
|
-
var position =
|
|
1881
|
+
var position = GLTFMeshParser._tempVector3;
|
|
1862
1882
|
min.set(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
|
|
1863
1883
|
max.set(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
|
|
1864
1884
|
var stride2 = vertices.length / attributeCount;
|
|
@@ -1867,13 +1887,12 @@ var MeshParser = /*#__PURE__*/ function(Parser1) {
|
|
|
1867
1887
|
position.copyFromArray(vertices, offset1);
|
|
1868
1888
|
miniprogram$1.Vector3.min(min, position, min);
|
|
1869
1889
|
miniprogram$1.Vector3.max(max, position, max);
|
|
1870
|
-
keepMeshData && (positions[j1] = position.clone());
|
|
1871
1890
|
}
|
|
1872
1891
|
}
|
|
1873
1892
|
if (accessor.normalized) {
|
|
1874
|
-
var
|
|
1875
|
-
min.scale(
|
|
1876
|
-
max.scale(
|
|
1893
|
+
var scaleFactor = GLTFUtils.getNormalizedComponentScale(accessor.componentType);
|
|
1894
|
+
min.scale(scaleFactor);
|
|
1895
|
+
max.scale(scaleFactor);
|
|
1877
1896
|
}
|
|
1878
1897
|
}
|
|
1879
1898
|
}
|
|
@@ -1881,179 +1900,72 @@ var MeshParser = /*#__PURE__*/ function(Parser1) {
|
|
|
1881
1900
|
// Indices
|
|
1882
1901
|
if (indices !== undefined) {
|
|
1883
1902
|
var indexAccessor = gltf.accessors[indices];
|
|
1884
|
-
var
|
|
1885
|
-
mesh.setIndices(
|
|
1903
|
+
var accessorBuffer1 = GLTFUtils.getAccessorBuffer(context, gltf.bufferViews, indexAccessor);
|
|
1904
|
+
mesh.setIndices(accessorBuffer1.data);
|
|
1886
1905
|
mesh.addSubMesh(0, indexAccessor.count, mode);
|
|
1906
|
+
meshRestoreInfo.indexBuffer = accessorBuffer1.restoreInfo;
|
|
1887
1907
|
} else {
|
|
1888
1908
|
mesh.addSubMesh(0, vertexCount, mode);
|
|
1889
1909
|
}
|
|
1890
1910
|
// BlendShapes
|
|
1891
|
-
targets &&
|
|
1911
|
+
targets && GLTFMeshParser._createBlendShape(mesh, meshRestoreInfo, gltfMesh, targets, getBlendShapeData);
|
|
1892
1912
|
mesh.uploadData(!keepMeshData);
|
|
1893
1913
|
//@ts-ignore
|
|
1894
1914
|
mesh._positions = positions;
|
|
1895
1915
|
return Promise.resolve(mesh);
|
|
1896
1916
|
};
|
|
1897
|
-
|
|
1917
|
+
/**
|
|
1918
|
+
* @internal
|
|
1919
|
+
*/ GLTFMeshParser._createBlendShape = function _createBlendShape(mesh, meshRestoreInfo, glTFMesh, glTFTargets, getBlendShapeData) {
|
|
1898
1920
|
var blendShapeNames = glTFMesh.extras ? glTFMesh.extras.targetNames : null;
|
|
1899
1921
|
for(var i = 0, n = glTFTargets.length; i < n; i++){
|
|
1900
1922
|
var name = blendShapeNames ? blendShapeNames[i] : "blendShape" + i;
|
|
1901
|
-
var
|
|
1902
|
-
var
|
|
1903
|
-
var
|
|
1904
|
-
var deltaPositions =
|
|
1905
|
-
var deltaNormals =
|
|
1906
|
-
var deltaTangents =
|
|
1923
|
+
var deltaPosBufferInfo = getBlendShapeData("POSITION", i);
|
|
1924
|
+
var deltaNorBufferInfo = getBlendShapeData("NORMAL", i);
|
|
1925
|
+
var deltaTanBufferInfo = getBlendShapeData("TANGENT", i);
|
|
1926
|
+
var deltaPositions = deltaPosBufferInfo.data ? GLTFUtils.floatBufferToVector3Array(deltaPosBufferInfo.data) : null;
|
|
1927
|
+
var deltaNormals = (deltaNorBufferInfo == null ? void 0 : deltaNorBufferInfo.data) ? GLTFUtils.floatBufferToVector3Array(deltaNorBufferInfo == null ? void 0 : deltaNorBufferInfo.data) : null;
|
|
1928
|
+
var deltaTangents = (deltaTanBufferInfo == null ? void 0 : deltaTanBufferInfo.data) ? GLTFUtils.floatBufferToVector3Array(deltaTanBufferInfo == null ? void 0 : deltaTanBufferInfo.data) : null;
|
|
1907
1929
|
var blendShape = new miniprogram.BlendShape(name);
|
|
1908
1930
|
blendShape.addFrame(1.0, deltaPositions, deltaNormals, deltaTangents);
|
|
1909
1931
|
mesh.addBlendShape(blendShape);
|
|
1932
|
+
meshRestoreInfo.blendShapes.push(new BlendShapeRestoreInfo(blendShape, deltaPosBufferInfo.restoreInfo, deltaNorBufferInfo == null ? void 0 : deltaNorBufferInfo.restoreInfo, deltaTanBufferInfo == null ? void 0 : deltaTanBufferInfo.restoreInfo));
|
|
1910
1933
|
}
|
|
1911
1934
|
};
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
*/ _proto._parseMeshFromGLTFPrimitiveDraco = function _parseMeshFromGLTFPrimitiveDraco(mesh, gltfMesh, gltfPrimitive, gltf, getVertexBufferData, getBlendShapeData, getIndexBufferData, keepMeshData) {
|
|
1915
|
-
var attributes = gltfPrimitive.attributes, targets = gltfPrimitive.targets, indices = gltfPrimitive.indices, mode = gltfPrimitive.mode;
|
|
1916
|
-
var vertexCount;
|
|
1917
|
-
var accessors = gltf.accessors;
|
|
1918
|
-
var accessor = accessors[attributes["POSITION"]];
|
|
1919
|
-
var positionBuffer = getVertexBufferData("POSITION");
|
|
1920
|
-
var positions = GLTFUtil.floatBufferToVector3Array(positionBuffer);
|
|
1921
|
-
mesh.setPositions(positions);
|
|
1922
|
-
var bounds = mesh.bounds;
|
|
1923
|
-
vertexCount = accessor.count;
|
|
1924
|
-
if (accessor.min && accessor.max) {
|
|
1925
|
-
bounds.min.copyFromArray(accessor.min);
|
|
1926
|
-
bounds.max.copyFromArray(accessor.max);
|
|
1927
|
-
} else {
|
|
1928
|
-
var position = MeshParser._tempVector3;
|
|
1929
|
-
var min = bounds.min, max = bounds.max;
|
|
1930
|
-
min.set(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
|
|
1931
|
-
max.set(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
|
|
1932
|
-
var stride = positionBuffer.length / vertexCount;
|
|
1933
|
-
for(var j = 0; j < vertexCount; j++){
|
|
1934
|
-
var offset = j * stride;
|
|
1935
|
-
position.copyFromArray(positionBuffer, offset);
|
|
1936
|
-
miniprogram$1.Vector3.min(min, position, min);
|
|
1937
|
-
miniprogram$1.Vector3.max(max, position, max);
|
|
1938
|
-
}
|
|
1939
|
-
}
|
|
1940
|
-
for(var attributeSemantic in attributes){
|
|
1941
|
-
if (attributeSemantic === "POSITION") {
|
|
1942
|
-
continue;
|
|
1943
|
-
}
|
|
1944
|
-
var bufferData = getVertexBufferData(attributeSemantic);
|
|
1945
|
-
switch(attributeSemantic){
|
|
1946
|
-
case "NORMAL":
|
|
1947
|
-
var normals = GLTFUtil.floatBufferToVector3Array(bufferData);
|
|
1948
|
-
mesh.setNormals(normals);
|
|
1949
|
-
break;
|
|
1950
|
-
case "TEXCOORD_0":
|
|
1951
|
-
var texturecoords = GLTFUtil.floatBufferToVector2Array(bufferData);
|
|
1952
|
-
mesh.setUVs(texturecoords, 0);
|
|
1953
|
-
break;
|
|
1954
|
-
case "TEXCOORD_1":
|
|
1955
|
-
var texturecoords1 = GLTFUtil.floatBufferToVector2Array(bufferData);
|
|
1956
|
-
mesh.setUVs(texturecoords1, 1);
|
|
1957
|
-
break;
|
|
1958
|
-
case "TEXCOORD_2":
|
|
1959
|
-
var texturecoords2 = GLTFUtil.floatBufferToVector2Array(bufferData);
|
|
1960
|
-
mesh.setUVs(texturecoords2, 2);
|
|
1961
|
-
break;
|
|
1962
|
-
case "TEXCOORD_3":
|
|
1963
|
-
var texturecoords3 = GLTFUtil.floatBufferToVector2Array(bufferData);
|
|
1964
|
-
mesh.setUVs(texturecoords3, 3);
|
|
1965
|
-
break;
|
|
1966
|
-
case "TEXCOORD_4":
|
|
1967
|
-
var texturecoords4 = GLTFUtil.floatBufferToVector2Array(bufferData);
|
|
1968
|
-
mesh.setUVs(texturecoords4, 4);
|
|
1969
|
-
break;
|
|
1970
|
-
case "TEXCOORD_5":
|
|
1971
|
-
var texturecoords5 = GLTFUtil.floatBufferToVector2Array(bufferData);
|
|
1972
|
-
mesh.setUVs(texturecoords5, 5);
|
|
1973
|
-
break;
|
|
1974
|
-
case "TEXCOORD_6":
|
|
1975
|
-
var texturecoords6 = GLTFUtil.floatBufferToVector2Array(bufferData);
|
|
1976
|
-
mesh.setUVs(texturecoords6, 6);
|
|
1977
|
-
break;
|
|
1978
|
-
case "TEXCOORD_7":
|
|
1979
|
-
var texturecoords7 = GLTFUtil.floatBufferToVector2Array(bufferData);
|
|
1980
|
-
mesh.setUVs(texturecoords7, 7);
|
|
1981
|
-
break;
|
|
1982
|
-
case "COLOR_0":
|
|
1983
|
-
var colors = GLTFUtil.floatBufferToColorArray(bufferData, accessors[attributes["COLOR_0"]].type === AccessorType.VEC3);
|
|
1984
|
-
mesh.setColors(colors);
|
|
1985
|
-
break;
|
|
1986
|
-
case "TANGENT":
|
|
1987
|
-
var tangents = GLTFUtil.floatBufferToVector4Array(bufferData);
|
|
1988
|
-
mesh.setTangents(tangents);
|
|
1989
|
-
break;
|
|
1990
|
-
case "JOINTS_0":
|
|
1991
|
-
var joints = GLTFUtil.floatBufferToVector4Array(bufferData);
|
|
1992
|
-
mesh.setBoneIndices(joints);
|
|
1993
|
-
break;
|
|
1994
|
-
case "WEIGHTS_0":
|
|
1995
|
-
var weights = GLTFUtil.floatBufferToVector4Array(bufferData);
|
|
1996
|
-
mesh.setBoneWeights(weights);
|
|
1997
|
-
break;
|
|
1998
|
-
}
|
|
1999
|
-
}
|
|
2000
|
-
// Indices
|
|
2001
|
-
if (indices !== undefined) {
|
|
2002
|
-
var indexAccessor = gltf.accessors[indices];
|
|
2003
|
-
var indexData = getIndexBufferData();
|
|
2004
|
-
mesh.setIndices(indexData);
|
|
2005
|
-
mesh.addSubMesh(0, indexAccessor.count, mode);
|
|
2006
|
-
} else {
|
|
2007
|
-
mesh.addSubMesh(0, vertexCount, mode);
|
|
2008
|
-
}
|
|
2009
|
-
// BlendShapes
|
|
2010
|
-
targets && this._createBlendShape(mesh, gltfMesh, targets, getBlendShapeData);
|
|
2011
|
-
mesh.uploadData(!keepMeshData);
|
|
2012
|
-
return Promise.resolve(mesh);
|
|
2013
|
-
};
|
|
2014
|
-
return MeshParser;
|
|
2015
|
-
}(Parser);
|
|
1935
|
+
return GLTFMeshParser;
|
|
1936
|
+
}(GLTFParser);
|
|
2016
1937
|
(function() {
|
|
2017
|
-
|
|
1938
|
+
GLTFMeshParser._tempVector3 = new miniprogram$1.Vector3();
|
|
2018
1939
|
})();
|
|
2019
1940
|
|
|
2020
|
-
var
|
|
2021
|
-
_inherits(
|
|
2022
|
-
function
|
|
2023
|
-
return
|
|
1941
|
+
var GLTFSceneParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
1942
|
+
_inherits(GLTFSceneParser, GLTFParser1);
|
|
1943
|
+
function GLTFSceneParser() {
|
|
1944
|
+
return GLTFParser1.apply(this, arguments);
|
|
2024
1945
|
}
|
|
2025
|
-
var _proto =
|
|
1946
|
+
var _proto = GLTFSceneParser.prototype;
|
|
2026
1947
|
_proto.parse = function parse(context) {
|
|
2027
|
-
var glTFResource = context.glTFResource,
|
|
1948
|
+
var glTFResource = context.glTFResource, glTF = context.glTF;
|
|
2028
1949
|
var entities = glTFResource.entities;
|
|
2029
|
-
var nodes =
|
|
1950
|
+
var nodes = glTF.nodes, cameras = glTF.cameras;
|
|
2030
1951
|
if (!nodes) return;
|
|
2031
1952
|
var defaultSceneRootPromiseInfo = context.defaultSceneRootPromiseInfo;
|
|
2032
|
-
var promises = [];
|
|
2033
1953
|
for(var i = 0; i < nodes.length; i++){
|
|
2034
|
-
var
|
|
2035
|
-
var cameraID =
|
|
2036
|
-
var KHR_lights_punctual = extensions.KHR_lights_punctual;
|
|
1954
|
+
var glTFNode = nodes[i];
|
|
1955
|
+
var cameraID = glTFNode.camera, meshID = glTFNode.mesh, extensions = glTFNode.extensions;
|
|
2037
1956
|
var entity = entities[i];
|
|
2038
1957
|
if (cameraID !== undefined) {
|
|
2039
|
-
this._createCamera(glTFResource,
|
|
1958
|
+
this._createCamera(glTFResource, cameras[cameraID], entity);
|
|
2040
1959
|
}
|
|
2041
1960
|
if (meshID !== undefined) {
|
|
2042
|
-
|
|
2043
|
-
}
|
|
2044
|
-
if (KHR_lights_punctual) {
|
|
2045
|
-
var lightIndex = KHR_lights_punctual.light;
|
|
2046
|
-
var lights = gltf.extensions.KHR_lights_punctual.lights;
|
|
2047
|
-
Parser.parseEngineResource("KHR_lights_punctual", lights[lightIndex], entity, context);
|
|
1961
|
+
this._createRenderer(context, glTFNode, entity);
|
|
2048
1962
|
}
|
|
1963
|
+
GLTFParser.executeExtensionsAdditiveAndParse(extensions, context, entity, glTFNode);
|
|
2049
1964
|
}
|
|
2050
1965
|
if (glTFResource.defaultSceneRoot) {
|
|
2051
1966
|
this._createAnimator(context);
|
|
2052
1967
|
}
|
|
2053
|
-
|
|
2054
|
-
miniprogram.AssetPromise.all(promises).then(function() {
|
|
2055
|
-
return defaultSceneRootPromiseInfo.resolve(glTFResource.defaultSceneRoot);
|
|
2056
|
-
}).catch(defaultSceneRootPromiseInfo.reject);
|
|
1968
|
+
defaultSceneRootPromiseInfo.resolve(glTFResource.defaultSceneRoot);
|
|
2057
1969
|
return defaultSceneRootPromiseInfo.promise;
|
|
2058
1970
|
};
|
|
2059
1971
|
_proto._createCamera = function _createCamera(context, cameraSchema, entity) {
|
|
@@ -2089,8 +2001,16 @@ var SceneParser$1 = /*#__PURE__*/ function(Parser1) {
|
|
|
2089
2001
|
// @todo: use engine camera by default
|
|
2090
2002
|
camera.enabled = false;
|
|
2091
2003
|
};
|
|
2092
|
-
_proto._createRenderer = function _createRenderer(context,
|
|
2093
|
-
var
|
|
2004
|
+
_proto._createRenderer = function _createRenderer(context, glTFNode, entity) {
|
|
2005
|
+
var glTFResource = context.glTFResource, glTF = context.glTF;
|
|
2006
|
+
var glTFMeshes = glTF.meshes;
|
|
2007
|
+
var engine = glTFResource.engine, meshes = glTFResource.meshes, materials = glTFResource.materials, skins = glTFResource.skins;
|
|
2008
|
+
var meshID = glTFNode.mesh, skinID = glTFNode.skin;
|
|
2009
|
+
var glTFMesh = glTFMeshes[meshID];
|
|
2010
|
+
var glTFMeshPrimitives = glTFMesh.primitives;
|
|
2011
|
+
var blendShapeWeights = glTFNode.weights || glTFMesh.weights;
|
|
2012
|
+
for(var i = 0; i < glTFMeshPrimitives.length; i++){
|
|
2013
|
+
var gltfPrimitive = glTFMeshPrimitives[i];
|
|
2094
2014
|
var mesh = meshes[meshID][i];
|
|
2095
2015
|
var renderer = void 0;
|
|
2096
2016
|
if (skinID !== undefined || blendShapeWeights) {
|
|
@@ -2108,32 +2028,11 @@ var SceneParser$1 = /*#__PURE__*/ function(Parser1) {
|
|
|
2108
2028
|
renderer = entity.addComponent(miniprogram.MeshRenderer);
|
|
2109
2029
|
renderer.mesh = mesh;
|
|
2110
2030
|
}
|
|
2111
|
-
var materialIndex =
|
|
2112
|
-
var
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
}));
|
|
2117
|
-
} else {
|
|
2118
|
-
var material = (materials == null ? void 0 : materials[materialIndex]) || SceneParser._getDefaultMaterial(engine);
|
|
2119
|
-
renderer.setMaterial(material);
|
|
2120
|
-
}
|
|
2121
|
-
var _gltfMeshPrimitives_i = gltfMeshPrimitives[i], _gltfMeshPrimitives_i_extensions = _gltfMeshPrimitives_i.extensions, extensions = _gltfMeshPrimitives_i_extensions === void 0 ? {} : _gltfMeshPrimitives_i_extensions;
|
|
2122
|
-
var KHR_materials_variants = extensions.KHR_materials_variants;
|
|
2123
|
-
if (KHR_materials_variants) {
|
|
2124
|
-
Parser.parseEngineResource("KHR_materials_variants", KHR_materials_variants, renderer, context);
|
|
2125
|
-
}
|
|
2126
|
-
};
|
|
2127
|
-
var glTFResource = context.glTFResource, gltf = context.gltf;
|
|
2128
|
-
var gltfMeshes = gltf.meshes;
|
|
2129
|
-
var engine = glTFResource.engine, meshes = glTFResource.meshes, materials = glTFResource.materials, skins = glTFResource.skins;
|
|
2130
|
-
var meshID = gltfNode.mesh, skinID = gltfNode.skin;
|
|
2131
|
-
var glTFMesh = gltfMeshes[meshID];
|
|
2132
|
-
var gltfMeshPrimitives = glTFMesh.primitives;
|
|
2133
|
-
var blendShapeWeights = gltfNode.weights || glTFMesh.weights;
|
|
2134
|
-
var promises = [];
|
|
2135
|
-
for(var i = 0; i < gltfMeshPrimitives.length; i++)_loop(i);
|
|
2136
|
-
return Promise.all(promises);
|
|
2031
|
+
var materialIndex = gltfPrimitive.material;
|
|
2032
|
+
var material = (materials == null ? void 0 : materials[materialIndex]) || GLTFSceneParser._getDefaultMaterial(engine);
|
|
2033
|
+
renderer.setMaterial(material);
|
|
2034
|
+
GLTFParser.executeExtensionsAdditiveAndParse(gltfPrimitive.extensions, context, renderer, gltfPrimitive);
|
|
2035
|
+
}
|
|
2137
2036
|
};
|
|
2138
2037
|
_proto._createAnimator = function _createAnimator(context) {
|
|
2139
2038
|
if (!context.hasSkinned && !context.glTFResource.animations) {
|
|
@@ -2160,25 +2059,25 @@ var SceneParser$1 = /*#__PURE__*/ function(Parser1) {
|
|
|
2160
2059
|
}
|
|
2161
2060
|
}
|
|
2162
2061
|
};
|
|
2163
|
-
|
|
2164
|
-
if (!
|
|
2165
|
-
|
|
2062
|
+
GLTFSceneParser._getDefaultMaterial = function _getDefaultMaterial(engine) {
|
|
2063
|
+
if (!GLTFSceneParser._defaultMaterial) {
|
|
2064
|
+
GLTFSceneParser._defaultMaterial = new miniprogram.BlinnPhongMaterial(engine);
|
|
2166
2065
|
}
|
|
2167
|
-
return
|
|
2066
|
+
return GLTFSceneParser._defaultMaterial;
|
|
2168
2067
|
};
|
|
2169
|
-
return
|
|
2170
|
-
}(
|
|
2068
|
+
return GLTFSceneParser;
|
|
2069
|
+
}(GLTFParser);
|
|
2171
2070
|
|
|
2172
|
-
var
|
|
2173
|
-
_inherits(
|
|
2174
|
-
function
|
|
2175
|
-
return
|
|
2071
|
+
var GLTFSkinParser = /*#__PURE__*/ function(GLTFParser) {
|
|
2072
|
+
_inherits(GLTFSkinParser, GLTFParser);
|
|
2073
|
+
function GLTFSkinParser() {
|
|
2074
|
+
return GLTFParser.apply(this, arguments);
|
|
2176
2075
|
}
|
|
2177
|
-
var _proto =
|
|
2076
|
+
var _proto = GLTFSkinParser.prototype;
|
|
2178
2077
|
_proto.parse = function parse(context) {
|
|
2179
|
-
var glTFResource = context.glTFResource,
|
|
2078
|
+
var glTFResource = context.glTFResource, glTF = context.glTF; context.buffers;
|
|
2180
2079
|
var entities = glTFResource.entities;
|
|
2181
|
-
var gltfSkins =
|
|
2080
|
+
var gltfSkins = glTF.skins;
|
|
2182
2081
|
if (!gltfSkins) return;
|
|
2183
2082
|
var count = gltfSkins.length;
|
|
2184
2083
|
var skins = new Array(count);
|
|
@@ -2188,8 +2087,8 @@ var SkinParser = /*#__PURE__*/ function(Parser) {
|
|
|
2188
2087
|
var skin = new miniprogram.Skin(name);
|
|
2189
2088
|
skin.inverseBindMatrices.length = jointCount;
|
|
2190
2089
|
// parse IBM
|
|
2191
|
-
var accessor =
|
|
2192
|
-
var buffer =
|
|
2090
|
+
var accessor = glTF.accessors[inverseBindMatrices];
|
|
2091
|
+
var buffer = GLTFUtils.getAccessorBuffer(context, glTF.bufferViews, accessor).data;
|
|
2193
2092
|
for(var i1 = 0; i1 < jointCount; i1++){
|
|
2194
2093
|
var inverseBindMatrix = new miniprogram$1.Matrix();
|
|
2195
2094
|
inverseBindMatrix.copyFromArray(buffer, i1 * 16);
|
|
@@ -2250,52 +2149,55 @@ var SkinParser = /*#__PURE__*/ function(Parser) {
|
|
|
2250
2149
|
rootNode = entity1;
|
|
2251
2150
|
}
|
|
2252
2151
|
};
|
|
2253
|
-
return
|
|
2254
|
-
}(
|
|
2152
|
+
return GLTFSkinParser;
|
|
2153
|
+
}(GLTFParser);
|
|
2255
2154
|
|
|
2256
|
-
var
|
|
2257
|
-
_inherits(
|
|
2258
|
-
function
|
|
2259
|
-
return
|
|
2155
|
+
var GLTFTextureParser = /*#__PURE__*/ function(GLTFParser) {
|
|
2156
|
+
_inherits(GLTFTextureParser, GLTFParser);
|
|
2157
|
+
function GLTFTextureParser() {
|
|
2158
|
+
return GLTFParser.apply(this, arguments);
|
|
2260
2159
|
}
|
|
2261
|
-
var _proto =
|
|
2160
|
+
var _proto = GLTFTextureParser.prototype;
|
|
2262
2161
|
_proto.parse = function parse(context) {
|
|
2263
2162
|
var _this = this;
|
|
2264
|
-
var glTFResource = context.glTFResource,
|
|
2163
|
+
var glTFResource = context.glTFResource, glTF = context.glTF, buffers = context.buffers;
|
|
2265
2164
|
var engine = glTFResource.engine, url = glTFResource.url;
|
|
2266
|
-
if (
|
|
2165
|
+
if (glTF.textures) {
|
|
2267
2166
|
var texturesPromiseInfo = context.texturesPromiseInfo;
|
|
2268
|
-
miniprogram.AssetPromise.all(
|
|
2167
|
+
miniprogram.AssetPromise.all(glTF.textures.map(function(param, index) {
|
|
2269
2168
|
var sampler = param.sampler, _param_source = param.source, source = _param_source === void 0 ? 0 : _param_source, textureName = param.name;
|
|
2270
|
-
var
|
|
2169
|
+
var _glTF_images_source = glTF.images[source], uri = _glTF_images_source.uri, bufferViewIndex = _glTF_images_source.bufferView, mimeType = _glTF_images_source.mimeType, imageName = _glTF_images_source.name;
|
|
2271
2170
|
if (uri) {
|
|
2272
2171
|
// TODO: support ktx extension https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_texture_basisu/README.md
|
|
2273
2172
|
var index1 = uri.lastIndexOf(".");
|
|
2274
2173
|
var ext = uri.substring(index1 + 1);
|
|
2275
2174
|
var type = ext.startsWith("ktx") ? miniprogram.AssetType.KTX : miniprogram.AssetType.Texture2D;
|
|
2276
2175
|
return engine.resourceManager.load({
|
|
2277
|
-
url:
|
|
2176
|
+
url: miniprogram.Utils.resolveAbsoluteUrl(url, uri),
|
|
2278
2177
|
type: type
|
|
2279
2178
|
}).then(function(texture) {
|
|
2280
2179
|
if (!texture.name) {
|
|
2281
2180
|
texture.name = textureName || imageName || "texture_" + index1;
|
|
2282
2181
|
}
|
|
2283
2182
|
if (sampler !== undefined) {
|
|
2284
|
-
_this._parseSampler(texture,
|
|
2183
|
+
_this._parseSampler(texture, glTF.samplers[sampler]);
|
|
2285
2184
|
}
|
|
2286
2185
|
return texture;
|
|
2287
2186
|
});
|
|
2288
2187
|
} else {
|
|
2289
|
-
var bufferView =
|
|
2290
|
-
var
|
|
2291
|
-
|
|
2188
|
+
var bufferView = glTF.bufferViews[bufferViewIndex];
|
|
2189
|
+
var buffer = buffers[bufferView.buffer];
|
|
2190
|
+
var imageBuffer = new Uint8Array(buffer, bufferView.byteOffset, bufferView.byteLength);
|
|
2191
|
+
return GLTFUtils.loadImageBuffer(imageBuffer, mimeType).then(function(image) {
|
|
2292
2192
|
var texture = new miniprogram.Texture2D(engine, image.width, image.height);
|
|
2293
2193
|
texture.setImageSource(image);
|
|
2294
2194
|
texture.generateMipmaps();
|
|
2295
2195
|
texture.name = textureName || imageName || "texture_" + index;
|
|
2296
2196
|
if (sampler !== undefined) {
|
|
2297
|
-
_this._parseSampler(texture,
|
|
2197
|
+
_this._parseSampler(texture, glTF.samplers[sampler]);
|
|
2298
2198
|
}
|
|
2199
|
+
var bufferTextureRestoreInfo = new BufferTextureRestoreInfo(texture, bufferView, mimeType);
|
|
2200
|
+
context.contentRestorer.bufferTextures.push(bufferTextureRestoreInfo);
|
|
2299
2201
|
return texture;
|
|
2300
2202
|
});
|
|
2301
2203
|
}
|
|
@@ -2318,36 +2220,38 @@ var TextureParser = /*#__PURE__*/ function(Parser) {
|
|
|
2318
2220
|
}
|
|
2319
2221
|
}
|
|
2320
2222
|
if (wrapS) {
|
|
2321
|
-
texture.wrapModeU =
|
|
2223
|
+
texture.wrapModeU = GLTFTextureParser._wrapMap[wrapS];
|
|
2322
2224
|
}
|
|
2323
2225
|
if (wrapT) {
|
|
2324
|
-
texture.wrapModeV =
|
|
2226
|
+
texture.wrapModeV = GLTFTextureParser._wrapMap[wrapT];
|
|
2325
2227
|
}
|
|
2326
2228
|
};
|
|
2327
|
-
return
|
|
2328
|
-
}(
|
|
2229
|
+
return GLTFTextureParser;
|
|
2230
|
+
}(GLTFParser);
|
|
2329
2231
|
(function() {
|
|
2330
2232
|
var _obj;
|
|
2331
|
-
|
|
2233
|
+
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);
|
|
2332
2234
|
})();
|
|
2333
2235
|
|
|
2334
|
-
var
|
|
2335
|
-
_inherits(
|
|
2336
|
-
function
|
|
2337
|
-
return
|
|
2236
|
+
var GLTFValidator = /*#__PURE__*/ function(GLTFParser1) {
|
|
2237
|
+
_inherits(GLTFValidator, GLTFParser1);
|
|
2238
|
+
function GLTFValidator() {
|
|
2239
|
+
return GLTFParser1.apply(this, arguments);
|
|
2338
2240
|
}
|
|
2339
|
-
var _proto =
|
|
2241
|
+
var _proto = GLTFValidator.prototype;
|
|
2340
2242
|
_proto.parse = function parse(context) {
|
|
2341
|
-
var
|
|
2342
|
-
var
|
|
2343
|
-
if (!(
|
|
2344
|
-
throw "Only support
|
|
2243
|
+
var _context_glTF = context.glTF, version = _context_glTF.asset.version, extensionsUsed = _context_glTF.extensionsUsed, extensionsRequired = _context_glTF.extensionsRequired;
|
|
2244
|
+
var glTFVersion = Number(version);
|
|
2245
|
+
if (!(glTFVersion >= 2 && glTFVersion < 3)) {
|
|
2246
|
+
throw "Only support glTF 2.x.";
|
|
2345
2247
|
}
|
|
2248
|
+
var promises = [];
|
|
2346
2249
|
if (extensionsUsed) {
|
|
2347
2250
|
miniprogram.Logger.info("extensionsUsed: ", extensionsUsed);
|
|
2348
2251
|
for(var i = 0; i < extensionsUsed.length; i++){
|
|
2349
|
-
|
|
2350
|
-
|
|
2252
|
+
var extensionUsed = extensionsUsed[i];
|
|
2253
|
+
if (!GLTFParser.hasExtensionParser(extensionUsed)) {
|
|
2254
|
+
miniprogram.Logger.warn("Extension " + extensionUsed + " is not implemented, you can customize this extension in gltf.");
|
|
2351
2255
|
}
|
|
2352
2256
|
}
|
|
2353
2257
|
}
|
|
@@ -2355,68 +2259,68 @@ var Validator = /*#__PURE__*/ function(Parser1) {
|
|
|
2355
2259
|
miniprogram.Logger.info("extensionsRequired: " + extensionsRequired);
|
|
2356
2260
|
for(var i1 = 0; i1 < extensionsRequired.length; i1++){
|
|
2357
2261
|
var extensionRequired = extensionsRequired[i1];
|
|
2358
|
-
if (!
|
|
2262
|
+
if (!GLTFParser.hasExtensionParser(extensionRequired)) {
|
|
2359
2263
|
miniprogram.Logger.error("GLTF parser has not supported required extension " + extensionRequired + ".");
|
|
2360
2264
|
} else {
|
|
2361
|
-
|
|
2265
|
+
promises.push(GLTFParser.executeExtensionsInitialize(extensionRequired));
|
|
2362
2266
|
}
|
|
2363
2267
|
}
|
|
2364
2268
|
}
|
|
2269
|
+
return miniprogram.AssetPromise.all(promises).then(null);
|
|
2365
2270
|
};
|
|
2366
|
-
return
|
|
2367
|
-
}(
|
|
2271
|
+
return GLTFValidator;
|
|
2272
|
+
}(GLTFParser);
|
|
2368
2273
|
|
|
2369
|
-
|
|
2370
|
-
|
|
2274
|
+
/**
|
|
2275
|
+
* GLTF pipeline.
|
|
2276
|
+
*/ var GLTFPipeline = /*#__PURE__*/ function() {
|
|
2277
|
+
function GLTFPipeline() {
|
|
2278
|
+
for(var _len = arguments.length, parsers = new Array(_len), _key = 0; _key < _len; _key++){
|
|
2279
|
+
parsers[_key] = arguments[_key];
|
|
2280
|
+
}
|
|
2371
2281
|
var _this = this;
|
|
2372
|
-
this.
|
|
2373
|
-
|
|
2374
|
-
_this.
|
|
2282
|
+
this._parsers = [];
|
|
2283
|
+
parsers.forEach(function(pipe, index) {
|
|
2284
|
+
_this._parsers[index] = new pipe();
|
|
2375
2285
|
});
|
|
2376
2286
|
}
|
|
2377
|
-
var _proto =
|
|
2378
|
-
|
|
2287
|
+
var _proto = GLTFPipeline.prototype;
|
|
2288
|
+
/**
|
|
2289
|
+
* @internal
|
|
2290
|
+
*/ _proto._parse = function _parse(context) {
|
|
2379
2291
|
var _this = this;
|
|
2380
2292
|
var glTFResource = context.glTFResource;
|
|
2381
|
-
var
|
|
2293
|
+
var lastParser;
|
|
2382
2294
|
return new miniprogram.AssetPromise(function(resolve, reject) {
|
|
2383
|
-
_this.
|
|
2384
|
-
if (
|
|
2385
|
-
|
|
2295
|
+
_this._parsers.forEach(function(parser) {
|
|
2296
|
+
if (lastParser) {
|
|
2297
|
+
lastParser = lastParser.then(function() {
|
|
2386
2298
|
return parser.parse(context);
|
|
2387
2299
|
});
|
|
2388
|
-
if (
|
|
2389
|
-
context.chainPromises.push(
|
|
2300
|
+
if (lastParser.cancel) {
|
|
2301
|
+
context.chainPromises.push(lastParser);
|
|
2390
2302
|
}
|
|
2391
2303
|
} else {
|
|
2392
|
-
|
|
2304
|
+
lastParser = parser.parse(context);
|
|
2393
2305
|
}
|
|
2394
2306
|
});
|
|
2395
|
-
if (
|
|
2396
|
-
|
|
2307
|
+
if (lastParser) {
|
|
2308
|
+
lastParser.then(function() {
|
|
2397
2309
|
resolve(glTFResource);
|
|
2398
2310
|
}).catch(reject);
|
|
2399
2311
|
}
|
|
2400
2312
|
});
|
|
2401
2313
|
};
|
|
2402
|
-
return
|
|
2314
|
+
return GLTFPipeline;
|
|
2403
2315
|
}();
|
|
2404
2316
|
(function() {
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
TextureParser,
|
|
2409
|
-
MaterialParser,
|
|
2410
|
-
MeshParser,
|
|
2411
|
-
EntityParser,
|
|
2412
|
-
SkinParser,
|
|
2413
|
-
AnimationParser,
|
|
2414
|
-
SceneParser$1
|
|
2415
|
-
]);
|
|
2317
|
+
/**
|
|
2318
|
+
* Default pipeline.
|
|
2319
|
+
*/ GLTFPipeline.defaultPipeline = new GLTFPipeline(GLTFBufferParser, GLTFValidator, GLTFTextureParser, GLTFMaterialParser, GLTFMeshParser, GLTFEntityParser, GLTFSkinParser, GLTFAnimationParser, GLTFSceneParser);
|
|
2416
2320
|
})();
|
|
2417
2321
|
|
|
2418
2322
|
/**
|
|
2419
|
-
* Product after
|
|
2323
|
+
* Product after glTF parser, usually, `defaultSceneRoot` is only needed to use.
|
|
2420
2324
|
*/ var GLTFResource = /*#__PURE__*/ function(EngineObject) {
|
|
2421
2325
|
_inherits(GLTFResource, EngineObject);
|
|
2422
2326
|
function GLTFResource(engine, url) {
|
|
@@ -2428,11 +2332,8 @@ var GLTFParser = /*#__PURE__*/ function() {
|
|
|
2428
2332
|
var _proto = GLTFResource.prototype;
|
|
2429
2333
|
/**
|
|
2430
2334
|
* @override
|
|
2431
|
-
*/ _proto.
|
|
2432
|
-
|
|
2433
|
-
return;
|
|
2434
|
-
}
|
|
2435
|
-
EngineObject.prototype.destroy.call(this);
|
|
2335
|
+
*/ _proto._onDestroy = function _onDestroy() {
|
|
2336
|
+
EngineObject.prototype._onDestroy.call(this);
|
|
2436
2337
|
this.defaultSceneRoot.destroy();
|
|
2437
2338
|
this.textures = null;
|
|
2438
2339
|
this.materials = null;
|
|
@@ -2443,7 +2344,7 @@ var GLTFParser = /*#__PURE__*/ function() {
|
|
|
2443
2344
|
this.cameras = null;
|
|
2444
2345
|
this.lights = null;
|
|
2445
2346
|
this.sceneRoots = null;
|
|
2446
|
-
this.
|
|
2347
|
+
this.extensionsData = null;
|
|
2447
2348
|
};
|
|
2448
2349
|
return GLTFResource;
|
|
2449
2350
|
}(miniprogram.EngineObject);
|
|
@@ -2454,15 +2355,19 @@ var GLTFLoader = /*#__PURE__*/ function(Loader) {
|
|
|
2454
2355
|
return Loader.apply(this, arguments);
|
|
2455
2356
|
}
|
|
2456
2357
|
var _proto = GLTFLoader.prototype;
|
|
2457
|
-
|
|
2458
|
-
|
|
2358
|
+
/**
|
|
2359
|
+
* @override
|
|
2360
|
+
*/ _proto.load = function load(item, resourceManager) {
|
|
2459
2361
|
var url = item.url;
|
|
2460
|
-
var
|
|
2362
|
+
var params = item.params;
|
|
2363
|
+
var context = new GLTFParserContext(url);
|
|
2461
2364
|
var glTFResource = new GLTFResource(resourceManager.engine, url);
|
|
2365
|
+
var restorer = new GLTFContentRestorer(glTFResource);
|
|
2462
2366
|
var masterPromiseInfo = context.masterPromiseInfo;
|
|
2367
|
+
context.contentRestorer = restorer;
|
|
2463
2368
|
context.glTFResource = glTFResource;
|
|
2464
|
-
var
|
|
2465
|
-
context.keepMeshData = (
|
|
2369
|
+
var _params_keepMeshData;
|
|
2370
|
+
context.keepMeshData = (_params_keepMeshData = params == null ? void 0 : params.keepMeshData) != null ? _params_keepMeshData : false;
|
|
2466
2371
|
masterPromiseInfo.onCancel(function() {
|
|
2467
2372
|
var chainPromises = context.chainPromises;
|
|
2468
2373
|
for(var _iterator = _create_for_of_iterator_helper_loose(chainPromises), _step; !(_step = _iterator()).done;){
|
|
@@ -2470,7 +2375,10 @@ var GLTFLoader = /*#__PURE__*/ function(Loader) {
|
|
|
2470
2375
|
promise.cancel();
|
|
2471
2376
|
}
|
|
2472
2377
|
});
|
|
2473
|
-
|
|
2378
|
+
((params == null ? void 0 : params.pipeline) || GLTFPipeline.defaultPipeline)._parse(context).then(function(glTFResource) {
|
|
2379
|
+
resourceManager.addContentRestorer(restorer);
|
|
2380
|
+
masterPromiseInfo.resolve(glTFResource);
|
|
2381
|
+
}).catch(function(e) {
|
|
2474
2382
|
console.error(e);
|
|
2475
2383
|
masterPromiseInfo.reject("Error loading glTF model from " + url + " .");
|
|
2476
2384
|
});
|
|
@@ -2479,7 +2387,7 @@ var GLTFLoader = /*#__PURE__*/ function(Loader) {
|
|
|
2479
2387
|
return GLTFLoader;
|
|
2480
2388
|
}(miniprogram.Loader);
|
|
2481
2389
|
GLTFLoader = __decorate([
|
|
2482
|
-
miniprogram.resourceLoader(miniprogram.AssetType.
|
|
2390
|
+
miniprogram.resourceLoader(miniprogram.AssetType.GLTF, [
|
|
2483
2391
|
"gltf",
|
|
2484
2392
|
"glb"
|
|
2485
2393
|
])
|
|
@@ -2565,7 +2473,7 @@ var HDRLoader = (_HDRLoader = /*#__PURE__*/ function(Loader) {
|
|
|
2565
2473
|
return textureArray;
|
|
2566
2474
|
};
|
|
2567
2475
|
HDRLoader1._calcProjectionSpherical = function _calcProjectionSpherical(vDir, pixels, inputWidth, inputHeight) {
|
|
2568
|
-
var theta = Math.atan2(vDir.z,
|
|
2476
|
+
var theta = Math.atan2(vDir.z, vDir.x);
|
|
2569
2477
|
var phi = Math.acos(vDir.y);
|
|
2570
2478
|
while(theta < -PI){
|
|
2571
2479
|
theta += 2 * PI;
|
|
@@ -2867,40 +2775,40 @@ function getEngineFormat(internalFormat) {
|
|
|
2867
2775
|
// case GLCompressedTextureInternalFormat.RGBA_S3TC_DXT3_EXT:
|
|
2868
2776
|
// case GLCompressedTextureInternalFormat.RGBA_S3TC_DXT5_EXT:
|
|
2869
2777
|
// break;
|
|
2870
|
-
case miniprogram$
|
|
2778
|
+
case miniprogram$2.GLCompressedTextureInternalFormat.RGB_S3TC_DXT1_EXT:
|
|
2871
2779
|
return miniprogram.TextureFormat.DXT1;
|
|
2872
|
-
case miniprogram$
|
|
2780
|
+
case miniprogram$2.GLCompressedTextureInternalFormat.RGBA_S3TC_DXT5_EXT:
|
|
2873
2781
|
return miniprogram.TextureFormat.DXT5;
|
|
2874
|
-
case miniprogram$
|
|
2782
|
+
case miniprogram$2.GLCompressedTextureInternalFormat.RGB_ETC1_WEBGL:
|
|
2875
2783
|
return miniprogram.TextureFormat.ETC1_RGB;
|
|
2876
|
-
case miniprogram$
|
|
2784
|
+
case miniprogram$2.GLCompressedTextureInternalFormat.RGB8_ETC2:
|
|
2877
2785
|
return miniprogram.TextureFormat.ETC2_RGB;
|
|
2878
|
-
case miniprogram$
|
|
2786
|
+
case miniprogram$2.GLCompressedTextureInternalFormat.RGB8_PUNCHTHROUGH_ALPHA1_ETC2:
|
|
2879
2787
|
return miniprogram.TextureFormat.ETC2_RGBA5;
|
|
2880
|
-
case miniprogram$
|
|
2788
|
+
case miniprogram$2.GLCompressedTextureInternalFormat.RGBA8_ETC2_EAC:
|
|
2881
2789
|
return miniprogram.TextureFormat.ETC2_RGBA8;
|
|
2882
|
-
case miniprogram$
|
|
2790
|
+
case miniprogram$2.GLCompressedTextureInternalFormat.RGB_PVRTC_2BPPV1_IMG:
|
|
2883
2791
|
return miniprogram.TextureFormat.PVRTC_RGB2;
|
|
2884
|
-
case miniprogram$
|
|
2792
|
+
case miniprogram$2.GLCompressedTextureInternalFormat.RGBA_PVRTC_2BPPV1_IMG:
|
|
2885
2793
|
return miniprogram.TextureFormat.PVRTC_RGBA2;
|
|
2886
|
-
case miniprogram$
|
|
2794
|
+
case miniprogram$2.GLCompressedTextureInternalFormat.RGB_PVRTC_4BPPV1_IMG:
|
|
2887
2795
|
return miniprogram.TextureFormat.PVRTC_RGB4;
|
|
2888
|
-
case miniprogram$
|
|
2796
|
+
case miniprogram$2.GLCompressedTextureInternalFormat.RGBA_PVRTC_4BPPV1_IMG:
|
|
2889
2797
|
return miniprogram.TextureFormat.PVRTC_RGBA4;
|
|
2890
|
-
case miniprogram$
|
|
2798
|
+
case miniprogram$2.GLCompressedTextureInternalFormat.RGBA_ASTC_4X4_KHR:
|
|
2891
2799
|
return miniprogram.TextureFormat.ASTC_4x4;
|
|
2892
|
-
case miniprogram$
|
|
2800
|
+
case miniprogram$2.GLCompressedTextureInternalFormat.RGBA_ASTC_5X5_KHR:
|
|
2893
2801
|
return miniprogram.TextureFormat.ASTC_5x5;
|
|
2894
|
-
case miniprogram$
|
|
2802
|
+
case miniprogram$2.GLCompressedTextureInternalFormat.RGBA_ASTC_6X6_KHR:
|
|
2895
2803
|
return miniprogram.TextureFormat.ASTC_6x6;
|
|
2896
|
-
case miniprogram$
|
|
2804
|
+
case miniprogram$2.GLCompressedTextureInternalFormat.RGBA_ASTC_8X8_KHR:
|
|
2897
2805
|
return miniprogram.TextureFormat.ASTC_8x8;
|
|
2898
|
-
case miniprogram$
|
|
2806
|
+
case miniprogram$2.GLCompressedTextureInternalFormat.RGBA_ASTC_10X10_KHR:
|
|
2899
2807
|
return miniprogram.TextureFormat.ASTC_10x10;
|
|
2900
|
-
case miniprogram$
|
|
2808
|
+
case miniprogram$2.GLCompressedTextureInternalFormat.RGBA_ASTC_12X12_KHR:
|
|
2901
2809
|
return miniprogram.TextureFormat.ASTC_12x12;
|
|
2902
2810
|
default:
|
|
2903
|
-
var formatName = miniprogram$
|
|
2811
|
+
var formatName = miniprogram$2.GLCompressedTextureInternalFormat[internalFormat];
|
|
2904
2812
|
throw new Error("this format is not supported in Galacean Engine: " + formatName);
|
|
2905
2813
|
}
|
|
2906
2814
|
}
|
|
@@ -3248,7 +3156,7 @@ var BufferReader = /*#__PURE__*/ function() {
|
|
|
3248
3156
|
var strByteLength = this.nextUint16();
|
|
3249
3157
|
var uint8Array = new Uint8Array(this.buffer, this._offset, strByteLength);
|
|
3250
3158
|
this._offset += strByteLength;
|
|
3251
|
-
return
|
|
3159
|
+
return miniprogram.Utils.decodeText(uint8Array);
|
|
3252
3160
|
};
|
|
3253
3161
|
/**
|
|
3254
3162
|
* image data 放在最后
|
|
@@ -3333,8 +3241,8 @@ var FileHeader = /*#__PURE__*/ function() {
|
|
|
3333
3241
|
var typeUint8Array = new Uint8Array(arrayBuffer, 7, typeLen);
|
|
3334
3242
|
var nameLen = dataView.getUint16(7 + typeLen, true);
|
|
3335
3243
|
var nameUint8Array = new Uint8Array(arrayBuffer, 9 + typeLen, nameLen);
|
|
3336
|
-
var name =
|
|
3337
|
-
var type =
|
|
3244
|
+
var name = miniprogram.Utils.decodeText(nameUint8Array);
|
|
3245
|
+
var type = miniprogram.Utils.decodeText(typeUint8Array);
|
|
3338
3246
|
var header = new FileHeader();
|
|
3339
3247
|
header.totalLength = totalLen;
|
|
3340
3248
|
header.name = name;
|
|
@@ -4284,28 +4192,57 @@ SpriteLoader = __decorate([
|
|
|
4284
4192
|
], false)
|
|
4285
4193
|
], SpriteLoader);
|
|
4286
4194
|
|
|
4195
|
+
/**
|
|
4196
|
+
* @internal
|
|
4197
|
+
*/ var Texture2DContentRestorer = /*#__PURE__*/ function(ContentRestorer) {
|
|
4198
|
+
_inherits(Texture2DContentRestorer, ContentRestorer);
|
|
4199
|
+
function Texture2DContentRestorer(resource, url, requestConfig) {
|
|
4200
|
+
var _this;
|
|
4201
|
+
_this = ContentRestorer.call(this, resource) || this;
|
|
4202
|
+
_this.url = url;
|
|
4203
|
+
_this.requestConfig = requestConfig;
|
|
4204
|
+
return _this;
|
|
4205
|
+
}
|
|
4206
|
+
var _proto = Texture2DContentRestorer.prototype;
|
|
4207
|
+
/**
|
|
4208
|
+
* @override
|
|
4209
|
+
*/ _proto.restoreContent = function restoreContent() {
|
|
4210
|
+
var _this = this;
|
|
4211
|
+
return miniprogram.request(this.url, this.requestConfig).then(function(image) {
|
|
4212
|
+
var resource = _this.resource;
|
|
4213
|
+
resource.setImageSource(image);
|
|
4214
|
+
resource.generateMipmaps();
|
|
4215
|
+
return resource;
|
|
4216
|
+
});
|
|
4217
|
+
};
|
|
4218
|
+
return Texture2DContentRestorer;
|
|
4219
|
+
}(miniprogram.ContentRestorer);
|
|
4220
|
+
|
|
4287
4221
|
var Texture2DLoader = /*#__PURE__*/ function(Loader) {
|
|
4288
4222
|
_inherits(Texture2DLoader, Loader);
|
|
4289
4223
|
function Texture2DLoader() {
|
|
4290
4224
|
return Loader.apply(this, arguments);
|
|
4291
4225
|
}
|
|
4292
4226
|
var _proto = Texture2DLoader.prototype;
|
|
4293
|
-
|
|
4227
|
+
/**
|
|
4228
|
+
* @override
|
|
4229
|
+
*/ _proto.load = function load(item, resourceManager) {
|
|
4294
4230
|
var _this = this;
|
|
4295
4231
|
return new miniprogram.AssetPromise(function(resolve, reject) {
|
|
4296
|
-
|
|
4232
|
+
var url = item.url;
|
|
4233
|
+
var requestConfig = _extends({}, item, {
|
|
4297
4234
|
type: "image"
|
|
4298
|
-
})
|
|
4299
|
-
|
|
4300
|
-
var params =
|
|
4301
|
-
var texture = new miniprogram.Texture2D(resourceManager.engine, image.width, image.height, params.format, params.mipmap);
|
|
4302
|
-
/** @ts-ignore */ if (!texture._platformTexture) return;
|
|
4235
|
+
});
|
|
4236
|
+
_this.request(url, requestConfig).then(function(image) {
|
|
4237
|
+
var params = item.params;
|
|
4238
|
+
var texture = new miniprogram.Texture2D(resourceManager.engine, image.width, image.height, params == null ? void 0 : params.format, params == null ? void 0 : params.mipmap);
|
|
4303
4239
|
texture.setImageSource(image);
|
|
4304
4240
|
texture.generateMipmaps();
|
|
4305
|
-
if (
|
|
4306
|
-
var
|
|
4307
|
-
texture.name =
|
|
4241
|
+
if (url.indexOf("data:") !== 0) {
|
|
4242
|
+
var index = url.lastIndexOf("/");
|
|
4243
|
+
texture.name = url.substring(index + 1);
|
|
4308
4244
|
}
|
|
4245
|
+
resourceManager.addContentRestorer(new Texture2DContentRestorer(texture, url, requestConfig));
|
|
4309
4246
|
resolve(texture);
|
|
4310
4247
|
}).catch(function(e) {
|
|
4311
4248
|
reject(e);
|
|
@@ -4323,32 +4260,70 @@ Texture2DLoader = __decorate([
|
|
|
4323
4260
|
])
|
|
4324
4261
|
], Texture2DLoader);
|
|
4325
4262
|
|
|
4263
|
+
/**
|
|
4264
|
+
* @internal
|
|
4265
|
+
*/ var TextureCubeContentRestorer = /*#__PURE__*/ function(ContentRestorer) {
|
|
4266
|
+
_inherits(TextureCubeContentRestorer, ContentRestorer);
|
|
4267
|
+
function TextureCubeContentRestorer(resource, urls, requestConfig) {
|
|
4268
|
+
var _this;
|
|
4269
|
+
_this = ContentRestorer.call(this, resource) || this;
|
|
4270
|
+
_this.urls = urls;
|
|
4271
|
+
_this.requestConfig = requestConfig;
|
|
4272
|
+
return _this;
|
|
4273
|
+
}
|
|
4274
|
+
var _proto = TextureCubeContentRestorer.prototype;
|
|
4275
|
+
/**
|
|
4276
|
+
* @override
|
|
4277
|
+
*/ _proto.restoreContent = function restoreContent() {
|
|
4278
|
+
var _this = this;
|
|
4279
|
+
return new miniprogram.AssetPromise(function(resolve, reject) {
|
|
4280
|
+
Promise.all(_this.urls.map(function(url) {
|
|
4281
|
+
return miniprogram.request(url, _this.requestConfig);
|
|
4282
|
+
})).then(function(images) {
|
|
4283
|
+
var resource = _this.resource;
|
|
4284
|
+
for(var faceIndex = 0; faceIndex < 6; faceIndex++){
|
|
4285
|
+
resource.setImageSource(miniprogram.TextureCubeFace.PositiveX + faceIndex, images[faceIndex], 0);
|
|
4286
|
+
}
|
|
4287
|
+
resource.generateMipmaps();
|
|
4288
|
+
resolve(resource);
|
|
4289
|
+
}).catch(function(e) {
|
|
4290
|
+
reject(e);
|
|
4291
|
+
});
|
|
4292
|
+
});
|
|
4293
|
+
};
|
|
4294
|
+
return TextureCubeContentRestorer;
|
|
4295
|
+
}(miniprogram.ContentRestorer);
|
|
4296
|
+
|
|
4326
4297
|
var TextureCubeLoader = /*#__PURE__*/ function(Loader) {
|
|
4327
4298
|
_inherits(TextureCubeLoader, Loader);
|
|
4328
4299
|
function TextureCubeLoader() {
|
|
4329
4300
|
return Loader.apply(this, arguments);
|
|
4330
4301
|
}
|
|
4331
4302
|
var _proto = TextureCubeLoader.prototype;
|
|
4332
|
-
|
|
4303
|
+
/**
|
|
4304
|
+
* @override
|
|
4305
|
+
*/ _proto.load = function load(item, resourceManager) {
|
|
4333
4306
|
var _this = this;
|
|
4334
4307
|
return new miniprogram.AssetPromise(function(resolve, reject) {
|
|
4335
|
-
|
|
4336
|
-
|
|
4337
|
-
|
|
4338
|
-
|
|
4308
|
+
var urls = item.urls;
|
|
4309
|
+
var requestConfig = _extends({}, item, {
|
|
4310
|
+
type: "image"
|
|
4311
|
+
});
|
|
4312
|
+
Promise.all(urls.map(function(url) {
|
|
4313
|
+
return _this.request(url, requestConfig);
|
|
4339
4314
|
})).then(function(images) {
|
|
4340
4315
|
var _images_ = images[0], width = _images_.width, height = _images_.height;
|
|
4341
4316
|
if (width !== height) {
|
|
4342
4317
|
console.error("The cube texture must have the same width and height");
|
|
4343
4318
|
return;
|
|
4344
4319
|
}
|
|
4345
|
-
var
|
|
4346
|
-
/** @ts-ignore */ if (!tex._platformTexture) return;
|
|
4320
|
+
var texture = new miniprogram.TextureCube(resourceManager.engine, width);
|
|
4347
4321
|
for(var faceIndex = 0; faceIndex < 6; faceIndex++){
|
|
4348
|
-
|
|
4322
|
+
texture.setImageSource(miniprogram.TextureCubeFace.PositiveX + faceIndex, images[faceIndex], 0);
|
|
4349
4323
|
}
|
|
4350
|
-
|
|
4351
|
-
|
|
4324
|
+
texture.generateMipmaps();
|
|
4325
|
+
resourceManager.addContentRestorer(new TextureCubeContentRestorer(texture, urls, requestConfig));
|
|
4326
|
+
resolve(texture);
|
|
4352
4327
|
}).catch(function(e) {
|
|
4353
4328
|
reject(e);
|
|
4354
4329
|
});
|
|
@@ -4362,6 +4337,30 @@ TextureCubeLoader = __decorate([
|
|
|
4362
4337
|
])
|
|
4363
4338
|
], TextureCubeLoader);
|
|
4364
4339
|
|
|
4340
|
+
var AnimationClipLoader = /*#__PURE__*/ function(Loader) {
|
|
4341
|
+
_inherits(AnimationClipLoader, Loader);
|
|
4342
|
+
function AnimationClipLoader() {
|
|
4343
|
+
return Loader.apply(this, arguments);
|
|
4344
|
+
}
|
|
4345
|
+
var _proto = AnimationClipLoader.prototype;
|
|
4346
|
+
_proto.load = function load(item, resourceManager) {
|
|
4347
|
+
var _this = this;
|
|
4348
|
+
return new miniprogram.AssetPromise(function(resolve, reject) {
|
|
4349
|
+
_this.request(item.url, _extends({}, item, {
|
|
4350
|
+
type: "arraybuffer"
|
|
4351
|
+
})).then(function(data) {
|
|
4352
|
+
return decode(data, resourceManager.engine);
|
|
4353
|
+
}).catch(reject);
|
|
4354
|
+
});
|
|
4355
|
+
};
|
|
4356
|
+
return AnimationClipLoader;
|
|
4357
|
+
}(miniprogram.Loader);
|
|
4358
|
+
AnimationClipLoader = __decorate([
|
|
4359
|
+
miniprogram.resourceLoader(miniprogram.AssetType.AnimationClip, [
|
|
4360
|
+
"ani"
|
|
4361
|
+
])
|
|
4362
|
+
], AnimationClipLoader);
|
|
4363
|
+
|
|
4365
4364
|
var SceneLoader = /*#__PURE__*/ function(Loader) {
|
|
4366
4365
|
_inherits(SceneLoader, Loader);
|
|
4367
4366
|
function SceneLoader() {
|
|
@@ -4406,7 +4405,7 @@ var SceneLoader = /*#__PURE__*/ function(Loader) {
|
|
|
4406
4405
|
backgroundPromise = resourceManager.getResourceByRef(background.sky).then(function(light) {
|
|
4407
4406
|
var sky = scene.background.sky;
|
|
4408
4407
|
var skyMaterial = new miniprogram.SkyBoxMaterial(engine);
|
|
4409
|
-
skyMaterial.
|
|
4408
|
+
skyMaterial.texture = light.specularTexture;
|
|
4410
4409
|
skyMaterial.textureDecodeRGBM = true;
|
|
4411
4410
|
sky.material = skyMaterial;
|
|
4412
4411
|
sky.mesh = miniprogram.PrimitiveMesh.createCuboid(engine, 1, 1, 1);
|
|
@@ -4462,10 +4461,410 @@ ReflectionParser.registerCustomParseComponent("TextRenderer", /*#__PURE__*/ _asy
|
|
|
4462
4461
|
});
|
|
4463
4462
|
}));
|
|
4464
4463
|
|
|
4464
|
+
var _KHR_draco_mesh_compression;
|
|
4465
|
+
var KHR_draco_mesh_compression = (_KHR_draco_mesh_compression = /*#__PURE__*/ function(GLTFExtensionParser) {
|
|
4466
|
+
_inherits(KHR_draco_mesh_compression1, GLTFExtensionParser);
|
|
4467
|
+
function KHR_draco_mesh_compression1() {
|
|
4468
|
+
return GLTFExtensionParser.apply(this, arguments);
|
|
4469
|
+
}
|
|
4470
|
+
var _proto = KHR_draco_mesh_compression1.prototype;
|
|
4471
|
+
/**
|
|
4472
|
+
* @override
|
|
4473
|
+
*/ _proto.initialize = function initialize() {
|
|
4474
|
+
if (!KHR_draco_mesh_compression._decoder) {
|
|
4475
|
+
KHR_draco_mesh_compression._decoder = new miniprogram$3.DRACODecoder();
|
|
4476
|
+
}
|
|
4477
|
+
};
|
|
4478
|
+
/**
|
|
4479
|
+
* @override
|
|
4480
|
+
*/ _proto.createAndParse = function createAndParse(context, schema, glTFPrimitive, glTFMesh) {
|
|
4481
|
+
var _this = this;
|
|
4482
|
+
var glTF = context.glTF, buffers = context.buffers, engine = context.glTFResource.engine;
|
|
4483
|
+
var bufferViews = glTF.bufferViews, accessors = glTF.accessors;
|
|
4484
|
+
var bufferViewIndex = schema.bufferView, gltfAttributeMap = schema.attributes;
|
|
4485
|
+
var attributeMap = {};
|
|
4486
|
+
var attributeTypeMap = {};
|
|
4487
|
+
for(var attributeName in gltfAttributeMap){
|
|
4488
|
+
attributeMap[attributeName] = gltfAttributeMap[attributeName];
|
|
4489
|
+
}
|
|
4490
|
+
for(var attributeName1 in glTFPrimitive.attributes){
|
|
4491
|
+
if (gltfAttributeMap[attributeName1] !== undefined) {
|
|
4492
|
+
var accessorDef = accessors[glTFPrimitive.attributes[attributeName1]];
|
|
4493
|
+
attributeTypeMap[attributeName1] = GLTFUtils.getComponentType(accessorDef.componentType).name;
|
|
4494
|
+
}
|
|
4495
|
+
}
|
|
4496
|
+
var indexAccessor = accessors[glTFPrimitive.indices];
|
|
4497
|
+
var indexType = GLTFUtils.getComponentType(indexAccessor.componentType).name;
|
|
4498
|
+
var taskConfig = {
|
|
4499
|
+
attributeIDs: attributeMap,
|
|
4500
|
+
attributeTypes: attributeTypeMap,
|
|
4501
|
+
useUniqueIDs: true,
|
|
4502
|
+
indexType: indexType
|
|
4503
|
+
};
|
|
4504
|
+
var buffer = GLTFUtils.getBufferViewData(bufferViews[bufferViewIndex], buffers);
|
|
4505
|
+
return KHR_draco_mesh_compression._decoder.decode(buffer, taskConfig).then(function(decodedGeometry) {
|
|
4506
|
+
var mesh = new miniprogram.ModelMesh(engine, glTFMesh.name);
|
|
4507
|
+
return _this._parseMeshFromGLTFPrimitiveDraco(mesh, glTFMesh, glTFPrimitive, glTF, function(attributeSemantic) {
|
|
4508
|
+
for(var j = 0; j < decodedGeometry.attributes.length; j++){
|
|
4509
|
+
if (decodedGeometry.attributes[j].name === attributeSemantic) {
|
|
4510
|
+
return decodedGeometry.attributes[j].array;
|
|
4511
|
+
}
|
|
4512
|
+
}
|
|
4513
|
+
return null;
|
|
4514
|
+
}, function(attributeSemantic, shapeIndex) {
|
|
4515
|
+
throw "BlendShape animation is not supported when using draco.";
|
|
4516
|
+
}, function() {
|
|
4517
|
+
return decodedGeometry.index.array;
|
|
4518
|
+
}, context.keepMeshData);
|
|
4519
|
+
});
|
|
4520
|
+
};
|
|
4521
|
+
_proto._parseMeshFromGLTFPrimitiveDraco = function _parseMeshFromGLTFPrimitiveDraco(mesh, gltfMesh, gltfPrimitive, gltf, getVertexBufferData, getBlendShapeData, getIndexBufferData, keepMeshData) {
|
|
4522
|
+
var attributes = gltfPrimitive.attributes, targets = gltfPrimitive.targets, indices = gltfPrimitive.indices, mode = gltfPrimitive.mode;
|
|
4523
|
+
var vertexCount;
|
|
4524
|
+
var accessors = gltf.accessors;
|
|
4525
|
+
var accessor = accessors[attributes["POSITION"]];
|
|
4526
|
+
var positionBuffer = getVertexBufferData("POSITION");
|
|
4527
|
+
var positions = GLTFUtils.floatBufferToVector3Array(positionBuffer);
|
|
4528
|
+
mesh.setPositions(positions);
|
|
4529
|
+
var bounds = mesh.bounds;
|
|
4530
|
+
vertexCount = accessor.count;
|
|
4531
|
+
if (accessor.min && accessor.max) {
|
|
4532
|
+
bounds.min.copyFromArray(accessor.min);
|
|
4533
|
+
bounds.max.copyFromArray(accessor.max);
|
|
4534
|
+
} else {
|
|
4535
|
+
var position = KHR_draco_mesh_compression._tempVector3;
|
|
4536
|
+
var min = bounds.min, max = bounds.max;
|
|
4537
|
+
min.set(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
|
|
4538
|
+
max.set(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
|
|
4539
|
+
var stride = positionBuffer.length / vertexCount;
|
|
4540
|
+
for(var j = 0; j < vertexCount; j++){
|
|
4541
|
+
var offset = j * stride;
|
|
4542
|
+
position.copyFromArray(positionBuffer, offset);
|
|
4543
|
+
miniprogram$1.Vector3.min(min, position, min);
|
|
4544
|
+
miniprogram$1.Vector3.max(max, position, max);
|
|
4545
|
+
}
|
|
4546
|
+
}
|
|
4547
|
+
for(var attributeSemantic in attributes){
|
|
4548
|
+
if (attributeSemantic === "POSITION") {
|
|
4549
|
+
continue;
|
|
4550
|
+
}
|
|
4551
|
+
var bufferData = getVertexBufferData(attributeSemantic);
|
|
4552
|
+
switch(attributeSemantic){
|
|
4553
|
+
case "NORMAL":
|
|
4554
|
+
var normals = GLTFUtils.floatBufferToVector3Array(bufferData);
|
|
4555
|
+
mesh.setNormals(normals);
|
|
4556
|
+
break;
|
|
4557
|
+
case "TEXCOORD_0":
|
|
4558
|
+
var texturecoords = GLTFUtils.floatBufferToVector2Array(bufferData);
|
|
4559
|
+
mesh.setUVs(texturecoords, 0);
|
|
4560
|
+
break;
|
|
4561
|
+
case "TEXCOORD_1":
|
|
4562
|
+
var texturecoords1 = GLTFUtils.floatBufferToVector2Array(bufferData);
|
|
4563
|
+
mesh.setUVs(texturecoords1, 1);
|
|
4564
|
+
break;
|
|
4565
|
+
case "TEXCOORD_2":
|
|
4566
|
+
var texturecoords2 = GLTFUtils.floatBufferToVector2Array(bufferData);
|
|
4567
|
+
mesh.setUVs(texturecoords2, 2);
|
|
4568
|
+
break;
|
|
4569
|
+
case "TEXCOORD_3":
|
|
4570
|
+
var texturecoords3 = GLTFUtils.floatBufferToVector2Array(bufferData);
|
|
4571
|
+
mesh.setUVs(texturecoords3, 3);
|
|
4572
|
+
break;
|
|
4573
|
+
case "TEXCOORD_4":
|
|
4574
|
+
var texturecoords4 = GLTFUtils.floatBufferToVector2Array(bufferData);
|
|
4575
|
+
mesh.setUVs(texturecoords4, 4);
|
|
4576
|
+
break;
|
|
4577
|
+
case "TEXCOORD_5":
|
|
4578
|
+
var texturecoords5 = GLTFUtils.floatBufferToVector2Array(bufferData);
|
|
4579
|
+
mesh.setUVs(texturecoords5, 5);
|
|
4580
|
+
break;
|
|
4581
|
+
case "TEXCOORD_6":
|
|
4582
|
+
var texturecoords6 = GLTFUtils.floatBufferToVector2Array(bufferData);
|
|
4583
|
+
mesh.setUVs(texturecoords6, 6);
|
|
4584
|
+
break;
|
|
4585
|
+
case "TEXCOORD_7":
|
|
4586
|
+
var texturecoords7 = GLTFUtils.floatBufferToVector2Array(bufferData);
|
|
4587
|
+
mesh.setUVs(texturecoords7, 7);
|
|
4588
|
+
break;
|
|
4589
|
+
case "COLOR_0":
|
|
4590
|
+
var colors = GLTFUtils.floatBufferToColorArray(bufferData, accessors[attributes["COLOR_0"]].type === AccessorType.VEC3);
|
|
4591
|
+
mesh.setColors(colors);
|
|
4592
|
+
break;
|
|
4593
|
+
case "TANGENT":
|
|
4594
|
+
var tangents = GLTFUtils.floatBufferToVector4Array(bufferData);
|
|
4595
|
+
mesh.setTangents(tangents);
|
|
4596
|
+
break;
|
|
4597
|
+
case "JOINTS_0":
|
|
4598
|
+
var joints = GLTFUtils.floatBufferToVector4Array(bufferData);
|
|
4599
|
+
mesh.setBoneIndices(joints);
|
|
4600
|
+
break;
|
|
4601
|
+
case "WEIGHTS_0":
|
|
4602
|
+
var weights = GLTFUtils.floatBufferToVector4Array(bufferData);
|
|
4603
|
+
mesh.setBoneWeights(weights);
|
|
4604
|
+
break;
|
|
4605
|
+
}
|
|
4606
|
+
}
|
|
4607
|
+
// Indices
|
|
4608
|
+
if (indices !== undefined) {
|
|
4609
|
+
var indexAccessor = gltf.accessors[indices];
|
|
4610
|
+
var indexData = getIndexBufferData();
|
|
4611
|
+
mesh.setIndices(indexData);
|
|
4612
|
+
mesh.addSubMesh(0, indexAccessor.count, mode);
|
|
4613
|
+
} else {
|
|
4614
|
+
mesh.addSubMesh(0, vertexCount, mode);
|
|
4615
|
+
}
|
|
4616
|
+
// BlendShapes
|
|
4617
|
+
targets && GLTFMeshParser._createBlendShape(mesh, null, gltfMesh, targets, getBlendShapeData);
|
|
4618
|
+
mesh.uploadData(!keepMeshData);
|
|
4619
|
+
return Promise.resolve(mesh);
|
|
4620
|
+
};
|
|
4621
|
+
return KHR_draco_mesh_compression1;
|
|
4622
|
+
}(GLTFExtensionParser), function() {
|
|
4623
|
+
_KHR_draco_mesh_compression._tempVector3 = new miniprogram$1.Vector3();
|
|
4624
|
+
}(), _KHR_draco_mesh_compression);
|
|
4625
|
+
KHR_draco_mesh_compression = __decorate([
|
|
4626
|
+
registerGLTFExtension("KHR_draco_mesh_compression", exports.GLTFExtensionMode.CreateAndParse)
|
|
4627
|
+
], KHR_draco_mesh_compression);
|
|
4628
|
+
|
|
4629
|
+
var KHR_lights_punctual = /*#__PURE__*/ function(GLTFExtensionParser) {
|
|
4630
|
+
_inherits(KHR_lights_punctual, GLTFExtensionParser);
|
|
4631
|
+
function KHR_lights_punctual() {
|
|
4632
|
+
return GLTFExtensionParser.apply(this, arguments);
|
|
4633
|
+
}
|
|
4634
|
+
var _proto = KHR_lights_punctual.prototype;
|
|
4635
|
+
/**
|
|
4636
|
+
* @override
|
|
4637
|
+
*/ _proto.additiveParse = function additiveParse(context, entity, extensionSchema) {
|
|
4638
|
+
var lightsSchema = context.glTF.extensions.KHR_lights_punctual.lights;
|
|
4639
|
+
var lightSchema = lightsSchema[extensionSchema.light];
|
|
4640
|
+
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;
|
|
4641
|
+
var glTFResource = context.glTFResource;
|
|
4642
|
+
var light;
|
|
4643
|
+
if (type === "directional") {
|
|
4644
|
+
light = entity.addComponent(miniprogram.DirectLight);
|
|
4645
|
+
} else if (type === "point") {
|
|
4646
|
+
light = entity.addComponent(miniprogram.PointLight);
|
|
4647
|
+
} else if (type === "spot") {
|
|
4648
|
+
light = entity.addComponent(miniprogram.SpotLight);
|
|
4649
|
+
}
|
|
4650
|
+
if (color) {
|
|
4651
|
+
light.color.set(color[0], color[1], color[2], 1);
|
|
4652
|
+
}
|
|
4653
|
+
light.intensity = intensity;
|
|
4654
|
+
if (range && !_instanceof(light, miniprogram.DirectLight)) {
|
|
4655
|
+
light.distance = range;
|
|
4656
|
+
}
|
|
4657
|
+
if (spot && _instanceof(light, miniprogram.SpotLight)) {
|
|
4658
|
+
var _spot_innerConeAngle = spot.innerConeAngle, innerConeAngle = _spot_innerConeAngle === void 0 ? 0 : _spot_innerConeAngle, _spot_outerConeAngle = spot.outerConeAngle, outerConeAngle = _spot_outerConeAngle === void 0 ? Math.PI / 4 : _spot_outerConeAngle;
|
|
4659
|
+
light.angle = innerConeAngle;
|
|
4660
|
+
light.penumbra = outerConeAngle - innerConeAngle;
|
|
4661
|
+
}
|
|
4662
|
+
if (!glTFResource.lights) glTFResource.lights = [];
|
|
4663
|
+
glTFResource.lights.push(light);
|
|
4664
|
+
};
|
|
4665
|
+
return KHR_lights_punctual;
|
|
4666
|
+
}(GLTFExtensionParser);
|
|
4667
|
+
KHR_lights_punctual = __decorate([
|
|
4668
|
+
registerGLTFExtension("KHR_lights_punctual", exports.GLTFExtensionMode.AdditiveParse)
|
|
4669
|
+
], KHR_lights_punctual);
|
|
4670
|
+
|
|
4671
|
+
var KHR_materials_clearcoat = /*#__PURE__*/ function(GLTFExtensionParser) {
|
|
4672
|
+
_inherits(KHR_materials_clearcoat, GLTFExtensionParser);
|
|
4673
|
+
function KHR_materials_clearcoat() {
|
|
4674
|
+
return GLTFExtensionParser.apply(this, arguments);
|
|
4675
|
+
}
|
|
4676
|
+
var _proto = KHR_materials_clearcoat.prototype;
|
|
4677
|
+
/**
|
|
4678
|
+
* @override
|
|
4679
|
+
*/ _proto.additiveParse = function additiveParse(context, material, schema) {
|
|
4680
|
+
var textures = context.glTFResource.textures;
|
|
4681
|
+
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;
|
|
4682
|
+
material.clearCoat = clearcoatFactor;
|
|
4683
|
+
material.clearCoatRoughness = clearcoatRoughnessFactor;
|
|
4684
|
+
if (clearcoatTexture) {
|
|
4685
|
+
material.clearCoatTexture = textures[clearcoatTexture.index];
|
|
4686
|
+
GLTFMaterialParser._checkOtherTextureTransform(clearcoatTexture, "Clear coat");
|
|
4687
|
+
}
|
|
4688
|
+
if (clearcoatRoughnessTexture) {
|
|
4689
|
+
material.clearCoatRoughnessTexture = textures[clearcoatRoughnessTexture.index];
|
|
4690
|
+
GLTFMaterialParser._checkOtherTextureTransform(clearcoatRoughnessTexture, "Clear coat roughness");
|
|
4691
|
+
}
|
|
4692
|
+
if (clearcoatNormalTexture) {
|
|
4693
|
+
material.clearCoatNormalTexture = textures[clearcoatNormalTexture.index];
|
|
4694
|
+
GLTFMaterialParser._checkOtherTextureTransform(clearcoatNormalTexture, "Clear coat normal");
|
|
4695
|
+
}
|
|
4696
|
+
};
|
|
4697
|
+
return KHR_materials_clearcoat;
|
|
4698
|
+
}(GLTFExtensionParser);
|
|
4699
|
+
KHR_materials_clearcoat = __decorate([
|
|
4700
|
+
registerGLTFExtension("KHR_materials_clearcoat", exports.GLTFExtensionMode.AdditiveParse)
|
|
4701
|
+
], KHR_materials_clearcoat);
|
|
4702
|
+
|
|
4703
|
+
var KHR_materials_pbrSpecularGlossiness = /*#__PURE__*/ function(GLTFExtensionParser) {
|
|
4704
|
+
_inherits(KHR_materials_pbrSpecularGlossiness, GLTFExtensionParser);
|
|
4705
|
+
function KHR_materials_pbrSpecularGlossiness() {
|
|
4706
|
+
return GLTFExtensionParser.apply(this, arguments);
|
|
4707
|
+
}
|
|
4708
|
+
var _proto = KHR_materials_pbrSpecularGlossiness.prototype;
|
|
4709
|
+
/**
|
|
4710
|
+
* @override
|
|
4711
|
+
*/ _proto.createAndParse = function createAndParse(context, schema, ownerSchema) {
|
|
4712
|
+
var _context_glTFResource = context.glTFResource, engine = _context_glTFResource.engine, textures = _context_glTFResource.textures;
|
|
4713
|
+
var material = new miniprogram.PBRSpecularMaterial(engine);
|
|
4714
|
+
var diffuseFactor = schema.diffuseFactor, diffuseTexture = schema.diffuseTexture, specularFactor = schema.specularFactor, glossinessFactor = schema.glossinessFactor, specularGlossinessTexture = schema.specularGlossinessTexture;
|
|
4715
|
+
if (diffuseFactor) {
|
|
4716
|
+
material.baseColor = new miniprogram$1.Color(miniprogram$1.Color.linearToGammaSpace(diffuseFactor[0]), miniprogram$1.Color.linearToGammaSpace(diffuseFactor[1]), miniprogram$1.Color.linearToGammaSpace(diffuseFactor[2]), diffuseFactor[3]);
|
|
4717
|
+
}
|
|
4718
|
+
if (diffuseTexture) {
|
|
4719
|
+
material.baseTexture = textures[diffuseTexture.index];
|
|
4720
|
+
GLTFParser.executeExtensionsAdditiveAndParse(diffuseTexture.extensions, context, material, diffuseTexture);
|
|
4721
|
+
}
|
|
4722
|
+
if (specularFactor) {
|
|
4723
|
+
material.specularColor = new miniprogram$1.Color(miniprogram$1.Color.linearToGammaSpace(specularFactor[0]), miniprogram$1.Color.linearToGammaSpace(specularFactor[1]), miniprogram$1.Color.linearToGammaSpace(specularFactor[2]));
|
|
4724
|
+
}
|
|
4725
|
+
if (glossinessFactor !== undefined) {
|
|
4726
|
+
material.glossiness = glossinessFactor;
|
|
4727
|
+
}
|
|
4728
|
+
if (specularGlossinessTexture) {
|
|
4729
|
+
material.specularGlossinessTexture = textures[specularGlossinessTexture.index];
|
|
4730
|
+
GLTFMaterialParser._checkOtherTextureTransform(specularGlossinessTexture, "Specular glossiness");
|
|
4731
|
+
}
|
|
4732
|
+
material.name = ownerSchema.name;
|
|
4733
|
+
GLTFMaterialParser._parseStandardProperty(context, material, ownerSchema);
|
|
4734
|
+
return material;
|
|
4735
|
+
};
|
|
4736
|
+
return KHR_materials_pbrSpecularGlossiness;
|
|
4737
|
+
}(GLTFExtensionParser);
|
|
4738
|
+
KHR_materials_pbrSpecularGlossiness = __decorate([
|
|
4739
|
+
registerGLTFExtension("KHR_materials_pbrSpecularGlossiness", exports.GLTFExtensionMode.CreateAndParse)
|
|
4740
|
+
], KHR_materials_pbrSpecularGlossiness);
|
|
4741
|
+
|
|
4742
|
+
var KHR_materials_unlit = /*#__PURE__*/ function(GLTFExtensionParser) {
|
|
4743
|
+
_inherits(KHR_materials_unlit, GLTFExtensionParser);
|
|
4744
|
+
function KHR_materials_unlit() {
|
|
4745
|
+
return GLTFExtensionParser.apply(this, arguments);
|
|
4746
|
+
}
|
|
4747
|
+
var _proto = KHR_materials_unlit.prototype;
|
|
4748
|
+
/**
|
|
4749
|
+
* @override
|
|
4750
|
+
*/ _proto.createAndParse = function createAndParse(context, _, ownerSchema) {
|
|
4751
|
+
var engine = context.glTFResource.engine;
|
|
4752
|
+
var material = new miniprogram.UnlitMaterial(engine);
|
|
4753
|
+
material.name = ownerSchema.name;
|
|
4754
|
+
GLTFMaterialParser._parseStandardProperty(context, material, ownerSchema);
|
|
4755
|
+
return material;
|
|
4756
|
+
};
|
|
4757
|
+
return KHR_materials_unlit;
|
|
4758
|
+
}(GLTFExtensionParser);
|
|
4759
|
+
KHR_materials_unlit = __decorate([
|
|
4760
|
+
registerGLTFExtension("KHR_materials_unlit", exports.GLTFExtensionMode.CreateAndParse)
|
|
4761
|
+
], KHR_materials_unlit);
|
|
4762
|
+
|
|
4763
|
+
var KHR_mesh_quantization = /*#__PURE__*/ function(GLTFExtensionParser) {
|
|
4764
|
+
_inherits(KHR_mesh_quantization, GLTFExtensionParser);
|
|
4765
|
+
function KHR_mesh_quantization() {
|
|
4766
|
+
return GLTFExtensionParser.apply(this, arguments);
|
|
4767
|
+
}
|
|
4768
|
+
return KHR_mesh_quantization;
|
|
4769
|
+
}(GLTFExtensionParser);
|
|
4770
|
+
KHR_mesh_quantization = __decorate([
|
|
4771
|
+
registerGLTFExtension("KHR_mesh_quantization", exports.GLTFExtensionMode.AdditiveParse)
|
|
4772
|
+
], KHR_mesh_quantization);
|
|
4773
|
+
|
|
4774
|
+
var KHR_texture_transform = /*#__PURE__*/ function(GLTFExtensionParser) {
|
|
4775
|
+
_inherits(KHR_texture_transform, GLTFExtensionParser);
|
|
4776
|
+
function KHR_texture_transform() {
|
|
4777
|
+
return GLTFExtensionParser.apply(this, arguments);
|
|
4778
|
+
}
|
|
4779
|
+
var _proto = KHR_texture_transform.prototype;
|
|
4780
|
+
/**
|
|
4781
|
+
* @override
|
|
4782
|
+
*/ _proto.additiveParse = function additiveParse(context, material, schema) {
|
|
4783
|
+
var offset = schema.offset, rotation = schema.rotation, scale = schema.scale, texCoord = schema.texCoord;
|
|
4784
|
+
if (offset) {
|
|
4785
|
+
material.tilingOffset.z = offset[0];
|
|
4786
|
+
material.tilingOffset.w = offset[1];
|
|
4787
|
+
}
|
|
4788
|
+
if (scale) {
|
|
4789
|
+
material.tilingOffset.x = scale[0];
|
|
4790
|
+
material.tilingOffset.y = scale[1];
|
|
4791
|
+
}
|
|
4792
|
+
if (rotation) {
|
|
4793
|
+
miniprogram.Logger.warn("rotation in KHR_texture_transform is not supported now");
|
|
4794
|
+
}
|
|
4795
|
+
if (texCoord) {
|
|
4796
|
+
miniprogram.Logger.warn("texCoord in KHR_texture_transform is not supported now");
|
|
4797
|
+
}
|
|
4798
|
+
};
|
|
4799
|
+
return KHR_texture_transform;
|
|
4800
|
+
}(GLTFExtensionParser);
|
|
4801
|
+
KHR_texture_transform = __decorate([
|
|
4802
|
+
registerGLTFExtension("KHR_texture_transform", exports.GLTFExtensionMode.AdditiveParse)
|
|
4803
|
+
], KHR_texture_transform);
|
|
4804
|
+
|
|
4805
|
+
var GALACEAN_materials_remap = /*#__PURE__*/ function(GLTFExtensionParser) {
|
|
4806
|
+
_inherits(GALACEAN_materials_remap, GLTFExtensionParser);
|
|
4807
|
+
function GALACEAN_materials_remap() {
|
|
4808
|
+
return GLTFExtensionParser.apply(this, arguments);
|
|
4809
|
+
}
|
|
4810
|
+
var _proto = GALACEAN_materials_remap.prototype;
|
|
4811
|
+
/**
|
|
4812
|
+
* @override
|
|
4813
|
+
*/ _proto.createAndParse = function createAndParse(context, schema) {
|
|
4814
|
+
var engine = context.glTFResource.engine;
|
|
4815
|
+
// @ts-ignore
|
|
4816
|
+
return engine.resourceManager.getResourceByRef(schema);
|
|
4817
|
+
};
|
|
4818
|
+
return GALACEAN_materials_remap;
|
|
4819
|
+
}(GLTFExtensionParser);
|
|
4820
|
+
GALACEAN_materials_remap = __decorate([
|
|
4821
|
+
registerGLTFExtension("GALACEAN_materials_remap", exports.GLTFExtensionMode.CreateAndParse)
|
|
4822
|
+
], GALACEAN_materials_remap);
|
|
4823
|
+
|
|
4824
|
+
var GALACEAN_animation_event = /*#__PURE__*/ function(GLTFExtensionParser) {
|
|
4825
|
+
_inherits(GALACEAN_animation_event, GLTFExtensionParser);
|
|
4826
|
+
function GALACEAN_animation_event() {
|
|
4827
|
+
return GLTFExtensionParser.apply(this, arguments);
|
|
4828
|
+
}
|
|
4829
|
+
var _proto = GALACEAN_animation_event.prototype;
|
|
4830
|
+
/**
|
|
4831
|
+
* @override
|
|
4832
|
+
*/ _proto.additiveParse = function additiveParse(context, animationClip, schema) {
|
|
4833
|
+
context.glTFResource.engine;
|
|
4834
|
+
var events = schema.events;
|
|
4835
|
+
events.map(function(eventData) {
|
|
4836
|
+
var event = new miniprogram.AnimationEvent();
|
|
4837
|
+
event.functionName = eventData.functionName;
|
|
4838
|
+
event.time = eventData.time;
|
|
4839
|
+
event.parameter = eventData.parameter;
|
|
4840
|
+
animationClip.addEvent(event);
|
|
4841
|
+
});
|
|
4842
|
+
};
|
|
4843
|
+
return GALACEAN_animation_event;
|
|
4844
|
+
}(GLTFExtensionParser);
|
|
4845
|
+
GALACEAN_animation_event = __decorate([
|
|
4846
|
+
registerGLTFExtension("GALACEAN_animation_event", exports.GLTFExtensionMode.AdditiveParse)
|
|
4847
|
+
], GALACEAN_animation_event);
|
|
4848
|
+
|
|
4465
4849
|
exports.ComponentMap = ComponentMap;
|
|
4850
|
+
exports.GLTFAnimationParser = GLTFAnimationParser;
|
|
4851
|
+
exports.GLTFBufferParser = GLTFBufferParser;
|
|
4852
|
+
exports.GLTFEntityParser = GLTFEntityParser;
|
|
4853
|
+
exports.GLTFExtensionParser = GLTFExtensionParser;
|
|
4854
|
+
exports.GLTFMaterialParser = GLTFMaterialParser;
|
|
4855
|
+
exports.GLTFMeshParser = GLTFMeshParser;
|
|
4856
|
+
exports.GLTFParser = GLTFParser;
|
|
4857
|
+
exports.GLTFParserContext = GLTFParserContext;
|
|
4858
|
+
exports.GLTFPipeline = GLTFPipeline;
|
|
4466
4859
|
exports.GLTFResource = GLTFResource;
|
|
4860
|
+
exports.GLTFSceneParser = GLTFSceneParser;
|
|
4861
|
+
exports.GLTFSkinParser = GLTFSkinParser;
|
|
4862
|
+
exports.GLTFTextureParser = GLTFTextureParser;
|
|
4863
|
+
exports.GLTFUtils = GLTFUtils;
|
|
4864
|
+
exports.GLTFValidator = GLTFValidator;
|
|
4467
4865
|
exports.PrefabParser = PrefabParser;
|
|
4468
4866
|
exports.ReflectionParser = ReflectionParser;
|
|
4469
4867
|
exports.SceneParser = SceneParser;
|
|
4470
4868
|
exports.decode = decode;
|
|
4471
4869
|
exports.parseSingleKTX = parseSingleKTX;
|
|
4870
|
+
exports.registerGLTFExtension = registerGLTFExtension;
|