Skip to content

threeJs 事件封装 click和hover(移入,移出)

Notifications You must be signed in to change notification settings

AprildreamMI/three-event

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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) => {
        // 移出...
    })

About

threeJs 事件封装 click和hover(移入,移出)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published