@operato/scene-indoor-map 1.2.45 → 1.2.49

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,25 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [1.2.49](https://github.com/things-scene/operato-scene/compare/v1.2.48...v1.2.49) (2023-06-26)
7
+
8
+
9
+ ### :bug: Bug Fix
10
+
11
+ * missing .npmignore ([61ba4f2](https://github.com/things-scene/operato-scene/commit/61ba4f2ae22a865d700a971d62eb01f950c34d0e))
12
+
13
+
14
+
15
+ ## [1.2.46](https://github.com/things-scene/operato-scene/compare/v1.2.45...v1.2.46) (2023-06-10)
16
+
17
+
18
+ ### :bug: Bug Fix
19
+
20
+ * card layout related ([5b1e1d7](https://github.com/things-scene/operato-scene/commit/5b1e1d78d3307b9550bad33d113501db4cea6522))
21
+ * typescript build options ([3eb0d7f](https://github.com/things-scene/operato-scene/commit/3eb0d7fd80e2c3cea698501aa1d9d54903423a7b))
22
+
23
+
24
+
6
25
  ## [1.2.45](https://github.com/things-scene/operato-scene/compare/v1.2.44...v1.2.45) (2023-06-09)
7
26
 
8
27
 
package/dist/floor.js CHANGED
@@ -16,7 +16,7 @@ const NATURE = {
16
16
  action: function (floor) {
17
17
  let indoor = floor.parent;
18
18
  indoor.removeComponent(floor);
19
- indoor.set('activeIndex', 0);
19
+ indoor.setState('activeIndex', 0);
20
20
  }
21
21
  }
22
22
  }
package/dist/floor.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"floor.js","sourceRoot":"","sources":["../src/floor.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,SAAS,EAAmB,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAI9E,MAAM,MAAM,GAAoB;IAC9B,OAAO,EAAE,KAAK;IACd,SAAS,EAAE,IAAI;IACf,SAAS,EAAE,IAAI;IACf,UAAU,EAAE;QACV;YACE,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,QAAQ;YACf,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE;gBACR,IAAI,EAAE,eAAe;gBACrB,MAAM,EAAE,UAAU,KAAY;oBAC5B,IAAI,MAAM,GAAG,KAAK,CAAC,MAAmB,CAAA;oBACtC,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,CAAA;oBAC7B,MAAM,CAAC,GAAG,CAAC,aAAa,EAAE,CAAC,CAAC,CAAA;gBAC9B,CAAC;aACF;SACF;KACF;CACF,CAAA;AAED,MAAM,CAAC,OAAO,OAAO,KAAM,SAAQ,SAAS;IAG1C,IAAI,eAAe;QACjB,OAAO,KAAK,CAAA;IACd,CAAC;IAED,IAAI,cAAc;QAChB,OAAO,KAAK,CAAA;IACd,CAAC;IAED;;;;;;;OAOG;IACH,IAAI,OAAO;QACT,OAAO,KAAK,CAAA;IACd,CAAC;IAED;;;;;OAKG;IACH,IAAI,SAAS;QACX,OAAO,KAAK,CAAA;IACd,CAAC;IAED;;;;OAIG;IACH,IAAI,SAAS;QACX,OAAO,KAAK,CAAA;IACd,CAAC;IAED,IAAI,MAAM;QACR,OAAO,MAAM,CAAA;IACf,CAAC;CAsTF;AAED,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA","sourcesContent":["/*\n * Copyright © HatioLab Inc. All rights reserved.\n */\nimport { Component, ComponentNature, Container } from '@hatiolab/things-scene'\n\nimport IndoorMap from './indoor-map'\n\nconst NATURE: ComponentNature = {\n mutable: false,\n resizable: true,\n rotatable: true,\n properties: [\n {\n type: 'action',\n label: 'remove',\n name: 'remove',\n property: {\n icon: 'remove_circle',\n action: function (floor: Floor) {\n let indoor = floor.parent as IndoorMap\n indoor.removeComponent(floor)\n indoor.set('activeIndex', 0)\n }\n }\n }\n ]\n}\n\nexport default class Floor extends Container {\n private _clickPoint?: Component\n\n get hasTextProperty() {\n return false\n }\n\n get showMoveHandle() {\n return false\n }\n\n /*\n * PATH 리스트를 직접 수정할 수 있는 지를 결정한다.\n *\n * 일반적으로 PATH는 바운드 생성을 위해서 논리적으로 생성되므로, 직접 수정하지 않는다.(return false)\n * 그러나, 각 꼭지점들이 개별로 움직이는 다각형류는 path 라는 모델데이타를 가지므로, 직접수정이 가능할 수 있다.(return true)\n *\n * Immutable 컴포넌트의 형상을 바꾸는 방법은 바운드를 이용한 리사이즈나, 특별한 컨트롤을 통해서 가능하다.\n */\n get mutable() {\n return false\n }\n\n /*\n * BOUND를 통해서 리사이즈를 할 수 있는 지를 결정한다.\n *\n * 일반적으로 면적을 갖는 컴포넌트는 대체로 가능하다.(return true)\n * 그러나, LINE 등 면적을 가지지않는 컴포넌트는 가능하지 않도록 정의한다.(return false)\n */\n get resizable() {\n return false\n }\n\n /*\n * 회전을 할 수 있는 지를 결정한다.\n *\n * 일반적으로 모든 컴포넌트는 가능하다.(return true)\n */\n get rotatable() {\n return false\n }\n\n get nature() {\n return NATURE\n }\n\n // drawLocationMarkers(locations) {\n // for (let uuid in locations) {\n // let locInfo = locations[uuid]\n // let props = locInfo.props || {}\n\n // props.width = props.width || 10\n // props.height = props.height || 10\n\n // let currentTime = new Date().getTime()\n // // let diffTime = 500\n // let diffTime = currentTime - locInfo.lastUpdateTime\n\n // if (diffTime < locInfo.updateInterval) {\n // let movingObject = this.findById(uuid)\n // if (movingObject) {\n // // props.yaw = 0;\n // // props.roll = 0;\n\n // movingObject.set(props)\n // for (let key in props) {\n // movingObject[key] = props[key]\n // }\n // } else {\n // // TODO: marker의 초기값 관련 로직 정리 필요.\n\n // let config = Object.assign(\n // {\n // type: locInfo.type || 'rect',\n // // type: locInfo.type || \"camera\",\n // id: uuid,\n // fillStyle: 'red',\n // left: props.center.x - props.width * 0.5,\n // top: props.center.y - props.height * 0.5,\n // cx: props.center.x,\n // cy: props.center.y\n // },\n // props\n // )\n\n // let marker = Model.compile(config)\n\n // this.addComponent(marker)\n\n // // movingObject = this.findById(uuid)\n // // if(movingObject) {\n // // movingObject.set(props);\n // // }\n // }\n // } else {\n // let movingObject = this.findById(uuid)\n // this.removeComponent(movingObject)\n // }\n\n // this.invalidate()\n // }\n // }\n\n // simulate(point) {\n // // for(let i in this.components) {\n // // if(this.components[i].model.type != 'beacon')\n // // continue;\n // //\n // // let beacon = this.components[i]\n // // let distance = Math.sqrt(Math.pow(beacon.center.x - point.x, 2) + Math.pow(beacon.center.y - point.y, 2)) * 0.01\n // // let rssi = -10 * Math.log10(distance) + (beacon.txPower || -71)\n // //\n // // let randRssi = gaussian(rssi, Math.pow(4.894686948810031, 2))\n // //\n // // rssi = randRssi.ppf(Math.random())\n // //\n // // console.log(rssi);\n // // }\n\n // let beacons: {\n // distance: number;\n // gaussian: number;\n // txPower: number;\n // }[] = []\n\n // for (let i in this.components) {\n // if (this.components[i].model.type != 'beacon') continue\n\n // let beacon = this.components[i]\n\n // beacon.distance = Math.sqrt(\n // Math.pow(beacon.center.x - point.x, 2) +\n // Math.pow(beacon.center.y - point.y, 2)\n // )\n // beacon.gaussian = gaussian(\n // beacon.model.txPower || -71,\n // Math.pow(3.209, 2)\n // )\n // beacon.txPower = beacon.gaussian.ppf(Math.random())\n\n // beacons.push(beacon)\n // }\n\n // beacons = beacons.slice(0)\n\n // this.calculatePosition(beacons, point)\n // }\n\n // calculatePosition(nodeArr, position) {\n // let beacons = nodeArr\n\n // beacons.sort(function(a, b) {\n // let rssiA = -10 * Math.log10(a.distance) + a.txPower\n // let rssiB = -10 * Math.log10(b.distance) + b.txPower\n\n // return Math.abs(rssiA) - Math.abs(rssiB)\n // })\n\n // let beaconCombs = this.k_combinations(beacons.slice(0, 4), 3)\n // let positions = []\n\n // for (let i in beaconCombs) {\n // let beaconComb = beaconCombs[i]\n // let beaconA = beaconComb[0]\n // let beaconB = beaconComb[1]\n // let beaconC = beaconComb[2]\n\n // let xa = beaconA.center.x\n // let ya = beaconA.center.y\n // let xb = beaconB.center.x\n // let yb = beaconB.center.y\n // let xc = beaconC.center.x\n // let yc = beaconC.center.y\n // let ra = beaconA.distance\n // let rb = beaconB.distance\n // let rc = beaconC.distance\n\n // // let ra = Math.sqrt(Math.pow(beaconA.center.x - position.x, 2) + Math.pow(beaconA.center.y - position.y, 2)) * 0.01\n // // let rb = Math.sqrt(Math.pow(beaconB.center.x - position.x, 2) + Math.pow(beaconB.center.y - position.y, 2)) * 0.01\n // // let rc = Math.sqrt(Math.pow(beaconC.center.x - position.x, 2) + Math.pow(beaconC.center.y - position.y, 2)) * 0.01\n\n // let rssiA = -10 * Math.log10(beaconA.distance * 0.01) + beaconA.txPower\n // let rssiB = -10 * Math.log10(beaconB.distance * 0.01) + beaconB.txPower\n // let rssiC = -10 * Math.log10(beaconC.distance * 0.01) + beaconC.txPower\n\n // ra = this.calculateDistance(beaconA.txPower, rssiA) * 100\n // rb = this.calculateDistance(beaconB.txPower, rssiB) * 100\n // rc = this.calculateDistance(beaconC.txPower, rssiC) * 100\n\n // let xaSq = xa * xa,\n // xbSq = xb * xb,\n // xcSq = xc * xc,\n // yaSq = ya * ya,\n // ybSq = yb * yb,\n // ycSq = yc * yc,\n // raSq = ra * ra,\n // rbSq = rb * rb,\n // rcSq = rc * rc\n // let numerator1 =\n // (xb - xa) * (xcSq + ycSq - rcSq) +\n // (xa - xc) * (xbSq + ybSq - rbSq) +\n // (xc - xb) * (xaSq + yaSq - raSq)\n // let denominator1 = 2 * (yc * (xb - xa) + yb * (xa - xc) + ya * (xc - xb))\n // let y = numerator1 / denominator1\n // let numerator2 =\n // rbSq - raSq + xaSq - xbSq + yaSq - ybSq - 2 * (ya - yb) * y\n // let denominator2 = 2 * (xa - xb)\n // let x = numerator2 / denominator2\n\n // if (Number.isFinite(x) && Number.isFinite(y)) {\n // positions.push({\n // x: x,\n // y: y\n // })\n // }\n // }\n\n // let avgPosition = this.averageOfPositions(positions)\n\n // if (this._simPosition) this.removeComponent(this._simPosition)\n\n // this._simPosition = Model.compile({\n // type: 'ellipse',\n // cx: avgPosition.x,\n // cy: avgPosition.y,\n // rx: 10,\n // ry: 10,\n // fillStyle: 'navy'\n // })\n\n // this.addComponent(this._simPosition)\n // }\n\n // calculateDistance(txPower, rssi) {\n // if (rssi == 0) {\n // return -1.0 // if we cannot determine distance, return -1.\n // }\n\n // let ratio = (rssi * 1.0) / txPower\n // if (ratio < 1.0) {\n // return Math.pow(ratio, 10)\n // } else {\n // let accuracy = 0.89976 * Math.pow(ratio, 7.7095) + 0.111\n // return accuracy\n // }\n // }\n\n // calculateAngle(p1, p2, p3) {\n // let l1 = Math.pow(p2.x - p1.x, 2) + Math.pow(p2.y - p1.y, 2),\n // l2 = Math.pow(p2.x - p3.x, 2) + Math.pow(p2.y - p3.y, 2),\n // l3 = Math.pow(p3.x - p1.x, 2) + Math.pow(p3.y - p1.y, 2)\n\n // return Math.acos((l1 + l2 - l3) / Math.sqrt(4 * l1 * l2))\n // }\n\n // averageOfPositions(p) {\n // let sumOfX = 0\n // let sumOfY = 0\n\n // for (let i in p) {\n // let point = p[i]\n // sumOfX += point.x\n // sumOfY += point.y\n // }\n\n // return {\n // x: sumOfX / p.length,\n // y: sumOfY / p.length\n // }\n // }\n\n // k_combinations(set, k) {\n // var i, j, combs, head, tailcombs\n\n // // There is no way to take e.g. sets of 5 elements from\n // // a set of 4.\n // if (k > set.length || k <= 0) {\n // return []\n // }\n\n // // K-sized set has only one K-sized subset.\n // if (k == set.length) {\n // return [set]\n // }\n\n // // There is N 1-sized subsets in a N-sized set.\n // if (k == 1) {\n // combs = []\n // for (i = 0; i < set.length; i++) {\n // combs.push([set[i]])\n // }\n // return combs\n // }\n\n // // Assert {1 < k < set.length}\n\n // // Algorithm description:\n // // To get k-combinations of a set, we want to join each element\n // // with all (k-1)-combinations of the other elements. The set of\n // // these k-sized sets would be the desired result. However, as we\n // // represent sets with lists, we need to take duplicates into\n // // account. To avoid producing duplicates and also unnecessary\n // // computing, we use the following approach: each element i\n // // divides the list into three: the preceding elements, the\n // // current element i, and the subsequent elements. For the first\n // // element, the list of preceding elements is empty. For element i,\n // // we compute the (k-1)-computations of the subsequent elements,\n // // join each with the element i, and store the joined to the set of\n // // computed k-combinations. We do not need to take the preceding\n // // elements into account, because they have already been the i:th\n // // element so they are already computed and stored. When the length\n // // of the subsequent list drops below (k-1), we cannot find any\n // // (k-1)-combs, hence the upper limit for the iteration:\n // combs = []\n // for (i = 0; i < set.length - k + 1; i++) {\n // // head is a list that includes only our current element.\n // head = set.slice(i, i + 1)\n // // We take smaller combinations from the subsequent elements\n // tailcombs = this.k_combinations(set.slice(i + 1), k - 1)\n // // For each (k-1)-combination we join it with the current\n // // and store it to the set of k-combinations.\n // for (j = 0; j < tailcombs.length; j++) {\n // combs.push(head.concat(tailcombs[j]))\n // }\n // }\n // return combs\n // }\n\n // onclick(e) {\n // return\n\n // let point = this.transcoordC2S(e.offsetX, e.offsetY)\n\n // if (this._clickPoint) {\n // this.removeComponent(this._clickPoint)\n // }\n\n // this._clickPoint = Model.compile({\n // type: 'ellipse',\n // cx: point.x,\n // cy: point.y,\n // rx: 10,\n // ry: 10,\n // fillStyle: 'red'\n // })\n\n // this.addComponent(this._clickPoint)\n // this.simulate(point)\n // // let self = this\n // // setTimeout(function() {\n // // self.simulate(point)\n // // }, 500)\n // this.invalidate()\n // }\n}\n\nComponent.register('floor', Floor)\n"]}
1
+ {"version":3,"file":"floor.js","sourceRoot":"","sources":["../src/floor.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,SAAS,EAAmB,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAI9E,MAAM,MAAM,GAAoB;IAC9B,OAAO,EAAE,KAAK;IACd,SAAS,EAAE,IAAI;IACf,SAAS,EAAE,IAAI;IACf,UAAU,EAAE;QACV;YACE,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,QAAQ;YACf,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE;gBACR,IAAI,EAAE,eAAe;gBACrB,MAAM,EAAE,UAAU,KAAY;oBAC5B,IAAI,MAAM,GAAG,KAAK,CAAC,MAAmB,CAAA;oBACtC,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,CAAA;oBAC7B,MAAM,CAAC,QAAQ,CAAC,aAAa,EAAE,CAAC,CAAC,CAAA;gBACnC,CAAC;aACF;SACF;KACF;CACF,CAAA;AAED,MAAM,CAAC,OAAO,OAAO,KAAM,SAAQ,SAAS;IAG1C,IAAI,eAAe;QACjB,OAAO,KAAK,CAAA;IACd,CAAC;IAED,IAAI,cAAc;QAChB,OAAO,KAAK,CAAA;IACd,CAAC;IAED;;;;;;;OAOG;IACH,IAAI,OAAO;QACT,OAAO,KAAK,CAAA;IACd,CAAC;IAED;;;;;OAKG;IACH,IAAI,SAAS;QACX,OAAO,KAAK,CAAA;IACd,CAAC;IAED;;;;OAIG;IACH,IAAI,SAAS;QACX,OAAO,KAAK,CAAA;IACd,CAAC;IAED,IAAI,MAAM;QACR,OAAO,MAAM,CAAA;IACf,CAAC;CAsTF;AAED,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA","sourcesContent":["/*\n * Copyright © HatioLab Inc. All rights reserved.\n */\nimport { Component, ComponentNature, Container } from '@hatiolab/things-scene'\n\nimport IndoorMap from './indoor-map'\n\nconst NATURE: ComponentNature = {\n mutable: false,\n resizable: true,\n rotatable: true,\n properties: [\n {\n type: 'action',\n label: 'remove',\n name: 'remove',\n property: {\n icon: 'remove_circle',\n action: function (floor: Floor) {\n let indoor = floor.parent as IndoorMap\n indoor.removeComponent(floor)\n indoor.setState('activeIndex', 0)\n }\n }\n }\n ]\n}\n\nexport default class Floor extends Container {\n private _clickPoint?: Component\n\n get hasTextProperty() {\n return false\n }\n\n get showMoveHandle() {\n return false\n }\n\n /*\n * PATH 리스트를 직접 수정할 수 있는 지를 결정한다.\n *\n * 일반적으로 PATH는 바운드 생성을 위해서 논리적으로 생성되므로, 직접 수정하지 않는다.(return false)\n * 그러나, 각 꼭지점들이 개별로 움직이는 다각형류는 path 라는 모델데이타를 가지므로, 직접수정이 가능할 수 있다.(return true)\n *\n * Immutable 컴포넌트의 형상을 바꾸는 방법은 바운드를 이용한 리사이즈나, 특별한 컨트롤을 통해서 가능하다.\n */\n get mutable() {\n return false\n }\n\n /*\n * BOUND를 통해서 리사이즈를 할 수 있는 지를 결정한다.\n *\n * 일반적으로 면적을 갖는 컴포넌트는 대체로 가능하다.(return true)\n * 그러나, LINE 등 면적을 가지지않는 컴포넌트는 가능하지 않도록 정의한다.(return false)\n */\n get resizable() {\n return false\n }\n\n /*\n * 회전을 할 수 있는 지를 결정한다.\n *\n * 일반적으로 모든 컴포넌트는 가능하다.(return true)\n */\n get rotatable() {\n return false\n }\n\n get nature() {\n return NATURE\n }\n\n // drawLocationMarkers(locations) {\n // for (let uuid in locations) {\n // let locInfo = locations[uuid]\n // let props = locInfo.props || {}\n\n // props.width = props.width || 10\n // props.height = props.height || 10\n\n // let currentTime = new Date().getTime()\n // // let diffTime = 500\n // let diffTime = currentTime - locInfo.lastUpdateTime\n\n // if (diffTime < locInfo.updateInterval) {\n // let movingObject = this.findById(uuid)\n // if (movingObject) {\n // // props.yaw = 0;\n // // props.roll = 0;\n\n // movingObject.set(props)\n // for (let key in props) {\n // movingObject[key] = props[key]\n // }\n // } else {\n // // TODO: marker의 초기값 관련 로직 정리 필요.\n\n // let config = Object.assign(\n // {\n // type: locInfo.type || 'rect',\n // // type: locInfo.type || \"camera\",\n // id: uuid,\n // fillStyle: 'red',\n // left: props.center.x - props.width * 0.5,\n // top: props.center.y - props.height * 0.5,\n // cx: props.center.x,\n // cy: props.center.y\n // },\n // props\n // )\n\n // let marker = Model.compile(config)\n\n // this.addComponent(marker)\n\n // // movingObject = this.findById(uuid)\n // // if(movingObject) {\n // // movingObject.set(props);\n // // }\n // }\n // } else {\n // let movingObject = this.findById(uuid)\n // this.removeComponent(movingObject)\n // }\n\n // this.invalidate()\n // }\n // }\n\n // simulate(point) {\n // // for(let i in this.components) {\n // // if(this.components[i].model.type != 'beacon')\n // // continue;\n // //\n // // let beacon = this.components[i]\n // // let distance = Math.sqrt(Math.pow(beacon.center.x - point.x, 2) + Math.pow(beacon.center.y - point.y, 2)) * 0.01\n // // let rssi = -10 * Math.log10(distance) + (beacon.txPower || -71)\n // //\n // // let randRssi = gaussian(rssi, Math.pow(4.894686948810031, 2))\n // //\n // // rssi = randRssi.ppf(Math.random())\n // //\n // // console.log(rssi);\n // // }\n\n // let beacons: {\n // distance: number;\n // gaussian: number;\n // txPower: number;\n // }[] = []\n\n // for (let i in this.components) {\n // if (this.components[i].model.type != 'beacon') continue\n\n // let beacon = this.components[i]\n\n // beacon.distance = Math.sqrt(\n // Math.pow(beacon.center.x - point.x, 2) +\n // Math.pow(beacon.center.y - point.y, 2)\n // )\n // beacon.gaussian = gaussian(\n // beacon.model.txPower || -71,\n // Math.pow(3.209, 2)\n // )\n // beacon.txPower = beacon.gaussian.ppf(Math.random())\n\n // beacons.push(beacon)\n // }\n\n // beacons = beacons.slice(0)\n\n // this.calculatePosition(beacons, point)\n // }\n\n // calculatePosition(nodeArr, position) {\n // let beacons = nodeArr\n\n // beacons.sort(function(a, b) {\n // let rssiA = -10 * Math.log10(a.distance) + a.txPower\n // let rssiB = -10 * Math.log10(b.distance) + b.txPower\n\n // return Math.abs(rssiA) - Math.abs(rssiB)\n // })\n\n // let beaconCombs = this.k_combinations(beacons.slice(0, 4), 3)\n // let positions = []\n\n // for (let i in beaconCombs) {\n // let beaconComb = beaconCombs[i]\n // let beaconA = beaconComb[0]\n // let beaconB = beaconComb[1]\n // let beaconC = beaconComb[2]\n\n // let xa = beaconA.center.x\n // let ya = beaconA.center.y\n // let xb = beaconB.center.x\n // let yb = beaconB.center.y\n // let xc = beaconC.center.x\n // let yc = beaconC.center.y\n // let ra = beaconA.distance\n // let rb = beaconB.distance\n // let rc = beaconC.distance\n\n // // let ra = Math.sqrt(Math.pow(beaconA.center.x - position.x, 2) + Math.pow(beaconA.center.y - position.y, 2)) * 0.01\n // // let rb = Math.sqrt(Math.pow(beaconB.center.x - position.x, 2) + Math.pow(beaconB.center.y - position.y, 2)) * 0.01\n // // let rc = Math.sqrt(Math.pow(beaconC.center.x - position.x, 2) + Math.pow(beaconC.center.y - position.y, 2)) * 0.01\n\n // let rssiA = -10 * Math.log10(beaconA.distance * 0.01) + beaconA.txPower\n // let rssiB = -10 * Math.log10(beaconB.distance * 0.01) + beaconB.txPower\n // let rssiC = -10 * Math.log10(beaconC.distance * 0.01) + beaconC.txPower\n\n // ra = this.calculateDistance(beaconA.txPower, rssiA) * 100\n // rb = this.calculateDistance(beaconB.txPower, rssiB) * 100\n // rc = this.calculateDistance(beaconC.txPower, rssiC) * 100\n\n // let xaSq = xa * xa,\n // xbSq = xb * xb,\n // xcSq = xc * xc,\n // yaSq = ya * ya,\n // ybSq = yb * yb,\n // ycSq = yc * yc,\n // raSq = ra * ra,\n // rbSq = rb * rb,\n // rcSq = rc * rc\n // let numerator1 =\n // (xb - xa) * (xcSq + ycSq - rcSq) +\n // (xa - xc) * (xbSq + ybSq - rbSq) +\n // (xc - xb) * (xaSq + yaSq - raSq)\n // let denominator1 = 2 * (yc * (xb - xa) + yb * (xa - xc) + ya * (xc - xb))\n // let y = numerator1 / denominator1\n // let numerator2 =\n // rbSq - raSq + xaSq - xbSq + yaSq - ybSq - 2 * (ya - yb) * y\n // let denominator2 = 2 * (xa - xb)\n // let x = numerator2 / denominator2\n\n // if (Number.isFinite(x) && Number.isFinite(y)) {\n // positions.push({\n // x: x,\n // y: y\n // })\n // }\n // }\n\n // let avgPosition = this.averageOfPositions(positions)\n\n // if (this._simPosition) this.removeComponent(this._simPosition)\n\n // this._simPosition = Model.compile({\n // type: 'ellipse',\n // cx: avgPosition.x,\n // cy: avgPosition.y,\n // rx: 10,\n // ry: 10,\n // fillStyle: 'navy'\n // })\n\n // this.addComponent(this._simPosition)\n // }\n\n // calculateDistance(txPower, rssi) {\n // if (rssi == 0) {\n // return -1.0 // if we cannot determine distance, return -1.\n // }\n\n // let ratio = (rssi * 1.0) / txPower\n // if (ratio < 1.0) {\n // return Math.pow(ratio, 10)\n // } else {\n // let accuracy = 0.89976 * Math.pow(ratio, 7.7095) + 0.111\n // return accuracy\n // }\n // }\n\n // calculateAngle(p1, p2, p3) {\n // let l1 = Math.pow(p2.x - p1.x, 2) + Math.pow(p2.y - p1.y, 2),\n // l2 = Math.pow(p2.x - p3.x, 2) + Math.pow(p2.y - p3.y, 2),\n // l3 = Math.pow(p3.x - p1.x, 2) + Math.pow(p3.y - p1.y, 2)\n\n // return Math.acos((l1 + l2 - l3) / Math.sqrt(4 * l1 * l2))\n // }\n\n // averageOfPositions(p) {\n // let sumOfX = 0\n // let sumOfY = 0\n\n // for (let i in p) {\n // let point = p[i]\n // sumOfX += point.x\n // sumOfY += point.y\n // }\n\n // return {\n // x: sumOfX / p.length,\n // y: sumOfY / p.length\n // }\n // }\n\n // k_combinations(set, k) {\n // var i, j, combs, head, tailcombs\n\n // // There is no way to take e.g. sets of 5 elements from\n // // a set of 4.\n // if (k > set.length || k <= 0) {\n // return []\n // }\n\n // // K-sized set has only one K-sized subset.\n // if (k == set.length) {\n // return [set]\n // }\n\n // // There is N 1-sized subsets in a N-sized set.\n // if (k == 1) {\n // combs = []\n // for (i = 0; i < set.length; i++) {\n // combs.push([set[i]])\n // }\n // return combs\n // }\n\n // // Assert {1 < k < set.length}\n\n // // Algorithm description:\n // // To get k-combinations of a set, we want to join each element\n // // with all (k-1)-combinations of the other elements. The set of\n // // these k-sized sets would be the desired result. However, as we\n // // represent sets with lists, we need to take duplicates into\n // // account. To avoid producing duplicates and also unnecessary\n // // computing, we use the following approach: each element i\n // // divides the list into three: the preceding elements, the\n // // current element i, and the subsequent elements. For the first\n // // element, the list of preceding elements is empty. For element i,\n // // we compute the (k-1)-computations of the subsequent elements,\n // // join each with the element i, and store the joined to the set of\n // // computed k-combinations. We do not need to take the preceding\n // // elements into account, because they have already been the i:th\n // // element so they are already computed and stored. When the length\n // // of the subsequent list drops below (k-1), we cannot find any\n // // (k-1)-combs, hence the upper limit for the iteration:\n // combs = []\n // for (i = 0; i < set.length - k + 1; i++) {\n // // head is a list that includes only our current element.\n // head = set.slice(i, i + 1)\n // // We take smaller combinations from the subsequent elements\n // tailcombs = this.k_combinations(set.slice(i + 1), k - 1)\n // // For each (k-1)-combination we join it with the current\n // // and store it to the set of k-combinations.\n // for (j = 0; j < tailcombs.length; j++) {\n // combs.push(head.concat(tailcombs[j]))\n // }\n // }\n // return combs\n // }\n\n // onclick(e) {\n // return\n\n // let point = this.transcoordC2S(e.offsetX, e.offsetY)\n\n // if (this._clickPoint) {\n // this.removeComponent(this._clickPoint)\n // }\n\n // this._clickPoint = Model.compile({\n // type: 'ellipse',\n // cx: point.x,\n // cy: point.y,\n // rx: 10,\n // ry: 10,\n // fillStyle: 'red'\n // })\n\n // this.addComponent(this._clickPoint)\n // this.simulate(point)\n // // let self = this\n // // setTimeout(function() {\n // // self.simulate(point)\n // // }, 500)\n // this.invalidate()\n // }\n}\n\nComponent.register('floor', Floor)\n"]}
@@ -1,5 +1,4 @@
1
1
  import { ComponentNature, Container, State } from '@hatiolab/things-scene';
2
- import Floor from './floor';
3
2
  export default class IndoorMap extends Container {
4
3
  private _focused;
5
4
  private __down_point?;
@@ -7,7 +6,6 @@ export default class IndoorMap extends Container {
7
6
  get layout(): import("@hatiolab/things-scene").LAYOUT;
8
7
  get layoutConfig(): any;
9
8
  set layoutConfig(config: any);
10
- get activeFloor(): Floor;
11
9
  get activeIndex(): number;
12
10
  set activeIndex(activeIndex: number);
13
11
  ready(): void;
@@ -44,14 +44,13 @@ export default class IndoorMap extends Container {
44
44
  return CardLayout;
45
45
  }
46
46
  get layoutConfig() {
47
- return this.getState('layoutConfig');
47
+ return (this.getState('layoutConfig') || {
48
+ activeIndex: this.activeIndex
49
+ });
48
50
  }
49
51
  set layoutConfig(config) {
50
52
  this.setState('layoutConfig', config);
51
53
  }
52
- get activeFloor() {
53
- return this.components[this.getState('layoutConfig').activeIndex];
54
- }
55
54
  get activeIndex() {
56
55
  return this.getState('activeIndex');
57
56
  }
@@ -60,8 +59,13 @@ export default class IndoorMap extends Container {
60
59
  }
61
60
  ready() {
62
61
  super.ready();
63
- if (this.components.length == 0)
62
+ if (this.components.length == 0) {
64
63
  this.addFloor();
64
+ }
65
+ this.layoutConfig = {
66
+ ...this.layoutConfig,
67
+ activeIndex: this.activeIndex
68
+ };
65
69
  }
66
70
  postrender(context) {
67
71
  if (!this.app.isViewMode && this._focused) {
@@ -128,10 +132,12 @@ export default class IndoorMap extends Container {
128
132
  return;
129
133
  y /= LABEL_HEIGHT;
130
134
  y = Math.floor(y);
131
- if (!this.layoutConfig)
135
+ if (!this.layoutConfig) {
132
136
  this.layoutConfig = {};
133
- if (y >= this.components.length)
137
+ }
138
+ if (y >= this.components.length) {
134
139
  return;
140
+ }
135
141
  // /* 생성 버튼이 클릭되면, 새로운 floor를 추가한다. */
136
142
  // if(y == this.components.length) {
137
143
  // this.add(Model.compile({
@@ -1 +1 @@
1
- {"version":3,"file":"indoor-map.js","sourceRoot":"","sources":["../src/indoor-map.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAmB,SAAS,EAAE,KAAK,EAAgB,MAAM,wBAAwB,CAAA;AAI/G,MAAM,WAAW,GAAG,EAAE,CAAA;AACtB,MAAM,YAAY,GAAG,EAAE,CAAA;AAEvB,SAAS,IAAI,CAAC,CAAS,EAAE,CAAS,EAAE,CAAS,EAAE,CAAS;IACtD,OAAO,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAA;AACvC,CAAC;AAED,MAAM,MAAM,GAAoB;IAC9B,OAAO,EAAE,KAAK;IACd,SAAS,EAAE,IAAI;IACf,SAAS,EAAE,IAAI;IACf,UAAU,EAAE;QACV;YACE,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,WAAW;YAClB,IAAI,EAAE,UAAU;Y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AG,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAA;QAC/D,MAAM,GAAG,GAAG,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;QAE9B,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC;YAC1B,IAAI,EAAE,OAAO;YACb,SAAS,EAAE,IAAI,GAAG,GAAG,GAAG,GAAG,GAAG,EAAE;YAChC,GAAG,EAAE,CAAC;YACN,IAAI,EAAE,CAAC;YACP,KAAK,EAAE,GAAG;YACV,MAAM,EAAE,GAAG;SACZ,CAAC,CAAA;QAEF,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,CAAA;QACxB,IAAI,CAAC,QAAQ,CAAC,aAAa,EAAE,IAAI,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;IAC1D,CAAC;CACF;AAED,SAAS,CAAC,QAAQ,CAAC,YAAY,EAAE,SAAS,CAAC,CAAA","sourcesContent":["/*\n * Copyright © HatioLab Inc. All rights reserved.\n */\nimport { CardLayout, Component, ComponentNature, Container, Model, POINT, State } from '@hatiolab/things-scene'\n\nimport Floor from './floor'\n\nconst LABEL_WIDTH = 25\nconst LABEL_HEIGHT = 25\n\nfunction rgba(r: number, g: number, b: number, a: number) {\n return `rgba(${r}, ${g}, ${b}, ${a})`\n}\n\nconst NATURE: ComponentNature = {\n mutable: false,\n resizable: true,\n rotatable: true,\n properties: [\n {\n type: 'action',\n label: 'add-floor',\n name: 'addFloor',\n property: {\n icon: 'add_circle',\n action: (indoorMap: IndoorMap) => {\n indoorMap.addFloor()\n }\n }\n },\n {\n type: 'number',\n label: 'active index',\n name: 'activeIndex'\n }\n ],\n 'value-property': 'activeIndex',\n help: 'scene/component/indoor-map'\n}\n\nexport default class IndoorMap extends Container {\n private _focused: boolean = false\n private __down_point?: POINT\n\n get nature() {\n return NATURE\n }\n\n get layout() {\n return CardLayout\n }\n\n get layoutConfig() {\n return this.getState('layoutConfig')\n }\n\n set layoutConfig(config) {\n this.setState('layoutConfig', config)\n }\n\n get activeFloor(): Floor {\n return this.components[this.getState('layoutConfig').activeIndex] as Floor\n }\n\n get activeIndex() {\n return this.getState('activeIndex')\n }\n\n set activeIndex(activeIndex: number) {\n this.setState('activeIndex', Number(activeIndex))\n }\n\n ready() {\n super.ready()\n\n if (this.components.length == 0) this.addFloor()\n }\n\n postrender(context: CanvasRenderingContext2D) {\n if (!this.app.isViewMode && this._focused) {\n var { left, top, width, fillStyle } = this.state\n\n // floor 선택 탭 그리기\n for (let i = 0; i < this.components.length; i++) {\n context.beginPath()\n\n context.rect(left - LABEL_WIDTH, top + i * LABEL_HEIGHT, LABEL_WIDTH, LABEL_HEIGHT)\n\n let color = 255 - ((20 * (i + 1)) % 255)\n context.fillStyle = rgba(color, color, color, 1)\n context.fill()\n\n context.closePath()\n }\n\n context.beginPath()\n\n context.moveTo(left, top)\n context.lineTo(left - LABEL_WIDTH, top)\n context.lineTo(left - LABEL_WIDTH, top + this.components.length * LABEL_HEIGHT)\n context.lineTo(left, top + this.components.length * LABEL_HEIGHT)\n\n context.strokeStyle = '#ccc'\n context.stroke()\n\n context.closePath()\n }\n\n super.postrender(context)\n }\n\n contains(x: number, y: number) {\n var contains = super.contains(x, y)\n\n if (this.app.isViewMode) return contains\n\n var { left, top, width } = this.bounds\n var h = LABEL_HEIGHT\n\n contains =\n contains ||\n // card selector 영역에 포함되는지\n (x < Math.max(left - LABEL_WIDTH, left) &&\n x > Math.min(left - LABEL_WIDTH, left) &&\n y < Math.max(top + h * this.size(), top) &&\n y > Math.min(top + h * this.size(), top))\n\n if (contains) this._focused = true\n else this._focused = false\n\n this.invalidate()\n return contains\n }\n\n onchange(after: State) {\n if ('activeIndex' in after) {\n this.layoutConfig = {\n ...this.layoutConfig,\n activeIndex: after.activeIndex\n }\n }\n }\n\n onmouseup(e: MouseEvent) {\n var down_point = this.__down_point\n delete this.__down_point\n\n if (!down_point || down_point.x != e.offsetX || down_point.y != e.offsetY) {\n return\n }\n\n var point = this.transcoordC2S(e.offsetX, e.offsetY)\n\n var { left, top } = this.state\n\n var x = point.x - left\n var y = point.y - top\n\n if (x > 0) return\n\n y /= LABEL_HEIGHT\n y = Math.floor(y)\n\n if (!this.layoutConfig) this.layoutConfig = {}\n\n if (y >= this.components.length) return\n\n // /* 생성 버튼이 클릭되면, 새로운 floor를 추가한다. */\n // if(y == this.components.length) {\n // this.add(Model.compile({\n // type: 'floor',\n // width: 100,\n // height: 100\n // }))\n // }\n this.setState('activeIndex', y)\n }\n\n onmousedown(e: MouseEvent) {\n this.__down_point = {\n x: e.offsetX,\n y: e.offsetY\n }\n }\n\n addFloor() {\n const color = 255 - ((20 * (this.components.length + 1)) % 255)\n const hex = color.toString(16)\n\n const floor = Model.compile({\n type: 'floor',\n fillStyle: `#${hex}${hex}${hex}`,\n top: 0,\n left: 0,\n width: 100,\n height: 100\n })\n\n this.addComponent(floor)\n this.setState('activeIndex', this.components.length - 1)\n }\n}\n\nComponent.register('indoor-map', IndoorMap)\n"]}
1
+ {"version":3,"file":"indoor-map.js","sourceRoot":"","sources":["../src/indoor-map.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAmB,SAAS,EAAE,KAAK,EAAgB,MAAM,wBAAwB,CAAA;AAE/G,MAAM,WAAW,GAAG,EAAE,CAAA;AACtB,MAAM,YAAY,GAAG,EAAE,CAAA;AAEvB,SAAS,IAAI,CAAC,CAAS,EAAE,CAAS,EAAE,CAAS,EAAE,CAAS;IACtD,OAAO,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAA;AACvC,CAAC;AAED,MAAM,MAAM,GAAoB;IAC9B,OAAO,EAAE,KAAK;IACd,SAAS,EAAE,IAAI;IACf,SAAS,EAAE,IAAI;IACf,UAAU,EAAE;QACV;YACE,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,WAAW;YAClB,IAAI,EAAE,UAAU;YAChB,QAAQ,EAAE;gBACR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AAE,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAA;QAC/D,MAAM,GAAG,GAAG,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;QAE9B,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC;YAC1B,IAAI,EAAE,OAAO;YACb,SAAS,EAAE,IAAI,GAAG,GAAG,GAAG,GAAG,GAAG,EAAE;YAChC,GAAG,EAAE,CAAC;YACN,IAAI,EAAE,CAAC;YACP,KAAK,EAAE,GAAG;YACV,MAAM,EAAE,GAAG;SACZ,CAAC,CAAA;QAEF,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,CAAA;QACxB,IAAI,CAAC,QAAQ,CAAC,aAAa,EAAE,IAAI,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;IAC1D,CAAC;CACF;AAED,SAAS,CAAC,QAAQ,CAAC,YAAY,EAAE,SAAS,CAAC,CAAA","sourcesContent":["/*\n * Copyright © HatioLab Inc. All rights reserved.\n */\nimport { CardLayout, Component, ComponentNature, Container, Model, POINT, State } from '@hatiolab/things-scene'\n\nconst LABEL_WIDTH = 25\nconst LABEL_HEIGHT = 25\n\nfunction rgba(r: number, g: number, b: number, a: number) {\n return `rgba(${r}, ${g}, ${b}, ${a})`\n}\n\nconst NATURE: ComponentNature = {\n mutable: false,\n resizable: true,\n rotatable: true,\n properties: [\n {\n type: 'action',\n label: 'add-floor',\n name: 'addFloor',\n property: {\n icon: 'add_circle',\n action: (indoorMap: IndoorMap) => {\n indoorMap.addFloor()\n }\n }\n },\n {\n type: 'number',\n label: 'active index',\n name: 'activeIndex'\n }\n ],\n 'value-property': 'activeIndex',\n help: 'scene/component/indoor-map'\n}\n\nexport default class IndoorMap extends Container {\n private _focused: boolean = false\n private __down_point?: POINT\n\n get nature() {\n return NATURE\n }\n\n get layout() {\n return CardLayout\n }\n\n get layoutConfig() {\n return (\n this.getState('layoutConfig') || {\n activeIndex: this.activeIndex\n }\n )\n }\n\n set layoutConfig(config) {\n this.setState('layoutConfig', config)\n }\n\n get activeIndex() {\n return this.getState('activeIndex')\n }\n\n set activeIndex(activeIndex: number) {\n this.setState('activeIndex', Number(activeIndex))\n }\n\n ready() {\n super.ready()\n\n if (this.components.length == 0) {\n this.addFloor()\n }\n\n this.layoutConfig = {\n ...this.layoutConfig,\n activeIndex: this.activeIndex\n }\n }\n\n postrender(context: CanvasRenderingContext2D) {\n if (!this.app.isViewMode && this._focused) {\n var { left, top, width, fillStyle } = this.state\n\n // floor 선택 탭 그리기\n for (let i = 0; i < this.components.length; i++) {\n context.beginPath()\n\n context.rect(left - LABEL_WIDTH, top + i * LABEL_HEIGHT, LABEL_WIDTH, LABEL_HEIGHT)\n\n let color = 255 - ((20 * (i + 1)) % 255)\n context.fillStyle = rgba(color, color, color, 1)\n context.fill()\n\n context.closePath()\n }\n\n context.beginPath()\n\n context.moveTo(left, top)\n context.lineTo(left - LABEL_WIDTH, top)\n context.lineTo(left - LABEL_WIDTH, top + this.components.length * LABEL_HEIGHT)\n context.lineTo(left, top + this.components.length * LABEL_HEIGHT)\n\n context.strokeStyle = '#ccc'\n context.stroke()\n\n context.closePath()\n }\n\n super.postrender(context)\n }\n\n contains(x: number, y: number) {\n var contains = super.contains(x, y)\n\n if (this.app.isViewMode) return contains\n\n var { left, top, width } = this.bounds\n var h = LABEL_HEIGHT\n\n contains =\n contains ||\n // card selector 영역에 포함되는지\n (x < Math.max(left - LABEL_WIDTH, left) &&\n x > Math.min(left - LABEL_WIDTH, left) &&\n y < Math.max(top + h * this.size(), top) &&\n y > Math.min(top + h * this.size(), top))\n\n if (contains) this._focused = true\n else this._focused = false\n\n this.invalidate()\n return contains\n }\n\n onchange(after: State) {\n if ('activeIndex' in after) {\n this.layoutConfig = {\n ...this.layoutConfig,\n activeIndex: after.activeIndex\n }\n }\n }\n\n onmouseup(e: MouseEvent) {\n var down_point = this.__down_point\n delete this.__down_point\n\n if (!down_point || down_point.x != e.offsetX || down_point.y != e.offsetY) {\n return\n }\n\n var point = this.transcoordC2S(e.offsetX, e.offsetY)\n\n var { left, top } = this.state\n\n var x = point.x - left\n var y = point.y - top\n\n if (x > 0) return\n\n y /= LABEL_HEIGHT\n y = Math.floor(y)\n\n if (!this.layoutConfig) {\n this.layoutConfig = {}\n }\n\n if (y >= this.components.length) {\n return\n }\n\n // /* 생성 버튼이 클릭되면, 새로운 floor를 추가한다. */\n // if(y == this.components.length) {\n // this.add(Model.compile({\n // type: 'floor',\n // width: 100,\n // height: 100\n // }))\n // }\n this.setState('activeIndex', y)\n }\n\n onmousedown(e: MouseEvent) {\n this.__down_point = {\n x: e.offsetX,\n y: e.offsetY\n }\n }\n\n addFloor() {\n const color = 255 - ((20 * (this.components.length + 1)) % 255)\n const hex = color.toString(16)\n\n const floor = Model.compile({\n type: 'floor',\n fillStyle: `#${hex}${hex}${hex}`,\n top: 0,\n left: 0,\n width: 100,\n height: 100\n })\n\n this.addComponent(floor)\n this.setState('activeIndex', this.components.length - 1)\n }\n}\n\nComponent.register('indoor-map', IndoorMap)\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@operato/scene-indoor-map",
3
- "version": "1.2.45",
3
+ "version": "1.2.49",
4
4
  "description": "Indoor Map component for things-scene.",
5
5
  "author": "heartyoh",
6
6
  "main": "dist/index.js",
@@ -58,5 +58,5 @@
58
58
  "prettier --write"
59
59
  ]
60
60
  },
61
- "gitHead": "131e93569c5da183050eb855d67b72580414d370"
61
+ "gitHead": "f91b0d45641177ae36015ebd23b780a48715349b"
62
62
  }