From d0a78e80616d5500212d4ed9b6fa16d815bcb051 Mon Sep 17 00:00:00 2001 From: Kevin Levron Date: Thu, 29 Apr 2021 19:42:26 +0200 Subject: [PATCH] add texture encoding --- src/materials/Texture.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/materials/Texture.ts b/src/materials/Texture.ts index feaabea..9f16ecc 100644 --- a/src/materials/Texture.ts +++ b/src/materials/Texture.ts @@ -1,5 +1,5 @@ import { defineComponent, PropType, watch } from 'vue' -import { ClampToEdgeWrapping, LinearFilter, LinearMipmapLinearFilter, ShaderMaterial, Texture, TextureLoader, UVMapping } from 'three' +import { ClampToEdgeWrapping, LinearEncoding, LinearFilter, LinearMipmapLinearFilter, ShaderMaterial, Texture, TextureLoader, UVMapping } from 'three' import { bindProp } from '../tools' import { MaterialInjectionKey, MaterialInterface } from './Material' import { Vector2PropInterface } from '../core/Object3D' @@ -20,6 +20,7 @@ export default defineComponent({ onLoad: Function as PropType<(t: Texture) => void>, onProgress: Function as PropType<(e: ProgressEvent) => void>, onError: Function as PropType<(e: ErrorEvent) => void>, + encoding: { type: Number, default: LinearEncoding }, // format: { type: Number, default: RGBAFormat }, mapping: { type: Number, default: UVMapping }, wrapS: { type: Number, default: ClampToEdgeWrapping }, @@ -46,7 +47,7 @@ export default defineComponent({ if (!this.src) return undefined const texture = new TextureLoader().load(this.src, this.onLoaded, this.onProgress, this.onError) // use format ? TextureLoader will automatically set format to THREE.RGBFormat for JPG images. - const wathProps = ['mapping', 'wrapS', 'wrapT', 'magFilter', 'minFilter', 'repeat', 'rotation', 'center'] + const wathProps = ['encoding', 'mapping', 'wrapS', 'wrapT', 'magFilter', 'minFilter', 'repeat', 'rotation', 'center'] wathProps.forEach(prop => { bindProp(this, prop, texture) }) return texture },