Project.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <template>
  2. <div>
  3. <object3d ref="block3d" name="Project" :obj="walls3dObj" :position="wallsPos" />
  4. <object3d ref="top" :obj="top3dObj" :position="topPos" />
  5. <object3d ref="floor" :obj="floor3dObj" :position="floorPos" />
  6. <!-- <object3d ref="level" :obj="level_mesh" :position="level_position" /> -->
  7. <mesh ref="label3d" name="Label" :position="label_position">
  8. <geometry type="Plane" :args="[label_size.x, label_size.y]" />
  9. <material type="MeshLambert" :options="label_opts">
  10. <texture :options="label_texture_opts" />
  11. </material>
  12. </mesh>
  13. <div v-if="isOpened">
  14. <ContentBlock
  15. v-for="item in contents.visibles"
  16. :key="item.id"
  17. :prtPosition="position"
  18. :prtSize="size"
  19. :prtIndex="index"
  20. type="visible"
  21. :data="item"
  22. />
  23. <ContentBlock
  24. v-for="item in contents.contexts"
  25. :key="item.id"
  26. :prtPosition="position"
  27. :prtSize="size"
  28. :prtIndex="index"
  29. type="context"
  30. :data="item"
  31. />
  32. <ContentBlock
  33. v-for="item in contents.processes"
  34. :key="item.id"
  35. :prtPosition="position"
  36. :prtSize="size"
  37. :prtIndex="index"
  38. type="process"
  39. :data="item"
  40. />
  41. <ContentBlock
  42. v-for="item in contents.concepts"
  43. :key="item.id"
  44. :prtPosition="position"
  45. :prtSize="size"
  46. :prtIndex="index"
  47. type="concept"
  48. :data="item"
  49. />
  50. </div>
  51. </div>
  52. </template>
  53. <script>
  54. import { mapInstanceState, mapInstanceActions } from '@urbn/vuex-helpers'
  55. import * as THREE from 'three'
  56. // import { ThreeBSP } from 'three-js-csg-es6'
  57. import mixins from 'components/mixins'
  58. import ContentBlock from 'components/objects/ContentBlock'
  59. // import BgVertex from 'assets/glsl/BgVertex'
  60. // import BuildingFragment from 'assets/glsl/BuildingFragment'
  61. // We'll determine our module based on the moduleName prop on this component
  62. // https://www.npmjs.com/package/@urbn/vuex-helpers
  63. const getModuleName = cmp => `project:${cmp.id}`
  64. export default {
  65. name: 'Project',
  66. components: {
  67. ContentBlock
  68. },
  69. mixins: [mixins],
  70. props: { id: Number },
  71. data () {
  72. console.log('Project data()')
  73. return {
  74. isOpened: false,
  75. block3d: null,
  76. label3d: null,
  77. label_opts: {
  78. side: THREE.DoubleSide,
  79. transparent: true
  80. // wireframe: false,
  81. // opacity: 0.6
  82. // renderOrder: 0
  83. },
  84. label_canvas: null,
  85. label_size: null,
  86. label_position: { x: 0, y: 0, z: 0 }
  87. // level_mesh: levelMesh,
  88. // level_position: { ...position },
  89. }
  90. },
  91. computed: {
  92. ...mapInstanceState(getModuleName, {
  93. title: state => state.Titre,
  94. size: state => state.size,
  95. position: state => state.position,
  96. walls3dObj: state => state.walls3dObj,
  97. wallsPos: state => state.wallsPos,
  98. top3dObj: state => state.top3dObj,
  99. topPos: state => state.topPos,
  100. topColor: state => state.topColor,
  101. floor3dObj: state => state.floor3dObj,
  102. floorPos: state => state.floorPos,
  103. contents: state => state.contents
  104. }),
  105. label_texture_opts () {
  106. return {
  107. canvas: this.label_canvas,
  108. minFilter: THREE.LinearFilter,
  109. wrapS: THREE.ClampToEdgeWrapping,
  110. wrapT: THREE.ClampToEdgeWrapping
  111. }
  112. }
  113. },
  114. created () {
  115. this.label_canvas = this.createLabelCanvas(this.title.replace(/ /g, '\n').toUpperCase(), 48, 21, '#000000', this.topColor)
  116. this.label_position.x = this.position.x - this.size.x / 2 + this.label_size.x / 2 + 1
  117. this.label_position.y = this.position.y + this.size.y / 2 - this.label_size.y / 2 - 1
  118. this.label_position.z = this.position.z + this.size.z / 2 + 0.5
  119. console.log('this.label_position', this.label_position)
  120. },
  121. mounted () {
  122. console.log('project mounted', this)
  123. // record self references
  124. this.block3d = this.$refs.block3d.curObj
  125. this.block3d.userData.vnode = this
  126. this.label3d = this.$refs.label3d.curObj
  127. },
  128. methods: {
  129. ...mapInstanceActions(getModuleName, {
  130. loadContents: 'loadContents'
  131. }),
  132. open () {
  133. this.isOpened = true
  134. this.loadContents()
  135. }
  136. }
  137. }
  138. </script>