Skip to content

Commit

Permalink
Examples: Fixed webgl_decals.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrdoob committed Aug 29, 2020
1 parent 9f2226e commit 2b477f0
Showing 1 changed file with 16 additions and 22 deletions.
38 changes: 16 additions & 22 deletions examples/webgl_decals.html
Original file line number Diff line number Diff line change
Expand Up @@ -131,48 +131,42 @@

} );

window.addEventListener( 'mousedown', function () {
window.addEventListener( 'pointerdown', function () {

moved = false;

}, false );

window.addEventListener( 'mouseup', function () {
window.addEventListener( 'pointerup', function ( event ) {

checkIntersection();
if ( ! moved && intersection.intersects ) shoot();
if ( moved === false ) {

} );
checkIntersection( event.clientX, event.clientY );

window.addEventListener( 'mousemove', onTouchMove );
window.addEventListener( 'touchmove', onTouchMove );
if ( intersection.intersects ) shoot();

function onTouchMove( event ) {
}

var x, y;
} );

if ( event.changedTouches ) {
window.addEventListener( 'pointermove', onPointerMove );

x = event.changedTouches[ 0 ].pageX;
y = event.changedTouches[ 0 ].pageY;
function onPointerMove( event ) {

} else {
if ( event.isPrimary ) {

x = event.clientX;
y = event.clientY;
checkIntersection( event.clientX, event.clientY );

}

mouse.x = ( x / window.innerWidth ) * 2 - 1;
mouse.y = - ( y / window.innerHeight ) * 2 + 1;

checkIntersection();

}

function checkIntersection() {
function checkIntersection( x, y ) {

if ( mesh === undefined ) return;

if ( ! mesh ) return;
mouse.x = ( x / window.innerWidth ) * 2 - 1;
mouse.y = - ( y / window.innerHeight ) * 2 + 1;

raycaster.setFromCamera( mouse, camera );
raycaster.intersectObject( mesh, false, intersects );
Expand Down

0 comments on commit 2b477f0

Please sign in to comment.