Open hayden2114 opened 4 years ago
Hi @haydeng21. I can only advise on how PlayCanvas does things. But for my raycast vehicle project, I just ensure that the camera tracks the vehicle after the simulation has stepped. In PlayCanvas, you do that by updating the camera in a postUpdate
function instead of the vanilla update
function. Otherwise, yep, you get jitters. Maybe a similar solution works for you.
Thanks for replying @willeastcott! In the actual project we're using aframe-physics-system with the ammo.js driver. The vehicle updates in step and I tried hooking the camera into the afterStep call in the physics system but unfortunately there was no noticeable difference.
@haydeng21 maybe make a codesandbox from your example and post it in the aframe-physics-system Issue Tracker
Hey @arpu! I have submitted an issue on the aframe-physics-system repo (https://github.com/donmccurdy/aframe-physics-system/issues/153#issue-642045495)
Hi haydeng21, can you share a working sample so I can look at it and attempt to figure out what is causing the jitter?
It looks like what you shared before is no longer operational ( https://loving-franklin-009677.netlify.app/ ) is that because you solved the issue?
I solved or at least patched the issue by setting the fixedTimeStep to 0.005. The scene was still lagging and jittering on some devices, which seemed to be caused by a separate issue that was fixed by reducing texture count + sizes and adding a ceiling to the fps at 72.
With that being said, the jitter issues will still occur when the fixedTimeStep is set back to it's default, which I believe is 0.016. But in this case the 0.005 value is the solution I needed!
I will go ahead and close the issue for now. By the way have you seen how to improve page performance by using web workers in javascript? "3D World Generation #7: Speeding it up via Threading (JavaScript Web Workers & Three.js)" If you are not already using workers for multi-threading it might reduce your lag & jitter on multi-core devices. https://www.youtube.com/watch?v=a1L7k35EHIc&ab_channel=SimonDev (I meant I will close the issue on the Aframe Physics page, not here)
I've never seen that before, thanks for sharing the knowledge!
Hi, I came across this and thought it might help
https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine
I think you should also instantiate scene
after await Ammo()
is complete.
I have also encountered this issue. I tried using getMotionState().getWorldTransform to get the vehicle's transformation and update it to the graphical object, which solved the problem partly. However, it seems that the rigid body of the vehicle still jitters, which prevents me from attaching cloth or soft body physics to the vehicle stably.
Hey Alon -
I've setup a simple test scene with a btRaycastVehicle and a camera that follows the vehicle around (follow_board). The issue is that the follow_board component creates a visual jitter on the chassis of the vehicle.
I'm wondering if you have any insight on how to remedy this issue as it results in an unpleasant experience and the experience I'm building relies upon a chase camera. One semi-solution I've found is to drop the fixedTimeStep to 0.005 or lower but it doesn't solve it on all devices. I've also tested multiple different implementations of the chase camera but none have solved it.
Here's a link to the test scene: https://loving-franklin-009677.netlify.app/. Control the vehicle with wasd. There's also a button to toggle the follow_board component so you can see that it's the main reason for the jitters.
This is built in a-frame and is using your most recent build of ammo.js. Here's the two components of importance:
Thanks in advance for any help or guidance you can offer! Please let me know if you'd like me to provide other code or info.
All the best, Hayden Greer