import * as RE from 'rogue-engine'
import * as THREE from 'three'

export default class ScrollObject extends RE.Component {
  @RE.Prop("Vector3") offsetPerTick = new THREE.Vector3(0, 0.01, 0)
  @RE.Prop("Vector3") completedBound = new THREE.Vector3(0, 10, 0)
  /* @RE.Prop("Scene") */ nextScene = "Title Screen"
  awake() {

  }

  start() {
    // this.delta = this.object3d.position.copy().sub(this.completedBound)
  }

  update() {
    this.object3d.position.add(this.offsetPerTick)

    if(this.object3d.position.x >= this.completedBound.x &&
      this.object3d.position.y >= this.completedBound.y &&
      this.object3d.position.z >= this.completedBound.z) {
        RE.App.loadScene(this.nextScene)
      }
  }
}

RE.registerComponent(ScrollObject);
