Skip to content

Conversation

@MuradAles
Copy link

@MuradAles MuradAles commented Nov 26, 2025

Add ThirdPersonControls Camera System

Screenshot 2025-11-27 at 04 46 23

https://raw.githack.com/MuradAles/three.js/feature/pivot-point/examples/misc_controls_thirdperson.html

Description

Implements a new third-person camera control system for three.js, following the patterns established by OrbitControls. The camera follows a target object, rotates around it using spherical coordinates, and includes collision avoidance via raycasting.

This addresses the gap in three.js's camera control ecosystem by providing a game-ready third-person camera system commonly used in action and adventure games.

Features

  • Spherical coordinate-based camera positioning (theta, phi, radius)
  • Smooth camera movement with configurable damping
  • Automatic collision detection and avoidance
  • Target switching with optional smooth transitions
  • Auto-alignment behind moving targets
  • Configurable pivot offset for over-the-shoulder positioning
  • Full touch and pointer event support
  • Orthographic camera support

Files Added

  • examples/jsm/controls/ThirdPersonControls.js - Main control class
  • examples/misc_controls_thirdperson.html - Interactive demonstration scene
  • docs/pages/ThirdPersonControls.html - Complete API documentation
  • examples/screenshots/misc_controls_thirdperson.jpg - Screenshot for examples gallery

Files Modified

  • examples/jsm/Addons.js - Added export for ThirdPersonControls

Testing

  • Tested with PerspectiveCamera and OrthographicCamera
  • Verified collision detection with various geometry types
  • Tested target switching with multiple objects
  • Verified touch and pointer event handling
  • All existing examples continue to work

Implements a new third-person camera control system for three.js, following
the patterns established by OrbitControls. The camera follows a target object,
rotates around it using spherical coordinates, and includes collision avoidance
via raycasting.

Features:
- Spherical coordinate-based camera positioning (theta, phi, radius)
- Smooth camera movement with configurable damping
- Automatic collision detection and avoidance
- Target switching with optional smooth transitions
- Auto-alignment behind moving targets
- Configurable pivot offset for over-the-shoulder positioning
- Full touch and pointer event support
- Orthographic camera support

Files added:
- examples/jsm/controls/ThirdPersonControls.js - Main control class
- examples/misc_controls_thirdperson.html - Interactive demonstration
- docs/pages/ThirdPersonControls.html - Complete API documentation
- examples/screenshots/misc_controls_thirdperson.jpg - Screenshot

Files modified:
- examples/jsm/Addons.js - Added export for ThirdPersonControls
@mrdoob mrdoob added this to the r183 milestone Nov 27, 2025
@Mugen87
Copy link
Collaborator

Mugen87 commented Nov 27, 2025

TBH, I have seriously issues with all these AI generated PRs. And I share the concerns raised in #32370 (comment).

Just because it is easy now to generate code, that does not mean we have to include all this stuff in this repository. The code still needs to be reviewed, understood, supported and maintained. Given the code quality of AI tools, it's irresponsible to blindly use the code. In apps in general and even more in libraries. I just observe that most of my time is now spend in reviewing such (low-quality) PRs and most of them are closed anyway. TBH, this is all SPAM to me since anyone can setup such PRs without even understanding the underlying concepts.

I would prefer if users like @MuradAles file a issue first so it can be discussed if certain features should be added to the repository or not. E.g. there are existing libraries like https://github.com/pmndrs/ecctrl that are an ideal baseline for third-person controls.

@Mugen87
Copy link
Collaborator

Mugen87 commented Nov 27, 2025

Verified collision detection with various geometry types

Doesn't work for me. Pressing space and toggle collision has no effect.

A collision detection should be in general not implemented in a control class.

@mrdoob
Copy link
Owner

mrdoob commented Nov 27, 2025

I'm definitely not enjoying the mindless AI assisted PRs either.

But I feel like there's a chance that some of these people could actually provide value and I'm giving them a chance whenever it feels like they're trying.

Given the code quality of AI tools, it's irresponsible to blindly use the code. In apps in general and even more in libraries.

The code quality I'm getting out of them outperforms many of the contributors we've had over the years. The furnace test was fixed in less than an hour. Many contributors worked on and debated that issue for months/years in the past. Just this month alone I've managed to solve many issues we've not been able to fix for years because we've too much in our plate.

So it's not a problem of the AI tools but a problem of how some humans are using them.

I just observe that most of my time is now spend in reviewing such (low-quality) PRs and most of them are closed anyway. TBH, this is all SPAM to me since anyone can setup such PRs without even understanding the underlying concepts.

I feel like I'll end up writing a Chrome extension that reviews PRs automatically and classifies the PRs by code quality somehow. I'm surprised you haven't looked into that already. The only way to fight AI is with more AI.

I would prefer if users like @MuradAles file a issue first so it can be discussed if certain features should be added to the repository or not.

That's how things were in the past and it was nice. But now things are different and I suspect that the only way to achieve that now would be by making the repo private and screen one by one every person that wants to contribute.

@mrdoob
Copy link
Owner

mrdoob commented Nov 27, 2025

A collision detection should be in general not implemented in a control class.

Agreed. @MuradAles can you ask the AI to remove that feature?

@Mugen87
Copy link
Collaborator

Mugen87 commented Nov 27, 2025

So it's not a problem of the AI tools but a problem of how some humans are using them.

I agree the AI tools are powerful in the right hands. Only because they introduces some downsides, it does not mean to abandon them. I use Gemini quite regular e.g. as an advanced search and it's real help. I don't want to miss it anymore. However, the AI code quality I observe here and elsewhere is still a mixed bag (even when professionals provide proper input for the AI). Yes, sometimes it can be great, other times it's a complete failure. That's why I mean it must be reviewed and undestood.

I'm still reserved by the trend to rely on too much AI. If we start to stop thinking ourselves, we end up with low-quality work overall. AI should be an assistant and not replace the expert. Unfortunately, I see it too often the other way around with serious consequences.

@Mugen87
Copy link
Collaborator

Mugen87 commented Nov 27, 2025

I feel like I'll end up writing a Chrome extension that reviews PRs automatically and classifies the PRs by code quality somehow. I'm surprised you haven't looked into that already. The only way to fight AI is with more AI.

Maybe we should write AI agents for ourselves and stop working altogether?

IMO, too much AI quickly goes in the wrong direction. I understand there are strong speakers for AI in the coding community and the tech industry in general but you also observe a lot of AI-limitations are often ignored by such people. I think a more guided and controlled work with AI is a good middle way that should work out best.

@mrdoob
Copy link
Owner

mrdoob commented Nov 27, 2025

I agree the AI tools are powerful in the right hands. Only because they introduces some downsides, it does not mean to abandon them. I also use Gemini quite regular e.g. as an advanced search. However, the AI code quality I observe here and elsewhere is still a mixed bag. Yes, sometimes it can be great, other times it's a complete failure. That's why I mean it must be reviewed and undestood.

We just need a way to easily detect and nicely dismiss low effort PRs. Until GitHub does it for us 🤞

In the case of this PR, you can see that the person put some effort. We can then discuss what features we want or not.

I used to worry a lot about maintenance but I don't worry so much now. I can learn everything pretty quickly and tweak it to the shape I want.

My current goal is to make it easy for the AI to do Three.js stuff. I feel like it'd be harder for the AI to use ecctrl than to use a simpler class that's part of the examples.

@Mugen87
Copy link
Collaborator

Mugen87 commented Nov 27, 2025

But now things are different and I suspect that the only way to achieve that now would be by making the repo private and screen one by one every person that wants to contribute.

Instead of making the repo private, it could stay public but with limit interaction settings. I've mentioned it elsewhere but I don't find the issue anymore. It's this setting:

image

I wish GitHub would provide us more options for this feature. For example new users are allowed to file issues but not PRs. That should be only possible for know contributors or collaborators. The contributor status should be a thing that we (project owner and collaborators) could explicitly assign (or remove) to users. Like at a forum.

Of course an additional SPAM detection tool from GitHub would also be nice feature. Hopefully, they are working on this.

@mrdoob
Copy link
Owner

mrdoob commented Nov 27, 2025

Screenshot 2025-11-27 at 4 02 56 PM

Lets see if this helps 🤞

@MuradAles
Copy link
Author

MuradAles commented Nov 27, 2025

Hey there, I thought a simple third-person camera with just three parameters would be useful for people who want to quickly preview their character or object without dealing with big libraries. I used Opus 4.5 to speed things up. (Trying to be helpful)
@mrdoob

@Mugen87
Copy link
Collaborator

Mugen87 commented Nov 27, 2025

How are the controls supposed to work on touch devices?

Looking at the code, the module imitates OrbitControls by supporting orbiting and dollying but without any possibilities to move the character around. This is essential for a third-person controls though. ecctrl provides a proper solution for this known from mobile games by implementing a virtual analog stick and buttons.

image

Trying to be helpful

I admit your attitude but the PR hasn't properly been tested and misses many conceptual thoughts. I have often noticed from such AI generated PRs that the OPs don't even check for existing solutions in the repository and the community and are not referring to it once. Besides, I would prefer PRs from developers who actually understand their topics. If not, they should spend time in research and learning the concepts they are trying to implement.

@MuradAles
Copy link
Author

Hey there, I understand the feedback. I was only testing this on desktop, not on touch devices, so I can improve it and make the controls work better across different setups. I just wanted a simple control for users who do not want to download big libraries for basic testing, and I thought this small feature would be helpful. I will update it based on the comments.

@danrossi
Copy link
Contributor

danrossi commented Nov 27, 2025

I don't believe some are being helpful. I'm not sure what the purpose is. but one just copied my PR to redo it in AI within the hour of submitting it. And they forked a tonne of projects within the past few days to create fake PRs so are spammers.

For some things like a hack I had to do for a webkit audio api bug recently not available anywhere but now it is. vibe code won't have a clue. I don't find it useful at all and indexing bad code. There is 6th sense required designing some things and of course the design needs peers to discuss the best placement of something as it might not be the right placement. I had such a discussion with a PR to shaka player recently for adding an append event and figured it out in the end. AI won't be able to do that.

How chatgpt titled and formatted the PR I am taking into account though.

@mrdoob
Copy link
Owner

mrdoob commented Nov 28, 2025

@Mugen87 I''ve just added this workflow that should protect /builds and /docs. Hope it helps 🤞

@Mugen87
Copy link
Collaborator

Mugen87 commented Nov 28, 2025

@mrdoob Love it, thanks! Although the sentence "Please don't modify build files." somewhat became a punchline for me like "Have you tried turning it off and on again?" from the IT Crowd. A part of my inner self is maybe going to miss it^^.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants