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

26 lines
625 B
JavaScript
Raw Normal View History

2020-09-15 22:21:07 +08:00
import { SphereBufferGeometry } from 'three';
2020-09-14 22:57:11 +08:00
import Mesh from './Mesh.js';
export default {
extends: Mesh,
props: {
radius: Number,
2020-09-28 22:18:57 +08:00
widthSegments: { type: Number, default: 12 },
heightSegments: { type: Number, default: 12 },
2020-09-14 22:57:11 +08:00
},
2020-09-20 03:42:33 +08:00
watch: {
radius() { this.refreshGeometry(); },
widthSegments() { this.refreshGeometry(); },
heightSegments() { this.refreshGeometry(); },
},
2020-09-14 22:57:11 +08:00
created() {
2020-09-20 03:42:33 +08:00
this.createGeometry();
},
methods: {
createGeometry() {
this.geometry = new SphereBufferGeometry(this.radius, this.widthSegments, this.heightSegments);
},
2020-09-14 22:57:11 +08:00
},
2020-09-19 22:40:58 +08:00
__hmrId: 'Sphere',
2020-09-14 22:57:11 +08:00
};