I
I
IliaNeverov2020-06-21 20:07:30
JavaScript
IliaNeverov, 2020-06-21 20:07:30

Is it possible to make a certain function be called on a click on the mash?

There is a 3D model in canvas. Is it possible to make it so that by clicking on this 3D model or on the area in which it is located, a certain function is called?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
W
WapSter, 2020-06-21
@IliaNeverov

You hang a click event on the entire canvas, get the cursor coordinates from the event, and under the given conditions, run the desired function.

S
Seanyr, 2020-06-21
@Seanyr

You need to attach an event handler to this element:

function handler() {
 ... ваша функция
}
elem.addEventListener( "click" , handler);

A
Arthur Belan, 2020-06-21
@Belartale

Good guide to events!
https://developer.mozilla.org/ru/docs/Web/Events
Click https://developer.mozilla.org/en-US/docs/Web/API/E...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question