Examples: Add player controller foot IK - #34136
Conversation
|
|
||
| // renderer | ||
| renderer = new THREE.WebGLRenderer( { antialias: true } ); | ||
| renderer.setPixelRatio( Math.min( window.devicePixelRatio, 2 ) ); |
There was a problem hiding this comment.
Don't force a too high pixel ratio. Just use:
renderer.setPixelRatio( window.devicePixelRatio );| renderer.toneMapping = THREE.ACESFilmicToneMapping; | ||
| renderer.toneMappingExposure = 0.8; | ||
| renderer.shadowMap.enabled = true; | ||
| renderer.shadowMap.type = THREE.PCFShadowMap; |
There was a problem hiding this comment.
Also the shadows don't look good at the moment. Have you tried using VSM instead? Check out how the shadows are configured in: https://threejs.org/examples/games_fps
| camera.position.copy( initialPlayerPosition ).add( new THREE.Vector3( - 1.5, 1.2, 0 ) ); | ||
|
|
||
| // controls | ||
| controls = new MapControls( camera, renderer.domElement ); |
There was a problem hiding this comment.
Please use OrbitControls. Semantically, MapControls does not look like a sensible fit.
There was a problem hiding this comment.
| camLookAtHeightRatio: 0.5, | ||
| enableSpringCamera: true, | ||
| playerModelConfig: { | ||
| url: 'models/gltf/UAL1_Standard/UAL1_Standard.glb', |
There was a problem hiding this comment.
I'm not sure it's ideal to except glTF assets. What if the user wants to load an FBX asset?
I was hoping you could reuse the character model from webgl_loader_fbx instead of adding a new asset.
I think you should change the API and allow to pass a loaded skinned mesh.
There was a problem hiding this comment.
Thanks! I agree that the controller API should accept a preloaded model and animation clips instead of loading glTF internally. I’ll update the API accordingly.
The existing Samba Dancing.fbx only contains one usable animation clip, while this example currently relies on idle, walk, run, and jump animations. Would it be okay if I added the required animations to Samba Dancing.fbx?
There was a problem hiding this comment.
No, it's better to not modify it. How about using the Soldier model instead?
https://threejs.org/examples/webgl_animation_skinning_blending
There was a problem hiding this comment.
Sure! I’ll use the Soldier model instead.
|
As noted in #33095 (comment), I'm not sure about the design of your Addon. You couple third-person controls with collision detection which seems ineffective. What if you need to do collision detections apart from your the third-person controller? What if you don't want to use TBH, I'm not sure your project is scoped well enough that it is ready to be showcased as a Community example. |
Thanks for the feedback. The coupling is intentional because the addon is designed as an opinionated, ready-to-use character controller rather than only an input or movement abstraction.
At the moment, three-mesh-bvh is a required implementation dependency. It can coexist with another spatial index and is used only for the controller’s collision queries. |
|
It is not ideal if you have to maintain separate spatial indices in your app for movement and additional collision detection (like bullet intersections/simulations). You essentially would maintain the same thing twice which is inefficient. As earlier mentioned I think the entire third-person controls mechanisms are highly use case specific and application dependent. To me, it just makes more sense to showcase something more simple like the character movement demo from https://gkjohnson.github.io/three-mesh-bvh/example/bundle/characterMovement.html. That would better fit to games_fps where we do the collision detection with our own E.g. if you want to integrate your player controller into the |
|
My initial implementation also used Octree for collision detection. It worked well in small scenes with relatively few vertices, but I experienced significant frame-rate drops in larger, high-poly scenes. |
|
The problem is that your Addon makes the assumption: "Collision is intrinsic to character movement, so it must be built in." But this is usually not how apps work. We also demonstrate this in our examples. In games_fps and in physics_rapier_character_controller the spatial index or the physics are built on app level and then used for character control. So the approach of your Addon is conceptually no good fit to what we already promote in the demos. And how apps usually work with spatial indices and physics. Apart from the efficiency issue I've mentioned earlier (the need of maintaining more than one spatial index), the Addon also has a correctness problem when the app uses a different type of spatial index than Also, while reviewing your Addons, there are more issues:
Sorry, but given all these findings |
|
Thanks for the feedback. I can extract the foot IK system from three-player-controller and create a minimal demo using three-mesh-bvh for collision detection. Would this approach be feasible? |
|
That sounds indeed better. Yes, I think that's worth giving a try. |
🖼️ E2E screenshot tests✅ All examples render correctly again (run). |
Description
Adds a community example demonstrating player controller foot IK.
The example includes:
Preview
footik.mp4