createTextureAndSetAttrib: P.method(function(glTFTextureObject, stateSet, location, uniform) { if (!glTFTextureObject) return; var json = this._glTFJSON; var glTFTexture = json.textures[glTFTextureObject.index]; if (!glTFTexture) return; var image = json.images[glTFTexture.source]; if (!image) return; var texture = new Texture(); // GLTF texture origin is correct texture.setFlipY(false); texture.setWrapS('REPEAT'); texture.setWrapT('REPEAT'); this.loadFile(image.uri).then(function(data) { if (!data) return; texture.setImage(data, ReaderWriterGLTF.TEXTURE_FORMAT[glTFTexture.format]); stateSet.setTextureAttributeAndModes(location, texture); if (uniform) { stateSet.addUniform(Uniform.createInt(location, uniform)); } return; }); }),
_texture: function(gltfTexture) { var textures = this._gltfJSON.textures; var images = this._gltfJSON.images; var texture = textures[gltfTexture.index]; var image = images[texture.source]; if (texture.osgjsTexture) return texture.osgjsTexture; var osgjsTexture = new Texture(); texture.osgjsTexture = osgjsTexture; // GLTF texture origin is correct osgjsTexture.setFlipY(false); osgjsTexture.setWrapS('REPEAT'); osgjsTexture.setWrapT('REPEAT'); if (image.osgjsImage) { var format = ReaderWriterGLTF.TEXTURE_FORMAT[texture.format]; osgjsTexture.setImage(image.osgjsImage, format); } return osgjsTexture; },