1

我是 Cesium 的新手,我有一个 3D 模型,我将其显示如下:

this.model = scene.primitives.add(Cesium.Model.fromGltf({
  url : './assets/cesium/myPlane.glb',
  modelMatrix : modelMatrix,
  minimumPixelSize : 128,
  maximumScale : 20000
}));
  1. 如何更改模型的“滚动”(它显示颠倒)
  2. 我如何将其“头部”更改为 wame 方向作为 moovingf 方向(如果平面向左移动,则其头部将向左改变角度)

谢谢,
拉里

4

2 回答 2

0

您可以将模型加载为 czml 并设置方向。见下文 :

    var position = Cesium.Cartesian3.fromDegrees(<lon>, <lat>, <alt>);
    var pheading = Cesium.Math.toRadians(<heading>);
    var pitch = Cesium.Math.toRadians(0);
    var roll = Cesium.Math.toRadians(0);
    var hpr = new Cesium.HeadingPitchRoll(pheading, pitch, roll);
    var orientation = new Cesium.ConstantProperty(Cesium.Transforms.headingPitchRollQuaternion(position, hpr));


    var czml = [
        {
            "id": "document",
            "name": "CZML Model",
            "version": "1.0"

        }, {
            "id": id,
            "name": id,

            "position": {
                "cartographicDegrees": [
                    lon, lat, alt
                ]
            },

            "model": {

                "gltf": <gltfpath>



            }

        }
    ];

    var promise = olcesium.nc.viewer.dataSources.add(Cesium.CzmlDataSource.load(czml));
    promise.orientation = orientation;
    promise.then(function (dataSource) {

        for (var i = 0; i < dataSource.entities.values.length; i++) {
            dataSource.entities.values[i].orientation = orientation;
        }

    });
于 2019-01-30T12:36:39.907 回答
0

这听起来像您的模型与 Cesium 的轴约定不正确对齐。你有两个选择:

  1. 在建模软件(blender、3ds max 等)中重新定位您的模型。
  2. 引入一个中间坐标系,在您的应用程序中重新定位模型(尽管需要一些数学知识)。

我的建议是尝试第一个选项,如果这不起作用或者您无法修改模型,请尝试第二个选项。

提示:对于在 Cesium 中调试模型,检查器确实很有帮助,因为您可以显示参考框架。这是您的模型应该是什么样子的沙箱:

检查员:模型轴

希望有帮助!

于 2020-05-09T07:09:39.393 回答