mirror of
https://github.com/troisjs/trois.git
synced 2024-11-24 04:12:02 +08:00
Snapshot
This commit is contained in:
parent
18b425ff50
commit
aa0bb91949
13
src/core/README.md
Normal file
13
src/core/README.md
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
Changelog:
|
||||||
|
|
||||||
|
### Raycaster component
|
||||||
|
|
||||||
|
|
||||||
|
### Deprecations
|
||||||
|
|
||||||
|
* `mouseMove`, `mouseRaycast`, and `mouseOver` are all no longer used on the renderer.
|
||||||
|
* `usePointer` on the `Renderer` is `true` by default. Switch to `false` to prevent mouse event handling on the renderer element. Example:
|
||||||
|
```html
|
||||||
|
<!-- Do not listen to mousemove events - marginal performance improvement -->
|
||||||
|
<Renderer :use-pointer="false">
|
||||||
|
```
|
@ -23,7 +23,7 @@ export default function useThree() {
|
|||||||
// mouse_raycast: false,
|
// mouse_raycast: false,
|
||||||
// mouse_over: false,
|
// mouse_over: false,
|
||||||
use_pointer: true,
|
use_pointer: true,
|
||||||
click: false,
|
// click: false,
|
||||||
resize: true,
|
resize: true,
|
||||||
width: 0,
|
width: 0,
|
||||||
height: 0,
|
height: 0,
|
||||||
@ -114,7 +114,7 @@ export default function useThree() {
|
|||||||
// conf.mouse_move = conf.mouse_move || conf.mouse_over;
|
// conf.mouse_move = conf.mouse_move || conf.mouse_over;
|
||||||
if (conf.use_pointer) {
|
if (conf.use_pointer) {
|
||||||
if (conf.use_pointer === true) {
|
if (conf.use_pointer === true) {
|
||||||
// use renderer as mousemove by default
|
// use renderer element as mousemove by default
|
||||||
obj.mouse_move_element = obj.renderer.domElement;
|
obj.mouse_move_element = obj.renderer.domElement;
|
||||||
} else {
|
} else {
|
||||||
// use custom element as mousemove element
|
// use custom element as mousemove element
|
||||||
@ -125,9 +125,9 @@ export default function useThree() {
|
|||||||
// TODO: touch
|
// TODO: touch
|
||||||
}
|
}
|
||||||
|
|
||||||
if (conf.click) {
|
// if (conf.click) {
|
||||||
obj.renderer.domElement.addEventListener('click', onClick);
|
// obj.renderer.domElement.addEventListener('click', onClick);
|
||||||
}
|
// }
|
||||||
|
|
||||||
afterInitCallbacks.forEach(c => c());
|
afterInitCallbacks.forEach(c => c());
|
||||||
|
|
||||||
@ -216,7 +216,8 @@ export default function useThree() {
|
|||||||
obj.mouse_move_element.removeEventListener('mousemove', onMousemove);
|
obj.mouse_move_element.removeEventListener('mousemove', onMousemove);
|
||||||
obj.mouse_move_element.removeEventListener('mouseleave', onMouseleave);
|
obj.mouse_move_element.removeEventListener('mouseleave', onMouseleave);
|
||||||
}
|
}
|
||||||
obj.renderer.domElement.removeEventListener('click', onClick);
|
// obj.renderer.domElement.removeEventListener('click', onClick);
|
||||||
|
// TODO: touch
|
||||||
if (obj.orbitCtrl) obj.orbitCtrl.dispose();
|
if (obj.orbitCtrl) obj.orbitCtrl.dispose();
|
||||||
this.renderer.dispose();
|
this.renderer.dispose();
|
||||||
}
|
}
|
||||||
@ -232,15 +233,15 @@ export default function useThree() {
|
|||||||
/**
|
/**
|
||||||
* click listener
|
* click listener
|
||||||
*/
|
*/
|
||||||
function onClick(e) {
|
// function onClick(e) {
|
||||||
updateMouse(e);
|
// updateMouse(e);
|
||||||
raycaster.setFromCamera(mouse, obj.camera);
|
// raycaster.setFromCamera(mouse, obj.camera);
|
||||||
const objects = raycaster.intersectObjects(intersectObjects);
|
// const objects = raycaster.intersectObjects(intersectObjects);
|
||||||
for (let i = 0; i < objects.length; i++) {
|
// for (let i = 0; i < objects.length; i++) {
|
||||||
const o = objects[i].object;
|
// const o = objects[i].object;
|
||||||
if (o.onClick) o.onClick(e);
|
// if (o.onClick) o.onClick(e);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* mousemove listener
|
* mousemove listener
|
||||||
|
Loading…
Reference in New Issue
Block a user