1
0
mirror of https://github.com/troisjs/trois.git synced 2024-11-24 04:12:02 +08:00

fix polyhedron

This commit is contained in:
Kevin Levron 2020-09-28 16:56:10 +02:00
parent f8cc0fb429
commit a90e9f663c
2 changed files with 7 additions and 3 deletions

View File

@ -4,10 +4,12 @@ import Geometry from './Geometry.js';
export default {
extends: Geometry,
props: {
vertices: Array,
indices: Array,
radius: { type: Number, default: 1 },
detail: { type: Number, default: 0 },
},
created() {
this.parent.geometry = new PolyhedronBufferGeometry(this.radius, this.detail);
this.parent.geometry = new PolyhedronBufferGeometry(this.vertices, this.indices, this.radius, this.detail);
},
};

View File

@ -5,13 +5,15 @@ import Mesh from './Mesh.js';
export default {
extends: Mesh,
props: {
vertices: Array,
indices: Array,
radius: { type: Number, default: 1 },
detail: { type: Number, default: 0 },
},
created() {
this.createGeometry();
const watchProps = ['radius', 'detail'];
const watchProps = ['vertices', 'indices', 'radius', 'detail'];
watchProps.forEach(prop => {
watch(() => this[prop], () => {
this.refreshGeometry();
@ -20,7 +22,7 @@ export default {
},
methods: {
createGeometry() {
this.geometry = new PolyhedronBufferGeometry(this.radius, this.detail);
this.geometry = new PolyhedronBufferGeometry(this.vertices, this.indices, this.radius, this.detail);
},
},
__hmrId: 'Polyhedron',