mirror of
https://github.com/troisjs/trois.git
synced 2024-11-24 04:12:02 +08:00
simplify geometries
This commit is contained in:
parent
62f47d10aa
commit
c900286de8
@ -1,6 +1,5 @@
|
|||||||
import { defineComponent } from 'vue';
|
import { geometryComponent } from './Geometry.js';
|
||||||
import { BoxGeometry } from 'three';
|
import { BoxGeometry } from 'three';
|
||||||
import Geometry from './Geometry.js';
|
|
||||||
|
|
||||||
export const props = {
|
export const props = {
|
||||||
size: Number,
|
size: Number,
|
||||||
@ -20,12 +19,4 @@ export function createGeometry(comp) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export default defineComponent({
|
export default geometryComponent('BoxGeometry', props, createGeometry);
|
||||||
extends: Geometry,
|
|
||||||
props,
|
|
||||||
methods: {
|
|
||||||
createGeometry() {
|
|
||||||
this.geometry = createGeometry(this);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import { defineComponent } from 'vue';
|
import { geometryComponent } from './Geometry.js';
|
||||||
import { CircleGeometry } from 'three';
|
import { CircleGeometry } from 'three';
|
||||||
import Geometry from './Geometry.js';
|
|
||||||
|
|
||||||
export const props = {
|
export const props = {
|
||||||
radius: { type: Number, default: 1 },
|
radius: { type: Number, default: 1 },
|
||||||
@ -13,12 +12,4 @@ export function createGeometry(comp) {
|
|||||||
return new CircleGeometry(comp.radius, comp.segments, comp.thetaStart, comp.thetaLength);
|
return new CircleGeometry(comp.radius, comp.segments, comp.thetaStart, comp.thetaLength);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default defineComponent({
|
export default geometryComponent('CircleGeometry', props, createGeometry);
|
||||||
extends: Geometry,
|
|
||||||
props,
|
|
||||||
methods: {
|
|
||||||
createGeometry() {
|
|
||||||
this.geometry = createGeometry(this);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import { defineComponent } from 'vue';
|
import { geometryComponent } from './Geometry.js';
|
||||||
import { ConeGeometry } from 'three';
|
import { ConeGeometry } from 'three';
|
||||||
import Geometry from './Geometry.js';
|
|
||||||
|
|
||||||
export const props = {
|
export const props = {
|
||||||
radius: { type: Number, default: 1 },
|
radius: { type: Number, default: 1 },
|
||||||
@ -16,12 +15,4 @@ export function createGeometry(comp) {
|
|||||||
return new ConeGeometry(comp.radius, comp.height, comp.radialSegments, comp.heightSegments, comp.openEnded, comp.thetaStart, comp.thetaLength);
|
return new ConeGeometry(comp.radius, comp.height, comp.radialSegments, comp.heightSegments, comp.openEnded, comp.thetaStart, comp.thetaLength);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default defineComponent({
|
export default geometryComponent('ConeGeometry', props, createGeometry);
|
||||||
extends: Geometry,
|
|
||||||
props,
|
|
||||||
methods: {
|
|
||||||
createGeometry() {
|
|
||||||
this.geometry = createGeometry(this);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import { defineComponent } from 'vue';
|
import { geometryComponent } from './Geometry.js';
|
||||||
import { CylinderGeometry } from 'three';
|
import { CylinderGeometry } from 'three';
|
||||||
import Geometry from './Geometry.js';
|
|
||||||
|
|
||||||
export const props = {
|
export const props = {
|
||||||
radiusTop: { type: Number, default: 1 },
|
radiusTop: { type: Number, default: 1 },
|
||||||
@ -17,12 +16,4 @@ export function createGeometry(comp) {
|
|||||||
return new CylinderGeometry(comp.radiusTop, comp.radiusBottom, comp.height, comp.radialSegments, comp.heightSegments, comp.openEnded, comp.thetaStart, comp.thetaLength);
|
return new CylinderGeometry(comp.radiusTop, comp.radiusBottom, comp.height, comp.radialSegments, comp.heightSegments, comp.openEnded, comp.thetaStart, comp.thetaLength);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default defineComponent({
|
export default geometryComponent('CylinderGeometry', props, createGeometry);
|
||||||
extends: Geometry,
|
|
||||||
props,
|
|
||||||
methods: {
|
|
||||||
createGeometry() {
|
|
||||||
this.geometry = createGeometry(this);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import { defineComponent } from 'vue';
|
import { geometryComponent } from './Geometry.js';
|
||||||
import { DodecahedronGeometry } from 'three';
|
import { DodecahedronGeometry } from 'three';
|
||||||
import Geometry from './Geometry.js';
|
|
||||||
|
|
||||||
export const props = {
|
export const props = {
|
||||||
radius: { type: Number, default: 1 },
|
radius: { type: Number, default: 1 },
|
||||||
@ -11,12 +10,4 @@ export function createGeometry(comp) {
|
|||||||
return new DodecahedronGeometry(comp.radius, comp.detail);
|
return new DodecahedronGeometry(comp.radius, comp.detail);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default defineComponent({
|
export default geometryComponent('DodecahedronGeometry', props, createGeometry);
|
||||||
extends: Geometry,
|
|
||||||
props,
|
|
||||||
methods: {
|
|
||||||
createGeometry() {
|
|
||||||
this.geometry = createGeometry(this);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { defineComponent, watch } from 'vue';
|
import { defineComponent, watch } from 'vue';
|
||||||
|
|
||||||
export default defineComponent({
|
const Geometry = defineComponent({
|
||||||
inject: ['mesh'],
|
inject: ['mesh'],
|
||||||
props: {
|
props: {
|
||||||
rotateX: Number,
|
rotateX: Number,
|
||||||
@ -47,3 +47,18 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
render() { return []; },
|
render() { return []; },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export default Geometry;
|
||||||
|
|
||||||
|
export function geometryComponent(name, props, createGeometry) {
|
||||||
|
return defineComponent({
|
||||||
|
name,
|
||||||
|
extends: Geometry,
|
||||||
|
props,
|
||||||
|
methods: {
|
||||||
|
createGeometry() {
|
||||||
|
this.geometry = createGeometry(this);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import { defineComponent } from 'vue';
|
import { geometryComponent } from './Geometry.js';
|
||||||
import { IcosahedronGeometry } from 'three';
|
import { IcosahedronGeometry } from 'three';
|
||||||
import Geometry from './Geometry.js';
|
|
||||||
|
|
||||||
export const props = {
|
export const props = {
|
||||||
radius: { type: Number, default: 1 },
|
radius: { type: Number, default: 1 },
|
||||||
@ -11,12 +10,4 @@ export function createGeometry(comp) {
|
|||||||
return new IcosahedronGeometry(comp.radius, comp.detail);
|
return new IcosahedronGeometry(comp.radius, comp.detail);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default defineComponent({
|
export default geometryComponent('IcosahedronGeometry', props, createGeometry);
|
||||||
extends: Geometry,
|
|
||||||
props,
|
|
||||||
methods: {
|
|
||||||
createGeometry() {
|
|
||||||
this.geometry = createGeometry(this);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import { defineComponent } from 'vue';
|
import { geometryComponent } from './Geometry.js';
|
||||||
import { LatheGeometry } from 'three';
|
import { LatheGeometry } from 'three';
|
||||||
import Geometry from './Geometry.js';
|
|
||||||
|
|
||||||
export const props = {
|
export const props = {
|
||||||
points: Array,
|
points: Array,
|
||||||
@ -13,12 +12,4 @@ export function createGeometry(comp) {
|
|||||||
return new LatheGeometry(comp.points, comp.segments, comp.phiStart, comp.phiLength);
|
return new LatheGeometry(comp.points, comp.segments, comp.phiStart, comp.phiLength);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default defineComponent({
|
export default geometryComponent('LatheGeometry', props, createGeometry);
|
||||||
extends: Geometry,
|
|
||||||
props,
|
|
||||||
methods: {
|
|
||||||
createGeometry() {
|
|
||||||
this.geometry = createGeometry(this);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import { defineComponent } from 'vue';
|
import { geometryComponent } from './Geometry.js';
|
||||||
import { OctahedronGeometry } from 'three';
|
import { OctahedronGeometry } from 'three';
|
||||||
import Geometry from './Geometry.js';
|
|
||||||
|
|
||||||
export const props = {
|
export const props = {
|
||||||
radius: { type: Number, default: 1 },
|
radius: { type: Number, default: 1 },
|
||||||
@ -11,12 +10,4 @@ export function createGeometry(comp) {
|
|||||||
return new OctahedronGeometry(comp.radius, comp.detail);
|
return new OctahedronGeometry(comp.radius, comp.detail);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default defineComponent({
|
export default geometryComponent('OctahedronGeometry', props, createGeometry);
|
||||||
extends: Geometry,
|
|
||||||
props,
|
|
||||||
methods: {
|
|
||||||
createGeometry() {
|
|
||||||
this.geometry = createGeometry(this);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import { defineComponent } from 'vue';
|
import { geometryComponent } from './Geometry.js';
|
||||||
import { PlaneGeometry } from 'three';
|
import { PlaneGeometry } from 'three';
|
||||||
import Geometry from './Geometry.js';
|
|
||||||
|
|
||||||
export const props = {
|
export const props = {
|
||||||
width: { type: Number, default: 1 },
|
width: { type: Number, default: 1 },
|
||||||
@ -13,12 +12,4 @@ export function createGeometry(comp) {
|
|||||||
return new PlaneGeometry(comp.width, comp.height, comp.widthSegments, comp.heightSegments);
|
return new PlaneGeometry(comp.width, comp.height, comp.widthSegments, comp.heightSegments);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default defineComponent({
|
export default geometryComponent('PlaneGeometry', props, createGeometry);
|
||||||
extends: Geometry,
|
|
||||||
props,
|
|
||||||
methods: {
|
|
||||||
createGeometry() {
|
|
||||||
this.geometry = createGeometry(this);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import { defineComponent } from 'vue';
|
import { geometryComponent } from './Geometry.js';
|
||||||
import { PolyhedronGeometry } from 'three';
|
import { PolyhedronGeometry } from 'three';
|
||||||
import Geometry from './Geometry.js';
|
|
||||||
|
|
||||||
export const props = {
|
export const props = {
|
||||||
vertices: Array,
|
vertices: Array,
|
||||||
@ -13,12 +12,4 @@ export function createGeometry(comp) {
|
|||||||
return new PolyhedronGeometry(comp.vertices, comp.indices, comp.radius, comp.detail);
|
return new PolyhedronGeometry(comp.vertices, comp.indices, comp.radius, comp.detail);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default defineComponent({
|
export default geometryComponent('PolyhedronGeometry', props, createGeometry);
|
||||||
extends: Geometry,
|
|
||||||
props,
|
|
||||||
methods: {
|
|
||||||
createGeometry() {
|
|
||||||
this.geometry = createGeometry(this);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import { defineComponent } from 'vue';
|
import { geometryComponent } from './Geometry.js';
|
||||||
import { RingGeometry } from 'three';
|
import { RingGeometry } from 'three';
|
||||||
import Geometry from './Geometry.js';
|
|
||||||
|
|
||||||
export const props = {
|
export const props = {
|
||||||
innerRadius: { type: Number, default: 0.5 },
|
innerRadius: { type: Number, default: 0.5 },
|
||||||
@ -15,12 +14,4 @@ export function createGeometry(comp) {
|
|||||||
return new RingGeometry(comp.innerRadius, comp.outerRadius, comp.thetaSegments, comp.phiSegments, comp.thetaStart, comp.thetaLength);
|
return new RingGeometry(comp.innerRadius, comp.outerRadius, comp.thetaSegments, comp.phiSegments, comp.thetaStart, comp.thetaLength);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default defineComponent({
|
export default geometryComponent('RingGeometry', props, createGeometry);
|
||||||
extends: Geometry,
|
|
||||||
props,
|
|
||||||
methods: {
|
|
||||||
createGeometry() {
|
|
||||||
this.geometry = createGeometry(this);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import { defineComponent } from 'vue';
|
import { geometryComponent } from './Geometry.js';
|
||||||
import { SphereGeometry } from 'three';
|
import { SphereGeometry } from 'three';
|
||||||
import Geometry from './Geometry.js';
|
|
||||||
|
|
||||||
export const props = {
|
export const props = {
|
||||||
radius: { type: Number, default: 1 },
|
radius: { type: Number, default: 1 },
|
||||||
@ -12,12 +11,4 @@ export function createGeometry(comp) {
|
|||||||
return new SphereGeometry(comp.radius, comp.widthSegments, comp.heightSegments);
|
return new SphereGeometry(comp.radius, comp.widthSegments, comp.heightSegments);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default defineComponent({
|
export default geometryComponent('SphereGeometry', props, createGeometry);
|
||||||
extends: Geometry,
|
|
||||||
props,
|
|
||||||
methods: {
|
|
||||||
createGeometry() {
|
|
||||||
this.geometry = createGeometry(this);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import { defineComponent } from 'vue';
|
import { geometryComponent } from './Geometry.js';
|
||||||
import { TetrahedronGeometry } from 'three';
|
import { TetrahedronGeometry } from 'three';
|
||||||
import Geometry from './Geometry.js';
|
|
||||||
|
|
||||||
export const props = {
|
export const props = {
|
||||||
radius: { type: Number, default: 1 },
|
radius: { type: Number, default: 1 },
|
||||||
@ -11,12 +10,4 @@ export function createGeometry(comp) {
|
|||||||
return new TetrahedronGeometry(comp.radius, comp.detail);
|
return new TetrahedronGeometry(comp.radius, comp.detail);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default defineComponent({
|
export default geometryComponent('TetrahedronGeometry', props, createGeometry);
|
||||||
extends: Geometry,
|
|
||||||
props,
|
|
||||||
methods: {
|
|
||||||
createGeometry() {
|
|
||||||
this.geometry = createGeometry(this);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import { defineComponent } from 'vue';
|
import { geometryComponent } from './Geometry.js';
|
||||||
import { TorusGeometry } from 'three';
|
import { TorusGeometry } from 'three';
|
||||||
import Geometry from './Geometry.js';
|
|
||||||
|
|
||||||
export const props = {
|
export const props = {
|
||||||
radius: { type: Number, default: 1 },
|
radius: { type: Number, default: 1 },
|
||||||
@ -14,12 +13,4 @@ export function createGeometry(comp) {
|
|||||||
return new TorusGeometry(comp.radius, comp.tube, comp.radialSegments, comp.tubularSegments, comp.arc);
|
return new TorusGeometry(comp.radius, comp.tube, comp.radialSegments, comp.tubularSegments, comp.arc);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default defineComponent({
|
export default geometryComponent('TorusGeometry', props, createGeometry);
|
||||||
extends: Geometry,
|
|
||||||
props,
|
|
||||||
methods: {
|
|
||||||
createGeometry() {
|
|
||||||
this.geometry = createGeometry(this);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import { defineComponent } from 'vue';
|
import { geometryComponent } from './Geometry.js';
|
||||||
import { TorusKnotGeometry } from 'three';
|
import { TorusKnotGeometry } from 'three';
|
||||||
import Geometry from './Geometry.js';
|
|
||||||
|
|
||||||
export const props = {
|
export const props = {
|
||||||
radius: { type: Number, default: 1 },
|
radius: { type: Number, default: 1 },
|
||||||
@ -15,12 +14,4 @@ export function createGeometry(comp) {
|
|||||||
return new TorusKnotGeometry(comp.radius, comp.tube, comp.tubularSegments, comp.radialSegments, comp.p, comp.q);
|
return new TorusKnotGeometry(comp.radius, comp.tube, comp.tubularSegments, comp.radialSegments, comp.p, comp.q);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default defineComponent({
|
export default geometryComponent('TorusKnotGeometry', props, createGeometry);
|
||||||
extends: Geometry,
|
|
||||||
props,
|
|
||||||
methods: {
|
|
||||||
createGeometry() {
|
|
||||||
this.geometry = createGeometry(this);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
Loading…
Reference in New Issue
Block a user