Three.js detect click on none transparent pixel of object texture -
i have couple of three.planegeometry texture of human faces png transparent pixels around face.
i using three.raycaster observe objects under mouse pointer, when list of intersects - need know if click on transparent pixel, , if case - move next intersect object.
something this:
var onstagemousedown = function( event ) { event.preventdefault(); // stageel - element contain renderer var vector = new three.vector3( ( event.offsetx / stageel.offsetwidth ) * 2 - 1, - ( event.offsety / stageel.offsetheight ) * 2 + 1, 0.5 ); projector.unprojectvector( vector, photographic camera ); var ray = new three.raycaster( camera.position, vector.sub( camera.position ).normalize() ); // objects - list of meshes var intersects = ray.intersectobjects( objects ); for(var i=0; i<intersects.length; i++) { // don't know how calculate.... var pointistransparentpixelonmeshtexture = ?; if ( pointistransparentpixelonmeshtexture ) continue; alert( "you clicked on "+intersects[i].object.name ); return; } alert( "you clicked no 1 " ); }
any ideas?
thanks.
three.js
No comments:
Post a Comment