Commit 353addd4d73986d68fc84085bb3bef4525f0edc7

Authored by nguyenhanhdk
1 parent 670b6d6f84
Exists in RM-1508

Roof

Showing 1 changed file with 47 additions and 22 deletions Side-by-side Diff

... ... @@ -18,6 +18,11 @@
18 18 var floor_height = 960;
19 19 var isViewHandrail = false;
20 20  
  21 +var roofTan1 = 300/(1810/2);
  22 +var roofTan2 = 300/1810;
  23 +
  24 +var heightRoof = 0;
  25 +
21 26 var wallPaintTexture;
22 27 var wallPaint = [];
23 28 var loader = new THREE.TextureLoader();
24 29  
... ... @@ -46,11 +51,11 @@
46 51  
47 52 var wall3D = {
48 53 'height_startpoint': converMMtoPX(0),
49   - 'height_endpoint': converMMtoPX(2330),
  54 + 'height_endpoint': converMMtoPX(1850),
50 55 };
51 56 var column3D = {
52 57 'height_startpoint': converMMtoPX(0),
53   - 'height_endpoint': converMMtoPX(2330),
  58 + 'height_endpoint': converMMtoPX(1850),
54 59 };
55 60 var door3D = {
56 61 'height_startpoint': converMMtoPX(100),
57 62  
58 63  
... ... @@ -246,20 +251,22 @@
246 251 var _3dobject = stepper[3];
247 252 drawStepper(scene, _3dxy, _3dobject);
248 253 }
249   -
250   -
  254 +
251 255 if (!inside) {
252 256 // roof 101
253 257 var roofList = getArray3dCadByType(101);
254 258 if (roofList.length != 0) {
  259 +
  260 + heightRoof = roofTan2*floorInfo[2][2];
  261 +
255 262 roofList = roofList[0];
256 263 var _3dxy = {
257 264 'start_X': (roofList[2][0]),
258 265 'start_Y': (roofList[2][1]),
259 266 'width_X': (roofList[2][2]),
260 267 'width_Y': (roofList[2][3]),
261   - 'height_startpoint': converMMtoPX(2110),
262   - 'height_endpoint': converMMtoPX(2110 + 50),
  268 + 'height_startpoint': wall3D.height_endpoint + converMMtoPX( heightRoof/2- 300),
  269 + 'height_endpoint': wall3D.height_endpoint+ converMMtoPX(heightRoof/2- 300+50),
263 270 };
264 271 var _3dobject = roofList[3];
265 272 console.log(baconInfo);
266 273  
... ... @@ -268,14 +275,17 @@
268 275 // roof 102
269 276 var roofList = getArray3dCadByType(102);
270 277 if (roofList.length != 0) {
  278 +
  279 + heightRoof = roofTan2*floorInfo[2][2];
  280 +
271 281 roofList = roofList[0];
272 282 var _3dxy = {
273 283 'start_X': (roofList[2][0]),
274 284 'start_Y': (roofList[2][1]),
275 285 'width_X': (roofList[2][2]),
276 286 'width_Y': (roofList[2][3]),
277   - 'height_startpoint': converMMtoPX(2110),
278   - 'height_endpoint': converMMtoPX(2110 + 50),
  287 + 'height_startpoint': wall3D.height_endpoint + converMMtoPX( heightRoof/2- 300),
  288 + 'height_endpoint': wall3D.height_endpoint+ converMMtoPX(heightRoof/2- 300+50),
279 289 };
280 290 var _3dobject = roofList[3];
281 291 drawRoof3D(scene, _3dxy, _3dobject, 102);
282 292  
... ... @@ -283,14 +293,16 @@
283 293 // roof 103
284 294 var roofList = getArray3dCadByType(103);
285 295 if (roofList.length != 0) {
  296 + heightRoof = roofTan2*floorInfo[2][3];
  297 +
286 298 roofList = roofList[0];
287 299 var _3dxy = {
288 300 'start_X': (roofList[2][0]),
289 301 'start_Y': (roofList[2][1]),
290 302 'width_X': (roofList[2][2]),
291 303 'width_Y': (roofList[2][3]),
292   - 'height_startpoint': converMMtoPX(2110),
293   - 'height_endpoint': converMMtoPX(2110 + 50),
  304 + 'height_startpoint': wall3D.height_endpoint + converMMtoPX( heightRoof/2 - 300),
  305 + 'height_endpoint': wall3D.height_endpoint+ converMMtoPX(heightRoof/2- 300 +50),
294 306 };
295 307 var _3dobject = roofList[3];
296 308 drawRoof3D(scene, _3dxy, _3dobject, 103);
297 309  
... ... @@ -298,14 +310,18 @@
298 310 // roof 104
299 311 var roofList = getArray3dCadByType(104);
300 312 if (roofList.length != 0) {
  313 +
  314 +
  315 + heightRoof = roofTan2*floorInfo[2][3];
  316 +
301 317 roofList = roofList[0];
302 318 var _3dxy = {
303 319 'start_X': (roofList[2][0]),
304 320 'start_Y': (roofList[2][1]),
305 321 'width_X': (roofList[2][2]),
306 322 'width_Y': (roofList[2][3]),
307   - 'height_startpoint': converMMtoPX(2110),
308   - 'height_endpoint': converMMtoPX(2110 + 50),
  323 + 'height_startpoint': wall3D.height_endpoint + converMMtoPX( heightRoof/2- 300),
  324 + 'height_endpoint': wall3D.height_endpoint+ converMMtoPX(heightRoof/2- 300+50),
309 325 };
310 326 var _3dobject = roofList[3];
311 327 drawRoof3D(scene, _3dxy, _3dobject, 104);
312 328  
... ... @@ -743,8 +759,10 @@
743 759 } else {
744 760 _3dxy.width_Y = converMMtoPX(wallWidth);
745 761 }
746   - _3dxy.height_endpoint = wall3D.height_endpoint + floor3D.height_endpoint;
  762 + console.log("drawWal heightRoof: " + heightRoof);
  763 + _3dxy.height_endpoint = wall3D.height_endpoint + floor3D.height_endpoint + converMMtoPX(heightRoof) ;
747 764 _3dxy.height_startpoint = wall3D.height_startpoint + floor3D.height_endpoint;
  765 +
748 766 var material = {
749 767 'tex': wallTexture,
750 768 };
... ... @@ -840,7 +858,7 @@
840 858  
841 859 //Draw Pillar
842 860 function drawPillar(scene, _3dxy, _3dobject) {
843   - _3dxy.height_endpoint = column3D.height_endpoint + floor3D.height_endpoint;
  861 + _3dxy.height_endpoint = column3D.height_endpoint + floor3D.height_endpoint + converMMtoPX(heightRoof) ;
844 862 _3dxy.height_startpoint = floor3D.height_endpoint;
845 863  
846 864 drawPillarWithPaintInside(scene, _3dxy, _3dobject)
... ... @@ -1923,7 +1941,7 @@
1923 1941 }
1924 1942 var typeRoof = _3dobject[0].split('-');
1925 1943 typeRoof = typeRoof[0] + '-' + typeRoof[1];
1926   - var heightRoof = 300;
  1944 + //var heightRoof = 300;
1927 1945 //
1928 1946 var rType = JSON.parse(JSON.stringify(roofType));
1929 1947 if (rotate == 1)
... ... @@ -1936,6 +1954,7 @@
1936 1954 type = 104;
1937 1955 //
1938 1956 if (typeRoof == 'roof-2') {
  1957 + var tan = roofTan2;
1939 1958  
1940 1959 roof3D = drawObj(scene, _3dxy, _3dobject, material);
1941 1960 roof_2roof_obj = null;
1942 1961  
1943 1962  
1944 1963  
1945 1964  
... ... @@ -1945,21 +1964,26 @@
1945 1964 _3dxyRoof = JSON.parse(JSON.stringify(_3dxy));
1946 1965 ////
1947 1966 if (type == 101) {
1948   - var tan = (heightRoof) / (floorInfo[2][3]);
  1967 + //var tan = (heightRoof) / (floorInfo[2][3]);
  1968 + //heightRoof = tan*floorInfo[2][3];
  1969 +
1949 1970 var b = 2030 +tan*(floorInfo[2][3]-(converPxtoMm(_3dxyRoof.width_Y)/2 - 300)) + 50 / 2;
1950   - // var b = 1820 + converPxtoMm(tan * (floorInfo[2][3])-(_3dxyRoof.width_Y/2-converMMtoPX(300))) + 50 / 2;
  1971 + // var b = 1820 + converPxtoMm(tan * (floorInfo[2][3])-(_3dxyRoof.width_Y/2-converMMtoPX(heightRoof))) + 50 / 2;
1951 1972 roof3D.rotation.x = Math.atan(tan);
1952 1973 }
1953 1974 else if (type == 102) {
1954   - var tan = (heightRoof) / (floorInfo[2][3]);
  1975 + //var tan = (heightRoof) / (floorInfo[2][3]);
  1976 + //heightRoof = tan*floorInfo[2][3];
1955 1977 var b = 2030 +tan*(floorInfo[2][3]-(converPxtoMm(_3dxyRoof.width_Y)/2 - 300)) + 50 / 2;
1956 1978 roof3D.rotation.x = -Math.atan(tan);
1957 1979 } else if (type == 103) {
1958   - var tan = (heightRoof) / (floorInfo[2][2]);
  1980 + //var tan = (heightRoof) / (floorInfo[2][2]);
  1981 + //heightRoof = tan*floorInfo[2][2];
1959 1982 var b = 2030 +tan*(floorInfo[2][2]-(converPxtoMm(_3dxyRoof.width_X)/2 - 300)) + 50 / 2;
1960 1983 roof3D.rotation.z = -Math.atan(tan);
1961 1984 } else if (type == 104) {
1962   - var tan = (heightRoof) / (floorInfo[2][2]);
  1985 + //var tan = (heightRoof) / (floorInfo[2][2]);
  1986 + //heightRoof = tan*floorInfo[2][2];
1963 1987 var b = 2030 +tan*(floorInfo[2][2]-(converPxtoMm(_3dxyRoof.width_X)/2 - 300)) + 50 / 2;
1964 1988 roof3D.rotation.z = Math.atan(tan);
1965 1989 }
1966 1990  
... ... @@ -1992,14 +2016,15 @@
1992 2016 scene.add(roofSlice);
1993 2017 } else if (typeRoof == 'roof-1') {
1994 2018 var diff = 300;
1995   - var heightRoof = 300;
  2019 + //var heightRoof = 300;
  2020 + tan = roofTan1;
1996 2021 roof3D = null;
1997 2022 if (type == 101 || type === 102) {
1998 2023 var roof_1roof = JSON.parse(JSON.stringify(_3dxy));
1999 2024 //roof1
2000 2025 roof_1roof.width_Y = roof_1roof.width_Y / 2;
2001 2026 roof_1roof_obj = drawObj(scene, roof_1roof, _3dobject, material);
2002   - var tan = converMMtoPX(heightRoof) / (roof_1roof.width_Y);
  2027 + //var tan = converMMtoPX(heightRoof) / (roof_1roof.width_Y);
2003 2028 roof_1roof_obj.rotation.x = -Math.atan(tan);
2004 2029 var c = 2030 + 300 - tan * roof_1roof.width_Y * 2;
2005 2030 roof_1roof_obj.position.y = converMMtoPX(c) + floor3D.height_endpoint - floor3D.height_startpoint;