From e4e372b2a38fbc205157131d03144270800ed3bd Mon Sep 17 00:00:00 2001 From: David Rowe Date: Thu, 9 Apr 2015 15:51:19 -0700 Subject: [PATCH] Create a raindrop with a lifetime --- examples/example/entities/rain.js | 34 +++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/examples/example/entities/rain.js b/examples/example/entities/rain.js index 4cc8827293..a4860a1eac 100644 --- a/examples/example/entities/rain.js +++ b/examples/example/entities/rain.js @@ -13,12 +13,17 @@ var RainSquall = function (properties) { var // Properties origin, radius, + dropSize = { x: 0.1, y: 0.1, z: 0.1 }, + dropLifetime = 60, // Seconds debug = false, // Display origin circle // Other squallCircle, SQUALL_CIRCLE_COLOR = { red: 255, green: 0, blue: 0 }, - SQUALL_CIRCLE_ALPHA = 0.3, - SQUALL_CIRCLE_ROTATION = Quat.fromPitchYawRollDegrees(90, 0, 0); + SQUALL_CIRCLE_ALPHA = 0.5, + 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; function processProperties() { if (!properties.hasOwnProperty("origin")) { @@ -33,9 +38,29 @@ var RainSquall = function (properties) { } radius = properties.radius; + if (properties.hasOwnProperty("dropSize")) { + dropSize = properties.dropSize; + } + + if (properties.hasOwnProperty("dropLifetime")) { + dropLifetime = properties.dropLifetime; + } + if (properties.hasOwnProperty("debug")) { debug = properties.debug; } + + raindropProperties = { + type: "Model", + modelURL: RAINDROP_MODEL_URL, + lifetime: dropLifetime, + dimensions: dropSize + }; + } + + function createRaindrop() { + raindropProperties.position = Vec3.sum(origin, { x: 0, y: -0.1, z: 0 }); + Entities.addEntity(raindropProperties); } function setUp() { @@ -48,9 +73,12 @@ var RainSquall = function (properties) { position: origin, rotation: SQUALL_CIRCLE_ROTATION }); + + raindropTimer = Script.setInterval(createRaindrop, 3000); } function tearDown() { + Script.clearInterval(raindropTimer); Overlays.deleteOverlay(squallCircle); } @@ -65,5 +93,7 @@ var RainSquall = function (properties) { var rainSquall1 = new RainSquall({ origin: { x: 8192, y: 8200, z: 8192 }, radius: 2.5, + dropSize: { x: 0.1, y: 0.1, z: 0.1 }, + dropLifetime: 2, debug: true }); \ No newline at end of file