var is_roof = false; var isRoof2D = 1; var shapeBox, roof_1, roof_2, roof, chooseTexRoof, tex_1, tex_2, tex_3, tex_id, border_selected, rotate, rotateImg, typeR, opacityShapeBox; var isRoof3D = 1; var roof = function () { if (!isRoof2D ) { if (!is_roof) { drawShape(stage); is_roof = true; } else { removeShape(stage); is_roof = false; } } } function drawShape(stage) { if ( transitionState < STATE_TRANSITION_SET_ROOF) return ; // stage.removeChild(shapeBox); shapeBox = new createjs.Shape(); shapeBox.graphics.setStrokeStyle(padding).beginStroke('#FF4500').beginFill('#FFFFFF') .moveTo(0, 0).lineTo(100, 0).lineTo(100, 400).lineTo(0, 400).lineTo(0, 0); shapeBox.x = 0; shapeBox.y = 370; stage.addChild(shapeBox); chooseTexRoof = new createjs.Shape(); chooseTexRoof.graphics.setStrokeStyle(padding).beginStroke('#FF4500').beginFill('#FFFFFF') .moveTo(0, 0).lineTo(100, 0).lineTo(100, 400).lineTo(0, 400).lineTo(0, 0); chooseTexRoof.x = 120; chooseTexRoof.y = 370; stage.addChild(chooseTexRoof); tex_1 = texRoof_1(); stage.addChild(tex_1); tex_2 = texRoof_2(); stage.addChild(tex_2); tex_3 = texRoof_3(); stage.addChild(tex_3); roof_1 = createRoof_1(); roof_2 = createRoof_2(); stage.addChild(roof_1); stage.addChild(roof_2); var text = new createjs.Text("切妻", "14px Arial", "#000"); text.x = 37; // + (100- text.clientWidth)/2; text.y = 470; text.textBaseline = "alphabetic"; stage.addChild(text) var text = new createjs.Text("片流れ", "14px Arial", "#000"); text.x = 30; // + (100- text.clientWidth)/2; text.y = 550; text.textBaseline = "alphabetic"; stage.addChild(text) // if (!border_selected) { border_selected = new createjs.Shape(); border_selected.graphics.setStrokeStyle(padding).beginStroke('#000000') .moveTo(0, 0).lineTo(70, 0).lineTo(70, 40).lineTo(0, 40).lineTo(0, 0); } if (tex_id) { if (tex_id == 1) { border_selected.x = 135; border_selected.y = 415; } if (tex_id == 2) { border_selected.x = 135; border_selected.y = 495; } if (tex_id == 3) { border_selected.x = 135; border_selected.y = 575; } } else { border_selected.x = 135; border_selected.y = 415; } stage.addChild(border_selected); stage.update; } function removeShape() { stage.removeChild(shapeBox); stage.removeChild(roof_1); stage.removeChild(roof_2); stage.removeChild(chooseTexRoof); stage.removeChild(tex_1); stage.removeChild(tex_2); stage.removeChild(tex_3); stage.removeChild(border_selected); } function texRoof_1() { var texR_1 = new createjs.Bitmap("images/roof-1-1.jpg"); texR_1.scaleX = 60 / 272; texR_1.scaleY = 30 / 114; texR_1.x = 140; texR_1.y = 420; texR_1.name = '1'; texR_1.addEventListener('click', chooseTex); return texR_1; } function texRoof_2() { var texR_2 = new createjs.Bitmap("images/roof-1-2.jpg"); texR_2.scaleX = 60 / 276; texR_2.scaleY = 30 / 106; texR_2.x = 140; texR_2.y = 500; texR_2.name = '2'; texR_2.addEventListener('click', chooseTex); return texR_2; } function texRoof_3() { var texR_3 = new createjs.Bitmap("images/roof-1-3.jpg"); texR_3.scaleX = 60 / 260; texR_3.scaleY = 30 / 117; texR_3.x = 140; texR_3.y = 580; texR_3.name = '3'; texR_3.addEventListener('click', chooseTex); return texR_3; } function chooseTex($this) { tex_id = $this.target.name; // if (!border_selected) { border_selected = new createjs.Shape(); border_selected.graphics.setStrokeStyle(padding).beginStroke('#000000') .moveTo(0, 0).lineTo(70, 0).lineTo(70, 40).lineTo(0, 40).lineTo(0, 0); } if (tex_id == 1) { border_selected.x = 135; border_selected.y = 415; } if (tex_id == 2) { border_selected.x = 135; border_selected.y = 495; } if (tex_id == 3) { border_selected.x = 135; border_selected.y = 575; } stage.addChild(border_selected); stage.update(); // var roof = getArray3dCad(100); if (roof) { var roof_file_name = roof[3][0].split('-'); roof_file_name = roof_file_name[0] + '-' + roof_file_name[1] + '-' + tex_id; updateArray3dCad(roof[0][0], roof_file_name, roof[1][0], roof[2][0], roof[2][1], roof[2][2], roof[2][3], roof[2][4], roof[2][5], roof[3][1], roof[3][2], roof[3][3], roof[3][4]); } } function createRoof_1() { var roof_1 = new createjs.Shape(); roof_1.graphics.setStrokeStyle(padding).beginStroke('#000000').beginFill('#FFFFFF') .moveTo(0, 0).lineTo(60, 0).lineTo(60, 30).lineTo(0, 30).lineTo(0, 0) .setStrokeDash([5, 5]) .moveTo(0, 15).lineTo(60, 15) .endStroke(); ; roof_1.x = 20; roof_1.y = 420; //var roof_12 = new createjs.Shape(); //var mypen= graphics.newPen(graphics.BrushType.SOLID_COLOR,[0,0,0,1],1); //roof_1.graphics.drawString("切妻",0, 35); roof_1.addEventListener('click', clickRoof_1) return roof_1; } function createRoof_2() { var roof_2 = new createjs.Shape(); roof_2.graphics.setStrokeStyle(padding).beginStroke('#000000').beginFill('#FFFFFF') .moveTo(0, 0).lineTo(60, 0).lineTo(60, 30).lineTo(0, 30).lineTo(0, 0); roof_2.x = 20; roof_2.y = 500; roof_2.addEventListener('click', clickRoof_2) return roof_2; } function clickRoof_1(evt) { if (rotateImg) stage.removeChild(rotateImg); drawRoof(1); //dontChooseObj(); } function clickRoof_2(evt) { if (rotateImg) stage.removeChild(rotateImg); drawRoof(2); //dontChooseObj(); } function drawRoof(typeRoof) { typeR = typeRoof; var floor = getArray3dCadByType(TYPE_FLOOR)[0][2]; var temp = 300; if (typeBalcony == TYPE_BALCONY_NONE) { var balcony = 0; widthRoof = converMMtoPX(floor[2] + temp * 2); heightRoof = converMMtoPX(floor[3] + temp * 2); X_Roof = converMMtoPX(floor[0] - temp); Y_Roof = converMMtoPX(floor[1] - temp); roofType = 101; } else { var balcony = getArray3dCadByType(TYPE_BALCONY)[0][2]; } if (roof) { stage.removeChild(roof); } roof = new createjs.Shape(); if (floor[0] == balcony[0]) { if (floor[1] < balcony[1]) { X_Roof = converMMtoPX(floor[0] - temp); Y_Roof = converMMtoPX(floor[1] - temp); roofType = 101; if (!rotate) rotate = 1; } else { X_Roof = converMMtoPX(balcony[0] - temp); Y_Roof = converMMtoPX(balcony[1] - temp); roofType = 102; if (!rotate) rotate = 2; } widthRoof = converMMtoPX(floor[2] + temp * 2); // Check is roof cover balcony if (typeBalcony == TYPE_BALCONY_HASROOF) { heightRoof = converMMtoPX(floor[3] + balcony[3] + temp * 2); } else { heightRoof = converMMtoPX(floor[3] + temp * 2); } } if (floor[1] == balcony[1]) { if (floor[0] < balcony[0]) { X_Roof = converMMtoPX(floor[0] - temp); Y_Roof = converMMtoPX(floor[1] - temp); roofType = 103; if (!rotate) rotate = 3; } else { X_Roof = converMMtoPX(balcony[0] - temp); Y_Roof = converMMtoPX(balcony[1] - temp); roofType = 104; if (!rotate) rotate = 4; } if (typeBalcony == TYPE_BALCONY_HASROOF) { widthRoof = converMMtoPX(floor[2] + balcony[2] + temp * 2); } else { widthRoof = converMMtoPX(floor[2] + temp * 2); } heightRoof = converMMtoPX(floor[3] + temp * 2); } if (!balcony) { if (!rotate) rotate = 1; } X_Roof = X_Roof * zoom; Y_Roof = Y_Roof * zoom; widthRoof = widthRoof * zoom; heightRoof = heightRoof * zoom; if (typeRoof == 1) { if (roofType == 101) { roof.graphics.setStrokeStyle(5).beginStroke('#457198') .moveTo(0, 0).lineTo(widthRoof, 0).lineTo(widthRoof, heightRoof).lineTo(0, heightRoof).lineTo(0, 0); if (rotate == 1 || rotate == 2) { roof.graphics.setStrokeDash([5, 5]) .moveTo(0, heightRoof / 2).lineTo(widthRoof, heightRoof / 2) .endStroke(); } if (rotate == 3 || rotate == 4) { roof.graphics.setStrokeDash([5, 5]) .moveTo(widthRoof / 2, 0).lineTo(widthRoof / 2, heightRoof) .endStroke(); } } if (roofType == 102) { roof.graphics.setStrokeStyle(5).beginStroke('#457198') .moveTo(0, 0).lineTo(widthRoof, 0).lineTo(widthRoof, heightRoof).lineTo(0, heightRoof).lineTo(0, 0); if (rotate == 1 || rotate == 2) { roof.graphics.setStrokeDash([5, 5]) .moveTo(0, heightRoof / 2).lineTo(widthRoof, heightRoof / 2) .endStroke(); } if (rotate == 3 || rotate == 4) { roof.graphics.setStrokeDash([5, 5]) .moveTo(widthRoof / 2, 0).lineTo(widthRoof / 2, heightRoof) .endStroke(); } } if (roofType == 103) { roof.graphics.setStrokeStyle(5).beginStroke('#457198') .moveTo(0, 0).lineTo(widthRoof, 0).lineTo(widthRoof, heightRoof).lineTo(0, heightRoof).lineTo(0, 0); if (rotate == 3 || rotate == 4) { roof.graphics.setStrokeDash([5, 5]) .moveTo(widthRoof / 2, 0).lineTo(widthRoof / 2, heightRoof) .endStroke(); } if (rotate == 1 || rotate == 2) { roof.graphics.setStrokeDash([5, 5]) .moveTo(0, heightRoof / 2).lineTo(widthRoof, heightRoof / 2) .endStroke(); } } if (roofType == 104) { roof.graphics.setStrokeStyle(5).beginStroke('#457198') .moveTo(0, 0).lineTo(widthRoof, 0).lineTo(widthRoof, heightRoof).lineTo(0, heightRoof).lineTo(0, 0); if (rotate == 3 || rotate == 4) { roof.graphics.setStrokeDash([5, 5]) .moveTo(widthRoof / 2, 0).lineTo(widthRoof / 2, heightRoof) .endStroke(); } if (rotate == 1 || rotate == 2) { roof.graphics.setStrokeDash([5, 5]) .moveTo(0, heightRoof / 2).lineTo(widthRoof, heightRoof / 2) .endStroke(); } } } else { roof.graphics.setStrokeStyle(5).beginStroke('#457198') .moveTo(0, 0).lineTo(widthRoof, 0).lineTo(widthRoof, heightRoof).lineTo(0, heightRoof).lineTo(0, 0); if (rotate == 1) { roof.graphics.setStrokeStyle(5).beginStroke('#000000').beginFill('#000000') .moveTo((widthRoof) / 2, (heightRoof + 40) / 2).lineTo(widthRoof / 2 + 20, (heightRoof - 40) / 2).lineTo(widthRoof / 2 - 20, (heightRoof - 40) / 2).lineTo((widthRoof) / 2, (heightRoof + 40) / 2) .setStrokeDash([5, 5]) .moveTo(widthRoof / 2, 10).lineTo(widthRoof / 2, heightRoof - 10) .endStroke(); ; } if (rotate == 2) { roof.graphics.setStrokeStyle(5).beginStroke('#000000').beginFill('#000000') .moveTo(widthRoof / 2, (heightRoof - 40) / 2).lineTo(widthRoof / 2 + 20, (heightRoof + 40) / 2).lineTo(widthRoof / 2 - 20, (heightRoof + 40) / 2).lineTo(widthRoof / 2, (heightRoof - 40) / 2) .setStrokeDash([5, 5]) .moveTo(widthRoof / 2, 10).lineTo(widthRoof / 2, heightRoof - 10) .endStroke(); ; } if (rotate == 4) { roof.graphics.setStrokeStyle(5).beginStroke('#000000').beginFill('#000000') .moveTo((widthRoof - 40) / 2, heightRoof / 2) .lineTo((widthRoof + 40) / 2, (heightRoof - 40) / 2) .lineTo((widthRoof + 40) / 2, (heightRoof + 40) / 2) .lineTo((widthRoof - 40) / 2, heightRoof / 2) .setStrokeDash([5, 5]) .moveTo(10, heightRoof / 2).lineTo(widthRoof - 10, heightRoof / 2) .endStroke(); } if (rotate == 3) { roof.graphics.setStrokeStyle(5).beginStroke('#000000').beginFill('#000000') .moveTo((widthRoof + 40) / 2, heightRoof / 2) .lineTo((widthRoof - 40) / 2, (heightRoof + 40) / 2) .lineTo((widthRoof - 40) / 2, (heightRoof - 40) / 2) .lineTo((widthRoof + 40) / 2, heightRoof / 2) .setStrokeDash([5, 5]) .moveTo(10, heightRoof / 2).lineTo(widthRoof - 10, heightRoof / 2) .endStroke(); } } roof.x = X_Roof; roof.y = Y_Roof; stage.addChild(roof); stage.removeChild(rotateImg); rotateImg = new createjs.Bitmap("images/redo.jpg"); rotateImg.scaleX = 50 / 256; rotateImg.scaleY = 50 / 256; rotateImg.x = X_Roof + 10; rotateImg.y = Y_Roof + 10; rotateImg.addEventListener('click', rotateRoof) stage.addChild(rotateImg); stage.update(); /* * Roof Type 101: balcony is bottom of floor; * Roof Type 102: balcony is top of floor; * Roof Type 103: balcony is right of floor; * Roof Type 103: balcony is left of floor; * */ deleteArray3dCad(100); var roofTex; if (tex_id) { roofTex = 'roof-' + typeRoof + '-' + tex_id; } else { roofTex = 'roof-' + typeRoof + '-1'; } X_Roof = X_Roof / zoom; Y_Roof = Y_Roof / zoom; widthRoof = widthRoof / zoom; heightRoof = heightRoof / zoom; createArray3dCad(100, roofTex, roofType, X_Roof, Y_Roof, widthRoof, heightRoof, 0, converMMtoPX(300)); } /// function rotateRoof() { if (rotate == 1) { rotate = 4; } else if (rotate == 4) { rotate = 2; } else if (rotate == 2) { rotate = 3; } else if (rotate == 3) { rotate = 1; } stage.removeChild(roof); drawRoof(typeR); } function dontChooseObj() { if (!isChoose) { isChoose = 1; isRoof3D = 0; opacityShapeBox = new createjs.Shape(); opacityShapeBox.graphics.setStrokeStyle(padding).beginStroke('#000000').beginFill('#FFFFFF') .moveTo(0, 0).lineTo(1279, 0).lineTo(1279, 128.2).lineTo(0, 128.2).lineTo(0, 0); opacityShapeBox.x = 0.05; opacityShapeBox.y = 829.8; opacityShapeBox.alpha = 0.5; stage.addChild(opacityShapeBox); //setTransitionState(5) //diablog(stage, '3DVIEWを出してください'); } } function loadRoof( roofTex, type, X_Roof, Y_Roof, widthRoof, heightRoof ) { roofType = type; console.log("roofType: " + roofType); var res = roofTex.split("-"); var typeRoof = parseInt(res[1]); typeR = typeRoof; tex_id = parseInt(res[2]); var floor = getArray3dCadByType(TYPE_FLOOR)[0][2]; var temp = 300; if (typeBalcony != TYPE_BALCONY_NONE) { var balcony = getArray3dCadByType(TYPE_BALCONY)[0][2]; } if (roof) { stage.removeChild(roof); } roof = new createjs.Shape(); X_Roof = X_Roof * zoom*scale; Y_Roof = Y_Roof * zoom*scale; widthRoof = widthRoof * zoom*scale; heightRoof = heightRoof * zoom*scale; if (typeRoof == 1) { if (roofType == 101) { roof.graphics.setStrokeStyle(5).beginStroke('#457198') .moveTo(0, 0).lineTo(widthRoof, 0).lineTo(widthRoof, heightRoof).lineTo(0, heightRoof).lineTo(0, 0); if (rotate == 1 || rotate == 2) { roof.graphics.setStrokeDash([5, 5]) .moveTo(0, heightRoof / 2).lineTo(widthRoof, heightRoof / 2) .endStroke(); } if (rotate == 3 || rotate == 4) { roof.graphics.setStrokeDash([5, 5]) .moveTo(widthRoof / 2, 0).lineTo(widthRoof / 2, heightRoof) .endStroke(); } } if (roofType == 102) { roof.graphics.setStrokeStyle(5).beginStroke('#457198') .moveTo(0, 0).lineTo(widthRoof, 0).lineTo(widthRoof, heightRoof).lineTo(0, heightRoof).lineTo(0, 0); if (rotate == 1 || rotate == 2) { roof.graphics.setStrokeDash([5, 5]) .moveTo(0, heightRoof / 2).lineTo(widthRoof, heightRoof / 2) .endStroke(); } if (rotate == 3 || rotate == 4) { roof.graphics.setStrokeDash([5, 5]) .moveTo(widthRoof / 2, 0).lineTo(widthRoof / 2, heightRoof) .endStroke(); } } if (roofType == 103) { roof.graphics.setStrokeStyle(5).beginStroke('#457198') .moveTo(0, 0).lineTo(widthRoof, 0).lineTo(widthRoof, heightRoof).lineTo(0, heightRoof).lineTo(0, 0); if (rotate == 3 || rotate == 4) { roof.graphics.setStrokeDash([5, 5]) .moveTo(widthRoof / 2, 0).lineTo(widthRoof / 2, heightRoof) .endStroke(); } if (rotate == 1 || rotate == 2) { roof.graphics.setStrokeDash([5, 5]) .moveTo(0, heightRoof / 2).lineTo(widthRoof, heightRoof / 2) .endStroke(); } } if (roofType == 104) { roof.graphics.setStrokeStyle(5).beginStroke('#457198') .moveTo(0, 0).lineTo(widthRoof, 0).lineTo(widthRoof, heightRoof).lineTo(0, heightRoof).lineTo(0, 0); if (rotate == 3 || rotate == 4) { roof.graphics.setStrokeDash([5, 5]) .moveTo(widthRoof / 2, 0).lineTo(widthRoof / 2, heightRoof) .endStroke(); } if (rotate == 1 || rotate == 2) { roof.graphics.setStrokeDash([5, 5]) .moveTo(0, heightRoof / 2).lineTo(widthRoof, heightRoof / 2) .endStroke(); } } } else { roof.graphics.setStrokeStyle(5).beginStroke('#457198') .moveTo(0, 0).lineTo(widthRoof, 0).lineTo(widthRoof, heightRoof).lineTo(0, heightRoof).lineTo(0, 0); if (rotate == 1) { roof.graphics.setStrokeStyle(5).beginStroke('#000000').beginFill('#000000') .moveTo((widthRoof) / 2, (heightRoof + 40) / 2).lineTo(widthRoof / 2 + 20, (heightRoof - 40) / 2).lineTo(widthRoof / 2 - 20, (heightRoof - 40) / 2).lineTo((widthRoof) / 2, (heightRoof + 40) / 2) .setStrokeDash([5, 5]) .moveTo(widthRoof / 2, 10).lineTo(widthRoof / 2, heightRoof - 10) .endStroke(); ; } if (rotate == 2) { roof.graphics.setStrokeStyle(5).beginStroke('#000000').beginFill('#000000') .moveTo(widthRoof / 2, (heightRoof - 40) / 2).lineTo(widthRoof / 2 + 20, (heightRoof + 40) / 2).lineTo(widthRoof / 2 - 20, (heightRoof + 40) / 2).lineTo(widthRoof / 2, (heightRoof - 40) / 2) .setStrokeDash([5, 5]) .moveTo(widthRoof / 2, 10).lineTo(widthRoof / 2, heightRoof - 10) .endStroke(); ; } if (rotate == 4) { roof.graphics.setStrokeStyle(5).beginStroke('#000000').beginFill('#000000') .moveTo((widthRoof - 40) / 2, heightRoof / 2) .lineTo((widthRoof + 40) / 2, (heightRoof - 40) / 2) .lineTo((widthRoof + 40) / 2, (heightRoof + 40) / 2) .lineTo((widthRoof - 40) / 2, heightRoof / 2) .setStrokeDash([5, 5]) .moveTo(10, heightRoof / 2).lineTo(widthRoof - 10, heightRoof / 2) .endStroke(); } if (rotate == 3) { roof.graphics.setStrokeStyle(5).beginStroke('#000000').beginFill('#000000') .moveTo((widthRoof + 40) / 2, heightRoof / 2) .lineTo((widthRoof - 40) / 2, (heightRoof + 40) / 2) .lineTo((widthRoof - 40) / 2, (heightRoof - 40) / 2) .lineTo((widthRoof + 40) / 2, heightRoof / 2) .setStrokeDash([5, 5]) .moveTo(10, heightRoof / 2).lineTo(widthRoof - 10, heightRoof / 2) .endStroke(); } } roof.x = X_Roof; roof.y = Y_Roof; stage.addChild(roof); stage.removeChild(rotateImg); rotateImg = new createjs.Bitmap("images/redo.jpg"); rotateImg.scaleX = 50 / 256; rotateImg.scaleY = 50 / 256; rotateImg.x = X_Roof + 10; rotateImg.y = Y_Roof + 10; rotateImg.addEventListener('click', rotateRoof) stage.addChild(rotateImg); stage.update(); /* * Roof Type 101: balcony is bottom of floor; * Roof Type 102: balcony is top of floor; * Roof Type 103: balcony is right of floor; * Roof Type 103: balcony is left of floor; * */ deleteArray3dCad(100); X_Roof = X_Roof / (zoom*scale); Y_Roof = Y_Roof / (zoom*scale); widthRoof = widthRoof / (zoom*scale); heightRoof = heightRoof / (zoom*scale); createArray3dCad(100, roofTex, roofType, X_Roof, Y_Roof, widthRoof, heightRoof, 0, converMMtoPX(300)); }