FloorRaycastReceiver.re.ts 838 B

123456789101112131415161718192021222324252627282930313233343536
  1. import * as RE from 'rogue-engine';
  2. import RaycastReceiver from './RaycastReceiver.re';
  3. export default class FloorRaycastReceiver extends RaycastReceiver {
  4. awake() {
  5. }
  6. start() {
  7. }
  8. update() {
  9. }
  10. onMouseOver(intersect):boolean {
  11. let positionOnObject = {x: (intersect.uv.x - 0.5) * intersect.object.geometry.parameters.width, z:-(intersect.uv.y - 0.5) * intersect.object.geometry.parameters.depth}
  12. const targetSelector = RE.App.currentScene.getObjectByName("GridTarget")
  13. if(!targetSelector) {
  14. return true
  15. }
  16. targetSelector.position.setX(Math.floor(positionOnObject.x) + 0.5)
  17. targetSelector.position.setY(0)
  18. targetSelector.position.setZ(Math.floor(positionOnObject.z) + 0.5)
  19. return true
  20. }
  21. onMouseOut():boolean{
  22. return true
  23. }
  24. }
  25. RE.registerComponent(FloorRaycastReceiver);