From f662d22a4f83372a1f7b2411b8bc3e36b0c2e5a4 Mon Sep 17 00:00:00 2001 From: wanli Date: Thu, 29 Dec 2022 18:19:22 +0800 Subject: [PATCH 1/2] =?UTF-8?q?[Frontend][=E7=B3=BB=E7=B5=B1=E7=9B=A3?= =?UTF-8?q?=E6=8E=A7]=20=E6=A8=93=E5=B1=A4=20=E5=8A=A0=E5=85=A5=E5=89=96?= =?UTF-8?q?=E9=9D=A2=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Frontend/_sysMonAll.html | 4 +- Frontend/_sysMonFloor.html | 51 ++++- Frontend/js/forge/forgemodel.js | 325 +++++++++++++++++++++++++++----- 3 files changed, 332 insertions(+), 48 deletions(-) diff --git a/Frontend/_sysMonAll.html b/Frontend/_sysMonAll.html index c15d475..e51b9d5 100644 --- a/Frontend/_sysMonAll.html +++ b/Frontend/_sysMonAll.html @@ -256,8 +256,8 @@ function show3DModel(urn) { launchViewerForHotspot(urn, (viewer, nodeIds) => { - - },"[name=forgeViewer]"); + loadHeatmap(); + }, "[name=forgeViewer]"); } function getHotspotPoint(callback = null) { diff --git a/Frontend/_sysMonFloor.html b/Frontend/_sysMonFloor.html index 87686c0..737dc97 100644 --- a/Frontend/_sysMonFloor.html +++ b/Frontend/_sysMonFloor.html @@ -30,9 +30,12 @@ var allDeviceRowData = []; //所有設備原始資料 var global_emergency_alarm_device_number = []; var zoomToggle = 3; + var urn_all = "dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6LW1pdHN1YmlzaGkvJUUzJTgwJTkwJUU1JThGJUIwJUU1JThDJTk3JUU0JUI4JUFEJUU4JThGJUIxJUU1JUE0JUE3JUU2JUE4JTkzJUUzJTgwJTkxQVJDJUU5JTlCJTk5JUU5JUExJUFGXzEyMjgubndk"; $(function () { - show3DModel(); + getHotspotPoint(() => { + show3DModel(urn_all); + }); initChart(); getFloData(); subDevice(); @@ -864,9 +867,49 @@ } } - function show3DModel() { - launchViewer("dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dnNjb2RlX2ZvcmdlX3Rlc3QvJUUzJTgwJTkwQVJDJUUzJTgwJTkxQjFGXzIwMjJfMTJfMDQubndj", (viewer, nodeIds) => { - + function show3DModel(urn) { + launchViewerForHotspot(urn, (viewer, nodeIds) => { + getLevelsData(); + 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); + } \ No newline at end of file diff --git a/Frontend/js/forge/forgemodel.js b/Frontend/js/forge/forgemodel.js index b957b65..252142d 100644 --- a/Frontend/js/forge/forgemodel.js +++ b/Frontend/js/forge/forgemodel.js @@ -5,6 +5,7 @@ var targetFloorZ; var elevatorSpeed; var selector = "#forgeViewer"; let myDataList; +var levels;//剖面用 function launchViewer(urn, callback, _selector = "#forgeViewer") { selector = _selector; @@ -479,62 +480,76 @@ function getForgeToken(callback) { } 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 }, + id: "Oficina 5", + position: { x: 6.98, y: -19.00, z: 16.86 }, + sensorTypes: ["temperature", "humidity"] + }, + { + id: "Oficina 4", + position: { x: 35.85, y: -2.24, z: 16.86 }, + sensorTypes: ["temperature", "humidity"] + }, + { + id: "Oficina 3", + position: { x: 6.98, y: -2.24, z: 16.86 }, sensorTypes: ["temperature", "humidity"] } ]; - var offset = Autodesk.viewer.model.getGlobalOffset(); - removeOffset(devices[0], offset) + // Initialize sensor values + let sensorVals = []; + for (let i = 0; i < devices.length; i++) { + sensorVals[i] = Math.random(); + } + const roomDbIds = []; + + roomDbIds.push(7567); + + 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); + }); // Generates `SurfaceShadingData` after assigning each device to a room. + const heatmapData = new SurfaceShadingData(); + heatmapData.addChild(shadingNode); + heatmapData.initialize(model); - const shadingData = await Autodesk.structureInfo.generateSurfaceShadingData(devices); + // Setup surface shading + await dataVizExtn.setupSurfaceShading(model, heatmapData); - // Use the resulting shading data to generate heatmap from. - await dataVizExtn.setupSurfaceShading(model, shadingData); + dataVizExtn.registerSurfaceShadingColors("temperature", [0xff0000, 0x0000ff]); - // 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); + function getSensorValue(device, sensorType) { + return sensorVals[parseInt(device.id.slice(-1)) - 1]; } - // This value can also be a room instead of a floor - const floorName = "01 - Entry Level"; - dataVizExtn.renderSurfaceShading(floorName, sensorType, getSensorValue); -} + 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); +} function setTransparentBuilding() { //allDbIdsStr.forEach((dbId) => { @@ -746,4 +761,230 @@ function closeHotspotModal() { //modal.style.display = "none"; } -//------------------ end -------------------------------- \ No newline at end of file +//------------------ 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: 6.98, y: -19.00, z: 16.86 }, // x: 0, y: 25, z: -2.5 (-4.93, -20.61, 16.86) + sensorTypes: ["temperature", "humidity"] + }, + { + id: "Oficina 4", + //name: "Oficina-", + position: { x: 35.85, y: -2.24, z: 16.86 }, // x: 0, y: 25.03, z: -2.52 (23.94, -3.85, 16.86) + sensorTypes: ["temperature", "humidity"] + }, + { + id: "Oficina 3", + //name: "Oficina-", + position: { x: 6.98, y: -2.24, z: 16.86 }, // x: 0, y: 25.03, z: -2.52 (-4.93, -3.85, 16.86) + sensorTypes: ["temperature", "humidity"] + } + ]; + + // Initialize sensor values + let sensorVals = []; + for (let i = 0; i < devices.length; i++) { + sensorVals[i] = Math.random(); + } + + const roomDbIds = []; + + roomDbIds.push(7567); + + 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("co2", [0x00ff00, 0xff0000]); + 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); +} + +// +async function loadHeatmap() { + const model = viewer.model; + loadHeatmaps(model); +} + +async function loadHeatmapForFloor() { + const model = viewer.model; + loadHeatmapsForFloor(model); +} + +//------------ 剖面 ---------------------- +async function getRemoteLevels() { + const aecData = await Autodesk.Viewing.Document.getAecModelData(this.viewer.model.getDocumentNode()); + if (!aecData.levels) return null; + + const levels2 = aecData.levels; + levels2.sort((a, b) => b.elevation - a.elevation); + return levels2; +} + +async function getLevelsData() { + const data = await this.getRemoteLevels(); + this.levels = data; + profile(); +} + +function getCutPlaneParam(idx, n) { + if (idx < 0 || !n) return; + + const level = this.levels[idx]; + if (!level) return; + + const model = this.viewer.model; + const globalOffset = model.getData().globalOffset; + const units = model.getUnitString(); + const elevRaw = Autodesk.Viewing.Private.convertUnits('ft', units, 1, level.elevation); + + let d = elevRaw - globalOffset.z - 0.5; + if (n == 1) + d = -1 * d; + + return new THREE.Vector4(0, 0, n, d); +} + +function profile() { + const upperIdx = 6; + const upperCutPlaneParam = this.getCutPlaneParam(upperIdx, 1); + const lowerIdx = 7; + const lowerCutPlaneParam = this.getCutPlaneParam(lowerIdx, -1); + this.viewer.setCutPlanes([upperCutPlaneParam, lowerCutPlaneParam]); +} +//----------------- end ----------------------------------------------- \ No newline at end of file From aa6ebf3497ae55c837a88a060248b407bfeb625c Mon Sep 17 00:00:00 2001 From: wanli Date: Thu, 29 Dec 2022 18:20:16 +0800 Subject: [PATCH 2/2] =?UTF-8?q?[Frontend]=20=E6=B8=AC=E8=A9=A6=E5=89=96?= =?UTF-8?q?=E9=9D=A2=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Frontend/forgetTest2.html | 47 +++++++- Frontend/js/forge/modeltest.js | 206 ++++++++++++++++++++++++++++++--- 2 files changed, 233 insertions(+), 20 deletions(-) diff --git a/Frontend/forgetTest2.html b/Frontend/forgetTest2.html index 1c7670c..15f9ccc 100644 --- a/Frontend/forgetTest2.html +++ b/Frontend/forgetTest2.html @@ -34,6 +34,12 @@ + + + + + + @@ -206,15 +212,31 @@ //launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dnNjb2RlX2ZvcmdlX3Rlc3QvJUU2JTk2JUI5JUU2JUExJTg4NF8yMDIyXzEyXzI2Lm53ZA'); //12.28 三菱單層樓 + 系統 - launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dnNjb2RlX2ZvcmdlX3Rlc3QvQVJDJUU1JTk2JUFFJUU1JUIxJUE0K01FUCVFNSU4NSVBOCVFNiVBMyU5Rl83Rl9ERU1PLm53ZA'); + //launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dnNjb2RlX2ZvcmdlX3Rlc3QvQVJDJUU1JTk2JUFFJUU1JUIxJUE0K01FUCVFNSU4NSVBOCVFNiVBMyU5Rl83Rl9ERU1PLm53ZA'); + //目前線上整棟模型 //launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dnNjb2RlX2ZvcmdlX3Rlc3QvJUU2JTk2JUI5JUU2JUExJTg4NF8yMDIyXzEyXzI2Lm53ZA'); + //單層 + 系統 + //launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6LW1pdHN1YmlzaGkvTUVQK0FSQzdGX0RFTU9fJUU1JTg5JThBJUU5JUEwJTgyXzEyMjgubndk'); + + //單層 + //launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dnNjb2RlX2ZvcmdlX3Rlc3QvJUUzJTgwJTkwQVJDJUUzJTgwJTkxMUZfREVNT18yMDIyXzEyXzI5Lm53Yw'); + + //MEP + //launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dnNjb2RlX2ZvcmdlX3Rlc3QvJUUzJTgwJTkwTUVQJUUzJTgwJTkxXzIwMjJfMTJfMjkubndj'); + + //12.29 整棟 + launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6LW1pdHN1YmlzaGkvJUUzJTgwJTkwJUU1JThGJUIwJUU1JThDJTk3JUU0JUI4JUFEJUU4JThGJUIxJUU1JUE0JUE3JUU2JUE4JTkzJUUzJTgwJTkxQVJDJUU5JTlCJTk5JUU5JUExJUFGXzEyMjgubndk'); //launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dnNjb2RlX2ZvcmdlX3Rlc3QvJUUzJTgwJTkwQVJDJUUzJTgwJTkxXzIwMjJfMTJfMTMubndk');//new ARC //launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dnNjb2RlX2ZvcmdlX3Rlc3QvJUUzJTgwJTkwTUVQJUUzJTgwJTkxXzIwMjJfMTJfMTMubndj');//new MEP //launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dnNjb2RlX2ZvcmdlX3Rlc3QvJUUzJTgwJTkwQVJDJUUzJTgwJTkxJUU1JTg1JUE4JUU2JUEzJTlGXzIwMjJfMTJfMTMubndj');//全棟 ARC + + + + }); function move1Floor() { setElevatorSpeed(0.2); @@ -319,8 +341,31 @@ loadHeatmap(); } + function hideModel() { + hideObject(); + } + function openModel() { + openObject(); + } + function transparentModel() { + setObjectTransparent(); + } + + function cancelTransparentModel() { + cancelObjectTransparent(); + } + + function getLevels() { + //取得levels + getLevelsData(); + } + + function proFile() { + profile(); + } + diff --git a/Frontend/js/forge/modeltest.js b/Frontend/js/forge/modeltest.js index a6d3afc..c697ccc 100644 --- a/Frontend/js/forge/modeltest.js +++ b/Frontend/js/forge/modeltest.js @@ -9,6 +9,7 @@ var myDataList; var viewableData; var dataVizExtn; var spriteColorRed; +var levels;//剖面用 function launchViewer(urn) { var av = Autodesk.Viewing; @@ -547,12 +548,12 @@ async function addHotPoint(data) { // event.hasStopped = true; // const viewablesToUpdate = [event.dbId]; - // dataVizExtn.invalidateViewables(viewablesToUpdate, (viewable) => { - // return { - // scale: 1.0, // Restore the viewable size - // url: "https://.../circle.svg", - // }; - // }); + //dataVizExtn.invalidateViewables(viewablesToUpdate, (viewable) => { + // return { + // scale: 1.0, // Restore the viewable size + // //url: "https://.../circle.svg", + // }; + //}); //} //function onSpriteHovering(event) { @@ -709,7 +710,7 @@ function setTransparentBuilding() { //}) for (var i = 0; i < allDbIdsStr.length; i++) { - setTransparency(parseInt(allDbIdsStr[i]) , 0.2); + setTransparency(parseInt(allDbIdsStr[i]) , 0); } } @@ -1068,19 +1069,19 @@ async function loadHeatmaps(model) { { 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 + position: { x: 6.98, y: -19.00, z: 16.86 }, // x: 0, y: 25, z: -2.5 (-4.93, -20.61, 16.86) 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) + position: { x: 35.85, y: -2.24, z: 16.86 }, // x: 0, y: 25.03, z: -2.52 (23.94, -3.85, 16.86) 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) + position: { x: 6.98, y: -2.24, z: 16.86 }, // x: 0, y: 25.03, z: -2.52 (-4.93, -3.85, 16.86) sensorTypes: ["temperature", "humidity"] } @@ -1103,7 +1104,7 @@ async function loadHeatmaps(model) { // sensorTypes: ["temperature", "humidity"] //} ]; - //冷氣N5: (-4.93, -20.61, 16.86), N4: (23.94, -3.85, 16.86), N3: (-4.93, -3.85, 16.86) + //冷氣N5: (6.98, -19.00, 16.86), N4: (35.85, -2.24, 16.86), N3: (6.98, -2.24, 16.86) // Initialize sensor values let sensorVals = []; @@ -1118,20 +1119,20 @@ async function loadHeatmaps(model) { // Retrive all dbIds that compose the stadium roof. const it = viewer.model.getInstanceTree(); - const roofDbIds = []; + const roomDbIds = []; //it.enumNodeChildren( // 5027,//4239 // (id) => { // if (it.getNodeName(id) == "【ARC】【樓板】RC") {//【ARC】【樓板】RC 樓板 - // roofDbIds.push(id); + // roomDbIds.push(id); // } // }, // true //); - roofDbIds.push(792);//5113 834 838 8106 8177 792 8181 - //roofDbIds.push(8183); - //roofDbIds.push(8185); + roomDbIds.push(7567);//5113 834 838 8106 8177 792 8181 + //roomDbIds.push(8183); + //roomDbIds.push(8185); const { SurfaceShadingData, @@ -1139,7 +1140,7 @@ async function loadHeatmaps(model) { SurfaceShadingNode, } = Autodesk.DataVisualization.Core; - const shadingNode = new SurfaceShadingNode("Roof Panel", roofDbIds); + const shadingNode = new SurfaceShadingNode("Room Panel", roomDbIds); devices.forEach((device) => { const shadingPoint = new SurfaceShadingPoint( @@ -1168,7 +1169,7 @@ async function loadHeatmaps(model) { return sensorVals[parseInt(device.id.slice(-1)) - 1]; } - dataVizExtn.renderSurfaceShading("Roof Panel", "temperature", getSensorValue); + dataVizExtn.renderSurfaceShading("Room Panel", "temperature", getSensorValue); setInterval(() => { // Modify sensor values. @@ -1223,4 +1224,171 @@ async function loadHeatmaps(model) { async function loadHeatmap() { const model = viewer.model; loadHeatmaps(model); -} \ No newline at end of file +} + +function hideObject() { + //viewer.hide(4); + //viewer.hide(58); + //viewer.hide(613); + //viewer.hide(640); + //viewer.hide(560); + + for (var i = 0; i < allDbIdsStr.length; i++) { + viewer.hide(parseInt(allDbIdsStr[i])); + } +} + +function openObject() { + //viewer.show(4); + //viewer.show(58); + //viewer.show(613); + //viewer.show(640); + //viewer.show(560); + + for (var i = 0; i < allDbIdsStr.length; i++) { + viewer.show(parseInt(allDbIdsStr[i])); + } +} + +async function setObjectTransparent() { + //setTransparency(4, 0); + //setTransparency(58, 0); + //setTransparency(613, 0); + //setTransparency(640, 0); + //setTransparency(560, 0); + //setTransparency(parseInt(515), 0); + + //for (var i = 0; i < allDbIdsStr.length; i++) { + // setTransparency(parseInt(allDbIdsStr[i]), 0); + //} + + //setTransparency(parseInt(515), 0); + //setTransparency(parseInt(516), 0); + //setTransparency(parseInt(517), 0); + //setTransparency(parseInt(518), 0); + //setTransparency(parseInt(519), 0); + //setTransparency(parseInt(399), 0); + //setTransparency(parseInt(101), 0); + //setTransparency(parseInt(100), 0); + //setTransparency(parseInt(58), 0); + + //setTransparency(parseInt(587), 0); + //setTransparency(parseInt(586), 0); + //setTransparency(parseInt(585), 0); + //setTransparency(parseInt(584), 0); + //setTransparency(parseInt(583), 0); + //setTransparency(parseInt(562), 0); + //setTransparency(parseInt(361), 0); + + //test(); + //hideColor(587); + //hideColor(586); + //hideColor(585); + //hideColor(584); + //hideColor(583); + //hideColor(562); + //hideColor(361); + + setTransparentBuilding(); + +} + +async function cancelObjectTransparent() { + //setTransparency(4, 1); + //setTransparency(58, 1); + //setTransparency(613, 1); + //setTransparency(640, 1); + //setTransparency(560, 1); + //for (var i = 0; i < allDbIdsStr.length; i++) { + // setTransparency(parseInt(allDbIdsStr[i]), 1); + //} + + //setTransparency(515, 0.2); + //setTransparency(516, 0.2); + //setTransparency(517, 0.2); + //setTransparency(518, 0.2); + //setTransparency(519, 0.2); + //setTransparency(399, 0.2); + //setTransparency(101, 0.2); + //setTransparency(100, 0.2); + //setTransparency(58, 0.2); + + recoverTransparentBuilding(); + +} + +async function test() { + var model = viewer.model; + var nodeId = 560; + + var fragList = viewer.model.getFragmentList(); + + var fragIds = [] + + model.getData().instanceTree.enumNodeFragments( + nodeId, (fragId) => { + fragIds.push(fragId) + }); + + fragIds.forEach((fragId) => { + //获取材质 + var material = fragList.getMaterial(fragId); + + if (material) { + //设置透明度 + material.opacity = 0.5; + material.transparent = true; + //标记更新 + material.needsUpdate = true + } + }) + + //更新viewer + viewer.impl.invalidate(true, true, true) + +} + + +//------------ 剖面 ---------------------- +async function getRemoteLevels() { + const aecData = await Autodesk.Viewing.Document.getAecModelData(this.viewer.model.getDocumentNode()); + if (!aecData.levels) return null; + + const levels = aecData.levels; + levels.sort((a, b) => b.elevation - a.elevation); + return levels; +} + +async function getLevelsData() { + const data = await this.getRemoteLevels(); + this.levels = data; +} + +//function getCutPlaneParam(idx, n) { +// if (idx < 0 || !n) return; + +// const level = this.levels[idx]; +// if (!level) return; + +// //const precision = Autodesk.Viewing.Private.calculatePrecision( level.elevation ); +// const model = this.viewer.model; +// const globalOffset = model.getData().globalOffset; +// const units = model.getUnitString(); +// const elevRaw = Autodesk.Viewing.Private.convertUnits('ft', units, 1, level.elevation); + +// let d = elevRaw - globalOffset.z - 0.5; +// if (n == 1) +// d = -1 * d; + +// return new THREE.Vector4(0, 0, n, d); +//} + + +function profile() { + const upperIdx = 6; + const upperCutPlaneParam = this.getCutPlaneParam(upperIdx, 1); + const lowerIdx = 7; + const lowerCutPlaneParam = this.getCutPlaneParam(lowerIdx, -1); + this.viewer.setCutPlanes([upperCutPlaneParam, lowerCutPlaneParam]); +} +//----------------- end ----------------------------------------------- \ No newline at end of file