Autodesk Platform Services热力图无法渲染显示问题求助
Autodesk Platform Services 热力图无法显示问题排查
基于APS IoT扩展示例创建热力图,但热力图无法显示。我对示例代码做了以下修改,请协助排查问题:
修改内容
- 修改
/public/config.js参数:
APS_MODEL_URN = 'URN' APS_MODEL_VIEW = ''
URN取自“转换Revit文件并生成房间与空间信息”教程。
因模型无原生房间信息,在
/public/extensions/SensorHeatmapsExtension.js中手动定义房间。修改
/services/iot.mocked.js中4个传感器的位置,使其位于自定义房间立方体内:
const SENSORS = { 'sensor-1': { name: 'sensor_1-1',// 设备ID description: 'rack_1-1_Basic_sensor.', groupName: 'Level 2', location: {// 世界坐标 x: 70, y: 0, z: -5 }, objectId: 1 }, 'sensor-2': { name: 'sensor_1-2', description: 'rack_1-2_Basic_sensor.', groupName: 'Level 2', location: { x: 70, y: -30, z: -5 }, objectId: 2 }, 'sensor-3': { name: 'sensor_1-3', description: 'rack_1-3_Basic_sensor.', groupName: 'Level 2', location: { x: 75, y: 0, z: -5 }, objectId: 3 }, 'sensor-4': { name: 'sensor_1-4', description: 'rack_1-4_Basic_sensor.', groupName: 'Level 2', location: { x: 75, y: -30, z: -5 }, objectId: 4 } };
- 修改
/public/extensions/SensorHeatmapsExtension.js中的_setupSurfaceShading方法:
async _setupSurfaceShading(model) { if (!this.dataView) { return; } } const DataVizCore = Autodesk.DataVisualization.Core; const structureInfo = new DataVizCore.ModelStructureInfo(model); let levelRoomsMap = await structureInfo.getLevelRoomsMap(); ///////////////手动定义房间/////////////// let room_2 = new DataVizCore.Room( 2222, // 房间DbId "2F_Room",// 房间名称 Box3(new THREE.Vector3(60, -40. -20), new THREE.Vector3(100, 10, 10))// 房间边界 ); for (const [sensorId, sensor] of this.dataView.getSensors().entries()) { if(sensor.objectId >= 1 && sensor.objectId <= 4){ room_2.addDevice(sensor); } } levelRoomsMap.addRoomToLevel("Level 2", room_2); /////////////// 表面着色设置 /////////////// const shadingGroup = new DataVizCore.SurfaceShadingGroup('iot-heatmap'); const rooms = new Map(); for (const [sensorId, sensor] of this.dataView.getSensors().entries()) { if (!sensor.objectId) { continue; } if (!rooms.has(room_2.id)) { const room = new Autodesk.DataVisualization.Core.SurfaceShadingNode(room_2.name, room_2.id); shadingGroup.addChild(room); rooms.set(room_2.id, room); } const room = rooms.get(room_2.id); const types = Array.from(this.dataView.getChannels().keys()); room.addPoint(new Autodesk.DataVisualization.Core.SurfaceShadingPoint(sensorId, sensor.location, types)); } this._surfaceShadingData = new DataVizCore.SurfaceShadingData(); this._surfaceShadingData.addChild(shadingGroup); this._surfaceShadingData.initialize(model); await this._dataVizExt.setupSurfaceShading(model, this._surfaceShadingData); //this._dataVizExt.registerSurfaceShadingColors('temp', [0x00ff00, 0xffff00, 0xff0000]); }
排查方向
- 房间边界笔误:代码中
Box3(new THREE.Vector3(60, -40. -20), ...)里的-40. -20是语法错误,应为-40, -20,该错误会导致房间边界计算异常,直接影响热力图生成。 - 颜色映射未启用:代码注释掉了
registerSurfaceShadingColors,热力图默认可能无颜色映射,导致显示不可见,建议取消注释并确认对应数据通道(如'temp')存在有效传感器数据。 - 传感器数据有效性:检查
this.dataView.getChannels()是否返回有效数据通道,若无对应数值数据传入,热力图无法渲染。 - 房间ID冲突:手动设置的房间DbId(2222)是否与模型中现有元素ID冲突,导致SurfaceShadingNode无法正确绑定房间范围。
- 初始化顺序问题:确认
this._dataVizExt已正确加载,且levelRoomsMap.addRoomToLevel后,SurfaceShadingData的初始化流程无遗漏。
内容的提问来源于stack exchange,提问作者y.hosokawa
相关产品推荐
相关产品推荐

