diff --git a/src/App.vue b/src/App.vue
index 40ea588..1aa3876 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -6,7 +6,7 @@
class="site-title"
tabindex="0"
>
- Muntadas
+ Muntadas
@@ -33,7 +33,7 @@
-
+
-
+
@@ -13,27 +13,36 @@ export default {
// mixins: [Object3D],
props: { prtPosition: Object, prtSize: Object },
data: () => ({
- color: 0xffffff,
- size: { x: 2, y: 2, z: 2 },
- position: { x: 0, y: 5, z: 2 },
+ block3d: null,
+ size: { x: 2, y: 3, z: 0.1 },
+ position: { x: 0, y: 0, z: 0 },
opts: {
side: THREE.DoubleSide
// wireframe: false,
// transparent: false,
// opacity: 0.6
- }
+ },
+ isOpened: false
}),
+ computed: {
+ color () {
+ return this.opened ? 0xff0000 : 0x0000ff
+ }
+ },
created () {
console.log('ContentBlock created', this.prtSize)
this.position.x = this.prtPosition.x - this.prtSize.x / 2 + Math.random() * this.prtSize.x
-
- // console.log('this.position.y', this.position.y)
- if (Math.random() > 0.5) {
- this.position.y = this.prtPosition.y + this.prtSize.y / 2 + Math.random() * 20
- } else {
- this.position.y = this.prtPosition.y - this.prtSize.y / 2 - Math.random() * 20
+ this.position.y = this.prtPosition.y - this.prtSize.y / 2 + Math.random() * this.prtSize.y
+ this.position.z = this.prtPosition.z - this.prtSize.z / 2 + Math.random() * this.prtSize.z
+ },
+ mounted () {
+ this.block3d = this.$refs.block3d.curObj
+ // this.block3d.castShadow = true
+ // this.block3d.receiveShadow = true
+ // record self references
+ this.block3d.userData = {
+ vnode: this
}
- // this.position.z = this.prtPosition.Z
}
}
diff --git a/src/components/objects/Project.vue b/src/components/objects/Project.vue
index 8309c10..7b2b8a2 100644
--- a/src/components/objects/Project.vue
+++ b/src/components/objects/Project.vue
@@ -22,6 +22,7 @@
import * as THREE from 'three'
// import { Base } from 'vue-threejs'
+import mixins from 'components/mixins'
import ContentBlock from 'components/objects/ContentBlock'
export default {
@@ -29,17 +30,10 @@ export default {
components: {
ContentBlock
},
- // mixins: [Base],
+ mixins: [mixins],
// props: { size: Object, texture: String, position: Object, color: Number },
props: { data: Object, len: Number, index: Number },
data: () => ({
- // mesh_opts: {
- // userData: {
- // test: 'Hello!'
- // },
- // receiveShadow: true,
- // castShadow: true
- // },
block3d: null,
block_opts: {
side: THREE.DoubleSide
@@ -52,7 +46,7 @@ export default {
label_opts: {
side: THREE.DoubleSide,
// wireframe: false,
- transparent: false
+ transparent: true
// opacity: 0.6
// renderOrder: 0
},
@@ -79,13 +73,19 @@ export default {
// randomize size and positions
this.size.y = 100 + Math.random() * 90
this.size.z = 10 + Math.random() * 30
- this.position.x = this.label_position.x = (-this.len + 1) / 2 * (this.size.x + 5) + (this.size.x + 5) * this.index
+
+ this.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_position.y = 5
+
+ this.label_canvas = this.createLabelCanvas(this.data.Titre.replace(/ /g, '\n').toUpperCase(), 48)
+ this.label_position.x = this.position.x - this.size.x / 2 + this.label_size.x / 2 + 1
+ this.label_position.y = this.position.y + this.size.y / 2 - this.label_size.y / 2 - 1
this.label_position.z = this.position.z + this.size.z / 2 + 0.1
- this.label_canvas = this.createLabelCanvas()
// console.log('this.label_canvas', this.label_canvas)
+ },
+ mounted () {
+ // console.log('project mounted', this)
// mesh options
this.block3d = this.$refs.block3d.curObj
this.block3d.castShadow = true
@@ -95,38 +95,15 @@ export default {
vnode: this
}
this.label3d = this.$refs.label3d.curObj
- },
- mounted () {
- // console.log('project mounted', this)
- },
- methods: {
- createLabelCanvas () {
- // console.log('createLabelCanvas', this.data.Titre)
- const size = 48
- const borderSize = 5
- const ctx = document.createElement('canvas').getContext('2d')
- const font = `${size}px bold noto_sans`
- ctx.font = font
- // measure how long the name will be
- const doubleBorderSize = borderSize * 2
- const width = ctx.measureText(this.data.Titre).width + doubleBorderSize
- const height = size + doubleBorderSize
- this.label_size = { x: width / 21, y: height / 21 }
- ctx.canvas.width = width
- ctx.canvas.height = height
-
- // need to set font again after resizing canvas
- ctx.font = font
- ctx.textBaseline = 'top'
-
- ctx.fillStyle = 'white'
- ctx.fillRect(0, 0, width, height)
- ctx.fillStyle = 'black'
- ctx.fillText(this.data.Titre, borderSize, borderSize)
- // console.log('createLabelCanvas', ctx)
- return ctx.canvas
- }
+ // light
+ // console.log('project mounted', this.$env3d)
+ // var light = new THREE.AmbientLight(0xbf1a1a) // soft white light
+ // this.$env3d.scene.add(light)
}
+ // ,
+ // methods: {
+ //
+ // }
}
diff --git a/src/index.js b/src/index.js
index 1160c72..d70e6cd 100644
--- a/src/index.js
+++ b/src/index.js
@@ -14,6 +14,14 @@ import 'assets/css/app.scss'
Vue.use(Meta)
Vue.use(VueThreejs)
+// https://stackoverflow.com/a/43193455
+var env3d = {
+ scene: null,
+ renderer: null,
+ camera: null
+}
+Vue.prototype.$env3d = env3d
+
// sync(store, router) // done. Returns an unsync callback fn
// sync(store)