From 94b9a5452f0e07d6d2e55027a40282085d7d973e Mon Sep 17 00:00:00 2001 From: Bachir Soussi Chiadmi Date: Mon, 31 Aug 2020 15:52:38 +0200 Subject: [PATCH] contents are placed on inner faces of building, with visibles above surface and others below --- src/App.vue | 72 +++++++----- src/components/mixins.js | 6 +- src/components/objects/ContentBlock.vue | 148 +++++++++++++++++++++--- src/components/objects/Project.vue | 29 ++++- 4 files changed, 204 insertions(+), 51 deletions(-) diff --git a/src/App.vue b/src/App.vue index 1aa3876..71044d3 100644 --- a/src/App.vue +++ b/src/App.vue @@ -184,7 +184,7 @@ export default { // cam_controls: null, init_cam_pos: { x: 0, y: 10, z: 100 }, raycaster: new THREE.Raycaster(), - interactive_objects_names: ['Project', 'ContentBlock'], + interactive_objects_names: ['Project', 'Content'], interactive_objects: [], light_opts: { castShadow: true @@ -286,34 +286,47 @@ export default { let cam = this.camera let camPos = { ...this.camera.position } if (intersects.length) { - console.log('onDocMouseUp intersects', intersects) - for (var i = 0; i < intersects.length; i++) { - object = intersects[i].object - vnode = object.userData.vnode - vnode.isOpened = true + // console.log('onDocMouseUp intersects', intersects) + // for (var i = 0; i < intersects.length; i++) { + object = intersects[0].object + vnode = object.userData.vnode + vnode.isOpened = true - // new TWEEN.Tween(this.controls.cam_target) - // .to(object.position, 400) - // .start() - // - toPos = { ...object.position } - if (object.name === 'ContentBlock') { - toPos.z += 1 + toPos = { ...object.position } + if (object.name === 'Content') { + // toPos.z += 1 + switch (vnode.face) { + case 'left': + toPos.x += 2 + break + case 'back': + toPos.z += 2 + break + case 'right': + toPos.x -= 2 + break + case 'front': + toPos.z -= 2 + break } - // toPos.y = 5 - new TWEEN.Tween(camPos) - .easing(TWEEN.Easing.Quadratic.InOut) - .to(toPos, 3000) - .onUpdate(function () { - // console.log('tween update', this._object) - cam.position.set(this._object.x, this._object.y, this._object.z) - // camControls.update() - }) - .start() - - // console.log('tween', tween) - break + // TODO: we need to update lon and lat accordingly when chaging camera orientation + // new TWEEN.Tween(this.controls.cam_target) + // .to(object.position, 2000) + // .start() } + // toPos.y = 5 + new TWEEN.Tween(camPos) + .easing(TWEEN.Easing.Quadratic.InOut) + .to(toPos, 3000) + .onUpdate(function () { + // console.log('tween update', this._object) + cam.position.set(this._object.x, this._object.y, this._object.z) + }) + .start() + + // console.log('tween', tween) + // break + // } } else { // new TWEEN.Tween(this.camera.position) // .to(this.init_cam_pos, 1000) @@ -329,13 +342,16 @@ export default { // if (this.controls.user_interact === false) { // this.controls.lon += 0.1 // } + // if (this.controls.user_interact) { this.controls.cam_target.x = 500 * Math.sin(this.controls.phi) * Math.cos(this.controls.theta) this.controls.cam_target.y = 500 * Math.cos(this.controls.phi) this.controls.cam_target.z = 500 * Math.sin(this.controls.phi) * Math.sin(this.controls.theta) - // if (this.camera && this.controls.user_interact) { - this.camera.lookAt(this.controls.cam_target) // } + if (this.camera) { + this.camera.lookAt(this.controls.cam_target) + } + // TWEENS TWEEN.update() } diff --git a/src/components/mixins.js b/src/components/mixins.js index 26210fa..b7fa7c6 100644 --- a/src/components/mixins.js +++ b/src/components/mixins.js @@ -4,7 +4,7 @@ export default { deg2rad (deg) { return deg * (Math.PI / 180) }, - createLabelCanvas (text, fontsize) { + createLabelCanvas (text, fontsize, sizefactore, txtcolor) { // console.log('createLabelCanvas', this.data.Titre) const size = fontsize const borderSize = 5 @@ -19,7 +19,7 @@ export default { width = Math.max(width, ctx.measureText(lines[i]).width + doubleBorderSize) } const height = size * lines.length + doubleBorderSize - this.label_size = { x: width / 21, y: height / 21 } + this.label_size = { x: width / sizefactore, y: height / sizefactore } ctx.canvas.width = width ctx.canvas.height = height @@ -29,7 +29,7 @@ export default { // ctx.fillStyle = 'red' // ctx.fillRect(0, 0, width, height) - ctx.fillStyle = 'black' + ctx.fillStyle = txtcolor for (var j = 0; j < lines.length; j++) { ctx.fillText(lines[j], borderSize, borderSize + j * size) } diff --git a/src/components/objects/ContentBlock.vue b/src/components/objects/ContentBlock.vue index a56d918..0a4e0d3 100644 --- a/src/components/objects/ContentBlock.vue +++ b/src/components/objects/ContentBlock.vue @@ -1,46 +1,160 @@