@babylonjs/loaders 5.17.1 → 5.18.0
Sign up to get free protection for your applications and to get access to all the features.
- package/glTF/2.0/Extensions/KHR_animation_pointer.d.ts +76 -0
- package/glTF/2.0/Extensions/KHR_animation_pointer.js +281 -0
- package/glTF/2.0/Extensions/KHR_animation_pointer.js.map +1 -0
- package/glTF/2.0/Extensions/KHR_animation_pointer.map.d.ts +15 -0
- package/glTF/2.0/Extensions/KHR_animation_pointer.map.js +484 -0
- package/glTF/2.0/Extensions/KHR_animation_pointer.map.js.map +1 -0
- package/glTF/2.0/Extensions/KHR_lights_punctual.d.ts +1 -0
- package/glTF/2.0/Extensions/KHR_lights_punctual.js +1 -0
- package/glTF/2.0/Extensions/KHR_lights_punctual.js.map +1 -1
- package/glTF/2.0/Extensions/index.d.ts +1 -0
- package/glTF/2.0/Extensions/index.js +1 -0
- package/glTF/2.0/Extensions/index.js.map +1 -1
- package/glTF/2.0/glTFLoader.d.ts +3 -14
- package/glTF/2.0/glTFLoader.js +27 -207
- package/glTF/2.0/glTFLoader.js.map +1 -1
- package/glTF/2.0/glTFLoaderInterfaces.d.ts +11 -0
- package/glTF/2.0/glTFLoaderInterfaces.js.map +1 -1
- package/glTF/2.0/glTFUtilities.d.ts +7 -0
- package/glTF/2.0/glTFUtilities.js +23 -0
- package/glTF/2.0/glTFUtilities.js.map +1 -0
- package/package.json +3 -3
@@ -20,6 +20,7 @@ export * from "./KHR_mesh_quantization.js";
|
|
20
20
|
export * from "./KHR_texture_basisu.js";
|
21
21
|
export * from "./KHR_texture_transform.js";
|
22
22
|
export * from "./KHR_xmp_json_ld.js";
|
23
|
+
export * from "./KHR_animation_pointer.js";
|
23
24
|
export * from "./MSFT_audio_emitter.js";
|
24
25
|
export * from "./MSFT_lod.js";
|
25
26
|
export * from "./MSFT_minecraftMesh.js";
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../lts/loaders/generated/glTF/2.0/Extensions/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oBAAoB,CAAC;AACnC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uBAAuB,CAAC;AACtC,cAAc,uCAAuC,CAAC;AACtD,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,mCAAmC,CAAC;AAClD,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,YAAY,CAAC;AAC3B,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC","sourcesContent":["export * from \"./EXT_lights_image_based\";\r\nexport * from \"./EXT_mesh_gpu_instancing\";\r\nexport * from \"./EXT_meshopt_compression\";\r\nexport * from \"./EXT_texture_webp\";\r\nexport * from \"./KHR_draco_mesh_compression\";\r\nexport * from \"./KHR_lights_punctual\";\r\nexport * from \"./KHR_materials_pbrSpecularGlossiness\";\r\nexport * from \"./KHR_materials_unlit\";\r\nexport * from \"./KHR_materials_clearcoat\";\r\nexport * from \"./KHR_materials_iridescence\";\r\nexport * from \"./KHR_materials_emissive_strength\";\r\nexport * from \"./KHR_materials_sheen\";\r\nexport * from \"./KHR_materials_specular\";\r\nexport * from \"./KHR_materials_ior\";\r\nexport * from \"./KHR_materials_variants\";\r\nexport * from \"./KHR_materials_transmission\";\r\nexport * from \"./KHR_materials_translucency\";\r\nexport * from \"./KHR_materials_volume\";\r\nexport * from \"./KHR_mesh_quantization\";\r\nexport * from \"./KHR_texture_basisu\";\r\nexport * from \"./KHR_texture_transform\";\r\nexport * from \"./KHR_xmp_json_ld\";\r\nexport * from \"./MSFT_audio_emitter\";\r\nexport * from \"./MSFT_lod\";\r\nexport * from \"./MSFT_minecraftMesh\";\r\nexport * from \"./MSFT_sRGBFactors\";\r\nexport * from \"./ExtrasAsMetadata\";\r\n"]}
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../lts/loaders/generated/glTF/2.0/Extensions/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oBAAoB,CAAC;AACnC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uBAAuB,CAAC;AACtC,cAAc,uCAAuC,CAAC;AACtD,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,mCAAmC,CAAC;AAClD,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,YAAY,CAAC;AAC3B,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC","sourcesContent":["export * from \"./EXT_lights_image_based\";\r\nexport * from \"./EXT_mesh_gpu_instancing\";\r\nexport * from \"./EXT_meshopt_compression\";\r\nexport * from \"./EXT_texture_webp\";\r\nexport * from \"./KHR_draco_mesh_compression\";\r\nexport * from \"./KHR_lights_punctual\";\r\nexport * from \"./KHR_materials_pbrSpecularGlossiness\";\r\nexport * from \"./KHR_materials_unlit\";\r\nexport * from \"./KHR_materials_clearcoat\";\r\nexport * from \"./KHR_materials_iridescence\";\r\nexport * from \"./KHR_materials_emissive_strength\";\r\nexport * from \"./KHR_materials_sheen\";\r\nexport * from \"./KHR_materials_specular\";\r\nexport * from \"./KHR_materials_ior\";\r\nexport * from \"./KHR_materials_variants\";\r\nexport * from \"./KHR_materials_transmission\";\r\nexport * from \"./KHR_materials_translucency\";\r\nexport * from \"./KHR_materials_volume\";\r\nexport * from \"./KHR_mesh_quantization\";\r\nexport * from \"./KHR_texture_basisu\";\r\nexport * from \"./KHR_texture_transform\";\r\nexport * from \"./KHR_xmp_json_ld\";\r\nexport * from \"./KHR_animation_pointer\";\r\nexport * from \"./MSFT_audio_emitter\";\r\nexport * from \"./MSFT_lod\";\r\nexport * from \"./MSFT_minecraftMesh\";\r\nexport * from \"./MSFT_sRGBFactors\";\r\nexport * from \"./ExtrasAsMetadata\";\r\n"]}
|
package/glTF/2.0/glTFLoader.d.ts
CHANGED
@@ -9,11 +9,10 @@ import { Mesh } from "@babylonjs/core/Meshes/mesh.js";
|
|
9
9
|
import type { ISceneLoaderAsyncResult, ISceneLoaderProgressEvent } from "@babylonjs/core/Loading/sceneLoader.js";
|
10
10
|
import type { Scene } from "@babylonjs/core/scene.js";
|
11
11
|
import type { IProperty } from "babylonjs-gltf2interface";
|
12
|
-
import type { IGLTF, ISampler, INode, IScene, IMesh, IAccessor, ICamera, IAnimation,
|
12
|
+
import type { IGLTF, ISampler, INode, IScene, IMesh, IAccessor, ICamera, IAnimation, IBuffer, IBufferView, IMaterial, ITextureInfo, ITexture, IImage, IMeshPrimitive, IArrayItem as IArrItem } from "./glTFLoaderInterfaces";
|
13
13
|
import type { IGLTFLoaderExtension } from "./glTFLoaderExtension";
|
14
14
|
import type { IGLTFLoader, IGLTFLoaderData } from "../glTFFileLoader";
|
15
15
|
import { GLTFFileLoader } from "../glTFFileLoader";
|
16
|
-
import type { IAnimatable } from "@babylonjs/core/Animations/animatable.interface.js";
|
17
16
|
import type { IDataBuffer } from "@babylonjs/core/Misc/dataReader.js";
|
18
17
|
import type { Light } from "@babylonjs/core/Lights/light.js";
|
19
18
|
import type { AssetContainer } from "@babylonjs/core/assetContainer.js";
|
@@ -39,6 +38,8 @@ export declare class ArrayItem {
|
|
39
38
|
* The glTF 2.0 loader
|
40
39
|
*/
|
41
40
|
export declare class GLTFLoader implements IGLTFLoader {
|
41
|
+
/** @hidden */
|
42
|
+
static readonly _KHRAnimationPointerName = "KHR_animation_pointer";
|
42
43
|
/** @hidden */
|
43
44
|
readonly _completePromises: Promise<any>[];
|
44
45
|
/** @hidden */
|
@@ -191,18 +192,6 @@ export declare class GLTFLoader implements IGLTFLoader {
|
|
191
192
|
* @returns A promise that resolves with the loaded Babylon animation group when the load is complete
|
192
193
|
*/
|
193
194
|
loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
|
194
|
-
/**
|
195
|
-
* @hidden Loads a glTF animation channel.
|
196
|
-
* @param context The context when loading the asset
|
197
|
-
* @param animationContext The context of the animation when loading the asset
|
198
|
-
* @param animation The glTF animation property
|
199
|
-
* @param channel The glTF animation channel property
|
200
|
-
* @param babylonAnimationGroup The babylon animation group property
|
201
|
-
* @param animationTargetOverride The babylon animation channel target override property. My be null.
|
202
|
-
* @returns A void promise when the channel load is complete
|
203
|
-
*/
|
204
|
-
_loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
|
205
|
-
private _loadAnimationSamplerAsync;
|
206
195
|
/**
|
207
196
|
* Loads a glTF buffer.
|
208
197
|
* @param context The context when loading the asset
|
package/glTF/2.0/glTFLoader.js
CHANGED
@@ -5,7 +5,6 @@ import { Tools } from "@babylonjs/core/Misc/tools.js";
|
|
5
5
|
import { Camera } from "@babylonjs/core/Cameras/camera.js";
|
6
6
|
import { FreeCamera } from "@babylonjs/core/Cameras/freeCamera.js";
|
7
7
|
import { AnimationGroup } from "@babylonjs/core/Animations/animationGroup.js";
|
8
|
-
import { Animation } from "@babylonjs/core/Animations/animation.js";
|
9
8
|
import { Bone } from "@babylonjs/core/Bones/bone.js";
|
10
9
|
import { Skeleton } from "@babylonjs/core/Bones/skeleton.js";
|
11
10
|
import { Material } from "@babylonjs/core/Materials/material.js";
|
@@ -18,7 +17,6 @@ import { Mesh } from "@babylonjs/core/Meshes/mesh.js";
|
|
18
17
|
import { MorphTarget } from "@babylonjs/core/Morph/morphTarget.js";
|
19
18
|
import { MorphTargetManager } from "@babylonjs/core/Morph/morphTargetManager.js";
|
20
19
|
import { GLTFFileLoader, GLTFLoaderState, GLTFLoaderCoordinateSystemMode, GLTFLoaderAnimationStartMode } from "../glTFFileLoader.js";
|
21
|
-
import { AnimationKeyInterpolation } from "@babylonjs/core/Animations/animationKey.js";
|
22
20
|
import { DecodeBase64UrlToBinary, IsBase64DataUrl, LoadFileError } from "@babylonjs/core/Misc/fileTools.js";
|
23
21
|
import { Logger } from "@babylonjs/core/Misc/logger.js";
|
24
22
|
import { BoundingInfo } from "@babylonjs/core/Culling/boundingInfo.js";
|
@@ -1225,6 +1223,8 @@ var GLTFLoader = /** @class */ (function () {
|
|
1225
1223
|
GLTFLoader.AddPointerMetadata(babylonCamera, context);
|
1226
1224
|
this._parent.onCameraLoadedObservable.notifyObservers(babylonCamera);
|
1227
1225
|
assign(babylonCamera);
|
1226
|
+
// register the camera to be used later.
|
1227
|
+
camera._babylonCamera = babylonCamera;
|
1228
1228
|
this.logClose();
|
1229
1229
|
return Promise.all(promises).then(function () {
|
1230
1230
|
return babylonCamera;
|
@@ -1254,217 +1254,33 @@ var GLTFLoader = /** @class */ (function () {
|
|
1254
1254
|
* @returns A promise that resolves with the loaded Babylon animation group when the load is complete
|
1255
1255
|
*/
|
1256
1256
|
GLTFLoader.prototype.loadAnimationAsync = function (context, animation) {
|
1257
|
-
|
1258
|
-
|
1259
|
-
|
1257
|
+
// turn everything into pointer
|
1258
|
+
for (var _i = 0, _a = animation.channels; _i < _a.length; _i++) {
|
1259
|
+
var channel = _a[_i];
|
1260
|
+
if (channel.target.path == "pointer" /* POINTER */) {
|
1261
|
+
continue;
|
1262
|
+
}
|
1263
|
+
// decorate the channel with a KHR_animation_pointer extension.
|
1264
|
+
channel.target.extensions = channel.target.extensions || {};
|
1265
|
+
channel.target.extensions.KHR_animation_pointer = {
|
1266
|
+
pointer: "/nodes/".concat(channel.target.node, "/").concat(channel.target.path),
|
1267
|
+
};
|
1268
|
+
channel.target.path = "pointer" /* POINTER */;
|
1269
|
+
delete channel.target.node;
|
1270
|
+
// ensure to declare extension used.
|
1271
|
+
this._gltf.extensionsUsed = this._gltf.extensionsUsed || [];
|
1272
|
+
if (this._gltf.extensionsUsed.indexOf(GLTFLoader._KHRAnimationPointerName) === -1) {
|
1273
|
+
this._gltf.extensionsUsed.push(GLTFLoader._KHRAnimationPointerName);
|
1274
|
+
}
|
1260
1275
|
}
|
1276
|
+
// create the animation group to be passed to extension.
|
1261
1277
|
this._babylonScene._blockEntityCollection = !!this._assetContainer;
|
1262
1278
|
var babylonAnimationGroup = new AnimationGroup(animation.name || "animation".concat(animation.index), this._babylonScene);
|
1263
1279
|
babylonAnimationGroup._parentContainer = this._assetContainer;
|
1264
1280
|
this._babylonScene._blockEntityCollection = false;
|
1265
1281
|
animation._babylonAnimationGroup = babylonAnimationGroup;
|
1266
|
-
var
|
1267
|
-
|
1268
|
-
ArrayItem.Assign(animation.samplers);
|
1269
|
-
for (var _i = 0, _a = animation.channels; _i < _a.length; _i++) {
|
1270
|
-
var channel = _a[_i];
|
1271
|
-
promises.push(this._loadAnimationChannelAsync("".concat(context, "/channels/").concat(channel.index), context, animation, channel, babylonAnimationGroup));
|
1272
|
-
}
|
1273
|
-
return Promise.all(promises).then(function () {
|
1274
|
-
babylonAnimationGroup.normalize(0);
|
1275
|
-
return babylonAnimationGroup;
|
1276
|
-
});
|
1277
|
-
};
|
1278
|
-
/**
|
1279
|
-
* @hidden Loads a glTF animation channel.
|
1280
|
-
* @param context The context when loading the asset
|
1281
|
-
* @param animationContext The context of the animation when loading the asset
|
1282
|
-
* @param animation The glTF animation property
|
1283
|
-
* @param channel The glTF animation channel property
|
1284
|
-
* @param babylonAnimationGroup The babylon animation group property
|
1285
|
-
* @param animationTargetOverride The babylon animation channel target override property. My be null.
|
1286
|
-
* @returns A void promise when the channel load is complete
|
1287
|
-
*/
|
1288
|
-
GLTFLoader.prototype._loadAnimationChannelAsync = function (context, animationContext, animation, channel, babylonAnimationGroup, animationTargetOverride) {
|
1289
|
-
var _this = this;
|
1290
|
-
if (animationTargetOverride === void 0) { animationTargetOverride = null; }
|
1291
|
-
if (channel.target.node == undefined) {
|
1292
|
-
return Promise.resolve();
|
1293
|
-
}
|
1294
|
-
var targetNode = ArrayItem.Get("".concat(context, "/target/node"), this._gltf.nodes, channel.target.node);
|
1295
|
-
// Ignore animations that have no animation targets.
|
1296
|
-
if ((channel.target.path === "weights" /* WEIGHTS */ && !targetNode._numMorphTargets) ||
|
1297
|
-
(channel.target.path !== "weights" /* WEIGHTS */ && !targetNode._babylonTransformNode)) {
|
1298
|
-
return Promise.resolve();
|
1299
|
-
}
|
1300
|
-
var sampler = ArrayItem.Get("".concat(context, "/sampler"), animation.samplers, channel.sampler);
|
1301
|
-
return this._loadAnimationSamplerAsync("".concat(animationContext, "/samplers/").concat(channel.sampler), sampler).then(function (data) {
|
1302
|
-
var targetPath;
|
1303
|
-
var animationType;
|
1304
|
-
switch (channel.target.path) {
|
1305
|
-
case "translation" /* TRANSLATION */: {
|
1306
|
-
targetPath = "position";
|
1307
|
-
animationType = Animation.ANIMATIONTYPE_VECTOR3;
|
1308
|
-
break;
|
1309
|
-
}
|
1310
|
-
case "rotation" /* ROTATION */: {
|
1311
|
-
targetPath = "rotationQuaternion";
|
1312
|
-
animationType = Animation.ANIMATIONTYPE_QUATERNION;
|
1313
|
-
break;
|
1314
|
-
}
|
1315
|
-
case "scale" /* SCALE */: {
|
1316
|
-
targetPath = "scaling";
|
1317
|
-
animationType = Animation.ANIMATIONTYPE_VECTOR3;
|
1318
|
-
break;
|
1319
|
-
}
|
1320
|
-
case "weights" /* WEIGHTS */: {
|
1321
|
-
targetPath = "influence";
|
1322
|
-
animationType = Animation.ANIMATIONTYPE_FLOAT;
|
1323
|
-
break;
|
1324
|
-
}
|
1325
|
-
default: {
|
1326
|
-
throw new Error("".concat(context, "/target/path: Invalid value (").concat(channel.target.path, ")"));
|
1327
|
-
}
|
1328
|
-
}
|
1329
|
-
var outputBufferOffset = 0;
|
1330
|
-
var getNextOutputValue;
|
1331
|
-
switch (targetPath) {
|
1332
|
-
case "position": {
|
1333
|
-
getNextOutputValue = function (scale) {
|
1334
|
-
var value = Vector3.FromArray(data.output, outputBufferOffset).scaleInPlace(scale);
|
1335
|
-
outputBufferOffset += 3;
|
1336
|
-
return value;
|
1337
|
-
};
|
1338
|
-
break;
|
1339
|
-
}
|
1340
|
-
case "rotationQuaternion": {
|
1341
|
-
getNextOutputValue = function (scale) {
|
1342
|
-
var value = Quaternion.FromArray(data.output, outputBufferOffset).scaleInPlace(scale);
|
1343
|
-
outputBufferOffset += 4;
|
1344
|
-
return value;
|
1345
|
-
};
|
1346
|
-
break;
|
1347
|
-
}
|
1348
|
-
case "scaling": {
|
1349
|
-
getNextOutputValue = function (scale) {
|
1350
|
-
var value = Vector3.FromArray(data.output, outputBufferOffset).scaleInPlace(scale);
|
1351
|
-
outputBufferOffset += 3;
|
1352
|
-
return value;
|
1353
|
-
};
|
1354
|
-
break;
|
1355
|
-
}
|
1356
|
-
case "influence": {
|
1357
|
-
getNextOutputValue = function (scale) {
|
1358
|
-
var value = new Array(targetNode._numMorphTargets);
|
1359
|
-
for (var i = 0; i < targetNode._numMorphTargets; i++) {
|
1360
|
-
value[i] = data.output[outputBufferOffset++] * scale;
|
1361
|
-
}
|
1362
|
-
return value;
|
1363
|
-
};
|
1364
|
-
break;
|
1365
|
-
}
|
1366
|
-
}
|
1367
|
-
var getNextKey;
|
1368
|
-
switch (data.interpolation) {
|
1369
|
-
case "STEP" /* STEP */: {
|
1370
|
-
getNextKey = function (frameIndex) { return ({
|
1371
|
-
frame: data.input[frameIndex] * _this.parent.targetFps,
|
1372
|
-
value: getNextOutputValue(1),
|
1373
|
-
interpolation: AnimationKeyInterpolation.STEP,
|
1374
|
-
}); };
|
1375
|
-
break;
|
1376
|
-
}
|
1377
|
-
case "LINEAR" /* LINEAR */: {
|
1378
|
-
getNextKey = function (frameIndex) { return ({
|
1379
|
-
frame: data.input[frameIndex] * _this.parent.targetFps,
|
1380
|
-
value: getNextOutputValue(1),
|
1381
|
-
}); };
|
1382
|
-
break;
|
1383
|
-
}
|
1384
|
-
case "CUBICSPLINE" /* CUBICSPLINE */: {
|
1385
|
-
var invTargetFps_1 = 1 / _this.parent.targetFps;
|
1386
|
-
getNextKey = function (frameIndex) { return ({
|
1387
|
-
frame: data.input[frameIndex] * _this.parent.targetFps,
|
1388
|
-
inTangent: getNextOutputValue(invTargetFps_1),
|
1389
|
-
value: getNextOutputValue(1),
|
1390
|
-
outTangent: getNextOutputValue(invTargetFps_1),
|
1391
|
-
}); };
|
1392
|
-
break;
|
1393
|
-
}
|
1394
|
-
}
|
1395
|
-
var keys = new Array(data.input.length);
|
1396
|
-
for (var frameIndex = 0; frameIndex < data.input.length; frameIndex++) {
|
1397
|
-
keys[frameIndex] = getNextKey(frameIndex);
|
1398
|
-
}
|
1399
|
-
if (targetPath === "influence") {
|
1400
|
-
var _loop_2 = function (targetIndex) {
|
1401
|
-
var animationName = "".concat(babylonAnimationGroup.name, "_channel").concat(babylonAnimationGroup.targetedAnimations.length);
|
1402
|
-
var babylonAnimation = new Animation(animationName, targetPath, _this.parent.targetFps, animationType);
|
1403
|
-
babylonAnimation.setKeys(keys.map(function (key) { return ({
|
1404
|
-
frame: key.frame,
|
1405
|
-
inTangent: key.inTangent ? key.inTangent[targetIndex] : undefined,
|
1406
|
-
value: key.value[targetIndex],
|
1407
|
-
outTangent: key.outTangent ? key.outTangent[targetIndex] : undefined,
|
1408
|
-
interpolation: key.interpolation,
|
1409
|
-
}); }));
|
1410
|
-
_this._forEachPrimitive(targetNode, function (babylonAbstractMesh) {
|
1411
|
-
var babylonMesh = babylonAbstractMesh;
|
1412
|
-
if (babylonMesh.morphTargetManager) {
|
1413
|
-
var morphTarget = babylonMesh.morphTargetManager.getTarget(targetIndex);
|
1414
|
-
var babylonAnimationClone = babylonAnimation.clone();
|
1415
|
-
morphTarget.animations.push(babylonAnimationClone);
|
1416
|
-
babylonAnimationGroup.addTargetedAnimation(babylonAnimationClone, morphTarget);
|
1417
|
-
}
|
1418
|
-
});
|
1419
|
-
};
|
1420
|
-
for (var targetIndex = 0; targetIndex < targetNode._numMorphTargets; targetIndex++) {
|
1421
|
-
_loop_2(targetIndex);
|
1422
|
-
}
|
1423
|
-
}
|
1424
|
-
else {
|
1425
|
-
var animationName = "".concat(babylonAnimationGroup.name, "_channel").concat(babylonAnimationGroup.targetedAnimations.length);
|
1426
|
-
var babylonAnimation = new Animation(animationName, targetPath, _this.parent.targetFps, animationType);
|
1427
|
-
babylonAnimation.setKeys(keys);
|
1428
|
-
if (animationTargetOverride != null && animationTargetOverride.animations != null) {
|
1429
|
-
animationTargetOverride.animations.push(babylonAnimation);
|
1430
|
-
babylonAnimationGroup.addTargetedAnimation(babylonAnimation, animationTargetOverride);
|
1431
|
-
}
|
1432
|
-
else {
|
1433
|
-
targetNode._babylonTransformNode.animations.push(babylonAnimation);
|
1434
|
-
babylonAnimationGroup.addTargetedAnimation(babylonAnimation, targetNode._babylonTransformNode);
|
1435
|
-
}
|
1436
|
-
}
|
1437
|
-
});
|
1438
|
-
};
|
1439
|
-
GLTFLoader.prototype._loadAnimationSamplerAsync = function (context, sampler) {
|
1440
|
-
if (sampler._data) {
|
1441
|
-
return sampler._data;
|
1442
|
-
}
|
1443
|
-
var interpolation = sampler.interpolation || "LINEAR" /* LINEAR */;
|
1444
|
-
switch (interpolation) {
|
1445
|
-
case "STEP" /* STEP */:
|
1446
|
-
case "LINEAR" /* LINEAR */:
|
1447
|
-
case "CUBICSPLINE" /* CUBICSPLINE */: {
|
1448
|
-
break;
|
1449
|
-
}
|
1450
|
-
default: {
|
1451
|
-
throw new Error("".concat(context, "/interpolation: Invalid value (").concat(sampler.interpolation, ")"));
|
1452
|
-
}
|
1453
|
-
}
|
1454
|
-
var inputAccessor = ArrayItem.Get("".concat(context, "/input"), this._gltf.accessors, sampler.input);
|
1455
|
-
var outputAccessor = ArrayItem.Get("".concat(context, "/output"), this._gltf.accessors, sampler.output);
|
1456
|
-
sampler._data = Promise.all([
|
1457
|
-
this._loadFloatAccessorAsync("/accessors/".concat(inputAccessor.index), inputAccessor),
|
1458
|
-
this._loadFloatAccessorAsync("/accessors/".concat(outputAccessor.index), outputAccessor),
|
1459
|
-
]).then(function (_a) {
|
1460
|
-
var inputData = _a[0], outputData = _a[1];
|
1461
|
-
return {
|
1462
|
-
input: inputData,
|
1463
|
-
interpolation: interpolation,
|
1464
|
-
output: outputData,
|
1465
|
-
};
|
1466
|
-
});
|
1467
|
-
return sampler._data;
|
1282
|
+
var promise = this._extensionsLoadAnimationAsync(context, animation);
|
1283
|
+
return promise !== null && promise !== void 0 ? promise : Promise.resolve(animation._babylonAnimationGroup);
|
1468
1284
|
};
|
1469
1285
|
/**
|
1470
1286
|
* Loads a glTF buffer.
|
@@ -2392,6 +2208,10 @@ var GLTFLoader = /** @class */ (function () {
|
|
2392
2208
|
GLTFLoader.prototype.endPerformanceCounter = function (counterName) {
|
2393
2209
|
this._parent._endPerformanceCounter(counterName);
|
2394
2210
|
};
|
2211
|
+
/** @hidden */
|
2212
|
+
// note : KHR_animation_pointer is used to load animation in ALL case, turning everything
|
2213
|
+
// into pointer. This is the reason why this value is located here.
|
2214
|
+
GLTFLoader._KHRAnimationPointerName = "KHR_animation_pointer";
|
2395
2215
|
GLTFLoader._RegisteredExtensions = {};
|
2396
2216
|
/**
|
2397
2217
|
* The default glTF sampler.
|