From 4239d5716b5b42a9154860762fe5f7a0b76a4d5a Mon Sep 17 00:00:00 2001 From: Anatoly Date: Sat, 29 Jan 2022 23:14:15 +0300 Subject: [PATCH] Start floating on load --- bundle/vue-three-d-mockup.esm.js | 9 ++++++--- src/Mockup.vue | 5 +++-- src/MockupModel.js | 4 +++- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/bundle/vue-three-d-mockup.esm.js b/bundle/vue-three-d-mockup.esm.js index 0ad9b8f..72333d8 100644 --- a/bundle/vue-three-d-mockup.esm.js +++ b/bundle/vue-three-d-mockup.esm.js @@ -11,9 +11,11 @@ class MockupModel extends Group { this.goingHome = false; this.home = home; + this.position.x = this.home.position.x; - this.position.y = this.home.position.z; + this.position.y = this.home.position.y; this.position.z = this.home.position.z; + this.rotation.x = this.home.rotation.x; this.rotation.y = this.home.rotation.y; this.rotation.z = this.home.rotation.z; @@ -242,6 +244,7 @@ var script = { z: 0.06, }, }); + phone.startFloat(); scene.add(phone); screenInit(); bodyInit(); @@ -271,11 +274,11 @@ var script = { } function handleMouseEnter() { - phone.animation = 'lookAt'; + if (phone) { phone.animation = 'lookAt'; } } function handleMouseLeave() { - phone.animation = 'home'; + if (phone) { phone.animation = 'home'; } } function handleMouseMove(event) { diff --git a/src/Mockup.vue b/src/Mockup.vue index 393dcd5..0fbfd35 100644 --- a/src/Mockup.vue +++ b/src/Mockup.vue @@ -137,6 +137,7 @@ export default { z: 0.06, }, }); + phone.startFloat(); scene.add(phone); screenInit(); bodyInit(); @@ -166,11 +167,11 @@ export default { } function handleMouseEnter() { - phone.animation = 'lookAt'; + if (phone) { phone.animation = 'lookAt'; } } function handleMouseLeave() { - phone.animation = 'home'; + if (phone) { phone.animation = 'home'; } } function handleMouseMove(event) { diff --git a/src/MockupModel.js b/src/MockupModel.js index fd39ace..518ee61 100644 --- a/src/MockupModel.js +++ b/src/MockupModel.js @@ -8,9 +8,11 @@ export default class MockupModel extends Group { this.goingHome = false; this.home = home; + this.position.x = this.home.position.x; - this.position.y = this.home.position.z; + this.position.y = this.home.position.y; this.position.z = this.home.position.z; + this.rotation.x = this.home.rotation.x; this.rotation.y = this.home.rotation.y; this.rotation.z = this.home.rotation.z;