@galacean/engine-loader 2.0.0-alpha.56 → 2.0.0-alpha.58
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 +190 -99
- package/dist/main.js.map +1 -1
- package/dist/module.js +191 -100
- package/dist/module.js.map +1 -1
- package/package.json +4 -4
- package/types/ImageDecoder.d.ts +14 -0
- package/types/PrimitiveMeshAsset.d.ts +238 -0
- package/types/gltf/extensions/GLTFExtensionSchema.d.ts +7 -1
- package/types/gltf/extensions/KHR_materials_emissive_strength.d.ts +1 -0
- package/types/gltf/extensions/index.d.ts +1 -0
- package/types/index.d.ts +1 -0
package/dist/module.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Utils, AssetPromise, AnimationClip, AnimationEvent, Loader, AnimationStringCurve, Keyframe, AnimationBoolCurve, AnimationRefCurve, AnimationQuaternionCurve, AnimationColorCurve, AnimationVector4Curve, AnimationVector3Curve, AnimationVector2Curve, AnimationFloatArrayCurve, AnimationArrayCurve, AnimationFloatCurve, ModelMesh, BlendShape, TextureFormat, Texture2D, TextureCube, TextureCubeFace, ReferResource, Entity, resourceLoader, AssetType, AnimatorController, AnimatorControllerLayer, AnimatorStateTransition, BufferAsset, GLCapabilityType, Logger, ContentRestorer, AmbientLight, DiffuseMode, TextureFilterMode, Font,
|
|
1
|
+
import { Utils, AssetPromise, AnimationClip, AnimationEvent, Loader, AnimationStringCurve, Keyframe, AnimationBoolCurve, AnimationRefCurve, AnimationQuaternionCurve, AnimationColorCurve, AnimationVector4Curve, AnimationVector3Curve, AnimationVector2Curve, AnimationFloatArrayCurve, AnimationArrayCurve, AnimationFloatCurve, ModelMesh, BlendShape, SystemInfo, Platform, TextureFormat, Texture2D, TextureCube, TextureCubeFace, ReferResource, Entity, resourceLoader, AssetType, AnimatorController, AnimatorControllerLayer, AnimatorStateTransition, BufferAsset, GLCapabilityType, Logger, ContentRestorer, AmbientLight, DiffuseMode, TextureFilterMode, Font, Animator, IndexFormat, VertexElementFormat, request, InterpolationType, SkinnedMeshRenderer, Transform, PBRMaterial, TextureCoordinate, RenderFace, VertexElement, Buffer, BufferBindFlag, BufferUsage, Camera, MeshRenderer, Skin, TextureWrapMode as TextureWrapMode$1, TextureUtils, AnimatorStateMachine, JSONAsset, Shader, Material, Texture, PrimitiveMesh, SpriteAtlas, Sprite, TextAsset, AudioClip, PhysicsMaterial, RenderTarget, Scene, BackgroundMode, DirectLight, PointLight, SpotLight, UnlitMaterial } from '@galacean/engine-core';
|
|
2
2
|
import { Quaternion, Vector4, Color, Vector3, Vector2, MathUtil, SphericalHarmonics3, Matrix, BoundingBox, Rect } from '@galacean/engine-math';
|
|
3
3
|
import { GLCompressedTextureInternalFormat } from '@galacean/engine-rhi-webgl';
|
|
4
4
|
|
|
@@ -1194,6 +1194,72 @@ HDRDecoder._float2HalfTables = HDRDecoder._generateFloat2HalfTables();
|
|
|
1194
1194
|
HDRDecoder._floatView = new Float32Array(1);
|
|
1195
1195
|
HDRDecoder._uint32View = new Uint32Array(HDRDecoder._floatView.buffer);
|
|
1196
1196
|
|
|
1197
|
+
function _instanceof(left, right) {
|
|
1198
|
+
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
1199
|
+
return !!right[Symbol.hasInstance](left);
|
|
1200
|
+
} else return left instanceof right;
|
|
1201
|
+
}
|
|
1202
|
+
|
|
1203
|
+
/**
|
|
1204
|
+
* Decodes encoded image bytes (PNG, JPEG, WebP, ...) into an image element.
|
|
1205
|
+
*
|
|
1206
|
+
* The blob handed to the image carries the declared `mimeType` or the MIME type detected from the bytes:
|
|
1207
|
+
* browsers sniff an untyped blob, but some platforms (for example mini-game runtimes) only decode images
|
|
1208
|
+
* whose type is declared.
|
|
1209
|
+
* @internal
|
|
1210
|
+
*/ var ImageDecoder = /*#__PURE__*/ function() {
|
|
1211
|
+
function ImageDecoder() {}
|
|
1212
|
+
ImageDecoder._decode = function _decode(data, url, mimeType) {
|
|
1213
|
+
return new AssetPromise(function(resolve, reject) {
|
|
1214
|
+
var objectUrl = URL.createObjectURL(new Blob([
|
|
1215
|
+
data
|
|
1216
|
+
], {
|
|
1217
|
+
type: mimeType || ImageDecoder._getMimeType(data)
|
|
1218
|
+
}));
|
|
1219
|
+
var image = new Image();
|
|
1220
|
+
image.onload = function() {
|
|
1221
|
+
var complete = function() {
|
|
1222
|
+
ImageDecoder._releaseObjectUrl(image, objectUrl);
|
|
1223
|
+
resolve(image);
|
|
1224
|
+
};
|
|
1225
|
+
if ((SystemInfo.platform === Platform.IPhone || SystemInfo.platform === Platform.IPad) && typeof requestAnimationFrame !== "undefined") {
|
|
1226
|
+
// Defer on iOS WebKit so the decoded image surface is ready before revoking the blob URL.
|
|
1227
|
+
requestAnimationFrame(complete);
|
|
1228
|
+
} else {
|
|
1229
|
+
complete();
|
|
1230
|
+
}
|
|
1231
|
+
};
|
|
1232
|
+
image.onerror = image.onabort = function() {
|
|
1233
|
+
ImageDecoder._releaseObjectUrl(image, objectUrl);
|
|
1234
|
+
reject(new Error('TextureLoader: failed to decode texture "' + url + '" (' + data.byteLength + " bytes)."));
|
|
1235
|
+
};
|
|
1236
|
+
image.crossOrigin = "anonymous";
|
|
1237
|
+
image.src = objectUrl;
|
|
1238
|
+
});
|
|
1239
|
+
};
|
|
1240
|
+
ImageDecoder._getMimeType = function _getMimeType(data) {
|
|
1241
|
+
var bytes = _instanceof(data, Uint8Array) ? data : ArrayBuffer.isView(data) ? new Uint8Array(data.buffer, data.byteOffset, data.byteLength) : new Uint8Array(data);
|
|
1242
|
+
if (bytes.length >= 4 && bytes[0] === 0x89 && bytes[1] === 0x50 && bytes[2] === 0x4e && bytes[3] === 0x47) {
|
|
1243
|
+
return "image/png";
|
|
1244
|
+
}
|
|
1245
|
+
if (bytes.length >= 3 && bytes[0] === 0xff && bytes[1] === 0xd8 && bytes[2] === 0xff) {
|
|
1246
|
+
return "image/jpeg";
|
|
1247
|
+
}
|
|
1248
|
+
// "RIFF" .... "WEBP"
|
|
1249
|
+
if (bytes.length >= 12 && bytes[0] === 0x52 && bytes[1] === 0x49 && bytes[2] === 0x46 && bytes[3] === 0x46 && bytes[8] === 0x57 && bytes[9] === 0x45 && bytes[10] === 0x42 && bytes[11] === 0x50) {
|
|
1250
|
+
return "image/webp";
|
|
1251
|
+
}
|
|
1252
|
+
return "";
|
|
1253
|
+
};
|
|
1254
|
+
ImageDecoder._releaseObjectUrl = function _releaseObjectUrl(image, objectUrl) {
|
|
1255
|
+
image.onload = null;
|
|
1256
|
+
image.onerror = null;
|
|
1257
|
+
image.onabort = null;
|
|
1258
|
+
URL.revokeObjectURL(objectUrl);
|
|
1259
|
+
};
|
|
1260
|
+
return ImageDecoder;
|
|
1261
|
+
}();
|
|
1262
|
+
|
|
1197
1263
|
/**
|
|
1198
1264
|
* Data format: [url] [mipmap(1B)] [filterMode(1B)] [anisoLevel(1B)] [wrapModeU(1B)] [wrapModeV(1B)]
|
|
1199
1265
|
* [format(1B)] [width(2B)] [height(2B)] [isSRGBColorSpace(1B)] [Uint32(imageSize) + imageBytes]
|
|
@@ -1201,7 +1267,7 @@ HDRDecoder._uint32View = new Uint32Array(HDRDecoder._floatView.buffer);
|
|
|
1201
1267
|
function Texture2DDecoder() {}
|
|
1202
1268
|
Texture2DDecoder.decode = function decode(engine, bufferReader, restoredTexture) {
|
|
1203
1269
|
return new AssetPromise(function(resolve, reject) {
|
|
1204
|
-
bufferReader.nextStr();
|
|
1270
|
+
var url = bufferReader.nextStr();
|
|
1205
1271
|
var mipmap = !!bufferReader.nextUint8();
|
|
1206
1272
|
var filterMode = bufferReader.nextUint8();
|
|
1207
1273
|
var anisoLevel = bufferReader.nextUint8();
|
|
@@ -1225,21 +1291,11 @@ HDRDecoder._uint32View = new Uint32Array(HDRDecoder._floatView.buffer);
|
|
|
1225
1291
|
mipmap && texture.generateMipmaps();
|
|
1226
1292
|
resolve(texture);
|
|
1227
1293
|
} else {
|
|
1228
|
-
|
|
1229
|
-
imageData
|
|
1230
|
-
]);
|
|
1231
|
-
var img = new Image();
|
|
1232
|
-
img.onload = function() {
|
|
1233
|
-
URL.revokeObjectURL(img.src);
|
|
1294
|
+
ImageDecoder._decode(imageData, url).then(function(img) {
|
|
1234
1295
|
texture.setImageSource(img);
|
|
1235
1296
|
mipmap && texture.generateMipmaps();
|
|
1236
1297
|
resolve(texture);
|
|
1237
|
-
};
|
|
1238
|
-
img.onerror = function(e) {
|
|
1239
|
-
URL.revokeObjectURL(img.src);
|
|
1240
|
-
reject(e);
|
|
1241
|
-
};
|
|
1242
|
-
img.src = URL.createObjectURL(blob);
|
|
1298
|
+
}, reject);
|
|
1243
1299
|
}
|
|
1244
1300
|
});
|
|
1245
1301
|
};
|
|
@@ -1256,7 +1312,7 @@ Texture2DDecoder = __decorate([
|
|
|
1256
1312
|
function TextureCubeDecoder() {}
|
|
1257
1313
|
TextureCubeDecoder.decode = function decode(engine, bufferReader, restoredTexture) {
|
|
1258
1314
|
return new AssetPromise(function(resolve, reject) {
|
|
1259
|
-
bufferReader.nextStr();
|
|
1315
|
+
var url = bufferReader.nextStr();
|
|
1260
1316
|
var mipmap = !!bufferReader.nextUint8();
|
|
1261
1317
|
var filterMode = bufferReader.nextUint8();
|
|
1262
1318
|
var anisoLevel = bufferReader.nextUint8();
|
|
@@ -1283,23 +1339,13 @@ Texture2DDecoder = __decorate([
|
|
|
1283
1339
|
resolve(texture);
|
|
1284
1340
|
} else {
|
|
1285
1341
|
var _loop = function(i1) {
|
|
1286
|
-
|
|
1287
|
-
facesData[i1]
|
|
1288
|
-
]);
|
|
1289
|
-
var img = new Image();
|
|
1290
|
-
img.onload = function() {
|
|
1291
|
-
URL.revokeObjectURL(img.src);
|
|
1342
|
+
ImageDecoder._decode(facesData[i1], url).then(function(img) {
|
|
1292
1343
|
texture.setImageSource(TextureCubeFace.PositiveX + i1, img);
|
|
1293
1344
|
if (++loadedCount === 6) {
|
|
1294
1345
|
mipmap && texture.generateMipmaps();
|
|
1295
1346
|
resolve(texture);
|
|
1296
1347
|
}
|
|
1297
|
-
};
|
|
1298
|
-
img.onerror = function(e) {
|
|
1299
|
-
URL.revokeObjectURL(img.src);
|
|
1300
|
-
reject(e);
|
|
1301
|
-
};
|
|
1302
|
-
img.src = URL.createObjectURL(blob);
|
|
1348
|
+
}, reject);
|
|
1303
1349
|
};
|
|
1304
1350
|
var loadedCount = 0;
|
|
1305
1351
|
for(var i1 = 0; i1 < 6; i1++)_loop(i1);
|
|
@@ -1312,12 +1358,6 @@ TextureCubeDecoder = __decorate([
|
|
|
1312
1358
|
decoder("TextureCube")
|
|
1313
1359
|
], TextureCubeDecoder);
|
|
1314
1360
|
|
|
1315
|
-
function _instanceof(left, right) {
|
|
1316
|
-
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
1317
|
-
return !!right[Symbol.hasInstance](left);
|
|
1318
|
-
} else return left instanceof right;
|
|
1319
|
-
}
|
|
1320
|
-
|
|
1321
1361
|
/**
|
|
1322
1362
|
* The Prefab resource.
|
|
1323
1363
|
*/ var PrefabResource = /*#__PURE__*/ function(ReferResource1) {
|
|
@@ -3752,30 +3792,7 @@ function registerGLTFParser(pipeline) {
|
|
|
3752
3792
|
/**
|
|
3753
3793
|
* Load image buffer
|
|
3754
3794
|
*/ GLTFUtils.loadImageBuffer = function loadImageBuffer(imageBuffer, type) {
|
|
3755
|
-
return
|
|
3756
|
-
var blob = new window.Blob([
|
|
3757
|
-
imageBuffer
|
|
3758
|
-
], {
|
|
3759
|
-
type: type
|
|
3760
|
-
});
|
|
3761
|
-
var img = new Image();
|
|
3762
|
-
img.onerror = function() {
|
|
3763
|
-
URL.revokeObjectURL(img.src);
|
|
3764
|
-
reject(new Error("Failed to load image buffer"));
|
|
3765
|
-
};
|
|
3766
|
-
img.onload = function() {
|
|
3767
|
-
// Call requestAnimationFrame to avoid iOS's bug.
|
|
3768
|
-
requestAnimationFrame(function() {
|
|
3769
|
-
URL.revokeObjectURL(img.src);
|
|
3770
|
-
resolve(img);
|
|
3771
|
-
img.onload = null;
|
|
3772
|
-
img.onerror = null;
|
|
3773
|
-
img.onabort = null;
|
|
3774
|
-
});
|
|
3775
|
-
};
|
|
3776
|
-
img.crossOrigin = "anonymous";
|
|
3777
|
-
img.src = URL.createObjectURL(blob);
|
|
3778
|
-
});
|
|
3795
|
+
return Promise.resolve(ImageDecoder._decode(imageBuffer, type, type));
|
|
3779
3796
|
};
|
|
3780
3797
|
/**
|
|
3781
3798
|
* Parse the glb format.
|
|
@@ -3914,7 +3931,7 @@ function registerGLTFParser(pipeline) {
|
|
|
3914
3931
|
}
|
|
3915
3932
|
});
|
|
3916
3933
|
} else {
|
|
3917
|
-
return
|
|
3934
|
+
return ImageDecoder._decode(bufferData, _this.resource.url, textureRestoreInfo.mimeType).then(function(image) {
|
|
3918
3935
|
texture.setImageSource(image);
|
|
3919
3936
|
texture.generateMipmaps();
|
|
3920
3937
|
});
|
|
@@ -5182,8 +5199,9 @@ var GLTFTextureParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
5182
5199
|
var bufferView = glTF.bufferViews[bufferViewIndex];
|
|
5183
5200
|
texture = context.get(GLTFParserType.Buffer).then(function(buffers) {
|
|
5184
5201
|
var buffer = buffers[bufferView.buffer];
|
|
5185
|
-
var
|
|
5186
|
-
|
|
5202
|
+
var _bufferView_byteOffset;
|
|
5203
|
+
var imageBuffer = new Uint8Array(buffer, (_bufferView_byteOffset = bufferView.byteOffset) != null ? _bufferView_byteOffset : 0, bufferView.byteLength);
|
|
5204
|
+
return ImageDecoder._decode(imageBuffer, imageName || textureName || url, mimeType).then(function(image) {
|
|
5187
5205
|
var width = image.width, height = image.height;
|
|
5188
5206
|
var format = TextureFormat.R8G8B8A8;
|
|
5189
5207
|
var _samplerInfo_mipmap;
|
|
@@ -5197,8 +5215,6 @@ var GLTFTextureParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
5197
5215
|
context.contentRestorer.bufferTextures.push(bufferTextureRestoreInfo);
|
|
5198
5216
|
return texture;
|
|
5199
5217
|
});
|
|
5200
|
-
}).catch(function(e) {
|
|
5201
|
-
Logger.error("GLTFTextureParser: image buffer error", e);
|
|
5202
5218
|
});
|
|
5203
5219
|
}
|
|
5204
5220
|
return texture;
|
|
@@ -5922,26 +5938,102 @@ var PrimitiveMeshLoader = /*#__PURE__*/ function(Loader) {
|
|
|
5922
5938
|
}
|
|
5923
5939
|
var _proto = PrimitiveMeshLoader.prototype;
|
|
5924
5940
|
_proto.load = function load(item, resourceManager) {
|
|
5925
|
-
var
|
|
5941
|
+
var _this = this;
|
|
5926
5942
|
return resourceManager._request(item.url, _extends({}, item, {
|
|
5927
5943
|
type: "json"
|
|
5928
5944
|
})).then(function(data) {
|
|
5929
|
-
|
|
5930
|
-
|
|
5931
|
-
|
|
5932
|
-
|
|
5933
|
-
|
|
5934
|
-
|
|
5935
|
-
|
|
5936
|
-
|
|
5937
|
-
|
|
5938
|
-
|
|
5939
|
-
|
|
5940
|
-
|
|
5941
|
-
|
|
5942
|
-
|
|
5943
|
-
|
|
5945
|
+
return _this._createPrimitiveMesh(resourceManager.engine, data);
|
|
5946
|
+
});
|
|
5947
|
+
};
|
|
5948
|
+
_proto._createPrimitiveMesh = function _createPrimitiveMesh(engine, data) {
|
|
5949
|
+
var type = data.type;
|
|
5950
|
+
switch(type){
|
|
5951
|
+
case "sphere":
|
|
5952
|
+
return PrimitiveMesh.createSphere(engine, data.sphereRadius, this._parseRangeOptions(data.sphereOptions));
|
|
5953
|
+
case "cuboid":
|
|
5954
|
+
return PrimitiveMesh.createCuboid(engine, data.cuboidWidth, data.cuboidHeight, data.cuboidDepth, data.cuboidOptions);
|
|
5955
|
+
case "plane":
|
|
5956
|
+
return PrimitiveMesh.createPlane(engine, data.planeWidth, data.planeDepth, data.planeOptions);
|
|
5957
|
+
case "cylinder":
|
|
5958
|
+
return PrimitiveMesh.createCylinder(engine, data.cylinderRadius, data.cylinderHeight, this._parseRangeOptions(data.cylinderOptions));
|
|
5959
|
+
case "truncatedCone":
|
|
5960
|
+
return PrimitiveMesh.createTruncatedCone(engine, data.truncatedConeTopRadius, data.truncatedConeBottomRadius, data.truncatedConeHeight, this._parseRangeOptions(data.truncatedConeOptions));
|
|
5961
|
+
case "cone":
|
|
5962
|
+
return PrimitiveMesh.createCone(engine, data.coneRadius, data.coneHeight, this._parseRangeOptions(data.coneOptions));
|
|
5963
|
+
case "capsule":
|
|
5964
|
+
return PrimitiveMesh.createCapsule(engine, data.capsuleRadius, data.capsuleCylinderHeight, data.capsuleOptions);
|
|
5965
|
+
case "torus":
|
|
5966
|
+
return PrimitiveMesh.createTorus(engine, data.torusRadius, data.torusTubeRadius, this._parseRangeOptions(data.torusOptions));
|
|
5967
|
+
case "circle":
|
|
5968
|
+
return PrimitiveMesh.createCircle(engine, data.circleRadius, this._parseRangeOptions(data.circleOptions));
|
|
5969
|
+
case "ring":
|
|
5970
|
+
return PrimitiveMesh.createRing(engine, data.ringOuterRadius, data.ringInnerRadius, this._parseRangeOptions(data.ringOptions));
|
|
5971
|
+
case "tetrahedron":
|
|
5972
|
+
return PrimitiveMesh.createTetrahedron(engine, data.tetrahedronRadius, data.tetrahedronOptions);
|
|
5973
|
+
case "octahedron":
|
|
5974
|
+
return PrimitiveMesh.createOctahedron(engine, data.octahedronRadius, data.octahedronOptions);
|
|
5975
|
+
case "icosahedron":
|
|
5976
|
+
return PrimitiveMesh.createIcosahedron(engine, data.icosahedronRadius, data.icosahedronOptions);
|
|
5977
|
+
case "dodecahedron":
|
|
5978
|
+
return PrimitiveMesh.createDodecahedron(engine, data.dodecahedronRadius, data.dodecahedronOptions);
|
|
5979
|
+
case "revolvedSurface":
|
|
5980
|
+
return PrimitiveMesh.createRevolvedSurface(engine, this._parseVector2s(data.revolvedSurfaceProfile), this._parseRangeOptions(data.revolvedSurfaceOptions));
|
|
5981
|
+
case "tube":
|
|
5982
|
+
return PrimitiveMesh.createTube(engine, this._parseVector3s(data.tubePath), data.tubeRadius, data.tubeOptions);
|
|
5983
|
+
case "polygon":
|
|
5984
|
+
return PrimitiveMesh.createPolygon(engine, this._parseShapes(data.polygonShapes), data.polygonOptions);
|
|
5985
|
+
case "extrudedPolygon":
|
|
5986
|
+
if ("extrudedPolygonPath" in data) {
|
|
5987
|
+
return PrimitiveMesh.createExtrudedPolygon(engine, this._parseShapes(data.extrudedPolygonShapes), this._parseVector3s(data.extrudedPolygonPath), data.extrudedPolygonOptions);
|
|
5988
|
+
}
|
|
5989
|
+
return PrimitiveMesh.createExtrudedPolygon(engine, this._parseShapes(data.extrudedPolygonShapes), data.extrudedPolygonDepth, data.extrudedPolygonOptions);
|
|
5990
|
+
case "torusKnot":
|
|
5991
|
+
return PrimitiveMesh.createTorusKnot(engine, data.torusKnotRadius, data.torusKnotTubeRadius, data.torusKnotAxisTurns, data.torusKnotCrossSectionTurns, data.torusKnotOptions);
|
|
5992
|
+
case "roundedCuboid":
|
|
5993
|
+
return PrimitiveMesh.createRoundedCuboid(engine, data.roundedCuboidWidth, data.roundedCuboidHeight, data.roundedCuboidDepth, data.roundedCuboidCornerRadius, data.roundedCuboidOptions);
|
|
5994
|
+
default:
|
|
5995
|
+
{
|
|
5996
|
+
var unsupportedType = type;
|
|
5997
|
+
throw new Error("Unknown primitive mesh type: " + unsupportedType);
|
|
5998
|
+
}
|
|
5999
|
+
}
|
|
6000
|
+
};
|
|
6001
|
+
_proto._parseRangeOptions = function _parseRangeOptions(options) {
|
|
6002
|
+
if (!options) {
|
|
6003
|
+
return;
|
|
6004
|
+
}
|
|
6005
|
+
var result;
|
|
6006
|
+
for(var key in options){
|
|
6007
|
+
var value = options[key];
|
|
6008
|
+
if (value && (typeof value === "undefined" ? "undefined" : _type_of(value)) === "object") {
|
|
6009
|
+
var range = value;
|
|
6010
|
+
(result != null ? result : result = _extends({}, options))[key] = new Vector2(range.x, range.y);
|
|
5944
6011
|
}
|
|
6012
|
+
}
|
|
6013
|
+
return result != null ? result : options;
|
|
6014
|
+
};
|
|
6015
|
+
_proto._parseVector2s = function _parseVector2s(points) {
|
|
6016
|
+
return points.map(function(param) {
|
|
6017
|
+
var x = param.x, y = param.y;
|
|
6018
|
+
return new Vector2(x, y);
|
|
6019
|
+
});
|
|
6020
|
+
};
|
|
6021
|
+
_proto._parseVector3s = function _parseVector3s(points) {
|
|
6022
|
+
return points.map(function(param) {
|
|
6023
|
+
var x = param.x, y = param.y, z = param.z;
|
|
6024
|
+
return new Vector3(x, y, z);
|
|
6025
|
+
});
|
|
6026
|
+
};
|
|
6027
|
+
_proto._parseShapes = function _parseShapes(shapes) {
|
|
6028
|
+
var _this = this;
|
|
6029
|
+
return shapes.map(function(param) {
|
|
6030
|
+
var points = param.points, holes = param.holes;
|
|
6031
|
+
return {
|
|
6032
|
+
points: _this._parseVector2s(points),
|
|
6033
|
+
holes: holes == null ? void 0 : holes.map(function(hole) {
|
|
6034
|
+
return _this._parseVector2s(hole);
|
|
6035
|
+
})
|
|
6036
|
+
};
|
|
5945
6037
|
});
|
|
5946
6038
|
};
|
|
5947
6039
|
return PrimitiveMeshLoader;
|
|
@@ -6245,7 +6337,7 @@ var TextureLoader = /*#__PURE__*/ function(Loader) {
|
|
|
6245
6337
|
};
|
|
6246
6338
|
_proto._decodeImage = function _decodeImage(buffer, item, resourceManager) {
|
|
6247
6339
|
var _this = this;
|
|
6248
|
-
return
|
|
6340
|
+
return ImageDecoder._decode(buffer, item.url).then(function(img) {
|
|
6249
6341
|
var _item_params;
|
|
6250
6342
|
var _ref = (_item_params = item.params) != null ? _item_params : {}, _ref_format = _ref.format, format = _ref_format === void 0 ? TextureFormat.R8G8B8A8 : _ref_format, _ref_isSRGBColorSpace = _ref.isSRGBColorSpace, isSRGBColorSpace = _ref_isSRGBColorSpace === void 0 ? true : _ref_isSRGBColorSpace, _ref_mipmap = _ref.mipmap, mipmap = _ref_mipmap === void 0 ? true : _ref_mipmap;
|
|
6251
6343
|
var engine = resourceManager.engine;
|
|
@@ -6304,7 +6396,7 @@ var TextureContentRestorer = /*#__PURE__*/ function(ContentRestorer) {
|
|
|
6304
6396
|
texture.mipmapCount > 1 && texture.generateMipmaps();
|
|
6305
6397
|
return texture;
|
|
6306
6398
|
}
|
|
6307
|
-
return
|
|
6399
|
+
return ImageDecoder._decode(buffer, _this.url).then(function(img) {
|
|
6308
6400
|
texture.setImageSource(img);
|
|
6309
6401
|
texture.mipmapCount > 1 && texture.generateMipmaps();
|
|
6310
6402
|
return texture;
|
|
@@ -6313,26 +6405,6 @@ var TextureContentRestorer = /*#__PURE__*/ function(ContentRestorer) {
|
|
|
6313
6405
|
};
|
|
6314
6406
|
return TextureContentRestorer;
|
|
6315
6407
|
}(ContentRestorer);
|
|
6316
|
-
function decodeImage(buffer, url) {
|
|
6317
|
-
return new AssetPromise(function(resolve, reject) {
|
|
6318
|
-
var objectUrl = URL.createObjectURL(new Blob([
|
|
6319
|
-
buffer
|
|
6320
|
-
]));
|
|
6321
|
-
var image = new Image();
|
|
6322
|
-
var releaseObjectUrl = function() {
|
|
6323
|
-
return URL.revokeObjectURL(objectUrl);
|
|
6324
|
-
};
|
|
6325
|
-
image.onload = function() {
|
|
6326
|
-
releaseObjectUrl();
|
|
6327
|
-
resolve(image);
|
|
6328
|
-
};
|
|
6329
|
-
image.onerror = function() {
|
|
6330
|
-
releaseObjectUrl();
|
|
6331
|
-
reject(new Error('TextureLoader: failed to decode texture "' + url + '" (' + buffer.byteLength + " bytes)."));
|
|
6332
|
-
};
|
|
6333
|
-
image.src = objectUrl;
|
|
6334
|
-
});
|
|
6335
|
-
}
|
|
6336
6408
|
|
|
6337
6409
|
var AudioLoader = /*#__PURE__*/ function(Loader) {
|
|
6338
6410
|
_inherits(AudioLoader, Loader);
|
|
@@ -6729,6 +6801,25 @@ KHR_materials_clearcoat = __decorate([
|
|
|
6729
6801
|
registerGLTFExtension("KHR_materials_clearcoat", GLTFExtensionMode.AdditiveParse)
|
|
6730
6802
|
], KHR_materials_clearcoat);
|
|
6731
6803
|
|
|
6804
|
+
var KHR_materials_emissive_strength = /*#__PURE__*/ function(GLTFExtensionParser) {
|
|
6805
|
+
_inherits(KHR_materials_emissive_strength, GLTFExtensionParser);
|
|
6806
|
+
function KHR_materials_emissive_strength() {
|
|
6807
|
+
return GLTFExtensionParser.apply(this, arguments) || this;
|
|
6808
|
+
}
|
|
6809
|
+
var _proto = KHR_materials_emissive_strength.prototype;
|
|
6810
|
+
_proto.additiveParse = function additiveParse(_, material, schema) {
|
|
6811
|
+
var _schema_emissiveStrength = schema.emissiveStrength, emissiveStrength = _schema_emissiveStrength === void 0 ? 1 : _schema_emissiveStrength;
|
|
6812
|
+
if (emissiveStrength !== 1 && _instanceof(material, PBRMaterial)) {
|
|
6813
|
+
var color = material.emissiveColor;
|
|
6814
|
+
color.set(color.r * emissiveStrength, color.g * emissiveStrength, color.b * emissiveStrength, color.a);
|
|
6815
|
+
}
|
|
6816
|
+
};
|
|
6817
|
+
return KHR_materials_emissive_strength;
|
|
6818
|
+
}(GLTFExtensionParser);
|
|
6819
|
+
KHR_materials_emissive_strength = __decorate([
|
|
6820
|
+
registerGLTFExtension("KHR_materials_emissive_strength", GLTFExtensionMode.AdditiveParse)
|
|
6821
|
+
], KHR_materials_emissive_strength);
|
|
6822
|
+
|
|
6732
6823
|
var KHR_materials_ior = /*#__PURE__*/ function(GLTFExtensionParser) {
|
|
6733
6824
|
_inherits(KHR_materials_ior, GLTFExtensionParser);
|
|
6734
6825
|
function KHR_materials_ior() {
|