We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.

Selecting a face normal

Home Forums General Questions Selecting a face normal

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #76423
    adamabr
    Customer

    Hi, I wanted to try building a little cube building demo in Verge3D. Basically super simple version of Minecraft where you only can add blocks on top of other blocks.

    I have come up with a way to detect the face I hover over with my mouse cursor and moving a “selection icon” over that face with the correct rotation. However, it seems quite slow and unreliable.

    I use raycasting from the camera to the mouse position. Then I identify the normal of the intersected face and the corresponding object position. After that I move the indicator to the center of the cube and rotate it in the corresponding direction. See image or project files for details.

    Project file: https://www.dropbox.com/t/A5jyDeGtcCb1RbS9

    Does anyone have a suggestion for a better approach?

    Attachments:
    You must be logged in to view attached files.
    #76471
    David Duperron
    Customer

    Hi!
    As it is, you only evaluate your normal once when you “enter” one of your cubes, meaning that if you go from one face to another, WITHOUT exiting your cube (i.e. without triggering the “out” slot) your selected face will not change.
    You have to put something in place to “constantly” evaluate your hovered face while hovering your cube, and update the position of your “selectedFace” object accordingly, and stop it as soon as you are not hovering your objects anymore…

    #76472
    David Duperron
    Customer

    Something like this:

    There is still an issue when hovering a cube while orbiting the camera with this solution that causes a crash.

    Attachments:
    You must be logged in to view attached files.
    #76552
    adamabr
    Customer

    I appreciate the response David! I’ll have to look into this more as I have more time but I am happy I got some input.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.