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(); },