|
@@ -4,6 +4,7 @@
|
|
|
// import qs from 'querystring'
|
|
|
// import { REST } from 'api/rest-axios'
|
|
|
import { GRAPHQL } from 'api/graphql-axios'
|
|
|
+import Query from 'graphql-query-builder'
|
|
|
|
|
|
import * as THREE from 'three'
|
|
|
import { ThreeBSP } from 'three-js-csg-es6'
|
|
@@ -24,6 +25,8 @@ export default {
|
|
|
floor3dObj: null,
|
|
|
floorPos: null,
|
|
|
florrColor: null,
|
|
|
+ levels3dObj: null,
|
|
|
+ levelsPos: null,
|
|
|
wall: {
|
|
|
wallW: 0.001,
|
|
|
// dig windows on face and back
|
|
@@ -81,6 +84,8 @@ export default {
|
|
|
setFloorPos: (state, pos) => { state.floorPos = pos },
|
|
|
setTopColor: (state, col) => { state.topColor = col },
|
|
|
setFloorColor: (state, col) => { state.floorColor = col },
|
|
|
+ setLevels3dObj: (state, obj) => { state.levels3dObj = obj },
|
|
|
+ setLevelsPos: (state, pos) => { state.levelsPos = pos },
|
|
|
setContents: (state, contents) => { state.contents = contents },
|
|
|
setGrid: (state, grid) => { state.grid = grid },
|
|
|
shiftGrid: (state, c) => {
|
|
@@ -311,25 +316,39 @@ export default {
|
|
|
let floorPosition = { ...state.position, ...{ y: state.position.y - 0.5 * state.size.y } }
|
|
|
commit('setFloorPos', floorPosition)
|
|
|
|
|
|
- //
|
|
|
- // // LEVELS
|
|
|
- // let levelGeom = new THREE.BoxGeometry(state.size.x, 1, state.size.z)
|
|
|
- // let levelMesh = new THREE.Mesh(levelGeom)
|
|
|
- // let levelBSP = new ThreeBSP(levelMesh)
|
|
|
- // let levelHoleGeom = new THREE.BoxGeometry(state.size.x - 3, 1, state.size.z - 3)
|
|
|
- // let levelHoleMesh = new THREE.Mesh(levelHoleGeom)
|
|
|
- // let levelHoleBSP = new ThreeBSP(levelHoleMesh)
|
|
|
- // levelBSP = levelBSP.subtract(levelHoleBSP)
|
|
|
- // levelMesh = levelBSP.toMesh()
|
|
|
- // let levelOpts = {
|
|
|
- // color: 0xff0000,
|
|
|
- // shininess: 10
|
|
|
- // }
|
|
|
- // let levelMat = new THREE.MeshPhongMaterial(levelOpts)
|
|
|
- // levelMesh.material = levelMat
|
|
|
+ // LEVELS
|
|
|
+ let levelGeom = new THREE.BoxGeometry(state.size.x - state.wall.wallW * 2, 0.1, state.size.z - state.wall.wallW * 2)
|
|
|
+ let levelMesh = new THREE.Mesh(levelGeom)
|
|
|
+ let levelBSP = new ThreeBSP(levelMesh)
|
|
|
+ let levelHoleGeom = new THREE.BoxGeometry(state.size.x - state.wall.wallW * 2 - 3, 0.1, state.size.z - state.wall.wallW * 2 - 3)
|
|
|
+ let levelHoleMesh = new THREE.Mesh(levelHoleGeom)
|
|
|
+ let levelHoleBSP = new ThreeBSP(levelHoleMesh)
|
|
|
+ levelBSP = levelBSP.subtract(levelHoleBSP)
|
|
|
+ levelMesh = levelBSP.toMesh()
|
|
|
+ let levelsGeom = new THREE.Geometry()
|
|
|
+ for (var k = -1; k < 2; k++) {
|
|
|
+ levelMesh.position.y = k * state.size.y * 0.25
|
|
|
+ levelsGeom.mergeMesh(levelMesh)
|
|
|
+ }
|
|
|
+ let levelsOpts = {
|
|
|
+ color: new THREE.Color(`hsl(${hTop}, ${sTop}%, ${lTop}%)`),
|
|
|
+ shininess: 10
|
|
|
+ }
|
|
|
+ let levelsMat = new THREE.MeshPhongMaterial(levelsOpts)
|
|
|
+ let levelsMesh = new THREE.Mesh(levelsGeom, levelsMat)
|
|
|
+ commit('setLevels3dObj', levelsMesh)
|
|
|
+ let levelsPos = { ...state.position }
|
|
|
+ commit('setLevelsPos', levelsPos)
|
|
|
},
|
|
|
loadContents ({ dispatch, commit, state }) {
|
|
|
console.log('loadContents')
|
|
|
+ let contentsQuery = new Query('project', { id: state.id })
|
|
|
+ let visiblesQuery = new Query('visibles')
|
|
|
+ visiblesQuery.filter({ Published: true })
|
|
|
+ visiblesQuery.find(['id', 'Name', 'Text2', 'Vimeo', 'Url', 'categories'])
|
|
|
+ contentsQuery.find([visiblesQuery])
|
|
|
+ console.log('contentsQuery', `${contentsQuery}`)
|
|
|
+
|
|
|
GRAPHQL.post('', { query: `query {
|
|
|
project(id: "${state.id}") {
|
|
|
visibles(where: { Published: "true" }){
|