|
@@ -152,6 +152,7 @@ function init() {
|
|
|
onWindowResize();
|
|
|
window.addEventListener( 'resize', onWindowResize, false );
|
|
|
window.addEventListener( 'mousemove', onMouseMove, false );
|
|
|
+ window.addEventListener( 'click', onMouseClick, false );
|
|
|
|
|
|
// GUI
|
|
|
const gui = new dat.GUI();
|
|
@@ -208,6 +209,29 @@ function onMouseMove( e ) {
|
|
|
|
|
|
}
|
|
|
|
|
|
+function onMouseClick( e ) {
|
|
|
+
|
|
|
+ raycaster.setFromCamera( mouse, params.orthographic ? orthoCamera : camera );
|
|
|
+ raycaster.firstHitOnly = true;
|
|
|
+ const results = raycaster.intersectObject( tiles.group, true );
|
|
|
+ if ( results.length ) {
|
|
|
+
|
|
|
+ const object = results[ 0 ].object;
|
|
|
+ const info = tiles.getTileInformationFromObject( object );
|
|
|
+
|
|
|
+ let str = '';
|
|
|
+ for ( const key in info ) {
|
|
|
+
|
|
|
+ str += `${ key } : ${ info[ key ] }\n`;
|
|
|
+
|
|
|
+ }
|
|
|
+ console.log( str );
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
function updateOrthoCamera() {
|
|
|
|
|
|
orthoCamera.position.copy( camera.position );
|