@newkrok/three-particles 1.0.0 → 1.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/package.json
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@newkrok/three-particles",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "Particle system for ThreeJS",
|
|
5
|
-
"main": "src/js/effects/three-particles.js",
|
|
6
|
-
"bin": {
|
|
7
|
-
"three-particles": "src/js/effects/three-particles.js"
|
|
8
|
-
},
|
|
9
|
-
"repository": {
|
|
10
|
-
"type": "git",
|
|
11
|
-
"url": "git+https://github.com/NewKrok/three-particles.git"
|
|
12
|
-
},
|
|
13
|
-
"keywords": [
|
|
14
|
-
"threejs",
|
|
15
|
-
"particle",
|
|
16
|
-
"particles",
|
|
17
|
-
"particle engine",
|
|
18
|
-
"effects",
|
|
19
|
-
"3d",
|
|
20
|
-
"lib"
|
|
21
|
-
],
|
|
22
|
-
"author": "Istvan Krisztian Somoracz",
|
|
23
|
-
"license": "MIT",
|
|
24
|
-
"bugs": {
|
|
25
|
-
"url": "https://github.com/NewKrok/three-particles/issues"
|
|
26
|
-
},
|
|
27
|
-
"homepage": "https://github.com/NewKrok/three-particles#readme",
|
|
28
|
-
"dependencies": {
|
|
29
|
-
"easing-functions": "1.0.1",
|
|
30
|
-
"three": "^0.144.0",
|
|
31
|
-
"three-noise": "1.1.2",
|
|
32
|
-
"@newkrok/three-utils": "^0.
|
|
33
|
-
},
|
|
34
|
-
"scripts": {
|
|
35
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
|
36
|
-
}
|
|
37
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@newkrok/three-particles",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Particle system for ThreeJS",
|
|
5
|
+
"main": "src/js/effects/three-particles.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"three-particles": "src/js/effects/three-particles.js"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/NewKrok/three-particles.git"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"threejs",
|
|
15
|
+
"particle",
|
|
16
|
+
"particles",
|
|
17
|
+
"particle engine",
|
|
18
|
+
"effects",
|
|
19
|
+
"3d",
|
|
20
|
+
"lib"
|
|
21
|
+
],
|
|
22
|
+
"author": "Istvan Krisztian Somoracz",
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"bugs": {
|
|
25
|
+
"url": "https://github.com/NewKrok/three-particles/issues"
|
|
26
|
+
},
|
|
27
|
+
"homepage": "https://github.com/NewKrok/three-particles#readme",
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"easing-functions": "1.0.1",
|
|
30
|
+
"three": "^0.144.0",
|
|
31
|
+
"three-noise": "1.1.2",
|
|
32
|
+
"@newkrok/three-utils": "^1.0.0"
|
|
33
|
+
},
|
|
34
|
+
"scripts": {
|
|
35
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export const SimulationSpace = {
|
|
2
|
+
LOCAL: "LOCAL",
|
|
3
|
+
WORLD: "WORLD",
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
export const Shape = {
|
|
7
|
+
SPHERE: "SPHERE",
|
|
8
|
+
CONE: "CONE",
|
|
9
|
+
BOX: "BOX",
|
|
10
|
+
CIRCLE: "CIRCLE",
|
|
11
|
+
RECTANGLE: "RECTANGLE",
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const EmitFrom = {
|
|
15
|
+
VOLUME: "VOLUME",
|
|
16
|
+
SHELL: "SHELL",
|
|
17
|
+
EDGE: "EDGE",
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const TimeMode = {
|
|
21
|
+
LIFETIME: "LIFETIME",
|
|
22
|
+
FPS: "FPS",
|
|
23
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
export type Point3D = {
|
|
2
|
+
x?: number;
|
|
3
|
+
y?: number;
|
|
4
|
+
z?: number;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
export type Transform = {
|
|
8
|
+
position?: Point3D;
|
|
9
|
+
rotation?: Point3D;
|
|
10
|
+
scale?: Point3D;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export type MinMaxNumber = {
|
|
14
|
+
min: number;
|
|
15
|
+
max: number;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export type Rgb = {
|
|
19
|
+
r: number;
|
|
20
|
+
g: number;
|
|
21
|
+
b: number;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export type MinMaxColor = {
|
|
25
|
+
min: Rgb;
|
|
26
|
+
max: Rgb;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export type Emission = {
|
|
30
|
+
rateOverTime: number;
|
|
31
|
+
rateOverDistance: number;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export type ParticleSystemConfig = {
|
|
35
|
+
transform: Transform;
|
|
36
|
+
duration: number;
|
|
37
|
+
looping: boolean;
|
|
38
|
+
startDelay: MinMaxNumber;
|
|
39
|
+
startLifetime: MinMaxNumber;
|
|
40
|
+
startSpeed: MinMaxNumber;
|
|
41
|
+
startSize: MinMaxNumber;
|
|
42
|
+
startRotation: MinMaxNumber;
|
|
43
|
+
startColor: MinMaxColor;
|
|
44
|
+
startOpacity: MinMaxNumber;
|
|
45
|
+
gravity: number;
|
|
46
|
+
simulationSpace: "LOCAL" | "WORLD";
|
|
47
|
+
maxParticles: number;
|
|
48
|
+
emission: Emission;
|
|
49
|
+
shape: any;
|
|
50
|
+
map: any;
|
|
51
|
+
renderer: any;
|
|
52
|
+
velocityOverLifetime: any;
|
|
53
|
+
sizeOverLifetime: any;
|
|
54
|
+
opacityOverLifetime: any;
|
|
55
|
+
rotationOverLifetime: any;
|
|
56
|
+
noise: any;
|
|
57
|
+
textureSheetAnimation: any;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export type ParticleSystem = {
|
|
61
|
+
instance: THREE.Object3D;
|
|
62
|
+
resumeEmitter: () => void;
|
|
63
|
+
pauseEmitter: () => void;
|
|
64
|
+
dispose: () => void;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export function createParticleSystem(
|
|
68
|
+
config: ParticleSystemConfig,
|
|
69
|
+
externalNow?: number
|
|
70
|
+
): ParticleSystem;
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import * as THREE from "three";
|
|
2
2
|
|
|
3
|
+
import {
|
|
4
|
+
EmitFrom,
|
|
5
|
+
Shape,
|
|
6
|
+
SimulationSpace,
|
|
7
|
+
TimeMode,
|
|
8
|
+
} from "./three-particles/three-particles-enums.js";
|
|
3
9
|
import {
|
|
4
10
|
calculateRandomPositionAndVelocityOnBox,
|
|
5
11
|
calculateRandomPositionAndVelocityOnCircle,
|
|
@@ -11,38 +17,14 @@ import {
|
|
|
11
17
|
import { CurveFunction } from "./three-particles/three-particles-curves.js";
|
|
12
18
|
import { FBM } from "three-noise/build/three-noise.module.js";
|
|
13
19
|
import { Gyroscope } from "three/examples/jsm/misc/Gyroscope.js";
|
|
20
|
+
import { ObjectUtils } from "@newkrok/three-utils";
|
|
14
21
|
import ParticleSystemFragmentShader from "./three-particles/shaders/particle-system-fragment-shader.glsl.js";
|
|
15
22
|
import ParticleSystemVertexShader from "./three-particles/shaders/particle-system-vertex-shader.glsl.js";
|
|
16
23
|
import { applyModifiers } from "./three-particles/three-particles-modifiers.js";
|
|
17
24
|
import { createBezierCurveFunction } from "./three-particles/three-particles-bezier";
|
|
18
|
-
import { patchObject } from "@newkrok/three-utils/src/js/newkrok/three-utils/object-utils.js";
|
|
19
25
|
|
|
20
26
|
let createdParticleSystems = [];
|
|
21
27
|
|
|
22
|
-
export const SimulationSpace = {
|
|
23
|
-
LOCAL: "LOCAL",
|
|
24
|
-
WORLD: "WORLD",
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export const Shape = {
|
|
28
|
-
SPHERE: "SPHERE",
|
|
29
|
-
CONE: "CONE",
|
|
30
|
-
BOX: "BOX",
|
|
31
|
-
CIRCLE: "CIRCLE",
|
|
32
|
-
RECTANGLE: "RECTANGLE",
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
export const EmitFrom = {
|
|
36
|
-
VOLUME: "VOLUME",
|
|
37
|
-
SHELL: "SHELL",
|
|
38
|
-
EDGE: "EDGE",
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
export const TimeMode = {
|
|
42
|
-
LIFETIME: "LIFETIME",
|
|
43
|
-
FPS: "FPS",
|
|
44
|
-
};
|
|
45
|
-
|
|
46
28
|
export const blendingMap = {
|
|
47
29
|
"THREE.NoBlending": THREE.NoBlending,
|
|
48
30
|
"THREE.NormalBlending": THREE.NormalBlending,
|
|
@@ -283,6 +265,9 @@ const calculatePositionAndVelocity = (
|
|
|
283
265
|
}
|
|
284
266
|
};
|
|
285
267
|
|
|
268
|
+
/**
|
|
269
|
+
* @deprecated Since version 1.0.1. Will be deleted in version 1.1.0. Use particleSystem.dispose instead.
|
|
270
|
+
*/
|
|
286
271
|
export const destroyParticleSystem = (particleSystem) => {
|
|
287
272
|
createdParticleSystems = createdParticleSystems.filter(
|
|
288
273
|
({ particleSystem: savedParticleSystem, wrapper }) => {
|
|
@@ -327,7 +312,10 @@ export const createParticleSystem = (
|
|
|
327
312
|
isEnabled: true,
|
|
328
313
|
};
|
|
329
314
|
|
|
330
|
-
const normalizedConfig = patchObject(
|
|
315
|
+
const normalizedConfig = ObjectUtils.patchObject(
|
|
316
|
+
DEFAULT_PARTICLE_SYSTEM_CONFIG,
|
|
317
|
+
config
|
|
318
|
+
);
|
|
331
319
|
|
|
332
320
|
const bezierCompatibleProperties = [
|
|
333
321
|
"sizeOverLifetime",
|