diff --git a/src/meshes/Circle.js b/src/meshes/Circle.js index 4fc46a3..60367da 100644 --- a/src/meshes/Circle.js +++ b/src/meshes/Circle.js @@ -9,7 +9,6 @@ export default { segments: { type: Number, default: 8 }, thetaStart: { type: Number, default: 0 }, thetaLength: { type: Number, default: Math.PI * 2 }, - }, created() { this.createGeometry(); diff --git a/src/meshes/Cone.js b/src/meshes/Cone.js index 6c18791..7adf5ed 100644 --- a/src/meshes/Cone.js +++ b/src/meshes/Cone.js @@ -12,7 +12,6 @@ export default { openEnded: { type: Boolean, default: false }, thetaStart: { type: Number, default: 0 }, thetaLength: { type: Number, default: Math.PI * 2 }, - }, created() { this.createGeometry(); diff --git a/src/meshes/Cylinder.js b/src/meshes/Cylinder.js index 0d0832f..fa771a5 100644 --- a/src/meshes/Cylinder.js +++ b/src/meshes/Cylinder.js @@ -13,7 +13,6 @@ export default { openEnded: { type: Boolean, default: false }, thetaStart: { type: Number, default: 0 }, thetaLength: { type: Number, default: Math.PI * 2 }, - }, created() { this.createGeometry(); diff --git a/src/meshes/Dodecahedron.js b/src/meshes/Dodecahedron.js index 8497326..1334d0a 100644 --- a/src/meshes/Dodecahedron.js +++ b/src/meshes/Dodecahedron.js @@ -7,7 +7,6 @@ export default { props: { radius: { type: Number, default: 1 }, detail: { type: Number, default: 0 }, - }, created() { this.createGeometry(); diff --git a/src/meshes/Icosahedron.js b/src/meshes/Icosahedron.js index 16419e9..67c6f14 100644 --- a/src/meshes/Icosahedron.js +++ b/src/meshes/Icosahedron.js @@ -7,7 +7,6 @@ export default { props: { radius: { type: Number, default: 1 }, detail: { type: Number, default: 0 }, - }, created() { this.createGeometry(); diff --git a/src/meshes/Lathe.js b/src/meshes/Lathe.js index 33917f6..dd6f804 100644 --- a/src/meshes/Lathe.js +++ b/src/meshes/Lathe.js @@ -9,7 +9,6 @@ export default { segments: { type: Number, default: 12 }, phiStart: { type: Number, default: 0 }, phiLength: { type: Number, default: Math.PI * 2 }, - }, created() { this.createGeometry(); diff --git a/src/meshes/Octahedron.js b/src/meshes/Octahedron.js index 1a4c638..568b284 100644 --- a/src/meshes/Octahedron.js +++ b/src/meshes/Octahedron.js @@ -7,7 +7,6 @@ export default { props: { radius: { type: Number, default: 1 }, detail: { type: Number, default: 0 }, - }, created() { this.createGeometry(); diff --git a/src/meshes/Plane.js b/src/meshes/Plane.js index c7ebaf6..5955804 100644 --- a/src/meshes/Plane.js +++ b/src/meshes/Plane.js @@ -1,34 +1,24 @@ import { PlaneBufferGeometry } from 'three'; +import { watch } from 'vue'; import Mesh from './Mesh.js'; export default { extends: Mesh, props: { - width: { - type: Number, - default: 1, - }, - height: { - type: Number, - default: 1, - }, - widthSegments: { - type: Number, - default: 1, - }, - heightSegments: { - type: Number, - default: 1, - }, - }, - watch: { - width() { this.refreshGeometry(); }, - height() { this.refreshGeometry(); }, - widthSegments() { this.refreshGeometry(); }, - heightSegments() { this.refreshGeometry(); }, + width: { type: Number, default: 1 }, + height: { type: Number, default: 1 }, + widthSegments: { type: Number, default: 1 }, + heightSegments: { type: Number, default: 1 }, }, created() { this.createGeometry(); + + const watchProps = ['width', 'height', 'widthSegments', 'heightSegments']; + watchProps.forEach(prop => { + watch(() => this[prop], () => { + this.refreshGeometry(); + }); + }); }, methods: { createGeometry() { diff --git a/src/meshes/Polyhedron.js b/src/meshes/Polyhedron.js index c24cfd1..87672ae 100644 --- a/src/meshes/Polyhedron.js +++ b/src/meshes/Polyhedron.js @@ -7,7 +7,6 @@ export default { props: { radius: { type: Number, default: 1 }, detail: { type: Number, default: 0 }, - }, created() { this.createGeometry(); diff --git a/src/meshes/Ring.js b/src/meshes/Ring.js index 43b0bce..4e36523 100644 --- a/src/meshes/Ring.js +++ b/src/meshes/Ring.js @@ -11,7 +11,6 @@ export default { phiSegments: { type: Number, default: 1 }, thetaStart: { type: Number, default: 0 }, thetaLength: { type: Number, default: Math.PI * 2 }, - }, created() { this.createGeometry(); diff --git a/src/meshes/Sphere.js b/src/meshes/Sphere.js index 2d80ec9..1b0f851 100644 --- a/src/meshes/Sphere.js +++ b/src/meshes/Sphere.js @@ -5,14 +5,8 @@ export default { extends: Mesh, props: { radius: Number, - widthSegments: { - type: Number, - default: 12, - }, - heightSegments: { - type: Number, - default: 12, - }, + widthSegments: { type: Number, default: 12 }, + heightSegments: { type: Number, default: 12 }, }, watch: { radius() { this.refreshGeometry(); }, diff --git a/src/meshes/Tetrahedron.js b/src/meshes/Tetrahedron.js index 1f96e68..8fbb7b5 100644 --- a/src/meshes/Tetrahedron.js +++ b/src/meshes/Tetrahedron.js @@ -7,7 +7,6 @@ export default { props: { radius: { type: Number, default: 1 }, detail: { type: Number, default: 0 }, - }, created() { this.createGeometry(); diff --git a/src/meshes/Torus.js b/src/meshes/Torus.js index 649f201..6211331 100644 --- a/src/meshes/Torus.js +++ b/src/meshes/Torus.js @@ -10,7 +10,6 @@ export default { radialSegments: { type: Number, default: 8 }, tubularSegments: { type: Number, default: 6 }, arc: { type: Number, default: Math.PI * 2 }, - }, created() { this.createGeometry(); diff --git a/src/meshes/TorusKnot.js b/src/meshes/TorusKnot.js index 8635f1b..f020a54 100644 --- a/src/meshes/TorusKnot.js +++ b/src/meshes/TorusKnot.js @@ -11,7 +11,6 @@ export default { tubularSegments: { type: Number, default: 8 }, p: { type: Number, default: 2 }, q: { type: Number, default: 3 }, - }, created() { this.createGeometry(); diff --git a/src/meshes/Tube.js b/src/meshes/Tube.js index 61a5bf8..750d8de 100644 --- a/src/meshes/Tube.js +++ b/src/meshes/Tube.js @@ -10,7 +10,6 @@ export default { radius: { type: Number, default: 1 }, radialSegments: { type: Number, default: 8 }, closed: { type: Boolean, default: false }, - }, created() { this.createGeometry();