1.0.2 • Published 2 years ago

three-event v1.0.2

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

three-event

基于three-onEvent,对其有如下修改

  • 解决一些bug
  • 监听传入的renderer.domElement

功能

通过THREE.Raycaster方法官方例子实现Object3D对象的选取

  • click

  • hover

    移入移出

使用方式

例子

  1. 安装

    依赖threeJs

    npm i three-event
  2. 使用

    import ThreeEvent from './onEvent.js'
    
    // 初始化
    const threeOnEvent = new ThreeEvent({
        domElement: renderer.domElement,
        camera: camera
    });
    
    // click
    mesh.on('click', (mesh, event) => {
        // ...
    })
    
    // hover
    mesh.on('hover', (mesh, event) => {
        // 移入...
    }, (mesh, event) => {
        // 移出...
    })