@onerjs/core 8.30.7 → 8.30.8
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/abstractAudio/audioEngineV2.d.ts +0 -4
- package/AudioV2/abstractAudio/audioEngineV2.js +0 -4
- package/AudioV2/abstractAudio/audioEngineV2.js.map +1 -1
- package/AudioV2/abstractAudio/subNodes/volumeAudioSubNode.js +1 -1
- package/AudioV2/abstractAudio/subNodes/volumeAudioSubNode.js.map +1 -1
- package/AudioV2/audioParameter.d.ts +5 -1
- package/AudioV2/audioParameter.js +4 -0
- package/AudioV2/audioParameter.js.map +1 -1
- package/AudioV2/webAudio/components/webAudioParameterComponent.d.ts +0 -18
- package/AudioV2/webAudio/components/webAudioParameterComponent.js +7 -67
- package/AudioV2/webAudio/components/webAudioParameterComponent.js.map +1 -1
- package/Particles/EmitterTypes/sphereParticleEmitter.d.ts +3 -1
- package/Particles/EmitterTypes/sphereParticleEmitter.js +7 -1
- package/Particles/EmitterTypes/sphereParticleEmitter.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/boxShapeBlock.d.ts +1 -1
- package/Particles/Node/Blocks/Emitters/boxShapeBlock.js +2 -1
- package/Particles/Node/Blocks/Emitters/boxShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/cylinderShapeBlock.d.ts +10 -1
- package/Particles/Node/Blocks/Emitters/cylinderShapeBlock.js +50 -17
- package/Particles/Node/Blocks/Emitters/cylinderShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/emitters.functions.d.ts +6 -0
- package/Particles/Node/Blocks/Emitters/emitters.functions.js +13 -0
- package/Particles/Node/Blocks/Emitters/emitters.functions.js.map +1 -0
- package/Particles/Node/Blocks/Emitters/meshShapeBlock.d.ts +2 -2
- package/Particles/Node/Blocks/Emitters/meshShapeBlock.js +5 -1
- package/Particles/Node/Blocks/Emitters/meshShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/pointShapeBlock.d.ts +1 -1
- package/Particles/Node/Blocks/Emitters/pointShapeBlock.js +3 -1
- package/Particles/Node/Blocks/Emitters/pointShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/sphereShapeBlock.d.ts +10 -1
- package/Particles/Node/Blocks/Emitters/sphereShapeBlock.js +45 -13
- package/Particles/Node/Blocks/Emitters/sphereShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/particleInputBlock.js +1 -0
- package/Particles/Node/Blocks/particleInputBlock.js.map +1 -1
- package/Particles/Node/Enums/nodeParticleContextualSources.d.ts +3 -1
- package/Particles/Node/Enums/nodeParticleContextualSources.js +2 -0
- package/Particles/Node/Enums/nodeParticleContextualSources.js.map +1 -1
- package/Particles/Node/nodeParticleBuildState.js +5 -0
- package/Particles/Node/nodeParticleBuildState.js.map +1 -1
- package/Particles/Node/nodeParticleSystemSet.helper.js +35 -8
- package/Particles/Node/nodeParticleSystemSet.helper.js.map +1 -1
- package/Particles/thinParticleSystem.function.d.ts +2 -2
- package/Particles/thinParticleSystem.function.js +2 -2
- package/Particles/thinParticleSystem.function.js.map +1 -1
- package/Rendering/prePassRenderer.js +4 -1
- package/Rendering/prePassRenderer.js.map +1 -1
- package/package.json +1 -1
|
@@ -3,8 +3,10 @@ import { RegisterClass } from "../../../../Misc/typeStore.js";
|
|
|
3
3
|
import { NodeParticleBlockConnectionPointTypes } from "../../Enums/nodeParticleBlockConnectionPointTypes.js";
|
|
4
4
|
import { NodeParticleBlock } from "../../nodeParticleBlock.js";
|
|
5
5
|
import { Vector3 } from "../../../../Maths/math.vector.js";
|
|
6
|
+
import { _CreateLocalPositionData } from "./emitters.functions.js";
|
|
6
7
|
/**
|
|
7
8
|
* Block used to provide a flow of particles emitted from a cylinder shape.
|
|
9
|
+
* DirectionRandomizer will be used for the particles initial direction unless both direction1 and direction2 are connected.
|
|
8
10
|
*/
|
|
9
11
|
export class CylinderShapeBlock extends NodeParticleBlock {
|
|
10
12
|
/**
|
|
@@ -19,6 +21,8 @@ export class CylinderShapeBlock extends NodeParticleBlock {
|
|
|
19
21
|
this.registerInput("height", NodeParticleBlockConnectionPointTypes.Float, true, 1, 0);
|
|
20
22
|
this.registerInput("radiusRange", NodeParticleBlockConnectionPointTypes.Float, true, 1, 0, 1);
|
|
21
23
|
this.registerInput("directionRandomizer", NodeParticleBlockConnectionPointTypes.Float, true, 0, 0, 1);
|
|
24
|
+
this.registerInput("direction1", NodeParticleBlockConnectionPointTypes.Vector3, true);
|
|
25
|
+
this.registerInput("direction2", NodeParticleBlockConnectionPointTypes.Vector3, true);
|
|
22
26
|
this.registerOutput("output", NodeParticleBlockConnectionPointTypes.Particle);
|
|
23
27
|
}
|
|
24
28
|
/**
|
|
@@ -58,6 +62,18 @@ export class CylinderShapeBlock extends NodeParticleBlock {
|
|
|
58
62
|
get directionRandomizer() {
|
|
59
63
|
return this._inputs[4];
|
|
60
64
|
}
|
|
65
|
+
/**
|
|
66
|
+
* Gets the direction1 input component
|
|
67
|
+
*/
|
|
68
|
+
get direction1() {
|
|
69
|
+
return this._inputs[5];
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Gets the direction2 input component
|
|
73
|
+
*/
|
|
74
|
+
get direction2() {
|
|
75
|
+
return this._inputs[6];
|
|
76
|
+
}
|
|
61
77
|
/**
|
|
62
78
|
* Gets the output component
|
|
63
79
|
*/
|
|
@@ -73,24 +89,40 @@ export class CylinderShapeBlock extends NodeParticleBlock {
|
|
|
73
89
|
system._directionCreation.process = (particle) => {
|
|
74
90
|
state.particleContext = particle;
|
|
75
91
|
state.systemContext = system;
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
92
|
+
// We always use directionRandomizer unless both directions are connected
|
|
93
|
+
if (this.direction1.isConnected === false || this.direction2.isConnected === false) {
|
|
94
|
+
const directionRandomizer = this.directionRandomizer.getConnectedValue(state);
|
|
95
|
+
particle.position.subtractToRef(state.emitterPosition, this._tempVector);
|
|
96
|
+
this._tempVector.normalize();
|
|
97
|
+
if (state.emitterInverseWorldMatrix) {
|
|
98
|
+
Vector3.TransformNormalToRef(this._tempVector, state.emitterInverseWorldMatrix, this._tempVector);
|
|
99
|
+
}
|
|
100
|
+
const randY = RandomRange(-directionRandomizer / 2, directionRandomizer / 2);
|
|
101
|
+
let angle = Math.atan2(this._tempVector.x, this._tempVector.z);
|
|
102
|
+
angle += RandomRange(-Math.PI / 2, Math.PI / 2) * directionRandomizer;
|
|
103
|
+
this._tempVector.y = randY; // set direction y to rand y to mirror normal of cylinder surface
|
|
104
|
+
this._tempVector.x = Math.sin(angle);
|
|
105
|
+
this._tempVector.z = Math.cos(angle);
|
|
106
|
+
this._tempVector.normalize();
|
|
107
|
+
if (system.isLocal) {
|
|
108
|
+
particle.direction.copyFrom(this._tempVector);
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
Vector3.TransformNormalFromFloatsToRef(this._tempVector.x, this._tempVector.y, this._tempVector.z, state.emitterWorldMatrix, particle.direction);
|
|
112
|
+
}
|
|
91
113
|
}
|
|
92
114
|
else {
|
|
93
|
-
|
|
115
|
+
const direction1 = this.direction1.getConnectedValue(state);
|
|
116
|
+
const direction2 = this.direction2.getConnectedValue(state);
|
|
117
|
+
const randX = RandomRange(direction1.x, direction2.x);
|
|
118
|
+
const randY = RandomRange(direction1.y, direction2.y);
|
|
119
|
+
const randZ = RandomRange(direction1.z, direction2.z);
|
|
120
|
+
if (system.isLocal) {
|
|
121
|
+
particle.direction.copyFromFloats(randX, randY, randZ);
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
Vector3.TransformNormalFromFloatsToRef(randX, randY, randZ, state.emitterWorldMatrix, particle.direction);
|
|
125
|
+
}
|
|
94
126
|
}
|
|
95
127
|
particle._initialDirection = particle.direction.clone();
|
|
96
128
|
};
|
|
@@ -102,17 +134,18 @@ export class CylinderShapeBlock extends NodeParticleBlock {
|
|
|
102
134
|
const radius = this.radius.getConnectedValue(state);
|
|
103
135
|
const yPos = RandomRange(-height / 2, height / 2);
|
|
104
136
|
const angle = RandomRange(0, 2 * Math.PI);
|
|
137
|
+
// Pick a properly distributed point within the circle https://programming.guide/random-point-within-circle.html
|
|
105
138
|
const radiusDistribution = RandomRange((1 - radiusRange) * (1 - radiusRange), 1);
|
|
106
139
|
const positionRadius = Math.sqrt(radiusDistribution) * radius;
|
|
107
140
|
const xPos = positionRadius * Math.cos(angle);
|
|
108
141
|
const zPos = positionRadius * Math.sin(angle);
|
|
109
142
|
if (system.isLocal) {
|
|
110
143
|
particle.position.copyFromFloats(xPos, yPos, zPos);
|
|
111
|
-
particle.position.addInPlace(state.emitterPosition);
|
|
112
144
|
}
|
|
113
145
|
else {
|
|
114
146
|
Vector3.TransformCoordinatesFromFloatsToRef(xPos, yPos, zPos, state.emitterWorldMatrix, particle.position);
|
|
115
147
|
}
|
|
148
|
+
_CreateLocalPositionData(particle);
|
|
116
149
|
};
|
|
117
150
|
this.output._storedValue = system;
|
|
118
151
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cylinderShapeBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Particles/Node/Blocks/Emitters/cylinderShapeBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,mDAAyC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,qCAAqC,EAAE,MAAM,mDAAmD,CAAC;AAC1G,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAI5D,OAAO,EAAE,OAAO,EAAE,yCAA+B;AAGjD;;GAEG;AACH,MAAM,OAAO,kBAAmB,SAAQ,iBAAiB;IAErD;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAA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AE,CAAC,CAAC;YAE1C,MAAM,kBAAkB,GAAG,WAAW,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC,GAAG,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC;YACjF,MAAM,cAAc,GAAG,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,GAAG,MAAM,CAAC;YAC9D,MAAM,IAAI,GAAG,cAAc,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YAC9C,MAAM,IAAI,GAAG,cAAc,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YAE9C,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;gBACjB,QAAQ,CAAC,QAAQ,CAAC,cAAc,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;gBACnD,QAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,eAAgB,CAAC,CAAC;YACzD,CAAC;iBAAM,CAAC;gBACJ,OAAO,CAAC,mCAAmC,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,kBAAmB,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;YAChH,CAAC;QACL,CAAC,CAAC;QAEF,IAAI,CAAC,MAAM,CAAC,YAAY,GAAG,MAAM,CAAC;IACtC,CAAC;CACJ;AAED,aAAa,CAAC,4BAA4B,EAAE,kBAAkB,CAAC,CAAC","sourcesContent":["import { RandomRange } from \"core/Maths/math.scalar.functions\";\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\nimport type { Particle } from \"core/Particles/particle\";\r\nimport { Vector3 } from \"core/Maths/math.vector\";\r\nimport type { IShapeBlock } from \"./IShapeBlock\";\r\n\r\n/**\r\n * Block used to provide a flow of particles emitted from a cylinder shape.\r\n */\r\nexport class CylinderShapeBlock extends NodeParticleBlock implements IShapeBlock {\r\n private _tempVector = Vector3.Zero();\r\n /**\r\n * Create a new CylinderShapeBlock\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(\"radius\", NodeParticleBlockConnectionPointTypes.Float, true, 1);\r\n this.registerInput(\"height\", NodeParticleBlockConnectionPointTypes.Float, true, 1, 0);\r\n this.registerInput(\"radiusRange\", NodeParticleBlockConnectionPointTypes.Float, true, 1, 0, 1);\r\n this.registerInput(\"directionRandomizer\", NodeParticleBlockConnectionPointTypes.Float, true, 0, 0, 1);\r\n this.registerOutput(\"output\", NodeParticleBlockConnectionPointTypes.Particle);\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 \"CylinderShapeBlock\";\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 radius input component\r\n */\r\n public get radius(): NodeParticleConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the height input component\r\n */\r\n public get height(): NodeParticleConnectionPoint {\r\n return this._inputs[2];\r\n }\r\n\r\n /**\r\n * Gets the radiusRange input component\r\n */\r\n public get radiusRange(): NodeParticleConnectionPoint {\r\n return this._inputs[3];\r\n }\r\n\r\n /**\r\n * Gets the directionRandomizer input component\r\n */\r\n public get directionRandomizer(): NodeParticleConnectionPoint {\r\n return this._inputs[4];\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 * Builds the block\r\n * @param state defines the build state\r\n */\r\n public override _build(state: NodeParticleBuildState) {\r\n const system = this.particle.getConnectedValue(state);\r\n\r\n system._directionCreation.process = (particle: Particle) => {\r\n state.particleContext = particle;\r\n state.systemContext = system;\r\n\r\n const directionRandomizer = this.directionRandomizer.getConnectedValue(state);\r\n particle.position.subtractToRef(state.emitterPosition!, this._tempVector);\r\n\r\n this._tempVector.normalize();\r\n\r\n if (state.emitterInverseWorldMatrix) {\r\n Vector3.TransformNormalToRef(this._tempVector, state.emitterInverseWorldMatrix, this._tempVector);\r\n }\r\n\r\n const randY = RandomRange(-directionRandomizer / 2, directionRandomizer / 2);\r\n\r\n let angle = Math.atan2(this._tempVector.x, this._tempVector.z);\r\n angle += RandomRange(-Math.PI / 2, Math.PI / 2) * directionRandomizer;\r\n\r\n this._tempVector.y = randY; // set direction y to rand y to mirror normal of cylinder surface\r\n this._tempVector.x = Math.sin(angle);\r\n this._tempVector.z = Math.cos(angle);\r\n this._tempVector.normalize();\r\n\r\n if (system.isLocal) {\r\n particle.direction.copyFrom(this._tempVector);\r\n } else {\r\n Vector3.TransformNormalFromFloatsToRef(this._tempVector.x, this._tempVector.y, this._tempVector.z, state.emitterWorldMatrix!, particle.direction);\r\n }\r\n\r\n particle._initialDirection = particle.direction.clone();\r\n };\r\n\r\n system._positionCreation.process = (particle: Particle) => {\r\n state.particleContext = particle;\r\n state.systemContext = system;\r\n\r\n const height = this.height.getConnectedValue(state);\r\n const radiusRange = this.radiusRange.getConnectedValue(state);\r\n const radius = this.radius.getConnectedValue(state);\r\n const yPos = RandomRange(-height / 2, height / 2);\r\n const angle = RandomRange(0, 2 * Math.PI);\r\n\r\n const radiusDistribution = RandomRange((1 - radiusRange) * (1 - radiusRange), 1);\r\n const positionRadius = Math.sqrt(radiusDistribution) * radius;\r\n const xPos = positionRadius * Math.cos(angle);\r\n const zPos = positionRadius * Math.sin(angle);\r\n\r\n if (system.isLocal) {\r\n particle.position.copyFromFloats(xPos, yPos, zPos);\r\n particle.position.addInPlace(state.emitterPosition!);\r\n } else {\r\n Vector3.TransformCoordinatesFromFloatsToRef(xPos, yPos, zPos, state.emitterWorldMatrix!, particle.position);\r\n }\r\n };\r\n\r\n this.output._storedValue = system;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.CylinderShapeBlock\", CylinderShapeBlock);\r\n"]}
|
|
1
|
+
{"version":3,"file":"cylinderShapeBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Particles/Node/Blocks/Emitters/cylinderShapeBlock.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,EAAE,mDAAyC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,qCAAqC,EAAE,MAAM,mDAAmD,CAAC;AAC1G,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAE,yCAA+B;AACjD,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAEhE;;;GAGG;AACH,MAAM,OAAO,kBAAmB,SAAQ,iBAAiB;IAErD;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,CAAC,CAAC;QANR,gBAAW,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;QAQjC,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,qCAAqC,CAAC,QAAQ,CAAC,CAAC;QAC/E,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE,qCAAqC,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QACnF,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE,qCAAqC,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QACtF,IAAI,CAAC,aAAa,CAAC,aAAa,EAAE,qCAAqC,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QAC9F,IAAI,CAAC,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AAQ,CAAC,QAAQ,CAAC,cAAc,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;YACvD,CAAC;iBAAM,CAAC;gBACJ,OAAO,CAAC,mCAAmC,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,kBAAmB,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;YAChH,CAAC;YAED,wBAAwB,CAAC,QAAQ,CAAC,CAAC;QACvC,CAAC,CAAC;QAEF,IAAI,CAAC,MAAM,CAAC,YAAY,GAAG,MAAM,CAAC;IACtC,CAAC;CACJ;AAED,aAAa,CAAC,4BAA4B,EAAE,kBAAkB,CAAC,CAAC","sourcesContent":["import type { NodeParticleConnectionPoint } from \"../../nodeParticleBlockConnectionPoint\";\r\nimport type { NodeParticleBuildState } from \"../../nodeParticleBuildState\";\r\nimport type { Particle } from \"core/Particles/particle\";\r\nimport type { IShapeBlock } from \"./IShapeBlock\";\r\n\r\nimport { RandomRange } from \"core/Maths/math.scalar.functions\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport { NodeParticleBlockConnectionPointTypes } from \"../../Enums/nodeParticleBlockConnectionPointTypes\";\r\nimport { NodeParticleBlock } from \"../../nodeParticleBlock\";\r\nimport { Vector3 } from \"core/Maths/math.vector\";\r\nimport { _CreateLocalPositionData } from \"./emitters.functions\";\r\n\r\n/**\r\n * Block used to provide a flow of particles emitted from a cylinder shape.\r\n * DirectionRandomizer will be used for the particles initial direction unless both direction1 and direction2 are connected.\r\n */\r\nexport class CylinderShapeBlock extends NodeParticleBlock implements IShapeBlock {\r\n private _tempVector = Vector3.Zero();\r\n /**\r\n * Create a new CylinderShapeBlock\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(\"radius\", NodeParticleBlockConnectionPointTypes.Float, true, 1);\r\n this.registerInput(\"height\", NodeParticleBlockConnectionPointTypes.Float, true, 1, 0);\r\n this.registerInput(\"radiusRange\", NodeParticleBlockConnectionPointTypes.Float, true, 1, 0, 1);\r\n this.registerInput(\"directionRandomizer\", NodeParticleBlockConnectionPointTypes.Float, true, 0, 0, 1);\r\n this.registerInput(\"direction1\", NodeParticleBlockConnectionPointTypes.Vector3, true);\r\n this.registerInput(\"direction2\", NodeParticleBlockConnectionPointTypes.Vector3, true);\r\n this.registerOutput(\"output\", NodeParticleBlockConnectionPointTypes.Particle);\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 \"CylinderShapeBlock\";\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 radius input component\r\n */\r\n public get radius(): NodeParticleConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the height input component\r\n */\r\n public get height(): NodeParticleConnectionPoint {\r\n return this._inputs[2];\r\n }\r\n\r\n /**\r\n * Gets the radiusRange input component\r\n */\r\n public get radiusRange(): NodeParticleConnectionPoint {\r\n return this._inputs[3];\r\n }\r\n\r\n /**\r\n * Gets the directionRandomizer input component\r\n */\r\n public get directionRandomizer(): NodeParticleConnectionPoint {\r\n return this._inputs[4];\r\n }\r\n\r\n /**\r\n * Gets the direction1 input component\r\n */\r\n public get direction1(): NodeParticleConnectionPoint {\r\n return this._inputs[5];\r\n }\r\n\r\n /**\r\n * Gets the direction2 input component\r\n */\r\n public get direction2(): NodeParticleConnectionPoint {\r\n return this._inputs[6];\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 * Builds the block\r\n * @param state defines the build state\r\n */\r\n public override _build(state: NodeParticleBuildState) {\r\n const system = this.particle.getConnectedValue(state);\r\n\r\n system._directionCreation.process = (particle: Particle) => {\r\n state.particleContext = particle;\r\n state.systemContext = system;\r\n\r\n // We always use directionRandomizer unless both directions are connected\r\n if (this.direction1.isConnected === false || this.direction2.isConnected === false) {\r\n const directionRandomizer = this.directionRandomizer.getConnectedValue(state) as number;\r\n\r\n particle.position.subtractToRef(state.emitterPosition!, this._tempVector);\r\n this._tempVector.normalize();\r\n\r\n if (state.emitterInverseWorldMatrix) {\r\n Vector3.TransformNormalToRef(this._tempVector, state.emitterInverseWorldMatrix, this._tempVector);\r\n }\r\n\r\n const randY = RandomRange(-directionRandomizer / 2, directionRandomizer / 2);\r\n\r\n let angle = Math.atan2(this._tempVector.x, this._tempVector.z);\r\n angle += RandomRange(-Math.PI / 2, Math.PI / 2) * directionRandomizer;\r\n\r\n this._tempVector.y = randY; // set direction y to rand y to mirror normal of cylinder surface\r\n this._tempVector.x = Math.sin(angle);\r\n this._tempVector.z = Math.cos(angle);\r\n this._tempVector.normalize();\r\n\r\n if (system.isLocal) {\r\n particle.direction.copyFrom(this._tempVector);\r\n } else {\r\n Vector3.TransformNormalFromFloatsToRef(this._tempVector.x, this._tempVector.y, this._tempVector.z, state.emitterWorldMatrix!, particle.direction);\r\n }\r\n } else {\r\n const direction1 = this.direction1.getConnectedValue(state) as Vector3;\r\n const direction2 = this.direction2.getConnectedValue(state) as Vector3;\r\n\r\n const randX = RandomRange(direction1.x, direction2.x);\r\n const randY = RandomRange(direction1.y, direction2.y);\r\n const randZ = RandomRange(direction1.z, direction2.z);\r\n\r\n if (system.isLocal) {\r\n particle.direction.copyFromFloats(randX, randY, randZ);\r\n } else {\r\n Vector3.TransformNormalFromFloatsToRef(randX, randY, randZ, state.emitterWorldMatrix!, particle.direction);\r\n }\r\n }\r\n\r\n particle._initialDirection = particle.direction.clone();\r\n };\r\n\r\n system._positionCreation.process = (particle: Particle) => {\r\n state.particleContext = particle;\r\n state.systemContext = system;\r\n\r\n const height = this.height.getConnectedValue(state) as number;\r\n const radiusRange = this.radiusRange.getConnectedValue(state) as number;\r\n const radius = this.radius.getConnectedValue(state) as number;\r\n\r\n const yPos = RandomRange(-height / 2, height / 2);\r\n const angle = RandomRange(0, 2 * Math.PI);\r\n\r\n // Pick a properly distributed point within the circle https://programming.guide/random-point-within-circle.html\r\n const radiusDistribution = RandomRange((1 - radiusRange) * (1 - radiusRange), 1);\r\n const positionRadius = Math.sqrt(radiusDistribution) * radius;\r\n const xPos = positionRadius * Math.cos(angle);\r\n const zPos = positionRadius * Math.sin(angle);\r\n\r\n if (system.isLocal) {\r\n particle.position.copyFromFloats(xPos, yPos, zPos);\r\n } else {\r\n Vector3.TransformCoordinatesFromFloatsToRef(xPos, yPos, zPos, state.emitterWorldMatrix!, particle.position);\r\n }\r\n\r\n _CreateLocalPositionData(particle);\r\n };\r\n\r\n this.output._storedValue = system;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.CylinderShapeBlock\", CylinderShapeBlock);\r\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates the local position data for the particle
|
|
3
|
+
* @param particle The particle to update
|
|
4
|
+
*/
|
|
5
|
+
export function _CreateLocalPositionData(particle) {
|
|
6
|
+
if (!particle._localPosition) {
|
|
7
|
+
particle._localPosition = particle.position.clone();
|
|
8
|
+
}
|
|
9
|
+
else {
|
|
10
|
+
particle._localPosition.copyFrom(particle.position);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=emitters.functions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emitters.functions.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Particles/Node/Blocks/Emitters/emitters.functions.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,UAAU,wBAAwB,CAAC,QAAkB;IACvD,IAAI,CAAC,QAAQ,CAAC,cAAc,EAAE,CAAC;QAC3B,QAAQ,CAAC,cAAc,GAAG,QAAQ,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;IACxD,CAAC;SAAM,CAAC;QACJ,QAAQ,CAAC,cAAc,CAAC,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACxD,CAAC;AACL,CAAC","sourcesContent":["import type { Particle } from \"core/Particles/particle\";\r\n\r\n/**\r\n * Creates the local position data for the particle\r\n * @param particle The particle to update\r\n */\r\nexport function _CreateLocalPositionData(particle: Particle): void {\r\n if (!particle._localPosition) {\r\n particle._localPosition = particle.position.clone();\r\n } else {\r\n particle._localPosition.copyFrom(particle.position);\r\n }\r\n}\r\n"]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { Mesh } from "../../../../Meshes/mesh.js";
|
|
2
1
|
import type { Nullable } from "../../../../types.js";
|
|
3
|
-
import {
|
|
2
|
+
import type { Mesh } from "../../../../Meshes/mesh.js";
|
|
4
3
|
import type { NodeParticleBuildState } from "../../nodeParticleBuildState.js";
|
|
5
4
|
import type { NodeParticleConnectionPoint } from "../../nodeParticleBlockConnectionPoint.js";
|
|
6
5
|
import type { IShapeBlock } from "./IShapeBlock.js";
|
|
6
|
+
import { NodeParticleBlock } from "../../nodeParticleBlock.js";
|
|
7
7
|
/**
|
|
8
8
|
* Defines a block used to generate particle shape from mesh geometry data
|
|
9
9
|
*/
|
|
@@ -6,6 +6,7 @@ import { NodeParticleBlock } from "../../nodeParticleBlock.js";
|
|
|
6
6
|
import { NodeParticleBlockConnectionPointTypes } from "../../Enums/nodeParticleBlockConnectionPointTypes.js";
|
|
7
7
|
import { TmpVectors, Vector3, Vector4 } from "../../../../Maths/math.vector.js";
|
|
8
8
|
import { RandomRange } from "../../../../Maths/math.scalar.functions.js";
|
|
9
|
+
import { _CreateLocalPositionData } from "./emitters.functions.js";
|
|
9
10
|
/**
|
|
10
11
|
* Defines a block used to generate particle shape from mesh geometry data
|
|
11
12
|
*/
|
|
@@ -38,7 +39,7 @@ export class MeshShapeBlock extends NodeParticleBlock {
|
|
|
38
39
|
/**
|
|
39
40
|
* Gets or sets a boolean indicating if the mesh normals should be used for particle direction
|
|
40
41
|
*/
|
|
41
|
-
this.useMeshNormalsForDirection =
|
|
42
|
+
this.useMeshNormalsForDirection = true;
|
|
42
43
|
/**
|
|
43
44
|
* Gets or sets a boolean indicating if the mesh colors should be used for particle color
|
|
44
45
|
*/
|
|
@@ -146,6 +147,8 @@ export class MeshShapeBlock extends NodeParticleBlock {
|
|
|
146
147
|
particle._initialDirection = particle.direction.clone();
|
|
147
148
|
};
|
|
148
149
|
system._positionCreation.process = (particle) => {
|
|
150
|
+
state.particleContext = particle;
|
|
151
|
+
state.systemContext = system;
|
|
149
152
|
if (!this._indices || !this._positions) {
|
|
150
153
|
return;
|
|
151
154
|
}
|
|
@@ -175,6 +178,7 @@ export class MeshShapeBlock extends NodeParticleBlock {
|
|
|
175
178
|
else {
|
|
176
179
|
Vector3.TransformCoordinatesFromFloatsToRef(randomVertex.x, randomVertex.y, randomVertex.z, state.emitterWorldMatrix, particle.position);
|
|
177
180
|
}
|
|
181
|
+
_CreateLocalPositionData(particle);
|
|
178
182
|
if (this.useMeshNormalsForDirection && this._normals) {
|
|
179
183
|
Vector3.FromArrayToRef(this._normals, faceIndexA * 3, vertexA);
|
|
180
184
|
Vector3.FromArrayToRef(this._normals, faceIndexB * 3, vertexB);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meshShapeBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Particles/Node/Blocks/Emitters/meshShapeBlock.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE3D,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAEhE,OAAO,EAA0B,sBAAsB,EAAE,gDAAsC;AAC/F,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,qCAAqC,EAAE,MAAM,mDAAmD,CAAC;AAI1G,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,y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BAAoB,CAAC;QACvE,IAAI,CAAC,0BAA0B,GAAG,CAAC,CAAC,mBAAmB,CAAC,0BAA0B,CAAC;QACnF,IAAI,CAAC,oBAAoB,GAAG,CAAC,CAAC,mBAAmB,CAAC,oBAAoB,CAAC;QACvE,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC,mBAAmB,CAAC,UAAU,CAAC;IACvD,CAAC;CACJ;AA5PU;IADN,sBAAsB,CAAC,uBAAuB,0CAAkC,UAAU,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC;4DAC1G;AAM7B;IADN,sBAAsB,CAAC,2BAA2B,0CAAkC,UAAU,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC;kEACxG;AAMnC;IADN,sBAAsB,CAAC,4BAA4B,0CAAkC,UAAU,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC;4DAC/G;AAM7B;IADN,sBAAsB,CAAC,aAAa,0CAAkC,UAAU,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC;kDAC1G;AA4O9B,aAAa,CAAC,wBAAwB,EAAE,cAAc,CAAC,CAAC","sourcesContent":["import { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport type { Mesh } from \"../../../../Meshes/mesh\";\r\nimport { VertexData } from \"../../../../Meshes/mesh.vertexData\";\r\nimport type { FloatArray, IndicesArray, Nullable } from \"../../../../types\";\r\nimport { PropertyTypeForEdition, editableInPropertyPage } from \"core/Decorators/nodeDecorator\";\r\nimport { NodeParticleBlock } from \"../../nodeParticleBlock\";\r\nimport { NodeParticleBlockConnectionPointTypes } from \"../../Enums/nodeParticleBlockConnectionPointTypes\";\r\nimport type { NodeParticleBuildState } from \"../../nodeParticleBuildState\";\r\nimport type { NodeParticleConnectionPoint } from \"../../nodeParticleBlockConnectionPoint\";\r\nimport type { Particle } from \"core/Particles/particle\";\r\nimport { TmpVectors, Vector3, Vector4 } from \"core/Maths/math.vector\";\r\nimport { RandomRange } from \"core/Maths/math.scalar.functions\";\r\nimport type { IShapeBlock } from \"./IShapeBlock\";\r\n\r\n/**\r\n * Defines a block used to generate particle shape from mesh geometry data\r\n */\r\nexport class MeshShapeBlock extends NodeParticleBlock implements IShapeBlock {\r\n private _mesh: Nullable<Mesh>;\r\n private _cachedVertexData: Nullable<VertexData> = null;\r\n private _indices: Nullable<IndicesArray> = null;\r\n private _positions: Nullable<FloatArray> = null;\r\n private _normals: Nullable<FloatArray> = null;\r\n private _colors: Nullable<FloatArray> = null;\r\n private _storedNormal = Vector3.Zero();\r\n\r\n /**\r\n * Gets or sets a boolean indicating that this block should serialize its cached data\r\n */\r\n @editableInPropertyPage(\"Serialize cached data\", PropertyTypeForEdition.Boolean, \"ADVANCED\", { embedded: true, notifiers: { rebuild: true } })\r\n public serializedCachedData = false;\r\n\r\n /**\r\n * Gets or sets a boolean indicating if the mesh normals should be used for particle direction\r\n */\r\n @editableInPropertyPage(\"Use normals for direction\", PropertyTypeForEdition.Boolean, \"ADVANCED\", { embedded: true, notifiers: { rebuild: true } })\r\n public useMeshNormalsForDirection = false;\r\n\r\n /**\r\n * Gets or sets a boolean indicating if the mesh colors should be used for particle color\r\n */\r\n @editableInPropertyPage(\"Use vertex color for color\", PropertyTypeForEdition.Boolean, \"ADVANCED\", { embedded: true, notifiers: { rebuild: true } })\r\n public useMeshColorForColor = false;\r\n\r\n /**\r\n * Gets or sets a boolean indicating if the coordinates should be in world space (local space by default)\r\n */\r\n @editableInPropertyPage(\"World space\", PropertyTypeForEdition.Boolean, \"ADVANCED\", { embedded: true, notifiers: { rebuild: true } })\r\n public worldSpace = false;\r\n\r\n /**\r\n * Gets or sets the mesh to use to get vertex data\r\n */\r\n public get mesh() {\r\n return this._mesh;\r\n }\r\n\r\n public set mesh(value: Nullable<Mesh>) {\r\n this._mesh = value;\r\n }\r\n\r\n /**\r\n * Create a new MeshShapeBlock\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(\"direction1\", NodeParticleBlockConnectionPointTypes.Vector3, true, new Vector3(0, 1.0, 0));\r\n this.registerInput(\"direction2\", NodeParticleBlockConnectionPointTypes.Vector3, true, new Vector3(0, 1.0, 0));\r\n this.registerOutput(\"output\", NodeParticleBlockConnectionPointTypes.Particle);\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 \"MeshShapeBlock\";\r\n }\r\n\r\n /**\r\n * Gets a boolean indicating if the block is using cached data\r\n */\r\n public get isUsingCachedData() {\r\n return !this.mesh && !!this._cachedVertexData;\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 direction1 input component\r\n */\r\n public get direction1(): NodeParticleConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the direction2 input component\r\n */\r\n public get direction2(): 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 * Remove stored data\r\n */\r\n public cleanData() {\r\n this._mesh = null;\r\n this._cachedVertexData = null;\r\n }\r\n\r\n /**\r\n * Builds the block\r\n * @param state defines the build state\r\n */\r\n public override _build(state: NodeParticleBuildState) {\r\n const system = this.particle.getConnectedValue(state);\r\n\r\n if (!this._mesh && !this._cachedVertexData) {\r\n this.output._storedValue = system;\r\n return;\r\n }\r\n\r\n if (this._mesh) {\r\n this._cachedVertexData = VertexData.ExtractFromMesh(this._mesh, false, true);\r\n }\r\n\r\n if (!this._cachedVertexData) {\r\n this.output._storedValue = system;\r\n return;\r\n }\r\n\r\n this._indices = this._cachedVertexData.indices;\r\n this._positions = this._cachedVertexData.positions;\r\n this._normals = this._cachedVertexData.normals;\r\n this._colors = this._cachedVertexData.colors;\r\n\r\n if (this.useMeshColorForColor && this._colors) {\r\n system._colorCreation.process = () => {};\r\n }\r\n\r\n system._directionCreation.process = (particle: Particle) => {\r\n state.particleContext = particle;\r\n state.systemContext = system;\r\n\r\n if (this.useMeshNormalsForDirection && this._normals) {\r\n if (system.isLocal) {\r\n particle.direction.copyFrom(this._storedNormal);\r\n } else {\r\n Vector3.TransformNormalToRef(this._storedNormal, state.emitterWorldMatrix!, particle.direction);\r\n }\r\n return;\r\n }\r\n\r\n const direction1 = this.direction1.getConnectedValue(state) as Vector3;\r\n const direction2 = this.direction2.getConnectedValue(state) as Vector3;\r\n\r\n const randX = RandomRange(direction1.x, direction2.x);\r\n const randY = RandomRange(direction1.y, direction2.y);\r\n const randZ = RandomRange(direction1.z, direction2.z);\r\n\r\n if (system.isLocal) {\r\n particle.direction.copyFromFloats(randX, randY, randZ);\r\n } else {\r\n Vector3.TransformNormalFromFloatsToRef(randX, randY, randZ, state.emitterWorldMatrix!, particle.direction);\r\n }\r\n\r\n particle._initialDirection = particle.direction.clone();\r\n };\r\n\r\n system._positionCreation.process = (particle: Particle) => {\r\n if (!this._indices || !this._positions) {\r\n return;\r\n }\r\n\r\n const randomFaceIndex = 3 * ((Math.random() * (this._indices.length / 3)) | 0);\r\n const bu = Math.random();\r\n const bv = Math.random() * (1.0 - bu);\r\n const bw = 1.0 - bu - bv;\r\n\r\n const faceIndexA = this._indices[randomFaceIndex];\r\n const faceIndexB = this._indices[randomFaceIndex + 1];\r\n const faceIndexC = this._indices[randomFaceIndex + 2];\r\n const vertexA = TmpVectors.Vector3[0];\r\n const vertexB = TmpVectors.Vector3[1];\r\n const vertexC = TmpVectors.Vector3[2];\r\n const randomVertex = TmpVectors.Vector3[3];\r\n\r\n Vector3.FromArrayToRef(this._positions, faceIndexA * 3, vertexA);\r\n Vector3.FromArrayToRef(this._positions, faceIndexB * 3, vertexB);\r\n Vector3.FromArrayToRef(this._positions, faceIndexC * 3, vertexC);\r\n\r\n randomVertex.x = bu * vertexA.x + bv * vertexB.x + bw * vertexC.x;\r\n randomVertex.y = bu * vertexA.y + bv * vertexB.y + bw * vertexC.y;\r\n randomVertex.z = bu * vertexA.z + bv * vertexB.z + bw * vertexC.z;\r\n\r\n if (this.worldSpace && this.mesh) {\r\n Vector3.TransformCoordinatesFromFloatsToRef(randomVertex.x, randomVertex.y, randomVertex.z, this.mesh.getWorldMatrix(), randomVertex);\r\n }\r\n\r\n if (system.isLocal) {\r\n particle.position.copyFromFloats(randomVertex.x, randomVertex.y, randomVertex.z);\r\n } else {\r\n Vector3.TransformCoordinatesFromFloatsToRef(randomVertex.x, randomVertex.y, randomVertex.z, state.emitterWorldMatrix!, particle.position);\r\n }\r\n\r\n if (this.useMeshNormalsForDirection && this._normals) {\r\n Vector3.FromArrayToRef(this._normals, faceIndexA * 3, vertexA);\r\n Vector3.FromArrayToRef(this._normals, faceIndexB * 3, vertexB);\r\n Vector3.FromArrayToRef(this._normals, faceIndexC * 3, vertexC);\r\n\r\n this._storedNormal.x = bu * vertexA.x + bv * vertexB.x + bw * vertexC.x;\r\n this._storedNormal.y = bu * vertexA.y + bv * vertexB.y + bw * vertexC.y;\r\n this._storedNormal.z = bu * vertexA.z + bv * vertexB.z + bw * vertexC.z;\r\n }\r\n\r\n if (this.useMeshColorForColor && this._colors) {\r\n Vector4.FromArrayToRef(this._colors, faceIndexA * 4, TmpVectors.Vector4[0]);\r\n Vector4.FromArrayToRef(this._colors, faceIndexB * 4, TmpVectors.Vector4[1]);\r\n Vector4.FromArrayToRef(this._colors, faceIndexC * 4, TmpVectors.Vector4[2]);\r\n\r\n particle.color.copyFromFloats(\r\n bu * TmpVectors.Vector4[0].x + bv * TmpVectors.Vector4[1].x + bw * TmpVectors.Vector4[2].x,\r\n bu * TmpVectors.Vector4[0].y + bv * TmpVectors.Vector4[1].y + bw * TmpVectors.Vector4[2].y,\r\n bu * TmpVectors.Vector4[0].z + bv * TmpVectors.Vector4[1].z + bw * TmpVectors.Vector4[2].z,\r\n bu * TmpVectors.Vector4[0].w + bv * TmpVectors.Vector4[1].w + bw * TmpVectors.Vector4[2].w\r\n );\r\n }\r\n };\r\n\r\n this.output._storedValue = system;\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 serializationObject.serializedCachedData = this.serializedCachedData;\r\n\r\n if (this.serializedCachedData) {\r\n if (this._mesh) {\r\n serializationObject.cachedVertexData = VertexData.ExtractFromMesh(this._mesh, false, true).serialize();\r\n } else if (this._cachedVertexData) {\r\n serializationObject.cachedVertexData = this._cachedVertexData.serialize();\r\n }\r\n }\r\n\r\n serializationObject.useMeshNormalsForDirection = this.useMeshNormalsForDirection;\r\n serializationObject.useMeshColorForColor = this.useMeshColorForColor;\r\n serializationObject.worldSpace = this.worldSpace;\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 if (serializationObject.cachedVertexData) {\r\n this._cachedVertexData = VertexData.Parse(serializationObject.cachedVertexData);\r\n }\r\n\r\n this.serializedCachedData = !!serializationObject.serializedCachedData;\r\n this.useMeshNormalsForDirection = !!serializationObject.useMeshNormalsForDirection;\r\n this.useMeshColorForColor = !!serializationObject.useMeshColorForColor;\r\n this.worldSpace = !!serializationObject.worldSpace;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.MeshShapeBlock\", MeshShapeBlock);\r\n"]}
|
|
1
|
+
{"version":3,"file":"meshShapeBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Particles/Node/Blocks/Emitters/meshShapeBlock.ts"],"names":[],"m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AE,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC;kDAC1G;AAiP9B,aAAa,CAAC,wBAAwB,EAAE,cAAc,CAAC,CAAC","sourcesContent":["import type { FloatArray, IndicesArray, Nullable } from \"core/types\";\r\nimport type { Mesh } from \"core/Meshes/mesh\";\r\nimport type { NodeParticleBuildState } from \"core/Particles/Node/nodeParticleBuildState\";\r\nimport type { NodeParticleConnectionPoint } from \"core/Particles/Node/nodeParticleBlockConnectionPoint\";\r\nimport type { Particle } from \"core/Particles/particle\";\r\nimport type { IShapeBlock } from \"./IShapeBlock\";\r\n\r\nimport { RegisterClass } from \"core/Misc/typeStore\";\r\nimport { VertexData } from \"core/Meshes/mesh.vertexData\";\r\nimport { PropertyTypeForEdition, editableInPropertyPage } from \"core/Decorators/nodeDecorator\";\r\nimport { NodeParticleBlock } from \"core/Particles/Node/nodeParticleBlock\";\r\nimport { NodeParticleBlockConnectionPointTypes } from \"../../Enums/nodeParticleBlockConnectionPointTypes\";\r\nimport { TmpVectors, Vector3, Vector4 } from \"core/Maths/math.vector\";\r\nimport { RandomRange } from \"core/Maths/math.scalar.functions\";\r\nimport { _CreateLocalPositionData } from \"./emitters.functions\";\r\n\r\n/**\r\n * Defines a block used to generate particle shape from mesh geometry data\r\n */\r\nexport class MeshShapeBlock extends NodeParticleBlock implements IShapeBlock {\r\n private _mesh: Nullable<Mesh>;\r\n private _cachedVertexData: Nullable<VertexData> = null;\r\n private _indices: Nullable<IndicesArray> = null;\r\n private _positions: Nullable<FloatArray> = null;\r\n private _normals: Nullable<FloatArray> = null;\r\n private _colors: Nullable<FloatArray> = null;\r\n private _storedNormal = Vector3.Zero();\r\n\r\n /**\r\n * Gets or sets a boolean indicating that this block should serialize its cached data\r\n */\r\n @editableInPropertyPage(\"Serialize cached data\", PropertyTypeForEdition.Boolean, \"ADVANCED\", { embedded: true, notifiers: { rebuild: true } })\r\n public serializedCachedData = false;\r\n\r\n /**\r\n * Gets or sets a boolean indicating if the mesh normals should be used for particle direction\r\n */\r\n @editableInPropertyPage(\"Use normals for direction\", PropertyTypeForEdition.Boolean, \"ADVANCED\", { embedded: true, notifiers: { rebuild: true } })\r\n public useMeshNormalsForDirection = true;\r\n\r\n /**\r\n * Gets or sets a boolean indicating if the mesh colors should be used for particle color\r\n */\r\n @editableInPropertyPage(\"Use vertex color for color\", PropertyTypeForEdition.Boolean, \"ADVANCED\", { embedded: true, notifiers: { rebuild: true } })\r\n public useMeshColorForColor = false;\r\n\r\n /**\r\n * Gets or sets a boolean indicating if the coordinates should be in world space (local space by default)\r\n */\r\n @editableInPropertyPage(\"World space\", PropertyTypeForEdition.Boolean, \"ADVANCED\", { embedded: true, notifiers: { rebuild: true } })\r\n public worldSpace = false;\r\n\r\n /**\r\n * Gets or sets the mesh to use to get vertex data\r\n */\r\n public get mesh() {\r\n return this._mesh;\r\n }\r\n\r\n public set mesh(value: Nullable<Mesh>) {\r\n this._mesh = value;\r\n }\r\n\r\n /**\r\n * Create a new MeshShapeBlock\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(\"direction1\", NodeParticleBlockConnectionPointTypes.Vector3, true, new Vector3(0, 1.0, 0));\r\n this.registerInput(\"direction2\", NodeParticleBlockConnectionPointTypes.Vector3, true, new Vector3(0, 1.0, 0));\r\n this.registerOutput(\"output\", NodeParticleBlockConnectionPointTypes.Particle);\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 \"MeshShapeBlock\";\r\n }\r\n\r\n /**\r\n * Gets a boolean indicating if the block is using cached data\r\n */\r\n public get isUsingCachedData() {\r\n return !this.mesh && !!this._cachedVertexData;\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 direction1 input component\r\n */\r\n public get direction1(): NodeParticleConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the direction2 input component\r\n */\r\n public get direction2(): 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 * Remove stored data\r\n */\r\n public cleanData() {\r\n this._mesh = null;\r\n this._cachedVertexData = null;\r\n }\r\n\r\n /**\r\n * Builds the block\r\n * @param state defines the build state\r\n */\r\n public override _build(state: NodeParticleBuildState) {\r\n const system = this.particle.getConnectedValue(state);\r\n\r\n if (!this._mesh && !this._cachedVertexData) {\r\n this.output._storedValue = system;\r\n return;\r\n }\r\n\r\n if (this._mesh) {\r\n this._cachedVertexData = VertexData.ExtractFromMesh(this._mesh, false, true);\r\n }\r\n\r\n if (!this._cachedVertexData) {\r\n this.output._storedValue = system;\r\n return;\r\n }\r\n\r\n this._indices = this._cachedVertexData.indices;\r\n this._positions = this._cachedVertexData.positions;\r\n this._normals = this._cachedVertexData.normals;\r\n this._colors = this._cachedVertexData.colors;\r\n\r\n if (this.useMeshColorForColor && this._colors) {\r\n system._colorCreation.process = () => {};\r\n }\r\n\r\n system._directionCreation.process = (particle: Particle) => {\r\n state.particleContext = particle;\r\n state.systemContext = system;\r\n\r\n if (this.useMeshNormalsForDirection && this._normals) {\r\n if (system.isLocal) {\r\n particle.direction.copyFrom(this._storedNormal);\r\n } else {\r\n Vector3.TransformNormalToRef(this._storedNormal, state.emitterWorldMatrix!, particle.direction);\r\n }\r\n return;\r\n }\r\n\r\n const direction1 = this.direction1.getConnectedValue(state) as Vector3;\r\n const direction2 = this.direction2.getConnectedValue(state) as Vector3;\r\n\r\n const randX = RandomRange(direction1.x, direction2.x);\r\n const randY = RandomRange(direction1.y, direction2.y);\r\n const randZ = RandomRange(direction1.z, direction2.z);\r\n\r\n if (system.isLocal) {\r\n particle.direction.copyFromFloats(randX, randY, randZ);\r\n } else {\r\n Vector3.TransformNormalFromFloatsToRef(randX, randY, randZ, state.emitterWorldMatrix!, particle.direction);\r\n }\r\n\r\n particle._initialDirection = particle.direction.clone();\r\n };\r\n\r\n system._positionCreation.process = (particle: Particle) => {\r\n state.particleContext = particle;\r\n state.systemContext = system;\r\n\r\n if (!this._indices || !this._positions) {\r\n return;\r\n }\r\n\r\n const randomFaceIndex = 3 * ((Math.random() * (this._indices.length / 3)) | 0);\r\n const bu = Math.random();\r\n const bv = Math.random() * (1.0 - bu);\r\n const bw = 1.0 - bu - bv;\r\n\r\n const faceIndexA = this._indices[randomFaceIndex];\r\n const faceIndexB = this._indices[randomFaceIndex + 1];\r\n const faceIndexC = this._indices[randomFaceIndex + 2];\r\n const vertexA = TmpVectors.Vector3[0];\r\n const vertexB = TmpVectors.Vector3[1];\r\n const vertexC = TmpVectors.Vector3[2];\r\n const randomVertex = TmpVectors.Vector3[3];\r\n\r\n Vector3.FromArrayToRef(this._positions, faceIndexA * 3, vertexA);\r\n Vector3.FromArrayToRef(this._positions, faceIndexB * 3, vertexB);\r\n Vector3.FromArrayToRef(this._positions, faceIndexC * 3, vertexC);\r\n\r\n randomVertex.x = bu * vertexA.x + bv * vertexB.x + bw * vertexC.x;\r\n randomVertex.y = bu * vertexA.y + bv * vertexB.y + bw * vertexC.y;\r\n randomVertex.z = bu * vertexA.z + bv * vertexB.z + bw * vertexC.z;\r\n\r\n if (this.worldSpace && this.mesh) {\r\n Vector3.TransformCoordinatesFromFloatsToRef(randomVertex.x, randomVertex.y, randomVertex.z, this.mesh.getWorldMatrix(), randomVertex);\r\n }\r\n\r\n if (system.isLocal) {\r\n particle.position.copyFromFloats(randomVertex.x, randomVertex.y, randomVertex.z);\r\n } else {\r\n Vector3.TransformCoordinatesFromFloatsToRef(randomVertex.x, randomVertex.y, randomVertex.z, state.emitterWorldMatrix!, particle.position);\r\n }\r\n\r\n _CreateLocalPositionData(particle);\r\n\r\n if (this.useMeshNormalsForDirection && this._normals) {\r\n Vector3.FromArrayToRef(this._normals, faceIndexA * 3, vertexA);\r\n Vector3.FromArrayToRef(this._normals, faceIndexB * 3, vertexB);\r\n Vector3.FromArrayToRef(this._normals, faceIndexC * 3, vertexC);\r\n\r\n this._storedNormal.x = bu * vertexA.x + bv * vertexB.x + bw * vertexC.x;\r\n this._storedNormal.y = bu * vertexA.y + bv * vertexB.y + bw * vertexC.y;\r\n this._storedNormal.z = bu * vertexA.z + bv * vertexB.z + bw * vertexC.z;\r\n }\r\n\r\n if (this.useMeshColorForColor && this._colors) {\r\n Vector4.FromArrayToRef(this._colors, faceIndexA * 4, TmpVectors.Vector4[0]);\r\n Vector4.FromArrayToRef(this._colors, faceIndexB * 4, TmpVectors.Vector4[1]);\r\n Vector4.FromArrayToRef(this._colors, faceIndexC * 4, TmpVectors.Vector4[2]);\r\n\r\n particle.color.copyFromFloats(\r\n bu * TmpVectors.Vector4[0].x + bv * TmpVectors.Vector4[1].x + bw * TmpVectors.Vector4[2].x,\r\n bu * TmpVectors.Vector4[0].y + bv * TmpVectors.Vector4[1].y + bw * TmpVectors.Vector4[2].y,\r\n bu * TmpVectors.Vector4[0].z + bv * TmpVectors.Vector4[1].z + bw * TmpVectors.Vector4[2].z,\r\n bu * TmpVectors.Vector4[0].w + bv * TmpVectors.Vector4[1].w + bw * TmpVectors.Vector4[2].w\r\n );\r\n }\r\n };\r\n\r\n this.output._storedValue = system;\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 serializationObject.serializedCachedData = this.serializedCachedData;\r\n\r\n if (this.serializedCachedData) {\r\n if (this._mesh) {\r\n serializationObject.cachedVertexData = VertexData.ExtractFromMesh(this._mesh, false, true).serialize();\r\n } else if (this._cachedVertexData) {\r\n serializationObject.cachedVertexData = this._cachedVertexData.serialize();\r\n }\r\n }\r\n\r\n serializationObject.useMeshNormalsForDirection = this.useMeshNormalsForDirection;\r\n serializationObject.useMeshColorForColor = this.useMeshColorForColor;\r\n serializationObject.worldSpace = this.worldSpace;\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 if (serializationObject.cachedVertexData) {\r\n this._cachedVertexData = VertexData.Parse(serializationObject.cachedVertexData);\r\n }\r\n\r\n this.serializedCachedData = !!serializationObject.serializedCachedData;\r\n this.useMeshNormalsForDirection = !!serializationObject.useMeshNormalsForDirection;\r\n this.useMeshColorForColor = !!serializationObject.useMeshColorForColor;\r\n this.worldSpace = !!serializationObject.worldSpace;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.MeshShapeBlock\", MeshShapeBlock);\r\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { NodeParticleConnectionPoint } from "../../nodeParticleBlockConnectionPoint.js";
|
|
2
2
|
import type { NodeParticleBuildState } from "../../nodeParticleBuildState.js";
|
|
3
|
-
import { NodeParticleBlock } from "../../nodeParticleBlock.js";
|
|
4
3
|
import type { IShapeBlock } from "./IShapeBlock.js";
|
|
4
|
+
import { NodeParticleBlock } from "../../nodeParticleBlock.js";
|
|
5
5
|
/**
|
|
6
6
|
* Block used to provide a flow of particles emitted from a point.
|
|
7
7
|
*/
|
|
@@ -3,6 +3,7 @@ import { NodeParticleBlockConnectionPointTypes } from "../../Enums/nodeParticleB
|
|
|
3
3
|
import { Vector3 } from "../../../../Maths/math.vector.js";
|
|
4
4
|
import { NodeParticleBlock } from "../../nodeParticleBlock.js";
|
|
5
5
|
import { RandomRange } from "../../../../Maths/math.scalar.functions.js";
|
|
6
|
+
import { _CreateLocalPositionData } from "./emitters.functions.js";
|
|
6
7
|
/**
|
|
7
8
|
* Block used to provide a flow of particles emitted from a point.
|
|
8
9
|
*/
|
|
@@ -74,11 +75,12 @@ export class PointShapeBlock extends NodeParticleBlock {
|
|
|
74
75
|
system._positionCreation.process = (particle) => {
|
|
75
76
|
state.systemContext = system;
|
|
76
77
|
if (system.isLocal) {
|
|
77
|
-
particle.position.
|
|
78
|
+
particle.position.copyFromFloats(0, 0, 0);
|
|
78
79
|
}
|
|
79
80
|
else {
|
|
80
81
|
Vector3.TransformCoordinatesFromFloatsToRef(0, 0, 0, state.emitterWorldMatrix, particle.position);
|
|
81
82
|
}
|
|
83
|
+
_CreateLocalPositionData(particle);
|
|
82
84
|
};
|
|
83
85
|
this.output._storedValue = system;
|
|
84
86
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pointShapeBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Particles/Node/Blocks/Emitters/pointShapeBlock.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pointShapeBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Particles/Node/Blocks/Emitters/pointShapeBlock.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,qCAAqC,EAAE,MAAM,mDAAmD,CAAC;AAC1G,OAAO,EAAE,OAAO,EAAE,yCAA+B;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,mDAAyC;AAC/D,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAEhE;;GAEG;AACH,MAAM,OAAO,eAAgB,SAAQ,iBAAiB;IAClD;;;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,EAAE,IAAI,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;QAC9G,IAAI,CAAC,aAAa,CAAC,Y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CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;YACtD,MAAM,KAAK,GAAG,WAAW,CAAC,UAAU,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;YAEtD,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;gBACjB,QAAQ,CAAC,SAAS,CAAC,cAAc,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;YAC3D,CAAC;iBAAM,CAAC;gBACJ,OAAO,CAAC,8BAA8B,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,kBAAmB,EAAE,QAAQ,CAAC,SAAS,CAAC,CAAC;YAC/G,CAAC;YAED,QAAQ,CAAC,iBAAiB,GAAG,QAAQ,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;QAC5D,CAAC,CAAC;QAEF,MAAM,CAAC,iBAAiB,CAAC,OAAO,GAAG,CAAC,QAAkB,EAAE,EAAE;YACtD,KAAK,CAAC,aAAa,GAAG,MAAM,CAAC;YAC7B,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;gBACjB,QAAQ,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;YAC9C,CAAC;iBAAM,CAAC;gBACJ,OAAO,CAAC,mCAAmC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,kBAAmB,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;YACvG,CAAC;YAED,wBAAwB,CAAC,QAAQ,CAAC,CAAC;QACvC,CAAC,CAAC;QAEF,IAAI,CAAC,MAAM,CAAC,YAAY,GAAG,MAAM,CAAC;IACtC,CAAC;CACJ;AAED,aAAa,CAAC,yBAAyB,EAAE,eAAe,CAAC,CAAC","sourcesContent":["import type { NodeParticleConnectionPoint } from \"../../nodeParticleBlockConnectionPoint\";\r\nimport type { NodeParticleBuildState } from \"../../nodeParticleBuildState\";\r\nimport type { Particle } from \"core/Particles/particle\";\r\nimport type { IShapeBlock } from \"./IShapeBlock\";\r\n\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport { NodeParticleBlockConnectionPointTypes } from \"../../Enums/nodeParticleBlockConnectionPointTypes\";\r\nimport { Vector3 } from \"core/Maths/math.vector\";\r\nimport { NodeParticleBlock } from \"../../nodeParticleBlock\";\r\nimport { RandomRange } from \"core/Maths/math.scalar.functions\";\r\nimport { _CreateLocalPositionData } from \"./emitters.functions\";\r\n\r\n/**\r\n * Block used to provide a flow of particles emitted from a point.\r\n */\r\nexport class PointShapeBlock extends NodeParticleBlock implements IShapeBlock {\r\n /**\r\n * Create a new PointShapeBlock\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(\"direction1\", NodeParticleBlockConnectionPointTypes.Vector3, true, new Vector3(0, 1.0, 0));\r\n this.registerInput(\"direction2\", NodeParticleBlockConnectionPointTypes.Vector3, true, new Vector3(0, 1.0, 0));\r\n this.registerOutput(\"output\", NodeParticleBlockConnectionPointTypes.Particle);\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 \"PointShapeBlock\";\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 direction1 input component\r\n */\r\n public get direction1(): NodeParticleConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the direction2 input component\r\n */\r\n public get direction2(): 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 * Builds the block\r\n * @param state defines the build state\r\n */\r\n public override _build(state: NodeParticleBuildState) {\r\n const system = this.particle.getConnectedValue(state);\r\n\r\n system._directionCreation.process = (particle: Particle) => {\r\n state.particleContext = particle;\r\n state.systemContext = system;\r\n\r\n const direction1 = this.direction1.getConnectedValue(state) as Vector3;\r\n const direction2 = this.direction2.getConnectedValue(state) as Vector3;\r\n\r\n const randX = RandomRange(direction1.x, direction2.x);\r\n const randY = RandomRange(direction1.y, direction2.y);\r\n const randZ = RandomRange(direction1.z, direction2.z);\r\n\r\n if (system.isLocal) {\r\n particle.direction.copyFromFloats(randX, randY, randZ);\r\n } else {\r\n Vector3.TransformNormalFromFloatsToRef(randX, randY, randZ, state.emitterWorldMatrix!, particle.direction);\r\n }\r\n\r\n particle._initialDirection = particle.direction.clone();\r\n };\r\n\r\n system._positionCreation.process = (particle: Particle) => {\r\n state.systemContext = system;\r\n if (system.isLocal) {\r\n particle.position.copyFromFloats(0, 0, 0);\r\n } else {\r\n Vector3.TransformCoordinatesFromFloatsToRef(0, 0, 0, state.emitterWorldMatrix!, particle.position);\r\n }\r\n\r\n _CreateLocalPositionData(particle);\r\n };\r\n\r\n this.output._storedValue = system;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.PointShapeBlock\", PointShapeBlock);\r\n"]}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { NodeParticleConnectionPoint } from "../../nodeParticleBlockConnectionPoint.js";
|
|
2
2
|
import type { NodeParticleBuildState } from "../../nodeParticleBuildState.js";
|
|
3
|
-
import { NodeParticleBlock } from "../../nodeParticleBlock.js";
|
|
4
3
|
import type { IShapeBlock } from "./IShapeBlock.js";
|
|
4
|
+
import { NodeParticleBlock } from "../../nodeParticleBlock.js";
|
|
5
5
|
/**
|
|
6
6
|
* Block used to provide a flow of particles emitted from a sphere shape.
|
|
7
|
+
* DirectionRandomizer will be used for the particles initial direction unless both direction1 and direction2 are connected.
|
|
7
8
|
*/
|
|
8
9
|
export declare class SphereShapeBlock extends NodeParticleBlock implements IShapeBlock {
|
|
9
10
|
/**
|
|
@@ -32,6 +33,14 @@ export declare class SphereShapeBlock extends NodeParticleBlock implements IShap
|
|
|
32
33
|
* Gets the directionRandomizer input component
|
|
33
34
|
*/
|
|
34
35
|
get directionRandomizer(): NodeParticleConnectionPoint;
|
|
36
|
+
/**
|
|
37
|
+
* Gets the direction1 input component
|
|
38
|
+
*/
|
|
39
|
+
get direction1(): NodeParticleConnectionPoint;
|
|
40
|
+
/**
|
|
41
|
+
* Gets the direction2 input component
|
|
42
|
+
*/
|
|
43
|
+
get direction2(): NodeParticleConnectionPoint;
|
|
35
44
|
/**
|
|
36
45
|
* Gets the output component
|
|
37
46
|
*/
|
|
@@ -3,8 +3,10 @@ import { NodeParticleBlockConnectionPointTypes } from "../../Enums/nodeParticleB
|
|
|
3
3
|
import { NodeParticleBlock } from "../../nodeParticleBlock.js";
|
|
4
4
|
import { Vector3 } from "../../../../Maths/math.vector.js";
|
|
5
5
|
import { RandomRange } from "../../../../Maths/math.scalar.functions.js";
|
|
6
|
+
import { _CreateLocalPositionData } from "./emitters.functions.js";
|
|
6
7
|
/**
|
|
7
8
|
* Block used to provide a flow of particles emitted from a sphere shape.
|
|
9
|
+
* DirectionRandomizer will be used for the particles initial direction unless both direction1 and direction2 are connected.
|
|
8
10
|
*/
|
|
9
11
|
export class SphereShapeBlock extends NodeParticleBlock {
|
|
10
12
|
/**
|
|
@@ -17,6 +19,8 @@ export class SphereShapeBlock extends NodeParticleBlock {
|
|
|
17
19
|
this.registerInput("radius", NodeParticleBlockConnectionPointTypes.Float, true, 1);
|
|
18
20
|
this.registerInput("radiusRange", NodeParticleBlockConnectionPointTypes.Float, true, 1, 0, 1);
|
|
19
21
|
this.registerInput("directionRandomizer", NodeParticleBlockConnectionPointTypes.Float, true, 0, 0, 1);
|
|
22
|
+
this.registerInput("direction1", NodeParticleBlockConnectionPointTypes.Vector3, true);
|
|
23
|
+
this.registerInput("direction2", NodeParticleBlockConnectionPointTypes.Vector3, true);
|
|
20
24
|
this.registerOutput("output", NodeParticleBlockConnectionPointTypes.Particle);
|
|
21
25
|
}
|
|
22
26
|
/**
|
|
@@ -50,6 +54,18 @@ export class SphereShapeBlock extends NodeParticleBlock {
|
|
|
50
54
|
get directionRandomizer() {
|
|
51
55
|
return this._inputs[3];
|
|
52
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* Gets the direction1 input component
|
|
59
|
+
*/
|
|
60
|
+
get direction1() {
|
|
61
|
+
return this._inputs[4];
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Gets the direction2 input component
|
|
65
|
+
*/
|
|
66
|
+
get direction2() {
|
|
67
|
+
return this._inputs[5];
|
|
68
|
+
}
|
|
53
69
|
/**
|
|
54
70
|
* Gets the output component
|
|
55
71
|
*/
|
|
@@ -65,20 +81,36 @@ export class SphereShapeBlock extends NodeParticleBlock {
|
|
|
65
81
|
system._directionCreation.process = (particle) => {
|
|
66
82
|
state.particleContext = particle;
|
|
67
83
|
state.systemContext = system;
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
84
|
+
// We always use directionRandomizer unless both directions are connected
|
|
85
|
+
if (this.direction1.isConnected === false || this.direction2.isConnected === false) {
|
|
86
|
+
const directionRandomizer = this.directionRandomizer.getConnectedValue(state);
|
|
87
|
+
const direction = particle.position.subtract(state.emitterPosition).normalize();
|
|
88
|
+
const randX = RandomRange(0, directionRandomizer);
|
|
89
|
+
const randY = RandomRange(0, directionRandomizer);
|
|
90
|
+
const randZ = RandomRange(0, directionRandomizer);
|
|
91
|
+
direction.x += randX;
|
|
92
|
+
direction.y += randY;
|
|
93
|
+
direction.z += randZ;
|
|
94
|
+
direction.normalize();
|
|
95
|
+
if (system.isLocal) {
|
|
96
|
+
particle.direction.copyFromFloats(direction.x, direction.y, direction.z);
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
Vector3.TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, state.emitterWorldMatrix, particle.direction);
|
|
100
|
+
}
|
|
79
101
|
}
|
|
80
102
|
else {
|
|
81
|
-
|
|
103
|
+
const direction1 = this.direction1.getConnectedValue(state);
|
|
104
|
+
const direction2 = this.direction2.getConnectedValue(state);
|
|
105
|
+
const randX = RandomRange(direction1.x, direction2.x);
|
|
106
|
+
const randY = RandomRange(direction1.y, direction2.y);
|
|
107
|
+
const randZ = RandomRange(direction1.z, direction2.z);
|
|
108
|
+
if (system.isLocal) {
|
|
109
|
+
particle.direction.copyFromFloats(randX, randY, randZ);
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
Vector3.TransformNormalFromFloatsToRef(randX, randY, randZ, state.emitterWorldMatrix, particle.direction);
|
|
113
|
+
}
|
|
82
114
|
}
|
|
83
115
|
particle._initialDirection = particle.direction.clone();
|
|
84
116
|
};
|
|
@@ -96,11 +128,11 @@ export class SphereShapeBlock extends NodeParticleBlock {
|
|
|
96
128
|
const randZ = randRadius * Math.sin(phi) * Math.sin(theta);
|
|
97
129
|
if (system.isLocal) {
|
|
98
130
|
particle.position.copyFromFloats(randX, randY, randZ);
|
|
99
|
-
particle.position.addInPlace(state.emitterPosition);
|
|
100
131
|
}
|
|
101
132
|
else {
|
|
102
133
|
Vector3.TransformCoordinatesFromFloatsToRef(randX, randY, randZ, state.emitterWorldMatrix, particle.position);
|
|
103
134
|
}
|
|
135
|
+
_CreateLocalPositionData(particle);
|
|
104
136
|
};
|
|
105
137
|
this.output._storedValue = system;
|
|
106
138
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sphereShapeBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Particles/Node/Blocks/Emitters/sphereShapeBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,qCAAqC,EAAE,MAAM,mDAAmD,CAAC;AAG1G,OAAO,EAAE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AAK,CAAC,eAAgB,CAAC,CAAC;YACzD,CAAC;iBAAM,CAAC;gBACJ,OAAO,CAAC,mCAAmC,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,kBAAmB,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;YACnH,CAAC;QACL,CAAC,CAAC;QAEF,IAAI,CAAC,MAAM,CAAC,YAAY,GAAG,MAAM,CAAC;IACtC,CAAC;CACJ;AAED,aAAa,CAAC,0BAA0B,EAAE,gBAAgB,CAAC,CAAC","sourcesContent":["import { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport { NodeParticleBlockConnectionPointTypes } from \"../../Enums/nodeParticleBlockConnectionPointTypes\";\r\nimport type { NodeParticleConnectionPoint } from \"../../nodeParticleBlockConnectionPoint\";\r\nimport type { NodeParticleBuildState } from \"../../nodeParticleBuildState\";\r\nimport { NodeParticleBlock } from \"../../nodeParticleBlock\";\r\nimport type { Particle } from \"core/Particles/particle\";\r\nimport { Vector3 } from \"core/Maths/math.vector\";\r\nimport { RandomRange } from \"core/Maths/math.scalar.functions\";\r\nimport type { IShapeBlock } from \"./IShapeBlock\";\r\n\r\n/**\r\n * Block used to provide a flow of particles emitted from a sphere shape.\r\n */\r\nexport class SphereShapeBlock extends NodeParticleBlock implements IShapeBlock {\r\n /**\r\n * Create a new SphereShapeBlock\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(\"radius\", NodeParticleBlockConnectionPointTypes.Float, true, 1);\r\n this.registerInput(\"radiusRange\", NodeParticleBlockConnectionPointTypes.Float, true, 1, 0, 1);\r\n this.registerInput(\"directionRandomizer\", NodeParticleBlockConnectionPointTypes.Float, true, 0, 0, 1);\r\n this.registerOutput(\"output\", NodeParticleBlockConnectionPointTypes.Particle);\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 \"SphereShapeBlock\";\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 radius input component\r\n */\r\n public get radius(): NodeParticleConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the radiusRange input component\r\n */\r\n public get radiusRange(): NodeParticleConnectionPoint {\r\n return this._inputs[2];\r\n }\r\n\r\n /**\r\n * Gets the directionRandomizer input component\r\n */\r\n public get directionRandomizer(): NodeParticleConnectionPoint {\r\n return this._inputs[3];\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 * Builds the block\r\n * @param state defines the build state\r\n */\r\n public override _build(state: NodeParticleBuildState) {\r\n const system = this.particle.getConnectedValue(state);\r\n\r\n system._directionCreation.process = (particle: Particle) => {\r\n state.particleContext = particle;\r\n state.systemContext = system;\r\n\r\n const directionRandomizer = this.directionRandomizer.getConnectedValue(state);\r\n\r\n const direction = particle.position.subtract(state.emitterPosition!).normalize();\r\n const randX = RandomRange(0, directionRandomizer);\r\n const randY = RandomRange(0, directionRandomizer);\r\n const randZ = RandomRange(0, directionRandomizer);\r\n direction.x += randX;\r\n direction.y += randY;\r\n direction.z += randZ;\r\n direction.normalize();\r\n\r\n if (system.isLocal) {\r\n particle.direction.copyFromFloats(randX, randY, randZ);\r\n } else {\r\n Vector3.TransformNormalFromFloatsToRef(randX, randY, randZ, state.emitterWorldMatrix!, particle.direction);\r\n }\r\n\r\n particle._initialDirection = particle.direction.clone();\r\n };\r\n\r\n system._positionCreation.process = (particle: Particle) => {\r\n state.particleContext = particle;\r\n state.systemContext = system;\r\n\r\n const radius = this.radius.getConnectedValue(state);\r\n const radiusRange = this.radiusRange.getConnectedValue(state);\r\n\r\n const randRadius = radius - RandomRange(0, radius * radiusRange);\r\n const v = RandomRange(0, 1.0);\r\n const phi = RandomRange(0, 2 * Math.PI);\r\n const theta = Math.acos(2 * v - 1);\r\n const randX = randRadius * Math.cos(phi) * Math.sin(theta);\r\n const randY = randRadius * Math.cos(theta);\r\n const randZ = randRadius * Math.sin(phi) * Math.sin(theta);\r\n\r\n if (system.isLocal) {\r\n particle.position.copyFromFloats(randX, randY, randZ);\r\n particle.position.addInPlace(state.emitterPosition!);\r\n } else {\r\n Vector3.TransformCoordinatesFromFloatsToRef(randX, randY, randZ, state.emitterWorldMatrix!, particle.position);\r\n }\r\n };\r\n\r\n this.output._storedValue = system;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.SphereShapeBlock\", SphereShapeBlock);\r\n"]}
|
|
1
|
+
{"version":3,"file":"sphereShapeBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Particles/Node/Blocks/Emitters/sphereShapeBlock.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,qCAAqC,EAAE,MAAM,mDAAmD,CAAC;AAC1G,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAE,yCAA+B;AACjD,OAAO,EAAE,WAAW,EAAE,mDAAyC;AAC/D,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAEhE;;;GAGG;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,QAAQ,EAAE,qCAAqC,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QACnF,IAAI,CAAC,aAAa,CAAC,aAAa,EAAE,qCAAqC,CAAC,KAAK,EAAE,IA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{ NodeParticleBuildState } from \"../../nodeParticleBuildState\";\r\nimport type { Particle } from \"core/Particles/particle\";\r\nimport type { IShapeBlock } from \"./IShapeBlock\";\r\n\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport { NodeParticleBlockConnectionPointTypes } from \"../../Enums/nodeParticleBlockConnectionPointTypes\";\r\nimport { NodeParticleBlock } from \"../../nodeParticleBlock\";\r\nimport { Vector3 } from \"core/Maths/math.vector\";\r\nimport { RandomRange } from \"core/Maths/math.scalar.functions\";\r\nimport { _CreateLocalPositionData } from \"./emitters.functions\";\r\n\r\n/**\r\n * Block used to provide a flow of particles emitted from a sphere shape.\r\n * DirectionRandomizer will be used for the particles initial direction unless both direction1 and direction2 are connected.\r\n */\r\nexport class SphereShapeBlock extends NodeParticleBlock implements IShapeBlock {\r\n /**\r\n * Create a new SphereShapeBlock\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(\"radius\", NodeParticleBlockConnectionPointTypes.Float, true, 1);\r\n this.registerInput(\"radiusRange\", NodeParticleBlockConnectionPointTypes.Float, true, 1, 0, 1);\r\n this.registerInput(\"directionRandomizer\", NodeParticleBlockConnectionPointTypes.Float, true, 0, 0, 1);\r\n this.registerInput(\"direction1\", NodeParticleBlockConnectionPointTypes.Vector3, true);\r\n this.registerInput(\"direction2\", NodeParticleBlockConnectionPointTypes.Vector3, true);\r\n this.registerOutput(\"output\", NodeParticleBlockConnectionPointTypes.Particle);\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 \"SphereShapeBlock\";\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 radius input component\r\n */\r\n public get radius(): NodeParticleConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the radiusRange input component\r\n */\r\n public get radiusRange(): NodeParticleConnectionPoint {\r\n return this._inputs[2];\r\n }\r\n\r\n /**\r\n * Gets the directionRandomizer input component\r\n */\r\n public get directionRandomizer(): NodeParticleConnectionPoint {\r\n return this._inputs[3];\r\n }\r\n\r\n /**\r\n * Gets the direction1 input component\r\n */\r\n public get direction1(): NodeParticleConnectionPoint {\r\n return this._inputs[4];\r\n }\r\n\r\n /**\r\n * Gets the direction2 input component\r\n */\r\n public get direction2(): NodeParticleConnectionPoint {\r\n return this._inputs[5];\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 * Builds the block\r\n * @param state defines the build state\r\n */\r\n public override _build(state: NodeParticleBuildState) {\r\n const system = this.particle.getConnectedValue(state);\r\n\r\n system._directionCreation.process = (particle: Particle) => {\r\n state.particleContext = particle;\r\n state.systemContext = system;\r\n\r\n // We always use directionRandomizer unless both directions are connected\r\n if (this.direction1.isConnected === false || this.direction2.isConnected === false) {\r\n const directionRandomizer = this.directionRandomizer.getConnectedValue(state) as number;\r\n\r\n const direction = particle.position.subtract(state.emitterPosition!).normalize();\r\n const randX = RandomRange(0, directionRandomizer);\r\n const randY = RandomRange(0, directionRandomizer);\r\n const randZ = RandomRange(0, directionRandomizer);\r\n direction.x += randX;\r\n direction.y += randY;\r\n direction.z += randZ;\r\n direction.normalize();\r\n\r\n if (system.isLocal) {\r\n particle.direction.copyFromFloats(direction.x, direction.y, direction.z);\r\n } else {\r\n Vector3.TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, state.emitterWorldMatrix!, particle.direction);\r\n }\r\n } else {\r\n const direction1 = this.direction1.getConnectedValue(state) as Vector3;\r\n const direction2 = this.direction2.getConnectedValue(state) as Vector3;\r\n\r\n const randX = RandomRange(direction1.x, direction2.x);\r\n const randY = RandomRange(direction1.y, direction2.y);\r\n const randZ = RandomRange(direction1.z, direction2.z);\r\n\r\n if (system.isLocal) {\r\n particle.direction.copyFromFloats(randX, randY, randZ);\r\n } else {\r\n Vector3.TransformNormalFromFloatsToRef(randX, randY, randZ, state.emitterWorldMatrix!, particle.direction);\r\n }\r\n }\r\n\r\n particle._initialDirection = particle.direction.clone();\r\n };\r\n\r\n system._positionCreation.process = (particle: Particle) => {\r\n state.particleContext = particle;\r\n state.systemContext = system;\r\n\r\n const radius = this.radius.getConnectedValue(state) as number;\r\n const radiusRange = this.radiusRange.getConnectedValue(state) as number;\r\n\r\n const randRadius = radius - RandomRange(0, radius * radiusRange);\r\n const v = RandomRange(0, 1.0);\r\n const phi = RandomRange(0, 2 * Math.PI);\r\n const theta = Math.acos(2 * v - 1);\r\n const randX = randRadius * Math.cos(phi) * Math.sin(theta);\r\n const randY = randRadius * Math.cos(theta);\r\n const randZ = randRadius * Math.sin(phi) * Math.sin(theta);\r\n\r\n if (system.isLocal) {\r\n particle.position.copyFromFloats(randX, randY, randZ);\r\n } else {\r\n Vector3.TransformCoordinatesFromFloatsToRef(randX, randY, randZ, state.emitterWorldMatrix!, particle.position);\r\n }\r\n\r\n _CreateLocalPositionData(particle);\r\n };\r\n\r\n this.output._storedValue = system;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.SphereShapeBlock\", SphereShapeBlock);\r\n"]}
|