moved all project sizings and positiongs on project store, creating my own geometry

This commit is contained in:
2020-09-09 12:40:06 +02:00
parent e67c7debc5
commit d1c5942f43
2 changed files with 42 additions and 38 deletions
+39 -37
View File
@@ -1,7 +1,7 @@
<template> <template>
<div> <div>
<mesh ref="block3d" name="Project" :position="position"> <mesh ref="block3d" name="Project" :position="position">
<geometry type="Box" :args="[size.x, size.y, size.z]" /> <!-- <geometry type="Box" :args="[size.x, size.y, size.z]" /> -->
<material type="MeshLambert" :color="color" :options="block_opts"> <material type="MeshLambert" :color="color" :options="block_opts">
<!-- <texture :options="label_texture_opts" /> --> <!-- <texture :options="label_texture_opts" /> -->
</material> </material>
@@ -56,32 +56,42 @@ export default {
mixins: [mixins], mixins: [mixins],
// props: { size: Object, texture: String, position: Object, color: Number }, // props: { size: Object, texture: String, position: Object, color: Number },
props: { data: Object, len: Number, index: Number }, props: { data: Object, len: Number, index: Number },
data: () => ({ data () {
block3d: null, console.log('Project data() : data', this.data)
block_opts: { // get size and positions from project store
side: THREE.DoubleSide let size = { ...this.data.size }
// wireframe: true, let position = { ...this.data.position }
// transparent: true,
// opacity: 0.6 let geometry = new THREE.BoxBufferGeometry(size.x, size.y, size.z)
// renderOrder: 0
}, return {
label3d: null, block3d: null,
label_opts: { block_opts: {
side: THREE.DoubleSide, side: THREE.DoubleSide
// wireframe: false, // wireframe: true,
transparent: true // transparent: true,
// opacity: 0.6 // opacity: 0.6
// renderOrder: 0 // renderOrder: 0
}, },
// size and positions are defined in store project label3d: null,
size: { x: 0, y: 0, z: 0 }, label_opts: {
position: { x: 0, y: 0, z: 0 }, side: THREE.DoubleSide,
label_position: { x: 0, y: 0, z: 0 }, // wireframe: false,
color: 0xffffff, transparent: true
label_canvas: null, // opacity: 0.6
label_size: null, // renderOrder: 0
isOpened: false },
}), // size and positions are defined in store project
size: size,
position: position,
geometry: geometry,
label_position: { x: 0, y: 0, z: 0 },
color: 0xffffff,
label_canvas: null,
label_size: null,
isOpened: false
}
},
computed: { computed: {
label_texture_opts () { label_texture_opts () {
return { return {
@@ -93,16 +103,7 @@ export default {
} }
}, },
created () { created () {
console.log('Project created: data', this.data) console.log('Project created: data', this, this.data)
// randomize size and positions
// this.size.x = ... // it's
this.size = { ...this.data.size }
// this.size.y = 100 + Math.random() * 90
// this.size.z = 10 + Math.random() * 30
this.position.x = this.data.position.x// (-this.len + 1) / 2 * (this.size.x + 5) + (this.size.x + 5) * this.index
this.position.y = -1 * this.size.y / 2 + 10 + Math.random() * 30// -10 + Math.random() * this.size.y / 2
this.position.z = -10 + Math.random() * 10
this.label_canvas = this.createLabelCanvas(this.data.Titre.replace(/ /g, '\n').toUpperCase(), 48, 21, '#000000') this.label_canvas = this.createLabelCanvas(this.data.Titre.replace(/ /g, '\n').toUpperCase(), 48, 21, '#000000')
this.label_position.x = this.position.x - this.size.x / 2 + this.label_size.x / 2 + 1 this.label_position.x = this.position.x - this.size.x / 2 + this.label_size.x / 2 + 1
@@ -114,6 +115,7 @@ export default {
// console.log('project mounted', this) // console.log('project mounted', this)
// mesh options // mesh options
this.block3d = this.$refs.block3d.curObj this.block3d = this.$refs.block3d.curObj
this.block3d.geometry = this.geometry
this.block3d.castShadow = true this.block3d.castShadow = true
this.block3d.receiveShadow = true this.block3d.receiveShadow = true
// record self references // record self references
+3 -1
View File
@@ -40,7 +40,9 @@ export default {
x += margin * j x += margin * j
x += state.projects[j].size.x / 2 x += state.projects[j].size.x / 2
state.projects[j].position = { state.projects[j].position = {
x: x x: x,
y: -1 * state.projects[j].size.y / 2 + 10 + Math.random() * 30, // -10 + Math.random() * this.size.y / 2
z: -10 + Math.random() * 10
} }
} }
} }