javascript - Event handling for geometries in Three.js? -


I have some types of event handling for geometries / cameras / lights (things that we add to the scene) in three.js I am looking for

I can googled but can not find anything relevant, I rendered a simple field and tried to see the DIV content in firebug, but there is only one canvas, and adding any "onclic" to the canvas From the event for all canvas, it is not just for the hemisphere or light.

Any suggestions?

You need some o things to achieve interactivity

  • Mouse Get a vector for the position
  • Unexpected the mouse vector on the camera basis
  • A ray shot from the camera's position,

    It may be complicated, but the code already exists:

  • p>
      function on documentmousedown (event) {event.preventDefault ( ); Var vector = new three. Vector 3 ((event.clientX / window.innerWidth) * 2 - 1, - (event.clientY / window.innerHeight) * 2 + 1, 0.5); Projector. Inject vector (vector, camera); Var ray = new three Ray (camera.Search, vector.sib (camera.Search). General ()); Var intersects = ray.intersectObjects (objects); If (intersects.length & gt; 0) {intersects [0] .object.material.color.setHex (Math.random () * 0xffffff); Var particle = new three. Part (particle material); Particle.position = intersection [0] .point; Particle.scale.x = particle.scale.y = 8; scene.add (particle); } / * / Parsing the faces for everyone (i in intersection var i) {intersects [i] .face.material [0] .color.sethex (Math.random (* * 0xffffff | 0x80000000); } * /}   

    From the above example, this code comes with the library. In doubt, it is always good to check whether there is an example that resolves the problem.

    canvas_interactive_cubes sample preview

  • Comments

    Popular posts from this blog

    php - PDO bindParam() fatal error -

    logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

    java - Why my included JSP file won't get processed correctly? -