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

improve meshes ts

This commit is contained in:
Kevin Levron 2021-04-26 18:36:57 +02:00
parent f70bbaebef
commit 5562d5f496

View File

@ -69,7 +69,7 @@ const Mesh = defineComponent({
this.initObject3D(mesh)
},
createGeometry() {},
addGeometryWatchers(props: ComponentPropsOptions) {
addGeometryWatchers(props: Readonly<ComponentPropsOptions>) {
Object.keys(props).forEach(prop => {
// @ts-ignore
watch(() => this[prop], () => {
@ -105,15 +105,16 @@ const Mesh = defineComponent({
export default Mesh
// @ts-ignore
export function meshComponent(name, props, createGeometry) {
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export function meshComponent<P extends Readonly<ComponentPropsOptions>>(
name: string,
props: P,
createGeometry: {(c: any): BufferGeometry}
) {
return defineComponent({
name,
extends: Mesh,
props,
setup(): MeshSetupInterface {
return {}
},
created() {
this.createGeometry()
this.addGeometryWatchers(props)
@ -123,6 +124,5 @@ export function meshComponent(name, props, createGeometry) {
this.geometry = createGeometry(this)
},
},
// __hmrId: name,
})
}