Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion examples/jsm/exporters/GLTFExporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand Down Expand Up @@ -1506,6 +1506,8 @@ class GLTFWriter {
wrapT: THREE_TO_WEBGL[ map.wrapT ]
};

this.serializeUserData( map, samplerDef );

return json.samplers.push( samplerDef ) - 1;

}
Expand Down
16 changes: 8 additions & 8 deletions examples/jsm/loaders/GLTFLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -3431,8 +3433,6 @@ class GLTFParser {

}

assignExtrasToUserData( texture, sourceDef );

texture.userData.mimeType = sourceDef.mimeType || getImageURIMimeType( sourceDef.uri );

return texture;
Expand Down