ContentBlock.vue 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <template>
  2. <mesh name="ContentBlock" :position="position">
  3. <geometry type="Box" :args="[size.x, size.y, size.z]" />
  4. <material type="MeshLambert" :color="color" :options="opts" />
  5. </mesh>
  6. </template>
  7. <script>
  8. import * as THREE from 'three'
  9. export default {
  10. name: 'ContentBlock',
  11. // mixins: [Object3D],
  12. props: { prtPosition: Object, prtSize: Object },
  13. data: () => ({
  14. color: 0xffffff,
  15. size: { x: 2, y: 2, z: 2 },
  16. position: { x: 0, y: 5, z: 2 },
  17. opts: {
  18. side: THREE.DoubleSide
  19. // wireframe: false,
  20. // transparent: false,
  21. // opacity: 0.6
  22. }
  23. }),
  24. created () {
  25. console.log('ContentBlock created', this.prtSize)
  26. this.position.x = this.prtPosition.x - this.prtSize.x / 2 + Math.random() * this.prtSize.x
  27. // console.log('this.position.y', this.position.y)
  28. if (Math.random() > 0.5) {
  29. this.position.y = this.prtPosition.y + this.prtSize.y / 2 + Math.random() * 20
  30. } else {
  31. this.position.y = this.prtPosition.y - this.prtSize.y / 2 - Math.random() * 20
  32. }
  33. // this.position.z = this.prtPosition.Z
  34. }
  35. }
  36. </script>