Update: CC - SnailRunner - Before Render (94xi7aitax.js) 369 bytes modified
parent
fffbed7360
commit
e97b66e18f
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue