diff --git a/src/materials/Texture.js b/src/materials/Texture.js index e83e552..9dd0ff3 100644 --- a/src/materials/Texture.js +++ b/src/materials/Texture.js @@ -1,15 +1,24 @@ -import { TextureLoader } from 'three'; +import { ClampToEdgeWrapping, LinearFilter, LinearMipmapLinearFilter, TextureLoader, UVMapping } from 'three'; import { watch } from 'vue'; +import { bindProp } from '../tools.js'; export default { inject: ['material'], emits: ['loaded'], props: { + id: { type: String, default: 'map' }, src: String, onLoad: Function, onProgress: Function, onError: Function, - id: { type: String, default: 'map' }, + mapping: { type: Number, default: UVMapping }, + wrapS: { type: Number, default: ClampToEdgeWrapping }, + wrapT: { type: Number, default: ClampToEdgeWrapping }, + magFilter: { type: Number, default: LinearFilter }, + minFilter: { type: Number, default: LinearMipmapLinearFilter }, + repeat: { type: Object, default: { x: 1, y: 1 } }, + rotation: { type: Number, default: 0 }, + center: { type: Object, default: { x: 0, y: 0 } }, }, created() { this.refreshTexture(); @@ -22,6 +31,10 @@ export default { methods: { createTexture() { this.texture = new TextureLoader().load(this.src, this.onLoaded, this.onProgress, this.onError); + const wathProps = ['mapping', 'wrapS', 'wrapT', 'magFilter', 'minFilter', 'repeat', 'rotation', 'rotation', 'center']; + wathProps.forEach(prop => { + bindProp(this, prop, this.texture); + }); }, refreshTexture() { this.createTexture();