@galacean/engine-loader 1.0.0-beta.0 → 1.0.0-beta.10
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 +164 -123
- package/dist/main.js.map +1 -1
- package/dist/miniprogram.js +164 -123
- package/dist/module.js +166 -125
- package/dist/module.js.map +1 -1
- package/package.json +5 -5
- package/types/GLTFContentRestorer.d.ts +1 -4
- package/types/GLTFLoader.d.ts +0 -3
- package/types/Texture2DContentRestorer.d.ts +0 -3
- package/types/TextureCubeContentRestorer.d.ts +0 -3
- package/types/gltf/GLTFParser.d.ts +9 -0
- package/types/gltf/GLTFResource.d.ts +1 -1
- package/types/gltf/GLTFUtil.d.ts +53 -0
- package/types/gltf/GLTFUtils.d.ts +1 -1
- package/types/gltf/Schema.d.ts +814 -0
- package/types/gltf/extensions/ExtensionParser.d.ts +8 -0
- package/types/gltf/extensions/GLTFExtensionSchema.d.ts +1 -1
- package/types/gltf/extensions/KHR_materials_ior.d.ts +1 -0
- package/types/gltf/extensions/Schema.d.ts +142 -0
- package/types/gltf/extensions/index.d.ts +1 -0
- package/types/gltf/parser/AnimationParser.d.ts +7 -0
- package/types/gltf/parser/BufferParser.d.ts +7 -0
- package/types/gltf/parser/EntityParser.d.ts +9 -0
- package/types/gltf/parser/GLTFMeshParser.d.ts +1 -1
- package/types/gltf/parser/GLTFParser.d.ts +1 -1
- package/types/gltf/parser/GLTFParserContext.d.ts +1 -1
- package/types/gltf/parser/MaterialParser.d.ts +8 -0
- package/types/gltf/parser/MeshParser.d.ts +13 -0
- package/types/gltf/parser/Parser.d.ts +21 -0
- package/types/gltf/parser/ParserContext.d.ts +46 -0
- package/types/gltf/parser/SceneParser.d.ts +11 -0
- package/types/gltf/parser/SkinParser.d.ts +6 -0
- package/types/gltf/parser/TextureParser.d.ts +8 -0
- package/types/gltf/parser/Validator.d.ts +5 -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/SceneSchema.d.ts +41 -0
- package/types/resource-deserialize/resources/schema/index.d.ts +3 -0
package/dist/module.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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,
|
|
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, Animator, BlinnPhongMaterial, MeshRenderer, Skin, TextureWrapMode as TextureWrapMode$1, Texture2D, EngineObject, 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
3
|
import { GLCompressedTextureInternalFormat } from '@galacean/engine-rhi-webgl';
|
|
4
4
|
import { DRACODecoder } from '@galacean/engine-draco';
|
|
@@ -393,9 +393,7 @@ function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
|
|
|
393
393
|
return _this;
|
|
394
394
|
}
|
|
395
395
|
var _proto = GLTFContentRestorer.prototype;
|
|
396
|
-
|
|
397
|
-
* @override
|
|
398
|
-
*/ _proto.restoreContent = function restoreContent() {
|
|
396
|
+
_proto.restoreContent = function restoreContent() {
|
|
399
397
|
var _this = this;
|
|
400
398
|
return new AssetPromise(function(resolve, reject) {
|
|
401
399
|
Promise.all(_this.bufferRequests.map(function(bufferRequestInfo) {
|
|
@@ -1821,21 +1819,31 @@ var GLTFMeshParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
1821
1819
|
var vertexCount;
|
|
1822
1820
|
var bufferBindIndex = 0;
|
|
1823
1821
|
var positions;
|
|
1824
|
-
|
|
1822
|
+
var boneIndices;
|
|
1823
|
+
var boneWeights;
|
|
1824
|
+
if (keepMeshData) {
|
|
1825
|
+
positions = new Array(vertexCount);
|
|
1826
|
+
boneIndices = new Array(vertexCount);
|
|
1827
|
+
boneWeights = new Array(vertexCount);
|
|
1828
|
+
}
|
|
1825
1829
|
for(var attribute in attributes){
|
|
1826
1830
|
var accessor = accessors[attributes[attribute]];
|
|
1827
1831
|
var accessorBuffer = GLTFUtils.getAccessorBuffer(context, gltf.bufferViews, accessor);
|
|
1828
1832
|
var dataElementSize = GLTFUtils.getAccessorTypeSize(accessor.type);
|
|
1829
|
-
var
|
|
1833
|
+
var accessorCount = accessor.count;
|
|
1830
1834
|
var vertices = accessorBuffer.data;
|
|
1831
1835
|
var vertexElement = void 0;
|
|
1832
1836
|
var meshId = mesh.instanceId;
|
|
1833
1837
|
var vertexBindingInfos = accessorBuffer.vertexBindingInfos;
|
|
1834
|
-
var
|
|
1838
|
+
var elementNormalized = accessor.normalized;
|
|
1839
|
+
var elementFormat = GLTFUtils.getElementFormat(accessor.componentType, dataElementSize, elementNormalized);
|
|
1840
|
+
var scaleFactor = void 0;
|
|
1841
|
+
elementNormalized && (scaleFactor = GLTFUtils.getNormalizedComponentScale(accessor.componentType));
|
|
1842
|
+
var elementOffset = void 0;
|
|
1835
1843
|
if (accessorBuffer.interleaved) {
|
|
1836
1844
|
var byteOffset = accessor.byteOffset || 0;
|
|
1837
1845
|
var stride = accessorBuffer.stride;
|
|
1838
|
-
|
|
1846
|
+
elementOffset = byteOffset % stride;
|
|
1839
1847
|
if (vertexBindingInfos[meshId] === undefined) {
|
|
1840
1848
|
vertexElement = new VertexElement(attribute, elementOffset, elementFormat, bufferBindIndex);
|
|
1841
1849
|
var vertexBuffer = accessorBuffer.vertexBuffer;
|
|
@@ -1851,7 +1859,8 @@ var GLTFMeshParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
1851
1859
|
vertexElement = new VertexElement(attribute, elementOffset, elementFormat, vertexBindingInfos[meshId]);
|
|
1852
1860
|
}
|
|
1853
1861
|
} else {
|
|
1854
|
-
|
|
1862
|
+
elementOffset = 0;
|
|
1863
|
+
vertexElement = new VertexElement(attribute, elementOffset, elementFormat, bufferBindIndex);
|
|
1855
1864
|
var vertexBuffer1 = new Buffer(engine, BufferBindFlag.VertexBuffer, vertices.byteLength, BufferUsage.Static);
|
|
1856
1865
|
vertexBuffer1.setData(vertices);
|
|
1857
1866
|
meshRestoreInfo.vertexBuffers.push(new BufferRestoreInfo(vertexBuffer1, accessorBuffer.restoreInfo));
|
|
@@ -1860,35 +1869,61 @@ var GLTFMeshParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
1860
1869
|
}
|
|
1861
1870
|
vertexElements.push(vertexElement);
|
|
1862
1871
|
if (attribute === "POSITION") {
|
|
1863
|
-
vertexCount =
|
|
1872
|
+
vertexCount = accessorCount;
|
|
1864
1873
|
var _mesh_bounds = mesh.bounds, min = _mesh_bounds.min, max = _mesh_bounds.max;
|
|
1865
1874
|
if (accessor.min && accessor.max) {
|
|
1866
1875
|
min.copyFromArray(accessor.min);
|
|
1867
1876
|
max.copyFromArray(accessor.max);
|
|
1868
1877
|
if (keepMeshData) {
|
|
1869
|
-
var
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1878
|
+
var baseOffset = elementOffset / vertices.BYTES_PER_ELEMENT;
|
|
1879
|
+
var stride1 = vertices.length / accessorCount;
|
|
1880
|
+
for(var j = 0; j < accessorCount; j++){
|
|
1881
|
+
var offset = baseOffset + j * stride1;
|
|
1882
|
+
var position = new Vector3(vertices[offset], vertices[offset + 1], vertices[offset + 2]);
|
|
1883
|
+
elementNormalized && position.scale(scaleFactor);
|
|
1884
|
+
positions[j] = position;
|
|
1873
1885
|
}
|
|
1874
1886
|
}
|
|
1875
1887
|
} else {
|
|
1876
|
-
var
|
|
1888
|
+
var position1 = GLTFMeshParser._tempVector3;
|
|
1877
1889
|
min.set(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
|
|
1878
1890
|
max.set(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
|
|
1879
|
-
var
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
Vector3.
|
|
1891
|
+
var baseOffset1 = elementOffset / vertices.BYTES_PER_ELEMENT;
|
|
1892
|
+
var stride2 = vertices.length / accessorCount;
|
|
1893
|
+
for(var j1 = 0; j1 < accessorCount; j1++){
|
|
1894
|
+
var offset1 = baseOffset1 + j1 * stride2;
|
|
1895
|
+
position1.copyFromArray(vertices, offset1);
|
|
1896
|
+
Vector3.min(min, position1, min);
|
|
1897
|
+
Vector3.max(max, position1, max);
|
|
1898
|
+
if (keepMeshData) {
|
|
1899
|
+
var clonePosition = position1.clone();
|
|
1900
|
+
elementNormalized && clonePosition.scale(scaleFactor);
|
|
1901
|
+
positions[j1] = clonePosition;
|
|
1902
|
+
}
|
|
1885
1903
|
}
|
|
1886
1904
|
}
|
|
1887
|
-
if (
|
|
1888
|
-
var scaleFactor = GLTFUtils.getNormalizedComponentScale(accessor.componentType);
|
|
1905
|
+
if (elementNormalized) {
|
|
1889
1906
|
min.scale(scaleFactor);
|
|
1890
1907
|
max.scale(scaleFactor);
|
|
1891
1908
|
}
|
|
1909
|
+
} else if (attribute === "JOINTS_0" && keepMeshData) {
|
|
1910
|
+
var baseOffset2 = elementOffset / vertices.BYTES_PER_ELEMENT;
|
|
1911
|
+
var stride3 = vertices.length / accessorCount;
|
|
1912
|
+
for(var j2 = 0; j2 < accessorCount; j2++){
|
|
1913
|
+
var offset2 = baseOffset2 + j2 * stride3;
|
|
1914
|
+
var boneIndex = new Vector4(vertices[offset2], vertices[offset2 + 1], vertices[offset2 + 2], vertices[offset2 + 3]);
|
|
1915
|
+
elementNormalized && boneIndex.scale(scaleFactor);
|
|
1916
|
+
boneIndices[j2] = boneIndex;
|
|
1917
|
+
}
|
|
1918
|
+
} else if (attribute === "WEIGHTS_0" && keepMeshData) {
|
|
1919
|
+
var baseOffset3 = elementOffset / vertices.BYTES_PER_ELEMENT;
|
|
1920
|
+
var stride4 = vertices.length / accessorCount;
|
|
1921
|
+
for(var j3 = 0; j3 < accessorCount; j3++){
|
|
1922
|
+
var offset3 = baseOffset3 + j3 * stride4;
|
|
1923
|
+
var boneWeight = new Vector4(vertices[offset3], vertices[offset3 + 1], vertices[offset3 + 2], vertices[offset3 + 3]);
|
|
1924
|
+
elementNormalized && boneWeight.scale(scaleFactor);
|
|
1925
|
+
boneWeights[j3] = boneWeight;
|
|
1926
|
+
}
|
|
1892
1927
|
}
|
|
1893
1928
|
}
|
|
1894
1929
|
mesh.setVertexElements(vertexElements);
|
|
@@ -1907,6 +1942,10 @@ var GLTFMeshParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
1907
1942
|
mesh.uploadData(!keepMeshData);
|
|
1908
1943
|
//@ts-ignore
|
|
1909
1944
|
mesh._positions = positions;
|
|
1945
|
+
//@ts-ignore
|
|
1946
|
+
mesh._boneIndices = boneIndices;
|
|
1947
|
+
//@ts-ignore
|
|
1948
|
+
mesh._boneWeights = boneWeights;
|
|
1910
1949
|
return Promise.resolve(mesh);
|
|
1911
1950
|
};
|
|
1912
1951
|
/**
|
|
@@ -1997,14 +2036,7 @@ var GLTFSceneParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
1997
2036
|
camera.enabled = false;
|
|
1998
2037
|
};
|
|
1999
2038
|
_proto._createRenderer = function _createRenderer(context, glTFNode, entity) {
|
|
2000
|
-
var
|
|
2001
|
-
var glTFMeshes = glTF.meshes;
|
|
2002
|
-
var engine = glTFResource.engine, meshes = glTFResource.meshes, materials = glTFResource.materials, skins = glTFResource.skins;
|
|
2003
|
-
var meshID = glTFNode.mesh, skinID = glTFNode.skin;
|
|
2004
|
-
var glTFMesh = glTFMeshes[meshID];
|
|
2005
|
-
var glTFMeshPrimitives = glTFMesh.primitives;
|
|
2006
|
-
var blendShapeWeights = glTFNode.weights || glTFMesh.weights;
|
|
2007
|
-
for(var i = 0; i < glTFMeshPrimitives.length; i++){
|
|
2039
|
+
var _loop = function(i) {
|
|
2008
2040
|
var gltfPrimitive = glTFMeshPrimitives[i];
|
|
2009
2041
|
var mesh = meshes[meshID][i];
|
|
2010
2042
|
var renderer = void 0;
|
|
@@ -2026,8 +2058,22 @@ var GLTFSceneParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
2026
2058
|
var materialIndex = gltfPrimitive.material;
|
|
2027
2059
|
var material = (materials == null ? void 0 : materials[materialIndex]) || GLTFSceneParser._getDefaultMaterial(engine);
|
|
2028
2060
|
renderer.setMaterial(material);
|
|
2061
|
+
// Enable vertex color if mesh has COLOR_0 vertex element
|
|
2062
|
+
mesh.vertexElements.forEach(function(element) {
|
|
2063
|
+
if (element.semantic === "COLOR_0") {
|
|
2064
|
+
renderer.enableVertexColor = true;
|
|
2065
|
+
}
|
|
2066
|
+
});
|
|
2029
2067
|
GLTFParser.executeExtensionsAdditiveAndParse(gltfPrimitive.extensions, context, renderer, gltfPrimitive);
|
|
2030
|
-
}
|
|
2068
|
+
};
|
|
2069
|
+
var glTFResource = context.glTFResource, glTF = context.glTF;
|
|
2070
|
+
var glTFMeshes = glTF.meshes;
|
|
2071
|
+
var engine = glTFResource.engine, meshes = glTFResource.meshes, materials = glTFResource.materials, skins = glTFResource.skins;
|
|
2072
|
+
var meshID = glTFNode.mesh, skinID = glTFNode.skin;
|
|
2073
|
+
var glTFMesh = glTFMeshes[meshID];
|
|
2074
|
+
var glTFMeshPrimitives = glTFMesh.primitives;
|
|
2075
|
+
var blendShapeWeights = glTFNode.weights || glTFMesh.weights;
|
|
2076
|
+
for(var i = 0; i < glTFMeshPrimitives.length; i++)_loop(i);
|
|
2031
2077
|
};
|
|
2032
2078
|
_proto._createAnimator = function _createAnimator(context) {
|
|
2033
2079
|
if (!context.hasSkinned && !context.glTFResource.animations) {
|
|
@@ -2326,7 +2372,7 @@ var GLTFValidator = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
2326
2372
|
}
|
|
2327
2373
|
var _proto = GLTFResource.prototype;
|
|
2328
2374
|
/**
|
|
2329
|
-
* @
|
|
2375
|
+
* @internal
|
|
2330
2376
|
*/ _proto._onDestroy = function _onDestroy() {
|
|
2331
2377
|
EngineObject.prototype._onDestroy.call(this);
|
|
2332
2378
|
this.defaultSceneRoot.destroy();
|
|
@@ -2350,9 +2396,7 @@ var GLTFLoader = /*#__PURE__*/ function(Loader) {
|
|
|
2350
2396
|
return Loader.apply(this, arguments);
|
|
2351
2397
|
}
|
|
2352
2398
|
var _proto = GLTFLoader.prototype;
|
|
2353
|
-
|
|
2354
|
-
* @override
|
|
2355
|
-
*/ _proto.load = function load(item, resourceManager) {
|
|
2399
|
+
_proto.load = function load(item, resourceManager) {
|
|
2356
2400
|
var url = item.url;
|
|
2357
2401
|
var params = item.params;
|
|
2358
2402
|
var context = new GLTFParserContext(url);
|
|
@@ -2977,6 +3021,15 @@ KTXLoader = __decorate([
|
|
|
2977
3021
|
])
|
|
2978
3022
|
], KTXLoader);
|
|
2979
3023
|
|
|
3024
|
+
function parseProperty(object, key, value) {
|
|
3025
|
+
if (typeof value === "object") {
|
|
3026
|
+
for(var subKey in value){
|
|
3027
|
+
parseProperty(object[key], subKey, value[subKey]);
|
|
3028
|
+
}
|
|
3029
|
+
} else {
|
|
3030
|
+
object[key] = value;
|
|
3031
|
+
}
|
|
3032
|
+
}
|
|
2980
3033
|
var MaterialLoader = /*#__PURE__*/ function(Loader) {
|
|
2981
3034
|
_inherits(MaterialLoader, Loader);
|
|
2982
3035
|
function MaterialLoader() {
|
|
@@ -2988,7 +3041,7 @@ var MaterialLoader = /*#__PURE__*/ function(Loader) {
|
|
|
2988
3041
|
return new AssetPromise(function(resolve, reject) {
|
|
2989
3042
|
_this.request(item.url, _extends({}, item, {
|
|
2990
3043
|
type: "json"
|
|
2991
|
-
})).then(function(
|
|
3044
|
+
})).then(function(materialSchema) {
|
|
2992
3045
|
var _loop = function(key) {
|
|
2993
3046
|
var _shaderData_key = shaderData[key], type = _shaderData_key.type, value = _shaderData_key.value;
|
|
2994
3047
|
switch(type){
|
|
@@ -3016,27 +3069,8 @@ var MaterialLoader = /*#__PURE__*/ function(Loader) {
|
|
|
3016
3069
|
}
|
|
3017
3070
|
};
|
|
3018
3071
|
var engine = resourceManager.engine;
|
|
3019
|
-
var name =
|
|
3020
|
-
var material;
|
|
3021
|
-
switch(shader){
|
|
3022
|
-
case "pbr":
|
|
3023
|
-
material = new PBRMaterial(engine);
|
|
3024
|
-
break;
|
|
3025
|
-
case "pbr-specular":
|
|
3026
|
-
material = new PBRSpecularMaterial(engine);
|
|
3027
|
-
break;
|
|
3028
|
-
case "unlit":
|
|
3029
|
-
material = new UnlitMaterial(engine);
|
|
3030
|
-
break;
|
|
3031
|
-
case "blinn-phong":
|
|
3032
|
-
material = new BlinnPhongMaterial(engine);
|
|
3033
|
-
break;
|
|
3034
|
-
case "bake-pbr":
|
|
3035
|
-
// @todo refactor custom shader later
|
|
3036
|
-
// @ts-ignore
|
|
3037
|
-
material = new PBRBaseMaterial(engine, Shader.find("bake-pbr"));
|
|
3038
|
-
break;
|
|
3039
|
-
}
|
|
3072
|
+
var name = materialSchema.name, shader = materialSchema.shader, shaderData = materialSchema.shaderData, macros = materialSchema.macros, renderState = materialSchema.renderState;
|
|
3073
|
+
var material = new Material(engine, Shader.find(shader));
|
|
3040
3074
|
material.name = name;
|
|
3041
3075
|
var texturePromises = new Array();
|
|
3042
3076
|
var materialShaderData = material.shaderData;
|
|
@@ -3049,9 +3083,7 @@ var MaterialLoader = /*#__PURE__*/ function(Loader) {
|
|
|
3049
3083
|
materialShaderData.enableMacro(name1, value);
|
|
3050
3084
|
}
|
|
3051
3085
|
}
|
|
3052
|
-
|
|
3053
|
-
material[key1] = renderState[key1];
|
|
3054
|
-
}
|
|
3086
|
+
parseProperty(material, "renderState", renderState);
|
|
3055
3087
|
return Promise.all(texturePromises).then(function() {
|
|
3056
3088
|
resolve(material);
|
|
3057
3089
|
});
|
|
@@ -3806,6 +3838,12 @@ AnimationClipDecoder = __decorate([
|
|
|
3806
3838
|
decoder("AnimationClip")
|
|
3807
3839
|
], AnimationClipDecoder);
|
|
3808
3840
|
|
|
3841
|
+
var SpecularMode;
|
|
3842
|
+
(function(SpecularMode) {
|
|
3843
|
+
SpecularMode["Sky"] = "Sky";
|
|
3844
|
+
SpecularMode["Custom"] = "Custom";
|
|
3845
|
+
})(SpecularMode || (SpecularMode = {}));
|
|
3846
|
+
|
|
3809
3847
|
var SceneParserContext = /*#__PURE__*/ function() {
|
|
3810
3848
|
function SceneParserContext(originalData, scene) {
|
|
3811
3849
|
this.originalData = originalData;
|
|
@@ -4088,7 +4126,7 @@ var SpriteAtlasLoader = /*#__PURE__*/ function(Loader) {
|
|
|
4088
4126
|
var atlasItem = atlasItems[i];
|
|
4089
4127
|
if (atlasItem.img) {
|
|
4090
4128
|
chainPromises.push(resourceManager.load({
|
|
4091
|
-
url: atlasItem.img,
|
|
4129
|
+
url: Utils.resolveAbsoluteUrl(item.url, atlasItem.img),
|
|
4092
4130
|
type: AssetType.Texture2D,
|
|
4093
4131
|
params: {
|
|
4094
4132
|
format: format,
|
|
@@ -4199,9 +4237,7 @@ SpriteLoader = __decorate([
|
|
|
4199
4237
|
return _this;
|
|
4200
4238
|
}
|
|
4201
4239
|
var _proto = Texture2DContentRestorer.prototype;
|
|
4202
|
-
|
|
4203
|
-
* @override
|
|
4204
|
-
*/ _proto.restoreContent = function restoreContent() {
|
|
4240
|
+
_proto.restoreContent = function restoreContent() {
|
|
4205
4241
|
var _this = this;
|
|
4206
4242
|
return request(this.url, this.requestConfig).then(function(image) {
|
|
4207
4243
|
var resource = _this.resource;
|
|
@@ -4219,9 +4255,7 @@ var Texture2DLoader = /*#__PURE__*/ function(Loader) {
|
|
|
4219
4255
|
return Loader.apply(this, arguments);
|
|
4220
4256
|
}
|
|
4221
4257
|
var _proto = Texture2DLoader.prototype;
|
|
4222
|
-
|
|
4223
|
-
* @override
|
|
4224
|
-
*/ _proto.load = function load(item, resourceManager) {
|
|
4258
|
+
_proto.load = function load(item, resourceManager) {
|
|
4225
4259
|
var _this = this;
|
|
4226
4260
|
return new AssetPromise(function(resolve, reject) {
|
|
4227
4261
|
var url = item.url;
|
|
@@ -4267,9 +4301,7 @@ Texture2DLoader = __decorate([
|
|
|
4267
4301
|
return _this;
|
|
4268
4302
|
}
|
|
4269
4303
|
var _proto = TextureCubeContentRestorer.prototype;
|
|
4270
|
-
|
|
4271
|
-
* @override
|
|
4272
|
-
*/ _proto.restoreContent = function restoreContent() {
|
|
4304
|
+
_proto.restoreContent = function restoreContent() {
|
|
4273
4305
|
var _this = this;
|
|
4274
4306
|
return new AssetPromise(function(resolve, reject) {
|
|
4275
4307
|
Promise.all(_this.urls.map(function(url) {
|
|
@@ -4295,9 +4327,7 @@ var TextureCubeLoader = /*#__PURE__*/ function(Loader) {
|
|
|
4295
4327
|
return Loader.apply(this, arguments);
|
|
4296
4328
|
}
|
|
4297
4329
|
var _proto = TextureCubeLoader.prototype;
|
|
4298
|
-
|
|
4299
|
-
* @override
|
|
4300
|
-
*/ _proto.load = function load(item, resourceManager) {
|
|
4330
|
+
_proto.load = function load(item, resourceManager) {
|
|
4301
4331
|
var _this = this;
|
|
4302
4332
|
return new AssetPromise(function(resolve, reject) {
|
|
4303
4333
|
var urls = item.urls;
|
|
@@ -4372,47 +4402,63 @@ var SceneLoader = /*#__PURE__*/ function(Loader) {
|
|
|
4372
4402
|
// @ts-ignore
|
|
4373
4403
|
engine.resourceManager.initVirtualResources(data.files);
|
|
4374
4404
|
return SceneParser.parse(engine, data).then(function(scene) {
|
|
4405
|
+
var promises = [];
|
|
4375
4406
|
// parse ambient light
|
|
4376
4407
|
var ambient = data.scene.ambient;
|
|
4377
|
-
var
|
|
4378
|
-
if (ambient.
|
|
4379
|
-
|
|
4380
|
-
|
|
4381
|
-
|
|
4408
|
+
var useCustomAmbient = ambient.specularMode === "Custom";
|
|
4409
|
+
if (useCustomAmbient && ambient.customAmbientLight) {
|
|
4410
|
+
// @ts-ignore
|
|
4411
|
+
// prettier-ignore
|
|
4412
|
+
var customAmbientPromise = resourceManager.getResourceByRef(ambient.customAmbientLight).then(function(ambientLight) {
|
|
4413
|
+
scene.ambientLight = ambientLight;
|
|
4382
4414
|
scene.ambientLight.diffuseIntensity = ambient.diffuseIntensity;
|
|
4383
4415
|
scene.ambientLight.specularIntensity = ambient.specularIntensity;
|
|
4416
|
+
scene.ambientLight.diffuseMode = ambient.diffuseMode;
|
|
4417
|
+
scene.ambientLight.diffuseSolidColor.copyFrom(ambient.diffuseSolidColor);
|
|
4384
4418
|
});
|
|
4385
|
-
|
|
4386
|
-
|
|
4387
|
-
|
|
4388
|
-
|
|
4419
|
+
promises.push(customAmbientPromise);
|
|
4420
|
+
} else if (!useCustomAmbient && ambient.ambientLight) {
|
|
4421
|
+
// @ts-ignore
|
|
4422
|
+
// prettier-ignore
|
|
4423
|
+
var ambientLightPromise = resourceManager.getResourceByRef(ambient.ambientLight).then(function(ambientLight) {
|
|
4424
|
+
scene.ambientLight = ambientLight;
|
|
4425
|
+
scene.ambientLight.diffuseIntensity = ambient.diffuseIntensity;
|
|
4426
|
+
scene.ambientLight.specularIntensity = ambient.specularIntensity;
|
|
4427
|
+
scene.ambientLight.diffuseMode = ambient.diffuseMode;
|
|
4428
|
+
scene.ambientLight.diffuseSolidColor.copyFrom(ambient.diffuseSolidColor);
|
|
4429
|
+
});
|
|
4430
|
+
promises.push(ambientLightPromise);
|
|
4389
4431
|
}
|
|
4390
4432
|
var background = data.scene.background;
|
|
4391
4433
|
scene.background.mode = background.mode;
|
|
4392
|
-
var backgroundPromise = Promise.resolve();
|
|
4393
4434
|
switch(scene.background.mode){
|
|
4394
4435
|
case BackgroundMode.SolidColor:
|
|
4395
4436
|
scene.background.solidColor.copyFrom(background.color);
|
|
4396
4437
|
break;
|
|
4397
4438
|
case BackgroundMode.Sky:
|
|
4398
|
-
if (background.
|
|
4439
|
+
if (background.skyMesh && background.skyMaterial) {
|
|
4440
|
+
// @ts-ignore
|
|
4441
|
+
var skyMeshPromise = resourceManager.getResourceByRef(background.skyMesh).then(function(mesh) {
|
|
4442
|
+
scene.background.sky.mesh = mesh;
|
|
4443
|
+
});
|
|
4399
4444
|
// @ts-ignore
|
|
4400
|
-
|
|
4401
|
-
|
|
4402
|
-
|
|
4403
|
-
skyMaterial.texture = light.specularTexture;
|
|
4404
|
-
skyMaterial.textureDecodeRGBM = true;
|
|
4405
|
-
sky.material = skyMaterial;
|
|
4406
|
-
sky.mesh = PrimitiveMesh.createCuboid(engine, 1, 1, 1);
|
|
4445
|
+
// prettier-ignore
|
|
4446
|
+
var skyMaterialPromise = resourceManager.getResourceByRef(background.skyMaterial).then(function(material) {
|
|
4447
|
+
scene.background.sky.material = material;
|
|
4407
4448
|
});
|
|
4449
|
+
promises.push(skyMeshPromise, skyMaterialPromise);
|
|
4450
|
+
} else {
|
|
4451
|
+
Logger.warn("Sky background mode requires skyMesh and skyMaterial");
|
|
4408
4452
|
}
|
|
4409
4453
|
break;
|
|
4410
4454
|
case BackgroundMode.Texture:
|
|
4411
4455
|
if (background.texture) {
|
|
4412
4456
|
// @ts-ignore
|
|
4413
|
-
|
|
4457
|
+
// prettier-ignore
|
|
4458
|
+
var backgroundPromise = resourceManager.getResourceByRef(background.texture).then(function(texture) {
|
|
4414
4459
|
scene.background.texture = texture;
|
|
4415
4460
|
});
|
|
4461
|
+
promises.push(backgroundPromise);
|
|
4416
4462
|
}
|
|
4417
4463
|
break;
|
|
4418
4464
|
}
|
|
@@ -4424,10 +4470,7 @@ var SceneLoader = /*#__PURE__*/ function(Loader) {
|
|
|
4424
4470
|
if (shadow.shadowDistance != undefined) scene.shadowDistance = shadow.shadowDistance;
|
|
4425
4471
|
if (shadow.shadowCascades != undefined) scene.shadowCascades = shadow.shadowCascades;
|
|
4426
4472
|
}
|
|
4427
|
-
return Promise.all(
|
|
4428
|
-
ambientLightPromise,
|
|
4429
|
-
backgroundPromise
|
|
4430
|
-
]).then(function() {
|
|
4473
|
+
return Promise.all(promises).then(function() {
|
|
4431
4474
|
resolve(scene);
|
|
4432
4475
|
});
|
|
4433
4476
|
});
|
|
@@ -4463,16 +4506,12 @@ var KHR_draco_mesh_compression = (_KHR_draco_mesh_compression = /*#__PURE__*/ fu
|
|
|
4463
4506
|
return GLTFExtensionParser.apply(this, arguments);
|
|
4464
4507
|
}
|
|
4465
4508
|
var _proto = KHR_draco_mesh_compression1.prototype;
|
|
4466
|
-
|
|
4467
|
-
* @override
|
|
4468
|
-
*/ _proto.initialize = function initialize() {
|
|
4509
|
+
_proto.initialize = function initialize() {
|
|
4469
4510
|
if (!KHR_draco_mesh_compression._decoder) {
|
|
4470
4511
|
KHR_draco_mesh_compression._decoder = new DRACODecoder();
|
|
4471
4512
|
}
|
|
4472
4513
|
};
|
|
4473
|
-
|
|
4474
|
-
* @override
|
|
4475
|
-
*/ _proto.createAndParse = function createAndParse(context, schema, glTFPrimitive, glTFMesh) {
|
|
4514
|
+
_proto.createAndParse = function createAndParse(context, schema, glTFPrimitive, glTFMesh) {
|
|
4476
4515
|
var _this = this;
|
|
4477
4516
|
var glTF = context.glTF, buffers = context.buffers, engine = context.glTFResource.engine;
|
|
4478
4517
|
var bufferViews = glTF.bufferViews, accessors = glTF.accessors;
|
|
@@ -4627,9 +4666,7 @@ var KHR_lights_punctual = /*#__PURE__*/ function(GLTFExtensionParser) {
|
|
|
4627
4666
|
return GLTFExtensionParser.apply(this, arguments);
|
|
4628
4667
|
}
|
|
4629
4668
|
var _proto = KHR_lights_punctual.prototype;
|
|
4630
|
-
|
|
4631
|
-
* @override
|
|
4632
|
-
*/ _proto.additiveParse = function additiveParse(context, entity, extensionSchema) {
|
|
4669
|
+
_proto.additiveParse = function additiveParse(context, entity, extensionSchema) {
|
|
4633
4670
|
var lightsSchema = context.glTF.extensions.KHR_lights_punctual.lights;
|
|
4634
4671
|
var lightSchema = lightsSchema[extensionSchema.light];
|
|
4635
4672
|
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;
|
|
@@ -4669,9 +4706,7 @@ var KHR_materials_clearcoat = /*#__PURE__*/ function(GLTFExtensionParser) {
|
|
|
4669
4706
|
return GLTFExtensionParser.apply(this, arguments);
|
|
4670
4707
|
}
|
|
4671
4708
|
var _proto = KHR_materials_clearcoat.prototype;
|
|
4672
|
-
|
|
4673
|
-
* @override
|
|
4674
|
-
*/ _proto.additiveParse = function additiveParse(context, material, schema) {
|
|
4709
|
+
_proto.additiveParse = function additiveParse(context, material, schema) {
|
|
4675
4710
|
var textures = context.glTFResource.textures;
|
|
4676
4711
|
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;
|
|
4677
4712
|
material.clearCoat = clearcoatFactor;
|
|
@@ -4695,15 +4730,29 @@ KHR_materials_clearcoat = __decorate([
|
|
|
4695
4730
|
registerGLTFExtension("KHR_materials_clearcoat", GLTFExtensionMode.AdditiveParse)
|
|
4696
4731
|
], KHR_materials_clearcoat);
|
|
4697
4732
|
|
|
4733
|
+
var KHR_materials_ior = /*#__PURE__*/ function(GLTFExtensionParser) {
|
|
4734
|
+
_inherits(KHR_materials_ior, GLTFExtensionParser);
|
|
4735
|
+
function KHR_materials_ior() {
|
|
4736
|
+
return GLTFExtensionParser.apply(this, arguments);
|
|
4737
|
+
}
|
|
4738
|
+
var _proto = KHR_materials_ior.prototype;
|
|
4739
|
+
_proto.additiveParse = function additiveParse(context, material, schema) {
|
|
4740
|
+
var _schema_ior = schema.ior, ior = _schema_ior === void 0 ? 1.5 : _schema_ior;
|
|
4741
|
+
material.ior = ior;
|
|
4742
|
+
};
|
|
4743
|
+
return KHR_materials_ior;
|
|
4744
|
+
}(GLTFExtensionParser);
|
|
4745
|
+
KHR_materials_ior = __decorate([
|
|
4746
|
+
registerGLTFExtension("KHR_materials_ior", GLTFExtensionMode.AdditiveParse)
|
|
4747
|
+
], KHR_materials_ior);
|
|
4748
|
+
|
|
4698
4749
|
var KHR_materials_pbrSpecularGlossiness = /*#__PURE__*/ function(GLTFExtensionParser) {
|
|
4699
4750
|
_inherits(KHR_materials_pbrSpecularGlossiness, GLTFExtensionParser);
|
|
4700
4751
|
function KHR_materials_pbrSpecularGlossiness() {
|
|
4701
4752
|
return GLTFExtensionParser.apply(this, arguments);
|
|
4702
4753
|
}
|
|
4703
4754
|
var _proto = KHR_materials_pbrSpecularGlossiness.prototype;
|
|
4704
|
-
|
|
4705
|
-
* @override
|
|
4706
|
-
*/ _proto.createAndParse = function createAndParse(context, schema, ownerSchema) {
|
|
4755
|
+
_proto.createAndParse = function createAndParse(context, schema, ownerSchema) {
|
|
4707
4756
|
var _context_glTFResource = context.glTFResource, engine = _context_glTFResource.engine, textures = _context_glTFResource.textures;
|
|
4708
4757
|
var material = new PBRSpecularMaterial(engine);
|
|
4709
4758
|
var diffuseFactor = schema.diffuseFactor, diffuseTexture = schema.diffuseTexture, specularFactor = schema.specularFactor, glossinessFactor = schema.glossinessFactor, specularGlossinessTexture = schema.specularGlossinessTexture;
|
|
@@ -4740,9 +4789,7 @@ var KHR_materials_unlit = /*#__PURE__*/ function(GLTFExtensionParser) {
|
|
|
4740
4789
|
return GLTFExtensionParser.apply(this, arguments);
|
|
4741
4790
|
}
|
|
4742
4791
|
var _proto = KHR_materials_unlit.prototype;
|
|
4743
|
-
|
|
4744
|
-
* @override
|
|
4745
|
-
*/ _proto.createAndParse = function createAndParse(context, _, ownerSchema) {
|
|
4792
|
+
_proto.createAndParse = function createAndParse(context, _, ownerSchema) {
|
|
4746
4793
|
var engine = context.glTFResource.engine;
|
|
4747
4794
|
var material = new UnlitMaterial(engine);
|
|
4748
4795
|
material.name = ownerSchema.name;
|
|
@@ -4772,9 +4819,7 @@ var KHR_texture_transform = /*#__PURE__*/ function(GLTFExtensionParser) {
|
|
|
4772
4819
|
return GLTFExtensionParser.apply(this, arguments);
|
|
4773
4820
|
}
|
|
4774
4821
|
var _proto = KHR_texture_transform.prototype;
|
|
4775
|
-
|
|
4776
|
-
* @override
|
|
4777
|
-
*/ _proto.additiveParse = function additiveParse(context, material, schema) {
|
|
4822
|
+
_proto.additiveParse = function additiveParse(context, material, schema) {
|
|
4778
4823
|
var offset = schema.offset, rotation = schema.rotation, scale = schema.scale, texCoord = schema.texCoord;
|
|
4779
4824
|
if (offset) {
|
|
4780
4825
|
material.tilingOffset.z = offset[0];
|
|
@@ -4803,9 +4848,7 @@ var GALACEAN_materials_remap = /*#__PURE__*/ function(GLTFExtensionParser) {
|
|
|
4803
4848
|
return GLTFExtensionParser.apply(this, arguments);
|
|
4804
4849
|
}
|
|
4805
4850
|
var _proto = GALACEAN_materials_remap.prototype;
|
|
4806
|
-
|
|
4807
|
-
* @override
|
|
4808
|
-
*/ _proto.createAndParse = function createAndParse(context, schema) {
|
|
4851
|
+
_proto.createAndParse = function createAndParse(context, schema) {
|
|
4809
4852
|
var engine = context.glTFResource.engine;
|
|
4810
4853
|
// @ts-ignore
|
|
4811
4854
|
return engine.resourceManager.getResourceByRef(schema);
|
|
@@ -4822,9 +4865,7 @@ var GALACEAN_animation_event = /*#__PURE__*/ function(GLTFExtensionParser) {
|
|
|
4822
4865
|
return GLTFExtensionParser.apply(this, arguments);
|
|
4823
4866
|
}
|
|
4824
4867
|
var _proto = GALACEAN_animation_event.prototype;
|
|
4825
|
-
|
|
4826
|
-
* @override
|
|
4827
|
-
*/ _proto.additiveParse = function additiveParse(context, animationClip, schema) {
|
|
4868
|
+
_proto.additiveParse = function additiveParse(context, animationClip, schema) {
|
|
4828
4869
|
context.glTFResource.engine;
|
|
4829
4870
|
var events = schema.events;
|
|
4830
4871
|
events.map(function(eventData) {
|
|
@@ -4841,5 +4882,5 @@ GALACEAN_animation_event = __decorate([
|
|
|
4841
4882
|
registerGLTFExtension("GALACEAN_animation_event", GLTFExtensionMode.AdditiveParse)
|
|
4842
4883
|
], GALACEAN_animation_event);
|
|
4843
4884
|
|
|
4844
|
-
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 };
|
|
4885
|
+
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 };
|
|
4845
4886
|
//# sourceMappingURL=module.js.map
|