mirror of
https://github.com/troisjs/trois.git
synced 2024-11-24 20:32:02 +08:00
29 lines
548 B
JavaScript
29 lines
548 B
JavaScript
|
import { TextureLoader } from 'three';
|
||
|
// import { watch } from 'vue';
|
||
|
|
||
|
export default {
|
||
|
inject: ['three'],
|
||
|
emits: ['loaded'],
|
||
|
props: {
|
||
|
src: String,
|
||
|
onLoad: Function,
|
||
|
onProgress: Function,
|
||
|
onError: Function,
|
||
|
},
|
||
|
created() {
|
||
|
this.texture = new TextureLoader().load(this.src, this.onLoaded, this.onProgress, this.onError);
|
||
|
},
|
||
|
unmounted() {
|
||
|
this.texture.dispose();
|
||
|
},
|
||
|
methods: {
|
||
|
onLoaded() {
|
||
|
if (this.onLoad) this.onLoad();
|
||
|
this.$emit('loaded');
|
||
|
},
|
||
|
},
|
||
|
render() {
|
||
|
return [];
|
||
|
},
|
||
|
};
|