1
0
mirror of https://github.com/troisjs/trois.git synced 2024-11-23 20:02:32 +08:00

Models: add before-load event

This commit is contained in:
Georg Nagel 2021-11-26 11:20:29 +01:00
parent f109069d9f
commit 07064c32a3
3 changed files with 3 additions and 1 deletions

View File

@ -6,6 +6,7 @@ export default defineComponent({
extends: Model, extends: Model,
created() { created() {
const loader = new FBXLoader() const loader = new FBXLoader()
this.$emit('before-load', loader)
loader.load(this.src, (fbx) => { loader.load(this.src, (fbx) => {
this.onLoad(fbx) this.onLoad(fbx)
}, this.onProgress, this.onError) }, this.onProgress, this.onError)

View File

@ -6,6 +6,7 @@ export default defineComponent({
extends: Model, extends: Model,
created() { created() {
const loader = new GLTFLoader() const loader = new GLTFLoader()
this.$emit('before-load', loader)
loader.load(this.src, (gltf) => { loader.load(this.src, (gltf) => {
this.onLoad(gltf.scene) this.onLoad(gltf.scene)
}, this.onProgress, this.onError) }, this.onProgress, this.onError)

View File

@ -4,7 +4,7 @@ import Object3D from '../core/Object3D'
export default defineComponent({ export default defineComponent({
extends: Object3D, extends: Object3D,
emits: ['load', 'progress', 'error'], emits: ['load', 'progress', 'error', 'before-load'],
props: { props: {
src: { type: String, required: true }, src: { type: String, required: true },
}, },