@babylonjs/loaders 6.36.1 → 6.37.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (30) hide show
  1. package/glTF/2.0/Extensions/KHR_animation_pointer.d.ts +1 -18
  2. package/glTF/2.0/Extensions/KHR_animation_pointer.js +18 -55
  3. package/glTF/2.0/Extensions/KHR_animation_pointer.js.map +1 -1
  4. package/glTF/2.0/Extensions/KHR_interactivity.d.ts +1 -0
  5. package/glTF/2.0/Extensions/KHR_interactivity.js +7 -14
  6. package/glTF/2.0/Extensions/KHR_interactivity.js.map +1 -1
  7. package/glTF/2.0/Extensions/gltfPathToObjectConverter.d.ts +31 -0
  8. package/glTF/2.0/Extensions/gltfPathToObjectConverter.js +62 -0
  9. package/glTF/2.0/Extensions/gltfPathToObjectConverter.js.map +1 -0
  10. package/glTF/2.0/Extensions/interactivityFunctions.js +1 -4
  11. package/glTF/2.0/Extensions/interactivityFunctions.js.map +1 -1
  12. package/glTF/2.0/Extensions/interactivityPathToObjectConverter.d.ts +9 -0
  13. package/glTF/2.0/Extensions/interactivityPathToObjectConverter.js +32 -0
  14. package/glTF/2.0/Extensions/interactivityPathToObjectConverter.js.map +1 -0
  15. package/glTF/2.0/glTFLoader.d.ts +2 -1
  16. package/glTF/2.0/glTFLoader.js +12 -10
  17. package/glTF/2.0/glTFLoader.js.map +1 -1
  18. package/package.json +3 -3
  19. package/glTF/2.0/Extensions/interactivityPathCameraExtensions.d.ts +0 -7
  20. package/glTF/2.0/Extensions/interactivityPathCameraExtensions.js +0 -77
  21. package/glTF/2.0/Extensions/interactivityPathCameraExtensions.js.map +0 -1
  22. package/glTF/2.0/Extensions/interactivityPathExtensions.d.ts +0 -2
  23. package/glTF/2.0/Extensions/interactivityPathExtensions.js +0 -5
  24. package/glTF/2.0/Extensions/interactivityPathExtensions.js.map +0 -1
  25. package/glTF/2.0/Extensions/interactivityPathMaterialExtensions.d.ts +0 -7
  26. package/glTF/2.0/Extensions/interactivityPathMaterialExtensions.js +0 -87
  27. package/glTF/2.0/Extensions/interactivityPathMaterialExtensions.js.map +0 -1
  28. package/glTF/2.0/Extensions/interactivityPathTransformNodeExtensions.d.ts +0 -2
  29. package/glTF/2.0/Extensions/interactivityPathTransformNodeExtensions.js +0 -50
  30. package/glTF/2.0/Extensions/interactivityPathTransformNodeExtensions.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@babylonjs/loaders",
3
- "version": "6.36.1",
3
+ "version": "6.37.0",
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": "^6.36.1",
21
+ "@babylonjs/core": "^6.37.0",
22
22
  "@dev/build-tools": "^1.0.0",
23
23
  "@lts/loaders": "^1.0.0",
24
- "babylonjs-gltf2interface": "^6.36.1"
24
+ "babylonjs-gltf2interface": "^6.37.0"
25
25
  },
26
26
  "peerDependencies": {
27
27
  "@babylonjs/core": "^6.0.0",
@@ -1,7 +0,0 @@
1
- import type { FlowGraphPath } from "@babylonjs/core/FlowGraph/flowGraphPath.js";
2
- import type { FlowGraphContext } from "@babylonjs/core/FlowGraph/flowGraphContext.js";
3
- export declare const camerasExtension: {
4
- shouldProcess(path: FlowGraphPath): boolean;
5
- processGet(path: FlowGraphPath, context: FlowGraphContext): any;
6
- processSet(path: FlowGraphPath, context: FlowGraphContext, value: any): void;
7
- };
@@ -1,77 +0,0 @@
1
- import { Tools } from "@babylonjs/core/Misc/tools.js";
2
- const camerasRegex = /^\/cameras\/(\d+)\/(orthographic|perspective)\/(xmag|ymag|zfar|znear|aspectRatio|yfov)$/;
3
- function getBabylonCamera(path, context) {
4
- const fullPath = path.getFinalPath();
5
- const gltfTree = context.getVariable("gltf");
6
- if (!gltfTree) {
7
- throw new Error(`No glTF tree found for path ${fullPath}`);
8
- }
9
- const matches = fullPath.match(camerasRegex);
10
- if (!matches || matches.length !== 4) {
11
- throw new Error(`Invalid path ${fullPath}`);
12
- }
13
- const cameraIndex = parseInt(matches[1]);
14
- const camera = gltfTree.cameras && gltfTree.cameras[cameraIndex];
15
- if (!camera) {
16
- throw new Error(`Invalid camera index for path ${fullPath}`);
17
- }
18
- const babylonCamera = camera._babylonCamera;
19
- if (!babylonCamera) {
20
- throw new Error(`No Babylon camera found for path ${fullPath}`);
21
- }
22
- const gltfProperty = matches[3];
23
- if (!gltfProperty) {
24
- throw new Error(`Invalid property for path ${fullPath}`);
25
- }
26
- return { babylonCamera, gltfProperty };
27
- }
28
- export const camerasExtension = {
29
- shouldProcess(path) {
30
- const fullPath = path.getFinalPath();
31
- return !!fullPath.match(camerasRegex);
32
- },
33
- processGet(path, context) {
34
- const { babylonCamera, gltfProperty } = getBabylonCamera(path, context);
35
- switch (gltfProperty) {
36
- case "aspectRatio":
37
- Tools.Warn("Getting aspect ratio is not supported.");
38
- return -1;
39
- case "zNear":
40
- return babylonCamera.minZ;
41
- case "zFar":
42
- return babylonCamera.maxZ;
43
- case "yfov":
44
- return babylonCamera.fov;
45
- case "xmag":
46
- return babylonCamera.orthoRight;
47
- case "ymag":
48
- return babylonCamera.orthoTop;
49
- }
50
- },
51
- processSet(path, context, value) {
52
- const { babylonCamera, gltfProperty } = getBabylonCamera(path, context);
53
- switch (gltfProperty) {
54
- case "aspectRatio":
55
- Tools.Warn("Setting aspect ratio is not supported.");
56
- break;
57
- case "zNear":
58
- babylonCamera.minZ = value;
59
- break;
60
- case "zFar":
61
- babylonCamera.maxZ = value;
62
- break;
63
- case "yfov":
64
- babylonCamera.fov = value;
65
- break;
66
- case "xmag":
67
- babylonCamera.orthoLeft = -value;
68
- babylonCamera.orthoRight = value;
69
- break;
70
- case "ymag":
71
- babylonCamera.orthoTop = value;
72
- babylonCamera.orthoBottom = -value;
73
- break;
74
- }
75
- },
76
- };
77
- //# sourceMappingURL=interactivityPathCameraExtensions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"interactivityP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G,KAAK,CAAC;gBAC1B,MAAM;YACV,KAAK,MAAM;gBACP,aAAa,CAAC,SAAS,GAAG,CAAC,KAAK,CAAC;gBACjC,aAAa,CAAC,UAAU,GAAG,KAAK,CAAC;gBACjC,MAAM;YACV,KAAK,MAAM;gBACP,aAAa,CAAC,QAAQ,GAAG,KAAK,CAAC;gBAC/B,aAAa,CAAC,WAAW,GAAG,CAAC,KAAK,CAAC;gBACnC,MAAM;SACb;IACL,CAAC;CACJ,CAAC","sourcesContent":["import type { Camera } from \"core/Cameras/camera\";\r\nimport type { FlowGraphPath } from \"core/FlowGraph/flowGraphPath\";\r\nimport type { FlowGraphContext } from \"core/FlowGraph/flowGraphContext\";\r\nimport { Tools } from \"core/Misc/tools\";\r\nimport type { IGLTF } from \"../glTFLoaderInterfaces\";\r\n\r\nconst camerasRegex = /^\\/cameras\\/(\\d+)\\/(orthographic|perspective)\\/(xmag|ymag|zfar|znear|aspectRatio|yfov)$/;\r\n\r\nfunction getBabylonCamera(path: FlowGraphPath, context: FlowGraphContext): { babylonCamera: Camera; gltfProperty: string } {\r\n const fullPath = path.getFinalPath();\r\n const gltfTree = context.getVariable(\"gltf\") as IGLTF;\r\n if (!gltfTree) {\r\n throw new Error(`No glTF tree found for path ${fullPath}`);\r\n }\r\n const matches = fullPath.match(camerasRegex);\r\n if (!matches || matches.length !== 4) {\r\n throw new Error(`Invalid path ${fullPath}`);\r\n }\r\n const cameraIndex = parseInt(matches[1]);\r\n const camera = gltfTree.cameras && gltfTree.cameras[cameraIndex];\r\n if (!camera) {\r\n throw new Error(`Invalid camera index for path ${fullPath}`);\r\n }\r\n const babylonCamera = camera._babylonCamera;\r\n if (!babylonCamera) {\r\n throw new Error(`No Babylon camera found for path ${fullPath}`);\r\n }\r\n const gltfProperty = matches[3];\r\n if (!gltfProperty) {\r\n throw new Error(`Invalid property for path ${fullPath}`);\r\n }\r\n\r\n return { babylonCamera, gltfProperty };\r\n}\r\n\r\nexport const camerasExtension = {\r\n shouldProcess(path: FlowGraphPath): boolean {\r\n const fullPath = path.getFinalPath();\r\n return !!fullPath.match(camerasRegex);\r\n },\r\n processGet(path: FlowGraphPath, context: FlowGraphContext): any {\r\n const { babylonCamera, gltfProperty } = getBabylonCamera(path, context);\r\n switch (gltfProperty) {\r\n case \"aspectRatio\":\r\n Tools.Warn(\"Getting aspect ratio is not supported.\");\r\n return -1;\r\n case \"zNear\":\r\n return babylonCamera.minZ;\r\n case \"zFar\":\r\n return babylonCamera.maxZ;\r\n case \"yfov\":\r\n return babylonCamera.fov;\r\n case \"xmag\":\r\n return babylonCamera.orthoRight;\r\n case \"ymag\":\r\n return babylonCamera.orthoTop;\r\n }\r\n },\r\n processSet(path: FlowGraphPath, context: FlowGraphContext, value: any) {\r\n const { babylonCamera, gltfProperty } = getBabylonCamera(path, context);\r\n switch (gltfProperty) {\r\n case \"aspectRatio\":\r\n Tools.Warn(\"Setting aspect ratio is not supported.\");\r\n break;\r\n case \"zNear\":\r\n babylonCamera.minZ = value;\r\n break;\r\n case \"zFar\":\r\n babylonCamera.maxZ = value;\r\n break;\r\n case \"yfov\":\r\n babylonCamera.fov = value;\r\n break;\r\n case \"xmag\":\r\n babylonCamera.orthoLeft = -value;\r\n babylonCamera.orthoRight = value;\r\n break;\r\n case \"ymag\":\r\n babylonCamera.orthoTop = value;\r\n babylonCamera.orthoBottom = -value;\r\n break;\r\n }\r\n },\r\n};\r\n"]}
@@ -1,2 +0,0 @@
1
- import type { IPathExtension } from "@babylonjs/core/FlowGraph/flowGraphPath.js";
2
- export declare const interactivityPathExensions: IPathExtension[];
@@ -1,5 +0,0 @@
1
- import { transformNodeExtension } from "./interactivityPathTransformNodeExtensions.js";
2
- import { pbrMaterialExtension } from "./interactivityPathMaterialExtensions.js";
3
- import { camerasExtension } from "./interactivityPathCameraExtensions.js";
4
- export const interactivityPathExensions = [transformNodeExtension, pbrMaterialExtension, camerasExtension];
5
- //# sourceMappingURL=interactivityPathExtensions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"interactivityPathExtensions.js","sourceRoot":"","sources":["../../../../../../dev/loaders/src/glTF/2.0/Extensions/interactivityPathExtensions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,4CAA4C,CAAC;AACpF,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AAEvE,MAAM,CAAC,MAAM,0BAA0B,GAAqB,CAAC,sBAAsB,EAAE,oBAAoB,EAAE,gBAAgB,CAAC,CAAC","sourcesContent":["import type { IPathExtension } from \"core/FlowGraph/flowGraphPath\";\r\nimport { transformNodeExtension } from \"./interactivityPathTransformNodeExtensions\";\r\nimport { pbrMaterialExtension } from \"./interactivityPathMaterialExtensions\";\r\nimport { camerasExtension } from \"./interactivityPathCameraExtensions\";\r\n\r\nexport const interactivityPathExensions: IPathExtension[] = [transformNodeExtension, pbrMaterialExtension, camerasExtension];\r\n"]}
@@ -1,7 +0,0 @@
1
- import type { FlowGraphPath } from "@babylonjs/core/FlowGraph/flowGraphPath.js";
2
- import type { FlowGraphContext } from "@babylonjs/core/FlowGraph/flowGraphContext.js";
3
- export declare const pbrMaterialExtension: {
4
- shouldProcess(path: FlowGraphPath): boolean;
5
- processGet(path: FlowGraphPath, context: FlowGraphContext): any;
6
- processSet(path: FlowGraphPath, context: FlowGraphContext, value: any): void;
7
- };
@@ -1,87 +0,0 @@
1
- import { Color3 } from "@babylonjs/core/Maths/math.color.js";
2
- const materialsRegex = /^\/materials\/(\d+)\/(pbrMetallicRoughness\/baseColorFactor|pbrMetallicRoughness\/metallicFactor|pbrMetallicRoughness\/roughnessFactor|alphaCutoff|emissiveFactor|normalTexture\/scale|emissiveTexture\/strength)$/;
3
- const gltfPbrMaterialPropertyToBabylonPropertyMap = {
4
- "pbrMetallicRoughness/baseColorFactor": "albedoColor",
5
- "pbrMetallicRoughness/metallicFactor": "metallic",
6
- "pbrMetallicRoughness/roughnessFactor": "roughness",
7
- emissiveFactor: "emissiveColor",
8
- };
9
- function getBabylonMaterial(path, context) {
10
- var _a;
11
- const fullPath = path.getFinalPath();
12
- const gltfTree = context.getVariable("gltf");
13
- if (!gltfTree) {
14
- throw new Error(`No glTF tree found for path ${fullPath}`);
15
- }
16
- const matches = fullPath.match(materialsRegex);
17
- if (!matches || matches.length !== 3) {
18
- throw new Error(`Invalid path ${fullPath}`);
19
- }
20
- const materialIndex = parseInt(matches[1]);
21
- const material = gltfTree.materials && gltfTree.materials[materialIndex];
22
- if (!material) {
23
- throw new Error(`Invalid material index for path ${fullPath}`);
24
- }
25
- const babylonMaterials = [];
26
- if (!material._data) {
27
- throw new Error(`No Babylon materials found for path ${fullPath}`);
28
- }
29
- for (const data of Object.keys(material._data)) {
30
- const babylonMaterial = material._data[parseInt(data)].babylonMaterial;
31
- if (babylonMaterial) {
32
- babylonMaterials.push(babylonMaterial);
33
- }
34
- }
35
- if (!babylonMaterials || babylonMaterials.length === 0) {
36
- throw new Error(`No Babylon materials found for path ${fullPath}`);
37
- }
38
- const property = matches[2];
39
- if (!property) {
40
- throw new Error(`Invalid property for path ${fullPath}`);
41
- }
42
- const babylonProperty = (_a = gltfPbrMaterialPropertyToBabylonPropertyMap[property]) !== null && _a !== void 0 ? _a : property;
43
- return { babylonMaterials, babylonProperty };
44
- }
45
- export const pbrMaterialExtension = {
46
- shouldProcess(path) {
47
- const fullPath = path.getFinalPath();
48
- return !!fullPath.match(materialsRegex);
49
- },
50
- processGet(path, context) {
51
- var _a, _b;
52
- const { babylonMaterials, babylonProperty } = getBabylonMaterial(path, context);
53
- /* The difference between the materials is only the drawMode, so we can return the
54
- property of the first one*/
55
- if (babylonProperty === "normalTexture/scale") {
56
- const firstMat = babylonMaterials[0];
57
- return (_a = firstMat.bumpTexture) === null || _a === void 0 ? void 0 : _a.uScale;
58
- }
59
- else if (babylonProperty === "emissiveTexture/strength") {
60
- const firstMat = babylonMaterials[0];
61
- return (_b = firstMat.emissiveTexture) === null || _b === void 0 ? void 0 : _b.level;
62
- }
63
- else {
64
- return babylonMaterials[0][babylonProperty];
65
- }
66
- },
67
- processSet(path, context, value) {
68
- const { babylonMaterials, babylonProperty } = getBabylonMaterial(path, context);
69
- for (const material of babylonMaterials) {
70
- if (babylonProperty === "normalTexture/scale") {
71
- material.bumpTexture.uScale = value;
72
- material.bumpTexture.vScale = value;
73
- }
74
- else if (babylonProperty === "emissiveTexture/strength") {
75
- material.emissiveTexture.level = value;
76
- }
77
- else {
78
- let finalValue = value;
79
- if (babylonProperty === "albedoColor" || babylonProperty === "emissiveColor") {
80
- finalValue = new Color3(value.x, value.y, value.z);
81
- }
82
- material[babylonProperty] = finalValue;
83
- }
84
- }
85
- },
86
- };
87
- //# sourceMappingURL=interactivityPathMaterialExtensions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"interactivityPathMaterialExtensions.js","sourceRoot":"","sources":["../../../../../../dev/loaders/src/glTF/2.0/Extensions/interactivityPathMaterialExtensions.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,4CAA8B;AAG/C,MAAM,cAAc,GAChB,oNAAoN,CAAC;AAEzN,MAAM,2CAA2C,GAA8B;IAC3E,sCAAsC,EAAE,aAAa;IACrD,qCAAqC,EAAE,UAAU;IACjD,sCAAsC,EAAE,WAAW;IACnD,cAAc,EAAE,eAAe;CAClC,CAAC;AAEF,SAAS,kBAAkB,CAAC,IAAmB,EAAE,OAAyB;;IACtE,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;IACrC,MAAM,QAAQ,GAAG,OAAO,CAAC,WAAW,CAAC,MAAM,CAAU,CAAC;IACtD,IAAI,CAAC,QAAQ,EAAE;QACX,MAAM,IAAI,KAAK,CAAC,+BAA+B,QAAQ,EAAE,CAAC,CAAC;KAC9D;IACD,MAAM,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;IAC/C,IAAI,CAAC,OAAO,I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,IAAI,UAAU,GAAG,KAAK,CAAC;gBACvB,IAAI,eAAe,KAAK,aAAa,IAAI,eAAe,KAAK,eAAe,EAAE;oBAC1E,UAAU,GAAG,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;iBACtD;gBACA,QAAgB,CAAC,eAAe,CAAC,GAAG,UAAU,CAAC;aACnD;SACJ;IACL,CAAC;CACJ,CAAC","sourcesContent":["import type { FlowGraphPath } from \"core/FlowGraph/flowGraphPath\";\r\nimport type { FlowGraphContext } from \"core/FlowGraph/flowGraphContext\";\r\nimport type { PBRMaterial } from \"core/Materials/PBR/pbrMaterial\";\r\nimport type { Texture } from \"core/Materials/Textures/texture\";\r\nimport { Color3 } from \"core/Maths/math.color\";\r\nimport type { IGLTF } from \"../glTFLoaderInterfaces\";\r\n\r\nconst materialsRegex =\r\n /^\\/materials\\/(\\d+)\\/(pbrMetallicRoughness\\/baseColorFactor|pbrMetallicRoughness\\/metallicFactor|pbrMetallicRoughness\\/roughnessFactor|alphaCutoff|emissiveFactor|normalTexture\\/scale|emissiveTexture\\/strength)$/;\r\n\r\nconst gltfPbrMaterialPropertyToBabylonPropertyMap: { [key: string]: string } = {\r\n \"pbrMetallicRoughness/baseColorFactor\": \"albedoColor\",\r\n \"pbrMetallicRoughness/metallicFactor\": \"metallic\",\r\n \"pbrMetallicRoughness/roughnessFactor\": \"roughness\",\r\n emissiveFactor: \"emissiveColor\",\r\n};\r\n\r\nfunction getBabylonMaterial(path: FlowGraphPath, context: FlowGraphContext) {\r\n const fullPath = path.getFinalPath();\r\n const gltfTree = context.getVariable(\"gltf\") as IGLTF;\r\n if (!gltfTree) {\r\n throw new Error(`No glTF tree found for path ${fullPath}`);\r\n }\r\n const matches = fullPath.match(materialsRegex);\r\n if (!matches || matches.length !== 3) {\r\n throw new Error(`Invalid path ${fullPath}`);\r\n }\r\n const materialIndex = parseInt(matches[1]);\r\n const material = gltfTree.materials && gltfTree.materials[materialIndex];\r\n if (!material) {\r\n throw new Error(`Invalid material index for path ${fullPath}`);\r\n }\r\n const babylonMaterials = [];\r\n if (!material._data) {\r\n throw new Error(`No Babylon materials found for path ${fullPath}`);\r\n }\r\n for (const data of Object.keys(material._data)) {\r\n const babylonMaterial = material._data[parseInt(data)].babylonMaterial as PBRMaterial;\r\n if (babylonMaterial) {\r\n babylonMaterials.push(babylonMaterial);\r\n }\r\n }\r\n if (!babylonMaterials || babylonMaterials.length === 0) {\r\n throw new Error(`No Babylon materials found for path ${fullPath}`);\r\n }\r\n const property = matches[2];\r\n if (!property) {\r\n throw new Error(`Invalid property for path ${fullPath}`);\r\n }\r\n const babylonProperty = gltfPbrMaterialPropertyToBabylonPropertyMap[property] ?? property;\r\n return { babylonMaterials, babylonProperty };\r\n}\r\n\r\nexport const pbrMaterialExtension = {\r\n shouldProcess(path: FlowGraphPath): boolean {\r\n const fullPath = path.getFinalPath();\r\n return !!fullPath.match(materialsRegex);\r\n },\r\n processGet(path: FlowGraphPath, context: FlowGraphContext): any {\r\n const { babylonMaterials, babylonProperty } = getBabylonMaterial(path, context);\r\n /* The difference between the materials is only the drawMode, so we can return the\r\n property of the first one*/\r\n if (babylonProperty === \"normalTexture/scale\") {\r\n const firstMat = babylonMaterials[0];\r\n return (firstMat.bumpTexture as Texture)?.uScale;\r\n } else if (babylonProperty === \"emissiveTexture/strength\") {\r\n const firstMat = babylonMaterials[0];\r\n return firstMat.emissiveTexture?.level;\r\n } else {\r\n return (babylonMaterials[0] as any)[babylonProperty];\r\n }\r\n },\r\n processSet(path: FlowGraphPath, context: FlowGraphContext, value: any) {\r\n const { babylonMaterials, babylonProperty } = getBabylonMaterial(path, context);\r\n for (const material of babylonMaterials) {\r\n if (babylonProperty === \"normalTexture/scale\") {\r\n (material.bumpTexture as Texture).uScale = value;\r\n (material.bumpTexture as Texture).vScale = value;\r\n } else if (babylonProperty === \"emissiveTexture/strength\") {\r\n material.emissiveTexture!.level = value;\r\n } else {\r\n let finalValue = value;\r\n if (babylonProperty === \"albedoColor\" || babylonProperty === \"emissiveColor\") {\r\n finalValue = new Color3(value.x, value.y, value.z);\r\n }\r\n (material as any)[babylonProperty] = finalValue;\r\n }\r\n }\r\n },\r\n};\r\n"]}
@@ -1,2 +0,0 @@
1
- import type { IPathExtension } from "@babylonjs/core/FlowGraph/flowGraphPath.js";
2
- export declare const transformNodeExtension: IPathExtension;
@@ -1,50 +0,0 @@
1
- const nodesRegex = /^\/nodes\/(\d+)\/(translation|rotation|scale)$/;
2
- function getBabylonTransformNode(path, context) {
3
- const fullPath = path.getFinalPath();
4
- const gltfTree = context.getVariable("gltf");
5
- if (!gltfTree) {
6
- throw new Error(`No glTF tree found for path ${fullPath}`);
7
- }
8
- const matches = fullPath.match(nodesRegex);
9
- if (!matches || matches.length !== 3) {
10
- throw new Error(`Invalid path ${fullPath}`);
11
- }
12
- const nodeIndex = parseInt(matches[1]);
13
- const node = gltfTree.nodes && gltfTree.nodes[nodeIndex];
14
- if (!node) {
15
- throw new Error(`Invalid node index for path ${fullPath}`);
16
- }
17
- const babylonNode = node._babylonTransformNode;
18
- if (!babylonNode) {
19
- throw new Error(`No Babylon node found for path ${fullPath}`);
20
- }
21
- const property = matches[2];
22
- if (!property) {
23
- throw new Error(`Invalid property for path ${fullPath}`);
24
- }
25
- const babylonProperty = gltfNodePropertyToBabylonPropertyMap[property];
26
- if (!babylonProperty) {
27
- throw new Error(`Invalid property for path ${fullPath}`);
28
- }
29
- return { babylonNode, babylonProperty };
30
- }
31
- const gltfNodePropertyToBabylonPropertyMap = {
32
- translation: "position",
33
- scale: "scaling",
34
- rotation: "rotationQuaternion",
35
- };
36
- export const transformNodeExtension = {
37
- shouldProcess(path) {
38
- const fullPath = path.getFinalPath();
39
- return !!fullPath.match(nodesRegex);
40
- },
41
- processGet(path, context) {
42
- const { babylonNode, babylonProperty } = getBabylonTransformNode(path, context);
43
- return babylonNode[babylonProperty];
44
- },
45
- processSet(path, context, value) {
46
- const { babylonNode, babylonProperty } = getBabylonTransformNode(path, context);
47
- babylonNode[babylonProperty] = value;
48
- },
49
- };
50
- //# sourceMappingURL=interactivityPathTransformNodeExtensions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"interactivityPathTransformNodeExtensions.js","sourceRoot":"","sources":["../../../../../../dev/loaders/src/glTF/2.0/Extensions/interactivityPathTransformNodeExtensions.ts"],"names":[],"mappings":"AAKA,MAAM,UAAU,GAAG,gDAAgD,CAAC;AAEpE,SAAS,uBAAuB,CAAC,IAAmB,EAAE,OAAyB;IAC3E,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;IACrC,MAAM,QAAQ,GAAG,OAAO,CAAC,WAAW,CAAC,MAAM,CAAU,CAAC;IACtD,IAAI,CAAC,QAAQ,EAAE;QACX,MAAM,IAAI,KAAK,CAAC,+BAA+B,QAAQ,EAAE,CAAC,CAAC;KAC9D;IACD,MAAM,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IAC3C,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE;QAClC,MAAM,IAAI,KAAK,CAAC,gBAAgB,QAAQ,EAAE,CAAC,CAAC;KAC/C;IACD,MAAM,SAAS,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IACvC,MAAM,IAAI,GAAG,QAAQ,CAAC,KAAK,IAAI,QAAQ,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IACzD,IAAI,CAAC,IAAI,EAAE;QACP,MAAM,IAAI,KAAK,CAAC,+BAA+B,QAAQ,EAAE,CAAC,CAAC;KAC9D;IACD,MAAM,WAAW,GAAG,IAAI,CAAC,qBAAsC,CAAC;IAChE,IAAI,CAAC,WAAW,EAAE;QACd,MAAM,IAAI,KAAK,CAAC,kCAAkC,QAAQ,EAAE,CAAC,CAAC;KACjE;IACD,MAAM,QAAQ,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAC5B,IAAI,CAAC,QAAQ,EAAE;QACX,MAAM,IAAI,KAAK,CAAC,6BAA6B,QAAQ,EAAE,CAAC,CAAC;KAC5D;IACD,MAAM,eAAe,GAAG,oCAAoC,CAAC,QAAQ,CAAC,CAAC;IACvE,IAAI,CAAC,eAAe,EAAE;QAClB,MAAM,IAAI,KAAK,CAAC,6BAA6B,QAAQ,EAAE,CAAC,CAAC;KAC5D;IACD,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,CAAC;AAC5C,CAAC;AAED,MAAM,oCAAoC,GAA8B;IACpE,WAAW,EAAE,UAAU;IACvB,KAAK,EAAE,SAAS;IAChB,QAAQ,EAAE,oBAAoB;CACjC,CAAC;AAEF,MAAM,CAAC,MAAM,sBAAsB,GAAmB;IAClD,aAAa,CAAC,IAAmB;QAC7B,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;QACrC,OAAO,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IACxC,CAAC;IACD,UAAU,CAAC,IAAmB,EAAE,OAAyB;QACrD,MAAM,EAAE,WAAW,EAAE,eAAe,EAAE,GAAG,uBAAuB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAChF,OAAQ,WAAmB,CAAC,eAAe,CAAC,CAAC;IACjD,CAAC;IACD,UAAU,CAAC,IAAmB,EAAE,OAAyB,EAAE,KAAU;QACjE,MAAM,EAAE,WAAW,EAAE,eAAe,EAAE,GAAG,uBAAuB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAC/E,WAAmB,CAAC,eAAe,CAAC,GAAG,KAAK,CAAC;IAClD,CAAC;CACJ,CAAC","sourcesContent":["import type { FlowGraphPath, IPathExtension } from \"core/FlowGraph/flowGraphPath\";\r\nimport type { FlowGraphContext } from \"core/FlowGraph/flowGraphContext\";\r\nimport type { TransformNode } from \"core/Meshes\";\r\nimport type { IGLTF } from \"../glTFLoaderInterfaces\";\r\n\r\nconst nodesRegex = /^\\/nodes\\/(\\d+)\\/(translation|rotation|scale)$/;\r\n\r\nfunction getBabylonTransformNode(path: FlowGraphPath, context: FlowGraphContext) {\r\n const fullPath = path.getFinalPath();\r\n const gltfTree = context.getVariable(\"gltf\") as IGLTF;\r\n if (!gltfTree) {\r\n throw new Error(`No glTF tree found for path ${fullPath}`);\r\n }\r\n const matches = fullPath.match(nodesRegex);\r\n if (!matches || matches.length !== 3) {\r\n throw new Error(`Invalid path ${fullPath}`);\r\n }\r\n const nodeIndex = parseInt(matches[1]);\r\n const node = gltfTree.nodes && gltfTree.nodes[nodeIndex];\r\n if (!node) {\r\n throw new Error(`Invalid node index for path ${fullPath}`);\r\n }\r\n const babylonNode = node._babylonTransformNode as TransformNode;\r\n if (!babylonNode) {\r\n throw new Error(`No Babylon node found for path ${fullPath}`);\r\n }\r\n const property = matches[2];\r\n if (!property) {\r\n throw new Error(`Invalid property for path ${fullPath}`);\r\n }\r\n const babylonProperty = gltfNodePropertyToBabylonPropertyMap[property];\r\n if (!babylonProperty) {\r\n throw new Error(`Invalid property for path ${fullPath}`);\r\n }\r\n return { babylonNode, babylonProperty };\r\n}\r\n\r\nconst gltfNodePropertyToBabylonPropertyMap: { [key: string]: string } = {\r\n translation: \"position\",\r\n scale: \"scaling\",\r\n rotation: \"rotationQuaternion\",\r\n};\r\n\r\nexport const transformNodeExtension: IPathExtension = {\r\n shouldProcess(path: FlowGraphPath): boolean {\r\n const fullPath = path.getFinalPath();\r\n return !!fullPath.match(nodesRegex);\r\n },\r\n processGet(path: FlowGraphPath, context: FlowGraphContext) {\r\n const { babylonNode, babylonProperty } = getBabylonTransformNode(path, context);\r\n return (babylonNode as any)[babylonProperty];\r\n },\r\n processSet(path: FlowGraphPath, context: FlowGraphContext, value: any) {\r\n const { babylonNode, babylonProperty } = getBabylonTransformNode(path, context);\r\n (babylonNode as any)[babylonProperty] = value;\r\n },\r\n};\r\n"]}