mirror of
https://github.com/troisjs/trois.git
synced 2024-11-23 20:02:32 +08:00
improve geometries ts
This commit is contained in:
parent
0a8f1ee88f
commit
f70bbaebef
@ -9,7 +9,7 @@ export const props = {
|
||||
widthSegments: { type: Number, default: 1 },
|
||||
heightSegments: { type: Number, default: 1 },
|
||||
depthSegments: { type: Number, default: 1 },
|
||||
}
|
||||
} as const
|
||||
|
||||
export function createGeometry(comp: any): BoxGeometry {
|
||||
if (comp.size) {
|
||||
|
@ -6,7 +6,7 @@ export const props = {
|
||||
segments: { type: Number, default: 8 },
|
||||
thetaStart: { type: Number, default: 0 },
|
||||
thetaLength: { type: Number, default: Math.PI * 2 },
|
||||
}
|
||||
} as const
|
||||
|
||||
export function createGeometry(comp: any): CircleGeometry {
|
||||
return new CircleGeometry(comp.radius, comp.segments, comp.thetaStart, comp.thetaLength)
|
||||
|
@ -9,7 +9,7 @@ export const props = {
|
||||
openEnded: { type: Boolean, default: false },
|
||||
thetaStart: { type: Number, default: 0 },
|
||||
thetaLength: { type: Number, default: Math.PI * 2 },
|
||||
}
|
||||
} as const
|
||||
|
||||
export function createGeometry(comp: any): ConeGeometry {
|
||||
return new ConeGeometry(comp.radius, comp.height, comp.radialSegments, comp.heightSegments, comp.openEnded, comp.thetaStart, comp.thetaLength)
|
||||
|
@ -10,7 +10,7 @@ export const props = {
|
||||
openEnded: { type: Boolean, default: false },
|
||||
thetaStart: { type: Number, default: 0 },
|
||||
thetaLength: { type: Number, default: Math.PI * 2 },
|
||||
}
|
||||
} as const
|
||||
|
||||
export function createGeometry(comp: any): CylinderGeometry {
|
||||
return new CylinderGeometry(comp.radiusTop, comp.radiusBottom, comp.height, comp.radialSegments, comp.heightSegments, comp.openEnded, comp.thetaStart, comp.thetaLength)
|
||||
|
@ -4,7 +4,7 @@ import { DodecahedronGeometry } from 'three'
|
||||
export const props = {
|
||||
radius: { type: Number, default: 1 },
|
||||
detail: { type: Number, default: 0 },
|
||||
}
|
||||
} as const
|
||||
|
||||
export function createGeometry(comp: any): DodecahedronGeometry {
|
||||
return new DodecahedronGeometry(comp.radius, comp.detail)
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { ComponentPropsOptions, defineComponent, watch } from 'vue'
|
||||
import { BufferGeometry } from 'three'
|
||||
import { defineComponent, inject, watch } from 'vue'
|
||||
import { MeshInjectionKey, MeshInterface } from '../meshes/Mesh'
|
||||
|
||||
export interface GeometrySetupInterface {
|
||||
@ -66,20 +66,20 @@ const Geometry = defineComponent({
|
||||
|
||||
export default Geometry
|
||||
|
||||
// @ts-ignore
|
||||
export function geometryComponent(name, props, createGeometry) {
|
||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
||||
export function geometryComponent<P extends Readonly<ComponentPropsOptions>>(
|
||||
name: string,
|
||||
props: P,
|
||||
createGeometry: {(c: any): BufferGeometry}
|
||||
) {
|
||||
return defineComponent({
|
||||
name,
|
||||
extends: Geometry,
|
||||
props,
|
||||
setup(): GeometrySetupInterface {
|
||||
return {}
|
||||
},
|
||||
methods: {
|
||||
createGeometry() {
|
||||
this.geometry = createGeometry(this)
|
||||
},
|
||||
},
|
||||
// __hmrId: name,
|
||||
})
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ import { IcosahedronGeometry } from 'three'
|
||||
export const props = {
|
||||
radius: { type: Number, default: 1 },
|
||||
detail: { type: Number, default: 0 },
|
||||
}
|
||||
} as const
|
||||
|
||||
export function createGeometry(comp: any): IcosahedronGeometry {
|
||||
return new IcosahedronGeometry(comp.radius, comp.detail)
|
||||
|
@ -6,7 +6,7 @@ export const props = {
|
||||
segments: { type: Number, default: 12 },
|
||||
phiStart: { type: Number, default: 0 },
|
||||
phiLength: { type: Number, default: Math.PI * 2 },
|
||||
}
|
||||
} as const
|
||||
|
||||
export function createGeometry(comp: any): LatheGeometry {
|
||||
return new LatheGeometry(comp.points, comp.segments, comp.phiStart, comp.phiLength)
|
||||
|
@ -4,7 +4,7 @@ import { OctahedronGeometry } from 'three'
|
||||
export const props = {
|
||||
radius: { type: Number, default: 1 },
|
||||
detail: { type: Number, default: 0 },
|
||||
}
|
||||
} as const
|
||||
|
||||
export function createGeometry(comp: any): OctahedronGeometry {
|
||||
return new OctahedronGeometry(comp.radius, comp.detail)
|
||||
|
@ -6,7 +6,7 @@ export const props = {
|
||||
height: { type: Number, default: 1 },
|
||||
widthSegments: { type: Number, default: 1 },
|
||||
heightSegments: { type: Number, default: 1 },
|
||||
}
|
||||
} as const
|
||||
|
||||
export function createGeometry(comp: any): PlaneGeometry {
|
||||
return new PlaneGeometry(comp.width, comp.height, comp.widthSegments, comp.heightSegments)
|
||||
|
@ -6,7 +6,7 @@ export const props = {
|
||||
indices: Array,
|
||||
radius: { type: Number, default: 1 },
|
||||
detail: { type: Number, default: 0 },
|
||||
}
|
||||
} as const
|
||||
|
||||
export function createGeometry(comp: any): PolyhedronGeometry {
|
||||
return new PolyhedronGeometry(comp.vertices, comp.indices, comp.radius, comp.detail)
|
||||
|
@ -8,7 +8,7 @@ export const props = {
|
||||
phiSegments: { type: Number, default: 1 },
|
||||
thetaStart: { type: Number, default: 0 },
|
||||
thetaLength: { type: Number, default: Math.PI * 2 },
|
||||
}
|
||||
} as const
|
||||
|
||||
export function createGeometry(comp: any): RingGeometry {
|
||||
return new RingGeometry(comp.innerRadius, comp.outerRadius, comp.thetaSegments, comp.phiSegments, comp.thetaStart, comp.thetaLength)
|
||||
|
@ -5,7 +5,7 @@ export const props = {
|
||||
radius: { type: Number, default: 1 },
|
||||
widthSegments: { type: Number, default: 12 },
|
||||
heightSegments: { type: Number, default: 12 },
|
||||
}
|
||||
} as const
|
||||
|
||||
export function createGeometry(comp: any): SphereGeometry {
|
||||
return new SphereGeometry(comp.radius, comp.widthSegments, comp.heightSegments)
|
||||
|
@ -4,7 +4,7 @@ import { TetrahedronGeometry } from 'three'
|
||||
export const props = {
|
||||
radius: { type: Number, default: 1 },
|
||||
detail: { type: Number, default: 0 },
|
||||
}
|
||||
} as const
|
||||
|
||||
export function createGeometry(comp: any): TetrahedronGeometry {
|
||||
return new TetrahedronGeometry(comp.radius, comp.detail)
|
||||
|
@ -7,7 +7,7 @@ export const props = {
|
||||
radialSegments: { type: Number, default: 8 },
|
||||
tubularSegments: { type: Number, default: 6 },
|
||||
arc: { type: Number, default: Math.PI * 2 },
|
||||
}
|
||||
} as const
|
||||
|
||||
export function createGeometry(comp: any): TorusGeometry {
|
||||
return new TorusGeometry(comp.radius, comp.tube, comp.radialSegments, comp.tubularSegments, comp.arc)
|
||||
|
@ -8,7 +8,7 @@ export const props = {
|
||||
radialSegments: { type: Number, default: 8 },
|
||||
p: { type: Number, default: 2 },
|
||||
q: { type: Number, default: 3 },
|
||||
}
|
||||
} as const
|
||||
|
||||
export function createGeometry(comp: any): TorusKnotGeometry {
|
||||
return new TorusKnotGeometry(comp.radius, comp.tube, comp.tubularSegments, comp.radialSegments, comp.p, comp.q)
|
||||
|
@ -9,7 +9,7 @@ export const props = {
|
||||
radius: { type: Number, default: 1 },
|
||||
radialSegments: { type: Number, default: 8 },
|
||||
closed: { type: Boolean, default: false },
|
||||
}
|
||||
} as const
|
||||
|
||||
export function createGeometry(comp: any): TubeGeometry {
|
||||
let curve
|
||||
|
Loading…
Reference in New Issue
Block a user