Skip to content

Commit fe7469f

Browse files
deltakoshDavid Catuhe
andauthored
Introducting the Node Particle Editor! (#16718)
- [x] On end trigger - [x] On start trigger - [x] support worldMatrix from emitter - [x] Preview popup - [x] Flow map - [x] Expose emitter - [x] Sprite sheet - [x] Delay start - [x] Particle trigger - [x] Condition - [x] Simple condition - [x] Auto expendable blocks - [x] Basic update - [x] Snippet & loading API - [x] Teleport - [x] Elbow - [x] Custom Emitter Type - [x] Trigonometrics - [x] Converter ![image](https://github.com/user-attachments/assets/7c1c1de0-780e-4074-ba48-26282b4a2eff) --------- Co-authored-by: David Catuhe <[email protected]>
1 parent f64cea8 commit fe7469f

File tree

177 files changed

+14564
-145
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

177 files changed

+14564
-145
lines changed

.vscode/launch.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,20 @@
239239
"url": "http://localhost:1344",
240240
"preLaunchTask": "Node Render Graph Editor Serve (Dev)"
241241
},
242+
{
243+
"type": "msedge",
244+
"request": "launch",
245+
"name": "Node Particle Editor development (Edge)",
246+
"url": "http://localhost:1345",
247+
"preLaunchTask": "Node Particle Editor Serve (Dev)"
248+
},
249+
{
250+
"type": "chrome",
251+
"request": "launch",
252+
"name": "Node Particle Editor development (Chrome)",
253+
"url": "http://localhost:1345",
254+
"preLaunchTask": "Node Particle Editor Serve (Dev)"
255+
},
242256
{
243257
/*
244258
Launch the playground to be use to test changes in dev packages

.vscode/tasks.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,42 @@
467467
},
468468
"problemMatcher": ["$ts-webpack-watch", "$tslint-webpack-watch"]
469469
},
470+
{
471+
"label": "Node Particle Editor Serve for core (Dev)",
472+
"type": "shell",
473+
"command": "npm",
474+
"dependsOn": "CDN Serve and watch (Dev)",
475+
"runOptions": {
476+
"instanceLimit": 1
477+
},
478+
"options": {
479+
"cwd": "${workspaceFolder}"
480+
},
481+
"args": ["run", "serve", "-w", "@tools/node-particle-editor"],
482+
"isBackground": true,
483+
"presentation": {
484+
"group": "serve"
485+
},
486+
"problemMatcher": ["$ts-webpack-watch", "$tslint-webpack-watch"]
487+
},
488+
{
489+
"label": "Node Particle Editor Serve (Dev)",
490+
"type": "shell",
491+
"command": "npm",
492+
"dependsOn": "CDN Serve and watch (Dev)",
493+
"runOptions": {
494+
"instanceLimit": 1
495+
},
496+
"options": {
497+
"cwd": "${workspaceFolder}"
498+
},
499+
"args": ["run", "serve", "-w", "@tools/node-particle-editor"],
500+
"isBackground": true,
501+
"presentation": {
502+
"group": "serve"
503+
},
504+
"problemMatcher": ["$ts-webpack-watch", "$tslint-webpack-watch"]
505+
},
470506
{
471507
"label": "VSM Serve for core (Dev)",
472508
"type": "shell",

package-lock.json

Lines changed: 120 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@
6464
"build:lts": "npm run build:assets && npm run build:source:lts",
6565
"build:source": "tsc -b ./tsconfig.devpackages.json",
6666
"build:source:lts": "npx nx run-many --target=compile --projects=@lts/core,@lts/gui,@lts/loaders,@lts/materials,@lts/post-processes,@lts/procedural-textures,@lts/serializers --parallel=1",
67-
"build:umd": "nx run-many --target=build --parallel --maxParallel=6 --projects=babylonjs,babylonjs-gui,babylonjs-inspector,babylonjs-loaders,babylonjs-materials,babylonjs-serializers,babylonjs-post-process,babylonjs-procedural-textures,babylonjs-node-editor,babylonjs-node-geometry-editor,babylonjs-node-render-graph-editor,babylonjs-gui-editor,babylonjs-ktx2decoder,babylonjs-accessibility,babylonjs-addons",
68-
"build:es6": "nx run-many --target=build --parallel --maxParallel=6 --projects=@babylonjs/core,@babylonjs/gui,@babylonjs/loaders,@babylonjs/materials,@babylonjs/serializers,@babylonjs/post-processes,@babylonjs/procedural-textures,@babylonjs/node-editor,@babylonjs/node-geometry-editor,@babylonjs/node-render-graph-editor,@babylonjs/inspector,@babylonjs/gui-editor,@babylonjs/viewer,@babylonjs/shared-ui-components,@babylonjs/addons,@babylonjs/accessibility,@babylonjs/ktx2decoder",
67+
"build:umd": "nx run-many --target=build --parallel --maxParallel=6 --projects=babylonjs,babylonjs-gui,babylonjs-inspector,babylonjs-loaders,babylonjs-materials,babylonjs-serializers,babylonjs-post-process,babylonjs-procedural-textures,babylonjs-node-editor,babylonjs-node-geometry-editor,babylonjs-node-render-graph-editor,babylonjs-node-particle-editor,babylonjs-gui-editor,babylonjs-ktx2decoder,babylonjs-accessibility,babylonjs-addons",
68+
"build:es6": "nx run-many --target=build --parallel --maxParallel=6 --projects=@babylonjs/core,@babylonjs/gui,@babylonjs/loaders,@babylonjs/materials,@babylonjs/serializers,@babylonjs/post-processes,@babylonjs/procedural-textures,@babylonjs/node-editor,@babylonjs/node-geometry-editor,@babylonjs/node-render-graph-editor,babylonjs-node-particle-editor,@babylonjs/inspector,@babylonjs/gui-editor,@babylonjs/viewer,@babylonjs/shared-ui-components,@babylonjs/addons,@babylonjs/accessibility,@babylonjs/ktx2decoder",
6969
"watch:shaders": "build-tools -c build-shaders --global --watch",
7070
"watch:assets": "build-tools -c pa --global --watch",
7171
"watch:source:dev": "tsc -b ./tsconfig.devpackages.json -w",

packages/dev/buildTools/src/generateDeclaration.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,11 @@ function GetPackageDeclaration(
366366
}
367367
}
368368

369+
// if the import is a return-type import from core, we remove the import and the dot
370+
if (line.match(/import\("core(.*)"\)\./g)) {
371+
line = line.replace(/import\("(.*)"\)\./g, "");
372+
}
373+
369374
if (excludeLine) {
370375
lines[i] = "";
371376
} else {
@@ -410,6 +415,9 @@ function GetPackageDeclaration(
410415
const devPackageToUse = isValidDevPackageName(localDevPackageMap, true) ? localDevPackageMap : devPackageName;
411416
const originalNamespace = getPublicPackageName(getPackageMappingByDevName(devPackageToUse).namespace);
412417
const namespace = getPublicPackageName(getPackageMappingByDevName(devPackageToUse).namespace, fullPath /*, fullPath*/);
418+
if (fullPath.indexOf("nodeParticleBuildState") !== -1) {
419+
console.log(`Replacing ${alias} with ${namespace}.${realClassName} in ${fullPath} for package ${devPackageToUse} (${originalNamespace})`);
420+
}
413421
if (namespace !== defaultModuleName || originalNamespace !== namespace || alias !== realClassName) {
414422
const matchRegex = new RegExp(`([ <])(${alias})([^\\w])`, "g");
415423
if (exported) {

packages/dev/buildTools/src/packageMapping.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export type DevPackageName =
1616
| "node-editor"
1717
| "node-geometry-editor"
1818
| "node-render-graph-editor"
19+
| "node-particle-editor"
1920
| "gui-editor"
2021
| "accessibility"
2122
| "viewer"
@@ -34,6 +35,7 @@ export type UMDPackageName =
3435
| "babylonjs-node-editor"
3536
| "babylonjs-node-geometry-editor"
3637
| "babylonjs-node-render-graph-editor"
38+
| "babylonjs-node-particle-editor"
3739
| "babylonjs-gui-editor"
3840
| "babylonjs-accessibility"
3941
| "babylonjs-viewer"
@@ -53,6 +55,7 @@ export type NamespacePackageName =
5355
| "BABYLON.NodeEditor"
5456
| "BABYLON.NodeGeometryEditor"
5557
| "BABYLON.NodeRenderGraphEditor"
58+
| "BABYLON.NodeParticleEditor"
5659
| "BABYLON.GuiEditor"
5760
| "BABYLON.Accessibility"
5861
| "ADDONS"
@@ -64,6 +67,7 @@ export type NamespacePackageName =
6467
| "BABYLON.NodeEditor.SharedUIComponents"
6568
| "BABYLON.NodeGeometryEditor.SharedUIComponents"
6669
| "BABYLON.NodeRenderGraphEditor.SharedUIComponents"
70+
| "BABYLON.NodeParticleEditor.SharedUIComponents"
6771
| "BABYLON.GuiEditor.SharedUIComponents";
6872
export type ES6PackageName =
6973
| "@babylonjs/core"
@@ -76,6 +80,7 @@ export type ES6PackageName =
7680
| "@babylonjs/node-editor"
7781
| "@babylonjs/node-geometry-editor"
7882
| "@babylonjs/node-render-graph-editor"
83+
| "@babylonjs/node-particle-editor"
7984
| "@babylonjs/gui-editor"
8085
| "@babylonjs/accessibility"
8186
| "@babylonjs/post-processes"
@@ -127,6 +132,10 @@ export const umdPackageMapping: { [key in UMDPackageName]: { baseDir: string; ba
127132
baseDir: "nodeRenderGraphEditor",
128133
baseFilename: "babylon.nodeRenderGraphEditor",
129134
},
135+
"babylonjs-node-particle-editor": {
136+
baseDir: "nodeParticleEditor",
137+
baseFilename: "babylon.nodeParticleEditor",
138+
},
130139
"babylonjs-gui-editor": {
131140
baseDir: "guiEditor",
132141
baseFilename: "babylon.guiEditor",
@@ -198,6 +207,12 @@ const packageMapping: {
198207
// }
199208
return "babylonjs-node-render-graph-editor";
200209
},
210+
"node-particle-editor": (_filePath?: string) => {
211+
// if (filePath && filePath.indexOf("sharedUiComponents") !== -1) {
212+
// return "babylonjs-shared-ui-components";
213+
// }
214+
return "babylonjs-node-particle-editor";
215+
},
201216
"gui-editor": (_filePath?: string) => {
202217
// if (filePath && filePath.indexOf("sharedUiComponents") !== -1) {
203218
// return "babylonjs-shared-ui-components";
@@ -223,6 +238,7 @@ const packageMapping: {
223238
"node-editor": "@babylonjs/node-editor",
224239
"node-geometry-editor": "@babylonjs/node-geometry-editor",
225240
"node-render-graph-editor": "@babylonjs/node-render-graph-editor",
241+
"node-particle-editor": "@babylonjs/node-particle-editor",
226242
"gui-editor": "@babylonjs/gui-editor",
227243
accessibility: "@babylonjs/accessibility",
228244
"post-processes": "@babylonjs/post-processes",
@@ -243,6 +259,7 @@ const packageMapping: {
243259
"node-editor": "@babylonjs/esm",
244260
"node-geometry-editor": "@babylonjs/esm",
245261
"node-render-graph-editor": "@babylonjs/esm",
262+
"node-particle-editor": "@babylonjs/esm",
246263
"gui-editor": "@babylonjs/esm",
247264
accessibility: "@babylonjs/accessibility",
248265
"post-processes": "@babylonjs/esm",
@@ -335,6 +352,17 @@ const packageMapping: {
335352
}
336353
return "BABYLON.NodeRenderGraphEditor";
337354
},
355+
"node-particle-editor": (filePath?: string) => {
356+
if (filePath) {
357+
if (filePath.includes("shared-ui-components/") || filePath.includes("/sharedUiComponents/")) {
358+
// was .endsWith
359+
return "BABYLON.NodeParticleEditor.SharedUIComponents";
360+
} else if (filePath.includes("babylonjs-gltf2interface")) {
361+
return "BABYLON.GLTF2";
362+
}
363+
}
364+
return "BABYLON.NodeParticleEditor";
365+
},
338366
"gui-editor": (filePath?: string) => {
339367
if (filePath) {
340368
if (filePath.includes("shared-ui-components/") || filePath.includes("/sharedUiComponents/")) {

packages/dev/core/src/Particles/EmitterTypes/customParticleEmitter.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ export class CustomParticleEmitter implements IParticleEmitterType {
2222
*/
2323
public particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void = () => {};
2424

25+
/**
26+
* Gets or sets the direction generator that will create the initial direction of each particle.
27+
* * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
28+
*/
29+
public particleDirectionGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void = () => {};
30+
2531
/**
2632
* Creates a new instance CustomParticleEmitter
2733
*/
@@ -37,7 +43,9 @@ export class CustomParticleEmitter implements IParticleEmitterType {
3743
public startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void {
3844
const tmpVector = TmpVectors.Vector3[0];
3945

40-
if (this.particleDestinationGenerator) {
46+
if (this.particleDirectionGenerator) {
47+
this.particleDirectionGenerator(-1, particle, tmpVector);
48+
} else if (this.particleDestinationGenerator) {
4149
this.particleDestinationGenerator(-1, particle, tmpVector);
4250

4351
// Get direction

packages/dev/core/src/Particles/IParticleSystem.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,10 @@ export interface IParticleSystem {
332332
* An event triggered when the system is stopped
333333
*/
334334
onStoppedObservable: Observable<IParticleSystem>;
335+
/**
336+
* An event triggered when the system is started
337+
*/
338+
onStartedObservable: Observable<IParticleSystem>;
335339
/**
336340
* Clones the particle system.
337341
* @param name The name of the cloned object

0 commit comments

Comments
 (0)