diff --git a/examples/jsm/exporters/GLTFExporter.js b/examples/jsm/exporters/GLTFExporter.js index 2da060f940b591..15b0bdb5f3a90c 100644 --- a/examples/jsm/exporters/GLTFExporter.js +++ b/examples/jsm/exporters/GLTFExporter.js @@ -761,7 +761,7 @@ class GLTFWriter { /** * Serializes a userData. * - * @param {THREE.Object3D|THREE.Material|THREE.BufferGeometry|THREE.AnimationClip} object + * @param {THREE.Object3D|THREE.Material|THREE.BufferGeometry|THREE.AnimationClip|THREE.Texture} object * @param {Object} objectDef */ serializeUserData( object, objectDef ) { @@ -1506,6 +1506,8 @@ class GLTFWriter { wrapT: THREE_TO_WEBGL[ map.wrapT ] }; + this.serializeUserData( map, samplerDef ); + return json.samplers.push( samplerDef ) - 1; } diff --git a/examples/jsm/loaders/GLTFLoader.js b/examples/jsm/loaders/GLTFLoader.js index 38f8c14fb50063..8af2c8b208ccc3 100644 --- a/examples/jsm/loaders/GLTFLoader.js +++ b/examples/jsm/loaders/GLTFLoader.js @@ -2376,7 +2376,7 @@ function addUnknownExtensionsToUserData( knownExtensions, object, objectDef ) { /** * * @private - * @param {Object3D|Material|BufferGeometry|Object|AnimationClip} object + * @param {Object3D|Material|BufferGeometry|Object|AnimationClip|Texture} object * @param {GLTF.definition} gltfDef */ function assignExtrasToUserData( object, gltfDef ) { @@ -3336,14 +3336,16 @@ class GLTFParser { } const samplers = json.samplers || {}; - const sampler = samplers[ textureDef.sampler ] || {}; + const samplerDef = samplers[ textureDef.sampler ] || {}; - texture.magFilter = WEBGL_FILTERS[ sampler.magFilter ] || LinearFilter; - texture.minFilter = WEBGL_FILTERS[ sampler.minFilter ] || LinearMipmapLinearFilter; - texture.wrapS = WEBGL_WRAPPINGS[ sampler.wrapS ] || RepeatWrapping; - texture.wrapT = WEBGL_WRAPPINGS[ sampler.wrapT ] || RepeatWrapping; + texture.magFilter = WEBGL_FILTERS[ samplerDef.magFilter ] || LinearFilter; + texture.minFilter = WEBGL_FILTERS[ samplerDef.minFilter ] || LinearMipmapLinearFilter; + texture.wrapS = WEBGL_WRAPPINGS[ samplerDef.wrapS ] || RepeatWrapping; + texture.wrapT = WEBGL_WRAPPINGS[ samplerDef.wrapT ] || RepeatWrapping; texture.generateMipmaps = ! texture.isCompressedTexture && texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter; + assignExtrasToUserData( texture, samplerDef ); + parser.associations.set( texture, { textures: textureIndex } ); return texture; @@ -3431,8 +3433,6 @@ class GLTFParser { } - assignExtrasToUserData( texture, sourceDef ); - texture.userData.mimeType = sourceDef.mimeType || getImageURIMimeType( sourceDef.uri ); return texture;