@babylonjs/core 8.45.1 → 8.45.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AudioV2/webAudio/components/webAudioParameterComponent.js +1 -3
- package/AudioV2/webAudio/components/webAudioParameterComponent.js.map +1 -1
- package/Cameras/Inputs/geospatialCameraPointersInput.d.ts +4 -0
- package/Cameras/Inputs/geospatialCameraPointersInput.js +56 -3
- package/Cameras/Inputs/geospatialCameraPointersInput.js.map +1 -1
- package/Cameras/Inputs/index.d.ts +1 -0
- package/Cameras/Inputs/index.js +1 -0
- package/Cameras/Inputs/index.js.map +1 -1
- package/Cameras/geospatialCamera.d.ts +3 -2
- package/Cameras/geospatialCamera.js +4 -4
- package/Cameras/geospatialCamera.js.map +1 -1
- package/Engines/Extensions/engine.debugging.d.ts +4 -0
- package/Engines/Extensions/engine.debugging.js.map +1 -1
- package/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/volumetricLightingTask.d.ts +1 -1
- package/FrameGraph/Tasks/PostProcesses/volumetricLightingTask.js.map +1 -1
- package/FrameGraph/frameGraphContext.js +3 -3
- package/FrameGraph/frameGraphContext.js.map +1 -1
- package/FrameGraph/frameGraphTask.js +4 -4
- package/FrameGraph/frameGraphTask.js.map +1 -1
- package/Lights/Shadows/cascadedShadowGenerator.js +1 -1
- package/Lights/Shadows/cascadedShadowGenerator.js.map +1 -1
- package/Lights/Shadows/shadowGenerator.js +3 -3
- package/Lights/Shadows/shadowGenerator.js.map +1 -1
- package/Lights/lightingVolume.js +6 -6
- package/Lights/lightingVolume.js.map +1 -1
- package/Materials/PBR/pbrBaseMaterial.d.ts +2 -1
- package/Materials/PBR/pbrBaseMaterial.js +1 -0
- package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
- package/Materials/PBR/pbrSubSurfaceConfiguration.d.ts +2 -0
- package/Materials/PBR/pbrSubSurfaceConfiguration.js +8 -4
- package/Materials/PBR/pbrSubSurfaceConfiguration.js.map +1 -1
- package/Materials/Textures/Procedurals/proceduralTexture.js +2 -2
- package/Materials/Textures/Procedurals/proceduralTexture.js.map +1 -1
- package/Materials/Textures/renderTargetTexture.js +2 -2
- package/Materials/Textures/renderTargetTexture.js.map +1 -1
- package/Misc/minMaxReducer.js +2 -2
- package/Misc/minMaxReducer.js.map +1 -1
- package/Particles/Node/Blocks/Conditions/particleConditionBlock.js +2 -0
- package/Particles/Node/Blocks/Conditions/particleConditionBlock.js.map +1 -1
- package/Particles/Node/Blocks/Update/updateRemapBlock.d.ts +39 -0
- package/Particles/Node/Blocks/Update/updateRemapBlock.js +93 -0
- package/Particles/Node/Blocks/Update/updateRemapBlock.js.map +1 -0
- package/Particles/Node/Blocks/index.d.ts +2 -1
- package/Particles/Node/Blocks/index.js +2 -1
- package/Particles/Node/Blocks/index.js.map +1 -1
- package/Particles/Node/Blocks/particleLocalVariableBlock.d.ts +2 -0
- package/Particles/Node/Blocks/particleLocalVariableBlock.js +22 -10
- package/Particles/Node/Blocks/particleLocalVariableBlock.js.map +1 -1
- package/Particles/Node/Blocks/particleMathBlock.d.ts +4 -0
- package/Particles/Node/Blocks/particleMathBlock.js +4 -0
- package/Particles/Node/Blocks/particleMathBlock.js.map +1 -1
- package/Particles/Node/Blocks/particleNumberMathBlock.d.ts +60 -0
- package/Particles/Node/Blocks/particleNumberMathBlock.js +149 -0
- package/Particles/Node/Blocks/particleNumberMathBlock.js.map +1 -0
- package/Particles/Node/Blocks/{particleModuloBlock.d.ts → particleVectorMathBlock.d.ts} +25 -4
- package/Particles/Node/Blocks/{particleModuloBlock.js → particleVectorMathBlock.js} +59 -24
- package/Particles/Node/Blocks/particleVectorMathBlock.js.map +1 -0
- package/Particles/Node/Blocks/systemBlock.d.ts +4 -0
- package/Particles/Node/Blocks/systemBlock.js +25 -5
- package/Particles/Node/Blocks/systemBlock.js.map +1 -1
- package/Particles/Node/nodeParticleSystemSet.helper.js +71 -0
- package/Particles/Node/nodeParticleSystemSet.helper.js.map +1 -1
- package/Particles/baseParticleSystem.d.ts +1 -1
- package/Particles/baseParticleSystem.js +1 -1
- package/Particles/baseParticleSystem.js.map +1 -1
- package/Particles/particle.d.ts +4 -0
- package/Particles/particle.js +3 -0
- package/Particles/particle.js.map +1 -1
- package/Probes/reflectionProbe.js +2 -2
- package/Probes/reflectionProbe.js.map +1 -1
- package/Rendering/depthRenderer.js +2 -2
- package/Rendering/depthRenderer.js.map +1 -1
- package/XR/features/WebXRControllerPhysics.d.ts +30 -1
- package/XR/features/WebXRControllerPhysics.js +269 -16
- package/XR/features/WebXRControllerPhysics.js.map +1 -1
- package/XR/features/WebXRHandTracking.js +36 -2
- package/XR/features/WebXRHandTracking.js.map +1 -1
- package/package.json +1 -1
- package/Particles/Node/Blocks/particleModuloBlock.js.map +0 -1
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { NodeParticleConnectionPoint } from "../../nodeParticleBlockConnectionPoint.js";
|
|
2
|
+
import type { NodeParticleBuildState } from "../../nodeParticleBuildState.js";
|
|
3
|
+
import { NodeParticleBlock } from "../../nodeParticleBlock.js";
|
|
4
|
+
/**
|
|
5
|
+
* Block used to update the remap value of a particle
|
|
6
|
+
*/
|
|
7
|
+
export declare class UpdateRemapBlock extends NodeParticleBlock {
|
|
8
|
+
/**
|
|
9
|
+
* Create a new UpdateRemapBlock
|
|
10
|
+
* @param name defines the block name
|
|
11
|
+
*/
|
|
12
|
+
constructor(name: string);
|
|
13
|
+
/**
|
|
14
|
+
* Gets the particle component
|
|
15
|
+
*/
|
|
16
|
+
get particle(): NodeParticleConnectionPoint;
|
|
17
|
+
/**
|
|
18
|
+
* Gets the remapColor input component
|
|
19
|
+
*/
|
|
20
|
+
get remapColor(): NodeParticleConnectionPoint;
|
|
21
|
+
/**
|
|
22
|
+
* Gets the remapAlpha input component
|
|
23
|
+
*/
|
|
24
|
+
get remapAlpha(): NodeParticleConnectionPoint;
|
|
25
|
+
/**
|
|
26
|
+
* Gets the output component
|
|
27
|
+
*/
|
|
28
|
+
get output(): NodeParticleConnectionPoint;
|
|
29
|
+
/**
|
|
30
|
+
* Gets the current class name
|
|
31
|
+
* @returns the class name
|
|
32
|
+
*/
|
|
33
|
+
getClassName(): string;
|
|
34
|
+
/**
|
|
35
|
+
* Builds the block
|
|
36
|
+
* @param state defines the current build state
|
|
37
|
+
*/
|
|
38
|
+
_build(state: NodeParticleBuildState): void;
|
|
39
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { Vector2, Vector4 } from "../../../../Maths/math.vector.js";
|
|
2
|
+
import { RegisterClass } from "../../../../Misc/typeStore.js";
|
|
3
|
+
import { NodeParticleBlock } from "../../nodeParticleBlock.js";
|
|
4
|
+
import { NodeParticleBlockConnectionPointTypes } from "../../Enums/nodeParticleBlockConnectionPointTypes.js";
|
|
5
|
+
import { _ConnectAtTheEnd } from "../../../Queue/executionQueue.js";
|
|
6
|
+
/**
|
|
7
|
+
* Block used to update the remap value of a particle
|
|
8
|
+
*/
|
|
9
|
+
export class UpdateRemapBlock extends NodeParticleBlock {
|
|
10
|
+
/**
|
|
11
|
+
* Create a new UpdateRemapBlock
|
|
12
|
+
* @param name defines the block name
|
|
13
|
+
*/
|
|
14
|
+
constructor(name) {
|
|
15
|
+
super(name);
|
|
16
|
+
this.registerInput("particle", NodeParticleBlockConnectionPointTypes.Particle);
|
|
17
|
+
this.registerInput("remapColor", NodeParticleBlockConnectionPointTypes.Vector2, true);
|
|
18
|
+
this.registerInput("remapAlpha", NodeParticleBlockConnectionPointTypes.Vector2, true);
|
|
19
|
+
this.registerOutput("output", NodeParticleBlockConnectionPointTypes.Particle);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Gets the particle component
|
|
23
|
+
*/
|
|
24
|
+
get particle() {
|
|
25
|
+
return this._inputs[0];
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Gets the remapColor input component
|
|
29
|
+
*/
|
|
30
|
+
get remapColor() {
|
|
31
|
+
return this._inputs[1];
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Gets the remapAlpha input component
|
|
35
|
+
*/
|
|
36
|
+
get remapAlpha() {
|
|
37
|
+
return this._inputs[2];
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Gets the output component
|
|
41
|
+
*/
|
|
42
|
+
get output() {
|
|
43
|
+
return this._outputs[0];
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Gets the current class name
|
|
47
|
+
* @returns the class name
|
|
48
|
+
*/
|
|
49
|
+
getClassName() {
|
|
50
|
+
return "UpdateRemapBlock";
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Builds the block
|
|
54
|
+
* @param state defines the current build state
|
|
55
|
+
*/
|
|
56
|
+
_build(state) {
|
|
57
|
+
const system = this.particle.getConnectedValue(state);
|
|
58
|
+
this.output._storedValue = system;
|
|
59
|
+
if (!this.remapColor.isConnected && !this.remapAlpha.isConnected) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const processRemap = (particle) => {
|
|
63
|
+
state.particleContext = particle;
|
|
64
|
+
state.systemContext = system;
|
|
65
|
+
const colorRemap = this.remapColor.isConnected ? this.remapColor.getConnectedValue(state) : new Vector2(0, 1);
|
|
66
|
+
const alphaRemap = this.remapAlpha.isConnected ? this.remapAlpha.getConnectedValue(state) : new Vector2(0, 1);
|
|
67
|
+
if (!particle.remapData) {
|
|
68
|
+
particle.remapData = new Vector4(0, 1, 0, 1);
|
|
69
|
+
}
|
|
70
|
+
if (colorRemap) {
|
|
71
|
+
particle.remapData.x = colorRemap.x;
|
|
72
|
+
particle.remapData.y = colorRemap.y;
|
|
73
|
+
}
|
|
74
|
+
if (alphaRemap) {
|
|
75
|
+
particle.remapData.z = alphaRemap.x;
|
|
76
|
+
particle.remapData.w = alphaRemap.y;
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
const remapProcessing = {
|
|
80
|
+
process: processRemap,
|
|
81
|
+
previousItem: null,
|
|
82
|
+
nextItem: null,
|
|
83
|
+
};
|
|
84
|
+
if (system._updateQueueStart) {
|
|
85
|
+
_ConnectAtTheEnd(remapProcessing, system._updateQueueStart);
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
system._updateQueueStart = remapProcessing;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
RegisterClass("BABYLON.UpdateRemapBlock", UpdateRemapBlock);
|
|
93
|
+
//# sourceMappingURL=updateRemapBlock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"updateRemapBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Particles/Node/Blocks/Update/updateRemapBlock.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,sCAA4B;AACpD,OAAO,EAAE,iBAAiB,EAAE,mCAA8C;AAC1E,OAAO,EAAE,qCAAqC,EAAE,6DAAwE;AACxH,OAAO,EAAE,gBAAgB,EAAE,yCAA4C;AAEvE;;GAEG;AACH,MAAM,OAAO,gBAAiB,SAAQ,iBAAiB;IACnD;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,CAAC,CAAC;QAEZ,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,qCAAqC,CAAC,QAAQ,CAAC,CAAC;QAC/E,IAAI,CAAC,aAAa,CAAC,YAAY,EAAE,qCAAqC,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QACtF,IAAI,CAAC,aAAa,CAAC,YAAY,EAAE,qCAAqC,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QACtF,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,qCAAqC,CAAC,QAAQ,CAAC,CAAC;IAClF,CAAC;IAED;;OAEG;IACH,IAAW,QAAQ;QACf,OAAO,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AAI,CAAC,QAAQ,CAAC,SAAS,EAAE,CAAC;gBACtB,QAAQ,CAAC,SAAS,GAAG,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;YACjD,CAAC;YAED,IAAI,UAAU,EAAE,CAAC;gBACb,QAAQ,CAAC,SAAS,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC;gBACpC,QAAQ,CAAC,SAAS,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC;YACxC,CAAC;YAED,IAAI,UAAU,EAAE,CAAC;gBACb,QAAQ,CAAC,SAAS,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC;gBACpC,QAAQ,CAAC,SAAS,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC;YACxC,CAAC;QACL,CAAC,CAAC;QAEF,MAAM,eAAe,GAAG;YACpB,OAAO,EAAE,YAAY;YACrB,YAAY,EAAE,IAAI;YAClB,QAAQ,EAAE,IAAI;SACjB,CAAC;QAEF,IAAI,MAAM,CAAC,iBAAiB,EAAE,CAAC;YAC3B,gBAAgB,CAAC,eAAe,EAAE,MAAM,CAAC,iBAAiB,CAAC,CAAC;QAChE,CAAC;aAAM,CAAC;YACJ,MAAM,CAAC,iBAAiB,GAAG,eAAe,CAAC;QAC/C,CAAC;IACL,CAAC;CACJ;AAED,aAAa,CAAC,0BAA0B,EAAE,gBAAgB,CAAC,CAAC","sourcesContent":["import type { Particle } from \"core/Particles/particle\";\r\nimport type { ThinParticleSystem } from \"core/Particles/thinParticleSystem\";\r\nimport type { NodeParticleConnectionPoint } from \"core/Particles/Node/nodeParticleBlockConnectionPoint\";\r\nimport type { NodeParticleBuildState } from \"core/Particles/Node/nodeParticleBuildState\";\r\n\r\nimport { Vector2, Vector4 } from \"../../../../Maths/math.vector\";\r\nimport { RegisterClass } from \"core/Misc/typeStore\";\r\nimport { NodeParticleBlock } from \"core/Particles/Node/nodeParticleBlock\";\r\nimport { NodeParticleBlockConnectionPointTypes } from \"core/Particles/Node/Enums/nodeParticleBlockConnectionPointTypes\";\r\nimport { _ConnectAtTheEnd } from \"core/Particles/Queue/executionQueue\";\r\n\r\n/**\r\n * Block used to update the remap value of a particle\r\n */\r\nexport class UpdateRemapBlock extends NodeParticleBlock {\r\n /**\r\n * Create a new UpdateRemapBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name);\r\n\r\n this.registerInput(\"particle\", NodeParticleBlockConnectionPointTypes.Particle);\r\n this.registerInput(\"remapColor\", NodeParticleBlockConnectionPointTypes.Vector2, true);\r\n this.registerInput(\"remapAlpha\", NodeParticleBlockConnectionPointTypes.Vector2, true);\r\n this.registerOutput(\"output\", NodeParticleBlockConnectionPointTypes.Particle);\r\n }\r\n\r\n /**\r\n * Gets the particle component\r\n */\r\n public get particle(): NodeParticleConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the remapColor input component\r\n */\r\n public get remapColor(): NodeParticleConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the remapAlpha input component\r\n */\r\n public get remapAlpha(): NodeParticleConnectionPoint {\r\n return this._inputs[2];\r\n }\r\n\r\n /**\r\n * Gets the output component\r\n */\r\n public get output(): NodeParticleConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public override getClassName() {\r\n return \"UpdateRemapBlock\";\r\n }\r\n\r\n /**\r\n * Builds the block\r\n * @param state defines the current build state\r\n */\r\n public override _build(state: NodeParticleBuildState) {\r\n const system = this.particle.getConnectedValue(state) as ThinParticleSystem;\r\n\r\n this.output._storedValue = system;\r\n\r\n if (!this.remapColor.isConnected && !this.remapAlpha.isConnected) {\r\n return;\r\n }\r\n\r\n const processRemap = (particle: Particle) => {\r\n state.particleContext = particle;\r\n state.systemContext = system;\r\n\r\n const colorRemap = this.remapColor.isConnected ? (this.remapColor.getConnectedValue(state) as Vector2) : new Vector2(0, 1);\r\n const alphaRemap = this.remapAlpha.isConnected ? (this.remapAlpha.getConnectedValue(state) as Vector2) : new Vector2(0, 1);\r\n\r\n if (!particle.remapData) {\r\n particle.remapData = new Vector4(0, 1, 0, 1);\r\n }\r\n\r\n if (colorRemap) {\r\n particle.remapData.x = colorRemap.x;\r\n particle.remapData.y = colorRemap.y;\r\n }\r\n\r\n if (alphaRemap) {\r\n particle.remapData.z = alphaRemap.x;\r\n particle.remapData.w = alphaRemap.y;\r\n }\r\n };\r\n\r\n const remapProcessing = {\r\n process: processRemap,\r\n previousItem: null,\r\n nextItem: null,\r\n };\r\n\r\n if (system._updateQueueStart) {\r\n _ConnectAtTheEnd(remapProcessing, system._updateQueueStart);\r\n } else {\r\n system._updateQueueStart = remapProcessing;\r\n }\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.UpdateRemapBlock\", UpdateRemapBlock);\r\n"]}
|
|
@@ -34,4 +34,5 @@ export * from "./Triggers/particleTriggerBlock.js";
|
|
|
34
34
|
export * from "./particleLocalVariableBlock.js";
|
|
35
35
|
export * from "./particleVectorLengthBlock.js";
|
|
36
36
|
export * from "./particleFresnelBlock.js";
|
|
37
|
-
export * from "./
|
|
37
|
+
export * from "./particleNumberMathBlock.js";
|
|
38
|
+
export * from "./particleVectorMathBlock.js";
|
|
@@ -35,5 +35,6 @@ export * from "./Triggers/particleTriggerBlock.js";
|
|
|
35
35
|
export * from "./particleLocalVariableBlock.js";
|
|
36
36
|
export * from "./particleVectorLengthBlock.js";
|
|
37
37
|
export * from "./particleFresnelBlock.js";
|
|
38
|
-
export * from "./
|
|
38
|
+
export * from "./particleNumberMathBlock.js";
|
|
39
|
+
export * from "./particleVectorMathBlock.js";
|
|
39
40
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Particles/Node/Blocks/index.ts"],"names":[],"mappings":"AAAA,6D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C;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,mCAAmC,CAAC;AAClD,cAAc,iCAAiC,CAAC;AAChD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,qCAAqC,CAAC;AACpD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,0BAA0B,CAAC;AACzC,cAAc,kBAAkB,CAAC;AACjC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oCAAoC,CAAC;AACnD,cAAc,qCAAqC,CAAC;AACpD,cAAc,qCAAqC,CAAC;AACpD,cAAc,iCAAiC,CAAC;AAChD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-restricted-imports */\r\nexport * from \"./systemBlock\";\r\nexport * from \"./particleFloatToIntBlock\";\r\nexport * from \"./particleInputBlock\";\r\nexport * from \"./particleSourceTextureBlock\";\r\nexport * from \"./particleMathBlock\";\r\nexport * from \"./particleLerpBlock\";\r\nexport * from \"./Update/updateDirectionBlock\";\r\nexport * from \"./Update/updatePositionBlock\";\r\nexport * from \"./Update/updateColorBlock\";\r\nexport * from \"./Update/updateScaleBlock\";\r\nexport * from \"./Update/updateSizeBlock\";\r\nexport * from \"./Update/updateAngleBlock\";\r\nexport * from \"./Update/updateAgeBlock\";\r\nexport * from \"./Update/basicPositionUpdateBlock\";\r\nexport * from \"./Update/basicSpriteUpdateBlock\";\r\nexport * from \"./Update/basicColorUpdateBlock\";\r\nexport * from \"./Update/updateSpriteCellIndexBlock\";\r\nexport * from \"./Update/updateFlowMapBlock\";\r\nexport * from \"./Update/updateNoiseBlock\";\r\nexport * from \"./Update/updateAttractorBlock\";\r\nexport * from \"./Update/alignAngleBlock\";\r\nexport * from \"./Emitters/index\";\r\nexport * from \"./particleGradientValueBlock\";\r\nexport * from \"./particleGradientBlock\";\r\nexport * from \"./particleConverterBlock\";\r\nexport * from \"./particleTrigonometryBlock\";\r\nexport * from \"./particleRandomBlock\";\r\nexport * from \"./particleDebugBlock\";\r\nexport * from \"./particleElbowBlock\";\r\nexport * from \"./Teleport/particleTeleportInBlock\";\r\nexport * from \"./Teleport/particleTeleportOutBlock\";\r\nexport * from \"./Conditions/particleConditionBlock\";\r\nexport * from \"./Triggers/particleTriggerBlock\";\r\nexport * from \"./particleLocalVariableBlock\";\r\nexport * from \"./particleVectorLengthBlock\";\r\nexport * from \"./particleFresnelBlock\";\r\nexport * from \"./particleNumberMathBlock\";\r\nexport * from \"./particleVectorMathBlock\";\r\n"]}
|
|
@@ -14,6 +14,7 @@ export declare class ParticleLocalVariableBlock extends NodeParticleBlock {
|
|
|
14
14
|
* Gets or sets the scope used by the block
|
|
15
15
|
*/
|
|
16
16
|
scope: ParticleLocalVariableBlockScope;
|
|
17
|
+
private _storage;
|
|
17
18
|
/**
|
|
18
19
|
* Create a new ParticleLocalVariableBlock
|
|
19
20
|
* @param name defines the block name
|
|
@@ -35,4 +36,5 @@ export declare class ParticleLocalVariableBlock extends NodeParticleBlock {
|
|
|
35
36
|
_build(state: NodeParticleBuildState): void;
|
|
36
37
|
serialize(): any;
|
|
37
38
|
_deserialize(serializationObject: any): void;
|
|
39
|
+
dispose(): void;
|
|
38
40
|
}
|
|
@@ -23,6 +23,7 @@ export class ParticleLocalVariableBlock extends NodeParticleBlock {
|
|
|
23
23
|
* Gets or sets the scope used by the block
|
|
24
24
|
*/
|
|
25
25
|
this.scope = ParticleLocalVariableBlockScope.Particle;
|
|
26
|
+
this._storage = new Map();
|
|
26
27
|
this._isDebug = true;
|
|
27
28
|
this.registerInput("input", NodeParticleBlockConnectionPointTypes.AutoDetect);
|
|
28
29
|
this.registerOutput("output", NodeParticleBlockConnectionPointTypes.BasedOnInput);
|
|
@@ -60,22 +61,29 @@ export class ParticleLocalVariableBlock extends NodeParticleBlock {
|
|
|
60
61
|
this.output._storedValue = null;
|
|
61
62
|
return;
|
|
62
63
|
}
|
|
63
|
-
let storedValue = null;
|
|
64
|
-
let localId = -1;
|
|
65
64
|
const func = (state) => {
|
|
66
65
|
if (!state.particleContext && !state.systemContext) {
|
|
67
|
-
|
|
66
|
+
this._storage.clear();
|
|
68
67
|
return null;
|
|
69
68
|
}
|
|
70
69
|
const id = (this.scope === ParticleLocalVariableBlockScope.Particle ? state.particleContext?.id : state.systemContext?.getScene().getFrameId()) || -1;
|
|
71
|
-
if (
|
|
72
|
-
|
|
73
|
-
|
|
70
|
+
if (!this._storage.has(id)) {
|
|
71
|
+
let value = this.input.getConnectedValue(state);
|
|
72
|
+
if (value.clone) {
|
|
73
|
+
value = value.clone(); // We clone to snapshot the value at this moment
|
|
74
|
+
}
|
|
75
|
+
this._storage.set(id, value);
|
|
76
|
+
if (this.scope === ParticleLocalVariableBlockScope.Particle) {
|
|
77
|
+
state.particleContext.onReset = () => {
|
|
78
|
+
this._storage.delete(id);
|
|
79
|
+
state.particleContext.onReset = null;
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
state.systemContext.onDisposeObservable.addOnce(() => {
|
|
83
|
+
this._storage.clear();
|
|
84
|
+
});
|
|
74
85
|
}
|
|
75
|
-
|
|
76
|
-
storedValue = this.input.getConnectedValue(state);
|
|
77
|
-
}
|
|
78
|
-
return storedValue;
|
|
86
|
+
return this._storage.get(id);
|
|
79
87
|
};
|
|
80
88
|
if (this.output.isConnected) {
|
|
81
89
|
this.output._storedFunction = func;
|
|
@@ -93,6 +101,10 @@ export class ParticleLocalVariableBlock extends NodeParticleBlock {
|
|
|
93
101
|
super._deserialize(serializationObject);
|
|
94
102
|
this.scope = serializationObject.scope;
|
|
95
103
|
}
|
|
104
|
+
dispose() {
|
|
105
|
+
this._storage.clear();
|
|
106
|
+
super.dispose();
|
|
107
|
+
}
|
|
96
108
|
}
|
|
97
109
|
__decorate([
|
|
98
110
|
editableInPropertyPage("Scope", 5 /* PropertyTypeForEdition.List */, "ADVANCED", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"particleLocalVariableBlock.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Particles/Node/Blocks/particleLocalVariableBlock.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,sBAAsB,EAA0B,6CAAsC;AAC/F,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,qCAAqC,EAAE,MAAM,gDAAgD,CAAC;AACvG,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAIzD,MAAM,CAAN,IAAY,+BAGX;AAHD,WAAY,+BAA+B;IACvC,6FAAY,CAAA;IACZ,qFAAQ,CAAA;AACZ,CAAC,EAHW,+BAA+B,KAA/B,+BAA+B,QAG1C;AAED;;;GAGG;AACH,MAAM,OAAO,0BAA2B,SAAQ,iBAAiB;
|
|
1
|
+
{"version":3,"file":"particleLocalVariableBlock.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Particles/Node/Blocks/particleLocalVariableBlock.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,sBAAsB,EAA0B,6CAAsC;AAC/F,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,qCAAqC,EAAE,MAAM,gDAAgD,CAAC;AACvG,OAAO,EAAE,iBAAiB,EAA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AY,CAAC,mBAAmB,CAAC,CAAC;QAExC,IAAI,CAAC,KAAK,GAAG,mBAAmB,CAAC,KAAK,CAAC;IAC3C,CAAC;IAEe,OAAO;QACnB,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;QACtB,KAAK,CAAC,OAAO,EAAE,CAAC;IACpB,CAAC;CACJ;AA7GU;IARN,sBAAsB,CAAC,OAAO,uCAA+B,UAAU,EAAE;QACtE,QAAQ,EAAE,IAAI;QACd,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;QAC5B,OAAO,EAAE;YACL,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,+BAA+B,CAAC,QAAQ,EAAE;YACtE,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,+BAA+B,CAAC,IAAI,EAAE;SACjE;KACJ,CAAC;yDACsD;AA+G5D,aAAa,CAAC,oCAAoC,EAAE,0BAA0B,CAAC,CAAC","sourcesContent":["import { editableInPropertyPage, PropertyTypeForEdition } from \"core/Decorators/nodeDecorator\";\r\nimport { RegisterClass } from \"../../../Misc/typeStore\";\r\nimport { NodeParticleBlockConnectionPointTypes } from \"../Enums/nodeParticleBlockConnectionPointTypes\";\r\nimport { NodeParticleBlock } from \"../nodeParticleBlock\";\r\nimport type { NodeParticleConnectionPoint } from \"../nodeParticleBlockConnectionPoint\";\r\nimport type { NodeParticleBuildState } from \"../nodeParticleBuildState\";\r\n\r\nexport enum ParticleLocalVariableBlockScope {\r\n Particle = 0,\r\n Loop = 1,\r\n}\r\n\r\n/**\r\n * Defines a block used to store local values\r\n * #A1OS53#5\r\n */\r\nexport class ParticleLocalVariableBlock extends NodeParticleBlock {\r\n /**\r\n * Gets or sets the scope used by the block\r\n */\r\n @editableInPropertyPage(\"Scope\", PropertyTypeForEdition.List, \"ADVANCED\", {\r\n embedded: true,\r\n notifiers: { rebuild: true },\r\n options: [\r\n { label: \"Particle\", value: ParticleLocalVariableBlockScope.Particle },\r\n { label: \"Loop\", value: ParticleLocalVariableBlockScope.Loop },\r\n ],\r\n })\r\n public scope = ParticleLocalVariableBlockScope.Particle;\r\n private _storage = new Map<number, any>();\r\n\r\n /**\r\n * Create a new ParticleLocalVariableBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name);\r\n\r\n this._isDebug = true;\r\n\r\n this.registerInput(\"input\", NodeParticleBlockConnectionPointTypes.AutoDetect);\r\n this.registerOutput(\"output\", NodeParticleBlockConnectionPointTypes.BasedOnInput);\r\n\r\n this._outputs[0]._typeConnectionSource = this._inputs[0];\r\n this._inputs[0].excludedConnectionPointTypes.push(NodeParticleBlockConnectionPointTypes.FloatGradient);\r\n this._inputs[0].excludedConnectionPointTypes.push(NodeParticleBlockConnectionPointTypes.Vector2Gradient);\r\n this._inputs[0].excludedConnectionPointTypes.push(NodeParticleBlockConnectionPointTypes.Vector3Gradient);\r\n this._inputs[0].excludedConnectionPointTypes.push(NodeParticleBlockConnectionPointTypes.Color4Gradient);\r\n this._inputs[0].excludedConnectionPointTypes.push(NodeParticleBlockConnectionPointTypes.System);\r\n this._inputs[0].excludedConnectionPointTypes.push(NodeParticleBlockConnectionPointTypes.Particle);\r\n this._inputs[0].excludedConnectionPointTypes.push(NodeParticleBlockConnectionPointTypes.Texture);\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public override getClassName() {\r\n return \"ParticleLocalVariableBlock\";\r\n }\r\n\r\n /**\r\n * Gets the input component\r\n */\r\n public get input(): NodeParticleConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the output component\r\n */\r\n public get output(): NodeParticleConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n public override _build(state: NodeParticleBuildState) {\r\n if (!this.input.isConnected) {\r\n this.output._storedFunction = null;\r\n this.output._storedValue = null;\r\n return;\r\n }\r\n\r\n const func = (state: NodeParticleBuildState) => {\r\n if (!state.particleContext && !state.systemContext) {\r\n this._storage.clear();\r\n return null;\r\n }\r\n\r\n const id = (this.scope === ParticleLocalVariableBlockScope.Particle ? state.particleContext?.id : state.systemContext?.getScene()!.getFrameId()) || -1;\r\n\r\n if (!this._storage.has(id)) {\r\n let value = this.input.getConnectedValue(state);\r\n\r\n if (value.clone) {\r\n value = value.clone(); // We clone to snapshot the value at this moment\r\n }\r\n this._storage.set(id, value);\r\n\r\n if (this.scope === ParticleLocalVariableBlockScope.Particle) {\r\n state.particleContext!.onReset = () => {\r\n this._storage.delete(id);\r\n state.particleContext!.onReset = null;\r\n };\r\n }\r\n state.systemContext!.onDisposeObservable.addOnce(() => {\r\n this._storage.clear();\r\n });\r\n }\r\n\r\n return this._storage.get(id);\r\n };\r\n\r\n if (this.output.isConnected) {\r\n this.output._storedFunction = func;\r\n } else {\r\n this.output._storedValue = func(state);\r\n }\r\n }\r\n\r\n public override serialize(): any {\r\n const serializationObject = super.serialize();\r\n\r\n serializationObject.scope = this.scope;\r\n\r\n return serializationObject;\r\n }\r\n\r\n public override _deserialize(serializationObject: any) {\r\n super._deserialize(serializationObject);\r\n\r\n this.scope = serializationObject.scope;\r\n }\r\n\r\n public override dispose() {\r\n this._storage.clear();\r\n super.dispose();\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.ParticleLocalVariableBlock\", ParticleLocalVariableBlock);\r\n"]}
|
|
@@ -60,5 +60,9 @@ export declare class ParticleMathBlock extends NodeParticleBlock {
|
|
|
60
60
|
* @returns the serialized block object
|
|
61
61
|
*/
|
|
62
62
|
serialize(): any;
|
|
63
|
+
/**
|
|
64
|
+
* Deserializes the block from a JSON object
|
|
65
|
+
* @param serializationObject the JSON object to deserialize from
|
|
66
|
+
*/
|
|
63
67
|
_deserialize(serializationObject: any): void;
|
|
64
68
|
}
|
|
@@ -298,6 +298,10 @@ export class ParticleMathBlock extends NodeParticleBlock {
|
|
|
298
298
|
serializationObject.operation = this.operation;
|
|
299
299
|
return serializationObject;
|
|
300
300
|
}
|
|
301
|
+
/**
|
|
302
|
+
* Deserializes the block from a JSON object
|
|
303
|
+
* @param serializationObject the JSON object to deserialize from
|
|
304
|
+
*/
|
|
301
305
|
_deserialize(serializationObject) {
|
|
302
306
|
super._deserialize(serializationObject);
|
|
303
307
|
this.operation = serializationObject.operation;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"particleMathBlock.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Particles/Node/Blocks/particleMathBlock.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,sCAA+B;AAC1D,OAAO,EAA0B,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAEnG,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,OAAO,EAAE,qCAAqC,EAAE,MAAM,gDAAgD,CAAC;AAEvG,OAAO,EAAE,MAAM,EAAE,qCAA8B;AAE/C;;GAEG;AACH,MAAM,CAAN,IAAY,2BAaX;AAbD,WAAY,2BAA2B;IACnC,UAAU;IACV,2EAAG,CAAA;IACH,eAAe;IACf,qFAAQ,CAAA;IACR,eAAe;IACf,qFAAQ,CAAA;IACR,aAAa;IACb,iFAAM,CAAA;IACN,UAAU;IACV,2EAAG,CAAA;IACH,UAAU;IACV,2EAAG,CAAA;AACP,CAAC,EAbW,2BAA2B,KAA3B,2BAA2B,QAatC;AAED;;GAEG;AACH,MAAM,OAAO,iBAAkB,SAAQ,iBAAiB;IAoBpD;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,CAAC,CAAC;QAxBhB;;WAEG;QAaI,cAAS,GAAG,2BAA2B,CAAC,GAAG,CAAC;QAW/C,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,qCAAqC,CAAC,UAAU,CAAC,CAAC;QAC7E,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,qCAAqC,CAAC,UAAU,CAAC,CAAC;QAE9E,IA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,GAAG,IAAI,CAAC,SAAS,CAAC;QAE/C,OAAO,mBAAmB,CAAC;IAC/B,CAAC;IAEe,YAAY,CAAC,mBAAwB;QACjD,KAAK,CAAC,YAAY,CAAC,mBAAmB,CAAC,CAAC;QAExC,IAAI,CAAC,SAAS,GAAG,mBAAmB,CAAC,SAAS,CAAC;IACnD,CAAC;CACJ;AA9SU;IAZN,sBAAsB,CAAC,WAAW,uCAA+B,UAAU,EAAE;QAC1E,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;QAC5B,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE;YACL,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,2BAA2B,CAAC,GAAG,EAAE;YACxD,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,2BAA2B,CAAC,QAAQ,EAAE;YAClE,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,2BAA2B,CAAC,QAAQ,EAAE;YAClE,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,2BAA2B,CAAC,MAAM,EAAE;YAC9D,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,2BAA2B,CAAC,GAAG,EAAE;YACxD,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,2BAA2B,CAAC,GAAG,EAAE;SAC3D;KACJ,CAAC;oDACiD;AAgTvD,aAAa,CAAC,2BAA2B,EAAE,iBAAiB,CAAC,CAAC","sourcesContent":["import { RegisterClass } from \"../../../Misc/typeStore\";\r\nimport { Vector2, Vector3 } from \"core/Maths/math.vector\";\r\nimport { PropertyTypeForEdition, editableInPropertyPage } from \"../../../Decorators/nodeDecorator\";\r\nimport type { Observer } from \"core/Misc/observable\";\r\nimport { NodeParticleBlock } from \"../nodeParticleBlock\";\r\nimport type { NodeParticleConnectionPoint } from \"../nodeParticleBlockConnectionPoint\";\r\nimport { NodeParticleBlockConnectionPointTypes } from \"../Enums/nodeParticleBlockConnectionPointTypes\";\r\nimport type { NodeParticleBuildState } from \"../nodeParticleBuildState\";\r\nimport { Color4 } from \"core/Maths/math.color\";\r\n\r\n/**\r\n * Operations supported by the Math block\r\n */\r\nexport enum ParticleMathBlockOperations {\r\n /** Add */\r\n Add,\r\n /** Subtract */\r\n Subtract,\r\n /** Multiply */\r\n Multiply,\r\n /** Divide */\r\n Divide,\r\n /** Max */\r\n Max,\r\n /** Min */\r\n Min,\r\n}\r\n\r\n/**\r\n * Block used to apply math functions\r\n */\r\nexport class ParticleMathBlock extends NodeParticleBlock {\r\n /**\r\n * Gets or sets the operation applied by the block\r\n */\r\n @editableInPropertyPage(\"Operation\", PropertyTypeForEdition.List, \"ADVANCED\", {\r\n notifiers: { rebuild: true },\r\n embedded: true,\r\n options: [\r\n { label: \"Add\", value: ParticleMathBlockOperations.Add },\r\n { label: \"Subtract\", value: ParticleMathBlockOperations.Subtract },\r\n { label: \"Multiply\", value: ParticleMathBlockOperations.Multiply },\r\n { label: \"Divide\", value: ParticleMathBlockOperations.Divide },\r\n { label: \"Max\", value: ParticleMathBlockOperations.Max },\r\n { label: \"Min\", value: ParticleMathBlockOperations.Min },\r\n ],\r\n })\r\n public operation = ParticleMathBlockOperations.Add;\r\n\r\n private readonly _connectionObservers: Observer<NodeParticleConnectionPoint>[];\r\n\r\n /**\r\n * Create a new ParticleMathBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name);\r\n\r\n this.registerInput(\"left\", NodeParticleBlockConnectionPointTypes.AutoDetect);\r\n this.registerInput(\"right\", NodeParticleBlockConnectionPointTypes.AutoDetect);\r\n\r\n this.registerOutput(\"output\", NodeParticleBlockConnectionPointTypes.BasedOnInput);\r\n\r\n this.output._typeConnectionSource = this.left;\r\n\r\n const excludedConnectionPointTypes = [\r\n NodeParticleBlockConnectionPointTypes.Matrix,\r\n NodeParticleBlockConnectionPointTypes.Particle,\r\n NodeParticleBlockConnectionPointTypes.Texture,\r\n NodeParticleBlockConnectionPointTypes.System,\r\n NodeParticleBlockConnectionPointTypes.FloatGradient,\r\n NodeParticleBlockConnectionPointTypes.Color4Gradient,\r\n NodeParticleBlockConnectionPointTypes.Vector2Gradient,\r\n NodeParticleBlockConnectionPointTypes.Vector3Gradient,\r\n ] as const;\r\n\r\n this.left.excludedConnectionPointTypes.push(...excludedConnectionPointTypes);\r\n this.right.excludedConnectionPointTypes.push(...excludedConnectionPointTypes);\r\n\r\n this._linkConnectionTypes(0, 1);\r\n\r\n this._connectionObservers = [\r\n this.left.onConnectionObservable.add(() => this._updateInputOutputTypes()),\r\n this.left.onDisconnectionObservable.add(() => this._updateInputOutputTypes()),\r\n this.right.onConnectionObservable.add(() => this._updateInputOutputTypes()),\r\n this.right.onDisconnectionObservable.add(() => this._updateInputOutputTypes()),\r\n ];\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public override getClassName() {\r\n return \"ParticleMathBlock\";\r\n }\r\n\r\n /**\r\n * Gets the left input component\r\n */\r\n public get left(): NodeParticleConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the right input component\r\n */\r\n public get right(): NodeParticleConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the geometry output component\r\n */\r\n public get output(): NodeParticleConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n public override _build(state: NodeParticleBuildState) {\r\n let func: (state: NodeParticleBuildState) => any;\r\n const left = this.left;\r\n const right = this.right;\r\n\r\n if (!left.isConnected || !right.isConnected) {\r\n this.output._storedFunction = null;\r\n this.output._storedValue = null;\r\n return;\r\n }\r\n\r\n const leftIsScalar = left.type === NodeParticleBlockConnectionPointTypes.Float || left.type === NodeParticleBlockConnectionPointTypes.Int;\r\n const rightIsScalar = right.type === NodeParticleBlockConnectionPointTypes.Float || right.type === NodeParticleBlockConnectionPointTypes.Int;\r\n\r\n // If both input types are scalars, then this is a scalar operation.\r\n const isScalar = leftIsScalar && rightIsScalar;\r\n\r\n switch (this.operation) {\r\n case ParticleMathBlockOperations.Add: {\r\n if (isScalar) {\r\n func = (state) => {\r\n return left.getConnectedValue(state) + right.getConnectedValue(state);\r\n };\r\n } else if (leftIsScalar) {\r\n func = (state) => {\r\n return state.adapt(left, right.type).add(right.getConnectedValue(state));\r\n };\r\n } else {\r\n func = (state) => {\r\n return left.getConnectedValue(state).add(state.adapt(right, left.type));\r\n };\r\n }\r\n break;\r\n }\r\n case ParticleMathBlockOperations.Subtract: {\r\n if (isScalar) {\r\n func = (state) => {\r\n return left.getConnectedValue(state) - right.getConnectedValue(state);\r\n };\r\n } else if (leftIsScalar) {\r\n func = (state) => {\r\n return state.adapt(left, right.type).subtract(right.getConnectedValue(state));\r\n };\r\n } else {\r\n func = (state) => {\r\n return left.getConnectedValue(state).subtract(state.adapt(right, left.type));\r\n };\r\n }\r\n break;\r\n }\r\n case ParticleMathBlockOperations.Multiply: {\r\n if (isScalar) {\r\n func = (state) => {\r\n return left.getConnectedValue(state) * right.getConnectedValue(state);\r\n };\r\n } else if (leftIsScalar) {\r\n func = (state) => {\r\n return state.adapt(left, right.type).multiply(right.getConnectedValue(state));\r\n };\r\n } else {\r\n func = (state) => {\r\n return left.getConnectedValue(state).multiply(state.adapt(right, left.type));\r\n };\r\n }\r\n break;\r\n }\r\n case ParticleMathBlockOperations.Divide: {\r\n if (isScalar) {\r\n func = (state) => {\r\n return left.getConnectedValue(state) / right.getConnectedValue(state);\r\n };\r\n } else if (leftIsScalar) {\r\n func = (state) => {\r\n return state.adapt(left, right.type).divide(right.getConnectedValue(state));\r\n };\r\n } else {\r\n func = (state) => {\r\n return left.getConnectedValue(state).divide(state.adapt(right, left.type));\r\n };\r\n }\r\n break;\r\n }\r\n case ParticleMathBlockOperations.Min: {\r\n if (isScalar) {\r\n func = (state) => {\r\n return Math.min(left.getConnectedValue(state), right.getConnectedValue(state));\r\n };\r\n } else {\r\n const [vector, scalar] = leftIsScalar ? [right, left] : [left, right];\r\n\r\n switch (vector.type) {\r\n case NodeParticleBlockConnectionPointTypes.Vector2: {\r\n func = (state) => {\r\n return Vector2.Minimize(vector.getConnectedValue(state), state.adapt(scalar, vector.type));\r\n };\r\n break;\r\n }\r\n case NodeParticleBlockConnectionPointTypes.Vector3: {\r\n func = (state) => {\r\n return Vector3.Minimize(vector.getConnectedValue(state), state.adapt(scalar, vector.type));\r\n };\r\n break;\r\n }\r\n case NodeParticleBlockConnectionPointTypes.Color4: {\r\n func = (state) => {\r\n const other = vector.getConnectedValue(state);\r\n const { r, g, b, a } = state.adapt(scalar, vector.type);\r\n\r\n return new Color4(Math.min(other.r, r), Math.min(other.g, g), Math.min(other.b, b), Math.min(other.a, a));\r\n };\r\n break;\r\n }\r\n }\r\n }\r\n break;\r\n }\r\n case ParticleMathBlockOperations.Max: {\r\n if (isScalar) {\r\n func = (state) => {\r\n return Math.max(left.getConnectedValue(state), right.getConnectedValue(state));\r\n };\r\n } else {\r\n const [vector, scalar] = leftIsScalar ? [right, left] : [left, right];\r\n\r\n switch (vector.type) {\r\n case NodeParticleBlockConnectionPointTypes.Vector2: {\r\n func = (state) => {\r\n return Vector2.Maximize(vector.getConnectedValue(state), state.adapt(scalar, vector.type));\r\n };\r\n break;\r\n }\r\n case NodeParticleBlockConnectionPointTypes.Vector3: {\r\n func = (state) => {\r\n return Vector3.Maximize(vector.getConnectedValue(state), state.adapt(scalar, vector.type));\r\n };\r\n break;\r\n }\r\n case NodeParticleBlockConnectionPointTypes.Color4: {\r\n func = (state) => {\r\n const other = vector.getConnectedValue(state);\r\n const { r, g, b, a } = state.adapt(scalar, vector.type);\r\n\r\n return new Color4(Math.max(other.r, r), Math.min(other.g, g), Math.min(other.b, b), Math.min(other.a, a));\r\n };\r\n break;\r\n }\r\n }\r\n break;\r\n }\r\n }\r\n }\r\n\r\n this.output._storedFunction = (state) => {\r\n if (left.type === NodeParticleBlockConnectionPointTypes.Int) {\r\n return func(state) | 0;\r\n }\r\n return func(state);\r\n };\r\n }\r\n\r\n private _updateInputOutputTypes() {\r\n // First update the output type with the initial assumption that we'll base it on the left input.\r\n this.output._typeConnectionSource = this.left;\r\n\r\n if (this.left.isConnected && this.right.isConnected) {\r\n // Both inputs are connected, so we need to determine the output type based on the input types.\r\n if (\r\n this.left.type === NodeParticleBlockConnectionPointTypes.Int ||\r\n (this.left.type === NodeParticleBlockConnectionPointTypes.Float && this.right.type !== NodeParticleBlockConnectionPointTypes.Int)\r\n ) {\r\n this.output._typeConnectionSource = this.right;\r\n }\r\n } else if (this.left.isConnected !== this.right.isConnected) {\r\n // Only one input is connected, so we need to determine the output type based on the connected input.\r\n this.output._typeConnectionSource = this.left.isConnected ? this.left : this.right;\r\n }\r\n\r\n // Next update the accepted connection point types for the inputs based on the current input connection state.\r\n if (this.left.isConnected || this.right.isConnected) {\r\n for (const [first, second] of [\r\n [this.left, this.right],\r\n [this.right, this.left],\r\n ]) {\r\n // Always allow Ints and Floats.\r\n first.acceptedConnectionPointTypes = [NodeParticleBlockConnectionPointTypes.Int, NodeParticleBlockConnectionPointTypes.Float];\r\n\r\n if (second.isConnected) {\r\n // The same types as the connected input are always allowed.\r\n first.acceptedConnectionPointTypes.push(second.type);\r\n\r\n // If the other input is a scalar, then we also allow Vector types.\r\n if (second.type === NodeParticleBlockConnectionPointTypes.Int || second.type === NodeParticleBlockConnectionPointTypes.Float) {\r\n first.acceptedConnectionPointTypes.push(\r\n NodeParticleBlockConnectionPointTypes.Vector2,\r\n NodeParticleBlockConnectionPointTypes.Vector3,\r\n NodeParticleBlockConnectionPointTypes.Color4\r\n );\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Release resources\r\n */\r\n public override dispose() {\r\n super.dispose();\r\n for (const observer of this._connectionObservers) {\r\n observer.remove();\r\n }\r\n this._connectionObservers.length = 0;\r\n }\r\n\r\n /**\r\n * Serializes this block in a JSON representation\r\n * @returns the serialized block object\r\n */\r\n public override serialize(): any {\r\n const serializationObject = super.serialize();\r\n\r\n serializationObject.operation = this.operation;\r\n\r\n return serializationObject;\r\n }\r\n\r\n public override _deserialize(serializationObject: any) {\r\n super._deserialize(serializationObject);\r\n\r\n this.operation = serializationObject.operation;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.ParticleMathBlock\", ParticleMathBlock);\r\n"]}
|
|
1
|
+
{"version":3,"file":"particleMathBlock.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Particles/Node/Blocks/particleMathBlock.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,sCAA+B;AAC1D,OAAO,EAA0B,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAEnG,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,OAAO,EAAE,qCAAqC,EAAE,MAAM,gDAAgD,CAAC;AAEvG,OAAO,EAAE,MAAM,EAAE,qCAA8B;AAE/C;;GAEG;AACH,MAAM,CAAN,IAAY,2BAaX;AAbD,WAAY,2BAA2B;IACnC,UAAU;IACV,2EAAG,CAAA;IACH,eAAe;IACf,qFAAQ,CAAA;IACR,eAAe;IACf,qFAAQ,CAAA;IACR,aAAa;IACb,iFAAM,CAAA;IACN,UAAU;IACV,2EAAG,CAAA;IACH,UAAU;IACV,2EAAG,CAAA;AACP,CAAC,EAbW,2BAA2B,KAA3B,2BAA2B,QAatC;AAED;;GAEG;AACH,MAAM,OAAO,iBAAkB,SAAQ,iBAAiB;IAoBpD;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,CAAC,CAAC;QAxBhB;;WAEG;QAaI,cAAS,GAAG,2BAA2B,CAAC,GAAG,CAAC;QAW/C,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,qCAAqC,CAAC,UAAU,CAAC,CAAC;QAC7E,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,qCAAqC,CAAC,UAAU,CAAC,CAAC;QAE9E,IAAI,CAAC,cAAc,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AC,SAAS,CAAC;QAE/C,OAAO,mBAAmB,CAAC;IAC/B,CAAC;IAED;;;OAGG;IACa,YAAY,CAAC,mBAAwB;QACjD,KAAK,CAAC,YAAY,CAAC,mBAAmB,CAAC,CAAC;QAExC,IAAI,CAAC,SAAS,GAAG,mBAAmB,CAAC,SAAS,CAAC;IACnD,CAAC;CACJ;AAlTU;IAZN,sBAAsB,CAAC,WAAW,uCAA+B,UAAU,EAAE;QAC1E,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;QAC5B,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE;YACL,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,2BAA2B,CAAC,GAAG,EAAE;YACxD,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,2BAA2B,CAAC,QAAQ,EAAE;YAClE,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,2BAA2B,CAAC,QAAQ,EAAE;YAClE,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,2BAA2B,CAAC,MAAM,EAAE;YAC9D,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,2BAA2B,CAAC,GAAG,EAAE;YACxD,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,2BAA2B,CAAC,GAAG,EAAE;SAC3D;KACJ,CAAC;oDACiD;AAoTvD,aAAa,CAAC,2BAA2B,EAAE,iBAAiB,CAAC,CAAC","sourcesContent":["import { RegisterClass } from \"../../../Misc/typeStore\";\r\nimport { Vector2, Vector3 } from \"core/Maths/math.vector\";\r\nimport { PropertyTypeForEdition, editableInPropertyPage } from \"../../../Decorators/nodeDecorator\";\r\nimport type { Observer } from \"core/Misc/observable\";\r\nimport { NodeParticleBlock } from \"../nodeParticleBlock\";\r\nimport type { NodeParticleConnectionPoint } from \"../nodeParticleBlockConnectionPoint\";\r\nimport { NodeParticleBlockConnectionPointTypes } from \"../Enums/nodeParticleBlockConnectionPointTypes\";\r\nimport type { NodeParticleBuildState } from \"../nodeParticleBuildState\";\r\nimport { Color4 } from \"core/Maths/math.color\";\r\n\r\n/**\r\n * Operations supported by the Math block\r\n */\r\nexport enum ParticleMathBlockOperations {\r\n /** Add */\r\n Add,\r\n /** Subtract */\r\n Subtract,\r\n /** Multiply */\r\n Multiply,\r\n /** Divide */\r\n Divide,\r\n /** Max */\r\n Max,\r\n /** Min */\r\n Min,\r\n}\r\n\r\n/**\r\n * Block used to apply math functions\r\n */\r\nexport class ParticleMathBlock extends NodeParticleBlock {\r\n /**\r\n * Gets or sets the operation applied by the block\r\n */\r\n @editableInPropertyPage(\"Operation\", PropertyTypeForEdition.List, \"ADVANCED\", {\r\n notifiers: { rebuild: true },\r\n embedded: true,\r\n options: [\r\n { label: \"Add\", value: ParticleMathBlockOperations.Add },\r\n { label: \"Subtract\", value: ParticleMathBlockOperations.Subtract },\r\n { label: \"Multiply\", value: ParticleMathBlockOperations.Multiply },\r\n { label: \"Divide\", value: ParticleMathBlockOperations.Divide },\r\n { label: \"Max\", value: ParticleMathBlockOperations.Max },\r\n { label: \"Min\", value: ParticleMathBlockOperations.Min },\r\n ],\r\n })\r\n public operation = ParticleMathBlockOperations.Add;\r\n\r\n private readonly _connectionObservers: Observer<NodeParticleConnectionPoint>[];\r\n\r\n /**\r\n * Create a new ParticleMathBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name);\r\n\r\n this.registerInput(\"left\", NodeParticleBlockConnectionPointTypes.AutoDetect);\r\n this.registerInput(\"right\", NodeParticleBlockConnectionPointTypes.AutoDetect);\r\n\r\n this.registerOutput(\"output\", NodeParticleBlockConnectionPointTypes.BasedOnInput);\r\n\r\n this.output._typeConnectionSource = this.left;\r\n\r\n const excludedConnectionPointTypes = [\r\n NodeParticleBlockConnectionPointTypes.Matrix,\r\n NodeParticleBlockConnectionPointTypes.Particle,\r\n NodeParticleBlockConnectionPointTypes.Texture,\r\n NodeParticleBlockConnectionPointTypes.System,\r\n NodeParticleBlockConnectionPointTypes.FloatGradient,\r\n NodeParticleBlockConnectionPointTypes.Color4Gradient,\r\n NodeParticleBlockConnectionPointTypes.Vector2Gradient,\r\n NodeParticleBlockConnectionPointTypes.Vector3Gradient,\r\n ] as const;\r\n\r\n this.left.excludedConnectionPointTypes.push(...excludedConnectionPointTypes);\r\n this.right.excludedConnectionPointTypes.push(...excludedConnectionPointTypes);\r\n\r\n this._linkConnectionTypes(0, 1);\r\n\r\n this._connectionObservers = [\r\n this.left.onConnectionObservable.add(() => this._updateInputOutputTypes()),\r\n this.left.onDisconnectionObservable.add(() => this._updateInputOutputTypes()),\r\n this.right.onConnectionObservable.add(() => this._updateInputOutputTypes()),\r\n this.right.onDisconnectionObservable.add(() => this._updateInputOutputTypes()),\r\n ];\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public override getClassName() {\r\n return \"ParticleMathBlock\";\r\n }\r\n\r\n /**\r\n * Gets the left input component\r\n */\r\n public get left(): NodeParticleConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the right input component\r\n */\r\n public get right(): NodeParticleConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the geometry output component\r\n */\r\n public get output(): NodeParticleConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n public override _build(state: NodeParticleBuildState) {\r\n let func: (state: NodeParticleBuildState) => any;\r\n const left = this.left;\r\n const right = this.right;\r\n\r\n if (!left.isConnected || !right.isConnected) {\r\n this.output._storedFunction = null;\r\n this.output._storedValue = null;\r\n return;\r\n }\r\n\r\n const leftIsScalar = left.type === NodeParticleBlockConnectionPointTypes.Float || left.type === NodeParticleBlockConnectionPointTypes.Int;\r\n const rightIsScalar = right.type === NodeParticleBlockConnectionPointTypes.Float || right.type === NodeParticleBlockConnectionPointTypes.Int;\r\n\r\n // If both input types are scalars, then this is a scalar operation.\r\n const isScalar = leftIsScalar && rightIsScalar;\r\n\r\n switch (this.operation) {\r\n case ParticleMathBlockOperations.Add: {\r\n if (isScalar) {\r\n func = (state) => {\r\n return left.getConnectedValue(state) + right.getConnectedValue(state);\r\n };\r\n } else if (leftIsScalar) {\r\n func = (state) => {\r\n return state.adapt(left, right.type).add(right.getConnectedValue(state));\r\n };\r\n } else {\r\n func = (state) => {\r\n return left.getConnectedValue(state).add(state.adapt(right, left.type));\r\n };\r\n }\r\n break;\r\n }\r\n case ParticleMathBlockOperations.Subtract: {\r\n if (isScalar) {\r\n func = (state) => {\r\n return left.getConnectedValue(state) - right.getConnectedValue(state);\r\n };\r\n } else if (leftIsScalar) {\r\n func = (state) => {\r\n return state.adapt(left, right.type).subtract(right.getConnectedValue(state));\r\n };\r\n } else {\r\n func = (state) => {\r\n return left.getConnectedValue(state).subtract(state.adapt(right, left.type));\r\n };\r\n }\r\n break;\r\n }\r\n case ParticleMathBlockOperations.Multiply: {\r\n if (isScalar) {\r\n func = (state) => {\r\n return left.getConnectedValue(state) * right.getConnectedValue(state);\r\n };\r\n } else if (leftIsScalar) {\r\n func = (state) => {\r\n return state.adapt(left, right.type).multiply(right.getConnectedValue(state));\r\n };\r\n } else {\r\n func = (state) => {\r\n return left.getConnectedValue(state).multiply(state.adapt(right, left.type));\r\n };\r\n }\r\n break;\r\n }\r\n case ParticleMathBlockOperations.Divide: {\r\n if (isScalar) {\r\n func = (state) => {\r\n return left.getConnectedValue(state) / right.getConnectedValue(state);\r\n };\r\n } else if (leftIsScalar) {\r\n func = (state) => {\r\n return state.adapt(left, right.type).divide(right.getConnectedValue(state));\r\n };\r\n } else {\r\n func = (state) => {\r\n return left.getConnectedValue(state).divide(state.adapt(right, left.type));\r\n };\r\n }\r\n break;\r\n }\r\n case ParticleMathBlockOperations.Min: {\r\n if (isScalar) {\r\n func = (state) => {\r\n return Math.min(left.getConnectedValue(state), right.getConnectedValue(state));\r\n };\r\n } else {\r\n const [vector, scalar] = leftIsScalar ? [right, left] : [left, right];\r\n\r\n switch (vector.type) {\r\n case NodeParticleBlockConnectionPointTypes.Vector2: {\r\n func = (state) => {\r\n return Vector2.Minimize(vector.getConnectedValue(state), state.adapt(scalar, vector.type));\r\n };\r\n break;\r\n }\r\n case NodeParticleBlockConnectionPointTypes.Vector3: {\r\n func = (state) => {\r\n return Vector3.Minimize(vector.getConnectedValue(state), state.adapt(scalar, vector.type));\r\n };\r\n break;\r\n }\r\n case NodeParticleBlockConnectionPointTypes.Color4: {\r\n func = (state) => {\r\n const other = vector.getConnectedValue(state);\r\n const { r, g, b, a } = state.adapt(scalar, vector.type);\r\n\r\n return new Color4(Math.min(other.r, r), Math.min(other.g, g), Math.min(other.b, b), Math.min(other.a, a));\r\n };\r\n break;\r\n }\r\n }\r\n }\r\n break;\r\n }\r\n case ParticleMathBlockOperations.Max: {\r\n if (isScalar) {\r\n func = (state) => {\r\n return Math.max(left.getConnectedValue(state), right.getConnectedValue(state));\r\n };\r\n } else {\r\n const [vector, scalar] = leftIsScalar ? [right, left] : [left, right];\r\n\r\n switch (vector.type) {\r\n case NodeParticleBlockConnectionPointTypes.Vector2: {\r\n func = (state) => {\r\n return Vector2.Maximize(vector.getConnectedValue(state), state.adapt(scalar, vector.type));\r\n };\r\n break;\r\n }\r\n case NodeParticleBlockConnectionPointTypes.Vector3: {\r\n func = (state) => {\r\n return Vector3.Maximize(vector.getConnectedValue(state), state.adapt(scalar, vector.type));\r\n };\r\n break;\r\n }\r\n case NodeParticleBlockConnectionPointTypes.Color4: {\r\n func = (state) => {\r\n const other = vector.getConnectedValue(state);\r\n const { r, g, b, a } = state.adapt(scalar, vector.type);\r\n\r\n return new Color4(Math.max(other.r, r), Math.min(other.g, g), Math.min(other.b, b), Math.min(other.a, a));\r\n };\r\n break;\r\n }\r\n }\r\n break;\r\n }\r\n }\r\n }\r\n\r\n this.output._storedFunction = (state) => {\r\n if (left.type === NodeParticleBlockConnectionPointTypes.Int) {\r\n return func(state) | 0;\r\n }\r\n return func(state);\r\n };\r\n }\r\n\r\n private _updateInputOutputTypes() {\r\n // First update the output type with the initial assumption that we'll base it on the left input.\r\n this.output._typeConnectionSource = this.left;\r\n\r\n if (this.left.isConnected && this.right.isConnected) {\r\n // Both inputs are connected, so we need to determine the output type based on the input types.\r\n if (\r\n this.left.type === NodeParticleBlockConnectionPointTypes.Int ||\r\n (this.left.type === NodeParticleBlockConnectionPointTypes.Float && this.right.type !== NodeParticleBlockConnectionPointTypes.Int)\r\n ) {\r\n this.output._typeConnectionSource = this.right;\r\n }\r\n } else if (this.left.isConnected !== this.right.isConnected) {\r\n // Only one input is connected, so we need to determine the output type based on the connected input.\r\n this.output._typeConnectionSource = this.left.isConnected ? this.left : this.right;\r\n }\r\n\r\n // Next update the accepted connection point types for the inputs based on the current input connection state.\r\n if (this.left.isConnected || this.right.isConnected) {\r\n for (const [first, second] of [\r\n [this.left, this.right],\r\n [this.right, this.left],\r\n ]) {\r\n // Always allow Ints and Floats.\r\n first.acceptedConnectionPointTypes = [NodeParticleBlockConnectionPointTypes.Int, NodeParticleBlockConnectionPointTypes.Float];\r\n\r\n if (second.isConnected) {\r\n // The same types as the connected input are always allowed.\r\n first.acceptedConnectionPointTypes.push(second.type);\r\n\r\n // If the other input is a scalar, then we also allow Vector types.\r\n if (second.type === NodeParticleBlockConnectionPointTypes.Int || second.type === NodeParticleBlockConnectionPointTypes.Float) {\r\n first.acceptedConnectionPointTypes.push(\r\n NodeParticleBlockConnectionPointTypes.Vector2,\r\n NodeParticleBlockConnectionPointTypes.Vector3,\r\n NodeParticleBlockConnectionPointTypes.Color4\r\n );\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Release resources\r\n */\r\n public override dispose() {\r\n super.dispose();\r\n for (const observer of this._connectionObservers) {\r\n observer.remove();\r\n }\r\n this._connectionObservers.length = 0;\r\n }\r\n\r\n /**\r\n * Serializes this block in a JSON representation\r\n * @returns the serialized block object\r\n */\r\n public override serialize(): any {\r\n const serializationObject = super.serialize();\r\n\r\n serializationObject.operation = this.operation;\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Deserializes the block from a JSON object\r\n * @param serializationObject the JSON object to deserialize from\r\n */\r\n public override _deserialize(serializationObject: any) {\r\n super._deserialize(serializationObject);\r\n\r\n this.operation = serializationObject.operation;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.ParticleMathBlock\", ParticleMathBlock);\r\n"]}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { NodeParticleConnectionPoint } from "../nodeParticleBlockConnectionPoint.js";
|
|
2
|
+
import type { NodeParticleBuildState } from "../nodeParticleBuildState.js";
|
|
3
|
+
import { NodeParticleBlock } from "../nodeParticleBlock.js";
|
|
4
|
+
/**
|
|
5
|
+
* Operations supported by the Number Math block
|
|
6
|
+
*/
|
|
7
|
+
export declare enum ParticleNumberMathBlockOperations {
|
|
8
|
+
/** Modulo */
|
|
9
|
+
Modulo = 0,
|
|
10
|
+
/** Power */
|
|
11
|
+
Pow = 1
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Block used to apply math operations that only appply to numbers (int/float)
|
|
15
|
+
*/
|
|
16
|
+
export declare class ParticleNumberMathBlock extends NodeParticleBlock {
|
|
17
|
+
/**
|
|
18
|
+
* Gets or sets the operation applied by the block
|
|
19
|
+
*/
|
|
20
|
+
operation: ParticleNumberMathBlockOperations;
|
|
21
|
+
private readonly _connectionObservers;
|
|
22
|
+
/**
|
|
23
|
+
* Create a new ParticleNumberMathBlock
|
|
24
|
+
* @param name defines the block name
|
|
25
|
+
*/
|
|
26
|
+
constructor(name: string);
|
|
27
|
+
/**
|
|
28
|
+
* Gets the current class name
|
|
29
|
+
* @returns the class name
|
|
30
|
+
*/
|
|
31
|
+
getClassName(): string;
|
|
32
|
+
/**
|
|
33
|
+
* Gets the left input component
|
|
34
|
+
*/
|
|
35
|
+
get left(): NodeParticleConnectionPoint;
|
|
36
|
+
/**
|
|
37
|
+
* Gets the right input component
|
|
38
|
+
*/
|
|
39
|
+
get right(): NodeParticleConnectionPoint;
|
|
40
|
+
/**
|
|
41
|
+
* Gets the geometry output component
|
|
42
|
+
*/
|
|
43
|
+
get output(): NodeParticleConnectionPoint;
|
|
44
|
+
_build(state: NodeParticleBuildState): void;
|
|
45
|
+
private _updateInputOutputTypes;
|
|
46
|
+
/**
|
|
47
|
+
* Release resources
|
|
48
|
+
*/
|
|
49
|
+
dispose(): void;
|
|
50
|
+
/**
|
|
51
|
+
* Serializes this block in a JSON representation
|
|
52
|
+
* @returns the serialized block object
|
|
53
|
+
*/
|
|
54
|
+
serialize(): any;
|
|
55
|
+
/**
|
|
56
|
+
* Deserializes the block from a JSON object
|
|
57
|
+
* @param serializationObject the JSON object to deserialize from
|
|
58
|
+
*/
|
|
59
|
+
_deserialize(serializationObject: any): void;
|
|
60
|
+
}
|