@galacean/engine-loader 1.0.0-alpha.6 → 1.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.js +418 -410
- package/dist/main.js.map +1 -1
- package/dist/miniprogram.js +418 -410
- package/dist/module.js +419 -411
- package/dist/module.js.map +1 -1
- package/package.json +5 -5
- package/types/GLTFContentRestorer.d.ts +0 -3
- package/types/GLTFLoader.d.ts +4 -4
- package/types/Texture2DContentRestorer.d.ts +0 -3
- package/types/TextureCubeContentRestorer.d.ts +0 -3
- package/types/gltf/GLTFResource.d.ts +0 -3
- package/types/gltf/GLTFUtil.d.ts +8 -8
- package/types/gltf/GLTFUtils.d.ts +47 -0
- package/types/gltf/extensions/GLTFExtensionSchema.d.ts +2 -2
- package/types/gltf/extensions/index.d.ts +2 -2
- package/types/gltf/index.d.ts +1 -1
- package/types/gltf/extensions/OASIS_materials_remap.d.ts +0 -1
- /package/types/gltf/extensions/{OASIS_animation_event.d.ts → GALACEAN_animation_event.d.ts} +0 -0
package/dist/module.js
CHANGED
|
@@ -1,56 +1,39 @@
|
|
|
1
|
-
import { resourceLoader, AssetType, AssetPromise, AnimatorController, AnimatorControllerLayer, AnimatorStateMachine, Loader, AnimatorStateTransition, TextureCube, TextureFilterMode, TextureCubeFace, AmbientLight, DiffuseMode, Font, request, ContentRestorer, IndexFormat, VertexElementFormat, AnimationClip, InterpolationType, AnimationFloatArrayCurve, Keyframe, AnimationQuaternionCurve, AnimationVector3Curve, SkinnedMeshRenderer, Transform, Entity, PBRMaterial, Logger, PBRSpecularMaterial, TextureCoordinate, RenderFace, VertexElement, Buffer, BufferBindFlag, BufferUsage, BlendShape, ModelMesh, Camera, MeshRenderer, Animator, BlinnPhongMaterial, Skin, TextureWrapMode as TextureWrapMode$1, Texture2D, EngineObject, TextureFormat, PBRBaseMaterial, Shader, UnlitMaterial, DirectLight, ParticleRenderer, PointLight, SpotLight, Script, SpriteMask, SpriteRenderer, TextRenderer, AnimationEvent, AnimationColorCurve, AnimationVector4Curve, AnimationVector2Curve, AnimationArrayCurve, AnimationFloatCurve, Scene, SpriteAtlas, Sprite, BackgroundMode, SkyBoxMaterial, PrimitiveMesh } from '@galacean/engine-core';
|
|
1
|
+
import { resourceLoader, AssetType, AssetPromise, AnimatorController, AnimatorControllerLayer, AnimatorStateMachine, Loader, AnimatorStateTransition, TextureCube, TextureFilterMode, TextureCubeFace, AmbientLight, DiffuseMode, Font, request, ContentRestorer, IndexFormat, VertexElementFormat, Utils, AnimationClip, InterpolationType, AnimationFloatArrayCurve, Keyframe, AnimationQuaternionCurve, AnimationVector3Curve, SkinnedMeshRenderer, Transform, Entity, PBRMaterial, Logger, PBRSpecularMaterial, TextureCoordinate, RenderFace, VertexElement, Buffer, BufferBindFlag, BufferUsage, BlendShape, ModelMesh, Camera, MeshRenderer, Animator, BlinnPhongMaterial, Skin, TextureWrapMode as TextureWrapMode$1, Texture2D, EngineObject, TextureFormat, PBRBaseMaterial, Shader, UnlitMaterial, DirectLight, ParticleRenderer, PointLight, SpotLight, Script, SpriteMask, SpriteRenderer, TextRenderer, AnimationEvent, AnimationColorCurve, AnimationVector4Curve, AnimationVector2Curve, AnimationArrayCurve, AnimationFloatCurve, Scene, SpriteAtlas, Sprite, BackgroundMode, SkyBoxMaterial, PrimitiveMesh } from '@galacean/engine-core';
|
|
2
2
|
import { SphericalHarmonics3, Vector2, Vector3, Vector4, Color, Quaternion, Matrix, Rect } from '@galacean/engine-math';
|
|
3
3
|
import { GLCompressedTextureInternalFormat } from '@galacean/engine-rhi-webgl';
|
|
4
4
|
import { DRACODecoder } from '@galacean/engine-draco';
|
|
5
5
|
|
|
6
|
-
function
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
for (var key in source) {
|
|
12
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
13
|
-
target[key] = source[key];
|
|
6
|
+
function _extends() {
|
|
7
|
+
_extends = Object.assign || function assign(target) {
|
|
8
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
9
|
+
var source = arguments[i];
|
|
10
|
+
for (var key in source) if (Object.prototype.hasOwnProperty.call(source, key)) target[key] = source[key];
|
|
14
11
|
}
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
12
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return extends_.apply(this, arguments);
|
|
22
|
-
}
|
|
13
|
+
return target;
|
|
14
|
+
};
|
|
23
15
|
|
|
24
|
-
|
|
25
|
-
return extends_.apply(this, arguments);
|
|
16
|
+
return _extends.apply(this, arguments);
|
|
26
17
|
}
|
|
27
18
|
|
|
28
|
-
function
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return o;
|
|
32
|
-
};
|
|
19
|
+
function _set_prototype_of(o, p) {
|
|
20
|
+
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
|
|
21
|
+
o.__proto__ = p;
|
|
33
22
|
|
|
34
|
-
|
|
35
|
-
}
|
|
23
|
+
return o;
|
|
24
|
+
};
|
|
36
25
|
|
|
37
|
-
|
|
38
|
-
return setPrototypeOf(o, p);
|
|
26
|
+
return _set_prototype_of(o, p);
|
|
39
27
|
}
|
|
40
28
|
|
|
41
29
|
function _inherits(subClass, superClass) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
47
|
-
constructor: {
|
|
48
|
-
value: subClass,
|
|
49
|
-
writable: true,
|
|
50
|
-
configurable: true
|
|
30
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
31
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
51
32
|
}
|
|
52
|
-
|
|
53
|
-
|
|
33
|
+
|
|
34
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } });
|
|
35
|
+
|
|
36
|
+
if (superClass) _set_prototype_of(subClass, superClass);
|
|
54
37
|
}
|
|
55
38
|
|
|
56
39
|
/******************************************************************************
|
|
@@ -269,39 +252,34 @@ EnvLoader = __decorate([
|
|
|
269
252
|
], EnvLoader);
|
|
270
253
|
|
|
271
254
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
resolve(value);
|
|
282
|
-
} else {
|
|
283
|
-
Promise.resolve(value).then(_next, _throw);
|
|
284
|
-
}
|
|
255
|
+
try {
|
|
256
|
+
var info = gen[key](arg);
|
|
257
|
+
var value = info.value;
|
|
258
|
+
} catch (error) {
|
|
259
|
+
reject(error);
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
if (info.done) resolve(value);
|
|
263
|
+
else Promise.resolve(value).then(_next, _throw);
|
|
285
264
|
}
|
|
265
|
+
function _async_to_generator(fn) {
|
|
266
|
+
return function() {
|
|
267
|
+
var self = this, args = arguments;
|
|
286
268
|
|
|
287
|
-
function
|
|
288
|
-
|
|
289
|
-
var self = this,
|
|
290
|
-
args = arguments;
|
|
291
|
-
return new Promise(function (resolve, reject) {
|
|
292
|
-
var gen = fn.apply(self, args);
|
|
269
|
+
return new Promise(function(resolve, reject) {
|
|
270
|
+
var gen = fn.apply(self, args);
|
|
293
271
|
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
272
|
+
function _next(value) {
|
|
273
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
274
|
+
}
|
|
297
275
|
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
276
|
+
function _throw(err) {
|
|
277
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
278
|
+
}
|
|
301
279
|
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
280
|
+
_next(undefined);
|
|
281
|
+
});
|
|
282
|
+
};
|
|
305
283
|
}
|
|
306
284
|
|
|
307
285
|
var FontLoader = /*#__PURE__*/ function(Loader) {
|
|
@@ -334,7 +312,7 @@ var FontLoader = /*#__PURE__*/ function(Loader) {
|
|
|
334
312
|
});
|
|
335
313
|
};
|
|
336
314
|
_proto._registerFont = function _registerFont(fontName, fontUrl) {
|
|
337
|
-
return
|
|
315
|
+
return _async_to_generator(function() {
|
|
338
316
|
var fontFace;
|
|
339
317
|
return __generator(this, function(_state) {
|
|
340
318
|
switch(_state.label){
|
|
@@ -362,39 +340,43 @@ FontLoader = __decorate([
|
|
|
362
340
|
], false)
|
|
363
341
|
], FontLoader);
|
|
364
342
|
|
|
365
|
-
function
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
343
|
+
function _array_like_to_array(arr, len) {
|
|
344
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
345
|
+
|
|
346
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
347
|
+
|
|
348
|
+
return arr2;
|
|
369
349
|
}
|
|
370
350
|
|
|
371
|
-
function
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
351
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
352
|
+
if (!o) return;
|
|
353
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
354
|
+
|
|
355
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
356
|
+
|
|
357
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
358
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
359
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
379
360
|
}
|
|
380
361
|
|
|
381
|
-
function
|
|
362
|
+
function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
|
|
382
363
|
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
364
|
+
|
|
383
365
|
if (it) return (it = it.call(o)).next.bind(it);
|
|
384
366
|
// Fallback for engines without symbol support
|
|
385
|
-
if (
|
|
386
|
-
Array.isArray(o) ||
|
|
387
|
-
(it = _unsupportedIterableToArray(o)) ||
|
|
388
|
-
(allowArrayLike && o && typeof o.length === "number")
|
|
389
|
-
) {
|
|
367
|
+
if (Array.isArray(o) || (it = _unsupported_iterable_to_array(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
390
368
|
if (it) o = it;
|
|
369
|
+
|
|
391
370
|
var i = 0;
|
|
392
|
-
|
|
371
|
+
|
|
372
|
+
return function() {
|
|
393
373
|
if (i >= o.length) return { done: true };
|
|
374
|
+
|
|
394
375
|
return { done: false, value: o[i++] };
|
|
395
|
-
}
|
|
376
|
+
};
|
|
396
377
|
}
|
|
397
|
-
|
|
378
|
+
|
|
379
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
398
380
|
}
|
|
399
381
|
|
|
400
382
|
/**
|
|
@@ -411,9 +393,7 @@ function _createForOfIteratorHelperLoose(o, allowArrayLike) {
|
|
|
411
393
|
return _this;
|
|
412
394
|
}
|
|
413
395
|
var _proto = GLTFContentRestorer.prototype;
|
|
414
|
-
|
|
415
|
-
* @override
|
|
416
|
-
*/ _proto.restoreContent = function restoreContent() {
|
|
396
|
+
_proto.restoreContent = function restoreContent() {
|
|
417
397
|
var _this = this;
|
|
418
398
|
return new AssetPromise(function(resolve, reject) {
|
|
419
399
|
Promise.all(_this.bufferRequests.map(function(bufferRequestInfo) {
|
|
@@ -436,16 +416,16 @@ function _createForOfIteratorHelperLoose(o, allowArrayLike) {
|
|
|
436
416
|
var buffer = buffers[bufferView.buffer];
|
|
437
417
|
var _bufferView_byteOffset;
|
|
438
418
|
var bufferData = new Uint8Array(buffer, (_bufferView_byteOffset = bufferView.byteOffset) != null ? _bufferView_byteOffset : 0, bufferView.byteLength);
|
|
439
|
-
return
|
|
419
|
+
return GLTFUtils.loadImageBuffer(bufferData, textureRestoreInfo.mimeType).then(function(image) {
|
|
440
420
|
textureRestoreInfo.texture.setImageSource(image);
|
|
441
421
|
textureRestoreInfo.texture.generateMipmaps();
|
|
442
422
|
});
|
|
443
423
|
})).then(function() {
|
|
444
424
|
// Restore mesh
|
|
445
|
-
for(var _iterator =
|
|
425
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(_this.meshes), _step; !(_step = _iterator()).done;){
|
|
446
426
|
var meshInfo = _step.value;
|
|
447
427
|
var mesh = meshInfo.mesh;
|
|
448
|
-
for(var _iterator1 =
|
|
428
|
+
for(var _iterator1 = _create_for_of_iterator_helper_loose(meshInfo.vertexBuffers), _step1; !(_step1 = _iterator1()).done;){
|
|
449
429
|
var bufferRestoreInfo = _step1.value;
|
|
450
430
|
var vertexData = _this._getBufferData(buffers, bufferRestoreInfo.data);
|
|
451
431
|
bufferRestoreInfo.buffer.setData(vertexData);
|
|
@@ -454,18 +434,18 @@ function _createForOfIteratorHelperLoose(o, allowArrayLike) {
|
|
|
454
434
|
var indexData = _this._getBufferData(buffers, meshInfo.indexBuffer);
|
|
455
435
|
mesh.setIndices(indexData);
|
|
456
436
|
}
|
|
457
|
-
for(var _iterator2 =
|
|
437
|
+
for(var _iterator2 = _create_for_of_iterator_helper_loose(meshInfo.blendShapes), _step2; !(_step2 = _iterator2()).done;){
|
|
458
438
|
var restoreInfo = _step2.value;
|
|
459
439
|
var frame = restoreInfo.blendShape.frames[0];
|
|
460
440
|
var positionData = _this._getBufferData(buffers, restoreInfo.position);
|
|
461
|
-
frame.deltaPositions =
|
|
441
|
+
frame.deltaPositions = GLTFUtils.floatBufferToVector3Array(positionData);
|
|
462
442
|
if (restoreInfo.normal) {
|
|
463
443
|
var normalData = _this._getBufferData(buffers, restoreInfo.normal);
|
|
464
|
-
frame.deltaNormals =
|
|
444
|
+
frame.deltaNormals = GLTFUtils.floatBufferToVector3Array(normalData);
|
|
465
445
|
}
|
|
466
446
|
if (restoreInfo.tangent) {
|
|
467
447
|
var tangentData = _this._getBufferData(buffers, restoreInfo.tangent);
|
|
468
|
-
frame.deltaTangents =
|
|
448
|
+
frame.deltaTangents = GLTFUtils.floatBufferToVector3Array(tangentData);
|
|
469
449
|
}
|
|
470
450
|
}
|
|
471
451
|
mesh.uploadData(true);
|
|
@@ -747,9 +727,9 @@ var TextureWrapMode;
|
|
|
747
727
|
|
|
748
728
|
/**
|
|
749
729
|
* @internal
|
|
750
|
-
*/ var
|
|
751
|
-
function
|
|
752
|
-
|
|
730
|
+
*/ var GLTFUtils = /*#__PURE__*/ function() {
|
|
731
|
+
function GLTFUtils() {}
|
|
732
|
+
GLTFUtils.floatBufferToVector2Array = function floatBufferToVector2Array(buffer) {
|
|
753
733
|
var bufferLen = buffer.length;
|
|
754
734
|
var array = new Array(bufferLen / 2);
|
|
755
735
|
for(var i = 0; i < bufferLen; i += 2){
|
|
@@ -757,7 +737,7 @@ var TextureWrapMode;
|
|
|
757
737
|
}
|
|
758
738
|
return array;
|
|
759
739
|
};
|
|
760
|
-
|
|
740
|
+
GLTFUtils.floatBufferToVector3Array = function floatBufferToVector3Array(buffer) {
|
|
761
741
|
var bufferLen = buffer.length;
|
|
762
742
|
var array = new Array(bufferLen / 3);
|
|
763
743
|
for(var i = 0; i < bufferLen; i += 3){
|
|
@@ -765,7 +745,7 @@ var TextureWrapMode;
|
|
|
765
745
|
}
|
|
766
746
|
return array;
|
|
767
747
|
};
|
|
768
|
-
|
|
748
|
+
GLTFUtils.floatBufferToVector4Array = function floatBufferToVector4Array(buffer) {
|
|
769
749
|
var bufferLen = buffer.length;
|
|
770
750
|
var array = new Array(bufferLen / 4);
|
|
771
751
|
for(var i = 0; i < bufferLen; i += 4){
|
|
@@ -773,7 +753,7 @@ var TextureWrapMode;
|
|
|
773
753
|
}
|
|
774
754
|
return array;
|
|
775
755
|
};
|
|
776
|
-
|
|
756
|
+
GLTFUtils.floatBufferToColorArray = function floatBufferToColorArray(buffer, isColor3) {
|
|
777
757
|
var bufferLen = buffer.length;
|
|
778
758
|
var colors = new Array(bufferLen / (isColor3 ? 3 : 4));
|
|
779
759
|
if (isColor3) {
|
|
@@ -788,21 +768,8 @@ var TextureWrapMode;
|
|
|
788
768
|
return colors;
|
|
789
769
|
};
|
|
790
770
|
/**
|
|
791
|
-
* Parse binary text for glb loader.
|
|
792
|
-
*/ GLTFUtil.decodeText = function decodeText(array) {
|
|
793
|
-
if (typeof TextDecoder !== "undefined") {
|
|
794
|
-
return new TextDecoder().decode(array);
|
|
795
|
-
}
|
|
796
|
-
// TextDecoder polyfill
|
|
797
|
-
var s = "";
|
|
798
|
-
for(var i = 0, il = array.length; i < il; i++){
|
|
799
|
-
s += String.fromCharCode(array[i]);
|
|
800
|
-
}
|
|
801
|
-
return decodeURIComponent(encodeURIComponent(s));
|
|
802
|
-
};
|
|
803
|
-
/**
|
|
804
771
|
* Get the number of bytes occupied by accessor type.
|
|
805
|
-
*/
|
|
772
|
+
*/ GLTFUtils.getAccessorTypeSize = function getAccessorTypeSize(accessorType) {
|
|
806
773
|
switch(accessorType){
|
|
807
774
|
case AccessorType.SCALAR:
|
|
808
775
|
return 1;
|
|
@@ -822,7 +789,7 @@ var TextureWrapMode;
|
|
|
822
789
|
};
|
|
823
790
|
/**
|
|
824
791
|
* Get the TypedArray corresponding to the component type.
|
|
825
|
-
*/
|
|
792
|
+
*/ GLTFUtils.getComponentType = function getComponentType(componentType) {
|
|
826
793
|
switch(componentType){
|
|
827
794
|
case AccessorComponentType.BYTE:
|
|
828
795
|
return Int8Array;
|
|
@@ -838,7 +805,7 @@ var TextureWrapMode;
|
|
|
838
805
|
return Float32Array;
|
|
839
806
|
}
|
|
840
807
|
};
|
|
841
|
-
|
|
808
|
+
GLTFUtils.getNormalizedComponentScale = function getNormalizedComponentScale(componentType) {
|
|
842
809
|
// Reference: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization#encoding-quantized-data
|
|
843
810
|
switch(componentType){
|
|
844
811
|
case AccessorComponentType.BYTE:
|
|
@@ -853,7 +820,7 @@ var TextureWrapMode;
|
|
|
853
820
|
throw new Error("Galacean.GLTFLoader: Unsupported normalized accessor component type.");
|
|
854
821
|
}
|
|
855
822
|
};
|
|
856
|
-
|
|
823
|
+
GLTFUtils.getAccessorBuffer = function getAccessorBuffer(context, bufferViews, accessor) {
|
|
857
824
|
var buffers = context.buffers;
|
|
858
825
|
var componentType = accessor.componentType;
|
|
859
826
|
var bufferView = bufferViews[accessor.bufferView];
|
|
@@ -861,8 +828,8 @@ var TextureWrapMode;
|
|
|
861
828
|
var buffer = buffers[bufferIndex];
|
|
862
829
|
var bufferByteOffset = bufferView.byteOffset || 0;
|
|
863
830
|
var byteOffset = accessor.byteOffset || 0;
|
|
864
|
-
var TypedArray =
|
|
865
|
-
var dataElementSize =
|
|
831
|
+
var TypedArray = GLTFUtils.getComponentType(componentType);
|
|
832
|
+
var dataElementSize = GLTFUtils.getAccessorTypeSize(accessor.type);
|
|
866
833
|
var dataElementBytes = TypedArray.BYTES_PER_ELEMENT;
|
|
867
834
|
var elementStride = dataElementSize * dataElementBytes;
|
|
868
835
|
var accessorCount = accessor.count;
|
|
@@ -889,25 +856,25 @@ var TextureWrapMode;
|
|
|
889
856
|
bufferInfo.restoreInfo = new BufferDataRestoreInfo(new RestoreDataAccessor(bufferIndex, TypedArray, offset1, count1));
|
|
890
857
|
}
|
|
891
858
|
if (accessor.sparse) {
|
|
892
|
-
|
|
859
|
+
GLTFUtils.processingSparseData(bufferViews, accessor, buffers, bufferInfo);
|
|
893
860
|
}
|
|
894
861
|
return bufferInfo;
|
|
895
862
|
};
|
|
896
863
|
/**
|
|
897
864
|
* @deprecated
|
|
898
865
|
* Get accessor data.
|
|
899
|
-
*/
|
|
866
|
+
*/ GLTFUtils.getAccessorData = function getAccessorData(glTF, accessor, buffers) {
|
|
900
867
|
var bufferViews = glTF.bufferViews;
|
|
901
868
|
var bufferView = bufferViews[accessor.bufferView];
|
|
902
869
|
var arrayBuffer = buffers[bufferView.buffer];
|
|
903
870
|
var accessorByteOffset = accessor.hasOwnProperty("byteOffset") ? accessor.byteOffset : 0;
|
|
904
871
|
var bufferViewByteOffset = bufferView.hasOwnProperty("byteOffset") ? bufferView.byteOffset : 0;
|
|
905
872
|
var byteOffset = accessorByteOffset + bufferViewByteOffset;
|
|
906
|
-
var accessorTypeSize =
|
|
873
|
+
var accessorTypeSize = GLTFUtils.getAccessorTypeSize(accessor.type);
|
|
907
874
|
var length = accessorTypeSize * accessor.count;
|
|
908
875
|
var _bufferView_byteStride;
|
|
909
876
|
var byteStride = (_bufferView_byteStride = bufferView.byteStride) != null ? _bufferView_byteStride : 0;
|
|
910
|
-
var arrayType =
|
|
877
|
+
var arrayType = GLTFUtils.getComponentType(accessor.componentType);
|
|
911
878
|
var uint8Array;
|
|
912
879
|
if (byteStride) {
|
|
913
880
|
var accessorByteSize = accessorTypeSize * arrayType.BYTES_PER_ELEMENT;
|
|
@@ -934,7 +901,7 @@ var TextureWrapMode;
|
|
|
934
901
|
var _values_byteOffset, _valuesBufferView_byteOffset;
|
|
935
902
|
var valuesByteOffset = ((_values_byteOffset = values.byteOffset) != null ? _values_byteOffset : 0) + ((_valuesBufferView_byteOffset = valuesBufferView.byteOffset) != null ? _valuesBufferView_byteOffset : 0);
|
|
936
903
|
var valuesByteLength = valuesBufferView.byteLength;
|
|
937
|
-
var indicesType =
|
|
904
|
+
var indicesType = GLTFUtils.getComponentType(indices.componentType);
|
|
938
905
|
var indicesArray = new indicesType(indicesArrayBuffer, indicesByteOffset, indicesByteLength / indicesType.BYTES_PER_ELEMENT);
|
|
939
906
|
var valuesArray = new arrayType(valuesArrayBuffer, valuesByteOffset, valuesByteLength / arrayType.BYTES_PER_ELEMENT);
|
|
940
907
|
for(var i1 = 0; i1 < count; i1++){
|
|
@@ -946,17 +913,17 @@ var TextureWrapMode;
|
|
|
946
913
|
}
|
|
947
914
|
return typedArray;
|
|
948
915
|
};
|
|
949
|
-
|
|
916
|
+
GLTFUtils.getBufferViewData = function getBufferViewData(bufferView, buffers) {
|
|
950
917
|
var _bufferView_byteOffset = bufferView.byteOffset, byteOffset = _bufferView_byteOffset === void 0 ? 0 : _bufferView_byteOffset;
|
|
951
918
|
var arrayBuffer = buffers[bufferView.buffer];
|
|
952
919
|
return arrayBuffer.slice(byteOffset, byteOffset + bufferView.byteLength);
|
|
953
920
|
};
|
|
954
921
|
/**
|
|
955
922
|
* Get accessor data.
|
|
956
|
-
*/
|
|
923
|
+
*/ GLTFUtils.processingSparseData = function processingSparseData(bufferViews, accessor, buffers, bufferInfo) {
|
|
957
924
|
var restoreInfo = bufferInfo.restoreInfo;
|
|
958
|
-
var accessorTypeSize =
|
|
959
|
-
var TypedArray =
|
|
925
|
+
var accessorTypeSize = GLTFUtils.getAccessorTypeSize(accessor.type);
|
|
926
|
+
var TypedArray = GLTFUtils.getComponentType(accessor.componentType);
|
|
960
927
|
var data = bufferInfo.data.slice();
|
|
961
928
|
var _accessor_sparse = accessor.sparse, count = _accessor_sparse.count, indices = _accessor_sparse.indices, values = _accessor_sparse.values;
|
|
962
929
|
var indicesBufferView = bufferViews[indices.bufferView];
|
|
@@ -973,7 +940,7 @@ var TextureWrapMode;
|
|
|
973
940
|
var valuesByteLength = valuesBufferView.byteLength;
|
|
974
941
|
restoreInfo.typeSize = accessorTypeSize;
|
|
975
942
|
restoreInfo.sparseCount = count;
|
|
976
|
-
var IndexTypeArray =
|
|
943
|
+
var IndexTypeArray = GLTFUtils.getComponentType(indices.componentType);
|
|
977
944
|
var indexLength = indicesByteLength / IndexTypeArray.BYTES_PER_ELEMENT;
|
|
978
945
|
var indicesArray = new IndexTypeArray(indicesArrayBuffer, indicesByteOffset, indexLength);
|
|
979
946
|
restoreInfo.sparseIndices = new RestoreDataAccessor(indicesBufferIndex, IndexTypeArray, indicesByteOffset, indexLength);
|
|
@@ -988,7 +955,7 @@ var TextureWrapMode;
|
|
|
988
955
|
}
|
|
989
956
|
bufferInfo.data = data;
|
|
990
957
|
};
|
|
991
|
-
|
|
958
|
+
GLTFUtils.getIndexFormat = function getIndexFormat(type) {
|
|
992
959
|
switch(type){
|
|
993
960
|
case AccessorComponentType.UNSIGNED_BYTE:
|
|
994
961
|
return IndexFormat.UInt8;
|
|
@@ -998,7 +965,7 @@ var TextureWrapMode;
|
|
|
998
965
|
return IndexFormat.UInt32;
|
|
999
966
|
}
|
|
1000
967
|
};
|
|
1001
|
-
|
|
968
|
+
GLTFUtils.getElementFormat = function getElementFormat(type, size, normalized) {
|
|
1002
969
|
if (normalized === void 0) normalized = false;
|
|
1003
970
|
if (type == AccessorComponentType.FLOAT) {
|
|
1004
971
|
switch(size){
|
|
@@ -1049,7 +1016,7 @@ var TextureWrapMode;
|
|
|
1049
1016
|
};
|
|
1050
1017
|
/**
|
|
1051
1018
|
* Load image buffer
|
|
1052
|
-
*/
|
|
1019
|
+
*/ GLTFUtils.loadImageBuffer = function loadImageBuffer(imageBuffer, type) {
|
|
1053
1020
|
return new Promise(function(resolve, reject) {
|
|
1054
1021
|
var blob = new window.Blob([
|
|
1055
1022
|
imageBuffer
|
|
@@ -1073,18 +1040,9 @@ var TextureWrapMode;
|
|
|
1073
1040
|
img.src = URL.createObjectURL(blob);
|
|
1074
1041
|
});
|
|
1075
1042
|
};
|
|
1076
|
-
GLTFUtil.isAbsoluteUrl = function isAbsoluteUrl(url) {
|
|
1077
|
-
return /^(?:http|blob|data:|\/)/.test(url);
|
|
1078
|
-
};
|
|
1079
|
-
GLTFUtil.parseRelativeUrl = function parseRelativeUrl(baseUrl, relativeUrl) {
|
|
1080
|
-
if (GLTFUtil.isAbsoluteUrl(relativeUrl)) {
|
|
1081
|
-
return relativeUrl;
|
|
1082
|
-
}
|
|
1083
|
-
return baseUrl.substring(0, baseUrl.lastIndexOf("/") + 1) + GLTFUtil._formatRelativePath(relativeUrl);
|
|
1084
|
-
};
|
|
1085
1043
|
/**
|
|
1086
1044
|
* Parse the glb format.
|
|
1087
|
-
*/
|
|
1045
|
+
*/ GLTFUtils.parseGLB = function parseGLB(context, glb) {
|
|
1088
1046
|
var UINT32_LENGTH = 4;
|
|
1089
1047
|
var GLB_HEADER_MAGIC = 0x46546c67; // 'glTF'
|
|
1090
1048
|
var GLB_HEADER_LENGTH = 12;
|
|
@@ -1112,7 +1070,7 @@ var TextureWrapMode;
|
|
|
1112
1070
|
return null;
|
|
1113
1071
|
}
|
|
1114
1072
|
var glTFData = new Uint8Array(glb, GLB_HEADER_LENGTH + 2 * UINT32_LENGTH, chunkLength);
|
|
1115
|
-
var glTF = JSON.parse(
|
|
1073
|
+
var glTF = JSON.parse(Utils.decodeText(glTFData));
|
|
1116
1074
|
// read all buffers
|
|
1117
1075
|
var buffers = [];
|
|
1118
1076
|
var byteOffset = GLB_HEADER_LENGTH + 2 * UINT32_LENGTH + chunkLength;
|
|
@@ -1135,7 +1093,7 @@ var TextureWrapMode;
|
|
|
1135
1093
|
buffers: buffers
|
|
1136
1094
|
};
|
|
1137
1095
|
};
|
|
1138
|
-
|
|
1096
|
+
GLTFUtils._formatRelativePath = function _formatRelativePath(path) {
|
|
1139
1097
|
// For example input is "a/b", "/a/b", "./a/b", "./a/./b", "./a/../a/b", output is "a/b"
|
|
1140
1098
|
return path.split("/").filter(Boolean).reduce(function(acc, cur) {
|
|
1141
1099
|
if (cur === "..") acc.pop();
|
|
@@ -1143,23 +1101,25 @@ var TextureWrapMode;
|
|
|
1143
1101
|
return acc;
|
|
1144
1102
|
}, []).join("/");
|
|
1145
1103
|
};
|
|
1146
|
-
return
|
|
1104
|
+
return GLTFUtils;
|
|
1147
1105
|
}();
|
|
1148
1106
|
|
|
1149
|
-
function
|
|
1150
|
-
|
|
1107
|
+
function _array_without_holes(arr) {
|
|
1108
|
+
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
1151
1109
|
}
|
|
1152
1110
|
|
|
1153
|
-
function
|
|
1154
|
-
|
|
1111
|
+
function _iterable_to_array(iter) {
|
|
1112
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) {
|
|
1113
|
+
return Array.from(iter);
|
|
1114
|
+
}
|
|
1155
1115
|
}
|
|
1156
1116
|
|
|
1157
|
-
function
|
|
1158
|
-
|
|
1117
|
+
function _non_iterable_spread() {
|
|
1118
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
1159
1119
|
}
|
|
1160
1120
|
|
|
1161
|
-
function
|
|
1162
|
-
|
|
1121
|
+
function _to_consumable_array(arr) {
|
|
1122
|
+
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
1163
1123
|
}
|
|
1164
1124
|
|
|
1165
1125
|
/**
|
|
@@ -1249,7 +1209,7 @@ var GLTFExtensionMode;
|
|
|
1249
1209
|
context,
|
|
1250
1210
|
extensionSchema,
|
|
1251
1211
|
ownerSchema
|
|
1252
|
-
].concat(
|
|
1212
|
+
].concat(_to_consumable_array(extra)));
|
|
1253
1213
|
if (resource) {
|
|
1254
1214
|
return resource;
|
|
1255
1215
|
}
|
|
@@ -1275,7 +1235,7 @@ var GLTFExtensionMode;
|
|
|
1275
1235
|
parseResource,
|
|
1276
1236
|
extensionSchema,
|
|
1277
1237
|
ownerSchema
|
|
1278
|
-
].concat(
|
|
1238
|
+
].concat(_to_consumable_array(extra)));
|
|
1279
1239
|
}
|
|
1280
1240
|
};
|
|
1281
1241
|
/**
|
|
@@ -1323,7 +1283,7 @@ var GLTFExtensionMode;
|
|
|
1323
1283
|
context,
|
|
1324
1284
|
extensionSchema,
|
|
1325
1285
|
ownerSchema
|
|
1326
|
-
].concat(
|
|
1286
|
+
].concat(_to_consumable_array(extra)));
|
|
1327
1287
|
}
|
|
1328
1288
|
};
|
|
1329
1289
|
GLTFParser._additiveParse = function _additiveParse(extensionName, context, parseResource, extensionSchema, ownerSchema) {
|
|
@@ -1338,12 +1298,14 @@ var GLTFExtensionMode;
|
|
|
1338
1298
|
parseResource,
|
|
1339
1299
|
extensionSchema,
|
|
1340
1300
|
ownerSchema
|
|
1341
|
-
].concat(
|
|
1301
|
+
].concat(_to_consumable_array(extra)));
|
|
1342
1302
|
}
|
|
1343
1303
|
};
|
|
1344
1304
|
return GLTFParser;
|
|
1345
1305
|
}();
|
|
1346
|
-
|
|
1306
|
+
(function() {
|
|
1307
|
+
GLTFParser._extensionParsers = {};
|
|
1308
|
+
})();
|
|
1347
1309
|
/**
|
|
1348
1310
|
* Declare ExtensionParser's decorator.
|
|
1349
1311
|
* @param extensionName - Extension name
|
|
@@ -1405,10 +1367,10 @@ var GLTFAnimationParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
1405
1367
|
var gltfSampler = samplers[j];
|
|
1406
1368
|
var inputAccessor = accessors[gltfSampler.input];
|
|
1407
1369
|
var outputAccessor = accessors[gltfSampler.output];
|
|
1408
|
-
var input =
|
|
1409
|
-
var output =
|
|
1370
|
+
var input = GLTFUtils.getAccessorBuffer(context, bufferViews, inputAccessor).data;
|
|
1371
|
+
var output = GLTFUtils.getAccessorBuffer(context, bufferViews, outputAccessor).data;
|
|
1410
1372
|
if (outputAccessor.normalized) {
|
|
1411
|
-
var scale =
|
|
1373
|
+
var scale = GLTFUtils.getNormalizedComponentScale(outputAccessor.componentType);
|
|
1412
1374
|
var scaled = new Float32Array(output.length);
|
|
1413
1375
|
for(var k = 0, v = output.length; k < v; k++){
|
|
1414
1376
|
scaled[k] = output[k] * scale;
|
|
@@ -1562,7 +1524,7 @@ var GLTFBufferParser = /*#__PURE__*/ function(GLTFParser) {
|
|
|
1562
1524
|
if (isGLB) {
|
|
1563
1525
|
return request(url, requestConfig).then(function(glb) {
|
|
1564
1526
|
restoreBufferRequests.push(new BufferRequestInfo(url, requestConfig));
|
|
1565
|
-
return
|
|
1527
|
+
return GLTFUtils.parseGLB(context, glb);
|
|
1566
1528
|
}).then(function(param) {
|
|
1567
1529
|
var glTF = param.glTF, buffers = param.buffers;
|
|
1568
1530
|
context.glTF = glTF;
|
|
@@ -1574,7 +1536,7 @@ var GLTFBufferParser = /*#__PURE__*/ function(GLTFParser) {
|
|
|
1574
1536
|
}).then(function(glTF) {
|
|
1575
1537
|
context.glTF = glTF;
|
|
1576
1538
|
return Promise.all(glTF.buffers.map(function(buffer) {
|
|
1577
|
-
var absoluteUrl =
|
|
1539
|
+
var absoluteUrl = Utils.resolveAbsoluteUrl(url, buffer.uri);
|
|
1578
1540
|
restoreBufferRequests.push(new BufferRequestInfo(absoluteUrl, requestConfig));
|
|
1579
1541
|
return request(absoluteUrl, requestConfig);
|
|
1580
1542
|
})).then(function(buffers) {
|
|
@@ -1664,7 +1626,9 @@ var GLTFEntityParser = /*#__PURE__*/ function(GLTFParser) {
|
|
|
1664
1626
|
};
|
|
1665
1627
|
return GLTFEntityParser;
|
|
1666
1628
|
}(GLTFParser);
|
|
1667
|
-
|
|
1629
|
+
(function() {
|
|
1630
|
+
/** @internal */ GLTFEntityParser._defaultName = "_GLTF_ENTITY_";
|
|
1631
|
+
})();
|
|
1668
1632
|
|
|
1669
1633
|
var GLTFMaterialParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
1670
1634
|
_inherits(GLTFMaterialParser, GLTFParser1);
|
|
@@ -1779,11 +1743,9 @@ var GLTFMaterialParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
1779
1743
|
}(GLTFParser);
|
|
1780
1744
|
|
|
1781
1745
|
function _instanceof(left, right) {
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
return left instanceof right;
|
|
1786
|
-
}
|
|
1746
|
+
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
1747
|
+
return !!right[Symbol.hasInstance](left);
|
|
1748
|
+
} else return left instanceof right;
|
|
1787
1749
|
}
|
|
1788
1750
|
|
|
1789
1751
|
var GLTFMeshParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
@@ -1818,13 +1780,13 @@ var GLTFMeshParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
1818
1780
|
var attributeAccessorIdx = shapeAccessorIdx[attributeName];
|
|
1819
1781
|
if (attributeAccessorIdx) {
|
|
1820
1782
|
var accessor = glTF.accessors[attributeAccessorIdx];
|
|
1821
|
-
return
|
|
1783
|
+
return GLTFUtils.getAccessorBuffer(context, context.glTF.bufferViews, accessor);
|
|
1822
1784
|
} else {
|
|
1823
1785
|
return null;
|
|
1824
1786
|
}
|
|
1825
1787
|
}, function() {
|
|
1826
1788
|
var indexAccessor = glTF.accessors[gltfPrimitive.indices];
|
|
1827
|
-
return
|
|
1789
|
+
return GLTFUtils.getAccessorData(glTF, indexAccessor, buffers);
|
|
1828
1790
|
}, context.keepMeshData).then(resolve);
|
|
1829
1791
|
}
|
|
1830
1792
|
});
|
|
@@ -1856,16 +1818,18 @@ var GLTFMeshParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
1856
1818
|
var vertexElements = new Array();
|
|
1857
1819
|
var vertexCount;
|
|
1858
1820
|
var bufferBindIndex = 0;
|
|
1821
|
+
var positions;
|
|
1822
|
+
keepMeshData && (positions = new Array(vertexCount));
|
|
1859
1823
|
for(var attribute in attributes){
|
|
1860
1824
|
var accessor = accessors[attributes[attribute]];
|
|
1861
|
-
var accessorBuffer =
|
|
1862
|
-
var dataElementSize =
|
|
1825
|
+
var accessorBuffer = GLTFUtils.getAccessorBuffer(context, gltf.bufferViews, accessor);
|
|
1826
|
+
var dataElementSize = GLTFUtils.getAccessorTypeSize(accessor.type);
|
|
1863
1827
|
var attributeCount = accessor.count;
|
|
1864
1828
|
var vertices = accessorBuffer.data;
|
|
1865
1829
|
var vertexElement = void 0;
|
|
1866
1830
|
var meshId = mesh.instanceId;
|
|
1867
1831
|
var vertexBindingInfos = accessorBuffer.vertexBindingInfos;
|
|
1868
|
-
var elementFormat =
|
|
1832
|
+
var elementFormat = GLTFUtils.getElementFormat(accessor.componentType, dataElementSize, accessor.normalized);
|
|
1869
1833
|
if (accessorBuffer.interleaved) {
|
|
1870
1834
|
var byteOffset = accessor.byteOffset || 0;
|
|
1871
1835
|
var stride = accessorBuffer.stride;
|
|
@@ -1899,20 +1863,27 @@ var GLTFMeshParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
1899
1863
|
if (accessor.min && accessor.max) {
|
|
1900
1864
|
min.copyFromArray(accessor.min);
|
|
1901
1865
|
max.copyFromArray(accessor.max);
|
|
1866
|
+
if (keepMeshData) {
|
|
1867
|
+
var stride1 = vertices.length / attributeCount;
|
|
1868
|
+
for(var j = 0; j < attributeCount; j++){
|
|
1869
|
+
var offset = j * stride1;
|
|
1870
|
+
positions[j] = new Vector3(vertices[offset], vertices[offset + 1], vertices[offset + 2]);
|
|
1871
|
+
}
|
|
1872
|
+
}
|
|
1902
1873
|
} else {
|
|
1903
1874
|
var position = GLTFMeshParser._tempVector3;
|
|
1904
1875
|
min.set(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
|
|
1905
1876
|
max.set(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
|
|
1906
|
-
var
|
|
1907
|
-
for(var
|
|
1908
|
-
var
|
|
1909
|
-
position.copyFromArray(vertices,
|
|
1877
|
+
var stride2 = vertices.length / attributeCount;
|
|
1878
|
+
for(var j1 = 0; j1 < attributeCount; j1++){
|
|
1879
|
+
var offset1 = j1 * stride2;
|
|
1880
|
+
position.copyFromArray(vertices, offset1);
|
|
1910
1881
|
Vector3.min(min, position, min);
|
|
1911
1882
|
Vector3.max(max, position, max);
|
|
1912
1883
|
}
|
|
1913
1884
|
}
|
|
1914
1885
|
if (accessor.normalized) {
|
|
1915
|
-
var scaleFactor =
|
|
1886
|
+
var scaleFactor = GLTFUtils.getNormalizedComponentScale(accessor.componentType);
|
|
1916
1887
|
min.scale(scaleFactor);
|
|
1917
1888
|
max.scale(scaleFactor);
|
|
1918
1889
|
}
|
|
@@ -1922,7 +1893,7 @@ var GLTFMeshParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
1922
1893
|
// Indices
|
|
1923
1894
|
if (indices !== undefined) {
|
|
1924
1895
|
var indexAccessor = gltf.accessors[indices];
|
|
1925
|
-
var accessorBuffer1 =
|
|
1896
|
+
var accessorBuffer1 = GLTFUtils.getAccessorBuffer(context, gltf.bufferViews, indexAccessor);
|
|
1926
1897
|
mesh.setIndices(accessorBuffer1.data);
|
|
1927
1898
|
mesh.addSubMesh(0, indexAccessor.count, mode);
|
|
1928
1899
|
meshRestoreInfo.indexBuffer = accessorBuffer1.restoreInfo;
|
|
@@ -1932,6 +1903,8 @@ var GLTFMeshParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
1932
1903
|
// BlendShapes
|
|
1933
1904
|
targets && GLTFMeshParser._createBlendShape(mesh, meshRestoreInfo, gltfMesh, targets, getBlendShapeData);
|
|
1934
1905
|
mesh.uploadData(!keepMeshData);
|
|
1906
|
+
//@ts-ignore
|
|
1907
|
+
mesh._positions = positions;
|
|
1935
1908
|
return Promise.resolve(mesh);
|
|
1936
1909
|
};
|
|
1937
1910
|
/**
|
|
@@ -1943,9 +1916,9 @@ var GLTFMeshParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
1943
1916
|
var deltaPosBufferInfo = getBlendShapeData("POSITION", i);
|
|
1944
1917
|
var deltaNorBufferInfo = getBlendShapeData("NORMAL", i);
|
|
1945
1918
|
var deltaTanBufferInfo = getBlendShapeData("TANGENT", i);
|
|
1946
|
-
var deltaPositions = deltaPosBufferInfo.data ?
|
|
1947
|
-
var deltaNormals = (deltaNorBufferInfo == null ? void 0 : deltaNorBufferInfo.data) ?
|
|
1948
|
-
var deltaTangents = (deltaTanBufferInfo == null ? void 0 : deltaTanBufferInfo.data) ?
|
|
1919
|
+
var deltaPositions = deltaPosBufferInfo.data ? GLTFUtils.floatBufferToVector3Array(deltaPosBufferInfo.data) : null;
|
|
1920
|
+
var deltaNormals = (deltaNorBufferInfo == null ? void 0 : deltaNorBufferInfo.data) ? GLTFUtils.floatBufferToVector3Array(deltaNorBufferInfo == null ? void 0 : deltaNorBufferInfo.data) : null;
|
|
1921
|
+
var deltaTangents = (deltaTanBufferInfo == null ? void 0 : deltaTanBufferInfo.data) ? GLTFUtils.floatBufferToVector3Array(deltaTanBufferInfo == null ? void 0 : deltaTanBufferInfo.data) : null;
|
|
1949
1922
|
var blendShape = new BlendShape(name);
|
|
1950
1923
|
blendShape.addFrame(1.0, deltaPositions, deltaNormals, deltaTangents);
|
|
1951
1924
|
mesh.addBlendShape(blendShape);
|
|
@@ -1954,7 +1927,9 @@ var GLTFMeshParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
1954
1927
|
};
|
|
1955
1928
|
return GLTFMeshParser;
|
|
1956
1929
|
}(GLTFParser);
|
|
1957
|
-
|
|
1930
|
+
(function() {
|
|
1931
|
+
GLTFMeshParser._tempVector3 = new Vector3();
|
|
1932
|
+
})();
|
|
1958
1933
|
|
|
1959
1934
|
var GLTFSceneParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
1960
1935
|
_inherits(GLTFSceneParser, GLTFParser1);
|
|
@@ -2106,7 +2081,7 @@ var GLTFSkinParser = /*#__PURE__*/ function(GLTFParser) {
|
|
|
2106
2081
|
skin.inverseBindMatrices.length = jointCount;
|
|
2107
2082
|
// parse IBM
|
|
2108
2083
|
var accessor = glTF.accessors[inverseBindMatrices];
|
|
2109
|
-
var buffer =
|
|
2084
|
+
var buffer = GLTFUtils.getAccessorBuffer(context, glTF.bufferViews, accessor).data;
|
|
2110
2085
|
for(var i1 = 0; i1 < jointCount; i1++){
|
|
2111
2086
|
var inverseBindMatrix = new Matrix();
|
|
2112
2087
|
inverseBindMatrix.copyFromArray(buffer, i1 * 16);
|
|
@@ -2141,7 +2116,7 @@ var GLTFSkinParser = /*#__PURE__*/ function(GLTFParser) {
|
|
|
2141
2116
|
};
|
|
2142
2117
|
_proto._findSkeletonRootBone = function _findSkeletonRootBone(joints, entities) {
|
|
2143
2118
|
var paths = {};
|
|
2144
|
-
for(var _iterator =
|
|
2119
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(joints), _step; !(_step = _iterator()).done;){
|
|
2145
2120
|
var index = _step.value;
|
|
2146
2121
|
var path = new Array();
|
|
2147
2122
|
var entity = entities[index];
|
|
@@ -2191,7 +2166,7 @@ var GLTFTextureParser = /*#__PURE__*/ function(GLTFParser) {
|
|
|
2191
2166
|
var ext = uri.substring(index1 + 1);
|
|
2192
2167
|
var type = ext.startsWith("ktx") ? AssetType.KTX : AssetType.Texture2D;
|
|
2193
2168
|
return engine.resourceManager.load({
|
|
2194
|
-
url:
|
|
2169
|
+
url: Utils.resolveAbsoluteUrl(url, uri),
|
|
2195
2170
|
type: type
|
|
2196
2171
|
}).then(function(texture) {
|
|
2197
2172
|
if (!texture.name) {
|
|
@@ -2206,7 +2181,7 @@ var GLTFTextureParser = /*#__PURE__*/ function(GLTFParser) {
|
|
|
2206
2181
|
var bufferView = glTF.bufferViews[bufferViewIndex];
|
|
2207
2182
|
var buffer = buffers[bufferView.buffer];
|
|
2208
2183
|
var imageBuffer = new Uint8Array(buffer, bufferView.byteOffset, bufferView.byteLength);
|
|
2209
|
-
return
|
|
2184
|
+
return GLTFUtils.loadImageBuffer(imageBuffer, mimeType).then(function(image) {
|
|
2210
2185
|
var texture = new Texture2D(engine, image.width, image.height);
|
|
2211
2186
|
texture.setImageSource(image);
|
|
2212
2187
|
texture.generateMipmaps();
|
|
@@ -2246,8 +2221,10 @@ var GLTFTextureParser = /*#__PURE__*/ function(GLTFParser) {
|
|
|
2246
2221
|
};
|
|
2247
2222
|
return GLTFTextureParser;
|
|
2248
2223
|
}(GLTFParser);
|
|
2249
|
-
|
|
2250
|
-
|
|
2224
|
+
(function() {
|
|
2225
|
+
var _obj;
|
|
2226
|
+
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);
|
|
2227
|
+
})();
|
|
2251
2228
|
|
|
2252
2229
|
var GLTFValidator = /*#__PURE__*/ function(GLTFParser1) {
|
|
2253
2230
|
_inherits(GLTFValidator, GLTFParser1);
|
|
@@ -2329,9 +2306,11 @@ var GLTFValidator = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
2329
2306
|
};
|
|
2330
2307
|
return GLTFPipeline;
|
|
2331
2308
|
}();
|
|
2332
|
-
|
|
2309
|
+
(function() {
|
|
2310
|
+
/**
|
|
2333
2311
|
* Default pipeline.
|
|
2334
2312
|
*/ GLTFPipeline.defaultPipeline = new GLTFPipeline(GLTFBufferParser, GLTFValidator, GLTFTextureParser, GLTFMaterialParser, GLTFMeshParser, GLTFEntityParser, GLTFSkinParser, GLTFAnimationParser, GLTFSceneParser);
|
|
2313
|
+
})();
|
|
2335
2314
|
|
|
2336
2315
|
/**
|
|
2337
2316
|
* Product after glTF parser, usually, `defaultSceneRoot` is only needed to use.
|
|
@@ -2344,9 +2323,7 @@ var GLTFValidator = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
2344
2323
|
return _this;
|
|
2345
2324
|
}
|
|
2346
2325
|
var _proto = GLTFResource.prototype;
|
|
2347
|
-
|
|
2348
|
-
* @override
|
|
2349
|
-
*/ _proto._onDestroy = function _onDestroy() {
|
|
2326
|
+
_proto._onDestroy = function _onDestroy() {
|
|
2350
2327
|
EngineObject.prototype._onDestroy.call(this);
|
|
2351
2328
|
this.defaultSceneRoot.destroy();
|
|
2352
2329
|
this.textures = null;
|
|
@@ -2369,9 +2346,7 @@ var GLTFLoader = /*#__PURE__*/ function(Loader) {
|
|
|
2369
2346
|
return Loader.apply(this, arguments);
|
|
2370
2347
|
}
|
|
2371
2348
|
var _proto = GLTFLoader.prototype;
|
|
2372
|
-
|
|
2373
|
-
* @override
|
|
2374
|
-
*/ _proto.load = function load(item, resourceManager) {
|
|
2349
|
+
_proto.load = function load(item, resourceManager) {
|
|
2375
2350
|
var url = item.url;
|
|
2376
2351
|
var params = item.params;
|
|
2377
2352
|
var context = new GLTFParserContext(url);
|
|
@@ -2384,7 +2359,7 @@ var GLTFLoader = /*#__PURE__*/ function(Loader) {
|
|
|
2384
2359
|
context.keepMeshData = (_params_keepMeshData = params == null ? void 0 : params.keepMeshData) != null ? _params_keepMeshData : false;
|
|
2385
2360
|
masterPromiseInfo.onCancel(function() {
|
|
2386
2361
|
var chainPromises = context.chainPromises;
|
|
2387
|
-
for(var _iterator =
|
|
2362
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(chainPromises), _step; !(_step = _iterator()).done;){
|
|
2388
2363
|
var promise = _step.value;
|
|
2389
2364
|
promise.cancel();
|
|
2390
2365
|
}
|
|
@@ -2487,7 +2462,7 @@ var HDRLoader = (_HDRLoader = /*#__PURE__*/ function(Loader) {
|
|
|
2487
2462
|
return textureArray;
|
|
2488
2463
|
};
|
|
2489
2464
|
HDRLoader1._calcProjectionSpherical = function _calcProjectionSpherical(vDir, pixels, inputWidth, inputHeight) {
|
|
2490
|
-
var theta = Math.atan2(vDir.z,
|
|
2465
|
+
var theta = Math.atan2(vDir.z, vDir.x);
|
|
2491
2466
|
var phi = Math.acos(vDir.y);
|
|
2492
2467
|
while(theta < -PI){
|
|
2493
2468
|
theta += 2 * PI;
|
|
@@ -2648,37 +2623,75 @@ var HDRLoader = (_HDRLoader = /*#__PURE__*/ function(Loader) {
|
|
|
2648
2623
|
color.a *= M;
|
|
2649
2624
|
};
|
|
2650
2625
|
return HDRLoader1;
|
|
2651
|
-
}(Loader),
|
|
2652
|
-
_HDRLoader._rightBottomBack,
|
|
2653
|
-
|
|
2654
|
-
_HDRLoader.
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
_HDRLoader.
|
|
2659
|
-
|
|
2660
|
-
_HDRLoader.
|
|
2661
|
-
|
|
2662
|
-
_HDRLoader._leftBottomFront,
|
|
2663
|
-
|
|
2664
|
-
_HDRLoader.
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
_HDRLoader.
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
_HDRLoader.
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2626
|
+
}(Loader), function() {
|
|
2627
|
+
_HDRLoader._rightBottomBack = new Vector3(1.0, -1.0, -1.0);
|
|
2628
|
+
}(), function() {
|
|
2629
|
+
_HDRLoader._rightBottomFront = new Vector3(1.0, -1.0, 1.0);
|
|
2630
|
+
}(), function() {
|
|
2631
|
+
_HDRLoader._rightUpBack = new Vector3(1.0, 1.0, -1.0);
|
|
2632
|
+
}(), function() {
|
|
2633
|
+
_HDRLoader._rightUpFront = new Vector3(1.0, 1.0, 1.0);
|
|
2634
|
+
}(), function() {
|
|
2635
|
+
_HDRLoader._leftBottomBack = new Vector3(-1.0, -1.0, -1.0);
|
|
2636
|
+
}(), function() {
|
|
2637
|
+
_HDRLoader._leftBottomFront = new Vector3(-1.0, -1.0, 1.0);
|
|
2638
|
+
}(), function() {
|
|
2639
|
+
_HDRLoader._leftUpBack = new Vector3(-1.0, 1.0, -1.0);
|
|
2640
|
+
}(), function() {
|
|
2641
|
+
_HDRLoader._leftUpFront = new Vector3(-1.0, 1.0, 1.0);
|
|
2642
|
+
}(), function() {
|
|
2643
|
+
_HDRLoader._faceRight = [
|
|
2644
|
+
_HDRLoader._rightBottomBack,
|
|
2645
|
+
_HDRLoader._rightBottomFront,
|
|
2646
|
+
_HDRLoader._rightUpBack,
|
|
2647
|
+
_HDRLoader._rightUpFront
|
|
2648
|
+
];
|
|
2649
|
+
}(), function() {
|
|
2650
|
+
_HDRLoader._faceLeft = [
|
|
2651
|
+
_HDRLoader._leftBottomFront,
|
|
2652
|
+
_HDRLoader._leftBottomBack,
|
|
2653
|
+
_HDRLoader._leftUpFront,
|
|
2654
|
+
_HDRLoader._leftUpBack
|
|
2655
|
+
];
|
|
2656
|
+
}(), function() {
|
|
2657
|
+
_HDRLoader._faceUp = [
|
|
2658
|
+
_HDRLoader._leftBottomFront,
|
|
2659
|
+
_HDRLoader._rightBottomFront,
|
|
2660
|
+
_HDRLoader._leftBottomBack,
|
|
2661
|
+
_HDRLoader._rightBottomBack
|
|
2662
|
+
];
|
|
2663
|
+
}(), function() {
|
|
2664
|
+
_HDRLoader._faceBottom = [
|
|
2665
|
+
_HDRLoader._leftUpBack,
|
|
2666
|
+
_HDRLoader._rightUpBack,
|
|
2667
|
+
_HDRLoader._leftUpFront,
|
|
2668
|
+
_HDRLoader._rightUpFront
|
|
2669
|
+
];
|
|
2670
|
+
}(), function() {
|
|
2671
|
+
_HDRLoader._faceFront = [
|
|
2672
|
+
_HDRLoader._leftBottomBack,
|
|
2673
|
+
_HDRLoader._rightBottomBack,
|
|
2674
|
+
_HDRLoader._leftUpBack,
|
|
2675
|
+
_HDRLoader._rightUpBack
|
|
2676
|
+
];
|
|
2677
|
+
}(), function() {
|
|
2678
|
+
_HDRLoader._faceBack = [
|
|
2679
|
+
_HDRLoader._rightBottomFront,
|
|
2680
|
+
_HDRLoader._leftBottomFront,
|
|
2681
|
+
_HDRLoader._rightUpFront,
|
|
2682
|
+
_HDRLoader._leftUpFront
|
|
2683
|
+
];
|
|
2684
|
+
}(), function() {
|
|
2685
|
+
_HDRLoader._tempVector3 = new Vector3();
|
|
2686
|
+
}(), function() {
|
|
2687
|
+
_HDRLoader._temp2Vector3 = new Vector3();
|
|
2688
|
+
}(), function() {
|
|
2689
|
+
_HDRLoader._temp3Vector3 = new Vector3();
|
|
2690
|
+
}(), function() {
|
|
2691
|
+
_HDRLoader._temp4Vector3 = new Vector3();
|
|
2692
|
+
}(), function() {
|
|
2693
|
+
_HDRLoader._temp5Vector3 = new Vector3();
|
|
2694
|
+
}(), _HDRLoader);
|
|
2682
2695
|
HDRLoader = __decorate([
|
|
2683
2696
|
resourceLoader(AssetType.HDR, [
|
|
2684
2697
|
"hdr"
|
|
@@ -3048,19 +3061,21 @@ MaterialLoader = __decorate([
|
|
|
3048
3061
|
], MaterialLoader);
|
|
3049
3062
|
|
|
3050
3063
|
function _defineProperties(target, props) {
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
|
|
3064
|
+
for (var i = 0; i < props.length; i++) {
|
|
3065
|
+
var descriptor = props[i];
|
|
3066
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
3067
|
+
descriptor.configurable = true;
|
|
3068
|
+
|
|
3069
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
3070
|
+
|
|
3071
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
3072
|
+
}
|
|
3058
3073
|
}
|
|
3074
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
3075
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
3076
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
3059
3077
|
|
|
3060
|
-
|
|
3061
|
-
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
3062
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
3063
|
-
return Constructor;
|
|
3078
|
+
return Constructor;
|
|
3064
3079
|
}
|
|
3065
3080
|
|
|
3066
3081
|
var BufferReader = /*#__PURE__*/ function() {
|
|
@@ -3130,7 +3145,7 @@ var BufferReader = /*#__PURE__*/ function() {
|
|
|
3130
3145
|
var strByteLength = this.nextUint16();
|
|
3131
3146
|
var uint8Array = new Uint8Array(this.buffer, this._offset, strByteLength);
|
|
3132
3147
|
this._offset += strByteLength;
|
|
3133
|
-
return
|
|
3148
|
+
return Utils.decodeText(uint8Array);
|
|
3134
3149
|
};
|
|
3135
3150
|
/**
|
|
3136
3151
|
* image data 放在最后
|
|
@@ -3169,7 +3184,7 @@ var BufferReader = /*#__PURE__*/ function() {
|
|
|
3169
3184
|
if (byteLength < maxByteLength) this._offset++;
|
|
3170
3185
|
return new Uint8Array(this._dataView.buffer, this._dataView.byteOffset + byteOffset, byteLength);
|
|
3171
3186
|
};
|
|
3172
|
-
|
|
3187
|
+
_create_class(BufferReader, [
|
|
3173
3188
|
{
|
|
3174
3189
|
key: "offset",
|
|
3175
3190
|
get: function get() {
|
|
@@ -3179,12 +3194,14 @@ var BufferReader = /*#__PURE__*/ function() {
|
|
|
3179
3194
|
]);
|
|
3180
3195
|
return BufferReader;
|
|
3181
3196
|
}();
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3197
|
+
(function() {
|
|
3198
|
+
BufferReader.imageMapping = {
|
|
3199
|
+
0: "image/png",
|
|
3200
|
+
1: "image/jpg",
|
|
3201
|
+
2: "image/webp",
|
|
3202
|
+
3: "ktx"
|
|
3203
|
+
};
|
|
3204
|
+
})();
|
|
3188
3205
|
|
|
3189
3206
|
var decoderMap = {};
|
|
3190
3207
|
/**
|
|
@@ -3213,8 +3230,8 @@ var FileHeader = /*#__PURE__*/ function() {
|
|
|
3213
3230
|
var typeUint8Array = new Uint8Array(arrayBuffer, 7, typeLen);
|
|
3214
3231
|
var nameLen = dataView.getUint16(7 + typeLen, true);
|
|
3215
3232
|
var nameUint8Array = new Uint8Array(arrayBuffer, 9 + typeLen, nameLen);
|
|
3216
|
-
var name =
|
|
3217
|
-
var type =
|
|
3233
|
+
var name = Utils.decodeText(nameUint8Array);
|
|
3234
|
+
var type = Utils.decodeText(typeUint8Array);
|
|
3218
3235
|
var header = new FileHeader();
|
|
3219
3236
|
header.totalLength = totalLen;
|
|
3220
3237
|
header.name = name;
|
|
@@ -3223,7 +3240,7 @@ var FileHeader = /*#__PURE__*/ function() {
|
|
|
3223
3240
|
header.headerLength = nameUint8Array.byteLength + typeUint8Array.byteLength + 9;
|
|
3224
3241
|
return header;
|
|
3225
3242
|
};
|
|
3226
|
-
|
|
3243
|
+
_create_class(FileHeader, [
|
|
3227
3244
|
{
|
|
3228
3245
|
key: "dataLength",
|
|
3229
3246
|
get: function get() {
|
|
@@ -3442,38 +3459,36 @@ Texture2DDecoder = __decorate([
|
|
|
3442
3459
|
decoder("Texture2D")
|
|
3443
3460
|
], Texture2DDecoder);
|
|
3444
3461
|
|
|
3445
|
-
function
|
|
3446
|
-
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
try {
|
|
3451
|
-
Date.prototype.toString.call(Reflect.construct(Date, [], function () { }));
|
|
3452
|
-
return true;
|
|
3453
|
-
} catch (e) {
|
|
3454
|
-
return false;
|
|
3455
|
-
}
|
|
3456
|
-
}
|
|
3462
|
+
function _is_native_reflect_construct() {
|
|
3463
|
+
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
3464
|
+
if (Reflect.construct.sham) return false;
|
|
3465
|
+
if (typeof Proxy === "function") return true;
|
|
3457
3466
|
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
construct = Reflect.construct;
|
|
3461
|
-
} else {
|
|
3462
|
-
construct = function construct(Parent, args, Class) {
|
|
3463
|
-
var a = [null];
|
|
3464
|
-
a.push.apply(a, args);
|
|
3465
|
-
var Constructor = Function.bind.apply(Parent, a);
|
|
3466
|
-
var instance = new Constructor();
|
|
3467
|
-
if (Class) _setPrototypeOf(instance, Class.prototype);
|
|
3468
|
-
return instance;
|
|
3469
|
-
};
|
|
3470
|
-
}
|
|
3467
|
+
try {
|
|
3468
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
3471
3469
|
|
|
3472
|
-
|
|
3470
|
+
return true;
|
|
3471
|
+
} catch (e) {
|
|
3472
|
+
return false;
|
|
3473
|
+
}
|
|
3473
3474
|
}
|
|
3474
3475
|
|
|
3475
3476
|
function _construct(Parent, args, Class) {
|
|
3476
|
-
|
|
3477
|
+
if (_is_native_reflect_construct()) _construct = Reflect.construct;
|
|
3478
|
+
else {
|
|
3479
|
+
_construct = function construct(Parent, args, Class) {
|
|
3480
|
+
var a = [null];
|
|
3481
|
+
a.push.apply(a, args);
|
|
3482
|
+
var Constructor = Function.bind.apply(Parent, a);
|
|
3483
|
+
var instance = new Constructor();
|
|
3484
|
+
|
|
3485
|
+
if (Class) _set_prototype_of(instance, Class.prototype);
|
|
3486
|
+
|
|
3487
|
+
return instance;
|
|
3488
|
+
};
|
|
3489
|
+
}
|
|
3490
|
+
|
|
3491
|
+
return _construct.apply(null, arguments);
|
|
3477
3492
|
}
|
|
3478
3493
|
|
|
3479
3494
|
var ReflectionParser = /*#__PURE__*/ function() {
|
|
@@ -3588,7 +3603,9 @@ var ReflectionParser = /*#__PURE__*/ function() {
|
|
|
3588
3603
|
};
|
|
3589
3604
|
return ReflectionParser;
|
|
3590
3605
|
}();
|
|
3591
|
-
|
|
3606
|
+
(function() {
|
|
3607
|
+
ReflectionParser.customParseComponentHandles = new Map();
|
|
3608
|
+
})();
|
|
3592
3609
|
|
|
3593
3610
|
var PrefabParser = /*#__PURE__*/ function() {
|
|
3594
3611
|
function PrefabParser() {}
|
|
@@ -3842,7 +3859,7 @@ var SceneParserContext = /*#__PURE__*/ function() {
|
|
|
3842
3859
|
};
|
|
3843
3860
|
_proto._organizeEntities = function _organizeEntities() {
|
|
3844
3861
|
var _this_context = this.context, entityConfigMap = _this_context.entityConfigMap, entityMap = _this_context.entityMap, scene = _this_context.scene, rootIds = _this_context.rootIds;
|
|
3845
|
-
for(var _iterator =
|
|
3862
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(rootIds), _step; !(_step = _iterator()).done;){
|
|
3846
3863
|
var rootId = _step.value;
|
|
3847
3864
|
PrefabParser.parseChildren(entityConfigMap, entityMap, rootId);
|
|
3848
3865
|
}
|
|
@@ -4006,7 +4023,7 @@ var SourceFontLoader = /*#__PURE__*/ function(Loader) {
|
|
|
4006
4023
|
});
|
|
4007
4024
|
};
|
|
4008
4025
|
_proto._registerFont = function _registerFont(fontName, fontUrl) {
|
|
4009
|
-
return
|
|
4026
|
+
return _async_to_generator(function() {
|
|
4010
4027
|
var fontFace;
|
|
4011
4028
|
return __generator(this, function(_state) {
|
|
4012
4029
|
switch(_state.label){
|
|
@@ -4043,6 +4060,7 @@ var SpriteAtlasLoader = /*#__PURE__*/ function(Loader) {
|
|
|
4043
4060
|
_this = Loader.apply(this, arguments) || this;
|
|
4044
4061
|
_this._tempRect = new Rect();
|
|
4045
4062
|
_this._tempVec2 = new Vector2();
|
|
4063
|
+
_this._tempVec4 = new Vector4();
|
|
4046
4064
|
return _this;
|
|
4047
4065
|
}
|
|
4048
4066
|
var _proto = SpriteAtlasLoader.prototype;
|
|
@@ -4060,57 +4078,65 @@ var SpriteAtlasLoader = /*#__PURE__*/ function(Loader) {
|
|
|
4060
4078
|
}));
|
|
4061
4079
|
chainPromises.push(configPromise);
|
|
4062
4080
|
configPromise.then(function(atlasData) {
|
|
4063
|
-
var
|
|
4064
|
-
|
|
4065
|
-
|
|
4066
|
-
|
|
4067
|
-
|
|
4068
|
-
|
|
4069
|
-
|
|
4070
|
-
|
|
4071
|
-
|
|
4072
|
-
return imagePromises.then(function(imgs) {
|
|
4073
|
-
var engine = resourceManager.engine;
|
|
4074
|
-
// Generate a SpriteAtlas object.
|
|
4075
|
-
var tempRect = _this._tempRect, tempVec2 = _this._tempVec2;
|
|
4076
|
-
var spriteAtlas = new SpriteAtlas(engine);
|
|
4077
|
-
for(var i = 0; i < atlasItemsLen; i++){
|
|
4078
|
-
// Generate Texture2D according to configuration.
|
|
4079
|
-
var originalImg = imgs[i];
|
|
4080
|
-
var width = originalImg.width, height = originalImg.height;
|
|
4081
|
-
var texture = new Texture2D(engine, width, height, format);
|
|
4082
|
-
texture.setImageSource(originalImg);
|
|
4083
|
-
texture.generateMipmaps();
|
|
4084
|
-
// Generate all the sprites on this texture.
|
|
4085
|
-
var atlasItem = atlasItems[i];
|
|
4086
|
-
var sprites = atlasItem.sprites;
|
|
4087
|
-
var sourceWidthReciprocal = 1.0 / width;
|
|
4088
|
-
var sourceHeightReciprocal = 1.0 / height;
|
|
4089
|
-
for(var j = sprites.length - 1; j >= 0; j--){
|
|
4090
|
-
var atlasSprite = sprites[j];
|
|
4091
|
-
var region = atlasSprite.region, atlasRegionOffset = atlasSprite.atlasRegionOffset, atlasRegion = atlasSprite.atlasRegion, id = atlasSprite.id, pivot = atlasSprite.pivot;
|
|
4092
|
-
var sprite = new Sprite(engine, texture, region ? tempRect.set(region.x, region.y, region.w, region.h) : undefined, pivot ? tempVec2.set(pivot.x, pivot.y) : undefined, undefined, atlasSprite.name);
|
|
4093
|
-
sprite.atlasRegion.set(atlasRegion.x * sourceWidthReciprocal, atlasRegion.y * sourceHeightReciprocal, atlasRegion.w * sourceWidthReciprocal, atlasRegion.h * sourceHeightReciprocal);
|
|
4094
|
-
atlasSprite.atlasRotated && (sprite.atlasRotated = true);
|
|
4095
|
-
if (atlasRegionOffset) {
|
|
4096
|
-
var offsetLeft = atlasRegionOffset.x, offsetTop = atlasRegionOffset.y, offsetRight = atlasRegionOffset.z, offsetBottom = atlasRegionOffset.w;
|
|
4097
|
-
sprite.atlasRegionOffset.set(offsetLeft * sourceWidthReciprocal, offsetTop * sourceHeightReciprocal, offsetRight * sourceWidthReciprocal, offsetBottom * sourceHeightReciprocal);
|
|
4081
|
+
var _loop = function(i) {
|
|
4082
|
+
var atlasItem = atlasItems[i];
|
|
4083
|
+
if (atlasItem.img) {
|
|
4084
|
+
chainPromises.push(resourceManager.load({
|
|
4085
|
+
url: atlasItem.img,
|
|
4086
|
+
type: AssetType.Texture2D,
|
|
4087
|
+
params: {
|
|
4088
|
+
format: format,
|
|
4089
|
+
mipmap: mipmap
|
|
4098
4090
|
}
|
|
4099
|
-
|
|
4091
|
+
}).then(function(texture) {
|
|
4092
|
+
anisoLevel && (texture.anisoLevel = anisoLevel);
|
|
4093
|
+
filterMode !== undefined && (texture.filterMode = filterMode);
|
|
4094
|
+
wrapModeU !== undefined && (texture.wrapModeU = wrapModeU);
|
|
4095
|
+
wrapModeV !== undefined && (texture.wrapModeV = wrapModeV);
|
|
4096
|
+
for(var i = 0; i < atlasItem.sprites.length; i++){
|
|
4100
4097
|
// @ts-ignore
|
|
4101
|
-
|
|
4098
|
+
spriteAtlas._addSprite(_this._makeSprite(engine, atlasItem.sprites[i], texture));
|
|
4102
4099
|
}
|
|
4100
|
+
}).catch(reject));
|
|
4101
|
+
} else {
|
|
4102
|
+
for(var i1 = 0; i1 < atlasItem.sprites.length; i1++){
|
|
4103
4103
|
// @ts-ignore
|
|
4104
|
-
spriteAtlas._addSprite(
|
|
4104
|
+
spriteAtlas._addSprite(_this._makeSprite(engine, atlasItem.sprites[i1]));
|
|
4105
4105
|
}
|
|
4106
4106
|
}
|
|
4107
|
+
};
|
|
4108
|
+
var atlasItems = atlasData.atlasItems, mipmap = atlasData.mipmap, anisoLevel = atlasData.anisoLevel, filterMode = atlasData.filterMode, wrapModeU = atlasData.wrapModeU, wrapModeV = atlasData.wrapModeV, format = atlasData.format;
|
|
4109
|
+
var atlasItemsLen = atlasItems ? atlasItems.length : 0;
|
|
4110
|
+
var engine = resourceManager.engine;
|
|
4111
|
+
var spriteAtlas = new SpriteAtlas(engine);
|
|
4112
|
+
if (atlasItemsLen < 0) {
|
|
4107
4113
|
resolve(spriteAtlas);
|
|
4108
|
-
|
|
4109
|
-
|
|
4110
|
-
|
|
4111
|
-
|
|
4114
|
+
return;
|
|
4115
|
+
}
|
|
4116
|
+
chainPromises.length = 0;
|
|
4117
|
+
for(var i = 0; i < atlasItems.length; i++)_loop(i);
|
|
4118
|
+
AssetPromise.all(chainPromises).then(function() {
|
|
4119
|
+
resolve(spriteAtlas);
|
|
4120
|
+
}).catch(reject);
|
|
4121
|
+
}).catch(reject);
|
|
4112
4122
|
});
|
|
4113
4123
|
};
|
|
4124
|
+
_proto._makeSprite = function _makeSprite(engine, config, texture) {
|
|
4125
|
+
// Generate a SpriteAtlas object.
|
|
4126
|
+
var region = config.region, atlasRegionOffset = config.atlasRegionOffset, atlasRegion = config.atlasRegion, pivot = config.pivot, border = config.border;
|
|
4127
|
+
var sprite = new Sprite(engine, texture, region ? this._tempRect.set(region.x, region.y, region.w, region.h) : undefined, pivot ? this._tempVec2.set(pivot.x, pivot.y) : undefined, border ? this._tempVec4.set(border.x, border.y, border.z, border.w) : undefined, config.name);
|
|
4128
|
+
if (texture) {
|
|
4129
|
+
var invW = 1 / texture.width;
|
|
4130
|
+
var invH = 1 / texture.height;
|
|
4131
|
+
sprite.atlasRegion.set(atlasRegion.x * invW, atlasRegion.y * invH, atlasRegion.w * invW, atlasRegion.h * invH);
|
|
4132
|
+
if (atlasRegionOffset) {
|
|
4133
|
+
var offsetLeft = atlasRegionOffset.x, offsetTop = atlasRegionOffset.y, offsetRight = atlasRegionOffset.z, offsetBottom = atlasRegionOffset.w;
|
|
4134
|
+
sprite.atlasRegionOffset.set(offsetLeft * invW, offsetTop * invH, offsetRight * invW, offsetBottom * invH);
|
|
4135
|
+
}
|
|
4136
|
+
config.atlasRotated && (sprite.atlasRotated = true);
|
|
4137
|
+
}
|
|
4138
|
+
return sprite;
|
|
4139
|
+
};
|
|
4114
4140
|
return SpriteAtlasLoader;
|
|
4115
4141
|
}(Loader);
|
|
4116
4142
|
SpriteAtlasLoader = __decorate([
|
|
@@ -4131,13 +4157,19 @@ var SpriteLoader = /*#__PURE__*/ function(Loader) {
|
|
|
4131
4157
|
_this.request(item.url, _extends({}, item, {
|
|
4132
4158
|
type: "json"
|
|
4133
4159
|
})).then(function(data) {
|
|
4134
|
-
|
|
4135
|
-
|
|
4136
|
-
|
|
4137
|
-
|
|
4138
|
-
|
|
4139
|
-
|
|
4140
|
-
|
|
4160
|
+
if (data.belongToAtlas) {
|
|
4161
|
+
resourceManager// @ts-ignore
|
|
4162
|
+
.getResourceByRef(data.belongToAtlas).then(function(atlas) {
|
|
4163
|
+
resolve(atlas.getSprite(data.fullPath));
|
|
4164
|
+
}).catch(reject);
|
|
4165
|
+
} else if (data.texture) {
|
|
4166
|
+
resourceManager// @ts-ignore
|
|
4167
|
+
.getResourceByRef(data.texture).then(function(texture) {
|
|
4168
|
+
resolve(new Sprite(resourceManager.engine, texture, data.region, data.pivot, data.border));
|
|
4169
|
+
}).catch(reject);
|
|
4170
|
+
} else {
|
|
4171
|
+
resolve(new Sprite(resourceManager.engine, null, data.region, data.pivot, data.border));
|
|
4172
|
+
}
|
|
4141
4173
|
}).catch(reject);
|
|
4142
4174
|
});
|
|
4143
4175
|
};
|
|
@@ -4161,9 +4193,7 @@ SpriteLoader = __decorate([
|
|
|
4161
4193
|
return _this;
|
|
4162
4194
|
}
|
|
4163
4195
|
var _proto = Texture2DContentRestorer.prototype;
|
|
4164
|
-
|
|
4165
|
-
* @override
|
|
4166
|
-
*/ _proto.restoreContent = function restoreContent() {
|
|
4196
|
+
_proto.restoreContent = function restoreContent() {
|
|
4167
4197
|
var _this = this;
|
|
4168
4198
|
return request(this.url, this.requestConfig).then(function(image) {
|
|
4169
4199
|
var resource = _this.resource;
|
|
@@ -4181,9 +4211,7 @@ var Texture2DLoader = /*#__PURE__*/ function(Loader) {
|
|
|
4181
4211
|
return Loader.apply(this, arguments);
|
|
4182
4212
|
}
|
|
4183
4213
|
var _proto = Texture2DLoader.prototype;
|
|
4184
|
-
|
|
4185
|
-
* @override
|
|
4186
|
-
*/ _proto.load = function load(item, resourceManager) {
|
|
4214
|
+
_proto.load = function load(item, resourceManager) {
|
|
4187
4215
|
var _this = this;
|
|
4188
4216
|
return new AssetPromise(function(resolve, reject) {
|
|
4189
4217
|
var url = item.url;
|
|
@@ -4229,9 +4257,7 @@ Texture2DLoader = __decorate([
|
|
|
4229
4257
|
return _this;
|
|
4230
4258
|
}
|
|
4231
4259
|
var _proto = TextureCubeContentRestorer.prototype;
|
|
4232
|
-
|
|
4233
|
-
* @override
|
|
4234
|
-
*/ _proto.restoreContent = function restoreContent() {
|
|
4260
|
+
_proto.restoreContent = function restoreContent() {
|
|
4235
4261
|
var _this = this;
|
|
4236
4262
|
return new AssetPromise(function(resolve, reject) {
|
|
4237
4263
|
Promise.all(_this.urls.map(function(url) {
|
|
@@ -4257,9 +4283,7 @@ var TextureCubeLoader = /*#__PURE__*/ function(Loader) {
|
|
|
4257
4283
|
return Loader.apply(this, arguments);
|
|
4258
4284
|
}
|
|
4259
4285
|
var _proto = TextureCubeLoader.prototype;
|
|
4260
|
-
|
|
4261
|
-
* @override
|
|
4262
|
-
*/ _proto.load = function load(item, resourceManager) {
|
|
4286
|
+
_proto.load = function load(item, resourceManager) {
|
|
4263
4287
|
var _this = this;
|
|
4264
4288
|
return new AssetPromise(function(resolve, reject) {
|
|
4265
4289
|
var urls = item.urls;
|
|
@@ -4362,7 +4386,7 @@ var SceneLoader = /*#__PURE__*/ function(Loader) {
|
|
|
4362
4386
|
backgroundPromise = resourceManager.getResourceByRef(background.sky).then(function(light) {
|
|
4363
4387
|
var sky = scene.background.sky;
|
|
4364
4388
|
var skyMaterial = new SkyBoxMaterial(engine);
|
|
4365
|
-
skyMaterial.
|
|
4389
|
+
skyMaterial.texture = light.specularTexture;
|
|
4366
4390
|
skyMaterial.textureDecodeRGBM = true;
|
|
4367
4391
|
sky.material = skyMaterial;
|
|
4368
4392
|
sky.mesh = PrimitiveMesh.createCuboid(engine, 1, 1, 1);
|
|
@@ -4403,7 +4427,7 @@ SceneLoader = __decorate([
|
|
|
4403
4427
|
"prefab"
|
|
4404
4428
|
], true)
|
|
4405
4429
|
], SceneLoader);
|
|
4406
|
-
ReflectionParser.registerCustomParseComponent("TextRenderer", /*#__PURE__*/
|
|
4430
|
+
ReflectionParser.registerCustomParseComponent("TextRenderer", /*#__PURE__*/ _async_to_generator(function(instance, item, engine) {
|
|
4407
4431
|
var props;
|
|
4408
4432
|
return __generator(this, function(_state) {
|
|
4409
4433
|
props = item.props;
|
|
@@ -4425,16 +4449,12 @@ var KHR_draco_mesh_compression = (_KHR_draco_mesh_compression = /*#__PURE__*/ fu
|
|
|
4425
4449
|
return GLTFExtensionParser.apply(this, arguments);
|
|
4426
4450
|
}
|
|
4427
4451
|
var _proto = KHR_draco_mesh_compression1.prototype;
|
|
4428
|
-
|
|
4429
|
-
* @override
|
|
4430
|
-
*/ _proto.initialize = function initialize() {
|
|
4452
|
+
_proto.initialize = function initialize() {
|
|
4431
4453
|
if (!KHR_draco_mesh_compression._decoder) {
|
|
4432
4454
|
KHR_draco_mesh_compression._decoder = new DRACODecoder();
|
|
4433
4455
|
}
|
|
4434
4456
|
};
|
|
4435
|
-
|
|
4436
|
-
* @override
|
|
4437
|
-
*/ _proto.createAndParse = function createAndParse(context, schema, glTFPrimitive, glTFMesh) {
|
|
4457
|
+
_proto.createAndParse = function createAndParse(context, schema, glTFPrimitive, glTFMesh) {
|
|
4438
4458
|
var _this = this;
|
|
4439
4459
|
var glTF = context.glTF, buffers = context.buffers, engine = context.glTFResource.engine;
|
|
4440
4460
|
var bufferViews = glTF.bufferViews, accessors = glTF.accessors;
|
|
@@ -4447,18 +4467,18 @@ var KHR_draco_mesh_compression = (_KHR_draco_mesh_compression = /*#__PURE__*/ fu
|
|
|
4447
4467
|
for(var attributeName1 in glTFPrimitive.attributes){
|
|
4448
4468
|
if (gltfAttributeMap[attributeName1] !== undefined) {
|
|
4449
4469
|
var accessorDef = accessors[glTFPrimitive.attributes[attributeName1]];
|
|
4450
|
-
attributeTypeMap[attributeName1] =
|
|
4470
|
+
attributeTypeMap[attributeName1] = GLTFUtils.getComponentType(accessorDef.componentType).name;
|
|
4451
4471
|
}
|
|
4452
4472
|
}
|
|
4453
4473
|
var indexAccessor = accessors[glTFPrimitive.indices];
|
|
4454
|
-
var indexType =
|
|
4474
|
+
var indexType = GLTFUtils.getComponentType(indexAccessor.componentType).name;
|
|
4455
4475
|
var taskConfig = {
|
|
4456
4476
|
attributeIDs: attributeMap,
|
|
4457
4477
|
attributeTypes: attributeTypeMap,
|
|
4458
4478
|
useUniqueIDs: true,
|
|
4459
4479
|
indexType: indexType
|
|
4460
4480
|
};
|
|
4461
|
-
var buffer =
|
|
4481
|
+
var buffer = GLTFUtils.getBufferViewData(bufferViews[bufferViewIndex], buffers);
|
|
4462
4482
|
return KHR_draco_mesh_compression._decoder.decode(buffer, taskConfig).then(function(decodedGeometry) {
|
|
4463
4483
|
var mesh = new ModelMesh(engine, glTFMesh.name);
|
|
4464
4484
|
return _this._parseMeshFromGLTFPrimitiveDraco(mesh, glTFMesh, glTFPrimitive, glTF, function(attributeSemantic) {
|
|
@@ -4481,7 +4501,7 @@ var KHR_draco_mesh_compression = (_KHR_draco_mesh_compression = /*#__PURE__*/ fu
|
|
|
4481
4501
|
var accessors = gltf.accessors;
|
|
4482
4502
|
var accessor = accessors[attributes["POSITION"]];
|
|
4483
4503
|
var positionBuffer = getVertexBufferData("POSITION");
|
|
4484
|
-
var positions =
|
|
4504
|
+
var positions = GLTFUtils.floatBufferToVector3Array(positionBuffer);
|
|
4485
4505
|
mesh.setPositions(positions);
|
|
4486
4506
|
var bounds = mesh.bounds;
|
|
4487
4507
|
vertexCount = accessor.count;
|
|
@@ -4508,55 +4528,55 @@ var KHR_draco_mesh_compression = (_KHR_draco_mesh_compression = /*#__PURE__*/ fu
|
|
|
4508
4528
|
var bufferData = getVertexBufferData(attributeSemantic);
|
|
4509
4529
|
switch(attributeSemantic){
|
|
4510
4530
|
case "NORMAL":
|
|
4511
|
-
var normals =
|
|
4531
|
+
var normals = GLTFUtils.floatBufferToVector3Array(bufferData);
|
|
4512
4532
|
mesh.setNormals(normals);
|
|
4513
4533
|
break;
|
|
4514
4534
|
case "TEXCOORD_0":
|
|
4515
|
-
var texturecoords =
|
|
4535
|
+
var texturecoords = GLTFUtils.floatBufferToVector2Array(bufferData);
|
|
4516
4536
|
mesh.setUVs(texturecoords, 0);
|
|
4517
4537
|
break;
|
|
4518
4538
|
case "TEXCOORD_1":
|
|
4519
|
-
var texturecoords1 =
|
|
4539
|
+
var texturecoords1 = GLTFUtils.floatBufferToVector2Array(bufferData);
|
|
4520
4540
|
mesh.setUVs(texturecoords1, 1);
|
|
4521
4541
|
break;
|
|
4522
4542
|
case "TEXCOORD_2":
|
|
4523
|
-
var texturecoords2 =
|
|
4543
|
+
var texturecoords2 = GLTFUtils.floatBufferToVector2Array(bufferData);
|
|
4524
4544
|
mesh.setUVs(texturecoords2, 2);
|
|
4525
4545
|
break;
|
|
4526
4546
|
case "TEXCOORD_3":
|
|
4527
|
-
var texturecoords3 =
|
|
4547
|
+
var texturecoords3 = GLTFUtils.floatBufferToVector2Array(bufferData);
|
|
4528
4548
|
mesh.setUVs(texturecoords3, 3);
|
|
4529
4549
|
break;
|
|
4530
4550
|
case "TEXCOORD_4":
|
|
4531
|
-
var texturecoords4 =
|
|
4551
|
+
var texturecoords4 = GLTFUtils.floatBufferToVector2Array(bufferData);
|
|
4532
4552
|
mesh.setUVs(texturecoords4, 4);
|
|
4533
4553
|
break;
|
|
4534
4554
|
case "TEXCOORD_5":
|
|
4535
|
-
var texturecoords5 =
|
|
4555
|
+
var texturecoords5 = GLTFUtils.floatBufferToVector2Array(bufferData);
|
|
4536
4556
|
mesh.setUVs(texturecoords5, 5);
|
|
4537
4557
|
break;
|
|
4538
4558
|
case "TEXCOORD_6":
|
|
4539
|
-
var texturecoords6 =
|
|
4559
|
+
var texturecoords6 = GLTFUtils.floatBufferToVector2Array(bufferData);
|
|
4540
4560
|
mesh.setUVs(texturecoords6, 6);
|
|
4541
4561
|
break;
|
|
4542
4562
|
case "TEXCOORD_7":
|
|
4543
|
-
var texturecoords7 =
|
|
4563
|
+
var texturecoords7 = GLTFUtils.floatBufferToVector2Array(bufferData);
|
|
4544
4564
|
mesh.setUVs(texturecoords7, 7);
|
|
4545
4565
|
break;
|
|
4546
4566
|
case "COLOR_0":
|
|
4547
|
-
var colors =
|
|
4567
|
+
var colors = GLTFUtils.floatBufferToColorArray(bufferData, accessors[attributes["COLOR_0"]].type === AccessorType.VEC3);
|
|
4548
4568
|
mesh.setColors(colors);
|
|
4549
4569
|
break;
|
|
4550
4570
|
case "TANGENT":
|
|
4551
|
-
var tangents =
|
|
4571
|
+
var tangents = GLTFUtils.floatBufferToVector4Array(bufferData);
|
|
4552
4572
|
mesh.setTangents(tangents);
|
|
4553
4573
|
break;
|
|
4554
4574
|
case "JOINTS_0":
|
|
4555
|
-
var joints =
|
|
4575
|
+
var joints = GLTFUtils.floatBufferToVector4Array(bufferData);
|
|
4556
4576
|
mesh.setBoneIndices(joints);
|
|
4557
4577
|
break;
|
|
4558
4578
|
case "WEIGHTS_0":
|
|
4559
|
-
var weights =
|
|
4579
|
+
var weights = GLTFUtils.floatBufferToVector4Array(bufferData);
|
|
4560
4580
|
mesh.setBoneWeights(weights);
|
|
4561
4581
|
break;
|
|
4562
4582
|
}
|
|
@@ -4576,7 +4596,9 @@ var KHR_draco_mesh_compression = (_KHR_draco_mesh_compression = /*#__PURE__*/ fu
|
|
|
4576
4596
|
return Promise.resolve(mesh);
|
|
4577
4597
|
};
|
|
4578
4598
|
return KHR_draco_mesh_compression1;
|
|
4579
|
-
}(GLTFExtensionParser),
|
|
4599
|
+
}(GLTFExtensionParser), function() {
|
|
4600
|
+
_KHR_draco_mesh_compression._tempVector3 = new Vector3();
|
|
4601
|
+
}(), _KHR_draco_mesh_compression);
|
|
4580
4602
|
KHR_draco_mesh_compression = __decorate([
|
|
4581
4603
|
registerGLTFExtension("KHR_draco_mesh_compression", GLTFExtensionMode.CreateAndParse)
|
|
4582
4604
|
], KHR_draco_mesh_compression);
|
|
@@ -4587,9 +4609,7 @@ var KHR_lights_punctual = /*#__PURE__*/ function(GLTFExtensionParser) {
|
|
|
4587
4609
|
return GLTFExtensionParser.apply(this, arguments);
|
|
4588
4610
|
}
|
|
4589
4611
|
var _proto = KHR_lights_punctual.prototype;
|
|
4590
|
-
|
|
4591
|
-
* @override
|
|
4592
|
-
*/ _proto.additiveParse = function additiveParse(context, entity, extensionSchema) {
|
|
4612
|
+
_proto.additiveParse = function additiveParse(context, entity, extensionSchema) {
|
|
4593
4613
|
var lightsSchema = context.glTF.extensions.KHR_lights_punctual.lights;
|
|
4594
4614
|
var lightSchema = lightsSchema[extensionSchema.light];
|
|
4595
4615
|
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;
|
|
@@ -4629,9 +4649,7 @@ var KHR_materials_clearcoat = /*#__PURE__*/ function(GLTFExtensionParser) {
|
|
|
4629
4649
|
return GLTFExtensionParser.apply(this, arguments);
|
|
4630
4650
|
}
|
|
4631
4651
|
var _proto = KHR_materials_clearcoat.prototype;
|
|
4632
|
-
|
|
4633
|
-
* @override
|
|
4634
|
-
*/ _proto.additiveParse = function additiveParse(context, material, schema) {
|
|
4652
|
+
_proto.additiveParse = function additiveParse(context, material, schema) {
|
|
4635
4653
|
var textures = context.glTFResource.textures;
|
|
4636
4654
|
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;
|
|
4637
4655
|
material.clearCoat = clearcoatFactor;
|
|
@@ -4661,9 +4679,7 @@ var KHR_materials_pbrSpecularGlossiness = /*#__PURE__*/ function(GLTFExtensionPa
|
|
|
4661
4679
|
return GLTFExtensionParser.apply(this, arguments);
|
|
4662
4680
|
}
|
|
4663
4681
|
var _proto = KHR_materials_pbrSpecularGlossiness.prototype;
|
|
4664
|
-
|
|
4665
|
-
* @override
|
|
4666
|
-
*/ _proto.createAndParse = function createAndParse(context, schema, ownerSchema) {
|
|
4682
|
+
_proto.createAndParse = function createAndParse(context, schema, ownerSchema) {
|
|
4667
4683
|
var _context_glTFResource = context.glTFResource, engine = _context_glTFResource.engine, textures = _context_glTFResource.textures;
|
|
4668
4684
|
var material = new PBRSpecularMaterial(engine);
|
|
4669
4685
|
var diffuseFactor = schema.diffuseFactor, diffuseTexture = schema.diffuseTexture, specularFactor = schema.specularFactor, glossinessFactor = schema.glossinessFactor, specularGlossinessTexture = schema.specularGlossinessTexture;
|
|
@@ -4700,9 +4716,7 @@ var KHR_materials_unlit = /*#__PURE__*/ function(GLTFExtensionParser) {
|
|
|
4700
4716
|
return GLTFExtensionParser.apply(this, arguments);
|
|
4701
4717
|
}
|
|
4702
4718
|
var _proto = KHR_materials_unlit.prototype;
|
|
4703
|
-
|
|
4704
|
-
* @override
|
|
4705
|
-
*/ _proto.createAndParse = function createAndParse(context, _, ownerSchema) {
|
|
4719
|
+
_proto.createAndParse = function createAndParse(context, _, ownerSchema) {
|
|
4706
4720
|
var engine = context.glTFResource.engine;
|
|
4707
4721
|
var material = new UnlitMaterial(engine);
|
|
4708
4722
|
material.name = ownerSchema.name;
|
|
@@ -4732,9 +4746,7 @@ var KHR_texture_transform = /*#__PURE__*/ function(GLTFExtensionParser) {
|
|
|
4732
4746
|
return GLTFExtensionParser.apply(this, arguments);
|
|
4733
4747
|
}
|
|
4734
4748
|
var _proto = KHR_texture_transform.prototype;
|
|
4735
|
-
|
|
4736
|
-
* @override
|
|
4737
|
-
*/ _proto.additiveParse = function additiveParse(context, material, schema) {
|
|
4749
|
+
_proto.additiveParse = function additiveParse(context, material, schema) {
|
|
4738
4750
|
var offset = schema.offset, rotation = schema.rotation, scale = schema.scale, texCoord = schema.texCoord;
|
|
4739
4751
|
if (offset) {
|
|
4740
4752
|
material.tilingOffset.z = offset[0];
|
|
@@ -4757,34 +4769,30 @@ KHR_texture_transform = __decorate([
|
|
|
4757
4769
|
registerGLTFExtension("KHR_texture_transform", GLTFExtensionMode.AdditiveParse)
|
|
4758
4770
|
], KHR_texture_transform);
|
|
4759
4771
|
|
|
4760
|
-
var
|
|
4761
|
-
_inherits(
|
|
4762
|
-
function
|
|
4772
|
+
var GALACEAN_materials_remap = /*#__PURE__*/ function(GLTFExtensionParser) {
|
|
4773
|
+
_inherits(GALACEAN_materials_remap, GLTFExtensionParser);
|
|
4774
|
+
function GALACEAN_materials_remap() {
|
|
4763
4775
|
return GLTFExtensionParser.apply(this, arguments);
|
|
4764
4776
|
}
|
|
4765
|
-
var _proto =
|
|
4766
|
-
|
|
4767
|
-
* @override
|
|
4768
|
-
*/ _proto.createAndParse = function createAndParse(context, schema) {
|
|
4777
|
+
var _proto = GALACEAN_materials_remap.prototype;
|
|
4778
|
+
_proto.createAndParse = function createAndParse(context, schema) {
|
|
4769
4779
|
var engine = context.glTFResource.engine;
|
|
4770
4780
|
// @ts-ignore
|
|
4771
4781
|
return engine.resourceManager.getResourceByRef(schema);
|
|
4772
4782
|
};
|
|
4773
|
-
return
|
|
4783
|
+
return GALACEAN_materials_remap;
|
|
4774
4784
|
}(GLTFExtensionParser);
|
|
4775
|
-
|
|
4776
|
-
registerGLTFExtension("
|
|
4777
|
-
],
|
|
4785
|
+
GALACEAN_materials_remap = __decorate([
|
|
4786
|
+
registerGLTFExtension("GALACEAN_materials_remap", GLTFExtensionMode.CreateAndParse)
|
|
4787
|
+
], GALACEAN_materials_remap);
|
|
4778
4788
|
|
|
4779
|
-
var
|
|
4780
|
-
_inherits(
|
|
4781
|
-
function
|
|
4789
|
+
var GALACEAN_animation_event = /*#__PURE__*/ function(GLTFExtensionParser) {
|
|
4790
|
+
_inherits(GALACEAN_animation_event, GLTFExtensionParser);
|
|
4791
|
+
function GALACEAN_animation_event() {
|
|
4782
4792
|
return GLTFExtensionParser.apply(this, arguments);
|
|
4783
4793
|
}
|
|
4784
|
-
var _proto =
|
|
4785
|
-
|
|
4786
|
-
* @override
|
|
4787
|
-
*/ _proto.additiveParse = function additiveParse(context, animationClip, schema) {
|
|
4794
|
+
var _proto = GALACEAN_animation_event.prototype;
|
|
4795
|
+
_proto.additiveParse = function additiveParse(context, animationClip, schema) {
|
|
4788
4796
|
context.glTFResource.engine;
|
|
4789
4797
|
var events = schema.events;
|
|
4790
4798
|
events.map(function(eventData) {
|
|
@@ -4795,11 +4803,11 @@ var OASIS_animation_event = /*#__PURE__*/ function(GLTFExtensionParser) {
|
|
|
4795
4803
|
animationClip.addEvent(event);
|
|
4796
4804
|
});
|
|
4797
4805
|
};
|
|
4798
|
-
return
|
|
4806
|
+
return GALACEAN_animation_event;
|
|
4799
4807
|
}(GLTFExtensionParser);
|
|
4800
|
-
|
|
4801
|
-
registerGLTFExtension("
|
|
4802
|
-
],
|
|
4808
|
+
GALACEAN_animation_event = __decorate([
|
|
4809
|
+
registerGLTFExtension("GALACEAN_animation_event", GLTFExtensionMode.AdditiveParse)
|
|
4810
|
+
], GALACEAN_animation_event);
|
|
4803
4811
|
|
|
4804
|
-
export { AnimationClipDecoder, ComponentMap, EditorTextureLoader, GLTFAnimationParser, GLTFBufferParser, GLTFEntityParser, GLTFExtensionMode, GLTFExtensionParser, GLTFMaterialParser, GLTFMeshParser, GLTFParser, GLTFParserContext, GLTFPipeline, GLTFResource, GLTFSceneParser, GLTFSkinParser, GLTFTextureParser,
|
|
4812
|
+
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, Texture2DDecoder, decode, parseSingleKTX, registerGLTFExtension };
|
|
4805
4813
|
//# sourceMappingURL=module.js.map
|