Merge branch 'master' of https://gitea.mjm-staging.developers-homelab.net/BIMS/BIMS
This commit is contained in:
commit
2819434390
@ -256,7 +256,7 @@
|
||||
|
||||
function show3DModel(urn) {
|
||||
launchViewerForHotspot(urn, (viewer, nodeIds) => {
|
||||
|
||||
loadHeatmap();
|
||||
},"[name=forgeViewer]");
|
||||
}
|
||||
|
||||
|
@ -30,8 +30,12 @@
|
||||
var allDeviceRowData = []; //所有設備原始資料
|
||||
var global_emergency_alarm_device_number = [];
|
||||
var zoomToggle = 3;
|
||||
var urn2 = "dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dnNjb2RlX2ZvcmdlX3Rlc3QvQVJDJUU1JTk2JUFFJUU1JUIxJUE0K01FUCVFNSU4NSVBOCVFNiVBMyU5Rl83Rl9ERU1PLm53ZA";
|
||||
$(function () {
|
||||
show3DModel();
|
||||
getHotspotPoint(() => {
|
||||
show3DModel(urn2);
|
||||
});
|
||||
|
||||
initChart();
|
||||
getFloData();
|
||||
})
|
||||
@ -826,9 +830,48 @@
|
||||
}
|
||||
}
|
||||
|
||||
function show3DModel() {
|
||||
launchViewer("dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dnNjb2RlX2ZvcmdlX3Rlc3QvJUUzJTgwJTkwQVJDJUUzJTgwJTkxQjFGXzIwMjJfMTJfMDQubndj", (viewer, nodeIds) => {
|
||||
|
||||
function show3DModel(urn) {
|
||||
launchViewerForHotspot(urn, (viewer, nodeIds) => {
|
||||
loadHeatmapForFloor();
|
||||
});
|
||||
}
|
||||
|
||||
function getHotspotPoint(callback = null) {
|
||||
let url = baseApiUrl + "/api/GetDevForCor";
|
||||
let sendData = {
|
||||
"device_area_tag": pageAct.AreaTag,
|
||||
"device_building_tag": pageAct.buiTag,
|
||||
"device_system_tag": pageAct.sysMainTag,
|
||||
"device_name_tag": pageAct.sysSubTag,
|
||||
"device_floor_tag": pageAct.floTag,
|
||||
};
|
||||
objSendData.Data = sendData;
|
||||
ytAjax = new YourTeam.Ajax(url, objSendData, function (res) {
|
||||
if (!res || res.code != "0000" || !res.data) {
|
||||
|
||||
} else {
|
||||
debugger
|
||||
let myDataList = [];
|
||||
$.each(res.data, (idx, data) => {
|
||||
let item = {};
|
||||
item.position = {};
|
||||
if (item.device_coordinate_3d != null && isJSON(item.device_coordinate_3d)) {
|
||||
item.position = JSON.parse(x.device_coordinate_3d);
|
||||
}
|
||||
$.extend(item, data);
|
||||
myDataList.push(item);
|
||||
})
|
||||
|
||||
console.log("1", myDataList)
|
||||
setHotspotPoint(myDataList);
|
||||
callback ? callback() : "";
|
||||
}
|
||||
}, null, "POST").send();
|
||||
|
||||
}
|
||||
|
||||
function setHotspotPoint(myDataList = []) {
|
||||
console.log(myDataList)
|
||||
getHopspotPoint(myDataList);
|
||||
}
|
||||
</script>
|
@ -32,6 +32,8 @@
|
||||
<button id="12F1oor" onclick="move12Floor()">12 Floor</button>
|
||||
<button id="13F1oor" onclick="moveB1Floor()">B1 Floor</button>
|
||||
<button type="button" class="btn btn-secondary" onclick="openOrCloseLight()">電源</button>
|
||||
<button type="button" class="btn btn-danger" onclick="changeColorHotspot()">變更熱點顏色</button>
|
||||
<button type="button" class="btn btn-dark" onclick="loadHeatMap()">載入熱圖</button>
|
||||
<!--<input id="lightBar" type="range" min="0" max="100" step="5" onchange="changeLightPower()">亮度-->
|
||||
<!-- <input type="range">Main Axis</input> -->
|
||||
</div>
|
||||
@ -192,9 +194,9 @@
|
||||
//launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dnNjb2RlX2ZvcmdlX3Rlc3QvJUUzJTgwJTkwJUU1JThGJUIwJUU1JThDJTk3JUU0JUI4JUFEJUU4JThGJUIxJUU1JUE0JUE3JUU2JUE4JTkzJUUzJTgwJTkxQVJDXzEyMjFfMjIzMC5ud2Q');
|
||||
|
||||
//測試單獨 7樓熱圖 DEMO
|
||||
launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dnNjb2RlX2ZvcmdlX3Rlc3QvJUUzJTgwJTkwQVJDJUUzJTgwJTkxN0ZfREVNT18yMDIyXzEyXzI2Lm53Yw');
|
||||
//launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dnNjb2RlX2ZvcmdlX3Rlc3QvJUUzJTgwJTkwQVJDJUUzJTgwJTkxN0ZfREVNT18yMDIyXzEyXzI2Lm53Yw');
|
||||
|
||||
//測試 方案2 7樓熱圖
|
||||
//測試 方案2 7樓熱圖
|
||||
//launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6LW1vZGVsX3Rlc3QxMTIxLyVFMyU4MCU5MEFSQyVFMyU4MCU5MTdGXzIwMjJfMTJfMjYubndj');
|
||||
|
||||
//測試 方案3 熱圖
|
||||
@ -203,6 +205,13 @@
|
||||
//測試 方案4
|
||||
//launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dnNjb2RlX2ZvcmdlX3Rlc3QvJUU2JTk2JUI5JUU2JUExJTg4NF8yMDIyXzEyXzI2Lm53ZA');
|
||||
|
||||
//12.28 三菱單層樓 + 系統
|
||||
launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dnNjb2RlX2ZvcmdlX3Rlc3QvQVJDJUU1JTk2JUFFJUU1JUIxJUE0K01FUCVFNSU4NSVBOCVFNiVBMyU5Rl83Rl9ERU1PLm53ZA');
|
||||
|
||||
//launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dnNjb2RlX2ZvcmdlX3Rlc3QvJUU2JTk2JUI5JUU2JUExJTg4NF8yMDIyXzEyXzI2Lm53ZA');
|
||||
|
||||
|
||||
|
||||
//launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dnNjb2RlX2ZvcmdlX3Rlc3QvJUUzJTgwJTkwQVJDJUUzJTgwJTkxXzIwMjJfMTJfMTMubndk');//new ARC
|
||||
//launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dnNjb2RlX2ZvcmdlX3Rlc3QvJUUzJTgwJTkwTUVQJUUzJTgwJTkxXzIwMjJfMTJfMTMubndj');//new MEP
|
||||
//launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dnNjb2RlX2ZvcmdlX3Rlc3QvJUUzJTgwJTkwQVJDJUUzJTgwJTkxJUU1JTg1JUE4JUU2JUEzJTlGXzIwMjJfMTJfMTMubndj');//全棟 ARC
|
||||
@ -302,6 +311,13 @@
|
||||
}
|
||||
}
|
||||
|
||||
function changeColorHotspot() {
|
||||
changeColorForHotspot(10);
|
||||
}
|
||||
|
||||
function loadHeatMap() {
|
||||
loadHeatmap();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -478,64 +478,6 @@ function getForgeToken(callback) {
|
||||
//callback("eyJhbGciOiJSUzI1NiIsImtpZCI6IlU3c0dGRldUTzlBekNhSzBqZURRM2dQZXBURVdWN2VhIn0.eyJzY29wZSI6WyJkYXRhOndyaXRlIiwiZGF0YTpyZWFkIiwiYnVja2V0OnJlYWQiLCJidWNrZXQ6dXBkYXRlIiwiYnVja2V0OmNyZWF0ZSJdLCJjbGllbnRfaWQiOiJUQTNocXNGZnpRYk5PVVhLcGxkS1VLU2V3NFNKMjF3NSIsImF1ZCI6Imh0dHBzOi8vYXV0b2Rlc2suY29tL2F1ZC9hand0ZXhwNjAiLCJqdGkiOiJiemxzWE5qWElvZ2R1UjUzTUJkdlhrTTNTT01qeVB1bHJrMmdTVWJudGNTeDg1b01kRG1xejg3Z05jenJkRzhpIiwiZXhwIjoxNjY4MTgzMDM2fQ.VU3qLwTJ9nlXnomKCdk4y5UcgszGEO_zlvE7w5mWWajeBMwKLo-zw7LJEqUEajRksvssppR9SbVsjLSx-vDVc3DRhCo3jYTWKPT1T3wQrlkOSqLeIrAdnKdBDNBWKgrGJt_xcmXc3dZ3XNKf9L_F6Ex808rUlo6cem1mcPpKl1jCBDqKu1mAX7aDtZ65TTQZbGGhbG4HdnET-d1i5w4LunGN11UAHhDUW3n0SWWIBL27PiiUQONZttajhD5st6IngYLcjr93BYVyJmDF7-wm4WZlHSw2OnXIfbJcFXEd83uVv_Rej4UXjzZ0e6kHwzc2nvGvKSIFu3Nt7CabdR8CkA", 3599);
|
||||
}
|
||||
|
||||
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",
|
||||
name: "Oficina-",
|
||||
position: { x: 22.475382737884104, y: 7.4884431474006163, z: 3.0 },
|
||||
sensorTypes: ["temperature", "humidity"]
|
||||
}
|
||||
];
|
||||
|
||||
var offset = Autodesk.viewer.model.getGlobalOffset();
|
||||
removeOffset(devices[0], offset)
|
||||
|
||||
// Generates `SurfaceShadingData` after assigning each device to a room.
|
||||
|
||||
const shadingData = await Autodesk.structureInfo.generateSurfaceShadingData(devices);
|
||||
|
||||
// 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 setTransparentBuilding() {
|
||||
//allDbIdsStr.forEach((dbId) => {
|
||||
// setTransparency(dbId, 0.2);
|
||||
@ -722,4 +664,188 @@ function closeHotspotModal() {
|
||||
//modal.style.display = "none";
|
||||
|
||||
}
|
||||
//------------------ end --------------------------------
|
||||
//------------------ end --------------------------------
|
||||
|
||||
//------------------ 熱圖 -------------------------------
|
||||
async function loadHeatmaps(model) {
|
||||
const dataVizExtn = await viewer.loadExtension("Autodesk.DataVisualization");
|
||||
|
||||
//取三個空調設備的位置打點
|
||||
const devices = [
|
||||
//{
|
||||
// id: "Oficina 5",
|
||||
// position: { x: -4.93, y: -20.61, z: 16.86 }, // x: 0, y: 25, z: -2.5
|
||||
// sensorTypes: ["temperature", "humidity"]
|
||||
//},
|
||||
//{
|
||||
// id: "Oficina 4",
|
||||
// position: { x: 23.94, y: -3.85, z: 16.86 }, // x: 0, y: 25.03, z: -2.52
|
||||
// sensorTypes: ["temperature", "humidity"]
|
||||
//},
|
||||
//{
|
||||
// id: "Oficina 3",
|
||||
// position: { x: -4.93, y: -3.85, z: 16.86 }, // x: 0, y: 25.03, z: -2.52
|
||||
// sensorTypes: ["temperature", "humidity"]
|
||||
//}
|
||||
{
|
||||
id: "Oficina 5",
|
||||
//name: "Oficina-",
|
||||
position: { x: 3.35, y: -4.81, z: 12.88 }, // x: 0, y: 25, z: -2.5 (3.35, -4.81, 12.88
|
||||
sensorTypes: ["temperature", "humidity"]
|
||||
},
|
||||
{
|
||||
id: "Oficina 4",
|
||||
//name: "Oficina-",
|
||||
position: { x: 37.03, y: -4.81, z: 12.88 }, // x: 0, y: 25.03, z: -2.52 (37.03, -4.81, 12.88)
|
||||
sensorTypes: ["temperature", "humidity"]
|
||||
},
|
||||
{
|
||||
id: "Oficina 3",
|
||||
//name: "Oficina-",
|
||||
position: { x: 2.83, y: -22.60, z: 12.88 }, // x: 0, y: 25.03, z: -2.52 (2.83, -22.60, 12.88)
|
||||
sensorTypes: ["temperature", "humidity"]
|
||||
}
|
||||
];
|
||||
//冷氣N5: (-4.93, -20.61, 16.86), N4: (23.94, -3.85, 16.86), N3: (-4.93, -3.85, 16.86)
|
||||
|
||||
// Initialize sensor values
|
||||
let sensorVals = [];
|
||||
for (let i = 0; i < devices.length; i++) {
|
||||
sensorVals[i] = Math.random();
|
||||
}
|
||||
|
||||
const roomDbIds = [];
|
||||
roomDbIds.push(8181);//房間的dbid 七樓的 Room3-5 792
|
||||
roomDbIds.push(8183);
|
||||
roomDbIds.push(8185);
|
||||
|
||||
const {
|
||||
SurfaceShadingData,
|
||||
SurfaceShadingPoint,
|
||||
SurfaceShadingNode,
|
||||
} = Autodesk.DataVisualization.Core;
|
||||
|
||||
const shadingNode = new SurfaceShadingNode("Room Panel", roomDbIds);
|
||||
|
||||
devices.forEach((device) => {
|
||||
const shadingPoint = new SurfaceShadingPoint(
|
||||
device.id,
|
||||
device.position,
|
||||
device.sensorTypes
|
||||
);
|
||||
shadingNode.addPoint(shadingPoint);
|
||||
});
|
||||
|
||||
const heatmapData = new SurfaceShadingData();
|
||||
heatmapData.addChild(shadingNode);
|
||||
heatmapData.initialize(model);
|
||||
|
||||
// Setup surface shading
|
||||
await dataVizExtn.setupSurfaceShading(model, heatmapData);
|
||||
|
||||
dataVizExtn.registerSurfaceShadingColors("temperature", [0xff0000, 0x0000ff]);
|
||||
|
||||
function getSensorValue(device, sensorType) {
|
||||
return sensorVals[parseInt(device.id.slice(-1)) - 1];
|
||||
}
|
||||
|
||||
dataVizExtn.renderSurfaceShading("Room Panel", "temperature", getSensorValue);
|
||||
|
||||
setInterval(() => {
|
||||
// Modify sensor values.
|
||||
for (let i = 0; i < devices.length; i++) {
|
||||
sensorVals[i] = Math.random();
|
||||
}
|
||||
dataVizExtn.updateSurfaceShading(getSensorValue);
|
||||
}, 2000);
|
||||
}
|
||||
//------------------ end --------------------------------
|
||||
async function loadHeatmapsForFloor(model) {
|
||||
|
||||
const dataVizExtn = await viewer.loadExtension("Autodesk.DataVisualization");
|
||||
|
||||
//x: -17.33, y: 51.03, z: -2.52
|
||||
const devices = [
|
||||
{
|
||||
id: "Oficina 5",
|
||||
//name: "Oficina-",
|
||||
position: { x: -4.93, y: -20.61, z: 16.86 }, // x: 0, y: 25, z: -2.5 (3.35, -4.81, 12.88
|
||||
sensorTypes: ["temperature", "humidity"]
|
||||
},
|
||||
{
|
||||
id: "Oficina 4",
|
||||
//name: "Oficina-",
|
||||
position: { x: 23.94, y: -3.85, z: 16.86 }, // x: 0, y: 25.03, z: -2.52 (37.03, -4.81, 12.88)
|
||||
sensorTypes: ["temperature", "humidity"]
|
||||
},
|
||||
{
|
||||
id: "Oficina 3",
|
||||
//name: "Oficina-",
|
||||
position: { x: -4.93, y: -3.85, z: 16.86 }, // x: 0, y: 25.03, z: -2.52 (2.83, -22.60, 12.88)
|
||||
sensorTypes: ["temperature", "humidity"]
|
||||
}
|
||||
];
|
||||
//冷氣N5: (-4.93, -20.61, 16.86), N4: (23.94, -3.85, 16.86), N3: (-4.93, -3.85, 16.86)
|
||||
|
||||
// Initialize sensor values
|
||||
let sensorVals = [];
|
||||
for (let i = 0; i < devices.length; i++) {
|
||||
sensorVals[i] = Math.random();
|
||||
}
|
||||
|
||||
const roofDbIds = [];
|
||||
|
||||
roofDbIds.push(792);
|
||||
|
||||
const {
|
||||
SurfaceShadingData,
|
||||
SurfaceShadingPoint,
|
||||
SurfaceShadingNode,
|
||||
} = Autodesk.DataVisualization.Core;
|
||||
|
||||
const shadingNode = new SurfaceShadingNode("Roof Panel", roofDbIds);
|
||||
|
||||
devices.forEach((device) => {
|
||||
const shadingPoint = new SurfaceShadingPoint(
|
||||
device.id,
|
||||
device.position,
|
||||
device.sensorTypes
|
||||
);
|
||||
shadingNode.addPoint(shadingPoint);
|
||||
});
|
||||
|
||||
const heatmapData = new SurfaceShadingData();
|
||||
heatmapData.addChild(shadingNode);
|
||||
heatmapData.initialize(model);
|
||||
|
||||
// Setup surface shading
|
||||
await dataVizExtn.setupSurfaceShading(model, heatmapData);
|
||||
|
||||
//dataVizExtn.registerSurfaceShadingColors("co2", [0x00ff00, 0xff0000]);
|
||||
dataVizExtn.registerSurfaceShadingColors("temperature", [0xff0000, 0x0000ff]);
|
||||
|
||||
function getSensorValue(device, sensorType) {
|
||||
return sensorVals[parseInt(device.id.slice(-1)) - 1];
|
||||
}
|
||||
|
||||
dataVizExtn.renderSurfaceShading("Roof Panel", "temperature", getSensorValue);
|
||||
|
||||
setInterval(() => {
|
||||
// Modify sensor values.
|
||||
for (let i = 0; i < devices.length; i++) {
|
||||
sensorVals[i] = Math.random();
|
||||
}
|
||||
dataVizExtn.updateSurfaceShading(getSensorValue);
|
||||
}, 2000);
|
||||
}
|
||||
|
||||
//
|
||||
async function loadHeatmap() {
|
||||
const model = viewer.model;
|
||||
loadHeatmaps(model);
|
||||
}
|
||||
|
||||
async function loadHeatmapForFloor() {
|
||||
const model = viewer.model;
|
||||
loadHeatmapsForFloor(model);
|
||||
}
|
@ -5,6 +5,10 @@ var elevatorSpeed;
|
||||
var allDbIdsStr;
|
||||
let bulbLight;//點燈
|
||||
let spotLight;//聚光燈
|
||||
var myDataList;
|
||||
var viewableData;
|
||||
var dataVizExtn;
|
||||
var spriteColorRed;
|
||||
|
||||
function launchViewer(urn) {
|
||||
var av = Autodesk.Viewing;
|
||||
@ -20,9 +24,9 @@ function launchViewer(urn) {
|
||||
var documentId = 'urn:' + urn;
|
||||
|
||||
//加入熱點
|
||||
//viewer.addEventListener(av.GEOMETRY_LOADED_EVENT, addHotPoint, {
|
||||
// once: true,
|
||||
//});
|
||||
viewer.addEventListener(av.GEOMETRY_LOADED_EVENT, addHotPoint, {
|
||||
once: true,
|
||||
});
|
||||
|
||||
Autodesk.Viewing.Document.load(documentId, onDocumentLoadSuccess, onDocumentLoadFailure);
|
||||
|
||||
@ -167,7 +171,7 @@ function onDocumentLoadSuccess(doc) {
|
||||
const fragList = model.getFragmentList();
|
||||
|
||||
|
||||
loadHeatmaps(model);
|
||||
/*loadHeatmaps(model);*/
|
||||
|
||||
|
||||
|
||||
@ -446,14 +450,14 @@ function onDocumentLoadSuccess(doc) {
|
||||
//viewer.scene.add(bulbLight);
|
||||
|
||||
//聚光燈
|
||||
//spotLight = new THREE.SpotLight(0xffffff, 80, 10);//0xffffff
|
||||
//spotLight.position.set(-17.33, 51.03, -2.52);
|
||||
//spotLight = new THREE.SpotLight(0xffff00, 80, 10);//0xffffff
|
||||
//spotLight.position.set(-7.58, 18.20, -0.25); //set(-17.33, 51.03, -2.52);
|
||||
//spotLight.castShadow = true;
|
||||
//spotLight.visible = true;
|
||||
//var geom = new THREE.BoxGeometry(); //create 幾何對象 -17.33, 51.03, -4.52
|
||||
//var material = new THREE.MeshLambertMaterial({ color: 0xff0000 });
|
||||
//var material = new THREE.MeshLambertMaterial({ color: 0xffff00 });//0xff0000
|
||||
//var cube = new THREE.Mesh(geom, material);
|
||||
//cube.position.set(-17.33, 51.03, -10);//-4.52
|
||||
//cube.position.set(-7.58, 18.20, -1); //set(-17.33, 51.03, -10);//-4.52
|
||||
//viewer.scene.add(cube);
|
||||
//spotLight.target = cube;
|
||||
//viewer.scene.add(spotLight);
|
||||
@ -463,11 +467,12 @@ function onDocumentLoadSuccess(doc) {
|
||||
//------------------- 加入熱點 -----------------
|
||||
async function addHotPoint(data) {
|
||||
var viewer = data.target;
|
||||
const dataVizExtn = await viewer.loadExtension("Autodesk.DataVisualization");
|
||||
dataVizExtn = await viewer.loadExtension("Autodesk.DataVisualization");
|
||||
const DataVizCore = Autodesk.DataVisualization.Core;
|
||||
const viewableType = Autodesk.DataVisualization.Core.ViewableType.SPRITE;//DataVizCore.ViewableType.SPRITE;
|
||||
const spriteColor = new THREE.Color(0xffffff);
|
||||
const spriteIcon = "/img/forge/hotspot.svg";
|
||||
const spriteColor = new THREE.Color(0xffff00); //0xffffff
|
||||
spriteColorRed = new THREE.Color(0xff0000);
|
||||
const spriteIcon = "https://d2zqnmauvnpnnm.cloudfront.net/assets-1/images/circle.svg"; //"/img/forge/hotspot.svg";
|
||||
|
||||
const style = new DataVizCore.ViewableStyle(viewableType, spriteColor, spriteIcon);
|
||||
|
||||
@ -487,11 +492,11 @@ async function addHotPoint(data) {
|
||||
onSelectionChange
|
||||
);
|
||||
|
||||
const viewableData = new DataVizCore.ViewableData();
|
||||
viewableData = new DataVizCore.ViewableData();
|
||||
viewableData.spriteSize = 24; // Sprites as points of size 24 x 24 pixels
|
||||
|
||||
//熱圖 打點 x: 0, y: 25.03, z: -2.52 三菱
|
||||
const myDataList = [{ position: { x: -21.95, y: 8.92, z: 63.27 } }, //-21.95, 8.92, 63.27
|
||||
myDataList = [{ position: { x: -21.95, y: 8.92, z: 63.27 } }, //-21.95, 8.92, 63.27
|
||||
{ position: { x: -21.95, y: 7.61, z: 63.27 } },//-21.95, 7.61, 63.27
|
||||
{ position: { x: -21.95, y: 6.43, z: 63.27 } },//-21.95, 6.43, 63.27
|
||||
{ position: { x: -21.95, y: 5.31, z: 63.27 } }//-21.95, 5.31, 63.27
|
||||
@ -510,7 +515,7 @@ async function addHotPoint(data) {
|
||||
|
||||
//---------------- 熱點點擊事件 --------------------
|
||||
function onSpriteClicked(event) {
|
||||
//event.hasStopped = true;
|
||||
event.hasStopped = true;
|
||||
if (event != undefined && event != null) {
|
||||
if (event.dbId >= 10 && event.dbId <= 13) {//event.dbId > 0 && event.dbId < 19
|
||||
console.log(`Sprite clicked: ${event.dbId}`);
|
||||
@ -518,6 +523,16 @@ async function addHotPoint(data) {
|
||||
}
|
||||
|
||||
if (event.clickInfo != null) {
|
||||
//if (event.clickInfo.dbId == 12449) {
|
||||
//const viewablesToUpdate = [event.dbId];
|
||||
//dataVizExtn.invalidateViewables(viewablesToUpdate, (viewable) => {
|
||||
// return {
|
||||
// color: spriteColorRed,
|
||||
// };
|
||||
//});
|
||||
//}
|
||||
|
||||
|
||||
//document.getElementById('lbltipAddedComment').innerHTML .toFixed(2);
|
||||
document.getElementById('deviceName').innerHTML = viewer.model.getInstanceTree().getNodeName(event.clickInfo.dbId);
|
||||
document.getElementById('deviceDbid').innerHTML = event.clickInfo.dbId;
|
||||
@ -558,6 +573,18 @@ async function addHotPoint(data) {
|
||||
}
|
||||
//------------------- end --------------
|
||||
|
||||
// 熱點 更換顏色
|
||||
function changeColorForHotspot(dbId) {
|
||||
//const viewablesToUpdate = [event.dbId];
|
||||
const viewablesToUpdate = dbId;
|
||||
dataVizExtn.invalidateViewables(viewablesToUpdate, (viewable) => {
|
||||
return {
|
||||
color: spriteColorRed,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
////---------------- 熱點點擊事件 --------------------
|
||||
//function onSpriteClicked(event) {
|
||||
// //event.hasStopped = true;
|
||||
@ -1039,12 +1066,44 @@ async function loadHeatmaps(model) {
|
||||
//x: -17.33, y: 51.03, z: -2.52
|
||||
const devices = [
|
||||
{
|
||||
id: "Oficina 6",
|
||||
id: "Oficina 5",
|
||||
//name: "Oficina-",
|
||||
position: { x: 0, y: 25, z: -2.5 }, // x: 0, y: 25.03, z: -2.52
|
||||
position: { x: -4.93, y: -20.61, z: 16.86 }, // x: 0, y: 25, z: -2.5 (3.35, -4.81, 12.88
|
||||
sensorTypes: ["temperature", "humidity"]
|
||||
},
|
||||
{
|
||||
id: "Oficina 4",
|
||||
//name: "Oficina-",
|
||||
position: { x: 23.94, y: -3.85, z: 16.86 }, // x: 0, y: 25.03, z: -2.52 (37.03, -4.81, 12.88)
|
||||
sensorTypes: ["temperature", "humidity"]
|
||||
},
|
||||
{
|
||||
id: "Oficina 3",
|
||||
//name: "Oficina-",
|
||||
position: { x: -4.93, y: -3.85, z: 16.86 }, // x: 0, y: 25.03, z: -2.52 (2.83, -22.60, 12.88)
|
||||
sensorTypes: ["temperature", "humidity"]
|
||||
}
|
||||
|
||||
//{
|
||||
// id: "Oficina 5",
|
||||
// //name: "Oficina-",
|
||||
// position: { x: 3.35, y: -4.81, z: 12.88 }, // x: 0, y: 25, z: -2.5 (3.35, -4.81, 12.88
|
||||
// sensorTypes: ["temperature", "humidity"]
|
||||
//},
|
||||
//{
|
||||
// id: "Oficina 4",
|
||||
// //name: "Oficina-",
|
||||
// position: { x: 37.03, y: -4.81, z: 12.88 }, // x: 0, y: 25.03, z: -2.52 (37.03, -4.81, 12.88)
|
||||
// sensorTypes: ["temperature", "humidity"]
|
||||
//},
|
||||
//{
|
||||
// id: "Oficina 3",
|
||||
// //name: "Oficina-",
|
||||
// position: { x: 2.83, y: -22.60, z: 12.88 }, // x: 0, y: 25.03, z: -2.52 (2.83, -22.60, 12.88)
|
||||
// sensorTypes: ["temperature", "humidity"]
|
||||
//}
|
||||
];
|
||||
//冷氣N5: (-4.93, -20.61, 16.86), N4: (23.94, -3.85, 16.86), N3: (-4.93, -3.85, 16.86)
|
||||
|
||||
// Initialize sensor values
|
||||
let sensorVals = [];
|
||||
@ -1070,7 +1129,9 @@ async function loadHeatmaps(model) {
|
||||
// },
|
||||
// true
|
||||
//);
|
||||
roofDbIds.push(834);//5113 834 838 8106 8177
|
||||
roofDbIds.push(792);//5113 834 838 8106 8177 792 8181
|
||||
//roofDbIds.push(8183);
|
||||
//roofDbIds.push(8185);
|
||||
|
||||
const {
|
||||
SurfaceShadingData,
|
||||
@ -1109,6 +1170,14 @@ async function loadHeatmaps(model) {
|
||||
|
||||
dataVizExtn.renderSurfaceShading("Roof Panel", "temperature", getSensorValue);
|
||||
|
||||
setInterval(() => {
|
||||
// Modify sensor values.
|
||||
for (let i = 0; i < devices.length; i++) {
|
||||
sensorVals[i] = Math.random();
|
||||
}
|
||||
dataVizExtn.updateSurfaceShading(getSensorValue);
|
||||
}, 2000);
|
||||
|
||||
//viewer.hide(5108);//五樓底下的六樓物件
|
||||
//-------------------------------------------------------------------------------
|
||||
|
||||
@ -1149,4 +1218,9 @@ async function loadHeatmaps(model) {
|
||||
|
||||
//dataVizExtn.updateSurfaceShading(getSensorValue);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
async function loadHeatmap() {
|
||||
const model = viewer.model;
|
||||
loadHeatmaps(model);
|
||||
}
|
Loading…
Reference in New Issue
Block a user