Hi all,
I am currently having a hard time setting the Frustum Geometry orientation to be the same as the Camera Orientation. Here’s a snippet of my code:
const orientation = {
heading: Cesium.Math.Radians(headingDegree),
pitch: Cesium.Math.Radians(pitchDegree),
roll: Cesium.Math.Radians(rollDegree),
}
// Camera
viewer.camera.flyTo({
destination: origin,
orientation,
})
const hpr = Cesium.HeadingPitchRoll.fromDegrees(headingDegree, pitchDegree, rollDegree)
const quaternion = Cesium.Quaternion.fromHeadingPitchRoll(hpr)
// FrustumGeometry
const frustumGeometry = new FrustumOutlineGeometry({
frustum,
origin,
orientation: quaternion
})
``
Here’s a screenshot of the result:
Origin is correct but the Frustum is facing a different direction. How do I set its orientation to be the same as that of the camera given the heading, pitch, roll? I hope someone can help me.
Thank you!
omar
August 23, 2019, 8:22pm
3
You can extract the frustum directly from the camera here:
https://cesiumjs.org/Cesium/Build/Documentation/Camera.html?classFilter=camera#frustum
Is this what you’re passing to the geometry constructor? You might also want to look into the 3D Tiles inspector, which already has a way to visualize the camera frustum:
https://cesiumjs.org/Cesium/Apps/Sandcastle/index.html?src=3D%20Tiles%20Inspector.html&label=All
If you click “Update” and “Freeze frame” and then zoom out you’ll see it. You can see the code that sets this up here:
function updateDebugFrustumPlanes(scene) {
var frameState = scene._frameState;
if (scene.debugShowFrustumPlanes !== scene._debugShowFrustumPlanes) {
if (scene.debugShowFrustumPlanes) {
scene._debugFrustumPlanes = new DebugCameraPrimitive({
camera: scene.camera,
updateOnChange: false
});
} else {
scene._debugFrustumPlanes = scene._debugFrustumPlanes && scene._debugFrustumPlanes.destroy();
}
scene._debugShowFrustumPlanes = scene.debugShowFrustumPlanes;
}
if (defined(scene._debugFrustumPlanes)) {
scene._debugFrustumPlanes.update(frameState);
}
}
Hi Omar,
Sorry for the late reply. Thank you for this one. Though is there a way to edit the debugFrustumPlane color?
Thanks!
omar
October 3, 2019, 6:07pm
5
You might need to modify the default color in the source since it’s a private class:
function DebugCameraPrimitive(options) {
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
//>>includeStart('debug', pragmas.debug);
if (!defined(options.camera)) {
throw new DeveloperError('options.camera is required.');
}
//>>includeEnd('debug');
this._camera = options.camera;
this._color = defaultValue(options.color, Color.CYAN);
this._updateOnChange = defaultValue(options.updateOnChange, true);
/**
* Determines if this primitive will be shown.
*
* @type Boolean
* @default true
*/
this.show = defaultValue(options.show, true);