mirror of
https://github.com/JulianGro/overte.git
synced 2025-08-04 12:46:50 +02:00
exploding fireworks
This commit is contained in:
parent
8b07bd00f8
commit
5520094bac
2 changed files with 76 additions and 15 deletions
|
@ -43,10 +43,10 @@ var keysToAllow = [
|
||||||
'emitSpeed',
|
'emitSpeed',
|
||||||
'speedSpread',
|
'speedSpread',
|
||||||
'emitOrientation',
|
'emitOrientation',
|
||||||
'emitDimensios',
|
'emitDimensions',
|
||||||
'emitRadiusStart',
|
|
||||||
'polarStart',
|
'polarStart',
|
||||||
'polarFinish',
|
'polarFinish',
|
||||||
|
'azimuthStart',
|
||||||
'azimuthFinish',
|
'azimuthFinish',
|
||||||
'emitAcceleration',
|
'emitAcceleration',
|
||||||
'accelerationSpread',
|
'accelerationSpread',
|
||||||
|
|
|
@ -29,9 +29,72 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
shootFirework: function() {
|
shootFirework: function() {
|
||||||
|
var position = Vec3.sum(_this.position, {x: 0, y: 0.5, z: 0});
|
||||||
|
_this.missle = Entities.addEntity({
|
||||||
|
type: "Sphere",
|
||||||
|
position: position,
|
||||||
|
color: {red: 200, green : 10, blue: 200},
|
||||||
|
dimensions: {x: 0.2, y: 0.4, z: 0.2},
|
||||||
|
damping: 0,
|
||||||
|
dynamic: true,
|
||||||
|
velocity: {x: 0.0, y: 0.1, z: 0},
|
||||||
|
gravity: {x: 0, y: 0.7, z: 0}
|
||||||
|
});
|
||||||
|
|
||||||
|
var smokeSettings = {
|
||||||
|
type: "ParticleEffect",
|
||||||
|
position: position,
|
||||||
|
name: "Smoke Trail",
|
||||||
|
maxParticles: 1000,
|
||||||
|
emitRate: 20,
|
||||||
|
emitSpeed: 0,
|
||||||
|
speedSpread: 0,
|
||||||
|
dimensions: {x: 1000, y: 1000, z: 1000},
|
||||||
|
polarStart: 0,
|
||||||
|
polarFinish: 0,
|
||||||
|
azimuthStart: -3.14,
|
||||||
|
azimuthFinish: 3.14,
|
||||||
|
emitAcceleration: {
|
||||||
|
x: 0,
|
||||||
|
y: -0.5,
|
||||||
|
z: 0
|
||||||
|
},
|
||||||
|
accelerationSpread: {
|
||||||
|
x: 0.2,
|
||||||
|
y: 0,
|
||||||
|
z: 0.2
|
||||||
|
},
|
||||||
|
radiusSpread: 0.04,
|
||||||
|
particleRadius: 0.07,
|
||||||
|
radiusStart: 0.07,
|
||||||
|
radiusFinish: 0.07,
|
||||||
|
alpha: 0.7,
|
||||||
|
alphaSpread: 0,
|
||||||
|
alphaStart: 0,
|
||||||
|
alphaFinish: 0,
|
||||||
|
additiveBlending: 0,
|
||||||
|
textures: "https://hifi-public.s3.amazonaws.com/alan/Particles/Particle-Sprite-Smoke-1.png",
|
||||||
|
emitterShouldTrail: true,
|
||||||
|
parentID: _this.missle
|
||||||
|
};
|
||||||
|
|
||||||
|
_this.smoke = Entities.addEntity(smokeSettings);
|
||||||
|
|
||||||
|
|
||||||
|
Script.setTimeout(function() {
|
||||||
|
var explodePosition = Entities.getEntityProperties(_this.missle, "position").position;
|
||||||
|
Entities.deleteEntity(_this.missle);
|
||||||
|
Entities.deleteEntity(_this.smoke);
|
||||||
|
_this.explodeFirework(explodePosition);
|
||||||
|
}, 2500)
|
||||||
|
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
explodeFirework: function(explodePosition) {
|
||||||
var fireworkSettings = {
|
var fireworkSettings = {
|
||||||
name: "fireworks emitter",
|
name: "fireworks emitter",
|
||||||
position: _this.position,
|
position: explodePosition,
|
||||||
type: "ParticleEffect",
|
type: "ParticleEffect",
|
||||||
color: {
|
color: {
|
||||||
red: 205,
|
red: 205,
|
||||||
|
@ -50,12 +113,6 @@
|
||||||
z: 0,
|
z: 0,
|
||||||
w: 0.7
|
w: 0.7
|
||||||
},
|
},
|
||||||
emitDimensions: {
|
|
||||||
x: 0,
|
|
||||||
y: 0,
|
|
||||||
z: 0
|
|
||||||
},
|
|
||||||
emitRadiusStart: 0.5,
|
|
||||||
polarStart: 1,
|
polarStart: 1,
|
||||||
polarFinish: 1.2,
|
polarFinish: 1.2,
|
||||||
azimuthStart: -Math.PI,
|
azimuthStart: -Math.PI,
|
||||||
|
@ -72,8 +129,8 @@
|
||||||
},
|
},
|
||||||
particleRadius: 0.04,
|
particleRadius: 0.04,
|
||||||
radiusSpread: 0,
|
radiusSpread: 0,
|
||||||
radiusStart: 0.14,
|
radiusStart: 0.06,
|
||||||
radiusFinish: 0.14,
|
radiusFinish: 0.05,
|
||||||
colorSpread: {
|
colorSpread: {
|
||||||
red: 0,
|
red: 0,
|
||||||
green: 0,
|
green: 0,
|
||||||
|
@ -92,11 +149,16 @@
|
||||||
alpha: 1,
|
alpha: 1,
|
||||||
alphaSpread: 0,
|
alphaSpread: 0,
|
||||||
alphaStart: 0,
|
alphaStart: 0,
|
||||||
alphaFinish: 1,
|
alphaFinish: 0,
|
||||||
textures: "https://hifi-public.s3.amazonaws.com/alan/Particles/spark_2.png",
|
textures: "https://hifi-public.s3.amazonaws.com/alan/Particles/spark_2.png",
|
||||||
};
|
};
|
||||||
|
|
||||||
_this.firework = Entities.addEntity(fireworkSettings);
|
_this.firework = Entities.addEntity(fireworkSettings);
|
||||||
|
|
||||||
|
Script.setTimeout(function() {
|
||||||
|
Entities.editEntity(_this.firework, {isEmitting: false});
|
||||||
|
}, 1000)
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
preload: function(entityID) {
|
preload: function(entityID) {
|
||||||
|
@ -107,9 +169,8 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
unload: function() {
|
unload: function() {
|
||||||
if (_this.firework) {
|
Entities.deleteEntity(_this.smoke);
|
||||||
Entities.deleteEntity(_this.firework);
|
Entities.deleteEntity(_this.missle);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue