|
@@ -1,302 +0,0 @@
|
|
|
-import Geometry from "./Geometry";
|
|
|
-// import { mathUtil } from "../Util/MathUtil.js/index.js";
|
|
|
-import SelectState from "../enum/SelectState.js";
|
|
|
-import VectorType from "../enum/VectorType.js";
|
|
|
-import Constant from "../Constant.js";
|
|
|
-import { coordinate } from "../Coordinate";
|
|
|
-
|
|
|
-export default class Furniture extends Geometry {
|
|
|
- constructor(center, vectorId, type) {
|
|
|
- super();
|
|
|
- this.center = center;
|
|
|
- this.geoType = type;
|
|
|
- //this.boundingVertexs = []
|
|
|
- this.angle = 0; //逆时针为负,顺时针为正。单位是:°
|
|
|
- this.zoom = 1; //缩放比例
|
|
|
- this.setId(vectorId);
|
|
|
- }
|
|
|
-
|
|
|
- isContain(position) {
|
|
|
- // const dis = mathUtil.getDistance(position, this.center)
|
|
|
- // let len = this.getScale() * this.zoom
|
|
|
- // if (dis < len / 2) {
|
|
|
- // return SelectState.Select
|
|
|
- // } else {
|
|
|
- // return null
|
|
|
- // }
|
|
|
- const points2d = this.getBoundingVertexs(this.center);
|
|
|
- return mathUtil.isPointInPoly(position, points2d);
|
|
|
- }
|
|
|
-
|
|
|
- getScale() {
|
|
|
- switch (this.geoType) {
|
|
|
- case VectorType.TV: //电视
|
|
|
- return 1.3;
|
|
|
- case VectorType.CombinationSofa: //组合沙发
|
|
|
- return 3.4;
|
|
|
- case VectorType.SingleSofa: //单人沙发
|
|
|
- return 1;
|
|
|
- case VectorType.TeaTable: //茶几
|
|
|
- return 0.8;
|
|
|
- case VectorType.Carpet: //地毯
|
|
|
- return 2;
|
|
|
- case VectorType.Plant: //植物
|
|
|
- return 1;
|
|
|
- case VectorType.DiningTable: //餐桌
|
|
|
- return 2.4;
|
|
|
- case VectorType.DoubleBed: //双人床
|
|
|
- return 2;
|
|
|
- case VectorType.SingleBed: //单人床
|
|
|
- return 2;
|
|
|
- case VectorType.Wardrobe: //衣柜
|
|
|
- return 1.2;
|
|
|
- case VectorType.Dresser: //梳妆台
|
|
|
- return 0.8;
|
|
|
- case VectorType.BedsideCupboard: //床头柜
|
|
|
- return 0.4;
|
|
|
- case VectorType.Pillow: //抱枕
|
|
|
- return 0.6;
|
|
|
- case VectorType.GasStove: //燃气灶
|
|
|
- return 1;
|
|
|
- case VectorType.Cupboard: //橱柜
|
|
|
- return 1.2;
|
|
|
- case VectorType.Bathtub: //浴缸
|
|
|
- return 1.6;
|
|
|
- case VectorType.Closestool: //马桶
|
|
|
- return 0.63;
|
|
|
- case VectorType.Washstand: //洗漱台
|
|
|
- return 0.8;
|
|
|
- case VectorType.Desk: //书桌
|
|
|
- return 1.2;
|
|
|
- case VectorType.BalconyChair: //阳台椅
|
|
|
- return 2;
|
|
|
- case VectorType.Elevator: //电梯
|
|
|
- return 1.5;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- getLengthWidth() {
|
|
|
- switch (this.geoType) {
|
|
|
- case VectorType.TV: //电视
|
|
|
- return {
|
|
|
- length: 32,
|
|
|
- width: 10,
|
|
|
- };
|
|
|
- case VectorType.CombinationSofa: //组合沙发
|
|
|
- return {
|
|
|
- length: 32,
|
|
|
- width: 28,
|
|
|
- };
|
|
|
- case VectorType.SingleSofa: //单人沙发
|
|
|
- return {
|
|
|
- length: 26,
|
|
|
- width: 20,
|
|
|
- };
|
|
|
- case VectorType.TeaTable: //茶几
|
|
|
- return {
|
|
|
- length: 30,
|
|
|
- width: 16,
|
|
|
- };
|
|
|
- case VectorType.Carpet: //地毯
|
|
|
- return {
|
|
|
- length: 32,
|
|
|
- width: 20,
|
|
|
- };
|
|
|
- case VectorType.Plant: //植物
|
|
|
- return {
|
|
|
- length: 28,
|
|
|
- width: 28,
|
|
|
- };
|
|
|
- case VectorType.DiningTable: //餐桌
|
|
|
- return {
|
|
|
- length: 28,
|
|
|
- width: 26,
|
|
|
- };
|
|
|
- case VectorType.DoubleBed: //双人床
|
|
|
- return {
|
|
|
- length: 24,
|
|
|
- width: 26,
|
|
|
- };
|
|
|
- case VectorType.SingleBed: //单人床
|
|
|
- return {
|
|
|
- length: 18,
|
|
|
- width: 26,
|
|
|
- };
|
|
|
- case VectorType.Wardrobe: //衣柜
|
|
|
- return {
|
|
|
- length: 30,
|
|
|
- width: 18,
|
|
|
- };
|
|
|
- case VectorType.Dresser: //梳妆台
|
|
|
- return {
|
|
|
- length: 28,
|
|
|
- width: 26,
|
|
|
- };
|
|
|
- case VectorType.BedsideCupboard: //床头柜
|
|
|
- return {
|
|
|
- length: 28,
|
|
|
- width: 28,
|
|
|
- };
|
|
|
- case VectorType.Pillow: //抱枕
|
|
|
- return {
|
|
|
- length: 26,
|
|
|
- width: 26,
|
|
|
- };
|
|
|
- case VectorType.GasStove: //燃气灶
|
|
|
- return {
|
|
|
- length: 32,
|
|
|
- width: 20,
|
|
|
- };
|
|
|
- case VectorType.Cupboard: //橱柜
|
|
|
- return {
|
|
|
- length: 12,
|
|
|
- width: 32,
|
|
|
- };
|
|
|
- case VectorType.Bathtub: //浴缸
|
|
|
- return {
|
|
|
- length: 32,
|
|
|
- width: 18,
|
|
|
- };
|
|
|
- case VectorType.Closestool: //马桶
|
|
|
- return {
|
|
|
- length: 22,
|
|
|
- width: 28,
|
|
|
- };
|
|
|
- case VectorType.Washstand: //洗漱台
|
|
|
- return {
|
|
|
- length: 28,
|
|
|
- width: 20,
|
|
|
- };
|
|
|
- case VectorType.Desk: //书桌
|
|
|
- return {
|
|
|
- length: 26,
|
|
|
- width: 20,
|
|
|
- };
|
|
|
- case VectorType.BalconyChair: //阳台椅
|
|
|
- return {
|
|
|
- length: 32,
|
|
|
- width: 10,
|
|
|
- };
|
|
|
- case VectorType.Elevator: //电梯
|
|
|
- return {
|
|
|
- length: 28,
|
|
|
- width: 28,
|
|
|
- };
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /*
|
|
|
- getBoundingVertexs(center) {
|
|
|
- //this.boundingVertexs = []
|
|
|
- const boundingVertexs = []
|
|
|
- //const width = (((this.getScale() * Constant.furnitureWidth) / coordinate.res) * this.zoom)
|
|
|
- const width = this.getScale() * this.zoom
|
|
|
-
|
|
|
- const minX = center.x - width / 2
|
|
|
- const minY = center.y - width / 2
|
|
|
- const maxX = center.x + width / 2
|
|
|
- const maxY = center.y + width / 2
|
|
|
-
|
|
|
- const point1 = this.rotatePoint(
|
|
|
- {
|
|
|
- x: minX,
|
|
|
- y: maxY,
|
|
|
- },
|
|
|
- center,
|
|
|
- this.angle
|
|
|
- )
|
|
|
-
|
|
|
- const point2 = this.rotatePoint(
|
|
|
- {
|
|
|
- x: maxX,
|
|
|
- y: maxY,
|
|
|
- },
|
|
|
- center,
|
|
|
- this.angle
|
|
|
- )
|
|
|
-
|
|
|
- const point3 = this.rotatePoint(
|
|
|
- {
|
|
|
- x: maxX,
|
|
|
- y: minY,
|
|
|
- },
|
|
|
- center,
|
|
|
- this.angle
|
|
|
- )
|
|
|
-
|
|
|
- const point4 = this.rotatePoint(
|
|
|
- {
|
|
|
- x: minX,
|
|
|
- y: minY,
|
|
|
- },
|
|
|
- center,
|
|
|
- this.angle
|
|
|
- )
|
|
|
-
|
|
|
- boundingVertexs.push(point1)
|
|
|
- boundingVertexs.push(point2)
|
|
|
- boundingVertexs.push(point3)
|
|
|
- boundingVertexs.push(point4)
|
|
|
-
|
|
|
- return boundingVertexs
|
|
|
- }
|
|
|
- */
|
|
|
- getBoundingVertexs(center) {
|
|
|
- //this.boundingVertexs = []
|
|
|
- const boundingVertexs = [];
|
|
|
- const rec = this.getLengthWidth();
|
|
|
- //const width = (((this.getScale() * Constant.furnitureWidth) / coordinate.res) * this.zoom)
|
|
|
- const length =
|
|
|
- (this.getScale() * rec.length * this.zoom) / Constant.furnitureWidth;
|
|
|
- const width =
|
|
|
- (this.getScale() * rec.width * this.zoom) / Constant.furnitureWidth;
|
|
|
-
|
|
|
- const minX = center.x - length / 2;
|
|
|
- const minY = center.y - width / 2;
|
|
|
- const maxX = center.x + length / 2;
|
|
|
- const maxY = center.y + width / 2;
|
|
|
-
|
|
|
- const point1 = this.rotatePoint(
|
|
|
- {
|
|
|
- x: minX,
|
|
|
- y: maxY,
|
|
|
- },
|
|
|
- center,
|
|
|
- this.angle
|
|
|
- );
|
|
|
-
|
|
|
- const point2 = this.rotatePoint(
|
|
|
- {
|
|
|
- x: maxX,
|
|
|
- y: maxY,
|
|
|
- },
|
|
|
- center,
|
|
|
- this.angle
|
|
|
- );
|
|
|
-
|
|
|
- const point3 = this.rotatePoint(
|
|
|
- {
|
|
|
- x: maxX,
|
|
|
- y: minY,
|
|
|
- },
|
|
|
- center,
|
|
|
- this.angle
|
|
|
- );
|
|
|
-
|
|
|
- const point4 = this.rotatePoint(
|
|
|
- {
|
|
|
- x: minX,
|
|
|
- y: minY,
|
|
|
- },
|
|
|
- center,
|
|
|
- this.angle
|
|
|
- );
|
|
|
-
|
|
|
- boundingVertexs.push(point1);
|
|
|
- boundingVertexs.push(point2);
|
|
|
- boundingVertexs.push(point3);
|
|
|
- boundingVertexs.push(point4);
|
|
|
-
|
|
|
- return boundingVertexs;
|
|
|
- }
|
|
|
-}
|