From d11c2fe247bf3f1abf5aa9ed9422d8a01b6b4c18 Mon Sep 17 00:00:00 2001 From: Kevin Levron Date: Fri, 2 Apr 2021 23:22:19 +0200 Subject: [PATCH] intersectMode (#35) --- src/core/Renderer.js | 4 ++-- src/core/useThree.js | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/core/Renderer.js b/src/core/Renderer.js index c7716a1..c5adb2f 100644 --- a/src/core/Renderer.js +++ b/src/core/Renderer.js @@ -7,8 +7,8 @@ export default { antialias: Boolean, alpha: Boolean, autoClear: { type: Boolean, default: true }, - usePointer: { type: Boolean, default: false }, orbitCtrl: { type: [Boolean, Object], default: false }, + pointer: { type: [Boolean, Object], default: false }, resize: { type: [Boolean, String], default: false }, shadow: Boolean, width: String, @@ -35,7 +35,7 @@ export default { alpha: this.alpha, autoClear: this.autoClear, orbit_ctrl: this.orbitCtrl, - use_pointer: this.usePointer, + pointer: this.pointer, resize: this.resize, width: this.width, height: this.height, diff --git a/src/core/useThree.js b/src/core/useThree.js index 4deb2fb..e4c4608 100644 --- a/src/core/useThree.js +++ b/src/core/useThree.js @@ -113,6 +113,11 @@ export default function useThree() { obj.pointer = usePointer(pointerConf); if (conf.pointer || intersectObjects.length) { obj.pointer.addListeners(); + if (conf.pointer.intersectMode === 'frame') { + onBeforeRender(() => { + obj.pointer.intersect(); + }); + } } } @@ -156,7 +161,6 @@ export default function useThree() { */ function render() { if (obj.orbitCtrl) obj.orbitCtrl.update(); - // if (obj.pointer) obj.pointer.intersect(); beforeRenderCallbacks.forEach(c => c()); obj.renderer.render(obj.scene, obj.camera); } @@ -166,7 +170,6 @@ export default function useThree() { */ function renderC() { if (obj.orbitCtrl) obj.orbitCtrl.update(); - // if (obj.pointer) obj.pointer.intersect(); beforeRenderCallbacks.forEach(c => c()); obj.composer.render(); }