babylonjs-loaders 5.17.1 → 5.20.0
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/babylon.glTF2FileLoader.js +877 -217
- package/babylon.glTF2FileLoader.js.map +1 -1
- package/babylon.glTF2FileLoader.min.js +1 -1
- package/babylon.glTF2FileLoader.min.js.map +1 -1
- package/babylon.glTFFileLoader.js +877 -217
- package/babylon.glTFFileLoader.js.map +1 -1
- package/babylon.glTFFileLoader.min.js +1 -1
- package/babylon.glTFFileLoader.min.js.map +1 -1
- package/babylonjs.loaders.d.ts +121 -12
- package/babylonjs.loaders.js +877 -217
- package/babylonjs.loaders.js.map +1 -1
- package/babylonjs.loaders.min.js +1 -1
- package/babylonjs.loaders.min.js.map +1 -1
- package/babylonjs.loaders.module.d.ts +244 -26
- package/package.json +3 -3
|
@@ -744,6 +744,805 @@ var ExtrasAsMetadata = /** @class */ (function () {
|
|
|
744
744
|
_glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new ExtrasAsMetadata(loader); });
|
|
745
745
|
|
|
746
746
|
|
|
747
|
+
/***/ }),
|
|
748
|
+
|
|
749
|
+
/***/ "../../../lts/loaders/dist/glTF/2.0/Extensions/KHR_animation_pointer.js":
|
|
750
|
+
/*!******************************************************************************!*\
|
|
751
|
+
!*** ../../../lts/loaders/dist/glTF/2.0/Extensions/KHR_animation_pointer.js ***!
|
|
752
|
+
\******************************************************************************/
|
|
753
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
754
|
+
|
|
755
|
+
__webpack_require__.r(__webpack_exports__);
|
|
756
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
757
|
+
/* harmony export */ "KHR_animation_pointer": () => (/* binding */ KHR_animation_pointer)
|
|
758
|
+
/* harmony export */ });
|
|
759
|
+
/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../glTFLoader */ "../../../lts/loaders/dist/glTF/2.0/glTFLoader.js");
|
|
760
|
+
/* harmony import */ var core_Animations_animationGroup__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! core/Animations/animationKey */ "core/Misc/observable");
|
|
761
|
+
/* harmony import */ var core_Animations_animationGroup__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(core_Animations_animationGroup__WEBPACK_IMPORTED_MODULE_1__);
|
|
762
|
+
/* harmony import */ var _KHR_animation_pointer_map__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./KHR_animation_pointer.map */ "../../../lts/loaders/dist/glTF/2.0/Extensions/KHR_animation_pointer.map.js");
|
|
763
|
+
/* harmony import */ var _glTFUtilities__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../glTFUtilities */ "../../../lts/loaders/dist/glTF/2.0/glTFUtilities.js");
|
|
764
|
+
|
|
765
|
+
|
|
766
|
+
|
|
767
|
+
|
|
768
|
+
|
|
769
|
+
var NAME = _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader._KHRAnimationPointerName;
|
|
770
|
+
/**
|
|
771
|
+
* [Specification PR](https://github.com/KhronosGroup/glTF/pull/2147)
|
|
772
|
+
*/
|
|
773
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
774
|
+
var KHR_animation_pointer = /** @class */ (function () {
|
|
775
|
+
/**
|
|
776
|
+
* @param loader
|
|
777
|
+
* @hidden
|
|
778
|
+
*/
|
|
779
|
+
function KHR_animation_pointer(loader) {
|
|
780
|
+
/**
|
|
781
|
+
* used to gently ignore invalid pointer. If false, invalid pointer will throw exception.
|
|
782
|
+
*/
|
|
783
|
+
this.ignoreInvalidPointer = true;
|
|
784
|
+
/**
|
|
785
|
+
* The name of this extension.
|
|
786
|
+
*/
|
|
787
|
+
this.name = NAME;
|
|
788
|
+
this._loader = loader;
|
|
789
|
+
}
|
|
790
|
+
Object.defineProperty(KHR_animation_pointer.prototype, "enabled", {
|
|
791
|
+
/**
|
|
792
|
+
* Defines whether this extension is enabled.
|
|
793
|
+
*/
|
|
794
|
+
get: function () {
|
|
795
|
+
return this._loader.isExtensionUsed(NAME);
|
|
796
|
+
},
|
|
797
|
+
enumerable: false,
|
|
798
|
+
configurable: true
|
|
799
|
+
});
|
|
800
|
+
/** @hidden */
|
|
801
|
+
KHR_animation_pointer.prototype.dispose = function () {
|
|
802
|
+
this._loader = null;
|
|
803
|
+
};
|
|
804
|
+
/**
|
|
805
|
+
* according to specification,
|
|
806
|
+
* It is not allowed to animate a glTFid property, as it does change the structure of the glTF in general
|
|
807
|
+
* It is not allowed to animate a name property in general.
|
|
808
|
+
* @param property
|
|
809
|
+
* @hidden
|
|
810
|
+
*/
|
|
811
|
+
KHR_animation_pointer.prototype.accept = function (property) {
|
|
812
|
+
return property != "name";
|
|
813
|
+
};
|
|
814
|
+
KHR_animation_pointer.prototype.loadAnimationAsync = function (context, animation) {
|
|
815
|
+
// ensure an animation group is present.
|
|
816
|
+
if (!animation._babylonAnimationGroup) {
|
|
817
|
+
this._loader.babylonScene._blockEntityCollection = !!this._loader._assetContainer;
|
|
818
|
+
var group = new core_Animations_animationGroup__WEBPACK_IMPORTED_MODULE_1__.AnimationGroup(animation.name || "animation".concat(animation.index), this._loader.babylonScene);
|
|
819
|
+
group._parentContainer = this._loader._assetContainer;
|
|
820
|
+
this._loader.babylonScene._blockEntityCollection = false;
|
|
821
|
+
animation._babylonAnimationGroup = group;
|
|
822
|
+
}
|
|
823
|
+
var babylonAnimationGroup = animation._babylonAnimationGroup;
|
|
824
|
+
var promises = new Array();
|
|
825
|
+
_glTFLoader__WEBPACK_IMPORTED_MODULE_0__.ArrayItem.Assign(animation.channels);
|
|
826
|
+
_glTFLoader__WEBPACK_IMPORTED_MODULE_0__.ArrayItem.Assign(animation.samplers);
|
|
827
|
+
for (var _i = 0, _a = animation.channels; _i < _a.length; _i++) {
|
|
828
|
+
var channel = _a[_i];
|
|
829
|
+
promises.push(this._loadAnimationChannelAsync("".concat(context, "/channels/").concat(channel.index), context, animation, channel));
|
|
830
|
+
}
|
|
831
|
+
return Promise.all(promises).then(function () {
|
|
832
|
+
babylonAnimationGroup.normalize(0);
|
|
833
|
+
return babylonAnimationGroup;
|
|
834
|
+
});
|
|
835
|
+
};
|
|
836
|
+
/**
|
|
837
|
+
* @hidden Loads a glTF animation channel.
|
|
838
|
+
* @param context The context when loading the asset
|
|
839
|
+
* @param animationContext The context of the animation when loading the asset
|
|
840
|
+
* @param animation The glTF animation property
|
|
841
|
+
* @param channel The glTF animation channel property
|
|
842
|
+
* @param animationTargetOverride The babylon animation channel target override property. My be null.
|
|
843
|
+
* @returns A void promise when the channel load is complete
|
|
844
|
+
*/
|
|
845
|
+
KHR_animation_pointer.prototype._loadAnimationChannelAsync = function (context, animationContext, animation, channel, animationTargetOverride) {
|
|
846
|
+
var _this = this;
|
|
847
|
+
var _a, _b;
|
|
848
|
+
if (animationTargetOverride === void 0) { animationTargetOverride = null; }
|
|
849
|
+
if (channel.target.path != "pointer" /* POINTER */) {
|
|
850
|
+
throw new Error("".concat(context, "/target/path: Invalid value (").concat(channel.target.path, ")"));
|
|
851
|
+
}
|
|
852
|
+
if (channel.target.node != undefined) {
|
|
853
|
+
// According to KHR_animation_pointer specification
|
|
854
|
+
// If this extension is used, the animation.channel.target.node must not be set.
|
|
855
|
+
// Because the node is defined, the channel is ignored and not animated due to the specification.
|
|
856
|
+
return Promise.resolve();
|
|
857
|
+
}
|
|
858
|
+
var pointer = (_b = (_a = channel.target.extensions) === null || _a === void 0 ? void 0 : _a.KHR_animation_pointer) === null || _b === void 0 ? void 0 : _b.pointer;
|
|
859
|
+
if (!pointer) {
|
|
860
|
+
throw new Error("".concat(context, "/target/extensions/").concat(this.name, ": Pointer is missing"));
|
|
861
|
+
}
|
|
862
|
+
var sampler = _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.ArrayItem.Get("".concat(context, "/sampler"), animation.samplers, channel.sampler);
|
|
863
|
+
return this._loadAnimationSamplerAsync("".concat(context, "/samplers/").concat(channel.sampler), sampler).then(function (data) {
|
|
864
|
+
var _a;
|
|
865
|
+
// this is where we process the pointer.
|
|
866
|
+
var animationTarget = _this._parseAnimationPointer("".concat(context, "/extensions/").concat(_this.name, "/pointer"), pointer);
|
|
867
|
+
if (!animationTarget) {
|
|
868
|
+
return;
|
|
869
|
+
}
|
|
870
|
+
// build the keys
|
|
871
|
+
// build the animations into the group
|
|
872
|
+
var babylonAnimationGroup = animation._babylonAnimationGroup;
|
|
873
|
+
if (!babylonAnimationGroup) {
|
|
874
|
+
return;
|
|
875
|
+
}
|
|
876
|
+
var outputAccessor = _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.ArrayItem.Get("".concat(context, "/output"), _this._loader.gltf.accessors, sampler.output);
|
|
877
|
+
// stride is the size of each element stored into the output buffer.
|
|
878
|
+
var stride = (_a = animationTarget.stride) !== null && _a !== void 0 ? _a : (0,_glTFUtilities__WEBPACK_IMPORTED_MODULE_3__.getDataAccessorElementCount)(outputAccessor.type);
|
|
879
|
+
var fps = _this._loader.parent.targetFps;
|
|
880
|
+
// we extract the corresponding values from the read value.
|
|
881
|
+
// the reason for that is one GLTF value may be dispatched to several Babylon properties
|
|
882
|
+
// one of example is baseColorFactor which is a Color4 under GLTF and dispatched to
|
|
883
|
+
// - albedoColor as Color3(Color4.r,Color4.g,Color4.b)
|
|
884
|
+
// - alpha as Color4.a
|
|
885
|
+
for (var _i = 0, _b = animationTarget.properties; _i < _b.length; _i++) {
|
|
886
|
+
var propertyInfo = _b[_i];
|
|
887
|
+
// Ignore animations that have no animation valid targets.
|
|
888
|
+
if (!propertyInfo.isValid(animationTarget.target)) {
|
|
889
|
+
return;
|
|
890
|
+
}
|
|
891
|
+
// build the keys.
|
|
892
|
+
var keys = new Array(data.input.length);
|
|
893
|
+
var outputOffset = 0;
|
|
894
|
+
switch (data.interpolation) {
|
|
895
|
+
case "STEP" /* STEP */: {
|
|
896
|
+
for (var frameIndex = 0; frameIndex < data.input.length; frameIndex++) {
|
|
897
|
+
keys[frameIndex] = {
|
|
898
|
+
frame: data.input[frameIndex] * fps,
|
|
899
|
+
value: propertyInfo.get(animationTarget.target, data.output, outputOffset),
|
|
900
|
+
interpolation: core_Animations_animationGroup__WEBPACK_IMPORTED_MODULE_1__.AnimationKeyInterpolation.STEP,
|
|
901
|
+
};
|
|
902
|
+
outputOffset += stride;
|
|
903
|
+
}
|
|
904
|
+
break;
|
|
905
|
+
}
|
|
906
|
+
case "CUBICSPLINE" /* CUBICSPLINE */: {
|
|
907
|
+
var invfps = 1 / fps;
|
|
908
|
+
for (var frameIndex = 0; frameIndex < data.input.length; frameIndex++) {
|
|
909
|
+
var k = {
|
|
910
|
+
frame: data.input[frameIndex] * fps,
|
|
911
|
+
};
|
|
912
|
+
(k.inTangent = propertyInfo.get(animationTarget.target, data.output, outputOffset, invfps)), (outputOffset += stride);
|
|
913
|
+
(k.value = propertyInfo.get(animationTarget.target, data.output, outputOffset)), (outputOffset += stride);
|
|
914
|
+
(k.outTangent = propertyInfo.get(animationTarget.target, data.output, outputOffset, invfps)), (outputOffset += stride);
|
|
915
|
+
keys[frameIndex] = k;
|
|
916
|
+
}
|
|
917
|
+
break;
|
|
918
|
+
}
|
|
919
|
+
case "LINEAR" /* LINEAR */:
|
|
920
|
+
default: {
|
|
921
|
+
for (var frameIndex = 0; frameIndex < data.input.length; frameIndex++) {
|
|
922
|
+
keys[frameIndex] = {
|
|
923
|
+
frame: data.input[frameIndex] * fps,
|
|
924
|
+
value: propertyInfo.get(animationTarget.target, data.output, outputOffset),
|
|
925
|
+
};
|
|
926
|
+
outputOffset += stride;
|
|
927
|
+
}
|
|
928
|
+
break;
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
// each properties has its own build animation process.
|
|
932
|
+
// these logics are located into KHR_animation_pointer.map.ts
|
|
933
|
+
propertyInfo.buildAnimations(animationTarget.target, fps, keys, babylonAnimationGroup, animationTargetOverride, animationTarget.params);
|
|
934
|
+
}
|
|
935
|
+
});
|
|
936
|
+
};
|
|
937
|
+
KHR_animation_pointer.prototype._loadAnimationSamplerAsync = function (context, sampler) {
|
|
938
|
+
if (sampler._data) {
|
|
939
|
+
return sampler._data;
|
|
940
|
+
}
|
|
941
|
+
var interpolation = sampler.interpolation || "LINEAR" /* LINEAR */;
|
|
942
|
+
switch (interpolation) {
|
|
943
|
+
case "STEP" /* STEP */:
|
|
944
|
+
case "LINEAR" /* LINEAR */:
|
|
945
|
+
case "CUBICSPLINE" /* CUBICSPLINE */: {
|
|
946
|
+
break;
|
|
947
|
+
}
|
|
948
|
+
default: {
|
|
949
|
+
throw new Error("".concat(context, "/interpolation: Invalid value (").concat(sampler.interpolation, ")"));
|
|
950
|
+
}
|
|
951
|
+
}
|
|
952
|
+
var inputAccessor = _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.ArrayItem.Get("".concat(context, "/input"), this._loader.gltf.accessors, sampler.input);
|
|
953
|
+
var outputAccessor = _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.ArrayItem.Get("".concat(context, "/output"), this._loader.gltf.accessors, sampler.output);
|
|
954
|
+
sampler._data = Promise.all([
|
|
955
|
+
this._loader._loadFloatAccessorAsync("/accessors/".concat(inputAccessor.index), inputAccessor),
|
|
956
|
+
this._loader._loadFloatAccessorAsync("/accessors/".concat(outputAccessor.index), outputAccessor),
|
|
957
|
+
]).then(function (_a) {
|
|
958
|
+
var inputData = _a[0], outputData = _a[1];
|
|
959
|
+
return {
|
|
960
|
+
input: inputData,
|
|
961
|
+
interpolation: interpolation,
|
|
962
|
+
output: outputData,
|
|
963
|
+
};
|
|
964
|
+
});
|
|
965
|
+
return sampler._data;
|
|
966
|
+
};
|
|
967
|
+
/**
|
|
968
|
+
* parsing animation pointer is the core of animation channel.
|
|
969
|
+
* Animation pointer is a Json pointer, which mean it locate an item into the json hierarchy.
|
|
970
|
+
* Consequentely the pointer has the following BNF
|
|
971
|
+
|
|
972
|
+
* <animationPointer> := <sep><assetContainer><sep><assetIndex><sep><propertyPath>
|
|
973
|
+
* <assetContainer> := "nodes" | "materials" | "meshes" | "cameras" | "extensions"
|
|
974
|
+
* <assetIndex> := <digit> | <name>
|
|
975
|
+
* <propertyPath> := <extensionPath> | <standardPath>
|
|
976
|
+
* <extensionPath> := "extensions"<sep><name><sep><standardPath>
|
|
977
|
+
* <standardPath> := <name> | <name><sep><standardPath>
|
|
978
|
+
* <sep>:= "/"
|
|
979
|
+
* <name> := W+
|
|
980
|
+
* <digit> := D+
|
|
981
|
+
*
|
|
982
|
+
* examples of pointer are
|
|
983
|
+
* - "/nodes/0/rotation"
|
|
984
|
+
* - "/materials/2/emissiveFactor"
|
|
985
|
+
* - "/materials/2/pbrMetallicRoughness/baseColorFactor"
|
|
986
|
+
* - "/materials/2/extensions/KHR_materials_emissive_strength/emissiveStrength"
|
|
987
|
+
* @param context
|
|
988
|
+
* @param pointer
|
|
989
|
+
* @return
|
|
990
|
+
*/
|
|
991
|
+
KHR_animation_pointer.prototype._parseAnimationPointer = function (context, pointer) {
|
|
992
|
+
var sep = "/";
|
|
993
|
+
if (pointer.charAt(0) == sep) {
|
|
994
|
+
pointer = pointer.substring(1);
|
|
995
|
+
}
|
|
996
|
+
var parts = pointer.split(sep);
|
|
997
|
+
// we have a least 3 part
|
|
998
|
+
if (parts.length >= 3) {
|
|
999
|
+
var node = _KHR_animation_pointer_map__WEBPACK_IMPORTED_MODULE_2__.CoreAnimationPointerMap; // the map of possible path
|
|
1000
|
+
var indices = [];
|
|
1001
|
+
var getTarget = null;
|
|
1002
|
+
for (var i = 0; i < parts.length; i++) {
|
|
1003
|
+
var part = parts[i];
|
|
1004
|
+
node = node[part];
|
|
1005
|
+
if (!node) {
|
|
1006
|
+
// nothing to do so far
|
|
1007
|
+
break;
|
|
1008
|
+
}
|
|
1009
|
+
if (node.getTarget) {
|
|
1010
|
+
getTarget = node.getTarget;
|
|
1011
|
+
}
|
|
1012
|
+
if (node.hasIndex) {
|
|
1013
|
+
indices.push(parts[++i]);
|
|
1014
|
+
// move to the next part
|
|
1015
|
+
continue;
|
|
1016
|
+
}
|
|
1017
|
+
if (node.isIndex) {
|
|
1018
|
+
indices.push(part);
|
|
1019
|
+
// move to the next part
|
|
1020
|
+
continue;
|
|
1021
|
+
}
|
|
1022
|
+
if (node.properties && getTarget) {
|
|
1023
|
+
var t = getTarget(this._loader.gltf, indices[0]);
|
|
1024
|
+
if (t != null) {
|
|
1025
|
+
return {
|
|
1026
|
+
target: t,
|
|
1027
|
+
stride: node.getStride ? node.getStride(t) : undefined,
|
|
1028
|
+
properties: node.properties,
|
|
1029
|
+
params: indices,
|
|
1030
|
+
};
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
}
|
|
1035
|
+
if (this.ignoreInvalidPointer) {
|
|
1036
|
+
return null;
|
|
1037
|
+
}
|
|
1038
|
+
throw new Error("".concat(context, " invalid pointer. ").concat(pointer));
|
|
1039
|
+
};
|
|
1040
|
+
return KHR_animation_pointer;
|
|
1041
|
+
}());
|
|
1042
|
+
|
|
1043
|
+
_glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_animation_pointer(loader); });
|
|
1044
|
+
|
|
1045
|
+
|
|
1046
|
+
/***/ }),
|
|
1047
|
+
|
|
1048
|
+
/***/ "../../../lts/loaders/dist/glTF/2.0/Extensions/KHR_animation_pointer.map.js":
|
|
1049
|
+
/*!**********************************************************************************!*\
|
|
1050
|
+
!*** ../../../lts/loaders/dist/glTF/2.0/Extensions/KHR_animation_pointer.map.js ***!
|
|
1051
|
+
\**********************************************************************************/
|
|
1052
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
1053
|
+
|
|
1054
|
+
__webpack_require__.r(__webpack_exports__);
|
|
1055
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
1056
|
+
/* harmony export */ "CoreAnimationPointerMap": () => (/* binding */ CoreAnimationPointerMap)
|
|
1057
|
+
/* harmony export */ });
|
|
1058
|
+
/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../../../node_modules/tslib/tslib.es6.js");
|
|
1059
|
+
/* harmony import */ var core_Animations_animation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! core/Materials/material */ "core/Misc/observable");
|
|
1060
|
+
/* harmony import */ var core_Animations_animation__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(core_Animations_animation__WEBPACK_IMPORTED_MODULE_1__);
|
|
1061
|
+
|
|
1062
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
1063
|
+
|
|
1064
|
+
|
|
1065
|
+
|
|
1066
|
+
|
|
1067
|
+
var parseIntIndex = function (str) {
|
|
1068
|
+
var targetIndex = parseInt(str);
|
|
1069
|
+
if (isNaN(targetIndex)) {
|
|
1070
|
+
return -1;
|
|
1071
|
+
}
|
|
1072
|
+
return targetIndex;
|
|
1073
|
+
};
|
|
1074
|
+
var getGltfNode = function (gltf, index) {
|
|
1075
|
+
if (gltf.nodes) {
|
|
1076
|
+
var i = parseIntIndex(index);
|
|
1077
|
+
if (i != -1) {
|
|
1078
|
+
return gltf.nodes[i];
|
|
1079
|
+
}
|
|
1080
|
+
}
|
|
1081
|
+
return null;
|
|
1082
|
+
};
|
|
1083
|
+
var getGltfMaterial = function (gltf, index) {
|
|
1084
|
+
if (gltf.materials) {
|
|
1085
|
+
var i = parseIntIndex(index);
|
|
1086
|
+
if (i != -1) {
|
|
1087
|
+
return gltf.materials[i];
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
1090
|
+
return null;
|
|
1091
|
+
};
|
|
1092
|
+
var getGltfCamera = function (gltf, index) {
|
|
1093
|
+
if (gltf.cameras) {
|
|
1094
|
+
var i = parseIntIndex(index);
|
|
1095
|
+
if (i != -1) {
|
|
1096
|
+
return gltf.cameras[i];
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
return null;
|
|
1100
|
+
};
|
|
1101
|
+
var getGltfExtension = function (gltf, index) {
|
|
1102
|
+
if (gltf.extensions && index) {
|
|
1103
|
+
return gltf.extensions[index];
|
|
1104
|
+
}
|
|
1105
|
+
return null;
|
|
1106
|
+
};
|
|
1107
|
+
var getMatrix = function (_target, source, offset, scale) {
|
|
1108
|
+
return scale ? core_Animations_animation__WEBPACK_IMPORTED_MODULE_1__.Matrix.FromArray(source, offset).scale(scale) : core_Animations_animation__WEBPACK_IMPORTED_MODULE_1__.Matrix.FromArray(source, offset);
|
|
1109
|
+
};
|
|
1110
|
+
var getVector3 = function (_target, source, offset, scale) {
|
|
1111
|
+
return scale ? core_Animations_animation__WEBPACK_IMPORTED_MODULE_1__.Vector3.FromArray(source, offset).scaleInPlace(scale) : core_Animations_animation__WEBPACK_IMPORTED_MODULE_1__.Vector3.FromArray(source, offset);
|
|
1112
|
+
};
|
|
1113
|
+
var getQuaternion = function (_target, source, offset, scale) {
|
|
1114
|
+
return scale ? core_Animations_animation__WEBPACK_IMPORTED_MODULE_1__.Quaternion.FromArray(source, offset).scaleInPlace(scale) : core_Animations_animation__WEBPACK_IMPORTED_MODULE_1__.Quaternion.FromArray(source, offset);
|
|
1115
|
+
};
|
|
1116
|
+
var getColor3 = function (_target, source, offset, scale) {
|
|
1117
|
+
return scale ? core_Animations_animation__WEBPACK_IMPORTED_MODULE_1__.Color3.FromArray(source, offset).scale(scale) : core_Animations_animation__WEBPACK_IMPORTED_MODULE_1__.Color3.FromArray(source, offset);
|
|
1118
|
+
};
|
|
1119
|
+
var getAlpha = function (_target, source, offset, scale) {
|
|
1120
|
+
return scale ? source[offset + 3] * scale : source[offset + 3];
|
|
1121
|
+
};
|
|
1122
|
+
var getFloat = function (_target, source, offset, scale) {
|
|
1123
|
+
return scale ? source[offset] * scale : source[offset];
|
|
1124
|
+
};
|
|
1125
|
+
var getMinusFloat = function (_target, source, offset, scale) {
|
|
1126
|
+
return -(scale ? source[offset] * scale : source[offset]);
|
|
1127
|
+
};
|
|
1128
|
+
var getNextFloat = function (_target, source, offset, scale) {
|
|
1129
|
+
return scale ? source[offset + 1] * scale : source[offset + 1];
|
|
1130
|
+
};
|
|
1131
|
+
var getFloatBy2 = function (_target, source, offset, scale) {
|
|
1132
|
+
return (scale ? source[offset] * scale : source[offset]) * 2;
|
|
1133
|
+
};
|
|
1134
|
+
var getWeights = function (target, source, offset, scale) {
|
|
1135
|
+
if (target._numMorphTargets) {
|
|
1136
|
+
var value = new Array(target._numMorphTargets);
|
|
1137
|
+
for (var i = 0; i < target._numMorphTargets; i++) {
|
|
1138
|
+
value[i] = scale ? source[offset++] * scale : source[offset++];
|
|
1139
|
+
}
|
|
1140
|
+
return value;
|
|
1141
|
+
}
|
|
1142
|
+
return null;
|
|
1143
|
+
};
|
|
1144
|
+
var AbstractAnimationPointerPropertyInfos = /** @class */ (function () {
|
|
1145
|
+
function AbstractAnimationPointerPropertyInfos(type, name, get) {
|
|
1146
|
+
this.type = type;
|
|
1147
|
+
this.name = name;
|
|
1148
|
+
this.get = get;
|
|
1149
|
+
}
|
|
1150
|
+
AbstractAnimationPointerPropertyInfos.prototype._buildAnimation = function (animatable, fps, keys, babylonAnimationGroup, animationTargetOverride) {
|
|
1151
|
+
if (animationTargetOverride === void 0) { animationTargetOverride = null; }
|
|
1152
|
+
if (animatable || animationTargetOverride) {
|
|
1153
|
+
var animationName = "".concat(babylonAnimationGroup.name, "_channel").concat(babylonAnimationGroup.targetedAnimations.length, "_").concat(this.name);
|
|
1154
|
+
var babylonAnimation = new core_Animations_animation__WEBPACK_IMPORTED_MODULE_1__.Animation(animationName, this.name, fps, this.type);
|
|
1155
|
+
babylonAnimation.setKeys(keys);
|
|
1156
|
+
if (animationTargetOverride != null && animationTargetOverride.animations != null) {
|
|
1157
|
+
animationTargetOverride.animations.push(babylonAnimation);
|
|
1158
|
+
babylonAnimationGroup.addTargetedAnimation(babylonAnimation, animationTargetOverride);
|
|
1159
|
+
}
|
|
1160
|
+
else if (animatable) {
|
|
1161
|
+
animatable.animations = animatable.animations || Array(1);
|
|
1162
|
+
animatable.animations.push(babylonAnimation);
|
|
1163
|
+
babylonAnimationGroup.addTargetedAnimation(babylonAnimation, animatable);
|
|
1164
|
+
}
|
|
1165
|
+
}
|
|
1166
|
+
};
|
|
1167
|
+
AbstractAnimationPointerPropertyInfos.prototype.isValid = function (_target) {
|
|
1168
|
+
return true;
|
|
1169
|
+
};
|
|
1170
|
+
return AbstractAnimationPointerPropertyInfos;
|
|
1171
|
+
}());
|
|
1172
|
+
var TransformNodeAnimationPointerPropertyInfos = /** @class */ (function (_super) {
|
|
1173
|
+
(0,tslib__WEBPACK_IMPORTED_MODULE_0__.__extends)(TransformNodeAnimationPointerPropertyInfos, _super);
|
|
1174
|
+
function TransformNodeAnimationPointerPropertyInfos(type, name, get) {
|
|
1175
|
+
if (get === void 0) { get = getVector3; }
|
|
1176
|
+
return _super.call(this, type, name, get) || this;
|
|
1177
|
+
}
|
|
1178
|
+
TransformNodeAnimationPointerPropertyInfos.prototype.isValid = function (target) {
|
|
1179
|
+
return target._babylonTransformNode !== null && target._babylonTransformNode !== undefined;
|
|
1180
|
+
};
|
|
1181
|
+
TransformNodeAnimationPointerPropertyInfos.prototype.buildAnimations = function (target, fps, keys, group, animationTargetOverride) {
|
|
1182
|
+
if (animationTargetOverride === void 0) { animationTargetOverride = null; }
|
|
1183
|
+
return this._buildAnimation(target._babylonTransformNode, fps, keys, group, animationTargetOverride);
|
|
1184
|
+
};
|
|
1185
|
+
return TransformNodeAnimationPointerPropertyInfos;
|
|
1186
|
+
}(AbstractAnimationPointerPropertyInfos));
|
|
1187
|
+
var CameraAnimationPointerPropertyInfos = /** @class */ (function (_super) {
|
|
1188
|
+
(0,tslib__WEBPACK_IMPORTED_MODULE_0__.__extends)(CameraAnimationPointerPropertyInfos, _super);
|
|
1189
|
+
function CameraAnimationPointerPropertyInfos(type, name, get) {
|
|
1190
|
+
if (get === void 0) { get = getFloat; }
|
|
1191
|
+
return _super.call(this, type, name, get) || this;
|
|
1192
|
+
}
|
|
1193
|
+
CameraAnimationPointerPropertyInfos.prototype.isValid = function (target) {
|
|
1194
|
+
return target._babylonCamera != null && target._babylonCamera !== undefined;
|
|
1195
|
+
};
|
|
1196
|
+
CameraAnimationPointerPropertyInfos.prototype.buildAnimations = function (target, fps, keys, group, animationTargetOverride) {
|
|
1197
|
+
if (animationTargetOverride === void 0) { animationTargetOverride = null; }
|
|
1198
|
+
return this._buildAnimation(target._babylonCamera, fps, keys, group, animationTargetOverride);
|
|
1199
|
+
};
|
|
1200
|
+
return CameraAnimationPointerPropertyInfos;
|
|
1201
|
+
}(AbstractAnimationPointerPropertyInfos));
|
|
1202
|
+
var MaterialAnimationPointerPropertyInfos = /** @class */ (function (_super) {
|
|
1203
|
+
(0,tslib__WEBPACK_IMPORTED_MODULE_0__.__extends)(MaterialAnimationPointerPropertyInfos, _super);
|
|
1204
|
+
function MaterialAnimationPointerPropertyInfos(type, name, get, fillMode) {
|
|
1205
|
+
if (get === void 0) { get = getFloat; }
|
|
1206
|
+
if (fillMode === void 0) { fillMode = core_Animations_animation__WEBPACK_IMPORTED_MODULE_1__.Material.TriangleFillMode; }
|
|
1207
|
+
var _this = _super.call(this, type, name, get) || this;
|
|
1208
|
+
_this.fillMode = fillMode;
|
|
1209
|
+
return _this;
|
|
1210
|
+
}
|
|
1211
|
+
MaterialAnimationPointerPropertyInfos.prototype.isValid = function (target) {
|
|
1212
|
+
var data = target._data;
|
|
1213
|
+
if (data) {
|
|
1214
|
+
var c = data[this.fillMode];
|
|
1215
|
+
if (c) {
|
|
1216
|
+
return c.babylonMaterial !== null && c.babylonMaterial !== undefined;
|
|
1217
|
+
}
|
|
1218
|
+
}
|
|
1219
|
+
return false;
|
|
1220
|
+
};
|
|
1221
|
+
MaterialAnimationPointerPropertyInfos.prototype.buildAnimations = function (target, fps, keys, group, animationTargetOverride) {
|
|
1222
|
+
if (animationTargetOverride === void 0) { animationTargetOverride = null; }
|
|
1223
|
+
return this._buildAnimation(target._data[this.fillMode].babylonMaterial, fps, keys, group, animationTargetOverride);
|
|
1224
|
+
};
|
|
1225
|
+
return MaterialAnimationPointerPropertyInfos;
|
|
1226
|
+
}(AbstractAnimationPointerPropertyInfos));
|
|
1227
|
+
var LightAnimationPointerPropertyInfos = /** @class */ (function (_super) {
|
|
1228
|
+
(0,tslib__WEBPACK_IMPORTED_MODULE_0__.__extends)(LightAnimationPointerPropertyInfos, _super);
|
|
1229
|
+
function LightAnimationPointerPropertyInfos(type, name, get) {
|
|
1230
|
+
if (get === void 0) { get = getFloat; }
|
|
1231
|
+
return _super.call(this, type, name, get) || this;
|
|
1232
|
+
}
|
|
1233
|
+
LightAnimationPointerPropertyInfos.prototype.isValid = function (target) {
|
|
1234
|
+
return target && target.length != 0;
|
|
1235
|
+
};
|
|
1236
|
+
// note : the extensions array store directly the BabylonLight reference
|
|
1237
|
+
LightAnimationPointerPropertyInfos.prototype.buildAnimations = function (target, fps, keys, group, animationTargetOverride, params) {
|
|
1238
|
+
if (animationTargetOverride === void 0) { animationTargetOverride = null; }
|
|
1239
|
+
var i = parseIntIndex(params[1]);
|
|
1240
|
+
var l = i >= 0 && i < target.lights.length ? target.lights[i] : null;
|
|
1241
|
+
return this._buildAnimation(l._babylonLight, fps, keys, group, animationTargetOverride);
|
|
1242
|
+
};
|
|
1243
|
+
return LightAnimationPointerPropertyInfos;
|
|
1244
|
+
}(AbstractAnimationPointerPropertyInfos));
|
|
1245
|
+
var WeightAnimationPointerPropertyInfos = /** @class */ (function (_super) {
|
|
1246
|
+
(0,tslib__WEBPACK_IMPORTED_MODULE_0__.__extends)(WeightAnimationPointerPropertyInfos, _super);
|
|
1247
|
+
function WeightAnimationPointerPropertyInfos(type, name, get) {
|
|
1248
|
+
if (get === void 0) { get = getWeights; }
|
|
1249
|
+
return _super.call(this, type, name, get) || this;
|
|
1250
|
+
}
|
|
1251
|
+
WeightAnimationPointerPropertyInfos.prototype.isValid = function (target) {
|
|
1252
|
+
return target._numMorphTargets;
|
|
1253
|
+
};
|
|
1254
|
+
WeightAnimationPointerPropertyInfos.prototype.buildAnimations = function (targetNode, fps, keys, babylonAnimationGroup, _animationTargetOverride) {
|
|
1255
|
+
if (_animationTargetOverride === void 0) { _animationTargetOverride = null; }
|
|
1256
|
+
if (targetNode._numMorphTargets) {
|
|
1257
|
+
var _loop_1 = function (targetIndex) {
|
|
1258
|
+
var animationName = "".concat(babylonAnimationGroup.name, "_channel").concat(babylonAnimationGroup.targetedAnimations.length);
|
|
1259
|
+
var babylonAnimation = new core_Animations_animation__WEBPACK_IMPORTED_MODULE_1__.Animation(animationName, this_1.name, fps, this_1.type);
|
|
1260
|
+
babylonAnimation.setKeys(keys.map(function (key) { return ({
|
|
1261
|
+
frame: key.frame,
|
|
1262
|
+
inTangent: key.inTangent ? key.inTangent[targetIndex] : undefined,
|
|
1263
|
+
value: key.value[targetIndex],
|
|
1264
|
+
outTangent: key.outTangent ? key.outTangent[targetIndex] : undefined,
|
|
1265
|
+
interpolation: key.interpolation,
|
|
1266
|
+
}); }));
|
|
1267
|
+
if (targetNode._primitiveBabylonMeshes) {
|
|
1268
|
+
for (var _i = 0, _a = targetNode._primitiveBabylonMeshes; _i < _a.length; _i++) {
|
|
1269
|
+
var m = _a[_i];
|
|
1270
|
+
var babylonMesh = m;
|
|
1271
|
+
if (babylonMesh.morphTargetManager) {
|
|
1272
|
+
var morphTarget = babylonMesh.morphTargetManager.getTarget(targetIndex);
|
|
1273
|
+
var babylonAnimationClone = babylonAnimation.clone();
|
|
1274
|
+
morphTarget.animations.push(babylonAnimationClone);
|
|
1275
|
+
babylonAnimationGroup.addTargetedAnimation(babylonAnimationClone, morphTarget);
|
|
1276
|
+
}
|
|
1277
|
+
}
|
|
1278
|
+
}
|
|
1279
|
+
};
|
|
1280
|
+
var this_1 = this;
|
|
1281
|
+
for (var targetIndex = 0; targetIndex < targetNode._numMorphTargets; targetIndex++) {
|
|
1282
|
+
_loop_1(targetIndex);
|
|
1283
|
+
}
|
|
1284
|
+
}
|
|
1285
|
+
};
|
|
1286
|
+
return WeightAnimationPointerPropertyInfos;
|
|
1287
|
+
}(AbstractAnimationPointerPropertyInfos));
|
|
1288
|
+
var CoreAnimationNodesPointerMap = {
|
|
1289
|
+
getTarget: getGltfNode,
|
|
1290
|
+
hasIndex: true,
|
|
1291
|
+
matrix: {
|
|
1292
|
+
properties: [new TransformNodeAnimationPointerPropertyInfos(core_Animations_animation__WEBPACK_IMPORTED_MODULE_1__.Animation.ANIMATIONTYPE_MATRIX, "matrix", getMatrix)],
|
|
1293
|
+
},
|
|
1294
|
+
translation: {
|
|
1295
|
+
properties: [new TransformNodeAnimationPointerPropertyInfos(core_Animations_animation__WEBPACK_IMPORTED_MODULE_1__.Animation.ANIMATIONTYPE_VECTOR3, "position")],
|
|
1296
|
+
},
|
|
1297
|
+
rotation: {
|
|
1298
|
+
properties: [new TransformNodeAnimationPointerPropertyInfos(core_Animations_animation__WEBPACK_IMPORTED_MODULE_1__.Animation.ANIMATIONTYPE_QUATERNION, "rotationQuaternion", getQuaternion)],
|
|
1299
|
+
},
|
|
1300
|
+
scale: {
|
|
1301
|
+
properties: [new TransformNodeAnimationPointerPropertyInfos(core_Animations_animation__WEBPACK_IMPORTED_MODULE_1__.Animation.ANIMATIONTYPE_VECTOR3, "scaling")],
|
|
1302
|
+
},
|
|
1303
|
+
weights: {
|
|
1304
|
+
getStride: function (target) {
|
|
1305
|
+
return target._numMorphTargets;
|
|
1306
|
+
},
|
|
1307
|
+
properties: [new WeightAnimationPointerPropertyInfos(core_Animations_animation__WEBPACK_IMPORTED_MODULE_1__.Animation.ANIMATIONTYPE_FLOAT, "influence")],
|
|
1308
|
+
},
|
|
1309
|
+
};
|
|
1310
|
+
var CoreAnimationCamerasPointerMap = {
|
|
1311
|
+
hasIndex: true,
|
|
1312
|
+
getTarget: getGltfCamera,
|
|
1313
|
+
orthographic: {
|
|
1314
|
+
xmag: {
|
|
1315
|
+
properties: [
|
|
1316
|
+
new CameraAnimationPointerPropertyInfos(core_Animations_animation__WEBPACK_IMPORTED_MODULE_1__.Animation.ANIMATIONTYPE_FLOAT, "orthoLeft", getMinusFloat),
|
|
1317
|
+
new CameraAnimationPointerPropertyInfos(core_Animations_animation__WEBPACK_IMPORTED_MODULE_1__.Animation.ANIMATIONTYPE_FLOAT, "orthoRight", getNextFloat),
|
|
1318
|
+
],
|
|
1319
|
+
},
|
|
1320
|
+
ymag: {
|
|
1321
|
+
properties: [
|
|
1322
|
+
new CameraAnimationPointerPropertyInfos(core_Animations_animation__WEBPACK_IMPORTED_MODULE_1__.Animation.ANIMATIONTYPE_FLOAT, "orthoBottom", getMinusFloat),
|
|
1323
|
+
new CameraAnimationPointerPropertyInfos(core_Animations_animation__WEBPACK_IMPORTED_MODULE_1__.Animation.ANIMATIONTYPE_FLOAT, "orthoTop", getNextFloat),
|
|
1324
|
+
],
|
|
1325
|
+
},
|
|
1326
|
+
zfar: {
|
|
1327
|
+
properties: [new CameraAnimationPointerPropertyInfos(core_Animations_animation__WEBPACK_IMPORTED_MODULE_1__.Animation.ANIMATIONTYPE_FLOAT, "maxZ")],
|
|
1328
|
+
},
|
|
1329
|
+
znear: {
|
|
1330
|
+
properties: [new CameraAnimationPointerPropertyInfos(core_Animations_animation__WEBPACK_IMPORTED_MODULE_1__.Animation.ANIMATIONTYPE_FLOAT, "minZ")],
|
|
1331
|
+
},
|
|
1332
|
+
},
|
|
1333
|
+
perspective: {
|
|
1334
|
+
aspectRatio: {
|
|
1335
|
+
// not supported.
|
|
1336
|
+
},
|
|
1337
|
+
yfov: {
|
|
1338
|
+
properties: [new CameraAnimationPointerPropertyInfos(core_Animations_animation__WEBPACK_IMPORTED_MODULE_1__.Animation.ANIMATIONTYPE_FLOAT, "fov")],
|
|
1339
|
+
},
|
|
1340
|
+
zfar: {
|
|
1341
|
+
properties: [new CameraAnimationPointerPropertyInfos(core_Animations_animation__WEBPACK_IMPORTED_MODULE_1__.Animation.ANIMATIONTYPE_FLOAT, "maxZ")],
|
|
1342
|
+
},
|
|
1343
|
+
znear: {
|
|
1344
|
+
properties: [new CameraAnimationPointerPropertyInfos(core_Animations_animation__WEBPACK_IMPORTED_MODULE_1__.Animation.ANIMATIONTYPE_FLOAT, "minZ")],
|
|
1345
|
+
},
|
|
1346
|
+
},
|
|
1347
|
+
};
|
|
1348
|
+
var CoreAnimationMaterialsPointerMap = {
|
|
1349
|
+
hasIndex: true,
|
|
1350
|
+
getTarget: getGltfMaterial,
|
|
1351
|
+
pbrMetallicRoughness: {
|
|
1352
|
+
baseColorFactor: {
|
|
1353
|
+
properties: [
|
|
1354
|
+
new MaterialAnimationPointerPropertyInfos(core_Animations_animation__WEBPACK_IMPORTED_MODULE_1__.Animation.ANIMATIONTYPE_COLOR3, "albedoColor", getColor3),
|
|
1355
|
+
new MaterialAnimationPointerPropertyInfos(core_Animations_animation__WEBPACK_IMPORTED_MODULE_1__.Animation.ANIMATIONTYPE_FLOAT, "alpha", getAlpha),
|
|
1356
|
+
],
|
|
1357
|
+
},
|
|
1358
|
+
metallicFactor: {
|
|
1359
|
+
properties: [new MaterialAnimationPointerPropertyInfos(core_Animations_animation__WEBPACK_IMPORTED_MODULE_1__.Animation.ANIMATIONTYPE_FLOAT, "metallic")],
|
|
1360
|
+
},
|
|
1361
|
+
roughnessFactor: {
|
|
1362
|
+
properties: [new MaterialAnimationPointerPropertyInfos(core_Animations_animation__WEBPACK_IMPORTED_MODULE_1__.Animation.ANIMATIONTYPE_FLOAT, "roughness")],
|
|
1363
|
+
},
|
|
1364
|
+
baseColorTexture: {
|
|
1365
|
+
extensions: {
|
|
1366
|
+
KHR_texture_transform: {
|
|
1367
|
+
scale: {
|
|
1368
|
+
properties: [
|
|
1369
|
+
// MAY introduce set scale(Vector2) into texture.
|
|
1370
|
+
new MaterialAnimationPointerPropertyInfos(core_Animations_animation__WEBPACK_IMPORTED_MODULE_1__.Animation.ANIMATIONTYPE_FLOAT, "albedoTexture.uScale"),
|
|
1371
|
+
new MaterialAnimationPointerPropertyInfos(core_Animations_animation__WEBPACK_IMPORTED_MODULE_1__.Animation.ANIMATIONTYPE_FLOAT, "albedoTexture.vScale", getNextFloat),
|
|
1372
|
+
],
|
|
1373
|
+
},
|
|
1374
|
+
offset: {
|
|
1375
|
+
properties: [
|
|
1376
|
+
// MAY introduce set offset(Vector2) into texture.
|
|
1377
|
+
new MaterialAnimationPointerPropertyInfos(core_Animations_animation__WEBPACK_IMPORTED_MODULE_1__.Animation.ANIMATIONTYPE_FLOAT, "albedoTexture.uOffset"),
|
|
1378
|
+
new MaterialAnimationPointerPropertyInfos(core_Animations_animation__WEBPACK_IMPORTED_MODULE_1__.Animation.ANIMATIONTYPE_FLOAT, "albedoTexture.vOffset", getNextFloat),
|
|
1379
|
+
],
|
|
1380
|
+
},
|
|
1381
|
+
rotation: {
|
|
1382
|
+
properties: [new MaterialAnimationPointerPropertyInfos(core_Animations_animation__WEBPACK_IMPORTED_MODULE_1__.Animation.ANIMATIONTYPE_FLOAT, "albedoTexture.wAng", getMinusFloat)],
|
|
1383
|
+
},
|
|
1384
|
+
},
|
|
1385
|
+
},
|
|
1386
|
+
},
|
|
1387
|
+
},
|
|
1388
|
+
emissiveFactor: {
|
|
1389
|
+
properties: [new MaterialAnimationPointerPropertyInfos(core_Animations_animation__WEBPACK_IMPORTED_MODULE_1__.Animation.ANIMATIONTYPE_COLOR3, "emissiveColor", getColor3)],
|
|
1390
|
+
},
|
|
1391
|
+
normalTexture: {
|
|
1392
|
+
scale: {
|
|
1393
|
+
properties: [new MaterialAnimationPointerPropertyInfos(core_Animations_animation__WEBPACK_IMPORTED_MODULE_1__.Animation.ANIMATIONTYPE_FLOAT, "bumpTexture.level")],
|
|
1394
|
+
},
|
|
1395
|
+
},
|
|
1396
|
+
occlusionTexture: {
|
|
1397
|
+
strength: {
|
|
1398
|
+
properties: [new MaterialAnimationPointerPropertyInfos(core_Animations_animation__WEBPACK_IMPORTED_MODULE_1__.Animation.ANIMATIONTYPE_FLOAT, "ambientTextureStrength")],
|
|
1399
|
+
},
|
|
1400
|
+
extensions: {
|
|
1401
|
+
KHR_texture_transform: {
|
|
1402
|
+
scale: {
|
|
1403
|
+
properties: [
|
|
1404
|
+
// MAY introduce set scale(Vector2) into texture.
|
|
1405
|
+
new MaterialAnimationPointerPropertyInfos(core_Animations_animation__WEBPACK_IMPORTED_MODULE_1__.Animation.ANIMATIONTYPE_FLOAT, "ambientTexture.uScale"),
|
|
1406
|
+
new MaterialAnimationPointerPropertyInfos(core_Animations_animation__WEBPACK_IMPORTED_MODULE_1__.Animation.ANIMATIONTYPE_FLOAT, "ambientTexture.vScale", getNextFloat),
|
|
1407
|
+
],
|
|
1408
|
+
},
|
|
1409
|
+
offset: {
|
|
1410
|
+
properties: [
|
|
1411
|
+
// MAY introduce set offset(Vector2) into texture.
|
|
1412
|
+
new MaterialAnimationPointerPropertyInfos(core_Animations_animation__WEBPACK_IMPORTED_MODULE_1__.Animation.ANIMATIONTYPE_FLOAT, "ambientTexture.uOffset"),
|
|
1413
|
+
new MaterialAnimationPointerPropertyInfos(core_Animations_animation__WEBPACK_IMPORTED_MODULE_1__.Animation.ANIMATIONTYPE_FLOAT, "ambientTexture.vOffset", getNextFloat),
|
|
1414
|
+
],
|
|
1415
|
+
},
|
|
1416
|
+
rotation: {
|
|
1417
|
+
properties: [new MaterialAnimationPointerPropertyInfos(core_Animations_animation__WEBPACK_IMPORTED_MODULE_1__.Animation.ANIMATIONTYPE_FLOAT, "ambientTexture.wAng", getMinusFloat)],
|
|
1418
|
+
},
|
|
1419
|
+
},
|
|
1420
|
+
},
|
|
1421
|
+
},
|
|
1422
|
+
emissiveTexture: {
|
|
1423
|
+
extensions: {
|
|
1424
|
+
KHR_texture_transform: {
|
|
1425
|
+
scale: {
|
|
1426
|
+
properties: [
|
|
1427
|
+
// MAY introduce set scale(Vector2) into texture.
|
|
1428
|
+
new MaterialAnimationPointerPropertyInfos(core_Animations_animation__WEBPACK_IMPORTED_MODULE_1__.Animation.ANIMATIONTYPE_FLOAT, "emissiveTexture.uScale"),
|
|
1429
|
+
new MaterialAnimationPointerPropertyInfos(core_Animations_animation__WEBPACK_IMPORTED_MODULE_1__.Animation.ANIMATIONTYPE_FLOAT, "emissiveTexture.vScale", getNextFloat),
|
|
1430
|
+
],
|
|
1431
|
+
},
|
|
1432
|
+
offset: {
|
|
1433
|
+
properties: [
|
|
1434
|
+
// MAY introduce set offset(Vector2) into texture.
|
|
1435
|
+
new MaterialAnimationPointerPropertyInfos(core_Animations_animation__WEBPACK_IMPORTED_MODULE_1__.Animation.ANIMATIONTYPE_FLOAT, "emissiveTexture.uOffset"),
|
|
1436
|
+
new MaterialAnimationPointerPropertyInfos(core_Animations_animation__WEBPACK_IMPORTED_MODULE_1__.Animation.ANIMATIONTYPE_FLOAT, "emissiveTexture.vOffset", getNextFloat),
|
|
1437
|
+
],
|
|
1438
|
+
},
|
|
1439
|
+
rotation: {
|
|
1440
|
+
properties: [new MaterialAnimationPointerPropertyInfos(core_Animations_animation__WEBPACK_IMPORTED_MODULE_1__.Animation.ANIMATIONTYPE_FLOAT, "emissiveTexture.wAng", getMinusFloat)],
|
|
1441
|
+
},
|
|
1442
|
+
},
|
|
1443
|
+
},
|
|
1444
|
+
},
|
|
1445
|
+
extensions: {
|
|
1446
|
+
KHR_materials_ior: {
|
|
1447
|
+
ior: {
|
|
1448
|
+
properties: [new MaterialAnimationPointerPropertyInfos(core_Animations_animation__WEBPACK_IMPORTED_MODULE_1__.Animation.ANIMATIONTYPE_FLOAT, "indexOfRefraction")],
|
|
1449
|
+
},
|
|
1450
|
+
},
|
|
1451
|
+
KHR_materials_clearcoat: {
|
|
1452
|
+
clearcoatFactor: {
|
|
1453
|
+
properties: [new MaterialAnimationPointerPropertyInfos(core_Animations_animation__WEBPACK_IMPORTED_MODULE_1__.Animation.ANIMATIONTYPE_FLOAT, "clearCoat.intensity")],
|
|
1454
|
+
},
|
|
1455
|
+
clearcoatRoughnessFactor: {
|
|
1456
|
+
properties: [new MaterialAnimationPointerPropertyInfos(core_Animations_animation__WEBPACK_IMPORTED_MODULE_1__.Animation.ANIMATIONTYPE_FLOAT, "clearCoat.roughness")],
|
|
1457
|
+
},
|
|
1458
|
+
},
|
|
1459
|
+
KHR_materials_sheen: {
|
|
1460
|
+
sheenColorFactor: {
|
|
1461
|
+
properties: [new MaterialAnimationPointerPropertyInfos(core_Animations_animation__WEBPACK_IMPORTED_MODULE_1__.Animation.ANIMATIONTYPE_COLOR3, "sheen.color", getColor3)],
|
|
1462
|
+
},
|
|
1463
|
+
sheenRoughnessFactor: {
|
|
1464
|
+
properties: [new MaterialAnimationPointerPropertyInfos(core_Animations_animation__WEBPACK_IMPORTED_MODULE_1__.Animation.ANIMATIONTYPE_FLOAT, "sheen.roughness")],
|
|
1465
|
+
},
|
|
1466
|
+
},
|
|
1467
|
+
KHR_materials_specular: {
|
|
1468
|
+
specularFactor: {
|
|
1469
|
+
properties: [new MaterialAnimationPointerPropertyInfos(core_Animations_animation__WEBPACK_IMPORTED_MODULE_1__.Animation.ANIMATIONTYPE_FLOAT, "metallicF0Factor")],
|
|
1470
|
+
},
|
|
1471
|
+
specularColorFactor: {
|
|
1472
|
+
properties: [new MaterialAnimationPointerPropertyInfos(core_Animations_animation__WEBPACK_IMPORTED_MODULE_1__.Animation.ANIMATIONTYPE_COLOR3, "metallicReflectanceColor", getColor3)],
|
|
1473
|
+
},
|
|
1474
|
+
},
|
|
1475
|
+
KHR_materials_emissive_strength: {
|
|
1476
|
+
emissiveStrength: {
|
|
1477
|
+
properties: [new MaterialAnimationPointerPropertyInfos(core_Animations_animation__WEBPACK_IMPORTED_MODULE_1__.Animation.ANIMATIONTYPE_FLOAT, "emissiveIntensity")],
|
|
1478
|
+
},
|
|
1479
|
+
},
|
|
1480
|
+
KHR_materials_transmission: {
|
|
1481
|
+
transmissionFactor: {
|
|
1482
|
+
properties: [new MaterialAnimationPointerPropertyInfos(core_Animations_animation__WEBPACK_IMPORTED_MODULE_1__.Animation.ANIMATIONTYPE_FLOAT, "subSurface.refractionIntensity")],
|
|
1483
|
+
},
|
|
1484
|
+
},
|
|
1485
|
+
KHR_materials_volume: {
|
|
1486
|
+
attenuationColor: {
|
|
1487
|
+
properties: [new MaterialAnimationPointerPropertyInfos(core_Animations_animation__WEBPACK_IMPORTED_MODULE_1__.Animation.ANIMATIONTYPE_COLOR3, "subSurface.tintColor", getColor3)],
|
|
1488
|
+
},
|
|
1489
|
+
attenuationDistance: {
|
|
1490
|
+
properties: [new MaterialAnimationPointerPropertyInfos(core_Animations_animation__WEBPACK_IMPORTED_MODULE_1__.Animation.ANIMATIONTYPE_FLOAT, "subSurface.tintColorAtDistance")],
|
|
1491
|
+
},
|
|
1492
|
+
thicknessFactor: {
|
|
1493
|
+
properties: [new MaterialAnimationPointerPropertyInfos(core_Animations_animation__WEBPACK_IMPORTED_MODULE_1__.Animation.ANIMATIONTYPE_FLOAT, "subSurface.maximumThickness")],
|
|
1494
|
+
},
|
|
1495
|
+
},
|
|
1496
|
+
KHR_materials_iridescence: {
|
|
1497
|
+
iridescenceFactor: {
|
|
1498
|
+
properties: [new MaterialAnimationPointerPropertyInfos(core_Animations_animation__WEBPACK_IMPORTED_MODULE_1__.Animation.ANIMATIONTYPE_FLOAT, "iridescence.intensity")],
|
|
1499
|
+
},
|
|
1500
|
+
iridescenceIor: {
|
|
1501
|
+
properties: [new MaterialAnimationPointerPropertyInfos(core_Animations_animation__WEBPACK_IMPORTED_MODULE_1__.Animation.ANIMATIONTYPE_FLOAT, "iridescence.indexOfRefraction")],
|
|
1502
|
+
},
|
|
1503
|
+
iridescenceThicknessMinimum: {
|
|
1504
|
+
properties: [new MaterialAnimationPointerPropertyInfos(core_Animations_animation__WEBPACK_IMPORTED_MODULE_1__.Animation.ANIMATIONTYPE_FLOAT, "iridescence.minimumThickness")],
|
|
1505
|
+
},
|
|
1506
|
+
iridescenceThicknessMaximum: {
|
|
1507
|
+
properties: [new MaterialAnimationPointerPropertyInfos(core_Animations_animation__WEBPACK_IMPORTED_MODULE_1__.Animation.ANIMATIONTYPE_FLOAT, "iridescence.maximumThickness")],
|
|
1508
|
+
},
|
|
1509
|
+
},
|
|
1510
|
+
},
|
|
1511
|
+
};
|
|
1512
|
+
var CoreAnimationExtensionsPointerMap = {
|
|
1513
|
+
getTarget: getGltfExtension,
|
|
1514
|
+
KHR_lights_punctual: {
|
|
1515
|
+
isIndex: true,
|
|
1516
|
+
lights: {
|
|
1517
|
+
hasIndex: true,
|
|
1518
|
+
color: {
|
|
1519
|
+
properties: [new LightAnimationPointerPropertyInfos(core_Animations_animation__WEBPACK_IMPORTED_MODULE_1__.Animation.ANIMATIONTYPE_COLOR3, "diffuse", getColor3)],
|
|
1520
|
+
},
|
|
1521
|
+
intensity: {
|
|
1522
|
+
properties: [new LightAnimationPointerPropertyInfos(core_Animations_animation__WEBPACK_IMPORTED_MODULE_1__.Animation.ANIMATIONTYPE_FLOAT, "intensity")],
|
|
1523
|
+
},
|
|
1524
|
+
range: {
|
|
1525
|
+
properties: [new LightAnimationPointerPropertyInfos(core_Animations_animation__WEBPACK_IMPORTED_MODULE_1__.Animation.ANIMATIONTYPE_FLOAT, "range")],
|
|
1526
|
+
},
|
|
1527
|
+
spot: {
|
|
1528
|
+
innerConeAngle: {
|
|
1529
|
+
properties: [new LightAnimationPointerPropertyInfos(core_Animations_animation__WEBPACK_IMPORTED_MODULE_1__.Animation.ANIMATIONTYPE_FLOAT, "innerAngle", getFloatBy2)],
|
|
1530
|
+
},
|
|
1531
|
+
outerConeAngle: {
|
|
1532
|
+
properties: [new LightAnimationPointerPropertyInfos(core_Animations_animation__WEBPACK_IMPORTED_MODULE_1__.Animation.ANIMATIONTYPE_FLOAT, "angle", getFloatBy2)],
|
|
1533
|
+
},
|
|
1534
|
+
},
|
|
1535
|
+
},
|
|
1536
|
+
},
|
|
1537
|
+
};
|
|
1538
|
+
var CoreAnimationPointerMap = {
|
|
1539
|
+
nodes: CoreAnimationNodesPointerMap,
|
|
1540
|
+
materials: CoreAnimationMaterialsPointerMap,
|
|
1541
|
+
cameras: CoreAnimationCamerasPointerMap,
|
|
1542
|
+
extensions: CoreAnimationExtensionsPointerMap,
|
|
1543
|
+
};
|
|
1544
|
+
|
|
1545
|
+
|
|
747
1546
|
/***/ }),
|
|
748
1547
|
|
|
749
1548
|
/***/ "../../../lts/loaders/dist/glTF/2.0/Extensions/KHR_draco_mesh_compression.js":
|
|
@@ -968,6 +1767,7 @@ var KHR_lights = /** @class */ (function () {
|
|
|
968
1767
|
babylonLight.range = light.range == undefined ? Number.MAX_VALUE : light.range;
|
|
969
1768
|
babylonLight.parent = babylonMesh;
|
|
970
1769
|
_this._loader._babylonLights.push(babylonLight);
|
|
1770
|
+
light._babylonLight = babylonLight;
|
|
971
1771
|
_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.AddPointerMetadata(babylonLight, extensionContext);
|
|
972
1772
|
assign(babylonMesh);
|
|
973
1773
|
});
|
|
@@ -3483,7 +4283,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
3483
4283
|
/* harmony export */ "EXT_mesh_gpu_instancing": () => (/* reexport safe */ _EXT_mesh_gpu_instancing__WEBPACK_IMPORTED_MODULE_1__.EXT_mesh_gpu_instancing),
|
|
3484
4284
|
/* harmony export */ "EXT_meshopt_compression": () => (/* reexport safe */ _EXT_meshopt_compression__WEBPACK_IMPORTED_MODULE_2__.EXT_meshopt_compression),
|
|
3485
4285
|
/* harmony export */ "EXT_texture_webp": () => (/* reexport safe */ _EXT_texture_webp__WEBPACK_IMPORTED_MODULE_3__.EXT_texture_webp),
|
|
3486
|
-
/* harmony export */ "ExtrasAsMetadata": () => (/* reexport safe */
|
|
4286
|
+
/* harmony export */ "ExtrasAsMetadata": () => (/* reexport safe */ _ExtrasAsMetadata__WEBPACK_IMPORTED_MODULE_27__.ExtrasAsMetadata),
|
|
4287
|
+
/* harmony export */ "KHR_animation_pointer": () => (/* reexport safe */ _KHR_animation_pointer__WEBPACK_IMPORTED_MODULE_22__.KHR_animation_pointer),
|
|
3487
4288
|
/* harmony export */ "KHR_draco_mesh_compression": () => (/* reexport safe */ _KHR_draco_mesh_compression__WEBPACK_IMPORTED_MODULE_4__.KHR_draco_mesh_compression),
|
|
3488
4289
|
/* harmony export */ "KHR_lights": () => (/* reexport safe */ _KHR_lights_punctual__WEBPACK_IMPORTED_MODULE_5__.KHR_lights),
|
|
3489
4290
|
/* harmony export */ "KHR_materials_clearcoat": () => (/* reexport safe */ _KHR_materials_clearcoat__WEBPACK_IMPORTED_MODULE_8__.KHR_materials_clearcoat),
|
|
@@ -3502,10 +4303,10 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
3502
4303
|
/* harmony export */ "KHR_texture_basisu": () => (/* reexport safe */ _KHR_texture_basisu__WEBPACK_IMPORTED_MODULE_19__.KHR_texture_basisu),
|
|
3503
4304
|
/* harmony export */ "KHR_texture_transform": () => (/* reexport safe */ _KHR_texture_transform__WEBPACK_IMPORTED_MODULE_20__.KHR_texture_transform),
|
|
3504
4305
|
/* harmony export */ "KHR_xmp_json_ld": () => (/* reexport safe */ _KHR_xmp_json_ld__WEBPACK_IMPORTED_MODULE_21__.KHR_xmp_json_ld),
|
|
3505
|
-
/* harmony export */ "MSFT_audio_emitter": () => (/* reexport safe */
|
|
3506
|
-
/* harmony export */ "MSFT_lod": () => (/* reexport safe */
|
|
3507
|
-
/* harmony export */ "MSFT_minecraftMesh": () => (/* reexport safe */
|
|
3508
|
-
/* harmony export */ "MSFT_sRGBFactors": () => (/* reexport safe */
|
|
4306
|
+
/* harmony export */ "MSFT_audio_emitter": () => (/* reexport safe */ _MSFT_audio_emitter__WEBPACK_IMPORTED_MODULE_23__.MSFT_audio_emitter),
|
|
4307
|
+
/* harmony export */ "MSFT_lod": () => (/* reexport safe */ _MSFT_lod__WEBPACK_IMPORTED_MODULE_24__.MSFT_lod),
|
|
4308
|
+
/* harmony export */ "MSFT_minecraftMesh": () => (/* reexport safe */ _MSFT_minecraftMesh__WEBPACK_IMPORTED_MODULE_25__.MSFT_minecraftMesh),
|
|
4309
|
+
/* harmony export */ "MSFT_sRGBFactors": () => (/* reexport safe */ _MSFT_sRGBFactors__WEBPACK_IMPORTED_MODULE_26__.MSFT_sRGBFactors)
|
|
3509
4310
|
/* harmony export */ });
|
|
3510
4311
|
/* harmony import */ var _EXT_lights_image_based__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./EXT_lights_image_based */ "../../../lts/loaders/dist/glTF/2.0/Extensions/EXT_lights_image_based.js");
|
|
3511
4312
|
/* harmony import */ var _EXT_mesh_gpu_instancing__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./EXT_mesh_gpu_instancing */ "../../../lts/loaders/dist/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js");
|
|
@@ -3529,11 +4330,13 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
3529
4330
|
/* harmony import */ var _KHR_texture_basisu__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./KHR_texture_basisu */ "../../../lts/loaders/dist/glTF/2.0/Extensions/KHR_texture_basisu.js");
|
|
3530
4331
|
/* harmony import */ var _KHR_texture_transform__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./KHR_texture_transform */ "../../../lts/loaders/dist/glTF/2.0/Extensions/KHR_texture_transform.js");
|
|
3531
4332
|
/* harmony import */ var _KHR_xmp_json_ld__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./KHR_xmp_json_ld */ "../../../lts/loaders/dist/glTF/2.0/Extensions/KHR_xmp_json_ld.js");
|
|
3532
|
-
/* harmony import */ var
|
|
3533
|
-
/* harmony import */ var
|
|
3534
|
-
/* harmony import */ var
|
|
3535
|
-
/* harmony import */ var
|
|
3536
|
-
/* harmony import */ var
|
|
4333
|
+
/* harmony import */ var _KHR_animation_pointer__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./KHR_animation_pointer */ "../../../lts/loaders/dist/glTF/2.0/Extensions/KHR_animation_pointer.js");
|
|
4334
|
+
/* harmony import */ var _MSFT_audio_emitter__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./MSFT_audio_emitter */ "../../../lts/loaders/dist/glTF/2.0/Extensions/MSFT_audio_emitter.js");
|
|
4335
|
+
/* harmony import */ var _MSFT_lod__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./MSFT_lod */ "../../../lts/loaders/dist/glTF/2.0/Extensions/MSFT_lod.js");
|
|
4336
|
+
/* harmony import */ var _MSFT_minecraftMesh__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./MSFT_minecraftMesh */ "../../../lts/loaders/dist/glTF/2.0/Extensions/MSFT_minecraftMesh.js");
|
|
4337
|
+
/* harmony import */ var _MSFT_sRGBFactors__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./MSFT_sRGBFactors */ "../../../lts/loaders/dist/glTF/2.0/Extensions/MSFT_sRGBFactors.js");
|
|
4338
|
+
/* harmony import */ var _ExtrasAsMetadata__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./ExtrasAsMetadata */ "../../../lts/loaders/dist/glTF/2.0/Extensions/ExtrasAsMetadata.js");
|
|
4339
|
+
|
|
3537
4340
|
|
|
3538
4341
|
|
|
3539
4342
|
|
|
@@ -3598,8 +4401,6 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
3598
4401
|
|
|
3599
4402
|
|
|
3600
4403
|
|
|
3601
|
-
|
|
3602
|
-
|
|
3603
4404
|
|
|
3604
4405
|
|
|
3605
4406
|
|
|
@@ -4806,6 +5607,8 @@ var GLTFLoader = /** @class */ (function () {
|
|
|
4806
5607
|
GLTFLoader.AddPointerMetadata(babylonCamera, context);
|
|
4807
5608
|
this._parent.onCameraLoadedObservable.notifyObservers(babylonCamera);
|
|
4808
5609
|
assign(babylonCamera);
|
|
5610
|
+
// register the camera to be used later.
|
|
5611
|
+
camera._babylonCamera = babylonCamera;
|
|
4809
5612
|
this.logClose();
|
|
4810
5613
|
return Promise.all(promises).then(function () {
|
|
4811
5614
|
return babylonCamera;
|
|
@@ -4835,217 +5638,33 @@ var GLTFLoader = /** @class */ (function () {
|
|
|
4835
5638
|
* @returns A promise that resolves with the loaded Babylon animation group when the load is complete
|
|
4836
5639
|
*/
|
|
4837
5640
|
GLTFLoader.prototype.loadAnimationAsync = function (context, animation) {
|
|
4838
|
-
|
|
4839
|
-
|
|
4840
|
-
|
|
5641
|
+
// turn everything into pointer
|
|
5642
|
+
for (var _i = 0, _a = animation.channels; _i < _a.length; _i++) {
|
|
5643
|
+
var channel = _a[_i];
|
|
5644
|
+
if (channel.target.path == "pointer" /* POINTER */) {
|
|
5645
|
+
continue;
|
|
5646
|
+
}
|
|
5647
|
+
// decorate the channel with a KHR_animation_pointer extension.
|
|
5648
|
+
channel.target.extensions = channel.target.extensions || {};
|
|
5649
|
+
channel.target.extensions.KHR_animation_pointer = {
|
|
5650
|
+
pointer: "/nodes/".concat(channel.target.node, "/").concat(channel.target.path),
|
|
5651
|
+
};
|
|
5652
|
+
channel.target.path = "pointer" /* POINTER */;
|
|
5653
|
+
delete channel.target.node;
|
|
5654
|
+
// ensure to declare extension used.
|
|
5655
|
+
this._gltf.extensionsUsed = this._gltf.extensionsUsed || [];
|
|
5656
|
+
if (this._gltf.extensionsUsed.indexOf(GLTFLoader._KHRAnimationPointerName) === -1) {
|
|
5657
|
+
this._gltf.extensionsUsed.push(GLTFLoader._KHRAnimationPointerName);
|
|
5658
|
+
}
|
|
4841
5659
|
}
|
|
5660
|
+
// create the animation group to be passed to extension.
|
|
4842
5661
|
this._babylonScene._blockEntityCollection = !!this._assetContainer;
|
|
4843
5662
|
var babylonAnimationGroup = new core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.AnimationGroup(animation.name || "animation".concat(animation.index), this._babylonScene);
|
|
4844
5663
|
babylonAnimationGroup._parentContainer = this._assetContainer;
|
|
4845
5664
|
this._babylonScene._blockEntityCollection = false;
|
|
4846
5665
|
animation._babylonAnimationGroup = babylonAnimationGroup;
|
|
4847
|
-
var
|
|
4848
|
-
|
|
4849
|
-
ArrayItem.Assign(animation.samplers);
|
|
4850
|
-
for (var _i = 0, _a = animation.channels; _i < _a.length; _i++) {
|
|
4851
|
-
var channel = _a[_i];
|
|
4852
|
-
promises.push(this._loadAnimationChannelAsync("".concat(context, "/channels/").concat(channel.index), context, animation, channel, babylonAnimationGroup));
|
|
4853
|
-
}
|
|
4854
|
-
return Promise.all(promises).then(function () {
|
|
4855
|
-
babylonAnimationGroup.normalize(0);
|
|
4856
|
-
return babylonAnimationGroup;
|
|
4857
|
-
});
|
|
4858
|
-
};
|
|
4859
|
-
/**
|
|
4860
|
-
* @hidden Loads a glTF animation channel.
|
|
4861
|
-
* @param context The context when loading the asset
|
|
4862
|
-
* @param animationContext The context of the animation when loading the asset
|
|
4863
|
-
* @param animation The glTF animation property
|
|
4864
|
-
* @param channel The glTF animation channel property
|
|
4865
|
-
* @param babylonAnimationGroup The babylon animation group property
|
|
4866
|
-
* @param animationTargetOverride The babylon animation channel target override property. My be null.
|
|
4867
|
-
* @returns A void promise when the channel load is complete
|
|
4868
|
-
*/
|
|
4869
|
-
GLTFLoader.prototype._loadAnimationChannelAsync = function (context, animationContext, animation, channel, babylonAnimationGroup, animationTargetOverride) {
|
|
4870
|
-
var _this = this;
|
|
4871
|
-
if (animationTargetOverride === void 0) { animationTargetOverride = null; }
|
|
4872
|
-
if (channel.target.node == undefined) {
|
|
4873
|
-
return Promise.resolve();
|
|
4874
|
-
}
|
|
4875
|
-
var targetNode = ArrayItem.Get("".concat(context, "/target/node"), this._gltf.nodes, channel.target.node);
|
|
4876
|
-
// Ignore animations that have no animation targets.
|
|
4877
|
-
if ((channel.target.path === "weights" /* WEIGHTS */ && !targetNode._numMorphTargets) ||
|
|
4878
|
-
(channel.target.path !== "weights" /* WEIGHTS */ && !targetNode._babylonTransformNode)) {
|
|
4879
|
-
return Promise.resolve();
|
|
4880
|
-
}
|
|
4881
|
-
var sampler = ArrayItem.Get("".concat(context, "/sampler"), animation.samplers, channel.sampler);
|
|
4882
|
-
return this._loadAnimationSamplerAsync("".concat(animationContext, "/samplers/").concat(channel.sampler), sampler).then(function (data) {
|
|
4883
|
-
var targetPath;
|
|
4884
|
-
var animationType;
|
|
4885
|
-
switch (channel.target.path) {
|
|
4886
|
-
case "translation" /* TRANSLATION */: {
|
|
4887
|
-
targetPath = "position";
|
|
4888
|
-
animationType = core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_VECTOR3;
|
|
4889
|
-
break;
|
|
4890
|
-
}
|
|
4891
|
-
case "rotation" /* ROTATION */: {
|
|
4892
|
-
targetPath = "rotationQuaternion";
|
|
4893
|
-
animationType = core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_QUATERNION;
|
|
4894
|
-
break;
|
|
4895
|
-
}
|
|
4896
|
-
case "scale" /* SCALE */: {
|
|
4897
|
-
targetPath = "scaling";
|
|
4898
|
-
animationType = core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_VECTOR3;
|
|
4899
|
-
break;
|
|
4900
|
-
}
|
|
4901
|
-
case "weights" /* WEIGHTS */: {
|
|
4902
|
-
targetPath = "influence";
|
|
4903
|
-
animationType = core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT;
|
|
4904
|
-
break;
|
|
4905
|
-
}
|
|
4906
|
-
default: {
|
|
4907
|
-
throw new Error("".concat(context, "/target/path: Invalid value (").concat(channel.target.path, ")"));
|
|
4908
|
-
}
|
|
4909
|
-
}
|
|
4910
|
-
var outputBufferOffset = 0;
|
|
4911
|
-
var getNextOutputValue;
|
|
4912
|
-
switch (targetPath) {
|
|
4913
|
-
case "position": {
|
|
4914
|
-
getNextOutputValue = function (scale) {
|
|
4915
|
-
var value = core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArray(data.output, outputBufferOffset).scaleInPlace(scale);
|
|
4916
|
-
outputBufferOffset += 3;
|
|
4917
|
-
return value;
|
|
4918
|
-
};
|
|
4919
|
-
break;
|
|
4920
|
-
}
|
|
4921
|
-
case "rotationQuaternion": {
|
|
4922
|
-
getNextOutputValue = function (scale) {
|
|
4923
|
-
var value = core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Quaternion.FromArray(data.output, outputBufferOffset).scaleInPlace(scale);
|
|
4924
|
-
outputBufferOffset += 4;
|
|
4925
|
-
return value;
|
|
4926
|
-
};
|
|
4927
|
-
break;
|
|
4928
|
-
}
|
|
4929
|
-
case "scaling": {
|
|
4930
|
-
getNextOutputValue = function (scale) {
|
|
4931
|
-
var value = core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArray(data.output, outputBufferOffset).scaleInPlace(scale);
|
|
4932
|
-
outputBufferOffset += 3;
|
|
4933
|
-
return value;
|
|
4934
|
-
};
|
|
4935
|
-
break;
|
|
4936
|
-
}
|
|
4937
|
-
case "influence": {
|
|
4938
|
-
getNextOutputValue = function (scale) {
|
|
4939
|
-
var value = new Array(targetNode._numMorphTargets);
|
|
4940
|
-
for (var i = 0; i < targetNode._numMorphTargets; i++) {
|
|
4941
|
-
value[i] = data.output[outputBufferOffset++] * scale;
|
|
4942
|
-
}
|
|
4943
|
-
return value;
|
|
4944
|
-
};
|
|
4945
|
-
break;
|
|
4946
|
-
}
|
|
4947
|
-
}
|
|
4948
|
-
var getNextKey;
|
|
4949
|
-
switch (data.interpolation) {
|
|
4950
|
-
case "STEP" /* STEP */: {
|
|
4951
|
-
getNextKey = function (frameIndex) { return ({
|
|
4952
|
-
frame: data.input[frameIndex] * _this.parent.targetFps,
|
|
4953
|
-
value: getNextOutputValue(1),
|
|
4954
|
-
interpolation: core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.AnimationKeyInterpolation.STEP,
|
|
4955
|
-
}); };
|
|
4956
|
-
break;
|
|
4957
|
-
}
|
|
4958
|
-
case "LINEAR" /* LINEAR */: {
|
|
4959
|
-
getNextKey = function (frameIndex) { return ({
|
|
4960
|
-
frame: data.input[frameIndex] * _this.parent.targetFps,
|
|
4961
|
-
value: getNextOutputValue(1),
|
|
4962
|
-
}); };
|
|
4963
|
-
break;
|
|
4964
|
-
}
|
|
4965
|
-
case "CUBICSPLINE" /* CUBICSPLINE */: {
|
|
4966
|
-
var invTargetFps_1 = 1 / _this.parent.targetFps;
|
|
4967
|
-
getNextKey = function (frameIndex) { return ({
|
|
4968
|
-
frame: data.input[frameIndex] * _this.parent.targetFps,
|
|
4969
|
-
inTangent: getNextOutputValue(invTargetFps_1),
|
|
4970
|
-
value: getNextOutputValue(1),
|
|
4971
|
-
outTangent: getNextOutputValue(invTargetFps_1),
|
|
4972
|
-
}); };
|
|
4973
|
-
break;
|
|
4974
|
-
}
|
|
4975
|
-
}
|
|
4976
|
-
var keys = new Array(data.input.length);
|
|
4977
|
-
for (var frameIndex = 0; frameIndex < data.input.length; frameIndex++) {
|
|
4978
|
-
keys[frameIndex] = getNextKey(frameIndex);
|
|
4979
|
-
}
|
|
4980
|
-
if (targetPath === "influence") {
|
|
4981
|
-
var _loop_2 = function (targetIndex) {
|
|
4982
|
-
var animationName = "".concat(babylonAnimationGroup.name, "_channel").concat(babylonAnimationGroup.targetedAnimations.length);
|
|
4983
|
-
var babylonAnimation = new core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Animation(animationName, targetPath, _this.parent.targetFps, animationType);
|
|
4984
|
-
babylonAnimation.setKeys(keys.map(function (key) { return ({
|
|
4985
|
-
frame: key.frame,
|
|
4986
|
-
inTangent: key.inTangent ? key.inTangent[targetIndex] : undefined,
|
|
4987
|
-
value: key.value[targetIndex],
|
|
4988
|
-
outTangent: key.outTangent ? key.outTangent[targetIndex] : undefined,
|
|
4989
|
-
interpolation: key.interpolation,
|
|
4990
|
-
}); }));
|
|
4991
|
-
_this._forEachPrimitive(targetNode, function (babylonAbstractMesh) {
|
|
4992
|
-
var babylonMesh = babylonAbstractMesh;
|
|
4993
|
-
if (babylonMesh.morphTargetManager) {
|
|
4994
|
-
var morphTarget = babylonMesh.morphTargetManager.getTarget(targetIndex);
|
|
4995
|
-
var babylonAnimationClone = babylonAnimation.clone();
|
|
4996
|
-
morphTarget.animations.push(babylonAnimationClone);
|
|
4997
|
-
babylonAnimationGroup.addTargetedAnimation(babylonAnimationClone, morphTarget);
|
|
4998
|
-
}
|
|
4999
|
-
});
|
|
5000
|
-
};
|
|
5001
|
-
for (var targetIndex = 0; targetIndex < targetNode._numMorphTargets; targetIndex++) {
|
|
5002
|
-
_loop_2(targetIndex);
|
|
5003
|
-
}
|
|
5004
|
-
}
|
|
5005
|
-
else {
|
|
5006
|
-
var animationName = "".concat(babylonAnimationGroup.name, "_channel").concat(babylonAnimationGroup.targetedAnimations.length);
|
|
5007
|
-
var babylonAnimation = new core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Animation(animationName, targetPath, _this.parent.targetFps, animationType);
|
|
5008
|
-
babylonAnimation.setKeys(keys);
|
|
5009
|
-
if (animationTargetOverride != null && animationTargetOverride.animations != null) {
|
|
5010
|
-
animationTargetOverride.animations.push(babylonAnimation);
|
|
5011
|
-
babylonAnimationGroup.addTargetedAnimation(babylonAnimation, animationTargetOverride);
|
|
5012
|
-
}
|
|
5013
|
-
else {
|
|
5014
|
-
targetNode._babylonTransformNode.animations.push(babylonAnimation);
|
|
5015
|
-
babylonAnimationGroup.addTargetedAnimation(babylonAnimation, targetNode._babylonTransformNode);
|
|
5016
|
-
}
|
|
5017
|
-
}
|
|
5018
|
-
});
|
|
5019
|
-
};
|
|
5020
|
-
GLTFLoader.prototype._loadAnimationSamplerAsync = function (context, sampler) {
|
|
5021
|
-
if (sampler._data) {
|
|
5022
|
-
return sampler._data;
|
|
5023
|
-
}
|
|
5024
|
-
var interpolation = sampler.interpolation || "LINEAR" /* LINEAR */;
|
|
5025
|
-
switch (interpolation) {
|
|
5026
|
-
case "STEP" /* STEP */:
|
|
5027
|
-
case "LINEAR" /* LINEAR */:
|
|
5028
|
-
case "CUBICSPLINE" /* CUBICSPLINE */: {
|
|
5029
|
-
break;
|
|
5030
|
-
}
|
|
5031
|
-
default: {
|
|
5032
|
-
throw new Error("".concat(context, "/interpolation: Invalid value (").concat(sampler.interpolation, ")"));
|
|
5033
|
-
}
|
|
5034
|
-
}
|
|
5035
|
-
var inputAccessor = ArrayItem.Get("".concat(context, "/input"), this._gltf.accessors, sampler.input);
|
|
5036
|
-
var outputAccessor = ArrayItem.Get("".concat(context, "/output"), this._gltf.accessors, sampler.output);
|
|
5037
|
-
sampler._data = Promise.all([
|
|
5038
|
-
this._loadFloatAccessorAsync("/accessors/".concat(inputAccessor.index), inputAccessor),
|
|
5039
|
-
this._loadFloatAccessorAsync("/accessors/".concat(outputAccessor.index), outputAccessor),
|
|
5040
|
-
]).then(function (_a) {
|
|
5041
|
-
var inputData = _a[0], outputData = _a[1];
|
|
5042
|
-
return {
|
|
5043
|
-
input: inputData,
|
|
5044
|
-
interpolation: interpolation,
|
|
5045
|
-
output: outputData,
|
|
5046
|
-
};
|
|
5047
|
-
});
|
|
5048
|
-
return sampler._data;
|
|
5666
|
+
var promise = this._extensionsLoadAnimationAsync(context, animation);
|
|
5667
|
+
return promise !== null && promise !== void 0 ? promise : Promise.resolve(animation._babylonAnimationGroup);
|
|
5049
5668
|
};
|
|
5050
5669
|
/**
|
|
5051
5670
|
* Loads a glTF buffer.
|
|
@@ -5973,6 +6592,10 @@ var GLTFLoader = /** @class */ (function () {
|
|
|
5973
6592
|
GLTFLoader.prototype.endPerformanceCounter = function (counterName) {
|
|
5974
6593
|
this._parent._endPerformanceCounter(counterName);
|
|
5975
6594
|
};
|
|
6595
|
+
/** @hidden */
|
|
6596
|
+
// note : KHR_animation_pointer is used to load animation in ALL case, turning everything
|
|
6597
|
+
// into pointer. This is the reason why this value is located here.
|
|
6598
|
+
GLTFLoader._KHRAnimationPointerName = "KHR_animation_pointer";
|
|
5976
6599
|
GLTFLoader._RegisteredExtensions = {};
|
|
5977
6600
|
/**
|
|
5978
6601
|
* The default glTF sampler.
|
|
@@ -6008,6 +6631,42 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
6008
6631
|
|
|
6009
6632
|
|
|
6010
6633
|
|
|
6634
|
+
/***/ }),
|
|
6635
|
+
|
|
6636
|
+
/***/ "../../../lts/loaders/dist/glTF/2.0/glTFUtilities.js":
|
|
6637
|
+
/*!***********************************************************!*\
|
|
6638
|
+
!*** ../../../lts/loaders/dist/glTF/2.0/glTFUtilities.js ***!
|
|
6639
|
+
\***********************************************************/
|
|
6640
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
6641
|
+
|
|
6642
|
+
__webpack_require__.r(__webpack_exports__);
|
|
6643
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
6644
|
+
/* harmony export */ "getDataAccessorElementCount": () => (/* binding */ getDataAccessorElementCount)
|
|
6645
|
+
/* harmony export */ });
|
|
6646
|
+
/**
|
|
6647
|
+
* Used internally to determine how much data to be gather from input buffer at each key frame.
|
|
6648
|
+
* @param accessorType the accessor type
|
|
6649
|
+
* @returns the number of item to be gather at each keyframe
|
|
6650
|
+
*/
|
|
6651
|
+
function getDataAccessorElementCount(accessorType) {
|
|
6652
|
+
switch (accessorType) {
|
|
6653
|
+
case "SCALAR" /* SCALAR */:
|
|
6654
|
+
return 1;
|
|
6655
|
+
case "VEC2" /* VEC2 */:
|
|
6656
|
+
return 2;
|
|
6657
|
+
case "VEC3" /* VEC3 */:
|
|
6658
|
+
return 3;
|
|
6659
|
+
case "VEC4" /* VEC4 */:
|
|
6660
|
+
case "MAT2" /* MAT2 */:
|
|
6661
|
+
return 4;
|
|
6662
|
+
case "MAT3" /* MAT3 */:
|
|
6663
|
+
return 9;
|
|
6664
|
+
case "MAT4" /* MAT4 */:
|
|
6665
|
+
return 16;
|
|
6666
|
+
}
|
|
6667
|
+
}
|
|
6668
|
+
|
|
6669
|
+
|
|
6011
6670
|
/***/ }),
|
|
6012
6671
|
|
|
6013
6672
|
/***/ "../../../lts/loaders/dist/glTF/2.0/index.js":
|
|
@@ -6025,6 +6684,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
6025
6684
|
/* harmony export */ "EXT_texture_webp": () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.EXT_texture_webp),
|
|
6026
6685
|
/* harmony export */ "ExtrasAsMetadata": () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.ExtrasAsMetadata),
|
|
6027
6686
|
/* harmony export */ "GLTFLoader": () => (/* reexport safe */ _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader),
|
|
6687
|
+
/* harmony export */ "KHR_animation_pointer": () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_animation_pointer),
|
|
6028
6688
|
/* harmony export */ "KHR_draco_mesh_compression": () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_draco_mesh_compression),
|
|
6029
6689
|
/* harmony export */ "KHR_lights": () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_lights),
|
|
6030
6690
|
/* harmony export */ "KHR_materials_clearcoat": () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_materials_clearcoat),
|