if (!this.entityLoaded) { return; } if (!this.initialized) { this.camera = this.entityLoaded.camera; this.buttons = this.entityLoaded.buttons; this.raycaster = this.entityLoaded.raycaster; this.canvasHUD = this.entityLoaded.canvasHUD; this.initialized = true; } var mouse = { x : (data.event.offsetX / data.event.target.width ) * 2 - 1, y : -(data.event.offsetY / data.event.target.height) * 2 + 1 } console.log('mouse ' + mouse.x + ', ' + mouse.y); this.raycaster.setFromCamera( mouse, this.camera ); var intersects = this.raycaster.getIntersectedObjects(this.buttons); if (intersects.length === 0) { console.log('nothing'); } intersects.map( function(intersect) { var pixels = intersect.mesh.materials[0].diffuseMap.image.getPixelData(); var image = [[]] var x = 0; var y = 0; var alphas = []; for (i = 0; i < pixels.length; i += 4) { alphas.push(pixels[i + 3]); } var x = Math.round(intersect.uv.x * 256); var y = intersect.uv.y; var y = Math.round(y * 256); /* for (var x = 0; x < 256; x++) { var line = ''; for (var y = 0; y < 256; y++) { line += alphas[(256 * y) + x]; } console.log(line); } */ var pixel = alphas[(256 * y) + x]; if (pixel === 255) { console.log(intersect.mesh.name + ' : ' + pixel); } } ); //@ sourceURL=mouseDown.js