From 9fc7ef75b739e0e01fa0b3370258605e9c2214ee Mon Sep 17 00:00:00 2001 From: Kevin Levron Date: Sat, 3 Oct 2020 22:57:33 +0200 Subject: [PATCH] wip --- src/components/demos/Demo3.vue | 3 +++ src/geometries/Geometry.js | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/components/demos/Demo3.vue b/src/components/demos/Demo3.vue index a68681d..3a3094d 100644 --- a/src/components/demos/Demo3.vue +++ b/src/components/demos/Demo3.vue @@ -8,6 +8,9 @@ + + + diff --git a/src/geometries/Geometry.js b/src/geometries/Geometry.js index 0d0fe38..39fdb20 100644 --- a/src/geometries/Geometry.js +++ b/src/geometries/Geometry.js @@ -3,6 +3,11 @@ import { watch } from 'vue'; export default { emits: ['ready'], inject: ['mesh'], + props: { + rotateX: Number, + rotateY: Number, + rotateZ: Number, + }, created() { if (!this.mesh) { console.error('Missing parent Mesh'); @@ -12,6 +17,7 @@ export default { }, beforeMount() { this.createGeometry(); + this.rotateGeometry(); this.mesh.setGeometry(this.geometry); }, mounted() { @@ -21,6 +27,11 @@ export default { this.geometry.dispose(); }, methods: { + rotateGeometry() { + if (this.rotateX) this.geometry.rotateX(this.rotateX); + if (this.rotateY) this.geometry.rotateY(this.rotateY); + if (this.rotateZ) this.geometry.rotateZ(this.rotateZ); + }, addWatchers() { this.watchProps.forEach(prop => { watch(() => this[prop], () => { @@ -31,6 +42,7 @@ export default { refreshGeometry() { const oldGeo = this.geometry; this.createGeometry(); + this.rotateGeometry(); this.mesh.setGeometry(this.geometry); oldGeo.dispose(); },