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.

Question about using OrbitControls for Child Camera

Home Forums General Questions Question about using OrbitControls for Child Camera

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #69408
    aqiang
    Customer

    GroupOrbitControl-Demo

    Hello everyone!

    I have a question about using OrbitControls to manipulate a camera that is a child of a group. When the group is at the origin, everything works fine with the orbit controls. However, when the group is moved away from the origin (you can click on the robot object to move it forward), the orbit control for rotating the scene becomes uncontrollable. I’ve tried various solutions without success, and I suspect it might be necessary to modify the source code of OrbitControls. I’m seeking help from the experts on the forum. The demo has been provided in the link.I hope the orbit of the orbit will always be centered around the robot

    Thank you!

    • This topic was modified 11 months, 4 weeks ago by aqiang.
    Attachments:
    You must be logged in to view attached files.
    #69411
    kdv
    Participant

    Add the TrackTo constraint and it will work like here https://v3d.net/ps8 (use WASD to move).

    Or you can use this puzzle after moving your model. Set the time value to 0.

    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.

    #69412
    qiangge
    Participant

    Great! This is the effect I wanted, thank you, KDV! Is this constraint set up in 3D software beforehand? Because I couldn’t find this part in the JavaScript logic. Could you display the key code or logic for this? My confusion is, if the character and the camera are not grouped, how does the camera follow the character? The target point of the camera can be constrained to the position of the character. Can you please advise on how to set up the camera? Thanks again, KDV.

    #69413
    kdv
    Participant

    s this constraint set up in 3D software beforehand?

    I just added that constraint in Blender.

    The camera is a child for an object you want to move and it moves together with its parent. The TrackTo constraint forces the camera to look at its parent at any moment.

    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.

    #69415
    qiangge
    Participant

    I used 3dsMax, and the principle should be the same as what you described. I tried both methods, and the result is similar to the demo I provided earlier. The camera follows the parent object and always faces the target object, which is correct. However, the issue arises when the target object moves away from the origin—the orbit path becomes strange. Could it be a bug specific to the Max version?

    Attachments:
    You must be logged in to view attached files.
    #69418
    kdv
    Participant

    In fact, your scene’s camera has no controls at all. You add Orbit controls later in visual_logic.js. Why? Can’t you export you scene with Orbit controls chosen in 3Dmax?

    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.

    #69419
    kdv
    Participant

    Could it be a bug specific to the Max version?

    Maybe, have no idea. In Blender it’s much easier to do. I juts re-exported you scene and it works with no problems as expected.
    https://v3d.net/rp1

    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.

    #69420
    qiangge
    Participant

    demo2
    I’ve uploaded a demo that uses the default controls with the method I used last night. Please take a look. Shanks KDV

    • This reply was modified 11 months, 4 weeks ago by qiangge.
    • This reply was modified 11 months, 4 weeks ago by qiangge.
    • This reply was modified 11 months, 4 weeks ago by qiangge.
    Attachments:
    You must be logged in to view attached files.
    #69426
    qiangge
    Participant

    Yes, your Blender export is correct. I had suspected an issue with the matrix transformation in the update function of OrbitControls. if (i.targetObj.updateWorldMatrix(!0, !1).

    I hope someone can verify whether this is indeed a bug that exists only in the Max version.

    #69427
    qiangge
    Participant

    hadBugDemo
    Posts lost, resend the demo.

    • This reply was modified 11 months, 4 weeks ago by qiangge.
    #69429
    kdv
    Participant

    You have “Camera001.Target” parented to “pepole”. Thus the position of “Camera001.Target” is always (0, 0, 0). This object is an orbit center. app.controls.targetObj shouldn’t have any parent or its parent should be the scene itself. It should have position in the world’s coordinates. Have no idea why in Max it’s exported this way.

    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.

    #69430
    kdv
    Participant

    If you can’t add the constraint in Max you can do it using JS code.

    https://v3d.net/rp1

    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.

    #69433
    qiangge
    Participant

    :good: :good: :good: for KDV,Thank you for your splendid contribution!

    OrbitForMaxChildCam

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