Commit 353addd4d73986d68fc84085bb3bef4525f0edc7
1 parent
670b6d6f84
Exists in
RM-1508
Roof
Showing 1 changed file with 47 additions and 22 deletions Inline Diff
js/view3d.js
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 = {}; | 1416 | var materialDoor = {}; |
1399 | var door = drawObj(scene, doorW, _3dobject, materialDoor); | 1417 | var door = drawObj(scene, doorW, _3dobject, materialDoor); |
1400 | //vแบฝ viแปn cแปญa | 1418 | //vแบฝ viแปn cแปญa |
1401 | var materialDoorB = { | 1419 | var materialDoorB = { |
1402 | 'tex': windowTexture, | 1420 | 'tex': windowTexture, |
1403 | 'transparent': false, | 1421 | 'transparent': false, |
1404 | 'opacity': 0.1 | 1422 | 'opacity': 0.1 |
1405 | 1423 | ||
1406 | }; | 1424 | }; |
1407 | var wBorder = 140; | 1425 | var wBorder = 140; |
1408 | var hBoder = 20; | 1426 | var hBoder = 20; |
1409 | var doorBLeft = JSON.parse(JSON.stringify(doorW)); | 1427 | var doorBLeft = JSON.parse(JSON.stringify(doorW)); |
1410 | var doorBRight = JSON.parse(JSON.stringify(doorW)); | 1428 | var doorBRight = JSON.parse(JSON.stringify(doorW)); |
1411 | var doorBTop = JSON.parse(JSON.stringify(doorW)); | 1429 | var doorBTop = JSON.parse(JSON.stringify(doorW)); |
1412 | var doorBBottom = JSON.parse(JSON.stringify(doorW)); | 1430 | var doorBBottom = JSON.parse(JSON.stringify(doorW)); |
1413 | var doorBMid = JSON.parse(JSON.stringify(doorW)); | 1431 | var doorBMid = JSON.parse(JSON.stringify(doorW)); |
1414 | if (doorW.width_X > doorW.width_Y) { | 1432 | if (doorW.width_X > doorW.width_Y) { |
1415 | //border left | 1433 | //border left |
1416 | doorBLeft.start_Y = doorBLeft.start_Y + doorBLeft.width_Y; | 1434 | doorBLeft.start_Y = doorBLeft.start_Y + doorBLeft.width_Y; |
1417 | doorBLeft.width_X = converMMtoPX(wBorder); | 1435 | doorBLeft.width_X = converMMtoPX(wBorder); |
1418 | doorBLeft.width_Y = converMMtoPX(hBoder); | 1436 | doorBLeft.width_Y = converMMtoPX(hBoder); |
1419 | //border Right | 1437 | //border Right |
1420 | doorBRight.start_X = doorBRight.start_X + doorBRight.width_X - converMMtoPX(140); | 1438 | doorBRight.start_X = doorBRight.start_X + doorBRight.width_X - converMMtoPX(140); |
1421 | doorBRight.start_Y = doorBRight.start_Y + doorBRight.width_Y; | 1439 | doorBRight.start_Y = doorBRight.start_Y + doorBRight.width_Y; |
1422 | doorBRight.width_X = converMMtoPX(wBorder); | 1440 | doorBRight.width_X = converMMtoPX(wBorder); |
1423 | doorBRight.width_Y = converMMtoPX(hBoder); | 1441 | doorBRight.width_Y = converMMtoPX(hBoder); |
1424 | //border Top | 1442 | //border Top |
1425 | doorBTop.start_X = doorBTop.start_X + converMMtoPX(wBorder); | 1443 | doorBTop.start_X = doorBTop.start_X + converMMtoPX(wBorder); |
1426 | doorBTop.start_Y = doorBTop.start_Y + doorBTop.width_Y; | 1444 | doorBTop.start_Y = doorBTop.start_Y + doorBTop.width_Y; |
1427 | doorBTop.width_X = doorBTop.width_X - converMMtoPX(wBorder) * 2; | 1445 | doorBTop.width_X = doorBTop.width_X - converMMtoPX(wBorder) * 2; |
1428 | doorBTop.width_Y = converMMtoPX(hBoder); | 1446 | doorBTop.width_Y = converMMtoPX(hBoder); |
1429 | doorBTop.height_startpoint = doorBTop.height_endpoint - converMMtoPX(wBorder); | 1447 | doorBTop.height_startpoint = doorBTop.height_endpoint - converMMtoPX(wBorder); |
1430 | //border Bottom | 1448 | //border Bottom |
1431 | doorBBottom.start_X = doorBBottom.start_X + converMMtoPX(wBorder); | 1449 | doorBBottom.start_X = doorBBottom.start_X + converMMtoPX(wBorder); |
1432 | doorBBottom.start_Y = doorBBottom.start_Y + doorBBottom.width_Y; | 1450 | doorBBottom.start_Y = doorBBottom.start_Y + doorBBottom.width_Y; |
1433 | doorBBottom.width_X = doorBBottom.width_X - converMMtoPX(wBorder) * 2; | 1451 | doorBBottom.width_X = doorBBottom.width_X - converMMtoPX(wBorder) * 2; |
1434 | doorBBottom.width_Y = converMMtoPX(hBoder); | 1452 | doorBBottom.width_Y = converMMtoPX(hBoder); |
1435 | doorBBottom.height_endpoint = doorBBottom.height_startpoint + converMMtoPX(wBorder); | 1453 | doorBBottom.height_endpoint = doorBBottom.height_startpoint + converMMtoPX(wBorder); |
1436 | //border Mid | 1454 | //border Mid |
1437 | doorBMid.start_X = doorBMid.start_X + converMMtoPX(wBorder); | 1455 | doorBMid.start_X = doorBMid.start_X + converMMtoPX(wBorder); |
1438 | doorBMid.start_Y = doorBMid.start_Y + doorBMid.width_Y; | 1456 | doorBMid.start_Y = doorBMid.start_Y + doorBMid.width_Y; |
1439 | doorBMid.width_X = doorBMid.width_X - converMMtoPX(wBorder) * 2; | 1457 | doorBMid.width_X = doorBMid.width_X - converMMtoPX(wBorder) * 2; |
1440 | doorBMid.width_Y = converMMtoPX(hBoder); | 1458 | doorBMid.width_Y = converMMtoPX(hBoder); |
1441 | doorBMid.height_startpoint = (doorW.height_endpoint - doorW.height_startpoint - converMMtoPX(wBorder)) / 2 + floor3D.height_endpoint; | 1459 | doorBMid.height_startpoint = (doorW.height_endpoint - doorW.height_startpoint - converMMtoPX(wBorder)) / 2 + floor3D.height_endpoint; |
1442 | doorBMid.height_endpoint = (doorW.height_endpoint - doorW.height_startpoint + converMMtoPX(wBorder)) / 2 + floor3D.height_endpoint; | 1460 | doorBMid.height_endpoint = (doorW.height_endpoint - doorW.height_startpoint + converMMtoPX(wBorder)) / 2 + floor3D.height_endpoint; |
1443 | } else { | 1461 | } else { |
1444 | //border left | 1462 | //border left |
1445 | doorBLeft.start_X = doorBLeft.start_X + doorBLeft.width_X; | 1463 | doorBLeft.start_X = doorBLeft.start_X + doorBLeft.width_X; |
1446 | doorBLeft.width_Y = converMMtoPX(wBorder); | 1464 | doorBLeft.width_Y = converMMtoPX(wBorder); |
1447 | doorBLeft.width_X = converMMtoPX(hBoder); | 1465 | doorBLeft.width_X = converMMtoPX(hBoder); |
1448 | //border Right | 1466 | //border Right |
1449 | doorBRight.start_Y = doorBRight.start_Y + doorBRight.width_Y - converMMtoPX(wBorder); | 1467 | doorBRight.start_Y = doorBRight.start_Y + doorBRight.width_Y - converMMtoPX(wBorder); |
1450 | doorBRight.start_X = doorBRight.start_X + doorBRight.width_X; | 1468 | doorBRight.start_X = doorBRight.start_X + doorBRight.width_X; |
1451 | doorBRight.width_Y = converMMtoPX(wBorder); | 1469 | doorBRight.width_Y = converMMtoPX(wBorder); |
1452 | doorBRight.width_X = converMMtoPX(hBoder); | 1470 | doorBRight.width_X = converMMtoPX(hBoder); |
1453 | //border Top | 1471 | //border Top |
1454 | doorBTop.start_Y = doorBTop.start_Y + converMMtoPX(wBorder); | 1472 | doorBTop.start_Y = doorBTop.start_Y + converMMtoPX(wBorder); |
1455 | doorBTop.start_X = doorBTop.start_X + doorBTop.width_X; | 1473 | doorBTop.start_X = doorBTop.start_X + doorBTop.width_X; |
1456 | doorBTop.width_Y = doorBTop.width_Y - converMMtoPX(wBorder) * 2; | 1474 | doorBTop.width_Y = doorBTop.width_Y - converMMtoPX(wBorder) * 2; |
1457 | doorBTop.width_X = converMMtoPX(hBoder); | 1475 | doorBTop.width_X = converMMtoPX(hBoder); |
1458 | doorBTop.height_startpoint = doorBTop.height_endpoint - converMMtoPX(wBorder); | 1476 | doorBTop.height_startpoint = doorBTop.height_endpoint - converMMtoPX(wBorder); |
1459 | //border Bottom | 1477 | //border Bottom |
1460 | doorBBottom.start_Y = doorBBottom.start_Y + converMMtoPX(wBorder); | 1478 | doorBBottom.start_Y = doorBBottom.start_Y + converMMtoPX(wBorder); |
1461 | doorBBottom.start_X = doorBBottom.start_X + doorBBottom.width_X; | 1479 | doorBBottom.start_X = doorBBottom.start_X + doorBBottom.width_X; |
1462 | doorBBottom.width_Y = doorBBottom.width_Y - converMMtoPX(wBorder) * 2; | 1480 | doorBBottom.width_Y = doorBBottom.width_Y - converMMtoPX(wBorder) * 2; |
1463 | doorBBottom.width_X = converMMtoPX(hBoder); | 1481 | doorBBottom.width_X = converMMtoPX(hBoder); |
1464 | doorBBottom.height_endpoint = doorBBottom.height_startpoint + converMMtoPX(wBorder); | 1482 | doorBBottom.height_endpoint = doorBBottom.height_startpoint + converMMtoPX(wBorder); |
1465 | //border Mid | 1483 | //border Mid |
1466 | doorBMid.start_Y = doorBMid.start_Y + converMMtoPX(wBorder); | 1484 | doorBMid.start_Y = doorBMid.start_Y + converMMtoPX(wBorder); |
1467 | doorBMid.start_X = doorBMid.start_X + doorBMid.width_X; | 1485 | doorBMid.start_X = doorBMid.start_X + doorBMid.width_X; |
1468 | doorBMid.width_Y = doorBMid.width_Y - converMMtoPX(wBorder) * 2; | 1486 | doorBMid.width_Y = doorBMid.width_Y - converMMtoPX(wBorder) * 2; |
1469 | doorBMid.width_X = converMMtoPX(hBoder); | 1487 | doorBMid.width_X = converMMtoPX(hBoder); |
1470 | doorBMid.height_startpoint = (doorW.height_endpoint - doorW.height_startpoint - converMMtoPX(wBorder)) / 2 + floor3D.height_endpoint; | 1488 | doorBMid.height_startpoint = (doorW.height_endpoint - doorW.height_startpoint - converMMtoPX(wBorder)) / 2 + floor3D.height_endpoint; |
1471 | doorBMid.height_endpoint = (doorW.height_endpoint - doorW.height_startpoint + converMMtoPX(wBorder)) / 2 + floor3D.height_endpoint; | 1489 | doorBMid.height_endpoint = (doorW.height_endpoint - doorW.height_startpoint + converMMtoPX(wBorder)) / 2 + floor3D.height_endpoint; |
1472 | 1490 | ||
1473 | } | 1491 | } |
1474 | var doorBLeft3D = drawObj(scene, doorBLeft, _3dobject, materialDoorB); | 1492 | var doorBLeft3D = drawObj(scene, doorBLeft, _3dobject, materialDoorB); |
1475 | var doorBRight3D = drawObj(scene, doorBRight, _3dobject, materialDoorB); | 1493 | var doorBRight3D = drawObj(scene, doorBRight, _3dobject, materialDoorB); |
1476 | var doorBTop3D = drawObj(scene, doorBTop, _3dobject, materialDoorB); | 1494 | var doorBTop3D = drawObj(scene, doorBTop, _3dobject, materialDoorB); |
1477 | var doorBBottom3D = drawObj(scene, doorBBottom, _3dobject, materialDoorB); | 1495 | var doorBBottom3D = drawObj(scene, doorBBottom, _3dobject, materialDoorB); |
1478 | var doorBMid3D = drawObj(scene, doorBMid, _3dobject, materialDoorB); | 1496 | var doorBMid3D = drawObj(scene, doorBMid, _3dobject, materialDoorB); |
1479 | 1497 | ||
1480 | 1498 | ||
1481 | var doorBLeft_1 = JSON.parse(JSON.stringify(doorBLeft)); | 1499 | var doorBLeft_1 = JSON.parse(JSON.stringify(doorBLeft)); |
1482 | var doorBRight_1 = JSON.parse(JSON.stringify(doorBRight)); | 1500 | var doorBRight_1 = JSON.parse(JSON.stringify(doorBRight)); |
1483 | var doorBTop_1 = JSON.parse(JSON.stringify(doorBTop)); | 1501 | var doorBTop_1 = JSON.parse(JSON.stringify(doorBTop)); |
1484 | var doorBBottom_1 = JSON.parse(JSON.stringify(doorBBottom)); | 1502 | var doorBBottom_1 = JSON.parse(JSON.stringify(doorBBottom)); |
1485 | var doorBMid_1 = JSON.parse(JSON.stringify(doorBMid)); | 1503 | var doorBMid_1 = JSON.parse(JSON.stringify(doorBMid)); |
1486 | if (doorW.width_X > doorW.width_Y) { | 1504 | if (doorW.width_X > doorW.width_Y) { |
1487 | doorBLeft_1.start_Y = doorBLeft_1.start_Y - doorW.width_Y - doorBLeft_1.width_Y; | 1505 | doorBLeft_1.start_Y = doorBLeft_1.start_Y - doorW.width_Y - doorBLeft_1.width_Y; |
1488 | doorBRight_1.start_Y = doorBRight_1.start_Y - doorW.width_Y - doorBRight_1.width_Y; | 1506 | doorBRight_1.start_Y = doorBRight_1.start_Y - doorW.width_Y - doorBRight_1.width_Y; |
1489 | doorBTop_1.start_Y = doorBTop_1.start_Y - doorW.width_Y - doorBTop_1.width_Y; | 1507 | doorBTop_1.start_Y = doorBTop_1.start_Y - doorW.width_Y - doorBTop_1.width_Y; |
1490 | doorBBottom_1.start_Y = doorBBottom_1.start_Y - doorW.width_Y - doorBBottom_1.width_Y; | 1508 | doorBBottom_1.start_Y = doorBBottom_1.start_Y - doorW.width_Y - doorBBottom_1.width_Y; |
1491 | doorBMid_1.start_Y = doorBMid_1.start_Y - doorW.width_Y - doorBMid_1.width_Y; | 1509 | doorBMid_1.start_Y = doorBMid_1.start_Y - doorW.width_Y - doorBMid_1.width_Y; |
1492 | } else { | 1510 | } else { |
1493 | doorBLeft_1.start_X = doorBLeft_1.start_X - doorW.width_X - doorBLeft_1.width_X; | 1511 | doorBLeft_1.start_X = doorBLeft_1.start_X - doorW.width_X - doorBLeft_1.width_X; |
1494 | doorBRight_1.start_X = doorBRight_1.start_X - doorW.width_X - doorBRight_1.width_X; | 1512 | doorBRight_1.start_X = doorBRight_1.start_X - doorW.width_X - doorBRight_1.width_X; |
1495 | doorBTop_1.start_X = doorBTop_1.start_X - doorW.width_X - doorBTop_1.width_X; | 1513 | doorBTop_1.start_X = doorBTop_1.start_X - doorW.width_X - doorBTop_1.width_X; |
1496 | doorBBottom_1.start_X = doorBBottom_1.start_X - doorW.width_X - doorBBottom_1.width_X; | 1514 | doorBBottom_1.start_X = doorBBottom_1.start_X - doorW.width_X - doorBBottom_1.width_X; |
1497 | doorBMid_1.start_X = doorBMid_1.start_X - doorW.width_X - doorBMid_1.width_X; | 1515 | doorBMid_1.start_X = doorBMid_1.start_X - doorW.width_X - doorBMid_1.width_X; |
1498 | } | 1516 | } |
1499 | var doorBLeft3D_1 = drawObj(scene, doorBLeft_1, _3dobject, materialDoorB); | 1517 | var doorBLeft3D_1 = drawObj(scene, doorBLeft_1, _3dobject, materialDoorB); |
1500 | var doorBRight3D_1 = drawObj(scene, doorBRight_1, _3dobject, materialDoorB); | 1518 | var doorBRight3D_1 = drawObj(scene, doorBRight_1, _3dobject, materialDoorB); |
1501 | var doorBTop3D_1 = drawObj(scene, doorBTop_1, _3dobject, materialDoorB); | 1519 | var doorBTop3D_1 = drawObj(scene, doorBTop_1, _3dobject, materialDoorB); |
1502 | var doorBBottom3D_1 = drawObj(scene, doorBBottom_1, _3dobject, materialDoorB); | 1520 | var doorBBottom3D_1 = drawObj(scene, doorBBottom_1, _3dobject, materialDoorB); |
1503 | var doorBMid3D_1 = drawObj(scene, doorBMid_1, _3dobject, materialDoorB); | 1521 | var doorBMid3D_1 = drawObj(scene, doorBMid_1, _3dobject, materialDoorB); |
1504 | 1522 | ||
1505 | 1523 | ||
1506 | scene.add(doorBLeft3D); | 1524 | scene.add(doorBLeft3D); |
1507 | scene.add(doorBRight3D); | 1525 | scene.add(doorBRight3D); |
1508 | scene.add(doorBTop3D); | 1526 | scene.add(doorBTop3D); |
1509 | scene.add(doorBBottom3D); | 1527 | scene.add(doorBBottom3D); |
1510 | scene.add(doorBMid3D); | 1528 | scene.add(doorBMid3D); |
1511 | 1529 | ||
1512 | scene.add(doorBLeft3D_1); | 1530 | scene.add(doorBLeft3D_1); |
1513 | scene.add(doorBRight3D_1); | 1531 | scene.add(doorBRight3D_1); |
1514 | scene.add(doorBTop3D_1); | 1532 | scene.add(doorBTop3D_1); |
1515 | scene.add(doorBBottom3D_1); | 1533 | scene.add(doorBBottom3D_1); |
1516 | scene.add(doorBMid3D_1); | 1534 | scene.add(doorBMid3D_1); |
1517 | //glass Door | 1535 | //glass Door |
1518 | var borderGlass = 50; | 1536 | var borderGlass = 50; |
1519 | var gDoor_3dxy = JSON.parse(JSON.stringify(doorW)); | 1537 | var gDoor_3dxy = JSON.parse(JSON.stringify(doorW)); |
1520 | if (gDoor_3dxy.width_X < gDoor_3dxy.width_Y) { | 1538 | if (gDoor_3dxy.width_X < gDoor_3dxy.width_Y) { |
1521 | gDoor_3dxy.start_Y = doorBLeft.start_Y + doorBLeft.width_Y + converMMtoPX(borderGlass); | 1539 | gDoor_3dxy.start_Y = doorBLeft.start_Y + doorBLeft.width_Y + converMMtoPX(borderGlass); |
1522 | gDoor_3dxy.width_Y = doorBRight.start_Y - (doorBLeft.start_Y + doorBLeft.width_Y) - converMMtoPX(borderGlass) * 2; | 1540 | gDoor_3dxy.width_Y = doorBRight.start_Y - (doorBLeft.start_Y + doorBLeft.width_Y) - converMMtoPX(borderGlass) * 2; |
1523 | } else { | 1541 | } else { |
1524 | gDoor_3dxy.start_X = doorBLeft.start_X + doorBLeft.width_X + converMMtoPX(borderGlass); | 1542 | gDoor_3dxy.start_X = doorBLeft.start_X + doorBLeft.width_X + converMMtoPX(borderGlass); |
1525 | gDoor_3dxy.width_X = doorBRight.start_X - (doorBLeft.start_X + doorBLeft.width_X) - converMMtoPX(borderGlass) * 2; | 1543 | gDoor_3dxy.width_X = doorBRight.start_X - (doorBLeft.start_X + doorBLeft.width_X) - converMMtoPX(borderGlass) * 2; |
1526 | } | 1544 | } |
1527 | gDoor_3dxy.height_endpoint = doorBTop.height_startpoint - converMMtoPX(borderGlass); | 1545 | gDoor_3dxy.height_endpoint = doorBTop.height_startpoint - converMMtoPX(borderGlass); |
1528 | gDoor_3dxy.height_startpoint = doorBMid.height_endpoint + converMMtoPX(borderGlass); | 1546 | gDoor_3dxy.height_startpoint = doorBMid.height_endpoint + converMMtoPX(borderGlass); |
1529 | var materialGlass_door = { | 1547 | var materialGlass_door = { |
1530 | 'tex': glassTexture, | 1548 | 'tex': glassTexture, |
1531 | 'transparent': true, | 1549 | 'transparent': true, |
1532 | 'opacity': 0.5 | 1550 | 'opacity': 0.5 |
1533 | }; | 1551 | }; |
1534 | var glassDoor = drawObj(scene, gDoor_3dxy, _3dobject, materialGlass_door); | 1552 | var glassDoor = drawObj(scene, gDoor_3dxy, _3dobject, materialGlass_door); |
1535 | scene.add(glassDoor); | 1553 | scene.add(glassDoor); |
1536 | // | 1554 | // |
1537 | var doorBSP = new ThreeBSP(door); | 1555 | var doorBSP = new ThreeBSP(door); |
1538 | var boderBSP = new ThreeBSP(bDoor); | 1556 | var boderBSP = new ThreeBSP(bDoor); |
1539 | var glassBSP = new ThreeBSP(glassDoor); | 1557 | var glassBSP = new ThreeBSP(glassDoor); |
1540 | doorBSP = doorBSP.subtract(glassBSP); | 1558 | doorBSP = doorBSP.subtract(glassBSP); |
1541 | boderBSP = boderBSP.subtract(glassBSP); | 1559 | boderBSP = boderBSP.subtract(glassBSP); |
1542 | boderBSP = boderBSP.subtract(doorBSP); | 1560 | boderBSP = boderBSP.subtract(doorBSP); |
1543 | 1561 | ||
1544 | bDoor = boderBSP.toMesh(); | 1562 | bDoor = boderBSP.toMesh(); |
1545 | var bTex = new THREE.MeshBasicMaterial({ | 1563 | var bTex = new THREE.MeshBasicMaterial({ |
1546 | map: windowTexture, | 1564 | map: windowTexture, |
1547 | shading: THREE.FlatShading, | 1565 | shading: THREE.FlatShading, |
1548 | side: THREE.DoubleSide, | 1566 | side: THREE.DoubleSide, |
1549 | }); | 1567 | }); |
1550 | 1568 | ||
1551 | bDoor.material = bTex; | 1569 | bDoor.material = bTex; |
1552 | var doorToMesh = doorBSP.toMesh(); | 1570 | var doorToMesh = doorBSP.toMesh(); |
1553 | var dTex = new THREE.MeshBasicMaterial({ | 1571 | var dTex = new THREE.MeshBasicMaterial({ |
1554 | map: windowTexture, | 1572 | map: windowTexture, |
1555 | shading: THREE.FlatShading, | 1573 | shading: THREE.FlatShading, |
1556 | side: THREE.DoubleSide, | 1574 | side: THREE.DoubleSide, |
1557 | }); | 1575 | }); |
1558 | doorToMesh.material = dTex; | 1576 | doorToMesh.material = dTex; |
1559 | doorObj.push(bDoor); | 1577 | doorObj.push(bDoor); |
1560 | doorObj.push(doorToMesh); | 1578 | doorObj.push(doorToMesh); |
1561 | doorObj.push(glassDoor); | 1579 | doorObj.push(glassDoor); |
1562 | if (!sphereTex) { | 1580 | if (!sphereTex) { |
1563 | sphereTex = new loader.load('images/sphere.png'); | 1581 | sphereTex = new loader.load('images/sphere.png'); |
1564 | sphereTex.wrapS = sphereTex.wrapT = THREE.RepeatWrapping; | 1582 | sphereTex.wrapS = sphereTex.wrapT = THREE.RepeatWrapping; |
1565 | sphereTex.repeat.set(1, 1); | 1583 | sphereTex.repeat.set(1, 1); |
1566 | } | 1584 | } |
1567 | if (_3dobject[0] == '1wingDoorLeft') { | 1585 | if (_3dobject[0] == '1wingDoorLeft') { |
1568 | var sphereGeometry = new THREE.SphereGeometry(converMMtoPX(50), 32, 32); | 1586 | var sphereGeometry = new THREE.SphereGeometry(converMMtoPX(50), 32, 32); |
1569 | var sphereMaterial = new THREE.MeshBasicMaterial({ | 1587 | var sphereMaterial = new THREE.MeshBasicMaterial({ |
1570 | map: sphereTex, | 1588 | map: sphereTex, |
1571 | shading: THREE.FlatShading, | 1589 | shading: THREE.FlatShading, |
1572 | side: THREE.DoubleSide, | 1590 | side: THREE.DoubleSide, |
1573 | }); | 1591 | }); |
1574 | var sphere1 = new THREE.Mesh(sphereGeometry, sphereMaterial); | 1592 | var sphere1 = new THREE.Mesh(sphereGeometry, sphereMaterial); |
1575 | var sphere2 = new THREE.Mesh(sphereGeometry, sphereMaterial); | 1593 | var sphere2 = new THREE.Mesh(sphereGeometry, sphereMaterial); |
1576 | if (_3dxy.width_X > _3dxy.width_Y) { | 1594 | if (_3dxy.width_X > _3dxy.width_Y) { |
1577 | sphere1.position.x = doorBLeft.start_X + (doorBLeft.width_X / 2) - floor_width / 2; | 1595 | sphere1.position.x = doorBLeft.start_X + (doorBLeft.width_X / 2) - floor_width / 2; |
1578 | sphere1.position.z = _3dxy.start_Y + _3dxy.width_Y - floor_height / 2 + converMMtoPX(40 + 10); | 1596 | sphere1.position.z = _3dxy.start_Y + _3dxy.width_Y - floor_height / 2 + converMMtoPX(40 + 10); |
1579 | sphere1.position.y = (_3dxy.height_endpoint - _3dxy.height_startpoint) / 2 + converMMtoPX(300); | 1597 | sphere1.position.y = (_3dxy.height_endpoint - _3dxy.height_startpoint) / 2 + converMMtoPX(300); |
1580 | } else { | 1598 | } else { |
1581 | sphere1.position.z = doorBLeft.start_Y + (doorBLeft.width_Y / 2) - floor_height / 2; | 1599 | sphere1.position.z = doorBLeft.start_Y + (doorBLeft.width_Y / 2) - floor_height / 2; |
1582 | sphere1.position.x = _3dxy.start_X + _3dxy.width_X - floor_width / 2 + converMMtoPX(40 + 10); | 1600 | sphere1.position.x = _3dxy.start_X + _3dxy.width_X - floor_width / 2 + converMMtoPX(40 + 10); |
1583 | sphere1.position.y = (_3dxy.height_endpoint - _3dxy.height_startpoint) / 2 + converMMtoPX(300); | 1601 | sphere1.position.y = (_3dxy.height_endpoint - _3dxy.height_startpoint) / 2 + converMMtoPX(300); |
1584 | } | 1602 | } |
1585 | if (_3dxy.width_X > _3dxy.width_Y) { | 1603 | if (_3dxy.width_X > _3dxy.width_Y) { |
1586 | sphere2.position.x = doorBLeft.start_X + (doorBLeft.width_X / 2) - floor_width / 2; | 1604 | sphere2.position.x = doorBLeft.start_X + (doorBLeft.width_X / 2) - floor_width / 2; |
1587 | sphere2.position.z = _3dxy.start_Y - floor_height / 2 - converMMtoPX(40); | 1605 | sphere2.position.z = _3dxy.start_Y - floor_height / 2 - converMMtoPX(40); |
1588 | sphere2.position.y = (_3dxy.height_endpoint - _3dxy.height_startpoint) / 2 + converMMtoPX(300); | 1606 | sphere2.position.y = (_3dxy.height_endpoint - _3dxy.height_startpoint) / 2 + converMMtoPX(300); |
1589 | } else { | 1607 | } else { |
1590 | sphere2.position.z = doorBLeft.start_Y + (doorBLeft.width_Y / 2) - floor_height / 2; | 1608 | sphere2.position.z = doorBLeft.start_Y + (doorBLeft.width_Y / 2) - floor_height / 2; |
1591 | sphere2.position.x = _3dxy.start_X - floor_width / 2 - converMMtoPX(40); | 1609 | sphere2.position.x = _3dxy.start_X - floor_width / 2 - converMMtoPX(40); |
1592 | sphere2.position.y = (_3dxy.height_endpoint - _3dxy.height_startpoint) / 2 + converMMtoPX(300); | 1610 | sphere2.position.y = (_3dxy.height_endpoint - _3dxy.height_startpoint) / 2 + converMMtoPX(300); |
1593 | } | 1611 | } |
1594 | } | 1612 | } |
1595 | if (_3dobject[0] == '1wingDoorRight') { | 1613 | if (_3dobject[0] == '1wingDoorRight') { |
1596 | var sphereGeometry = new THREE.SphereGeometry(converMMtoPX(50), 32, 32); | 1614 | var sphereGeometry = new THREE.SphereGeometry(converMMtoPX(50), 32, 32); |
1597 | var sphereMaterial = new THREE.MeshBasicMaterial({ | 1615 | var sphereMaterial = new THREE.MeshBasicMaterial({ |
1598 | map: sphereTex, | 1616 | map: sphereTex, |
1599 | shading: THREE.FlatShading, | 1617 | shading: THREE.FlatShading, |
1600 | side: THREE.DoubleSide, | 1618 | side: THREE.DoubleSide, |
1601 | }); | 1619 | }); |
1602 | var sphere1 = new THREE.Mesh(sphereGeometry, sphereMaterial); | 1620 | var sphere1 = new THREE.Mesh(sphereGeometry, sphereMaterial); |
1603 | var sphere2 = new THREE.Mesh(sphereGeometry, sphereMaterial); | 1621 | var sphere2 = new THREE.Mesh(sphereGeometry, sphereMaterial); |
1604 | if (_3dxy.width_X > _3dxy.width_Y) { | 1622 | if (_3dxy.width_X > _3dxy.width_Y) { |
1605 | sphere1.position.x = doorBRight.start_X + (doorBRight.width_X / 2) - floor_width / 2; | 1623 | sphere1.position.x = doorBRight.start_X + (doorBRight.width_X / 2) - floor_width / 2; |
1606 | sphere1.position.z = _3dxy.start_Y + _3dxy.width_Y - floor_height / 2 + converMMtoPX(40 + 10); | 1624 | sphere1.position.z = _3dxy.start_Y + _3dxy.width_Y - floor_height / 2 + converMMtoPX(40 + 10); |
1607 | sphere1.position.y = (_3dxy.height_endpoint - _3dxy.height_startpoint) / 2 + converMMtoPX(300); | 1625 | sphere1.position.y = (_3dxy.height_endpoint - _3dxy.height_startpoint) / 2 + converMMtoPX(300); |
1608 | } else { | 1626 | } else { |
1609 | sphere1.position.z = doorBRight.start_Y + (doorBRight.width_Y / 2) - floor_height / 2; | 1627 | sphere1.position.z = doorBRight.start_Y + (doorBRight.width_Y / 2) - floor_height / 2; |
1610 | sphere1.position.x = _3dxy.start_X + _3dxy.width_X - floor_width / 2 + converMMtoPX(40 + 10); | 1628 | sphere1.position.x = _3dxy.start_X + _3dxy.width_X - floor_width / 2 + converMMtoPX(40 + 10); |
1611 | sphere1.position.y = (_3dxy.height_endpoint - _3dxy.height_startpoint) / 2 + converMMtoPX(300); | 1629 | sphere1.position.y = (_3dxy.height_endpoint - _3dxy.height_startpoint) / 2 + converMMtoPX(300); |
1612 | } | 1630 | } |
1613 | if (_3dxy.width_X > _3dxy.width_Y) { | 1631 | if (_3dxy.width_X > _3dxy.width_Y) { |
1614 | sphere2.position.x = doorBRight.start_X + (doorBRight.width_X / 2) - floor_width / 2; | 1632 | sphere2.position.x = doorBRight.start_X + (doorBRight.width_X / 2) - floor_width / 2; |
1615 | sphere2.position.z = _3dxy.start_Y - floor_height / 2 - converMMtoPX(40); | 1633 | sphere2.position.z = _3dxy.start_Y - floor_height / 2 - converMMtoPX(40); |
1616 | sphere2.position.y = (_3dxy.height_endpoint - _3dxy.height_startpoint) / 2 + converMMtoPX(300); | 1634 | sphere2.position.y = (_3dxy.height_endpoint - _3dxy.height_startpoint) / 2 + converMMtoPX(300); |
1617 | } else { | 1635 | } else { |
1618 | sphere2.position.z = doorBRight.start_Y + (doorBRight.width_Y / 2) - floor_height / 2; | 1636 | sphere2.position.z = doorBRight.start_Y + (doorBRight.width_Y / 2) - floor_height / 2; |
1619 | sphere2.position.x = _3dxy.start_X - floor_width / 2 - converMMtoPX(40); | 1637 | sphere2.position.x = _3dxy.start_X - floor_width / 2 - converMMtoPX(40); |
1620 | sphere2.position.y = (_3dxy.height_endpoint - _3dxy.height_startpoint) / 2 + converMMtoPX(300); | 1638 | sphere2.position.y = (_3dxy.height_endpoint - _3dxy.height_startpoint) / 2 + converMMtoPX(300); |
1621 | } | 1639 | } |
1622 | 1640 | ||
1623 | } | 1641 | } |
1624 | scene.add(sphere1); | 1642 | scene.add(sphere1); |
1625 | scene.add(sphere2); | 1643 | scene.add(sphere2); |
1626 | // scene.add(doorToMesh); | 1644 | // scene.add(doorToMesh); |
1627 | } | 1645 | } |
1628 | // Draw Window | 1646 | // Draw Window |
1629 | function drawWindow(scene, _3dxy, _3dobject) { | 1647 | function drawWindow(scene, _3dxy, _3dobject) { |
1630 | if (!windowTexture) { | 1648 | if (!windowTexture) { |
1631 | windowTexture = new loader.load('images/windowTex.jpg'); | 1649 | windowTexture = new loader.load('images/windowTex.jpg'); |
1632 | windowTexture.wrapS = windowTexture.wrapT = THREE.RepeatWrapping; | 1650 | windowTexture.wrapS = windowTexture.wrapT = THREE.RepeatWrapping; |
1633 | windowTexture.repeat.set(1, 1); | 1651 | windowTexture.repeat.set(1, 1); |
1634 | } | 1652 | } |
1635 | _3dxy.height_endpoint = window3D.height_endpoint + floor3D.height_endpoint; | 1653 | _3dxy.height_endpoint = window3D.height_endpoint + floor3D.height_endpoint; |
1636 | _3dxy.height_startpoint = window3D.height_startpoint + floor3D.height_endpoint; | 1654 | _3dxy.height_startpoint = window3D.height_startpoint + floor3D.height_endpoint; |
1637 | var sizePillar = 91 / 2 + 20; | 1655 | var sizePillar = 91 / 2 + 20; |
1638 | if (_3dxy.width_X > _3dxy.width_Y) { | 1656 | if (_3dxy.width_X > _3dxy.width_Y) { |
1639 | _3dxy.start_X = _3dxy.start_X + 5;// + converMMtoPX(sizePillar); // chinh lai cua so hard code | 1657 | _3dxy.start_X = _3dxy.start_X + 5;// + converMMtoPX(sizePillar); // chinh lai cua so hard code |
1640 | _3dxy.width_X = _3dxy.width_X - converMMtoPX(sizePillar * 2); | 1658 | _3dxy.width_X = _3dxy.width_X - converMMtoPX(sizePillar * 2); |
1641 | } else { | 1659 | } else { |
1642 | _3dxy.start_Y = _3dxy.start_Y + 5;// + converMMtoPX(sizePillar); // chinh lai cua so hard code | 1660 | _3dxy.start_Y = _3dxy.start_Y + 5;// + converMMtoPX(sizePillar); // chinh lai cua so hard code |
1643 | _3dxy.width_Y = _3dxy.width_Y - converMMtoPX(sizePillar * 2); | 1661 | _3dxy.width_Y = _3dxy.width_Y - converMMtoPX(sizePillar * 2); |
1644 | } | 1662 | } |
1645 | if (_3dobject[0] == 'smallwindow') { | 1663 | if (_3dobject[0] == 'smallwindow') { |
1646 | draw1wingWindow(scene, _3dxy, _3dobject); | 1664 | draw1wingWindow(scene, _3dxy, _3dobject); |
1647 | } | 1665 | } |
1648 | if (_3dobject[0] == 'normalwindow') { | 1666 | if (_3dobject[0] == 'normalwindow') { |
1649 | window1wings = JSON.parse(JSON.stringify(_3dxy)); | 1667 | window1wings = JSON.parse(JSON.stringify(_3dxy)); |
1650 | // if (_3dxy.width_X < _3dxy.width_Y) { | 1668 | // if (_3dxy.width_X < _3dxy.width_Y) { |
1651 | // window1wings.width_Y = _3dxy.width_Y / 2; | 1669 | // window1wings.width_Y = _3dxy.width_Y / 2; |
1652 | // window1wings.width_X = _3dxy.width_X / 2; | 1670 | // window1wings.width_X = _3dxy.width_X / 2; |
1653 | // // window1wings.start_X = _3dxy.start_X - converMMtoPX(75); | 1671 | // // window1wings.start_X = _3dxy.start_X - converMMtoPX(75); |
1654 | // } else { | 1672 | // } else { |
1655 | // window1wings.width_Y = _3dxy.width_Y / 2; | 1673 | // window1wings.width_Y = _3dxy.width_Y / 2; |
1656 | // window1wings.width_X = _3dxy.width_X / 2; | 1674 | // window1wings.width_X = _3dxy.width_X / 2; |
1657 | // // window1wings.start_Y = _3dxy.start_Y - converMMtoPX(75); | 1675 | // // window1wings.start_Y = _3dxy.start_Y - converMMtoPX(75); |
1658 | // } | 1676 | // } |
1659 | // // draw1wingWindow(scene, window1wings, _3dobject); | 1677 | // // draw1wingWindow(scene, window1wings, _3dobject); |
1660 | // window2wings = JSON.parse(JSON.stringify(_3dxy)); | 1678 | // window2wings = JSON.parse(JSON.stringify(_3dxy)); |
1661 | // if (_3dxy.width_X < _3dxy.width_Y) { | 1679 | // if (_3dxy.width_X < _3dxy.width_Y) { |
1662 | // window2wings.width_Y = _3dxy.width_Y / 2; | 1680 | // window2wings.width_Y = _3dxy.width_Y / 2; |
1663 | // window2wings.width_X = _3dxy.width_X / 2; | 1681 | // window2wings.width_X = _3dxy.width_X / 2; |
1664 | // // window2wings.start_X = _3dxy.start_X + converMMtoPX(25); | 1682 | // // window2wings.start_X = _3dxy.start_X + converMMtoPX(25); |
1665 | // window2wings.start_Y = _3dxy.start_Y + _3dxy.width_Y / 2; | 1683 | // window2wings.start_Y = _3dxy.start_Y + _3dxy.width_Y / 2; |
1666 | // } else { | 1684 | // } else { |
1667 | // window2wings.width_X = _3dxy.width_X / 2; | 1685 | // window2wings.width_X = _3dxy.width_X / 2; |
1668 | // window2wings.width_Y = _3dxy.width_Y / 2; | 1686 | // window2wings.width_Y = _3dxy.width_Y / 2; |
1669 | // // window2wings.start_Y = _3dxy.start_Y + converMMtoPX(25); | 1687 | // // window2wings.start_Y = _3dxy.start_Y + converMMtoPX(25); |
1670 | // window2wings.start_X = _3dxy.start_X + _3dxy.width_X / 2; | 1688 | // window2wings.start_X = _3dxy.start_X + _3dxy.width_X / 2; |
1671 | // } | 1689 | // } |
1672 | if (_3dxy.width_X < _3dxy.width_Y) { | 1690 | if (_3dxy.width_X < _3dxy.width_Y) { |
1673 | window1wings.width_X = _3dxy.width_X / 2; | 1691 | window1wings.width_X = _3dxy.width_X / 2; |
1674 | } else { | 1692 | } else { |
1675 | window1wings.width_Y = _3dxy.width_Y / 2; | 1693 | window1wings.width_Y = _3dxy.width_Y / 2; |
1676 | } | 1694 | } |
1677 | draw1wingWindow(scene, window1wings, _3dobject); | 1695 | draw1wingWindow(scene, window1wings, _3dobject); |
1678 | } | 1696 | } |
1679 | //var material = { | 1697 | //var material = { |
1680 | // 'transparent': true, | 1698 | // 'transparent': true, |
1681 | // 'opacity': 0.0001 | 1699 | // 'opacity': 0.0001 |
1682 | //}; | 1700 | //}; |
1683 | //var window = drawObj(scene, _3dxy, _3dobject, material); | 1701 | //var window = drawObj(scene, _3dxy, _3dobject, material); |
1684 | 1702 | ||
1685 | //windowObj.push(window); | 1703 | //windowObj.push(window); |
1686 | } | 1704 | } |
1687 | function draw1wingWindow(scene, Dxy, _3dobject) { | 1705 | function draw1wingWindow(scene, Dxy, _3dobject) { |
1688 | var materialWoodW = { | 1706 | var materialWoodW = { |
1689 | 'tex': windowTexture, | 1707 | 'tex': windowTexture, |
1690 | 'transparent': false, | 1708 | 'transparent': false, |
1691 | 'opacity': 0.0001 | 1709 | 'opacity': 0.0001 |
1692 | }; | 1710 | }; |
1693 | var borderWindow = 100; | 1711 | var borderWindow = 100; |
1694 | wWindow = JSON.parse(JSON.stringify(Dxy)); | 1712 | wWindow = JSON.parse(JSON.stringify(Dxy)); |
1695 | if (wWindow.width_X > wWindow.width_Y) { | 1713 | if (wWindow.width_X > wWindow.width_Y) { |
1696 | wWindow.start_Y = wWindow.start_Y - wWindow.width_Y; | 1714 | wWindow.start_Y = wWindow.start_Y - wWindow.width_Y; |
1697 | wWindow.start_X = wWindow.start_X - converMMtoPX(20); | 1715 | wWindow.start_X = wWindow.start_X - converMMtoPX(20); |
1698 | wWindow.width_X = wWindow.width_X + converMMtoPX(40); | 1716 | wWindow.width_X = wWindow.width_X + converMMtoPX(40); |
1699 | wWindow.width_Y = wWindow.width_Y * 2; | 1717 | wWindow.width_Y = wWindow.width_Y * 2; |
1700 | } else { | 1718 | } else { |
1701 | wWindow.start_X = wWindow.start_X - wWindow.width_X; | 1719 | wWindow.start_X = wWindow.start_X - wWindow.width_X; |
1702 | wWindow.start_Y = wWindow.start_Y - converMMtoPX(20); | 1720 | wWindow.start_Y = wWindow.start_Y - converMMtoPX(20); |
1703 | wWindow.width_Y = wWindow.width_Y + converMMtoPX(40); | 1721 | wWindow.width_Y = wWindow.width_Y + converMMtoPX(40); |
1704 | wWindow.width_X = wWindow.width_X * 2; | 1722 | wWindow.width_X = wWindow.width_X * 2; |
1705 | } | 1723 | } |
1706 | wWindow.height_endpoint = wWindow.height_endpoint + converMMtoPX(20); | 1724 | wWindow.height_endpoint = wWindow.height_endpoint + converMMtoPX(20); |
1707 | wWindow.height_startpoint = wWindow.height_startpoint - converMMtoPX(20); | 1725 | wWindow.height_startpoint = wWindow.height_startpoint - converMMtoPX(20); |
1708 | var woodWindow = drawObj(scene, wWindow, _3dobject, materialWoodW); | 1726 | var woodWindow = drawObj(scene, wWindow, _3dobject, materialWoodW); |
1709 | windowObj.push(woodWindow); | 1727 | windowObj.push(woodWindow); |
1710 | // Border Window | 1728 | // Border Window |
1711 | var border_window = JSON.parse(JSON.stringify(wWindow)); | 1729 | var border_window = JSON.parse(JSON.stringify(wWindow)); |
1712 | var materialBorder = { | 1730 | var materialBorder = { |
1713 | 'map': windowTexture, | 1731 | 'map': windowTexture, |
1714 | 'transparent': false, | 1732 | 'transparent': false, |
1715 | 'opacity': 1 | 1733 | 'opacity': 1 |
1716 | }; | 1734 | }; |
1717 | var drawWindow_border = drawObj(scene, border_window, _3dobject, materialBorder); | 1735 | var drawWindow_border = drawObj(scene, border_window, _3dobject, materialBorder); |
1718 | //Wood Window | 1736 | //Wood Window |
1719 | var wood_window = JSON.parse(JSON.stringify(Dxy)); | 1737 | var wood_window = JSON.parse(JSON.stringify(Dxy)); |
1720 | if (wood_window.width_X > wood_window.width_Y) { | 1738 | if (wood_window.width_X > wood_window.width_Y) { |
1721 | //wood_window.start_X = wood_window.start_X - converMMtoPX(100); | 1739 | //wood_window.start_X = wood_window.start_X - converMMtoPX(100); |
1722 | wood_window.start_Y = wWindow.start_Y - wWindow.width_Y; | 1740 | wood_window.start_Y = wWindow.start_Y - wWindow.width_Y; |
1723 | wood_window.width_Y = wWindow.width_Y * 2; | 1741 | wood_window.width_Y = wWindow.width_Y * 2; |
1724 | } else { | 1742 | } else { |
1725 | //wood_window.start_Y = wood_window.start_Y - converMMtoPX(100); | 1743 | //wood_window.start_Y = wood_window.start_Y - converMMtoPX(100); |
1726 | wood_window.start_X = wWindow.start_X - wWindow.width_X; | 1744 | wood_window.start_X = wWindow.start_X - wWindow.width_X; |
1727 | wood_window.width_X = wWindow.width_X * 2; | 1745 | wood_window.width_X = wWindow.width_X * 2; |
1728 | } | 1746 | } |
1729 | var materialWood_window = {}; | 1747 | var materialWood_window = {}; |
1730 | var drawWindow_wood_window = drawObj(scene, wood_window, _3dobject, materialWood_window); | 1748 | var drawWindow_wood_window = drawObj(scene, wood_window, _3dobject, materialWood_window); |
1731 | // swing 1 | 1749 | // swing 1 |
1732 | var window_dxy1 = JSON.parse(JSON.stringify(Dxy)); | 1750 | var window_dxy1 = JSON.parse(JSON.stringify(Dxy)); |
1733 | if (window_dxy1.width_X > window_dxy1.width_Y) { | 1751 | if (window_dxy1.width_X > window_dxy1.width_Y) { |
1734 | window_dxy1.start_Y = window_dxy1.start_Y - window_dxy1.width_Y; | 1752 | window_dxy1.start_Y = window_dxy1.start_Y - window_dxy1.width_Y; |
1735 | window_dxy1.width_X = window_dxy1.width_X / 2 + converMMtoPX(borderWindow / 2); | 1753 | window_dxy1.width_X = window_dxy1.width_X / 2 + converMMtoPX(borderWindow / 2); |
1736 | } else { | 1754 | } else { |
1737 | window_dxy1.start_X = window_dxy1.start_X - window_dxy1.width_X; | 1755 | window_dxy1.start_X = window_dxy1.start_X - window_dxy1.width_X; |
1738 | window_dxy1.width_Y = window_dxy1.width_Y / 2 + converMMtoPX(borderWindow / 2); | 1756 | window_dxy1.width_Y = window_dxy1.width_Y / 2 + converMMtoPX(borderWindow / 2); |
1739 | } | 1757 | } |
1740 | var draw_window_swing1 = drawObj(scene, window_dxy1, _3dobject, materialWood_window); | 1758 | var draw_window_swing1 = drawObj(scene, window_dxy1, _3dobject, materialWood_window); |
1741 | 1759 | ||
1742 | //glass swing 1 | 1760 | //glass swing 1 |
1743 | 1761 | ||
1744 | var glassW1 = JSON.parse(JSON.stringify(window_dxy1)); | 1762 | var glassW1 = JSON.parse(JSON.stringify(window_dxy1)); |
1745 | glassW1.height_endpoint = Dxy.height_endpoint - converMMtoPX(borderWindow); | 1763 | glassW1.height_endpoint = Dxy.height_endpoint - converMMtoPX(borderWindow); |
1746 | glassW1.height_startpoint = Dxy.height_startpoint + converMMtoPX(borderWindow); | 1764 | glassW1.height_startpoint = Dxy.height_startpoint + converMMtoPX(borderWindow); |
1747 | if (glassW1.width_X > glassW1.width_Y) { | 1765 | if (glassW1.width_X > glassW1.width_Y) { |
1748 | glassW1.start_X = glassW1.start_X + converMMtoPX(borderWindow); | 1766 | glassW1.start_X = glassW1.start_X + converMMtoPX(borderWindow); |
1749 | glassW1.width_X = glassW1.width_X - converMMtoPX(borderWindow * 2); | 1767 | glassW1.width_X = glassW1.width_X - converMMtoPX(borderWindow * 2); |
1750 | } else { | 1768 | } else { |
1751 | glassW1.start_Y = glassW1.start_Y + converMMtoPX(borderWindow); | 1769 | glassW1.start_Y = glassW1.start_Y + converMMtoPX(borderWindow); |
1752 | glassW1.width_Y = (glassW1.width_Y - converMMtoPX(borderWindow * 2)); | 1770 | glassW1.width_Y = (glassW1.width_Y - converMMtoPX(borderWindow * 2)); |
1753 | } | 1771 | } |
1754 | var material_glass = { | 1772 | var material_glass = { |
1755 | 'tex': glassTexture, | 1773 | 'tex': glassTexture, |
1756 | 'transparent': true, | 1774 | 'transparent': true, |
1757 | 'opacity': 0.5 | 1775 | 'opacity': 0.5 |
1758 | }; | 1776 | }; |
1759 | var glassW1_window = drawObj(scene, glassW1, _3dobject, material_glass); | 1777 | var glassW1_window = drawObj(scene, glassW1, _3dobject, material_glass); |
1760 | // swing 2 | 1778 | // swing 2 |
1761 | var window_dxy2 = JSON.parse(JSON.stringify(Dxy)); | 1779 | var window_dxy2 = JSON.parse(JSON.stringify(Dxy)); |
1762 | if (window_dxy2.width_X > window_dxy2.width_Y) { | 1780 | if (window_dxy2.width_X > window_dxy2.width_Y) { |
1763 | 1781 | ||
1764 | window_dxy2.start_Y = window_dxy2.start_Y; | 1782 | window_dxy2.start_Y = window_dxy2.start_Y; |
1765 | window_dxy2.width_X = window_dxy2.width_X / 2 + converMMtoPX(borderWindow / 2); | 1783 | window_dxy2.width_X = window_dxy2.width_X / 2 + converMMtoPX(borderWindow / 2); |
1766 | window_dxy2.start_X = window_dxy2.start_X + window_dxy2.width_X - converMMtoPX(borderWindow); | 1784 | window_dxy2.start_X = window_dxy2.start_X + window_dxy2.width_X - converMMtoPX(borderWindow); |
1767 | } else { | 1785 | } else { |
1768 | window_dxy2.start_X = window_dxy2.start_X; | 1786 | window_dxy2.start_X = window_dxy2.start_X; |
1769 | window_dxy2.width_Y = window_dxy2.width_Y / 2 + converMMtoPX(borderWindow / 2); | 1787 | window_dxy2.width_Y = window_dxy2.width_Y / 2 + converMMtoPX(borderWindow / 2); |
1770 | window_dxy2.start_Y = window_dxy2.start_Y + window_dxy2.width_Y - converMMtoPX(borderWindow); | 1788 | window_dxy2.start_Y = window_dxy2.start_Y + window_dxy2.width_Y - converMMtoPX(borderWindow); |
1771 | } | 1789 | } |
1772 | var draw_window_swing2 = drawObj(scene, window_dxy2, _3dobject, materialWood_window); | 1790 | var draw_window_swing2 = drawObj(scene, window_dxy2, _3dobject, materialWood_window); |
1773 | //Glass 2 | 1791 | //Glass 2 |
1774 | var glassW2 = JSON.parse(JSON.stringify(window_dxy2)); | 1792 | var glassW2 = JSON.parse(JSON.stringify(window_dxy2)); |
1775 | glassW2.height_endpoint = Dxy.height_endpoint - converMMtoPX(borderWindow); | 1793 | glassW2.height_endpoint = Dxy.height_endpoint - converMMtoPX(borderWindow); |
1776 | glassW2.height_startpoint = Dxy.height_startpoint + converMMtoPX(borderWindow); | 1794 | glassW2.height_startpoint = Dxy.height_startpoint + converMMtoPX(borderWindow); |
1777 | if (glassW2.width_X > glassW2.width_Y) { | 1795 | if (glassW2.width_X > glassW2.width_Y) { |
1778 | glassW2.start_X = glassW2.start_X + converMMtoPX(borderWindow); | 1796 | glassW2.start_X = glassW2.start_X + converMMtoPX(borderWindow); |
1779 | glassW2.width_X = glassW2.width_X - converMMtoPX(borderWindow * 2); | 1797 | glassW2.width_X = glassW2.width_X - converMMtoPX(borderWindow * 2); |
1780 | } else { | 1798 | } else { |
1781 | glassW2.start_Y = glassW2.start_Y + converMMtoPX(borderWindow); | 1799 | glassW2.start_Y = glassW2.start_Y + converMMtoPX(borderWindow); |
1782 | glassW2.width_Y = (glassW2.width_Y - converMMtoPX(borderWindow * 2)); | 1800 | glassW2.width_Y = (glassW2.width_Y - converMMtoPX(borderWindow * 2)); |
1783 | } | 1801 | } |
1784 | var material_glass = { | 1802 | var material_glass = { |
1785 | 'tex': glassTexture, | 1803 | 'tex': glassTexture, |
1786 | 'transparent': true, | 1804 | 'transparent': true, |
1787 | 'opacity': 0.5 | 1805 | 'opacity': 0.5 |
1788 | }; | 1806 | }; |
1789 | var glassW2_window = drawObj(scene, glassW2, _3dobject, material_glass); | 1807 | var glassW2_window = drawObj(scene, glassW2, _3dobject, material_glass); |
1790 | 1808 | ||
1791 | //slice Window | 1809 | //slice Window |
1792 | var drawWindow_border_BSP = new ThreeBSP(drawWindow_border); | 1810 | var drawWindow_border_BSP = new ThreeBSP(drawWindow_border); |
1793 | var drawWindow_wood_window_BSP = new ThreeBSP(drawWindow_wood_window); | 1811 | var drawWindow_wood_window_BSP = new ThreeBSP(drawWindow_wood_window); |
1794 | drawWindow_border_BSP = drawWindow_border_BSP.subtract(drawWindow_wood_window_BSP); | 1812 | drawWindow_border_BSP = drawWindow_border_BSP.subtract(drawWindow_wood_window_BSP); |
1795 | 1813 | ||
1796 | 1814 | ||
1797 | //add Window | 1815 | //add Window |
1798 | var drawWindow_border_Mesh = drawWindow_border_BSP.toMesh(); | 1816 | var drawWindow_border_Mesh = drawWindow_border_BSP.toMesh(); |
1799 | var materialBorder = new THREE.MeshBasicMaterial({ | 1817 | var materialBorder = new THREE.MeshBasicMaterial({ |
1800 | map: windowTexture, | 1818 | map: windowTexture, |
1801 | shading: THREE.FlatShading, | 1819 | shading: THREE.FlatShading, |
1802 | side: THREE.DoubleSide, | 1820 | side: THREE.DoubleSide, |
1803 | }); | 1821 | }); |
1804 | drawWindow_border_Mesh.material = materialBorder; | 1822 | drawWindow_border_Mesh.material = materialBorder; |
1805 | woodWindowObj.push(drawWindow_border_Mesh); | 1823 | woodWindowObj.push(drawWindow_border_Mesh); |
1806 | 1824 | ||
1807 | var draw_window_swing1_BSP = new ThreeBSP(draw_window_swing1); | 1825 | var draw_window_swing1_BSP = new ThreeBSP(draw_window_swing1); |
1808 | var glassW1_BSP = new ThreeBSP(glassW1_window); | 1826 | var glassW1_BSP = new ThreeBSP(glassW1_window); |
1809 | draw_window_swing1_BSP = draw_window_swing1_BSP.subtract(glassW1_BSP); | 1827 | draw_window_swing1_BSP = draw_window_swing1_BSP.subtract(glassW1_BSP); |
1810 | var draw_window_swing1_Mesh = draw_window_swing1_BSP.toMesh(); | 1828 | var draw_window_swing1_Mesh = draw_window_swing1_BSP.toMesh(); |
1811 | draw_window_swing1_Mesh.material = materialBorder; | 1829 | draw_window_swing1_Mesh.material = materialBorder; |
1812 | woodWindowObj.push(draw_window_swing1_Mesh); | 1830 | woodWindowObj.push(draw_window_swing1_Mesh); |
1813 | woodWindowObj.push(glassW1_window); | 1831 | woodWindowObj.push(glassW1_window); |
1814 | // | 1832 | // |
1815 | var draw_window_swing2_BSP = new ThreeBSP(draw_window_swing2); | 1833 | var draw_window_swing2_BSP = new ThreeBSP(draw_window_swing2); |
1816 | var glassW2_BSP = new ThreeBSP(glassW2_window); | 1834 | var glassW2_BSP = new ThreeBSP(glassW2_window); |
1817 | draw_window_swing2_BSP = draw_window_swing2_BSP.subtract(glassW2_BSP); | 1835 | draw_window_swing2_BSP = draw_window_swing2_BSP.subtract(glassW2_BSP); |
1818 | var draw_window_swing2_Mesh = draw_window_swing2_BSP.toMesh(); | 1836 | var draw_window_swing2_Mesh = draw_window_swing2_BSP.toMesh(); |
1819 | draw_window_swing2_Mesh.material = materialBorder; | 1837 | draw_window_swing2_Mesh.material = materialBorder; |
1820 | woodWindowObj.push(draw_window_swing2_Mesh); | 1838 | woodWindowObj.push(draw_window_swing2_Mesh); |
1821 | woodWindowObj.push(glassW2_window); | 1839 | woodWindowObj.push(glassW2_window); |
1822 | 1840 | ||
1823 | } | 1841 | } |
1824 | 1842 | ||
1825 | // Draw Object with differene texture | 1843 | // Draw Object with differene texture |
1826 | function drawObjDiffTexture(scene, _3dxy, _3dobject, materialArr) { | 1844 | function drawObjDiffTexture(scene, _3dxy, _3dobject, materialArr) { |
1827 | 1845 | ||
1828 | var cubeMaterials = new THREE.MeshFaceMaterial(materialArr); | 1846 | var cubeMaterials = new THREE.MeshFaceMaterial(materialArr); |
1829 | 1847 | ||
1830 | var cubeGeometry = new THREE.CubeGeometry(_3dxy.width_X, _3dxy.height_endpoint - _3dxy.height_startpoint, _3dxy.width_Y, 10, 10, 10); | 1848 | var cubeGeometry = new THREE.CubeGeometry(_3dxy.width_X, _3dxy.height_endpoint - _3dxy.height_startpoint, _3dxy.width_Y, 10, 10, 10); |
1831 | cube = new THREE.Mesh(cubeGeometry, cubeMaterials); | 1849 | cube = new THREE.Mesh(cubeGeometry, cubeMaterials); |
1832 | if (inside) { | 1850 | if (inside) { |
1833 | cube.position.set((_3dxy.width_X ) / 2 + _3dxy.start_X - converMMtoPX(floorInfo[2][0]) - converMMtoPX(floorInfo[2][2]) / 2, (_3dxy.height_endpoint + _3dxy.height_startpoint) / 2 - converMMtoPX(300 + 300), (_3dxy.width_Y ) / 2 + _3dxy.start_Y - converMMtoPX(floorInfo[2][1]) - converMMtoPX(floorInfo[2][3]) / 2); | 1851 | cube.position.set((_3dxy.width_X ) / 2 + _3dxy.start_X - converMMtoPX(floorInfo[2][0]) - converMMtoPX(floorInfo[2][2]) / 2, (_3dxy.height_endpoint + _3dxy.height_startpoint) / 2 - converMMtoPX(300 + 300), (_3dxy.width_Y ) / 2 + _3dxy.start_Y - converMMtoPX(floorInfo[2][1]) - converMMtoPX(floorInfo[2][3]) / 2); |
1834 | 1852 | ||
1835 | } else { | 1853 | } else { |
1836 | cube.position.set((_3dxy.width_X - floor_width) / 2 + _3dxy.start_X, (_3dxy.height_endpoint + _3dxy.height_startpoint) / 2, (_3dxy.width_Y - floor_height) / 2 + _3dxy.start_Y); | 1854 | cube.position.set((_3dxy.width_X - floor_width) / 2 + _3dxy.start_X, (_3dxy.height_endpoint + _3dxy.height_startpoint) / 2, (_3dxy.width_Y - floor_height) / 2 + _3dxy.start_Y); |
1837 | } | 1855 | } |
1838 | 1856 | ||
1839 | return cube; | 1857 | return cube; |
1840 | } | 1858 | } |
1841 | 1859 | ||
1842 | // Draw Obj | 1860 | // Draw Obj |
1843 | function drawObj(scene, _3dxy, _3dobject, material) { | 1861 | function drawObj(scene, _3dxy, _3dobject, material) { |
1844 | // Create an array of materials to be used in a cube, one for each side | 1862 | // Create an array of materials to be used in a cube, one for each side |
1845 | var cubeMaterialArray = []; | 1863 | var cubeMaterialArray = []; |
1846 | // order to add materials: x+,x-,y+,y-,z+,z- | 1864 | // order to add materials: x+,x-,y+,y-,z+,z- |
1847 | if (material.tex == undefined || !material.tex) | 1865 | if (material.tex == undefined || !material.tex) |
1848 | material.tex = defaultTextute; | 1866 | material.tex = defaultTextute; |
1849 | if (!material.transparent || material.transparent == undefined) | 1867 | if (!material.transparent || material.transparent == undefined) |
1850 | material.transparent = false; | 1868 | material.transparent = false; |
1851 | if (!material.opacity || material.opacity == undefined) | 1869 | if (!material.opacity || material.opacity == undefined) |
1852 | material.opacity = 1; | 1870 | material.opacity = 1; |
1853 | cubeMaterialArray.push(new THREE.MeshBasicMaterial({ | 1871 | cubeMaterialArray.push(new THREE.MeshBasicMaterial({ |
1854 | map: material.tex, | 1872 | map: material.tex, |
1855 | side: THREE.DoubleSide, | 1873 | side: THREE.DoubleSide, |
1856 | transparent: material.transparent, | 1874 | transparent: material.transparent, |
1857 | opacity: material.opacity | 1875 | opacity: material.opacity |
1858 | })); | 1876 | })); |
1859 | cubeMaterialArray.push(new THREE.MeshBasicMaterial({ | 1877 | cubeMaterialArray.push(new THREE.MeshBasicMaterial({ |
1860 | map: material.tex, | 1878 | map: material.tex, |
1861 | side: THREE.DoubleSide, | 1879 | side: THREE.DoubleSide, |
1862 | transparent: material.transparent, | 1880 | transparent: material.transparent, |
1863 | opacity: material.opacity | 1881 | opacity: material.opacity |
1864 | })); | 1882 | })); |
1865 | cubeMaterialArray.push(new THREE.MeshBasicMaterial({ | 1883 | cubeMaterialArray.push(new THREE.MeshBasicMaterial({ |
1866 | map: material.tex, | 1884 | map: material.tex, |
1867 | side: THREE.DoubleSide, | 1885 | side: THREE.DoubleSide, |
1868 | transparent: material.transparent, | 1886 | transparent: material.transparent, |
1869 | opacity: material.opacity | 1887 | opacity: material.opacity |
1870 | })); | 1888 | })); |
1871 | cubeMaterialArray.push(new THREE.MeshBasicMaterial({ | 1889 | cubeMaterialArray.push(new THREE.MeshBasicMaterial({ |
1872 | map: material.tex, | 1890 | map: material.tex, |
1873 | side: THREE.DoubleSide, | 1891 | side: THREE.DoubleSide, |
1874 | transparent: material.transparent, | 1892 | transparent: material.transparent, |
1875 | opacity: material.opacity | 1893 | opacity: material.opacity |
1876 | })); | 1894 | })); |
1877 | cubeMaterialArray.push(new THREE.MeshBasicMaterial({ | 1895 | cubeMaterialArray.push(new THREE.MeshBasicMaterial({ |
1878 | map: material.tex, | 1896 | map: material.tex, |
1879 | side: THREE.DoubleSide, | 1897 | side: THREE.DoubleSide, |
1880 | transparent: material.transparent, | 1898 | transparent: material.transparent, |
1881 | opacity: material.opacity | 1899 | opacity: material.opacity |
1882 | })); | 1900 | })); |
1883 | cubeMaterialArray.push(new THREE.MeshBasicMaterial({ | 1901 | cubeMaterialArray.push(new THREE.MeshBasicMaterial({ |
1884 | map: material.tex, | 1902 | map: material.tex, |
1885 | side: THREE.DoubleSide, | 1903 | side: THREE.DoubleSide, |
1886 | transparent: material.transparent, | 1904 | transparent: material.transparent, |
1887 | opacity: material.opacity | 1905 | opacity: material.opacity |
1888 | })); | 1906 | })); |
1889 | var cubeMaterials = new THREE.MeshFaceMaterial(cubeMaterialArray); | 1907 | var cubeMaterials = new THREE.MeshFaceMaterial(cubeMaterialArray); |
1890 | 1908 | ||
1891 | var cubeGeometry = new THREE.CubeGeometry(_3dxy.width_X, _3dxy.height_endpoint - _3dxy.height_startpoint, _3dxy.width_Y, 10, 10, 10); | 1909 | var cubeGeometry = new THREE.CubeGeometry(_3dxy.width_X, _3dxy.height_endpoint - _3dxy.height_startpoint, _3dxy.width_Y, 10, 10, 10); |
1892 | if (isDraw == 'roof') { | 1910 | if (isDraw == 'roof') { |
1893 | 1911 | ||
1894 | 1912 | ||
1895 | } | 1913 | } |
1896 | if (isDraw == 'wall') { | 1914 | if (isDraw == 'wall') { |
1897 | 1915 | ||
1898 | } | 1916 | } |
1899 | cube = new THREE.Mesh(cubeGeometry, cubeMaterials); | 1917 | cube = new THREE.Mesh(cubeGeometry, cubeMaterials); |
1900 | if (inside) { | 1918 | if (inside) { |
1901 | cube.position.set((_3dxy.width_X ) / 2 + _3dxy.start_X - converMMtoPX(floorInfo[2][0]) - converMMtoPX(floorInfo[2][2]) / 2, (_3dxy.height_endpoint + _3dxy.height_startpoint) / 2 - converMMtoPX(300 + 300), (_3dxy.width_Y ) / 2 + _3dxy.start_Y - converMMtoPX(floorInfo[2][1]) - converMMtoPX(floorInfo[2][3]) / 2); | 1919 | cube.position.set((_3dxy.width_X ) / 2 + _3dxy.start_X - converMMtoPX(floorInfo[2][0]) - converMMtoPX(floorInfo[2][2]) / 2, (_3dxy.height_endpoint + _3dxy.height_startpoint) / 2 - converMMtoPX(300 + 300), (_3dxy.width_Y ) / 2 + _3dxy.start_Y - converMMtoPX(floorInfo[2][1]) - converMMtoPX(floorInfo[2][3]) / 2); |
1902 | 1920 | ||
1903 | } else { | 1921 | } else { |
1904 | cube.position.set((_3dxy.width_X - floor_width) / 2 + _3dxy.start_X, (_3dxy.height_endpoint + _3dxy.height_startpoint) / 2, (_3dxy.width_Y - floor_height) / 2 + _3dxy.start_Y); | 1922 | cube.position.set((_3dxy.width_X - floor_width) / 2 + _3dxy.start_X, (_3dxy.height_endpoint + _3dxy.height_startpoint) / 2, (_3dxy.width_Y - floor_height) / 2 + _3dxy.start_Y); |
1905 | } | 1923 | } |
1906 | //cube.castShadow = true; | 1924 | //cube.castShadow = true; |
1907 | //cube.receiveShadow = false; | 1925 | //cube.receiveShadow = false; |
1908 | return cube; | 1926 | return cube; |
1909 | } | 1927 | } |
1910 | function drawRoof3D(scene, _3dxy, _3dobject, type) { | 1928 | function drawRoof3D(scene, _3dxy, _3dobject, type) { |
1911 | var url = 'images/' + _3dobject[0] + '.jpg'; | 1929 | var url = 'images/' + _3dobject[0] + '.jpg'; |
1912 | roofTex = new loader.load(url); | 1930 | roofTex = new loader.load(url); |
1913 | roofTex.wrapS = roofTex.wrapT = THREE.RepeatWrapping; | 1931 | roofTex.wrapS = roofTex.wrapT = THREE.RepeatWrapping; |
1914 | roofTex.repeat.set(1, 1); | 1932 | roofTex.repeat.set(1, 1); |
1915 | var material = { | 1933 | var material = { |
1916 | 'tex': roofTex, | 1934 | 'tex': roofTex, |
1917 | }; | 1935 | }; |
1918 | isDraw = 'roof'; | 1936 | isDraw = 'roof'; |
1919 | if (typeBalcony == TYPE_BALCONY_NONE) { | 1937 | if (typeBalcony == TYPE_BALCONY_NONE) { |
1920 | baconInfo = []; | 1938 | baconInfo = []; |
1921 | baconInfo[2] = []; | 1939 | baconInfo[2] = []; |
1922 | baconInfo[2][3] = 0; | 1940 | baconInfo[2][3] = 0; |
1923 | } | 1941 | } |
1924 | var typeRoof = _3dobject[0].split('-'); | 1942 | var typeRoof = _3dobject[0].split('-'); |
1925 | typeRoof = typeRoof[0] + '-' + typeRoof[1]; | 1943 | typeRoof = typeRoof[0] + '-' + typeRoof[1]; |
1926 | var heightRoof = 300; | 1944 | //var heightRoof = 300; |
1927 | // | 1945 | // |
1928 | var rType = JSON.parse(JSON.stringify(roofType)); | 1946 | var rType = JSON.parse(JSON.stringify(roofType)); |
1929 | if (rotate == 1) | 1947 | if (rotate == 1) |
1930 | type = 101; | 1948 | type = 101; |
1931 | if (rotate == 2) | 1949 | if (rotate == 2) |
1932 | type = 102; | 1950 | type = 102; |
1933 | if (rotate == 3) | 1951 | if (rotate == 3) |
1934 | type = 103; | 1952 | type = 103; |
1935 | if (rotate == 4) | 1953 | if (rotate == 4) |
1936 | type = 104; | 1954 | type = 104; |
1937 | // | 1955 | // |
1938 | if (typeRoof == 'roof-2') { | 1956 | if (typeRoof == 'roof-2') { |
1957 | var tan = roofTan2; | ||
1939 | 1958 | ||
1940 | roof3D = drawObj(scene, _3dxy, _3dobject, material); | 1959 | roof3D = drawObj(scene, _3dxy, _3dobject, material); |
1941 | roof_2roof_obj = null; | 1960 | roof_2roof_obj = null; |
1942 | roof_1roof_obj = null; | 1961 | roof_1roof_obj = null; |
1943 | // set rotate roof | 1962 | // set rotate roof |
1944 | 1963 | ||
1945 | _3dxyRoof = JSON.parse(JSON.stringify(_3dxy)); | 1964 | _3dxyRoof = JSON.parse(JSON.stringify(_3dxy)); |
1946 | //// | 1965 | //// |
1947 | if (type == 101) { | 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 | var b = 2030 +tan*(floorInfo[2][3]-(converPxtoMm(_3dxyRoof.width_Y)/2 - 300)) + 50 / 2; | 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 | roof3D.rotation.x = Math.atan(tan); | 1972 | roof3D.rotation.x = Math.atan(tan); |
1952 | } | 1973 | } |
1953 | else if (type == 102) { | 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 | var b = 2030 +tan*(floorInfo[2][3]-(converPxtoMm(_3dxyRoof.width_Y)/2 - 300)) + 50 / 2; | 1977 | var b = 2030 +tan*(floorInfo[2][3]-(converPxtoMm(_3dxyRoof.width_Y)/2 - 300)) + 50 / 2; |
1956 | roof3D.rotation.x = -Math.atan(tan); | 1978 | roof3D.rotation.x = -Math.atan(tan); |
1957 | } else if (type == 103) { | 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 | var b = 2030 +tan*(floorInfo[2][2]-(converPxtoMm(_3dxyRoof.width_X)/2 - 300)) + 50 / 2; | 1982 | var b = 2030 +tan*(floorInfo[2][2]-(converPxtoMm(_3dxyRoof.width_X)/2 - 300)) + 50 / 2; |
1960 | roof3D.rotation.z = -Math.atan(tan); | 1983 | roof3D.rotation.z = -Math.atan(tan); |
1961 | } else if (type == 104) { | 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 | var b = 2030 +tan*(floorInfo[2][2]-(converPxtoMm(_3dxyRoof.width_X)/2 - 300)) + 50 / 2; | 1987 | var b = 2030 +tan*(floorInfo[2][2]-(converPxtoMm(_3dxyRoof.width_X)/2 - 300)) + 50 / 2; |
1964 | roof3D.rotation.z = Math.atan(tan); | 1988 | roof3D.rotation.z = Math.atan(tan); |
1965 | } | 1989 | } |
1966 | roof3D.position.y = converMMtoPX(b) + floor3D.height_endpoint - floor3D.height_startpoint; | 1990 | roof3D.position.y = converMMtoPX(b) + floor3D.height_endpoint - floor3D.height_startpoint; |
1967 | 1991 | ||
1968 | drawBeamsRoof(scene, _3dxy, tan, type, typeRoof); | 1992 | drawBeamsRoof(scene, _3dxy, tan, type, typeRoof); |
1969 | scene.add(roof3D); | 1993 | scene.add(roof3D); |
1970 | // roof slice | 1994 | // roof slice |
1971 | _3dxy_roofSlice = JSON.parse(JSON.stringify(_3dxy)); | 1995 | _3dxy_roofSlice = JSON.parse(JSON.stringify(_3dxy)); |
1972 | var kc = 200; | 1996 | var kc = 200; |
1973 | _3dxy_roofSlice.height_startpoint = _3dxy.height_endpoint; | 1997 | _3dxy_roofSlice.height_startpoint = _3dxy.height_endpoint; |
1974 | _3dxy_roofSlice.height_endpoint = _3dxy.height_endpoint + kc; | 1998 | _3dxy_roofSlice.height_endpoint = _3dxy.height_endpoint + kc; |
1975 | var material = { | 1999 | var material = { |
1976 | 'tex': windowTexture, | 2000 | 'tex': windowTexture, |
1977 | 'transparent': true, | 2001 | 'transparent': true, |
1978 | 'opacity': 0.000001 | 2002 | 'opacity': 0.000001 |
1979 | }; | 2003 | }; |
1980 | roofSlice = drawObj(scene, _3dxy_roofSlice, _3dobject, material); | 2004 | roofSlice = drawObj(scene, _3dxy_roofSlice, _3dobject, material); |
1981 | if (type == 101) { | 2005 | if (type == 101) { |
1982 | roofSlice.rotation.x = Math.atan(tan); | 2006 | roofSlice.rotation.x = Math.atan(tan); |
1983 | } | 2007 | } |
1984 | else if (type == 102) { | 2008 | else if (type == 102) { |
1985 | roofSlice.rotation.x = -Math.atan(tan); | 2009 | roofSlice.rotation.x = -Math.atan(tan); |
1986 | } else if (type == 103) { | 2010 | } else if (type == 103) { |
1987 | roofSlice.rotation.z = -Math.atan(tan); | 2011 | roofSlice.rotation.z = -Math.atan(tan); |
1988 | } else if (type == 104) { | 2012 | } else if (type == 104) { |
1989 | roofSlice.rotation.z = Math.atan(tan); | 2013 | roofSlice.rotation.z = Math.atan(tan); |
1990 | } | 2014 | } |
1991 | roofSlice.position.y = converMMtoPX(b) + floor3D.height_endpoint - floor3D.height_startpoint + kc / 2; | 2015 | roofSlice.position.y = converMMtoPX(b) + floor3D.height_endpoint - floor3D.height_startpoint + kc / 2; |
1992 | scene.add(roofSlice); | 2016 | scene.add(roofSlice); |
1993 | } else if (typeRoof == 'roof-1') { | 2017 | } else if (typeRoof == 'roof-1') { |
1994 | var diff = 300; | 2018 | var diff = 300; |
1995 | var heightRoof = 300; | 2019 | //var heightRoof = 300; |
2020 | tan = roofTan1; | ||
1996 | roof3D = null; | 2021 | roof3D = null; |
1997 | if (type == 101 || type === 102) { | 2022 | if (type == 101 || type === 102) { |
1998 | var roof_1roof = JSON.parse(JSON.stringify(_3dxy)); | 2023 | var roof_1roof = JSON.parse(JSON.stringify(_3dxy)); |
1999 | //roof1 | 2024 | //roof1 |
2000 | roof_1roof.width_Y = roof_1roof.width_Y / 2; | 2025 | roof_1roof.width_Y = roof_1roof.width_Y / 2; |
2001 | roof_1roof_obj = drawObj(scene, roof_1roof, _3dobject, material); | 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 | roof_1roof_obj.rotation.x = -Math.atan(tan); | 2028 | roof_1roof_obj.rotation.x = -Math.atan(tan); |
2004 | var c = 2030 + 300 - tan * roof_1roof.width_Y * 2; | 2029 | var c = 2030 + 300 - tan * roof_1roof.width_Y * 2; |
2005 | roof_1roof_obj.position.y = converMMtoPX(c) + floor3D.height_endpoint - floor3D.height_startpoint; | 2030 | roof_1roof_obj.position.y = converMMtoPX(c) + floor3D.height_endpoint - floor3D.height_startpoint; |
2006 | drawBeamsRoof(scene, _3dxy, tan, type, typeRoof); | 2031 | drawBeamsRoof(scene, _3dxy, tan, type, typeRoof); |
2007 | scene.add(roof_1roof_obj); | 2032 | scene.add(roof_1roof_obj); |
2008 | //roof1_slice | 2033 | //roof1_slice |
2009 | var _3dxy_roofSlice1 = JSON.parse(JSON.stringify(roof_1roof)); | 2034 | var _3dxy_roofSlice1 = JSON.parse(JSON.stringify(roof_1roof)); |
2010 | var kc = 200; | 2035 | var kc = 200; |
2011 | _3dxy_roofSlice1.height_startpoint = roof_1roof.height_endpoint; | 2036 | _3dxy_roofSlice1.height_startpoint = roof_1roof.height_endpoint; |
2012 | _3dxy_roofSlice1.height_endpoint = roof_1roof.height_endpoint + kc; | 2037 | _3dxy_roofSlice1.height_endpoint = roof_1roof.height_endpoint + kc; |
2013 | var material1 = { | 2038 | var material1 = { |
2014 | 'tex': windowTexture, | 2039 | 'tex': windowTexture, |
2015 | 'transparent': true, | 2040 | 'transparent': true, |
2016 | 'opacity': 0.0001 | 2041 | 'opacity': 0.0001 |
2017 | }; | 2042 | }; |
2018 | roofSlice1 = drawObj(scene, _3dxy_roofSlice1, _3dobject, material1); | 2043 | roofSlice1 = drawObj(scene, _3dxy_roofSlice1, _3dobject, material1); |
2019 | roofSlice1.rotation.x = -Math.atan(tan); | 2044 | roofSlice1.rotation.x = -Math.atan(tan); |
2020 | roofSlice1.position.y = converMMtoPX(c) + floor3D.height_endpoint - floor3D.height_startpoint + kc / 2; | 2045 | roofSlice1.position.y = converMMtoPX(c) + floor3D.height_endpoint - floor3D.height_startpoint + kc / 2; |
2021 | scene.add(roofSlice1); | 2046 | scene.add(roofSlice1); |
2022 | //roof2 | 2047 | //roof2 |
2023 | 2048 | ||
2024 | var roof_2roof = JSON.parse(JSON.stringify(_3dxy)); | 2049 | var roof_2roof = JSON.parse(JSON.stringify(_3dxy)); |
2025 | 2050 | ||
2026 | // Check is roof cover balcony | 2051 | // Check is roof cover balcony |
2027 | roof_2roof.width_Y = roof_2roof.width_Y / 2; | 2052 | roof_2roof.width_Y = roof_2roof.width_Y / 2; |
2028 | roof_2roof.start_Y = roof_2roof.start_Y + _3dxy.width_Y / 2 - converMMtoPX(50); | 2053 | roof_2roof.start_Y = roof_2roof.start_Y + _3dxy.width_Y / 2 - converMMtoPX(50); |
2029 | roof_2roof_obj = drawObj(scene, roof_2roof, _3dobject, material); | 2054 | roof_2roof_obj = drawObj(scene, roof_2roof, _3dobject, material); |
2030 | var tan = converMMtoPX(heightRoof) / (roof_1roof.width_Y); | 2055 | var tan = converMMtoPX(heightRoof) / (roof_1roof.width_Y); |
2031 | roof_2roof_obj.rotation.x = Math.atan(tan); | 2056 | roof_2roof_obj.rotation.x = Math.atan(tan); |
2032 | 2057 | ||
2033 | // Check is roof cover balcony | 2058 | // Check is roof cover balcony |
2034 | 2059 | ||
2035 | var d = 2030 + 300 - tan * roof_2roof.width_Y * 2; | 2060 | var d = 2030 + 300 - tan * roof_2roof.width_Y * 2; |
2036 | // console.log(c); | 2061 | // console.log(c); |
2037 | roof_2roof_obj.position.y = converMMtoPX(d) + floor3D.height_endpoint - floor3D.height_startpoint; | 2062 | roof_2roof_obj.position.y = converMMtoPX(d) + floor3D.height_endpoint - floor3D.height_startpoint; |
2038 | drawBeamsRoof(scene, _3dxy, tan, type, typeRoof); | 2063 | drawBeamsRoof(scene, _3dxy, tan, type, typeRoof); |
2039 | scene.add(roof_2roof_obj); | 2064 | scene.add(roof_2roof_obj); |
2040 | 2065 | ||
2041 | 2066 | ||
2042 | //roof2_slice | 2067 | //roof2_slice |
2043 | var _3dxy_roofSlice2 = JSON.parse(JSON.stringify(roof_2roof)); | 2068 | var _3dxy_roofSlice2 = JSON.parse(JSON.stringify(roof_2roof)); |
2044 | var kc = 200; | 2069 | var kc = 200; |
2045 | _3dxy_roofSlice2.height_startpoint = roof_2roof.height_endpoint; | 2070 | _3dxy_roofSlice2.height_startpoint = roof_2roof.height_endpoint; |
2046 | _3dxy_roofSlice2.height_endpoint = roof_2roof.height_endpoint + kc; | 2071 | _3dxy_roofSlice2.height_endpoint = roof_2roof.height_endpoint + kc; |
2047 | var material1 = { | 2072 | var material1 = { |
2048 | 'tex': windowTexture, | 2073 | 'tex': windowTexture, |
2049 | 'transparent': true, | 2074 | 'transparent': true, |
2050 | 'opacity': 0.0001 | 2075 | 'opacity': 0.0001 |
2051 | }; | 2076 | }; |
2052 | roofSlice2 = drawObj(scene, _3dxy_roofSlice2, _3dobject, material1); | 2077 | roofSlice2 = drawObj(scene, _3dxy_roofSlice2, _3dobject, material1); |
2053 | roofSlice2.rotation.x = Math.atan(tan); | 2078 | roofSlice2.rotation.x = Math.atan(tan); |
2054 | roofSlice2.position.y = converMMtoPX(d) + floor3D.height_endpoint - floor3D.height_startpoint + kc / 2; | 2079 | roofSlice2.position.y = converMMtoPX(d) + floor3D.height_endpoint - floor3D.height_startpoint + kc / 2; |
2055 | scene.add(roofSlice2); | 2080 | scene.add(roofSlice2); |
2056 | 2081 | ||
2057 | } else if (type == 103 || type == 104) { | 2082 | } else if (type == 103 || type == 104) { |
2058 | var roof_1roof = JSON.parse(JSON.stringify(_3dxy)); | 2083 | var roof_1roof = JSON.parse(JSON.stringify(_3dxy)); |
2059 | roof_1roof.width_X = roof_1roof.width_X / 2; | 2084 | roof_1roof.width_X = roof_1roof.width_X / 2; |
2060 | //roof1 | 2085 | //roof1 |
2061 | roof_1roof_obj = drawObj(scene, roof_1roof, _3dobject, material); | 2086 | roof_1roof_obj = drawObj(scene, roof_1roof, _3dobject, material); |
2062 | var tan = converMMtoPX(heightRoof) / roof_1roof.width_X; | 2087 | var tan = converMMtoPX(heightRoof) / roof_1roof.width_X; |
2063 | roof_1roof_obj.rotation.z = Math.atan(tan); | 2088 | roof_1roof_obj.rotation.z = Math.atan(tan); |
2064 | var c = 2030 + 300 - tan * roof_1roof.width_X * 2; | 2089 | var c = 2030 + 300 - tan * roof_1roof.width_X * 2; |
2065 | roof_1roof_obj.position.y = converMMtoPX(c) + floor3D.height_endpoint - floor3D.height_startpoint; | 2090 | roof_1roof_obj.position.y = converMMtoPX(c) + floor3D.height_endpoint - floor3D.height_startpoint; |
2066 | drawBeamsRoof(scene, _3dxy, tan, type); | 2091 | drawBeamsRoof(scene, _3dxy, tan, type); |
2067 | scene.add(roof_1roof_obj); | 2092 | scene.add(roof_1roof_obj); |
2068 | //roof1_slice | 2093 | //roof1_slice |
2069 | var _3dxy_roofSlice1 = JSON.parse(JSON.stringify(roof_1roof)); | 2094 | var _3dxy_roofSlice1 = JSON.parse(JSON.stringify(roof_1roof)); |
2070 | var kc = 200; | 2095 | var kc = 200; |
2071 | _3dxy_roofSlice1.height_startpoint = roof_1roof.height_endpoint; | 2096 | _3dxy_roofSlice1.height_startpoint = roof_1roof.height_endpoint; |
2072 | _3dxy_roofSlice1.height_endpoint = roof_1roof.height_endpoint + kc; | 2097 | _3dxy_roofSlice1.height_endpoint = roof_1roof.height_endpoint + kc; |
2073 | var material1 = { | 2098 | var material1 = { |
2074 | 'tex': windowTexture, | 2099 | 'tex': windowTexture, |
2075 | 'transparent': true, | 2100 | 'transparent': true, |
2076 | 'opacity': 0.0001 | 2101 | 'opacity': 0.0001 |
2077 | }; | 2102 | }; |
2078 | roofSlice1 = drawObj(scene, _3dxy_roofSlice1, _3dobject, material1); | 2103 | roofSlice1 = drawObj(scene, _3dxy_roofSlice1, _3dobject, material1); |
2079 | roofSlice1.rotation.z = Math.atan(tan); | 2104 | roofSlice1.rotation.z = Math.atan(tan); |
2080 | roofSlice1.position.y = converMMtoPX(c) + floor3D.height_endpoint - floor3D.height_startpoint + kc / 2; | 2105 | roofSlice1.position.y = converMMtoPX(c) + floor3D.height_endpoint - floor3D.height_startpoint + kc / 2; |
2081 | scene.add(roofSlice1); | 2106 | scene.add(roofSlice1); |
2082 | //roof2 | 2107 | //roof2 |
2083 | 2108 | ||
2084 | var roof_2roof = JSON.parse(JSON.stringify(_3dxy)); | 2109 | var roof_2roof = JSON.parse(JSON.stringify(_3dxy)); |
2085 | 2110 | ||
2086 | // Check is roof cover balcony | 2111 | // Check is roof cover balcony |
2087 | 2112 | ||
2088 | roof_2roof.width_X = roof_2roof.width_X / 2; | 2113 | roof_2roof.width_X = roof_2roof.width_X / 2; |
2089 | 2114 | ||
2090 | roof_2roof.start_X = roof_2roof.start_X + roof_2roof.width_X - converMMtoPX(50); | 2115 | roof_2roof.start_X = roof_2roof.start_X + roof_2roof.width_X - converMMtoPX(50); |
2091 | roof_2roof_obj = drawObj(scene, roof_2roof, _3dobject, material); | 2116 | roof_2roof_obj = drawObj(scene, roof_2roof, _3dobject, material); |
2092 | var tan = converMMtoPX(heightRoof) / roof_1roof.width_X; | 2117 | var tan = converMMtoPX(heightRoof) / roof_1roof.width_X; |
2093 | roof_2roof_obj.rotation.z = -Math.atan(tan); | 2118 | roof_2roof_obj.rotation.z = -Math.atan(tan); |
2094 | 2119 | ||
2095 | var d = 2030 + 300 - tan * roof_2roof.width_X * 2; | 2120 | var d = 2030 + 300 - tan * roof_2roof.width_X * 2; |
2096 | // console.log(c); | 2121 | // console.log(c); |
2097 | roof_2roof_obj.position.y = converMMtoPX(d) + floor3D.height_endpoint - floor3D.height_startpoint; | 2122 | roof_2roof_obj.position.y = converMMtoPX(d) + floor3D.height_endpoint - floor3D.height_startpoint; |
2098 | drawBeamsRoof(scene, _3dxy, tan, type); | 2123 | drawBeamsRoof(scene, _3dxy, tan, type); |
2099 | scene.add(roof_2roof_obj); | 2124 | scene.add(roof_2roof_obj); |
2100 | 2125 | ||
2101 | 2126 | ||
2102 | //roof2_slice | 2127 | //roof2_slice |
2103 | var _3dxy_roofSlice2 = JSON.parse(JSON.stringify(roof_2roof)); | 2128 | var _3dxy_roofSlice2 = JSON.parse(JSON.stringify(roof_2roof)); |
2104 | var kc = 200; | 2129 | var kc = 200; |
2105 | _3dxy_roofSlice2.height_startpoint = roof_2roof.height_endpoint; | 2130 | _3dxy_roofSlice2.height_startpoint = roof_2roof.height_endpoint; |
2106 | _3dxy_roofSlice2.height_endpoint = roof_2roof.height_endpoint + kc; | 2131 | _3dxy_roofSlice2.height_endpoint = roof_2roof.height_endpoint + kc; |
2107 | var material1 = { | 2132 | var material1 = { |
2108 | 'tex': windowTexture, | 2133 | 'tex': windowTexture, |
2109 | 'transparent': true, | 2134 | 'transparent': true, |
2110 | 'opacity': 0.0001 | 2135 | 'opacity': 0.0001 |
2111 | }; | 2136 | }; |
2112 | roofSlice2 = drawObj(scene, _3dxy_roofSlice2, _3dobject, material1); | 2137 | roofSlice2 = drawObj(scene, _3dxy_roofSlice2, _3dobject, material1); |
2113 | roofSlice2.rotation.z = -Math.atan(tan); | 2138 | roofSlice2.rotation.z = -Math.atan(tan); |
2114 | roofSlice2.position.y = converMMtoPX(d) + floor3D.height_endpoint - floor3D.height_startpoint + kc / 2; | 2139 | roofSlice2.position.y = converMMtoPX(d) + floor3D.height_endpoint - floor3D.height_startpoint + kc / 2; |
2115 | scene.add(roofSlice2); | 2140 | scene.add(roofSlice2); |
2116 | } | 2141 | } |
2117 | 2142 | ||
2118 | } | 2143 | } |
2119 | } | 2144 | } |
2120 | function drawBeamsRoof(scene, _3dxy, tan, type, typeRoof) { | 2145 | function drawBeamsRoof(scene, _3dxy, tan, type, typeRoof) { |
2121 | var width_beam1 = 90; | 2146 | var width_beam1 = 90; |
2122 | var height_beam1 = 90; | 2147 | var height_beam1 = 90; |
2123 | if (typeRoof == 'roof-2') { | 2148 | if (typeRoof == 'roof-2') { |
2124 | if (type == 101 || type == 102) { | 2149 | if (type == 101 || type == 102) { |
2125 | var height_startpoint = converMMtoPX(2030 + 300) + floor3D.height_endpoint - tan * (_3dxy.width_Y - converMMtoPX(250 * 2) + converMMtoPX(width_beam1)); | 2150 | var height_startpoint = converMMtoPX(2030 + 300) + floor3D.height_endpoint - tan * (_3dxy.width_Y - converMMtoPX(250 * 2) + converMMtoPX(width_beam1)); |
2126 | } else { | 2151 | } else { |
2127 | var height_startpoint = converMMtoPX(2030 + 300) + floor3D.height_endpoint - tan * (_3dxy.width_X - converMMtoPX(250 * 2) + converMMtoPX(width_beam1)); | 2152 | var height_startpoint = converMMtoPX(2030 + 300) + floor3D.height_endpoint - tan * (_3dxy.width_X - converMMtoPX(250 * 2) + converMMtoPX(width_beam1)); |
2128 | 2153 | ||
2129 | } | 2154 | } |
2130 | } else { | 2155 | } else { |
2131 | if (type == 101 || type == 102) { | 2156 | if (type == 101 || type == 102) { |
2132 | var height_startpoint = converMMtoPX(2030 + 300) + floor3D.height_endpoint - tan * (_3dxy.width_X / 2 + converMMtoPX(width_beam1 * 2)) - converMMtoPX(50); | 2157 | var height_startpoint = converMMtoPX(2030 + 300) + floor3D.height_endpoint - tan * (_3dxy.width_X / 2 + converMMtoPX(width_beam1 * 2)) - converMMtoPX(50); |
2133 | 2158 | ||
2134 | } else { | 2159 | } else { |
2135 | var height_startpoint = converMMtoPX(2030 + 300) + floor3D.height_endpoint - tan * (_3dxy.width_Y / 2 + converMMtoPX(width_beam1 * 2)) - converMMtoPX(50); | 2160 | var height_startpoint = converMMtoPX(2030 + 300) + floor3D.height_endpoint - tan * (_3dxy.width_Y / 2 + converMMtoPX(width_beam1 * 2)) - converMMtoPX(50); |
2136 | } | 2161 | } |
2137 | 2162 | ||
2138 | } | 2163 | } |
2139 | height_startpoint = height_startpoint - converMMtoPX(20); | 2164 | height_startpoint = height_startpoint - converMMtoPX(20); |
2140 | // beam 1 | 2165 | // beam 1 |
2141 | var beam1 = JSON.parse(JSON.stringify(_3dxy)); | 2166 | var beam1 = JSON.parse(JSON.stringify(_3dxy)); |
2142 | beam1.start_X = beam1.start_X + converMMtoPX(250); | 2167 | beam1.start_X = beam1.start_X + converMMtoPX(250); |
2143 | beam1.start_Y = beam1.start_Y + converMMtoPX(250); | 2168 | beam1.start_Y = beam1.start_Y + converMMtoPX(250); |
2144 | beam1.width_X = converMMtoPX(width_beam1); | 2169 | beam1.width_X = converMMtoPX(width_beam1); |
2145 | beam1.width_Y = beam1.width_Y - converMMtoPX(250 * 2); | 2170 | beam1.width_Y = beam1.width_Y - converMMtoPX(250 * 2); |
2146 | beam1.height_startpoint = height_startpoint; | 2171 | beam1.height_startpoint = height_startpoint; |
2147 | beam1.height_endpoint = beam1.height_startpoint + converMMtoPX(width_beam1); | 2172 | beam1.height_endpoint = beam1.height_startpoint + converMMtoPX(width_beam1); |
2148 | var materialBeams = { | 2173 | var materialBeams = { |
2149 | 'tex': wallTexture | 2174 | 'tex': wallTexture |
2150 | }; | 2175 | }; |
2151 | var beam1_3D = drawObj(scene, beam1, null, materialBeams); | 2176 | var beam1_3D = drawObj(scene, beam1, null, materialBeams); |
2152 | scene.add(beam1_3D); | 2177 | scene.add(beam1_3D); |
2153 | // beam 2 | 2178 | // beam 2 |
2154 | var beam2 = JSON.parse(JSON.stringify(_3dxy)); | 2179 | var beam2 = JSON.parse(JSON.stringify(_3dxy)); |
2155 | beam2.start_X = beam2.start_X + converMMtoPX(250); | 2180 | beam2.start_X = beam2.start_X + converMMtoPX(250); |
2156 | beam2.start_Y = beam2.start_Y + converMMtoPX(250); | 2181 | beam2.start_Y = beam2.start_Y + converMMtoPX(250); |
2157 | beam2.width_Y = converMMtoPX(width_beam1); | 2182 | beam2.width_Y = converMMtoPX(width_beam1); |
2158 | beam2.width_X = beam2.width_X - converMMtoPX(250 * 2); | 2183 | beam2.width_X = beam2.width_X - converMMtoPX(250 * 2); |
2159 | beam2.height_startpoint = height_startpoint; | 2184 | beam2.height_startpoint = height_startpoint; |
2160 | beam2.height_endpoint = beam2.height_startpoint + converMMtoPX(width_beam1); | 2185 | beam2.height_endpoint = beam2.height_startpoint + converMMtoPX(width_beam1); |
2161 | var materialBeams = { | 2186 | var materialBeams = { |
2162 | 'tex': wallTexture | 2187 | 'tex': wallTexture |
2163 | }; | 2188 | }; |
2164 | var beam2_3D = drawObj(scene, beam2, null, materialBeams); | 2189 | var beam2_3D = drawObj(scene, beam2, null, materialBeams); |
2165 | scene.add(beam2_3D); | 2190 | scene.add(beam2_3D); |
2166 | 2191 | ||
2167 | // beam 3 | 2192 | // beam 3 |
2168 | var beam3 = JSON.parse(JSON.stringify(_3dxy)); | 2193 | var beam3 = JSON.parse(JSON.stringify(_3dxy)); |
2169 | beam3.start_X = beam1.start_X + beam2.width_X - converMMtoPX(width_beam1); | 2194 | beam3.start_X = beam1.start_X + beam2.width_X - converMMtoPX(width_beam1); |
2170 | beam3.start_Y = beam3.start_Y + converMMtoPX(250); | 2195 | beam3.start_Y = beam3.start_Y + converMMtoPX(250); |
2171 | beam3.width_X = converMMtoPX(width_beam1); | 2196 | beam3.width_X = converMMtoPX(width_beam1); |
2172 | beam3.width_Y = beam3.width_Y - converMMtoPX(250 * 2); | 2197 | beam3.width_Y = beam3.width_Y - converMMtoPX(250 * 2); |
2173 | beam3.height_startpoint = height_startpoint; | 2198 | beam3.height_startpoint = height_startpoint; |
2174 | beam3.height_endpoint = beam3.height_startpoint + converMMtoPX(width_beam1); | 2199 | beam3.height_endpoint = beam3.height_startpoint + converMMtoPX(width_beam1); |
2175 | var materialBeams = { | 2200 | var materialBeams = { |
2176 | 'tex': wallTexture | 2201 | 'tex': wallTexture |
2177 | }; | 2202 | }; |
2178 | var beam3_3D = drawObj(scene, beam3, null, materialBeams); | 2203 | var beam3_3D = drawObj(scene, beam3, null, materialBeams); |
2179 | scene.add(beam3_3D); | 2204 | scene.add(beam3_3D); |
2180 | 2205 | ||
2181 | // beam 4 | 2206 | // beam 4 |
2182 | var beam4 = JSON.parse(JSON.stringify(_3dxy)); | 2207 | var beam4 = JSON.parse(JSON.stringify(_3dxy)); |
2183 | beam4.start_X = beam4.start_X + converMMtoPX(250); | 2208 | beam4.start_X = beam4.start_X + converMMtoPX(250); |
2184 | beam4.start_Y = beam2.start_Y + beam1.width_Y - converMMtoPX(width_beam1); | 2209 | beam4.start_Y = beam2.start_Y + beam1.width_Y - converMMtoPX(width_beam1); |
2185 | beam4.width_Y = converMMtoPX(width_beam1); | 2210 | beam4.width_Y = converMMtoPX(width_beam1); |
2186 | beam4.width_X = beam4.width_X - converMMtoPX(250 * 2); | 2211 | beam4.width_X = beam4.width_X - converMMtoPX(250 * 2); |
2187 | beam4.height_startpoint = height_startpoint; | 2212 | beam4.height_startpoint = height_startpoint; |
2188 | beam4.height_endpoint = beam4.height_startpoint + converMMtoPX(width_beam1); | 2213 | beam4.height_endpoint = beam4.height_startpoint + converMMtoPX(width_beam1); |
2189 | var materialBeams = { | 2214 | var materialBeams = { |
2190 | 'tex': wallTexture | 2215 | 'tex': wallTexture |
2191 | }; | 2216 | }; |
2192 | var beam4_3D = drawObj(scene, beam4, null, materialBeams); | 2217 | var beam4_3D = drawObj(scene, beam4, null, materialBeams); |
2193 | scene.add(beam4_3D); | 2218 | scene.add(beam4_3D); |
2194 | 2219 | ||
2195 | } | 2220 | } |
2196 | de2ra = function (degree) { | 2221 | de2ra = function (degree) { |
2197 | return degree * (Math.PI / 180); | 2222 | return degree * (Math.PI / 180); |
2198 | }; | 2223 | }; |
2199 | 2224 | ||
2200 | // wall color attribute name immage | 2225 | // wall color attribute name immage |
2201 | var wallColor = [ | 2226 | var wallColor = [ |
2202 | ["wall_S5-3500", "S5-3500 ใชใผใฏ", "wall_S5-3500"], // 9b7e6c oak/gแป sแปi | 2227 | ["wall_S5-3500", "S5-3500 ใชใผใฏ", "wall_S5-3500"], // 9b7e6c oak/gแป sแปi |
2203 | ["wall_S5-3700", "S5-3700 ใใผใฏ", "wall_S5-3700"], // cea27b teak/mร u gแป tแบฟch | 2228 | ["wall_S5-3700", "S5-3700 ใใผใฏ", "wall_S5-3700"], // cea27b teak/mร u gแป tแบฟch |
2204 | ["wall_S5-4900", "S5-4900 ใกใคใบ", "wall_S5-4900"], // d9bf51 maize/vร ng nhแบกt | 2229 | ["wall_S5-4900", "S5-4900 ใกใคใบ", "wall_S5-4900"], // d9bf51 maize/vร ng nhแบกt |
2205 | ["wall_S5-5900", "S5-5900 ้ป", "wall_S5-5900"] // 3d3d41 ฤen | 2230 | ["wall_S5-5900", "S5-5900 ้ป", "wall_S5-5900"] // 3d3d41 ฤen |
2206 | ]; | 2231 | ]; |
2207 | 2232 | ||
2208 | //function updateColor() | 2233 | //function updateColor() |
2209 | //{ | 2234 | //{ |
2210 | // | 2235 | // |
2211 | // var selectColor = document.getElementById('wall_option').selectedIndex; | 2236 | // var selectColor = document.getElementById('wall_option').selectedIndex; |
2212 | // | 2237 | // |
2213 | // wallPaintTexture = new loader.load('images/'+ wallColor[selectColor][2] + '.PNG'); | 2238 | // wallPaintTexture = new loader.load('images/'+ wallColor[selectColor][2] + '.PNG'); |
2214 | // wallPaintTexture.wrapT = THREE.RepeatWrapping; | 2239 | // wallPaintTexture.wrapT = THREE.RepeatWrapping; |
2215 | // wallPaintTexture.repeat.set(5, 5); | 2240 | // wallPaintTexture.repeat.set(5, 5); |
2216 | // | 2241 | // |
2217 | // // Create an array of materials to be used in a cube, one for each side | 2242 | // // Create an array of materials to be used in a cube, one for each side |
2218 | // var cubeMaterialArray = []; | 2243 | // var cubeMaterialArray = []; |
2219 | // | 2244 | // |
2220 | // cubeMaterialArray.push(new THREE.MeshBasicMaterial({ | 2245 | // cubeMaterialArray.push(new THREE.MeshBasicMaterial({ |
2221 | // map: wallPaintTexture, | 2246 | // map: wallPaintTexture, |
2222 | // side: THREE.DoubleSide, | 2247 | // side: THREE.DoubleSide, |
2223 | // transparent: material.transparent, | 2248 | // transparent: material.transparent, |
2224 | // opacity: material.opacity | 2249 | // opacity: material.opacity |
2225 | // })); | 2250 | // })); |
2226 | // cubeMaterialArray.push(new THREE.MeshBasicMaterial({ | 2251 | // cubeMaterialArray.push(new THREE.MeshBasicMaterial({ |
2227 | // map: wallPaintTexture, | 2252 | // map: wallPaintTexture, |
2228 | // side: THREE.DoubleSide, | 2253 | // side: THREE.DoubleSide, |
2229 | // transparent: material.transparent, | 2254 | // transparent: material.transparent, |
2230 | // opacity: material.opacity | 2255 | // opacity: material.opacity |
2231 | // })); | 2256 | // })); |
2232 | // cubeMaterialArray.push(new THREE.MeshBasicMaterial({ | 2257 | // cubeMaterialArray.push(new THREE.MeshBasicMaterial({ |
2233 | // map: wallPaintTexture, | 2258 | // map: wallPaintTexture, |
2234 | // side: THREE.DoubleSide, | 2259 | // side: THREE.DoubleSide, |
2235 | // transparent: material.transparent, | 2260 | // transparent: material.transparent, |
2236 | // opacity: material.opacity | 2261 | // opacity: material.opacity |
2237 | // })); | 2262 | // })); |
2238 | // cubeMaterialArray.push(new THREE.MeshBasicMaterial({ | 2263 | // cubeMaterialArray.push(new THREE.MeshBasicMaterial({ |
2239 | // map: wallPaintTexture, | 2264 | // map: wallPaintTexture, |
2240 | // side: THREE.DoubleSide, | 2265 | // side: THREE.DoubleSide, |
2241 | // transparent: material.transparent, | 2266 | // transparent: material.transparent, |
2242 | // opacity: material.opacity | 2267 | // opacity: material.opacity |
2243 | // })); | 2268 | // })); |
2244 | // cubeMaterialArray.push(new THREE.MeshBasicMaterial({ | 2269 | // cubeMaterialArray.push(new THREE.MeshBasicMaterial({ |
2245 | // map: wallPaintTexture, | 2270 | // map: wallPaintTexture, |
2246 | // side: THREE.DoubleSide, | 2271 | // side: THREE.DoubleSide, |
2247 | // transparent: material.transparent, | 2272 | // transparent: material.transparent, |
2248 | // opacity: material.opacity | 2273 | // opacity: material.opacity |
2249 | // })); | 2274 | // })); |
2250 | // cubeMaterialArray.push(new THREE.MeshBasicMaterial({ | 2275 | // cubeMaterialArray.push(new THREE.MeshBasicMaterial({ |
2251 | // map: wallPaintTexture, | 2276 | // map: wallPaintTexture, |
2252 | // side: THREE.DoubleSide, | 2277 | // side: THREE.DoubleSide, |
2253 | // transparent: material.transparent, | 2278 | // transparent: material.transparent, |
2254 | // opacity: material.opacity | 2279 | // opacity: material.opacity |
2255 | // })); | 2280 | // })); |
2256 | // var cubeMaterials = new THREE.MeshFaceMaterial(cubeMaterialArray); | 2281 | // var cubeMaterials = new THREE.MeshFaceMaterial(cubeMaterialArray); |
2257 | // for ( var i = 0; i < handrailObj.length; i++) | 2282 | // for ( var i = 0; i < handrailObj.length; i++) |
2258 | // { | 2283 | // { |
2259 | // handrailObj[i].material = new THREE.MeshFaceMaterial(cubeMaterialArray); | 2284 | // handrailObj[i].material = new THREE.MeshFaceMaterial(cubeMaterialArray); |
2260 | // handrailObj[i].material.map.needsUpdate = true; | 2285 | // handrailObj[i].material.map.needsUpdate = true; |
2261 | // } | 2286 | // } |
2262 | // | 2287 | // |
2263 | //} | 2288 | //} |
2264 | 2289 | ||
2265 | function drawBeamUnderFloor(scene) { | 2290 | function drawBeamUnderFloor(scene) { |
2266 | var type; | 2291 | var type; |
2267 | if (baconInfo) { | 2292 | if (baconInfo) { |
2268 | if (floorInfo[2][0] == baconInfo[2][0]) { | 2293 | if (floorInfo[2][0] == baconInfo[2][0]) { |
2269 | if (floorInfo[2][1] < baconInfo[2][1]) { | 2294 | if (floorInfo[2][1] < baconInfo[2][1]) { |
2270 | type = 1; | 2295 | type = 1; |
2271 | var start_X = floorInfo[2][0]; | 2296 | var start_X = floorInfo[2][0]; |
2272 | var start_Y = floorInfo[2][1]; | 2297 | var start_Y = floorInfo[2][1]; |
2273 | } else { | 2298 | } else { |
2274 | type = 2; | 2299 | type = 2; |
2275 | var start_X = baconInfo[2][0]; | 2300 | var start_X = baconInfo[2][0]; |
2276 | var start_Y = baconInfo[2][1]; | 2301 | var start_Y = baconInfo[2][1]; |
2277 | } | 2302 | } |
2278 | var width = floorInfo[2][2]; | 2303 | var width = floorInfo[2][2]; |
2279 | var height = floorInfo[2][3] + baconInfo[2][3]; | 2304 | var height = floorInfo[2][3] + baconInfo[2][3]; |
2280 | 2305 | ||
2281 | } | 2306 | } |
2282 | if (floorInfo[2][1] == baconInfo[2][1]) { | 2307 | if (floorInfo[2][1] == baconInfo[2][1]) { |
2283 | if (floorInfo[2][0] < baconInfo[2][0]) { | 2308 | if (floorInfo[2][0] < baconInfo[2][0]) { |
2284 | type = 3; | 2309 | type = 3; |
2285 | var start_X = floorInfo[2][0]; | 2310 | var start_X = floorInfo[2][0]; |
2286 | var start_Y = floorInfo[2][1]; | 2311 | var start_Y = floorInfo[2][1]; |
2287 | } else { | 2312 | } else { |
2288 | type = 4; | 2313 | type = 4; |
2289 | var start_X = baconInfo[2][0]; | 2314 | var start_X = baconInfo[2][0]; |
2290 | var start_Y = baconInfo[2][1]; | 2315 | var start_Y = baconInfo[2][1]; |
2291 | } | 2316 | } |
2292 | var width = floorInfo[2][2] + baconInfo[2][2]; | 2317 | var width = floorInfo[2][2] + baconInfo[2][2]; |
2293 | var height = floorInfo[2][3]; | 2318 | var height = floorInfo[2][3]; |
2294 | } | 2319 | } |
2295 | 2320 | ||
2296 | } else { | 2321 | } else { |
2297 | type = 1; | 2322 | type = 1; |
2298 | var width = floorInfo[2][2]; | 2323 | var width = floorInfo[2][2]; |
2299 | var height = floorInfo[2][3]; | 2324 | var height = floorInfo[2][3]; |
2300 | var start_X = floorInfo[2][0]; | 2325 | var start_X = floorInfo[2][0]; |
2301 | var start_Y = floorInfo[2][1]; | 2326 | var start_Y = floorInfo[2][1]; |
2302 | } | 2327 | } |
2303 | var material_beamUF = { | 2328 | var material_beamUF = { |
2304 | 'tex': wallTexture, | 2329 | 'tex': wallTexture, |
2305 | }; | 2330 | }; |
2306 | //if (type == 1 || type == 2) { | 2331 | //if (type == 1 || type == 2) { |
2307 | // | 2332 | // |
2308 | if (width < 2730) { | 2333 | if (width < 2730) { |
2309 | var dxy_1 = { | 2334 | var dxy_1 = { |
2310 | 'start_X': converMMtoPX(start_X), | 2335 | 'start_X': converMMtoPX(start_X), |
2311 | 'start_Y': converMMtoPX(start_Y - 30), | 2336 | 'start_Y': converMMtoPX(start_Y - 30), |
2312 | 'width_X': converMMtoPX(90), | 2337 | 'width_X': converMMtoPX(90), |
2313 | 'width_Y': converMMtoPX(height), | 2338 | 'width_Y': converMMtoPX(height), |
2314 | 'height_startpoint': converMMtoPX(-180), | 2339 | 'height_startpoint': converMMtoPX(-180), |
2315 | 'height_endpoint': converMMtoPX(-90) | 2340 | 'height_endpoint': converMMtoPX(-90) |
2316 | }; | 2341 | }; |
2317 | var beamUF_1 = drawObj(scene, dxy_1, null, material_beamUF); | 2342 | var beamUF_1 = drawObj(scene, dxy_1, null, material_beamUF); |
2318 | scene.add(beamUF_1); | 2343 | scene.add(beamUF_1); |
2319 | 2344 | ||
2320 | var dxy_2 = { | 2345 | var dxy_2 = { |
2321 | 'start_X': converMMtoPX(start_X + width - 90), | 2346 | 'start_X': converMMtoPX(start_X + width - 90), |
2322 | 'start_Y': converMMtoPX(start_Y - 30), | 2347 | 'start_Y': converMMtoPX(start_Y - 30), |
2323 | 'width_X': converMMtoPX(90), | 2348 | 'width_X': converMMtoPX(90), |
2324 | 'width_Y': converMMtoPX(height + 60), | 2349 | 'width_Y': converMMtoPX(height + 60), |
2325 | 'height_startpoint': converMMtoPX(-180), | 2350 | 'height_startpoint': converMMtoPX(-180), |
2326 | 'height_endpoint': converMMtoPX(-90) | 2351 | 'height_endpoint': converMMtoPX(-90) |
2327 | }; | 2352 | }; |
2328 | var beamUF_2 = drawObj(scene, dxy_2, null, material_beamUF); | 2353 | var beamUF_2 = drawObj(scene, dxy_2, null, material_beamUF); |
2329 | scene.add(beamUF_2); | 2354 | scene.add(beamUF_2); |
2330 | } | 2355 | } |
2331 | if (width >= 2730 && width < 3640) { | 2356 | if (width >= 2730 && width < 3640) { |
2332 | var dxy_1 = { | 2357 | var dxy_1 = { |
2333 | 'start_X': converMMtoPX(start_X + 275), | 2358 | 'start_X': converMMtoPX(start_X + 275), |
2334 | 'start_Y': converMMtoPX(start_Y - 30), | 2359 | 'start_Y': converMMtoPX(start_Y - 30), |
2335 | 'width_X': converMMtoPX(90), | 2360 | 'width_X': converMMtoPX(90), |
2336 | 'width_Y': converMMtoPX(height + 60), | 2361 | 'width_Y': converMMtoPX(height + 60), |
2337 | 'height_startpoint': converMMtoPX(-180), | 2362 | 'height_startpoint': converMMtoPX(-180), |
2338 | 'height_endpoint': converMMtoPX(-90) | 2363 | 'height_endpoint': converMMtoPX(-90) |
2339 | }; | 2364 | }; |
2340 | var beamUF_1 = drawObj(scene, dxy_1, null, material_beamUF); | 2365 | var beamUF_1 = drawObj(scene, dxy_1, null, material_beamUF); |
2341 | scene.add(beamUF_1); | 2366 | scene.add(beamUF_1); |
2342 | 2367 | ||
2343 | var dxy_2 = { | 2368 | var dxy_2 = { |
2344 | 'start_X': converMMtoPX(start_X + width - 90 - 275), | 2369 | 'start_X': converMMtoPX(start_X + width - 90 - 275), |
2345 | 'start_Y': converMMtoPX(start_Y - 30), | 2370 | 'start_Y': converMMtoPX(start_Y - 30), |
2346 | 'width_X': converMMtoPX(90), | 2371 | 'width_X': converMMtoPX(90), |
2347 | 'width_Y': converMMtoPX(height + 60), | 2372 | 'width_Y': converMMtoPX(height + 60), |
2348 | 'height_startpoint': converMMtoPX(-180), | 2373 | 'height_startpoint': converMMtoPX(-180), |
2349 | 'height_endpoint': converMMtoPX(-90) | 2374 | 'height_endpoint': converMMtoPX(-90) |
2350 | }; | 2375 | }; |
2351 | var beamUF_2 = drawObj(scene, dxy_2, null, material_beamUF); | 2376 | var beamUF_2 = drawObj(scene, dxy_2, null, material_beamUF); |
2352 | scene.add(beamUF_2); | 2377 | scene.add(beamUF_2); |
2353 | } | 2378 | } |
2354 | if (width >= 3640 && width < 4550) { | 2379 | if (width >= 3640 && width < 4550) { |
2355 | var dxy_1 = { | 2380 | var dxy_1 = { |
2356 | 'start_X': converMMtoPX(start_X + 420), | 2381 | 'start_X': converMMtoPX(start_X + 420), |
2357 | 'start_Y': converMMtoPX(start_Y - 30), | 2382 | 'start_Y': converMMtoPX(start_Y - 30), |
2358 | 'width_X': converMMtoPX(90), | 2383 | 'width_X': converMMtoPX(90), |
2359 | 'width_Y': converMMtoPX(height + 60), | 2384 | 'width_Y': converMMtoPX(height + 60), |
2360 | 'height_startpoint': converMMtoPX(-180), | 2385 | 'height_startpoint': converMMtoPX(-180), |
2361 | 'height_endpoint': converMMtoPX(-90) | 2386 | 'height_endpoint': converMMtoPX(-90) |
2362 | }; | 2387 | }; |
2363 | var beamUF_1 = drawObj(scene, dxy_1, null, material_beamUF); | 2388 | var beamUF_1 = drawObj(scene, dxy_1, null, material_beamUF); |
2364 | scene.add(beamUF_1); | 2389 | scene.add(beamUF_1); |
2365 | 2390 | ||
2366 | var dxy_2 = { | 2391 | var dxy_2 = { |
2367 | 'start_X': converMMtoPX(start_X + width - 90 - 420), | 2392 | 'start_X': converMMtoPX(start_X + width - 90 - 420), |
2368 | 'start_Y': converMMtoPX(start_Y - 30), | 2393 | 'start_Y': converMMtoPX(start_Y - 30), |
2369 | 'width_X': converMMtoPX(90), | 2394 | 'width_X': converMMtoPX(90), |
2370 | 'width_Y': converMMtoPX(height + 60), | 2395 | 'width_Y': converMMtoPX(height + 60), |
2371 | 'height_startpoint': converMMtoPX(-180), | 2396 | 'height_startpoint': converMMtoPX(-180), |
2372 | 'height_endpoint': converMMtoPX(-90) | 2397 | 'height_endpoint': converMMtoPX(-90) |
2373 | }; | 2398 | }; |
2374 | var beamUF_2 = drawObj(scene, dxy_2, null, material_beamUF); | 2399 | var beamUF_2 = drawObj(scene, dxy_2, null, material_beamUF); |
2375 | scene.add(beamUF_2); | 2400 | scene.add(beamUF_2); |
2376 | } | 2401 | } |
2377 | if (width >= 4550) { | 2402 | if (width >= 4550) { |
2378 | var dxy_1 = { | 2403 | var dxy_1 = { |
2379 | 'start_X': converMMtoPX(start_X + 420), | 2404 | 'start_X': converMMtoPX(start_X + 420), |
2380 | 'start_Y': converMMtoPX(start_Y - 30), | 2405 | 'start_Y': converMMtoPX(start_Y - 30), |
2381 | 'width_X': converMMtoPX(90), | 2406 | 'width_X': converMMtoPX(90), |
2382 | 'width_Y': converMMtoPX(height + 60), | 2407 | 'width_Y': converMMtoPX(height + 60), |
2383 | 'height_startpoint': converMMtoPX(-180), | 2408 | 'height_startpoint': converMMtoPX(-180), |
2384 | 'height_endpoint': converMMtoPX(-90) | 2409 | 'height_endpoint': converMMtoPX(-90) |
2385 | }; | 2410 | }; |
2386 | var beamUF_1 = drawObj(scene, dxy_1, null, material_beamUF); | 2411 | var beamUF_1 = drawObj(scene, dxy_1, null, material_beamUF); |
2387 | scene.add(beamUF_1); | 2412 | scene.add(beamUF_1); |
2388 | 2413 | ||
2389 | var dxy_2 = { | 2414 | var dxy_2 = { |
2390 | 'start_X': converMMtoPX(start_X + width - 90 - 420), | 2415 | 'start_X': converMMtoPX(start_X + width - 90 - 420), |
2391 | 'start_Y': converMMtoPX(start_Y - 30), | 2416 | 'start_Y': converMMtoPX(start_Y - 30), |
2392 | 'width_X': converMMtoPX(90), | 2417 | 'width_X': converMMtoPX(90), |
2393 | 'width_Y': converMMtoPX(height + 60), | 2418 | 'width_Y': converMMtoPX(height + 60), |
2394 | 'height_startpoint': converMMtoPX(-180), | 2419 | 'height_startpoint': converMMtoPX(-180), |
2395 | 'height_endpoint': converMMtoPX(-90) | 2420 | 'height_endpoint': converMMtoPX(-90) |
2396 | }; | 2421 | }; |
2397 | var beamUF_2 = drawObj(scene, dxy_2, null, material_beamUF); | 2422 | var beamUF_2 = drawObj(scene, dxy_2, null, material_beamUF); |
2398 | scene.add(beamUF_2); | 2423 | scene.add(beamUF_2); |
2399 | var dxy_3 = { | 2424 | var dxy_3 = { |
2400 | 'start_X': converMMtoPX(width + height + 90) / 2, | 2425 | 'start_X': converMMtoPX(width + height + 90) / 2, |
2401 | 'start_Y': converMMtoPX(start_Y - 30), | 2426 | 'start_Y': converMMtoPX(start_Y - 30), |
2402 | 'width_X': converMMtoPX(90), | 2427 | 'width_X': converMMtoPX(90), |
2403 | 'width_Y': converMMtoPX(height + 60), | 2428 | 'width_Y': converMMtoPX(height + 60), |
2404 | 'height_startpoint': converMMtoPX(-180), | 2429 | 'height_startpoint': converMMtoPX(-180), |
2405 | 'height_endpoint': converMMtoPX(-90) | 2430 | 'height_endpoint': converMMtoPX(-90) |
2406 | }; | 2431 | }; |
2407 | var beamUF_3 = drawObj(scene, dxy_3, null, material_beamUF); | 2432 | var beamUF_3 = drawObj(scene, dxy_3, null, material_beamUF); |
2408 | scene.add(beamUF_3); | 2433 | scene.add(beamUF_3); |
2409 | } | 2434 | } |
2410 | // | 2435 | // |
2411 | var dxy_h_1 = { | 2436 | var dxy_h_1 = { |
2412 | 'start_X': converMMtoPX(start_X - 30), | 2437 | 'start_X': converMMtoPX(start_X - 30), |
2413 | 'start_Y': converMMtoPX(start_Y - 45), | 2438 | 'start_Y': converMMtoPX(start_Y - 45), |
2414 | 'width_X': converMMtoPX(width + 60), | 2439 | 'width_X': converMMtoPX(width + 60), |
2415 | 'width_Y': converMMtoPX(90), | 2440 | 'width_Y': converMMtoPX(90), |
2416 | 'height_startpoint': converMMtoPX(-90), | 2441 | 'height_startpoint': converMMtoPX(-90), |
2417 | 'height_endpoint': converMMtoPX(0) | 2442 | 'height_endpoint': converMMtoPX(0) |
2418 | }; | 2443 | }; |
2419 | var beamUF_h_1 = drawObj(scene, dxy_h_1, null, material_beamUF); | 2444 | var beamUF_h_1 = drawObj(scene, dxy_h_1, null, material_beamUF); |
2420 | scene.add(beamUF_h_1); | 2445 | scene.add(beamUF_h_1); |
2421 | var dxy_h_2 = { | 2446 | var dxy_h_2 = { |
2422 | 'start_X': converMMtoPX(start_X - 30), | 2447 | 'start_X': converMMtoPX(start_X - 30), |
2423 | 'start_Y': converMMtoPX(start_Y + height - 45), | 2448 | 'start_Y': converMMtoPX(start_Y + height - 45), |
2424 | 'width_X': converMMtoPX(width + 60), | 2449 | 'width_X': converMMtoPX(width + 60), |
2425 | 'width_Y': converMMtoPX(90), | 2450 | 'width_Y': converMMtoPX(90), |
2426 | 'height_startpoint': converMMtoPX(-90), | 2451 | 'height_startpoint': converMMtoPX(-90), |
2427 | 'height_endpoint': converMMtoPX(0) | 2452 | 'height_endpoint': converMMtoPX(0) |
2428 | }; | 2453 | }; |
2429 | var beamUF_h_2 = drawObj(scene, dxy_h_2, null, material_beamUF); | 2454 | var beamUF_h_2 = drawObj(scene, dxy_h_2, null, material_beamUF); |
2430 | scene.add(beamUF_h_2); | 2455 | scene.add(beamUF_h_2); |
2431 | if (height >= 3640 && height < 5915) { | 2456 | if (height >= 3640 && height < 5915) { |
2432 | var dxy_h_3 = { | 2457 | var dxy_h_3 = { |
2433 | 'start_X': converMMtoPX(start_X - 30), | 2458 | 'start_X': converMMtoPX(start_X - 30), |
2434 | 'start_Y': converMMtoPX(start_Y + height / 2 - 45), | 2459 | 'start_Y': converMMtoPX(start_Y + height / 2 - 45), |
2435 | 'width_X': converMMtoPX(width + 60), | 2460 | 'width_X': converMMtoPX(width + 60), |
2436 | 'width_Y': converMMtoPX(90), | 2461 | 'width_Y': converMMtoPX(90), |
2437 | 'height_startpoint': converMMtoPX(-90), | 2462 | 'height_startpoint': converMMtoPX(-90), |
2438 | 'height_endpoint': converMMtoPX(0) | 2463 | 'height_endpoint': converMMtoPX(0) |
2439 | }; | 2464 | }; |
2440 | var beamUF_h_3 = drawObj(scene, dxy_h_3, null, material_beamUF); | 2465 | var beamUF_h_3 = drawObj(scene, dxy_h_3, null, material_beamUF); |
2441 | scene.add(beamUF_h_3); | 2466 | scene.add(beamUF_h_3); |
2442 | } | 2467 | } |
2443 | if (height >= 5915) { | 2468 | if (height >= 5915) { |
2444 | var dxy_h_3 = { | 2469 | var dxy_h_3 = { |
2445 | 'start_X': converMMtoPX(start_X - 30), | 2470 | 'start_X': converMMtoPX(start_X - 30), |
2446 | 'start_Y': converMMtoPX(start_Y + height / 3 - 45), | 2471 | 'start_Y': converMMtoPX(start_Y + height / 3 - 45), |
2447 | 'width_X': converMMtoPX(width + 60), | 2472 | 'width_X': converMMtoPX(width + 60), |
2448 | 'width_Y': converMMtoPX(90), | 2473 | 'width_Y': converMMtoPX(90), |
2449 | 'height_startpoint': converMMtoPX(-90), | 2474 | 'height_startpoint': converMMtoPX(-90), |
2450 | 'height_endpoint': converMMtoPX(0) | 2475 | 'height_endpoint': converMMtoPX(0) |
2451 | }; | 2476 | }; |
2452 | var beamUF_h_3 = drawObj(scene, dxy_h_3, null, material_beamUF); | 2477 | var beamUF_h_3 = drawObj(scene, dxy_h_3, null, material_beamUF); |
2453 | scene.add(beamUF_h_3); | 2478 | scene.add(beamUF_h_3); |
2454 | var dxy_h_4 = { | 2479 | var dxy_h_4 = { |
2455 | 'start_X': converMMtoPX(start_X - 30), | 2480 | 'start_X': converMMtoPX(start_X - 30), |
2456 | 'start_Y': converMMtoPX(start_Y + height / 3 * 2 - 45), | 2481 | 'start_Y': converMMtoPX(start_Y + height / 3 * 2 - 45), |
2457 | 'width_X': converMMtoPX(width + 60), | 2482 | 'width_X': converMMtoPX(width + 60), |
2458 | 'width_Y': converMMtoPX(90), | 2483 | 'width_Y': converMMtoPX(90), |
2459 | 'height_startpoint': converMMtoPX(-90), | 2484 | 'height_startpoint': converMMtoPX(-90), |
2460 | 'height_endpoint': converMMtoPX(0) | 2485 | 'height_endpoint': converMMtoPX(0) |
2461 | }; | 2486 | }; |
2462 | var beamUF_h_4 = drawObj(scene, dxy_h_4, null, material_beamUF); | 2487 | var beamUF_h_4 = drawObj(scene, dxy_h_4, null, material_beamUF); |
2463 | scene.add(beamUF_h_4); | 2488 | scene.add(beamUF_h_4); |
2464 | } | 2489 | } |
2465 | //}else{ | 2490 | //}else{ |
2466 | // | 2491 | // |
2467 | //} | 2492 | //} |
2468 | } | 2493 | } |
2469 | 2494 | ||
2470 | function showHanrail(){ | 2495 | function showHanrail(){ |
2471 | var handrailList = getArray3dCadByType(TYPE_HANDRAIL); | 2496 | var handrailList = getArray3dCadByType(TYPE_HANDRAIL); |
2472 | for (var i = 0; i < handrailList.length; i++) { | 2497 | for (var i = 0; i < handrailList.length; i++) { |
2473 | handrail = handrailList[i]; | 2498 | handrail = handrailList[i]; |
2474 | var _3dxy = { | 2499 | var _3dxy = { |
2475 | 'start_X': converMMtoPX(handrail[2][0]), | 2500 | 'start_X': converMMtoPX(handrail[2][0]), |
2476 | 'start_Y': converMMtoPX(handrail[2][1]), | 2501 | 'start_Y': converMMtoPX(handrail[2][1]), |
2477 | 'width_X': converMMtoPX(handrail[2][2]), | 2502 | 'width_X': converMMtoPX(handrail[2][2]), |
2478 | 'width_Y': converMMtoPX(handrail[2][3]), | 2503 | 'width_Y': converMMtoPX(handrail[2][3]), |
2479 | 'height_startpoint': converMMtoPX(handrail[2][4]), | 2504 | 'height_startpoint': converMMtoPX(handrail[2][4]), |
2480 | 'height_endpoint': converMMtoPX(handrail[2][5]), | 2505 | 'height_endpoint': converMMtoPX(handrail[2][5]), |
2481 | }; | 2506 | }; |
2482 | 2507 | ||
2483 | var _3dobject = handrail[3]; | 2508 | var _3dobject = handrail[3]; |
2484 | //drawHandrail(scene, _3dxy, _3dobject); | 2509 | //drawHandrail(scene, _3dxy, _3dobject); |
2485 | // Check if have step | 2510 | // Check if have step |
2486 | checkAndDrawHandrail(_3dxy, _3dobject); | 2511 | checkAndDrawHandrail(_3dxy, _3dobject); |
2487 | 2512 | ||
2488 | } | 2513 | } |
2489 | } | 2514 | } |