After updating the Cesium library in my Vue project, I encountered some errors.
This is the code snippet:
camera.setView({
destination,
orientation: { heading, pitch }
})
The error message reads:
Type '{ heading: number; pitch: number; }' is not assignable to type 'HeadingPitchRollValues | DirectionUp | undefined'.
Property 'roll' is missing in type '{ heading: number; pitch: number; }' but required in type 'HeadingPitchRollValues'.
The function signature is as follows:
setView(options: {
destination?: Cartesian3 | Rectangle;
orientation?: HeadingPitchRollValues | DirectionUp;
endTransform?: Matrix4;
convert?: boolean;
}): void;
export type HeadingPitchRollValues = {
heading: number;
pitch: number;
roll: number;
};
However, the function can work without the 'roll' attribute:
// JavaScript source code snippet that handles default values for heading, pitch, and roll
scratchHpr.heading = defaultValue(orientation.heading, 0.0);
scratchHpr.pitch = defaultValue(orientation.pitch, -CesiumMath.PI_OVER_TWO);
scratchHpr.roll = defaultValue(orientation.roll, 0.0);
To resolve this issue, the type definition should be modified to:
setView(options: {
destination?: Cartesian3 | Rectangle;
orientation?: Partial<HeadingPitchRollValues> | DirectionUp;
endTransform?: Matrix4;
convert?: boolean;
}): void;
I am looking for a way to update this type in my Vue project without resorting to 'patch-package'. Any suggestions?
My repository: https://github.com/Gu-Miao/learn-cesium
SOME UPDATE
The structure of the Cesium library's type definitions:
declare module 'cesium' {
// ...some classes and functions
export class Camera {
// ...some properties
setView(options: {
destination?: Cartesian3 | Rectangle
orientation?: HeadingPitchRollValues | DirectionUp
endTransform?: Matrix4
convert?: boolean
}): void
}
}
Due to numerous classes and functions, the file size is approximately 2MB. My goal is to modify only the type of the 'setView()' function while keeping everything else intact within the library.