50 lines
909 B
JavaScript
50 lines
909 B
JavaScript
if (!this.entityLoaded) {
|
|
return;
|
|
}
|
|
|
|
if (!this.initialized) {
|
|
|
|
/**
|
|
* Meshes
|
|
*/
|
|
this.sections = this.entityLoaded.sections;
|
|
this.cloud = this.entityLoaded.cloud;
|
|
|
|
this.time = 0;
|
|
|
|
this.speed = 50;
|
|
|
|
this.spawnCloud = function() {
|
|
this.cloud.position.x = -155;
|
|
this.cloud.position.z = (Math.random() * 10) - 5;
|
|
this.cloud.updateInstance('position');
|
|
}
|
|
|
|
this.initialized = true;
|
|
}
|
|
|
|
var diff = data.delta * this.speed;
|
|
|
|
this.cloud.position.x += diff;
|
|
this.cloud.updateInstance('position');
|
|
|
|
this.sections.map(
|
|
function(section) {
|
|
section.left.position.x += diff;
|
|
section.road.position.x += diff;
|
|
section.right.position.x += diff;
|
|
|
|
section.left.updateInstance('position');
|
|
section.road.updateInstance('position');
|
|
section.right.updateInstance('position');
|
|
}
|
|
);
|
|
|
|
this.time += data.delta;
|
|
|
|
if (this.time > 5) {
|
|
this.spawnCloud();
|
|
this.time = 0;
|
|
}
|
|
|
|
//@ sourceURL=beforeRender.js
|