App.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <template>
  2. <div id="root">
  3. <!-- <header role="banner">
  4. <div class="wrapper">
  5. <h1
  6. class="site-title"
  7. tabindex="0"
  8. >
  9. </h1>
  10. </div>
  11. </header> -->
  12. <section role="main-content">
  13. <div class="wrapper">
  14. <renderer :obj="myRenderer" :size="size">
  15. <scene :obj="myScene" @update:obj="handleScene">
  16. <orbit-controls :position="{x:0,y:150,z:0}" :rotation="{ x: -90, y: 0, z: 0 }">
  17. <camera />
  18. </orbit-controls>
  19. <!-- <camera :position="{x:0, y:300, z:0}" :rotation="{x:deg2rad(-90), y:0, z:0}"/> -->
  20. <!-- <camera :position="{x:0,y:50,z:0}" :lookat="{x:0,y:0,z:0}" /> -->
  21. <!-- <light :hex="0xff0000" :intensity="10" :position="{x:-100}" /> -->
  22. <!-- <mesh :obj="mesh" :position="{ y: -200 }" /> -->
  23. <!-- <animation :fn="animate" :speed="3" /> -->
  24. <plan :size="{w:5000,h:5000}" :position="{x:0,y:0,z:0}" :color="0xffffff" :rotation="{x:90,y:0,z:0}" />
  25. <template v-if="debug">
  26. <cube :size="{x:30,y:1,z:1}" :position="{x:15,y:0,z:0}" :color="0x992222" />
  27. <cube :size="{x:1,y:30,z:1}" :position="{x:0,y:15,z:0}" :color="0x00BBFF" />
  28. <cube :size="{x:1,y:1,z:30}" :position="{x:0,y:0,z:15}" :color="0x17d100" />
  29. </template>
  30. <template v-if="projects.length">
  31. <project
  32. v-for="(project, index) in projects"
  33. :key="project.id"
  34. :data="project"
  35. :len="projects.length"
  36. :index="index"
  37. />
  38. </template>
  39. <line />
  40. </scene>
  41. </renderer>
  42. </div>
  43. </section>
  44. <footer />
  45. </div>
  46. </template>
  47. <script>
  48. import { mapState, mapActions } from 'vuex'
  49. import mixins from 'components/mixins'
  50. import * as THREE from 'three'
  51. import Plan from './components/objects/Plan'
  52. import Cube from './components/objects/Cube'
  53. import Project from './components/objects/Project'
  54. export default {
  55. metaInfo: {
  56. // if no subcomponents specify a metaInfo.title, this title will be used
  57. title: 'Home',
  58. // all titles will be injected into this template
  59. titleTemplate: '%s | Muntadas'
  60. },
  61. components: {
  62. Cube,
  63. Project,
  64. Plan
  65. },
  66. mixins: [mixins],
  67. data () {
  68. let renderer = new THREE.WebGLRenderer({ alpha: false, antialias: true })
  69. renderer.setClearColor(0x000000, 0)
  70. // scene obj is well overwrited but background color not visible
  71. let scene = new THREE.Scene()
  72. scene.background = new THREE.Color(0x000000)
  73. scene.fog = new THREE.Fog(scene.background, 1, 5000)
  74. console.log('myScene', scene)
  75. return {
  76. debug: true,
  77. myRenderer: renderer,
  78. myScene: scene
  79. }
  80. },
  81. computed: {
  82. ...mapState({
  83. projects: state => state.Projects.projects
  84. }),
  85. size () {
  86. return {
  87. w: window.innerWidth,
  88. h: window.innerHeight
  89. }
  90. }
  91. },
  92. created () {
  93. if (!this.projects.length) {
  94. this.getProjects()
  95. }
  96. },
  97. methods: {
  98. ...mapActions({
  99. getProjects: 'Projects/getProjects'
  100. }),
  101. handleScene (scene) {
  102. console.log('handlescene', scene)
  103. }
  104. }
  105. }
  106. </script>
  107. <style lang="scss" scoped>
  108. .container{
  109. // font-family:'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;
  110. max-width: 1200px;
  111. }
  112. </style>