@babylonjs/loaders 6.33.1 → 6.33.2
Sign up to get free protection for your applications and to get access to all the features.
- package/SPLAT/splatFileLoader.d.ts +6 -0
- package/SPLAT/splatFileLoader.js +132 -1
- package/SPLAT/splatFileLoader.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_interactivity.d.ts +23 -0
- package/glTF/2.0/Extensions/KHR_interactivity.js +49 -0
- package/glTF/2.0/Extensions/KHR_interactivity.js.map +1 -0
- package/glTF/2.0/Extensions/index.d.ts +1 -0
- package/glTF/2.0/Extensions/index.js +1 -0
- package/glTF/2.0/Extensions/index.js.map +1 -1
- package/glTF/2.0/Extensions/interactivityFunctions.d.ts +9 -0
- package/glTF/2.0/Extensions/interactivityFunctions.js +204 -0
- package/glTF/2.0/Extensions/interactivityFunctions.js.map +1 -0
- package/glTF/2.0/Extensions/interactivityPathCameraExtensions.d.ts +7 -0
- package/glTF/2.0/Extensions/interactivityPathCameraExtensions.js +77 -0
- package/glTF/2.0/Extensions/interactivityPathCameraExtensions.js.map +1 -0
- package/glTF/2.0/Extensions/interactivityPathExtensions.d.ts +2 -0
- package/glTF/2.0/Extensions/interactivityPathExtensions.js +5 -0
- package/glTF/2.0/Extensions/interactivityPathExtensions.js.map +1 -0
- package/glTF/2.0/Extensions/interactivityPathMaterialExtensions.d.ts +7 -0
- package/glTF/2.0/Extensions/interactivityPathMaterialExtensions.js +87 -0
- package/glTF/2.0/Extensions/interactivityPathMaterialExtensions.js.map +1 -0
- package/glTF/2.0/Extensions/interactivityPathTransformNodeExtensions.d.ts +2 -0
- package/glTF/2.0/Extensions/interactivityPathTransformNodeExtensions.js +50 -0
- package/glTF/2.0/Extensions/interactivityPathTransformNodeExtensions.js.map +1 -0
- package/glTF/2.0/Extensions/interactivityUtils.d.ts +4 -0
- package/glTF/2.0/Extensions/interactivityUtils.js +93 -0
- package/glTF/2.0/Extensions/interactivityUtils.js.map +1 -0
- package/package.json +3 -3
@@ -30,6 +30,12 @@ export declare class SPLATFileLoader implements ISceneLoaderPluginAsync, ISceneL
|
|
30
30
|
* @returns if the data can be loaded directly
|
31
31
|
*/
|
32
32
|
canDirectLoad(): boolean;
|
33
|
+
/**
|
34
|
+
* Code from https://github.com/dylanebert/gsplat.js/blob/main/src/loaders/PLYLoader.ts Under MIT license
|
35
|
+
* Loads a .ply from data array buffer
|
36
|
+
* if data array buffer is not ply, returns the original buffer
|
37
|
+
*/
|
38
|
+
private _loadPLY;
|
33
39
|
/**
|
34
40
|
* Imports from the loaded gaussian splatting data and adds them to the scene
|
35
41
|
* @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
|
package/SPLAT/splatFileLoader.js
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
import { SceneLoader } from "@babylonjs/core/Loading/sceneLoader.js";
|
2
|
+
import { Quaternion } from "@babylonjs/core/Maths/math.vector.js";
|
2
3
|
import { GaussianSplatting } from "@babylonjs/core/Rendering/GaussianSplatting/gaussianSplatting.js";
|
3
4
|
/**
|
4
5
|
* @experimental
|
@@ -21,6 +22,7 @@ export class SPLATFileLoader {
|
|
21
22
|
*/
|
22
23
|
this.extensions = {
|
23
24
|
".splat": { isBinary: true },
|
25
|
+
".ply": { isBinary: true },
|
24
26
|
};
|
25
27
|
}
|
26
28
|
/**
|
@@ -37,6 +39,135 @@ export class SPLATFileLoader {
|
|
37
39
|
canDirectLoad() {
|
38
40
|
return false;
|
39
41
|
}
|
42
|
+
/**
|
43
|
+
* Code from https://github.com/dylanebert/gsplat.js/blob/main/src/loaders/PLYLoader.ts Under MIT license
|
44
|
+
* Loads a .ply from data array buffer
|
45
|
+
* if data array buffer is not ply, returns the original buffer
|
46
|
+
*/
|
47
|
+
_loadPLY(data) {
|
48
|
+
const ubuf = new Uint8Array(data);
|
49
|
+
const header = new TextDecoder().decode(ubuf.slice(0, 1024 * 10));
|
50
|
+
const headerEnd = "end_header\n";
|
51
|
+
const headerEndIndex = header.indexOf(headerEnd);
|
52
|
+
if (headerEndIndex < 0 || !header) {
|
53
|
+
return data;
|
54
|
+
}
|
55
|
+
const vertexCount = parseInt(/element vertex (\d+)\n/.exec(header)[1]);
|
56
|
+
let rowOffset = 0;
|
57
|
+
const offsets = {
|
58
|
+
double: 8,
|
59
|
+
int: 4,
|
60
|
+
uint: 4,
|
61
|
+
float: 4,
|
62
|
+
short: 2,
|
63
|
+
ushort: 2,
|
64
|
+
uchar: 1,
|
65
|
+
};
|
66
|
+
const properties = [];
|
67
|
+
const filtered = header
|
68
|
+
.slice(0, headerEndIndex)
|
69
|
+
.split("\n")
|
70
|
+
.filter((k) => k.startsWith("property "));
|
71
|
+
for (const prop of filtered) {
|
72
|
+
const [_p, type, name] = prop.split(" ");
|
73
|
+
properties.push({ name, type, offset: rowOffset });
|
74
|
+
if (!offsets[type])
|
75
|
+
throw new Error(`Unsupported property type: ${type}`);
|
76
|
+
rowOffset += offsets[type];
|
77
|
+
}
|
78
|
+
const rowLength = 3 * 4 + 3 * 4 + 4 + 4;
|
79
|
+
const SH_C0 = 0.28209479177387814;
|
80
|
+
const dataView = new DataView(data, headerEndIndex + headerEnd.length);
|
81
|
+
const buffer = new ArrayBuffer(rowLength * vertexCount);
|
82
|
+
const q = new Quaternion();
|
83
|
+
for (let i = 0; i < vertexCount; i++) {
|
84
|
+
const position = new Float32Array(buffer, i * rowLength, 3);
|
85
|
+
const scale = new Float32Array(buffer, i * rowLength + 12, 3);
|
86
|
+
const rgba = new Uint8ClampedArray(buffer, i * rowLength + 24, 4);
|
87
|
+
const rot = new Uint8ClampedArray(buffer, i * rowLength + 28, 4);
|
88
|
+
let r0 = 255;
|
89
|
+
let r1 = 0;
|
90
|
+
let r2 = 0;
|
91
|
+
let r3 = 0;
|
92
|
+
for (let propertyIndex = 0; propertyIndex < properties.length; propertyIndex++) {
|
93
|
+
const property = properties[propertyIndex];
|
94
|
+
let value;
|
95
|
+
switch (property.type) {
|
96
|
+
case "float":
|
97
|
+
value = dataView.getFloat32(property.offset + i * rowOffset, true);
|
98
|
+
break;
|
99
|
+
case "int":
|
100
|
+
value = dataView.getInt32(property.offset + i * rowOffset, true);
|
101
|
+
break;
|
102
|
+
default:
|
103
|
+
throw new Error(`Unsupported property type: ${property.type}`);
|
104
|
+
}
|
105
|
+
switch (property.name) {
|
106
|
+
case "x":
|
107
|
+
position[0] = value;
|
108
|
+
break;
|
109
|
+
case "y":
|
110
|
+
position[1] = value;
|
111
|
+
break;
|
112
|
+
case "z":
|
113
|
+
position[2] = value;
|
114
|
+
break;
|
115
|
+
case "scale_0":
|
116
|
+
scale[0] = Math.exp(value);
|
117
|
+
break;
|
118
|
+
case "scale_1":
|
119
|
+
scale[1] = Math.exp(value);
|
120
|
+
break;
|
121
|
+
case "scale_2":
|
122
|
+
scale[2] = Math.exp(value);
|
123
|
+
break;
|
124
|
+
case "red":
|
125
|
+
rgba[0] = value;
|
126
|
+
break;
|
127
|
+
case "green":
|
128
|
+
rgba[1] = value;
|
129
|
+
break;
|
130
|
+
case "blue":
|
131
|
+
rgba[2] = value;
|
132
|
+
break;
|
133
|
+
case "f_dc_0":
|
134
|
+
rgba[0] = (0.5 + SH_C0 * value) * 255;
|
135
|
+
break;
|
136
|
+
case "f_dc_1":
|
137
|
+
rgba[1] = (0.5 + SH_C0 * value) * 255;
|
138
|
+
break;
|
139
|
+
case "f_dc_2":
|
140
|
+
rgba[2] = (0.5 + SH_C0 * value) * 255;
|
141
|
+
break;
|
142
|
+
case "f_dc_3":
|
143
|
+
rgba[3] = (0.5 + SH_C0 * value) * 255;
|
144
|
+
break;
|
145
|
+
case "opacity":
|
146
|
+
rgba[3] = (1 / (1 + Math.exp(-value))) * 255;
|
147
|
+
break;
|
148
|
+
case "rot_0":
|
149
|
+
r0 = value;
|
150
|
+
break;
|
151
|
+
case "rot_1":
|
152
|
+
r1 = value;
|
153
|
+
break;
|
154
|
+
case "rot_2":
|
155
|
+
r2 = value;
|
156
|
+
break;
|
157
|
+
case "rot_3":
|
158
|
+
r3 = value;
|
159
|
+
break;
|
160
|
+
}
|
161
|
+
}
|
162
|
+
q.set(r1, r2, r3, r0);
|
163
|
+
q.normalize();
|
164
|
+
rot[0] = q.w * 128 + 128;
|
165
|
+
rot[1] = q.x * 128 + 128;
|
166
|
+
rot[2] = q.y * 128 + 128;
|
167
|
+
rot[3] = q.z * 128 + 128;
|
168
|
+
}
|
169
|
+
return buffer;
|
170
|
+
}
|
40
171
|
/**
|
41
172
|
* Imports from the loaded gaussian splatting data and adds them to the scene
|
42
173
|
* @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
|
@@ -58,7 +189,7 @@ export class SPLATFileLoader {
|
|
58
189
|
*/
|
59
190
|
loadAsync(scene, data, _rootUrl) {
|
60
191
|
const gaussianSplatting = new GaussianSplatting("GaussianSplatting", scene);
|
61
|
-
return gaussianSplatting.loadDataAsync(data);
|
192
|
+
return gaussianSplatting.loadDataAsync(this._loadPLY(data));
|
62
193
|
}
|
63
194
|
/**
|
64
195
|
* Load into an asset container.
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"splatFileLoader.js","sourceRoot":"","sources":["../../../../dev/loaders/src/SPLAT/splatFileLoader.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,+CAAiC;AACvD,OAAO,EAAE,iBAAiB,EAAE,yEAA2D;AAIvF;;;;GAIG;AACH,MAAM,OAAO,eAAe;IAcxB,+CAA+C;IAC/C;;OAEG;IACH;QAjBA;;WAEG;QACI,SAAI,GAAG,OAAO,CAAC;QAEtB;;;WAGG;QACI,eAAU,GAAiC;YAC9C,QAAQ,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE;SAC/B,CAAC;IAMa,CAAC;IAEhB;;;OAGG;IACH,YAAY;QACR,OAAO,IAAI,eAAe,EAAE,CAAC;IACjC,CAAC;IAED;;;OAGG;IACI,aAAa;QAChB,OAAO,KAAK,CAAC;IACjB,CAAC;IAED;;;;;;;OAOG;IACI,eAAe,CAAC,YAAiB,EAAE,KAAY,EAAE,IAAS,EAAE,OAAe;QAC9E,MAAM,iBAAiB,GAAG,IAAI,iBAAiB,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;QAC3D,OAAO,iBAAiB,CAAC,aAAa,CAAC,OAAO,CAAQ,CAAC;IAC3D,CAAC;IAED;;;;;;OAMG;IACI,SAAS,CAAC,KAAY,EAAE,IAAS,EAAE,QAAgB;QACtD,MAAM,iBAAiB,GAAG,IAAI,iBAAiB,CAAC,mBAAmB,EAAE,KAAK,CAAC,CAAC;QAC5E,OAAO,iBAAiB,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IACjD,CAAC;IAED;;;;;;OAMG;IACI,uBAAuB,CAAC,MAAa,EAAE,KAAa,EAAE,QAAgB;QACzE,MAAM,IAAI,KAAK,CAAC,wEAAwE,CAAC,CAAC;IAC9F,CAAC;CACJ;AAED,IAAI,WAAW,EAAE;IACb,0CAA0C;IAC1C,WAAW,CAAC,cAAc,CAAC,IAAI,eAAe,EAAE,CAAC,CAAC;CACrD","sourcesContent":["import type { ISceneLoaderPluginAsync, ISceneLoaderPluginFactory, ISceneLoaderPlugin, ISceneLoaderAsyncResult, ISceneLoaderPluginExtensions } from \"core/Loading/sceneLoader\";\r\nimport { SceneLoader } from \"core/Loading/sceneLoader\";\r\nimport { GaussianSplatting } from \"core/Rendering/GaussianSplatting/gaussianSplatting\";\r\nimport type { AssetContainer } from \"core/assetContainer\";\r\nimport type { Scene } from \"core/scene\";\r\n\r\n/**\r\n * @experimental\r\n * SPLAT file type loader.\r\n * This is a babylon scene loader plugin.\r\n */\r\nexport class SPLATFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {\r\n /**\r\n * Defines the name of the plugin.\r\n */\r\n public name = \"splat\";\r\n\r\n /**\r\n * Defines the extensions the splat loader is able to load.\r\n * force data to come in as an ArrayBuffer\r\n */\r\n public extensions: ISceneLoaderPluginExtensions = {\r\n \".splat\": { isBinary: true },\r\n };\r\n\r\n //private _loadingOptions: SPLATLoadingOptions;\r\n /**\r\n * Creates loader for gaussian splatting files\r\n */\r\n constructor() {}\r\n\r\n /**\r\n * Instantiates a gaussian splatting file loader plugin.\r\n * @returns the created plugin\r\n */\r\n createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin {\r\n return new SPLATFileLoader();\r\n }\r\n\r\n /**\r\n * If the data string can be loaded directly.\r\n * @returns if the data can be loaded directly\r\n */\r\n public canDirectLoad(): boolean {\r\n return false;\r\n }\r\n\r\n /**\r\n * Imports from the loaded gaussian splatting data and adds them to the scene\r\n * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file\r\n * @param scene the scene the meshes should be added to\r\n * @param data the gaussian splatting data to load\r\n * @param rootUrl root url to load from\r\n * @returns a promise containing the loaded meshes, particles, skeletons and animations\r\n */\r\n public importMeshAsync(_meshesNames: any, scene: Scene, data: any, rootUrl: string): Promise<ISceneLoaderAsyncResult> {\r\n const gaussianSplatting = new GaussianSplatting(\"\", scene);\r\n return gaussianSplatting.loadFileAsync(rootUrl) as any;\r\n }\r\n\r\n /**\r\n * Imports all objects from the loaded gaussian splatting data and adds them to the scene\r\n * @param scene the scene the objects should be added to\r\n * @param data the gaussian splatting data to load\r\n * @param rootUrl root url to load from\r\n * @returns a promise which completes when objects have been loaded to the scene\r\n */\r\n public loadAsync(scene: Scene, data: any, _rootUrl: string): Promise<void> {\r\n const gaussianSplatting = new GaussianSplatting(\"GaussianSplatting\", scene);\r\n return gaussianSplatting.loadDataAsync(data);\r\n }\r\n\r\n /**\r\n * Load into an asset container.\r\n * @param scene The scene to load into\r\n * @param data The data to import\r\n * @param rootUrl The root url for scene and resources\r\n * @returns The loaded asset container\r\n */\r\n public loadAssetContainerAsync(_scene: Scene, _data: string, _rootUrl: string): Promise<AssetContainer> {\r\n throw new Error(\"loadAssetContainerAsync not implemented for Gaussian Splatting loading\");\r\n }\r\n}\r\n\r\nif (SceneLoader) {\r\n //Add this loader into the register plugin\r\n SceneLoader.RegisterPlugin(new SPLATFileLoader());\r\n}\r\n"]}
|
1
|
+
{"version":3,"file":"splatFileLo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AC,KAAY,EAAE,IAAS,EAAE,QAAgB;QACtD,MAAM,iBAAiB,GAAG,IAAI,iBAAiB,CAAC,mBAAmB,EAAE,KAAK,CAAC,CAAC;QAC5E,OAAO,iBAAiB,CAAC,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;IAChE,CAAC;IAED;;;;;;OAMG;IACI,uBAAuB,CAAC,MAAa,EAAE,KAAa,EAAE,QAAgB;QACzE,MAAM,IAAI,KAAK,CAAC,wEAAwE,CAAC,CAAC;IAC9F,CAAC;CACJ;AAED,IAAI,WAAW,EAAE;IACb,0CAA0C;IAC1C,WAAW,CAAC,cAAc,CAAC,IAAI,eAAe,EAAE,CAAC,CAAC;CACrD","sourcesContent":["import type { ISceneLoaderPluginAsync, ISceneLoaderPluginFactory, ISceneLoaderPlugin, ISceneLoaderAsyncResult, ISceneLoaderPluginExtensions } from \"core/Loading/sceneLoader\";\r\nimport { SceneLoader } from \"core/Loading/sceneLoader\";\r\nimport { Quaternion } from \"core/Maths/math.vector\";\r\nimport { GaussianSplatting } from \"core/Rendering/GaussianSplatting/gaussianSplatting\";\r\nimport type { AssetContainer } from \"core/assetContainer\";\r\nimport type { Scene } from \"core/scene\";\r\n\r\n/**\r\n * @experimental\r\n * SPLAT file type loader.\r\n * This is a babylon scene loader plugin.\r\n */\r\nexport class SPLATFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {\r\n /**\r\n * Defines the name of the plugin.\r\n */\r\n public name = \"splat\";\r\n\r\n /**\r\n * Defines the extensions the splat loader is able to load.\r\n * force data to come in as an ArrayBuffer\r\n */\r\n public extensions: ISceneLoaderPluginExtensions = {\r\n \".splat\": { isBinary: true },\r\n \".ply\": { isBinary: true },\r\n };\r\n\r\n //private _loadingOptions: SPLATLoadingOptions;\r\n /**\r\n * Creates loader for gaussian splatting files\r\n */\r\n constructor() {}\r\n\r\n /**\r\n * Instantiates a gaussian splatting file loader plugin.\r\n * @returns the created plugin\r\n */\r\n createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin {\r\n return new SPLATFileLoader();\r\n }\r\n\r\n /**\r\n * If the data string can be loaded directly.\r\n * @returns if the data can be loaded directly\r\n */\r\n public canDirectLoad(): boolean {\r\n return false;\r\n }\r\n\r\n /**\r\n * Code from https://github.com/dylanebert/gsplat.js/blob/main/src/loaders/PLYLoader.ts Under MIT license\r\n * Loads a .ply from data array buffer\r\n * if data array buffer is not ply, returns the original buffer\r\n */\r\n private _loadPLY(data: any): ArrayBuffer {\r\n const ubuf = new Uint8Array(data);\r\n const header = new TextDecoder().decode(ubuf.slice(0, 1024 * 10));\r\n const headerEnd = \"end_header\\n\";\r\n const headerEndIndex = header.indexOf(headerEnd);\r\n if (headerEndIndex < 0 || !header) {\r\n return data;\r\n }\r\n const vertexCount = parseInt(/element vertex (\\d+)\\n/.exec(header)![1]);\r\n\r\n let rowOffset = 0;\r\n const offsets: Record<string, number> = {\r\n double: 8,\r\n int: 4,\r\n uint: 4,\r\n float: 4,\r\n short: 2,\r\n ushort: 2,\r\n uchar: 1,\r\n };\r\n\r\n type PlyProperty = {\r\n name: string;\r\n type: string;\r\n offset: number;\r\n };\r\n const properties: PlyProperty[] = [];\r\n const filtered = header\r\n .slice(0, headerEndIndex)\r\n .split(\"\\n\")\r\n .filter((k) => k.startsWith(\"property \"));\r\n for (const prop of filtered) {\r\n const [_p, type, name] = prop.split(\" \");\r\n properties.push({ name, type, offset: rowOffset });\r\n if (!offsets[type]) throw new Error(`Unsupported property type: ${type}`);\r\n rowOffset += offsets[type];\r\n }\r\n\r\n const rowLength = 3 * 4 + 3 * 4 + 4 + 4;\r\n const SH_C0 = 0.28209479177387814;\r\n\r\n const dataView = new DataView(data, headerEndIndex + headerEnd.length);\r\n const buffer = new ArrayBuffer(rowLength * vertexCount);\r\n const q = new Quaternion();\r\n\r\n for (let i = 0; i < vertexCount; i++) {\r\n const position = new Float32Array(buffer, i * rowLength, 3);\r\n const scale = new Float32Array(buffer, i * rowLength + 12, 3);\r\n const rgba = new Uint8ClampedArray(buffer, i * rowLength + 24, 4);\r\n const rot = new Uint8ClampedArray(buffer, i * rowLength + 28, 4);\r\n\r\n let r0: number = 255;\r\n let r1: number = 0;\r\n let r2: number = 0;\r\n let r3: number = 0;\r\n\r\n for (let propertyIndex = 0; propertyIndex < properties.length; propertyIndex++) {\r\n const property = properties[propertyIndex];\r\n let value;\r\n switch (property.type) {\r\n case \"float\":\r\n value = dataView.getFloat32(property.offset + i * rowOffset, true);\r\n break;\r\n case \"int\":\r\n value = dataView.getInt32(property.offset + i * rowOffset, true);\r\n break;\r\n default:\r\n throw new Error(`Unsupported property type: ${property.type}`);\r\n }\r\n\r\n switch (property.name) {\r\n case \"x\":\r\n position[0] = value;\r\n break;\r\n case \"y\":\r\n position[1] = value;\r\n break;\r\n case \"z\":\r\n position[2] = value;\r\n break;\r\n case \"scale_0\":\r\n scale[0] = Math.exp(value);\r\n break;\r\n case \"scale_1\":\r\n scale[1] = Math.exp(value);\r\n break;\r\n case \"scale_2\":\r\n scale[2] = Math.exp(value);\r\n break;\r\n case \"red\":\r\n rgba[0] = value;\r\n break;\r\n case \"green\":\r\n rgba[1] = value;\r\n break;\r\n case \"blue\":\r\n rgba[2] = value;\r\n break;\r\n case \"f_dc_0\":\r\n rgba[0] = (0.5 + SH_C0 * value) * 255;\r\n break;\r\n case \"f_dc_1\":\r\n rgba[1] = (0.5 + SH_C0 * value) * 255;\r\n break;\r\n case \"f_dc_2\":\r\n rgba[2] = (0.5 + SH_C0 * value) * 255;\r\n break;\r\n case \"f_dc_3\":\r\n rgba[3] = (0.5 + SH_C0 * value) * 255;\r\n break;\r\n case \"opacity\":\r\n rgba[3] = (1 / (1 + Math.exp(-value))) * 255;\r\n break;\r\n case \"rot_0\":\r\n r0 = value;\r\n break;\r\n case \"rot_1\":\r\n r1 = value;\r\n break;\r\n case \"rot_2\":\r\n r2 = value;\r\n break;\r\n case \"rot_3\":\r\n r3 = value;\r\n break;\r\n }\r\n }\r\n\r\n q.set(r1, r2, r3, r0);\r\n q.normalize();\r\n rot[0] = q.w * 128 + 128;\r\n rot[1] = q.x * 128 + 128;\r\n rot[2] = q.y * 128 + 128;\r\n rot[3] = q.z * 128 + 128;\r\n }\r\n\r\n return buffer;\r\n }\r\n\r\n /**\r\n * Imports from the loaded gaussian splatting data and adds them to the scene\r\n * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file\r\n * @param scene the scene the meshes should be added to\r\n * @param data the gaussian splatting data to load\r\n * @param rootUrl root url to load from\r\n * @returns a promise containing the loaded meshes, particles, skeletons and animations\r\n */\r\n public importMeshAsync(_meshesNames: any, scene: Scene, data: any, rootUrl: string): Promise<ISceneLoaderAsyncResult> {\r\n const gaussianSplatting = new GaussianSplatting(\"\", scene);\r\n return gaussianSplatting.loadFileAsync(rootUrl) as any;\r\n }\r\n\r\n /**\r\n * Imports all objects from the loaded gaussian splatting data and adds them to the scene\r\n * @param scene the scene the objects should be added to\r\n * @param data the gaussian splatting data to load\r\n * @param rootUrl root url to load from\r\n * @returns a promise which completes when objects have been loaded to the scene\r\n */\r\n public loadAsync(scene: Scene, data: any, _rootUrl: string): Promise<void> {\r\n const gaussianSplatting = new GaussianSplatting(\"GaussianSplatting\", scene);\r\n return gaussianSplatting.loadDataAsync(this._loadPLY(data));\r\n }\r\n\r\n /**\r\n * Load into an asset container.\r\n * @param scene The scene to load into\r\n * @param data The data to import\r\n * @param rootUrl The root url for scene and resources\r\n * @returns The loaded asset container\r\n */\r\n public loadAssetContainerAsync(_scene: Scene, _data: string, _rootUrl: string): Promise<AssetContainer> {\r\n throw new Error(\"loadAssetContainerAsync not implemented for Gaussian Splatting loading\");\r\n }\r\n}\r\n\r\nif (SceneLoader) {\r\n //Add this loader into the register plugin\r\n SceneLoader.RegisterPlugin(new SPLATFileLoader());\r\n}\r\n"]}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
import { GLTFLoader } from "../glTFLoader";
|
2
|
+
import type { IGLTFLoaderExtension } from "../glTFLoaderExtension";
|
3
|
+
/**
|
4
|
+
* Loader extension for KHR_interactivity
|
5
|
+
*/
|
6
|
+
export declare class KHR_interactivity implements IGLTFLoaderExtension {
|
7
|
+
private _loader;
|
8
|
+
/**
|
9
|
+
* The name of this extension.
|
10
|
+
*/
|
11
|
+
readonly name = "KHR_interactivity";
|
12
|
+
/**
|
13
|
+
* Defines whether this extension is enabled.
|
14
|
+
*/
|
15
|
+
enabled: boolean;
|
16
|
+
/**
|
17
|
+
* @internal
|
18
|
+
* @param _loader
|
19
|
+
*/
|
20
|
+
constructor(_loader: GLTFLoader);
|
21
|
+
dispose(): void;
|
22
|
+
onReady(): void;
|
23
|
+
}
|
@@ -0,0 +1,49 @@
|
|
1
|
+
import { GLTFLoader } from "../glTFLoader.js";
|
2
|
+
import { FlowGraphCoordinator } from "@babylonjs/core/FlowGraph/flowGraphCoordinator.js";
|
3
|
+
import { FlowGraph } from "@babylonjs/core/FlowGraph/flowGraph.js";
|
4
|
+
import { FlowGraphPath } from "@babylonjs/core/FlowGraph/flowGraphPath.js";
|
5
|
+
import { convertGLTFToSerializedFlowGraph } from "./interactivityFunctions.js";
|
6
|
+
import { interactivityPathExensions } from "./interactivityPathExtensions.js";
|
7
|
+
const NAME = "KHR_interactivity";
|
8
|
+
/**
|
9
|
+
* Loader extension for KHR_interactivity
|
10
|
+
*/
|
11
|
+
export class KHR_interactivity {
|
12
|
+
/**
|
13
|
+
* @internal
|
14
|
+
* @param _loader
|
15
|
+
*/
|
16
|
+
constructor(_loader) {
|
17
|
+
this._loader = _loader;
|
18
|
+
/**
|
19
|
+
* The name of this extension.
|
20
|
+
*/
|
21
|
+
this.name = NAME;
|
22
|
+
this.enabled = this._loader.isExtensionUsed(NAME);
|
23
|
+
}
|
24
|
+
dispose() {
|
25
|
+
this._loader = null;
|
26
|
+
}
|
27
|
+
onReady() {
|
28
|
+
var _a;
|
29
|
+
if (!this._loader.babylonScene) {
|
30
|
+
return;
|
31
|
+
}
|
32
|
+
const scene = this._loader.babylonScene;
|
33
|
+
const definition = (_a = this._loader.gltf.extensions) === null || _a === void 0 ? void 0 : _a.KHR_interactivity;
|
34
|
+
// Fill out the array of extensions that the FlowGraphPath can use
|
35
|
+
for (const extension of interactivityPathExensions) {
|
36
|
+
if (!FlowGraphPath.Extensions.includes(extension)) {
|
37
|
+
FlowGraphPath.Extensions.push(extension);
|
38
|
+
}
|
39
|
+
}
|
40
|
+
const json = convertGLTFToSerializedFlowGraph(definition);
|
41
|
+
const coordinator = new FlowGraphCoordinator({ scene });
|
42
|
+
const graph = FlowGraph.Parse(json, coordinator);
|
43
|
+
const context = graph.getContext(0);
|
44
|
+
context.setVariable("gltf", this._loader.gltf);
|
45
|
+
coordinator.start();
|
46
|
+
}
|
47
|
+
}
|
48
|
+
GLTFLoader.RegisterExtension(NAME, (loader) => new KHR_interactivity(loader));
|
49
|
+
//# sourceMappingURL=KHR_interactivity.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"KHR_interactivity.js","sourceRoot":"","sources":["../../../../../../dev/loaders/src/glTF/2.0/Extensions/KHR_interactivity.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,EAAE,oBAAoB,EAAE,0DAA4C;AAC3E,OAAO,EAAE,SAAS,EAAE,+CAAiC;AACrD,OAAO,EAAE,aAAa,EAAE,mDAAqC;AAC7D,OAAO,EAAE,gCAAgC,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAE3E,MAAM,IAAI,GAAG,mBAAmB,CAAC;AAEjC;;GAEG;AACH,MAAM,OAAO,iBAAiB;IAU1B;;;OAGG;IACH,YAAoB,OAAmB;QAAnB,YAAO,GAAP,OAAO,CAAY;QAbvC;;WAEG;QACa,SAAI,GAAG,IAAI,CAAC;QAWxB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IACtD,CAAC;IAEM,OAAO;QACT,IAAI,CAAC,OAAe,GAAG,IAAI,CAAC;IACjC,CAAC;IAEM,OAAO;;QACV,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE;YAC5B,OAAO;SACV;QACD,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC;QACxC,MAAM,UAAU,GAAG,MAAA,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,0CAAE,iBAAsC,CAAC;QAExF,kEAAkE;QAClE,KAAK,MAAM,SAAS,IAAI,0BAA0B,EAAE;YAChD,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE;gBAC/C,aAAa,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;aAC5C;SACJ;QACD,MAAM,IAAI,GAAG,gCAAgC,CAAC,UAAU,CAAC,CAAC;QAE1D,MAAM,WAAW,GAAG,IAAI,oBAAoB,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;QACxD,MAAM,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;QACjD,MAAM,OAAO,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QACpC,OAAO,CAAC,WAAW,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAE/C,WAAW,CAAC,KAAK,EAAE,CAAC;IACxB,CAAC;CACJ;AAED,UAAU,CAAC,iBAAiB,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type { IKHRInteractivity } from \"babylonjs-gltf2interface\";\r\nimport { GLTFLoader } from \"../glTFLoader\";\r\nimport type { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\r\nimport { FlowGraphCoordinator } from \"core/FlowGraph/flowGraphCoordinator\";\r\nimport { FlowGraph } from \"core/FlowGraph/flowGraph\";\r\nimport { FlowGraphPath } from \"core/FlowGraph/flowGraphPath\";\r\nimport { convertGLTFToSerializedFlowGraph } from \"./interactivityFunctions\";\r\nimport { interactivityPathExensions } from \"./interactivityPathExtensions\";\r\n\r\nconst NAME = \"KHR_interactivity\";\r\n\r\n/**\r\n * Loader extension for KHR_interactivity\r\n */\r\nexport class KHR_interactivity implements IGLTFLoaderExtension {\r\n /**\r\n * The name of this extension.\r\n */\r\n public readonly name = NAME;\r\n /**\r\n * Defines whether this extension is enabled.\r\n */\r\n public enabled: boolean;\r\n\r\n /**\r\n * @internal\r\n * @param _loader\r\n */\r\n constructor(private _loader: GLTFLoader) {\r\n this.enabled = this._loader.isExtensionUsed(NAME);\r\n }\r\n\r\n public dispose() {\r\n (this._loader as any) = null;\r\n }\r\n\r\n public onReady(): void {\r\n if (!this._loader.babylonScene) {\r\n return;\r\n }\r\n const scene = this._loader.babylonScene;\r\n const definition = this._loader.gltf.extensions?.KHR_interactivity as IKHRInteractivity;\r\n\r\n // Fill out the array of extensions that the FlowGraphPath can use\r\n for (const extension of interactivityPathExensions) {\r\n if (!FlowGraphPath.Extensions.includes(extension)) {\r\n FlowGraphPath.Extensions.push(extension);\r\n }\r\n }\r\n const json = convertGLTFToSerializedFlowGraph(definition);\r\n\r\n const coordinator = new FlowGraphCoordinator({ scene });\r\n const graph = FlowGraph.Parse(json, coordinator);\r\n const context = graph.getContext(0);\r\n context.setVariable(\"gltf\", this._loader.gltf);\r\n\r\n coordinator.start();\r\n }\r\n}\r\n\r\nGLTFLoader.RegisterExtension(NAME, (loader) => new KHR_interactivity(loader));\r\n"]}
|
@@ -27,5 +27,6 @@ export * from "./MSFT_audio_emitter.js";
|
|
27
27
|
export * from "./MSFT_lod.js";
|
28
28
|
export * from "./MSFT_minecraftMesh.js";
|
29
29
|
export * from "./MSFT_sRGBFactors.js";
|
30
|
+
export * from "./KHR_interactivity.js";
|
30
31
|
export * from "./ExtrasAsMetadata.js";
|
31
32
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../dev/loaders/src/glTF/2.0/Extensions/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oBAAoB,CAAC;AACnC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uBAAuB,CAAC;AACtC,cAAc,uCAAuC,CAAC;AACtD,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mCAAmC,CAAC;AAClD,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,YAAY,CAAC;AAC3B,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC","sourcesContent":["export * from \"./EXT_lights_image_based\";\r\nexport * from \"./EXT_mesh_gpu_instancing\";\r\nexport * from \"./EXT_meshopt_compression\";\r\nexport * from \"./EXT_texture_webp\";\r\nexport * from \"./KHR_draco_mesh_compression\";\r\nexport * from \"./KHR_lights_punctual\";\r\nexport * from \"./KHR_materials_pbrSpecularGlossiness\";\r\nexport * from \"./KHR_materials_unlit\";\r\nexport * from \"./KHR_materials_clearcoat\";\r\nexport * from \"./KHR_materials_iridescence\";\r\nexport * from \"./KHR_materials_anisotropy\";\r\nexport * from \"./KHR_materials_emissive_strength\";\r\nexport * from \"./KHR_materials_sheen\";\r\nexport * from \"./KHR_materials_specular\";\r\nexport * from \"./KHR_materials_ior\";\r\nexport * from \"./KHR_materials_variants\";\r\nexport * from \"./KHR_materials_transmission\";\r\nexport * from \"./KHR_materials_translucency\";\r\nexport * from \"./KHR_materials_volume\";\r\nexport * from \"./KHR_materials_dispersion\";\r\nexport * from \"./KHR_mesh_quantization\";\r\nexport * from \"./KHR_texture_basisu\";\r\nexport * from \"./KHR_texture_transform\";\r\nexport * from \"./KHR_xmp_json_ld\";\r\nexport * from \"./KHR_animation_pointer\";\r\nexport * from \"./MSFT_audio_emitter\";\r\nexport * from \"./MSFT_lod\";\r\nexport * from \"./MSFT_minecraftMesh\";\r\nexport * from \"./MSFT_sRGBFactors\";\r\nexport * from \"./ExtrasAsMetadata\";\r\n"]}
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../dev/loaders/src/glTF/2.0/Extensions/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oBAAoB,CAAC;AACnC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uBAAuB,CAAC;AACtC,cAAc,uCAAuC,CAAC;AACtD,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mCAAmC,CAAC;AAClD,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,YAAY,CAAC;AAC3B,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC","sourcesContent":["export * from \"./EXT_lights_image_based\";\r\nexport * from \"./EXT_mesh_gpu_instancing\";\r\nexport * from \"./EXT_meshopt_compression\";\r\nexport * from \"./EXT_texture_webp\";\r\nexport * from \"./KHR_draco_mesh_compression\";\r\nexport * from \"./KHR_lights_punctual\";\r\nexport * from \"./KHR_materials_pbrSpecularGlossiness\";\r\nexport * from \"./KHR_materials_unlit\";\r\nexport * from \"./KHR_materials_clearcoat\";\r\nexport * from \"./KHR_materials_iridescence\";\r\nexport * from \"./KHR_materials_anisotropy\";\r\nexport * from \"./KHR_materials_emissive_strength\";\r\nexport * from \"./KHR_materials_sheen\";\r\nexport * from \"./KHR_materials_specular\";\r\nexport * from \"./KHR_materials_ior\";\r\nexport * from \"./KHR_materials_variants\";\r\nexport * from \"./KHR_materials_transmission\";\r\nexport * from \"./KHR_materials_translucency\";\r\nexport * from \"./KHR_materials_volume\";\r\nexport * from \"./KHR_materials_dispersion\";\r\nexport * from \"./KHR_mesh_quantization\";\r\nexport * from \"./KHR_texture_basisu\";\r\nexport * from \"./KHR_texture_transform\";\r\nexport * from \"./KHR_xmp_json_ld\";\r\nexport * from \"./KHR_animation_pointer\";\r\nexport * from \"./MSFT_audio_emitter\";\r\nexport * from \"./MSFT_lod\";\r\nexport * from \"./MSFT_minecraftMesh\";\r\nexport * from \"./MSFT_sRGBFactors\";\r\nexport * from \"./KHR_interactivity\";\r\nexport * from \"./ExtrasAsMetadata\";\r\n"]}
|
@@ -0,0 +1,9 @@
|
|
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;
|
@@ -0,0 +1,204 @@
|
|
1
|
+
import { RandomGUID } from "@babylonjs/core/Misc/guid.js";
|
2
|
+
import { gltfToFlowGraphTypeMap, gltfTypeToBabylonType } from "./interactivityUtils.js";
|
3
|
+
import { FlowGraphConnectionType } from "@babylonjs/core/FlowGraph/flowGraphConnection.js";
|
4
|
+
function convertValueWithType(configObject, definition, context) {
|
5
|
+
if (configObject.type !== undefined) {
|
6
|
+
// get the type on the gltf definition
|
7
|
+
const type = definition.types && definition.types[configObject.type];
|
8
|
+
if (!type) {
|
9
|
+
throw new Error(`${context}: Unknown type: ${configObject.type}`);
|
10
|
+
}
|
11
|
+
const signature = type.signature;
|
12
|
+
if (!signature) {
|
13
|
+
throw new Error(`${context}: Type ${configObject.type} has no signature`);
|
14
|
+
}
|
15
|
+
const convertedType = gltfTypeToBabylonType[signature];
|
16
|
+
return {
|
17
|
+
value: configObject.value,
|
18
|
+
className: convertedType,
|
19
|
+
};
|
20
|
+
}
|
21
|
+
else {
|
22
|
+
return configObject.value;
|
23
|
+
}
|
24
|
+
}
|
25
|
+
function convertConfiguration(gltfBlock, definition, id) {
|
26
|
+
var _a;
|
27
|
+
const converted = {};
|
28
|
+
const configurationList = (_a = gltfBlock.configuration) !== null && _a !== void 0 ? _a : [];
|
29
|
+
for (const configObject of configurationList) {
|
30
|
+
if (configObject.id === "customEvent") {
|
31
|
+
const customEvent = definition.customEvents && definition.customEvents[configObject.value];
|
32
|
+
if (!customEvent) {
|
33
|
+
throw new Error(`/extensions/KHR_interactivity/nodes/${id}: Unknown custom event: ${configObject.value}`);
|
34
|
+
}
|
35
|
+
converted.eventId = customEvent.id;
|
36
|
+
converted.eventData = customEvent.values.map((v) => v.id);
|
37
|
+
}
|
38
|
+
else if (configObject.id === "variable") {
|
39
|
+
const variable = definition.variables && definition.variables[configObject.value];
|
40
|
+
if (!variable) {
|
41
|
+
throw new Error(`/extensions/KHR_interactivity/nodes/${id}: Unknown variable: ${configObject.value}`);
|
42
|
+
}
|
43
|
+
converted.variableName = variable.id;
|
44
|
+
}
|
45
|
+
else if (configObject.id === "path") {
|
46
|
+
// Convert from a GLTF path to a reference to the Babylon.js object
|
47
|
+
const pathValue = configObject.value;
|
48
|
+
converted.path = {
|
49
|
+
path: pathValue,
|
50
|
+
className: "FGPath",
|
51
|
+
};
|
52
|
+
}
|
53
|
+
else {
|
54
|
+
converted[configObject.id] = convertValueWithType(configObject, definition, `/extensions/KHR_interactivity/nodes/${id}`);
|
55
|
+
}
|
56
|
+
}
|
57
|
+
return converted;
|
58
|
+
}
|
59
|
+
function convertBlock(id, gltfBlock, definition) {
|
60
|
+
const className = gltfToFlowGraphTypeMap[gltfBlock.type];
|
61
|
+
if (!className) {
|
62
|
+
throw new Error(`/extensions/KHR_interactivity/nodes/${id}: Unknown block type: ${gltfBlock.type}`);
|
63
|
+
}
|
64
|
+
const uniqueId = id.toString();
|
65
|
+
const config = convertConfiguration(gltfBlock, definition, uniqueId);
|
66
|
+
const metadata = gltfBlock.metadata;
|
67
|
+
const dataInputs = [];
|
68
|
+
const dataOutputs = [];
|
69
|
+
const signalInputs = [];
|
70
|
+
const signalOutputs = [];
|
71
|
+
return {
|
72
|
+
className,
|
73
|
+
config,
|
74
|
+
uniqueId,
|
75
|
+
metadata,
|
76
|
+
dataInputs,
|
77
|
+
dataOutputs,
|
78
|
+
signalInputs,
|
79
|
+
signalOutputs,
|
80
|
+
};
|
81
|
+
}
|
82
|
+
/**
|
83
|
+
* @internal
|
84
|
+
* Converts a glTF Interactivity Extension to a serialized flow graph.
|
85
|
+
* @param gltf the interactivity data
|
86
|
+
* @returns a serialized flow graph
|
87
|
+
*/
|
88
|
+
export function convertGLTFToSerializedFlowGraph(gltf) {
|
89
|
+
var _a, _b, _c;
|
90
|
+
// create an empty serialized context to store the values of the connections
|
91
|
+
const context = {
|
92
|
+
uniqueId: RandomGUID(),
|
93
|
+
_userVariables: {},
|
94
|
+
_connectionValues: {},
|
95
|
+
};
|
96
|
+
const executionContexts = [context];
|
97
|
+
// Blocks converted to the flow graph json format
|
98
|
+
const flowGraphJsonBlocks = [];
|
99
|
+
for (let i = 0; i < gltf.nodes.length; i++) {
|
100
|
+
const gltfBlock = gltf.nodes[i];
|
101
|
+
const flowGraphJsonBlock = convertBlock(i, gltfBlock, gltf);
|
102
|
+
flowGraphJsonBlocks.push(flowGraphJsonBlock);
|
103
|
+
}
|
104
|
+
// Parse the connections
|
105
|
+
for (let i = 0; i < gltf.nodes.length; i++) {
|
106
|
+
const gltfBlock = gltf.nodes[i];
|
107
|
+
// get the block that was created in the previous step
|
108
|
+
const fgBlock = flowGraphJsonBlocks[i];
|
109
|
+
const gltfFlows = (_a = gltfBlock.flows) !== null && _a !== void 0 ? _a : [];
|
110
|
+
// for each output flow of the gltf block
|
111
|
+
for (const flow of gltfFlows) {
|
112
|
+
const socketOutName = flow.id;
|
113
|
+
// create an output connection for the flow graph block
|
114
|
+
const socketOut = {
|
115
|
+
uniqueId: RandomGUID(),
|
116
|
+
name: socketOutName,
|
117
|
+
_connectionType: FlowGraphConnectionType.Output,
|
118
|
+
connectedPointIds: [],
|
119
|
+
};
|
120
|
+
fgBlock.signalOutputs.push(socketOut);
|
121
|
+
// get the input node of this flow
|
122
|
+
const nodeInId = flow.node;
|
123
|
+
const nodeInSocketName = flow.socket;
|
124
|
+
// find the corresponding flow graph node
|
125
|
+
const nodeIn = flowGraphJsonBlocks[nodeInId];
|
126
|
+
if (!nodeIn) {
|
127
|
+
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}`);
|
128
|
+
}
|
129
|
+
// in all of the flow graph input connections, find the one with the same name as the socket
|
130
|
+
let socketIn = nodeIn.signalInputs.find((s) => s.name === nodeInSocketName);
|
131
|
+
// if the socket doesn't exist, create the input socket for the connection
|
132
|
+
if (!socketIn) {
|
133
|
+
socketIn = {
|
134
|
+
uniqueId: RandomGUID(),
|
135
|
+
name: nodeInSocketName,
|
136
|
+
_connectionType: FlowGraphConnectionType.Input,
|
137
|
+
connectedPointIds: [],
|
138
|
+
};
|
139
|
+
nodeIn.signalInputs.push(socketIn);
|
140
|
+
}
|
141
|
+
// connect the sockets
|
142
|
+
socketIn.connectedPointIds.push(socketOut.uniqueId);
|
143
|
+
socketOut.connectedPointIds.push(socketIn.uniqueId);
|
144
|
+
}
|
145
|
+
// for each input value of the gltf block
|
146
|
+
const gltfValues = (_b = gltfBlock.values) !== null && _b !== void 0 ? _b : [];
|
147
|
+
for (const value of gltfValues) {
|
148
|
+
const socketInName = value.id;
|
149
|
+
// create an input data connection for the flow graph block
|
150
|
+
const socketIn = {
|
151
|
+
uniqueId: RandomGUID(),
|
152
|
+
name: socketInName,
|
153
|
+
_connectionType: FlowGraphConnectionType.Input,
|
154
|
+
connectedPointIds: [],
|
155
|
+
};
|
156
|
+
fgBlock.dataInputs.push(socketIn);
|
157
|
+
if (value.value !== undefined) {
|
158
|
+
// if the value is set on the socket itself, store it in the context
|
159
|
+
const convertedValue = convertValueWithType(value, gltf, `/extensions/KHR_interactivity/nodes/${i}`);
|
160
|
+
// convertBlockInputType(gltfBlock, value, convertedValue, `/extensions/KHR_interactivity/nodes/${i}`);
|
161
|
+
context._connectionValues[socketIn.uniqueId] = convertedValue;
|
162
|
+
}
|
163
|
+
else if (value.node !== undefined && value.socket !== undefined) {
|
164
|
+
// if the value is connected with the output data of another socket, connect the two
|
165
|
+
const nodeOutId = value.node;
|
166
|
+
const nodeOutSocketName = value.socket;
|
167
|
+
// find the flow graph node that owns that output socket
|
168
|
+
const nodeOut = flowGraphJsonBlocks[nodeOutId];
|
169
|
+
if (!nodeOut) {
|
170
|
+
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}`);
|
171
|
+
}
|
172
|
+
let socketOut = nodeOut.dataOutputs.find((s) => s.name === nodeOutSocketName);
|
173
|
+
// if the socket doesn't exist, create it
|
174
|
+
if (!socketOut) {
|
175
|
+
socketOut = {
|
176
|
+
uniqueId: RandomGUID(),
|
177
|
+
name: nodeOutSocketName,
|
178
|
+
_connectionType: FlowGraphConnectionType.Output,
|
179
|
+
connectedPointIds: [],
|
180
|
+
};
|
181
|
+
nodeOut.dataOutputs.push(socketOut);
|
182
|
+
}
|
183
|
+
// connect the sockets
|
184
|
+
socketIn.connectedPointIds.push(socketOut.uniqueId);
|
185
|
+
socketOut.connectedPointIds.push(socketIn.uniqueId);
|
186
|
+
}
|
187
|
+
else {
|
188
|
+
throw new Error(`/extensions/KHR_interactivity/nodes/${i}: Invalid socket ${socketInName} in node ${i}`);
|
189
|
+
}
|
190
|
+
}
|
191
|
+
}
|
192
|
+
const variables = (_c = gltf.variables) !== null && _c !== void 0 ? _c : [];
|
193
|
+
// Parse variables
|
194
|
+
for (let i = 0; i < variables.length; i++) {
|
195
|
+
const variable = variables[i];
|
196
|
+
const variableName = variable.id;
|
197
|
+
context._userVariables[variableName] = convertValueWithType(variable, gltf, `/extensions/KHR_interactivity/variables/${i}`);
|
198
|
+
}
|
199
|
+
return {
|
200
|
+
allBlocks: flowGraphJsonBlocks,
|
201
|
+
executionContexts,
|
202
|
+
};
|
203
|
+
}
|
204
|
+
//# sourceMappingURL=interactivityFunctions.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"interactivityFunctions.js","sourceRoot":"","sources":["../../../../../../dev/lo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A2C,EAAE,IAAI,EAAE,2CAA2C,CAAC,EAAE,CAAC,CAAC;KAClK;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 = {\r\n path: pathValue,\r\n className: \"FGPath\",\r\n };\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"]}
|
@@ -0,0 +1,7 @@
|
|
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
|
+
};
|
@@ -0,0 +1,77 @@
|
|
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
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"interactivityPathCameraExtensions.js","sourceRoot":"","sources":["../../../../../../dev/loaders/src/glTF/2.0/Extensions/interactivityPathCameraExtensions.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,EAAE,sCAAwB;AAGxC,MAAM,YAAY,GAAG,yFAAyF,CAAC;AAE/G,SAAS,gBAAgB,CAAC,IAAmB,EAAE,OAAyB;IACpE,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,YAAY,CAAC,CAAC;IAC7C,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE;QAClC,MAAM,IAAI,KAAK,CAAC,gBAAgB,QAAQ,EAAE,CAAC,CAAC;KAC/C;IACD,MAAM,WAAW,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IACzC,MAAM,MAAM,GAAG,QAAQ,CAAC,OAAO,IAAI,QAAQ,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IACjE,IAAI,CAAC,MAAM,EAAE;QACT,MAAM,IAAI,KAAK,CAAC,iCAAiC,QAAQ,EAAE,CAAC,CAAC;KAChE;IACD,MAAM,aAAa,GAAG,MAAM,CAAC,cAAc,CAAC;IAC5C,IAAI,CAAC,aAAa,EAAE;QAChB,MAAM,IAAI,KAAK,CAAC,oCAAoC,QAAQ,EAAE,CAAC,CAAC;KACnE;IACD,MAAM,YAAY,GAAG,OAAO,CAAC,C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gBAC3B,MAAM;YACV,KAAK,MAAM;gBACP,aAAa,CAAC,IAAI,GAAG,KAAK,CAAC;gBAC3B,MAAM;YACV,KAAK,MAAM;gBACP,aAAa,CAAC,GAAG,GAAG,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"]}
|
@@ -0,0 +1,5 @@
|
|
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
|
@@ -0,0 +1 @@
|
|
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"]}
|
@@ -0,0 +1,7 @@
|
|
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
|
+
};
|
@@ -0,0 +1,87 @@
|
|
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
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"interactivityPathMaterialExtensions.js","sourceRoot":"","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QAAQ,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAAC;YACrC,OAAO,MAAA,QAAQ,CAAC,eAAe,0CAAE,KAAK,CAAC;SAC1C;aAAM;YACH,OAAQ,gBAAgB,CAAC,CAAC,CAAS,CAAC,eAAe,CAAC,CAAC;SACxD;IACL,CAAC;IACD,UAAU,CAAC,IAAmB,EAAE,OAAyB,EAAE,KAAU;QACjE,MAAM,EAAE,gBAAgB,EAAE,eAAe,EAAE,GAAG,kBAAkB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAChF,KAAK,MAAM,QAAQ,IAAI,gBAAgB,EAAE;YACrC,IAAI,eAAe,KAAK,qBAAqB,EAAE;gBAC1C,QAAQ,CAAC,WAAuB,CAAC,MAAM,GAAG,KAAK,CAAC;gBAChD,QAAQ,CAAC,WAAuB,CAAC,MAAM,GAAG,KAAK,CAAC;aACpD;iBAAM,IAAI,eAAe,KAAK,0BAA0B,EAAE;gBACvD,QAAQ,CAAC,eAAgB,CAAC,KAAK,GAAG,KAAK,CAAC;aAC3C;iBAAM;gBACH,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"]}
|
@@ -0,0 +1,50 @@
|
|
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
|
@@ -0,0 +1 @@
|
|
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,O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,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"]}
|
@@ -0,0 +1,93 @@
|
|
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, } 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
|
+
};
|
88
|
+
export const gltfTypeToBabylonType = {
|
89
|
+
float2: "Vector2",
|
90
|
+
float3: "Vector3",
|
91
|
+
float4: "Vector4",
|
92
|
+
};
|
93
|
+
//# sourceMappingURL=interactivityUtils.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"interactivityUtils.js","sourceRoot":"","sources":["../../../../../../dev/loaders/src/glTF/2.0/Extensions/interactivityUtils.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,OAAO,EAAE,6BAA6B,EAAE,gFAAkE;AAC1G,OAAO,EAAE,4BAA4B,EAAE,+EAAiE;AACxG,OAAO,EAAE,wBAAwB,EAAE,+EAAiE;AACpG,OAAO,EAAE,mBAAmB,EAAE,sFAAwE;AACtG,OAAO,EAAE,6BAA6B,EAAE,oFAAsE;AAC9G,OAAO,EAAE,gCAAgC,EAAE,mFAAqE;AAChH,OAAO,EAAE,sBAAsB,EAAE,yFAA2E;AAC5G,OAAO,EAAE,yBAAyB,EAAE,2EAA6D;AACjG,OAAO,EAAE,yBAAyB,EAAE,gFAAkE;AACtG,OAAO,EACH,iBAAiB,EACjB,oBAAoB,EACpB,sBAAsB,EACtB,sBAAsB,EACtB,sBAAsB,EACtB,iBAAiB,EACjB,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACnB,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,oBAAoB,EACpB,uBAAuB,EACvB,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,EACnB,sBAAsB,EACtB,yBAAyB,EACzB,gBAAgB,EAChB,6BAA6B,EAC7B,yBAAyB,EACzB,gCAAgC,EAChC,mBAAmB,EACnB,mBAAmB,EACnB,sBAAsB,EACtB,sBAAsB,EACtB,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAClB,sBAAsB,EACtB,iBAAiB,EACjB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AAmB,CAAC,SAAS;IAC3C,YAAY,EAAE,mBAAmB,CAAC,SAAS;IAC3C,UAAU,EAAE,iBAAiB,CAAC,SAAS;IACvC,UAAU,EAAE,iBAAiB,CAAC,SAAS;IACvC,WAAW,EAAE,kBAAkB,CAAC,SAAS;IACzC,YAAY,EAAE,mBAAmB,CAAC,SAAS;IAC3C,WAAW,EAAE,kBAAkB,CAAC,SAAS;IACzC,WAAW,EAAE,sBAAsB,CAAC,SAAS;IAC7C,UAAU,EAAE,iBAAiB,CAAC,SAAS;IACvC,aAAa,EAAE,oBAAoB,CAAC,SAAS;IAC7C,gBAAgB,EAAE,uBAAuB,CAAC,SAAS;IACnD,UAAU,EAAE,iBAAiB,CAAC,SAAS;IACvC,YAAY,EAAE,mBAAmB,CAAC,SAAS;IAC3C,eAAe,EAAE,sBAAsB,CAAC,SAAS;IACjD,eAAe,EAAE,sBAAsB,CAAC,SAAS;CACpD,CAAC;AAEF,MAAM,CAAC,MAAM,qBAAqB,GAAQ;IACtC,MAAM,EAAE,SAAS;IACjB,MAAM,EAAE,SAAS;IACjB,MAAM,EAAE,SAAS;CACpB,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport { FlowGraphSceneReadyEventBlock } from \"core/FlowGraph/Blocks/Event/flowGraphSceneReadyEventBlock\";\r\nimport { FlowGraphSceneTickEventBlock } from \"core/FlowGraph/Blocks/Event/flowGraphSceneTickEventBlock\";\r\nimport { FlowGraphConsoleLogBlock } from \"core/FlowGraph/Blocks/Execution/flowGraphConsoleLogBlock\";\r\nimport { FlowGraphTimerBlock } from \"core/FlowGraph/Blocks/Execution/ControlFlow/flowGraphTimerBlock\";\r\nimport { FlowGraphSendCustomEventBlock } from \"core/FlowGraph/Blocks/Execution/flowGraphSendCustomEventBlock\";\r\nimport { FlowGraphReceiveCustomEventBlock } from \"core/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock\";\r\nimport { FlowGraphSequenceBlock } from \"core/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSequenceBlock\";\r\nimport { FlowGraphGetPropertyBlock } from \"core/FlowGraph/Blocks/Data/flowGraphGetPropertyBlock\";\r\nimport { FlowGraphSetPropertyBlock } from \"core/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock\";\r\nimport {\r\n FlowGraphAddBlock,\r\n FlowGraphRandomBlock,\r\n FlowGraphLessThanBlock,\r\n FlowGraphMultiplyBlock,\r\n FlowGraphSubtractBlock,\r\n FlowGraphDotBlock,\r\n FlowGraphEBlock,\r\n FlowGraphPiBlock,\r\n FlowGraphInfBlock,\r\n FlowGraphNaNBlock,\r\n FlowGraphAbsBlock,\r\n FlowGraphSignBlock,\r\n FlowGraphTruncBlock,\r\n FlowGraphFloorBlock,\r\n FlowGraphCeilBlock,\r\n FlowGraphFractBlock,\r\n FlowGraphNegBlock,\r\n FlowGraphDivideBlock,\r\n FlowGraphRemainderBlock,\r\n FlowGraphMinBlock,\r\n FlowGraphMaxBlock,\r\n FlowGraphClampBlock,\r\n FlowGraphSaturateBlock,\r\n FlowGraphInterpolateBlock,\r\n FlowGraphEqBlock,\r\n FlowGraphLessThanOrEqualBlock,\r\n FlowGraphGreaterThanBlock,\r\n FlowGraphGreaterThanOrEqualBlock,\r\n FlowGraphIsNanBlock,\r\n FlowGraphIsInfBlock,\r\n FlowGraphDegToRadBlock,\r\n FlowGraphRadToDegBlock,\r\n FlowGraphSinBlock,\r\n FlowGraphCosBlock,\r\n FlowGraphTanBlock,\r\n FlowGraphAsinBlock,\r\n FlowGraphAcosBlock,\r\n FlowGraphAtanBlock,\r\n FlowGraphAtan2Block,\r\n FlowGraphSinhBlock,\r\n FlowGraphCoshBlock,\r\n FlowGraphTanhBlock,\r\n FlowGraphAsinhBlock,\r\n FlowGraphAcoshBlock,\r\n FlowGraphAtanhBlock,\r\n FlowGraphExpBlock,\r\n FlowGraphLog2Block,\r\n FlowGraphLogBlock,\r\n FlowGraphLog10Block,\r\n FlowGraphSqrtBlock,\r\n FlowGraphCubeRootBlock,\r\n FlowGraphPowBlock,\r\n FlowGraphLengthBlock,\r\n FlowGraphNormalizeBlock,\r\n FlowGraphCrossBlock,\r\n FlowGraphRotate2DBlock,\r\n FlowGraphRotate3DBlock,\r\n} from \"core/FlowGraph/Blocks/Data/Math/flowGraphMathBlocks\";\r\nimport { FlowGraphDoNBlock } from \"core/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDoNBlock\";\r\nimport { FlowGraphGetVariableBlock } from \"core/FlowGraph/Blocks/Data/flowGraphGetVariableBlock\";\r\nimport { FlowGraphSetVariableBlock } from \"core/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock\";\r\nimport { FlowGraphWhileLoopBlock } from \"core/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWhileLoopBlock\";\r\n\r\nexport const gltfToFlowGraphTypeMap: { [key: string]: string } = {\r\n \"lifecycle/onStart\": FlowGraphSceneReadyEventBlock.ClassName,\r\n \"lifecycle/onTick\": FlowGraphSceneTickEventBlock.ClassName,\r\n log: FlowGraphConsoleLogBlock.ClassName,\r\n \"flow/delay\": FlowGraphTimerBlock.ClassName,\r\n \"customEvent/send\": FlowGraphSendCustomEventBlock.ClassName,\r\n \"customEvent/receive\": FlowGraphReceiveCustomEventBlock.ClassName,\r\n \"flow/sequence\": FlowGraphSequenceBlock.ClassName,\r\n \"world/get\": FlowGraphGetPropertyBlock.ClassName,\r\n \"world/set\": FlowGraphSetPropertyBlock.ClassName,\r\n \"flow/doN\": FlowGraphDoNBlock.ClassName,\r\n \"variable/get\": FlowGraphGetVariableBlock.ClassName,\r\n \"variable/set\": FlowGraphSetVariableBlock.ClassName,\r\n \"flow/whileLoop\": FlowGraphWhileLoopBlock.ClassName,\r\n \"math/random\": FlowGraphRandomBlock.ClassName,\r\n \"math/e\": FlowGraphEBlock.ClassName,\r\n \"math/pi\": FlowGraphPiBlock.ClassName,\r\n \"math/inf\": FlowGraphInfBlock.ClassName,\r\n \"math/nan\": FlowGraphNaNBlock.ClassName,\r\n \"math/abs\": FlowGraphAbsBlock.ClassName,\r\n \"math/sign\": FlowGraphSignBlock.ClassName,\r\n \"math/trunc\": FlowGraphTruncBlock.ClassName,\r\n \"math/floor\": FlowGraphFloorBlock.ClassName,\r\n \"math/ceil\": FlowGraphCeilBlock.ClassName,\r\n \"math/fract\": FlowGraphFractBlock.ClassName,\r\n \"math/neg\": FlowGraphNegBlock.ClassName,\r\n \"math/add\": FlowGraphAddBlock.ClassName,\r\n \"math/sub\": FlowGraphSubtractBlock.ClassName,\r\n \"math/mul\": FlowGraphMultiplyBlock.ClassName,\r\n \"math/div\": FlowGraphDivideBlock.ClassName,\r\n \"math/rem\": FlowGraphRemainderBlock.ClassName,\r\n \"math/min\": FlowGraphMinBlock.ClassName,\r\n \"math/max\": FlowGraphMaxBlock.ClassName,\r\n \"math/clamp\": FlowGraphClampBlock.ClassName,\r\n \"math/saturate\": FlowGraphSaturateBlock.ClassName,\r\n \"math/mix\": FlowGraphInterpolateBlock.ClassName,\r\n \"math/eq\": FlowGraphEqBlock.ClassName,\r\n \"math/lt\": FlowGraphLessThanBlock.ClassName,\r\n \"math/le\": FlowGraphLessThanOrEqualBlock.ClassName,\r\n \"math/gt\": FlowGraphGreaterThanBlock.ClassName,\r\n \"math/ge\": FlowGraphGreaterThanOrEqualBlock.ClassName,\r\n \"math/isnan\": FlowGraphIsNanBlock.ClassName,\r\n \"math/isinf\": FlowGraphIsInfBlock.ClassName,\r\n \"math/rad\": FlowGraphDegToRadBlock.ClassName,\r\n \"math/deg\": FlowGraphRadToDegBlock.ClassName,\r\n \"math/sin\": FlowGraphSinBlock.ClassName,\r\n \"math/cos\": FlowGraphCosBlock.ClassName,\r\n \"math/tan\": FlowGraphTanBlock.ClassName,\r\n \"math/asin\": FlowGraphAsinBlock.ClassName,\r\n \"math/acos\": FlowGraphAcosBlock.ClassName,\r\n \"math/atan\": FlowGraphAtanBlock.ClassName,\r\n \"math/atan2\": FlowGraphAtan2Block.ClassName,\r\n \"math/sinh\": FlowGraphSinhBlock.ClassName,\r\n \"math/cosh\": FlowGraphCoshBlock.ClassName,\r\n \"math/tanh\": FlowGraphTanhBlock.ClassName,\r\n \"math/asinh\": FlowGraphAsinhBlock.ClassName,\r\n \"math/acosh\": FlowGraphAcoshBlock.ClassName,\r\n \"math/atanh\": FlowGraphAtanhBlock.ClassName,\r\n \"math/exp\": FlowGraphExpBlock.ClassName,\r\n \"math/log\": FlowGraphLogBlock.ClassName,\r\n \"math/log2\": FlowGraphLog2Block.ClassName,\r\n \"math/log10\": FlowGraphLog10Block.ClassName,\r\n \"math/sqrt\": FlowGraphSqrtBlock.ClassName,\r\n \"math/cbrt\": FlowGraphCubeRootBlock.ClassName,\r\n \"math/pow\": FlowGraphPowBlock.ClassName,\r\n \"math/length\": FlowGraphLengthBlock.ClassName,\r\n \"math/normalize\": FlowGraphNormalizeBlock.ClassName,\r\n \"math/dot\": FlowGraphDotBlock.ClassName,\r\n \"math/cross\": FlowGraphCrossBlock.ClassName,\r\n \"math/rotate2d\": FlowGraphRotate2DBlock.ClassName,\r\n \"math/rotate3d\": FlowGraphRotate3DBlock.ClassName,\r\n};\r\n\r\nexport const gltfTypeToBabylonType: any = {\r\n float2: \"Vector2\",\r\n float3: \"Vector3\",\r\n float4: \"Vector4\",\r\n};\r\n"]}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@babylonjs/loaders",
|
3
|
-
"version": "6.33.
|
3
|
+
"version": "6.33.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": "^6.33.
|
21
|
+
"@babylonjs/core": "^6.33.2",
|
22
22
|
"@dev/build-tools": "^1.0.0",
|
23
23
|
"@lts/loaders": "^1.0.0",
|
24
|
-
"babylonjs-gltf2interface": "^6.33.
|
24
|
+
"babylonjs-gltf2interface": "^6.33.2"
|
25
25
|
},
|
26
26
|
"peerDependencies": {
|
27
27
|
"@babylonjs/core": "^6.0.0",
|