CesiumCameraController currently expects the GameObject it's attached to to also have a CesiumGlobeAnchor component. It then creates a CharacterController on this GameObject and uses that controller to move the camera around, with the required CesiumOriginShift keeping the CesiumGeoreference informed.
Now, here's the problem. I have a hierarchy that looks like this:
- CesiumGeoreference
- CesiumGlobeAnchor, CesiumOriginShift
- XROrigin
- Main Camera
XROriginmust be above the camera, as it's the reference point for (0, 0, 0) in the real world. For example, if you start up the app in your chair and then walk across the room, the XROrigin remains at your chair but the Main Camera has translated and rotated along with your head as you moved. Also, the XROriginmust be georeferenced, to maintain its attachment to the real-world space it's representing. Otherwise, if you sit in that same chair and fly across the earth, you'll end up with the origin hundreds of thousands of units away, breaking that spatial connection and running into precision errors to boot. You might see the problem here - we can't have the CesiumGlobeAnchor and CesiumCameraController on the same object.
The CesiumCameraController should treat the parent CesiumGlobeAnchor as the anchor to modify and create the character controller on, rather than assuming it will always be on the same GameObject. This could be accomplished by using GetComponentInParent instead of GetComponent for this._globeAnchor, and creating the CharacterController on the same GameObject as the this._globeAnchor.
CesiumCameraController
currently expects the GameObject it's attached to to also have aCesiumGlobeAnchor
component. It then creates aCharacterController
on this GameObject and uses that controller to move the camera around, with the requiredCesiumOriginShift
keeping theCesiumGeoreference
informed.Now, here's the problem. I have a hierarchy that looks like this:
XROrigin
must be above the camera, as it's the reference point for (0, 0, 0) in the real world. For example, if you start up the app in your chair and then walk across the room, theXROrigin
remains at your chair but theMain Camera
has translated and rotated along with your head as you moved. Also, theXROrigin
must be georeferenced, to maintain its attachment to the real-world space it's representing. Otherwise, if you sit in that same chair and fly across the earth, you'll end up with the origin hundreds of thousands of units away, breaking that spatial connection and running into precision errors to boot. You might see the problem here - we can't have theCesiumGlobeAnchor
andCesiumCameraController
on the same object.The
CesiumCameraController
should treat the parentCesiumGlobeAnchor
as the anchor to modify and create the character controller on, rather than assuming it will always be on the same GameObject. This could be accomplished by usingGetComponentInParent
instead ofGetComponent
forthis._globeAnchor
, and creating theCharacterController
on the same GameObject as thethis._globeAnchor
.