Re-render object on mouse hover

前端 未结 1 1118
走了就别回头了
走了就别回头了 2021-01-23 00:37

I\'m setting up the threejs editor in electron, and I\'m going to customize it. I\'m trying to implement a \"hover\" object to change the color of faces, then select two faces o

相关标签:
1条回答
  • 2021-01-23 00:57

    Same approach, but working you may find in my fiddle here: http://jsfiddle.net/mmalex/ed0jhpyk/

    Helper classes are used from here: https://github.com/nmalex/three.js-helpers

    var cube = new THREE.Mesh(geometry, material);
    scene.add(cube);
    
    var mouseMove = new RayysMouseMove(mouse, controls);
    
    //let mouseMove "know" which objects should be interactive
    mouseMove.objects.push(cube);
    
    mouseMove.cb.onObjectEnter.push(function(obj) {
        //todo: handle mouse hover, obj here is threejs scene node
    });
    mouseMove.cb.onObjectLeave.push(function(obj) {
        //todo: handle mouse unhover, obj here is threejs scene node
    });
    

    0 讨论(0)
提交回复
热议问题