Project.vue 4.7 KB

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