|
@@ -16,6 +16,7 @@ export default {
|
|
|
|
|
|
// initial state
|
|
|
state: {
|
|
|
+ debug: true,
|
|
|
obj3d: null,
|
|
|
size: { x: 0, y: 0, z: 0 },
|
|
|
position: { x: 0, y: 0, z: 0 },
|
|
@@ -33,7 +34,8 @@ export default {
|
|
|
wallW: 0.001,
|
|
|
// dig windows on face and back
|
|
|
winW: 2 + Math.random() * 2,
|
|
|
- winH: 4 + Math.random() * 4,
|
|
|
+ // winH: 4 + Math.random() * 4,
|
|
|
+ winH: 0,
|
|
|
margin: 2,
|
|
|
nbrWinX: 0,
|
|
|
paddingX: 0,
|
|
@@ -46,7 +48,12 @@ export default {
|
|
|
contents_size_factor: 1, // factor to get the contents (grid) size proportional to windows
|
|
|
contentTypes: ['visible', 'context', 'process', 'concept'],
|
|
|
grids: null,
|
|
|
+ gridCel: {
|
|
|
+ width: 6,
|
|
|
+ height: 4.5
|
|
|
+ },
|
|
|
gridsContentPlaced: {},
|
|
|
+ // gridBebug3dObj: null,
|
|
|
activeLevel: 'visibles'
|
|
|
},
|
|
|
|
|
@@ -91,8 +98,9 @@ export default {
|
|
|
setLevelsPos: (state, pos) => { state.levelsPos = pos },
|
|
|
setContents: (state, contents) => { state.contents = contents },
|
|
|
setGrids: (state, grids) => { state.grids = grids },
|
|
|
+ // setDebugGrids3dObj: (state, obj) => { state.gridBebug3dObj = obj },
|
|
|
shiftGrid: (state, c) => {
|
|
|
- console.log('shiftGrid c:', c)
|
|
|
+ // console.log('shiftGrid c:', c)
|
|
|
let side
|
|
|
switch (c.face) {
|
|
|
case 'back':
|
|
@@ -104,7 +112,7 @@ export default {
|
|
|
side = 'z'
|
|
|
break
|
|
|
}
|
|
|
- let p = state.grids[side][c.face][c.type].shift()
|
|
|
+ let p = state.grids[side][c.face][c.type].pop()
|
|
|
if (!state.gridsContentPlaced[side]) {
|
|
|
state.gridsContentPlaced[side] = {}
|
|
|
}
|
|
@@ -176,15 +184,15 @@ export default {
|
|
|
a++
|
|
|
}
|
|
|
a = 0
|
|
|
- state.wall.nbrWinY = Math.floor((state.size.y - 2 * state.wall.margin) / state.wall.winH)
|
|
|
+ // state.wall.nbrWinY = Math.floor((state.size.y - 2 * state.wall.margin) / state.wall.winH)
|
|
|
+ state.wall.nbrWinY = 4 * 10
|
|
|
+ state.wall.winH = (state.size.y - 2 * state.wall.margin) / state.wall.nbrWinY
|
|
|
// removing windows on Y until padding is enough
|
|
|
while (state.wall.paddingY < 0.4) {
|
|
|
state.wall.nbrWinY -= a
|
|
|
state.wall.paddingY = (state.size.y - 2 * state.wall.margin - state.wall.winH * state.wall.nbrWinY) / (state.wall.nbrWinY - 1)
|
|
|
- a++
|
|
|
+ a += 4
|
|
|
}
|
|
|
-
|
|
|
- // 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) {
|
|
@@ -193,30 +201,42 @@ export default {
|
|
|
a++
|
|
|
}
|
|
|
|
|
|
+ // CONTENTS GRID
|
|
|
// create grids for right/left & face/back
|
|
|
let grids = {
|
|
|
x: { front: {}, back: {} },
|
|
|
z: { left: {}, right: {} }
|
|
|
}
|
|
|
// console.log('grids', grids)
|
|
|
- let grid, rows, cols, t, cel
|
|
|
+ let grid, rows, cols, t, cel, paddingH
|
|
|
// console.log('Object.keys(grids)', Object.keys(grids))
|
|
|
- Object.keys(grids).map(function (side) {
|
|
|
- // console.log('GRID side:', side)
|
|
|
+ // Object.keys(grids).map(function (side) {
|
|
|
+ Object.keys(grids).forEach(side => {
|
|
|
+ // console.log('# GRID side:', side)
|
|
|
+ // create one grid for each face x & z
|
|
|
+ // will then clone both for each face front/back or left/right)
|
|
|
grid = {}
|
|
|
// calculate cols nbr regarding the face orientation
|
|
|
switch (side) {
|
|
|
case 'z':
|
|
|
- cols = state.wall.nbrWinZ / state.contents_size_factor
|
|
|
+ // cols = state.wall.nbrWinZ / state.contents_size_factor
|
|
|
+ cols = Math.floor(state.size.z / state.gridCel.width)
|
|
|
+ // compute padding to centering the grid horizontaly
|
|
|
+ paddingH = (state.size.z - cols * state.gridCel.width) / 2
|
|
|
break
|
|
|
case 'x':
|
|
|
- cols = state.wall.nbrWinX / state.contents_size_factor
|
|
|
+ // cols = state.wall.nbrWinX / state.contents_size_factor
|
|
|
+ cols = Math.floor(state.size.x / state.gridCel.width)
|
|
|
+ // compute padding to centering the grid horizontaly
|
|
|
+ paddingH = (state.size.x - cols * state.gridCel.width) / 2
|
|
|
break
|
|
|
}
|
|
|
// calculate rows
|
|
|
- rows = state.wall.nbrWinY / state.contents_size_factor
|
|
|
+ // rows = state.wall.nbrWinY / state.contents_size_factor
|
|
|
+ rows = Math.floor(state.size.y / state.gridCel.height)
|
|
|
+
|
|
|
// dispatch grid rows on to 4 levels (t)
|
|
|
- for (var m = 0; m < rows; m++) { // rows
|
|
|
+ for (var m = rows - 1; m > 0; m--) { // rows
|
|
|
if (m > rows / 4 * 3 + 1) {
|
|
|
t = state.contentTypes[0]
|
|
|
} else if (m > rows / 4 * 2 + 1) {
|
|
@@ -229,35 +249,86 @@ export default {
|
|
|
// create level if not exists
|
|
|
if (!grid[t]) {
|
|
|
grid[t] = []
|
|
|
+ // skip the first level's row as we will display wall title
|
|
|
+ continue
|
|
|
}
|
|
|
// create cols for each rows
|
|
|
- for (var l = 0; l < cols; l++) { // cols
|
|
|
- cel = { y: margin + state.wall.winH * state.contents_size_factor * m }
|
|
|
+ for (var l = cols - 1; l >= 0; l--) { // cols
|
|
|
+ // cel = { y: margin + state.wall.winH * state.contents_size_factor * m }
|
|
|
+ cel = { y: state.position.y - state.size.y / 2 + state.gridCel.height * m }
|
|
|
switch (side) {
|
|
|
case 'z':
|
|
|
- cel.z = margin + state.wall.winW * state.contents_size_factor * l
|
|
|
+ // cel.z = margin + state.wall.winW * state.contents_size_factor * l
|
|
|
+ cel.z = state.position.z - state.size.z / 2 + paddingH + state.gridCel.width * l
|
|
|
break
|
|
|
case 'x':
|
|
|
- cel.x = margin + state.wall.winW * state.contents_size_factor * l
|
|
|
+ // cel.x = margin + state.wall.winW * state.contents_size_factor * l
|
|
|
+ cel.x = state.position.x - state.size.x / 2 + paddingH + state.gridCel.width * 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
|
|
|
- }
|
|
|
+
|
|
|
+ // apply grid for each face of each side
|
|
|
+ // Object.keys(grids[side]).map(function (face) {
|
|
|
+ Object.keys(grids[side]).forEach(face => {
|
|
|
+ // console.log('## GRID face:', face)
|
|
|
+ // // shuffling the grid
|
|
|
+ // 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)
|
|
|
+
|
|
|
+ // cloning the grid for each face
|
|
|
+ // grids[side][face] = { ...grid } this is not working as it is not deep copy
|
|
|
+ grids[side][face] = JSON.parse(JSON.stringify(grid))
|
|
|
+
|
|
|
+ // comput common values
|
|
|
+ let x, z, ry
|
|
|
+ switch (face) {
|
|
|
+ case 'front': // side x
|
|
|
+ z = state.position.z + state.size.z / 2 - 0.1
|
|
|
+ ry = 180
|
|
|
+ break
|
|
|
+ case 'back': // side x
|
|
|
+ z = state.position.z - state.size.z / 2 + 0.1
|
|
|
+ ry = 0
|
|
|
+ break
|
|
|
+ case 'left': // side z
|
|
|
+ x = state.position.x - state.size.x / 2 + 0.1
|
|
|
+ ry = 90
|
|
|
+ break
|
|
|
+ case 'right': // side z
|
|
|
+ x = state.position.x + state.size.x / 2 - 0.1
|
|
|
+ ry = -90
|
|
|
+ break
|
|
|
}
|
|
|
- // console.log('shuffeld grid', grid)
|
|
|
- grids[side][face] = { ...grid }
|
|
|
+
|
|
|
+ // loop through levels
|
|
|
+ // apply common values
|
|
|
+ // Object.keys(grids[side][face]).map(function (level) {
|
|
|
+ Object.keys(grids[side][face]).forEach(level => {
|
|
|
+ // console.log(`${side} ${face} ${level} x: ${x}, z: ${z}, ry: ${ry}`)
|
|
|
+ // loop through all cels of the level
|
|
|
+ for (var i = 0; i < grids[side][face][level].length; i++) {
|
|
|
+ grids[side][face][level][i].ry = ry
|
|
|
+ switch (side) {
|
|
|
+ case 'z':
|
|
|
+ grids[side][face][level][i].x = x
|
|
|
+ break
|
|
|
+ case 'x':
|
|
|
+ grids[side][face][level][i].z = z
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
})
|
|
|
})
|
|
|
commit('setGrids', grids)
|
|
@@ -392,16 +463,32 @@ export default {
|
|
|
let levelsPos = { ...state.position }
|
|
|
commit('setLevelsPos', levelsPos)
|
|
|
|
|
|
- // // repère
|
|
|
- // let repGeom = new THREE.BoxGeometry(1, 1, 1)
|
|
|
- // let repMesh = new THREE.Mesh(repGeom)
|
|
|
- // let repOpts = {
|
|
|
- // color: 0x0000ff,
|
|
|
- // shininess: 30
|
|
|
+ // // DEBUG GRID
|
|
|
+ // if (state.debug) {
|
|
|
+ // let celDebugGeom = new THREE.BoxGeometry(1, 1, 0.01)
|
|
|
+ // let celDebugMesh = new THREE.Mesh(celDebugGeom)
|
|
|
+ // let gridsDebugGeom = new THREE.Geometry()
|
|
|
+ // Object.keys(state.grids).map(function (side) {
|
|
|
+ // Object.keys(state.grids[side]).map(function (face) {
|
|
|
+ // Object.keys(state.grids[side][face]).map(function (level) {
|
|
|
+ // state.grids[side][face][level].forEach((item, i) => {
|
|
|
+ // // console.log(`grid ${side} ${face} ${level} ${i}`, item)
|
|
|
+ // celDebugMesh.position.y = state.grids[side][face][level][i].y
|
|
|
+ // celDebugMesh.position.x = state.grids[side][face][level][i].x
|
|
|
+ // celDebugMesh.position.z = state.grids[side][face][level][i].z
|
|
|
+ // celDebugMesh.rotation.y = state.grids[side][face][level][i].ry
|
|
|
+ // gridsDebugGeom.mergeMesh(celDebugMesh)
|
|
|
+ // })
|
|
|
+ // })
|
|
|
+ // })
|
|
|
+ // })
|
|
|
+ // let gridsDebugOpts = {
|
|
|
+ // color: 0xff0000
|
|
|
+ // }
|
|
|
+ // let gridsDebugMat = new THREE.MeshPhongMaterial(gridsDebugOpts)
|
|
|
+ // let gridsDebugMesh = new THREE.Mesh(gridsDebugGeom, gridsDebugMat)
|
|
|
+ // commit('setDebugGrids3dObj', gridsDebugMesh)
|
|
|
// }
|
|
|
- // repMesh.material = new THREE.MeshPhongMaterial(repOpts)
|
|
|
- // repMesh.position = { ...state.position, ...{ y: 0 } }
|
|
|
- // commit('setRep3dObj', levelsMesh)
|
|
|
},
|
|
|
getContents ({ dispatch, commit, state }) {
|
|
|
return new Promise((resolve, reject) => {
|
|
@@ -496,7 +583,7 @@ export default {
|
|
|
return Promise.all(Object.keys(contents).map(function (key) {
|
|
|
return Promise.all(contents[key].map(function (content) {
|
|
|
if (content.Vimeo) {
|
|
|
- console.log('Vimeo', content.Vimeo)
|
|
|
+ // console.log('Vimeo', content.Vimeo)
|
|
|
// GET https://vimeo.com/api/oembed.json?url=https%3A//vimeo.com/286898202&width=480&height=360
|
|
|
let params = {
|
|
|
url: content.Vimeo,
|
|
@@ -507,7 +594,7 @@ export default {
|
|
|
let q = qs.stringify(params)
|
|
|
return VIMEO.get('?' + q, {})
|
|
|
.then(({ data }) => {
|
|
|
- console.log('Vimeo data', data)
|
|
|
+ // console.log('Vimeo data', data)
|
|
|
content.Vimeo = data// thumbnail_url_with_play_button
|
|
|
return content
|
|
|
})
|
|
@@ -519,7 +606,7 @@ export default {
|
|
|
}
|
|
|
})).then((cts) => {
|
|
|
// return an object with the right key (visible, etc, ...)
|
|
|
- console.log(`${key} cts`, cts)
|
|
|
+ // console.log(`${key} cts`, cts)
|
|
|
let o = {}
|
|
|
o[key] = cts
|
|
|
return o
|