Commit 353addd4d73986d68fc84085bb3bef4525f0edc7

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

Roof

Showing 1 changed file with 47 additions and 22 deletions Inline Diff

1 // standard global variables 1 // standard global variables
2 var container, scene, camera, renderer, controls; 2 var container, scene, camera, renderer, controls;
3 var keyboard; 3 var keyboard;
4 // custom global variables 4 // custom global variables
5 var cube; 5 var cube;
6 var floor; 6 var floor;
7 var defaultTextute; 7 var defaultTextute;
8 var wallTexture; 8 var wallTexture;
9 var collumTextute; 9 var collumTextute;
10 var baconTextute; 10 var baconTextute;
11 var doorTexute; 11 var doorTexute;
12 var door2wTexute; 12 var door2wTexute;
13 var windowTexture; 13 var windowTexture;
14 var roofTex, sphereTex; 14 var roofTex, sphereTex;
15 var glassTexture; 15 var glassTexture;
16 var inside = false; 16 var inside = false;
17 var floor_width = 1283; 17 var floor_width = 1283;
18 var floor_height = 960; 18 var floor_height = 960;
19 var isViewHandrail = false; 19 var isViewHandrail = false;
20 20
21 var roofTan1 = 300/(1810/2);
22 var roofTan2 = 300/1810;
23
24 var heightRoof = 0;
25
21 var wallPaintTexture; 26 var wallPaintTexture;
22 var wallPaint = []; 27 var wallPaint = [];
23 var loader = new THREE.TextureLoader(); 28 var loader = new THREE.TextureLoader();
24 var wallObj, pillarObj, doorObj, windowObj, baconObj, floorObj, floorInfo, baconInfo, roofSlice, isDraw, roofSlice1, roofSlice2, woodWindowObj, roof_2roof_obj, roof_1roof_obj, roof3D, handrailObj, stepperObj; 29 var wallObj, pillarObj, doorObj, windowObj, baconObj, floorObj, floorInfo, baconInfo, roofSlice, isDraw, roofSlice1, roofSlice2, woodWindowObj, roof_2roof_obj, roof_1roof_obj, roof3D, handrailObj, stepperObj;
25 30
26 var floor3D = { 31 var floor3D = {
27 'height_startpoint': converMMtoPX(0), 32 'height_startpoint': converMMtoPX(0),
28 'height_endpoint': converMMtoPX(100), 33 'height_endpoint': converMMtoPX(100),
29 }; 34 };
30 var bacon3D = { 35 var bacon3D = {
31 'height_startpoint': converMMtoPX(0), 36 'height_startpoint': converMMtoPX(0),
32 'height_endpoint': converMMtoPX(100), 37 'height_endpoint': converMMtoPX(100),
33 }; 38 };
34 39
35 40
36 // MR 1340 - START 41 // MR 1340 - START
37 var handrail3D = { 42 var handrail3D = {
38 'height_startpoint': converMMtoPX(300), 43 'height_startpoint': converMMtoPX(300),
39 'height_endpoint': converMMtoPX(1000), 44 'height_endpoint': converMMtoPX(1000),
40 }; 45 };
41 // MR 1340 - END 46 // MR 1340 - END
42 var stepper3D = { 47 var stepper3D = {
43 'height_startpoint': converMMtoPX(0), 48 'height_startpoint': converMMtoPX(0),
44 'height_endpoint': converMMtoPX(250), 49 'height_endpoint': converMMtoPX(250),
45 }; 50 };
46 51
47 var wall3D = { 52 var wall3D = {
48 'height_startpoint': converMMtoPX(0), 53 'height_startpoint': converMMtoPX(0),
49 'height_endpoint': converMMtoPX(2330), 54 'height_endpoint': converMMtoPX(1850),
50 }; 55 };
51 var column3D = { 56 var column3D = {
52 'height_startpoint': converMMtoPX(0), 57 'height_startpoint': converMMtoPX(0),
53 'height_endpoint': converMMtoPX(2330), 58 'height_endpoint': converMMtoPX(1850),
54 }; 59 };
55 var door3D = { 60 var door3D = {
56 'height_startpoint': converMMtoPX(100), 61 'height_startpoint': converMMtoPX(100),
57 'height_endpoint': converMMtoPX(1780), 62 'height_endpoint': converMMtoPX(1780),
58 }; 63 };
59 var window3D = { 64 var window3D = {
60 'height_startpoint': converMMtoPX(580), 65 'height_startpoint': converMMtoPX(580),
61 'height_endpoint': converMMtoPX(1780), 66 'height_endpoint': converMMtoPX(1780),
62 }; 67 };
63 // initialization 68 // initialization
64 69
65 var viewHandrailEvent= function () { 70 var viewHandrailEvent= function () {
66 console.log("viewHandrailEvent"); 71 console.log("viewHandrailEvent");
67 isViewHandrail = !isViewHandrail; 72 isViewHandrail = !isViewHandrail;
68 view3d(false); 73 view3d(false);
69 } 74 }
70 // animation loop / game loop 75 // animation loop / game loop
71 var view2d = function () { 76 var view2d = function () {
72 document.getElementById('canvas').style.display = 'block'; 77 document.getElementById('canvas').style.display = 'block';
73 document.getElementById('view2d').style.display = 'none'; 78 document.getElementById('view2d').style.display = 'none';
74 document.getElementById('canvas3d').style.display = 'none'; 79 document.getElementById('canvas3d').style.display = 'none';
75 document.getElementById('inside').style.display = 'none'; 80 document.getElementById('inside').style.display = 'none';
76 document.getElementById('outside').style.display = 'none'; 81 document.getElementById('outside').style.display = 'none';
77 document.getElementById('no-roof').style.display = 'none'; 82 document.getElementById('no-roof').style.display = 'none';
78 document.getElementById('wallColor').style.display = 'none'; 83 document.getElementById('wallColor').style.display = 'none';
79 document.getElementById('wall-select').style.display = 'none'; 84 document.getElementById('wall-select').style.display = 'none';
80 document.getElementById('viewHandrail').style.display = 'none'; 85 document.getElementById('viewHandrail').style.display = 'none';
81 var canvas3d = document.getElementById('canvas3d'); 86 var canvas3d = document.getElementById('canvas3d');
82 var remove = canvas3d.getElementsByTagName('canvas'); 87 var remove = canvas3d.getElementsByTagName('canvas');
83 canvas3d.removeChild(remove[0]); 88 canvas3d.removeChild(remove[0]);
84 isChoose = 0; 89 isChoose = 0;
85 stage.removeChild(opacityShapeBox); 90 stage.removeChild(opacityShapeBox);
86 }; 91 };
87 var view3d = function (isInside) { 92 var view3d = function (isInside) {
88 if (transitionState != STATE_TRANSITION_SET_3DVIEW) return; 93 if (transitionState != STATE_TRANSITION_SET_3DVIEW) return;
89 if (isInside == true) { 94 if (isInside == true) {
90 inside = true; 95 inside = true;
91 } 96 }
92 if (isInside == false) 97 if (isInside == false)
93 inside = false; 98 inside = false;
94 99
95 var canvas3d = document.getElementById('canvas3d'); 100 var canvas3d = document.getElementById('canvas3d');
96 var remove = canvas3d.getElementsByTagName('canvas'); 101 var remove = canvas3d.getElementsByTagName('canvas');
97 if (remove[0]) 102 if (remove[0])
98 canvas3d.removeChild(remove[0]); 103 canvas3d.removeChild(remove[0]);
99 document.getElementById('canvas').style.display = 'none'; 104 document.getElementById('canvas').style.display = 'none';
100 document.getElementById('view2d').style.display = 'block'; 105 document.getElementById('view2d').style.display = 'block';
101 document.getElementById('inside').style.display = 'block'; 106 document.getElementById('inside').style.display = 'block';
102 document.getElementById('outside').style.display = 'block'; 107 document.getElementById('outside').style.display = 'block';
103 if (!inside) { 108 if (!inside) {
104 document.getElementById('no-roof').style.display = 'block'; 109 document.getElementById('no-roof').style.display = 'block';
105 } else { 110 } else {
106 document.getElementById('no-roof').style.display = 'none'; 111 document.getElementById('no-roof').style.display = 'none';
107 } 112 }
108 document.getElementById('wallColor').style.display = 'block'; 113 document.getElementById('wallColor').style.display = 'block';
109 document.getElementById('wall-select').style.display = 'block'; 114 document.getElementById('wall-select').style.display = 'block';
110 document.getElementById('viewHandrail').style.display = 'block'; 115 document.getElementById('viewHandrail').style.display = 'block';
111 116
112 document.getElementById('canvas3d').style.display = 'block'; 117 document.getElementById('canvas3d').style.display = 'block';
113 defaultTextute = new loader.load('images/wood-floor.jpg'); 118 defaultTextute = new loader.load('images/wood-floor.jpg');
114 doorTexute = new loader.load('images/door1wings.jpg'); 119 doorTexute = new loader.load('images/door1wings.jpg');
115 door2wTexute = new loader.load('images/door2wings.jpg'); 120 door2wTexute = new loader.load('images/door2wings.jpg');
116 glassTexture = new loader.load('images/blue.png'); 121 glassTexture = new loader.load('images/blue.png');
117 keyboard = new THREEx.KeyboardState(); 122 keyboard = new THREEx.KeyboardState();
118 wallObj = []; 123 wallObj = [];
119 pillarObj = []; 124 pillarObj = [];
120 doorObj = []; 125 doorObj = [];
121 windowObj = []; 126 windowObj = [];
122 baconObj = new THREE.Object3D(); 127 baconObj = new THREE.Object3D();
123 128
124 floorObj = new THREE.Object3D(); 129 floorObj = new THREE.Object3D();
125 woodWindowObj = []; 130 woodWindowObj = [];
126 roofSlice = null; 131 roofSlice = null;
127 roofSlice1 = null; 132 roofSlice1 = null;
128 roofSlice2 = null; 133 roofSlice2 = null;
129 // MR 1340 - START 134 // MR 1340 - START
130 handrailObj = []; 135 handrailObj = [];
131 // MR 1340 - END 136 // MR 1340 - END
132 stepperObj = []; 137 stepperObj = [];
133 wallPaint = []; 138 wallPaint = [];
134 139
135 140
136 // Load wall pain texture 141 // Load wall pain texture
137 wallPaintTexture = loader.load('images/kabe.jpg'); 142 wallPaintTexture = loader.load('images/kabe.jpg');
138 wallPaintTexture.wrapS = THREE.RepeatWrapping; 143 wallPaintTexture.wrapS = THREE.RepeatWrapping;
139 wallPaintTexture.wrapT = THREE.RepeatWrapping; 144 wallPaintTexture.wrapT = THREE.RepeatWrapping;
140 wallPaintTexture.repeat.set(5, 5); 145 wallPaintTexture.repeat.set(5, 5);
141 146
142 // Load default wall color 147 // Load default wall color
143 var selectColor = document.getElementById('wall_option').selectedIndex; 148 var selectColor = document.getElementById('wall_option').selectedIndex;
144 wallTexture = new loader.load('images/' + wallColor[selectColor][2] + '.PNG'); 149 wallTexture = new loader.load('images/' + wallColor[selectColor][2] + '.PNG');
145 wallTexture.wrapT = THREE.RepeatWrapping; 150 wallTexture.wrapT = THREE.RepeatWrapping;
146 wallTexture.repeat.set(5, 5); 151 wallTexture.repeat.set(5, 5);
147 152
148 153
149 initializeScene(); 154 initializeScene();
150 animate() 155 animate()
151 }; 156 };
152 function initializeScene() { 157 function initializeScene() {
153 158
154 scene = new THREE.Scene(); 159 scene = new THREE.Scene();
155 160
156 161
157 var SCREEN_WIDTH = window.innerWidth, SCREEN_HEIGHT = window.innerHeight; 162 var SCREEN_WIDTH = window.innerWidth, SCREEN_HEIGHT = window.innerHeight;
158 var VIEW_ANGLE = 45, ASPECT = SCREEN_WIDTH / SCREEN_HEIGHT, NEAR = 0.1, FAR = 20000; 163 var VIEW_ANGLE = 45, ASPECT = SCREEN_WIDTH / SCREEN_HEIGHT, NEAR = 0.1, FAR = 20000;
159 camera = new THREE.PerspectiveCamera(VIEW_ANGLE, ASPECT, NEAR, FAR); 164 camera = new THREE.PerspectiveCamera(VIEW_ANGLE, ASPECT, NEAR, FAR);
160 scene.add(camera); 165 scene.add(camera);
161 if (inside) { 166 if (inside) {
162 camera.position.set(1, 0, 1); 167 camera.position.set(1, 0, 1);
163 } else { 168 } else {
164 camera.position.set(0, 700, 1400); 169 camera.position.set(0, 700, 1400);
165 } 170 }
166 171
167 camera.lookAt(scene.position); 172 camera.lookAt(scene.position);
168 173
169 174
170 if (Detector.webgl) 175 if (Detector.webgl)
171 renderer = new THREE.WebGLRenderer({antialias: true}); 176 renderer = new THREE.WebGLRenderer({antialias: true});
172 else 177 else
173 renderer = new THREE.CanvasRenderer(); 178 renderer = new THREE.CanvasRenderer();
174 179
175 renderer.setSize(SCREEN_WIDTH, SCREEN_HEIGHT); 180 renderer.setSize(SCREEN_WIDTH, SCREEN_HEIGHT);
176 181
177 container = document.getElementById('canvas3d'); 182 container = document.getElementById('canvas3d');
178 container.appendChild(renderer.domElement); 183 container.appendChild(renderer.domElement);
179 184
180 185
181 // automatically resize renderer 186 // automatically resize renderer
182 THREEx.WindowResize(renderer, camera); 187 THREEx.WindowResize(renderer, camera);
183 // toggle full-screen on given key press 188 // toggle full-screen on given key press
184 THREEx.FullScreen.bindKey({charCode: 'm'.charCodeAt(0)}); 189 THREEx.FullScreen.bindKey({charCode: 'm'.charCodeAt(0)});
185 190
186 191
187 controls = new THREE.OrbitControls(camera, renderer.domElement); 192 controls = new THREE.OrbitControls(camera, renderer.domElement);
188 193
189 194
190 var ambientLight = new THREE.AmbientLight(0x111111); 195 var ambientLight = new THREE.AmbientLight(0x111111);
191 // floor 196 // floor
192 var floorList = getArray3dCadByType(1); 197 var floorList = getArray3dCadByType(1);
193 if (floorList.length != 0) { 198 if (floorList.length != 0) {
194 floorList = floorList[0]; 199 floorList = floorList[0];
195 var _3dxy = { 200 var _3dxy = {
196 'start_X': converMMtoPX(floorList[2][0] - widthPillar/2), 201 'start_X': converMMtoPX(floorList[2][0] - widthPillar/2),
197 'start_Y': converMMtoPX(floorList[2][1] - widthPillar/2), 202 'start_Y': converMMtoPX(floorList[2][1] - widthPillar/2),
198 'width_X': converMMtoPX(floorList[2][2] + widthPillar + wallWidth), 203 'width_X': converMMtoPX(floorList[2][2] + widthPillar + wallWidth),
199 'width_Y': converMMtoPX(floorList[2][3] + widthPillar + wallWidth), 204 'width_Y': converMMtoPX(floorList[2][3] + widthPillar + wallWidth),
200 'height_startpoint': converMMtoPX(floorList[2][4]), 205 'height_startpoint': converMMtoPX(floorList[2][4]),
201 'height_endpoint': converMMtoPX(floorList[2][5]), 206 'height_endpoint': converMMtoPX(floorList[2][5]),
202 }; 207 };
203 208
204 var _3dobject = floorList[3]; 209 var _3dobject = floorList[3];
205 floorInfo = floorList; 210 floorInfo = floorList;
206 drawFloor3D(scene, _3dxy, _3dobject); 211 drawFloor3D(scene, _3dxy, _3dobject);
207 } 212 }
208 213
209 // bacon 214 // bacon
210 var baconList = getArray3dCadByType(2); 215 var baconList = getArray3dCadByType(2);
211 if (baconList.length != 0) { 216 if (baconList.length != 0) {
212 baconList = baconList[0]; 217 baconList = baconList[0];
213 var _3dxy = { 218 var _3dxy = {
214 'start_X': converMMtoPX(baconList[2][0] - widthPillar/2), 219 'start_X': converMMtoPX(baconList[2][0] - widthPillar/2),
215 'start_Y': converMMtoPX(baconList[2][1] - widthPillar/2 ), 220 'start_Y': converMMtoPX(baconList[2][1] - widthPillar/2 ),
216 'width_X': converMMtoPX(baconList[2][2] + widthPillar + wallWidth ), 221 'width_X': converMMtoPX(baconList[2][2] + widthPillar + wallWidth ),
217 'width_Y': converMMtoPX(baconList[2][3] + widthPillar + wallWidth ), 222 'width_Y': converMMtoPX(baconList[2][3] + widthPillar + wallWidth ),
218 'height_startpoint': converMMtoPX(baconList[2][4]), 223 'height_startpoint': converMMtoPX(baconList[2][4]),
219 'height_endpoint': converMMtoPX(baconList[2][5]), 224 'height_endpoint': converMMtoPX(baconList[2][5]),
220 }; 225 };
221 226
222 var _3dobject = baconList[3]; 227 var _3dobject = baconList[3];
223 baconInfo = baconList; 228 baconInfo = baconList;
224 drawBacon(scene, _3dxy, _3dobject); 229 drawBacon(scene, _3dxy, _3dobject);
225 } 230 }
226 231
227 232
228 // MR 1340 - START 233 // MR 1340 - START
229 // handrail 234 // handrail
230 if( isViewHandrail == true) showHanrail(); 235 if( isViewHandrail == true) showHanrail();
231 // MR 1340 - END 236 // MR 1340 - END
232 237
233 // stepper 238 // stepper
234 var stepperList = getArray3dCadByType(TYPE_STEPPER); 239 var stepperList = getArray3dCadByType(TYPE_STEPPER);
235 for (var i = 0; i < stepperList.length; i++) { 240 for (var i = 0; i < stepperList.length; i++) {
236 stepper = stepperList[i]; 241 stepper = stepperList[i];
237 var _3dxy = { 242 var _3dxy = {
238 'start_X': converMMtoPX(stepper[2][0]), 243 'start_X': converMMtoPX(stepper[2][0]),
239 'start_Y': converMMtoPX(stepper[2][1]), 244 'start_Y': converMMtoPX(stepper[2][1]),
240 'width_X': converMMtoPX(stepper[2][2]), 245 'width_X': converMMtoPX(stepper[2][2]),
241 'width_Y': converMMtoPX(stepper[2][3]), 246 'width_Y': converMMtoPX(stepper[2][3]),
242 'height_startpoint': converMMtoPX(-180), 247 'height_startpoint': converMMtoPX(-180),
243 'height_endpoint': converMMtoPX(stepper[2][5] - 180), 248 'height_endpoint': converMMtoPX(stepper[2][5] - 180),
244 }; 249 };
245 250
246 var _3dobject = stepper[3]; 251 var _3dobject = stepper[3];
247 drawStepper(scene, _3dxy, _3dobject); 252 drawStepper(scene, _3dxy, _3dobject);
248 } 253 }
249 254
250
251 if (!inside) { 255 if (!inside) {
252 // roof 101 256 // roof 101
253 var roofList = getArray3dCadByType(101); 257 var roofList = getArray3dCadByType(101);
254 if (roofList.length != 0) { 258 if (roofList.length != 0) {
259
260 heightRoof = roofTan2*floorInfo[2][2];
261
255 roofList = roofList[0]; 262 roofList = roofList[0];
256 var _3dxy = { 263 var _3dxy = {
257 'start_X': (roofList[2][0]), 264 'start_X': (roofList[2][0]),
258 'start_Y': (roofList[2][1]), 265 'start_Y': (roofList[2][1]),
259 'width_X': (roofList[2][2]), 266 'width_X': (roofList[2][2]),
260 'width_Y': (roofList[2][3]), 267 'width_Y': (roofList[2][3]),
261 'height_startpoint': converMMtoPX(2110), 268 'height_startpoint': wall3D.height_endpoint + converMMtoPX( heightRoof/2- 300),
262 'height_endpoint': converMMtoPX(2110 + 50), 269 'height_endpoint': wall3D.height_endpoint+ converMMtoPX(heightRoof/2- 300+50),
263 }; 270 };
264 var _3dobject = roofList[3]; 271 var _3dobject = roofList[3];
265 console.log(baconInfo); 272 console.log(baconInfo);
266 drawRoof3D(scene, _3dxy, _3dobject, 101); 273 drawRoof3D(scene, _3dxy, _3dobject, 101);
267 } 274 }
268 // roof 102 275 // roof 102
269 var roofList = getArray3dCadByType(102); 276 var roofList = getArray3dCadByType(102);
270 if (roofList.length != 0) { 277 if (roofList.length != 0) {
278
279 heightRoof = roofTan2*floorInfo[2][2];
280
271 roofList = roofList[0]; 281 roofList = roofList[0];
272 var _3dxy = { 282 var _3dxy = {
273 'start_X': (roofList[2][0]), 283 'start_X': (roofList[2][0]),
274 'start_Y': (roofList[2][1]), 284 'start_Y': (roofList[2][1]),
275 'width_X': (roofList[2][2]), 285 'width_X': (roofList[2][2]),
276 'width_Y': (roofList[2][3]), 286 'width_Y': (roofList[2][3]),
277 'height_startpoint': converMMtoPX(2110), 287 'height_startpoint': wall3D.height_endpoint + converMMtoPX( heightRoof/2- 300),
278 'height_endpoint': converMMtoPX(2110 + 50), 288 'height_endpoint': wall3D.height_endpoint+ converMMtoPX(heightRoof/2- 300+50),
279 }; 289 };
280 var _3dobject = roofList[3]; 290 var _3dobject = roofList[3];
281 drawRoof3D(scene, _3dxy, _3dobject, 102); 291 drawRoof3D(scene, _3dxy, _3dobject, 102);
282 } 292 }
283 // roof 103 293 // roof 103
284 var roofList = getArray3dCadByType(103); 294 var roofList = getArray3dCadByType(103);
285 if (roofList.length != 0) { 295 if (roofList.length != 0) {
296 heightRoof = roofTan2*floorInfo[2][3];
297
286 roofList = roofList[0]; 298 roofList = roofList[0];
287 var _3dxy = { 299 var _3dxy = {
288 'start_X': (roofList[2][0]), 300 'start_X': (roofList[2][0]),
289 'start_Y': (roofList[2][1]), 301 'start_Y': (roofList[2][1]),
290 'width_X': (roofList[2][2]), 302 'width_X': (roofList[2][2]),
291 'width_Y': (roofList[2][3]), 303 'width_Y': (roofList[2][3]),
292 'height_startpoint': converMMtoPX(2110), 304 'height_startpoint': wall3D.height_endpoint + converMMtoPX( heightRoof/2 - 300),
293 'height_endpoint': converMMtoPX(2110 + 50), 305 'height_endpoint': wall3D.height_endpoint+ converMMtoPX(heightRoof/2- 300 +50),
294 }; 306 };
295 var _3dobject = roofList[3]; 307 var _3dobject = roofList[3];
296 drawRoof3D(scene, _3dxy, _3dobject, 103); 308 drawRoof3D(scene, _3dxy, _3dobject, 103);
297 } 309 }
298 // roof 104 310 // roof 104
299 var roofList = getArray3dCadByType(104); 311 var roofList = getArray3dCadByType(104);
300 if (roofList.length != 0) { 312 if (roofList.length != 0) {
313
314
315 heightRoof = roofTan2*floorInfo[2][3];
316
301 roofList = roofList[0]; 317 roofList = roofList[0];
302 var _3dxy = { 318 var _3dxy = {
303 'start_X': (roofList[2][0]), 319 'start_X': (roofList[2][0]),
304 'start_Y': (roofList[2][1]), 320 'start_Y': (roofList[2][1]),
305 'width_X': (roofList[2][2]), 321 'width_X': (roofList[2][2]),
306 'width_Y': (roofList[2][3]), 322 'width_Y': (roofList[2][3]),
307 'height_startpoint': converMMtoPX(2110), 323 'height_startpoint': wall3D.height_endpoint + converMMtoPX( heightRoof/2- 300),
308 'height_endpoint': converMMtoPX(2110 + 50), 324 'height_endpoint': wall3D.height_endpoint+ converMMtoPX(heightRoof/2- 300+50),
309 }; 325 };
310 var _3dobject = roofList[3]; 326 var _3dobject = roofList[3];
311 drawRoof3D(scene, _3dxy, _3dobject, 104); 327 drawRoof3D(scene, _3dxy, _3dobject, 104);
312 } 328 }
313 } 329 }
314 var doorList = getArray3dCadByType(5); 330 var doorList = getArray3dCadByType(5);
315 if (doorList) { 331 if (doorList) {
316 doorList.forEach(function (d) { 332 doorList.forEach(function (d) {
317 var _3dobject = d[3]; 333 var _3dobject = d[3];
318 var _3dxy = { 334 var _3dxy = {
319 'start_X': (d[2][0]), 335 'start_X': (d[2][0]),
320 'start_Y': (d[2][1]), 336 'start_Y': (d[2][1]),
321 'width_X': (d[2][2]), 337 'width_X': (d[2][2]),
322 'width_Y': (d[2][3]), 338 'width_Y': (d[2][3]),
323 'height_startpoint': (d[2][4]), 339 'height_startpoint': (d[2][4]),
324 'height_endpoint': (d[2][5]), 340 'height_endpoint': (d[2][5]),
325 }; 341 };
326 drawDoor(scene, _3dxy, _3dobject); 342 drawDoor(scene, _3dxy, _3dobject);
327 }); 343 });
328 } 344 }
329 array3dCad.forEach(function (v) { 345 array3dCad.forEach(function (v) {
330 var _3dxy = { 346 var _3dxy = {
331 'start_X': converMMtoPX(v[2][0]), 347 'start_X': converMMtoPX(v[2][0]),
332 'start_Y': converMMtoPX(v[2][1]), 348 'start_Y': converMMtoPX(v[2][1]),
333 'width_X': converMMtoPX(v[2][2]), 349 'width_X': converMMtoPX(v[2][2]),
334 'width_Y': converMMtoPX(v[2][3]), 350 'width_Y': converMMtoPX(v[2][3]),
335 'height_startpoint': converMMtoPX(v[2][4]), 351 'height_startpoint': converMMtoPX(v[2][4]),
336 'height_endpoint': converMMtoPX(v[2][5]), 352 'height_endpoint': converMMtoPX(v[2][5]),
337 }; 353 };
338 var _3dobject = v[3]; 354 var _3dobject = v[3];
339 355
340 // if (v[1] == 7) { 356 // if (v[1] == 7) {
341 // var _3dxy = { 357 // var _3dxy = {
342 // 'start_X': (v[2][0]), 358 // 'start_X': (v[2][0]),
343 // 'start_Y': (v[2][1]), 359 // 'start_Y': (v[2][1]),
344 // 'width_X': (v[2][2]), 360 // 'width_X': (v[2][2]),
345 // 'width_Y': (v[2][3]), 361 // 'width_Y': (v[2][3]),
346 // 'height_startpoint': (v[2][4]), 362 // 'height_startpoint': (v[2][4]),
347 // 'height_endpoint': (v[2][5]), 363 // 'height_endpoint': (v[2][5]),
348 // }; 364 // };
349 // drawWindow(scene, _3dxy, _3dobject); 365 // drawWindow(scene, _3dxy, _3dobject);
350 // } 366 // }
351 if (v[1] == 5) { 367 if (v[1] == 5) {
352 368
353 } 369 }
354 if (v[1] == 3) { 370 if (v[1] == 3) {
355 drawWall(scene, _3dxy, _3dobject); 371 drawWall(scene, _3dxy, _3dobject);
356 } 372 }
357 if (v[1] == 4) { 373 if (v[1] == 4) {
358 drawPillar(scene, _3dxy, _3dobject); 374 drawPillar(scene, _3dxy, _3dobject);
359 } 375 }
360 if (v[1] == 6) { 376 if (v[1] == 6) {
361 var _3dxy = { 377 var _3dxy = {
362 'start_X': (v[2][0]), 378 'start_X': (v[2][0]),
363 'start_Y': (v[2][1]), 379 'start_Y': (v[2][1]),
364 'width_X': (v[2][2]), 380 'width_X': (v[2][2]),
365 'width_Y': (v[2][3]), 381 'width_Y': (v[2][3]),
366 'height_startpoint': (v[2][4]), 382 'height_startpoint': (v[2][4]),
367 'height_endpoint': (v[2][5]), 383 'height_endpoint': (v[2][5]),
368 }; 384 };
369 drawWindow(scene, _3dxy, _3dobject); 385 drawWindow(scene, _3dxy, _3dobject);
370 } 386 }
371 387
372 388
373 }); 389 });
374 var arrWall = []; 390 var arrWall = [];
375 wallObj.forEach(function (val, key) { 391 wallObj.forEach(function (val, key) {
376 var wallCSG = new ThreeBSP(val); 392 var wallCSG = new ThreeBSP(val);
377 windowObj.forEach(function (v, k) { 393 windowObj.forEach(function (v, k) {
378 var windowCSG = new ThreeBSP(v); 394 var windowCSG = new ThreeBSP(v);
379 wallCSG = wallCSG.subtract(windowCSG); 395 wallCSG = wallCSG.subtract(windowCSG);
380 }); 396 });
381 397
382 if (roofSlice) { 398 if (roofSlice) {
383 var roofCSG = new ThreeBSP(roofSlice); 399 var roofCSG = new ThreeBSP(roofSlice);
384 wallCSG = wallCSG.subtract(roofCSG); 400 wallCSG = wallCSG.subtract(roofCSG);
385 } 401 }
386 if (roofSlice1) { 402 if (roofSlice1) {
387 var roofCSG = new ThreeBSP(roofSlice1); 403 var roofCSG = new ThreeBSP(roofSlice1);
388 wallCSG = wallCSG.subtract(roofCSG); 404 wallCSG = wallCSG.subtract(roofCSG);
389 } 405 }
390 if (roofSlice2) { 406 if (roofSlice2) {
391 var roofCSG = new ThreeBSP(roofSlice2); 407 var roofCSG = new ThreeBSP(roofSlice2);
392 wallCSG = wallCSG.subtract(roofCSG); 408 wallCSG = wallCSG.subtract(roofCSG);
393 } 409 }
394 doorObj.forEach(function (dr, k) { 410 doorObj.forEach(function (dr, k) {
395 var doorCSG = new ThreeBSP(dr); 411 var doorCSG = new ThreeBSP(dr);
396 wallCSG = wallCSG.subtract(doorCSG); 412 wallCSG = wallCSG.subtract(doorCSG);
397 }); 413 });
398 arrWall.push(wallCSG.toMesh()); 414 arrWall.push(wallCSG.toMesh());
399 }); 415 });
400 arrWall.forEach(function (item, index) { 416 arrWall.forEach(function (item, index) {
401 var ceilingMaterial = new THREE.MeshBasicMaterial({ 417 var ceilingMaterial = new THREE.MeshBasicMaterial({
402 map: wallTexture, 418 map: wallTexture,
403 shading: THREE.FlatShading, 419 shading: THREE.FlatShading,
404 side: THREE.DoubleSide, 420 side: THREE.DoubleSide,
405 }); 421 });
406 item.material = ceilingMaterial; 422 item.material = ceilingMaterial;
407 scene.add(item); 423 scene.add(item);
408 }); 424 });
409 425
410 // MR 1347 - START 426 // MR 1347 - START
411 var arrWallPaint = []; 427 var arrWallPaint = [];
412 wallPaint.forEach(function (val, key) { 428 wallPaint.forEach(function (val, key) {
413 var wallCSG = new ThreeBSP(val); 429 var wallCSG = new ThreeBSP(val);
414 windowObj.forEach(function (v, k) { 430 windowObj.forEach(function (v, k) {
415 var windowCSG = new ThreeBSP(v); 431 var windowCSG = new ThreeBSP(v);
416 wallCSG = wallCSG.subtract(windowCSG); 432 wallCSG = wallCSG.subtract(windowCSG);
417 }); 433 });
418 434
419 if (roofSlice) { 435 if (roofSlice) {
420 var roofCSG = new ThreeBSP(roofSlice); 436 var roofCSG = new ThreeBSP(roofSlice);
421 wallCSG = wallCSG.subtract(roofCSG); 437 wallCSG = wallCSG.subtract(roofCSG);
422 } 438 }
423 if (roofSlice1) { 439 if (roofSlice1) {
424 var roofCSG = new ThreeBSP(roofSlice1); 440 var roofCSG = new ThreeBSP(roofSlice1);
425 wallCSG = wallCSG.subtract(roofCSG); 441 wallCSG = wallCSG.subtract(roofCSG);
426 } 442 }
427 if (roofSlice2) { 443 if (roofSlice2) {
428 var roofCSG = new ThreeBSP(roofSlice2); 444 var roofCSG = new ThreeBSP(roofSlice2);
429 wallCSG = wallCSG.subtract(roofCSG); 445 wallCSG = wallCSG.subtract(roofCSG);
430 } 446 }
431 doorObj.forEach(function (dr, k) { 447 doorObj.forEach(function (dr, k) {
432 var doorCSG = new ThreeBSP(dr); 448 var doorCSG = new ThreeBSP(dr);
433 wallCSG = wallCSG.subtract(doorCSG); 449 wallCSG = wallCSG.subtract(doorCSG);
434 }); 450 });
435 arrWallPaint.push(wallCSG.toMesh()); 451 arrWallPaint.push(wallCSG.toMesh());
436 }); 452 });
437 arrWallPaint.forEach(function (item, index) { 453 arrWallPaint.forEach(function (item, index) {
438 var ceilingMaterial = new THREE.MeshBasicMaterial({ 454 var ceilingMaterial = new THREE.MeshBasicMaterial({
439 map: wallPaintTexture, 455 map: wallPaintTexture,
440 shading: THREE.FlatShading, 456 shading: THREE.FlatShading,
441 side: THREE.DoubleSide, 457 side: THREE.DoubleSide,
442 }); 458 });
443 item.material = ceilingMaterial; 459 item.material = ceilingMaterial;
444 scene.add(item); 460 scene.add(item);
445 }); 461 });
446 462
447 // MR 1347 - END 463 // MR 1347 - END
448 464
449 var arrPillar = []; 465 var arrPillar = [];
450 pillarObj.forEach(function (v, k) { 466 pillarObj.forEach(function (v, k) {
451 var pillarCSG = new ThreeBSP(v); 467 var pillarCSG = new ThreeBSP(v);
452 if (roofSlice) { 468 if (roofSlice) {
453 var roofCSG = new ThreeBSP(roofSlice); 469 var roofCSG = new ThreeBSP(roofSlice);
454 pillarCSG = pillarCSG.subtract(roofCSG); 470 pillarCSG = pillarCSG.subtract(roofCSG);
455 } 471 }
456 if (roofSlice1) { 472 if (roofSlice1) {
457 var roofCSG = new ThreeBSP(roofSlice1); 473 var roofCSG = new ThreeBSP(roofSlice1);
458 pillarCSG = pillarCSG.subtract(roofCSG); 474 pillarCSG = pillarCSG.subtract(roofCSG);
459 } 475 }
460 if (roofSlice2) { 476 if (roofSlice2) {
461 var roofCSG = new ThreeBSP(roofSlice2); 477 var roofCSG = new ThreeBSP(roofSlice2);
462 pillarCSG = pillarCSG.subtract(roofCSG); 478 pillarCSG = pillarCSG.subtract(roofCSG);
463 } 479 }
464 arrPillar.push(pillarCSG.toMesh()); 480 arrPillar.push(pillarCSG.toMesh());
465 481
466 }); 482 });
467 arrPillar.forEach(function (pillar) { 483 arrPillar.forEach(function (pillar) {
468 var ceilingMaterial = new THREE.MeshBasicMaterial({ 484 var ceilingMaterial = new THREE.MeshBasicMaterial({
469 map: wallTexture, 485 map: wallTexture,
470 shading: THREE.FlatShading, 486 shading: THREE.FlatShading,
471 side: THREE.DoubleSide, 487 side: THREE.DoubleSide,
472 }); 488 });
473 pillar.material = ceilingMaterial; 489 pillar.material = ceilingMaterial;
474 scene.add(pillar); 490 scene.add(pillar);
475 }); 491 });
476 scene.add(baconObj); 492 scene.add(baconObj);
477 scene.add(floorObj); 493 scene.add(floorObj);
478 //windowObj.forEach(function (w, k) { 494 //windowObj.forEach(function (w, k) {
479 // scene.add(w); 495 // scene.add(w);
480 //}); 496 //});
481 woodWindowObj.forEach(function (ww, k) { 497 woodWindowObj.forEach(function (ww, k) {
482 scene.add(ww); 498 scene.add(ww);
483 }); 499 });
484 doorObj.forEach(function (dobj) { 500 doorObj.forEach(function (dobj) {
485 scene.add(dobj); 501 scene.add(dobj);
486 }); 502 });
487 503
488 504
489 // MR 1340 - START 505 // MR 1340 - START
490 handrailObj.forEach(function (ww, k) { 506 handrailObj.forEach(function (ww, k) {
491 scene.add(ww); 507 scene.add(ww);
492 }); 508 });
493 509
494 510
495 stepperObj.forEach(function (ww, k) { 511 stepperObj.forEach(function (ww, k) {
496 scene.add(ww); 512 scene.add(ww);
497 }); 513 });
498 514
499 //var floorTexture = new loader.load('images/3dhouse.jpg'); 515 //var floorTexture = new loader.load('images/3dhouse.jpg');
500 //floorTexture.wrapS = floorTexture.wrapT = THREE.RepeatWrapping; 516 //floorTexture.wrapS = floorTexture.wrapT = THREE.RepeatWrapping;
501 //floorTexture.repeat.set(100, 100); 517 //floorTexture.repeat.set(100, 100);
502 //var floorMaterial = new THREE.MeshBasicMaterial({map: floorTexture, side: THREE.DoubleSide}); 518 //var floorMaterial = new THREE.MeshBasicMaterial({map: floorTexture, side: THREE.DoubleSide});
503 //var floorGeometry = new THREE.PlaneGeometry(10000, 10000, 1, 1); 519 //var floorGeometry = new THREE.PlaneGeometry(10000, 10000, 1, 1);
504 //floor = new THREE.Mesh(floorGeometry, floorMaterial); 520 //floor = new THREE.Mesh(floorGeometry, floorMaterial);
505 //floor.position.y = -0.5; 521 //floor.position.y = -0.5;
506 //floor.rotation.x = -Math.PI / 2; 522 //floor.rotation.x = -Math.PI / 2;
507 //// 523 ////
508 //if (inside) { 524 //if (inside) {
509 // floor.position.y = -converMMtoPX(300 + 300); 525 // floor.position.y = -converMMtoPX(300 + 300);
510 // floor.position.x = converMMtoPX(floorInfo[2][0]); 526 // floor.position.x = converMMtoPX(floorInfo[2][0]);
511 // floor.position.z = converMMtoPX(floorInfo[2][1]); 527 // floor.position.z = converMMtoPX(floorInfo[2][1]);
512 //} 528 //}
513 529
514 530
515 // 531 //
516 scene.add(floorObj); 532 scene.add(floorObj);
517 533
518 534
519 var imagePrefix = "images/dawnmountain-"; 535 var imagePrefix = "images/dawnmountain-";
520 var directions = ["xpos", "xneg", "ypos", "yneg", "zpos", "zneg"]; 536 var directions = ["xpos", "xneg", "ypos", "yneg", "zpos", "zneg"];
521 var imageSuffix = ".png"; 537 var imageSuffix = ".png";
522 var skyGeometry = new THREE.CubeGeometry(6000, 6000, 6000); 538 var skyGeometry = new THREE.CubeGeometry(6000, 6000, 6000);
523 539
524 var materialArray = []; 540 var materialArray = [];
525 for (var i = 0; i < 6; i++) 541 for (var i = 0; i < 6; i++)
526 materialArray.push(new THREE.MeshBasicMaterial({ 542 materialArray.push(new THREE.MeshBasicMaterial({
527 map: loader.load(imagePrefix + directions[i] + imageSuffix), 543 map: loader.load(imagePrefix + directions[i] + imageSuffix),
528 side: THREE.BackSide 544 side: THREE.BackSide
529 })); 545 }));
530 var skyMaterial = new THREE.MeshFaceMaterial(materialArray); 546 var skyMaterial = new THREE.MeshFaceMaterial(materialArray);
531 var skyBox = new THREE.Mesh(skyGeometry, skyMaterial); 547 var skyBox = new THREE.Mesh(skyGeometry, skyMaterial);
532 skyBox.position.y = 3000 - converMMtoPX(180); 548 skyBox.position.y = 3000 - converMMtoPX(180);
533 if (inside) { 549 if (inside) {
534 skyBox.position.y = 3000 - converMMtoPX(300 + 300 + 180); 550 skyBox.position.y = 3000 - converMMtoPX(300 + 300 + 180);
535 skyBox.position.x = converMMtoPX(floorInfo[2][0]); 551 skyBox.position.x = converMMtoPX(floorInfo[2][0]);
536 skyBox.position.z = converMMtoPX(floorInfo[2][1]); 552 skyBox.position.z = converMMtoPX(floorInfo[2][1]);
537 } 553 }
538 scene.add(skyBox); 554 scene.add(skyBox);
539 555
540 //RM 1423 556 //RM 1423
541 drawBeamUnderFloor(scene); 557 drawBeamUnderFloor(scene);
542 558
543 559
544 //var skyBoxGeometry = new THREE.CubeGeometry(10000, 10000, 10000); 560 //var skyBoxGeometry = new THREE.CubeGeometry(10000, 10000, 10000);
545 // 561 //
546 //var skyTex = new loader.load('images/sky.jpg'); 562 //var skyTex = new loader.load('images/sky.jpg');
547 //skyTex.wrapS = skyTex.wrapT = THREE.RepeatWrapping; 563 //skyTex.wrapS = skyTex.wrapT = THREE.RepeatWrapping;
548 //skyTex.repeat.set(1, 1); 564 //skyTex.repeat.set(1, 1);
549 // 565 //
550 //var skyBoxMaterial = new THREE.MeshBasicMaterial({map: skyTex, color: 0xFFFFFF, side: THREE.BackSide}); 566 //var skyBoxMaterial = new THREE.MeshBasicMaterial({map: skyTex, color: 0xFFFFFF, side: THREE.BackSide});
551 //var skyBox = new THREE.Mesh(skyBoxGeometry, skyBoxMaterial); 567 //var skyBox = new THREE.Mesh(skyBoxGeometry, skyBoxMaterial);
552 //scene.add(skyBox); 568 //scene.add(skyBox);
553 // 569 //
554 // 570 //
555 //scene.fog = new THREE.FogExp2(0x9999ff, 0.000025); 571 //scene.fog = new THREE.FogExp2(0x9999ff, 0.000025);
556 } 572 }
557 573
558 function isExistStepper(handrail3dxy) 574 function isExistStepper(handrail3dxy)
559 { 575 {
560 var existFlag = false; 576 var existFlag = false;
561 var stepArr = []; 577 var stepArr = [];
562 // Get step info 578 // Get step info
563 var stepperList = getArray3dCadByType(TYPE_STEPPER); 579 var stepperList = getArray3dCadByType(TYPE_STEPPER);
564 if(stepperList.length > 0) 580 if(stepperList.length > 0)
565 { 581 {
566 for(var j = 0; j < stepperList.length; j++) 582 for(var j = 0; j < stepperList.length; j++)
567 { 583 {
568 var stepper = stepperList[j]; 584 var stepper = stepperList[j];
569 var stepper3dxy = { 585 var stepper3dxy = {
570 'start_X': converMMtoPX(stepper[2][0]), 586 'start_X': converMMtoPX(stepper[2][0]),
571 'start_Y': converMMtoPX(stepper[2][1]), 587 'start_Y': converMMtoPX(stepper[2][1]),
572 'width_X': converMMtoPX(stepper[2][2]), 588 'width_X': converMMtoPX(stepper[2][2]),
573 'width_Y': converMMtoPX(stepper[2][3]), 589 'width_Y': converMMtoPX(stepper[2][3]),
574 'height_startpoint': converMMtoPX(stepper[2][4]), 590 'height_startpoint': converMMtoPX(stepper[2][4]),
575 'height_endpoint': converMMtoPX(stepper[2][5]), 591 'height_endpoint': converMMtoPX(stepper[2][5]),
576 }; 592 };
577 593
578 //if both horizontal 594 //if both horizontal
579 if(stepper3dxy.width_X > stepper3dxy.width_Y && handrail3dxy.width_X > handrail3dxy.width_Y) 595 if(stepper3dxy.width_X > stepper3dxy.width_Y && handrail3dxy.width_X > handrail3dxy.width_Y)
580 { 596 {
581 if( handrail3dxy.start_X <= stepper3dxy.start_X + stepper3dxy.width_X/2 597 if( handrail3dxy.start_X <= stepper3dxy.start_X + stepper3dxy.width_X/2
582 && stepper3dxy.start_X + stepper3dxy.width_X/2 <= handrail3dxy.start_X + handrail3dxy.width_X 598 && stepper3dxy.start_X + stepper3dxy.width_X/2 <= handrail3dxy.start_X + handrail3dxy.width_X
583 && stepper3dxy.start_Y >= handrail3dxy.start_Y ) 599 && stepper3dxy.start_Y >= handrail3dxy.start_Y )
584 { 600 {
585 existFlag = true; 601 existFlag = true;
586 stepArr.push(stepper3dxy) 602 stepArr.push(stepper3dxy)
587 // return { 603 // return {
588 // 'isExist': true, 604 // 'isExist': true,
589 // 'stepper3dxy': stepper3dxy 605 // 'stepper3dxy': stepper3dxy
590 // }; 606 // };
591 } 607 }
592 } 608 }
593 else if(stepper3dxy.width_X < stepper3dxy.width_Y && handrail3dxy.width_X < handrail3dxy.width_Y) 609 else if(stepper3dxy.width_X < stepper3dxy.width_Y && handrail3dxy.width_X < handrail3dxy.width_Y)
594 { 610 {
595 if( handrail3dxy.start_Y <= stepper3dxy.start_Y + stepper3dxy.width_Y/2 611 if( handrail3dxy.start_Y <= stepper3dxy.start_Y + stepper3dxy.width_Y/2
596 && stepper3dxy.start_Y + stepper3dxy.width_Y/2 <= handrail3dxy.start_Y + handrail3dxy.width_Y 612 && stepper3dxy.start_Y + stepper3dxy.width_Y/2 <= handrail3dxy.start_Y + handrail3dxy.width_Y
597 && Math.abs(handrail3dxy.start_X - stepper3dxy.start_X) <= handrail3dxy.width_X + stepper3dxy.width_X) 613 && Math.abs(handrail3dxy.start_X - stepper3dxy.start_X) <= handrail3dxy.width_X + stepper3dxy.width_X)
598 { 614 {
599 existFlag = true; 615 existFlag = true;
600 stepArr.push(stepper3dxy) 616 stepArr.push(stepper3dxy)
601 // return { 617 // return {
602 // 'isExist': true, 618 // 'isExist': true,
603 // 'stepper3dxy': stepper3dxy 619 // 'stepper3dxy': stepper3dxy
604 // }; 620 // };
605 } 621 }
606 } 622 }
607 } 623 }
608 } 624 }
609 625
610 626
611 return { 627 return {
612 'isExist': existFlag, 628 'isExist': existFlag,
613 'stepArr': stepArr 629 'stepArr': stepArr
614 }; 630 };
615 } 631 }
616 function checkAndDrawHandrail(handrail3dxy, handrail3dObject) 632 function checkAndDrawHandrail(handrail3dxy, handrail3dObject)
617 { 633 {
618 var drawArr = []; //arrary to draw child handrail 634 var drawArr = []; //arrary to draw child handrail
619 var result = isExistStepper(handrail3dxy); 635 var result = isExistStepper(handrail3dxy);
620 // If exist handrail than need to canculate 636 // If exist handrail than need to canculate
621 if(result.stepArr.length > 0 && result.isExist) 637 if(result.stepArr.length > 0 && result.isExist)
622 { 638 {
623 // If horizontal 639 // If horizontal
624 if(handrail3dxy.width_X > handrail3dxy.width_Y) 640 if(handrail3dxy.width_X > handrail3dxy.width_Y)
625 { 641 {
626 drawArr.push(handrail3dxy.start_X); 642 drawArr.push(handrail3dxy.start_X);
627 // Sort step by xtart_x 643 // Sort step by xtart_x
628 result.stepArr.sort(function(a, b) { 644 result.stepArr.sort(function(a, b) {
629 return a.start_X - b.start_X; 645 return a.start_X - b.start_X;
630 }); 646 });
631 result.stepArr.forEach(function(item){ 647 result.stepArr.forEach(function(item){
632 drawArr.push(item.start_X); 648 drawArr.push(item.start_X);
633 drawArr.push(item.start_X + item.width_X); 649 drawArr.push(item.start_X + item.width_X);
634 }); 650 });
635 drawArr.push(handrail3dxy.start_X + handrail3dxy.width_X); 651 drawArr.push(handrail3dxy.start_X + handrail3dxy.width_X);
636 for (var i = 0; i < drawArr.length; i += 2) { 652 for (var i = 0; i < drawArr.length; i += 2) {
637 if(drawArr[i+1] > drawArr[i]) 653 if(drawArr[i+1] > drawArr[i])
638 { 654 {
639 //Draw handrail for this 655 //Draw handrail for this
640 var child3dxy = JSON.parse(JSON.stringify(handrail3dxy)); 656 var child3dxy = JSON.parse(JSON.stringify(handrail3dxy));
641 child3dxy.start_X = drawArr[i]; 657 child3dxy.start_X = drawArr[i];
642 child3dxy.width_X = drawArr[i + 1] - drawArr[i]; 658 child3dxy.width_X = drawArr[i + 1] - drawArr[i];
643 drawHandrail(scene, child3dxy, handrail3dObject); 659 drawHandrail(scene, child3dxy, handrail3dObject);
644 } 660 }
645 } 661 }
646 } 662 }
647 else 663 else
648 { 664 {
649 drawArr.push(handrail3dxy.start_Y); 665 drawArr.push(handrail3dxy.start_Y);
650 // Sort step by xtart_x 666 // Sort step by xtart_x
651 result.stepArr.sort(function(a, b) { 667 result.stepArr.sort(function(a, b) {
652 return a.start_Y - b.start_Y; 668 return a.start_Y - b.start_Y;
653 }); 669 });
654 result.stepArr.forEach(function(item){ 670 result.stepArr.forEach(function(item){
655 drawArr.push(item.start_Y); 671 drawArr.push(item.start_Y);
656 drawArr.push(item.start_Y + item.width_Y); 672 drawArr.push(item.start_Y + item.width_Y);
657 }); 673 });
658 drawArr.push(handrail3dxy.start_Y + handrail3dxy.width_Y); 674 drawArr.push(handrail3dxy.start_Y + handrail3dxy.width_Y);
659 for (var i = 0; i < drawArr.length; i += 2) { 675 for (var i = 0; i < drawArr.length; i += 2) {
660 if(drawArr[i+1] - drawArr[i] > 150) 676 if(drawArr[i+1] - drawArr[i] > 150)
661 { 677 {
662 //Draw handrail for this 678 //Draw handrail for this
663 var child3dxy = JSON.parse(JSON.stringify(handrail3dxy)); 679 var child3dxy = JSON.parse(JSON.stringify(handrail3dxy));
664 child3dxy.start_Y = drawArr[i]; 680 child3dxy.start_Y = drawArr[i];
665 child3dxy.width_Y = drawArr[i + 1] - drawArr[i]; 681 child3dxy.width_Y = drawArr[i + 1] - drawArr[i];
666 drawHandrail(scene, child3dxy, handrail3dObject); 682 drawHandrail(scene, child3dxy, handrail3dObject);
667 } 683 }
668 } 684 }
669 } 685 }
670 } 686 }
671 else 687 else
672 { 688 {
673 // draw normally 689 // draw normally
674 drawHandrail(scene, handrail3dxy, handrail3dObject); 690 drawHandrail(scene, handrail3dxy, handrail3dObject);
675 } 691 }
676 } 692 }
677 693
678 694
679 function animate() { 695 function animate() {
680 requestAnimationFrame(animate); 696 requestAnimationFrame(animate);
681 render(); 697 render();
682 update(); 698 update();
683 } 699 }
684 700
685 function update() { 701 function update() {
686 controls.update(); 702 controls.update();
687 } 703 }
688 function noRoof() { 704 function noRoof() {
689 if (roof3D) { 705 if (roof3D) {
690 scene.remove(roof3D); 706 scene.remove(roof3D);
691 } 707 }
692 if (roof_2roof_obj) { 708 if (roof_2roof_obj) {
693 scene.remove(roof_2roof_obj); 709 scene.remove(roof_2roof_obj);
694 } 710 }
695 if (roof_1roof_obj) { 711 if (roof_1roof_obj) {
696 scene.remove(roof_1roof_obj); 712 scene.remove(roof_1roof_obj);
697 } 713 }
698 document.getElementById('no-roof').style.display = 'none'; 714 document.getElementById('no-roof').style.display = 'none';
699 document.getElementById('has-roof').style.display = 'block'; 715 document.getElementById('has-roof').style.display = 'block';
700 716
701 animate(); 717 animate();
702 } 718 }
703 function hasRoof() { 719 function hasRoof() {
704 if (roof3D) { 720 if (roof3D) {
705 scene.add(roof3D); 721 scene.add(roof3D);
706 } else { 722 } else {
707 if (roof_2roof_obj) { 723 if (roof_2roof_obj) {
708 scene.add(roof_2roof_obj); 724 scene.add(roof_2roof_obj);
709 } 725 }
710 if (roof_1roof_obj) { 726 if (roof_1roof_obj) {
711 scene.add(roof_1roof_obj); 727 scene.add(roof_1roof_obj);
712 } 728 }
713 } 729 }
714 730
715 document.getElementById('no-roof').style.display = 'block'; 731 document.getElementById('no-roof').style.display = 'block';
716 document.getElementById('has-roof').style.display = 'none'; 732 document.getElementById('has-roof').style.display = 'none';
717 animate(); 733 animate();
718 } 734 }
719 function render() { 735 function render() {
720 //renderer.shadowMapType = THREE.PCFSoftShadowMap; 736 //renderer.shadowMapType = THREE.PCFSoftShadowMap;
721 //renderer.shadowMapEnabled = true; 737 //renderer.shadowMapEnabled = true;
722 renderer.render(scene, camera); 738 renderer.render(scene, camera);
723 } 739 }
724 function converMMtoPX(mm) { 740 function converMMtoPX(mm) {
725 return px = mm * 100 / 455; 741 return px = mm * 100 / 455;
726 } 742 }
727 743
728 function converPxtoMm(px) { 744 function converPxtoMm(px) {
729 return mm = px * 455 / ( 100); 745 return mm = px * 455 / ( 100);
730 } 746 }
731 747
732 var painterWidth = 2; 748 var painterWidth = 2;
733 var wallWidth = 40; // mm 749 var wallWidth = 40; // mm
734 // Draw Wall 750 // Draw Wall
735 function drawWall(scene, _3dxy, _3dobject) { 751 function drawWall(scene, _3dxy, _3dobject) {
736 if (!wallTexture) { 752 if (!wallTexture) {
737 wallTexture = new loader.load('images/kabe.jpg'); 753 wallTexture = new loader.load('images/kabe.jpg');
738 wallTexture.wrapT = THREE.RepeatWrapping; 754 wallTexture.wrapT = THREE.RepeatWrapping;
739 wallTexture.repeat.set(5, 5); 755 wallTexture.repeat.set(5, 5);
740 } 756 }
741 if (_3dxy.width_X < _3dxy.width_Y) { 757 if (_3dxy.width_X < _3dxy.width_Y) {
742 _3dxy.width_X = converMMtoPX(wallWidth); 758 _3dxy.width_X = converMMtoPX(wallWidth);
743 } else { 759 } else {
744 _3dxy.width_Y = converMMtoPX(wallWidth); 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 _3dxy.height_startpoint = wall3D.height_startpoint + floor3D.height_endpoint; 764 _3dxy.height_startpoint = wall3D.height_startpoint + floor3D.height_endpoint;
765
748 var material = { 766 var material = {
749 'tex': wallTexture, 767 'tex': wallTexture,
750 }; 768 };
751 isDraw = 'wall'; 769 isDraw = 'wall';
752 var wall = drawObj(scene, _3dxy, _3dobject, material); 770 var wall = drawObj(scene, _3dxy, _3dobject, material);
753 771
754 wallObj.push(wall); 772 wallObj.push(wall);
755 drawWallPaintInside(scene, _3dxy, _3dobject); 773 drawWallPaintInside(scene, _3dxy, _3dobject);
756 } 774 }
757 // MR 1347 - START 775 // MR 1347 - START
758 // draw wall paint Inside 776 // draw wall paint Inside
759 function drawWallPaintInside(scene, _3dxy, _3dobject) { 777 function drawWallPaintInside(scene, _3dxy, _3dobject) {
760 var _paint3dxy = { 778 var _paint3dxy = {
761 'start_X': _3dxy.start_X, 779 'start_X': _3dxy.start_X,
762 'start_Y': _3dxy.start_Y, 780 'start_Y': _3dxy.start_Y,
763 'width_X': _3dxy.width_X, 781 'width_X': _3dxy.width_X,
764 'width_Y': _3dxy.width_Y, 782 'width_Y': _3dxy.width_Y,
765 'height_startpoint': _3dxy.height_startpoint, 783 'height_startpoint': _3dxy.height_startpoint,
766 'height_endpoint': _3dxy.height_endpoint, 784 'height_endpoint': _3dxy.height_endpoint,
767 }; 785 };
768 var pos = getWallPosition(_3dxy); 786 var pos = getWallPosition(_3dxy);
769 switch (pos) { 787 switch (pos) {
770 case 1: 788 case 1:
771 // top 789 // top
772 _paint3dxy.start_Y += _3dxy.width_Y; 790 _paint3dxy.start_Y += _3dxy.width_Y;
773 _paint3dxy.width_Y = painterWidth; 791 _paint3dxy.width_Y = painterWidth;
774 792
775 break; 793 break;
776 case 2: 794 case 2:
777 // bottom 795 // bottom
778 _paint3dxy.start_Y -= painterWidth; 796 _paint3dxy.start_Y -= painterWidth;
779 _paint3dxy.width_Y = painterWidth; 797 _paint3dxy.width_Y = painterWidth;
780 break; 798 break;
781 case 3: 799 case 3:
782 // left 800 // left
783 _paint3dxy.start_X += _3dxy.width_X; 801 _paint3dxy.start_X += _3dxy.width_X;
784 _paint3dxy.width_X = painterWidth; 802 _paint3dxy.width_X = painterWidth;
785 803
786 break; 804 break;
787 case 4: 805 case 4:
788 // right 806 // right
789 _paint3dxy.start_X -= painterWidth; 807 _paint3dxy.start_X -= painterWidth;
790 _paint3dxy.width_X = painterWidth; 808 _paint3dxy.width_X = painterWidth;
791 809
792 break; 810 break;
793 default: 811 default:
794 console.log("Unknown position: " + pos); 812 console.log("Unknown position: " + pos);
795 break; 813 break;
796 } 814 }
797 815
798 var material = { 816 var material = {
799 'tex': wallPaintTexture, 817 'tex': wallPaintTexture,
800 }; 818 };
801 isDraw = 'wall'; 819 isDraw = 'wall';
802 var wall = drawObj(scene, _paint3dxy, _3dobject, material); 820 var wall = drawObj(scene, _paint3dxy, _3dobject, material);
803 821
804 wallPaint.push(wall); 822 wallPaint.push(wall);
805 823
806 } 824 }
807 825
808 826
809 // get wall position: return: 1: top 2: bรดtm 3: left 4: right 827 // get wall position: return: 1: top 2: bรดtm 3: left 4: right
810 function getWallPosition(_3dxy) { 828 function getWallPosition(_3dxy) {
811 var floorList = getArray3dCadByType(TYPE_FLOOR); 829 var floorList = getArray3dCadByType(TYPE_FLOOR);
812 if (floorList.length != 0) { 830 if (floorList.length != 0) {
813 var floor = floorList[0]; 831 var floor = floorList[0];
814 if (_3dxy.width_X > _3dxy.width_Y) { 832 if (_3dxy.width_X > _3dxy.width_Y) {
815 if (_3dxy.start_Y <= converMMtoPX(floor[2][1]) + _3dxy.width_Y) { 833 if (_3dxy.start_Y <= converMMtoPX(floor[2][1]) + _3dxy.width_Y) {
816 // top 834 // top
817 return 1; 835 return 1;
818 } 836 }
819 else { 837 else {
820 //bottom 838 //bottom
821 return 2; 839 return 2;
822 } 840 }
823 } 841 }
824 else { 842 else {
825 if (_3dxy.start_X <= converMMtoPX(floor[2][0]) + _3dxy.width_X) { 843 if (_3dxy.start_X <= converMMtoPX(floor[2][0]) + _3dxy.width_X) {
826 // left 844 // left
827 return 3; 845 return 3;
828 } 846 }
829 else { 847 else {
830 // right 848 // right
831 return 4; 849 return 4;
832 } 850 }
833 851
834 } 852 }
835 } 853 }
836 854
837 } 855 }
838 856
839 // MR 1347 - END 857 // MR 1347 - END
840 858
841 //Draw Pillar 859 //Draw Pillar
842 function drawPillar(scene, _3dxy, _3dobject) { 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 _3dxy.height_startpoint = floor3D.height_endpoint; 862 _3dxy.height_startpoint = floor3D.height_endpoint;
845 863
846 drawPillarWithPaintInside(scene, _3dxy, _3dobject) 864 drawPillarWithPaintInside(scene, _3dxy, _3dobject)
847 865
848 } 866 }
849 867
850 868
851 // MR 1508 - START 869 // MR 1508 - START
852 // draw pillar paint outside 870 // draw pillar paint outside
853 function drawPillarWithPaintInside(scene, _3dxy, _3dobject) { 871 function drawPillarWithPaintInside(scene, _3dxy, _3dobject) {
854 var _paint3dxy = { 872 var _paint3dxy = {
855 'start_X': _3dxy.start_X, 873 'start_X': _3dxy.start_X,
856 'start_Y': _3dxy.start_Y, 874 'start_Y': _3dxy.start_Y,
857 'width_X': _3dxy.width_X, 875 'width_X': _3dxy.width_X,
858 'width_Y': _3dxy.width_Y, 876 'width_Y': _3dxy.width_Y,
859 'height_startpoint': _3dxy.height_startpoint, 877 'height_startpoint': _3dxy.height_startpoint,
860 'height_endpoint': _3dxy.height_endpoint, 878 'height_endpoint': _3dxy.height_endpoint,
861 }; 879 };
862 if(checkPillarInsideFloor(_3dxy) == true) 880 if(checkPillarInsideFloor(_3dxy) == true)
863 { 881 {
864 if(checkPillarInLeftOrRightWall(_3dxy) == 1) 882 if(checkPillarInLeftOrRightWall(_3dxy) == 1)
865 { 883 {
866 // left 884 // left
867 if( checkPillarInAngleWall(_3dxy) == false) 885 if( checkPillarInAngleWall(_3dxy) == false)
868 { 886 {
869 _paint3dxy.start_X = _3dxy.start_X + _3dxy.width_X; 887 _paint3dxy.start_X = _3dxy.start_X + _3dxy.width_X;
870 _paint3dxy.width_X = painterWidth; 888 _paint3dxy.width_X = painterWidth;
871 _paint3dxy.start_Y = _3dxy.start_Y - painterWidth/2; 889 _paint3dxy.start_Y = _3dxy.start_Y - painterWidth/2;
872 _paint3dxy.width_Y = _3dxy.width_Y + painterWidth; 890 _paint3dxy.width_Y = _3dxy.width_Y + painterWidth;
873 891
874 painter(_paint3dxy, _3dobject); 892 painter(_paint3dxy, _3dobject);
875 } 893 }
876 894
877 } 895 }
878 else if(checkPillarInLeftOrRightWall(_3dxy) == 2) 896 else if(checkPillarInLeftOrRightWall(_3dxy) == 2)
879 { 897 {
880 // right 898 // right
881 _3dxy.start_X = _3dxy.start_X + converMMtoPX(40); /* adjust pos by wall width*/ 899 _3dxy.start_X = _3dxy.start_X + converMMtoPX(40); /* adjust pos by wall width*/
882 900
883 if( checkPillarInAngleWall(_3dxy) == false) 901 if( checkPillarInAngleWall(_3dxy) == false)
884 { 902 {
885 _paint3dxy.start_X = _3dxy.start_X - painterWidth; 903 _paint3dxy.start_X = _3dxy.start_X - painterWidth;
886 _paint3dxy.width_X = painterWidth; 904 _paint3dxy.width_X = painterWidth;
887 _paint3dxy.start_Y = _3dxy.start_Y - painterWidth/2; 905 _paint3dxy.start_Y = _3dxy.start_Y - painterWidth/2;
888 _paint3dxy.width_Y = _3dxy.width_Y + painterWidth; 906 _paint3dxy.width_Y = _3dxy.width_Y + painterWidth;
889 907
890 painter(_paint3dxy, _3dobject); 908 painter(_paint3dxy, _3dobject);
891 } 909 }
892 910
893 } 911 }
894 912
895 // check top Bottom 913 // check top Bottom
896 914
897 if(checkPillarInTopOrBottomWall(_3dxy) == 1) 915 if(checkPillarInTopOrBottomWall(_3dxy) == 1)
898 { 916 {
899 // top 917 // top
900 if( checkPillarInAngleWall(_3dxy) == false) 918 if( checkPillarInAngleWall(_3dxy) == false)
901 { 919 {
902 _paint3dxy.start_X = _3dxy.start_X - painterWidth/2; 920 _paint3dxy.start_X = _3dxy.start_X - painterWidth/2;
903 _paint3dxy.width_X = _3dxy.width_X + painterWidth; 921 _paint3dxy.width_X = _3dxy.width_X + painterWidth;
904 _paint3dxy.start_Y = _3dxy.start_Y + _3dxy.width_Y; 922 _paint3dxy.start_Y = _3dxy.start_Y + _3dxy.width_Y;
905 _paint3dxy.width_Y = painterWidth; 923 _paint3dxy.width_Y = painterWidth;
906 924
907 painter(_paint3dxy, _3dobject); 925 painter(_paint3dxy, _3dobject);
908 } 926 }
909 927
910 } 928 }
911 else if(checkPillarInTopOrBottomWall(_3dxy) == 2) 929 else if(checkPillarInTopOrBottomWall(_3dxy) == 2)
912 { 930 {
913 931
914 // bottom 932 // bottom
915 _3dxy.start_Y = _3dxy.start_Y + converMMtoPX(40); /* adjust pos by wall width*/ 933 _3dxy.start_Y = _3dxy.start_Y + converMMtoPX(40); /* adjust pos by wall width*/
916 934
917 if( checkPillarInAngleWall(_3dxy) == false) 935 if( checkPillarInAngleWall(_3dxy) == false)
918 { 936 {
919 _paint3dxy.start_X = _3dxy.start_X - painterWidth/2; 937 _paint3dxy.start_X = _3dxy.start_X - painterWidth/2;
920 _paint3dxy.width_X = _3dxy.width_X + painterWidth; 938 _paint3dxy.width_X = _3dxy.width_X + painterWidth;
921 _paint3dxy.start_Y = _3dxy.start_Y -painterWidth; 939 _paint3dxy.start_Y = _3dxy.start_Y -painterWidth;
922 _paint3dxy.width_Y = painterWidth; 940 _paint3dxy.width_Y = painterWidth;
923 941
924 painter(_paint3dxy, _3dobject); 942 painter(_paint3dxy, _3dobject);
925 } 943 }
926 } 944 }
927 } 945 }
928 var material = {}; 946 var material = {};
929 var pillar = drawObj(scene, _3dxy, _3dobject, material); 947 var pillar = drawObj(scene, _3dxy, _3dobject, material);
930 pillarObj.push(pillar); 948 pillarObj.push(pillar);
931 949
932 } 950 }
933 951
934 // Check Pillar on angle if floor in side floor 952 // Check Pillar on angle if floor in side floor
935 function checkPillarInAngleWall(_3dxy) { 953 function checkPillarInAngleWall(_3dxy) {
936 var floorList = getArray3dCadByType(TYPE_FLOOR); 954 var floorList = getArray3dCadByType(TYPE_FLOOR);
937 if (floorList.length != 0) { 955 if (floorList.length != 0) {
938 var floor = floorList[0]; 956 var floor = floorList[0];
939 if((_3dxy.start_Y <= converMMtoPX(floor[2][1]) &&_3dxy.start_X <= converMMtoPX(floor[2][0]) ) || 957 if((_3dxy.start_Y <= converMMtoPX(floor[2][1]) &&_3dxy.start_X <= converMMtoPX(floor[2][0]) ) ||
940 (_3dxy.start_Y + _3dxy.width_Y >= converMMtoPX(floor[2][1] + floor[2][3] ) &&_3dxy.start_X <= converMMtoPX(floor[2][0]) ) || 958 (_3dxy.start_Y + _3dxy.width_Y >= converMMtoPX(floor[2][1] + floor[2][3] ) &&_3dxy.start_X <= converMMtoPX(floor[2][0]) ) ||
941 (_3dxy.start_Y <= converMMtoPX(floor[2][1]) &&_3dxy.start_X + _3dxy.width_X >= converMMtoPX(floor[2][0] + floor[2][2] ) ) || 959 (_3dxy.start_Y <= converMMtoPX(floor[2][1]) &&_3dxy.start_X + _3dxy.width_X >= converMMtoPX(floor[2][0] + floor[2][2] ) ) ||
942 (_3dxy.start_Y + _3dxy.width_Y >= converMMtoPX(floor[2][1] + floor[2][3] ) &&_3dxy.start_X + _3dxy.width_X >= converMMtoPX(floor[2][0] + floor[2][2] ) ) ) 960 (_3dxy.start_Y + _3dxy.width_Y >= converMMtoPX(floor[2][1] + floor[2][3] ) &&_3dxy.start_X + _3dxy.width_X >= converMMtoPX(floor[2][0] + floor[2][2] ) ) )
943 { 961 {
944 return true; 962 return true;
945 } 963 }
946 } 964 }
947 return false; 965 return false;
948 } 966 }
949 967
950 968
951 // get pillar position: return: 1: left walll; 1: right: 0: midle 969 // get pillar position: return: 1: left walll; 1: right: 0: midle
952 function checkPillarInLeftOrRightWall(_3dxy) { 970 function checkPillarInLeftOrRightWall(_3dxy) {
953 var floorList = getArray3dCadByType(TYPE_FLOOR); 971 var floorList = getArray3dCadByType(TYPE_FLOOR);
954 if (floorList.length != 0) { 972 if (floorList.length != 0) {
955 var floor = floorList[0]; 973 var floor = floorList[0];
956 if(_3dxy.start_X <= converMMtoPX(floor[2][0]) && _3dxy.start_X + _3dxy.width_X >= converMMtoPX(floor[2][0]) ) 974 if(_3dxy.start_X <= converMMtoPX(floor[2][0]) && _3dxy.start_X + _3dxy.width_X >= converMMtoPX(floor[2][0]) )
957 { 975 {
958 return 1; 976 return 1;
959 } 977 }
960 if(_3dxy.start_X <= converMMtoPX(floor[2][0] +floor[2][2] ) && _3dxy.start_X + _3dxy.width_X >= converMMtoPX(floor[2][0] + floor[2][2]) ) 978 if(_3dxy.start_X <= converMMtoPX(floor[2][0] +floor[2][2] ) && _3dxy.start_X + _3dxy.width_X >= converMMtoPX(floor[2][0] + floor[2][2]) )
961 { 979 {
962 return 2; 980 return 2;
963 } 981 }
964 return 0; 982 return 0;
965 } 983 }
966 984
967 } 985 }
968 // get pillar position: return: 1: top walll; 2: bottom: 0: midle 986 // get pillar position: return: 1: top walll; 2: bottom: 0: midle
969 function checkPillarInTopOrBottomWall(_3dxy) { 987 function checkPillarInTopOrBottomWall(_3dxy) {
970 var floorList = getArray3dCadByType(TYPE_FLOOR); 988 var floorList = getArray3dCadByType(TYPE_FLOOR);
971 if (floorList.length != 0) { 989 if (floorList.length != 0) {
972 var floor = floorList[0]; 990 var floor = floorList[0];
973 if(_3dxy.start_Y <= converMMtoPX(floor[2][1]) && _3dxy.start_Y + _3dxy.width_Y >= converMMtoPX(floor[2][1]) ) 991 if(_3dxy.start_Y <= converMMtoPX(floor[2][1]) && _3dxy.start_Y + _3dxy.width_Y >= converMMtoPX(floor[2][1]) )
974 { 992 {
975 return 1; 993 return 1;
976 } 994 }
977 if(_3dxy.start_Y <= converMMtoPX(floor[2][1]+floor[2][3]) && _3dxy.start_Y + _3dxy.width_Y >= converMMtoPX(floor[2][1]+floor[2][3]) ) 995 if(_3dxy.start_Y <= converMMtoPX(floor[2][1]+floor[2][3]) && _3dxy.start_Y + _3dxy.width_Y >= converMMtoPX(floor[2][1]+floor[2][3]) )
978 { 996 {
979 return 2; 997 return 2;
980 } 998 }
981 return 0; 999 return 0;
982 } 1000 }
983 } 1001 }
984 1002
985 // check pillar not in floor: true: in/ false: out 1003 // check pillar not in floor: true: in/ false: out
986 function checkPillarInsideFloor(_3dxy) { 1004 function checkPillarInsideFloor(_3dxy) {
987 var floorList = getArray3dCadByType(TYPE_FLOOR); 1005 var floorList = getArray3dCadByType(TYPE_FLOOR);
988 if (floorList.length != 0) { 1006 if (floorList.length != 0) {
989 var floor = floorList[0]; 1007 var floor = floorList[0];
990 if(_3dxy.start_Y <= converMMtoPX(floor[2][1]+floor[2][3]) && _3dxy.start_Y + _3dxy.width_Y >= converMMtoPX(floor[2][1]) && 1008 if(_3dxy.start_Y <= converMMtoPX(floor[2][1]+floor[2][3]) && _3dxy.start_Y + _3dxy.width_Y >= converMMtoPX(floor[2][1]) &&
991 _3dxy.start_X <= converMMtoPX(floor[2][0] +floor[2][2] ) && _3dxy.start_X + _3dxy.width_X >= converMMtoPX(floor[2][0]) ) 1009 _3dxy.start_X <= converMMtoPX(floor[2][0] +floor[2][2] ) && _3dxy.start_X + _3dxy.width_X >= converMMtoPX(floor[2][0]) )
992 { 1010 {
993 return true; 1011 return true;
994 } 1012 }
995 return false; 1013 return false;
996 } 1014 }
997 } 1015 }
998 1016
999 function painter( _3dxy, _3dobject) 1017 function painter( _3dxy, _3dobject)
1000 { 1018 {
1001 var _3dPainterXY = { 1019 var _3dPainterXY = {
1002 'start_X': _3dxy.start_X, 1020 'start_X': _3dxy.start_X,
1003 'start_Y': _3dxy.start_Y, 1021 'start_Y': _3dxy.start_Y,
1004 'width_X': _3dxy.width_X, 1022 'width_X': _3dxy.width_X,
1005 'width_Y': _3dxy.width_Y, 1023 'width_Y': _3dxy.width_Y,
1006 'height_startpoint': _3dxy.height_startpoint, 1024 'height_startpoint': _3dxy.height_startpoint,
1007 'height_endpoint': _3dxy.height_endpoint, 1025 'height_endpoint': _3dxy.height_endpoint,
1008 }; 1026 };
1009 var material = { 1027 var material = {
1010 'tex': wallPaintTexture, 1028 'tex': wallPaintTexture,
1011 }; 1029 };
1012 var paint = drawObj(scene, _3dPainterXY, _3dobject, material); 1030 var paint = drawObj(scene, _3dPainterXY, _3dobject, material);
1013 1031
1014 wallPaint.push(paint); 1032 wallPaint.push(paint);
1015 } 1033 }
1016 1034
1017 //Draw bacon 1035 //Draw bacon
1018 function drawBacon(scene, _3dxy, _3dobject) { 1036 function drawBacon(scene, _3dxy, _3dobject) {
1019 _3dxy.height_endpoint = bacon3D.height_endpoint; 1037 _3dxy.height_endpoint = bacon3D.height_endpoint;
1020 _3dxy.height_startpoint = bacon3D.height_startpoint; 1038 _3dxy.height_startpoint = bacon3D.height_startpoint;
1021 1039
1022 var material = { 1040 var material = {
1023 'tex': wallTexture 1041 'tex': wallTexture
1024 }; 1042 };
1025 var bacon = drawObj(scene, _3dxy, _3dobject, material); 1043 var bacon = drawObj(scene, _3dxy, _3dobject, material);
1026 baconObj.add(bacon); 1044 baconObj.add(bacon);
1027 } 1045 }
1028 1046
1029 //Draw handrail3D -- MR 1340 - START 1047 //Draw handrail3D -- MR 1340 - START
1030 function drawHandrail(scene, _3dxy, _3dobject) { 1048 function drawHandrail(scene, _3dxy, _3dobject) {
1031 _3dxy.height_endpoint = _3dxy.height_endpoint + bacon3D.height_endpoint; 1049 _3dxy.height_endpoint = _3dxy.height_endpoint + bacon3D.height_endpoint;
1032 _3dxy.height_startpoint = _3dxy.height_startpoint + bacon3D.height_endpoint; 1050 _3dxy.height_startpoint = _3dxy.height_startpoint + bacon3D.height_endpoint;
1033 var balconyList = getArray3dCadByType(TYPE_BALCONY); 1051 var balconyList = getArray3dCadByType(TYPE_BALCONY);
1034 if (balconyList.length != 0) { 1052 if (balconyList.length != 0) {
1035 balcony = balconyList[0]; 1053 balcony = balconyList[0];
1036 balcony_start_X = converMMtoPX(balcony[2][0]); 1054 balcony_start_X = converMMtoPX(balcony[2][0]);
1037 balcony_start_Y = converMMtoPX(balcony[2][1]); 1055 balcony_start_Y = converMMtoPX(balcony[2][1]);
1038 balcony_width_X = converMMtoPX(balcony[2][2]); 1056 balcony_width_X = converMMtoPX(balcony[2][2]);
1039 balcony_width_Y = converMMtoPX(balcony[2][3]); 1057 balcony_width_Y = converMMtoPX(balcony[2][3]);
1040 1058
1041 } 1059 }
1042 //var materialWoodW = {}; 1060 //var materialWoodW = {};
1043 var material = { 1061 var material = {
1044 'tex': wallTexture, 1062 'tex': wallTexture,
1045 }; 1063 };
1046 // main handrail 1064 // main handrail
1047 var mainHanrail = JSON.parse(JSON.stringify(_3dxy)); 1065 var mainHanrail = JSON.parse(JSON.stringify(_3dxy));
1048 mainHanrail.height_endpoint = converMMtoPX(800); 1066 mainHanrail.height_endpoint = converMMtoPX(800);
1049 mainHanrail.height_startpoint = converMMtoPX(700); 1067 mainHanrail.height_startpoint = converMMtoPX(700);
1050 var woodHandrail = drawObj(scene, mainHanrail, _3dobject, material); 1068 var woodHandrail = drawObj(scene, mainHanrail, _3dobject, material);
1051 handrailObj.push(woodHandrail); 1069 handrailObj.push(woodHandrail);
1052 1070
1053 var subHanrail1 = JSON.parse(JSON.stringify(_3dxy)); 1071 var subHanrail1 = JSON.parse(JSON.stringify(_3dxy));
1054 subHanrail1.height_endpoint = converMMtoPX(650); 1072 subHanrail1.height_endpoint = converMMtoPX(650);
1055 subHanrail1.height_startpoint = converMMtoPX(550); 1073 subHanrail1.height_startpoint = converMMtoPX(550);
1056 var woodSubHanrail1 = drawObj(scene, subHanrail1, _3dobject, material); 1074 var woodSubHanrail1 = drawObj(scene, subHanrail1, _3dobject, material);
1057 handrailObj.push(woodSubHanrail1); 1075 handrailObj.push(woodSubHanrail1);
1058 1076
1059 var subHanrail2 = JSON.parse(JSON.stringify(_3dxy)); 1077 var subHanrail2 = JSON.parse(JSON.stringify(_3dxy));
1060 subHanrail2.height_endpoint = converMMtoPX(250); 1078 subHanrail2.height_endpoint = converMMtoPX(250);
1061 subHanrail2.height_startpoint = converMMtoPX(150); 1079 subHanrail2.height_startpoint = converMMtoPX(150);
1062 var woodSubHanrail2 = drawObj(scene, subHanrail2, _3dobject, material); 1080 var woodSubHanrail2 = drawObj(scene, subHanrail2, _3dobject, material);
1063 handrailObj.push(woodSubHanrail2); 1081 handrailObj.push(woodSubHanrail2);
1064 // Horizontal 1082 // Horizontal
1065 if (mainHanrail.width_X > mainHanrail.width_Y) { 1083 if (mainHanrail.width_X > mainHanrail.width_Y) {
1066 //If start of bacony than dont need to draw big Vhanrail 1084 //If start of bacony than dont need to draw big Vhanrail
1067 // draw big subVhanrail (width =100mm) at begin and end of subVhanrail 1085 // draw big subVhanrail (width =100mm) at begin and end of subVhanrail
1068 if(Math.abs((mainHanrail.start_X - balcony_start_X)) > converMMtoPX(50)) 1086 if(Math.abs((mainHanrail.start_X - balcony_start_X)) > converMMtoPX(50))
1069 { 1087 {
1070 var bigVHanrail = JSON.parse(JSON.stringify(_3dxy)); 1088 var bigVHanrail = JSON.parse(JSON.stringify(_3dxy));
1071 bigVHanrail.height_endpoint = converMMtoPX(1000); 1089 bigVHanrail.height_endpoint = converMMtoPX(1000);
1072 bigVHanrail.height_startpoint = converMMtoPX(0); 1090 bigVHanrail.height_startpoint = converMMtoPX(0);
1073 bigVHanrail.start_X = mainHanrail.start_X; 1091 bigVHanrail.start_X = mainHanrail.start_X;
1074 bigVHanrail.width_X = converMMtoPX(100); 1092 bigVHanrail.width_X = converMMtoPX(100);
1075 1093
1076 var woodbigVHanrail = drawObj(scene, bigVHanrail, _3dobject, material); 1094 var woodbigVHanrail = drawObj(scene, bigVHanrail, _3dobject, material);
1077 handrailObj.push(woodbigVHanrail); 1095 handrailObj.push(woodbigVHanrail);
1078 } 1096 }
1079 // Draw at end 1097 // Draw at end
1080 // if end of handrail is end of balcony than dont need to draw end handrail 1098 // if end of handrail is end of balcony than dont need to draw end handrail
1081 if( Math.abs(((mainHanrail.start_X + mainHanrail.width_X) - (balcony_start_X + balcony_width_X))) > converMMtoPX(50)) 1099 if( Math.abs(((mainHanrail.start_X + mainHanrail.width_X) - (balcony_start_X + balcony_width_X))) > converMMtoPX(50))
1082 { 1100 {
1083 var bigVHanrailEnd = JSON.parse(JSON.stringify(_3dxy)); 1101 var bigVHanrailEnd = JSON.parse(JSON.stringify(_3dxy));
1084 bigVHanrailEnd.height_endpoint = converMMtoPX(1000); 1102 bigVHanrailEnd.height_endpoint = converMMtoPX(1000);
1085 bigVHanrailEnd.height_startpoint = converMMtoPX(0); 1103 bigVHanrailEnd.height_startpoint = converMMtoPX(0);
1086 bigVHanrailEnd.start_X = mainHanrail.start_X + mainHanrail.width_X - converMMtoPX(100); 1104 bigVHanrailEnd.start_X = mainHanrail.start_X + mainHanrail.width_X - converMMtoPX(100);
1087 bigVHanrailEnd.width_X = converMMtoPX(100); 1105 bigVHanrailEnd.width_X = converMMtoPX(100);
1088 1106
1089 var woodbigVHanrailEnd = drawObj(scene, bigVHanrailEnd, _3dobject, material); 1107 var woodbigVHanrailEnd = drawObj(scene, bigVHanrailEnd, _3dobject, material);
1090 handrailObj.push(woodbigVHanrailEnd); 1108 handrailObj.push(woodbigVHanrailEnd);
1091 } 1109 }
1092 //Update mainHanrail widthX 1110 //Update mainHanrail widthX
1093 mainHanrail.start_X = mainHanrail.start_X + converMMtoPX(50); 1111 mainHanrail.start_X = mainHanrail.start_X + converMMtoPX(50);
1094 mainHanrail.width_X = mainHanrail.width_X - converMMtoPX(200); 1112 mainHanrail.width_X = mainHanrail.width_X - converMMtoPX(200);
1095 1113
1096 for (var k = 1; k < mainHanrail.width_X / converMMtoPX(150); k++) { 1114 for (var k = 1; k < mainHanrail.width_X / converMMtoPX(150); k++) {
1097 var subVHanrail = JSON.parse(JSON.stringify(_3dxy)); 1115 var subVHanrail = JSON.parse(JSON.stringify(_3dxy));
1098 subVHanrail.height_endpoint = converMMtoPX(250); 1116 subVHanrail.height_endpoint = converMMtoPX(250);
1099 subVHanrail.height_startpoint = converMMtoPX(550); 1117 subVHanrail.height_startpoint = converMMtoPX(550);
1100 subVHanrail.start_X = mainHanrail.start_X + converMMtoPX(k * 150 - 25); 1118 subVHanrail.start_X = mainHanrail.start_X + converMMtoPX(k * 150 - 25);
1101 //subVHanrail.start_Y = mainHanrail.start_Y + converMMtoPX( k * 150 - 25 ); 1119 //subVHanrail.start_Y = mainHanrail.start_Y + converMMtoPX( k * 150 - 25 );
1102 1120
1103 subVHanrail.width_X = converMMtoPX(50); 1121 subVHanrail.width_X = converMMtoPX(50);
1104 //subVHanrail.width_Y = converMMtoPX( 50 ); 1122 //subVHanrail.width_Y = converMMtoPX( 50 );
1105 1123
1106 var woodSubVHanrail = drawObj(scene, subVHanrail, _3dobject, material); 1124 var woodSubVHanrail = drawObj(scene, subVHanrail, _3dobject, material);
1107 handrailObj.push(woodSubVHanrail); 1125 handrailObj.push(woodSubVHanrail);
1108 1126
1109 } 1127 }
1110 1128
1111 } 1129 }
1112 else { 1130 else {
1113 //If start of bacony than dont need to draw big Vhanrail 1131 //If start of bacony than dont need to draw big Vhanrail
1114 //draw big subVhanrail (width =100mm) at begin and end of subVhanrail 1132 //draw big subVhanrail (width =100mm) at begin and end of subVhanrail
1115 if(Math.abs((mainHanrail.start_Y - balcony_start_Y)) > converMMtoPX(50)) 1133 if(Math.abs((mainHanrail.start_Y - balcony_start_Y)) > converMMtoPX(50))
1116 { 1134 {
1117 var bigVHanrail = JSON.parse(JSON.stringify(_3dxy)); 1135 var bigVHanrail = JSON.parse(JSON.stringify(_3dxy));
1118 bigVHanrail.height_endpoint = converMMtoPX(1000); 1136 bigVHanrail.height_endpoint = converMMtoPX(1000);
1119 bigVHanrail.height_startpoint = converMMtoPX(0); 1137 bigVHanrail.height_startpoint = converMMtoPX(0);
1120 bigVHanrail.start_Y = mainHanrail.start_Y; 1138 bigVHanrail.start_Y = mainHanrail.start_Y;
1121 bigVHanrail.width_Y = converMMtoPX(100); 1139 bigVHanrail.width_Y = converMMtoPX(100);
1122 1140
1123 var woodbigVHanrail = drawObj(scene, bigVHanrail, _3dobject, material); 1141 var woodbigVHanrail = drawObj(scene, bigVHanrail, _3dobject, material);
1124 handrailObj.push(woodbigVHanrail); 1142 handrailObj.push(woodbigVHanrail);
1125 } 1143 }
1126 // Draw at end 1144 // Draw at end
1127 // if end of handrail is end of balcony than dont need to draw end handrail 1145 // if end of handrail is end of balcony than dont need to draw end handrail
1128 if( Math.abs(((mainHanrail.start_Y + mainHanrail.width_Y) - (balcony_start_Y + balcony_width_Y))) > converMMtoPX(50)) 1146 if( Math.abs(((mainHanrail.start_Y + mainHanrail.width_Y) - (balcony_start_Y + balcony_width_Y))) > converMMtoPX(50))
1129 { 1147 {
1130 var bigVHanrailEnd = JSON.parse(JSON.stringify(_3dxy)); 1148 var bigVHanrailEnd = JSON.parse(JSON.stringify(_3dxy));
1131 bigVHanrailEnd.height_endpoint = converMMtoPX(1000); 1149 bigVHanrailEnd.height_endpoint = converMMtoPX(1000);
1132 bigVHanrailEnd.height_startpoint = converMMtoPX(0); 1150 bigVHanrailEnd.height_startpoint = converMMtoPX(0);
1133 bigVHanrailEnd.start_Y = mainHanrail.start_Y + mainHanrail.width_Y - converMMtoPX(100); 1151 bigVHanrailEnd.start_Y = mainHanrail.start_Y + mainHanrail.width_Y - converMMtoPX(100);
1134 bigVHanrailEnd.width_Y = converMMtoPX(100); 1152 bigVHanrailEnd.width_Y = converMMtoPX(100);
1135 1153
1136 var woodbigVHanrailEnd = drawObj(scene, bigVHanrailEnd, _3dobject, material); 1154 var woodbigVHanrailEnd = drawObj(scene, bigVHanrailEnd, _3dobject, material);
1137 handrailObj.push(woodbigVHanrailEnd); 1155 handrailObj.push(woodbigVHanrailEnd);
1138 } 1156 }
1139 //Update mainHanrail widthX 1157 //Update mainHanrail widthX
1140 mainHanrail.start_Y = mainHanrail.start_Y + converMMtoPX(50); 1158 mainHanrail.start_Y = mainHanrail.start_Y + converMMtoPX(50);
1141 mainHanrail.width_Y = mainHanrail.width_Y - converMMtoPX(200); 1159 mainHanrail.width_Y = mainHanrail.width_Y - converMMtoPX(200);
1142 1160
1143 1161
1144 1162
1145 for (var k = 1; k < mainHanrail.width_Y / converMMtoPX(150); k++) { 1163 for (var k = 1; k < mainHanrail.width_Y / converMMtoPX(150); k++) {
1146 var subVHanrail = JSON.parse(JSON.stringify(_3dxy)); 1164 var subVHanrail = JSON.parse(JSON.stringify(_3dxy));
1147 subVHanrail.height_endpoint = converMMtoPX(250); 1165 subVHanrail.height_endpoint = converMMtoPX(250);
1148 subVHanrail.height_startpoint = converMMtoPX(550); 1166 subVHanrail.height_startpoint = converMMtoPX(550);
1149 //subVHanrail.start_X = mainHanrail.start_X + converMMtoPX( k * 150 - 25 ); 1167 //subVHanrail.start_X = mainHanrail.start_X + converMMtoPX( k * 150 - 25 );
1150 subVHanrail.start_Y = mainHanrail.start_Y + converMMtoPX(k * 150 - 25); 1168 subVHanrail.start_Y = mainHanrail.start_Y + converMMtoPX(k * 150 - 25);
1151 1169
1152 //subVHanrail.width_X = converMMtoPX( 50 ); 1170 //subVHanrail.width_X = converMMtoPX( 50 );
1153 subVHanrail.width_Y = converMMtoPX(50); 1171 subVHanrail.width_Y = converMMtoPX(50);
1154 1172
1155 var woodSubVHanrail = drawObj(scene, subVHanrail, _3dobject, material); 1173 var woodSubVHanrail = drawObj(scene, subVHanrail, _3dobject, material);
1156 handrailObj.push(woodSubVHanrail); 1174 handrailObj.push(woodSubVHanrail);
1157 1175
1158 } 1176 }
1159 1177
1160 } 1178 }
1161 1179
1162 } 1180 }
1163 1181
1164 // MR 1340 - END 1182 // MR 1340 - END
1165 //Draw stepper 1183 //Draw stepper
1166 function drawStepper(scene, _3dxy, _3dobject) { 1184 function drawStepper(scene, _3dxy, _3dobject) {
1167 1185
1168 var material = { 1186 var material = {
1169 'tex': wallTexture, 1187 'tex': wallTexture,
1170 }; 1188 };
1171 1189
1172 if(_3dxy.width_X > _3dxy.width_Y) 1190 if(_3dxy.width_X > _3dxy.width_Y)
1173 { 1191 {
1174 var ALIGN_LONG = (converMMtoPX(1200) - _3dxy.width_X)/2; 1192 var ALIGN_LONG = (converMMtoPX(1200) - _3dxy.width_X)/2;
1175 } 1193 }
1176 else 1194 else
1177 { 1195 {
1178 var ALIGN_LONG = (converMMtoPX(1200) - _3dxy.width_Y)/2; 1196 var ALIGN_LONG = (converMMtoPX(1200) - _3dxy.width_Y)/2;
1179 } 1197 }
1180 1198
1181 BODY_H_LONG = converMMtoPX(1200); 1199 BODY_H_LONG = converMMtoPX(1200);
1182 BODY_V_LONG = converMMtoPX(165); 1200 BODY_V_LONG = converMMtoPX(165);
1183 BODY_HEIGHT = converMMtoPX(50); 1201 BODY_HEIGHT = converMMtoPX(50);
1184 BEGIN_STEPPER_TO_LEG = converMMtoPX(100); 1202 BEGIN_STEPPER_TO_LEG = converMMtoPX(100);
1185 //LEG_H_LONG = BODY_V_LONG; 1203 //LEG_H_LONG = BODY_V_LONG;
1186 //LEG_V_LONG = BODY_V_LONG; 1204 //LEG_V_LONG = BODY_V_LONG;
1187 LEG_HEIGHT_START = converMMtoPX(-180); 1205 LEG_HEIGHT_START = converMMtoPX(-180);
1188 LEG_HEIGHT_END = converMMtoPX(-100); 1206 LEG_HEIGHT_END = converMMtoPX(-100);
1189 1207
1190 var floor_start_X; 1208 var floor_start_X;
1191 var floor_start_Y; 1209 var floor_start_Y;
1192 1210
1193 var floorList = getArray3dCadByType(TYPE_FLOOR); 1211 var floorList = getArray3dCadByType(TYPE_FLOOR);
1194 if (floorList.length != 0) { 1212 if (floorList.length != 0) {
1195 floor = floorList[0]; 1213 floor = floorList[0];
1196 floor_start_X = converMMtoPX(floor[2][0]); 1214 floor_start_X = converMMtoPX(floor[2][0]);
1197 floor_start_Y = converMMtoPX(floor[2][1]); 1215 floor_start_Y = converMMtoPX(floor[2][1]);
1198 floor_width_X = converMMtoPX(floor[2][2]); 1216 floor_width_X = converMMtoPX(floor[2][2]);
1199 floor_width_Y = converMMtoPX(floor[2][3]); 1217 floor_width_Y = converMMtoPX(floor[2][3]);
1200 } 1218 }
1201 1219
1202 var balconyList = getArray3dCadByType(TYPE_BALCONY); 1220 var balconyList = getArray3dCadByType(TYPE_BALCONY);
1203 if (balconyList.length != 0) { 1221 if (balconyList.length != 0) {
1204 balcony = balconyList[0]; 1222 balcony = balconyList[0];
1205 balcony_start_X = converMMtoPX(balcony[2][0]); 1223 balcony_start_X = converMMtoPX(balcony[2][0]);
1206 balcony_start_Y = converMMtoPX(balcony[2][1]); 1224 balcony_start_Y = converMMtoPX(balcony[2][1]);
1207 balcony_width_X = converMMtoPX(balcony[2][2]); 1225 balcony_width_X = converMMtoPX(balcony[2][2]);
1208 balcony_width_Y = converMMtoPX(balcony[2][3]); 1226 balcony_width_Y = converMMtoPX(balcony[2][3]);
1209 } 1227 }
1210 // Draw body 1228 // Draw body
1211 var _body3dxy = JSON.parse(JSON.stringify(_3dxy)); 1229 var _body3dxy = JSON.parse(JSON.stringify(_3dxy));
1212 if(_body3dxy.width_X > _body3dxy.width_Y) 1230 if(_body3dxy.width_X > _body3dxy.width_Y)
1213 { 1231 {
1214 BODY_V_LONG = BODY_H_LONG * _body3dxy.width_Y/_body3dxy.width_X; 1232 BODY_V_LONG = BODY_H_LONG * _body3dxy.width_Y/_body3dxy.width_X;
1215 } 1233 }
1216 else 1234 else
1217 { 1235 {
1218 BODY_V_LONG = BODY_H_LONG * _body3dxy.width_X/_body3dxy.width_Y; 1236 BODY_V_LONG = BODY_H_LONG * _body3dxy.width_X/_body3dxy.width_Y;
1219 } 1237 }
1220 1238
1221 // If horizontal step 1239 // If horizontal step
1222 if(_body3dxy.width_X > _body3dxy.width_Y) 1240 if(_body3dxy.width_X > _body3dxy.width_Y)
1223 { 1241 {
1224 _body3dxy.start_X =_body3dxy.start_X - ALIGN_LONG; 1242 _body3dxy.start_X =_body3dxy.start_X - ALIGN_LONG;
1225 // Check if steper is top of floor 1243 // Check if steper is top of floor
1226 if(_body3dxy.start_Y < floor_start_Y) 1244 if(_body3dxy.start_Y < floor_start_Y)
1227 { 1245 {
1228 _body3dxy.start_Y = _body3dxy.start_Y + _body3dxy.width_Y/2 - BODY_V_LONG - converMMtoPX(50); 1246 _body3dxy.start_Y = _body3dxy.start_Y + _body3dxy.width_Y/2 - BODY_V_LONG - converMMtoPX(50);
1229 } 1247 }
1230 else 1248 else
1231 { 1249 {
1232 _body3dxy.start_Y = _body3dxy.start_Y - _body3dxy.width_Y/2 + converMMtoPX(50); 1250 _body3dxy.start_Y = _body3dxy.start_Y - _body3dxy.width_Y/2 + converMMtoPX(50);
1233 } 1251 }
1234 1252
1235 _body3dxy.width_X = BODY_H_LONG; 1253 _body3dxy.width_X = BODY_H_LONG;
1236 _body3dxy.width_Y = BODY_V_LONG; 1254 _body3dxy.width_Y = BODY_V_LONG;
1237 1255
1238 } 1256 }
1239 else 1257 else
1240 { 1258 {
1241 //if step is left of balcony or floor 1259 //if step is left of balcony or floor
1242 if(_body3dxy.start_X < floor_start_X) 1260 if(_body3dxy.start_X < floor_start_X)
1243 { 1261 {
1244 _body3dxy.start_X = _body3dxy.start_X + _body3dxy.width_X/2 - BODY_V_LONG - converMMtoPX(50); 1262 _body3dxy.start_X = _body3dxy.start_X + _body3dxy.width_X/2 - BODY_V_LONG - converMMtoPX(50);
1245 } 1263 }
1246 else 1264 else
1247 { 1265 {
1248 _body3dxy.start_X = _body3dxy.start_X - _body3dxy.width_X/2 + converMMtoPX(50); 1266 _body3dxy.start_X = _body3dxy.start_X - _body3dxy.width_X/2 + converMMtoPX(50);
1249 } 1267 }
1250 1268
1251 _body3dxy.start_Y = _body3dxy.start_Y - ALIGN_LONG; 1269 _body3dxy.start_Y = _body3dxy.start_Y - ALIGN_LONG;
1252 1270
1253 _body3dxy.width_X = BODY_V_LONG; 1271 _body3dxy.width_X = BODY_V_LONG;
1254 _body3dxy.width_Y = BODY_H_LONG; 1272 _body3dxy.width_Y = BODY_H_LONG;
1255 } 1273 }
1256 1274
1257 _body3dxy.height_startpoint = LEG_HEIGHT_END; 1275 _body3dxy.height_startpoint = LEG_HEIGHT_END;
1258 _body3dxy.height_endpoint = LEG_HEIGHT_END + BODY_HEIGHT; 1276 _body3dxy.height_endpoint = LEG_HEIGHT_END + BODY_HEIGHT;
1259 var body = drawObj(scene, _body3dxy, _3dobject, material); 1277 var body = drawObj(scene, _body3dxy, _3dobject, material);
1260 stepperObj.push(body) 1278 stepperObj.push(body)
1261 1279
1262 1280
1263 // Draw left leg 1281 // Draw left leg
1264 var _left3dxy = JSON.parse(JSON.stringify(_3dxy)); 1282 var _left3dxy = JSON.parse(JSON.stringify(_3dxy));
1265 1283
1266 // If horizontal stepper 1284 // If horizontal stepper
1267 if (_left3dxy.width_X > _left3dxy.width_Y) { 1285 if (_left3dxy.width_X > _left3dxy.width_Y) {
1268 _left3dxy.start_X = _body3dxy.start_X + BEGIN_STEPPER_TO_LEG; 1286 _left3dxy.start_X = _body3dxy.start_X + BEGIN_STEPPER_TO_LEG;
1269 _left3dxy.start_Y = _body3dxy.start_Y 1287 _left3dxy.start_Y = _body3dxy.start_Y
1270 _left3dxy.width_X = BODY_V_LONG; 1288 _left3dxy.width_X = BODY_V_LONG;
1271 _left3dxy.width_Y = BODY_V_LONG; 1289 _left3dxy.width_Y = BODY_V_LONG;
1272 1290
1273 } else { 1291 } else {
1274 _left3dxy.start_X = _body3dxy.start_X; 1292 _left3dxy.start_X = _body3dxy.start_X;
1275 _left3dxy.start_Y = _body3dxy.start_Y + BEGIN_STEPPER_TO_LEG; 1293 _left3dxy.start_Y = _body3dxy.start_Y + BEGIN_STEPPER_TO_LEG;
1276 _left3dxy.width_X = BODY_V_LONG; 1294 _left3dxy.width_X = BODY_V_LONG;
1277 _left3dxy.width_Y = BODY_V_LONG; 1295 _left3dxy.width_Y = BODY_V_LONG;
1278 } 1296 }
1279 1297
1280 _left3dxy.height_startpoint = LEG_HEIGHT_START; 1298 _left3dxy.height_startpoint = LEG_HEIGHT_START;
1281 _left3dxy.height_endpoint = LEG_HEIGHT_END; 1299 _left3dxy.height_endpoint = LEG_HEIGHT_END;
1282 var leftLeg = drawObj(scene, _left3dxy, _3dobject, material); 1300 var leftLeg = drawObj(scene, _left3dxy, _3dobject, material);
1283 stepperObj.push(leftLeg) 1301 stepperObj.push(leftLeg)
1284 1302
1285 1303
1286 //Draw right leg 1304 //Draw right leg
1287 var _right3dxy = JSON.parse(JSON.stringify(_3dxy)); 1305 var _right3dxy = JSON.parse(JSON.stringify(_3dxy));
1288 // If horizontal stepper 1306 // If horizontal stepper
1289 if (_right3dxy.width_X > _right3dxy.width_Y) { 1307 if (_right3dxy.width_X > _right3dxy.width_Y) {
1290 _right3dxy.start_X = _body3dxy.start_X + (BODY_H_LONG - BEGIN_STEPPER_TO_LEG - BODY_V_LONG); 1308 _right3dxy.start_X = _body3dxy.start_X + (BODY_H_LONG - BEGIN_STEPPER_TO_LEG - BODY_V_LONG);
1291 _right3dxy.start_Y = _body3dxy.start_Y; 1309 _right3dxy.start_Y = _body3dxy.start_Y;
1292 _right3dxy.width_X = BODY_V_LONG; 1310 _right3dxy.width_X = BODY_V_LONG;
1293 _right3dxy.width_Y = BODY_V_LONG; 1311 _right3dxy.width_Y = BODY_V_LONG;
1294 } else { 1312 } else {
1295 _right3dxy.start_X = _body3dxy.start_X; 1313 _right3dxy.start_X = _body3dxy.start_X;
1296 _right3dxy.start_Y = _body3dxy.start_Y + (BODY_H_LONG - BEGIN_STEPPER_TO_LEG - BODY_V_LONG); 1314 _right3dxy.start_Y = _body3dxy.start_Y + (BODY_H_LONG - BEGIN_STEPPER_TO_LEG - BODY_V_LONG);
1297 _right3dxy.width_X = BODY_V_LONG; 1315 _right3dxy.width_X = BODY_V_LONG;
1298 _right3dxy.width_Y = BODY_V_LONG; 1316 _right3dxy.width_Y = BODY_V_LONG;
1299 } 1317 }
1300 _right3dxy.height_startpoint = LEG_HEIGHT_START; 1318 _right3dxy.height_startpoint = LEG_HEIGHT_START;
1301 _right3dxy.height_endpoint = LEG_HEIGHT_END; 1319 _right3dxy.height_endpoint = LEG_HEIGHT_END;
1302 var rightLeg = drawObj(scene, _right3dxy, _3dobject, material); 1320 var rightLeg = drawObj(scene, _right3dxy, _3dobject, material);
1303 stepperObj.push(rightLeg); 1321 stepperObj.push(rightLeg);
1304 1322
1305 } 1323 }
1306 1324
1307 // Draw Floor 3D 1325 // Draw Floor 3D
1308 function drawFloor3D(scene, _3dxy, _3dobject) { 1326 function drawFloor3D(scene, _3dxy, _3dobject) {
1309 _3dxy.height_endpoint = floor3D.height_endpoint; 1327 _3dxy.height_endpoint = floor3D.height_endpoint;
1310 _3dxy.height_startpoint = floor3D.height_startpoint; 1328 _3dxy.height_startpoint = floor3D.height_startpoint;
1311 1329
1312 1330
1313 var cubeMaterialArray = []; 1331 var cubeMaterialArray = [];
1314 1332
1315 cubeMaterialArray.push(new THREE.MeshBasicMaterial({ 1333 cubeMaterialArray.push(new THREE.MeshBasicMaterial({
1316 map: wallTexture, 1334 map: wallTexture,
1317 side: THREE.DoubleSide 1335 side: THREE.DoubleSide
1318 })); 1336 }));
1319 cubeMaterialArray.push(new THREE.MeshBasicMaterial({ 1337 cubeMaterialArray.push(new THREE.MeshBasicMaterial({
1320 map: wallTexture, 1338 map: wallTexture,
1321 side: THREE.DoubleSide 1339 side: THREE.DoubleSide
1322 })); 1340 }));
1323 cubeMaterialArray.push(new THREE.MeshBasicMaterial({ 1341 cubeMaterialArray.push(new THREE.MeshBasicMaterial({
1324 map: defaultTextute, 1342 map: defaultTextute,
1325 side: THREE.DoubleSide 1343 side: THREE.DoubleSide
1326 })); 1344 }));
1327 cubeMaterialArray.push(new THREE.MeshBasicMaterial({ 1345 cubeMaterialArray.push(new THREE.MeshBasicMaterial({
1328 map: wallTexture, 1346 map: wallTexture,
1329 side: THREE.DoubleSide 1347 side: THREE.DoubleSide
1330 })); 1348 }));
1331 1349
1332 cubeMaterialArray.push(new THREE.MeshBasicMaterial({ 1350 cubeMaterialArray.push(new THREE.MeshBasicMaterial({
1333 map: wallTexture, 1351 map: wallTexture,
1334 side: THREE.DoubleSide 1352 side: THREE.DoubleSide
1335 })); 1353 }));
1336 1354
1337 cubeMaterialArray.push(new THREE.MeshBasicMaterial({ 1355 cubeMaterialArray.push(new THREE.MeshBasicMaterial({
1338 map: wallTexture, 1356 map: wallTexture,
1339 side: THREE.DoubleSide 1357 side: THREE.DoubleSide
1340 })); 1358 }));
1341 1359
1342 var floor = drawObjDiffTexture(scene, _3dxy, _3dobject, cubeMaterialArray); 1360 var floor = drawObjDiffTexture(scene, _3dxy, _3dobject, cubeMaterialArray);
1343 floorObj.add(floor); 1361 floorObj.add(floor);
1344 } 1362 }
1345 // Draw Door 1363 // Draw Door
1346 function drawDoor(scene, _3dxy, _3dobject) { 1364 function drawDoor(scene, _3dxy, _3dobject) {
1347 _3dxy.height_endpoint = door3D.height_endpoint + floor3D.height_endpoint; 1365 _3dxy.height_endpoint = door3D.height_endpoint + floor3D.height_endpoint;
1348 _3dxy.height_startpoint = door3D.height_startpoint + floor3D.height_endpoint; 1366 _3dxy.height_startpoint = door3D.height_startpoint + floor3D.height_endpoint;
1349 var sizePillar = 91 / 2; 1367 var sizePillar = 91 / 2;
1350 if (_3dxy.width_X > _3dxy.width_Y) { 1368 if (_3dxy.width_X > _3dxy.width_Y) {
1351 _3dxy.start_X = _3dxy.start_X;// + converMMtoPX(sizePillar); 1369 _3dxy.start_X = _3dxy.start_X;// + converMMtoPX(sizePillar);
1352 _3dxy.width_X = _3dxy.width_X - converMMtoPX(sizePillar * 2); 1370 _3dxy.width_X = _3dxy.width_X - converMMtoPX(sizePillar * 2);
1353 _3dxy.start_Y = _3dxy.start_Y - converMMtoPX(10); 1371 _3dxy.start_Y = _3dxy.start_Y - converMMtoPX(10);
1354 } else { 1372 } else {
1355 _3dxy.start_Y = _3dxy.start_Y;// + converMMtoPX(sizePillar); 1373 _3dxy.start_Y = _3dxy.start_Y;// + converMMtoPX(sizePillar);
1356 _3dxy.width_Y = _3dxy.width_Y - converMMtoPX(sizePillar * 2); 1374 _3dxy.width_Y = _3dxy.width_Y - converMMtoPX(sizePillar * 2);
1357 _3dxy.start_X = _3dxy.start_X - converMMtoPX(10); 1375 _3dxy.start_X = _3dxy.start_X - converMMtoPX(10);
1358 } 1376 }
1359 // if (_3dobject[0] == '1wingDoor') { 1377 // if (_3dobject[0] == '1wingDoor') {
1360 // var material = { 1378 // var material = {
1361 // 'tex': doorTexute, 1379 // 'tex': doorTexute,
1362 // 'transparent': false, 1380 // 'transparent': false,
1363 // 'opacity': 0.1 1381 // 'opacity': 0.1
1364 // }; 1382 // };
1365 // } 1383 // }
1366 // if (_3dobject[0] == '2wingDoor') { 1384 // if (_3dobject[0] == '2wingDoor') {
1367 // var material = { 1385 // var material = {
1368 // 'tex': door2wTexute, 1386 // 'tex': door2wTexute,
1369 // 'transparent': false, 1387 // 'transparent': false,
1370 // 'opacity': 0.1 1388 // 'opacity': 0.1
1371 // }; 1389 // };
1372 // } 1390 // }
1373 if (!windowTexture) { 1391 if (!windowTexture) {
1374 windowTexture = new loader.load('images/windowTex.jpg'); 1392 windowTexture = new loader.load('images/windowTex.jpg');
1375 windowTexture.wrapS = windowTexture.wrapT = THREE.RepeatWrapping; 1393 windowTexture.wrapS = windowTexture.wrapT = THREE.RepeatWrapping;
1376 windowTexture.repeat.set(1, 1); 1394 windowTexture.repeat.set(1, 1);
1377 } 1395 }
1378 if (!wallTexture) { 1396 if (!wallTexture) {
1379 wallTexture = new loader.load('images/kabe.jpg'); 1397 wallTexture = new loader.load('images/kabe.jpg');
1380 wallTexture.wrapT = THREE.RepeatWrapping; 1398 wallTexture.wrapT = THREE.RepeatWrapping;
1381 wallTexture.repeat.set(5, 5); 1399 wallTexture.repeat.set(5, 5);
1382 } 1400 }
1383 var materialBorder = {}; 1401 var materialBorder = {};
1384 var borderDoor = JSON.parse(JSON.stringify(_3dxy)); 1402 var borderDoor = JSON.parse(JSON.stringify(_3dxy));
1385 var bDoor = drawObj(scene, borderDoor, _3dobject, materialBorder); 1403 var bDoor = drawObj(scene, borderDoor, _3dobject, materialBorder);
1386 var doorW = JSON.parse(JSON.stringify(_3dxy)); 1404 var doorW = JSON.parse(JSON.stringify(_3dxy));
1387 if (doorW.width_X < doorW.width_Y) { 1405 if (doorW.width_X < doorW.width_Y) {
1388 doorW.start_Y = doorW.start_Y + converMMtoPX(30); 1406 doorW.start_Y = doorW.start_Y + converMMtoPX(30);
1389 doorW.width_Y = doorW.width_Y - converMMtoPX(60); 1407 doorW.width_Y = doorW.width_Y - converMMtoPX(60);
1390 1408
1391 } else { 1409 } else {
1392 doorW.start_X = doorW.start_X + converMMtoPX(30); 1410 doorW.start_X = doorW.start_X + converMMtoPX(30);
1393 doorW.width_X = doorW.width_X - converMMtoPX(60); 1411 doorW.width_X = doorW.width_X - converMMtoPX(60);
1394 } 1412 }
1395 doorW.height_startpoint = doorW.height_startpoint + converMMtoPX(30); 1413 doorW.height_startpoint = doorW.height_startpoint + converMMtoPX(30);
1396 doorW.height_endpoint = doorW.height_endpoint - converMMtoPX(30); 1414 doorW.height_endpoint = doorW.height_endpoint - converMMtoPX(30);
1397 1415
1398 var materialDoor = {};