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

intersectMode (#35)

This commit is contained in:
Kevin Levron 2021-04-02 23:22:19 +02:00
parent 75b34b23c5
commit d11c2fe247
2 changed files with 7 additions and 4 deletions

View File

@ -7,8 +7,8 @@ export default {
antialias: Boolean, antialias: Boolean,
alpha: Boolean, alpha: Boolean,
autoClear: { type: Boolean, default: true }, autoClear: { type: Boolean, default: true },
usePointer: { type: Boolean, default: false },
orbitCtrl: { type: [Boolean, Object], default: false }, orbitCtrl: { type: [Boolean, Object], default: false },
pointer: { type: [Boolean, Object], default: false },
resize: { type: [Boolean, String], default: false }, resize: { type: [Boolean, String], default: false },
shadow: Boolean, shadow: Boolean,
width: String, width: String,
@ -35,7 +35,7 @@ export default {
alpha: this.alpha, alpha: this.alpha,
autoClear: this.autoClear, autoClear: this.autoClear,
orbit_ctrl: this.orbitCtrl, orbit_ctrl: this.orbitCtrl,
use_pointer: this.usePointer, pointer: this.pointer,
resize: this.resize, resize: this.resize,
width: this.width, width: this.width,
height: this.height, height: this.height,

View File

@ -113,6 +113,11 @@ export default function useThree() {
obj.pointer = usePointer(pointerConf); obj.pointer = usePointer(pointerConf);
if (conf.pointer || intersectObjects.length) { if (conf.pointer || intersectObjects.length) {
obj.pointer.addListeners(); obj.pointer.addListeners();
if (conf.pointer.intersectMode === 'frame') {
onBeforeRender(() => {
obj.pointer.intersect();
});
}
} }
} }
@ -156,7 +161,6 @@ export default function useThree() {
*/ */
function render() { function render() {
if (obj.orbitCtrl) obj.orbitCtrl.update(); if (obj.orbitCtrl) obj.orbitCtrl.update();
// if (obj.pointer) obj.pointer.intersect();
beforeRenderCallbacks.forEach(c => c()); beforeRenderCallbacks.forEach(c => c());
obj.renderer.render(obj.scene, obj.camera); obj.renderer.render(obj.scene, obj.camera);
} }
@ -166,7 +170,6 @@ export default function useThree() {
*/ */
function renderC() { function renderC() {
if (obj.orbitCtrl) obj.orbitCtrl.update(); if (obj.orbitCtrl) obj.orbitCtrl.update();
// if (obj.pointer) obj.pointer.intersect();
beforeRenderCallbacks.forEach(c => c()); beforeRenderCallbacks.forEach(c => c());
obj.composer.render(); obj.composer.render();
} }