{"id":4480,"date":"2020-08-10T10:56:27","date_gmt":"2020-08-10T09:56:27","guid":{"rendered":"https:\/\/www.utilewebsites.nl\/knowledgebase\/working-example-three-js-onclick-3d-object-mouse-and-ipad-touchscreen-with-threejs-raycaster-javascript-events\/"},"modified":"2023-04-06T06:39:49","modified_gmt":"2023-04-06T05:39:49","slug":"working-example-three-js-onclick-3d-object-mouse-and-ipad-touchscreen-with-threejs-raycaster-javascript-events","status":"publish","type":"wz_knowledgebase","link":"https:\/\/www.utilewebsites.nl\/en\/knowledgebase\/working-example-three-js-onclick-3d-object-mouse-and-ipad-touchscreen-with-threejs-raycaster-javascript-events\/","title":{"rendered":"Working example Three.js onclick 3D object mouse and (ipad) touchscreen (with threejs Raycaster \/ JavaScript Events)"},"content":{"rendered":"\n<p><strong>Question :<\/strong><\/p>\n\n<p>How to click on a 3d object to then trigger a function<\/p>\n\n<p><strong>Solution :<\/strong><\/p>\n\n<p>You can use the script EventsControls.js (from Vildanov Almaz). This can be found here :<\/p>\n\n<p class=\"has-text-color has-vivid-cyan-blue-color\"><a href=\"https:\/\/github.com\/mrdoob\/three.js\/pull\/6058\/files#diff-eeaf107d189d8d1bb4f70a798575d150\">https:\/\/github.com\/mrdoob\/three.js\/pull\/6058\/files#diff-eeaf107d189d8d1bb4f70a798575d150<\/a><\/p>\n\n<h3 class=\"wp-block-heading\"><strong>Does the script also work on a touch screen for example an ipad.<\/strong><\/h3>\n\n<p><strong>Answer :<\/strong><br\/>No by default there can be issues on an ipad. On the one hand with the x,y positions.<\/p>\n\n<p><strong>Solution :<\/strong><br\/>For our projects, we modified the script \" EventsControls.js\" so that it works on an ipad.<\/p>\n\n<p><strong>Sample screenmovie pc&amp;ipad<\/strong><\/p>\n\n<p><\/p>\n\n<figure><iframe loading=\"lazy\" src=\"https:\/\/www.youtube.com\/embed\/_ZECnbUOBzw\" allowfullscreen=\"\" width=\"560\" height=\"315\"><\/iframe><\/figure>\n\n<p><strong>Testing yourself : <\/strong> <\/p>\n\n<p class=\"has-text-color has-vivid-cyan-blue-color\"><a href=\"https:\/\/www.utilewebsites.nl\/example\/clicktouchthreejs\/\">https:\/\/www.utilewebsites.nl\/example\/clicktouchthreejs\/<\/a><\/p>\n\n<p><strong>Source code sample download :<\/strong><\/p>\n\n<p class=\"has-text-color has-vivid-cyan-blue-color\"><a href=\"http:\/\/utilewebsites.nl\/knowlegdebasefiles\/html5\/example-threejs-click-touchscreen.zip\">example-threejs-click-touchscreen.zip<\/a><\/p>\n\n<p class=\"has-text-color has-very-dark-gray-color\"><strong>If node_module for e.g. Vuejs :<\/strong><\/p>\n\n<p class=\"has-text-color has-vivid-cyan-blue-color\"> <a href=\"http:\/\/utilewebsites.nl\/knowlegdebasefiles\/html5\/eventscontrols.zip\">eventscontrols.zip<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Question : How to click on a 3d object to then trigger a function Solution : You can use the script EventsControls.js (from Vildanov Almaz). This can be found here : https:\/\/github.com\/mrdoob\/three.js\/pull\/6058\/files#diff-eeaf107d189d8d1bb4f70a798575d150 Does the script also work on a touch screen for example an ipad. Answer :No by default there can be issues on an ipad. On the one hand with the x,y positions. Solution :For our projects, we modified the script \" EventsControls.js\" so that it works on an ipad. Sample screenmovie pc&amp;ipad Testing yourself : https:\/\/www.utilewebsites.nl\/example\/clicktouchthreejs\/ Source code sample download : example-threejs-click-touchscreen.zip If node_module for e.g. Vuejs :&nbsp;<a href=\"https:\/\/www.utilewebsites.nl\/en\/knowledgebase\/working-example-three-js-onclick-3d-object-mouse-and-ipad-touchscreen-with-threejs-raycaster-javascript-events\/\" class=\"read-more\">Continue Reading<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"wzkb_category":[69],"wzkb_tag":[],"class_list":["post-4480","wz_knowledgebase","type-wz_knowledgebase","status-publish","hentry","wzkb_category-three-js-vue-js"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Working example Three.js onclick 3D object mouse and (ipad) touchscreen (with threejs Raycaster \/ JavaScript Events) - Utilewebsites<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.utilewebsites.nl\/en\/knowledgebase\/working-example-three-js-onclick-3d-object-mouse-and-ipad-touchscreen-with-threejs-raycaster-javascript-events\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Working example Three.js onclick 3D object mouse and (ipad) touchscreen (with threejs Raycaster \/ JavaScript Events) - Utilewebsites\" \/>\n<meta property=\"og:description\" content=\"Question : How to click on a 3d object to then trigger a function Solution : You can use the script EventsControls.js (from Vildanov Almaz). This can be found here : https:\/\/github.com\/mrdoob\/three.js\/pull\/6058\/files#diff-eeaf107d189d8d1bb4f70a798575d150 Does the script also work on a touch screen for example an ipad. Answer :No by default there can be issues on an ipad. On the one hand with the x,y positions. Solution :For our projects, we modified the script &quot; EventsControls.js&quot; so that it works on an ipad. Sample screenmovie pc&amp;ipad Testing yourself : https:\/\/www.utilewebsites.nl\/example\/clicktouchthreejs\/ Source code sample download : example-threejs-click-touchscreen.zip If node_module for e.g. Vuejs :&nbsp;Continue Reading\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.utilewebsites.nl\/en\/knowledgebase\/working-example-three-js-onclick-3d-object-mouse-and-ipad-touchscreen-with-threejs-raycaster-javascript-events\/\" \/>\n<meta property=\"og:site_name\" content=\"Utilewebsites\" \/>\n<meta property=\"article:modified_time\" content=\"2023-04-06T05:39:49+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.utilewebsites.nl\\\/en\\\/knowledgebase\\\/working-example-three-js-onclick-3d-object-mouse-and-ipad-touchscreen-with-threejs-raycaster-javascript-events\\\/\",\"url\":\"https:\\\/\\\/www.utilewebsites.nl\\\/en\\\/knowledgebase\\\/working-example-three-js-onclick-3d-object-mouse-and-ipad-touchscreen-with-threejs-raycaster-javascript-events\\\/\",\"name\":\"Working example Three.js onclick 3D object mouse and (ipad) touchscreen (with threejs Raycaster \\\/ JavaScript Events) - Utilewebsites\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.utilewebsites.nl\\\/en\\\/#website\"},\"datePublished\":\"2020-08-10T09:56:27+00:00\",\"dateModified\":\"2023-04-06T05:39:49+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.utilewebsites.nl\\\/en\\\/knowledgebase\\\/working-example-three-js-onclick-3d-object-mouse-and-ipad-touchscreen-with-threejs-raycaster-javascript-events\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.utilewebsites.nl\\\/en\\\/knowledgebase\\\/working-example-three-js-onclick-3d-object-mouse-and-ipad-touchscreen-with-threejs-raycaster-javascript-events\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.utilewebsites.nl\\\/en\\\/knowledgebase\\\/working-example-three-js-onclick-3d-object-mouse-and-ipad-touchscreen-with-threejs-raycaster-javascript-events\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.utilewebsites.nl\\\/en\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Knowledge Base\",\"item\":\"https:\\\/\\\/www.utilewebsites.nl\\\/en\\\/knowledgebase\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Working example Three.js onclick 3D object mouse and (ipad) touchscreen (with threejs Raycaster \\\/ JavaScript Events)\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.utilewebsites.nl\\\/en\\\/#website\",\"url\":\"https:\\\/\\\/www.utilewebsites.nl\\\/en\\\/\",\"name\":\"Utilewebsites\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.utilewebsites.nl\\\/en\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.utilewebsites.nl\\\/en\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.utilewebsites.nl\\\/en\\\/#organization\",\"name\":\"Utilewebsites\",\"url\":\"https:\\\/\\\/www.utilewebsites.nl\\\/en\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.utilewebsites.nl\\\/en\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.utilewebsites.nl\\\/wp-content\\\/uploads\\\/2019\\\/08\\\/logo-Utilewebsites-2017.png\",\"contentUrl\":\"https:\\\/\\\/www.utilewebsites.nl\\\/wp-content\\\/uploads\\\/2019\\\/08\\\/logo-Utilewebsites-2017.png\",\"width\":3000,\"height\":593,\"caption\":\"Utilewebsites\"},\"image\":{\"@id\":\"https:\\\/\\\/www.utilewebsites.nl\\\/en\\\/#\\\/schema\\\/logo\\\/image\\\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Working example Three.js onclick 3D object mouse and (ipad) touchscreen (with threejs Raycaster \/ JavaScript Events) - Utilewebsites","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.utilewebsites.nl\/en\/knowledgebase\/working-example-three-js-onclick-3d-object-mouse-and-ipad-touchscreen-with-threejs-raycaster-javascript-events\/","og_locale":"en_US","og_type":"article","og_title":"Working example Three.js onclick 3D object mouse and (ipad) touchscreen (with threejs Raycaster \/ JavaScript Events) - Utilewebsites","og_description":"Question : How to click on a 3d object to then trigger a function Solution : You can use the script EventsControls.js (from Vildanov Almaz). This can be found here : https:\/\/github.com\/mrdoob\/three.js\/pull\/6058\/files#diff-eeaf107d189d8d1bb4f70a798575d150 Does the script also work on a touch screen for example an ipad. Answer :No by default there can be issues on an ipad. On the one hand with the x,y positions. Solution :For our projects, we modified the script \" EventsControls.js\" so that it works on an ipad. Sample screenmovie pc&amp;ipad Testing yourself : https:\/\/www.utilewebsites.nl\/example\/clicktouchthreejs\/ Source code sample download : example-threejs-click-touchscreen.zip If node_module for e.g. Vuejs :&nbsp;Continue Reading","og_url":"https:\/\/www.utilewebsites.nl\/en\/knowledgebase\/working-example-three-js-onclick-3d-object-mouse-and-ipad-touchscreen-with-threejs-raycaster-javascript-events\/","og_site_name":"Utilewebsites","article_modified_time":"2023-04-06T05:39:49+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.utilewebsites.nl\/en\/knowledgebase\/working-example-three-js-onclick-3d-object-mouse-and-ipad-touchscreen-with-threejs-raycaster-javascript-events\/","url":"https:\/\/www.utilewebsites.nl\/en\/knowledgebase\/working-example-three-js-onclick-3d-object-mouse-and-ipad-touchscreen-with-threejs-raycaster-javascript-events\/","name":"Working example Three.js onclick 3D object mouse and (ipad) touchscreen (with threejs Raycaster \/ JavaScript Events) - Utilewebsites","isPartOf":{"@id":"https:\/\/www.utilewebsites.nl\/en\/#website"},"datePublished":"2020-08-10T09:56:27+00:00","dateModified":"2023-04-06T05:39:49+00:00","breadcrumb":{"@id":"https:\/\/www.utilewebsites.nl\/en\/knowledgebase\/working-example-three-js-onclick-3d-object-mouse-and-ipad-touchscreen-with-threejs-raycaster-javascript-events\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.utilewebsites.nl\/en\/knowledgebase\/working-example-three-js-onclick-3d-object-mouse-and-ipad-touchscreen-with-threejs-raycaster-javascript-events\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.utilewebsites.nl\/en\/knowledgebase\/working-example-three-js-onclick-3d-object-mouse-and-ipad-touchscreen-with-threejs-raycaster-javascript-events\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.utilewebsites.nl\/en\/"},{"@type":"ListItem","position":2,"name":"Knowledge Base","item":"https:\/\/www.utilewebsites.nl\/en\/knowledgebase\/"},{"@type":"ListItem","position":3,"name":"Working example Three.js onclick 3D object mouse and (ipad) touchscreen (with threejs Raycaster \/ JavaScript Events)"}]},{"@type":"WebSite","@id":"https:\/\/www.utilewebsites.nl\/en\/#website","url":"https:\/\/www.utilewebsites.nl\/en\/","name":"Utilewebsites","description":"","publisher":{"@id":"https:\/\/www.utilewebsites.nl\/en\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.utilewebsites.nl\/en\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.utilewebsites.nl\/en\/#organization","name":"Utilewebsites","url":"https:\/\/www.utilewebsites.nl\/en\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.utilewebsites.nl\/en\/#\/schema\/logo\/image\/","url":"https:\/\/www.utilewebsites.nl\/wp-content\/uploads\/2019\/08\/logo-Utilewebsites-2017.png","contentUrl":"https:\/\/www.utilewebsites.nl\/wp-content\/uploads\/2019\/08\/logo-Utilewebsites-2017.png","width":3000,"height":593,"caption":"Utilewebsites"},"image":{"@id":"https:\/\/www.utilewebsites.nl\/en\/#\/schema\/logo\/image\/"}}]}},"_links":{"self":[{"href":"https:\/\/www.utilewebsites.nl\/en\/wp-json\/wp\/v2\/wz_knowledgebase\/4480","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.utilewebsites.nl\/en\/wp-json\/wp\/v2\/wz_knowledgebase"}],"about":[{"href":"https:\/\/www.utilewebsites.nl\/en\/wp-json\/wp\/v2\/types\/wz_knowledgebase"}],"author":[{"embeddable":true,"href":"https:\/\/www.utilewebsites.nl\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.utilewebsites.nl\/en\/wp-json\/wp\/v2\/comments?post=4480"}],"version-history":[{"count":1,"href":"https:\/\/www.utilewebsites.nl\/en\/wp-json\/wp\/v2\/wz_knowledgebase\/4480\/revisions"}],"predecessor-version":[{"id":4481,"href":"https:\/\/www.utilewebsites.nl\/en\/wp-json\/wp\/v2\/wz_knowledgebase\/4480\/revisions\/4481"}],"wp:attachment":[{"href":"https:\/\/www.utilewebsites.nl\/en\/wp-json\/wp\/v2\/media?parent=4480"}],"wp:term":[{"taxonomy":"wzkb_category","embeddable":true,"href":"https:\/\/www.utilewebsites.nl\/en\/wp-json\/wp\/v2\/wzkb_category?post=4480"},{"taxonomy":"wzkb_tag","embeddable":true,"href":"https:\/\/www.utilewebsites.nl\/en\/wp-json\/wp\/v2\/wzkb_tag?post=4480"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}