1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- import * as RE from 'rogue-engine';
- import RaycastReceiver from './RaycastReceiver.re';
- import * as THREE from 'three'
- export default class TileRaycastReceiver extends RaycastReceiver {
- @RE.props.vector2() tileSize = new THREE.Vector2(1.0, 1.0)
- isHovered = false
- onMouseOver(intersect) {
- this.isHovered = true
- RE.Runtime.rogueDOMContainer.style.cursor = "pointer"
- }
- onMouseOut(){
- if(this.isHovered) {
- this.isHovered = false
- RE.Runtime.rogueDOMContainer.style.cursor = "default"
- }
- }
- getPosition() {
- return this.object3d.position
- }
- awake() {
- }
- start() {
- }
- update() {
- if(!this.isHovered) {
- return
- }
- if(RE.Input.mouse.getButtonDown(0) || RE.Input.touch.touches.length == 1) {
- let target = RE.App.currentScene.getObjectByName("CameraTarget")
- if(!target) {
- RE.Debug.logWarning("didn't find CameraTarget Object3D")
- return
- }
- target.position.set(this.object3d.position.x, this.object3d.position.y, this.object3d.position.z)
- }
- }
- }
- RE.registerComponent(TileRaycastReceiver);
|