Results 1 to 2 of 2

Thread: Web buttons & webGL objects

  1. #1
    Junior Member
    Join Date
    Apr 2012
    Posts
    1

    Web buttons & webGL objects

    Hello
    I am a total webgl neophyte who is wondering what is possible.

    I have a 3D cube that I have been able to encode in webgl using the converter below.
    http://doc.instantreality.org/tools/x3d ... converter/

    What I am wondering is if it is possible to define that certain parts of the 3D scene are buttons. For instance, could a certain part of each side of the cube to a button or have some sort of interactivity beyond animation or camera manipulation.

    Any thoughts, examples or solutions are very welcome?
    Many thanks

  2. #2
    Junior Member
    Join Date
    Jul 2011
    Posts
    17

    Re: Web buttons & webGL objects

    There is no features built into WebGL for stuff like that.

    What you need to do, and this can be pretty complicated, is to implement some code of your own to find out what the user clicked at.

    The complicated way would be to do some raytracing and collision detection, but that would require a lot of code.

    The easier version is, when the user clicks somewhere you render your cube (or whole scene) to a buffer, like framebuffer_object, thus not showing it to the user, but instead rendering it to a renderbuffer or texture. And when you do this, you render each surface of the cube with a special color. One side red, other yellow, next blue, green etc.

    When this is done, you extract the pixel from the renderbuffer/texture to the CPU around where the user clicked. If it is red, the user clicked on the first surface etc.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •