数据可视化 API - Modelstructioninfo #getRoomList 返回空数组 - “设备未映射到房间”

问题描述 投票:0回答:1

如下图所示,我的精灵位于房间的中心。我使用相同的位置作为设备坐标:

enter image description here

const structureInfo =
                    new Autodesk.DataVisualization.Core.ModelStructureInfo(
                      model
                    );

const devices = [
                    {
                      id: "lobby-01",
                      position: {
                        x: -160.19818878173828,
                        y: 23.581119537353516,
                        z: -4.738031387329102,
                      },
                      sensorTypes: [
                        "temperature",
                        "humidity",
                      ], 
                    },
                  ];

const shadingData =
                    await structureInfo.generateSurfaceShadingData(
                      devices
                    );
                  await dataVizExtn.setupSurfaceShading(
                    model,
                    shadingData
                  );
    const sensorColors = [
                    0x0000ff, 0x00ff00, 0xffff00,
                    0xff0000,
                  ];
                  const sensorType =
                    "temperature";
                  dataVizExtn.registerSurfaceShadingColors(
                    sensorType,
                    sensorColors
                  );
                  const getSensorValue = (
                    surfaceShadingPoint,
                    sensorType
                  ) => {
                    // The `SurfaceShadingPoint.id` property matches one of the identifiers passed
                    // to `generateSurfaceShadingData` function. In our case above, this will either
                    // be "cafeteria-entrance-01" or "cafeteria-exit-01".
                    const deviceId =
                      surfaceShadingPoint.id;

                    // Read the sensor data, along with its possible value range
                    let sensorValue =
                      readSensorValue(
                        deviceId,
                        sensorType
                      );
                    const maxSensorValue =
                      getMaxSensorValue(
                        sensorType
                      );
                    const minSensorValue =
                      getMinSensorValue(
                        sensorType
                      );

                    // Normalize sensor value to [0, 1.0]
                    sensorValue =
                      (sensorValue -
                        minSensorValue) /
                      (maxSensorValue -
                        minSensorValue);

                    return clamp(
                      sensorValue,
                      0.0,
                      1.0
                    );
                  };

                  dataVizExtn.renderSurfaceShading(
                    "lobby-01",
                    sensorType,
                    getSensorValue
                  );

                  const rooms =
                    await structureInfo.getRoomList(
                      "Rooms"
                    );
                  console.log(shadingData, rooms);

但是,没有渲染任何热图,我仍然在控制台中收到此消息: enter image description here

我什至使用这些命令检查了房间的节点名称是否与“Rooms”相同:

NOP_VIEWER.model.getInstanceTree().getNodeParentId(19967); NOP_VIEWER.model.getInstanceTree().getNodeName(19966,false);

visualization autodesk-forge autodesk-viewer
1个回答
0
投票

我仔细检查了我使用的节点名称(“房间”)是否正确。我还确保设备放置在房间几何形状内。

最后,我设置了一个 setTimeOut() 回调,以便热图代码可以在 DocumentNode 在 Autodesk.Viewing.Document.load() 方法中加载后几秒钟运行。

最后,这是我的热图渐变: enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.