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:
parent
f70bbaebef
commit
5562d5f496
@ -69,7 +69,7 @@ const Mesh = defineComponent({
|
|||||||
this.initObject3D(mesh)
|
this.initObject3D(mesh)
|
||||||
},
|
},
|
||||||
createGeometry() {},
|
createGeometry() {},
|
||||||
addGeometryWatchers(props: ComponentPropsOptions) {
|
addGeometryWatchers(props: Readonly<ComponentPropsOptions>) {
|
||||||
Object.keys(props).forEach(prop => {
|
Object.keys(props).forEach(prop => {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
watch(() => this[prop], () => {
|
watch(() => this[prop], () => {
|
||||||
@ -105,15 +105,16 @@ const Mesh = defineComponent({
|
|||||||
|
|
||||||
export default Mesh
|
export default Mesh
|
||||||
|
|
||||||
// @ts-ignore
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
||||||
export function meshComponent(name, props, createGeometry) {
|
export function meshComponent<P extends Readonly<ComponentPropsOptions>>(
|
||||||
|
name: string,
|
||||||
|
props: P,
|
||||||
|
createGeometry: {(c: any): BufferGeometry}
|
||||||
|
) {
|
||||||
return defineComponent({
|
return defineComponent({
|
||||||
name,
|
name,
|
||||||
extends: Mesh,
|
extends: Mesh,
|
||||||
props,
|
props,
|
||||||
setup(): MeshSetupInterface {
|
|
||||||
return {}
|
|
||||||
},
|
|
||||||
created() {
|
created() {
|
||||||
this.createGeometry()
|
this.createGeometry()
|
||||||
this.addGeometryWatchers(props)
|
this.addGeometryWatchers(props)
|
||||||
@ -123,6 +124,5 @@ export function meshComponent(name, props, createGeometry) {
|
|||||||
this.geometry = createGeometry(this)
|
this.geometry = createGeometry(this)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
// __hmrId: name,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user