1
0
mirror of https://github.com/troisjs/trois.git synced 2024-11-24 12:22:03 +08:00
trois/src/meshes/Lathe.js

30 lines
735 B
JavaScript
Raw Normal View History

2020-09-28 20:48:39 +08:00
import { LatheBufferGeometry } from 'three';
import { watch } from 'vue';
import Mesh from './Mesh.js';
export default {
extends: Mesh,
props: {
points: Array,
segments: { type: Number, default: 12 },
phiStart: { type: Number, default: 0 },
phiLength: { type: Number, default: Math.PI * 2 },
},
created() {
this.createGeometry();
const watchProps = ['points', 'segments', 'phiStart', 'phiLength'];
watchProps.forEach(prop => {
watch(() => this[prop], () => {
this.refreshGeometry();
});
});
},
methods: {
createGeometry() {
this.geometry = new LatheBufferGeometry(this.points, this.segments, this.phiStart, this.phiLength);
},
},
__hmrId: 'Lathe',
};