From 68874eed964cce5d43d9853dfe7a340d1b4a23b3 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Fri, 18 Sep 2015 11:34:26 -0700 Subject: [PATCH] Update particle scripts --- examples/entityScripts/sprayPaintCan.js | 14 +++++++------- examples/fireworks.js | 11 ++++------- examples/particleDance.js | 10 ++++------ examples/particles.js | 7 +++++-- examples/toys/grenade.js | 8 ++++---- 5 files changed, 24 insertions(+), 26 deletions(-) diff --git a/examples/entityScripts/sprayPaintCan.js b/examples/entityScripts/sprayPaintCan.js index 4407140184..fb90a8f447 100644 --- a/examples/entityScripts/sprayPaintCan.js +++ b/examples/entityScripts/sprayPaintCan.js @@ -83,19 +83,18 @@ lastFrame: 10000, running: true }); + var PI = 3.141593; + var DEG_TO_RAD = PI / 180.0; this.paintStream = Entities.addEntity({ type: "ParticleEffect", animationSettings: animationSettings, position: this.properties.position, textures: "https://raw.githubusercontent.com/ericrius1/SantasLair/santa/assets/smokeparticle.png", - emitVelocity: ZERO_VEC, + emitSpeed: 0, + speedSpread: 0.02, + polarFinish: 2 * DEG_TO_RAD, emitAcceleration: ZERO_VEC, - velocitySpread: { - x: .02, - y: .02, - z: 0.02 - }, emitRate: 100, particleRadius: 0.01, color: { @@ -132,7 +131,8 @@ position = Vec3.sum(position, Vec3.multiply(upVec, TIP_OFFSET_Y)) Entities.editEntity(self.paintStream, { position: position, - emitVelocity: Vec3.multiply(forwardVec, 4) + emitOrientation: forwardVec, + emitSpeed: 4 }); //Now check for an intersection with an entity diff --git a/examples/fireworks.js b/examples/fireworks.js index 621931ee36..3485b1687f 100644 --- a/examples/fireworks.js +++ b/examples/fireworks.js @@ -101,7 +101,6 @@ Rocket = function(point, colorPalette) { this.burst = false; this.emitRate = randInt(80, 120); - this.emitStrength = randInt(5.0, 7.0); this.rocket = Entities.addEntity({ type: "Sphere", @@ -163,6 +162,9 @@ Rocket.prototype.explode = function(position) { }); var colorIndex = 0; + var PI = 3.141593; + var DEG_TO_RAD = PI / 180.0; + for (var i = 0; i < NUM_BURSTS; ++i) { var color = this.colors[colorIndex]; print(JSON.stringify(color)); @@ -172,12 +174,7 @@ Rocket.prototype.explode = function(position) { position: position, textures: 'https://raw.githubusercontent.com/ericrius1/SantasLair/santa/assets/smokeparticle.png', emitRate: this.emitRate, - emitStrength: this.emitStrength, - emitDirection: { - x: Math.pow(-1, i) * randFloat(0.0, 1.4), - y: 1.0, - z: 0.0 - }, + polarFinish: 25 * DEG_TO_RAD, color: color, lifespan: 1.0, visible: true, diff --git a/examples/particleDance.js b/examples/particleDance.js index e920fcfa41..6b1f84bb8e 100644 --- a/examples/particleDance.js +++ b/examples/particleDance.js @@ -6,6 +6,9 @@ var AUDIO_RANGE = 0.5 * RANGE; var DIST_BETWEEN_BURSTS = 1.0; + var PI = 3.141593; + var DEG_TO_RAD = PI / 180.0; + var LOUDNESS_RADIUS_RATIO = 10; var TEXTURE_PATH = 'https://raw.githubusercontent.com/ericrius1/SantasLair/santa/assets/smokeparticle.png'; @@ -86,12 +89,7 @@ position: this.point, textures: TEXTURE_PATH, emitRate: this.emitRate, - emitStrength: this.emitStrength, - emitDirection: { - x: Math.pow(-1, i) * randFloat(0.0, 0.4), - y: 1.0, - z: 0.0 - }, + polarFinish: 25 * DEG_TO_RAD, color: color, lifespan: 1.0, visible: true, diff --git a/examples/particles.js b/examples/particles.js index ad232dd781..def21704d1 100644 --- a/examples/particles.js +++ b/examples/particles.js @@ -35,13 +35,16 @@ firstFrame: 0, lastFrame: 30, loop: true }); + var PI = 3.141593; + var DEG_TO_RAD = PI / 180.0; this.entity = Entities.addEntity({ type: "ParticleEffect", animationSettings: animationSettings, position: spawnPoint, dimensions: {x: 2, y: 2, z: 2}, - emitVelocity: {x: 0, y: 5, z: 0}, - velocitySpread: {x: 2, y: 0, z: 2}, + emitSpeed: 5, + speedSpread: 2, + polarFinish: 30 * DEG_TO_RAD, emitAcceleration: {x: 0, y: -9.8, z: 0}, textures: "https://hifi-public.s3.amazonaws.com/alan/Particles/Particle-Sprite-Smoke-1.png", color: color, diff --git a/examples/toys/grenade.js b/examples/toys/grenade.js index b2dfebb888..c6a9c5bdeb 100644 --- a/examples/toys/grenade.js +++ b/examples/toys/grenade.js @@ -45,6 +45,8 @@ var explodeAnimationSettings = JSON.stringify({ var GRAVITY = -9.8; var TIME_TO_EXPLODE = 2500; var DISTANCE_IN_FRONT_OF_ME = 1.0; +var PI = 3.141593; +var DEG_TO_RAD = PI / 180.0; function makeGrenade() { var position = Vec3.sum(MyAvatar.position, @@ -87,8 +89,7 @@ function update() { position: newProperties.position, textures: 'https://raw.githubusercontent.com/ericrius1/SantasLair/santa/assets/smokeparticle.png', emitRate: 100, - emitStrength: 2.0, - emitDirection: { x: 0.0, y: 1.0, z: 0.0 }, + polarFinish: 25 * DEG_TO_RAD, color: { red: 200, green: 0, blue: 0 }, lifespan: 10.0, visible: true, @@ -145,8 +146,7 @@ function boom() { position: properties.position, textures: 'https://raw.githubusercontent.com/ericrius1/SantasLair/santa/assets/smokeparticle.png', emitRate: 200, - emitStrength: 3.0, - emitDirection: { x: 0.0, y: 1.0, z: 0.0 }, + polarFinish: 25 * DEG_TO_RAD, color: { red: 255, green: 255, blue: 0 }, lifespan: 2.0, visible: true,