Explorar o código

BIM元件庫依意見更新

nate %!s(int64=3) %!d(string=hai) anos
pai
achega
3d694c42ff

+ 7 - 43
assets/columnTable.json

@@ -1,48 +1,12 @@
 [
   {
-    "equipmentID": "設備編碼",
-    "equipmentName": "設備名稱",
-    "installType": "安裝型式",
+    "id": "序號",
+    "componentGroup": "元件類別",
+    "componentName": "元件名稱",
     "category": "族群品類",
-    "model": "型號",
-    "measurement": "尺寸(L*W*D)",
-    "material": "材質",
-    "currents": "電流(Amps)",
-    "voltage": "電壓(volts)",
-    "frequency": "頻率(HZ)",
-    "horsePower": "馬力(HP/KW)",
-    "diameter": "口徑D(入口/出口)",
-    "quantity": "流量Q(LPM)",
-    "head": "揚程H(M)",
-    "operatingTemperature": "動作溫度(C/F)",
-    "parameterComponent": "參數元件",
-    "capacity": "容量(L)",
-    "filePath": "存檔路徑",
-    "note": "備註",
-    "lightSourceSpec": "光源規格",
-    "emergencySupplySpec": "緊急電源規格",
-    "lightingTime": "照明時間(Hr)",
-    "weightOverMeasurement": "重量/尺寸Kg/(L*W*D)",
-    "type": "種類",
-    "powerOutput": "出輸功率(W)",
-    "densityPercent": "動作濃度(%)",
-    "densitySEC": "動作濃度(SEC)",
-    "operatingCurrent": "動作電流(V)",
-    "monitoringCurrent": "監視電流(V)",
-    "relativeHumidity": "相對溼度(%)",
-    "outputSoundPressure": "輸出音壓(dB)",
-    "numberOfCircuit": "回路數(L)",
-    "powers": "功率(KW)",
-    "displacement": "排氣量(L)",
-    "workingPressure": "工作壓力(Mpa)",
-    "waterSupplyDiameter": "給水口徑(D)",
-    "drainageDiameter": "排水口徑(D)",
-    "powerLoad": "動力負載(HP/KW)",
-    "wattage": "瓦數(W)",
-    "colorTemperature": "色溫(K)",
-    "schemeOfPowerSupply": "供電方式",
-    "designPressure": "設計壓力(KG/CM^2(G))",
-    "fileName": "元件名稱",
-    "revitVersion": "元件版本"
+    "family": "族群名稱",
+    "revitVersion": "元件版本",
+    "type": "類型名稱",
+    "unit": "單位"
   }
 ]

+ 1 - 1
bim-support-body.html

@@ -40,7 +40,7 @@
   <script src="assets/javascripts/theme.init.js"></script><!-- Examples -->
 
   <script src="assets/javascripts/ui-elements/examples.modals.js"></script>
-  <script src="script/js/upload-component.js"></script>
+  <!--<script src="script/js/upload-component.js"></script>-->
   <script src="assets/javascripts/pages/examples.mediagallery.js"></script>
   <title></title>
 </head>

+ 120 - 15
component-detail.php

@@ -19,15 +19,44 @@ if (!isset($_SESSION['loggedin'])) {
 		searchURL = searchURL.substring(1, searchURL.length);
 		var name = decodeURIComponent(searchURL.split("&")[0].split("=")[1]);
 		var type = searchURL.split("&")[1].split("=")[1];
+		var parent = searchURL.split("&")[2].split("=")[1];
+		var typeInChinese = "";
+		var parentInChinese = "";
 		var userName = '<?php echo $_SESSION['name']; ?>';
 		var header = [];
+		var sizeHeader = [];
 		var value = [];
+		var sizeValue = [];
 		pageHeader = "元件庫";
+
+		$.getJSON('./assets/equipmentTable2.json', function(data) {
+			for (var i = 0; i < data.length; i++) {
+				if (parent == data[i].category_code) {
+					parentInChinese = data[i].category_name;
+				}
+				for (var j = 0; j < data[i].children.length; j++) {
+					if (type == data[i].children[j].component_code) {
+						typeInChinese = data[i].children[j].component_name;
+					}
+				}
+			}
+		});
 	</script>
+	<style>
+		.hide-image {
+			display: none;
+			z-index: 100;
+			position: absolute;
+
+		}
+
+		.preview:hover .hide-image {
+			display: block
+		}
+	</style>
 </head>
 
 <body>
-	<canvas id="c"></canvas>
 	<section class="body">
 		<!-- start: header -->
 		<header-menu></header-menu>
@@ -44,10 +73,6 @@ if (!isset($_SESSION['loggedin'])) {
 				<section class="content-with-menu content-with-menu-has-toolbar media-gallery">
 					<div class="content-with-menu-container">
 						<inner-menu>
-							<template v-slot:inner-upload>
-								<upload-component></upload-component>
-								<hr class="separator" />
-							</template>
 							<template v-slot:inner-equipment>
 								<equipment-list></equipment-list>
 							</template>
@@ -55,6 +80,11 @@ if (!isset($_SESSION['loggedin'])) {
 						<div class="inner-body mg-main">
 							<div class="inner-toolbar">
 								<ul>
+									<li>
+										<label>
+											<span id="insertComponentName" style="font-size: 30px; color: white;"></span>
+										</label>
+									</li>
 									<li class="right">
 										<a href="#" onclick="window.history.go(-1); return false;"><i class="fa fa-undo"></i> 返回</a>
 									</li>
@@ -64,10 +94,28 @@ if (!isset($_SESSION['loggedin'])) {
 								</ul>
 							</div>
 							<div class="row">
-								<div class="col-md-6" id="content" style="width:500px; position: relative; padding: 0 0 0;">
 
+								<div class="col-md-6">
+									<div class="tabs">
+										<ul class="nav nav-tabs nav-justified">
+											<li class="active">
+												<a href="#content" data-toggle="tab" class="text-center">3D元件模型</a>
+											</li>
+											<li>
+												<a href="#2DImage" data-toggle="tab" class="text-center">2D圖例</a>
+											</li>
+										</ul>
+										<div class="tab-content">
+											<div id="content" class="tab-pane active" style="width:500px; position: relative; padding: 0 0 0;">
+
+											</div>
+											<div id="2DImage" class="tab-pane" style="overflow: auto;">
+
+											</div>
+										</div>
+									</div>
 								</div>
-								<div class="col-md-offset-1 col-md-6">
+								<div class="col-md-6">
 									<section class="panel">
 										<div class="panel-body" style="padding: 0px;">
 											<div class="table-responsive">
@@ -79,11 +127,21 @@ if (!isset($_SESSION['loggedin'])) {
 											</div>
 										</div>
 									</section>
-								</div>
+									<h3>尺寸:</h3>
+									<section class="panel">
+										<div class="panel-body" style="padding: 0px;">
+											<div class="table-responsive">
+												<table class="table table-bordered mb-none">
+													<tbody id="sizeTable">
 
+													</tbody>
+												</table>
+											</div>
+										</div>
+									</section>
+								</div>
 							</div>
 						</div>
-					</div>
 				</section>
 				<!-- end: page -->
 			</section>
@@ -100,30 +158,60 @@ if (!isset($_SESSION['loggedin'])) {
 				url: "./script/php/equipment_group_detail.php",
 				type: "GET",
 				data: {
-					type: type,
+					type: typeInChinese,
 					object: name,
+					parent: parentInChinese
 				},
 				contentType: "application/json",
 				dataType: "json"
 			}).done(function(data) {
 				header = data.header;
 				value = data.value;
+				sizeHeader = data.sizeHeader;
+				sizeValue = data.sizeValue;
+
 				for (var i = 0; i < header.length; i++) {
 					if (value[i] == null)
 						value[i] = "";
 					if (header[i] == "元件版本")
 						revitVersion = value[i];
-					$('#table').append("<tr><td>" + data.header[i] + "</td><td>" + data.value[i] + "</td></tr>");
+					if (data.header[i] == "族群品類" || data.header[i] == "族群名稱" || data.header[i] == "類型名稱") {
+						$('#table').append("<tr><td><div class='preview'>" + data.header[i] + "<img src='./assets/images/" + data.header[i] + ".jpg' class='hide-image'></div></td><td><div>" + data.value[i] + "</div></td></tr>");
+					} else {
+						$('#table').append("<tr><td><div>" + data.header[i] + "</div></td><td><div>" + data.value[i] + "</div></td></tr>");
+					}
+				}
+
+				for (var i = 0; i < sizeHeader.length; i++) {
+					if (value[i] == null)
+						value[i] = "";
+					if (data.sizeHeader[i] != 0 && data.sizeValue[i] != 0) {
+						$('#sizeTable').append("<tr><td>" + data.sizeHeader[i] + "</td><td>" + data.sizeValue[i] + "</td></tr>");
+					} else
+						$('#sizeTable').append("<tr><td>無資料</td><td>無資料</td></tr>");
 				}
+				$("#insertComponentName").text(name);
+
+				$.ajax({
+					url: "./assets/glb/Revit元件/Components/" + parentInChinese + "/" + typeInChinese + "/" + name + ".PNG",
+					success: function() {
+						$("#2DImage").append("<img src='./assets/glb/Revit元件/Components/" + parentInChinese + "/" + typeInChinese + "/" + name + ".PNG' style='width: 100%; aspect-ratio: 1 / 1;'>")
+					},
+					error: function() {
+						$("#2DImage").append("<span>此元件沒有2D圖例</span>");
+					}
+				});
+
 
 			}).error(function(error) {
 				console.log(error.responseText);
 			});
+
 			$.ajax({
 				url: "./script/php/addFavorite.php",
 				type: "GET",
 				data: {
-					type: type,
+					type: typeInChinese,
 					object: name,
 				},
 				contentType: "application/json",
@@ -143,6 +231,24 @@ if (!isset($_SESSION['loggedin'])) {
 
 		});
 
+		for (var i = 0; i < jsonData.length; i++) {
+			for (var j = 0; j < jsonData[i].children.length; j++) {
+				$("a").each(function() {
+					if (jsonData[i].category_code == parent) {
+						if (jsonData[i].children[j].component_code == type) {
+							var searchText = jsonData[i].children[j].component_name;
+							var found;
+
+							if ($(this).context.innerText == searchText && $(this).context.name == jsonData[i].category_code) {
+								$(this).context.classList.add("highlight");
+								$(this).context.parentNode.parentNode.parentNode.classList.add("nav-expanded");
+							}
+						}
+					}
+				});
+			}
+		}
+
 		function AddFavorite() {
 			var stack_bar_top = {
 				"dir1": "down",
@@ -157,7 +263,7 @@ if (!isset($_SESSION['loggedin'])) {
 					url: "./script/php/addFavorite.php",
 					type: "POST",
 					data: {
-						DelFavorite: type + "/" + name,
+						DelFavorite: parentInChinese + "/" + typeInChinese + "/" + name,
 						username: userName
 					}
 				}).done(function(data) {
@@ -188,7 +294,7 @@ if (!isset($_SESSION['loggedin'])) {
 					url: "./script/php/addFavorite.php",
 					type: "POST",
 					data: {
-						AddFavorite: type + "/" + name,
+						AddFavorite: parentInChinese + "/" + typeInChinese + "/" + name,
 						username: userName,
 						revitVersion: revitVersion
 					}
@@ -201,7 +307,6 @@ if (!isset($_SESSION['loggedin'])) {
 						stack: stack_bar_top,
 						width: "100%"
 					});
-					console.log("add favorite: " + data);
 					isFavorite = true;
 					$("#heart").css("color", "Tomato");
 					$("#favorite").html('移出清單');

+ 53 - 22
component-favorite.php

@@ -23,6 +23,12 @@ if (!isset($_SESSION['loggedin'])) {
 		var $grid;
 		//var year = [];
 		pageHeader = "元件庫";
+
+		var parent = [];
+		var type = [];
+		var object = [];
+		var typeInEnglish = [];
+		var parentInEnglish = [];
 	</script>
 </head>
 
@@ -44,10 +50,6 @@ if (!isset($_SESSION['loggedin'])) {
 				<section class="content-with-menu content-with-menu-has-toolbar media-gallery">
 					<div class="content-with-menu-container">
 						<inner-menu>
-							<template v-slot:inner-upload>
-								<upload-component></upload-component>
-								<hr class="separator" />
-							</template>
 							<template v-slot:inner-equipment>
 								<equipment-list></equipment-list>
 							</template>
@@ -84,17 +86,19 @@ if (!isset($_SESSION['loggedin'])) {
 	<script>
 		$(document).ready(function() {
 
-			var aTags = document.getElementsByTagName("a");
-			var searchText = "清單列表";
-			var found;
+			$("a").each(function() {
+				var searchText = "清單列表";
+				var found;
 
-			for (var i = 0; i < aTags.length; i++) {
-				if (aTags[i].textContent == searchText) {
-					found = aTags[i];
-					break;
+				if ($(this).context.innerText == searchText) {
+					$(this).context.classList.add("highlight");
 				}
-			}
-			found.classList.add("highlight");
+			});
+
+			//$.getJSON
+			$.ajaxSetup({
+				async: false
+			});
 
 			$.ajax({
 				url: "./script/php/equipment_group_favorite.php",
@@ -107,17 +111,44 @@ if (!isset($_SESSION['loggedin'])) {
 			}).done(function(data) {
 				id = data.id;
 				path = data.path;
+				for (let i = 0; i < path.length; i++) {
+					var array = path[i].split('/');
+					parent[i] = array[0];
+					type[i] = array[1];
+					object[i] = array[2];
+				}
+
+				$.getJSON('./assets/equipmentTable2.json', function(data) {
+					for (var k = 0; k < path.length; k++) {
+						for (var i = 0; i < data.length; i++) {
+							if (parent[k] == data[i].category_name) {
+								parentInEnglish[k] = data[i].category_code;
+							}
+							for (var j = 0; j < data[i].children.length; j++) {
+								if (type[k] == data[i].children[j].component_name) {
+									typeInEnglish[k] = data[i].children[j].component_code;
+								}
+							}
+						}
+					}
+				});
+
+
 				revitVersion = data.revitVersion;
 				for (var i = 0; i < data.year.length; i++) {
 					$("#revitVersion").append('<label><input type="checkbox" value=".' + data.year[i] + '" />   ' + data.year[i] + '</label> ');
 				}
-				$grid = $("#content").isotope({
-					itemSelector: ".isotope-item",
-					layoutMode: 'fitRows'
-				})
-				$.when(initThreeJS()).then(
-					$grid.isotope()
-				);
+
+				$.when(initThreeJS()).then(function() {
+					$grid = $("#content").isotope({
+						itemSelector: ".isotope-item",
+						layoutMode: 'fitRows'
+					});
+				}).then(function() {
+					setTimeout(function() {
+						$grid.isotope()
+					}, 100);
+				});
 
 			}).error(function(error) {
 				console.log(error);
@@ -125,6 +156,7 @@ if (!isset($_SESSION['loggedin'])) {
 
 		});
 
+		//刪除元件checkbox
 		$(document).on("change", "input[name='delCheck']", function() {
 			if ($(this).prop('checked') === true) {
 				delFavoriteList.push($(this).attr('value'));
@@ -146,9 +178,8 @@ if (!isset($_SESSION['loggedin'])) {
 			}).error(function(error) {
 				console.log(error);
 			});
-
-
 		}
+
 	</script>
 	<script src="script/js/3Dpic-favorite.js" type="module"></script>
 

+ 136 - 35
component-list.php

@@ -15,18 +15,55 @@ if (!isset($_SESSION['loggedin'])) {
 		var rvtName = [];
 		var categoryTable = [];
 		var year = [];
+
+		//當選擇大項時,需要展示所有'細項分類'內的元件
+		var category = [];
+		var categoryInEnglish = [];
+
+		//現在的細項分類
 		var type = "";
+		var typeInChinese = "";
+
+		//現在的大項分類
+		var parent = "";
+		var parentInChinese = "";
+
+		//類別的中英文字典,中文是為了檔案路徑
+		var allTypeInEnglish = [];
+		var allTypeInChinese = [];
+		var allParentInEnglish = [];
+		var allParentInChinese = [];
+
 		var userName = '<?php echo $_SESSION['name']; ?>';
 		var searchURL = window.location.search;
+
 		searchURL = searchURL.substring(1, searchURL.length);
-		type = searchURL.split("&")[0].split("=")[1];
-		if (type === undefined) {
-			window.location.href = "?type=CA";
-			type = 'CA';
+		if (searchURL != "") {
+			//類別選擇細項
+			if (searchURL.split("&") != undefined && searchURL.split("&")[1] != undefined) {
+				type = searchURL.split("&")[0].split("=")[1];
+				parent = searchURL.split("&")[1].split("=")[1];
+			//類別選擇大項
+			} else if (searchURL.split("&") != undefined && searchURL.split("&")[1] == undefined) {
+				parent = searchURL.split("&")[0].split("=")[1];
+			}
 		}
+
 		var $grid;
 
 		pageHeader = "元件庫";
+
+		//匯入大細項類別的中英文字典
+		$.getJSON('./assets/equipmentTable2.json', function(data) {
+			for (var i = 0; i < data.length; i++) {
+				allParentInEnglish.push(data[i].category_code);
+				allParentInChinese.push(data[i].category_name);
+				for (var j = 0; j < data[i].children.length; j++) {
+					allTypeInEnglish.push(data[i].children[j].component_code);
+					allTypeInChinese.push(data[i].children[j].component_name);
+				}
+			}
+		});
 	</script>
 </head>
 
@@ -48,10 +85,6 @@ if (!isset($_SESSION['loggedin'])) {
 				<section class="content-with-menu content-with-menu-has-toolbar media-gallery">
 					<div class="content-with-menu-container">
 						<inner-menu>
-							<template v-slot:inner-upload>
-								<upload-component></upload-component>
-								<hr class="separator" />
-							</template>
 							<template v-slot:inner-equipment>
 								<equipment-list></equipment-list>
 							</template>
@@ -82,68 +115,136 @@ if (!isset($_SESSION['loggedin'])) {
 	<script type="application/javascript">
 		$(function() {
 
-			for (var i = 0; i < jsonData.length; i++) {
-				if (jsonData[i]["equipment_code"].includes(type)) {
-					var aTags = document.getElementsByTagName("a");
-					var searchText = jsonData[i]["equipment_name"];
-					var found;
-
-					for (var i = 0; i < aTags.length; i++) {
-						if (aTags[i].textContent == searchText) {
-							found = aTags[i];
-							break;
-						}
-					}
-					found.classList.add("highlight");
+			//現在大項的中文
+			for (var i = 0; i < allParentInEnglish.length; i++) {
+				if (allParentInEnglish[i] == parent) {
+					parentInChinese = allParentInChinese[i];
 				}
 			}
 
+			//現在細項的中文
+			for (var i = 0; i < allTypeInEnglish.length; i++) {
+				if (allTypeInEnglish[i] == type) {
+					typeInChinese = allTypeInChinese[i];
+				}
+			}
+
+			//撈現在類別內的元件
 			$.ajax({
 				url: "./script/php/equipment_group.php",
 				type: "GET",
 				data: {
-					type: type
+					type: typeInChinese,
+					parent: parentInChinese
 				},
 				contentType: "application/json",
 				dataType: "json"
 			}).done(function(data) {
 				year = data['year'];
 				rvtName = data['rvtName'];
-				categoryTable = data['categoryTable'];
-				for (var i = 0; i < data["categoryList"].length; i++) {
-					$("#filters").append('<li><a class="button" data-filter=".' + i + '">' + data['categoryList'][i] + '</a></li>');
+				category = data["category"];
+
+				//若類別選大項,需要列所有細項的元件,因此需要所有元件的細項名稱
+				for (var i = 0; i < category.length; i++) {
+					for (var j = 0; j < allTypeInChinese.length; j++) {
+						if (category[i] == allTypeInChinese[j]) {
+							categoryInEnglish[i] = allTypeInEnglish[j];
+						}
+					}
 				}
 
-				$.when(initThreeJS()).then(function() {
-					$grid = $("#content").isotope({
-						itemSelector: ".isotope-item",
-						layoutMode: 'fitRows'
+				//一開始進入BIM元件庫顯示
+				if (searchURL == "") {
+					$("#content").append("<h3>請選擇左方類別以搜尋元件</h3>");
+					$("#content").css("padding", "0");
+					$("#content").css("text-align", "center");
+				}
+
+				if (!(type == "" && parent == "")) {
+					$.when(initThreeJS()).then(function() {
+
+						$grid = $("#content").isotope({
+							itemSelector: ".isotope-item",
+							layoutMode: 'fitRows'
+						});
+
+						//若選到細項,該細項內沒有元件檔案
+						if ($("#content").children().length == 0 && searchURL != "") {
+							$("#content").append("<h3>此類別沒有元件檔案</h3>");
+							$("#content").css("padding", "0");
+							$("#content").css("text-align", "center");
+						}
+
+					}).then(function() {
+
+						//元件有時候會不排版
+						setTimeout(function() {
+							$grid.isotope()
+						}, 100);
+
 					});
-				}).then(function() {
-					setTimeout(function() {
-						$grid.isotope()
-					}, 100);
-				});
+				}
 
 			}).error(function(error) {
 				console.log(error);
 			});
+
 			$.ajax({
 				url: "./script/php/equipment_revitVersion.php",
 				type: "GET",
 				data: {
-					type: type
+					type: type,
+					parent: parent
 				},
 				contentType: "application/json",
 				dataType: "json"
 			}).done(function(data) {
+
+				//篩選內元件版本
 				for (var i = 0; i < data.length; i++) {
 					$("#revitVersion").append('<label><input type="checkbox" value=".' + data[i] + '" />   ' + data[i] + '</label> ');
 				}
+
 			}).error(function(error) {
 				console.log(error);
 			});
 
+			//被選到的類別highlight起來
+			for (var i = 0; i < jsonData.length; i++) {
+				for (var j = 0; j < jsonData[i].children.length; j++) {
+					$("a").each(function() {
+						if (jsonData[i].category_code == parent) {
+							//選到的是細項類別
+							if (jsonData[i].children[j].component_code == type) {
+								var searchText = jsonData[i].children[j].component_name;
+								var found;
+
+								if ($(this).context.innerText == searchText && $(this).context.name == jsonData[i].category_code) {
+									$(this).context.classList.add("highlight");
+									$(this).context.parentNode.parentNode.parentNode.classList.add("nav-expanded");
+								}
+								//選到的是大項類別
+							} else if (type == "") {
+								var searchText = parentInChinese;
+								var found;
+
+								if ($(this).context.innerText == searchText && $(this).context.name == jsonData[i].category_code) {
+									if (!$(this).context.classList.contains("highlight")) {
+										$(this).context.classList.add("highlight");
+										$(this).context.setAttribute("style", "background: #0088cc");
+									} else {
+										$(this).context.removeAttribute("href");
+									}
+
+								}
+							}
+						}
+
+					});
+				}
+			}
+
+
 		});
 	</script>
 	<script src="script/js/3Dpic.js" type="module"></script>

+ 93 - 204
script/js/3Dpic-detail.js

@@ -6,236 +6,125 @@
 		OrbitControls
 	} from '../jsm/controls/OrbitControls.js';
 
-	let canvas, renderer;
+	let scene, camera, controls, renderer;
 
 	const scenes = [];
-	//const category = ['1', '2', '3'];
 
 	init();
 	animate();
 
 	function init() {
 
-		canvas = document.getElementById("c");
-
-		const content = document.getElementById('content');
-
-		var i = 0;
-
-			const scene = new THREE.Scene();
-			//scene.background = new THREE.Color(0x000000);
-
-			
-			// make a list item
-			const isotope = document.createElement('div');
-			content.appendChild(isotope);
-
-			const thumbnail = document.createElement('div');
-			thumbnail.className = 'thumbnail';
-			isotope.appendChild(thumbnail);
-
-			const element = document.createElement('div');
-			//element.className = 'thumb-preview list-item';
-			element.className = 'thumb-preview';
-			//element.className = 'list-item';
-			thumbnail.appendChild(element);
-
-			const a = document.createElement('a');
-			a.className = "thumb-image";
-			a.href = "assets/images/projects/project-8.png";
-			element.appendChild(a);
-
-			const sceneElement = document.createElement('div');
-			element.appendChild(sceneElement);
-
-			const img = document.createElement('img');
-			img.src = "assets/images/projects/project-8.png";
-			img.className = 'img-responsive';
-			sceneElement.appendChild(img);
-
-
-
-			// the element that represents the area we want to render the scene
-			scene.userData.element = sceneElement;
-			thumbnail.appendChild(element);
-
-			
-
-			/*const pullLeft = document.createElement('small');
-			pullLeft.className = 'pull-right text-muted';
-			pullLeft.innerText = 'Revit '+ year[i];
-			mgdescription.appendChild(pullLeft);*/
-
-
-			const camera = new THREE.PerspectiveCamera(50, 1, 1, 1000);
-			camera.position.set(0, 2.5, 8);
-			scene.userData.camera = camera;
-			//scene = new THREE.Scene();
-			scene.background = new THREE.Color(0x15608c);
-
-			const hemiLight = new THREE.HemisphereLight(0xffffff, 0x444444);
-			hemiLight.position.set(0, 20, 0);
-			scene.add(hemiLight);
-
-			const spotLight = new THREE.SpotLight(0xffffff);
-			spotLight.position.set(15, 40, 35);
-			spotLight.castShadow = true;
-			spotLight.intensity = 0.5;
-			scene.add(spotLight);
-			const spotLight2 = new THREE.SpotLight(0xffffff);
-			spotLight2.position.set(15, 40, -35);
-			spotLight2.castShadow = true;
-			spotLight2.intensity = 0.5;
-			scene.add(spotLight2);
-
-			const dirLight = new THREE.DirectionalLight(0xffffff);
-			dirLight.position.set(5, 5, 0);
-			dirLight.castShadow = true;
-			dirLight.shadow.camera.top = 1;
-			dirLight.shadow.camera.bottom = -1;
-			dirLight.shadow.camera.left = -1;
-			dirLight.shadow.camera.right = 1;
-			dirLight.shadow.camera.near = 0.1;
-			dirLight.shadow.camera.far = 20;
-			scene.add(dirLight);
-
-			const mesh = new THREE.Mesh(new THREE.PlaneGeometry(50, 50), new THREE.MeshPhongMaterial({
-				color: 0x999999,
-				depthWrite: false
-			}));
-			mesh.rotation.x = -Math.PI / 2;
-			mesh.receiveShadow = true;
-			scene.add(mesh);
-
-			const grid = new THREE.GridHelper(50, 50, 0x888888, 0x888888);
-			scene.add(grid);
-
-			const controls = new OrbitControls(scene.userData.camera, scene.userData.element);
-			controls.target.set(0, 2, 0);
-			controls.minDistance = 0.5;
-			controls.maxDistance = 10;
-			controls.maxPolarAngle = 0.5 * Math.PI;
-			controls.autoRotate = true;
-			scene.userData.controls = controls;
-
-
-
-			var loader = new GLTFLoader();
-			loader.setPath("./assets/glb/Revit元件/Components/Arch/MEP/" + type + "/");
-			
-
-			loader.load(name + ".glb", function (gltf) {
-				var mroot = gltf.scene;
-				var bbox = new THREE.Box3().setFromObject(mroot);
-				var cent = bbox.getCenter(new THREE.Vector3());
-				var size = bbox.getSize(new THREE.Vector3());
-
-				//Rescale the object to normalized space
-				var maxAxis = Math.max(size.x, size.y, size.z);
-				mroot.scale.multiplyScalar(5.0 / maxAxis);
-				bbox.setFromObject(mroot);
-				bbox.getCenter(cent);
-				bbox.getSize(size);
-				//Reposition to 0,halfY,0
-				mroot.position.copy(cent).multiplyScalar(-1);
-				mroot.position.y += (size.y * 0.5);
-				mroot.traverse(function (object) {
-					if (object.isMesh) {
-						object.castShadow = true;
-						if (object.material.name == '玻璃') {
-							object.material.transparent = true;
-							object.material.opacity = 0;
-						}
+		const container = document.getElementById('content');
+
+		scene = new THREE.Scene();
+
+		camera = new THREE.PerspectiveCamera(50, 1, 1, 1000);
+		camera.position.set(0, 2.5, 8);
+		scene.userData.camera = camera;
+		scene.background = new THREE.Color(0x15608c);
+
+		const hemiLight = new THREE.HemisphereLight(0xffffff, 0x444444);
+		hemiLight.position.set(0, 20, 0);
+		scene.add(hemiLight);
+
+		const spotLight = new THREE.SpotLight(0xffffff);
+		spotLight.position.set(15, 40, 35);
+		spotLight.castShadow = true;
+		spotLight.intensity = 0.5;
+		scene.add(spotLight);
+		const spotLight2 = new THREE.SpotLight(0xffffff);
+		spotLight2.position.set(15, 40, -35);
+		spotLight2.castShadow = true;
+		spotLight2.intensity = 0.5;
+		scene.add(spotLight2);
+
+		const dirLight = new THREE.DirectionalLight(0xffffff);
+		dirLight.position.set(5, 5, 0);
+		dirLight.castShadow = true;
+		dirLight.shadow.camera.top = 1;
+		dirLight.shadow.camera.bottom = -1;
+		dirLight.shadow.camera.left = -1;
+		dirLight.shadow.camera.right = 1;
+		dirLight.shadow.camera.near = 0.1;
+		dirLight.shadow.camera.far = 20;
+		scene.add(dirLight);
+
+		const mesh = new THREE.Mesh(new THREE.PlaneGeometry(50, 50), new THREE.MeshPhongMaterial({
+			color: 0x999999,
+			depthWrite: false
+		}));
+		mesh.rotation.x = -Math.PI / 2;
+		mesh.receiveShadow = true;
+		scene.add(mesh);
+
+		const grid = new THREE.GridHelper(50, 50, 0x888888, 0x888888);
+		scene.add(grid);
+
+		var loader = new GLTFLoader();
+		loader.setPath("./assets/glb/Revit元件/Components/" + parentInChinese + "/" + typeInChinese + "/");
+
+		loader.load(name + ".glb", function (gltf) {
+			var mroot = gltf.scene;
+			var bbox = new THREE.Box3().setFromObject(mroot);
+			var cent = bbox.getCenter(new THREE.Vector3());
+			var size = bbox.getSize(new THREE.Vector3());
+
+			//Rescale the object to normalized space
+			var maxAxis = Math.max(size.x, size.y, size.z);
+			mroot.scale.multiplyScalar(5.0 / maxAxis);
+			bbox.setFromObject(mroot);
+			bbox.getCenter(cent);
+			bbox.getSize(size);
+			//Reposition to 0,halfY,0
+			mroot.position.copy(cent).multiplyScalar(-1);
+			mroot.position.y += (size.y * 0.5);
+			mroot.traverse(function (object) {
+				if (object.isMesh) {
+					object.castShadow = true;
+					if (object.material.name == '玻璃') {
+						object.material.transparent = true;
+						object.material.opacity = 0;
 					}
-				});
-				scene.add(mroot);
-
+				}
 			});
+			scene.add(mroot);
 
+		});
 
-
-			scenes.push(scene);
-
-		
+		scenes.push(scene);
 
 		renderer = new THREE.WebGLRenderer({
-			canvas: canvas,
 			antialias: true
 		});
 		renderer.setClearColor(0xffffff, 1);
 		renderer.setPixelRatio(window.devicePixelRatio);
 		renderer.outputEncoding = THREE.sRGBEncoding;
 		renderer.shadowMap.enabled = true;
+
+		controls = new OrbitControls(camera, renderer.domElement);
+		controls.target.set(0, 2, 0);
+		controls.minDistance = 0.5;
+		controls.maxDistance = 10;
+		controls.maxPolarAngle = 0.5 * Math.PI;
+		controls.autoRotate = true;
+		scene.userData.controls = controls;
+
+		container.appendChild(renderer.domElement);
 	}
 
-	function updateSize() {
+	function animate() {
 
+		//render();
+		const canvas = renderer.domElement.parentNode.parentNode;
 		const width = canvas.clientWidth;
 		const height = canvas.clientHeight;
-
-		if (canvas.width !== width || canvas.height !== height) {
-
-			renderer.setSize(width, height, false);
-
+		if (canvas.width !== width || canvas.height !== width) {
+			renderer.setSize(width-30, width-30, false);
 		}
 
-	}
-
-	function animate() {
-
-		render();
+		renderer.render(scene, camera);
+		controls.update();
 		requestAnimationFrame(animate);
 
-	}
-
-	function render() {
-
-		updateSize();
-
-		canvas.style.transform = `translateY(${window.scrollY}px)`;
-
-		renderer.setClearColor(0xffffff);
-		renderer.setScissorTest(false);
-		renderer.clear();
-
-		renderer.setClearColor(0xe0e0e0);
-		renderer.setScissorTest(true);
-
-		scenes.forEach(function (scene) {
-
-			// get the element that is a place holder for where we want to
-			// draw the scene
-			const element = scene.userData.element;
-
-			// get its position relative to the page's viewport
-			const rect = element.getBoundingClientRect();
-
-			// check if it's offscreen. If so skip it
-			if (rect.bottom < 0 || rect.top > renderer.domElement.clientHeight ||
-				rect.right < 0 || rect.left > renderer.domElement.clientWidth) {
-
-				return; // it's off screen
-
-			}
-
-			// set the viewport
-			const width = rect.right - rect.left;
-			const height = rect.bottom - rect.top;
-			const left = rect.left;
-			const bottom = renderer.domElement.clientHeight - rect.bottom;
-
-			renderer.setViewport(left, bottom, width, height);
-			renderer.setScissor(left, bottom, width, height);
-
-			const camera = scene.userData.camera;
-
-			//camera.aspect = width / height; // not changing in this example
-			//camera.updateProjectionMatrix();
-
-			scene.userData.controls.update();
-
-			renderer.render(scene, camera);
-
-		});
-	}
-
+	}

+ 18 - 16
script/js/3Dpic-favorite.js

@@ -11,8 +11,9 @@
 	const scenes = [];
 	//const category = ['1', '2', '3'];
 
-	
+
 	window.initThreeJS = init;
+
 	function init() {
 
 		canvas = document.getElementById("c");
@@ -20,11 +21,10 @@
 		const content = document.getElementById('content');
 
 		for (let i = 0; i < id.length; i++) {
-			var type = path[i].split('/');
+
 			const scene = new THREE.Scene();
 			//scene.background = new THREE.Color(0x000000);
 
-			
 			// make a list item
 			const isotope = document.createElement('div');
 			isotope.className = 'isotope-item ' + revitVersion[i] + ' ' + categoryTable[i] + ' col-sm-6 col-md-4 col-lg-3';
@@ -56,7 +56,7 @@
 			element.appendChild(sceneElement);
 
 			const aImg = document.createElement('a');
-			aImg.setAttribute("href", "component-detail.php?object=" + type[1] + "&type=" + type[0]);
+			aImg.setAttribute("href", "component-detail.php?object=" + object[i] + "&type=" + typeInEnglish[i] + "&parent=" + parentInEnglish[i]);
 			sceneElement.appendChild(aImg);
 
 			const img = document.createElement('img');
@@ -72,8 +72,9 @@
 			thumbnail.appendChild(element);
 
 			const h5 = document.createElement('a');
-			h5.innerText = type[1];
-			h5.setAttribute("href","component-detail.php?object="+type[1]+"&type="+type[0]);
+			h5.innerText = object[i];
+			h5.setAttribute("href", "component-detail.php?object=" + object[i] + "&type=" + typeInEnglish[i] + "&parent=" + parentInEnglish[i]);
+			h5.style = "padding-bottom: 0px;"
 			thumbnail.appendChild(h5);
 
 			const smallRvt = document.createElement('small');
@@ -94,7 +95,7 @@
 
 			const pullRight = document.createElement('small');
 			pullRight.className = 'pull-right text-muted';
-			pullRight.innerText = 'Revit '+ revitVersion[i];
+			pullRight.innerText = 'Revit ' + revitVersion[i];
 			mgdescription.appendChild(pullRight);
 
 			const camera = new THREE.PerspectiveCamera(50, 1, 1, 1000);
@@ -153,11 +154,12 @@
 			}
 			scene.userData.controls = controls;
 
-			
+
 
 			var loader = new GLTFLoader();
-			loader.setPath("./assets/glb/Revit元件/Components/Arch/MEP/" + type[0] + "/");
-			var name = type[1] + ".glb";
+			loader.setPath("./assets/glb/Revit元件/Components/" + parent[i] + "/" + type[i] + "/");
+			
+			var name = object[i] + ".glb";
 
 			loader.load(name, function (gltf) {
 				var mroot = gltf.scene;
@@ -201,11 +203,11 @@
 		renderer.setPixelRatio(window.devicePixelRatio);
 		renderer.outputEncoding = THREE.sRGBEncoding;
 		renderer.shadowMap.enabled = true;
-		
+
 		animate();
 	}
 
-	function ellipsis(str){
+	function ellipsis(str) {
 		return (str.length > 32) ? str.substr(0, 31) + '...' : str;
 	}
 
@@ -280,9 +282,9 @@
 		});
 	}
 
-	$('input[name="delCheck"]').change(function() {
-		delFavoriteList = [];		
-		$('input[name="delCheck"]:checked').each(function() {
+	$('input[name="delCheck"]').change(function () {
+		delFavoriteList = [];
+		$('input[name="delCheck"]:checked').each(function () {
 			delFavoriteList.push($(this).val());
 		});
-	});
+	});

+ 25 - 34
script/js/3Dpic.js

@@ -9,7 +9,6 @@
 	let canvas, renderer;
 
 	const scenes = [];
-	//const category = ['1', '2', '3'];	
 
 	window.initThreeJS = init;
 
@@ -23,7 +22,7 @@
 			const scene = new THREE.Scene();
 			// make a list item
 			const isotope = document.createElement('div');
-			isotope.className = 'isotope-item ' + categoryTable[i] + ' ' + year[i] + ' col-sm-6 col-md-4 col-lg-3';
+			isotope.className = 'isotope-item ' + year[i] + ' col-sm-6 col-md-4 col-lg-3';
 			content.appendChild(isotope);
 
 			const thumbnail = document.createElement('div');
@@ -31,28 +30,25 @@
 			isotope.appendChild(thumbnail);
 
 			const element = document.createElement('div');
-			//element.className = 'thumb-preview list-item';
 			element.className = 'thumb-preview';
-			//element.className = 'list-item';
 			thumbnail.appendChild(element);
 
 			const a = document.createElement('div');
 			a.className = "thumb-image";
 			a.href = "assets/images/projects/project-8.png";
 			element.appendChild(a);
-			/*
-								const thumbImage = document.createElement('a');
-								thumbImage.className = 'thumb-image';
-								preview.appendChild(thumbImage);
-
-								const element = document.createElement( 'div' );
-								element.className = 'list-item';
-			*/
+
 			const sceneElement = document.createElement('div');
 			element.appendChild(sceneElement);
 
 			const aImg = document.createElement('a');
-			aImg.setAttribute("href", "component-detail.php?object=" + rvtName[i] + "&type=" + type);
+			if (type != "")
+				aImg.setAttribute("href", "component-detail.php?object=" + rvtName[i] + "&type=" + type + "&parent=" + parent);
+			else
+				aImg.setAttribute("href", "component-detail.php?object=" + rvtName[i] + "&type=" + categoryInEnglish[i] + "&parent=" + parent);
+			
+
+
 			sceneElement.appendChild(aImg);
 
 			const img = document.createElement('img');
@@ -61,15 +57,17 @@
 			img.alt = 'Project';
 			aImg.appendChild(img);
 
-
-
 			// the element that represents the area we want to render the scene
 			scene.userData.element = sceneElement;
 			thumbnail.appendChild(element);
 
 			const h5 = document.createElement('a');
 			h5.innerText = rvtName[i];
-			h5.setAttribute("href", "component-detail.php?object=" + rvtName[i] + "&type=" + type);
+			if (type != "")
+				h5.setAttribute("href", "component-detail.php?object=" + rvtName[i] + "&type=" + type + "&parent=" + parent);
+			else
+				h5.setAttribute("href", "component-detail.php?object=" + rvtName[i] + "&type=" + categoryInEnglish[i] + "&parent=" + parent);
+			
 			thumbnail.appendChild(h5);
 
 			const smallRvt = document.createElement('small');
@@ -87,15 +85,6 @@
 			pullLeft.innerText = 'Revit ' + year[i];
 			mgdescription.appendChild(pullLeft);
 
-			/*var year = Math.floor(Math.random() * 11) + 2010;
-			var month = Math.floor(Math.random() * 12) + 1;
-			var date = Math.floor(Math.random() * 28) + 1;
-
-			const pullRight = document.createElement('small');
-			pullRight.className = 'pull-right text-muted';
-			pullRight.innerText = year + '/' + month + '/' + date;
-			mgdescription.appendChild(pullRight);*/
-
 			const camera = new THREE.PerspectiveCamera(50, 1, 1, 1000);
 			camera.position.set(0, 2.5, 8);
 			scene.userData.camera = camera;
@@ -139,24 +128,25 @@
 			const grid = new THREE.GridHelper(50, 50, 0x888888, 0x888888);
 			scene.add(grid);
 
-			
+
 			const controls = new OrbitControls(scene.userData.camera, scene.userData.element);
 			controls.target.set(0, 2, 0);
 			controls.minDistance = 0.5;
 			controls.maxDistance = 10;
 			controls.maxPolarAngle = 0.5 * Math.PI;
 			controls.autoRotate = true;
-			controls.mouseButtons = {
-				LEFT: '',
-				TOP: '',
-				RIGHT: ''
-			}
+			controls.enableZoom = false;
+			controls.enableRotate = false;
+			controls.enablePan = false;
 			scene.userData.controls = controls;
-			
 
 
+			//change to new directory
 			var loader = new GLTFLoader();
-			loader.setPath("./assets/glb/Revit元件/Components/Arch/MEP/" + type + "/");
+			if (typeInChinese != "")
+				loader.setPath("./assets/glb/Revit元件/Components/" + parentInChinese + "/" + typeInChinese + "/");
+			else
+				loader.setPath("./assets/glb/Revit元件/Components/" + parentInChinese + "/" + category[i] + "/");
 			var name = rvtName[i] + ".glb";
 
 			loader.load(name, function (gltf) {
@@ -183,6 +173,7 @@
 						}
 					}
 				});
+
 				scene.add(mroot);
 
 			});
@@ -204,7 +195,7 @@
 		animate();
 	}
 
-	function ellipsis(str){
+	function ellipsis(str) {
 		return (str.length > 32) ? str.substr(0, 31) + '...' : str;
 	}
 

+ 2 - 2
script/js/getEquipmentJson.js

@@ -1,8 +1,8 @@
 var jsonData;
 var getUrl = window.location;
 var baseUrl = getUrl .protocol + "//" + getUrl.host + "/" + getUrl.pathname.split('/')[1];
-var requestURL = baseUrl + '/assets/equipmentTable.json';
-//var requestURL = baseUrl + '/assets/equipmentTable2.json';
+//var requestURL = baseUrl + '/assets/equipmentTable.json';
+var requestURL = baseUrl + '/assets/equipmentTable2.json';
 var request = new XMLHttpRequest();
 request.onreadystatechange = function () {
     if (this.readyState == 4 && this.status == 200) {

+ 53 - 26
script/js/global.js

@@ -201,7 +201,7 @@ vm.component('filter-bar', {
 });
 
 vm.component('filter-content', {
-    template: `<div id="filter-content" class="panel-body" style="display:none">
+    template: `<div id="filter-content" class="panel-body" style="display:none;">
     <label style="padding: 10px 15px;">元件版本:</label>
     <div class="btn-group">
         <div id="options">
@@ -210,21 +210,9 @@ vm.component('filter-content', {
             </div>
         </div>
     </div>
-    <div class="filters">
-        <div class="ui-group">
-            <ul class="button-group nav nav-pills nav-pills-primary" data-filter-group="type" id="filters">
-                <li style="padding: 10px 15px;">
-                    <label>族群品類:</label>
-                </li>
-                <li class="active">
-                    <a class="button" data-filter="">any</a>
-                </li>
-            </ul>
-        </div>
-    </div>
-    
 </div>`,
 });
+
 vm.component('filter-content2', {
     data() {
         return {
@@ -232,7 +220,7 @@ vm.component('filter-content2', {
             objectFilter: objectFilter,
         }
     },
-    template: `<div id="filter-content" class="panel-body" style="display:none">
+    template: `<div id="filter-content" class="panel-body" style="display:none;">
     <div class="filters">
         <div class="ui-group">
             <ul class="button-group nav nav-pills nav-pills-primary" data-filter-group="software">
@@ -294,7 +282,6 @@ vm.component('filter-li', {
 
 });
 
-
 vm.component('side-bar-list', {
     template: `<li v-bind:class = "GetLocation?'nav-active':''">
     <a v-bind:href="href">
@@ -429,24 +416,64 @@ vm.component('equipment-list', {
             url: "component-favorite.php?userName=" + userName,
         }
     },
-    template: `<div class="sidebar-widget m-none">
+    template: `
+    <div class="sidebar-widget m-none">
     <div class="widget-header clearfix">
         <h6 class="title pull-left mt-xs">類別</h6>                    
     </div>
     <div class="widget-content">
-        <ul class="mg-folders">
-            <inner-menu-li v-for="item in jsonData" v-bind:href="hrefLink(item.equipment_code)" v-bind:name="item.equipment_name"></inner-menu-li>                        
-            <hr class="separator" />
-            <li>
-                <a v-bind:href="url" class="menu-item"><i class="fa fa-gears"></i>清單列表</a>
-            </li>
-        </ul>
+        <nav id="menu" class="nav-main" role="navigation">
+            <ul class="nav nav-main">
+                <special-li v-for="item in jsonData" v-bind:name="item.category_name" v-bind:children="item.children" v-bind:parent="item.category_code"></special-li>     
+                <hr class="separator" />
+                <li>
+                    <a v-bind:href="url" class="menu-item"><i class="fa fa-gears"></i>清單列表</a>
+                </li>
+            </ul>
+        </nav>
+        
 
     </div>
 </div>`,
+
+});
+
+vm.component('special-li', {
+    template: `
+    <li class="nav-parent">
+        <a class="dropdown-btn" v-bind:href="hrefLink(parent)" v-bind:name="parent">{{name}}</a>
+        <ul class="nav nav-children" style="background: inherit; padding-left: 15px;">
+            <special-li2 v-for="item in children" v-bind:href="item.component_code" v-bind:name="item.component_name" v-bind:parent="parent"></special-li2>
+        </ul>
+    </li>
+    `,
+
+    props: {
+        name: String,
+        children: Array,
+        parent: String
+    },
+    methods: {
+        hrefLink(parent) {
+            return 'component-list.php?parent=' + parent;
+        }
+    }
+});
+
+vm.component('special-li2', {
+    template: `
+    <li>
+        <a v-bind:href="hrefLink(href, parent)" class="menu-item" v-bind:name="parent">{{name}}</a>
+    </li>
+    `,
+    props: {
+        href: String,
+        name: String,
+        parent: String
+    },
     methods: {
-        hrefLink(code) {
-            return 'component-list.php?type=' + code;
+        hrefLink(code, parent) {
+            return 'component-list.php?type=' + code + '&parent=' + parent;
         }
     }
 });

+ 14 - 28
script/php/equipment_group.php

@@ -1,44 +1,30 @@
 <?php
 include("connectSQL_Component.php");
-if (isset($_GET["type"])) {
+if (isset($_GET["type"]) && isset($_GET["parent"])) {
+
     $type = $_GET["type"];
-    $sql = 'SELECT DISTINCT [category] FROM [BIMComponents].[dbo].[Arch_MEP_' . $type . ']';
-    $fetchResult = sqlsrv_query($conn, $sql);
-    $html = '';
-    $categoryTable = [];
-    $categoryList = [];
+    $parent = $_GET["parent"];
     $year = [];
     $rvtName = [];
-    $i = 0;   
-    while ($row = sqlsrv_fetch_array($fetchResult)) {
-        if ($row["category"] != null) {            
-            array_push($categoryList, $row["category"]);
-            $i++;
-        }
-    }
-
+    $category = [];
 
-    $sql = 'SELECT [category] FROM [BIMComponents].[dbo].[Arch_MEP_' . $type . ']';
-    $fetchResult = sqlsrv_query($conn, $sql);
-    $html = '';
-
-    $i = 0;
-    while ($row = sqlsrv_fetch_array($fetchResult)) {
-        $key = array_search($row["category"], $categoryList);       
-        array_push($categoryTable, $key);
-    }    
-    $sql = 'SELECT * FROM [BIMComponents].[dbo].[Arch_MEP_' . $type . ']';
+    if($type != ""){
+        $sql = "SELECT * FROM [BIMComponents].[dbo].[Component_Info] WHERE [componentGroup] LIKE '%".$parent."%' AND [category] = '".$type."';";
+    }else{
+        $sql = "SELECT * FROM [BIMComponents].[dbo].[Component_Info] WHERE [componentGroup] LIKE '%".$parent."%';";
+    }
+    
     $fetchResult = sqlsrv_query($conn, $sql);
     while ($row = sqlsrv_fetch_array($fetchResult)) {        
-        array_push($rvtName, $row["fileName"]);
+        array_push($rvtName, $row["componentName"]);
         array_push($year, $row["revitVersion"]);
+        array_push($category, $row["category"]);
     }
+    
     $array = array();
-    $array["categoryTable"] = $categoryTable;
-    $array["categoryList"] = $categoryList;
     $array["rvtName"] = $rvtName;
     $array["year"] = $year;
+    $array["category"] = $category;
     echo json_encode($array);
 }
-
 sqlsrv_close($conn);

+ 31 - 7
script/php/equipment_group_detail.php

@@ -1,36 +1,60 @@
 <?php
 include("connectSQL_Component.php");
 if (isset($_GET["object"]) && isset($_GET["type"])) {
+    
     $type = $_GET["type"];
     $name = $_GET["object"];
+    $parent = $_GET["parent"];
+
+    $COLUMN_NAME = [];
     $table_header = [];
+    $size_table_header = [];
     $table_value = [];
-    $COLUMN_NAME = [];
-    $table= [];
-    $sql = "SELECT COLUMN_NAME 
-    FROM INFORMATION_SCHEMA.COLUMNS
-    WHERE TABLE_NAME = 'Arch_MEP_" . $type . "' ";
+    $size_table_value = [];
+    $table = [];
+    $size_table = [];
+    $id = "";
+    $unit = "";
+
+    $sql = "SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'Component_Info';";
     $fetchResult = sqlsrv_query($conn, $sql);
     while ($row = sqlsrv_fetch_array($fetchResult)) {
         array_push($COLUMN_NAME, $row["COLUMN_NAME"]);
     }
-    $sql = "SELECT * FROM [BIMComponents].[dbo].[Arch_MEP_" . $type . "] Where [fileName] = '" . $name . "';";
+
+    $sql = "SELECT * FROM [BIMComponents].[dbo].[Component_Info] Where [componentName] = '" . $name . "' AND [category] = '" . $type . "';";
     $fetchResult = sqlsrv_query($conn, $sql);
     $string = file_get_contents("../../assets/columnTable.json");
     $json = json_decode($string, true);
     while ($row = sqlsrv_fetch_array($fetchResult, SQLSRV_FETCH_NUMERIC)) {
         $table = $row;
     }
+    
     foreach ($table as $key => $value) {
-        if ($key != 0) {
+        if ($key != 0 && $key != 1 && $key != 2 && $key != 7) {
             array_push($table_header, $json[0][$COLUMN_NAME[$key]]);
             array_push($table_value, $value);
+        }else if($key == 0){
+            $id = $value;
+        }else if ($key == 7){
+            $unit = $value;
         }
     }
 
+    $sql = "SELECT * FROM [BIMComponents].[dbo].[Component_Size] WHERE [id] = '".$id."';";
+    $fetchResult = sqlsrv_query($conn, $sql);
+    while($row = sqlsrv_fetch_array($fetchResult)){
+        array_push($size_table_header, $row["sizeColumn"]);
+        array_push($size_table_value, $row["sizeValue"]." ".$unit);
+    }
+
     $array = array();
     $array["header"] = $table_header;
     $array["value"] = $table_value;
+    $array["sizeHeader"] = $size_table_header;
+    $array["sizeValue"] = $size_table_value;
+    $array["type"] = $type;
+    $array["parent"] = $parent;
     echo json_encode($array);
 }
 

+ 0 - 5
script/php/equipment_group_favorite.php

@@ -10,11 +10,6 @@ include("connectSQL_Component.php");
         array_push($revitVersion,$row['revitVersion']);
         array_push($id,$row['id']);
         array_push($path,$row['favorite']);
-        /*echo "<script>
-        id.push(".$row['id'].");
-        path.push('".$row['favorite']."');        
-                </script>";*/
-                
     }
     $year = array_unique($revitVersion);
     sort($year);    

+ 23 - 4
script/php/equipment_revitVersion.php

@@ -1,11 +1,30 @@
 <?php
 include("connectSQL_Component.php");
-if (isset($_GET["type"])) {
+if (isset($_GET["parent"])) {
     $type = $_GET["type"];
-    $sql = 'SELECT DISTINCT [revitVersion] FROM [BIMComponents].[dbo].[Arch_MEP_' . $type . ']';
-    $fetchResult = sqlsrv_query($conn, $sql);   
+    $parent = $_GET["parent"];
+
+    $jsonFileContents = file_get_contents("../../assets/equipmentTable2.json");
+    $json = json_decode($jsonFileContents);
+
+    for ($i = 0; $i < count($json); $i++) {
+        if ($parent == $json[$i]->category_code) {
+            $parent = $json[$i]->category_name;
+        }
+        for ($j = 0; $j < count($json[$i]->children); $j++) {
+            if ($type == $json[$i]->children[$j]->component_code) {
+                $type = $json[$i]->children[$j]->component_name;
+            }
+        }
+    }
+
+    if ($type != "")
+        $sql = "SELECT DISTINCT [revitVersion] FROM [BIMComponents].[dbo].[Component_Info] WHERE [componentGroup] LIKE '%" . $parent . "%' AND [category] = '" . $type . "';";
+    else if ($type == "")
+        $sql = "SELECT DISTINCT [revitVersion] FROM [BIMComponents].[dbo].[Component_Info] WHERE [componentGroup] LIKE '%" . $parent . "%';";
+
+    $fetchResult = sqlsrv_query($conn, $sql);
     $revitVersion = [];
-    $i = 0;
     while ($row = sqlsrv_fetch_array($fetchResult)) {
         if ($row["revitVersion"] != null) {
             array_push($revitVersion, $row["revitVersion"]);

+ 4 - 1
script/php/getTypeList.php

@@ -1,6 +1,9 @@
-<?php include("./equipment_converter.php");
+<?php 
+/*
+    include("./equipment_converter.php");
     $array = array();
     $array["equipmentName"] = $equipment_name;
     $array["equipmentCode"] = $equipment_code;
     echo json_encode($array, JSON_UNESCAPED_UNICODE);
+    */
 ?>

+ 63 - 0
script/php/uploadComponent.php

@@ -0,0 +1,63 @@
+<?php
+    include("connectSQL_Component.php");
+    $componentGroups = [];
+    $componentGroup = [];
+    $componentNames = [];
+    $categories = [];
+    $oldFilepath = "../../assets/glb/Revit元件/Components/Arch/MEP/";
+    $oldFilepaths = [];
+    $old = [];
+    $newFilepath = "../../assets/glb/Revit元件/Components/";
+    $newFilepaths = [];
+    $paths = array_diff(scandir($oldFilepath), array('.', '..', 'Thumbs.db'));
+    foreach($paths as $path){
+        array_push($oldFilepaths, $oldFilepath.$path);
+    }
+    
+    for($i = 0; $i < count($oldFilepaths); $i++){
+        $files = scandir($oldFilepaths[$i]);
+        for($j = 0; $j < count($files); $j++){
+            if(str_contains($files[$j], "glb")){
+                array_push($old, $oldFilepaths[$i]."/".$files[$j]);
+                
+            }
+        }
+    }
+
+    
+    
+    $sql = "SELECT [componentGroup], [componentName], [category] FROM [BIMComponents].[dbo].[Component_Info]";
+    $fetchResult = sqlsrv_query($conn, $sql);
+    while ($row = sqlsrv_fetch_array($fetchResult)) {
+        array_push($componentGroups, $row["componentGroup"]);
+        array_push($componentNames, $row["componentName"]);
+        array_push($categories, $row["category"]);
+    }
+    for($i = 0; $i < count($componentGroups); $i++) {
+        $componentGroup = explode(",", $componentGroups[$i]);
+        for($j = 0; $j < count($componentGroup) - 1; $j++) {
+            array_push($newFilepaths, $newFilepath.$componentGroup[$j]."/".$categories[$i]."/".$componentNames[$i].".glb");
+        }
+    }
+    $start = "";
+    $end = [];
+    $a = array_unique($componentNames);
+    for($i = 0; $i < count($a); $i++) {
+        for($j = 0; $j < count($old); $j++){
+            if(str_contains($old[$j], $a[$i])){
+                $start = $old[$j];
+            }
+        }
+        for($j = 0; $j < count($newFilepaths); $j++){
+            if(str_contains($newFilepaths[$j], $a[$i])){
+                array_push($end, $newFilepaths[$j]);
+            }
+        }
+
+        for($j = 0; $j < count($end); $j++){
+            copy($start, $end[$j]);
+        }
+        $end = [];
+    }
+
+?>