ScrollObject.re.js 757 B

123456789101112131415161718192021222324252627
  1. import * as RE from 'rogue-engine'
  2. import * as THREE from 'three'
  3. export default class ScrollObject extends RE.Component {
  4. @RE.Prop("Vector3") offsetPerTick = new THREE.Vector3(0, 0.01, 0)
  5. @RE.Prop("Vector3") completedBound = new THREE.Vector3(0, 10, 0)
  6. /* @RE.Prop("Scene") */ nextScene = "Title Screen"
  7. awake() {
  8. }
  9. start() {
  10. // this.delta = this.object3d.position.copy().sub(this.completedBound)
  11. }
  12. update() {
  13. this.object3d.position.add(this.offsetPerTick)
  14. if(this.object3d.position.x >= this.completedBound.x &&
  15. this.object3d.position.y >= this.completedBound.y &&
  16. this.object3d.position.z >= this.completedBound.z) {
  17. RE.App.loadScene(this.nextScene)
  18. }
  19. }
  20. }
  21. RE.registerComponent(ScrollObject);