sparcoon 0.0.1
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/LICENSE +21 -0
- package/dist/behaviorModules/FXBehaviorDirectionalGravity.d.ts +21 -0
- package/dist/behaviorModules/FXBehaviorDirectionalGravity.js +47 -0
- package/dist/behaviorModules/FXBehaviorModule.d.ts +14 -0
- package/dist/behaviorModules/FXBehaviorModule.js +9 -0
- package/dist/behaviorModules/FXBehaviorPointGravity.d.ts +39 -0
- package/dist/behaviorModules/FXBehaviorPointGravity.js +110 -0
- package/dist/behaviorModules/FXBehaviorScaleOverLife.d.ts +22 -0
- package/dist/behaviorModules/FXBehaviorScaleOverLife.js +66 -0
- package/dist/behaviorModules/FXBehaviorTorqueDamping.d.ts +20 -0
- package/dist/behaviorModules/FXBehaviorTorqueDamping.js +48 -0
- package/dist/behaviorModules/FXBehaviorTorqueNoise.d.ts +26 -0
- package/dist/behaviorModules/FXBehaviorTorqueNoise.js +66 -0
- package/dist/behaviorModules/FXBehaviorVelocityDamping.d.ts +20 -0
- package/dist/behaviorModules/FXBehaviorVelocityDamping.js +49 -0
- package/dist/behaviorModules/FXBehaviorVelocityNoise.d.ts +26 -0
- package/dist/behaviorModules/FXBehaviorVelocityNoise.js +73 -0
- package/dist/color/FXColor.Internal.d.ts +7 -0
- package/dist/color/FXColor.Internal.js +42 -0
- package/dist/color/FXColor.d.ts +234 -0
- package/dist/color/FXColor.js +636 -0
- package/dist/elements/FXEmitter.Internal.d.ts +10 -0
- package/dist/elements/FXEmitter.Internal.js +5 -0
- package/dist/elements/FXEmitter.d.ts +29 -0
- package/dist/elements/FXEmitter.js +154 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +18 -0
- package/dist/instancedParticle/FXInstancedParticle.Internal.d.ts +13 -0
- package/dist/instancedParticle/FXInstancedParticle.Internal.js +216 -0
- package/dist/instancedParticle/FXInstancedParticle.d.ts +17 -0
- package/dist/instancedParticle/FXInstancedParticle.js +93 -0
- package/dist/instancedParticle/shared.d.ts +27 -0
- package/dist/instancedParticle/shared.js +123 -0
- package/dist/miscellaneous/FXTransparencyMode.d.ts +7 -0
- package/dist/miscellaneous/asserts.d.ts +21 -0
- package/dist/miscellaneous/asserts.js +48 -0
- package/dist/miscellaneous/math.d.ts +8 -0
- package/dist/miscellaneous/math.js +11 -0
- package/dist/miscellaneous/miscellaneous.d.ts +33 -0
- package/dist/miscellaneous/miscellaneous.js +66 -0
- package/dist/miscellaneous/texture/FXTextureView.Internal.d.ts +49 -0
- package/dist/miscellaneous/texture/FXTextureView.Internal.js +6 -0
- package/dist/miscellaneous/texture/FXTextureView.d.ts +72 -0
- package/dist/miscellaneous/texture/FXTextureView.js +234 -0
- package/dist/miscellaneous/webglCapabilities.d.ts +1 -0
- package/dist/miscellaneous/webglCapabilities.js +45 -0
- package/dist/renderingModules/FXRenderingColorOverLife.d.ts +14 -0
- package/dist/renderingModules/FXRenderingColorOverLife.js +32 -0
- package/dist/renderingModules/FXRenderingColorOverVelocity.d.ts +15 -0
- package/dist/renderingModules/FXRenderingColorOverVelocity.js +37 -0
- package/dist/renderingModules/FXRenderingModule.d.ts +8 -0
- package/dist/renderingModules/FXRenderingModule.js +9 -0
- package/dist/renderingModules/FXRenderingTexture.d.ts +14 -0
- package/dist/renderingModules/FXRenderingTexture.js +26 -0
- package/dist/shaders/FXRenderingColorOverLife.glsl.js +3 -0
- package/dist/shaders/FXRenderingColorOverVelocity.glsl.js +3 -0
- package/dist/shaders/FXRenderingTexture.glsl.js +3 -0
- package/dist/spawnModules/FXSpawnBox.d.ts +27 -0
- package/dist/spawnModules/FXSpawnBox.js +67 -0
- package/dist/spawnModules/FXSpawnModule.d.ts +9 -0
- package/dist/spawnModules/FXSpawnModule.js +9 -0
- package/dist/spawnModules/FXSpawnOffset.d.ts +21 -0
- package/dist/spawnModules/FXSpawnOffset.js +49 -0
- package/dist/spawnModules/FXSpawnRandomLifetime.d.ts +20 -0
- package/dist/spawnModules/FXSpawnRandomLifetime.js +47 -0
- package/dist/spawnModules/FXSpawnRandomRotation.d.ts +20 -0
- package/dist/spawnModules/FXSpawnRandomRotation.js +45 -0
- package/dist/spawnModules/FXSpawnRandomScale.d.ts +26 -0
- package/dist/spawnModules/FXSpawnRandomScale.js +60 -0
- package/dist/spawnModules/FXSpawnRandomTorque.d.ts +20 -0
- package/dist/spawnModules/FXSpawnRandomTorque.js +45 -0
- package/dist/spawnModules/FXSpawnRandomVelocity.d.ts +26 -0
- package/dist/spawnModules/FXSpawnRandomVelocity.js +64 -0
- package/package.json +55 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { FXRange, FXRangeConfig } from "../miscellaneous/miscellaneous";
|
|
2
|
+
import { FXSpawnModule } from "./FXSpawnModule";
|
|
3
|
+
/**
|
|
4
|
+
* Assigns random lifetime to particles.
|
|
5
|
+
*
|
|
6
|
+
* Lifetime is chosen uniformly from the specified range. Age is set to 0.
|
|
7
|
+
*/
|
|
8
|
+
export declare class FXSpawnRandomLifetime extends FXSpawnModule<{
|
|
9
|
+
builtin: "Matrix4";
|
|
10
|
+
}> {
|
|
11
|
+
private lifetimeInternal;
|
|
12
|
+
/**
|
|
13
|
+
* @param lifetime - Lifetime range in seconds. Accepts number, tuple, or range object
|
|
14
|
+
*/
|
|
15
|
+
constructor(lifetime?: FXRangeConfig);
|
|
16
|
+
/** Lifetime range in seconds */
|
|
17
|
+
get lifetime(): FXRange;
|
|
18
|
+
/** Lifetime range in seconds */
|
|
19
|
+
set lifetime(value: FXRangeConfig);
|
|
20
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { MathUtils } from 'three';
|
|
2
|
+
import { assertValidPositiveNumber } from '../miscellaneous/asserts.js';
|
|
3
|
+
import { resolveFXRangeConfig, BUILTIN_OFFSET_LIFETIME, BUILTIN_OFFSET_AGE } from '../miscellaneous/miscellaneous.js';
|
|
4
|
+
import { FXSpawnModule } from './FXSpawnModule.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Assigns random lifetime to particles.
|
|
8
|
+
*
|
|
9
|
+
* Lifetime is chosen uniformly from the specified range. Age is set to 0.
|
|
10
|
+
*/
|
|
11
|
+
class FXSpawnRandomLifetime extends FXSpawnModule {
|
|
12
|
+
/**
|
|
13
|
+
* @param lifetime - Lifetime range in seconds. Accepts number, tuple, or range object
|
|
14
|
+
*/
|
|
15
|
+
constructor(lifetime = { min: 4, max: 8 }) {
|
|
16
|
+
super();
|
|
17
|
+
/** @internal */
|
|
18
|
+
this.requiredProperties = { builtin: "Matrix4" };
|
|
19
|
+
this._private_lifetimeInternal = resolveFXRangeConfig(lifetime);
|
|
20
|
+
assertValidPositiveNumber(this._private_lifetimeInternal.min, "UISpawnRandomLifetime.constructor.lifetime.min");
|
|
21
|
+
assertValidPositiveNumber(this._private_lifetimeInternal.max, "UISpawnRandomLifetime.constructor.lifetime.max");
|
|
22
|
+
}
|
|
23
|
+
/** Lifetime range in seconds */
|
|
24
|
+
get lifetime() {
|
|
25
|
+
return this._private_lifetimeInternal;
|
|
26
|
+
}
|
|
27
|
+
/** Lifetime range in seconds */
|
|
28
|
+
set lifetime(value) {
|
|
29
|
+
this._private_lifetimeInternal = resolveFXRangeConfig(value);
|
|
30
|
+
assertValidPositiveNumber(this._private_lifetimeInternal.min, "UISpawnRandomLifetime.lifetime.min");
|
|
31
|
+
assertValidPositiveNumber(this._private_lifetimeInternal.max, "UISpawnRandomLifetime.lifetime.max");
|
|
32
|
+
}
|
|
33
|
+
/** @internal */
|
|
34
|
+
spawn(properties, instanceBegin, instanceEnd) {
|
|
35
|
+
const { builtin } = properties;
|
|
36
|
+
const { array, itemSize } = builtin;
|
|
37
|
+
const { min: lifetimeMin, max: lifetimeMax } = this._private_lifetimeInternal;
|
|
38
|
+
for (let i = instanceBegin; i < instanceEnd; i++) {
|
|
39
|
+
const itemOffset = i * itemSize;
|
|
40
|
+
array[itemOffset + BUILTIN_OFFSET_LIFETIME] = MathUtils.randFloat(lifetimeMin, lifetimeMax);
|
|
41
|
+
array[itemOffset + BUILTIN_OFFSET_AGE] = 0;
|
|
42
|
+
}
|
|
43
|
+
builtin.needsUpdate = true;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export { FXSpawnRandomLifetime };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type FXRange, type FXRangeConfig } from "../miscellaneous/miscellaneous";
|
|
2
|
+
import { FXSpawnModule } from "./FXSpawnModule";
|
|
3
|
+
/**
|
|
4
|
+
* Assigns random rotation to particles.
|
|
5
|
+
*
|
|
6
|
+
* Initial rotation is chosen uniformly from the specified range.
|
|
7
|
+
*/
|
|
8
|
+
export declare class FXSpawnRandomRotation extends FXSpawnModule<{
|
|
9
|
+
builtin: "Matrix4";
|
|
10
|
+
}> {
|
|
11
|
+
private rotationInternal;
|
|
12
|
+
/**
|
|
13
|
+
* @param rotation - Rotation range in radians. Accepts number, tuple, or range object
|
|
14
|
+
*/
|
|
15
|
+
constructor(rotation?: FXRangeConfig);
|
|
16
|
+
/** Rotation range in radians */
|
|
17
|
+
get rotation(): FXRange;
|
|
18
|
+
/** Rotation range in radians */
|
|
19
|
+
set rotation(value: FXRangeConfig);
|
|
20
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { MathUtils } from 'three';
|
|
2
|
+
import { assertValidNumber } from '../miscellaneous/asserts.js';
|
|
3
|
+
import { resolveFXRangeConfig, BUILTIN_OFFSET_ROTATION } from '../miscellaneous/miscellaneous.js';
|
|
4
|
+
import { FXSpawnModule } from './FXSpawnModule.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Assigns random rotation to particles.
|
|
8
|
+
*
|
|
9
|
+
* Initial rotation is chosen uniformly from the specified range.
|
|
10
|
+
*/
|
|
11
|
+
class FXSpawnRandomRotation extends FXSpawnModule {
|
|
12
|
+
/**
|
|
13
|
+
* @param rotation - Rotation range in radians. Accepts number, tuple, or range object
|
|
14
|
+
*/
|
|
15
|
+
constructor(rotation = { min: -Math.PI, max: Math.PI }) {
|
|
16
|
+
super();
|
|
17
|
+
/** @internal */
|
|
18
|
+
this.requiredProperties = { builtin: "Matrix4" };
|
|
19
|
+
this._private_rotationInternal = resolveFXRangeConfig(rotation);
|
|
20
|
+
assertValidNumber(this._private_rotationInternal.min, "UISpawnRandomRotation.constructor.rotation.min");
|
|
21
|
+
assertValidNumber(this._private_rotationInternal.max, "UISpawnRandomRotation.constructor.rotation.max");
|
|
22
|
+
}
|
|
23
|
+
/** Rotation range in radians */
|
|
24
|
+
get rotation() {
|
|
25
|
+
return this._private_rotationInternal;
|
|
26
|
+
}
|
|
27
|
+
/** Rotation range in radians */
|
|
28
|
+
set rotation(value) {
|
|
29
|
+
this._private_rotationInternal = resolveFXRangeConfig(value);
|
|
30
|
+
assertValidNumber(this._private_rotationInternal.min, "UISpawnRandomRotation.rotation.min");
|
|
31
|
+
assertValidNumber(this._private_rotationInternal.max, "UISpawnRandomRotation.rotation.max");
|
|
32
|
+
}
|
|
33
|
+
/** @internal */
|
|
34
|
+
spawn(properties, instanceBegin, instanceEnd) {
|
|
35
|
+
const { builtin } = properties;
|
|
36
|
+
const { array, itemSize } = builtin;
|
|
37
|
+
const { min: rotationMin, max: rotationMax } = this._private_rotationInternal;
|
|
38
|
+
for (let i = instanceBegin; i < instanceEnd; i++) {
|
|
39
|
+
array[i * itemSize + BUILTIN_OFFSET_ROTATION] = MathUtils.randFloat(rotationMin, rotationMax);
|
|
40
|
+
}
|
|
41
|
+
builtin.needsUpdate = true;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export { FXSpawnRandomRotation };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type FXAspectConfig, type FXRange, type FXRangeConfig } from "../miscellaneous/miscellaneous";
|
|
2
|
+
import { FXSpawnModule } from "./FXSpawnModule";
|
|
3
|
+
/**
|
|
4
|
+
* Assigns random scale to particles.
|
|
5
|
+
*
|
|
6
|
+
* Base scale is chosen uniformly from the range. Aspect ratio is applied to X scale.
|
|
7
|
+
*/
|
|
8
|
+
export declare class FXSpawnRandomScale extends FXSpawnModule<{
|
|
9
|
+
builtin: "Matrix4";
|
|
10
|
+
}> {
|
|
11
|
+
private scaleInternal;
|
|
12
|
+
private aspectInternal;
|
|
13
|
+
/**
|
|
14
|
+
* @param scale - Base scale range. Accepts number, tuple, or range object
|
|
15
|
+
* @param aspect - Width/height ratio. Accepts number or texture
|
|
16
|
+
*/
|
|
17
|
+
constructor(scale?: FXRangeConfig, aspect?: FXAspectConfig);
|
|
18
|
+
/** Base scale range */
|
|
19
|
+
get scale(): FXRange;
|
|
20
|
+
/** Width/height aspect ratio */
|
|
21
|
+
get aspect(): number;
|
|
22
|
+
/** Base scale range */
|
|
23
|
+
set scale(value: FXRangeConfig);
|
|
24
|
+
/** Width/height aspect ratio */
|
|
25
|
+
set aspect(value: FXAspectConfig);
|
|
26
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { MathUtils } from 'three';
|
|
2
|
+
import { assertValidPositiveNumber } from '../miscellaneous/asserts.js';
|
|
3
|
+
import { resolveFXRangeConfig, resolveAspect, BUILTIN_OFFSET_SCALE_X, BUILTIN_OFFSET_SCALE_Y } from '../miscellaneous/miscellaneous.js';
|
|
4
|
+
import { FXSpawnModule } from './FXSpawnModule.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Assigns random scale to particles.
|
|
8
|
+
*
|
|
9
|
+
* Base scale is chosen uniformly from the range. Aspect ratio is applied to X scale.
|
|
10
|
+
*/
|
|
11
|
+
class FXSpawnRandomScale extends FXSpawnModule {
|
|
12
|
+
/**
|
|
13
|
+
* @param scale - Base scale range. Accepts number, tuple, or range object
|
|
14
|
+
* @param aspect - Width/height ratio. Accepts number or texture
|
|
15
|
+
*/
|
|
16
|
+
constructor(scale = { min: 50, max: 100 }, aspect = 1) {
|
|
17
|
+
super();
|
|
18
|
+
/** @internal */
|
|
19
|
+
this.requiredProperties = { builtin: "Matrix4" };
|
|
20
|
+
this._private_scaleInternal = resolveFXRangeConfig(scale);
|
|
21
|
+
this._private_aspectInternal = resolveAspect(aspect);
|
|
22
|
+
assertValidPositiveNumber(this._private_scaleInternal.min, "UISpawnRandomScale.constructor.scale.min");
|
|
23
|
+
assertValidPositiveNumber(this._private_scaleInternal.max, "UISpawnRandomScale.constructor.scale.max");
|
|
24
|
+
assertValidPositiveNumber(this._private_aspectInternal, "UISpawnRandomScale.constructor.aspect");
|
|
25
|
+
}
|
|
26
|
+
/** Base scale range */
|
|
27
|
+
get scale() {
|
|
28
|
+
return this._private_scaleInternal;
|
|
29
|
+
}
|
|
30
|
+
/** Width/height aspect ratio */
|
|
31
|
+
get aspect() {
|
|
32
|
+
return this._private_aspectInternal;
|
|
33
|
+
}
|
|
34
|
+
/** Base scale range */
|
|
35
|
+
set scale(value) {
|
|
36
|
+
this._private_scaleInternal = resolveFXRangeConfig(value);
|
|
37
|
+
assertValidPositiveNumber(this._private_scaleInternal.min, "UISpawnRandomScale.scale.min");
|
|
38
|
+
assertValidPositiveNumber(this._private_scaleInternal.max, "UISpawnRandomScale.scale.max");
|
|
39
|
+
}
|
|
40
|
+
/** Width/height aspect ratio */
|
|
41
|
+
set aspect(value) {
|
|
42
|
+
this._private_aspectInternal = resolveAspect(value);
|
|
43
|
+
assertValidPositiveNumber(this._private_aspectInternal, "UISpawnRandomScale.aspect");
|
|
44
|
+
}
|
|
45
|
+
/** @internal */
|
|
46
|
+
spawn(properties, instanceBegin, instanceEnd) {
|
|
47
|
+
const { builtin } = properties;
|
|
48
|
+
const { array, itemSize } = builtin;
|
|
49
|
+
const { min: scaleMin, max: scaleMax } = this._private_scaleInternal;
|
|
50
|
+
for (let i = instanceBegin; i < instanceEnd; i++) {
|
|
51
|
+
const itemOffset = i * itemSize;
|
|
52
|
+
const randomScale = MathUtils.randFloat(scaleMin, scaleMax);
|
|
53
|
+
array[itemOffset + BUILTIN_OFFSET_SCALE_X] = randomScale * this._private_aspectInternal;
|
|
54
|
+
array[itemOffset + BUILTIN_OFFSET_SCALE_Y] = randomScale;
|
|
55
|
+
}
|
|
56
|
+
builtin.needsUpdate = true;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export { FXSpawnRandomScale };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type FXRange, type FXRangeConfig } from "../miscellaneous/miscellaneous";
|
|
2
|
+
import { FXSpawnModule } from "./FXSpawnModule";
|
|
3
|
+
/**
|
|
4
|
+
* Assigns random angular velocity to particles.
|
|
5
|
+
*
|
|
6
|
+
* Torque (rotation speed) is chosen uniformly from the specified range.
|
|
7
|
+
*/
|
|
8
|
+
export declare class FXSpawnRandomTorque extends FXSpawnModule<{
|
|
9
|
+
builtin: "Matrix4";
|
|
10
|
+
}> {
|
|
11
|
+
private torqueInternal;
|
|
12
|
+
/**
|
|
13
|
+
* @param torque - Angular velocity range in radians/second. Accepts number, tuple, or range object
|
|
14
|
+
*/
|
|
15
|
+
constructor(torque?: FXRangeConfig);
|
|
16
|
+
/** Angular velocity range in radians/second */
|
|
17
|
+
get torque(): FXRange;
|
|
18
|
+
/** Angular velocity range in radians/second */
|
|
19
|
+
set torque(value: FXRangeConfig);
|
|
20
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { MathUtils } from 'three';
|
|
2
|
+
import { assertValidNumber } from '../miscellaneous/asserts.js';
|
|
3
|
+
import { resolveFXRangeConfig, BUILTIN_OFFSET_TORQUE } from '../miscellaneous/miscellaneous.js';
|
|
4
|
+
import { FXSpawnModule } from './FXSpawnModule.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Assigns random angular velocity to particles.
|
|
8
|
+
*
|
|
9
|
+
* Torque (rotation speed) is chosen uniformly from the specified range.
|
|
10
|
+
*/
|
|
11
|
+
class FXSpawnRandomTorque extends FXSpawnModule {
|
|
12
|
+
/**
|
|
13
|
+
* @param torque - Angular velocity range in radians/second. Accepts number, tuple, or range object
|
|
14
|
+
*/
|
|
15
|
+
constructor(torque = { min: -Math.PI, max: Math.PI }) {
|
|
16
|
+
super();
|
|
17
|
+
/** @internal */
|
|
18
|
+
this.requiredProperties = { builtin: "Matrix4" };
|
|
19
|
+
this._private_torqueInternal = resolveFXRangeConfig(torque);
|
|
20
|
+
assertValidNumber(this._private_torqueInternal.min, "UISpawnRandomTorque.constructor.torque.min");
|
|
21
|
+
assertValidNumber(this._private_torqueInternal.max, "UISpawnRandomTorque.constructor.torque.max");
|
|
22
|
+
}
|
|
23
|
+
/** Angular velocity range in radians/second */
|
|
24
|
+
get torque() {
|
|
25
|
+
return this._private_torqueInternal;
|
|
26
|
+
}
|
|
27
|
+
/** Angular velocity range in radians/second */
|
|
28
|
+
set torque(value) {
|
|
29
|
+
this._private_torqueInternal = resolveFXRangeConfig(value);
|
|
30
|
+
assertValidNumber(this._private_torqueInternal.min, "UISpawnRandomTorque.torque.min");
|
|
31
|
+
assertValidNumber(this._private_torqueInternal.max, "UISpawnRandomTorque.torque.max");
|
|
32
|
+
}
|
|
33
|
+
/** @internal */
|
|
34
|
+
spawn(properties, instanceBegin, instanceEnd) {
|
|
35
|
+
const { builtin } = properties;
|
|
36
|
+
const { array, itemSize } = builtin;
|
|
37
|
+
const { min: torqueMin, max: torqueMax } = this._private_torqueInternal;
|
|
38
|
+
for (let i = instanceBegin; i < instanceEnd; i++) {
|
|
39
|
+
array[i * itemSize + BUILTIN_OFFSET_TORQUE] = MathUtils.randFloat(torqueMin, torqueMax);
|
|
40
|
+
}
|
|
41
|
+
builtin.needsUpdate = true;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export { FXSpawnRandomTorque };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type FXRange, type FXRangeConfig } from "../miscellaneous/miscellaneous";
|
|
2
|
+
import { FXSpawnModule } from "./FXSpawnModule";
|
|
3
|
+
/**
|
|
4
|
+
* Assigns random velocity to particles.
|
|
5
|
+
*
|
|
6
|
+
* Direction and magnitude are chosen independently from their respective ranges.
|
|
7
|
+
*/
|
|
8
|
+
export declare class FXSpawnRandomVelocity extends FXSpawnModule<{
|
|
9
|
+
builtin: "Matrix4";
|
|
10
|
+
}> {
|
|
11
|
+
private angleInternal;
|
|
12
|
+
private magnitudeInternal;
|
|
13
|
+
/**
|
|
14
|
+
* @param angle - Direction range in radians. Accepts number, tuple, or range object
|
|
15
|
+
* @param magnitude - Speed range in units/second. Accepts number, tuple, or range object
|
|
16
|
+
*/
|
|
17
|
+
constructor(angle?: FXRangeConfig, magnitude?: FXRangeConfig);
|
|
18
|
+
/** Direction range in radians */
|
|
19
|
+
get angle(): FXRange;
|
|
20
|
+
/** Speed range in units/second */
|
|
21
|
+
get magnitude(): FXRange;
|
|
22
|
+
/** Direction range in radians */
|
|
23
|
+
set angle(value: FXRangeConfig);
|
|
24
|
+
/** Speed range in units/second */
|
|
25
|
+
set magnitude(value: FXRangeConfig);
|
|
26
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { MathUtils } from 'three';
|
|
2
|
+
import { assertValidNumber } from '../miscellaneous/asserts.js';
|
|
3
|
+
import { resolveFXRangeConfig, BUILTIN_OFFSET_VELOCITY_X, BUILTIN_OFFSET_VELOCITY_Y } from '../miscellaneous/miscellaneous.js';
|
|
4
|
+
import { FXSpawnModule } from './FXSpawnModule.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Assigns random velocity to particles.
|
|
8
|
+
*
|
|
9
|
+
* Direction and magnitude are chosen independently from their respective ranges.
|
|
10
|
+
*/
|
|
11
|
+
class FXSpawnRandomVelocity extends FXSpawnModule {
|
|
12
|
+
/**
|
|
13
|
+
* @param angle - Direction range in radians. Accepts number, tuple, or range object
|
|
14
|
+
* @param magnitude - Speed range in units/second. Accepts number, tuple, or range object
|
|
15
|
+
*/
|
|
16
|
+
constructor(angle = { min: -Math.PI, max: Math.PI }, magnitude = { min: -50, max: 50 }) {
|
|
17
|
+
super();
|
|
18
|
+
/** @internal */
|
|
19
|
+
this.requiredProperties = { builtin: "Matrix4" };
|
|
20
|
+
this._private_angleInternal = resolveFXRangeConfig(angle);
|
|
21
|
+
this._private_magnitudeInternal = resolveFXRangeConfig(magnitude);
|
|
22
|
+
assertValidNumber(this._private_angleInternal.min, "UISpawnRandomVelocity.constructor.angle.min");
|
|
23
|
+
assertValidNumber(this._private_angleInternal.max, "UISpawnRandomVelocity.constructor.angle.max");
|
|
24
|
+
assertValidNumber(this._private_magnitudeInternal.min, "UISpawnRandomVelocity.constructor.magnitude.min");
|
|
25
|
+
assertValidNumber(this._private_magnitudeInternal.max, "UISpawnRandomVelocity.constructor.magnitude.max");
|
|
26
|
+
}
|
|
27
|
+
/** Direction range in radians */
|
|
28
|
+
get angle() {
|
|
29
|
+
return this._private_angleInternal;
|
|
30
|
+
}
|
|
31
|
+
/** Speed range in units/second */
|
|
32
|
+
get magnitude() {
|
|
33
|
+
return this._private_magnitudeInternal;
|
|
34
|
+
}
|
|
35
|
+
/** Direction range in radians */
|
|
36
|
+
set angle(value) {
|
|
37
|
+
this._private_angleInternal = resolveFXRangeConfig(value);
|
|
38
|
+
assertValidNumber(this._private_angleInternal.min, "UISpawnRandomVelocity.angle.min");
|
|
39
|
+
assertValidNumber(this._private_angleInternal.max, "UISpawnRandomVelocity.angle.max");
|
|
40
|
+
}
|
|
41
|
+
/** Speed range in units/second */
|
|
42
|
+
set magnitude(value) {
|
|
43
|
+
this._private_magnitudeInternal = resolveFXRangeConfig(value);
|
|
44
|
+
assertValidNumber(this._private_magnitudeInternal.min, "UISpawnRandomVelocity.magnitude.min");
|
|
45
|
+
assertValidNumber(this._private_magnitudeInternal.max, "UISpawnRandomVelocity.magnitude.max");
|
|
46
|
+
}
|
|
47
|
+
/** @internal */
|
|
48
|
+
spawn(properties, instanceBegin, instanceEnd) {
|
|
49
|
+
const { builtin } = properties;
|
|
50
|
+
const { array, itemSize } = builtin;
|
|
51
|
+
const { min: angleMin, max: angleMax } = this._private_angleInternal;
|
|
52
|
+
const { min: magnitudeMin, max: magnitudeMax } = this._private_magnitudeInternal;
|
|
53
|
+
for (let i = instanceBegin; i < instanceEnd; i++) {
|
|
54
|
+
const itemOffset = i * itemSize;
|
|
55
|
+
const angle = MathUtils.randFloat(angleMin, angleMax);
|
|
56
|
+
const magnitude = MathUtils.randFloat(magnitudeMin, magnitudeMax);
|
|
57
|
+
array[itemOffset + BUILTIN_OFFSET_VELOCITY_X] = Math.cos(angle) * magnitude;
|
|
58
|
+
array[itemOffset + BUILTIN_OFFSET_VELOCITY_Y] = Math.sin(angle) * magnitude;
|
|
59
|
+
}
|
|
60
|
+
builtin.needsUpdate = true;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export { FXSpawnRandomVelocity };
|
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "sparcoon",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"particles",
|
|
7
|
+
"three.js",
|
|
8
|
+
"mobile",
|
|
9
|
+
"ads",
|
|
10
|
+
"typescript"
|
|
11
|
+
],
|
|
12
|
+
"author": "jango",
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://github.com/jango-git/sparcoon.git"
|
|
17
|
+
},
|
|
18
|
+
"type": "module",
|
|
19
|
+
"sideEffects": false,
|
|
20
|
+
"scripts": {
|
|
21
|
+
"clean": "rm -rf dist",
|
|
22
|
+
"build": "npm run clean && rollup -c",
|
|
23
|
+
"prepublishOnly": "npm run build"
|
|
24
|
+
},
|
|
25
|
+
"main": "./dist/index.js",
|
|
26
|
+
"module": "./dist/index.js",
|
|
27
|
+
"files": [
|
|
28
|
+
"dist",
|
|
29
|
+
"README.md",
|
|
30
|
+
"LICENSE"
|
|
31
|
+
],
|
|
32
|
+
"exports": {
|
|
33
|
+
".": {
|
|
34
|
+
"import": "./dist/index.js",
|
|
35
|
+
"types": "./dist/index.d.ts"
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"peerDependencies": {
|
|
39
|
+
"three": ">=0.157.0 <0.180.0",
|
|
40
|
+
"ferrsign": "^0.0.4"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@rollup/plugin-node-resolve": "^16.0.1",
|
|
44
|
+
"@types/node": "^25.0.2",
|
|
45
|
+
"@types/three": "^0.157.0",
|
|
46
|
+
"@typescript-eslint/eslint-plugin": "^8.32.0",
|
|
47
|
+
"@typescript-eslint/parser": "^8.32.0",
|
|
48
|
+
"eslint": "^9.26.0",
|
|
49
|
+
"rollup": "^4.40.2",
|
|
50
|
+
"rollup-plugin-string": "^3.0.0",
|
|
51
|
+
"rollup-plugin-typescript2": "^0.36.0",
|
|
52
|
+
"ts-transformer-minify-privates": "^1.0.0",
|
|
53
|
+
"typescript": "^5.8.3"
|
|
54
|
+
}
|
|
55
|
+
}
|