2018-03-09 00:36:40 +01:00
|
|
|
if (!this.entityLoaded) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!this.initialized) {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Meshes
|
|
|
|
*/
|
2018-03-09 02:37:49 +01:00
|
|
|
this.sections = this.entityLoaded.sections;
|
|
|
|
this.cloud = this.entityLoaded.cloud;
|
2018-03-09 00:36:40 +01:00
|
|
|
|
|
|
|
this.time = 0;
|
2018-03-09 02:37:49 +01:00
|
|
|
|
|
|
|
this.speed = 50;
|
2018-03-09 00:36:40 +01:00
|
|
|
|
2018-03-09 02:27:19 +01:00
|
|
|
this.spawnCloud = function() {
|
2018-03-09 02:37:49 +01:00
|
|
|
this.cloud.position.x = -155;
|
2018-03-09 02:27:19 +01:00
|
|
|
this.cloud.position.z = (Math.random() * 10) - 5;
|
|
|
|
this.cloud.updateInstance('position');
|
|
|
|
}
|
2018-03-09 00:36:40 +01:00
|
|
|
|
|
|
|
this.initialized = true;
|
|
|
|
}
|
|
|
|
|
2018-03-09 02:37:49 +01:00
|
|
|
var diff = data.delta * this.speed;
|
2018-03-09 00:36:40 +01:00
|
|
|
|
2018-03-09 02:37:49 +01:00
|
|
|
this.cloud.position.x += diff;
|
2018-03-09 02:27:19 +01:00
|
|
|
this.cloud.updateInstance('position');
|
2018-03-09 00:36:40 +01:00
|
|
|
|
2018-03-09 02:37:49 +01:00
|
|
|
this.sections.map(
|
|
|
|
function(section) {
|
|
|
|
section.left.position.x += diff;
|
|
|
|
section.road.position.x += diff;
|
|
|
|
section.right.position.x += diff;
|
|
|
|
|
2018-03-09 02:41:48 +01:00
|
|
|
if (section.left.position.x > 100) {
|
|
|
|
section.left.position.x -= 200;
|
|
|
|
section.road.position.x -= 200;
|
|
|
|
section.right.position.x -= 200;
|
|
|
|
}
|
|
|
|
|
2018-03-09 02:37:49 +01:00
|
|
|
section.left.updateInstance('position');
|
|
|
|
section.road.updateInstance('position');
|
|
|
|
section.right.updateInstance('position');
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2018-03-09 00:36:40 +01:00
|
|
|
this.time += data.delta;
|
|
|
|
|
|
|
|
if (this.time > 5) {
|
2018-03-09 02:27:19 +01:00
|
|
|
this.spawnCloud();
|
2018-03-09 00:36:40 +01:00
|
|
|
this.time = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//@ sourceURL=beforeRender.js
|