BallRaycastReceiver.re.ts 959 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import * as RE from 'rogue-engine';
  2. import * as THREE from 'three';
  3. import RaycastReceiver from './RaycastReceiver.re';
  4. export default class BallRaycastReceiver extends RaycastReceiver {
  5. originalMaterial: THREE.Material
  6. @RE.props.material() highlightMaterial: THREE.Material;
  7. awake() {
  8. }
  9. start() {
  10. if (!this.highlightMaterial) {
  11. RE.Debug.logError("BallRaycastReceiver has no highlight material set")
  12. }
  13. }
  14. update() {
  15. }
  16. onMouseOver(intersect): boolean {
  17. var currentObj = intersect.object
  18. this.originalMaterial = currentObj.material
  19. if (this.highlightMaterial) {
  20. currentObj.material = this.highlightMaterial
  21. }
  22. RE.Runtime.rogueDOMContainer.style.cursor = "pointer"
  23. return true
  24. }
  25. onMouseOut(): boolean {
  26. (this.object3d as any).material = this.originalMaterial
  27. RE.Runtime.rogueDOMContainer.style.cursor = "default"
  28. return true
  29. }
  30. }
  31. RE.registerComponent(BallRaycastReceiver);