1
0
mirror of https://github.com/troisjs/trois.git synced 2024-11-23 20:02:32 +08:00

geometries refactor

This commit is contained in:
Kevin Levron 2020-09-15 10:51:38 +02:00
parent f2229aa757
commit 726087cc3c
4 changed files with 65 additions and 37 deletions

View File

@ -0,0 +1,31 @@
import { BoxBufferGeometry } from 'three';
import Geometry from './Geometry.js';
export default {
extends: Geometry,
inject: ['parent'],
props: {
size: {
type: Number,
},
width: {
type: Number,
default: 1,
},
height: {
type: Number,
default: 1,
},
depth: {
type: Number,
default: 1,
},
},
mounted() {
if (this.size) {
this.parent.geometry = new BoxBufferGeometry(this.size, this.size, this.size);
} else {
this.parent.geometry = new BoxBufferGeometry(this.width, this.height, this.depth);
}
},
};

View File

@ -0,0 +1,11 @@
export default {
inject: ['parent'],
created() {
if (!this.parent) {
console.error('Missing parent Mesh');
}
},
render() {
return [];
},
};

View File

@ -0,0 +1,21 @@
import { SphereBufferGeometry } from 'three';
import Geometry from './Geometry.js';
export default {
extends: Geometry,
inject: ['parent'],
props: {
radius: Number,
widthSegments: {
type: Number,
default: 12,
},
heightSegments: {
type: Number,
default: 12,
},
},
mounted() {
this.geometry = new SphereBufferGeometry(this.radius, this.widthSegments, this.heightSegments);
},
};

View File

@ -1,37 +1,2 @@
import { BoxBufferGeometry } from 'three';
export const BoxGeometry = {
inject: ['parent'],
props: {
size: {
type: Number,
},
width: {
type: Number,
default: 1,
},
height: {
type: Number,
default: 1,
},
depth: {
type: Number,
default: 1,
},
},
mounted() {
if (!this.parent) {
console.error('Missing parent Mesh');
return;
}
if (this.size) {
this.parent.geometry = new BoxBufferGeometry(this.size, this.size, this.size);
} else {
this.parent.geometry = new BoxBufferGeometry(this.width, this.height, this.depth);
}
},
render() {
return [];
},
};
export { default as BoxGeometry } from './BoxGeometry.js';
export { default as SphereGeometry } from './SphereGeometry.js';