如何在 CesiumJS 中绘制小​​工具

How to draw a gizmo in CesiumJS

如何在 CesiumJS 应用程序中通过指定位置、方向和最终比例来绘制 Gizmo?

我所说的 gizmo 是指使用 (x,y,z) 向量的 3 轴右手参考系,理想情况下被描述为 (RGB) 值,例如:

我希望我可以通过放置这样的参考框架来描绘任何物体(例如 glTF)的方向,例如,在物体原点的位置(例如使用它的 longitude, latitude and elevation) and following its orientation, as defined by its heading, pitch and roll values which must follow the three given angles in their original order (heading first, pitch second and roll third) starting from the LTP-ENU (0,0,0) convention (x=0=东,y=0=北,z=0=向上)。

检查员不是一个选项。

您可以使用 DebugModelMatrixPrimitive。
这里是 Sandcastle
示例代码

const viewer = new Cesium.Viewer("cesiumContainer");

const position = Cesium.Cartesian3.fromDegrees(-107.0, 40.0, 300000.0);

const redSphere = viewer.entities.add({
    name: "Red sphere with black outline",
    position: position,
    ellipsoid: {
        radii: new Cesium.Cartesian3(300000.0, 300000.0, 300000.0),
        material: Cesium.Color.RED.withAlpha(0.5),
        outline: true,
        outlineColor: Cesium.Color.BLACK,
    },
});

const heading = Cesium.Math.toRadians(10);
const pitch = Cesium.Math.toRadians(50);
const roll = Cesium.Math.toRadians(0);

const hpr = new Cesium.HeadingPitchRoll(heading, pitch, roll);

const frame = Cesium.Transforms.headingPitchRollToFixedFrame(position, hpr);

viewer.scene.primitives.add(new Cesium.DebugModelMatrixPrimitive({
    modelMatrix: frame,
    length: 800000,
    width: 3.0
}));

viewer.zoomTo(viewer.entities);