1
0
mirror of https://github.com/troisjs/trois.git synced 2024-11-24 20:32:02 +08:00
trois/src/meshes/Circle.js

31 lines
773 B
JavaScript
Raw Normal View History

2020-09-28 20:48:39 +08:00
import { CircleBufferGeometry } from 'three';
import { watch } from 'vue';
import Mesh from './Mesh.js';
export default {
extends: Mesh,
props: {
radius: { type: Number, default: 1 },
segments: { type: Number, default: 8 },
thetaStart: { type: Number, default: 0 },
thetaLength: { type: Number, default: Math.PI * 2 },
},
created() {
this.createGeometry();
const watchProps = ['radius', 'segments', 'thetaStart', 'thetaLength'];
watchProps.forEach(prop => {
watch(() => this[prop], () => {
this.refreshGeometry();
});
});
},
methods: {
createGeometry() {
this.geometry = new CircleBufferGeometry(this.radius, this.segments, this.thetaStart, this.thetaLength);
},
},
__hmrId: 'Circle',
};