@galacean/engine-loader 1.0.0 → 1.0.2
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 +1764 -1208
- package/dist/main.js.map +1 -1
- package/dist/miniprogram.js +1784 -1228
- package/dist/module.js +1751 -1210
- package/dist/module.js.map +1 -1
- package/package.json +5 -5
- package/types/AnimationClipLoader.d.ts +1 -0
- package/types/GLTFContentRestorer.d.ts +92 -0
- package/types/GLTFLoader.d.ts +3 -0
- package/types/ProjectLoader.d.ts +1 -0
- package/types/Texture2DContentRestorer.d.ts +11 -0
- package/types/TextureCubeContentRestorer.d.ts +11 -0
- package/types/gltf/GLTFPipeline.d.ts +23 -0
- package/types/gltf/GLTFResource.d.ts +7 -15
- package/types/gltf/GLTFSchema.d.ts +816 -0
- package/types/gltf/GLTFUtil.d.ts +1 -1
- package/types/gltf/GLTFUtils.d.ts +48 -0
- package/types/gltf/extensions/GALACEAN_animation_event.d.ts +1 -0
- package/types/gltf/extensions/GLTFExtensionParser.d.ts +52 -0
- package/types/gltf/extensions/GLTFExtensionSchema.d.ts +149 -0
- package/types/gltf/extensions/KHR_materials_ior.d.ts +1 -0
- package/types/gltf/extensions/KHR_materials_variants.d.ts +6 -1
- package/types/gltf/extensions/index.d.ts +5 -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/GLTFParserContext.d.ts +53 -0
- package/types/gltf/parser/GLTFSceneParser.d.ts +11 -0
- package/types/gltf/parser/GLTFSchemaParser.d.ts +7 -0
- package/types/gltf/parser/GLTFSkinParser.d.ts +7 -0
- package/types/gltf/parser/GLTFTextureParser.d.ts +9 -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/ktx2/BinomialLLCTranscoder/BinomialLLCTranscoder.d.ts +13 -0
- package/types/ktx2/BinomialLLCTranscoder/TranscodeWorkerCode.d.ts +33 -0
- package/types/ktx2/KTX2Container.d.ts +72 -0
- package/types/ktx2/KTX2Loader.d.ts +53 -0
- package/types/ktx2/KTX2TargetFormat.d.ts +21 -0
- package/types/ktx2/KhronosTranscoder/KhronosTranscoder.d.ts +17 -0
- package/types/ktx2/KhronosTranscoder/TranscoderWorkerCode.d.ts +34 -0
- package/types/ktx2/TranscodeResult.d.ts +10 -0
- package/types/ktx2/WorkerPool.d.ts +32 -0
- package/types/ktx2/constants.d.ts +7 -0
- package/types/ktx2/transcoder/AbstractTranscoder.d.ts +55 -0
- package/types/ktx2/transcoder/BinomialLLCTranscoder.d.ts +8 -0
- package/types/ktx2/transcoder/BinomialLLCWorkerCode.d.ts +6 -0
- package/types/ktx2/transcoder/KhronosTranscoder.d.ts +13 -0
- package/types/ktx2/transcoder/KhronosWorkerCode.d.ts +1 -0
- package/types/ktx2/zstddec.d.ts +62 -0
- package/types/resource-deserialize/index.d.ts +3 -3
- package/types/resource-deserialize/resources/mesh/MeshDecoder.d.ts +1 -1
- package/types/resource-deserialize/resources/parser/PrefabParser.d.ts +5 -0
- package/types/resource-deserialize/resources/parser/ReflectionParser.d.ts +14 -0
- package/types/resource-deserialize/resources/scene/SceneParser.d.ts +1 -1
- package/types/resource-deserialize/resources/scene/SceneParserContext.d.ts +1 -1
- package/types/resource-deserialize/resources/schema/BasicSchema.d.ts +61 -0
- package/types/resource-deserialize/resources/schema/MaterialSchema.d.ts +91 -0
- package/types/resource-deserialize/resources/schema/ProjectSchema.d.ts +9 -0
- package/types/resource-deserialize/resources/schema/SceneSchema.d.ts +41 -0
- package/types/resource-deserialize/resources/schema/index.d.ts +3 -0
package/dist/module.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { resourceLoader, AssetType, AssetPromise, AnimatorController, AnimatorControllerLayer, AnimatorStateMachine,
|
|
1
|
+
import { resourceLoader, AssetType, AssetPromise, AnimatorController, AnimatorControllerLayer, AnimatorStateMachine, Loader, AnimatorStateTransition, TextureCube, TextureFilterMode, TextureCubeFace, AmbientLight, DiffuseMode, Font, request, ContentRestorer, IndexFormat, VertexElementFormat, Utils, AnimationClip, AnimationFloatArrayCurve, Keyframe, InterpolationType, AnimationQuaternionCurve, AnimationVector3Curve, SkinnedMeshRenderer, Transform, Entity, PBRMaterial, Logger, PBRSpecularMaterial, TextureCoordinate, RenderFace, VertexElement, Buffer, BufferBindFlag, BufferUsage, BlendShape, ModelMesh, Camera, Animator, BlinnPhongMaterial, MeshRenderer, Skin, TextureWrapMode as TextureWrapMode$1, Texture2D, ReferResource, TextureFormat, Material, Shader, DirectLight, ParticleRenderer, PointLight, SpotLight, Script, SpriteMask, SpriteRenderer, TextRenderer, AnimationEvent, AnimationColorCurve, AnimationVector4Curve, AnimationVector2Curve, AnimationArrayCurve, AnimationFloatCurve, Scene, SpriteAtlas, Sprite, BackgroundMode, UnlitMaterial } from '@galacean/engine-core';
|
|
2
2
|
import { SphericalHarmonics3, Vector2, Vector3, Vector4, Color, Quaternion, Matrix, Rect } from '@galacean/engine-math';
|
|
3
|
-
import { DRACODecoder } from '@galacean/engine-draco';
|
|
4
3
|
import { GLCompressedTextureInternalFormat } from '@galacean/engine-rhi-webgl';
|
|
4
|
+
import { DRACODecoder } from '@galacean/engine-draco';
|
|
5
5
|
|
|
6
6
|
function _extends() {
|
|
7
7
|
_extends = Object.assign || function assign(target) {
|
|
@@ -86,10 +86,10 @@ function __generator(thisArg, body) {
|
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
var AnimatorControllerLoader = /*#__PURE__*/ function(
|
|
90
|
-
_inherits(AnimatorControllerLoader,
|
|
89
|
+
var AnimatorControllerLoader = /*#__PURE__*/ function(Loader1) {
|
|
90
|
+
_inherits(AnimatorControllerLoader, Loader1);
|
|
91
91
|
function AnimatorControllerLoader() {
|
|
92
|
-
return
|
|
92
|
+
return Loader1.apply(this, arguments);
|
|
93
93
|
}
|
|
94
94
|
var _proto = AnimatorControllerLoader.prototype;
|
|
95
95
|
_proto.load = function load(item, resourceManager) {
|
|
@@ -110,13 +110,17 @@ var AnimatorControllerLoader = /*#__PURE__*/ function(Loader) {
|
|
|
110
110
|
var states = stateMachineData.states;
|
|
111
111
|
var stateMachine = layer.stateMachine = new AnimatorStateMachine();
|
|
112
112
|
states.forEach(function(stateData, stateIndex) {
|
|
113
|
-
var name = stateData.name, speed = stateData.speed, wrapMode = stateData.wrapMode, clipStartNormalizedTime = stateData.clipStartNormalizedTime, clipEndNormalizedTime = stateData.clipEndNormalizedTime, isDefaultState = stateData.isDefaultState, clipData = stateData.clip;
|
|
113
|
+
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;
|
|
114
114
|
var state = stateMachine.addState(name);
|
|
115
115
|
isDefaultState && (stateMachine.defaultState = state);
|
|
116
116
|
state.speed = speed;
|
|
117
117
|
state.wrapMode = wrapMode;
|
|
118
118
|
state.clipStartTime = clipStartNormalizedTime;
|
|
119
119
|
state.clipEndTime = clipEndNormalizedTime;
|
|
120
|
+
var scriptsObject = JSON.parse(scripts);
|
|
121
|
+
scriptsObject == null ? void 0 : scriptsObject.forEach(function(script) {
|
|
122
|
+
state.addStateMachineScript(Loader.getClass(script));
|
|
123
|
+
});
|
|
120
124
|
if (clipData) {
|
|
121
125
|
promises.push(new Promise(function(resolve) {
|
|
122
126
|
//@ts-ignore
|
|
@@ -214,7 +218,8 @@ var EnvLoader = /*#__PURE__*/ function(Loader) {
|
|
|
214
218
|
var shArray = new Float32Array(arraybuffer, 0, 27);
|
|
215
219
|
var shByteLength = 27 * 4;
|
|
216
220
|
var size = (_ref = new Uint16Array(arraybuffer, shByteLength, 1)) == null ? void 0 : _ref[0];
|
|
217
|
-
var
|
|
221
|
+
var engine = resourceManager.engine;
|
|
222
|
+
var texture = new TextureCube(engine, size);
|
|
218
223
|
texture.filterMode = TextureFilterMode.Trilinear;
|
|
219
224
|
var mipmapCount = texture.mipmapCount;
|
|
220
225
|
var offset = shByteLength + 2;
|
|
@@ -227,7 +232,7 @@ var EnvLoader = /*#__PURE__*/ function(Loader) {
|
|
|
227
232
|
texture.setPixelBuffer(TextureCubeFace.PositiveX + face, data, mipLevel);
|
|
228
233
|
}
|
|
229
234
|
}
|
|
230
|
-
var ambientLight = new AmbientLight();
|
|
235
|
+
var ambientLight = new AmbientLight(engine);
|
|
231
236
|
var sh = new SphericalHarmonics3();
|
|
232
237
|
ambientLight.diffuseMode = DiffuseMode.SphericalHarmonics;
|
|
233
238
|
sh.copyFromArray(shArray);
|
|
@@ -337,52 +342,205 @@ FontLoader = __decorate([
|
|
|
337
342
|
], false)
|
|
338
343
|
], FontLoader);
|
|
339
344
|
|
|
345
|
+
function _array_like_to_array(arr, len) {
|
|
346
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
347
|
+
|
|
348
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
349
|
+
|
|
350
|
+
return arr2;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
354
|
+
if (!o) return;
|
|
355
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
356
|
+
|
|
357
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
358
|
+
|
|
359
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
360
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
361
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
|
|
365
|
+
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
366
|
+
|
|
367
|
+
if (it) return (it = it.call(o)).next.bind(it);
|
|
368
|
+
// Fallback for engines without symbol support
|
|
369
|
+
if (Array.isArray(o) || (it = _unsupported_iterable_to_array(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
370
|
+
if (it) o = it;
|
|
371
|
+
|
|
372
|
+
var i = 0;
|
|
373
|
+
|
|
374
|
+
return function() {
|
|
375
|
+
if (i >= o.length) return { done: true };
|
|
376
|
+
|
|
377
|
+
return { done: false, value: o[i++] };
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
382
|
+
}
|
|
383
|
+
|
|
340
384
|
/**
|
|
341
385
|
* @internal
|
|
342
|
-
*/ var
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
this.masterPromiseInfo = new PromiseInfo();
|
|
353
|
-
this.promiseMap = {};
|
|
354
|
-
var promiseMap = this.promiseMap;
|
|
355
|
-
promiseMap["" + url + "?q=textures"] = this._initPromiseInfo(this.texturesPromiseInfo);
|
|
356
|
-
promiseMap["" + url + "?q=materials"] = this._initPromiseInfo(this.materialsPromiseInfo);
|
|
357
|
-
promiseMap["" + url + "?q=meshes"] = this._initPromiseInfo(this.meshesPromiseInfo);
|
|
358
|
-
promiseMap["" + url + "?q=animations"] = this._initPromiseInfo(this.animationClipsPromiseInfo);
|
|
359
|
-
promiseMap["" + url + "?q=defaultSceneRoot"] = this._initPromiseInfo(this.defaultSceneRootPromiseInfo);
|
|
360
|
-
promiseMap["" + url] = this._initPromiseInfo(this.masterPromiseInfo);
|
|
386
|
+
*/ var GLTFContentRestorer = /*#__PURE__*/ function(ContentRestorer) {
|
|
387
|
+
_inherits(GLTFContentRestorer, ContentRestorer);
|
|
388
|
+
function GLTFContentRestorer() {
|
|
389
|
+
var _this;
|
|
390
|
+
_this = ContentRestorer.apply(this, arguments) || this;
|
|
391
|
+
_this.bufferRequests = [];
|
|
392
|
+
_this.glbBufferSlices = [];
|
|
393
|
+
_this.bufferTextures = [];
|
|
394
|
+
_this.meshes = [];
|
|
395
|
+
return _this;
|
|
361
396
|
}
|
|
362
|
-
var _proto =
|
|
363
|
-
_proto.
|
|
364
|
-
var
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
397
|
+
var _proto = GLTFContentRestorer.prototype;
|
|
398
|
+
_proto.restoreContent = function restoreContent() {
|
|
399
|
+
var _this = this;
|
|
400
|
+
return new AssetPromise(function(resolve, reject) {
|
|
401
|
+
Promise.all(_this.bufferRequests.map(function(bufferRequestInfo) {
|
|
402
|
+
return request(bufferRequestInfo.url, bufferRequestInfo.config);
|
|
403
|
+
})).then(function(buffers) {
|
|
404
|
+
// Buffer parse
|
|
405
|
+
if (_this.isGLB) {
|
|
406
|
+
var glbBufferSlice = _this.glbBufferSlices;
|
|
407
|
+
var bigBuffer = buffers[0];
|
|
408
|
+
var bufferCount = glbBufferSlice.length;
|
|
409
|
+
buffers.length = bufferCount;
|
|
410
|
+
for(var i = 0; i < bufferCount; i++){
|
|
411
|
+
var slice = glbBufferSlice[i];
|
|
412
|
+
buffers[i] = bigBuffer.slice(slice.x, slice.x + slice.y);
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
// Restore texture
|
|
416
|
+
AssetPromise.all(_this.bufferTextures.map(function(textureRestoreInfo) {
|
|
417
|
+
var bufferView = textureRestoreInfo.bufferView;
|
|
418
|
+
var buffer = buffers[bufferView.buffer];
|
|
419
|
+
var _bufferView_byteOffset;
|
|
420
|
+
var bufferData = new Uint8Array(buffer, (_bufferView_byteOffset = bufferView.byteOffset) != null ? _bufferView_byteOffset : 0, bufferView.byteLength);
|
|
421
|
+
return GLTFUtils.loadImageBuffer(bufferData, textureRestoreInfo.mimeType).then(function(image) {
|
|
422
|
+
textureRestoreInfo.texture.setImageSource(image);
|
|
423
|
+
textureRestoreInfo.texture.generateMipmaps();
|
|
424
|
+
});
|
|
425
|
+
})).then(function() {
|
|
426
|
+
// Restore mesh
|
|
427
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(_this.meshes), _step; !(_step = _iterator()).done;){
|
|
428
|
+
var meshInfo = _step.value;
|
|
429
|
+
var mesh = meshInfo.mesh;
|
|
430
|
+
for(var _iterator1 = _create_for_of_iterator_helper_loose(meshInfo.vertexBuffers), _step1; !(_step1 = _iterator1()).done;){
|
|
431
|
+
var bufferRestoreInfo = _step1.value;
|
|
432
|
+
var vertexData = _this._getBufferData(buffers, bufferRestoreInfo.data);
|
|
433
|
+
bufferRestoreInfo.buffer.setData(vertexData);
|
|
434
|
+
}
|
|
435
|
+
if (meshInfo.indexBuffer) {
|
|
436
|
+
var indexData = _this._getBufferData(buffers, meshInfo.indexBuffer);
|
|
437
|
+
mesh.setIndices(indexData);
|
|
438
|
+
}
|
|
439
|
+
for(var _iterator2 = _create_for_of_iterator_helper_loose(meshInfo.blendShapes), _step2; !(_step2 = _iterator2()).done;){
|
|
440
|
+
var restoreInfo = _step2.value;
|
|
441
|
+
var frame = restoreInfo.blendShape.frames[0];
|
|
442
|
+
var position = restoreInfo.position;
|
|
443
|
+
var positionData = _this._getBufferData(buffers, position.buffer);
|
|
444
|
+
frame.deltaPositions = GLTFUtils.bufferToVector3Array(positionData, position.stride, position.byteOffset, position.count);
|
|
445
|
+
if (restoreInfo.normal) {
|
|
446
|
+
var normal = restoreInfo.normal;
|
|
447
|
+
var normalData = _this._getBufferData(buffers, normal.buffer);
|
|
448
|
+
frame.deltaNormals = GLTFUtils.bufferToVector3Array(normalData, normal.stride, normal.byteOffset, normal.count);
|
|
449
|
+
}
|
|
450
|
+
if (restoreInfo.tangent) {
|
|
451
|
+
var tangent = restoreInfo.tangent;
|
|
452
|
+
var tangentData = _this._getBufferData(buffers, tangent.buffer);
|
|
453
|
+
frame.deltaTangents = GLTFUtils.bufferToVector3Array(tangentData, tangent.stride, tangent.byteOffset, tangent.count);
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
mesh.uploadData(true);
|
|
457
|
+
}
|
|
458
|
+
resolve(_this.resource);
|
|
459
|
+
}).catch(reject);
|
|
460
|
+
}).catch(reject);
|
|
369
461
|
});
|
|
370
|
-
promiseInfo.promise = promise;
|
|
371
|
-
return promise;
|
|
372
462
|
};
|
|
373
|
-
|
|
374
|
-
|
|
463
|
+
_proto._getBufferData = function _getBufferData(buffers, restoreInfo) {
|
|
464
|
+
var main = restoreInfo.main;
|
|
465
|
+
var buffer = buffers[main.bufferIndex];
|
|
466
|
+
var data = new main.TypedArray(buffer, main.byteOffset, main.length);
|
|
467
|
+
var sparseCount = restoreInfo.sparseCount;
|
|
468
|
+
if (sparseCount) {
|
|
469
|
+
var sparseIndex = restoreInfo.sparseIndices;
|
|
470
|
+
var sparseIndexBuffer = buffers[sparseIndex.bufferIndex];
|
|
471
|
+
var sparseIndexData = new sparseIndex.TypedArray(sparseIndexBuffer, sparseIndex.byteOffset, sparseIndex.length);
|
|
472
|
+
var sparseValue = restoreInfo.sparseValues;
|
|
473
|
+
var sparseValueBuffer = buffers[sparseValue.bufferIndex];
|
|
474
|
+
var sparseValueData = new sparseValue.TypedArray(sparseValueBuffer, sparseValue.byteOffset, sparseValue.length);
|
|
475
|
+
var typeSize = restoreInfo.typeSize;
|
|
476
|
+
for(var i = 0; i < sparseCount; i++){
|
|
477
|
+
var replaceIndex = sparseIndexData[i];
|
|
478
|
+
for(var j = 0; j < typeSize; j++){
|
|
479
|
+
data[replaceIndex * typeSize + j] = sparseValueData[i * typeSize + j];
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
return data;
|
|
484
|
+
};
|
|
485
|
+
return GLTFContentRestorer;
|
|
486
|
+
}(ContentRestorer);
|
|
375
487
|
/**
|
|
376
488
|
* @internal
|
|
377
|
-
*/ var
|
|
489
|
+
*/ var BufferRequestInfo = function BufferRequestInfo(url, config) {
|
|
490
|
+
this.url = url;
|
|
491
|
+
this.config = config;
|
|
492
|
+
};
|
|
493
|
+
/**
|
|
494
|
+
* @internal
|
|
495
|
+
*/ var BufferTextureRestoreInfo = function BufferTextureRestoreInfo(texture, bufferView, mimeType) {
|
|
496
|
+
this.texture = texture;
|
|
497
|
+
this.bufferView = bufferView;
|
|
498
|
+
this.mimeType = mimeType;
|
|
499
|
+
};
|
|
500
|
+
/**
|
|
501
|
+
* @internal
|
|
502
|
+
*/ var ModelMeshRestoreInfo = function ModelMeshRestoreInfo() {
|
|
503
|
+
this.vertexBuffers = [];
|
|
504
|
+
this.blendShapes = [];
|
|
505
|
+
};
|
|
506
|
+
/**
|
|
507
|
+
* @internal
|
|
508
|
+
*/ var BufferRestoreInfo = function BufferRestoreInfo(buffer, data) {
|
|
509
|
+
this.buffer = buffer;
|
|
378
510
|
this.data = data;
|
|
379
|
-
this.interleaved = interleaved;
|
|
380
|
-
this.stride = stride;
|
|
381
|
-
this.vertexBindingInfos = {};
|
|
382
511
|
};
|
|
383
512
|
/**
|
|
384
513
|
* @internal
|
|
385
|
-
*/ var
|
|
514
|
+
*/ var BufferDataRestoreInfo = function BufferDataRestoreInfo(main, typeSize, sparseCount, sparseIndices, sparseValues) {
|
|
515
|
+
this.main = main;
|
|
516
|
+
this.typeSize = typeSize;
|
|
517
|
+
this.sparseCount = sparseCount;
|
|
518
|
+
this.sparseIndices = sparseIndices;
|
|
519
|
+
this.sparseValues = sparseValues;
|
|
520
|
+
};
|
|
521
|
+
/**
|
|
522
|
+
* @internal
|
|
523
|
+
*/ var RestoreDataAccessor = function RestoreDataAccessor(bufferIndex, TypedArray, byteOffset, length) {
|
|
524
|
+
this.bufferIndex = bufferIndex;
|
|
525
|
+
this.TypedArray = TypedArray;
|
|
526
|
+
this.byteOffset = byteOffset;
|
|
527
|
+
this.length = length;
|
|
528
|
+
};
|
|
529
|
+
/**
|
|
530
|
+
* @internal
|
|
531
|
+
*/ var BlendShapeRestoreInfo = function BlendShapeRestoreInfo(blendShape, position, normal, tangent) {
|
|
532
|
+
this.blendShape = blendShape;
|
|
533
|
+
this.position = position;
|
|
534
|
+
this.normal = normal;
|
|
535
|
+
this.tangent = tangent;
|
|
536
|
+
};
|
|
537
|
+
/**
|
|
538
|
+
* @internal
|
|
539
|
+
*/ var BlendShapeDataRestoreInfo = function BlendShapeDataRestoreInfo(buffer, stride, byteOffset, count) {
|
|
540
|
+
this.buffer = buffer;
|
|
541
|
+
this.stride = stride;
|
|
542
|
+
this.byteOffset = byteOffset;
|
|
543
|
+
this.count = count;
|
|
386
544
|
};
|
|
387
545
|
|
|
388
546
|
/**
|
|
@@ -534,9 +692,62 @@ var TextureWrapMode;
|
|
|
534
692
|
|
|
535
693
|
/**
|
|
536
694
|
* @internal
|
|
537
|
-
*/ var
|
|
538
|
-
function
|
|
539
|
-
|
|
695
|
+
*/ var GLTFParserContext = /*#__PURE__*/ function() {
|
|
696
|
+
function GLTFParserContext(url) {
|
|
697
|
+
this.hasSkinned = false;
|
|
698
|
+
this.chainPromises = [];
|
|
699
|
+
this.accessorBufferCache = {};
|
|
700
|
+
this.texturesPromiseInfo = new PromiseInfo();
|
|
701
|
+
this.materialsPromiseInfo = new PromiseInfo();
|
|
702
|
+
this.meshesPromiseInfo = new PromiseInfo();
|
|
703
|
+
this.animationClipsPromiseInfo = new PromiseInfo();
|
|
704
|
+
this.defaultSceneRootPromiseInfo = new PromiseInfo();
|
|
705
|
+
this.masterPromiseInfo = new PromiseInfo();
|
|
706
|
+
this.promiseMap = {};
|
|
707
|
+
var promiseMap = this.promiseMap;
|
|
708
|
+
promiseMap["" + url + "?q=textures"] = this._initPromiseInfo(this.texturesPromiseInfo);
|
|
709
|
+
promiseMap["" + url + "?q=materials"] = this._initPromiseInfo(this.materialsPromiseInfo);
|
|
710
|
+
promiseMap["" + url + "?q=meshes"] = this._initPromiseInfo(this.meshesPromiseInfo);
|
|
711
|
+
promiseMap["" + url + "?q=animations"] = this._initPromiseInfo(this.animationClipsPromiseInfo);
|
|
712
|
+
promiseMap["" + url + "?q=defaultSceneRoot"] = this._initPromiseInfo(this.defaultSceneRootPromiseInfo);
|
|
713
|
+
promiseMap["" + url] = this._initPromiseInfo(this.masterPromiseInfo);
|
|
714
|
+
}
|
|
715
|
+
var _proto = GLTFParserContext.prototype;
|
|
716
|
+
/**
|
|
717
|
+
* Get all the buffer data.
|
|
718
|
+
*/ _proto.getBuffers = function getBuffers() {
|
|
719
|
+
return Promise.resolve(this._buffers);
|
|
720
|
+
};
|
|
721
|
+
_proto._initPromiseInfo = function _initPromiseInfo(promiseInfo) {
|
|
722
|
+
var promise = new AssetPromise(function(resolve, reject, setProgress, onCancel) {
|
|
723
|
+
promiseInfo.resolve = resolve;
|
|
724
|
+
promiseInfo.reject = reject;
|
|
725
|
+
promiseInfo.setProgress = setProgress;
|
|
726
|
+
promiseInfo.onCancel = onCancel;
|
|
727
|
+
});
|
|
728
|
+
promiseInfo.promise = promise;
|
|
729
|
+
return promise;
|
|
730
|
+
};
|
|
731
|
+
return GLTFParserContext;
|
|
732
|
+
}();
|
|
733
|
+
/**
|
|
734
|
+
* @internal
|
|
735
|
+
*/ var BufferInfo = function BufferInfo(data, interleaved, stride) {
|
|
736
|
+
this.data = data;
|
|
737
|
+
this.interleaved = interleaved;
|
|
738
|
+
this.stride = stride;
|
|
739
|
+
this.vertexBindingInfos = {};
|
|
740
|
+
};
|
|
741
|
+
/**
|
|
742
|
+
* @internal
|
|
743
|
+
*/ var PromiseInfo = function PromiseInfo() {
|
|
744
|
+
};
|
|
745
|
+
|
|
746
|
+
/**
|
|
747
|
+
* @internal
|
|
748
|
+
*/ var GLTFUtils = /*#__PURE__*/ function() {
|
|
749
|
+
function GLTFUtils() {}
|
|
750
|
+
GLTFUtils.floatBufferToVector2Array = function floatBufferToVector2Array(buffer) {
|
|
540
751
|
var bufferLen = buffer.length;
|
|
541
752
|
var array = new Array(bufferLen / 2);
|
|
542
753
|
for(var i = 0; i < bufferLen; i += 2){
|
|
@@ -544,7 +755,7 @@ var TextureWrapMode;
|
|
|
544
755
|
}
|
|
545
756
|
return array;
|
|
546
757
|
};
|
|
547
|
-
|
|
758
|
+
GLTFUtils.floatBufferToVector3Array = function floatBufferToVector3Array(buffer) {
|
|
548
759
|
var bufferLen = buffer.length;
|
|
549
760
|
var array = new Array(bufferLen / 3);
|
|
550
761
|
for(var i = 0; i < bufferLen; i += 3){
|
|
@@ -552,7 +763,7 @@ var TextureWrapMode;
|
|
|
552
763
|
}
|
|
553
764
|
return array;
|
|
554
765
|
};
|
|
555
|
-
|
|
766
|
+
GLTFUtils.floatBufferToVector4Array = function floatBufferToVector4Array(buffer) {
|
|
556
767
|
var bufferLen = buffer.length;
|
|
557
768
|
var array = new Array(bufferLen / 4);
|
|
558
769
|
for(var i = 0; i < bufferLen; i += 4){
|
|
@@ -560,7 +771,7 @@ var TextureWrapMode;
|
|
|
560
771
|
}
|
|
561
772
|
return array;
|
|
562
773
|
};
|
|
563
|
-
|
|
774
|
+
GLTFUtils.floatBufferToColorArray = function floatBufferToColorArray(buffer, isColor3) {
|
|
564
775
|
var bufferLen = buffer.length;
|
|
565
776
|
var colors = new Array(bufferLen / (isColor3 ? 3 : 4));
|
|
566
777
|
if (isColor3) {
|
|
@@ -575,21 +786,8 @@ var TextureWrapMode;
|
|
|
575
786
|
return colors;
|
|
576
787
|
};
|
|
577
788
|
/**
|
|
578
|
-
* Parse binary text for glb loader.
|
|
579
|
-
*/ GLTFUtil.decodeText = function decodeText(array) {
|
|
580
|
-
if (typeof TextDecoder !== "undefined") {
|
|
581
|
-
return new TextDecoder().decode(array);
|
|
582
|
-
}
|
|
583
|
-
// TextDecoder polyfill
|
|
584
|
-
var s = "";
|
|
585
|
-
for(var i = 0, il = array.length; i < il; i++){
|
|
586
|
-
s += String.fromCharCode(array[i]);
|
|
587
|
-
}
|
|
588
|
-
return decodeURIComponent(encodeURIComponent(s));
|
|
589
|
-
};
|
|
590
|
-
/**
|
|
591
789
|
* Get the number of bytes occupied by accessor type.
|
|
592
|
-
*/
|
|
790
|
+
*/ GLTFUtils.getAccessorTypeSize = function getAccessorTypeSize(accessorType) {
|
|
593
791
|
switch(accessorType){
|
|
594
792
|
case AccessorType.SCALAR:
|
|
595
793
|
return 1;
|
|
@@ -609,7 +807,7 @@ var TextureWrapMode;
|
|
|
609
807
|
};
|
|
610
808
|
/**
|
|
611
809
|
* Get the TypedArray corresponding to the component type.
|
|
612
|
-
*/
|
|
810
|
+
*/ GLTFUtils.getComponentType = function getComponentType(componentType) {
|
|
613
811
|
switch(componentType){
|
|
614
812
|
case AccessorComponentType.BYTE:
|
|
615
813
|
return Int8Array;
|
|
@@ -625,7 +823,7 @@ var TextureWrapMode;
|
|
|
625
823
|
return Float32Array;
|
|
626
824
|
}
|
|
627
825
|
};
|
|
628
|
-
|
|
826
|
+
GLTFUtils.getNormalizedComponentScale = function getNormalizedComponentScale(componentType) {
|
|
629
827
|
// Reference: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization#encoding-quantized-data
|
|
630
828
|
switch(componentType){
|
|
631
829
|
case AccessorComponentType.BYTE:
|
|
@@ -640,60 +838,75 @@ var TextureWrapMode;
|
|
|
640
838
|
throw new Error("Galacean.GLTFLoader: Unsupported normalized accessor component type.");
|
|
641
839
|
}
|
|
642
840
|
};
|
|
643
|
-
|
|
644
|
-
var buffers = context.buffers;
|
|
645
|
-
var bufferViews = gltf.bufferViews;
|
|
841
|
+
GLTFUtils.getAccessorBuffer = function getAccessorBuffer(context, bufferViews, accessor) {
|
|
646
842
|
var componentType = accessor.componentType;
|
|
647
843
|
var bufferView = bufferViews[accessor.bufferView];
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
var
|
|
661
|
-
var
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
var
|
|
666
|
-
var
|
|
667
|
-
|
|
668
|
-
|
|
844
|
+
return context.getBuffers().then(function(buffers) {
|
|
845
|
+
var bufferIndex = bufferView.buffer;
|
|
846
|
+
var buffer = buffers[bufferIndex];
|
|
847
|
+
var _bufferView_byteOffset;
|
|
848
|
+
var bufferByteOffset = (_bufferView_byteOffset = bufferView.byteOffset) != null ? _bufferView_byteOffset : 0;
|
|
849
|
+
var _accessor_byteOffset;
|
|
850
|
+
var byteOffset = (_accessor_byteOffset = accessor.byteOffset) != null ? _accessor_byteOffset : 0;
|
|
851
|
+
var TypedArray = GLTFUtils.getComponentType(componentType);
|
|
852
|
+
var dataElementSize = GLTFUtils.getAccessorTypeSize(accessor.type);
|
|
853
|
+
var dataElementBytes = TypedArray.BYTES_PER_ELEMENT;
|
|
854
|
+
var elementStride = dataElementSize * dataElementBytes;
|
|
855
|
+
var accessorCount = accessor.count;
|
|
856
|
+
var bufferStride = bufferView.byteStride;
|
|
857
|
+
var bufferInfo;
|
|
858
|
+
// According to the glTF official documentation only byteStride not undefined is allowed
|
|
859
|
+
if (bufferStride !== undefined && bufferStride !== elementStride) {
|
|
860
|
+
var bufferSlice = Math.floor(byteOffset / bufferStride);
|
|
861
|
+
var bufferCacheKey = accessor.bufferView + ":" + componentType + ":" + bufferSlice + ":" + accessorCount;
|
|
862
|
+
var accessorBufferCache = context.accessorBufferCache;
|
|
863
|
+
bufferInfo = accessorBufferCache[bufferCacheKey];
|
|
864
|
+
if (!bufferInfo) {
|
|
865
|
+
var offset = bufferByteOffset + bufferSlice * bufferStride;
|
|
866
|
+
var count = accessorCount * (bufferStride / dataElementBytes);
|
|
867
|
+
var data = new TypedArray(buffer, offset, count);
|
|
868
|
+
accessorBufferCache[bufferCacheKey] = bufferInfo = new BufferInfo(data, true, bufferStride);
|
|
869
|
+
bufferInfo.restoreInfo = new BufferDataRestoreInfo(new RestoreDataAccessor(bufferIndex, TypedArray, offset, count));
|
|
870
|
+
}
|
|
871
|
+
} else {
|
|
872
|
+
var offset1 = bufferByteOffset + byteOffset;
|
|
873
|
+
var count1 = accessorCount * dataElementSize;
|
|
874
|
+
var data1 = new TypedArray(buffer, offset1, count1);
|
|
875
|
+
bufferInfo = new BufferInfo(data1, false, elementStride);
|
|
876
|
+
bufferInfo.restoreInfo = new BufferDataRestoreInfo(new RestoreDataAccessor(bufferIndex, TypedArray, offset1, count1));
|
|
669
877
|
}
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
878
|
+
if (accessor.sparse) {
|
|
879
|
+
GLTFUtils.processingSparseData(bufferViews, accessor, buffers, bufferInfo);
|
|
880
|
+
}
|
|
881
|
+
return bufferInfo;
|
|
882
|
+
});
|
|
883
|
+
};
|
|
884
|
+
GLTFUtils.bufferToVector3Array = function bufferToVector3Array(data, byteStride, accessorByteOffset, count) {
|
|
885
|
+
var bytesPerElement = data.BYTES_PER_ELEMENT;
|
|
886
|
+
var offset = accessorByteOffset % byteStride / bytesPerElement;
|
|
887
|
+
var stride = byteStride / bytesPerElement;
|
|
888
|
+
var vector3s = new Array(count);
|
|
889
|
+
for(var i = 0; i < count; i++){
|
|
890
|
+
var index = offset + i * stride;
|
|
891
|
+
vector3s[i] = new Vector3(data[index], data[index + 1], data[index + 2]);
|
|
679
892
|
}
|
|
680
|
-
return
|
|
893
|
+
return vector3s;
|
|
681
894
|
};
|
|
682
895
|
/**
|
|
683
896
|
* @deprecated
|
|
684
897
|
* Get accessor data.
|
|
685
|
-
*/
|
|
686
|
-
var bufferViews =
|
|
898
|
+
*/ GLTFUtils.getAccessorData = function getAccessorData(glTF, accessor, buffers) {
|
|
899
|
+
var bufferViews = glTF.bufferViews;
|
|
687
900
|
var bufferView = bufferViews[accessor.bufferView];
|
|
688
901
|
var arrayBuffer = buffers[bufferView.buffer];
|
|
689
902
|
var accessorByteOffset = accessor.hasOwnProperty("byteOffset") ? accessor.byteOffset : 0;
|
|
690
903
|
var bufferViewByteOffset = bufferView.hasOwnProperty("byteOffset") ? bufferView.byteOffset : 0;
|
|
691
904
|
var byteOffset = accessorByteOffset + bufferViewByteOffset;
|
|
692
|
-
var accessorTypeSize =
|
|
905
|
+
var accessorTypeSize = GLTFUtils.getAccessorTypeSize(accessor.type);
|
|
693
906
|
var length = accessorTypeSize * accessor.count;
|
|
694
907
|
var _bufferView_byteStride;
|
|
695
908
|
var byteStride = (_bufferView_byteStride = bufferView.byteStride) != null ? _bufferView_byteStride : 0;
|
|
696
|
-
var arrayType =
|
|
909
|
+
var arrayType = GLTFUtils.getComponentType(accessor.componentType);
|
|
697
910
|
var uint8Array;
|
|
698
911
|
if (byteStride) {
|
|
699
912
|
var accessorByteSize = accessorTypeSize * arrayType.BYTES_PER_ELEMENT;
|
|
@@ -720,7 +933,7 @@ var TextureWrapMode;
|
|
|
720
933
|
var _values_byteOffset, _valuesBufferView_byteOffset;
|
|
721
934
|
var valuesByteOffset = ((_values_byteOffset = values.byteOffset) != null ? _values_byteOffset : 0) + ((_valuesBufferView_byteOffset = valuesBufferView.byteOffset) != null ? _valuesBufferView_byteOffset : 0);
|
|
722
935
|
var valuesByteLength = valuesBufferView.byteLength;
|
|
723
|
-
var indicesType =
|
|
936
|
+
var indicesType = GLTFUtils.getComponentType(indices.componentType);
|
|
724
937
|
var indicesArray = new indicesType(indicesArrayBuffer, indicesByteOffset, indicesByteLength / indicesType.BYTES_PER_ELEMENT);
|
|
725
938
|
var valuesArray = new arrayType(valuesArrayBuffer, valuesByteOffset, valuesByteLength / arrayType.BYTES_PER_ELEMENT);
|
|
726
939
|
for(var i1 = 0; i1 < count; i1++){
|
|
@@ -732,41 +945,49 @@ var TextureWrapMode;
|
|
|
732
945
|
}
|
|
733
946
|
return typedArray;
|
|
734
947
|
};
|
|
735
|
-
|
|
736
|
-
var
|
|
737
|
-
var arrayBuffer = buffers[buffer];
|
|
738
|
-
return arrayBuffer.slice(byteOffset, byteOffset + byteLength);
|
|
948
|
+
GLTFUtils.getBufferViewData = function getBufferViewData(bufferView, buffers) {
|
|
949
|
+
var _bufferView_byteOffset = bufferView.byteOffset, byteOffset = _bufferView_byteOffset === void 0 ? 0 : _bufferView_byteOffset;
|
|
950
|
+
var arrayBuffer = buffers[bufferView.buffer];
|
|
951
|
+
return arrayBuffer.slice(byteOffset, byteOffset + bufferView.byteLength);
|
|
739
952
|
};
|
|
740
953
|
/**
|
|
741
954
|
* Get accessor data.
|
|
742
|
-
*/
|
|
743
|
-
var
|
|
744
|
-
var accessorTypeSize =
|
|
745
|
-
var TypedArray =
|
|
746
|
-
var data =
|
|
955
|
+
*/ GLTFUtils.processingSparseData = function processingSparseData(bufferViews, accessor, buffers, bufferInfo) {
|
|
956
|
+
var restoreInfo = bufferInfo.restoreInfo;
|
|
957
|
+
var accessorTypeSize = GLTFUtils.getAccessorTypeSize(accessor.type);
|
|
958
|
+
var TypedArray = GLTFUtils.getComponentType(accessor.componentType);
|
|
959
|
+
var data = bufferInfo.data.slice();
|
|
747
960
|
var _accessor_sparse = accessor.sparse, count = _accessor_sparse.count, indices = _accessor_sparse.indices, values = _accessor_sparse.values;
|
|
748
961
|
var indicesBufferView = bufferViews[indices.bufferView];
|
|
749
962
|
var valuesBufferView = bufferViews[values.bufferView];
|
|
750
|
-
var
|
|
751
|
-
var
|
|
963
|
+
var indicesBufferIndex = indicesBufferView.buffer;
|
|
964
|
+
var valuesBufferIndex = valuesBufferView.buffer;
|
|
965
|
+
var indicesArrayBuffer = buffers[indicesBufferIndex];
|
|
966
|
+
var valuesArrayBuffer = buffers[valuesBufferIndex];
|
|
752
967
|
var _indices_byteOffset, _indicesBufferView_byteOffset;
|
|
753
968
|
var indicesByteOffset = ((_indices_byteOffset = indices.byteOffset) != null ? _indices_byteOffset : 0) + ((_indicesBufferView_byteOffset = indicesBufferView.byteOffset) != null ? _indicesBufferView_byteOffset : 0);
|
|
754
969
|
var indicesByteLength = indicesBufferView.byteLength;
|
|
755
970
|
var _values_byteOffset, _valuesBufferView_byteOffset;
|
|
756
971
|
var valuesByteOffset = ((_values_byteOffset = values.byteOffset) != null ? _values_byteOffset : 0) + ((_valuesBufferView_byteOffset = valuesBufferView.byteOffset) != null ? _valuesBufferView_byteOffset : 0);
|
|
757
972
|
var valuesByteLength = valuesBufferView.byteLength;
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
var
|
|
973
|
+
restoreInfo.typeSize = accessorTypeSize;
|
|
974
|
+
restoreInfo.sparseCount = count;
|
|
975
|
+
var IndexTypeArray = GLTFUtils.getComponentType(indices.componentType);
|
|
976
|
+
var indexLength = indicesByteLength / IndexTypeArray.BYTES_PER_ELEMENT;
|
|
977
|
+
var indicesArray = new IndexTypeArray(indicesArrayBuffer, indicesByteOffset, indexLength);
|
|
978
|
+
restoreInfo.sparseIndices = new RestoreDataAccessor(indicesBufferIndex, IndexTypeArray, indicesByteOffset, indexLength);
|
|
979
|
+
var valueLength = valuesByteLength / TypedArray.BYTES_PER_ELEMENT;
|
|
980
|
+
var valuesArray = new TypedArray(valuesArrayBuffer, valuesByteOffset, valueLength);
|
|
981
|
+
restoreInfo.sparseValues = new RestoreDataAccessor(valuesBufferIndex, TypedArray, valuesByteOffset, valueLength);
|
|
761
982
|
for(var i = 0; i < count; i++){
|
|
762
983
|
var replaceIndex = indicesArray[i];
|
|
763
984
|
for(var j = 0; j < accessorTypeSize; j++){
|
|
764
985
|
data[replaceIndex * accessorTypeSize + j] = valuesArray[i * accessorTypeSize + j];
|
|
765
986
|
}
|
|
766
987
|
}
|
|
767
|
-
|
|
988
|
+
bufferInfo.data = data;
|
|
768
989
|
};
|
|
769
|
-
|
|
990
|
+
GLTFUtils.getIndexFormat = function getIndexFormat(type) {
|
|
770
991
|
switch(type){
|
|
771
992
|
case AccessorComponentType.UNSIGNED_BYTE:
|
|
772
993
|
return IndexFormat.UInt8;
|
|
@@ -776,7 +997,7 @@ var TextureWrapMode;
|
|
|
776
997
|
return IndexFormat.UInt32;
|
|
777
998
|
}
|
|
778
999
|
};
|
|
779
|
-
|
|
1000
|
+
GLTFUtils.getElementFormat = function getElementFormat(type, size, normalized) {
|
|
780
1001
|
if (normalized === void 0) normalized = false;
|
|
781
1002
|
if (type == AccessorComponentType.FLOAT) {
|
|
782
1003
|
switch(size){
|
|
@@ -827,7 +1048,7 @@ var TextureWrapMode;
|
|
|
827
1048
|
};
|
|
828
1049
|
/**
|
|
829
1050
|
* Load image buffer
|
|
830
|
-
*/
|
|
1051
|
+
*/ GLTFUtils.loadImageBuffer = function loadImageBuffer(imageBuffer, type) {
|
|
831
1052
|
return new Promise(function(resolve, reject) {
|
|
832
1053
|
var blob = new window.Blob([
|
|
833
1054
|
imageBuffer
|
|
@@ -851,18 +1072,9 @@ var TextureWrapMode;
|
|
|
851
1072
|
img.src = URL.createObjectURL(blob);
|
|
852
1073
|
});
|
|
853
1074
|
};
|
|
854
|
-
GLTFUtil.isAbsoluteUrl = function isAbsoluteUrl(url) {
|
|
855
|
-
return /^(?:http|blob|data:|\/)/.test(url);
|
|
856
|
-
};
|
|
857
|
-
GLTFUtil.parseRelativeUrl = function parseRelativeUrl(baseUrl, relativeUrl) {
|
|
858
|
-
if (GLTFUtil.isAbsoluteUrl(relativeUrl)) {
|
|
859
|
-
return relativeUrl;
|
|
860
|
-
}
|
|
861
|
-
return baseUrl.substring(0, baseUrl.lastIndexOf("/") + 1) + GLTFUtil._formatRelativePath(relativeUrl);
|
|
862
|
-
};
|
|
863
1075
|
/**
|
|
864
1076
|
* Parse the glb format.
|
|
865
|
-
*/
|
|
1077
|
+
*/ GLTFUtils.parseGLB = function parseGLB(context, glb) {
|
|
866
1078
|
var UINT32_LENGTH = 4;
|
|
867
1079
|
var GLB_HEADER_MAGIC = 0x46546c67; // 'glTF'
|
|
868
1080
|
var GLB_HEADER_LENGTH = 12;
|
|
@@ -890,10 +1102,11 @@ var TextureWrapMode;
|
|
|
890
1102
|
return null;
|
|
891
1103
|
}
|
|
892
1104
|
var glTFData = new Uint8Array(glb, GLB_HEADER_LENGTH + 2 * UINT32_LENGTH, chunkLength);
|
|
893
|
-
var
|
|
1105
|
+
var glTF = JSON.parse(Utils.decodeText(glTFData));
|
|
894
1106
|
// read all buffers
|
|
895
1107
|
var buffers = [];
|
|
896
1108
|
var byteOffset = GLB_HEADER_LENGTH + 2 * UINT32_LENGTH + chunkLength;
|
|
1109
|
+
var restoreGLBBufferSlice = context.contentRestorer.glbBufferSlices;
|
|
897
1110
|
while(byteOffset < header.length){
|
|
898
1111
|
chunkLength = dataView.getUint32(byteOffset, true);
|
|
899
1112
|
chunkType = dataView.getUint32(byteOffset + UINT32_LENGTH, true);
|
|
@@ -904,14 +1117,15 @@ var TextureWrapMode;
|
|
|
904
1117
|
var currentOffset = byteOffset + 2 * UINT32_LENGTH;
|
|
905
1118
|
var buffer = glb.slice(currentOffset, currentOffset + chunkLength);
|
|
906
1119
|
buffers.push(buffer);
|
|
1120
|
+
restoreGLBBufferSlice.push(new Vector2(currentOffset, chunkLength));
|
|
907
1121
|
byteOffset += chunkLength + 2 * UINT32_LENGTH;
|
|
908
1122
|
}
|
|
909
1123
|
return {
|
|
910
|
-
|
|
1124
|
+
glTF: glTF,
|
|
911
1125
|
buffers: buffers
|
|
912
1126
|
};
|
|
913
1127
|
};
|
|
914
|
-
|
|
1128
|
+
GLTFUtils._formatRelativePath = function _formatRelativePath(path) {
|
|
915
1129
|
// For example input is "a/b", "/a/b", "./a/b", "./a/./b", "./a/../a/b", output is "a/b"
|
|
916
1130
|
return path.split("/").filter(Boolean).reduce(function(acc, cur) {
|
|
917
1131
|
if (cur === "..") acc.pop();
|
|
@@ -919,17 +1133,9 @@ var TextureWrapMode;
|
|
|
919
1133
|
return acc;
|
|
920
1134
|
}, []).join("/");
|
|
921
1135
|
};
|
|
922
|
-
return
|
|
1136
|
+
return GLTFUtils;
|
|
923
1137
|
}();
|
|
924
1138
|
|
|
925
|
-
function _array_like_to_array(arr, len) {
|
|
926
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
927
|
-
|
|
928
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
929
|
-
|
|
930
|
-
return arr2;
|
|
931
|
-
}
|
|
932
|
-
|
|
933
1139
|
function _array_without_holes(arr) {
|
|
934
1140
|
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
935
1141
|
}
|
|
@@ -944,527 +1150,260 @@ function _non_iterable_spread() {
|
|
|
944
1150
|
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
945
1151
|
}
|
|
946
1152
|
|
|
947
|
-
function _unsupported_iterable_to_array(o, minLen) {
|
|
948
|
-
if (!o) return;
|
|
949
|
-
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
950
|
-
|
|
951
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
952
|
-
|
|
953
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
954
|
-
if (n === "Map" || n === "Set") return Array.from(n);
|
|
955
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
956
|
-
}
|
|
957
|
-
|
|
958
1153
|
function _to_consumable_array(arr) {
|
|
959
1154
|
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
960
1155
|
}
|
|
961
1156
|
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
1157
|
+
/**
|
|
1158
|
+
* Base class of glTF extension parser.
|
|
1159
|
+
*/ var GLTFExtensionParser = /*#__PURE__*/ function() {
|
|
1160
|
+
function GLTFExtensionParser() {}
|
|
1161
|
+
var _proto = GLTFExtensionParser.prototype;
|
|
1162
|
+
/**
|
|
1163
|
+
* Initialize the parser.
|
|
1164
|
+
* @remarks Some plugins require initialization.
|
|
1165
|
+
* @returns The void or promise
|
|
1166
|
+
*/ _proto.initialize = function initialize() {};
|
|
1167
|
+
/**
|
|
1168
|
+
* Create and parse the resource.
|
|
1169
|
+
* @remarks This method overrides the default resource creation.
|
|
1170
|
+
* @param context - The parser context
|
|
1171
|
+
* @param extensionSchema - The extension schema
|
|
1172
|
+
* @param extensionOwnerSchema - The extension owner schema
|
|
1173
|
+
* @returns The resource or promise
|
|
1174
|
+
*/ _proto.createAndParse = function createAndParse(context, extensionSchema, extensionOwnerSchema) {
|
|
1175
|
+
for(var _len = arguments.length, extra = new Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++){
|
|
1176
|
+
extra[_key - 3] = arguments[_key];
|
|
1177
|
+
}
|
|
1178
|
+
throw "Not implemented.";
|
|
1179
|
+
};
|
|
1180
|
+
/**
|
|
1181
|
+
* Additive parse to the resource.
|
|
1182
|
+
* @param context - The parser context
|
|
1183
|
+
* @param parseResource - The parsed resource
|
|
1184
|
+
* @param extensionSchema - The extension schema
|
|
1185
|
+
* @param extensionOwnerSchema - The extension owner schema
|
|
1186
|
+
* @returns The void or promise
|
|
1187
|
+
*/ _proto.additiveParse = function additiveParse(context, parseResource, extensionSchema, extensionOwnerSchema) {
|
|
965
1188
|
for(var _len = arguments.length, extra = new Array(_len > 4 ? _len - 4 : 0), _key = 4; _key < _len; _key++){
|
|
966
1189
|
extra[_key - 4] = arguments[_key];
|
|
967
1190
|
}
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
1191
|
+
throw "Not implemented.";
|
|
1192
|
+
};
|
|
1193
|
+
return GLTFExtensionParser;
|
|
1194
|
+
}();
|
|
1195
|
+
var GLTFExtensionMode;
|
|
1196
|
+
(function(GLTFExtensionMode) {
|
|
1197
|
+
GLTFExtensionMode[GLTFExtensionMode[/**
|
|
1198
|
+
* Cerate instance and parse mode.
|
|
1199
|
+
* @remarks
|
|
1200
|
+
* If the glTF property has multiple extensions of `CreateAndParse` mode, only execute the last one.
|
|
1201
|
+
* If this method is registered, the default pipeline processing will be ignored.
|
|
1202
|
+
*/ "CreateAndParse"] = 0] = "CreateAndParse";
|
|
1203
|
+
GLTFExtensionMode[GLTFExtensionMode[/** Additive parse mode. */ "AdditiveParse"] = 1] = "AdditiveParse";
|
|
1204
|
+
})(GLTFExtensionMode || (GLTFExtensionMode = {}));
|
|
1205
|
+
|
|
1206
|
+
/**
|
|
1207
|
+
* Base class of glTF parser.
|
|
1208
|
+
*/ var GLTFParser = /*#__PURE__*/ function() {
|
|
1209
|
+
function GLTFParser() {}
|
|
1210
|
+
/**
|
|
1211
|
+
* Execute all parses of extension to initialize plugin.
|
|
1212
|
+
* @remarks Some plugins require initialization.
|
|
1213
|
+
* @returns The void or promise
|
|
1214
|
+
*/ GLTFParser.executeExtensionsInitialize = function executeExtensionsInitialize(extensionName) {
|
|
1215
|
+
var parsers = GLTFParser._extensionParsers[extensionName];
|
|
1216
|
+
var length = parsers == null ? void 0 : parsers.length;
|
|
1217
|
+
if (length) {
|
|
1218
|
+
return parsers[length - 1].initialize();
|
|
978
1219
|
}
|
|
979
1220
|
};
|
|
980
|
-
|
|
1221
|
+
/**
|
|
1222
|
+
* Execute all parses of extension to create resource.
|
|
1223
|
+
* @param extensions - Related extensions field
|
|
1224
|
+
* @param context - The parser context
|
|
1225
|
+
* @param ownerSchema - The extension owner schema
|
|
1226
|
+
* @param extra - Extra params
|
|
1227
|
+
* @returns
|
|
1228
|
+
*/ GLTFParser.executeExtensionsCreateAndParse = function executeExtensionsCreateAndParse(extensions, context, ownerSchema) {
|
|
1229
|
+
if (extensions === void 0) extensions = {};
|
|
981
1230
|
for(var _len = arguments.length, extra = new Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++){
|
|
982
1231
|
extra[_key - 3] = arguments[_key];
|
|
983
1232
|
}
|
|
984
|
-
var
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
1233
|
+
var resource = null;
|
|
1234
|
+
var extensionArray = Object.keys(extensions);
|
|
1235
|
+
for(var i = extensionArray.length - 1; i >= 0; --i){
|
|
1236
|
+
var _GLTFParser;
|
|
1237
|
+
var extensionName = extensionArray[i];
|
|
1238
|
+
var extensionSchema = extensions[extensionName];
|
|
1239
|
+
resource = (_GLTFParser = GLTFParser)._createAndParse.apply(_GLTFParser, [
|
|
1240
|
+
extensionName,
|
|
1241
|
+
context,
|
|
1242
|
+
extensionSchema,
|
|
1243
|
+
ownerSchema
|
|
1244
|
+
].concat(_to_consumable_array(extra)));
|
|
1245
|
+
if (resource) {
|
|
1246
|
+
return resource;
|
|
1247
|
+
}
|
|
1248
|
+
}
|
|
1249
|
+
};
|
|
1250
|
+
/**
|
|
1251
|
+
* Execute all parses of extension to parse resource.
|
|
1252
|
+
* @param extensions - Related extensions field
|
|
1253
|
+
* @param context - The parser context
|
|
1254
|
+
* @param parseResource - The parsed resource
|
|
1255
|
+
* @param ownerSchema - The extension owner schema
|
|
1256
|
+
* @param extra - Extra params
|
|
1257
|
+
*/ GLTFParser.executeExtensionsAdditiveAndParse = function executeExtensionsAdditiveAndParse(extensions, context, parseResource, ownerSchema) {
|
|
1258
|
+
for(var _len = arguments.length, extra = new Array(_len > 4 ? _len - 4 : 0), _key = 4; _key < _len; _key++){
|
|
1259
|
+
extra[_key - 4] = arguments[_key];
|
|
1260
|
+
}
|
|
1261
|
+
for(var extensionName in extensions){
|
|
1262
|
+
var _GLTFParser;
|
|
1263
|
+
var extensionSchema = extensions[extensionName];
|
|
1264
|
+
(_GLTFParser = GLTFParser)._additiveParse.apply(_GLTFParser, [
|
|
1265
|
+
extensionName,
|
|
1266
|
+
context,
|
|
1267
|
+
parseResource,
|
|
988
1268
|
extensionSchema,
|
|
989
|
-
|
|
1269
|
+
ownerSchema
|
|
990
1270
|
].concat(_to_consumable_array(extra)));
|
|
991
1271
|
}
|
|
992
1272
|
};
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
1273
|
+
/**
|
|
1274
|
+
* Whether the plugin is registered.
|
|
1275
|
+
* @param extensionName - Extension name
|
|
1276
|
+
* @returns Boolean
|
|
1277
|
+
*/ GLTFParser.hasExtensionParser = function hasExtensionParser(extensionName) {
|
|
1278
|
+
var _GLTFParser__extensionParsers_extensionName;
|
|
1279
|
+
return !!((_GLTFParser__extensionParsers_extensionName = GLTFParser._extensionParsers[extensionName]) == null ? void 0 : _GLTFParser__extensionParsers_extensionName.length);
|
|
996
1280
|
};
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1281
|
+
/**
|
|
1282
|
+
* Get the last plugin by glTF extension mode.
|
|
1283
|
+
* @param extensionName - Extension name
|
|
1284
|
+
* @param mode - GLTF extension mode
|
|
1285
|
+
* @returns GLTF extension parser
|
|
1286
|
+
*/ GLTFParser.getExtensionParser = function getExtensionParser(extensionName, mode) {
|
|
1287
|
+
var parsers = GLTFParser._extensionParsers[extensionName];
|
|
1288
|
+
var length = parsers == null ? void 0 : parsers.length;
|
|
1289
|
+
if (length) {
|
|
1290
|
+
// only use the last parser.
|
|
1291
|
+
for(var i = length - 1; i >= 0; --i){
|
|
1292
|
+
var currentParser = parsers[i];
|
|
1293
|
+
if (currentParser._mode === mode) {
|
|
1294
|
+
return currentParser;
|
|
1295
|
+
}
|
|
1002
1296
|
}
|
|
1003
1297
|
}
|
|
1004
1298
|
};
|
|
1005
1299
|
/**
|
|
1006
1300
|
* @internal
|
|
1007
|
-
*/
|
|
1008
|
-
if (!
|
|
1009
|
-
|
|
1301
|
+
*/ GLTFParser._addExtensionParser = function _addExtensionParser(extensionName, extensionParser) {
|
|
1302
|
+
if (!GLTFParser._extensionParsers[extensionName]) {
|
|
1303
|
+
GLTFParser._extensionParsers[extensionName] = [];
|
|
1304
|
+
}
|
|
1305
|
+
GLTFParser._extensionParsers[extensionName].push(extensionParser);
|
|
1306
|
+
};
|
|
1307
|
+
GLTFParser._createAndParse = function _createAndParse(extensionName, context, extensionSchema, ownerSchema) {
|
|
1308
|
+
for(var _len = arguments.length, extra = new Array(_len > 4 ? _len - 4 : 0), _key = 4; _key < _len; _key++){
|
|
1309
|
+
extra[_key - 4] = arguments[_key];
|
|
1310
|
+
}
|
|
1311
|
+
var parser = GLTFParser.getExtensionParser(extensionName, GLTFExtensionMode.CreateAndParse);
|
|
1312
|
+
if (parser) {
|
|
1313
|
+
var _parser;
|
|
1314
|
+
return (_parser = parser).createAndParse.apply(_parser, [
|
|
1315
|
+
context,
|
|
1316
|
+
extensionSchema,
|
|
1317
|
+
ownerSchema
|
|
1318
|
+
].concat(_to_consumable_array(extra)));
|
|
1319
|
+
}
|
|
1320
|
+
};
|
|
1321
|
+
GLTFParser._additiveParse = function _additiveParse(extensionName, context, parseResource, extensionSchema, ownerSchema) {
|
|
1322
|
+
for(var _len = arguments.length, extra = new Array(_len > 5 ? _len - 5 : 0), _key = 5; _key < _len; _key++){
|
|
1323
|
+
extra[_key - 5] = arguments[_key];
|
|
1324
|
+
}
|
|
1325
|
+
var parser = GLTFParser.getExtensionParser(extensionName, GLTFExtensionMode.AdditiveParse);
|
|
1326
|
+
if (parser) {
|
|
1327
|
+
var _parser;
|
|
1328
|
+
(_parser = parser).additiveParse.apply(_parser, [
|
|
1329
|
+
context,
|
|
1330
|
+
parseResource,
|
|
1331
|
+
extensionSchema,
|
|
1332
|
+
ownerSchema
|
|
1333
|
+
].concat(_to_consumable_array(extra)));
|
|
1010
1334
|
}
|
|
1011
|
-
Parser._extensionParsers[extensionName].push(extensionParser);
|
|
1012
1335
|
};
|
|
1013
|
-
return
|
|
1336
|
+
return GLTFParser;
|
|
1014
1337
|
}();
|
|
1015
1338
|
(function() {
|
|
1016
|
-
|
|
1339
|
+
GLTFParser._extensionParsers = {};
|
|
1017
1340
|
})();
|
|
1018
1341
|
/**
|
|
1019
1342
|
* Declare ExtensionParser's decorator.
|
|
1020
1343
|
* @param extensionName - Extension name
|
|
1021
|
-
*/ function
|
|
1344
|
+
*/ function registerGLTFExtension(extensionName, mode) {
|
|
1022
1345
|
return function(parser) {
|
|
1023
1346
|
var extensionParser = new parser();
|
|
1024
|
-
|
|
1347
|
+
extensionParser._mode = mode;
|
|
1348
|
+
GLTFParser._addExtensionParser(extensionName, extensionParser);
|
|
1025
1349
|
};
|
|
1026
1350
|
}
|
|
1027
1351
|
|
|
1028
|
-
var
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1352
|
+
var GLTFAnimationParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
1353
|
+
_inherits(GLTFAnimationParser, GLTFParser1);
|
|
1354
|
+
function GLTFAnimationParser() {
|
|
1355
|
+
return GLTFParser1.apply(this, arguments);
|
|
1356
|
+
}
|
|
1357
|
+
var _proto = GLTFAnimationParser.prototype;
|
|
1358
|
+
_proto.parse = function parse(context) {
|
|
1359
|
+
var glTF = context.glTF, glTFResource = context.glTFResource;
|
|
1360
|
+
glTFResource.entities;
|
|
1361
|
+
var animations = glTF.animations; glTF.accessors; glTF.bufferViews;
|
|
1362
|
+
if (!animations) {
|
|
1363
|
+
return;
|
|
1035
1364
|
}
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1365
|
+
var animationClipsPromiseInfo = context.animationClipsPromiseInfo;
|
|
1366
|
+
var animationClipCount = animations.length;
|
|
1367
|
+
var animationClipPromises = [];
|
|
1368
|
+
new Array(animationClipCount);
|
|
1369
|
+
var parseStandardPropertyPromises = new Array();
|
|
1370
|
+
for(var i = 0; i < animationClipCount; i++){
|
|
1371
|
+
var animationInfo = animations[i];
|
|
1372
|
+
var _animationInfo_name = animationInfo.name, name = _animationInfo_name === void 0 ? "AnimationClip" + i : _animationInfo_name;
|
|
1373
|
+
var animationClip = GLTFParser.executeExtensionsCreateAndParse(animationInfo.extensions, context, animationInfo);
|
|
1374
|
+
if (!animationClip) {
|
|
1375
|
+
animationClip = new AnimationClip(name);
|
|
1376
|
+
parseStandardPropertyPromises.push(GLTFAnimationParser._parseStandardProperty(context, animationClip, animationInfo));
|
|
1377
|
+
}
|
|
1378
|
+
animationClipPromises.push(animationClip);
|
|
1040
1379
|
}
|
|
1041
|
-
return
|
|
1380
|
+
return AssetPromise.all(parseStandardPropertyPromises).then(function() {
|
|
1381
|
+
return AssetPromise.all(animationClipPromises).then(function(animationClips) {
|
|
1382
|
+
glTFResource.animations = animationClips;
|
|
1383
|
+
for(var i = 0; i < glTF.animations.length; i++){
|
|
1384
|
+
var animationInfo = glTF.animations[i];
|
|
1385
|
+
GLTFParser.executeExtensionsAdditiveAndParse(animationInfo.extensions, context, animationClips[i], animationInfo);
|
|
1386
|
+
}
|
|
1387
|
+
animationClipsPromiseInfo.resolve(animationClips);
|
|
1388
|
+
return animationClipsPromiseInfo.promise;
|
|
1389
|
+
});
|
|
1390
|
+
});
|
|
1042
1391
|
};
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
var
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
};
|
|
1057
|
-
_proto.createEngineResource = function createEngineResource(schema, context, gltfPrimitive) {
|
|
1058
|
-
var gltf = context.gltf, buffers = context.buffers;
|
|
1059
|
-
var bufferViews = gltf.bufferViews, accessors = gltf.accessors;
|
|
1060
|
-
var bufferViewIndex = schema.bufferView, gltfAttributeMap = schema.attributes;
|
|
1061
|
-
var attributeMap = {};
|
|
1062
|
-
var attributeTypeMap = {};
|
|
1063
|
-
for(var attributeName in gltfAttributeMap){
|
|
1064
|
-
attributeMap[attributeName] = gltfAttributeMap[attributeName];
|
|
1065
|
-
}
|
|
1066
|
-
for(var attributeName1 in gltfPrimitive.attributes){
|
|
1067
|
-
if (gltfAttributeMap[attributeName1] !== undefined) {
|
|
1068
|
-
var accessorDef = accessors[gltfPrimitive.attributes[attributeName1]];
|
|
1069
|
-
attributeTypeMap[attributeName1] = GLTFUtil.getComponentType(accessorDef.componentType).name;
|
|
1070
|
-
}
|
|
1071
|
-
}
|
|
1072
|
-
var indexAccessor = accessors[gltfPrimitive.indices];
|
|
1073
|
-
var indexType = GLTFUtil.getComponentType(indexAccessor.componentType).name;
|
|
1074
|
-
var taskConfig = {
|
|
1075
|
-
attributeIDs: attributeMap,
|
|
1076
|
-
attributeTypes: attributeTypeMap,
|
|
1077
|
-
useUniqueIDs: true,
|
|
1078
|
-
indexType: indexType
|
|
1079
|
-
};
|
|
1080
|
-
var buffer = GLTFUtil.getBufferViewData(bufferViews[bufferViewIndex], buffers);
|
|
1081
|
-
return KHR_draco_mesh_compression._decoder.decode(buffer, taskConfig).then(function(parsedGeometry) {
|
|
1082
|
-
return parsedGeometry;
|
|
1083
|
-
});
|
|
1084
|
-
};
|
|
1085
|
-
return KHR_draco_mesh_compression1;
|
|
1086
|
-
}(ExtensionParser);
|
|
1087
|
-
KHR_draco_mesh_compression = __decorate([
|
|
1088
|
-
registerExtension("KHR_draco_mesh_compression")
|
|
1089
|
-
], KHR_draco_mesh_compression);
|
|
1090
|
-
|
|
1091
|
-
function _instanceof(left, right) {
|
|
1092
|
-
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
1093
|
-
return !!right[Symbol.hasInstance](left);
|
|
1094
|
-
} else return left instanceof right;
|
|
1095
|
-
}
|
|
1096
|
-
|
|
1097
|
-
var KHR_lights_punctual = /*#__PURE__*/ function(ExtensionParser) {
|
|
1098
|
-
_inherits(KHR_lights_punctual, ExtensionParser);
|
|
1099
|
-
function KHR_lights_punctual() {
|
|
1100
|
-
return ExtensionParser.apply(this, arguments);
|
|
1101
|
-
}
|
|
1102
|
-
var _proto = KHR_lights_punctual.prototype;
|
|
1103
|
-
_proto.parseEngineResource = function parseEngineResource(schema, entity, context) {
|
|
1104
|
-
var color = schema.color, _schema_intensity = schema.intensity, intensity = _schema_intensity === void 0 ? 1 : _schema_intensity, type = schema.type, range = schema.range, spot = schema.spot;
|
|
1105
|
-
var glTFResource = context.glTFResource;
|
|
1106
|
-
var light;
|
|
1107
|
-
if (type === "directional") {
|
|
1108
|
-
light = entity.addComponent(DirectLight);
|
|
1109
|
-
} else if (type === "point") {
|
|
1110
|
-
light = entity.addComponent(PointLight);
|
|
1111
|
-
} else if (type === "spot") {
|
|
1112
|
-
light = entity.addComponent(SpotLight);
|
|
1113
|
-
}
|
|
1114
|
-
if (color) {
|
|
1115
|
-
light.color.set(color[0], color[1], color[2], 1);
|
|
1116
|
-
}
|
|
1117
|
-
light.intensity = intensity;
|
|
1118
|
-
if (range && !_instanceof(light, DirectLight)) {
|
|
1119
|
-
light.distance = range;
|
|
1120
|
-
}
|
|
1121
|
-
if (spot && _instanceof(light, SpotLight)) {
|
|
1122
|
-
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;
|
|
1123
|
-
light.angle = innerConeAngle;
|
|
1124
|
-
light.penumbra = outerConeAngle - innerConeAngle;
|
|
1125
|
-
}
|
|
1126
|
-
if (!glTFResource.lights) glTFResource.lights = [];
|
|
1127
|
-
glTFResource.lights.push(light);
|
|
1128
|
-
};
|
|
1129
|
-
return KHR_lights_punctual;
|
|
1130
|
-
}(ExtensionParser);
|
|
1131
|
-
KHR_lights_punctual = __decorate([
|
|
1132
|
-
registerExtension("KHR_lights_punctual")
|
|
1133
|
-
], KHR_lights_punctual);
|
|
1134
|
-
|
|
1135
|
-
var MaterialParser = /*#__PURE__*/ function(Parser1) {
|
|
1136
|
-
_inherits(MaterialParser, Parser1);
|
|
1137
|
-
function MaterialParser() {
|
|
1138
|
-
return Parser1.apply(this, arguments);
|
|
1139
|
-
}
|
|
1140
|
-
var _proto = MaterialParser.prototype;
|
|
1141
|
-
_proto.parse = function parse(context) {
|
|
1142
|
-
var gltf = context.gltf, glTFResource = context.glTFResource;
|
|
1143
|
-
var engine = glTFResource.engine, textures = glTFResource.textures;
|
|
1144
|
-
if (!gltf.materials) return;
|
|
1145
|
-
var materialsPromiseInfo = context.materialsPromiseInfo;
|
|
1146
|
-
var materials = [];
|
|
1147
|
-
for(var i = 0; i < gltf.materials.length; i++){
|
|
1148
|
-
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;
|
|
1149
|
-
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;
|
|
1150
|
-
var material = null;
|
|
1151
|
-
if (KHR_materials_unlit) {
|
|
1152
|
-
material = Parser.createEngineResource("KHR_materials_unlit", KHR_materials_unlit, context);
|
|
1153
|
-
} else if (KHR_materials_pbrSpecularGlossiness) {
|
|
1154
|
-
material = Parser.createEngineResource("KHR_materials_pbrSpecularGlossiness", KHR_materials_pbrSpecularGlossiness, context);
|
|
1155
|
-
} else {
|
|
1156
|
-
material = new PBRMaterial(engine);
|
|
1157
|
-
}
|
|
1158
|
-
material.name = name;
|
|
1159
|
-
if (KHR_materials_clearcoat) {
|
|
1160
|
-
Parser.parseEngineResource("KHR_materials_clearcoat", KHR_materials_clearcoat, material, context);
|
|
1161
|
-
}
|
|
1162
|
-
if (pbrMetallicRoughness) {
|
|
1163
|
-
var baseColorFactor = pbrMetallicRoughness.baseColorFactor, baseColorTexture = pbrMetallicRoughness.baseColorTexture, metallicFactor = pbrMetallicRoughness.metallicFactor, roughnessFactor = pbrMetallicRoughness.roughnessFactor, metallicRoughnessTexture = pbrMetallicRoughness.metallicRoughnessTexture;
|
|
1164
|
-
if (baseColorFactor) {
|
|
1165
|
-
material.baseColor = new Color(Color.linearToGammaSpace(baseColorFactor[0]), Color.linearToGammaSpace(baseColorFactor[1]), Color.linearToGammaSpace(baseColorFactor[2]), baseColorFactor[3]);
|
|
1166
|
-
}
|
|
1167
|
-
if (baseColorTexture) {
|
|
1168
|
-
material.baseTexture = textures[baseColorTexture.index];
|
|
1169
|
-
MaterialParser._parseTextureTransform(material, baseColorTexture.extensions, context);
|
|
1170
|
-
}
|
|
1171
|
-
if (!KHR_materials_unlit && !KHR_materials_pbrSpecularGlossiness) {
|
|
1172
|
-
var m = material;
|
|
1173
|
-
m.metallic = metallicFactor != null ? metallicFactor : 1;
|
|
1174
|
-
m.roughness = roughnessFactor != null ? roughnessFactor : 1;
|
|
1175
|
-
if (metallicRoughnessTexture) {
|
|
1176
|
-
m.roughnessMetallicTexture = textures[metallicRoughnessTexture.index];
|
|
1177
|
-
MaterialParser._parseTextureTransform(material, metallicRoughnessTexture.extensions, context);
|
|
1178
|
-
}
|
|
1179
|
-
}
|
|
1180
|
-
}
|
|
1181
|
-
if (!KHR_materials_unlit) {
|
|
1182
|
-
var m1 = material;
|
|
1183
|
-
if (emissiveTexture) {
|
|
1184
|
-
m1.emissiveTexture = textures[emissiveTexture.index];
|
|
1185
|
-
MaterialParser._parseTextureTransform(material, emissiveTexture.extensions, context);
|
|
1186
|
-
}
|
|
1187
|
-
if (emissiveFactor) {
|
|
1188
|
-
m1.emissiveColor = new Color(Color.linearToGammaSpace(emissiveFactor[0]), Color.linearToGammaSpace(emissiveFactor[1]), Color.linearToGammaSpace(emissiveFactor[2]));
|
|
1189
|
-
}
|
|
1190
|
-
if (normalTexture) {
|
|
1191
|
-
var index = normalTexture.index, scale = normalTexture.scale;
|
|
1192
|
-
m1.normalTexture = textures[index];
|
|
1193
|
-
MaterialParser._parseTextureTransform(material, normalTexture.extensions, context);
|
|
1194
|
-
if (scale !== undefined) {
|
|
1195
|
-
m1.normalTextureIntensity = scale;
|
|
1196
|
-
}
|
|
1197
|
-
}
|
|
1198
|
-
if (occlusionTexture) {
|
|
1199
|
-
var index1 = occlusionTexture.index, strength = occlusionTexture.strength, texCoord = occlusionTexture.texCoord;
|
|
1200
|
-
m1.occlusionTexture = textures[index1];
|
|
1201
|
-
MaterialParser._parseTextureTransform(material, occlusionTexture.extensions, context);
|
|
1202
|
-
if (strength !== undefined) {
|
|
1203
|
-
m1.occlusionTextureIntensity = strength;
|
|
1204
|
-
}
|
|
1205
|
-
if (texCoord === TextureCoordinate.UV1) {
|
|
1206
|
-
m1.occlusionTextureCoord = TextureCoordinate.UV1;
|
|
1207
|
-
} else if (texCoord > TextureCoordinate.UV1) {
|
|
1208
|
-
Logger.warn("Occlusion texture uv coordinate must be UV0 or UV1.");
|
|
1209
|
-
}
|
|
1210
|
-
}
|
|
1211
|
-
}
|
|
1212
|
-
if (OASIS_materials_remap) {
|
|
1213
|
-
var _gltf_extensions;
|
|
1214
|
-
gltf.extensions = (_gltf_extensions = gltf.extensions) != null ? _gltf_extensions : {};
|
|
1215
|
-
var _gltf_extensions_OASIS_materials_remap;
|
|
1216
|
-
gltf.extensions["OASIS_materials_remap"] = (_gltf_extensions_OASIS_materials_remap = gltf.extensions["OASIS_materials_remap"]) != null ? _gltf_extensions_OASIS_materials_remap : {};
|
|
1217
|
-
gltf.extensions["OASIS_materials_remap"][i] = Parser.createEngineResource("OASIS_materials_remap", OASIS_materials_remap, context);
|
|
1218
|
-
}
|
|
1219
|
-
if (doubleSided) {
|
|
1220
|
-
material.renderFace = RenderFace.Double;
|
|
1221
|
-
} else {
|
|
1222
|
-
material.renderFace = RenderFace.Front;
|
|
1223
|
-
}
|
|
1224
|
-
switch(alphaMode){
|
|
1225
|
-
case MaterialAlphaMode.OPAQUE:
|
|
1226
|
-
material.isTransparent = false;
|
|
1227
|
-
break;
|
|
1228
|
-
case MaterialAlphaMode.BLEND:
|
|
1229
|
-
material.isTransparent = true;
|
|
1230
|
-
break;
|
|
1231
|
-
case MaterialAlphaMode.MASK:
|
|
1232
|
-
material.alphaCutoff = alphaCutoff != null ? alphaCutoff : 0.5;
|
|
1233
|
-
break;
|
|
1234
|
-
}
|
|
1235
|
-
materials[i] = material;
|
|
1236
|
-
}
|
|
1237
|
-
glTFResource.materials = materials;
|
|
1238
|
-
materialsPromiseInfo.resolve(materials);
|
|
1239
|
-
return materialsPromiseInfo.promise;
|
|
1240
|
-
};
|
|
1241
|
-
/** @internal */ MaterialParser._parseTextureTransform = function _parseTextureTransform(material, extensions, context) {
|
|
1242
|
-
if (extensions === void 0) extensions = {};
|
|
1243
|
-
var schema = extensions.KHR_texture_transform;
|
|
1244
|
-
if (schema) {
|
|
1245
|
-
Parser.parseEngineResource("KHR_texture_transform", schema, material, context);
|
|
1246
|
-
}
|
|
1247
|
-
};
|
|
1248
|
-
return MaterialParser;
|
|
1249
|
-
}(Parser);
|
|
1250
|
-
|
|
1251
|
-
var KHR_materials_clearcoat = /*#__PURE__*/ function(ExtensionParser) {
|
|
1252
|
-
_inherits(KHR_materials_clearcoat, ExtensionParser);
|
|
1253
|
-
function KHR_materials_clearcoat() {
|
|
1254
|
-
return ExtensionParser.apply(this, arguments);
|
|
1255
|
-
}
|
|
1256
|
-
var _proto = KHR_materials_clearcoat.prototype;
|
|
1257
|
-
_proto.parseEngineResource = function parseEngineResource(schema, material, context) {
|
|
1258
|
-
var textures = context.glTFResource.textures;
|
|
1259
|
-
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;
|
|
1260
|
-
material.clearCoat = clearcoatFactor;
|
|
1261
|
-
material.clearCoatRoughness = clearcoatRoughnessFactor;
|
|
1262
|
-
if (clearcoatTexture) {
|
|
1263
|
-
material.clearCoatTexture = textures[clearcoatTexture.index];
|
|
1264
|
-
MaterialParser._parseTextureTransform(material, clearcoatTexture.extensions, context);
|
|
1265
|
-
}
|
|
1266
|
-
if (clearcoatRoughnessTexture) {
|
|
1267
|
-
material.clearCoatRoughnessTexture = textures[clearcoatRoughnessTexture.index];
|
|
1268
|
-
MaterialParser._parseTextureTransform(material, clearcoatRoughnessTexture.extensions, context);
|
|
1269
|
-
}
|
|
1270
|
-
if (clearcoatNormalTexture) {
|
|
1271
|
-
material.clearCoatNormalTexture = textures[clearcoatNormalTexture.index];
|
|
1272
|
-
MaterialParser._parseTextureTransform(material, clearcoatNormalTexture.extensions, context);
|
|
1273
|
-
}
|
|
1274
|
-
};
|
|
1275
|
-
return KHR_materials_clearcoat;
|
|
1276
|
-
}(ExtensionParser);
|
|
1277
|
-
KHR_materials_clearcoat = __decorate([
|
|
1278
|
-
registerExtension("KHR_materials_clearcoat")
|
|
1279
|
-
], KHR_materials_clearcoat);
|
|
1280
|
-
|
|
1281
|
-
var KHR_materials_pbrSpecularGlossiness = /*#__PURE__*/ function(ExtensionParser) {
|
|
1282
|
-
_inherits(KHR_materials_pbrSpecularGlossiness, ExtensionParser);
|
|
1283
|
-
function KHR_materials_pbrSpecularGlossiness() {
|
|
1284
|
-
return ExtensionParser.apply(this, arguments);
|
|
1285
|
-
}
|
|
1286
|
-
var _proto = KHR_materials_pbrSpecularGlossiness.prototype;
|
|
1287
|
-
_proto.createEngineResource = function createEngineResource(schema, context) {
|
|
1288
|
-
var _context_glTFResource = context.glTFResource, engine = _context_glTFResource.engine, textures = _context_glTFResource.textures;
|
|
1289
|
-
var material = new PBRSpecularMaterial(engine);
|
|
1290
|
-
var diffuseFactor = schema.diffuseFactor, diffuseTexture = schema.diffuseTexture, specularFactor = schema.specularFactor, glossinessFactor = schema.glossinessFactor, specularGlossinessTexture = schema.specularGlossinessTexture;
|
|
1291
|
-
if (diffuseFactor) {
|
|
1292
|
-
material.baseColor = new Color(Color.linearToGammaSpace(diffuseFactor[0]), Color.linearToGammaSpace(diffuseFactor[1]), Color.linearToGammaSpace(diffuseFactor[2]), diffuseFactor[3]);
|
|
1293
|
-
}
|
|
1294
|
-
if (diffuseTexture) {
|
|
1295
|
-
material.baseTexture = textures[diffuseTexture.index];
|
|
1296
|
-
MaterialParser._parseTextureTransform(material, diffuseTexture.extensions, context);
|
|
1297
|
-
}
|
|
1298
|
-
if (specularFactor) {
|
|
1299
|
-
material.specularColor = new Color(Color.linearToGammaSpace(specularFactor[0]), Color.linearToGammaSpace(specularFactor[1]), Color.linearToGammaSpace(specularFactor[2]));
|
|
1300
|
-
}
|
|
1301
|
-
if (glossinessFactor !== undefined) {
|
|
1302
|
-
material.glossiness = glossinessFactor;
|
|
1303
|
-
}
|
|
1304
|
-
if (specularGlossinessTexture) {
|
|
1305
|
-
material.specularGlossinessTexture = textures[specularGlossinessTexture.index];
|
|
1306
|
-
MaterialParser._parseTextureTransform(material, specularGlossinessTexture.extensions, context);
|
|
1307
|
-
}
|
|
1308
|
-
return material;
|
|
1309
|
-
};
|
|
1310
|
-
return KHR_materials_pbrSpecularGlossiness;
|
|
1311
|
-
}(ExtensionParser);
|
|
1312
|
-
KHR_materials_pbrSpecularGlossiness = __decorate([
|
|
1313
|
-
registerExtension("KHR_materials_pbrSpecularGlossiness")
|
|
1314
|
-
], KHR_materials_pbrSpecularGlossiness);
|
|
1315
|
-
|
|
1316
|
-
var KHR_materials_unlit = /*#__PURE__*/ function(ExtensionParser) {
|
|
1317
|
-
_inherits(KHR_materials_unlit, ExtensionParser);
|
|
1318
|
-
function KHR_materials_unlit() {
|
|
1319
|
-
return ExtensionParser.apply(this, arguments);
|
|
1320
|
-
}
|
|
1321
|
-
var _proto = KHR_materials_unlit.prototype;
|
|
1322
|
-
_proto.createEngineResource = function createEngineResource(schema, context) {
|
|
1323
|
-
var engine = context.glTFResource.engine;
|
|
1324
|
-
var material = new UnlitMaterial(engine);
|
|
1325
|
-
return material;
|
|
1326
|
-
};
|
|
1327
|
-
return KHR_materials_unlit;
|
|
1328
|
-
}(ExtensionParser);
|
|
1329
|
-
KHR_materials_unlit = __decorate([
|
|
1330
|
-
registerExtension("KHR_materials_unlit")
|
|
1331
|
-
], KHR_materials_unlit);
|
|
1332
|
-
|
|
1333
|
-
var KHR_materials_variants = /*#__PURE__*/ function(ExtensionParser) {
|
|
1334
|
-
_inherits(KHR_materials_variants, ExtensionParser);
|
|
1335
|
-
function KHR_materials_variants() {
|
|
1336
|
-
return ExtensionParser.apply(this, arguments);
|
|
1337
|
-
}
|
|
1338
|
-
var _proto = KHR_materials_variants.prototype;
|
|
1339
|
-
_proto.parseEngineResource = function parseEngineResource(schema, renderer, context) {
|
|
1340
|
-
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;
|
|
1341
|
-
var mappings = schema.mappings;
|
|
1342
|
-
for(var i = 0; i < mappings.length; i++){
|
|
1343
|
-
var _mappings_i = mappings[i], material = _mappings_i.material, variants = _mappings_i.variants;
|
|
1344
|
-
if (!glTFResource.variants) glTFResource.variants = [];
|
|
1345
|
-
glTFResource.variants.push({
|
|
1346
|
-
renderer: renderer,
|
|
1347
|
-
material: glTFResource.materials[material],
|
|
1348
|
-
variants: variants.map(function(index) {
|
|
1349
|
-
return variantNames[index].name;
|
|
1350
|
-
})
|
|
1351
|
-
});
|
|
1352
|
-
}
|
|
1353
|
-
};
|
|
1354
|
-
return KHR_materials_variants;
|
|
1355
|
-
}(ExtensionParser);
|
|
1356
|
-
KHR_materials_variants = __decorate([
|
|
1357
|
-
registerExtension("KHR_materials_variants")
|
|
1358
|
-
], KHR_materials_variants);
|
|
1359
|
-
|
|
1360
|
-
var KHR_mesh_quantization = /*#__PURE__*/ function(ExtensionParser) {
|
|
1361
|
-
_inherits(KHR_mesh_quantization, ExtensionParser);
|
|
1362
|
-
function KHR_mesh_quantization() {
|
|
1363
|
-
return ExtensionParser.apply(this, arguments);
|
|
1364
|
-
}
|
|
1365
|
-
return KHR_mesh_quantization;
|
|
1366
|
-
}(ExtensionParser);
|
|
1367
|
-
KHR_mesh_quantization = __decorate([
|
|
1368
|
-
registerExtension("KHR_mesh_quantization")
|
|
1369
|
-
], KHR_mesh_quantization);
|
|
1370
|
-
|
|
1371
|
-
var KHR_texture_transform = /*#__PURE__*/ function(ExtensionParser) {
|
|
1372
|
-
_inherits(KHR_texture_transform, ExtensionParser);
|
|
1373
|
-
function KHR_texture_transform() {
|
|
1374
|
-
return ExtensionParser.apply(this, arguments);
|
|
1375
|
-
}
|
|
1376
|
-
var _proto = KHR_texture_transform.prototype;
|
|
1377
|
-
_proto.parseEngineResource = function parseEngineResource(schema, material, context) {
|
|
1378
|
-
var offset = schema.offset, rotation = schema.rotation, scale = schema.scale, texCoord = schema.texCoord;
|
|
1379
|
-
if (offset) {
|
|
1380
|
-
material.tilingOffset.z = offset[0];
|
|
1381
|
-
material.tilingOffset.w = offset[1];
|
|
1382
|
-
}
|
|
1383
|
-
if (scale) {
|
|
1384
|
-
material.tilingOffset.x = scale[0];
|
|
1385
|
-
material.tilingOffset.y = scale[1];
|
|
1386
|
-
}
|
|
1387
|
-
if (rotation) {
|
|
1388
|
-
Logger.warn("rotation in KHR_texture_transform is not supported now");
|
|
1389
|
-
}
|
|
1390
|
-
if (texCoord) {
|
|
1391
|
-
Logger.warn("texCoord in KHR_texture_transform is not supported now");
|
|
1392
|
-
}
|
|
1393
|
-
};
|
|
1394
|
-
return KHR_texture_transform;
|
|
1395
|
-
}(ExtensionParser);
|
|
1396
|
-
KHR_texture_transform = __decorate([
|
|
1397
|
-
registerExtension("KHR_texture_transform")
|
|
1398
|
-
], KHR_texture_transform);
|
|
1399
|
-
|
|
1400
|
-
var GalaceanMaterialsRemap = /*#__PURE__*/ function(ExtensionParser) {
|
|
1401
|
-
_inherits(GalaceanMaterialsRemap, ExtensionParser);
|
|
1402
|
-
function GalaceanMaterialsRemap() {
|
|
1403
|
-
return ExtensionParser.apply(this, arguments);
|
|
1404
|
-
}
|
|
1405
|
-
var _proto = GalaceanMaterialsRemap.prototype;
|
|
1406
|
-
_proto.createEngineResource = function createEngineResource(schema, context) {
|
|
1407
|
-
var engine = context.glTFResource.engine;
|
|
1408
|
-
// @ts-ignore
|
|
1409
|
-
return engine.resourceManager.getResourceByRef(schema);
|
|
1410
|
-
};
|
|
1411
|
-
return GalaceanMaterialsRemap;
|
|
1412
|
-
}(ExtensionParser);
|
|
1413
|
-
GalaceanMaterialsRemap = __decorate([
|
|
1414
|
-
registerExtension("OASIS_materials_remap")
|
|
1415
|
-
], GalaceanMaterialsRemap);
|
|
1416
|
-
|
|
1417
|
-
function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
|
|
1418
|
-
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
1419
|
-
|
|
1420
|
-
if (it) return (it = it.call(o)).next.bind(it);
|
|
1421
|
-
// Fallback for engines without symbol support
|
|
1422
|
-
if (Array.isArray(o) || (it = _unsupported_iterable_to_array(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
1423
|
-
if (it) o = it;
|
|
1424
|
-
|
|
1425
|
-
var i = 0;
|
|
1426
|
-
|
|
1427
|
-
return function() {
|
|
1428
|
-
if (i >= o.length) return { done: true };
|
|
1429
|
-
|
|
1430
|
-
return { done: false, value: o[i++] };
|
|
1431
|
-
};
|
|
1432
|
-
}
|
|
1433
|
-
|
|
1434
|
-
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
1435
|
-
}
|
|
1436
|
-
|
|
1437
|
-
var AnimationParser = /*#__PURE__*/ function(Parser) {
|
|
1438
|
-
_inherits(AnimationParser, Parser);
|
|
1439
|
-
function AnimationParser() {
|
|
1440
|
-
return Parser.apply(this, arguments);
|
|
1441
|
-
}
|
|
1442
|
-
var _proto = AnimationParser.prototype;
|
|
1443
|
-
_proto.parse = function parse(context) {
|
|
1444
|
-
var gltf = context.gltf; context.buffers; var glTFResource = context.glTFResource;
|
|
1445
|
-
var entities = glTFResource.entities;
|
|
1446
|
-
var animations = gltf.animations, accessors = gltf.accessors;
|
|
1447
|
-
if (!animations) {
|
|
1448
|
-
return;
|
|
1449
|
-
}
|
|
1450
|
-
var animationClipsPromiseInfo = context.animationClipsPromiseInfo;
|
|
1451
|
-
var animationClipCount = animations.length;
|
|
1452
|
-
var animationClips = new Array(animationClipCount);
|
|
1453
|
-
var animationsIndices = new Array(animationClipCount);
|
|
1454
|
-
for(var i = 0; i < animationClipCount; i++){
|
|
1455
|
-
var gltfAnimation = animations[i];
|
|
1456
|
-
var channels = gltfAnimation.channels, samplers = gltfAnimation.samplers, _gltfAnimation_name = gltfAnimation.name, name = _gltfAnimation_name === void 0 ? "AnimationClip" + i : _gltfAnimation_name;
|
|
1457
|
-
var animationClip = new AnimationClip(name);
|
|
1458
|
-
var sampleDataCollection = new Array();
|
|
1459
|
-
// parse samplers
|
|
1460
|
-
for(var j = 0, m = samplers.length; j < m; j++){
|
|
1461
|
-
var gltfSampler = samplers[j];
|
|
1462
|
-
var inputAccessor = accessors[gltfSampler.input];
|
|
1463
|
-
var outputAccessor = accessors[gltfSampler.output];
|
|
1464
|
-
var input = GLTFUtil.getAccessorBuffer(context, gltf, inputAccessor).data;
|
|
1465
|
-
var output = GLTFUtil.getAccessorBuffer(context, gltf, outputAccessor).data;
|
|
1392
|
+
/**
|
|
1393
|
+
* @internal
|
|
1394
|
+
*/ GLTFAnimationParser._parseStandardProperty = function _parseStandardProperty(context, animationClip, animationInfo) {
|
|
1395
|
+
var _loop = function(j, m) {
|
|
1396
|
+
var gltfSampler = samplers[j];
|
|
1397
|
+
var inputAccessor = accessors[gltfSampler.input];
|
|
1398
|
+
var outputAccessor = accessors[gltfSampler.output];
|
|
1399
|
+
var promise = Promise.all([
|
|
1400
|
+
GLTFUtils.getAccessorBuffer(context, bufferViews, inputAccessor),
|
|
1401
|
+
GLTFUtils.getAccessorBuffer(context, bufferViews, outputAccessor)
|
|
1402
|
+
]).then(function(bufferInfos) {
|
|
1403
|
+
var input = bufferInfos[0].data;
|
|
1404
|
+
var output = bufferInfos[1].data;
|
|
1466
1405
|
if (outputAccessor.normalized) {
|
|
1467
|
-
var scale =
|
|
1406
|
+
var scale = GLTFUtils.getNormalizedComponentScale(outputAccessor.componentType);
|
|
1468
1407
|
var scaled = new Float32Array(output.length);
|
|
1469
1408
|
for(var k = 0, v = output.length; k < v; k++){
|
|
1470
1409
|
scaled[k] = output[k] * scale;
|
|
@@ -1474,7 +1413,7 @@ var AnimationParser = /*#__PURE__*/ function(Parser) {
|
|
|
1474
1413
|
var outputStride = output.length / input.length;
|
|
1475
1414
|
var _gltfSampler_interpolation;
|
|
1476
1415
|
var interpolation = (_gltfSampler_interpolation = gltfSampler.interpolation) != null ? _gltfSampler_interpolation : AnimationSamplerInterpolation.Linear;
|
|
1477
|
-
var samplerInterpolation
|
|
1416
|
+
var samplerInterpolation;
|
|
1478
1417
|
switch(interpolation){
|
|
1479
1418
|
case AnimationSamplerInterpolation.CubicSpine:
|
|
1480
1419
|
samplerInterpolation = InterpolationType.CubicSpine;
|
|
@@ -1494,9 +1433,21 @@ var AnimationParser = /*#__PURE__*/ function(Parser) {
|
|
|
1494
1433
|
output: output,
|
|
1495
1434
|
outputSize: outputStride
|
|
1496
1435
|
});
|
|
1497
|
-
}
|
|
1498
|
-
|
|
1499
|
-
|
|
1436
|
+
});
|
|
1437
|
+
promises.push(promise);
|
|
1438
|
+
};
|
|
1439
|
+
var _this = this;
|
|
1440
|
+
var glTF = context.glTF, glTFResource = context.glTFResource;
|
|
1441
|
+
var entities = glTFResource.entities;
|
|
1442
|
+
var accessors = glTF.accessors, bufferViews = glTF.bufferViews;
|
|
1443
|
+
var channels = animationInfo.channels, samplers = animationInfo.samplers;
|
|
1444
|
+
var sampleDataCollection = new Array();
|
|
1445
|
+
var promises = new Array();
|
|
1446
|
+
// parse samplers
|
|
1447
|
+
for(var j = 0, m = samplers.length; j < m; j++)_loop(j);
|
|
1448
|
+
return Promise.all(promises).then(function() {
|
|
1449
|
+
for(var j = 0, m = channels.length; j < m; j++){
|
|
1450
|
+
var gltfChannel = channels[j];
|
|
1500
1451
|
var target = gltfChannel.target;
|
|
1501
1452
|
var channelTargetEntity = entities[target.node];
|
|
1502
1453
|
var relativePath = "";
|
|
@@ -1525,25 +1476,15 @@ var AnimationParser = /*#__PURE__*/ function(Parser) {
|
|
|
1525
1476
|
propertyName = "blendShapeWeights";
|
|
1526
1477
|
break;
|
|
1527
1478
|
}
|
|
1528
|
-
var curve =
|
|
1479
|
+
var curve = _this._addCurve(target.path, gltfChannel, sampleDataCollection);
|
|
1529
1480
|
animationClip.addCurveBinding(relativePath, ComponentType, propertyName, curve);
|
|
1530
1481
|
}
|
|
1531
|
-
|
|
1532
|
-
animationsIndices[i] = {
|
|
1533
|
-
name: name,
|
|
1534
|
-
index: i
|
|
1535
|
-
};
|
|
1536
|
-
}
|
|
1537
|
-
glTFResource.animations = animationClips;
|
|
1538
|
-
// @ts-ignore for editor
|
|
1539
|
-
glTFResource._animationsIndices = animationsIndices;
|
|
1540
|
-
animationClipsPromiseInfo.resolve(animationClips);
|
|
1541
|
-
return animationClipsPromiseInfo.promise;
|
|
1482
|
+
});
|
|
1542
1483
|
};
|
|
1543
|
-
|
|
1484
|
+
GLTFAnimationParser._addCurve = function _addCurve(animationChannelTargetPath, gltfChannel, sampleDataCollection) {
|
|
1544
1485
|
var sampleData = sampleDataCollection[gltfChannel.sampler];
|
|
1545
1486
|
var input = sampleData.input, output = sampleData.output, outputSize = sampleData.outputSize;
|
|
1546
|
-
switch(
|
|
1487
|
+
switch(animationChannelTargetPath){
|
|
1547
1488
|
case AnimationChannelTargetPath.TRANSLATION:
|
|
1548
1489
|
case AnimationChannelTargetPath.SCALE:
|
|
1549
1490
|
{
|
|
@@ -1608,38 +1549,43 @@ var AnimationParser = /*#__PURE__*/ function(Parser) {
|
|
|
1608
1549
|
}
|
|
1609
1550
|
}
|
|
1610
1551
|
};
|
|
1611
|
-
return
|
|
1612
|
-
}(
|
|
1552
|
+
return GLTFAnimationParser;
|
|
1553
|
+
}(GLTFParser);
|
|
1613
1554
|
|
|
1614
|
-
var
|
|
1615
|
-
_inherits(
|
|
1616
|
-
function
|
|
1617
|
-
return
|
|
1555
|
+
var GLTFBufferParser = /*#__PURE__*/ function(GLTFParser) {
|
|
1556
|
+
_inherits(GLTFBufferParser, GLTFParser);
|
|
1557
|
+
function GLTFBufferParser() {
|
|
1558
|
+
return GLTFParser.apply(this, arguments);
|
|
1618
1559
|
}
|
|
1619
|
-
var _proto =
|
|
1560
|
+
var _proto = GLTFBufferParser.prototype;
|
|
1620
1561
|
_proto.parse = function parse(context) {
|
|
1621
|
-
var glTFResource = context.glTFResource;
|
|
1562
|
+
var glTFResource = context.glTFResource, contentRestorer = context.contentRestorer;
|
|
1622
1563
|
var url = glTFResource.url;
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1564
|
+
var restoreBufferRequests = contentRestorer.bufferRequests;
|
|
1565
|
+
var requestConfig = {
|
|
1566
|
+
type: "arraybuffer"
|
|
1567
|
+
};
|
|
1568
|
+
var isGLB = this._isGLB(url);
|
|
1569
|
+
contentRestorer.isGLB = isGLB;
|
|
1570
|
+
if (isGLB) {
|
|
1571
|
+
return request(url, requestConfig).then(function(glb) {
|
|
1572
|
+
restoreBufferRequests.push(new BufferRequestInfo(url, requestConfig));
|
|
1573
|
+
return GLTFUtils.parseGLB(context, glb);
|
|
1574
|
+
}).then(function(param) {
|
|
1575
|
+
var glTF = param.glTF, buffers = param.buffers;
|
|
1576
|
+
context.glTF = glTF;
|
|
1577
|
+
context._buffers = buffers;
|
|
1630
1578
|
});
|
|
1631
1579
|
} else {
|
|
1632
1580
|
return request(url, {
|
|
1633
1581
|
type: "json"
|
|
1634
|
-
}).then(function(
|
|
1635
|
-
context.
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
}))
|
|
1641
|
-
context.buffers = buffers;
|
|
1642
|
-
});
|
|
1582
|
+
}).then(function(glTF) {
|
|
1583
|
+
context.glTF = glTF;
|
|
1584
|
+
context._buffers = Promise.all(glTF.buffers.map(function(buffer) {
|
|
1585
|
+
var absoluteUrl = Utils.resolveAbsoluteUrl(url, buffer.uri);
|
|
1586
|
+
restoreBufferRequests.push(new BufferRequestInfo(absoluteUrl, requestConfig));
|
|
1587
|
+
return request(absoluteUrl, requestConfig);
|
|
1588
|
+
}));
|
|
1643
1589
|
});
|
|
1644
1590
|
}
|
|
1645
1591
|
};
|
|
@@ -1647,24 +1593,24 @@ var BufferParser = /*#__PURE__*/ function(Parser) {
|
|
|
1647
1593
|
var index = url.lastIndexOf(".");
|
|
1648
1594
|
return url.substring(index + 1, index + 4) === "glb";
|
|
1649
1595
|
};
|
|
1650
|
-
return
|
|
1651
|
-
}(
|
|
1596
|
+
return GLTFBufferParser;
|
|
1597
|
+
}(GLTFParser);
|
|
1652
1598
|
|
|
1653
|
-
var
|
|
1654
|
-
_inherits(
|
|
1655
|
-
function
|
|
1656
|
-
return
|
|
1599
|
+
var GLTFEntityParser = /*#__PURE__*/ function(GLTFParser) {
|
|
1600
|
+
_inherits(GLTFEntityParser, GLTFParser);
|
|
1601
|
+
function GLTFEntityParser() {
|
|
1602
|
+
return GLTFParser.apply(this, arguments);
|
|
1657
1603
|
}
|
|
1658
|
-
var _proto =
|
|
1604
|
+
var _proto = GLTFEntityParser.prototype;
|
|
1659
1605
|
_proto.parse = function parse(context) {
|
|
1660
|
-
var glTFResource = context.glTFResource, nodes = context.
|
|
1606
|
+
var glTFResource = context.glTFResource, nodes = context.glTF.nodes;
|
|
1661
1607
|
var engine = glTFResource.engine;
|
|
1662
1608
|
if (!nodes) return;
|
|
1663
1609
|
var entities = [];
|
|
1664
1610
|
for(var i = 0; i < nodes.length; i++){
|
|
1665
1611
|
var gltfNode = nodes[i];
|
|
1666
1612
|
var matrix = gltfNode.matrix, translation = gltfNode.translation, rotation = gltfNode.rotation, scale = gltfNode.scale;
|
|
1667
|
-
var entity = new Entity(engine, gltfNode.name || "" +
|
|
1613
|
+
var entity = new Entity(engine, gltfNode.name || "" + GLTFEntityParser._defaultName + i);
|
|
1668
1614
|
var transform = entity.transform;
|
|
1669
1615
|
if (matrix) {
|
|
1670
1616
|
var localMatrix = transform.localMatrix;
|
|
@@ -1688,7 +1634,7 @@ var EntityParser = /*#__PURE__*/ function(Parser) {
|
|
|
1688
1634
|
this._createSceneRoots(context, glTFResource);
|
|
1689
1635
|
};
|
|
1690
1636
|
_proto._buildEntityTree = function _buildEntityTree(context, glTFResource) {
|
|
1691
|
-
var nodes = context.
|
|
1637
|
+
var nodes = context.glTF.nodes;
|
|
1692
1638
|
var entities = glTFResource.entities;
|
|
1693
1639
|
for(var i = 0; i < nodes.length; i++){
|
|
1694
1640
|
var children = nodes[i].children;
|
|
@@ -1702,7 +1648,7 @@ var EntityParser = /*#__PURE__*/ function(Parser) {
|
|
|
1702
1648
|
}
|
|
1703
1649
|
};
|
|
1704
1650
|
_proto._createSceneRoots = function _createSceneRoots(context, glTFResource) {
|
|
1705
|
-
var
|
|
1651
|
+
var _context_glTF = context.glTF, tmp = _context_glTF.scene, sceneID = tmp === void 0 ? 0 : tmp, scenes = _context_glTF.scenes;
|
|
1706
1652
|
var engine = glTFResource.engine, entities = glTFResource.entities;
|
|
1707
1653
|
if (!scenes) return;
|
|
1708
1654
|
var sceneRoots = [];
|
|
@@ -1718,337 +1664,433 @@ var EntityParser = /*#__PURE__*/ function(Parser) {
|
|
|
1718
1664
|
}
|
|
1719
1665
|
sceneRoots[i] = rootEntity;
|
|
1720
1666
|
}
|
|
1667
|
+
// @ts-ignore
|
|
1668
|
+
sceneRoots[i]._hookResource = glTFResource;
|
|
1669
|
+
// @ts-ignore
|
|
1670
|
+
glTFResource._addReferCount(1);
|
|
1721
1671
|
}
|
|
1722
1672
|
glTFResource.sceneRoots = sceneRoots;
|
|
1723
1673
|
glTFResource.defaultSceneRoot = sceneRoots[sceneID];
|
|
1724
1674
|
};
|
|
1725
|
-
return
|
|
1726
|
-
}(
|
|
1675
|
+
return GLTFEntityParser;
|
|
1676
|
+
}(GLTFParser);
|
|
1727
1677
|
(function() {
|
|
1728
|
-
/** @internal */
|
|
1678
|
+
/** @internal */ GLTFEntityParser._defaultName = "_GLTF_ENTITY_";
|
|
1729
1679
|
})();
|
|
1730
1680
|
|
|
1731
|
-
var
|
|
1732
|
-
_inherits(
|
|
1733
|
-
function
|
|
1734
|
-
return
|
|
1681
|
+
var GLTFMaterialParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
1682
|
+
_inherits(GLTFMaterialParser, GLTFParser1);
|
|
1683
|
+
function GLTFMaterialParser() {
|
|
1684
|
+
return GLTFParser1.apply(this, arguments);
|
|
1735
1685
|
}
|
|
1736
|
-
var _proto =
|
|
1686
|
+
var _proto = GLTFMaterialParser.prototype;
|
|
1737
1687
|
_proto.parse = function parse(context) {
|
|
1738
|
-
var
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1688
|
+
var glTF = context.glTF, glTFResource = context.glTFResource, materialsPromiseInfo = context.materialsPromiseInfo;
|
|
1689
|
+
if (!glTF.materials) return;
|
|
1690
|
+
var engine = glTFResource.engine;
|
|
1691
|
+
var materialPromises = [];
|
|
1692
|
+
for(var i = 0; i < glTF.materials.length; i++){
|
|
1693
|
+
var materialInfo = glTF.materials[i];
|
|
1694
|
+
var material = GLTFParser.executeExtensionsCreateAndParse(materialInfo.extensions, context, materialInfo);
|
|
1695
|
+
if (!material) {
|
|
1696
|
+
material = new PBRMaterial(engine);
|
|
1697
|
+
material.name = materialInfo.name;
|
|
1698
|
+
GLTFMaterialParser._parseStandardProperty(context, material, materialInfo);
|
|
1699
|
+
}
|
|
1700
|
+
materialPromises.push(material);
|
|
1701
|
+
}
|
|
1702
|
+
return AssetPromise.all(materialPromises).then(function(materials) {
|
|
1703
|
+
glTFResource.materials = materials;
|
|
1704
|
+
for(var i = 0; i < glTF.materials.length; i++){
|
|
1705
|
+
var materialInfo = glTF.materials[i];
|
|
1706
|
+
GLTFParser.executeExtensionsAdditiveAndParse(materialInfo.extensions, context, materials[i], materialInfo);
|
|
1707
|
+
}
|
|
1708
|
+
materialsPromiseInfo.resolve(materials);
|
|
1709
|
+
return materialsPromiseInfo.promise;
|
|
1710
|
+
});
|
|
1711
|
+
};
|
|
1712
|
+
/**
|
|
1713
|
+
* @internal
|
|
1714
|
+
*/ GLTFMaterialParser._checkOtherTextureTransform = function _checkOtherTextureTransform(texture, textureName) {
|
|
1715
|
+
var _texture_extensions;
|
|
1716
|
+
if ((_texture_extensions = texture.extensions) == null ? void 0 : _texture_extensions.KHR_texture_transform) {
|
|
1717
|
+
Logger.warn("" + textureName + " texture always use the KHR_texture_transform of the base texture.");
|
|
1718
|
+
}
|
|
1719
|
+
};
|
|
1720
|
+
/**
|
|
1721
|
+
* @internal
|
|
1722
|
+
*/ GLTFMaterialParser._parseStandardProperty = function _parseStandardProperty(context, material, materialInfo) {
|
|
1723
|
+
var textures = context.glTFResource.textures;
|
|
1724
|
+
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;
|
|
1725
|
+
if (pbrMetallicRoughness) {
|
|
1726
|
+
var baseColorFactor = pbrMetallicRoughness.baseColorFactor, baseColorTexture = pbrMetallicRoughness.baseColorTexture, metallicFactor = pbrMetallicRoughness.metallicFactor, roughnessFactor = pbrMetallicRoughness.roughnessFactor, metallicRoughnessTexture = pbrMetallicRoughness.metallicRoughnessTexture;
|
|
1727
|
+
if (baseColorFactor) {
|
|
1728
|
+
material.baseColor = new Color(Color.linearToGammaSpace(baseColorFactor[0]), Color.linearToGammaSpace(baseColorFactor[1]), Color.linearToGammaSpace(baseColorFactor[2]), baseColorFactor[3]);
|
|
1729
|
+
}
|
|
1730
|
+
if (baseColorTexture) {
|
|
1731
|
+
material.baseTexture = textures[baseColorTexture.index];
|
|
1732
|
+
GLTFParser.executeExtensionsAdditiveAndParse(baseColorTexture.extensions, context, material, baseColorTexture);
|
|
1733
|
+
}
|
|
1734
|
+
if (material.constructor === PBRMaterial) {
|
|
1735
|
+
material.metallic = metallicFactor != null ? metallicFactor : 1;
|
|
1736
|
+
material.roughness = roughnessFactor != null ? roughnessFactor : 1;
|
|
1737
|
+
if (metallicRoughnessTexture) {
|
|
1738
|
+
material.roughnessMetallicTexture = textures[metallicRoughnessTexture.index];
|
|
1739
|
+
GLTFMaterialParser._checkOtherTextureTransform(metallicRoughnessTexture, "Roughness metallic");
|
|
1740
|
+
}
|
|
1741
|
+
}
|
|
1742
|
+
}
|
|
1743
|
+
if (material.constructor === PBRMaterial || material.constructor === PBRSpecularMaterial) {
|
|
1744
|
+
if (emissiveTexture) {
|
|
1745
|
+
material.emissiveTexture = textures[emissiveTexture.index];
|
|
1746
|
+
GLTFMaterialParser._checkOtherTextureTransform(emissiveTexture, "Emissive");
|
|
1747
|
+
}
|
|
1748
|
+
if (emissiveFactor) {
|
|
1749
|
+
material.emissiveColor = new Color(Color.linearToGammaSpace(emissiveFactor[0]), Color.linearToGammaSpace(emissiveFactor[1]), Color.linearToGammaSpace(emissiveFactor[2]));
|
|
1750
|
+
}
|
|
1751
|
+
if (normalTexture) {
|
|
1752
|
+
var index = normalTexture.index, scale = normalTexture.scale;
|
|
1753
|
+
material.normalTexture = textures[index];
|
|
1754
|
+
GLTFMaterialParser._checkOtherTextureTransform(normalTexture, "Normal");
|
|
1755
|
+
if (scale !== undefined) {
|
|
1756
|
+
material.normalTextureIntensity = scale;
|
|
1757
|
+
}
|
|
1758
|
+
}
|
|
1759
|
+
if (occlusionTexture) {
|
|
1760
|
+
var index1 = occlusionTexture.index, strength = occlusionTexture.strength, texCoord = occlusionTexture.texCoord;
|
|
1761
|
+
material.occlusionTexture = textures[index1];
|
|
1762
|
+
GLTFMaterialParser._checkOtherTextureTransform(occlusionTexture, "Occlusion");
|
|
1763
|
+
if (strength !== undefined) {
|
|
1764
|
+
material.occlusionTextureIntensity = strength;
|
|
1765
|
+
}
|
|
1766
|
+
if (texCoord === TextureCoordinate.UV1) {
|
|
1767
|
+
material.occlusionTextureCoord = TextureCoordinate.UV1;
|
|
1768
|
+
} else if (texCoord > TextureCoordinate.UV1) {
|
|
1769
|
+
Logger.warn("Occlusion texture uv coordinate must be UV0 or UV1.");
|
|
1770
|
+
}
|
|
1771
|
+
}
|
|
1772
|
+
}
|
|
1773
|
+
if (doubleSided) {
|
|
1774
|
+
material.renderFace = RenderFace.Double;
|
|
1775
|
+
} else {
|
|
1776
|
+
material.renderFace = RenderFace.Front;
|
|
1777
|
+
}
|
|
1778
|
+
switch(alphaMode){
|
|
1779
|
+
case MaterialAlphaMode.OPAQUE:
|
|
1780
|
+
material.isTransparent = false;
|
|
1781
|
+
break;
|
|
1782
|
+
case MaterialAlphaMode.BLEND:
|
|
1783
|
+
material.isTransparent = true;
|
|
1784
|
+
break;
|
|
1785
|
+
case MaterialAlphaMode.MASK:
|
|
1786
|
+
material.alphaCutoff = alphaCutoff != null ? alphaCutoff : 0.5;
|
|
1787
|
+
break;
|
|
1788
|
+
}
|
|
1789
|
+
};
|
|
1790
|
+
return GLTFMaterialParser;
|
|
1791
|
+
}(GLTFParser);
|
|
1792
|
+
|
|
1793
|
+
function _instanceof(left, right) {
|
|
1794
|
+
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
1795
|
+
return !!right[Symbol.hasInstance](left);
|
|
1796
|
+
} else return left instanceof right;
|
|
1797
|
+
}
|
|
1798
|
+
|
|
1799
|
+
var GLTFMeshParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
1800
|
+
_inherits(GLTFMeshParser, GLTFParser1);
|
|
1801
|
+
function GLTFMeshParser() {
|
|
1802
|
+
return GLTFParser1.apply(this, arguments);
|
|
1803
|
+
}
|
|
1804
|
+
var _proto = GLTFMeshParser.prototype;
|
|
1805
|
+
_proto.parse = function parse(context) {
|
|
1806
|
+
var _loop = function(i) {
|
|
1807
|
+
var _loop = function(j) {
|
|
1808
|
+
var gltfPrimitive = gltfMesh.primitives[j];
|
|
1809
|
+
primitivePromises[j] = new Promise(function(resolve) {
|
|
1810
|
+
var mesh = GLTFParser.executeExtensionsCreateAndParse(gltfPrimitive.extensions, context, gltfPrimitive, gltfMesh);
|
|
1811
|
+
if (mesh) {
|
|
1812
|
+
if (_instanceof(mesh, ModelMesh)) {
|
|
1813
|
+
resolve(mesh);
|
|
1814
|
+
} else {
|
|
1815
|
+
mesh.then(function(mesh) {
|
|
1816
|
+
return resolve(mesh);
|
|
1817
|
+
});
|
|
1818
|
+
}
|
|
1819
|
+
} else {
|
|
1820
|
+
var mesh1 = new ModelMesh(engine, gltfMesh.name || j + "");
|
|
1821
|
+
var meshRestoreInfo = new ModelMeshRestoreInfo();
|
|
1822
|
+
meshRestoreInfo.mesh = mesh1;
|
|
1823
|
+
context.contentRestorer.meshes.push(meshRestoreInfo);
|
|
1824
|
+
GLTFMeshParser._parseMeshFromGLTFPrimitive(context, mesh1, meshRestoreInfo, gltfMesh, gltfPrimitive, glTF, function(attributeSemantic) {
|
|
1825
|
+
return null;
|
|
1826
|
+
}, function(attributeName, shapeIndex) {
|
|
1827
|
+
var shapeAccessorIdx = gltfPrimitive.targets[shapeIndex];
|
|
1828
|
+
var attributeAccessorIdx = shapeAccessorIdx[attributeName];
|
|
1829
|
+
if (attributeAccessorIdx) {
|
|
1830
|
+
var accessor = glTF.accessors[attributeAccessorIdx];
|
|
1831
|
+
return GLTFUtils.getAccessorBuffer(context, context.glTF.bufferViews, accessor);
|
|
1832
|
+
} else {
|
|
1833
|
+
return null;
|
|
1771
1834
|
}
|
|
1772
1835
|
}, function() {
|
|
1773
|
-
var indexAccessor =
|
|
1774
|
-
return
|
|
1836
|
+
var indexAccessor = glTF.accessors[gltfPrimitive.indices];
|
|
1837
|
+
return context.getBuffers().then(function(buffers) {
|
|
1838
|
+
return GLTFUtils.getAccessorData(glTF, indexAccessor, buffers);
|
|
1839
|
+
});
|
|
1775
1840
|
}, context.keepMeshData).then(resolve);
|
|
1776
1841
|
}
|
|
1777
1842
|
});
|
|
1778
1843
|
};
|
|
1779
|
-
var gltfMesh =
|
|
1844
|
+
var gltfMesh = glTF.meshes[i];
|
|
1780
1845
|
var primitivePromises = [];
|
|
1781
1846
|
for(var j = 0; j < gltfMesh.primitives.length; j++)_loop(j);
|
|
1782
1847
|
meshPromises[i] = Promise.all(primitivePromises);
|
|
1783
1848
|
};
|
|
1784
|
-
var
|
|
1785
|
-
var gltf = context.gltf, buffers = context.buffers, glTFResource = context.glTFResource;
|
|
1849
|
+
var glTF = context.glTF, glTFResource = context.glTFResource;
|
|
1786
1850
|
var engine = glTFResource.engine;
|
|
1787
|
-
if (!
|
|
1851
|
+
if (!glTF.meshes) return;
|
|
1788
1852
|
var meshesPromiseInfo = context.meshesPromiseInfo;
|
|
1789
1853
|
var meshPromises = [];
|
|
1790
|
-
for(var i = 0; i <
|
|
1854
|
+
for(var i = 0; i < glTF.meshes.length; i++)_loop(i);
|
|
1791
1855
|
AssetPromise.all(meshPromises).then(function(meshes) {
|
|
1792
1856
|
glTFResource.meshes = meshes;
|
|
1793
1857
|
meshesPromiseInfo.resolve(meshes);
|
|
1794
1858
|
}).catch(meshesPromiseInfo.reject);
|
|
1795
1859
|
return meshesPromiseInfo.promise;
|
|
1796
1860
|
};
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
var
|
|
1801
|
-
var engine = mesh.engine;
|
|
1802
|
-
var vertexElements = new Array();
|
|
1803
|
-
var vertexCount;
|
|
1804
|
-
var bufferBindIndex = 0;
|
|
1805
|
-
var positions;
|
|
1806
|
-
keepMeshData && (positions = new Array(vertexCount));
|
|
1807
|
-
for(var attribute in attributes){
|
|
1861
|
+
/**
|
|
1862
|
+
* @internal
|
|
1863
|
+
*/ GLTFMeshParser._parseMeshFromGLTFPrimitive = function _parseMeshFromGLTFPrimitive(context, mesh, meshRestoreInfo, gltfMesh, gltfPrimitive, gltf, getVertexBufferData, getBlendShapeData, getIndexBufferData, keepMeshData) {
|
|
1864
|
+
var _loop = function(attribute) {
|
|
1808
1865
|
var accessor = accessors[attributes[attribute]];
|
|
1809
|
-
var
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
var
|
|
1819
|
-
|
|
1820
|
-
var elementOffset
|
|
1821
|
-
if (
|
|
1822
|
-
|
|
1823
|
-
var
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1866
|
+
var promise = GLTFUtils.getAccessorBuffer(context, gltf.bufferViews, accessor).then(function(accessorBuffer) {
|
|
1867
|
+
var dataElementSize = GLTFUtils.getAccessorTypeSize(accessor.type);
|
|
1868
|
+
var accessorCount = accessor.count;
|
|
1869
|
+
var vertices = accessorBuffer.data;
|
|
1870
|
+
var vertexElement;
|
|
1871
|
+
var meshId = mesh.instanceId;
|
|
1872
|
+
var vertexBindingInfos = accessorBuffer.vertexBindingInfos;
|
|
1873
|
+
var elementNormalized = accessor.normalized;
|
|
1874
|
+
var elementFormat = GLTFUtils.getElementFormat(accessor.componentType, dataElementSize, elementNormalized);
|
|
1875
|
+
var scaleFactor;
|
|
1876
|
+
elementNormalized && (scaleFactor = GLTFUtils.getNormalizedComponentScale(accessor.componentType));
|
|
1877
|
+
var elementOffset;
|
|
1878
|
+
if (accessorBuffer.interleaved) {
|
|
1879
|
+
var byteOffset = accessor.byteOffset || 0;
|
|
1880
|
+
var stride = accessorBuffer.stride;
|
|
1881
|
+
elementOffset = byteOffset % stride;
|
|
1882
|
+
if (vertexBindingInfos[meshId] === undefined) {
|
|
1883
|
+
vertexElement = new VertexElement(attribute, elementOffset, elementFormat, bufferBindIndex);
|
|
1884
|
+
var vertexBuffer = accessorBuffer.vertexBuffer;
|
|
1885
|
+
if (!vertexBuffer) {
|
|
1886
|
+
vertexBuffer = new Buffer(engine, BufferBindFlag.VertexBuffer, vertices.byteLength, BufferUsage.Static);
|
|
1887
|
+
vertexBuffer.setData(vertices);
|
|
1888
|
+
accessorBuffer.vertexBuffer = vertexBuffer;
|
|
1889
|
+
meshRestoreInfo.vertexBuffers.push(new BufferRestoreInfo(vertexBuffer, accessorBuffer.restoreInfo));
|
|
1890
|
+
}
|
|
1891
|
+
mesh.setVertexBufferBinding(vertexBuffer, stride, bufferBindIndex);
|
|
1892
|
+
vertexBindingInfos[meshId] = bufferBindIndex++;
|
|
1893
|
+
} else {
|
|
1894
|
+
vertexElement = new VertexElement(attribute, elementOffset, elementFormat, vertexBindingInfos[meshId]);
|
|
1828
1895
|
}
|
|
1829
|
-
mesh.setVertexBufferBinding(vertexBuffer, stride, bufferBindIndex);
|
|
1830
|
-
vertexBindingInfos[meshId] = bufferBindIndex++;
|
|
1831
1896
|
} else {
|
|
1832
|
-
|
|
1897
|
+
elementOffset = 0;
|
|
1898
|
+
vertexElement = new VertexElement(attribute, elementOffset, elementFormat, bufferBindIndex);
|
|
1899
|
+
var vertexBuffer1 = new Buffer(engine, BufferBindFlag.VertexBuffer, vertices.byteLength, BufferUsage.Static);
|
|
1900
|
+
vertexBuffer1.setData(vertices);
|
|
1901
|
+
meshRestoreInfo.vertexBuffers.push(new BufferRestoreInfo(vertexBuffer1, accessorBuffer.restoreInfo));
|
|
1902
|
+
mesh.setVertexBufferBinding(vertexBuffer1, accessorBuffer.stride, bufferBindIndex);
|
|
1903
|
+
vertexBindingInfos[meshId] = bufferBindIndex++;
|
|
1833
1904
|
}
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1905
|
+
vertexElements.push(vertexElement);
|
|
1906
|
+
if (attribute === "POSITION") {
|
|
1907
|
+
vertexCount = accessorCount;
|
|
1908
|
+
var _mesh_bounds = mesh.bounds, min = _mesh_bounds.min, max = _mesh_bounds.max;
|
|
1909
|
+
if (accessor.min && accessor.max) {
|
|
1910
|
+
min.copyFromArray(accessor.min);
|
|
1911
|
+
max.copyFromArray(accessor.max);
|
|
1912
|
+
if (keepMeshData) {
|
|
1913
|
+
var baseOffset = elementOffset / vertices.BYTES_PER_ELEMENT;
|
|
1914
|
+
var stride1 = vertices.length / accessorCount;
|
|
1915
|
+
for(var j = 0; j < accessorCount; j++){
|
|
1916
|
+
var offset = baseOffset + j * stride1;
|
|
1917
|
+
var position = new Vector3(vertices[offset], vertices[offset + 1], vertices[offset + 2]);
|
|
1918
|
+
elementNormalized && position.scale(scaleFactor);
|
|
1919
|
+
positions[j] = position;
|
|
1920
|
+
}
|
|
1921
|
+
}
|
|
1922
|
+
} else {
|
|
1923
|
+
var position1 = GLTFMeshParser._tempVector3;
|
|
1924
|
+
min.set(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
|
|
1925
|
+
max.set(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
|
|
1926
|
+
var baseOffset1 = elementOffset / vertices.BYTES_PER_ELEMENT;
|
|
1927
|
+
var stride2 = vertices.length / accessorCount;
|
|
1928
|
+
for(var j1 = 0; j1 < accessorCount; j1++){
|
|
1929
|
+
var offset1 = baseOffset1 + j1 * stride2;
|
|
1930
|
+
position1.copyFromArray(vertices, offset1);
|
|
1931
|
+
Vector3.min(min, position1, min);
|
|
1932
|
+
Vector3.max(max, position1, max);
|
|
1933
|
+
if (keepMeshData) {
|
|
1934
|
+
var clonePosition = position1.clone();
|
|
1935
|
+
elementNormalized && clonePosition.scale(scaleFactor);
|
|
1936
|
+
positions[j1] = clonePosition;
|
|
1937
|
+
}
|
|
1853
1938
|
}
|
|
1854
1939
|
}
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1940
|
+
if (elementNormalized) {
|
|
1941
|
+
min.scale(scaleFactor);
|
|
1942
|
+
max.scale(scaleFactor);
|
|
1943
|
+
}
|
|
1944
|
+
} else if (attribute === "JOINTS_0" && keepMeshData) {
|
|
1945
|
+
var baseOffset2 = elementOffset / vertices.BYTES_PER_ELEMENT;
|
|
1946
|
+
var stride3 = vertices.length / accessorCount;
|
|
1947
|
+
for(var j2 = 0; j2 < accessorCount; j2++){
|
|
1948
|
+
var offset2 = baseOffset2 + j2 * stride3;
|
|
1949
|
+
var boneIndex = new Vector4(vertices[offset2], vertices[offset2 + 1], vertices[offset2 + 2], vertices[offset2 + 3]);
|
|
1950
|
+
elementNormalized && boneIndex.scale(scaleFactor);
|
|
1951
|
+
boneIndices[j2] = boneIndex;
|
|
1952
|
+
}
|
|
1953
|
+
} else if (attribute === "WEIGHTS_0" && keepMeshData) {
|
|
1954
|
+
var baseOffset3 = elementOffset / vertices.BYTES_PER_ELEMENT;
|
|
1955
|
+
var stride4 = vertices.length / accessorCount;
|
|
1956
|
+
for(var j3 = 0; j3 < accessorCount; j3++){
|
|
1957
|
+
var offset3 = baseOffset3 + j3 * stride4;
|
|
1958
|
+
var boneWeight = new Vector4(vertices[offset3], vertices[offset3 + 1], vertices[offset3 + 2], vertices[offset3 + 3]);
|
|
1959
|
+
elementNormalized && boneWeight.scale(scaleFactor);
|
|
1960
|
+
boneWeights[j3] = boneWeight;
|
|
1866
1961
|
}
|
|
1867
1962
|
}
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
}
|
|
1873
|
-
}
|
|
1874
|
-
}
|
|
1875
|
-
mesh.setVertexElements(vertexElements);
|
|
1876
|
-
// Indices
|
|
1877
|
-
if (indices !== undefined) {
|
|
1878
|
-
var indexAccessor = gltf.accessors[indices];
|
|
1879
|
-
var indexData = getIndexBufferData();
|
|
1880
|
-
mesh.setIndices(indexData);
|
|
1881
|
-
mesh.addSubMesh(0, indexAccessor.count, mode);
|
|
1882
|
-
} else {
|
|
1883
|
-
mesh.addSubMesh(0, vertexCount, mode);
|
|
1884
|
-
}
|
|
1885
|
-
// BlendShapes
|
|
1886
|
-
targets && this._createBlendShape(mesh, gltfMesh, targets, getBlendShapeData);
|
|
1887
|
-
mesh.uploadData(!keepMeshData);
|
|
1888
|
-
//@ts-ignore
|
|
1889
|
-
mesh._positions = positions;
|
|
1890
|
-
return Promise.resolve(mesh);
|
|
1891
|
-
};
|
|
1892
|
-
_proto._createBlendShape = function _createBlendShape(mesh, glTFMesh, glTFTargets, getBlendShapeData) {
|
|
1893
|
-
var blendShapeNames = glTFMesh.extras ? glTFMesh.extras.targetNames : null;
|
|
1894
|
-
for(var i = 0, n = glTFTargets.length; i < n; i++){
|
|
1895
|
-
var name = blendShapeNames ? blendShapeNames[i] : "blendShape" + i;
|
|
1896
|
-
var deltaPosBuffer = getBlendShapeData("POSITION", i);
|
|
1897
|
-
var deltaNorBuffer = getBlendShapeData("NORMAL", i);
|
|
1898
|
-
var deltaTanBuffer = getBlendShapeData("TANGENT", i);
|
|
1899
|
-
var deltaPositions = deltaPosBuffer ? GLTFUtil.floatBufferToVector3Array(deltaPosBuffer) : null;
|
|
1900
|
-
var deltaNormals = deltaNorBuffer ? GLTFUtil.floatBufferToVector3Array(deltaNorBuffer) : null;
|
|
1901
|
-
var deltaTangents = deltaTanBuffer ? GLTFUtil.floatBufferToVector3Array(deltaTanBuffer) : null;
|
|
1902
|
-
var blendShape = new BlendShape(name);
|
|
1903
|
-
blendShape.addFrame(1.0, deltaPositions, deltaNormals, deltaTangents);
|
|
1904
|
-
mesh.addBlendShape(blendShape);
|
|
1905
|
-
}
|
|
1906
|
-
};
|
|
1907
|
-
/**
|
|
1908
|
-
* @deprecated
|
|
1909
|
-
*/ _proto._parseMeshFromGLTFPrimitiveDraco = function _parseMeshFromGLTFPrimitiveDraco(mesh, gltfMesh, gltfPrimitive, gltf, getVertexBufferData, getBlendShapeData, getIndexBufferData, keepMeshData) {
|
|
1963
|
+
});
|
|
1964
|
+
promises.push(promise);
|
|
1965
|
+
};
|
|
1966
|
+
var accessors = gltf.accessors;
|
|
1910
1967
|
var attributes = gltfPrimitive.attributes, targets = gltfPrimitive.targets, indices = gltfPrimitive.indices, mode = gltfPrimitive.mode;
|
|
1968
|
+
var engine = mesh.engine;
|
|
1969
|
+
var vertexElements = new Array();
|
|
1911
1970
|
var vertexCount;
|
|
1912
|
-
var
|
|
1913
|
-
var
|
|
1914
|
-
var
|
|
1915
|
-
var
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
bounds.min.copyFromArray(accessor.min);
|
|
1921
|
-
bounds.max.copyFromArray(accessor.max);
|
|
1922
|
-
} else {
|
|
1923
|
-
var position = MeshParser._tempVector3;
|
|
1924
|
-
var min = bounds.min, max = bounds.max;
|
|
1925
|
-
min.set(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
|
|
1926
|
-
max.set(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
|
|
1927
|
-
var stride = positionBuffer.length / vertexCount;
|
|
1928
|
-
for(var j = 0; j < vertexCount; j++){
|
|
1929
|
-
var offset = j * stride;
|
|
1930
|
-
position.copyFromArray(positionBuffer, offset);
|
|
1931
|
-
Vector3.min(min, position, min);
|
|
1932
|
-
Vector3.max(max, position, max);
|
|
1933
|
-
}
|
|
1971
|
+
var bufferBindIndex = 0;
|
|
1972
|
+
var positions;
|
|
1973
|
+
var boneIndices;
|
|
1974
|
+
var boneWeights;
|
|
1975
|
+
if (keepMeshData) {
|
|
1976
|
+
positions = new Array(vertexCount);
|
|
1977
|
+
boneIndices = new Array(vertexCount);
|
|
1978
|
+
boneWeights = new Array(vertexCount);
|
|
1934
1979
|
}
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1980
|
+
var promises = new Array();
|
|
1981
|
+
for(var attribute in attributes)_loop(attribute);
|
|
1982
|
+
return Promise.all(promises).then(function() {
|
|
1983
|
+
mesh.setVertexElements(vertexElements);
|
|
1984
|
+
// Indices
|
|
1985
|
+
if (indices !== undefined) {
|
|
1986
|
+
var indexAccessor = gltf.accessors[indices];
|
|
1987
|
+
var promise = GLTFUtils.getAccessorBuffer(context, gltf.bufferViews, indexAccessor).then(function(accessorBuffer) {
|
|
1988
|
+
mesh.setIndices(accessorBuffer.data);
|
|
1989
|
+
mesh.addSubMesh(0, indexAccessor.count, mode);
|
|
1990
|
+
meshRestoreInfo.indexBuffer = accessorBuffer.restoreInfo;
|
|
1991
|
+
});
|
|
1992
|
+
promises.push(promise);
|
|
1993
|
+
} else {
|
|
1994
|
+
mesh.addSubMesh(0, vertexCount, mode);
|
|
1938
1995
|
}
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
var normals = GLTFUtil.floatBufferToVector3Array(bufferData);
|
|
1943
|
-
mesh.setNormals(normals);
|
|
1944
|
-
break;
|
|
1945
|
-
case "TEXCOORD_0":
|
|
1946
|
-
var texturecoords = GLTFUtil.floatBufferToVector2Array(bufferData);
|
|
1947
|
-
mesh.setUVs(texturecoords, 0);
|
|
1948
|
-
break;
|
|
1949
|
-
case "TEXCOORD_1":
|
|
1950
|
-
var texturecoords1 = GLTFUtil.floatBufferToVector2Array(bufferData);
|
|
1951
|
-
mesh.setUVs(texturecoords1, 1);
|
|
1952
|
-
break;
|
|
1953
|
-
case "TEXCOORD_2":
|
|
1954
|
-
var texturecoords2 = GLTFUtil.floatBufferToVector2Array(bufferData);
|
|
1955
|
-
mesh.setUVs(texturecoords2, 2);
|
|
1956
|
-
break;
|
|
1957
|
-
case "TEXCOORD_3":
|
|
1958
|
-
var texturecoords3 = GLTFUtil.floatBufferToVector2Array(bufferData);
|
|
1959
|
-
mesh.setUVs(texturecoords3, 3);
|
|
1960
|
-
break;
|
|
1961
|
-
case "TEXCOORD_4":
|
|
1962
|
-
var texturecoords4 = GLTFUtil.floatBufferToVector2Array(bufferData);
|
|
1963
|
-
mesh.setUVs(texturecoords4, 4);
|
|
1964
|
-
break;
|
|
1965
|
-
case "TEXCOORD_5":
|
|
1966
|
-
var texturecoords5 = GLTFUtil.floatBufferToVector2Array(bufferData);
|
|
1967
|
-
mesh.setUVs(texturecoords5, 5);
|
|
1968
|
-
break;
|
|
1969
|
-
case "TEXCOORD_6":
|
|
1970
|
-
var texturecoords6 = GLTFUtil.floatBufferToVector2Array(bufferData);
|
|
1971
|
-
mesh.setUVs(texturecoords6, 6);
|
|
1972
|
-
break;
|
|
1973
|
-
case "TEXCOORD_7":
|
|
1974
|
-
var texturecoords7 = GLTFUtil.floatBufferToVector2Array(bufferData);
|
|
1975
|
-
mesh.setUVs(texturecoords7, 7);
|
|
1976
|
-
break;
|
|
1977
|
-
case "COLOR_0":
|
|
1978
|
-
var colors = GLTFUtil.floatBufferToColorArray(bufferData, accessors[attributes["COLOR_0"]].type === AccessorType.VEC3);
|
|
1979
|
-
mesh.setColors(colors);
|
|
1980
|
-
break;
|
|
1981
|
-
case "TANGENT":
|
|
1982
|
-
var tangents = GLTFUtil.floatBufferToVector4Array(bufferData);
|
|
1983
|
-
mesh.setTangents(tangents);
|
|
1984
|
-
break;
|
|
1985
|
-
case "JOINTS_0":
|
|
1986
|
-
var joints = GLTFUtil.floatBufferToVector4Array(bufferData);
|
|
1987
|
-
mesh.setBoneIndices(joints);
|
|
1988
|
-
break;
|
|
1989
|
-
case "WEIGHTS_0":
|
|
1990
|
-
var weights = GLTFUtil.floatBufferToVector4Array(bufferData);
|
|
1991
|
-
mesh.setBoneWeights(weights);
|
|
1992
|
-
break;
|
|
1996
|
+
// BlendShapes
|
|
1997
|
+
if (targets) {
|
|
1998
|
+
promises.push(GLTFMeshParser._createBlendShape(mesh, meshRestoreInfo, gltfMesh, accessors, targets, getBlendShapeData));
|
|
1993
1999
|
}
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2000
|
+
return Promise.all(promises).then(function() {
|
|
2001
|
+
mesh.uploadData(!keepMeshData);
|
|
2002
|
+
//@ts-ignore
|
|
2003
|
+
mesh._positions = positions;
|
|
2004
|
+
//@ts-ignore
|
|
2005
|
+
mesh._boneIndices = boneIndices;
|
|
2006
|
+
//@ts-ignore
|
|
2007
|
+
mesh._boneWeights = boneWeights;
|
|
2008
|
+
return Promise.resolve(mesh);
|
|
2009
|
+
});
|
|
2010
|
+
});
|
|
2011
|
+
};
|
|
2012
|
+
/**
|
|
2013
|
+
* @internal
|
|
2014
|
+
*/ GLTFMeshParser._createBlendShape = function _createBlendShape(mesh, meshRestoreInfo, glTFMesh, accessors, glTFTargets, getBlendShapeData) {
|
|
2015
|
+
var _loop = function(i, n) {
|
|
2016
|
+
var name = blendShapeNames ? blendShapeNames[i] : "blendShape" + i;
|
|
2017
|
+
var promise = Promise.all([
|
|
2018
|
+
getBlendShapeData("POSITION", i),
|
|
2019
|
+
getBlendShapeData("NORMAL", i),
|
|
2020
|
+
getBlendShapeData("TANGENT", i)
|
|
2021
|
+
]).then(function(infos) {
|
|
2022
|
+
var posBufferInfo = infos[0];
|
|
2023
|
+
var norBufferInfo = infos[1];
|
|
2024
|
+
var tanBufferInfo = infos[2];
|
|
2025
|
+
var target = glTFTargets[i];
|
|
2026
|
+
var posAccessor;
|
|
2027
|
+
var norAccessor;
|
|
2028
|
+
var tanAccessor;
|
|
2029
|
+
var positions = null;
|
|
2030
|
+
if (posBufferInfo) {
|
|
2031
|
+
posAccessor = accessors[target["POSITION"]];
|
|
2032
|
+
var _posAccessor_byteOffset;
|
|
2033
|
+
positions = GLTFUtils.bufferToVector3Array(posBufferInfo.data, posBufferInfo.stride, (_posAccessor_byteOffset = posAccessor.byteOffset) != null ? _posAccessor_byteOffset : 0, posAccessor.count);
|
|
2034
|
+
}
|
|
2035
|
+
var normals = null;
|
|
2036
|
+
if (norBufferInfo) {
|
|
2037
|
+
norAccessor = accessors[target["NORMAL"]];
|
|
2038
|
+
var _norAccessor_byteOffset;
|
|
2039
|
+
normals = GLTFUtils.bufferToVector3Array(norBufferInfo.data, norBufferInfo.stride, (_norAccessor_byteOffset = norAccessor.byteOffset) != null ? _norAccessor_byteOffset : 0, norAccessor.count);
|
|
2040
|
+
}
|
|
2041
|
+
var tangents = null;
|
|
2042
|
+
if (tanBufferInfo) {
|
|
2043
|
+
tanAccessor = accessors[target["NORMAL"]];
|
|
2044
|
+
var _tanAccessor_byteOffset;
|
|
2045
|
+
tangents = GLTFUtils.bufferToVector3Array(tanBufferInfo.data, tanBufferInfo.stride, (_tanAccessor_byteOffset = tanAccessor.byteOffset) != null ? _tanAccessor_byteOffset : 0, tanAccessor.count);
|
|
2046
|
+
}
|
|
2047
|
+
var blendShape = new BlendShape(name);
|
|
2048
|
+
blendShape.addFrame(1.0, positions, normals, tangents);
|
|
2049
|
+
mesh.addBlendShape(blendShape);
|
|
2050
|
+
var _posAccessor_byteOffset1, _norAccessor_byteOffset1, _tanAccessor_byteOffset1;
|
|
2051
|
+
meshRestoreInfo.blendShapes.push(new BlendShapeRestoreInfo(blendShape, new BlendShapeDataRestoreInfo(posBufferInfo.restoreInfo, posBufferInfo.stride, (_posAccessor_byteOffset1 = posAccessor.byteOffset) != null ? _posAccessor_byteOffset1 : 0, posAccessor.count), norBufferInfo ? new BlendShapeDataRestoreInfo(norBufferInfo.restoreInfo, norBufferInfo.stride, (_norAccessor_byteOffset1 = norAccessor.byteOffset) != null ? _norAccessor_byteOffset1 : 0, norAccessor.count) : null, tanBufferInfo ? new BlendShapeDataRestoreInfo(tanBufferInfo.restoreInfo, tanBufferInfo.stride, (_tanAccessor_byteOffset1 = tanAccessor.byteOffset) != null ? _tanAccessor_byteOffset1 : 0, tanAccessor.count) : null));
|
|
2052
|
+
});
|
|
2053
|
+
promises.push(promise);
|
|
2054
|
+
};
|
|
2055
|
+
var blendShapeNames = glTFMesh.extras ? glTFMesh.extras.targetNames : null;
|
|
2056
|
+
var promises = new Array();
|
|
2057
|
+
for(var i = 0, n = glTFTargets.length; i < n; i++)_loop(i);
|
|
2058
|
+
return Promise.all(promises);
|
|
2008
2059
|
};
|
|
2009
|
-
return
|
|
2010
|
-
}(
|
|
2060
|
+
return GLTFMeshParser;
|
|
2061
|
+
}(GLTFParser);
|
|
2011
2062
|
(function() {
|
|
2012
|
-
|
|
2063
|
+
GLTFMeshParser._tempVector3 = new Vector3();
|
|
2013
2064
|
})();
|
|
2014
2065
|
|
|
2015
|
-
var
|
|
2016
|
-
_inherits(
|
|
2017
|
-
function
|
|
2018
|
-
return
|
|
2066
|
+
var GLTFSceneParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
2067
|
+
_inherits(GLTFSceneParser, GLTFParser1);
|
|
2068
|
+
function GLTFSceneParser() {
|
|
2069
|
+
return GLTFParser1.apply(this, arguments);
|
|
2019
2070
|
}
|
|
2020
|
-
var _proto =
|
|
2071
|
+
var _proto = GLTFSceneParser.prototype;
|
|
2021
2072
|
_proto.parse = function parse(context) {
|
|
2022
|
-
var glTFResource = context.glTFResource,
|
|
2073
|
+
var glTFResource = context.glTFResource, glTF = context.glTF;
|
|
2023
2074
|
var entities = glTFResource.entities;
|
|
2024
|
-
var nodes =
|
|
2075
|
+
var nodes = glTF.nodes, cameras = glTF.cameras;
|
|
2025
2076
|
if (!nodes) return;
|
|
2026
2077
|
var defaultSceneRootPromiseInfo = context.defaultSceneRootPromiseInfo;
|
|
2027
|
-
var promises = [];
|
|
2028
2078
|
for(var i = 0; i < nodes.length; i++){
|
|
2029
|
-
var
|
|
2030
|
-
var cameraID =
|
|
2031
|
-
var KHR_lights_punctual = extensions.KHR_lights_punctual;
|
|
2079
|
+
var glTFNode = nodes[i];
|
|
2080
|
+
var cameraID = glTFNode.camera, meshID = glTFNode.mesh, extensions = glTFNode.extensions;
|
|
2032
2081
|
var entity = entities[i];
|
|
2033
2082
|
if (cameraID !== undefined) {
|
|
2034
|
-
this._createCamera(glTFResource,
|
|
2083
|
+
this._createCamera(glTFResource, cameras[cameraID], entity);
|
|
2035
2084
|
}
|
|
2036
2085
|
if (meshID !== undefined) {
|
|
2037
|
-
|
|
2038
|
-
}
|
|
2039
|
-
if (KHR_lights_punctual) {
|
|
2040
|
-
var lightIndex = KHR_lights_punctual.light;
|
|
2041
|
-
var lights = gltf.extensions.KHR_lights_punctual.lights;
|
|
2042
|
-
Parser.parseEngineResource("KHR_lights_punctual", lights[lightIndex], entity, context);
|
|
2086
|
+
this._createRenderer(context, glTFNode, entity);
|
|
2043
2087
|
}
|
|
2088
|
+
GLTFParser.executeExtensionsAdditiveAndParse(extensions, context, entity, glTFNode);
|
|
2044
2089
|
}
|
|
2045
2090
|
if (glTFResource.defaultSceneRoot) {
|
|
2046
2091
|
this._createAnimator(context);
|
|
2047
2092
|
}
|
|
2048
|
-
|
|
2049
|
-
AssetPromise.all(promises).then(function() {
|
|
2050
|
-
return defaultSceneRootPromiseInfo.resolve(glTFResource.defaultSceneRoot);
|
|
2051
|
-
}).catch(defaultSceneRootPromiseInfo.reject);
|
|
2093
|
+
defaultSceneRootPromiseInfo.resolve(glTFResource.defaultSceneRoot);
|
|
2052
2094
|
return defaultSceneRootPromiseInfo.promise;
|
|
2053
2095
|
};
|
|
2054
2096
|
_proto._createCamera = function _createCamera(context, cameraSchema, entity) {
|
|
@@ -2084,8 +2126,9 @@ var SceneParser$1 = /*#__PURE__*/ function(Parser1) {
|
|
|
2084
2126
|
// @todo: use engine camera by default
|
|
2085
2127
|
camera.enabled = false;
|
|
2086
2128
|
};
|
|
2087
|
-
_proto._createRenderer = function _createRenderer(context,
|
|
2129
|
+
_proto._createRenderer = function _createRenderer(context, glTFNode, entity) {
|
|
2088
2130
|
var _loop = function(i) {
|
|
2131
|
+
var gltfPrimitive = glTFMeshPrimitives[i];
|
|
2089
2132
|
var mesh = meshes[meshID][i];
|
|
2090
2133
|
var renderer = void 0;
|
|
2091
2134
|
if (skinID !== undefined || blendShapeWeights) {
|
|
@@ -2103,32 +2146,25 @@ var SceneParser$1 = /*#__PURE__*/ function(Parser1) {
|
|
|
2103
2146
|
renderer = entity.addComponent(MeshRenderer);
|
|
2104
2147
|
renderer.mesh = mesh;
|
|
2105
2148
|
}
|
|
2106
|
-
var materialIndex =
|
|
2107
|
-
var
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
var _gltfMeshPrimitives_i = gltfMeshPrimitives[i], _gltfMeshPrimitives_i_extensions = _gltfMeshPrimitives_i.extensions, extensions = _gltfMeshPrimitives_i_extensions === void 0 ? {} : _gltfMeshPrimitives_i_extensions;
|
|
2117
|
-
var KHR_materials_variants = extensions.KHR_materials_variants;
|
|
2118
|
-
if (KHR_materials_variants) {
|
|
2119
|
-
Parser.parseEngineResource("KHR_materials_variants", KHR_materials_variants, renderer, context);
|
|
2120
|
-
}
|
|
2149
|
+
var materialIndex = gltfPrimitive.material;
|
|
2150
|
+
var material = (materials == null ? void 0 : materials[materialIndex]) || GLTFSceneParser._getDefaultMaterial(engine);
|
|
2151
|
+
renderer.setMaterial(material);
|
|
2152
|
+
// Enable vertex color if mesh has COLOR_0 vertex element
|
|
2153
|
+
mesh.vertexElements.forEach(function(element) {
|
|
2154
|
+
if (element.semantic === "COLOR_0") {
|
|
2155
|
+
renderer.enableVertexColor = true;
|
|
2156
|
+
}
|
|
2157
|
+
});
|
|
2158
|
+
GLTFParser.executeExtensionsAdditiveAndParse(gltfPrimitive.extensions, context, renderer, gltfPrimitive);
|
|
2121
2159
|
};
|
|
2122
|
-
var glTFResource = context.glTFResource,
|
|
2123
|
-
var
|
|
2160
|
+
var glTFResource = context.glTFResource, glTF = context.glTF;
|
|
2161
|
+
var glTFMeshes = glTF.meshes;
|
|
2124
2162
|
var engine = glTFResource.engine, meshes = glTFResource.meshes, materials = glTFResource.materials, skins = glTFResource.skins;
|
|
2125
|
-
var meshID =
|
|
2126
|
-
var glTFMesh =
|
|
2127
|
-
var
|
|
2128
|
-
var blendShapeWeights =
|
|
2129
|
-
var
|
|
2130
|
-
for(var i = 0; i < gltfMeshPrimitives.length; i++)_loop(i);
|
|
2131
|
-
return Promise.all(promises);
|
|
2163
|
+
var meshID = glTFNode.mesh, skinID = glTFNode.skin;
|
|
2164
|
+
var glTFMesh = glTFMeshes[meshID];
|
|
2165
|
+
var glTFMeshPrimitives = glTFMesh.primitives;
|
|
2166
|
+
var blendShapeWeights = glTFNode.weights || glTFMesh.weights;
|
|
2167
|
+
for(var i = 0; i < glTFMeshPrimitives.length; i++)_loop(i);
|
|
2132
2168
|
};
|
|
2133
2169
|
_proto._createAnimator = function _createAnimator(context) {
|
|
2134
2170
|
if (!context.hasSkinned && !context.glTFResource.animations) {
|
|
@@ -2155,67 +2191,74 @@ var SceneParser$1 = /*#__PURE__*/ function(Parser1) {
|
|
|
2155
2191
|
}
|
|
2156
2192
|
}
|
|
2157
2193
|
};
|
|
2158
|
-
|
|
2159
|
-
if (!
|
|
2160
|
-
|
|
2194
|
+
GLTFSceneParser._getDefaultMaterial = function _getDefaultMaterial(engine) {
|
|
2195
|
+
if (!GLTFSceneParser._defaultMaterial) {
|
|
2196
|
+
GLTFSceneParser._defaultMaterial = new BlinnPhongMaterial(engine);
|
|
2161
2197
|
}
|
|
2162
|
-
return
|
|
2198
|
+
return GLTFSceneParser._defaultMaterial;
|
|
2163
2199
|
};
|
|
2164
|
-
return
|
|
2165
|
-
}(
|
|
2200
|
+
return GLTFSceneParser;
|
|
2201
|
+
}(GLTFParser);
|
|
2166
2202
|
|
|
2167
|
-
var
|
|
2168
|
-
_inherits(
|
|
2169
|
-
function
|
|
2170
|
-
return
|
|
2203
|
+
var GLTFSkinParser = /*#__PURE__*/ function(GLTFParser) {
|
|
2204
|
+
_inherits(GLTFSkinParser, GLTFParser);
|
|
2205
|
+
function GLTFSkinParser() {
|
|
2206
|
+
return GLTFParser.apply(this, arguments);
|
|
2171
2207
|
}
|
|
2172
|
-
var _proto =
|
|
2208
|
+
var _proto = GLTFSkinParser.prototype;
|
|
2173
2209
|
_proto.parse = function parse(context) {
|
|
2174
|
-
var
|
|
2175
|
-
var entities = glTFResource.entities;
|
|
2176
|
-
var gltfSkins = gltf.skins;
|
|
2177
|
-
if (!gltfSkins) return;
|
|
2178
|
-
var count = gltfSkins.length;
|
|
2179
|
-
var skins = new Array(count);
|
|
2180
|
-
for(var i = 0; i < count; i++){
|
|
2210
|
+
var _loop = function(i) {
|
|
2181
2211
|
var _gltfSkins_i = gltfSkins[i], inverseBindMatrices = _gltfSkins_i.inverseBindMatrices, skeleton = _gltfSkins_i.skeleton, joints = _gltfSkins_i.joints, _gltfSkins_i_name = _gltfSkins_i.name, name = _gltfSkins_i_name === void 0 ? "SKIN_" + i : _gltfSkins_i_name;
|
|
2182
2212
|
var jointCount = joints.length;
|
|
2183
2213
|
var skin = new Skin(name);
|
|
2184
2214
|
skin.inverseBindMatrices.length = jointCount;
|
|
2185
2215
|
// parse IBM
|
|
2186
|
-
var accessor =
|
|
2187
|
-
var
|
|
2188
|
-
|
|
2189
|
-
var
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2216
|
+
var accessor = glTF.accessors[inverseBindMatrices];
|
|
2217
|
+
var promise = GLTFUtils.getAccessorBuffer(context, glTF.bufferViews, accessor).then(function(bufferInfo) {
|
|
2218
|
+
var buffer = bufferInfo.data;
|
|
2219
|
+
for(var i = 0; i < jointCount; i++){
|
|
2220
|
+
var inverseBindMatrix = new Matrix();
|
|
2221
|
+
inverseBindMatrix.copyFromArray(buffer, i * 16);
|
|
2222
|
+
skin.inverseBindMatrices[i] = inverseBindMatrix;
|
|
2223
|
+
// get joints
|
|
2224
|
+
for(var i1 = 0; i1 < jointCount; i1++){
|
|
2225
|
+
var jointIndex = joints[i1];
|
|
2226
|
+
var jointName = entities[jointIndex].name;
|
|
2227
|
+
skin.joints[i1] = jointName;
|
|
2228
|
+
// @todo Temporary solution, but it can alleviate the current BUG, and the skinning data mechanism of SkinnedMeshRenderer will be completely refactored in the future
|
|
2229
|
+
for(var j = entities.length - 1; j >= 0; j--){
|
|
2230
|
+
if (jointIndex !== j && entities[j].name === jointName) {
|
|
2231
|
+
entities[j].name = jointName + "_" + j;
|
|
2232
|
+
}
|
|
2233
|
+
}
|
|
2234
|
+
}
|
|
2235
|
+
// get skeleton
|
|
2236
|
+
if (skeleton !== undefined) {
|
|
2237
|
+
skin.skeleton = entities[skeleton].name;
|
|
2238
|
+
} else {
|
|
2239
|
+
var rootBone = _this._findSkeletonRootBone(joints, entities);
|
|
2240
|
+
if (rootBone) {
|
|
2241
|
+
skin.skeleton = rootBone.name;
|
|
2242
|
+
} else {
|
|
2243
|
+
throw "Failed to find skeleton root bone.";
|
|
2244
|
+
}
|
|
2202
2245
|
}
|
|
2203
2246
|
}
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2247
|
+
return skin;
|
|
2248
|
+
});
|
|
2249
|
+
promises.push(promise);
|
|
2250
|
+
};
|
|
2251
|
+
var _this = this;
|
|
2252
|
+
var glTFResource = context.glTFResource, glTF = context.glTF;
|
|
2253
|
+
var entities = glTFResource.entities;
|
|
2254
|
+
var gltfSkins = glTF.skins;
|
|
2255
|
+
if (!gltfSkins) return;
|
|
2256
|
+
var count = gltfSkins.length;
|
|
2257
|
+
var promises = new Array();
|
|
2258
|
+
for(var i = 0; i < count; i++)_loop(i);
|
|
2259
|
+
return AssetPromise.all(promises).then(function(skins) {
|
|
2260
|
+
glTFResource.skins = skins;
|
|
2261
|
+
});
|
|
2219
2262
|
};
|
|
2220
2263
|
_proto._findSkeletonRootBone = function _findSkeletonRootBone(joints, entities) {
|
|
2221
2264
|
var paths = {};
|
|
@@ -2245,53 +2288,62 @@ var SkinParser = /*#__PURE__*/ function(Parser) {
|
|
|
2245
2288
|
rootNode = entity1;
|
|
2246
2289
|
}
|
|
2247
2290
|
};
|
|
2248
|
-
return
|
|
2249
|
-
}(
|
|
2291
|
+
return GLTFSkinParser;
|
|
2292
|
+
}(GLTFParser);
|
|
2250
2293
|
|
|
2251
|
-
var
|
|
2252
|
-
_inherits(
|
|
2253
|
-
function
|
|
2254
|
-
return
|
|
2294
|
+
var GLTFTextureParser = /*#__PURE__*/ function(GLTFParser) {
|
|
2295
|
+
_inherits(GLTFTextureParser, GLTFParser);
|
|
2296
|
+
function GLTFTextureParser() {
|
|
2297
|
+
return GLTFParser.apply(this, arguments);
|
|
2255
2298
|
}
|
|
2256
|
-
var _proto =
|
|
2299
|
+
var _proto = GLTFTextureParser.prototype;
|
|
2257
2300
|
_proto.parse = function parse(context) {
|
|
2258
2301
|
var _this = this;
|
|
2259
|
-
var glTFResource = context.glTFResource,
|
|
2302
|
+
var glTFResource = context.glTFResource, glTF = context.glTF;
|
|
2260
2303
|
var engine = glTFResource.engine, url = glTFResource.url;
|
|
2261
|
-
if (
|
|
2304
|
+
if (glTF.textures) {
|
|
2262
2305
|
var texturesPromiseInfo = context.texturesPromiseInfo;
|
|
2263
|
-
AssetPromise.all(
|
|
2306
|
+
AssetPromise.all(glTF.textures.map(function(param, index) {
|
|
2264
2307
|
var sampler = param.sampler, _param_source = param.source, source = _param_source === void 0 ? 0 : _param_source, textureName = param.name;
|
|
2265
|
-
var
|
|
2308
|
+
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;
|
|
2309
|
+
var samplerInfo = sampler !== undefined && _this._getSamplerInfo(glTF.samplers[sampler]);
|
|
2266
2310
|
if (uri) {
|
|
2267
2311
|
// TODO: support ktx extension https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_texture_basisu/README.md
|
|
2268
2312
|
var index1 = uri.lastIndexOf(".");
|
|
2269
2313
|
var ext = uri.substring(index1 + 1);
|
|
2270
2314
|
var type = ext.startsWith("ktx") ? AssetType.KTX : AssetType.Texture2D;
|
|
2271
2315
|
return engine.resourceManager.load({
|
|
2272
|
-
url:
|
|
2273
|
-
type: type
|
|
2316
|
+
url: Utils.resolveAbsoluteUrl(url, uri),
|
|
2317
|
+
type: type,
|
|
2318
|
+
params: {
|
|
2319
|
+
mipmap: samplerInfo == null ? void 0 : samplerInfo.mipmap
|
|
2320
|
+
}
|
|
2274
2321
|
}).then(function(texture) {
|
|
2275
2322
|
if (!texture.name) {
|
|
2276
2323
|
texture.name = textureName || imageName || "texture_" + index1;
|
|
2277
2324
|
}
|
|
2278
2325
|
if (sampler !== undefined) {
|
|
2279
|
-
_this._parseSampler(texture,
|
|
2326
|
+
_this._parseSampler(texture, samplerInfo);
|
|
2280
2327
|
}
|
|
2281
2328
|
return texture;
|
|
2282
2329
|
});
|
|
2283
2330
|
} else {
|
|
2284
|
-
var bufferView =
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
var
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2331
|
+
var bufferView = glTF.bufferViews[bufferViewIndex];
|
|
2332
|
+
return context.getBuffers().then(function(buffers) {
|
|
2333
|
+
var buffer = buffers[bufferView.buffer];
|
|
2334
|
+
var imageBuffer = new Uint8Array(buffer, bufferView.byteOffset, bufferView.byteLength);
|
|
2335
|
+
return GLTFUtils.loadImageBuffer(imageBuffer, mimeType).then(function(image) {
|
|
2336
|
+
var texture = new Texture2D(engine, image.width, image.height, undefined, samplerInfo == null ? void 0 : samplerInfo.mipmap);
|
|
2337
|
+
texture.setImageSource(image);
|
|
2338
|
+
texture.generateMipmaps();
|
|
2339
|
+
texture.name = textureName || imageName || "texture_" + index;
|
|
2340
|
+
if (sampler !== undefined) {
|
|
2341
|
+
_this._parseSampler(texture, samplerInfo);
|
|
2342
|
+
}
|
|
2343
|
+
var bufferTextureRestoreInfo = new BufferTextureRestoreInfo(texture, bufferView, mimeType);
|
|
2344
|
+
context.contentRestorer.bufferTextures.push(bufferTextureRestoreInfo);
|
|
2345
|
+
return texture;
|
|
2346
|
+
});
|
|
2295
2347
|
});
|
|
2296
2348
|
}
|
|
2297
2349
|
})).then(function(textures) {
|
|
@@ -2301,48 +2353,67 @@ var TextureParser = /*#__PURE__*/ function(Parser) {
|
|
|
2301
2353
|
return texturesPromiseInfo.promise;
|
|
2302
2354
|
}
|
|
2303
2355
|
};
|
|
2304
|
-
_proto.
|
|
2305
|
-
var
|
|
2306
|
-
|
|
2356
|
+
_proto._getSamplerInfo = function _getSamplerInfo(sampler) {
|
|
2357
|
+
var minFilter = sampler.minFilter, magFilter = sampler.magFilter, wrapS = sampler.wrapS, wrapT = sampler.wrapT;
|
|
2358
|
+
var info = {};
|
|
2359
|
+
if (minFilter || magFilter) {
|
|
2360
|
+
info.mipmap = minFilter >= TextureMinFilter.NEAREST_MIPMAP_NEAREST;
|
|
2307
2361
|
if (magFilter === TextureMagFilter.NEAREST) {
|
|
2308
|
-
|
|
2309
|
-
} else if (minFilter <= TextureMinFilter.LINEAR_MIPMAP_NEAREST) {
|
|
2310
|
-
texture.filterMode = TextureFilterMode.Bilinear;
|
|
2362
|
+
info.filterMode = TextureFilterMode.Point;
|
|
2311
2363
|
} else {
|
|
2312
|
-
|
|
2364
|
+
if (minFilter <= TextureMinFilter.LINEAR_MIPMAP_NEAREST) {
|
|
2365
|
+
info.filterMode = TextureFilterMode.Bilinear;
|
|
2366
|
+
} else {
|
|
2367
|
+
info.filterMode = TextureFilterMode.Trilinear;
|
|
2368
|
+
}
|
|
2313
2369
|
}
|
|
2314
2370
|
}
|
|
2315
2371
|
if (wrapS) {
|
|
2316
|
-
|
|
2372
|
+
info.wrapModeU = GLTFTextureParser._wrapMap[wrapS];
|
|
2317
2373
|
}
|
|
2318
2374
|
if (wrapT) {
|
|
2319
|
-
|
|
2375
|
+
info.wrapModeV = GLTFTextureParser._wrapMap[wrapT];
|
|
2320
2376
|
}
|
|
2377
|
+
return info;
|
|
2321
2378
|
};
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
(
|
|
2325
|
-
|
|
2326
|
-
|
|
2379
|
+
_proto._parseSampler = function _parseSampler(texture, samplerInfo) {
|
|
2380
|
+
var filterMode = samplerInfo.filterMode, wrapModeU = samplerInfo.wrapModeU, wrapModeV = samplerInfo.wrapModeV;
|
|
2381
|
+
if (filterMode !== undefined) {
|
|
2382
|
+
texture.filterMode = filterMode;
|
|
2383
|
+
}
|
|
2384
|
+
if (wrapModeU !== undefined) {
|
|
2385
|
+
texture.wrapModeU = wrapModeU;
|
|
2386
|
+
}
|
|
2387
|
+
if (wrapModeV !== undefined) {
|
|
2388
|
+
texture.wrapModeV = wrapModeV;
|
|
2389
|
+
}
|
|
2390
|
+
};
|
|
2391
|
+
return GLTFTextureParser;
|
|
2392
|
+
}(GLTFParser);
|
|
2393
|
+
(function() {
|
|
2394
|
+
var _obj;
|
|
2395
|
+
GLTFTextureParser._wrapMap = (_obj = {}, _obj[TextureWrapMode.CLAMP_TO_EDGE] = TextureWrapMode$1.Clamp, _obj[TextureWrapMode.MIRRORED_REPEAT] = TextureWrapMode$1.Mirror, _obj[TextureWrapMode.REPEAT] = TextureWrapMode$1.Repeat, _obj);
|
|
2327
2396
|
})();
|
|
2328
2397
|
|
|
2329
|
-
var
|
|
2330
|
-
_inherits(
|
|
2331
|
-
function
|
|
2332
|
-
return
|
|
2398
|
+
var GLTFValidator = /*#__PURE__*/ function(GLTFParser1) {
|
|
2399
|
+
_inherits(GLTFValidator, GLTFParser1);
|
|
2400
|
+
function GLTFValidator() {
|
|
2401
|
+
return GLTFParser1.apply(this, arguments);
|
|
2333
2402
|
}
|
|
2334
|
-
var _proto =
|
|
2403
|
+
var _proto = GLTFValidator.prototype;
|
|
2335
2404
|
_proto.parse = function parse(context) {
|
|
2336
|
-
var
|
|
2337
|
-
var
|
|
2338
|
-
if (!(
|
|
2339
|
-
throw "Only support
|
|
2405
|
+
var _context_glTF = context.glTF, version = _context_glTF.asset.version, extensionsUsed = _context_glTF.extensionsUsed, extensionsRequired = _context_glTF.extensionsRequired;
|
|
2406
|
+
var glTFVersion = Number(version);
|
|
2407
|
+
if (!(glTFVersion >= 2 && glTFVersion < 3)) {
|
|
2408
|
+
throw "Only support glTF 2.x.";
|
|
2340
2409
|
}
|
|
2410
|
+
var promises = [];
|
|
2341
2411
|
if (extensionsUsed) {
|
|
2342
2412
|
Logger.info("extensionsUsed: ", extensionsUsed);
|
|
2343
2413
|
for(var i = 0; i < extensionsUsed.length; i++){
|
|
2344
|
-
|
|
2345
|
-
|
|
2414
|
+
var extensionUsed = extensionsUsed[i];
|
|
2415
|
+
if (!GLTFParser.hasExtensionParser(extensionUsed)) {
|
|
2416
|
+
Logger.warn("Extension " + extensionUsed + " is not implemented, you can customize this extension in gltf.");
|
|
2346
2417
|
}
|
|
2347
2418
|
}
|
|
2348
2419
|
}
|
|
@@ -2350,98 +2421,78 @@ var Validator = /*#__PURE__*/ function(Parser1) {
|
|
|
2350
2421
|
Logger.info("extensionsRequired: " + extensionsRequired);
|
|
2351
2422
|
for(var i1 = 0; i1 < extensionsRequired.length; i1++){
|
|
2352
2423
|
var extensionRequired = extensionsRequired[i1];
|
|
2353
|
-
if (!
|
|
2424
|
+
if (!GLTFParser.hasExtensionParser(extensionRequired)) {
|
|
2354
2425
|
Logger.error("GLTF parser has not supported required extension " + extensionRequired + ".");
|
|
2355
2426
|
} else {
|
|
2356
|
-
|
|
2427
|
+
promises.push(GLTFParser.executeExtensionsInitialize(extensionRequired));
|
|
2357
2428
|
}
|
|
2358
2429
|
}
|
|
2359
2430
|
}
|
|
2431
|
+
return AssetPromise.all(promises).then(null);
|
|
2360
2432
|
};
|
|
2361
|
-
return
|
|
2362
|
-
}(
|
|
2433
|
+
return GLTFValidator;
|
|
2434
|
+
}(GLTFParser);
|
|
2363
2435
|
|
|
2364
|
-
|
|
2365
|
-
|
|
2436
|
+
/**
|
|
2437
|
+
* GLTF pipeline.
|
|
2438
|
+
*/ var GLTFPipeline = /*#__PURE__*/ function() {
|
|
2439
|
+
function GLTFPipeline() {
|
|
2440
|
+
for(var _len = arguments.length, parsers = new Array(_len), _key = 0; _key < _len; _key++){
|
|
2441
|
+
parsers[_key] = arguments[_key];
|
|
2442
|
+
}
|
|
2366
2443
|
var _this = this;
|
|
2367
|
-
this.
|
|
2368
|
-
|
|
2369
|
-
_this.
|
|
2444
|
+
this._parsers = [];
|
|
2445
|
+
parsers.forEach(function(pipe, index) {
|
|
2446
|
+
_this._parsers[index] = new pipe();
|
|
2370
2447
|
});
|
|
2371
2448
|
}
|
|
2372
|
-
var _proto =
|
|
2373
|
-
|
|
2449
|
+
var _proto = GLTFPipeline.prototype;
|
|
2450
|
+
/**
|
|
2451
|
+
* @internal
|
|
2452
|
+
*/ _proto._parse = function _parse(context) {
|
|
2374
2453
|
var _this = this;
|
|
2375
2454
|
var glTFResource = context.glTFResource;
|
|
2376
|
-
var
|
|
2455
|
+
var lastParser;
|
|
2377
2456
|
return new AssetPromise(function(resolve, reject) {
|
|
2378
|
-
_this.
|
|
2379
|
-
if (
|
|
2380
|
-
|
|
2457
|
+
_this._parsers.forEach(function(parser) {
|
|
2458
|
+
if (lastParser) {
|
|
2459
|
+
lastParser = lastParser.then(function() {
|
|
2381
2460
|
return parser.parse(context);
|
|
2382
2461
|
});
|
|
2383
|
-
if (
|
|
2384
|
-
context.chainPromises.push(
|
|
2462
|
+
if (lastParser.cancel) {
|
|
2463
|
+
context.chainPromises.push(lastParser);
|
|
2385
2464
|
}
|
|
2386
2465
|
} else {
|
|
2387
|
-
|
|
2466
|
+
lastParser = parser.parse(context);
|
|
2388
2467
|
}
|
|
2389
2468
|
});
|
|
2390
|
-
if (
|
|
2391
|
-
|
|
2469
|
+
if (lastParser) {
|
|
2470
|
+
lastParser.then(function() {
|
|
2392
2471
|
resolve(glTFResource);
|
|
2393
2472
|
}).catch(reject);
|
|
2394
2473
|
}
|
|
2395
2474
|
});
|
|
2396
2475
|
};
|
|
2397
|
-
return
|
|
2476
|
+
return GLTFPipeline;
|
|
2398
2477
|
}();
|
|
2399
2478
|
(function() {
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
TextureParser,
|
|
2404
|
-
MaterialParser,
|
|
2405
|
-
MeshParser,
|
|
2406
|
-
EntityParser,
|
|
2407
|
-
SkinParser,
|
|
2408
|
-
AnimationParser,
|
|
2409
|
-
SceneParser$1
|
|
2410
|
-
]);
|
|
2479
|
+
/**
|
|
2480
|
+
* Default pipeline.
|
|
2481
|
+
*/ GLTFPipeline.defaultPipeline = new GLTFPipeline(GLTFBufferParser, GLTFValidator, GLTFTextureParser, GLTFMaterialParser, GLTFMeshParser, GLTFEntityParser, GLTFSkinParser, GLTFAnimationParser, GLTFSceneParser);
|
|
2411
2482
|
})();
|
|
2412
2483
|
|
|
2413
2484
|
/**
|
|
2414
|
-
* Product after
|
|
2415
|
-
*/ var GLTFResource = /*#__PURE__*/ function(
|
|
2416
|
-
_inherits(GLTFResource,
|
|
2485
|
+
* Product after glTF parser, usually, `defaultSceneRoot` is only needed to use.
|
|
2486
|
+
*/ var GLTFResource = /*#__PURE__*/ function(ReferResource) {
|
|
2487
|
+
_inherits(GLTFResource, ReferResource);
|
|
2417
2488
|
function GLTFResource(engine, url) {
|
|
2418
2489
|
var _this;
|
|
2419
|
-
_this =
|
|
2490
|
+
_this = ReferResource.call(this, engine) || this;
|
|
2420
2491
|
_this.url = url;
|
|
2421
2492
|
return _this;
|
|
2422
2493
|
}
|
|
2423
|
-
var _proto = GLTFResource.prototype;
|
|
2424
|
-
/**
|
|
2425
|
-
* @override
|
|
2426
|
-
*/ _proto.destroy = function destroy() {
|
|
2427
|
-
if (this._destroyed) {
|
|
2428
|
-
return;
|
|
2429
|
-
}
|
|
2430
|
-
EngineObject.prototype.destroy.call(this);
|
|
2431
|
-
this.defaultSceneRoot.destroy();
|
|
2432
|
-
this.textures = null;
|
|
2433
|
-
this.materials = null;
|
|
2434
|
-
this.meshes = null;
|
|
2435
|
-
this.skins = null;
|
|
2436
|
-
this.animations = null;
|
|
2437
|
-
this.entities = null;
|
|
2438
|
-
this.cameras = null;
|
|
2439
|
-
this.lights = null;
|
|
2440
|
-
this.sceneRoots = null;
|
|
2441
|
-
this.variants = null;
|
|
2442
|
-
};
|
|
2443
2494
|
return GLTFResource;
|
|
2444
|
-
}(
|
|
2495
|
+
}(ReferResource);
|
|
2445
2496
|
|
|
2446
2497
|
var GLTFLoader = /*#__PURE__*/ function(Loader) {
|
|
2447
2498
|
_inherits(GLTFLoader, Loader);
|
|
@@ -2450,14 +2501,16 @@ var GLTFLoader = /*#__PURE__*/ function(Loader) {
|
|
|
2450
2501
|
}
|
|
2451
2502
|
var _proto = GLTFLoader.prototype;
|
|
2452
2503
|
_proto.load = function load(item, resourceManager) {
|
|
2453
|
-
var _item_params;
|
|
2454
2504
|
var url = item.url;
|
|
2455
|
-
var
|
|
2505
|
+
var params = item.params;
|
|
2506
|
+
var context = new GLTFParserContext(url);
|
|
2456
2507
|
var glTFResource = new GLTFResource(resourceManager.engine, url);
|
|
2508
|
+
var restorer = new GLTFContentRestorer(glTFResource);
|
|
2457
2509
|
var masterPromiseInfo = context.masterPromiseInfo;
|
|
2510
|
+
context.contentRestorer = restorer;
|
|
2458
2511
|
context.glTFResource = glTFResource;
|
|
2459
|
-
var
|
|
2460
|
-
context.keepMeshData = (
|
|
2512
|
+
var _params_keepMeshData;
|
|
2513
|
+
context.keepMeshData = (_params_keepMeshData = params == null ? void 0 : params.keepMeshData) != null ? _params_keepMeshData : false;
|
|
2461
2514
|
masterPromiseInfo.onCancel(function() {
|
|
2462
2515
|
var chainPromises = context.chainPromises;
|
|
2463
2516
|
for(var _iterator = _create_for_of_iterator_helper_loose(chainPromises), _step; !(_step = _iterator()).done;){
|
|
@@ -2465,16 +2518,25 @@ var GLTFLoader = /*#__PURE__*/ function(Loader) {
|
|
|
2465
2518
|
promise.cancel();
|
|
2466
2519
|
}
|
|
2467
2520
|
});
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
masterPromiseInfo.
|
|
2521
|
+
((params == null ? void 0 : params.pipeline) || GLTFPipeline.defaultPipeline)._parse(context).then(function(glTFResource) {
|
|
2522
|
+
resourceManager.addContentRestorer(restorer);
|
|
2523
|
+
masterPromiseInfo.resolve(glTFResource);
|
|
2524
|
+
}).catch(function(e) {
|
|
2525
|
+
var msg = "Error loading glTF model from " + url + " : " + e;
|
|
2526
|
+
Logger.error(msg);
|
|
2527
|
+
masterPromiseInfo.reject(msg);
|
|
2528
|
+
context.defaultSceneRootPromiseInfo.reject(e);
|
|
2529
|
+
context.texturesPromiseInfo.reject(e);
|
|
2530
|
+
context.materialsPromiseInfo.reject(e);
|
|
2531
|
+
context.meshesPromiseInfo.reject(e);
|
|
2532
|
+
context.animationClipsPromiseInfo.reject(e);
|
|
2471
2533
|
});
|
|
2472
2534
|
return context.promiseMap;
|
|
2473
2535
|
};
|
|
2474
2536
|
return GLTFLoader;
|
|
2475
2537
|
}(Loader);
|
|
2476
2538
|
GLTFLoader = __decorate([
|
|
2477
|
-
resourceLoader(AssetType.
|
|
2539
|
+
resourceLoader(AssetType.GLTF, [
|
|
2478
2540
|
"gltf",
|
|
2479
2541
|
"glb"
|
|
2480
2542
|
])
|
|
@@ -2560,7 +2622,7 @@ var HDRLoader = (_HDRLoader = /*#__PURE__*/ function(Loader) {
|
|
|
2560
2622
|
return textureArray;
|
|
2561
2623
|
};
|
|
2562
2624
|
HDRLoader1._calcProjectionSpherical = function _calcProjectionSpherical(vDir, pixels, inputWidth, inputHeight) {
|
|
2563
|
-
var theta = Math.atan2(vDir.z,
|
|
2625
|
+
var theta = Math.atan2(vDir.z, vDir.x);
|
|
2564
2626
|
var phi = Math.acos(vDir.y);
|
|
2565
2627
|
while(theta < -PI){
|
|
2566
2628
|
theta += 2 * PI;
|
|
@@ -3069,6 +3131,15 @@ KTXLoader = __decorate([
|
|
|
3069
3131
|
])
|
|
3070
3132
|
], KTXLoader);
|
|
3071
3133
|
|
|
3134
|
+
function parseProperty(object, key, value) {
|
|
3135
|
+
if (typeof value === "object") {
|
|
3136
|
+
for(var subKey in value){
|
|
3137
|
+
parseProperty(object[key], subKey, value[subKey]);
|
|
3138
|
+
}
|
|
3139
|
+
} else {
|
|
3140
|
+
object[key] = value;
|
|
3141
|
+
}
|
|
3142
|
+
}
|
|
3072
3143
|
var MaterialLoader = /*#__PURE__*/ function(Loader) {
|
|
3073
3144
|
_inherits(MaterialLoader, Loader);
|
|
3074
3145
|
function MaterialLoader() {
|
|
@@ -3080,7 +3151,7 @@ var MaterialLoader = /*#__PURE__*/ function(Loader) {
|
|
|
3080
3151
|
return new AssetPromise(function(resolve, reject) {
|
|
3081
3152
|
_this.request(item.url, _extends({}, item, {
|
|
3082
3153
|
type: "json"
|
|
3083
|
-
})).then(function(
|
|
3154
|
+
})).then(function(materialSchema) {
|
|
3084
3155
|
var _loop = function(key) {
|
|
3085
3156
|
var _shaderData_key = shaderData[key], type = _shaderData_key.type, value = _shaderData_key.value;
|
|
3086
3157
|
switch(type){
|
|
@@ -3108,27 +3179,8 @@ var MaterialLoader = /*#__PURE__*/ function(Loader) {
|
|
|
3108
3179
|
}
|
|
3109
3180
|
};
|
|
3110
3181
|
var engine = resourceManager.engine;
|
|
3111
|
-
var name =
|
|
3112
|
-
var material;
|
|
3113
|
-
switch(shader){
|
|
3114
|
-
case "pbr":
|
|
3115
|
-
material = new PBRMaterial(engine);
|
|
3116
|
-
break;
|
|
3117
|
-
case "pbr-specular":
|
|
3118
|
-
material = new PBRSpecularMaterial(engine);
|
|
3119
|
-
break;
|
|
3120
|
-
case "unlit":
|
|
3121
|
-
material = new UnlitMaterial(engine);
|
|
3122
|
-
break;
|
|
3123
|
-
case "blinn-phong":
|
|
3124
|
-
material = new BlinnPhongMaterial(engine);
|
|
3125
|
-
break;
|
|
3126
|
-
case "bake-pbr":
|
|
3127
|
-
// @todo refactor custom shader later
|
|
3128
|
-
// @ts-ignore
|
|
3129
|
-
material = new PBRBaseMaterial(engine, Shader.find("bake-pbr"));
|
|
3130
|
-
break;
|
|
3131
|
-
}
|
|
3182
|
+
var name = materialSchema.name, shader = materialSchema.shader, shaderData = materialSchema.shaderData, macros = materialSchema.macros, renderState = materialSchema.renderState;
|
|
3183
|
+
var material = new Material(engine, Shader.find(shader));
|
|
3132
3184
|
material.name = name;
|
|
3133
3185
|
var texturePromises = new Array();
|
|
3134
3186
|
var materialShaderData = material.shaderData;
|
|
@@ -3141,9 +3193,7 @@ var MaterialLoader = /*#__PURE__*/ function(Loader) {
|
|
|
3141
3193
|
materialShaderData.enableMacro(name1, value);
|
|
3142
3194
|
}
|
|
3143
3195
|
}
|
|
3144
|
-
|
|
3145
|
-
material[key1] = renderState[key1];
|
|
3146
|
-
}
|
|
3196
|
+
parseProperty(material, "renderState", renderState);
|
|
3147
3197
|
return Promise.all(texturePromises).then(function() {
|
|
3148
3198
|
resolve(material);
|
|
3149
3199
|
});
|
|
@@ -3243,7 +3293,7 @@ var BufferReader = /*#__PURE__*/ function() {
|
|
|
3243
3293
|
var strByteLength = this.nextUint16();
|
|
3244
3294
|
var uint8Array = new Uint8Array(this.buffer, this._offset, strByteLength);
|
|
3245
3295
|
this._offset += strByteLength;
|
|
3246
|
-
return
|
|
3296
|
+
return Utils.decodeText(uint8Array);
|
|
3247
3297
|
};
|
|
3248
3298
|
/**
|
|
3249
3299
|
* image data 放在最后
|
|
@@ -3328,8 +3378,8 @@ var FileHeader = /*#__PURE__*/ function() {
|
|
|
3328
3378
|
var typeUint8Array = new Uint8Array(arrayBuffer, 7, typeLen);
|
|
3329
3379
|
var nameLen = dataView.getUint16(7 + typeLen, true);
|
|
3330
3380
|
var nameUint8Array = new Uint8Array(arrayBuffer, 9 + typeLen, nameLen);
|
|
3331
|
-
var name =
|
|
3332
|
-
var type =
|
|
3381
|
+
var name = Utils.decodeText(nameUint8Array);
|
|
3382
|
+
var type = Utils.decodeText(typeUint8Array);
|
|
3333
3383
|
var header = new FileHeader();
|
|
3334
3384
|
header.totalLength = totalLen;
|
|
3335
3385
|
header.name = name;
|
|
@@ -3898,6 +3948,12 @@ AnimationClipDecoder = __decorate([
|
|
|
3898
3948
|
decoder("AnimationClip")
|
|
3899
3949
|
], AnimationClipDecoder);
|
|
3900
3950
|
|
|
3951
|
+
var SpecularMode;
|
|
3952
|
+
(function(SpecularMode) {
|
|
3953
|
+
SpecularMode["Sky"] = "Sky";
|
|
3954
|
+
SpecularMode["Custom"] = "Custom";
|
|
3955
|
+
})(SpecularMode || (SpecularMode = {}));
|
|
3956
|
+
|
|
3901
3957
|
var SceneParserContext = /*#__PURE__*/ function() {
|
|
3902
3958
|
function SceneParserContext(originalData, scene) {
|
|
3903
3959
|
this.originalData = originalData;
|
|
@@ -4025,7 +4081,7 @@ var MeshLoader$1 = /*#__PURE__*/ function(Loader) {
|
|
|
4025
4081
|
decode(data, resourceManager.engine).then(function(mesh) {
|
|
4026
4082
|
resolve(mesh);
|
|
4027
4083
|
});
|
|
4028
|
-
});
|
|
4084
|
+
}).catch(reject);
|
|
4029
4085
|
});
|
|
4030
4086
|
};
|
|
4031
4087
|
return MeshLoader;
|
|
@@ -4044,14 +4100,14 @@ var EditorTextureLoader = /*#__PURE__*/ function(Loader) {
|
|
|
4044
4100
|
var _proto = EditorTextureLoader.prototype;
|
|
4045
4101
|
_proto.load = function load(item, resourceManager) {
|
|
4046
4102
|
var _this = this;
|
|
4047
|
-
return new AssetPromise(function(resolve) {
|
|
4103
|
+
return new AssetPromise(function(resolve, reject) {
|
|
4048
4104
|
_this.request(item.url, {
|
|
4049
4105
|
type: "arraybuffer"
|
|
4050
4106
|
}).then(function(data) {
|
|
4051
4107
|
decode(data, resourceManager.engine).then(function(texture) {
|
|
4052
4108
|
resolve(texture);
|
|
4053
4109
|
});
|
|
4054
|
-
});
|
|
4110
|
+
}).catch(reject);
|
|
4055
4111
|
});
|
|
4056
4112
|
};
|
|
4057
4113
|
return EditorTextureLoader;
|
|
@@ -4180,7 +4236,7 @@ var SpriteAtlasLoader = /*#__PURE__*/ function(Loader) {
|
|
|
4180
4236
|
var atlasItem = atlasItems[i];
|
|
4181
4237
|
if (atlasItem.img) {
|
|
4182
4238
|
chainPromises.push(resourceManager.load({
|
|
4183
|
-
url: atlasItem.img,
|
|
4239
|
+
url: Utils.resolveAbsoluteUrl(item.url, atlasItem.img),
|
|
4184
4240
|
type: AssetType.Texture2D,
|
|
4185
4241
|
params: {
|
|
4186
4242
|
format: format,
|
|
@@ -4279,6 +4335,30 @@ SpriteLoader = __decorate([
|
|
|
4279
4335
|
], false)
|
|
4280
4336
|
], SpriteLoader);
|
|
4281
4337
|
|
|
4338
|
+
/**
|
|
4339
|
+
* @internal
|
|
4340
|
+
*/ var Texture2DContentRestorer = /*#__PURE__*/ function(ContentRestorer) {
|
|
4341
|
+
_inherits(Texture2DContentRestorer, ContentRestorer);
|
|
4342
|
+
function Texture2DContentRestorer(resource, url, requestConfig) {
|
|
4343
|
+
var _this;
|
|
4344
|
+
_this = ContentRestorer.call(this, resource) || this;
|
|
4345
|
+
_this.url = url;
|
|
4346
|
+
_this.requestConfig = requestConfig;
|
|
4347
|
+
return _this;
|
|
4348
|
+
}
|
|
4349
|
+
var _proto = Texture2DContentRestorer.prototype;
|
|
4350
|
+
_proto.restoreContent = function restoreContent() {
|
|
4351
|
+
var _this = this;
|
|
4352
|
+
return request(this.url, this.requestConfig).then(function(image) {
|
|
4353
|
+
var resource = _this.resource;
|
|
4354
|
+
resource.setImageSource(image);
|
|
4355
|
+
resource.generateMipmaps();
|
|
4356
|
+
return resource;
|
|
4357
|
+
});
|
|
4358
|
+
};
|
|
4359
|
+
return Texture2DContentRestorer;
|
|
4360
|
+
}(ContentRestorer);
|
|
4361
|
+
|
|
4282
4362
|
var Texture2DLoader = /*#__PURE__*/ function(Loader) {
|
|
4283
4363
|
_inherits(Texture2DLoader, Loader);
|
|
4284
4364
|
function Texture2DLoader() {
|
|
@@ -4288,19 +4368,20 @@ var Texture2DLoader = /*#__PURE__*/ function(Loader) {
|
|
|
4288
4368
|
_proto.load = function load(item, resourceManager) {
|
|
4289
4369
|
var _this = this;
|
|
4290
4370
|
return new AssetPromise(function(resolve, reject) {
|
|
4291
|
-
|
|
4371
|
+
var url = item.url;
|
|
4372
|
+
var requestConfig = _extends({}, item, {
|
|
4292
4373
|
type: "image"
|
|
4293
|
-
})
|
|
4294
|
-
|
|
4295
|
-
var params =
|
|
4296
|
-
var texture = new Texture2D(resourceManager.engine, image.width, image.height, params.format, params.mipmap);
|
|
4297
|
-
/** @ts-ignore */ if (!texture._platformTexture) return;
|
|
4374
|
+
});
|
|
4375
|
+
_this.request(url, requestConfig).then(function(image) {
|
|
4376
|
+
var params = item.params;
|
|
4377
|
+
var texture = new Texture2D(resourceManager.engine, image.width, image.height, params == null ? void 0 : params.format, params == null ? void 0 : params.mipmap);
|
|
4298
4378
|
texture.setImageSource(image);
|
|
4299
4379
|
texture.generateMipmaps();
|
|
4300
|
-
if (
|
|
4301
|
-
var
|
|
4302
|
-
texture.name =
|
|
4380
|
+
if (url.indexOf("data:") !== 0) {
|
|
4381
|
+
var index = url.lastIndexOf("/");
|
|
4382
|
+
texture.name = url.substring(index + 1);
|
|
4303
4383
|
}
|
|
4384
|
+
resourceManager.addContentRestorer(new Texture2DContentRestorer(texture, url, requestConfig));
|
|
4304
4385
|
resolve(texture);
|
|
4305
4386
|
}).catch(function(e) {
|
|
4306
4387
|
reject(e);
|
|
@@ -4318,6 +4399,38 @@ Texture2DLoader = __decorate([
|
|
|
4318
4399
|
])
|
|
4319
4400
|
], Texture2DLoader);
|
|
4320
4401
|
|
|
4402
|
+
/**
|
|
4403
|
+
* @internal
|
|
4404
|
+
*/ var TextureCubeContentRestorer = /*#__PURE__*/ function(ContentRestorer) {
|
|
4405
|
+
_inherits(TextureCubeContentRestorer, ContentRestorer);
|
|
4406
|
+
function TextureCubeContentRestorer(resource, urls, requestConfig) {
|
|
4407
|
+
var _this;
|
|
4408
|
+
_this = ContentRestorer.call(this, resource) || this;
|
|
4409
|
+
_this.urls = urls;
|
|
4410
|
+
_this.requestConfig = requestConfig;
|
|
4411
|
+
return _this;
|
|
4412
|
+
}
|
|
4413
|
+
var _proto = TextureCubeContentRestorer.prototype;
|
|
4414
|
+
_proto.restoreContent = function restoreContent() {
|
|
4415
|
+
var _this = this;
|
|
4416
|
+
return new AssetPromise(function(resolve, reject) {
|
|
4417
|
+
Promise.all(_this.urls.map(function(url) {
|
|
4418
|
+
return request(url, _this.requestConfig);
|
|
4419
|
+
})).then(function(images) {
|
|
4420
|
+
var resource = _this.resource;
|
|
4421
|
+
for(var faceIndex = 0; faceIndex < 6; faceIndex++){
|
|
4422
|
+
resource.setImageSource(TextureCubeFace.PositiveX + faceIndex, images[faceIndex], 0);
|
|
4423
|
+
}
|
|
4424
|
+
resource.generateMipmaps();
|
|
4425
|
+
resolve(resource);
|
|
4426
|
+
}).catch(function(e) {
|
|
4427
|
+
reject(e);
|
|
4428
|
+
});
|
|
4429
|
+
});
|
|
4430
|
+
};
|
|
4431
|
+
return TextureCubeContentRestorer;
|
|
4432
|
+
}(ContentRestorer);
|
|
4433
|
+
|
|
4321
4434
|
var TextureCubeLoader = /*#__PURE__*/ function(Loader) {
|
|
4322
4435
|
_inherits(TextureCubeLoader, Loader);
|
|
4323
4436
|
function TextureCubeLoader() {
|
|
@@ -4327,23 +4440,25 @@ var TextureCubeLoader = /*#__PURE__*/ function(Loader) {
|
|
|
4327
4440
|
_proto.load = function load(item, resourceManager) {
|
|
4328
4441
|
var _this = this;
|
|
4329
4442
|
return new AssetPromise(function(resolve, reject) {
|
|
4330
|
-
|
|
4331
|
-
|
|
4332
|
-
|
|
4333
|
-
|
|
4443
|
+
var urls = item.urls;
|
|
4444
|
+
var requestConfig = _extends({}, item, {
|
|
4445
|
+
type: "image"
|
|
4446
|
+
});
|
|
4447
|
+
Promise.all(urls.map(function(url) {
|
|
4448
|
+
return _this.request(url, requestConfig);
|
|
4334
4449
|
})).then(function(images) {
|
|
4335
4450
|
var _images_ = images[0], width = _images_.width, height = _images_.height;
|
|
4336
4451
|
if (width !== height) {
|
|
4337
4452
|
console.error("The cube texture must have the same width and height");
|
|
4338
4453
|
return;
|
|
4339
4454
|
}
|
|
4340
|
-
var
|
|
4341
|
-
/** @ts-ignore */ if (!tex._platformTexture) return;
|
|
4455
|
+
var texture = new TextureCube(resourceManager.engine, width);
|
|
4342
4456
|
for(var faceIndex = 0; faceIndex < 6; faceIndex++){
|
|
4343
|
-
|
|
4457
|
+
texture.setImageSource(TextureCubeFace.PositiveX + faceIndex, images[faceIndex], 0);
|
|
4344
4458
|
}
|
|
4345
|
-
|
|
4346
|
-
|
|
4459
|
+
texture.generateMipmaps();
|
|
4460
|
+
resourceManager.addContentRestorer(new TextureCubeContentRestorer(texture, urls, requestConfig));
|
|
4461
|
+
resolve(texture);
|
|
4347
4462
|
}).catch(function(e) {
|
|
4348
4463
|
reject(e);
|
|
4349
4464
|
});
|
|
@@ -4357,6 +4472,30 @@ TextureCubeLoader = __decorate([
|
|
|
4357
4472
|
])
|
|
4358
4473
|
], TextureCubeLoader);
|
|
4359
4474
|
|
|
4475
|
+
var AnimationClipLoader = /*#__PURE__*/ function(Loader) {
|
|
4476
|
+
_inherits(AnimationClipLoader, Loader);
|
|
4477
|
+
function AnimationClipLoader() {
|
|
4478
|
+
return Loader.apply(this, arguments);
|
|
4479
|
+
}
|
|
4480
|
+
var _proto = AnimationClipLoader.prototype;
|
|
4481
|
+
_proto.load = function load(item, resourceManager) {
|
|
4482
|
+
var _this = this;
|
|
4483
|
+
return new AssetPromise(function(resolve, reject) {
|
|
4484
|
+
_this.request(item.url, _extends({}, item, {
|
|
4485
|
+
type: "arraybuffer"
|
|
4486
|
+
})).then(function(data) {
|
|
4487
|
+
return decode(data, resourceManager.engine).then(resolve);
|
|
4488
|
+
}).catch(reject);
|
|
4489
|
+
});
|
|
4490
|
+
};
|
|
4491
|
+
return AnimationClipLoader;
|
|
4492
|
+
}(Loader);
|
|
4493
|
+
AnimationClipLoader = __decorate([
|
|
4494
|
+
resourceLoader(AssetType.AnimationClip, [
|
|
4495
|
+
"ani"
|
|
4496
|
+
])
|
|
4497
|
+
], AnimationClipLoader);
|
|
4498
|
+
|
|
4360
4499
|
var SceneLoader = /*#__PURE__*/ function(Loader) {
|
|
4361
4500
|
_inherits(SceneLoader, Loader);
|
|
4362
4501
|
function SceneLoader() {
|
|
@@ -4373,16 +4512,32 @@ var SceneLoader = /*#__PURE__*/ function(Loader) {
|
|
|
4373
4512
|
// @ts-ignore
|
|
4374
4513
|
engine.resourceManager.initVirtualResources(data.files);
|
|
4375
4514
|
return SceneParser.parse(engine, data).then(function(scene) {
|
|
4515
|
+
var promises = [];
|
|
4376
4516
|
// parse ambient light
|
|
4377
4517
|
var ambient = data.scene.ambient;
|
|
4378
|
-
var
|
|
4379
|
-
if (ambient.
|
|
4380
|
-
|
|
4381
|
-
|
|
4382
|
-
|
|
4518
|
+
var useCustomAmbient = ambient.specularMode === "Custom";
|
|
4519
|
+
if (useCustomAmbient && ambient.customAmbientLight) {
|
|
4520
|
+
// @ts-ignore
|
|
4521
|
+
// prettier-ignore
|
|
4522
|
+
var customAmbientPromise = resourceManager.getResourceByRef(ambient.customAmbientLight).then(function(ambientLight) {
|
|
4523
|
+
scene.ambientLight = ambientLight;
|
|
4524
|
+
scene.ambientLight.diffuseIntensity = ambient.diffuseIntensity;
|
|
4525
|
+
scene.ambientLight.specularIntensity = ambient.specularIntensity;
|
|
4526
|
+
scene.ambientLight.diffuseMode = ambient.diffuseMode;
|
|
4527
|
+
scene.ambientLight.diffuseSolidColor.copyFrom(ambient.diffuseSolidColor);
|
|
4528
|
+
});
|
|
4529
|
+
promises.push(customAmbientPromise);
|
|
4530
|
+
} else if (!useCustomAmbient && ambient.ambientLight) {
|
|
4531
|
+
// @ts-ignore
|
|
4532
|
+
// prettier-ignore
|
|
4533
|
+
var ambientLightPromise = resourceManager.getResourceByRef(ambient.ambientLight).then(function(ambientLight) {
|
|
4534
|
+
scene.ambientLight = ambientLight;
|
|
4383
4535
|
scene.ambientLight.diffuseIntensity = ambient.diffuseIntensity;
|
|
4384
4536
|
scene.ambientLight.specularIntensity = ambient.specularIntensity;
|
|
4537
|
+
scene.ambientLight.diffuseMode = ambient.diffuseMode;
|
|
4538
|
+
scene.ambientLight.diffuseSolidColor.copyFrom(ambient.diffuseSolidColor);
|
|
4385
4539
|
});
|
|
4540
|
+
promises.push(ambientLightPromise);
|
|
4386
4541
|
} else {
|
|
4387
4542
|
scene.ambientLight.diffuseIntensity = ambient.diffuseIntensity;
|
|
4388
4543
|
scene.ambientLight.specularIntensity = ambient.specularIntensity;
|
|
@@ -4390,30 +4545,34 @@ var SceneLoader = /*#__PURE__*/ function(Loader) {
|
|
|
4390
4545
|
}
|
|
4391
4546
|
var background = data.scene.background;
|
|
4392
4547
|
scene.background.mode = background.mode;
|
|
4393
|
-
var backgroundPromise = Promise.resolve();
|
|
4394
4548
|
switch(scene.background.mode){
|
|
4395
4549
|
case BackgroundMode.SolidColor:
|
|
4396
4550
|
scene.background.solidColor.copyFrom(background.color);
|
|
4397
4551
|
break;
|
|
4398
4552
|
case BackgroundMode.Sky:
|
|
4399
|
-
if (background.
|
|
4553
|
+
if (background.skyMesh && background.skyMaterial) {
|
|
4400
4554
|
// @ts-ignore
|
|
4401
|
-
|
|
4402
|
-
|
|
4403
|
-
var skyMaterial = new SkyBoxMaterial(engine);
|
|
4404
|
-
skyMaterial.textureCubeMap = light.specularTexture;
|
|
4405
|
-
skyMaterial.textureDecodeRGBM = true;
|
|
4406
|
-
sky.material = skyMaterial;
|
|
4407
|
-
sky.mesh = PrimitiveMesh.createCuboid(engine, 1, 1, 1);
|
|
4555
|
+
var skyMeshPromise = resourceManager.getResourceByRef(background.skyMesh).then(function(mesh) {
|
|
4556
|
+
scene.background.sky.mesh = mesh;
|
|
4408
4557
|
});
|
|
4558
|
+
// @ts-ignore
|
|
4559
|
+
// prettier-ignore
|
|
4560
|
+
var skyMaterialPromise = resourceManager.getResourceByRef(background.skyMaterial).then(function(material) {
|
|
4561
|
+
scene.background.sky.material = material;
|
|
4562
|
+
});
|
|
4563
|
+
promises.push(skyMeshPromise, skyMaterialPromise);
|
|
4564
|
+
} else {
|
|
4565
|
+
Logger.warn("Sky background mode requires skyMesh and skyMaterial");
|
|
4409
4566
|
}
|
|
4410
4567
|
break;
|
|
4411
4568
|
case BackgroundMode.Texture:
|
|
4412
4569
|
if (background.texture) {
|
|
4413
4570
|
// @ts-ignore
|
|
4414
|
-
|
|
4571
|
+
// prettier-ignore
|
|
4572
|
+
var backgroundPromise = resourceManager.getResourceByRef(background.texture).then(function(texture) {
|
|
4415
4573
|
scene.background.texture = texture;
|
|
4416
4574
|
});
|
|
4575
|
+
promises.push(backgroundPromise);
|
|
4417
4576
|
}
|
|
4418
4577
|
break;
|
|
4419
4578
|
}
|
|
@@ -4425,10 +4584,7 @@ var SceneLoader = /*#__PURE__*/ function(Loader) {
|
|
|
4425
4584
|
if (shadow.shadowDistance != undefined) scene.shadowDistance = shadow.shadowDistance;
|
|
4426
4585
|
if (shadow.shadowCascades != undefined) scene.shadowCascades = shadow.shadowCascades;
|
|
4427
4586
|
}
|
|
4428
|
-
return Promise.all(
|
|
4429
|
-
ambientLightPromise,
|
|
4430
|
-
backgroundPromise
|
|
4431
|
-
]).then(function() {
|
|
4587
|
+
return Promise.all(promises).then(function() {
|
|
4432
4588
|
resolve(scene);
|
|
4433
4589
|
});
|
|
4434
4590
|
});
|
|
@@ -4457,5 +4613,390 @@ ReflectionParser.registerCustomParseComponent("TextRenderer", /*#__PURE__*/ _asy
|
|
|
4457
4613
|
});
|
|
4458
4614
|
}));
|
|
4459
4615
|
|
|
4460
|
-
|
|
4616
|
+
var _KHR_draco_mesh_compression;
|
|
4617
|
+
var KHR_draco_mesh_compression = (_KHR_draco_mesh_compression = /*#__PURE__*/ function(GLTFExtensionParser) {
|
|
4618
|
+
_inherits(KHR_draco_mesh_compression1, GLTFExtensionParser);
|
|
4619
|
+
function KHR_draco_mesh_compression1() {
|
|
4620
|
+
return GLTFExtensionParser.apply(this, arguments);
|
|
4621
|
+
}
|
|
4622
|
+
var _proto = KHR_draco_mesh_compression1.prototype;
|
|
4623
|
+
_proto.initialize = function initialize() {
|
|
4624
|
+
if (!KHR_draco_mesh_compression._decoder) {
|
|
4625
|
+
KHR_draco_mesh_compression._decoder = new DRACODecoder();
|
|
4626
|
+
}
|
|
4627
|
+
};
|
|
4628
|
+
_proto.createAndParse = function createAndParse(context, schema, glTFPrimitive, glTFMesh) {
|
|
4629
|
+
var _this = this;
|
|
4630
|
+
var glTF = context.glTF, engine = context.glTFResource.engine;
|
|
4631
|
+
var bufferViews = glTF.bufferViews, accessors = glTF.accessors;
|
|
4632
|
+
var bufferViewIndex = schema.bufferView, gltfAttributeMap = schema.attributes;
|
|
4633
|
+
var attributeMap = {};
|
|
4634
|
+
var attributeTypeMap = {};
|
|
4635
|
+
for(var attributeName in gltfAttributeMap){
|
|
4636
|
+
attributeMap[attributeName] = gltfAttributeMap[attributeName];
|
|
4637
|
+
}
|
|
4638
|
+
for(var attributeName1 in glTFPrimitive.attributes){
|
|
4639
|
+
if (gltfAttributeMap[attributeName1] !== undefined) {
|
|
4640
|
+
var accessorDef = accessors[glTFPrimitive.attributes[attributeName1]];
|
|
4641
|
+
attributeTypeMap[attributeName1] = GLTFUtils.getComponentType(accessorDef.componentType).name;
|
|
4642
|
+
}
|
|
4643
|
+
}
|
|
4644
|
+
var indexAccessor = accessors[glTFPrimitive.indices];
|
|
4645
|
+
var indexType = GLTFUtils.getComponentType(indexAccessor.componentType).name;
|
|
4646
|
+
var taskConfig = {
|
|
4647
|
+
attributeIDs: attributeMap,
|
|
4648
|
+
attributeTypes: attributeTypeMap,
|
|
4649
|
+
useUniqueIDs: true,
|
|
4650
|
+
indexType: indexType
|
|
4651
|
+
};
|
|
4652
|
+
return context.getBuffers().then(function(buffers) {
|
|
4653
|
+
var buffer = GLTFUtils.getBufferViewData(bufferViews[bufferViewIndex], buffers);
|
|
4654
|
+
return KHR_draco_mesh_compression._decoder.decode(buffer, taskConfig).then(function(decodedGeometry) {
|
|
4655
|
+
var mesh = new ModelMesh(engine, glTFMesh.name);
|
|
4656
|
+
return _this._parseMeshFromGLTFPrimitiveDraco(mesh, glTFMesh, glTFPrimitive, glTF, function(attributeSemantic) {
|
|
4657
|
+
for(var j = 0; j < decodedGeometry.attributes.length; j++){
|
|
4658
|
+
if (decodedGeometry.attributes[j].name === attributeSemantic) {
|
|
4659
|
+
return decodedGeometry.attributes[j].array;
|
|
4660
|
+
}
|
|
4661
|
+
}
|
|
4662
|
+
return null;
|
|
4663
|
+
}, function(attributeSemantic, shapeIndex) {
|
|
4664
|
+
throw "BlendShape animation is not supported when using draco.";
|
|
4665
|
+
}, function() {
|
|
4666
|
+
return decodedGeometry.index.array;
|
|
4667
|
+
}, context.keepMeshData);
|
|
4668
|
+
});
|
|
4669
|
+
});
|
|
4670
|
+
};
|
|
4671
|
+
_proto._parseMeshFromGLTFPrimitiveDraco = function _parseMeshFromGLTFPrimitiveDraco(mesh, gltfMesh, gltfPrimitive, gltf, getVertexBufferData, getBlendShapeData, getIndexBufferData, keepMeshData) {
|
|
4672
|
+
var attributes = gltfPrimitive.attributes, targets = gltfPrimitive.targets, indices = gltfPrimitive.indices, mode = gltfPrimitive.mode;
|
|
4673
|
+
var vertexCount;
|
|
4674
|
+
var accessors = gltf.accessors;
|
|
4675
|
+
var accessor = accessors[attributes["POSITION"]];
|
|
4676
|
+
var positionBuffer = getVertexBufferData("POSITION");
|
|
4677
|
+
var positions = GLTFUtils.floatBufferToVector3Array(positionBuffer);
|
|
4678
|
+
mesh.setPositions(positions);
|
|
4679
|
+
var bounds = mesh.bounds;
|
|
4680
|
+
vertexCount = accessor.count;
|
|
4681
|
+
if (accessor.min && accessor.max) {
|
|
4682
|
+
bounds.min.copyFromArray(accessor.min);
|
|
4683
|
+
bounds.max.copyFromArray(accessor.max);
|
|
4684
|
+
} else {
|
|
4685
|
+
var position = KHR_draco_mesh_compression._tempVector3;
|
|
4686
|
+
var min = bounds.min, max = bounds.max;
|
|
4687
|
+
min.set(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
|
|
4688
|
+
max.set(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
|
|
4689
|
+
var stride = positionBuffer.length / vertexCount;
|
|
4690
|
+
for(var j = 0; j < vertexCount; j++){
|
|
4691
|
+
var offset = j * stride;
|
|
4692
|
+
position.copyFromArray(positionBuffer, offset);
|
|
4693
|
+
Vector3.min(min, position, min);
|
|
4694
|
+
Vector3.max(max, position, max);
|
|
4695
|
+
}
|
|
4696
|
+
}
|
|
4697
|
+
for(var attributeSemantic in attributes){
|
|
4698
|
+
if (attributeSemantic === "POSITION") {
|
|
4699
|
+
continue;
|
|
4700
|
+
}
|
|
4701
|
+
var bufferData = getVertexBufferData(attributeSemantic);
|
|
4702
|
+
switch(attributeSemantic){
|
|
4703
|
+
case "NORMAL":
|
|
4704
|
+
var normals = GLTFUtils.floatBufferToVector3Array(bufferData);
|
|
4705
|
+
mesh.setNormals(normals);
|
|
4706
|
+
break;
|
|
4707
|
+
case "TEXCOORD_0":
|
|
4708
|
+
var texturecoords = GLTFUtils.floatBufferToVector2Array(bufferData);
|
|
4709
|
+
mesh.setUVs(texturecoords, 0);
|
|
4710
|
+
break;
|
|
4711
|
+
case "TEXCOORD_1":
|
|
4712
|
+
var texturecoords1 = GLTFUtils.floatBufferToVector2Array(bufferData);
|
|
4713
|
+
mesh.setUVs(texturecoords1, 1);
|
|
4714
|
+
break;
|
|
4715
|
+
case "TEXCOORD_2":
|
|
4716
|
+
var texturecoords2 = GLTFUtils.floatBufferToVector2Array(bufferData);
|
|
4717
|
+
mesh.setUVs(texturecoords2, 2);
|
|
4718
|
+
break;
|
|
4719
|
+
case "TEXCOORD_3":
|
|
4720
|
+
var texturecoords3 = GLTFUtils.floatBufferToVector2Array(bufferData);
|
|
4721
|
+
mesh.setUVs(texturecoords3, 3);
|
|
4722
|
+
break;
|
|
4723
|
+
case "TEXCOORD_4":
|
|
4724
|
+
var texturecoords4 = GLTFUtils.floatBufferToVector2Array(bufferData);
|
|
4725
|
+
mesh.setUVs(texturecoords4, 4);
|
|
4726
|
+
break;
|
|
4727
|
+
case "TEXCOORD_5":
|
|
4728
|
+
var texturecoords5 = GLTFUtils.floatBufferToVector2Array(bufferData);
|
|
4729
|
+
mesh.setUVs(texturecoords5, 5);
|
|
4730
|
+
break;
|
|
4731
|
+
case "TEXCOORD_6":
|
|
4732
|
+
var texturecoords6 = GLTFUtils.floatBufferToVector2Array(bufferData);
|
|
4733
|
+
mesh.setUVs(texturecoords6, 6);
|
|
4734
|
+
break;
|
|
4735
|
+
case "TEXCOORD_7":
|
|
4736
|
+
var texturecoords7 = GLTFUtils.floatBufferToVector2Array(bufferData);
|
|
4737
|
+
mesh.setUVs(texturecoords7, 7);
|
|
4738
|
+
break;
|
|
4739
|
+
case "COLOR_0":
|
|
4740
|
+
var colors = GLTFUtils.floatBufferToColorArray(bufferData, accessors[attributes["COLOR_0"]].type === AccessorType.VEC3);
|
|
4741
|
+
mesh.setColors(colors);
|
|
4742
|
+
break;
|
|
4743
|
+
case "TANGENT":
|
|
4744
|
+
var tangents = GLTFUtils.floatBufferToVector4Array(bufferData);
|
|
4745
|
+
mesh.setTangents(tangents);
|
|
4746
|
+
break;
|
|
4747
|
+
case "JOINTS_0":
|
|
4748
|
+
var joints = GLTFUtils.floatBufferToVector4Array(bufferData);
|
|
4749
|
+
mesh.setBoneIndices(joints);
|
|
4750
|
+
break;
|
|
4751
|
+
case "WEIGHTS_0":
|
|
4752
|
+
var weights = GLTFUtils.floatBufferToVector4Array(bufferData);
|
|
4753
|
+
mesh.setBoneWeights(weights);
|
|
4754
|
+
break;
|
|
4755
|
+
}
|
|
4756
|
+
}
|
|
4757
|
+
// Indices
|
|
4758
|
+
if (indices !== undefined) {
|
|
4759
|
+
var indexAccessor = gltf.accessors[indices];
|
|
4760
|
+
var indexData = getIndexBufferData();
|
|
4761
|
+
mesh.setIndices(indexData);
|
|
4762
|
+
mesh.addSubMesh(0, indexAccessor.count, mode);
|
|
4763
|
+
} else {
|
|
4764
|
+
mesh.addSubMesh(0, vertexCount, mode);
|
|
4765
|
+
}
|
|
4766
|
+
// BlendShapes
|
|
4767
|
+
targets && GLTFMeshParser._createBlendShape(mesh, null, gltfMesh, accessors, targets, getBlendShapeData);
|
|
4768
|
+
mesh.uploadData(!keepMeshData);
|
|
4769
|
+
return Promise.resolve(mesh);
|
|
4770
|
+
};
|
|
4771
|
+
return KHR_draco_mesh_compression1;
|
|
4772
|
+
}(GLTFExtensionParser), function() {
|
|
4773
|
+
_KHR_draco_mesh_compression._tempVector3 = new Vector3();
|
|
4774
|
+
}(), _KHR_draco_mesh_compression);
|
|
4775
|
+
KHR_draco_mesh_compression = __decorate([
|
|
4776
|
+
registerGLTFExtension("KHR_draco_mesh_compression", GLTFExtensionMode.CreateAndParse)
|
|
4777
|
+
], KHR_draco_mesh_compression);
|
|
4778
|
+
|
|
4779
|
+
var KHR_lights_punctual = /*#__PURE__*/ function(GLTFExtensionParser) {
|
|
4780
|
+
_inherits(KHR_lights_punctual, GLTFExtensionParser);
|
|
4781
|
+
function KHR_lights_punctual() {
|
|
4782
|
+
return GLTFExtensionParser.apply(this, arguments);
|
|
4783
|
+
}
|
|
4784
|
+
var _proto = KHR_lights_punctual.prototype;
|
|
4785
|
+
_proto.additiveParse = function additiveParse(context, entity, extensionSchema) {
|
|
4786
|
+
var lightsSchema = context.glTF.extensions.KHR_lights_punctual.lights;
|
|
4787
|
+
var lightSchema = lightsSchema[extensionSchema.light];
|
|
4788
|
+
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;
|
|
4789
|
+
var glTFResource = context.glTFResource;
|
|
4790
|
+
var light;
|
|
4791
|
+
if (type === "directional") {
|
|
4792
|
+
light = entity.addComponent(DirectLight);
|
|
4793
|
+
} else if (type === "point") {
|
|
4794
|
+
light = entity.addComponent(PointLight);
|
|
4795
|
+
} else if (type === "spot") {
|
|
4796
|
+
light = entity.addComponent(SpotLight);
|
|
4797
|
+
}
|
|
4798
|
+
if (color) {
|
|
4799
|
+
light.color.set(color[0], color[1], color[2], 1);
|
|
4800
|
+
}
|
|
4801
|
+
light.intensity = intensity;
|
|
4802
|
+
if (range && !_instanceof(light, DirectLight)) {
|
|
4803
|
+
light.distance = range;
|
|
4804
|
+
}
|
|
4805
|
+
if (spot && _instanceof(light, SpotLight)) {
|
|
4806
|
+
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;
|
|
4807
|
+
light.angle = innerConeAngle;
|
|
4808
|
+
light.penumbra = outerConeAngle - innerConeAngle;
|
|
4809
|
+
}
|
|
4810
|
+
if (!glTFResource.lights) glTFResource.lights = [];
|
|
4811
|
+
glTFResource.lights.push(light);
|
|
4812
|
+
};
|
|
4813
|
+
return KHR_lights_punctual;
|
|
4814
|
+
}(GLTFExtensionParser);
|
|
4815
|
+
KHR_lights_punctual = __decorate([
|
|
4816
|
+
registerGLTFExtension("KHR_lights_punctual", GLTFExtensionMode.AdditiveParse)
|
|
4817
|
+
], KHR_lights_punctual);
|
|
4818
|
+
|
|
4819
|
+
var KHR_materials_clearcoat = /*#__PURE__*/ function(GLTFExtensionParser) {
|
|
4820
|
+
_inherits(KHR_materials_clearcoat, GLTFExtensionParser);
|
|
4821
|
+
function KHR_materials_clearcoat() {
|
|
4822
|
+
return GLTFExtensionParser.apply(this, arguments);
|
|
4823
|
+
}
|
|
4824
|
+
var _proto = KHR_materials_clearcoat.prototype;
|
|
4825
|
+
_proto.additiveParse = function additiveParse(context, material, schema) {
|
|
4826
|
+
var textures = context.glTFResource.textures;
|
|
4827
|
+
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;
|
|
4828
|
+
material.clearCoat = clearcoatFactor;
|
|
4829
|
+
material.clearCoatRoughness = clearcoatRoughnessFactor;
|
|
4830
|
+
if (clearcoatTexture) {
|
|
4831
|
+
material.clearCoatTexture = textures[clearcoatTexture.index];
|
|
4832
|
+
GLTFMaterialParser._checkOtherTextureTransform(clearcoatTexture, "Clear coat");
|
|
4833
|
+
}
|
|
4834
|
+
if (clearcoatRoughnessTexture) {
|
|
4835
|
+
material.clearCoatRoughnessTexture = textures[clearcoatRoughnessTexture.index];
|
|
4836
|
+
GLTFMaterialParser._checkOtherTextureTransform(clearcoatRoughnessTexture, "Clear coat roughness");
|
|
4837
|
+
}
|
|
4838
|
+
if (clearcoatNormalTexture) {
|
|
4839
|
+
material.clearCoatNormalTexture = textures[clearcoatNormalTexture.index];
|
|
4840
|
+
GLTFMaterialParser._checkOtherTextureTransform(clearcoatNormalTexture, "Clear coat normal");
|
|
4841
|
+
}
|
|
4842
|
+
};
|
|
4843
|
+
return KHR_materials_clearcoat;
|
|
4844
|
+
}(GLTFExtensionParser);
|
|
4845
|
+
KHR_materials_clearcoat = __decorate([
|
|
4846
|
+
registerGLTFExtension("KHR_materials_clearcoat", GLTFExtensionMode.AdditiveParse)
|
|
4847
|
+
], KHR_materials_clearcoat);
|
|
4848
|
+
|
|
4849
|
+
var KHR_materials_ior = /*#__PURE__*/ function(GLTFExtensionParser) {
|
|
4850
|
+
_inherits(KHR_materials_ior, GLTFExtensionParser);
|
|
4851
|
+
function KHR_materials_ior() {
|
|
4852
|
+
return GLTFExtensionParser.apply(this, arguments);
|
|
4853
|
+
}
|
|
4854
|
+
var _proto = KHR_materials_ior.prototype;
|
|
4855
|
+
_proto.additiveParse = function additiveParse(context, material, schema) {
|
|
4856
|
+
var _schema_ior = schema.ior, ior = _schema_ior === void 0 ? 1.5 : _schema_ior;
|
|
4857
|
+
material.ior = ior;
|
|
4858
|
+
};
|
|
4859
|
+
return KHR_materials_ior;
|
|
4860
|
+
}(GLTFExtensionParser);
|
|
4861
|
+
KHR_materials_ior = __decorate([
|
|
4862
|
+
registerGLTFExtension("KHR_materials_ior", GLTFExtensionMode.AdditiveParse)
|
|
4863
|
+
], KHR_materials_ior);
|
|
4864
|
+
|
|
4865
|
+
var KHR_materials_pbrSpecularGlossiness = /*#__PURE__*/ function(GLTFExtensionParser) {
|
|
4866
|
+
_inherits(KHR_materials_pbrSpecularGlossiness, GLTFExtensionParser);
|
|
4867
|
+
function KHR_materials_pbrSpecularGlossiness() {
|
|
4868
|
+
return GLTFExtensionParser.apply(this, arguments);
|
|
4869
|
+
}
|
|
4870
|
+
var _proto = KHR_materials_pbrSpecularGlossiness.prototype;
|
|
4871
|
+
_proto.createAndParse = function createAndParse(context, schema, ownerSchema) {
|
|
4872
|
+
var _context_glTFResource = context.glTFResource, engine = _context_glTFResource.engine, textures = _context_glTFResource.textures;
|
|
4873
|
+
var material = new PBRSpecularMaterial(engine);
|
|
4874
|
+
var diffuseFactor = schema.diffuseFactor, diffuseTexture = schema.diffuseTexture, specularFactor = schema.specularFactor, glossinessFactor = schema.glossinessFactor, specularGlossinessTexture = schema.specularGlossinessTexture;
|
|
4875
|
+
if (diffuseFactor) {
|
|
4876
|
+
material.baseColor = new Color(Color.linearToGammaSpace(diffuseFactor[0]), Color.linearToGammaSpace(diffuseFactor[1]), Color.linearToGammaSpace(diffuseFactor[2]), diffuseFactor[3]);
|
|
4877
|
+
}
|
|
4878
|
+
if (diffuseTexture) {
|
|
4879
|
+
material.baseTexture = textures[diffuseTexture.index];
|
|
4880
|
+
GLTFParser.executeExtensionsAdditiveAndParse(diffuseTexture.extensions, context, material, diffuseTexture);
|
|
4881
|
+
}
|
|
4882
|
+
if (specularFactor) {
|
|
4883
|
+
material.specularColor = new Color(Color.linearToGammaSpace(specularFactor[0]), Color.linearToGammaSpace(specularFactor[1]), Color.linearToGammaSpace(specularFactor[2]));
|
|
4884
|
+
}
|
|
4885
|
+
if (glossinessFactor !== undefined) {
|
|
4886
|
+
material.glossiness = glossinessFactor;
|
|
4887
|
+
}
|
|
4888
|
+
if (specularGlossinessTexture) {
|
|
4889
|
+
material.specularGlossinessTexture = textures[specularGlossinessTexture.index];
|
|
4890
|
+
GLTFMaterialParser._checkOtherTextureTransform(specularGlossinessTexture, "Specular glossiness");
|
|
4891
|
+
}
|
|
4892
|
+
material.name = ownerSchema.name;
|
|
4893
|
+
GLTFMaterialParser._parseStandardProperty(context, material, ownerSchema);
|
|
4894
|
+
return material;
|
|
4895
|
+
};
|
|
4896
|
+
return KHR_materials_pbrSpecularGlossiness;
|
|
4897
|
+
}(GLTFExtensionParser);
|
|
4898
|
+
KHR_materials_pbrSpecularGlossiness = __decorate([
|
|
4899
|
+
registerGLTFExtension("KHR_materials_pbrSpecularGlossiness", GLTFExtensionMode.CreateAndParse)
|
|
4900
|
+
], KHR_materials_pbrSpecularGlossiness);
|
|
4901
|
+
|
|
4902
|
+
var KHR_materials_unlit = /*#__PURE__*/ function(GLTFExtensionParser) {
|
|
4903
|
+
_inherits(KHR_materials_unlit, GLTFExtensionParser);
|
|
4904
|
+
function KHR_materials_unlit() {
|
|
4905
|
+
return GLTFExtensionParser.apply(this, arguments);
|
|
4906
|
+
}
|
|
4907
|
+
var _proto = KHR_materials_unlit.prototype;
|
|
4908
|
+
_proto.createAndParse = function createAndParse(context, _, ownerSchema) {
|
|
4909
|
+
var engine = context.glTFResource.engine;
|
|
4910
|
+
var material = new UnlitMaterial(engine);
|
|
4911
|
+
material.name = ownerSchema.name;
|
|
4912
|
+
GLTFMaterialParser._parseStandardProperty(context, material, ownerSchema);
|
|
4913
|
+
return material;
|
|
4914
|
+
};
|
|
4915
|
+
return KHR_materials_unlit;
|
|
4916
|
+
}(GLTFExtensionParser);
|
|
4917
|
+
KHR_materials_unlit = __decorate([
|
|
4918
|
+
registerGLTFExtension("KHR_materials_unlit", GLTFExtensionMode.CreateAndParse)
|
|
4919
|
+
], KHR_materials_unlit);
|
|
4920
|
+
|
|
4921
|
+
var KHR_mesh_quantization = /*#__PURE__*/ function(GLTFExtensionParser) {
|
|
4922
|
+
_inherits(KHR_mesh_quantization, GLTFExtensionParser);
|
|
4923
|
+
function KHR_mesh_quantization() {
|
|
4924
|
+
return GLTFExtensionParser.apply(this, arguments);
|
|
4925
|
+
}
|
|
4926
|
+
return KHR_mesh_quantization;
|
|
4927
|
+
}(GLTFExtensionParser);
|
|
4928
|
+
KHR_mesh_quantization = __decorate([
|
|
4929
|
+
registerGLTFExtension("KHR_mesh_quantization", GLTFExtensionMode.AdditiveParse)
|
|
4930
|
+
], KHR_mesh_quantization);
|
|
4931
|
+
|
|
4932
|
+
var KHR_texture_transform = /*#__PURE__*/ function(GLTFExtensionParser) {
|
|
4933
|
+
_inherits(KHR_texture_transform, GLTFExtensionParser);
|
|
4934
|
+
function KHR_texture_transform() {
|
|
4935
|
+
return GLTFExtensionParser.apply(this, arguments);
|
|
4936
|
+
}
|
|
4937
|
+
var _proto = KHR_texture_transform.prototype;
|
|
4938
|
+
_proto.additiveParse = function additiveParse(context, material, schema) {
|
|
4939
|
+
var offset = schema.offset, rotation = schema.rotation, scale = schema.scale, texCoord = schema.texCoord;
|
|
4940
|
+
if (offset) {
|
|
4941
|
+
material.tilingOffset.z = offset[0];
|
|
4942
|
+
material.tilingOffset.w = offset[1];
|
|
4943
|
+
}
|
|
4944
|
+
if (scale) {
|
|
4945
|
+
material.tilingOffset.x = scale[0];
|
|
4946
|
+
material.tilingOffset.y = scale[1];
|
|
4947
|
+
}
|
|
4948
|
+
if (rotation) {
|
|
4949
|
+
Logger.warn("rotation in KHR_texture_transform is not supported now");
|
|
4950
|
+
}
|
|
4951
|
+
if (texCoord) {
|
|
4952
|
+
Logger.warn("texCoord in KHR_texture_transform is not supported now");
|
|
4953
|
+
}
|
|
4954
|
+
};
|
|
4955
|
+
return KHR_texture_transform;
|
|
4956
|
+
}(GLTFExtensionParser);
|
|
4957
|
+
KHR_texture_transform = __decorate([
|
|
4958
|
+
registerGLTFExtension("KHR_texture_transform", GLTFExtensionMode.AdditiveParse)
|
|
4959
|
+
], KHR_texture_transform);
|
|
4960
|
+
|
|
4961
|
+
var GALACEAN_materials_remap = /*#__PURE__*/ function(GLTFExtensionParser) {
|
|
4962
|
+
_inherits(GALACEAN_materials_remap, GLTFExtensionParser);
|
|
4963
|
+
function GALACEAN_materials_remap() {
|
|
4964
|
+
return GLTFExtensionParser.apply(this, arguments);
|
|
4965
|
+
}
|
|
4966
|
+
var _proto = GALACEAN_materials_remap.prototype;
|
|
4967
|
+
_proto.createAndParse = function createAndParse(context, schema) {
|
|
4968
|
+
var engine = context.glTFResource.engine;
|
|
4969
|
+
// @ts-ignore
|
|
4970
|
+
return engine.resourceManager.getResourceByRef(schema);
|
|
4971
|
+
};
|
|
4972
|
+
return GALACEAN_materials_remap;
|
|
4973
|
+
}(GLTFExtensionParser);
|
|
4974
|
+
GALACEAN_materials_remap = __decorate([
|
|
4975
|
+
registerGLTFExtension("GALACEAN_materials_remap", GLTFExtensionMode.CreateAndParse)
|
|
4976
|
+
], GALACEAN_materials_remap);
|
|
4977
|
+
|
|
4978
|
+
var GALACEAN_animation_event = /*#__PURE__*/ function(GLTFExtensionParser) {
|
|
4979
|
+
_inherits(GALACEAN_animation_event, GLTFExtensionParser);
|
|
4980
|
+
function GALACEAN_animation_event() {
|
|
4981
|
+
return GLTFExtensionParser.apply(this, arguments);
|
|
4982
|
+
}
|
|
4983
|
+
var _proto = GALACEAN_animation_event.prototype;
|
|
4984
|
+
_proto.additiveParse = function additiveParse(context, animationClip, schema) {
|
|
4985
|
+
context.glTFResource.engine;
|
|
4986
|
+
var events = schema.events;
|
|
4987
|
+
events.map(function(eventData) {
|
|
4988
|
+
var event = new AnimationEvent();
|
|
4989
|
+
event.functionName = eventData.functionName;
|
|
4990
|
+
event.time = eventData.time;
|
|
4991
|
+
event.parameter = eventData.parameter;
|
|
4992
|
+
animationClip.addEvent(event);
|
|
4993
|
+
});
|
|
4994
|
+
};
|
|
4995
|
+
return GALACEAN_animation_event;
|
|
4996
|
+
}(GLTFExtensionParser);
|
|
4997
|
+
GALACEAN_animation_event = __decorate([
|
|
4998
|
+
registerGLTFExtension("GALACEAN_animation_event", GLTFExtensionMode.AdditiveParse)
|
|
4999
|
+
], GALACEAN_animation_event);
|
|
5000
|
+
|
|
5001
|
+
export { AnimationClipDecoder, ComponentMap, EditorTextureLoader, GLTFAnimationParser, GLTFBufferParser, GLTFEntityParser, GLTFExtensionMode, GLTFExtensionParser, GLTFMaterialParser, GLTFMeshParser, GLTFParser, GLTFParserContext, GLTFPipeline, GLTFResource, GLTFSceneParser, GLTFSkinParser, GLTFTextureParser, GLTFUtils, GLTFValidator, InterpolableValueType, MeshDecoder, MeshLoader$1 as MeshLoader, PrefabParser, ReflectionParser, SceneParser, SpecularMode, Texture2DDecoder, decode, parseSingleKTX, registerGLTFExtension };
|
|
4461
5002
|
//# sourceMappingURL=module.js.map
|