Camera Movement

88 views
Skip to first unread message

aon...@gmail.com

unread,
Sep 7, 2018, 7:35:52 PM9/7/18
to cesium-dev
I'm trying to create the effect of a FPS (first person shooter) game view, where WASD are used to move forward/back/felt/right, and mouse controls where the camera is looking.
I played with the "Camera Tutorial", however that's not the entire effect I'm looking for. Two things I can't figure out:

1. I need the camera to always be a constant height, and not move upwards if the viewer is looking upwards. The current way the Camera Tutorial is set up is forward/back directions moves in the direction of the heading and pitch direction. I only want the camera to move in the heading direction, and ignore the pitch component.
Is that possible?

2. The camera (user) will be walking/exploring through a 3d object (gltf/b3dm) environment, and I need the camera to follow the contour of the 3d object.
How does one set the camera height to always be a certain distance from the mesh beneath it?

Are there any existing examples I can look at to find a resolutions to my questions?

Thank you.

Omar Shehata

unread,
Sep 9, 2018, 11:32:02 AM9/9/18
to cesium-dev
The moveForward will move a camera in the direction it's facing. If you just want to translate the camera's position along a given direction, you can use move instead. You can read the camera's heading/pitch/roll and use what you need to compute this direction.

For the camera height, this might be a bit tricky, because it sounds like the camera will be inside the 3D model. Does the model have a ceiling where you're trying to sample the height?

I think the new pick ray functionality might be what you need. It's not released yet but it's very close. See Gabby's response here: https://groups.google.com/d/msg/cesium-dev/fOwyt5-_XPc/WsZb6jNwBgAJ

aon...@gmail.com

unread,
Sep 9, 2018, 6:16:30 PM9/9/18
to cesium-dev
Thank you for the suggestions Omar.
Using "move" solved my problem.

As for my second point, currently the camera is not inside the model (there's no ceiling), but I'll be working with models with a ceiling very soon.
The functionality in the "pick ray" from Gabby's post is exactly what I'm looking for.
Will the "pick ray" approach work when the object is inside the 3d model?

Thanks!

Omar Shehata

unread,
Sep 10, 2018, 1:27:57 PM9/10/18
to cesium-dev
Yup, that should work just fine. 

Exploring the inside of a 3D model like that in Cesium sounds really cool, what kind of application is this for? I'd definitely love to see it once it comes together!
Reply all
Reply to author
Forward
0 new messages