From 54c0aeaa03a0bb7765c4cde0b0f8cef344b578d7 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Thu, 9 Apr 2015 18:57:58 -0700 Subject: [PATCH] Work around entities not always getting velocity set at creation --- examples/acScripts/rain.js | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/examples/acScripts/rain.js b/examples/acScripts/rain.js index 6e03219934..fc7333fd65 100644 --- a/examples/acScripts/rain.js +++ b/examples/acScripts/rain.js @@ -25,7 +25,8 @@ var RainSquall = function (properties) { SQUALL_CIRCLE_ROTATION = Quat.fromPitchYawRollDegrees(90, 0, 0), raindropProperties, RAINDROP_MODEL_URL = "https://s3.amazonaws.com/hifi-public/ozan/Polyworld/Sets/sky/tetrahedron_v1-Faceted2.fbx", - raindropTimer; + raindropTimer, + rainDrops = []; function processProperties() { if (!properties.hasOwnProperty("origin")) { @@ -74,13 +75,26 @@ var RainSquall = function (properties) { function createRaindrop() { var angle, radius, - offset; + offset, + drop, + i; + + // HACK: Work around rain drops not always getting velocity set at creation + for (i = 0; i < rainDrops.length; i += 1) { + Entities.editEntity(rainDrops[i], { velocity: raindropProperties.velocity }); + } angle = Math.random() * 360; radius = Math.random() * squallRadius; offset = Vec3.multiplyQbyV(Quat.fromPitchYawRollDegrees(0, angle, 0), { x: 0, y: -0.1, z: radius }); raindropProperties.position = Vec3.sum(squallOrigin, offset); - Entities.addEntity(raindropProperties); + drop = Entities.addEntity(raindropProperties); + + // HACK: Work around rain drops not always getting velocity set at creation + rainDrops.push(drop); + if (rainDrops.length > 5) { + drop = rainDrops.shift(); + } } function setUp() {