Update: CC - SnailRunner - Before Render (94xi7aitax.js) 369 bytes modified

beta.r3js.org
-=yb4f310 2018-03-09 03:26:41 +01:00
parent fffbed7360
commit e97b66e18f
1 changed files with 28 additions and 2 deletions

View File

@ -16,10 +16,17 @@ if (!this.initialized) {
this.speed = 15;
this.clouds = [];
this.spawnCloud = function() {
var cloud = this.cloud.clone();
this.cloud.position.x = -155;
this.cloud.position.z = (Math.random() * 10) - 5;
this.cloud.updateInstance('position');
this.clouds.push(cloud);
}
this.initialized = true;
@ -27,8 +34,27 @@ if (!this.initialized) {
var diff = data.delta * this.speed;
this.cloud.position.x += diff;
this.cloud.updateInstance('position');
var deadClouds = this.clouds.reduce(
function(result, cloud) {
cloud.position.x += diff;
cloud.updateInstance('position');
if (cloud.position.x > 50) {
result.push(cloud);
}
return result;
},
[]
);
deadClouds.map(
function(deadCloud) {
deadCloud.geometry = null;
deadCloud.materials = null;
deadCloud.remove();
}
)
this.sections.map(
function(section) {