1
0
mirror of https://github.com/troisjs/trois.git synced 2024-11-24 04:12:02 +08:00

intersectMode for raycaster

This commit is contained in:
Kevin Levron 2021-04-03 00:59:58 +02:00
parent d11c2fe247
commit 8c5674b48f

View File

@ -9,6 +9,7 @@ export default {
onPointerMove: { type: Function, default: () => {} }, onPointerMove: { type: Function, default: () => {} },
onPointerLeave: { type: Function, default: () => {} }, onPointerLeave: { type: Function, default: () => {} },
onClick: { type: Function, default: () => {} }, onClick: { type: Function, default: () => {} },
intersectMode: { type: String, default: 'move' },
}, },
mounted() { mounted() {
this.rendererComponent.onMounted(() => { this.rendererComponent.onMounted(() => {
@ -23,10 +24,17 @@ export default {
onIntersectClick: this.onClick, onIntersectClick: this.onClick,
}); });
this.pointer.addListeners(); this.pointer.addListeners();
if (this.intersectMode === 'frame') {
this.three.onBeforeRender(this.pointer.intersect);
}
}); });
}, },
unmounted() { unmounted() {
if (this.pointer) this.pointer.removeListeners(); if (this.pointer) {
this.pointer.removeListeners();
this.three.offBeforeRender(this.pointer.intersect);
}
}, },
methods: { methods: {
getIntersectObjects() { getIntersectObjects() {