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

created event for materials #93

This commit is contained in:
Kevin Levron 2021-10-27 21:25:23 +02:00
parent 72b56d123e
commit b7fe5a6a7b

View File

@ -19,6 +19,7 @@ export interface MaterialPublicInterface extends ComponentPublicInstance, Materi
export const MaterialInjectionKey: InjectionKey<MaterialPublicInterface> = Symbol('Material') export const MaterialInjectionKey: InjectionKey<MaterialPublicInterface> = Symbol('Material')
const BaseMaterial = defineComponent({ const BaseMaterial = defineComponent({
emits: ['created'],
props: { props: {
color: { type: String, default: '#ffffff' }, color: { type: String, default: '#ffffff' },
props: { type: Object as PropType<MaterialPropsInterface>, default: () => ({}) }, props: { type: Object as PropType<MaterialPropsInterface>, default: () => ({}) },
@ -45,6 +46,7 @@ const BaseMaterial = defineComponent({
// @ts-ignore // @ts-ignore
watch(() => this.color, (value) => { material.color.set(value) }) watch(() => this.color, (value) => { material.color.set(value) })
bindObjectProp(this, 'props', material, false, this.setProp) bindObjectProp(this, 'props', material, false, this.setProp)
this.$emit('created', material)
this.mesh.setMaterial(material) this.mesh.setMaterial(material)
} }
}, },