1
0
mirror of https://github.com/troisjs/trois.git synced 2024-11-24 20:32:02 +08:00
trois/src/core/Texture.js

29 lines
548 B
JavaScript
Raw Normal View History

2020-10-04 06:07:10 +08:00
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 [];
},
};