@babylonjs/loaders 7.51.0 → 7.51.2

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.
Files changed (56) hide show
  1. package/glTF/2.0/Extensions/KHR_animation_pointer.d.ts +1 -0
  2. package/glTF/2.0/Extensions/KHR_animation_pointer.data.d.ts +0 -299
  3. package/glTF/2.0/Extensions/KHR_animation_pointer.data.js +190 -224
  4. package/glTF/2.0/Extensions/KHR_animation_pointer.data.js.map +1 -1
  5. package/glTF/2.0/Extensions/KHR_animation_pointer.js +11 -14
  6. package/glTF/2.0/Extensions/KHR_animation_pointer.js.map +1 -1
  7. package/glTF/2.0/Extensions/KHR_interactivity/declarationMapper.d.ts +339 -0
  8. package/glTF/2.0/Extensions/KHR_interactivity/declarationMapper.js +1507 -0
  9. package/glTF/2.0/Extensions/KHR_interactivity/declarationMapper.js.map +1 -0
  10. package/glTF/2.0/Extensions/KHR_interactivity/flowGraphGLTFDataProvider.d.ts +33 -0
  11. package/glTF/2.0/Extensions/KHR_interactivity/flowGraphGLTFDataProvider.js +20 -0
  12. package/glTF/2.0/Extensions/KHR_interactivity/flowGraphGLTFDataProvider.js.map +1 -0
  13. package/glTF/2.0/Extensions/KHR_interactivity/index.d.ts +3 -0
  14. package/glTF/2.0/Extensions/KHR_interactivity/index.js +4 -0
  15. package/glTF/2.0/Extensions/KHR_interactivity/index.js.map +1 -0
  16. package/glTF/2.0/Extensions/KHR_interactivity/interactivityGraphParser.d.ts +71 -0
  17. package/glTF/2.0/Extensions/KHR_interactivity/interactivityGraphParser.js +442 -0
  18. package/glTF/2.0/Extensions/KHR_interactivity/interactivityGraphParser.js.map +1 -0
  19. package/glTF/2.0/Extensions/KHR_interactivity.d.ts +7 -1
  20. package/glTF/2.0/Extensions/KHR_interactivity.js +105 -7
  21. package/glTF/2.0/Extensions/KHR_interactivity.js.map +1 -1
  22. package/glTF/2.0/Extensions/KHR_node_hoverability.js +153 -0
  23. package/glTF/2.0/Extensions/KHR_node_hoverability.js.map +1 -1
  24. package/glTF/2.0/Extensions/KHR_node_selectability.d.ts +30 -0
  25. package/glTF/2.0/Extensions/KHR_node_selectability.js +123 -0
  26. package/glTF/2.0/Extensions/KHR_node_selectability.js.map +1 -0
  27. package/glTF/2.0/Extensions/KHR_node_visibility.js +25 -0
  28. package/glTF/2.0/Extensions/KHR_node_visibility.js.map +1 -1
  29. package/glTF/2.0/Extensions/gltfPathToObjectConverter.d.ts +5 -2
  30. package/glTF/2.0/Extensions/gltfPathToObjectConverter.js +26 -5
  31. package/glTF/2.0/Extensions/gltfPathToObjectConverter.js.map +1 -1
  32. package/glTF/2.0/Extensions/index.d.ts +4 -0
  33. package/glTF/2.0/Extensions/index.js +5 -0
  34. package/glTF/2.0/Extensions/index.js.map +1 -1
  35. package/glTF/2.0/Extensions/objectModelMapping.d.ts +289 -0
  36. package/glTF/2.0/Extensions/objectModelMapping.js +801 -0
  37. package/glTF/2.0/Extensions/objectModelMapping.js.map +1 -0
  38. package/glTF/2.0/glTFLoader.d.ts +4 -1
  39. package/glTF/2.0/glTFLoader.js +22 -11
  40. package/glTF/2.0/glTFLoader.js.map +1 -1
  41. package/glTF/2.0/glTFLoaderAnimation.d.ts +12 -10
  42. package/glTF/2.0/glTFLoaderAnimation.js +13 -11
  43. package/glTF/2.0/glTFLoaderAnimation.js.map +1 -1
  44. package/glTF/2.0/index.d.ts +1 -0
  45. package/glTF/2.0/index.js +1 -0
  46. package/glTF/2.0/index.js.map +1 -1
  47. package/package.json +3 -3
  48. package/glTF/2.0/Extensions/interactivityFunctions.d.ts +0 -9
  49. package/glTF/2.0/Extensions/interactivityFunctions.js +0 -198
  50. package/glTF/2.0/Extensions/interactivityFunctions.js.map +0 -1
  51. package/glTF/2.0/Extensions/interactivityPathToObjectConverter.d.ts +0 -9
  52. package/glTF/2.0/Extensions/interactivityPathToObjectConverter.js +0 -32
  53. package/glTF/2.0/Extensions/interactivityPathToObjectConverter.js.map +0 -1
  54. package/glTF/2.0/Extensions/interactivityUtils.d.ts +0 -4
  55. package/glTF/2.0/Extensions/interactivityUtils.js +0 -108
  56. package/glTF/2.0/Extensions/interactivityUtils.js.map +0 -1
@@ -20,21 +20,23 @@ export declare abstract class AnimationPropertyInfo {
20
20
  constructor(type: number, name: string, getValue: GetValueFn, getStride: (target: any) => number);
21
21
  protected _buildAnimation(name: string, fps: number, keys: any[]): Animation;
22
22
  /** @internal */
23
- abstract buildAnimations(target: any, name: string, fps: number, keys: any[], callback: (babylonAnimatable: IAnimatable, babylonAnimation: Animation) => void): void;
23
+ abstract buildAnimations(target: any, name: string, fps: number, keys: any[]): {
24
+ babylonAnimatable: IAnimatable;
25
+ babylonAnimation: Animation;
26
+ }[];
24
27
  }
25
28
  /** @internal */
26
29
  export declare class TransformNodeAnimationPropertyInfo extends AnimationPropertyInfo {
27
30
  /** @internal */
28
- buildAnimations(target: INode, name: string, fps: number, keys: any[], callback: (babylonAnimatable: IAnimatable, babylonAnimation: Animation) => void): void;
31
+ buildAnimations(target: INode, name: string, fps: number, keys: any[]): {
32
+ babylonAnimatable: IAnimatable;
33
+ babylonAnimation: Animation;
34
+ }[];
29
35
  }
30
36
  /** @internal */
31
37
  export declare class WeightAnimationPropertyInfo extends AnimationPropertyInfo {
32
- buildAnimations(target: INode, name: string, fps: number, keys: any[], callback: (babylonAnimatable: IAnimatable, babylonAnimation: Animation) => void): void;
38
+ buildAnimations(target: INode, name: string, fps: number, keys: any[]): {
39
+ babylonAnimatable: IAnimatable;
40
+ babylonAnimation: Animation;
41
+ }[];
33
42
  }
34
- /** @internal */
35
- export declare const nodeAnimationData: {
36
- translation: TransformNodeAnimationPropertyInfo[];
37
- rotation: TransformNodeAnimationPropertyInfo[];
38
- scale: TransformNodeAnimationPropertyInfo[];
39
- weights: WeightAnimationPropertyInfo[];
40
- };
@@ -1,5 +1,6 @@
1
1
  import { Animation } from "@babylonjs/core/Animations/animation.js";
2
2
  import { Quaternion, Vector3 } from "@babylonjs/core/Maths/math.vector.js";
3
+ import { SetInterpolationForKey } from "./Extensions/objectModelMapping.js";
3
4
  /** @internal */
4
5
  export function getVector3(_target, source, offset, scale) {
5
6
  return Vector3.FromArray(source, offset).scaleInPlace(scale);
@@ -34,13 +35,16 @@ export class AnimationPropertyInfo {
34
35
  /** @internal */
35
36
  export class TransformNodeAnimationPropertyInfo extends AnimationPropertyInfo {
36
37
  /** @internal */
37
- buildAnimations(target, name, fps, keys, callback) {
38
- callback(target._babylonTransformNode, this._buildAnimation(name, fps, keys));
38
+ buildAnimations(target, name, fps, keys) {
39
+ const babylonAnimations = [];
40
+ babylonAnimations.push({ babylonAnimatable: target._babylonTransformNode, babylonAnimation: this._buildAnimation(name, fps, keys) });
41
+ return babylonAnimations;
39
42
  }
40
43
  }
41
44
  /** @internal */
42
45
  export class WeightAnimationPropertyInfo extends AnimationPropertyInfo {
43
- buildAnimations(target, name, fps, keys, callback) {
46
+ buildAnimations(target, name, fps, keys) {
47
+ const babylonAnimations = [];
44
48
  if (target._numMorphTargets) {
45
49
  for (let targetIndex = 0; targetIndex < target._numMorphTargets; targetIndex++) {
46
50
  const babylonAnimation = new Animation(`${name}_${targetIndex}`, this.name, fps, this.type);
@@ -57,19 +61,17 @@ export class WeightAnimationPropertyInfo extends AnimationPropertyInfo {
57
61
  const morphTarget = babylonMesh.morphTargetManager.getTarget(targetIndex);
58
62
  const babylonAnimationClone = babylonAnimation.clone();
59
63
  morphTarget.animations.push(babylonAnimationClone);
60
- callback(morphTarget, babylonAnimationClone);
64
+ babylonAnimations.push({ babylonAnimatable: morphTarget, babylonAnimation: babylonAnimationClone });
61
65
  }
62
66
  }
63
67
  }
64
68
  }
65
69
  }
70
+ return babylonAnimations;
66
71
  }
67
72
  }
68
- /** @internal */
69
- export const nodeAnimationData = {
70
- translation: [new TransformNodeAnimationPropertyInfo(Animation.ANIMATIONTYPE_VECTOR3, "position", getVector3, () => 3)],
71
- rotation: [new TransformNodeAnimationPropertyInfo(Animation.ANIMATIONTYPE_QUATERNION, "rotationQuaternion", getQuaternion, () => 4)],
72
- scale: [new TransformNodeAnimationPropertyInfo(Animation.ANIMATIONTYPE_VECTOR3, "scaling", getVector3, () => 3)],
73
- weights: [new WeightAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, "influence", getWeights, (target) => target._numMorphTargets)],
74
- };
73
+ SetInterpolationForKey("/nodes/{}/translation", [new TransformNodeAnimationPropertyInfo(Animation.ANIMATIONTYPE_VECTOR3, "position", getVector3, () => 3)]);
74
+ SetInterpolationForKey("/nodes/{}/rotation", [new TransformNodeAnimationPropertyInfo(Animation.ANIMATIONTYPE_QUATERNION, "rotationQuaternion", getQuaternion, () => 4)]);
75
+ SetInterpolationForKey("/nodes/{}/scale", [new TransformNodeAnimationPropertyInfo(Animation.ANIMATIONTYPE_VECTOR3, "scaling", getVector3, () => 3)]);
76
+ SetInterpolationForKey("/nodes/{}/weights", [new WeightAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, "influence", getWeights, (target) => target._numMorphTargets)]);
75
77
  //# sourceMappingURL=glTFLoaderAnimation.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"glTFLoaderAnimation.js","sourceRoot":"","sources":["../../../../../dev/loaders/src/glTF/2.0/glTFLoaderAnimation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,gDAAkC;AACtD,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,6CAA+B;AAO7D,gBAAgB;AAChB,MAAM,UAAU,UAAU,CAAC,OAAY,EAAE,MAAoB,EAAE,MAAc,EAAE,KAAa;IACxF,OAAO,OAAO,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;AACjE,CAAC;AAED,gBAAgB;AAChB,MAAM,UAAU,aAAa,CAAC,OAAY,EAAE,MAAoB,EAAE,MAAc,EAAE,KAAa;IAC3F,OAAO,UAAU,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,C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ACvD,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;4BACnD,QAAQ,CAAC,WAAW,EAAE,qBAAqB,CAAC,CAAC;wBACjD,CAAC;oBACL,CAAC;gBACL,CAAC;YACL,CAAC;QACL,CAAC;IACL,CAAC;CACJ;AAED,gBAAgB;AAChB,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC7B,WAAW,EAAE,CAAC,IAAI,kCAAkC,CAAC,SAAS,CAAC,qBAAqB,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;IACvH,QAAQ,EAAE,CAAC,IAAI,kCAAkC,CAAC,SAAS,CAAC,wBAAwB,EAAE,oBAAoB,EAAE,aAAa,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;IACpI,KAAK,EAAE,CAAC,IAAI,kCAAkC,CAAC,SAAS,CAAC,qBAAqB,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;IAChH,OAAO,EAAE,CAAC,IAAI,2BAA2B,CAAC,SAAS,CAAC,mBAAmB,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,gBAAiB,CAAC,CAAC;CAC3I,CAAC","sourcesContent":["import { Animation } from \"core/Animations/animation\";\r\nimport { Quaternion, Vector3 } from \"core/Maths/math.vector\";\r\nimport type { INode } from \"./glTFLoaderInterfaces\";\r\nimport type { IAnimatable } from \"core/Animations/animatable.interface\";\r\n\r\n/** @internal */\r\nexport type GetValueFn = (target: any, source: Float32Array, offset: number, scale: number) => any;\r\n\r\n/** @internal */\r\nexport function getVector3(_target: any, source: Float32Array, offset: number, scale: number): Vector3 {\r\n return Vector3.FromArray(source, offset).scaleInPlace(scale);\r\n}\r\n\r\n/** @internal */\r\nexport function getQuaternion(_target: any, source: Float32Array, offset: number, scale: number): Quaternion {\r\n return Quaternion.FromArray(source, offset).scaleInPlace(scale);\r\n}\r\n\r\n/** @internal */\r\nexport function getWeights(target: INode, source: Float32Array, offset: number, scale: number): Array<number> {\r\n const value = new Array<number>(target._numMorphTargets!);\r\n for (let i = 0; i < value.length; i++) {\r\n value[i] = source[offset++] * scale;\r\n }\r\n\r\n return value;\r\n}\r\n\r\n/** @internal */\r\nexport abstract class AnimationPropertyInfo {\r\n /** @internal */\r\n public constructor(\r\n public readonly type: number,\r\n public readonly name: string,\r\n public readonly getValue: GetValueFn,\r\n public readonly getStride: (target: any) => number\r\n ) {}\r\n\r\n protected _buildAnimation(name: string, fps: number, keys: any[]): Animation {\r\n const babylonAnimation = new Animation(name, this.name, fps, this.type);\r\n babylonAnimation.setKeys(keys);\r\n return babylonAnimation;\r\n }\r\n\r\n /** @internal */\r\n public abstract buildAnimations(target: any, name: string, fps: number, keys: any[], callback: (babylonAnimatable: IAnimatable, babylonAnimation: Animation) => void): void;\r\n}\r\n\r\n/** @internal */\r\nexport class TransformNodeAnimationPropertyInfo extends AnimationPropertyInfo {\r\n /** @internal */\r\n public buildAnimations(target: INode, name: string, fps: number, keys: any[], callback: (babylonAnimatable: IAnimatable, babylonAnimation: Animation) => void): void {\r\n callback(target._babylonTransformNode!, this._buildAnimation(name, fps, keys));\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport class WeightAnimationPropertyInfo extends AnimationPropertyInfo {\r\n public buildAnimations(target: INode, name: string, fps: number, keys: any[], callback: (babylonAnimatable: IAnimatable, babylonAnimation: Animation) => void): void {\r\n if (target._numMorphTargets) {\r\n for (let targetIndex = 0; targetIndex < target._numMorphTargets; targetIndex++) {\r\n const babylonAnimation = new Animation(`${name}_${targetIndex}`, this.name, fps, this.type);\r\n babylonAnimation.setKeys(\r\n keys.map((key) => ({\r\n frame: key.frame,\r\n inTangent: key.inTangent ? key.inTangent[targetIndex] : undefined,\r\n value: key.value[targetIndex],\r\n outTangent: key.outTangent ? key.outTangent[targetIndex] : undefined,\r\n interpolation: key.interpolation,\r\n }))\r\n );\r\n\r\n if (target._primitiveBabylonMeshes) {\r\n for (const babylonMesh of target._primitiveBabylonMeshes) {\r\n if (babylonMesh.morphTargetManager) {\r\n const morphTarget = babylonMesh.morphTargetManager.getTarget(targetIndex);\r\n const babylonAnimationClone = babylonAnimation.clone();\r\n morphTarget.animations.push(babylonAnimationClone);\r\n callback(morphTarget, babylonAnimationClone);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport const nodeAnimationData = {\r\n translation: [new TransformNodeAnimationPropertyInfo(Animation.ANIMATIONTYPE_VECTOR3, \"position\", getVector3, () => 3)],\r\n rotation: [new TransformNodeAnimationPropertyInfo(Animation.ANIMATIONTYPE_QUATERNION, \"rotationQuaternion\", getQuaternion, () => 4)],\r\n scale: [new TransformNodeAnimationPropertyInfo(Animation.ANIMATIONTYPE_VECTOR3, \"scaling\", getVector3, () => 3)],\r\n weights: [new WeightAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, \"influence\", getWeights, (target) => target._numMorphTargets!)],\r\n};\r\n"]}
1
+ {"version":3,"file":"glTFLoaderAnimation.js","sourceRoot":"","sources":["../../../../../dev/loaders/src/glTF/2.0/glTFLoaderAnimation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,gDAAkC;AACtD,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,6CAA+B;AAG7D,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAKzE,gBAAgB;AAChB,MAAM,UAAU,UAAU,CAAC,OAAY,EAAE,MAAoB,EAAE,MAAc,EAAE,KAAa;IACxF,OAAO,OAAO,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;AACjE,CAAC;AAED,gBAAgB;AAChB,MAAM,UAAU,aAAa,CAAC,OAAY,EAAE,MAAoB,EAAE,MAAc,EAAE,KAAa;IAC3F,OAAO,UAAU,CAAC,SAAS,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AAkB,EAAE,CAAC;4BACjC,MAAM,WAAW,GAAG,WAAW,CAAC,kBAAkB,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;4BAC1E,MAAM,qBAAqB,GAAG,gBAAgB,CAAC,KAAK,EAAE,CAAC;4BACvD,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;4BACnD,iBAAiB,CAAC,IAAI,CAAC,EAAE,iBAAiB,EAAE,WAAW,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,CAAC,CAAC;wBACxG,CAAC;oBACL,CAAC;gBACL,CAAC;YACL,CAAC;QACL,CAAC;QACD,OAAO,iBAAiB,CAAC;IAC7B,CAAC;CACJ;AAED,sBAAsB,CAAC,uBAAuB,EAAE,CAAC,IAAI,kCAAkC,CAAC,SAAS,CAAC,qBAAqB,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC5J,sBAAsB,CAAC,oBAAoB,EAAE,CAAC,IAAI,kCAAkC,CAAC,SAAS,CAAC,wBAAwB,EAAE,oBAAoB,EAAE,aAAa,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACzK,sBAAsB,CAAC,iBAAiB,EAAE,CAAC,IAAI,kCAAkC,CAAC,SAAS,CAAC,qBAAqB,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACrJ,sBAAsB,CAAC,mBAAmB,EAAE,CAAC,IAAI,2BAA2B,CAAC,SAAS,CAAC,mBAAmB,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,gBAAiB,CAAC,CAAC,CAAC,CAAC","sourcesContent":["import { Animation } from \"core/Animations/animation\";\r\nimport { Quaternion, Vector3 } from \"core/Maths/math.vector\";\r\nimport type { INode } from \"./glTFLoaderInterfaces\";\r\nimport type { IAnimatable } from \"core/Animations/animatable.interface\";\r\nimport { SetInterpolationForKey } from \"./Extensions/objectModelMapping\";\r\n\r\n/** @internal */\r\nexport type GetValueFn = (target: any, source: Float32Array, offset: number, scale: number) => any;\r\n\r\n/** @internal */\r\nexport function getVector3(_target: any, source: Float32Array, offset: number, scale: number): Vector3 {\r\n return Vector3.FromArray(source, offset).scaleInPlace(scale);\r\n}\r\n\r\n/** @internal */\r\nexport function getQuaternion(_target: any, source: Float32Array, offset: number, scale: number): Quaternion {\r\n return Quaternion.FromArray(source, offset).scaleInPlace(scale);\r\n}\r\n\r\n/** @internal */\r\nexport function getWeights(target: INode, source: Float32Array, offset: number, scale: number): Array<number> {\r\n const value = new Array<number>(target._numMorphTargets!);\r\n for (let i = 0; i < value.length; i++) {\r\n value[i] = source[offset++] * scale;\r\n }\r\n\r\n return value;\r\n}\r\n\r\n/** @internal */\r\nexport abstract class AnimationPropertyInfo {\r\n /** @internal */\r\n public constructor(\r\n public readonly type: number,\r\n public readonly name: string,\r\n public readonly getValue: GetValueFn,\r\n public readonly getStride: (target: any) => number\r\n ) {}\r\n\r\n protected _buildAnimation(name: string, fps: number, keys: any[]): Animation {\r\n const babylonAnimation = new Animation(name, this.name, fps, this.type);\r\n babylonAnimation.setKeys(keys);\r\n return babylonAnimation;\r\n }\r\n\r\n /** @internal */\r\n public abstract buildAnimations(target: any, name: string, fps: number, keys: any[]): { babylonAnimatable: IAnimatable; babylonAnimation: Animation }[];\r\n}\r\n\r\n/** @internal */\r\nexport class TransformNodeAnimationPropertyInfo extends AnimationPropertyInfo {\r\n /** @internal */\r\n public buildAnimations(target: INode, name: string, fps: number, keys: any[]) {\r\n const babylonAnimations: { babylonAnimatable: IAnimatable; babylonAnimation: Animation }[] = [];\r\n babylonAnimations.push({ babylonAnimatable: target._babylonTransformNode!, babylonAnimation: this._buildAnimation(name, fps, keys) });\r\n return babylonAnimations;\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport class WeightAnimationPropertyInfo extends AnimationPropertyInfo {\r\n public buildAnimations(target: INode, name: string, fps: number, keys: any[]) {\r\n const babylonAnimations: { babylonAnimatable: IAnimatable; babylonAnimation: Animation }[] = [];\r\n if (target._numMorphTargets) {\r\n for (let targetIndex = 0; targetIndex < target._numMorphTargets; targetIndex++) {\r\n const babylonAnimation = new Animation(`${name}_${targetIndex}`, this.name, fps, this.type);\r\n babylonAnimation.setKeys(\r\n keys.map((key) => ({\r\n frame: key.frame,\r\n inTangent: key.inTangent ? key.inTangent[targetIndex] : undefined,\r\n value: key.value[targetIndex],\r\n outTangent: key.outTangent ? key.outTangent[targetIndex] : undefined,\r\n interpolation: key.interpolation,\r\n }))\r\n );\r\n\r\n if (target._primitiveBabylonMeshes) {\r\n for (const babylonMesh of target._primitiveBabylonMeshes) {\r\n if (babylonMesh.morphTargetManager) {\r\n const morphTarget = babylonMesh.morphTargetManager.getTarget(targetIndex);\r\n const babylonAnimationClone = babylonAnimation.clone();\r\n morphTarget.animations.push(babylonAnimationClone);\r\n babylonAnimations.push({ babylonAnimatable: morphTarget, babylonAnimation: babylonAnimationClone });\r\n }\r\n }\r\n }\r\n }\r\n }\r\n return babylonAnimations;\r\n }\r\n}\r\n\r\nSetInterpolationForKey(\"/nodes/{}/translation\", [new TransformNodeAnimationPropertyInfo(Animation.ANIMATIONTYPE_VECTOR3, \"position\", getVector3, () => 3)]);\r\nSetInterpolationForKey(\"/nodes/{}/rotation\", [new TransformNodeAnimationPropertyInfo(Animation.ANIMATIONTYPE_QUATERNION, \"rotationQuaternion\", getQuaternion, () => 4)]);\r\nSetInterpolationForKey(\"/nodes/{}/scale\", [new TransformNodeAnimationPropertyInfo(Animation.ANIMATIONTYPE_VECTOR3, \"scaling\", getVector3, () => 3)]);\r\nSetInterpolationForKey(\"/nodes/{}/weights\", [new WeightAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, \"influence\", getWeights, (target) => target._numMorphTargets!)]);\r\n"]}
@@ -2,4 +2,5 @@ export * from "./glTFLoader";
2
2
  export * from "./glTFLoaderExtension";
3
3
  export * from "./glTFLoaderExtensionRegistry";
4
4
  export * from "./glTFLoaderInterfaces";
5
+ export * from "./glTFLoaderAnimation";
5
6
  export * from "./Extensions/index";
package/glTF/2.0/index.js CHANGED
@@ -3,5 +3,6 @@ export * from "./glTFLoader.js";
3
3
  export * from "./glTFLoaderExtension.js";
4
4
  export * from "./glTFLoaderExtensionRegistry.js";
5
5
  export * from "./glTFLoaderInterfaces.js";
6
+ export * from "./glTFLoaderAnimation.js";
6
7
  export * from "./Extensions/index.js";
7
8
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../dev/loaders/src/glTF/2.0/index.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,cAAc,cAAc,CAAC;AAC7B,cAAc,uBAAuB,CAAC;AACtC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC","sourcesContent":["/* eslint-disable import/no-internal-modules */\r\nexport * from \"./glTFLoader\";\r\nexport * from \"./glTFLoaderExtension\";\r\nexport * from \"./glTFLoaderExtensionRegistry\";\r\nexport * from \"./glTFLoaderInterfaces\";\r\nexport * from \"./Extensions/index\";\r\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../dev/loaders/src/glTF/2.0/index.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,cAAc,cAAc,CAAC;AAC7B,cAAc,uBAAuB,CAAC;AACtC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC","sourcesContent":["/* eslint-disable import/no-internal-modules */\r\nexport * from \"./glTFLoader\";\r\nexport * from \"./glTFLoaderExtension\";\r\nexport * from \"./glTFLoaderExtensionRegistry\";\r\nexport * from \"./glTFLoaderInterfaces\";\r\nexport * from \"./glTFLoaderAnimation\";\r\nexport * from \"./Extensions/index\";\r\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@babylonjs/loaders",
3
- "version": "7.51.0",
3
+ "version": "7.51.2",
4
4
  "main": "index.js",
5
5
  "module": "index.js",
6
6
  "types": "index.d.ts",
@@ -18,10 +18,10 @@
18
18
  "postcompile": "build-tools -c add-js-to-es6"
19
19
  },
20
20
  "devDependencies": {
21
- "@babylonjs/core": "^7.51.0",
21
+ "@babylonjs/core": "^7.51.2",
22
22
  "@dev/build-tools": "^1.0.0",
23
23
  "@lts/loaders": "^1.0.0",
24
- "babylonjs-gltf2interface": "^7.51.0"
24
+ "babylonjs-gltf2interface": "^7.51.2"
25
25
  },
26
26
  "peerDependencies": {
27
27
  "@babylonjs/core": "^7.0.0",
@@ -1,9 +0,0 @@
1
- import type { IKHRInteractivity } from "babylonjs-gltf2interface";
2
- import type { ISerializedFlowGraph } from "@babylonjs/core/FlowGraph/typeDefinitions.js";
3
- /**
4
- * @internal
5
- * Converts a glTF Interactivity Extension to a serialized flow graph.
6
- * @param gltf the interactivity data
7
- * @returns a serialized flow graph
8
- */
9
- export declare function convertGLTFToSerializedFlowGraph(gltf: IKHRInteractivity): ISerializedFlowGraph;
@@ -1,198 +0,0 @@
1
- import { RandomGUID } from "@babylonjs/core/Misc/guid.js";
2
- import { gltfToFlowGraphTypeMap, gltfTypeToBabylonType } from "./interactivityUtils.js";
3
- function convertValueWithType(configObject, definition, context) {
4
- if (configObject.type !== undefined) {
5
- // get the type on the gltf definition
6
- const type = definition.types && definition.types[configObject.type];
7
- if (!type) {
8
- throw new Error(`${context}: Unknown type: ${configObject.type}`);
9
- }
10
- const signature = type.signature;
11
- if (!signature) {
12
- throw new Error(`${context}: Type ${configObject.type} has no signature`);
13
- }
14
- const convertedType = gltfTypeToBabylonType[signature];
15
- return {
16
- value: configObject.value,
17
- className: convertedType,
18
- };
19
- }
20
- else {
21
- return configObject.value;
22
- }
23
- }
24
- function convertConfiguration(gltfBlock, definition, id) {
25
- const converted = {};
26
- const configurationList = gltfBlock.configuration ?? [];
27
- for (const configObject of configurationList) {
28
- if (configObject.id === "customEvent") {
29
- const customEvent = definition.customEvents && definition.customEvents[configObject.value];
30
- if (!customEvent) {
31
- throw new Error(`/extensions/KHR_interactivity/nodes/${id}: Unknown custom event: ${configObject.value}`);
32
- }
33
- converted.eventId = customEvent.id;
34
- converted.eventData = customEvent.values.map((v) => v.id);
35
- }
36
- else if (configObject.id === "variable") {
37
- const variable = definition.variables && definition.variables[configObject.value];
38
- if (!variable) {
39
- throw new Error(`/extensions/KHR_interactivity/nodes/${id}: Unknown variable: ${configObject.value}`);
40
- }
41
- converted.variableName = variable.id;
42
- }
43
- else if (configObject.id === "path") {
44
- // Convert from a GLTF path to a reference to the Babylon.js object
45
- const pathValue = configObject.value;
46
- converted.path = pathValue;
47
- }
48
- else {
49
- converted[configObject.id] = convertValueWithType(configObject, definition, `/extensions/KHR_interactivity/nodes/${id}`);
50
- }
51
- }
52
- return converted;
53
- }
54
- function convertBlock(id, gltfBlock, definition) {
55
- const className = gltfToFlowGraphTypeMap[gltfBlock.type];
56
- if (!className) {
57
- throw new Error(`/extensions/KHR_interactivity/nodes/${id}: Unknown block type: ${gltfBlock.type}`);
58
- }
59
- const uniqueId = id.toString();
60
- const config = convertConfiguration(gltfBlock, definition, uniqueId);
61
- const metadata = gltfBlock.metadata;
62
- const dataInputs = [];
63
- const dataOutputs = [];
64
- const signalInputs = [];
65
- const signalOutputs = [];
66
- return {
67
- className,
68
- config,
69
- uniqueId,
70
- metadata,
71
- dataInputs,
72
- dataOutputs,
73
- signalInputs,
74
- signalOutputs,
75
- };
76
- }
77
- /**
78
- * @internal
79
- * Converts a glTF Interactivity Extension to a serialized flow graph.
80
- * @param gltf the interactivity data
81
- * @returns a serialized flow graph
82
- */
83
- export function convertGLTFToSerializedFlowGraph(gltf) {
84
- // create an empty serialized context to store the values of the connections
85
- const context = {
86
- uniqueId: RandomGUID(),
87
- _userVariables: {},
88
- _connectionValues: {},
89
- };
90
- const executionContexts = [context];
91
- // Blocks converted to the flow graph json format
92
- const flowGraphJsonBlocks = [];
93
- for (let i = 0; i < gltf.nodes.length; i++) {
94
- const gltfBlock = gltf.nodes[i];
95
- const flowGraphJsonBlock = convertBlock(i, gltfBlock, gltf);
96
- flowGraphJsonBlocks.push(flowGraphJsonBlock);
97
- }
98
- // Parse the connections
99
- for (let i = 0; i < gltf.nodes.length; i++) {
100
- const gltfBlock = gltf.nodes[i];
101
- // get the block that was created in the previous step
102
- const fgBlock = flowGraphJsonBlocks[i];
103
- const gltfFlows = gltfBlock.flows ?? [];
104
- // for each output flow of the gltf block
105
- for (const flow of gltfFlows) {
106
- const socketOutName = flow.id;
107
- // create an output connection for the flow graph block
108
- const socketOut = {
109
- uniqueId: RandomGUID(),
110
- name: socketOutName,
111
- _connectionType: 1 /* FlowGraphConnectionType.Output */, // Output
112
- connectedPointIds: [],
113
- };
114
- fgBlock.signalOutputs.push(socketOut);
115
- // get the input node of this flow
116
- const nodeInId = flow.node;
117
- const nodeInSocketName = flow.socket;
118
- // find the corresponding flow graph node
119
- const nodeIn = flowGraphJsonBlocks[nodeInId];
120
- if (!nodeIn) {
121
- throw new Error(`/extensions/KHR_interactivity/nodes/${i}: Could not find node with id ${nodeInId} that connects its input with with node ${i}'s output ${socketOutName}`);
122
- }
123
- // in all of the flow graph input connections, find the one with the same name as the socket
124
- let socketIn = nodeIn.signalInputs.find((s) => s.name === nodeInSocketName);
125
- // if the socket doesn't exist, create the input socket for the connection
126
- if (!socketIn) {
127
- socketIn = {
128
- uniqueId: RandomGUID(),
129
- name: nodeInSocketName,
130
- _connectionType: 0 /* FlowGraphConnectionType.Input */, // Input
131
- connectedPointIds: [],
132
- };
133
- nodeIn.signalInputs.push(socketIn);
134
- }
135
- // connect the sockets
136
- socketIn.connectedPointIds.push(socketOut.uniqueId);
137
- socketOut.connectedPointIds.push(socketIn.uniqueId);
138
- }
139
- // for each input value of the gltf block
140
- const gltfValues = gltfBlock.values ?? [];
141
- for (const value of gltfValues) {
142
- const socketInName = value.id;
143
- // create an input data connection for the flow graph block
144
- const socketIn = {
145
- uniqueId: RandomGUID(),
146
- name: socketInName,
147
- _connectionType: 0 /* FlowGraphConnectionType.Input */,
148
- connectedPointIds: [],
149
- };
150
- fgBlock.dataInputs.push(socketIn);
151
- if (value.value !== undefined) {
152
- // if the value is set on the socket itself, store it in the context
153
- const convertedValue = convertValueWithType(value, gltf, `/extensions/KHR_interactivity/nodes/${i}`);
154
- // convertBlockInputType(gltfBlock, value, convertedValue, `/extensions/KHR_interactivity/nodes/${i}`);
155
- context._connectionValues[socketIn.uniqueId] = convertedValue;
156
- }
157
- else if (value.node !== undefined && value.socket !== undefined) {
158
- // if the value is connected with the output data of another socket, connect the two
159
- const nodeOutId = value.node;
160
- const nodeOutSocketName = value.socket;
161
- // find the flow graph node that owns that output socket
162
- const nodeOut = flowGraphJsonBlocks[nodeOutId];
163
- if (!nodeOut) {
164
- throw new Error(`/extensions/KHR_interactivity/nodes/${i}: Could not find node with id ${nodeOutId} that connects its output with node${i}'s input ${socketInName}`);
165
- }
166
- let socketOut = nodeOut.dataOutputs.find((s) => s.name === nodeOutSocketName);
167
- // if the socket doesn't exist, create it
168
- if (!socketOut) {
169
- socketOut = {
170
- uniqueId: RandomGUID(),
171
- name: nodeOutSocketName,
172
- _connectionType: 1 /* FlowGraphConnectionType.Output */,
173
- connectedPointIds: [],
174
- };
175
- nodeOut.dataOutputs.push(socketOut);
176
- }
177
- // connect the sockets
178
- socketIn.connectedPointIds.push(socketOut.uniqueId);
179
- socketOut.connectedPointIds.push(socketIn.uniqueId);
180
- }
181
- else {
182
- throw new Error(`/extensions/KHR_interactivity/nodes/${i}: Invalid socket ${socketInName} in node ${i}`);
183
- }
184
- }
185
- }
186
- const variables = gltf.variables ?? [];
187
- // Parse variables
188
- for (let i = 0; i < variables.length; i++) {
189
- const variable = variables[i];
190
- const variableName = variable.id;
191
- context._userVariables[variableName] = convertValueWithType(variable, gltf, `/extensions/KHR_interactivity/variables/${i}`);
192
- }
193
- return {
194
- allBlocks: flowGraphJsonBlocks,
195
- executionContexts,
196
- };
197
- }
198
- //# sourceMappingURL=interactivityFunctions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"interactivityFunctions.js","sourceRoot":"","sources":["../../../../../../dev/loaders/src/glTF/2.0/Extensions/interactivityFunctions.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,qCAAuB;AAC5C,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAGrF,SAAS,oBAAoB,CAAC,YAA6C,EAAE,UAA6B,EAAE,OAAe;IACvH,IAAI,YAAY,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QAClC,sCAAsC;QACtC,MAAM,IAAI,GAAG,UAAU,CAAC,KAAK,IAAI,UAAU,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;QACrE,IAAI,CAAC,IAAI,EAAE,CAAC;YACR,MAAM,IAAI,KAAK,CAAC,GAAG,OAAO,mBAAmB,YAAY,CAAC,IAAI,EAAE,CAAC,CAAC;QACtE,CAAC;QACD,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;QACjC,IAAI,CAAC,SAAS,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,GAAG,OAAO,UAAU,YAAY,CAAC,IAAI,mBAAmB,CAAC,CAAC;QAC9E,CAAC;QACD,MAAM,aAAa,GAAG,qBAAqB,CAAC,SAAS,CAAC,CAAC;QACvD,OAAO;YACH,KAAK,EAAE,YAAY,CAAC,KAAK;YACzB,SAAS,EAAE,aAAa;SAC3B,CAAC;IACN,CAAC;SAAM,CAAC;QACJ,OAAO,YAAY,CAAC,KAAK,CAAC;IAC9B,CAAC;AACL,CAAC;AAED,SAAS,oBAAoB,CAAC,SAAiC,EAAE,UAA6B,EAAE,EAAU;IACtG,MAAM,SAAS,GAAiC,EAAE,CAAC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,IAAI,CAAC,SAAS,IAAI,EAAE,CAAC;IACvC,kBAAkB;IAClB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACxC,MAAM,QAAQ,GAA+B,SAAS,CAAC,CAAC,CAAC,CAAC;QAC1D,MAAM,YAAY,GAAG,QAAQ,CAAC,EAAE,CAAC;QACjC,OAAO,CAAC,cAAc,CAAC,YAAY,CAAC,GAAG,oBAAoB,CAAC,QAA2C,EAAE,IAAI,EAAE,2CAA2C,CAAC,EAAE,CAAC,CAAC;IACnK,CAAC;IAED,OAAO;QACH,SAAS,EAAE,mBAAmB;QAC9B,iBAAiB;KACpB,CAAC;AACN,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type { IKHRInteractivity, IKHRInteractivity_Configuration, IKHRInteractivity_Node, IKHRInteractivity_Variable } from \"babylonjs-gltf2interface\";\r\nimport type { IFlowGraphBlockConfiguration } from \"core/FlowGraph/flowGraphBlock\";\r\nimport type { ISerializedFlowGraph, ISerializedFlowGraphBlock, ISerializedFlowGraphConnection, ISerializedFlowGraphContext } from \"core/FlowGraph/typeDefinitions\";\r\nimport { RandomGUID } from \"core/Misc/guid\";\r\nimport { gltfToFlowGraphTypeMap, gltfTypeToBabylonType } from \"./interactivityUtils\";\r\nimport { FlowGraphConnectionType } from \"core/FlowGraph/flowGraphConnection\";\r\n\r\nfunction convertValueWithType(configObject: IKHRInteractivity_Configuration, definition: IKHRInteractivity, context: string) {\r\n if (configObject.type !== undefined) {\r\n // get the type on the gltf definition\r\n const type = definition.types && definition.types[configObject.type];\r\n if (!type) {\r\n throw new Error(`${context}: Unknown type: ${configObject.type}`);\r\n }\r\n const signature = type.signature;\r\n if (!signature) {\r\n throw new Error(`${context}: Type ${configObject.type} has no signature`);\r\n }\r\n const convertedType = gltfTypeToBabylonType[signature];\r\n return {\r\n value: configObject.value,\r\n className: convertedType,\r\n };\r\n } else {\r\n return configObject.value;\r\n }\r\n}\r\n\r\nfunction convertConfiguration(gltfBlock: IKHRInteractivity_Node, definition: IKHRInteractivity, id: string): IFlowGraphBlockConfiguration {\r\n const converted: IFlowGraphBlockConfiguration = {};\r\n const configurationList: IKHRInteractivity_Configuration[] = gltfBlock.configuration ?? [];\r\n for (const configObject of configurationList) {\r\n if (configObject.id === \"customEvent\") {\r\n const customEvent = definition.customEvents && definition.customEvents[configObject.value];\r\n if (!customEvent) {\r\n throw new Error(`/extensions/KHR_interactivity/nodes/${id}: Unknown custom event: ${configObject.value}`);\r\n }\r\n converted.eventId = customEvent.id;\r\n converted.eventData = customEvent.values.map((v) => v.id);\r\n } else if (configObject.id === \"variable\") {\r\n const variable = definition.variables && definition.variables[configObject.value];\r\n if (!variable) {\r\n throw new Error(`/extensions/KHR_interactivity/nodes/${id}: Unknown variable: ${configObject.value}`);\r\n }\r\n converted.variableName = variable.id;\r\n } else if (configObject.id === \"path\") {\r\n // Convert from a GLTF path to a reference to the Babylon.js object\r\n const pathValue = configObject.value as string;\r\n converted.path = pathValue;\r\n } else {\r\n converted[configObject.id] = convertValueWithType(configObject, definition, `/extensions/KHR_interactivity/nodes/${id}`);\r\n }\r\n }\r\n return converted;\r\n}\r\n\r\nfunction convertBlock(id: number, gltfBlock: IKHRInteractivity_Node, definition: IKHRInteractivity): ISerializedFlowGraphBlock {\r\n const className = gltfToFlowGraphTypeMap[gltfBlock.type];\r\n if (!className) {\r\n throw new Error(`/extensions/KHR_interactivity/nodes/${id}: Unknown block type: ${gltfBlock.type}`);\r\n }\r\n const uniqueId = id.toString();\r\n const config = convertConfiguration(gltfBlock, definition, uniqueId);\r\n const metadata = gltfBlock.metadata;\r\n const dataInputs: ISerializedFlowGraphConnection[] = [];\r\n const dataOutputs: ISerializedFlowGraphConnection[] = [];\r\n const signalInputs: ISerializedFlowGraphConnection[] = [];\r\n const signalOutputs: ISerializedFlowGraphConnection[] = [];\r\n return {\r\n className,\r\n config,\r\n uniqueId,\r\n metadata,\r\n dataInputs,\r\n dataOutputs,\r\n signalInputs,\r\n signalOutputs,\r\n };\r\n}\r\n\r\n/**\r\n * @internal\r\n * Converts a glTF Interactivity Extension to a serialized flow graph.\r\n * @param gltf the interactivity data\r\n * @returns a serialized flow graph\r\n */\r\nexport function convertGLTFToSerializedFlowGraph(gltf: IKHRInteractivity): ISerializedFlowGraph {\r\n // create an empty serialized context to store the values of the connections\r\n const context: ISerializedFlowGraphContext = {\r\n uniqueId: RandomGUID(),\r\n _userVariables: {},\r\n _connectionValues: {},\r\n };\r\n const executionContexts = [context];\r\n\r\n // Blocks converted to the flow graph json format\r\n const flowGraphJsonBlocks: ISerializedFlowGraphBlock[] = [];\r\n\r\n for (let i = 0; i < gltf.nodes.length; i++) {\r\n const gltfBlock = gltf.nodes[i];\r\n const flowGraphJsonBlock = convertBlock(i, gltfBlock, gltf);\r\n flowGraphJsonBlocks.push(flowGraphJsonBlock);\r\n }\r\n\r\n // Parse the connections\r\n for (let i = 0; i < gltf.nodes.length; i++) {\r\n const gltfBlock = gltf.nodes[i];\r\n // get the block that was created in the previous step\r\n const fgBlock = flowGraphJsonBlocks[i];\r\n const gltfFlows = gltfBlock.flows ?? [];\r\n // for each output flow of the gltf block\r\n for (const flow of gltfFlows) {\r\n const socketOutName = flow.id;\r\n // create an output connection for the flow graph block\r\n const socketOut: ISerializedFlowGraphConnection = {\r\n uniqueId: RandomGUID(),\r\n name: socketOutName,\r\n _connectionType: FlowGraphConnectionType.Output, // Output\r\n connectedPointIds: [],\r\n };\r\n fgBlock.signalOutputs.push(socketOut);\r\n // get the input node of this flow\r\n const nodeInId = flow.node;\r\n const nodeInSocketName = flow.socket;\r\n // find the corresponding flow graph node\r\n const nodeIn = flowGraphJsonBlocks[nodeInId];\r\n if (!nodeIn) {\r\n throw new Error(\r\n `/extensions/KHR_interactivity/nodes/${i}: Could not find node with id ${nodeInId} that connects its input with with node ${i}'s output ${socketOutName}`\r\n );\r\n }\r\n // in all of the flow graph input connections, find the one with the same name as the socket\r\n let socketIn = nodeIn.signalInputs.find((s) => s.name === nodeInSocketName);\r\n // if the socket doesn't exist, create the input socket for the connection\r\n if (!socketIn) {\r\n socketIn = {\r\n uniqueId: RandomGUID(),\r\n name: nodeInSocketName,\r\n _connectionType: FlowGraphConnectionType.Input, // Input\r\n connectedPointIds: [],\r\n };\r\n nodeIn.signalInputs.push(socketIn);\r\n }\r\n // connect the sockets\r\n socketIn.connectedPointIds.push(socketOut.uniqueId);\r\n socketOut.connectedPointIds.push(socketIn.uniqueId);\r\n }\r\n // for each input value of the gltf block\r\n const gltfValues = gltfBlock.values ?? [];\r\n for (const value of gltfValues) {\r\n const socketInName = value.id;\r\n // create an input data connection for the flow graph block\r\n const socketIn: ISerializedFlowGraphConnection = {\r\n uniqueId: RandomGUID(),\r\n name: socketInName,\r\n _connectionType: FlowGraphConnectionType.Input,\r\n connectedPointIds: [],\r\n };\r\n fgBlock.dataInputs.push(socketIn);\r\n if (value.value !== undefined) {\r\n // if the value is set on the socket itself, store it in the context\r\n const convertedValue = convertValueWithType(value as IKHRInteractivity_Configuration, gltf, `/extensions/KHR_interactivity/nodes/${i}`);\r\n // convertBlockInputType(gltfBlock, value, convertedValue, `/extensions/KHR_interactivity/nodes/${i}`);\r\n context._connectionValues[socketIn.uniqueId] = convertedValue;\r\n } else if (value.node !== undefined && value.socket !== undefined) {\r\n // if the value is connected with the output data of another socket, connect the two\r\n const nodeOutId = value.node;\r\n const nodeOutSocketName = value.socket;\r\n // find the flow graph node that owns that output socket\r\n const nodeOut = flowGraphJsonBlocks[nodeOutId];\r\n if (!nodeOut) {\r\n throw new Error(\r\n `/extensions/KHR_interactivity/nodes/${i}: Could not find node with id ${nodeOutId} that connects its output with node${i}'s input ${socketInName}`\r\n );\r\n }\r\n let socketOut = nodeOut.dataOutputs.find((s) => s.name === nodeOutSocketName);\r\n // if the socket doesn't exist, create it\r\n if (!socketOut) {\r\n socketOut = {\r\n uniqueId: RandomGUID(),\r\n name: nodeOutSocketName,\r\n _connectionType: FlowGraphConnectionType.Output,\r\n connectedPointIds: [],\r\n };\r\n nodeOut.dataOutputs.push(socketOut);\r\n }\r\n // connect the sockets\r\n socketIn.connectedPointIds.push(socketOut.uniqueId);\r\n socketOut.connectedPointIds.push(socketIn.uniqueId);\r\n } else {\r\n throw new Error(`/extensions/KHR_interactivity/nodes/${i}: Invalid socket ${socketInName} in node ${i}`);\r\n }\r\n }\r\n }\r\n\r\n const variables = gltf.variables ?? [];\r\n // Parse variables\r\n for (let i = 0; i < variables.length; i++) {\r\n const variable: IKHRInteractivity_Variable = variables[i];\r\n const variableName = variable.id;\r\n context._userVariables[variableName] = convertValueWithType(variable as IKHRInteractivity_Configuration, gltf, `/extensions/KHR_interactivity/variables/${i}`);\r\n }\r\n\r\n return {\r\n allBlocks: flowGraphJsonBlocks,\r\n executionContexts,\r\n };\r\n}\r\n"]}
@@ -1,9 +0,0 @@
1
- import type { IGLTF } from "../glTFLoaderInterfaces";
2
- import { GLTFPathToObjectConverter } from "./gltfPathToObjectConverter";
3
- import type { IObjectAccessor } from "@babylonjs/core/FlowGraph/typeDefinitions.js";
4
- /**
5
- * Class to convert an interactivity pointer path to a smart object
6
- */
7
- export declare class InteractivityPathToObjectConverter extends GLTFPathToObjectConverter<IObjectAccessor> {
8
- constructor(gltf: IGLTF);
9
- }
@@ -1,32 +0,0 @@
1
- import { GLTFPathToObjectConverter } from "./gltfPathToObjectConverter.js";
2
- /**
3
- * Class to convert an interactivity pointer path to a smart object
4
- */
5
- export class InteractivityPathToObjectConverter extends GLTFPathToObjectConverter {
6
- constructor(gltf) {
7
- super(gltf, gltfTree);
8
- }
9
- }
10
- const nodesTree = {
11
- __array__: {
12
- __target__: true,
13
- translation: {
14
- type: "Vector3",
15
- get: (node) => {
16
- const babylonObject = node._babylonTransformNode;
17
- return babylonObject.position;
18
- },
19
- set: (value, node) => {
20
- const babylonObject = node._babylonTransformNode;
21
- babylonObject.position = value;
22
- },
23
- getObject(node) {
24
- return node._babylonTransformNode;
25
- },
26
- },
27
- },
28
- };
29
- const gltfTree = {
30
- nodes: nodesTree,
31
- };
32
- //# sourceMappingURL=interactivityPathToObjectConverter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"interactivityPathToObjectConverter.js","sourceRoot":"","sources":["../../../../../../dev/loaders/src/glTF/2.0/Extensions/interactivityPathToObjectConverter.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAIxE;;GAEG;AACH,MAAM,OAAO,kCAAmC,SAAQ,yBAA0C;IAC9F,YAAmB,IAAW;QAC1B,KAAK,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IAC1B,CAAC;CACJ;AAED,MAAM,SAAS,GAAG;IACd,SAAS,EAAE;QACP,UAAU,EAAE,IAAI;QAChB,WAAW,EAAE;YACT,IAAI,EAAE,SAAS;YACf,GAAG,EAAE,CAAC,IAAW,EAAE,EAAE;gBACjB,MAAM,aAAa,GAAG,IAAI,CAAC,qBAAsC,CAAC;gBAClE,OAAO,aAAa,CAAC,QAAQ,CAAC;YAClC,CAAC;YACD,GAAG,EAAE,CAAC,KAAU,EAAE,IAAW,EAAE,EAAE;gBAC7B,MAAM,aAAa,GAAG,IAAI,CAAC,qBAAsC,CAAC;gBAClE,aAAa,CAAC,QAAQ,GAAG,KAAK,CAAC;YACnC,CAAC;YACD,SAAS,CAAC,IAAW;gBACjB,OAAO,IAAI,CAAC,qBAAqB,CAAC;YACtC,CAAC;SACJ;KACJ;CACJ,CAAC;AAEF,MAAM,QAAQ,GAAG;IACb,KAAK,EAAE,SAAS;CACnB,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type { IGLTF, INode } from \"../glTFLoaderInterfaces\";\r\nimport { GLTFPathToObjectConverter } from \"./gltfPathToObjectConverter\";\r\nimport type { TransformNode } from \"core/Meshes\";\r\nimport type { IObjectAccessor } from \"core/FlowGraph/typeDefinitions\";\r\n\r\n/**\r\n * Class to convert an interactivity pointer path to a smart object\r\n */\r\nexport class InteractivityPathToObjectConverter extends GLTFPathToObjectConverter<IObjectAccessor> {\r\n public constructor(gltf: IGLTF) {\r\n super(gltf, gltfTree);\r\n }\r\n}\r\n\r\nconst nodesTree = {\r\n __array__: {\r\n __target__: true,\r\n translation: {\r\n type: \"Vector3\",\r\n get: (node: INode) => {\r\n const babylonObject = node._babylonTransformNode as TransformNode;\r\n return babylonObject.position;\r\n },\r\n set: (value: any, node: INode) => {\r\n const babylonObject = node._babylonTransformNode as TransformNode;\r\n babylonObject.position = value;\r\n },\r\n getObject(node: INode) {\r\n return node._babylonTransformNode;\r\n },\r\n },\r\n },\r\n};\r\n\r\nconst gltfTree = {\r\n nodes: nodesTree,\r\n};\r\n"]}
@@ -1,4 +0,0 @@
1
- export declare const gltfToFlowGraphTypeMap: {
2
- [key: string]: string;
3
- };
4
- export declare const gltfTypeToBabylonType: any;
@@ -1,108 +0,0 @@
1
- /* eslint-disable @typescript-eslint/naming-convention */
2
- import { FlowGraphSceneReadyEventBlock } from "@babylonjs/core/FlowGraph/Blocks/Event/flowGraphSceneReadyEventBlock.js";
3
- import { FlowGraphSceneTickEventBlock } from "@babylonjs/core/FlowGraph/Blocks/Event/flowGraphSceneTickEventBlock.js";
4
- import { FlowGraphConsoleLogBlock } from "@babylonjs/core/FlowGraph/Blocks/Execution/flowGraphConsoleLogBlock.js";
5
- import { FlowGraphTimerBlock } from "@babylonjs/core/FlowGraph/Blocks/Execution/ControlFlow/flowGraphTimerBlock.js";
6
- import { FlowGraphSendCustomEventBlock } from "@babylonjs/core/FlowGraph/Blocks/Execution/flowGraphSendCustomEventBlock.js";
7
- import { FlowGraphReceiveCustomEventBlock } from "@babylonjs/core/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.js";
8
- import { FlowGraphSequenceBlock } from "@babylonjs/core/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSequenceBlock.js";
9
- import { FlowGraphGetPropertyBlock } from "@babylonjs/core/FlowGraph/Blocks/Data/flowGraphGetPropertyBlock.js";
10
- import { FlowGraphSetPropertyBlock } from "@babylonjs/core/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.js";
11
- import { FlowGraphAddBlock, FlowGraphRandomBlock, FlowGraphLessThanBlock, FlowGraphMultiplyBlock, FlowGraphSubtractBlock, FlowGraphDotBlock, FlowGraphEBlock, FlowGraphPiBlock, FlowGraphInfBlock, FlowGraphNaNBlock, FlowGraphAbsBlock, FlowGraphSignBlock, FlowGraphTruncBlock, FlowGraphFloorBlock, FlowGraphCeilBlock, FlowGraphFractBlock, FlowGraphNegBlock, FlowGraphDivideBlock, FlowGraphRemainderBlock, FlowGraphMinBlock, FlowGraphMaxBlock, FlowGraphClampBlock, FlowGraphSaturateBlock, FlowGraphInterpolateBlock, FlowGraphEqBlock, FlowGraphLessThanOrEqualBlock, FlowGraphGreaterThanBlock, FlowGraphGreaterThanOrEqualBlock, FlowGraphIsNanBlock, FlowGraphIsInfBlock, FlowGraphDegToRadBlock, FlowGraphRadToDegBlock, FlowGraphSinBlock, FlowGraphCosBlock, FlowGraphTanBlock, FlowGraphAsinBlock, FlowGraphAcosBlock, FlowGraphAtanBlock, FlowGraphAtan2Block, FlowGraphSinhBlock, FlowGraphCoshBlock, FlowGraphTanhBlock, FlowGraphAsinhBlock, FlowGraphAcoshBlock, FlowGraphAtanhBlock, FlowGraphExpBlock, FlowGraphLog2Block, FlowGraphLogBlock, FlowGraphLog10Block, FlowGraphSqrtBlock, FlowGraphCubeRootBlock, FlowGraphPowBlock, FlowGraphLengthBlock, FlowGraphNormalizeBlock, FlowGraphCrossBlock, FlowGraphRotate2DBlock, FlowGraphRotate3DBlock, FlowGraphTransposeBlock, FlowGraphDeterminantBlock, FlowGraphInvertMatrixBlock, FlowGraphMatMulBlock, FlowGraphBitwiseNotBlock, FlowGraphBitwiseAndBlock, FlowGraphBitwiseOrBlock, FlowGraphBitwiseXorBlock, FlowGraphBitwiseRightShiftBlock, FlowGraphBitwiseLeftShiftBlock, FlowGraphCountLeadingZerosBlock, FlowGraphCountTrailingZerosBlock, FlowGraphCountOneBitsBlock, } from "@babylonjs/core/FlowGraph/Blocks/Data/Math/flowGraphMathBlocks.js";
12
- import { FlowGraphDoNBlock } from "@babylonjs/core/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDoNBlock.js";
13
- import { FlowGraphGetVariableBlock } from "@babylonjs/core/FlowGraph/Blocks/Data/flowGraphGetVariableBlock.js";
14
- import { FlowGraphSetVariableBlock } from "@babylonjs/core/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock.js";
15
- import { FlowGraphWhileLoopBlock } from "@babylonjs/core/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWhileLoopBlock.js";
16
- export const gltfToFlowGraphTypeMap = {
17
- "lifecycle/onStart": FlowGraphSceneReadyEventBlock.ClassName,
18
- "lifecycle/onTick": FlowGraphSceneTickEventBlock.ClassName,
19
- log: FlowGraphConsoleLogBlock.ClassName,
20
- "flow/delay": FlowGraphTimerBlock.ClassName,
21
- "customEvent/send": FlowGraphSendCustomEventBlock.ClassName,
22
- "customEvent/receive": FlowGraphReceiveCustomEventBlock.ClassName,
23
- "flow/sequence": FlowGraphSequenceBlock.ClassName,
24
- "world/get": FlowGraphGetPropertyBlock.ClassName,
25
- "world/set": FlowGraphSetPropertyBlock.ClassName,
26
- "flow/doN": FlowGraphDoNBlock.ClassName,
27
- "variable/get": FlowGraphGetVariableBlock.ClassName,
28
- "variable/set": FlowGraphSetVariableBlock.ClassName,
29
- "flow/whileLoop": FlowGraphWhileLoopBlock.ClassName,
30
- "math/random": FlowGraphRandomBlock.ClassName,
31
- "math/e": FlowGraphEBlock.ClassName,
32
- "math/pi": FlowGraphPiBlock.ClassName,
33
- "math/inf": FlowGraphInfBlock.ClassName,
34
- "math/nan": FlowGraphNaNBlock.ClassName,
35
- "math/abs": FlowGraphAbsBlock.ClassName,
36
- "math/sign": FlowGraphSignBlock.ClassName,
37
- "math/trunc": FlowGraphTruncBlock.ClassName,
38
- "math/floor": FlowGraphFloorBlock.ClassName,
39
- "math/ceil": FlowGraphCeilBlock.ClassName,
40
- "math/fract": FlowGraphFractBlock.ClassName,
41
- "math/neg": FlowGraphNegBlock.ClassName,
42
- "math/add": FlowGraphAddBlock.ClassName,
43
- "math/sub": FlowGraphSubtractBlock.ClassName,
44
- "math/mul": FlowGraphMultiplyBlock.ClassName,
45
- "math/div": FlowGraphDivideBlock.ClassName,
46
- "math/rem": FlowGraphRemainderBlock.ClassName,
47
- "math/min": FlowGraphMinBlock.ClassName,
48
- "math/max": FlowGraphMaxBlock.ClassName,
49
- "math/clamp": FlowGraphClampBlock.ClassName,
50
- "math/saturate": FlowGraphSaturateBlock.ClassName,
51
- "math/mix": FlowGraphInterpolateBlock.ClassName,
52
- "math/eq": FlowGraphEqBlock.ClassName,
53
- "math/lt": FlowGraphLessThanBlock.ClassName,
54
- "math/le": FlowGraphLessThanOrEqualBlock.ClassName,
55
- "math/gt": FlowGraphGreaterThanBlock.ClassName,
56
- "math/ge": FlowGraphGreaterThanOrEqualBlock.ClassName,
57
- "math/isnan": FlowGraphIsNanBlock.ClassName,
58
- "math/isinf": FlowGraphIsInfBlock.ClassName,
59
- "math/rad": FlowGraphDegToRadBlock.ClassName,
60
- "math/deg": FlowGraphRadToDegBlock.ClassName,
61
- "math/sin": FlowGraphSinBlock.ClassName,
62
- "math/cos": FlowGraphCosBlock.ClassName,
63
- "math/tan": FlowGraphTanBlock.ClassName,
64
- "math/asin": FlowGraphAsinBlock.ClassName,
65
- "math/acos": FlowGraphAcosBlock.ClassName,
66
- "math/atan": FlowGraphAtanBlock.ClassName,
67
- "math/atan2": FlowGraphAtan2Block.ClassName,
68
- "math/sinh": FlowGraphSinhBlock.ClassName,
69
- "math/cosh": FlowGraphCoshBlock.ClassName,
70
- "math/tanh": FlowGraphTanhBlock.ClassName,
71
- "math/asinh": FlowGraphAsinhBlock.ClassName,
72
- "math/acosh": FlowGraphAcoshBlock.ClassName,
73
- "math/atanh": FlowGraphAtanhBlock.ClassName,
74
- "math/exp": FlowGraphExpBlock.ClassName,
75
- "math/log": FlowGraphLogBlock.ClassName,
76
- "math/log2": FlowGraphLog2Block.ClassName,
77
- "math/log10": FlowGraphLog10Block.ClassName,
78
- "math/sqrt": FlowGraphSqrtBlock.ClassName,
79
- "math/cbrt": FlowGraphCubeRootBlock.ClassName,
80
- "math/pow": FlowGraphPowBlock.ClassName,
81
- "math/length": FlowGraphLengthBlock.ClassName,
82
- "math/normalize": FlowGraphNormalizeBlock.ClassName,
83
- "math/dot": FlowGraphDotBlock.ClassName,
84
- "math/cross": FlowGraphCrossBlock.ClassName,
85
- "math/rotate2d": FlowGraphRotate2DBlock.ClassName,
86
- "math/rotate3d": FlowGraphRotate3DBlock.ClassName,
87
- "math/transpose": FlowGraphTransposeBlock.ClassName,
88
- "math/determinant": FlowGraphDeterminantBlock.ClassName,
89
- "math/inverse": FlowGraphInvertMatrixBlock.ClassName,
90
- "math/matmul": FlowGraphMatMulBlock.ClassName,
91
- "math/not": FlowGraphBitwiseNotBlock.ClassName,
92
- "math/and": FlowGraphBitwiseAndBlock.ClassName,
93
- "math/or": FlowGraphBitwiseOrBlock.ClassName,
94
- "math/xor": FlowGraphBitwiseXorBlock.ClassName,
95
- "math/asr": FlowGraphBitwiseRightShiftBlock.ClassName,
96
- "math/lsl": FlowGraphBitwiseLeftShiftBlock.ClassName,
97
- "math/clz": FlowGraphCountLeadingZerosBlock.ClassName,
98
- "math/ctz": FlowGraphCountTrailingZerosBlock.ClassName,
99
- "math/popcnt": FlowGraphCountOneBitsBlock.ClassName,
100
- };
101
- export const gltfTypeToBabylonType = {
102
- float2: "Vector2",
103
- float3: "Vector3",
104
- float4: "Vector4",
105
- float4x4: "Matrix",
106
- int: "FlowGraphInteger",
107
- };
108
- //# sourceMappingURL=interactivityUtils.js.map