Skip to content

Adjusting Orbit auto rotate to realign to camera #526

Discussion options

You must be logged in to vote

Seems one possible solution is here: https://stackoverflow.com/a/42866733

I've implemented it into my code and seems to be working flawlessly with trackball controls even when I use mouse left click to rotate. @vasturiano please let me know if you see any issue with this solution/have any suggestions or solutions.

        rotateTimer.current = setInterval(() => {
            const threeCamera = (fgRef.current?.camera() as PerspectiveCamera)
            const upVec = threeCamera.up.clone()
            const origin = new Vector3(0,0,0)
            threeCamera.parent?.localToWorld(threeCamera.position); // compensate for world coordinate

            threeCamera.position.sub(origin); // remo…

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by mohidmakhdoomi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants