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.

Object scale relative to viewport size?

Home Forums Puzzles Object scale relative to viewport size?

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #67837
    David Duperron
    Customer

    Hi all!
    I would like to set an object scale in my scene (a 3D gizmo) relative to the 3D viewport size, so that the object size remains constant whatever the camera zoom level is.
    Anyone had the same need and could point me to the right direction to achieve that??
    Any help will be greatly appreciated!
    Cheers

    David

    #67838
    David Duperron
    Customer

    @kdv77kdv I think I might already have the exact function for that, right?
    function setObjectScale(mesh, factor) {
    right?
    Can I call this function from any other location in my puzzles using the javascript puzzle?

    #67840
    kdv
    Participant

    Can I call this function from any other location in my puzzles using the javascript puzzle?

    It’s a local function not visible in globals. But you may copy its code to use in some other function.

    Puzzles and JS coding. Fast and expensive.

    If you don’t see the meaning in something it primarily means that you just don’t see it but not the absence of the meaning at all.

    #67843
    David Duperron
    Customer

    Ok… and could you give me a hint or two about what I need to change or add to adapt this function to my needs??
    Thanks!

    #67844
    kdv
    Participant

    Hint: read the code carefully.

    Puzzles and JS coding. Fast and expensive.

    If you don’t see the meaning in something it primarily means that you just don’t see it but not the absence of the meaning at all.

    #67846
    David Duperron
    Customer

    Good hints, as usual… ;)
    I quickly identified that this “function within a function” – local function – was not directly accessible, and as suggested copied it in a custom procedure in my puzzles.
    Just had to identify that I needed to properly set the “mesh” using the getObjectByName function and that’s it! :yahoo:
    Thanks again!

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