Project.vue 4.0 KB

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