mirror of
https://github.com/troisjs/trois.git
synced 2024-11-24 04:12:02 +08:00
cylinder
This commit is contained in:
parent
680e5a7d49
commit
5ebe40b962
@ -1,21 +1,27 @@
|
|||||||
import { CylinderGeometry } from 'three';
|
import { CylinderGeometry } from 'three';
|
||||||
import Geometry from './Geometry.js';
|
import Geometry from './Geometry.js';
|
||||||
|
|
||||||
|
export const props = {
|
||||||
|
radiusTop: { type: Number, default: 1 },
|
||||||
|
radiusBottom: { type: Number, default: 1 },
|
||||||
|
height: { type: Number, default: 1 },
|
||||||
|
radialSegments: { type: Number, default: 8 },
|
||||||
|
heightSegments: { type: Number, default: 1 },
|
||||||
|
openEnded: { type: Boolean, default: false },
|
||||||
|
thetaStart: { type: Number, default: 0 },
|
||||||
|
thetaLength: { type: Number, default: Math.PI * 2 },
|
||||||
|
};
|
||||||
|
|
||||||
|
export function createGeometry(comp) {
|
||||||
|
return new CylinderGeometry(comp.radiusTop, comp.radiusBottom, comp.height, comp.radialSegments, comp.heightSegments, comp.openEnded, comp.thetaStart, comp.thetaLength);
|
||||||
|
};
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
extends: Geometry,
|
extends: Geometry,
|
||||||
props: {
|
props,
|
||||||
radiusTop: { type: Number, default: 1 },
|
|
||||||
radiusBottom: { type: Number, default: 1 },
|
|
||||||
height: { type: Number, default: 1 },
|
|
||||||
radialSegments: { type: Number, default: 8 },
|
|
||||||
heightSegments: { type: Number, default: 1 },
|
|
||||||
openEnded: { type: Boolean, default: false },
|
|
||||||
thetaStart: { type: Number, default: 0 },
|
|
||||||
thetaLength: { type: Number, default: Math.PI * 2 },
|
|
||||||
},
|
|
||||||
methods: {
|
methods: {
|
||||||
createGeometry() {
|
createGeometry() {
|
||||||
this.geometry = new CylinderGeometry(this.radiusTop, this.radiusBottom, this.height, this.radialSegments, this.heightSegments, this.openEnded, this.thetaStart, this.thetaLength);
|
this.geometry = createGeometry(this);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -1,32 +1,16 @@
|
|||||||
import { CylinderBufferGeometry } from 'three';
|
|
||||||
import { watch } from 'vue';
|
|
||||||
import Mesh from './Mesh.js';
|
import Mesh from './Mesh.js';
|
||||||
|
import { props, createGeometry } from '../geometries/CylinderGeometry.js';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
extends: Mesh,
|
extends: Mesh,
|
||||||
props: {
|
props,
|
||||||
radiusTop: { type: Number, default: 1 },
|
|
||||||
radiusBottom: { type: Number, default: 1 },
|
|
||||||
height: { type: Number, default: 1 },
|
|
||||||
radialSegments: { type: Number, default: 8 },
|
|
||||||
heightSegments: { type: Number, default: 1 },
|
|
||||||
openEnded: { type: Boolean, default: false },
|
|
||||||
thetaStart: { type: Number, default: 0 },
|
|
||||||
thetaLength: { type: Number, default: Math.PI * 2 },
|
|
||||||
},
|
|
||||||
created() {
|
created() {
|
||||||
this.createGeometry();
|
this.createGeometry();
|
||||||
|
this.addGeometryWatchers(props);
|
||||||
const watchProps = ['radiusTop', 'radiusBottom', 'height', 'radialSegments', 'heightSegments', 'openEnded', 'thetaStart', 'thetaLength'];
|
|
||||||
watchProps.forEach(prop => {
|
|
||||||
watch(() => this[prop], () => {
|
|
||||||
this.refreshGeometry();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
createGeometry() {
|
createGeometry() {
|
||||||
this.geometry = new CylinderBufferGeometry(this.radiusTop, this.radiusBottom, this.height, this.radialSegments, this.heightSegments, this.openEnded, this.thetaStart, this.thetaLength);
|
this.geometry = createGeometry(this);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
__hmrId: 'Cylinder',
|
__hmrId: 'Cylinder',
|
||||||
|
Loading…
Reference in New Issue
Block a user