-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathParticleManager.js
More file actions
127 lines (123 loc) · 4.38 KB
/
ParticleManager.js
File metadata and controls
127 lines (123 loc) · 4.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
import * as BABYLON from 'babylonjs';
import { scene } from './globals';
const ParticleManager = {
init: function(assets) {
this.materials = assets.materials;
this.run();
},
effectsProperties: {
blood: {
amount: 1000,
particleTexture: new BABYLON.Texture("textures/flare.png", scene),
minSize: 0.1,
maxSize: 0.3,
emitRate: 6000,
targetStopDuration: 1,
maxEmitPower: 1,
color1: new BABYLON.Color4(0.1, 0, 0, 1),
color2: new BABYLON.Color4(0.1, 0, 0, 1),
gravity: new BABYLON.Vector3(0, -150.81, 0),
disposeOnStop: true,
direction1: new BABYLON.Vector3(-7, 8, 3),
direction2: new BABYLON.Vector3(7, 8, -3)
},
blueBlood: {
amount: 1000,
particleTexture: new BABYLON.Texture("textures/flare.png", scene),
minSize: 0.1,
maxSize: 0.3,
emitRate: 6000,
targetStopDuration: 1,
maxEmitPower: 1,
color1: new BABYLON.Color4(0, 0, 1, 1),
color2: new BABYLON.Color4(0, 0, 1, 1),
gravity: new BABYLON.Vector3(0, -150.81, 0),
disposeOnStop: true,
direction1: new BABYLON.Vector3(-7, 8, 3),
direction2: new BABYLON.Vector3(7, 8, -3),
minLifeTime: 0.3,
maxLifeTime: 1
},
bulletPuff: {
amount: 10,
particleTexture: new BABYLON.Texture("textures/flare.png", scene),
minSize: 0.05,
maxSize: 0.05,
emitRate: 6000,
targetStopDuration: 1,
minEmitPower: 10,
color1: new BABYLON.Color4(1, 1, 1, 1),
color2: new BABYLON.Color4(1, 1, 1, 1),
gravity: new BABYLON.Vector3(0, 0, 0),
disposeOnStop: true,
direction1: new BABYLON.Vector3(0.5, 0.5, 0.5),
direction2: new BABYLON.Vector3(-0.5, 0.5, -0.5),
minLifeTime: 0.3,
maxLifeTime: 1
},
rocketTrail: {
amount: 5000,
particleTexture: new BABYLON.Texture("textures/flare.png", scene),
minSize: 0.4,
maxSize: 0.5,
emitRate: 500,
targetStopDuration: 100,
maxEmitPower: 10,
color1: new BABYLON.Color4(1, 0, 0, 1),
color2: new BABYLON.Color4(0.5, 0, 0, 1),
gravity: new BABYLON.Vector3(0, 0, 0),
disposeOnStop: false,
direction1: new BABYLON.Vector3(0, 0, 0),
direction2: new BABYLON.Vector3(0, 0, 0),
minLifeTime: 0.3,
maxLifeTime: 1
}
},
run: function() {
for(let effectName in this.effectsProperties) {
var props = this.effectsProperties[effectName];
this[effectName] = new BABYLON.ParticleSystem("particles", props.amount, scene);
// this[effectName] is now a ParticleSystem object and needs to be configured
this[effectName].particleTexture = props.particleTexture;
this[effectName].minSize = props.minSize;
this[effectName].maxSize = props.maxSize;
this[effectName].emitRate = props.emitRate;
this[effectName].targetStopDuration = props.targetStopDuration;
this[effectName].maxEmitPower = props.maxEmitPower;
this[effectName].color1 = props.color1;
this[effectName].color2 = props.color2;
this[effectName].gravity = props.gravity;
this[effectName].disposeOnStop = props.disposeOnStop;
this[effectName].direction1 = props.direction1;
this[effectName].direction2 = props.direction2;
this[effectName].minLifeTime = props.minLifeTime;
this[effectName].maxLifeTime = props.maxLifeTime;
}
},
emit: function(type, emitter, amount) {
var clonedParticleSystem = this[type].clone();
amount ? clonedParticleSystem._capacity = amount : 500
clonedParticleSystem.emitter = emitter;
clonedParticleSystem.start();
return clonedParticleSystem;
}
}
export default ParticleManager;
/*
var particleSystem = new BABYLON.ParticleSystem("particles", 400, scene);
particleSystem.particleTexture = new BABYLON.Texture("textures/Flare.png", scene);
particleSystem.emitter = pickInfo.pickedPoint;
particleSystem.minSize = 0.1;
particleSystem.maxSize = 0.3;
particleSystem.emitRate = 6000;
particleSystem.targetStopDuration = 1;
particleSystem.minEmitPower = 1;
particleSystem.maxEmitPower = 1;
particleSystem.color1 = new BABYLON.Color4(0.1, 0, 0, 1);
particleSystem.color2 = new BABYLON.Color4(0.1, 0, 0, 1);
particleSystem.gravity = new BABYLON.Vector3(0, -150.81, 0);
particleSystem.disposeOnStop = true;
particleSystem.direction1 = new BABYLON.Vector3(-7, 8, 3);
particleSystem.direction2 = new BABYLON.Vector3(7, 8, -3);
particleSystem.start()
*/