Skip to content

Commit

Permalink
Handle invalid initial box position.
Browse files Browse the repository at this point in the history
  • Loading branch information
na9da committed Sep 5, 2023
1 parent 35de3ed commit fb7be45
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions lib/ModelMixins/ClippingMixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,14 +186,21 @@ function ClippingMixin<T extends AbstractConstructor<BaseType>>(Base: T) {
const cartographic = Cartographic.fromCartesian(
Matrix4.getTranslation(clippingPlanesOriginMatrix, new Cartesian3())
);
cartographic.height = dimensions.z / 2;
position = Cartographic.toCartesian(
cartographic,
cesium.scene.globe.ellipsoid,
new Cartesian3()
);
// If the translation is at the center of the ellipsoid then this cartographic could be undefined.
// Although it is not reflected in the typescript type.
if (cartographic) {
cartographic.height = dimensions.z / 2;
position = Cartographic.toCartesian(
cartographic,
cesium.scene.globe.ellipsoid,
new Cartesian3()
);
}
}

// Nothing we can do - assign to zero
position ??= Cartesian3.ZERO.clone();

let hpr: HeadingPitchRoll | undefined;
if (
this.clippingBox.rotation.heading !== undefined &&
Expand Down

0 comments on commit fb7be45

Please sign in to comment.