|
@@ -45,8 +45,8 @@ export default {
|
|
|
contents: {},
|
|
|
contents_size_factor: 1, // factor to get the contents (grid) size proportional to windows
|
|
|
contentTypes: ['visible', 'context', 'process', 'concept'],
|
|
|
- grid: { visible: [], context: [], process: [], concept: [] },
|
|
|
- gridContentPlaced: {},
|
|
|
+ grids: null,
|
|
|
+ gridsContentPlaced: {},
|
|
|
activeLevel: 'visibles'
|
|
|
},
|
|
|
|
|
@@ -90,13 +90,31 @@ export default {
|
|
|
setLevels3dObj: (state, obj) => { state.levels3dObj = obj },
|
|
|
setLevelsPos: (state, pos) => { state.levelsPos = pos },
|
|
|
setContents: (state, contents) => { state.contents = contents },
|
|
|
- setGrid: (state, grid) => { state.grid = grid },
|
|
|
+ setGrids: (state, grids) => { state.grids = grids },
|
|
|
shiftGrid: (state, c) => {
|
|
|
- let p = state.grid[c.type].shift()
|
|
|
- if (!state.gridContentPlaced[c.type]) {
|
|
|
- state.gridContentPlaced[c.type] = {}
|
|
|
+ console.log('shiftGrid c:', c)
|
|
|
+ let side
|
|
|
+ switch (c.face) {
|
|
|
+ case 'back':
|
|
|
+ case 'front':
|
|
|
+ side = 'x'
|
|
|
+ break
|
|
|
+ case 'left':
|
|
|
+ case 'right':
|
|
|
+ side = 'z'
|
|
|
+ break
|
|
|
}
|
|
|
- state.gridContentPlaced[c.type][c.id] = p
|
|
|
+ let p = state.grids[side][c.face][c.type].shift()
|
|
|
+ if (!state.gridsContentPlaced[side]) {
|
|
|
+ state.gridsContentPlaced[side] = {}
|
|
|
+ }
|
|
|
+ if (!state.gridsContentPlaced[side][c.face]) {
|
|
|
+ state.gridsContentPlaced[side][c.face] = {}
|
|
|
+ }
|
|
|
+ if (!state.gridsContentPlaced[side][c.face][c.type]) {
|
|
|
+ state.gridsContentPlaced[side][c.face][c.type] = {}
|
|
|
+ }
|
|
|
+ state.gridsContentPlaced[side][c.face][c.type][c.id] = p
|
|
|
},
|
|
|
setActiveLevel: (state, l) => {
|
|
|
state.activeLevel = l
|
|
@@ -175,43 +193,75 @@ export default {
|
|
|
a++
|
|
|
}
|
|
|
|
|
|
- let grid = {}
|
|
|
- let rows = state.wall.nbrWinY / state.contents_size_factor
|
|
|
- let cols = state.wall.nbrWinZ / state.contents_size_factor
|
|
|
- let t
|
|
|
- for (var m = 0; m < rows; m++) { // rows
|
|
|
- if (m > rows / 4 * 3 + 1) {
|
|
|
- t = state.contentTypes[0]
|
|
|
- } else if (m > rows / 4 * 2 + 1) {
|
|
|
- t = state.contentTypes[1]
|
|
|
- } else if (m > rows / 4 + 1) {
|
|
|
- t = state.contentTypes[2]
|
|
|
- } else {
|
|
|
- t = state.contentTypes[3]
|
|
|
- }
|
|
|
- if (!grid[t]) {
|
|
|
- grid[t] = []
|
|
|
- }
|
|
|
- for (var l = 0; l < cols; l++) { // cols
|
|
|
- grid[t].push({
|
|
|
- z: margin + state.wall.winW * state.contents_size_factor * l,
|
|
|
- y: margin + state.wall.winH * state.contents_size_factor * m
|
|
|
- })
|
|
|
- }
|
|
|
+ // create grids for right/left & face/back
|
|
|
+ let grids = {
|
|
|
+ x: { front: {}, back: {} },
|
|
|
+ z: { left: {}, right: {} }
|
|
|
}
|
|
|
- console.log('grid', grid)
|
|
|
- // shuffle the grids
|
|
|
- for (var i = 0; i < state.contentTypes.length; i++) {
|
|
|
- for (let n = grid[state.contentTypes[i]].length - 1; n > 0; n--) {
|
|
|
- const o = Math.floor(Math.random() * n)
|
|
|
- const temp = grid[state.contentTypes[i]][n]
|
|
|
- grid[state.contentTypes[i]][n] = grid[state.contentTypes[i]][o]
|
|
|
- grid[state.contentTypes[i]][o] = temp
|
|
|
+ // console.log('grids', grids)
|
|
|
+ let grid, rows, cols, t, cel
|
|
|
+ // console.log('Object.keys(grids)', Object.keys(grids))
|
|
|
+ Object.keys(grids).map(function (side) {
|
|
|
+ // console.log('GRID side:', side)
|
|
|
+ grid = {}
|
|
|
+ // calculate cols nbr regarding the face orientation
|
|
|
+ switch (side) {
|
|
|
+ case 'z':
|
|
|
+ cols = state.wall.nbrWinZ / state.contents_size_factor
|
|
|
+ break
|
|
|
+ case 'x':
|
|
|
+ cols = state.wall.nbrWinX / state.contents_size_factor
|
|
|
+ break
|
|
|
}
|
|
|
- }
|
|
|
- console.log('shuffeld grid', grid)
|
|
|
- commit('setGrid', grid)
|
|
|
- console.log('state.grid', state.grid)
|
|
|
+ // calculate rows
|
|
|
+ rows = state.wall.nbrWinY / state.contents_size_factor
|
|
|
+ // dispatch grid rows on to 4 levels (t)
|
|
|
+ for (var m = 0; m < rows; m++) { // rows
|
|
|
+ if (m > rows / 4 * 3 + 1) {
|
|
|
+ t = state.contentTypes[0]
|
|
|
+ } else if (m > rows / 4 * 2 + 1) {
|
|
|
+ t = state.contentTypes[1]
|
|
|
+ } else if (m > rows / 4 + 1) {
|
|
|
+ t = state.contentTypes[2]
|
|
|
+ } else {
|
|
|
+ t = state.contentTypes[3]
|
|
|
+ }
|
|
|
+ // create level if not exists
|
|
|
+ if (!grid[t]) {
|
|
|
+ grid[t] = []
|
|
|
+ }
|
|
|
+ // create cols for each rows
|
|
|
+ for (var l = 0; l < cols; l++) { // cols
|
|
|
+ cel = { y: margin + state.wall.winH * state.contents_size_factor * m }
|
|
|
+ switch (side) {
|
|
|
+ case 'z':
|
|
|
+ cel.z = margin + state.wall.winW * state.contents_size_factor * l
|
|
|
+ break
|
|
|
+ case 'x':
|
|
|
+ cel.x = margin + state.wall.winW * state.contents_size_factor * l
|
|
|
+ break
|
|
|
+ }
|
|
|
+ grid[t].push(cel)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // console.log('grid', grid)
|
|
|
+ // clown and shuffle the grids (one by face)
|
|
|
+ // console.log('Object.keys(grids[side])', Object.keys(grids[side]))
|
|
|
+ Object.keys(grids[side]).map(function (face) {
|
|
|
+ for (var i = 0; i < state.contentTypes.length; i++) {
|
|
|
+ for (let n = grid[state.contentTypes[i]].length - 1; n > 0; n--) {
|
|
|
+ const o = Math.floor(Math.random() * n)
|
|
|
+ const temp = grid[state.contentTypes[i]][n]
|
|
|
+ grid[state.contentTypes[i]][n] = grid[state.contentTypes[i]][o]
|
|
|
+ grid[state.contentTypes[i]][o] = temp
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // console.log('shuffeld grid', grid)
|
|
|
+ grids[side][face] = { ...grid }
|
|
|
+ })
|
|
|
+ })
|
|
|
+ commit('setGrids', grids)
|
|
|
+ console.log('state.grids', state.grids)
|
|
|
},
|
|
|
build3dObjs ({ dispatch, commit, state, getters, rootGetters }) {
|
|
|
console.log('build3dObjs')
|