fixed camera's latitude, added nbr opaque faces option

This commit is contained in:
2020-10-07 16:32:40 +02:00
parent f41ebbc03c
commit 16b804be2b
4 changed files with 30 additions and 34 deletions
+6 -5
View File
@@ -39,8 +39,8 @@
<template v-if="projects.length"> <template v-if="projects.length">
<project <project
v-for="(project) in projects" v-for="(project) in projects"
:key="project.id"
:id="project.id" :id="project.id"
:key="project.id"
/> />
</template> </template>
@@ -317,7 +317,7 @@ export default {
let cam = this.camera let cam = this.camera
console.log('onDocMouseUp intersects', intersects) console.log('onDocMouseUp intersects', intersects)
let object = intersects[0].object let object = intersects[0].object
console.log('object[0].name', object.name) console.log('object[0]', object)
let vnode = object.userData.vnode let vnode = object.userData.vnode
if (object.name === 'Content' && vnode.isOpened) { if (object.name === 'Content' && vnode.isOpened) {
this.content_data = vnode.data this.content_data = vnode.data
@@ -335,8 +335,9 @@ export default {
this.opened_vnode = vnode this.opened_vnode = vnode
// get new camera target pos // get new camera target pos
let toPos = { ...object.position } let toPos
if (object.name === 'Content') { if (object.name === 'Content') {
toPos = { ...object.position }
this.controls.lat = 0 this.controls.lat = 0
switch (vnode.face) { switch (vnode.face) {
case 'left': case 'left':
@@ -363,7 +364,7 @@ export default {
.to(object.position, 2000) .to(object.position, 2000)
.start() .start()
} else if (object.name === 'Project') { } else if (object.name === 'Project') {
toPos.z *= 0.5 toPos = { ...object.userData.position }
toPos.y = 2 toPos.y = 2
} }
// toPos.y = 5 // toPos.y = 5
@@ -390,7 +391,7 @@ export default {
animate (tt) { animate (tt) {
// CONTROLS // CONTROLS
if (this.controls.user_interact) { if (this.controls.user_interact) {
this.controls.lat = Math.max(-85, Math.min(85, this.controls.lat)) this.controls.lat = Math.max(-25, Math.min(45, this.controls.lat))
this.controls.phi = this.deg2rad(90 - this.controls.lat) this.controls.phi = this.deg2rad(90 - this.controls.lat)
this.controls.theta = this.deg2rad(this.controls.lon) this.controls.theta = this.deg2rad(this.controls.lon)
// if (this.controls.user_interact === false) { // if (this.controls.user_interact === false) {
+1
View File
@@ -125,6 +125,7 @@ export default {
// record self references // record self references
this.block3d = this.$refs.block3d.curObj this.block3d = this.$refs.block3d.curObj
this.block3d.userData.vnode = this this.block3d.userData.vnode = this
this.block3d.userData.position = this.position
this.label3d = this.$refs.label3d.curObj this.label3d = this.$refs.label3d.curObj
}, },
methods: { methods: {
+22 -29
View File
@@ -100,12 +100,12 @@ export default {
// actions // actions
actions: { actions: {
init ({ dispatch, commit, state, rootGetters }) { init ({ dispatch, commit, state, rootGetters }) {
console.log('Init Project module', state.id) console.log(`Init Project module ${state.id}`, state)
dispatch('sizingBuilding') dispatch('sizingBuilding')
dispatch('build3dObjs') dispatch('build3dObjs')
}, },
sizingBuilding ({ dispatch, commit, state, rootGetters }) { sizingBuilding ({ dispatch, commit, state, rootGetters }) {
console.log('sizingBuilding') console.log('sizingBuilding, state', state)
let totalW = rootGetters['Projects/totalW'] let totalW = rootGetters['Projects/totalW']
// console.log('totalW', totalW) // console.log('totalW', totalW)
let margin = rootGetters['Projects/marginBetweenBuildings'] let margin = rootGetters['Projects/marginBetweenBuildings']
@@ -139,7 +139,7 @@ export default {
x: x, x: x,
// y: -1 * state.size.y / 2 + 10 + Math.random() * 30, // -10 + Math.random() * this.size.y / 2 // y: -1 * state.size.y / 2 + 10 + Math.random() * 30, // -10 + Math.random() * this.size.y / 2
y: -state.size.y / 4, y: -state.size.y / 4,
z: -10 + Math.random() * 10 z: 0// -10 + Math.random() * 10
}) })
// WINDOWS // WINDOWS
@@ -211,10 +211,10 @@ export default {
console.log('build3dObjs') console.log('build3dObjs')
// http://learningthreejs.com/blog/2011/12/10/constructive-solid-geometry-with-csg-js/ // http://learningthreejs.com/blog/2011/12/10/constructive-solid-geometry-with-csg-js/
let backGeom = new THREE.BoxGeometry(state.size.x, state.size.y, state.wall.wallW) let frontGeom = new THREE.BoxGeometry(state.size.x, state.size.y, state.wall.wallW)
let backMesh = new THREE.Mesh(backGeom) let frontMesh = new THREE.Mesh(frontGeom)
backMesh.position.z = -0.5 * state.size.z frontMesh.position.z = 0.5 * state.size.z
let backBSP = new ThreeBSP(backMesh) let frontBSP = new ThreeBSP(frontMesh)
// https://medium.com/techtrument/multithreading-javascript-46156179cf9a // https://medium.com/techtrument/multithreading-javascript-46156179cf9a
let winGeom = new THREE.BoxGeometry(state.wall.winW, state.wall.winH, state.wall.wallW) let winGeom = new THREE.BoxGeometry(state.wall.winW, state.wall.winH, state.wall.wallW)
@@ -223,7 +223,7 @@ export default {
for (var i = 0; i < state.wall.nbrWinX; i++) { for (var i = 0; i < state.wall.nbrWinX; i++) {
for (var j = 0; j < state.wall.nbrWinY; j++) { for (var j = 0; j < state.wall.nbrWinY; j++) {
winMesh.position.z = -0.5 * state.size.z winMesh.position.z = 0.5 * state.size.z
winMesh.position.x = -0.5 * state.size.x + state.wall.margin + state.wall.winW * 0.5 + i * (state.wall.winW + state.wall.paddingX) winMesh.position.x = -0.5 * state.size.x + state.wall.margin + state.wall.winW * 0.5 + i * (state.wall.winW + state.wall.paddingX)
winMesh.position.y = 0.5 * state.size.y - state.wall.margin - state.wall.winH * 0.5 - j * (state.wall.winH + state.wall.paddingY) winMesh.position.y = 0.5 * state.size.y - state.wall.margin - state.wall.winH * 0.5 - j * (state.wall.winH + state.wall.paddingY)
// winMesh.updateMatrix() // winMesh.updateMatrix()
@@ -231,23 +231,18 @@ export default {
} }
} }
let windowsBSP = new ThreeBSP(windowsGeom) let windowsBSP = new ThreeBSP(windowsGeom)
backBSP = backBSP.subtract(windowsBSP) let frontWindowedBSP = frontBSP.subtract(windowsBSP)
// let winBSP // console.log('state.Faces_opaques', state.Faces_opaques)
// for (var i = 0; i < state.wall.nbrWinX; i++) { let backWindowedMesh
// for (var j = 0; j < state.wall.nbrWinY; j++) { if (state.Faces_opaques === 3) {
// winMesh.position.z = -0.5 * state.size.z backWindowedMesh = frontMesh.clone()
// winMesh.position.x = -0.5 * state.size.x + state.wall.margin + state.wall.winW * 0.5 + i * (state.wall.winW + state.wall.paddingX) } else {
// winMesh.position.y = 0.5 * state.size.y - state.wall.margin - state.wall.winH * 0.5 - j * (state.wall.winH + state.wall.paddingY) let frontWindowedMesh = frontWindowedBSP.toMesh()
// winBSP = new ThreeBSP(winMesh) backWindowedMesh = frontWindowedMesh.clone()
// backBSP = backBSP.subtract(winBSP) }
// } backWindowedMesh.position.z = -0.5 * state.size.z
// } let backWindowedBSP = new ThreeBSP(backWindowedMesh)
backMesh = backBSP.toMesh()
let faceMesh = backMesh.clone()
faceMesh.position.z = 0.5 * state.size.z
let faceBSP = new ThreeBSP(faceMesh)
let rightGeom = new THREE.BoxGeometry(state.wall.wallW, state.size.y, state.size.z) let rightGeom = new THREE.BoxGeometry(state.wall.wallW, state.size.y, state.size.z)
let rightMesh = new THREE.Mesh(rightGeom) let rightMesh = new THREE.Mesh(rightGeom)
@@ -260,11 +255,9 @@ export default {
// leftMesh.position.z = 0.5 * state.size.z // leftMesh.position.z = 0.5 * state.size.z
let leftBSP = new ThreeBSP(leftMesh) let leftBSP = new ThreeBSP(leftMesh)
let buildingBSP = backBSP.union(rightBSP) let buildingBSP = frontWindowedBSP.union(rightBSP)
buildingBSP = buildingBSP.union(faceBSP) buildingBSP = buildingBSP.union(backWindowedBSP)
buildingBSP = buildingBSP.union(leftBSP) buildingBSP = buildingBSP.union(leftBSP)
// buildingBSP = buildingBSP.union(topBSP)
// buildingBSP = buildingBSP.union(floorBSP)
// convert back to three.js mesh // convert back to three.js mesh
let building = buildingBSP.toMesh() let building = buildingBSP.toMesh()
@@ -291,7 +284,7 @@ export default {
building.material = new THREE.MeshPhongMaterial(materialOpts) building.material = new THREE.MeshPhongMaterial(materialOpts)
// commiting walls // commiting walls
commit('setWalls3dObj', building) commit('setWalls3dObj', building)
let buildingPos = { ...state.position, ...{ z: state.position.z - 0.5 * state.size.z } } let buildingPos = { ...state.position, ...{ z: state.position.z + 0.5 * state.size.z } }
commit('setWallsPos', buildingPos) commit('setWallsPos', buildingPos)
// TOP & FLOOR // TOP & FLOOR
+1
View File
@@ -48,6 +48,7 @@ export default {
id id
Weight Weight
Titre Titre
Faces_opaques
} }
}` }) }` })
.then(({ data: { data: { projects } = null } }) => { .then(({ data: { data: { projects } = null } }) => {