2018-03-24 17:16:36 +01:00
|
|
|
if (!this.entityLoaded) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!this.initialized) {
|
2018-03-24 17:29:10 +01:00
|
|
|
|
|
|
|
this.camera = this.entityLoaded.camera;
|
|
|
|
this.buttons = this.entityLoaded.buttons;
|
|
|
|
this.raycaster = this.entityLoaded.raycaster;
|
|
|
|
|
2018-03-24 17:16:36 +01:00
|
|
|
this.initialized = true;
|
|
|
|
}
|
2018-03-24 17:22:36 +01:00
|
|
|
|
2018-03-24 17:24:03 +01:00
|
|
|
var mouse = {
|
|
|
|
x : (data.event.offsetX / data.event.target.width ) * 2 - 1,
|
|
|
|
y : -(data.event.offsetY / data.event.target.height) * 2 + 1
|
|
|
|
}
|
|
|
|
|
2018-03-24 17:35:30 +01:00
|
|
|
this.raycaster.setFromCamera(
|
|
|
|
mouse,
|
|
|
|
this.camera
|
|
|
|
);
|
2018-03-24 17:22:36 +01:00
|
|
|
|
2018-03-24 17:35:30 +01:00
|
|
|
this.raycaster.getIntersectedObjects(this.buttons).map(
|
|
|
|
function(intersect) {
|
2018-03-24 17:58:36 +01:00
|
|
|
|
|
|
|
var imageData = intersect.mesh.materials[0].diffuseMap.image.getPixelData();
|
|
|
|
|
2018-03-24 18:00:36 +01:00
|
|
|
var x = intersect.uv.x * 256;
|
|
|
|
var y = intersect.uv.y * 256;
|
|
|
|
|
|
|
|
|
2018-03-24 17:37:19 +01:00
|
|
|
console.log(intersect.mesh.name);
|
2018-03-24 17:35:30 +01:00
|
|
|
}
|
|
|
|
);
|
2018-03-24 17:15:24 +01:00
|
|
|
//@ sourceURL=mouseDown.js
|