1234567891011121314151617181920212223242526 |
- import * as RE from 'rogue-engine'
- import * as THREE from 'three'
- export default class FloatObject extends RE.Component {
- elapsed = 0
- @RE.Prop("Vector3") amplitude = new THREE.Vector3(0, 1, 0)
- @RE.Prop("Vector3") offset = new THREE.Vector3(0, 0, 0)
- @RE.Prop("Vector3") period = new THREE.Vector3(0, 4, 0)
- awake() {
- }
- start() {
- this.elapsed = 0
- }
- update() {
- this.elapsed += RE.Runtime.deltaTime
- this.object3d.position.x = this.amplitude.x * Math.cos(this.period.x * this.elapsed) + this.offset.x
- this.object3d.position.y = this.amplitude.y * Math.sin(this.period.y * this.elapsed) + this.offset.y
- this.object3d.position.z = this.amplitude.z * Math.sin(this.period.z * this.elapsed) + this.offset.z
- }
- }
- RE.registerComponent(FloatObject);
|