123456789101112131415161718192021222324252627282930313233343536 |
- import * as RE from 'rogue-engine';
- import RaycastReceiver from './RaycastReceiver.re';
- export default class FloorRaycastReceiver extends RaycastReceiver {
- awake() {
- }
- start() {
- }
- update() {
- }
- onMouseOver(intersect):boolean {
- let positionOnObject = {x: (intersect.uv.x - 0.5) * intersect.object.geometry.parameters.width, z:-(intersect.uv.y - 0.5) * intersect.object.geometry.parameters.depth}
- const targetSelector = RE.App.currentScene.getObjectByName("GridTarget")
- if(!targetSelector) {
- return true
- }
- targetSelector.position.setX(Math.floor(positionOnObject.x) + 0.5)
- targetSelector.position.setY(0)
- targetSelector.position.setZ(Math.floor(positionOnObject.z) + 0.5)
- return true
- }
- onMouseOut():boolean{
- return true
- }
- }
- RE.registerComponent(FloorRaycastReceiver);
|