Three.js:ThreeX没有捕获3d对象的mouseover或mouseout

时间:2015-08-09 23:14:22

标签: javascript three.js blender

我试图在使用ThreeX助手的Three.js环境中将鼠标悬停和鼠标输出事件放在3d obj(Blender场景)上。

出于某些原因,在我的代码中,ThreeX只捕获click,mouseup和mousedown,但不是mouseover或mouseout,也不是我的eventListener。我做错了什么?

鼠标悬停在鞋上,然后点击鞋子以查看点击事件。在鼠标悬停时应该发生什么事情是鼠标悬停在'扩展'按钮。

Here's my code demoand the json model file)。

这是我的js:

 var loader = new THREE.ObjectLoader();  
    loader.load("models/shoe4.json", function (obj) {
        scene.add (obj);
        scene.rotation.y = Math.PI/1;


     solefoam = obj.getObjectByName( "sole-foam", true );
     sole = obj.getObjectByName( "sole", true );


    THREEx.DomEvents.eventNames.forEach(function(eventName){
      if( eventName === 'mousemove' ) return
      domEvents.addEventListener(obj, eventName, function(event){
        var domElement  = document.querySelector('#logs')
        domElement.innerHTML  = event.type + '<br/>' + domElement.innerHTML
      }, false)
    })

    obj.addEventListener('click', function(object3d){ 
      over();
     });

    });   

function over(){
  TweenLite.to(solefoam.position , 1, {y: -2.5, ease:Sine.easeInOut} );
  TweenLite.to(sole.position, 1, {y: -5, ease:Sine.easeInOut} );
}

Here's an example from the threex website of threeX correctly picking up mouseover and mouseout events.

0 个答案:

没有答案