pillars.js
24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
var noIndex = 0, typeIndex = 1, dxyIndex = 2, objectIndex = 3;
var widthPillar = 91;
var padding = 50;
var maxLengthOfWall = 1820; // 100pixel ~ 455mm
var minLengthOfWall = 455;
var wallLengthNextToAngle = 910; // ~ 910mm
var markUpPillar;
var pillarIndexStage = [];
var listWallInStage = [];
var b_point = [];
var listInitPillar = [];
/**
* Draw wall from array3dCad
*/
function handleWallAndPillar(stage, zoom) {
var offsetX = (910 - 910 * scale) * 100 / 455;
var offsetY = (455 - 455 * scale) * 100 / 455;
// create wall
arrayPositionCanSetPillar = [];
var array3dCadWall = getArray3dCadByType(TYPE_WALL);
for (var i = 0; i < array3dCadWall.length; i++) {
var xWall = array3dCadWall[i][dxyIndex][0];
var yWall = array3dCadWall[i][dxyIndex][1];
var widthWall = array3dCadWall[i][dxyIndex][2];
var heightWall = array3dCadWall[i][dxyIndex][3];
if (findPillarPosition(getPixelFromMm(xWall - widthPillar/2), getPixelFromMm(yWall - widthPillar/2) ) == null) {
addPillarPosition(getPixelFromMm(xWall - widthPillar/2), getPixelFromMm(yWall - widthPillar/2));
}
if (widthWall > heightWall) {
// create wall that wall is top or bottom
var wall = createWall(xWall, yWall - heightWall / 2, widthWall, heightWall, scale);
stage.addChild(wall);
listWallInStage.push(wall);
// add to list position can set pillar
var start = xWall + minLengthOfWall;
while (start < xWall + widthWall) {
var xPillar = getPixelFromMm(start) + offsetX;
var yPillar = getPixelFromMm(yWall - heightWall / 2) + offsetY;
if (findPillarPosition(xPillar, yPillar) == null) {
addPillarPosition(xPillar, yPillar);
}
start = start + minLengthOfWall;
}
} else {
// create wall that wall is left or right
var wall = createWall(xWall - widthWall / 2, yWall, widthWall, heightWall);
stage.addChild(wall);
listWallInStage.push(wall);
// add to list position can set pillar
var start = yWall + minLengthOfWall;
while (start < yWall + heightWall) {
var xPillar = getPixelFromMm(xWall - widthWall / 2) + offsetX;
var yPillar = getPixelFromMm(start) + offsetY;
if (findPillarPosition(xPillar, yPillar) == null) {
addPillarPosition(xPillar, yPillar);
}
start = start + minLengthOfWall;
}
}
}
for (var i = 0; i < wallInBalcony.length; i++) {
var xWall = wallInBalcony[i][dxyIndex][0];
var yWall = wallInBalcony[i][dxyIndex][1];
var widthWall = wallInBalcony[i][dxyIndex][2];
var heightWall = wallInBalcony[i][dxyIndex][3];
if (widthWall > heightWall) {
// add to list position can set pillar
var start = xWall + minLengthOfWall;
while (start < xWall + widthWall) {
var xPillar = getPixelFromMm(start) + offsetX;
var yPillar = getPixelFromMm(yWall - heightWall / 2) + offsetY;
if (findPillarPosition(xPillar, yPillar) == null) {
addPillarPosition(xPillar, yPillar);
}
start = start + minLengthOfWall;
}
} else {
// add to list position can set pillar
var start = yWall + minLengthOfWall;
while (start < yWall + heightWall) {
var xPillar = getPixelFromMm(xWall - widthWall / 2) + offsetX;
var yPillar = getPixelFromMm(start) + offsetY;
if (findPillarPosition(xPillar, yPillar) == null) {
addPillarPosition(xPillar, yPillar);
}
start = start + minLengthOfWall;
}
}
}
// create pillar
addPillarToValidPosition(stage);
// event click to wall
stage.on("mousedown", function (event) {
clickFloorBorder(event);
});
// event mouse over wall
stage.addEventListener("mouseover", function (event) {
mouseOverWall(event);
});
}
function addWallPillarEvent() {
// event click to wall
stage.on("mousedown", function (event) {
clickFloorBorder(event);
});
// event mouse over wall
stage.addEventListener("mouseover", function (event) {
mouseOverWall(event);
});
}
function mouseOverWall(event) {
if (transitionState < STATE_TRANSITION_SET_PILLAR) return;
if (!isChoose) {
var absoluteX = event.localX;
var absoluteY = event.localY;
// Check object is not overlap to others
if(checkOverlapObjectWithPos(absoluteX , absoluteY , converMMtoPXWithScalenZoom( widthPillar ), converMMtoPXWithScalenZoom( widthPillar ) ) == true) return;
var pillarPosition = findPillarPosition(absoluteX, absoluteY);
if (pillarPosition != null) {
var mmPillarX = pillarPosition[0]; // pixcel
var mmPillarY = pillarPosition[1]; // pixcel
var mmPillarWidth = getPixelFromMm(widthPillar);
if (getByTypeAndXY(TYPE_PILLAR, mmPillarX * 455 / 100 / scale, mmPillarY * 455 / 100 / scale) == null) {
if (markUpPillar == null) {
var g = new createjs.Graphics().setStrokeStyle(2).beginStroke('#EE1122').drawRect(0, 0, mmPillarWidth, mmPillarWidth);
markUpPillar = new createjs.Shape(g);
}
markUpPillar.x = mmPillarX - mmPillarWidth / 2;
markUpPillar.y = mmPillarY - mmPillarWidth / 2;
stage.addChild(markUpPillar);
stage.update();
}
} else {
if (markUpPillar != null) {
stage.removeChild(markUpPillar);
stage.update();
markUpPillar = null;
}
}
}
}
/**
* Handler event click to wall to set pillar
*/
function clickFloorBorder(event) {
if (transitionState < STATE_TRANSITION_SET_PILLAR) return;
if (!isChoose) {
var absoluteX = event.localX;
var absoluteY = event.localY;
// Check object is not overlap to others
if(checkOverlapObjectWithPos(absoluteX , absoluteY , converMMtoPXWithScalenZoom( widthPillar ), converMMtoPXWithScalenZoom( widthPillar ) ) == true) return;
var pillarPosition = findPillarPosition(absoluteX, absoluteY);
if (pillarPosition != null) {
var mmPillarX = pillarPosition[0]; // pixcel
var mmPillarY = pillarPosition[1]; // pixcel
var mmPillarWidth = getPixelFromMm(widthPillar);
if (getByTypeAndXY(TYPE_PILLAR, converPxtoMmWithScalenZoom(mmPillarX - mmPillarWidth / 2), converPxtoMmWithScalenZoom(mmPillarY - mmPillarWidth / 2)) == null) {
var currentPillar = createPillarWithPixel(mmPillarX - mmPillarWidth / 2, mmPillarY - mmPillarWidth / 2, mmPillarWidth);
stage.addChild(currentPillar);
setArray3dCad(null, TYPE_PILLAR, converPxtoMmWithScalenZoom(mmPillarX - mmPillarWidth / 2), converPxtoMmWithScalenZoom(mmPillarY - mmPillarWidth / 2), widthPillar, widthPillar, 0, 0, 0, 0, 0, 0);
pillarIndexStage.push(currentPillar);
stage.update();
// only valid if state is less than 1
// setTransitionState(STATE_TRANSITION_SET_PILLAR);
isZoom = 1;
isRoof2D = 0;
//var homePage = new lib._3dhouse();
//var incBtn = homePage.instance_1;
//console.log(incBtn);
//incBtn.removeEventListener('click', incZoom);
//var desBtn = homePage.instance;
//desBtn.removeEventListener('click', desZoom);
//if (!opacityShape) {
// opacityShape = new createjs.Shape();
// opacityShape.graphics.setStrokeStyle(padding).beginStroke('#000000').beginFill('#FFFFFF')
// .moveTo(0, 0).lineTo(259.6, 0).lineTo(259.6, 102.6).lineTo(0, 102.6).lineTo(0, 0);
// opacityShape.x = 1019.45;
// opacityShape.y = 727.2;
// opacityShape.alpha = 0.5;
// stage.addChild(opacityShape);
//}
//diablog(stage, ' 柱を立ててください');
}
}
}
}
/**
* Handler event click button [Pillar] in left menu
*/
function addPillarToValidPosition(stage) {
var array3dCadWall = getArray3dCadByType(TYPE_WALL);
listInitPillar = [];
for (var t = 0; t < wallInBalcony.length; t++) {
array3dCadWall.push(wallInBalcony[t]);
}
for (var i = 0; i < array3dCadWall.length; i++) {
var xWall = array3dCadWall[i][dxyIndex][0];
var yWall = array3dCadWall[i][dxyIndex][1];
var widthWall = array3dCadWall[i][dxyIndex][2];
var heightWall = array3dCadWall[i][dxyIndex][3];
var offsetX = 0, offsetY = 0;
if (widthWall > heightWall) {
offsetX = widthWall;
offsetY = 0;
} else {
offsetX = 0;
offsetY = heightWall;
}
// add pillar to all angle
if (getByTypeAndXY(TYPE_PILLAR, xWall - widthPillar / 2, yWall - widthPillar / 2) == null) {
addPillarToStage(stage, xWall - widthPillar / 2, yWall - widthPillar / 2, widthPillar);
}
if (getByTypeAndXY(TYPE_PILLAR, xWall + offsetX - widthPillar / 2, yWall + offsetY - widthPillar / 2) == null) {
addPillarToStage(stage, xWall + offsetX - widthPillar / 2, yWall + offsetY - widthPillar / 2, widthPillar);
}
// set pillar follow by some rule
var currentLength = offsetX > 0 ? offsetX : offsetY;
var indexX = 0, indexY = 0;
if (widthWall > heightWall) {
indexX = 1;
} else {
indexY = 1;
}
var pixelToSet1820 = currentLength - wallLengthNextToAngle * 2;
if (pixelToSet1820 == 0) {
// wall length is 1820mm => set a pillar to center of wall
var pillarX = xWall + indexX * offsetX / 2 - widthPillar / 2;
var pillarY = yWall + indexY * offsetY / 2 - widthPillar / 2;
if(checkOverlapObjectWithPos( converMMtoPXWithScalenZoom(pillarX), converMMtoPXWithScalenZoom(pillarY), converMMtoPXWithScalenZoom(widthPillar), converMMtoPXWithScalenZoom(widthPillar) ) == false)
{
console.log("pillarX: "+ pillarX);
console.log("pillarY: "+ pillarY);
if (getByTypeAndXY(TYPE_PILLAR, xWall + indexX * offsetX / 2 - widthPillar / 2, yWall + indexY * offsetY / 2 - widthPillar / 2) == null) {
addPillarToStage(stage, xWall + indexX * offsetX / 2 - widthPillar / 2, yWall + indexY * offsetY / 2 - widthPillar / 2, widthPillar);
}
}
} else if (pixelToSet1820 > 0) {
// wall length is greater than 1820mm
var numberOfWall1820 = parseInt(pixelToSet1820 / maxLengthOfWall);
var remainPixelAfterSet1820 = pixelToSet1820 - numberOfWall1820 * maxLengthOfWall;
var newLength = wallLengthNextToAngle;
if (remainPixelAfterSet1820 == minLengthOfWall) {
newLength = wallLengthNextToAngle + remainPixelAfterSet1820;
pixelToSet1820 = pixelToSet1820 - remainPixelAfterSet1820;
}
// add pillar next to angle (primary pillar)
var pillarX = xWall + indexX * newLength - widthPillar / 2;
var pillarY = yWall + indexY * newLength - widthPillar / 2;
if(checkOverlapObjectWithPos( converMMtoPXWithScalenZoom(pillarX), converMMtoPXWithScalenZoom(pillarY), converMMtoPXWithScalenZoom(widthPillar), converMMtoPXWithScalenZoom(widthPillar) ) == false)
{
if (getByTypeAndXY(TYPE_PILLAR, xWall + indexX * newLength - widthPillar / 2, yWall + indexY * newLength - widthPillar / 2) == null) {
addPillarToStage(stage, xWall + indexX * newLength - widthPillar / 2, yWall + indexY * newLength - widthPillar / 2, widthPillar);
}
}
pillarX = xWall + indexX * (offsetX - wallLengthNextToAngle) - widthPillar / 2;
pillarY = yWall + indexY * (offsetY - wallLengthNextToAngle) - widthPillar / 2;
if(checkOverlapObjectWithPos( converMMtoPXWithScalenZoom(pillarX), converMMtoPXWithScalenZoom(pillarY), converMMtoPXWithScalenZoom(widthPillar), converMMtoPXWithScalenZoom(widthPillar) ) == false)
{
if (getByTypeAndXY(TYPE_PILLAR, xWall + indexX * (offsetX - wallLengthNextToAngle) - widthPillar / 2, yWall + indexY * (offsetY - wallLengthNextToAngle) - widthPillar / 2) == null) {
addPillarToStage(stage, xWall + indexX * (offsetX - wallLengthNextToAngle) - widthPillar / 2, yWall + indexY * (offsetY - wallLengthNextToAngle) - widthPillar / 2, widthPillar);
}
}
// draw pillar that distance with primary pillar is 1820mm (secondary pillar)
while (pixelToSet1820 > maxLengthOfWall) {
// set pillar from start to end of wall
pillarX = xWall + indexX * (wallLengthNextToAngle + maxLengthOfWall) - widthPillar / 2;
pillarY = yWall + indexY * (wallLengthNextToAngle + maxLengthOfWall) - widthPillar / 2;
if(checkOverlapObjectWithPos( converMMtoPXWithScalenZoom(pillarX), converMMtoPXWithScalenZoom(pillarY), converMMtoPXWithScalenZoom(widthPillar), converMMtoPXWithScalenZoom(widthPillar) ) == false)
{
console.log("pillarX1: "+ pillarX);
console.log("pillarY1: "+ pillarY);
if (getByTypeAndXY(TYPE_PILLAR, pillarX, pillarY) == null) {
addPillarToStage(stage, pillarX, pillarY, widthPillar);
}
}
pixelToSet1820 = pixelToSet1820 - maxLengthOfWall;
if (pixelToSet1820 > maxLengthOfWall) {
// set pillar from end to start of wall
pillarX = xWall + indexX * (offsetX - wallLengthNextToAngle - maxLengthOfWall) - widthPillar / 2;
pillarY = yWall + indexY * (offsetY - wallLengthNextToAngle - maxLengthOfWall) - widthPillar / 2;
if(checkOverlapObjectWithPos( converMMtoPXWithScalenZoom(pillarX), converMMtoPXWithScalenZoom(pillarY), converMMtoPXWithScalenZoom(widthPillar), converMMtoPXWithScalenZoom(widthPillar) ) == false)
{
console.log("pillarX2: "+ pillarX);
console.log("pillarY2: "+ pillarY);
if (getByTypeAndXY(TYPE_PILLAR, pillarX, pillarY) == null) {
addPillarToStage(stage, pillarX, pillarY, widthPillar);
}
pixelToSet1820 = pixelToSet1820 - maxLengthOfWall;
}
}
}
} else {
// wall length is smaller than 1820mm => Do not set pillar to this wall
}
}
addPillarBesideObjectInWall();
// update stage
stage.update();
}
function addPillarBesideObjectInWall()
{
for( var i = 0; i < arrObjectInWall.length; i++)
{
if(arrObjectInWall[i].width > arrObjectInWall[i].height)
{
createPillarNextToObjectLeftRight(arrObjectInWall[i]);
}
else
{
createPillarNextToObjectTopBottom(arrObjectInWall[i]);
}
}
}
/**
* Check clicked position is valid position to set pillar or not
*/
function validateClickedPosition(length) {
var number = parseInt(length / getPixelFromMm(minLengthOfWall));
var remainLength = length - number * getPixelFromMm(minLengthOfWall);
if (remainLength <= padding * scale) {
return true;
}
return false;
}
/**
* Create wall object
*/
function createWall(x, y, width, height) {
// var offsetX = (910 - 910 * scale) * 100 / 455;
// var offsetY = (455 - 455 * scale) * 100 / 455;
x = getPixelFromMm(x);
y = getPixelFromMm(y);
width = getPixelFromMm(width);
height = getPixelFromMm(height);
var g = new createjs.Graphics().beginStroke('#974E0B').beginFill("#974E0B").drawRect(0, 0, width, height);
var wall = new createjs.Shape(g);
wall.x = x;
wall.y = y;
return wall;
}
/**
* Create pillar
*/
function createPillar(x, y, width) {
// var offsetX = (910 - 910 * scale) * 100 / 455;
// var offsetY = (455 - 455 * scale) * 100 / 455;
x = getPixelFromMm(x);
y = getPixelFromMm(y);
width = getPixelFromMm(width);
var g = new createjs.Graphics().beginFill('#5C9FD4').drawRect(0, 0, width, width);
var pillar = new createjs.Shape(g);
pillar.x = x;
pillar.y = y;
return pillar;
}
function createPillarWithPixel(x, y, width) {
var g = new createjs.Graphics().beginFill('#5C9FD4').drawRect(0, 0, width, width);
var pillar = new createjs.Shape(g);
pillar.x = x;
pillar.y = y;
pillar.on("mousedown", function (evt) {
pillarOnClick(evt, this.x, this.y);
});
return pillar;
}
function addPillarToStage(stage, x, y, width) {
var pillar = createPillar(x, y, width);
stage.addChild(pillar);
setArray3dCad(null, TYPE_PILLAR, x, y, width, width, 0, 0, 0, 0, 0, 0);
pillarIndexStage.push(pillar);
pillar.on("mousedown", function (evt) {
b_point['x'] = evt.stageX;
b_point['y'] = evt.stageY;
pillarOnClick(evt, this.x, this.y);
});
}
function getPixelFromMm(mmValue) {
return parseInt(mmValue * zoom * scale * 100 / 455);
}
function pillarOnClick(evt, x, y) {
// Remove pillar
//var pillar = evt.target;
//var x = converPxtoMmWithScalenZoom(pillar.x);
//var y = converPxtoMmWithScalenZoom(pillar.y);
//
//// Delete pillar
//
//stage.removeChild(pillar);
//
//// remove pillar from memory
//var pillar3d = getByTypeAndXY(TYPE_PILLAR, x, y));
//if (pillar3d != null) {
// deleteArray3dCad(pillar3d[0][0]);
//}
//
//var pillarNextToObjIndex = findPillarNextToObject(pillarIndexStage[i]);
//if( pillarNextToObjIndex >= pillarNextToObjectList.length)
//{
//
// pillarNextToObjectList.splice(pillarNextToObjIndex, 1);
//}
//var floor_info = getArray3dCadByType(TYPE_FLOOR);
//floor_info = floor_info[0];
//if ((x) <= getPixelFromMm(floor_info[2][0] + 45) && (x) >= getPixelFromMm(floor_info[2][0] - 45) && y <= getPixelFromMm(floor_info[2][1] + 45) && y >= getPixelFromMm(floor_info[2][1] - 45)) {
// return;
//}
//if (x <= getPixelFromMm(floor_info[2][0] + 45) && x >= getPixelFromMm(floor_info[2][0] - 45) && y >= getPixelFromMm(floor_info[2][1] - 45) && y <= getPixelFromMm(floor_info[2][1] + floor_info[2][3] + 45)) {
// console.log('canh trai');
// drawWallInFloor(x, y, floor_info, 'left');
//}
//if (x <= getPixelFromMm(floor_info[2][0] + floor_info[2][2] + 45) && x >= getPixelFromMm(floor_info[2][0] + floor_info[2][2] - 45) && y >= getPixelFromMm(floor_info[2][1] - 45) && y <= getPixelFromMm(floor_info[2][1] + floor_info[2][3] + 45)) {
// console.log('canh phai');
// drawWallInFloor(x, y, floor_info, 'right');
//}
//if (x <= getPixelFromMm(floor_info[2][0] + floor_info[2][2] + 45) && x >= getPixelFromMm(floor_info[2][0] - 45) && y >= getPixelFromMm(floor_info[2][1] - 45) && y <= getPixelFromMm(floor_info[2][1] + 45)) {
// console.log('canh tren');
// drawWallInFloor(x, y, floor_info, 'top');
//}
//if (x <= getPixelFromMm(floor_info[2][0] + floor_info[2][2] + 45) && x >= getPixelFromMm(floor_info[2][0] - 45) && y >= getPixelFromMm(floor_info[2][1] + floor_info[2][3] - 45) && y <= getPixelFromMm(floor_info[2][1] + floor_info[2][3] + 45)) {
// console.log('canh duoi');
// drawWallInFloor(x, y, floor_info, 'bottom');
//}
}
function drawWallInFloor(x, y, floor_info, position) {
var g;
var isDraw = true;
var width, height;
g = new createjs.Shape();
y = y + getPixelFromMm(45);
x = x + getPixelFromMm(45);
stage.on('stagemousemove', function (evt) {
if (isDraw) {
if (position == 'left') {
// if
var diff = evt.stageX - b_point['x'];
if (diff <= 0) {
diff = 0;
}
if (diff >= floor_info[2][0] + floor_info[2][2]) {
diff = getPixelFromMm(floor_info[2][0] + floor_info[2][2]);
}
if (g)
stage.removeChild(g);
width = (diff) * 455 / 100;
width = Math.floor(width / 455) * 455;
height = 18;
g = createWall(x * 455 / 100, y * 455 / 100, width, height);
stage.addChild(g);
}
if (position == 'right') {
// if
var diff = b_point['x'] - evt.stageX;
if (diff <= 0) {
diff = 0;
}
if (diff >= floor_info[2][0] + floor_info[2][2]) {
diff = getPixelFromMm(floor_info[2][0] + floor_info[2][2]);
}
if (g)
stage.removeChild(g);
width = (diff) * 455 / 100;
width = Math.floor(width / 455) * 455;
height = 18;
g = createWall((x) * 455 / 100 - width, y * 455 / 100, width, height);
stage.addChild(g);
}
if (position == 'top') {
// if
var diff = evt.stageY - b_point['y'];
if (diff <= 0) {
diff = 0;
}
if (diff >= floor_info[2][1] + floor_info[2][3]) {
diff = getPixelFromMm(floor_info[2][1] + floor_info[2][3]);
}
if (g)
stage.removeChild(g);
height = (diff) * 455 / 100;
height = Math.floor(height / 455) * 455;
width = 18;
g = createWall(x * 455 / 100, y * 455 / 100, width, height);
stage.addChild(g);
}
if (position == 'bottom') {
// if
var diff = b_point['y'] - evt.stageY;
if (diff <= 0) {
diff = 0;
}
if (diff >= floor_info[2][1] + floor_info[2][3]) {
diff = getPixelFromMm(floor_info[2][1] + floor_info[2][3]);
}
if (g)
stage.removeChild(g);
height = (diff) * 455 / 100;
height = Math.floor(height / 455) * 455;
width = 18;
g = createWall(x * 455 / 100, y * 455 / 100 - height, width, height);
stage.addChild(g);
}
}
});
stage.on('stagemouseup', function () {
isDraw = false;
listWallInStage.push(g);
stage.update;
createArray3dCad(10, null, 3, g.x * 455 / 100, g.y * 455 / 100, width, height);
});
}
/**
* Get position of clicked
* Return 1, if clicked to border top
* Return 2, if clicked to border right
* Return 3, if clicked to border bottom
* Return 4, if clicked to border left
* @param x
* @param y
* @param width width of floor
* @param height height of floor
* @param clickedX x value of point that user clicked
* @param clickedY y value of point that user clicked
*/
function getPositionToSetPillar(x, y, width, height, clickedX, clickedY) {
if (x < clickedX && clickedX < x + width && Math.abs(y - clickedY) <= padding) {
return 1;
} else if (Math.abs(x + width - clickedX) <= padding && y < clickedY && clickedY < y + height) {
return 2;
} else if (x < clickedX && clickedX < x + width && Math.abs(y + height - clickedY) <= padding) {
return 3;
} else if (Math.abs(x - clickedX) <= padding && y < clickedY && clickedY < y + height) {
return 4;
} else {
return 0;
}
}