zone.vue 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <template>
  2. <div>
  3. <canvas id="wall" width="800" height="400" tabindex="0" />
  4. </div>
  5. </template>
  6. <script lang="ts">
  7. import { SGraphScene, SGraphView } from "@persagy-web/graph/";
  8. import { SZoneItem } from "@persagy-web/big/lib/items/floor/ZoneItem";
  9. import { Component, Vue } from "vue-property-decorator";
  10. /**
  11. * 业务空间对象示例
  12. *
  13. * @author 郝洁 <haojie@persagy.com>
  14. */
  15. @Component
  16. export default class ZoneCanvas extends Vue {
  17. outline = [
  18. [
  19. /** 未掏洞的空间 */
  20. [
  21. {"X": 30150.15, "Y": 82300.04, "Z": 59400.0},
  22. {"X": 30150.15, "Y": 81400.04, "Z": 59400.0},
  23. {"X": 33400.15, "Y": 82300.04, "Z": 59400.0},
  24. {"X": 30150.15, "Y": 82300.04, "Z": 59400.0}
  25. ],
  26. ],
  27. [
  28. /** 掏洞的空间 */
  29. [
  30. {"X": 25500.15, "Y": 77100.04, "Z": 59400.0},
  31. {"X": 28200.15, "Y": 77100.04, "Z": 59400.0},
  32. {"X": 28200.15, "Y": 82300.04, "Z": 59400.0},
  33. {"X": 25500.15, "Y": 82300.04, "Z": 59400.0},
  34. {"X": 25500.15, "Y": 77100.04, "Z": 59400.0}
  35. ],
  36. [
  37. {"X": 25900.15, "Y": 80300.04, "Z": 59400.0},
  38. {"X": 27200.15, "Y": 80300.04, "Z": 59400.0},
  39. {"X": 27200.15, "Y": 77900.04, "Z": 59400.0},
  40. {"X": 25900.15, "Y": 77900.04, "Z": 59400.0},
  41. ]
  42. ]
  43. ];
  44. /** 实例化 view */
  45. view: SGraphView | undefined;
  46. /**
  47. * 页面挂载
  48. */
  49. mounted() {
  50. this.init();
  51. };
  52. /**
  53. * 初始化加载
  54. */
  55. init() {
  56. this.view = new SGraphView('wall');
  57. const scene = new SGraphScene();
  58. this.view.scene = scene;
  59. // 只模拟了轮廓数据
  60. // @ts-ignore
  61. const item = new SZoneItem(null, {OutLine: this.outline});
  62. item.selectable = true;
  63. scene.addItem(item);
  64. this.view.fitSceneToView();
  65. console.log(this.view)
  66. this.view.scalable = false;
  67. }
  68. }
  69. </script>
  70. <style scoped>
  71. </style>