From 7ca4c95d4ab0112dde10752862de710da828ff5a Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Thu, 16 Oct 2014 21:03:40 -0700 Subject: [PATCH] more Particles to Entities migration --- examples/flockingBirds.js | 15 ++++++++------- examples/fountain.js | 14 ++++++++------ 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/examples/flockingBirds.js b/examples/flockingBirds.js index 0eb348b7b9..92a7b75f52 100644 --- a/examples/flockingBirds.js +++ b/examples/flockingBirds.js @@ -24,7 +24,7 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -var birdsInFlock = 40; +var birdsInFlock = 20; var birdLifetime = 60; // 2 minutes var count=0; // iterations @@ -60,7 +60,7 @@ var flockStartPosition = MyAvatar.position; var flockStartVelocity = { x: 0, y: 0, z: 0}; var flockStartThrust = { x: 0, y: 0, z: 0}; // slightly upward against gravity var INITIAL_XY_VELOCITY_SCALE = 2; -var birdRadius = 0.0925; +var birdRadius = 0.2; var baseBirdColor = { red: 0, green: 255, blue: 255 }; var glidingColor = { red: 255, green: 0, blue: 0 }; var thrustUpwardColor = { red: 0, green: 255, blue: 0 }; @@ -153,12 +153,13 @@ function createBirds() { } else { velocity = { x: 0, y: 0, z: 0}; } - birds[i].particle = Particles.addParticle({ + birds[i].particle = Entities.addEntity({ + type: "Sphere", position: position, velocity: velocity, gravity: flockGravity, damping: 0, - radius: birdRadius, + dimensions: { x: birdRadius, y: birdRadius, z: birdRadius}, color: baseBirdColor, lifetime: birdLifetime }); @@ -179,10 +180,10 @@ function updateBirds(deltaTime) { // identifyParticle() will check to see that the particle handle we have is in sync with the domain/server // context. If the handle is for a created particle that now has a known ID it will be updated to be a // handle with a known ID. - birds[i].particle = Particles.identifyParticle(birds[i].particle); + birds[i].particle = Entities.identifyEntity(birds[i].particle); if (birds[i].particle.isKnownID) { - birds[i].properties = Particles.getParticleProperties(birds[i].particle); + birds[i].properties = Entities.getEntityProperties(birds[i].particle); if (birds[i].properties.isKnownID) { knownBirds++; averageVelocity = Vec3.sum(averageVelocity, birds[i].properties.velocity); @@ -455,7 +456,7 @@ function updateBirds(deltaTime) { Vec3.print("birds["+i+"].newVelocity=", newVelocity); } - birds[i].particle = Particles.editParticle(birds[i].particle,{ velocity: newVelocity, color: color }); + birds[i].particle = Entities.editEntity(birds[i].particle,{ velocity: newVelocity, color: color }); } } diff --git a/examples/fountain.js b/examples/fountain.js index ab1b82cb76..aea53fb405 100644 --- a/examples/fountain.js +++ b/examples/fountain.js @@ -48,13 +48,15 @@ function vInterpolate(a, b, fraction) { var position = { x: 5.0, y: 0.6, z: 5.0 }; Voxels.setVoxel(position.x, 0, position.z, 0.5, 0, 0, 255); -var totalParticles = 0; +var totalEntities = 0; function makeFountain(deltaTime) { if (Math.random() < 0.10) { - //print("Made particle!\n"); + //print("Made entity!\n"); + var radius = (0.02 + (Math.random() * 0.05)); var properties = { + type: "Sphere", position: position, - radius: (0.02 + (Math.random() * 0.05)), + dimensions: { x: radius, y: radius, z: radius}, color: { red: 0, green: 0, blue: 128 }, velocity: { x: (Math.random() * 1.0 - 0.5), y: (1.0 + (Math.random() * 2.0)), @@ -64,10 +66,10 @@ function makeFountain(deltaTime) { lifetime: 1 } - Particles.addParticle(properties); - totalParticles++; + Entities.addEntity(properties); + totalEntities++; } - if (totalParticles > 100) { + if (totalEntities > 100) { Script.stop(); } }