StarShaderMaterialComponent.re.ts 622 B

1234567891011121314151617181920212223242526272829
  1. import * as RE from 'rogue-engine'
  2. import * as THREE from 'three'
  3. export default class StarShaderMaterialComponent extends RE.Component {
  4. material: THREE.ShaderMaterial
  5. elapsed: number = 0
  6. awake() {
  7. this.material = (this.object3d as any).material as THREE.ShaderMaterial
  8. this.material.uniforms = {
  9. uTime: { type: 'float', value: 0.0 },
  10. } as any
  11. this.elapsed = 0
  12. }
  13. start() {
  14. }
  15. update() {
  16. console.log("tick")
  17. this.elapsed += RE.Runtime.deltaTime
  18. this.material.uniforms["uTime"].value = this.elapsed
  19. }
  20. }
  21. RE.registerComponent(StarShaderMaterialComponent);