refactorisation fished, contents are back in grid

This commit is contained in:
2020-09-17 10:16:00 +02:00
parent 15ad778ce2
commit 8e37e02144
4 changed files with 99 additions and 91 deletions
+50 -35
View File
@@ -38,7 +38,8 @@ export default {
paddingZ: 0
},
contents: {},
grid: []
grid: [],
gridContentPlaced: {}
},
// getters
@@ -77,7 +78,15 @@ export default {
setFloor3dObj: (state, obj) => { state.floor3dObj = obj },
setFloorPos: (state, pos) => { state.floorPos = pos },
setTopColor: (state, col) => { state.topColor = col },
setFloorColor: (state, col) => { state.floorColor = col }
setFloorColor: (state, col) => { state.floorColor = col },
setContents: (state, contents) => { state.contents = contents },
shiftGrid: (state, c) => {
let p = state.grid.shift()
if (!state.gridContentPlaced[c.type]) {
state.gridContentPlaced[c.type] = {}
}
state.gridContentPlaced[c.type][c.id] = p
}
},
// actions
@@ -142,34 +151,33 @@ export default {
state.wall.paddingY = (state.size.y - 2 * state.wall.margin - state.wall.winH * state.wall.nbrWinY) / (state.wall.nbrWinY - 1)
a++
}
// state.wall = { ...wall }
//
// // CONTENTS GRID
// a = 0
// state.wall.nbrWinZ = Math.floor((state.size.z - 2 * state.wall.margin) / state.wall.winW)
// while (state.wall.paddingZ < 0.4) {
// state.wall.nbrWinZ -= a
// state.wall.paddingZ = (state.size.z - 2 * state.wall.margin - state.wall.winW * state.wall.nbrWinZ) / (state.wall.nbrWinZ - 1)
// a++
// }
//
// grid = []
// for (var l = 0; l < state.wall.nbrWinZ * 2; l++) { // cols
// for (var m = 0; m < state.wall.nbrWinY * 2; m++) { // rows
// grid.push({
// z: margin + state.wall.winW / 2 * l,
// y: margin + state.wall.winH / 2 * m
// })
// }
// }
// // shuffle the grid
// for (let n = grid.length - 1; n > 0; n--) {
// const o = Math.floor(Math.random() * n)
// const temp = grid[n]
// grid[n] = grid[o]
// grid[o] = temp
// }
// state.grid = [ ...grid ]
// CONTENTS GRID
a = 0
state.wall.nbrWinZ = Math.floor((state.size.z - 2 * state.wall.margin) / state.wall.winW)
while (state.wall.paddingZ < 0.4) {
state.wall.nbrWinZ -= a
state.wall.paddingZ = (state.size.z - 2 * state.wall.margin - state.wall.winW * state.wall.nbrWinZ) / (state.wall.nbrWinZ - 1)
a++
}
let grid = []
for (var l = 0; l < state.wall.nbrWinZ * 2; l++) { // cols
for (var m = 0; m < state.wall.nbrWinY * 2; m++) { // rows
grid.push({
z: margin + state.wall.winW / 2 * l,
y: margin + state.wall.winH / 2 * m
})
}
}
// shuffle the grid
for (let n = grid.length - 1; n > 0; n--) {
const o = Math.floor(Math.random() * n)
const temp = grid[n]
grid[n] = grid[o]
grid[o] = temp
}
state.grid = [ ...grid ]
},
build3dObjs ({ dispatch, commit, state, getters, rootGetters }) {
console.log('build3dObjs')
@@ -299,9 +307,10 @@ export default {
},
loadContents ({ dispatch, commit, state }) {
console.log('loadContents')
// (where: { Published: "true" })
GRAPHQL.post('', { query: `query {
project(id: "${state.id}") {
visibles(where: { Published: "true" }){
visibles{
id
Name
Media {
@@ -313,7 +322,7 @@ export default {
Url
categories
}
contexts(where: { Published: "true" }){
contexts{
id
Name
Images {
@@ -324,7 +333,7 @@ export default {
Vimeo
Url
}
processes(where: { Published: "true" }){
processes{
id
Name
Media {
@@ -335,7 +344,7 @@ export default {
Vimeo
Url
}
concepts(where: { Published: "true" }){
concepts{
id
Name
Images {
@@ -348,7 +357,8 @@ export default {
}
}` })
.then(({ data: { data: { project } = null } }) => {
console.log('graphql visibles', project)
console.log('graphql contents', project)
commit('setContents', project)
// dispatch('computeProjects', projects)
})
.catch((error) => {
@@ -356,5 +366,10 @@ export default {
Promise.reject(error)
})
}
// getGridPos ({ state, commit }) {
// let p = state.grid[0]
// commit('shiftGrid')
// Promise.resolve(p)
// }
}
}