Create a raindrop with a lifetime

This commit is contained in:
David Rowe 2015-04-09 15:51:19 -07:00
parent 55b92f7d1e
commit e4e372b2a3

View file

@ -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
});