将 Autodesk Forge 热图映射到房间 - 数据可视化 Api
Map Autodesk Forge heatmaps to room - Data Visualization Api
好的,所以我一直在尝试使用 DataViz api 将一些热图映射到 Revit 房间。我能够从 Revit 获得房间内传感器的 X Y Z,我已经减去 viewer.model.getGlobalOffset()
并设法在这些点上显示一些精灵。我知道这些精灵/点在房间内,但每当我尝试使用相同的点加载热图时,我都会收到 Some devices did not map to a room:
警告并且没有显示热图。
根据 API 文档,当点中没有房间信息时会出现此警告。我错过了什么吗?这是“我的”代码:
async function loadHeatmaps(model){
const dataVizExtn = await viewer.loadExtension("Autodesk.DataVisualization");
// Given a model loaded from Forge
const structureInfo = new Autodesk.DataVisualization.Core.ModelStructureInfo(model);
const devices = [
{
id: "Oficina 6", // An ID to identify this device
name:"Oficina-",
position: { x: 22.475382737884104, y: 7.4884431474006163, z: 3.0 }, // World coordinates of this device
sensorTypes: ["temperature", "humidity"], // The types/properties this device exposes
}
];
var offset = viewer.model.getGlobalOffset();
removeOffset(devices[0],offset)
// Generates `SurfaceShadingData` after assigning each device to a room.
const shadingData = await structureInfo.generateSurfaceShadingData(devices);
console.log(shadingData)
// Use the resulting shading data to generate heatmap from.
await dataVizExtn.setupSurfaceShading(model, shadingData);
// Register color stops for the heatmap. Along with the normalized sensor value
// in the range of [0.0, 1.0], `renderSurfaceShading` will interpolate the final
// heatmap color based on these specified colors.
const sensorColors = [0x0000ff, 0x00ff00, 0xffff00, 0xff0000];
// Set heatmap colors for temperature
const sensorType = "temperature";
dataVizExtn.registerSurfaceShadingColors(sensorType, sensorColors);
// Function that provides sensor value in the range of [0.0, 1.0]
function 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-entrace-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);
}
// This value can also be a room instead of a floor
const floorName = "01 - Entry Level";
dataVizExtn.renderSurfaceShading(floorName, sensorType, getSensorValue);
}
function removeOffset(pos, offset) {
pos.position.x = pos.position.x - offset.x;
pos.position.y = pos.position.y - offset.y;
pos.position.z = pos.position.z - offset.z;
}
我正在 onDocumentLoadSuccess
回调中调用 loadHeatmaps()
函数。
EDIT: It looks like in this particular case it was a problem with floorName
not being set to the right value. Note that this value (first parameter to dataVizExtn.renderSurfaceShading
) should be set either to the name of the room, or to the name of the floor you want to update.
偏移量有点棘手,所以我建议调试该区域,例如:
传感器定义在什么坐标系中?如果它们与建筑模型本身位于同一坐标系中,则不应向它们减去或添加任何偏移量。每当模型的元数据中有一个“全局偏移量”时,这基本上意味着模型衍生服务将模型移动到原点以避免浮点精度问题,然后查看器将在加载时将全局偏移量添加回每个几何体.
尝试使用查看器 API 获取设备应映射到的其中一个房间的边界框,并查看边界框是否实际包含您正在尝试的设备的 XYZ 点传递到 DataViz 扩展中。可以像这样找到任何对象的边界:
function getObjectBounds(model, dbid) {
const tree = model.getInstanceTree();
const frags = model.getFragmentList();
let bounds = new THREE.Box3();
tree.enumNodeFragments(dbid, function (fragid) {
let _bounds = new THREE.Box3();
frags.getWorldBounds(fragid, _bounds);
bounds.union(_bounds);
}, true);
return bounds;
}
我有同样的问题,我的 revit 模型是由 revit 2020 构建的。当我将模型更新到 2022 时,热图可以正确显示在房间上。
好的,所以我一直在尝试使用 DataViz api 将一些热图映射到 Revit 房间。我能够从 Revit 获得房间内传感器的 X Y Z,我已经减去 viewer.model.getGlobalOffset()
并设法在这些点上显示一些精灵。我知道这些精灵/点在房间内,但每当我尝试使用相同的点加载热图时,我都会收到 Some devices did not map to a room:
警告并且没有显示热图。
根据 API 文档,当点中没有房间信息时会出现此警告。我错过了什么吗?这是“我的”代码:
async function loadHeatmaps(model){
const dataVizExtn = await viewer.loadExtension("Autodesk.DataVisualization");
// Given a model loaded from Forge
const structureInfo = new Autodesk.DataVisualization.Core.ModelStructureInfo(model);
const devices = [
{
id: "Oficina 6", // An ID to identify this device
name:"Oficina-",
position: { x: 22.475382737884104, y: 7.4884431474006163, z: 3.0 }, // World coordinates of this device
sensorTypes: ["temperature", "humidity"], // The types/properties this device exposes
}
];
var offset = viewer.model.getGlobalOffset();
removeOffset(devices[0],offset)
// Generates `SurfaceShadingData` after assigning each device to a room.
const shadingData = await structureInfo.generateSurfaceShadingData(devices);
console.log(shadingData)
// Use the resulting shading data to generate heatmap from.
await dataVizExtn.setupSurfaceShading(model, shadingData);
// Register color stops for the heatmap. Along with the normalized sensor value
// in the range of [0.0, 1.0], `renderSurfaceShading` will interpolate the final
// heatmap color based on these specified colors.
const sensorColors = [0x0000ff, 0x00ff00, 0xffff00, 0xff0000];
// Set heatmap colors for temperature
const sensorType = "temperature";
dataVizExtn.registerSurfaceShadingColors(sensorType, sensorColors);
// Function that provides sensor value in the range of [0.0, 1.0]
function 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-entrace-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);
}
// This value can also be a room instead of a floor
const floorName = "01 - Entry Level";
dataVizExtn.renderSurfaceShading(floorName, sensorType, getSensorValue);
}
function removeOffset(pos, offset) {
pos.position.x = pos.position.x - offset.x;
pos.position.y = pos.position.y - offset.y;
pos.position.z = pos.position.z - offset.z;
}
我正在 onDocumentLoadSuccess
回调中调用 loadHeatmaps()
函数。
EDIT: It looks like in this particular case it was a problem with
floorName
not being set to the right value. Note that this value (first parameter todataVizExtn.renderSurfaceShading
) should be set either to the name of the room, or to the name of the floor you want to update.
偏移量有点棘手,所以我建议调试该区域,例如:
传感器定义在什么坐标系中?如果它们与建筑模型本身位于同一坐标系中,则不应向它们减去或添加任何偏移量。每当模型的元数据中有一个“全局偏移量”时,这基本上意味着模型衍生服务将模型移动到原点以避免浮点精度问题,然后查看器将在加载时将全局偏移量添加回每个几何体.
尝试使用查看器 API 获取设备应映射到的其中一个房间的边界框,并查看边界框是否实际包含您正在尝试的设备的 XYZ 点传递到 DataViz 扩展中。可以像这样找到任何对象的边界:
function getObjectBounds(model, dbid) {
const tree = model.getInstanceTree();
const frags = model.getFragmentList();
let bounds = new THREE.Box3();
tree.enumNodeFragments(dbid, function (fragid) {
let _bounds = new THREE.Box3();
frags.getWorldBounds(fragid, _bounds);
bounds.union(_bounds);
}, true);
return bounds;
}
我有同样的问题,我的 revit 模型是由 revit 2020 构建的。当我将模型更新到 2022 时,热图可以正确显示在房间上。