When I use ViewHelper.
it’s not work well with handleClick function, and I find I can fix the problem:
- The original code:
this.handleClick = function ( event ) {
...
mouse.x = ( ( event.clientX - offsetX ) / ( rect.width - offsetX ) ) * 2 - 1;
mouse.y = - ( ( event.clientY - offsetY ) / ( rect.bottom - offsetY ) ) * 2 + 1;
...
}
- After Fix:
this.handleClick = function ( event ) {
...
mouse.x = ( ( event.clientX - offsetX ) / ( rect.right - offsetX ) ) * 2 - 1;
mouse.y = - ( ( event.clientY - offsetY ) / ( rect.bottom - offsetY ) ) * 2 + 1;
...
}
just change
rect.width
torect.right
Is this correct? or how to use ViewHelper?