<commit_before>"use strict";
var _textures = [];

var _resizeCanvas = document.createElement("canvas");
_resizeCanvas.style.display = "none";
document.body.appendChild(_resizeCanvas);
var _resizeCtx = _resizeCanvas.getContext("2d");

function _resize(img, ratio) {
	_resizeCanvas.width = (img.width * ratio)|0;
	_resizeCanvas.height = (img.height * ratio)|0;
	_resizeCanvas.style.width = _resizeCanvas.width + "px";
	_resizeCanvas.style.height = _resizeCanvas.height + "px";
	_resizeCtx.drawImage(img, 0, 0, _resizeCanvas.width, _resizeCanvas.height);
	img.sized = true;
	img.src = _resizeCanvas.toDataURL("image/png");
};

function loadTexture(path, opts) {
	opts = opts || {};
	var image = new Image();
	image.sized = true;
	image.onload = function() {
		if (!image.sized) _resize(image, 0.0625);
		else texture.needsUpdate = true;
	};
	image.src = path;
	var texture = new THREE.Texture(
		image,
		new THREE.UVMapping(),
		THREE.RepeatWrapping,
		THREE.RepeatWrapping,
		CONFIG.linearTextureFilter ? THREE.LinearFilter : THREE.NearestFilter,
		CONFIG.linearTextureFilter ? THREE.LinearMipMapLinearFilter : THREE.NearestFilter,
		opts.alpha ? THREE.RGBAFormat : THREE.RGBFormat,
		THREE.UnsignedByteType,
		CONFIG.anisotropy
	);
	_textures.push(texture);
	return texture;
}


function updateTextures() {
	for (var i = 0; i < _textures.length; ++i) {
		_textures[i].magFilter = CONFIG.linearTextureFilter ? THREE.LinearFilter : THREE.NearestFilter;
		_textures[i].minFilter = CONFIG.linearTextureFilter ? THREE.LinearMipMapLinearFilter : THREE.NearestFilter;
		_textures[i].anisotropy = CONFIG.anisotropy;
		_textures[i].needsUpdate = true;
	}
	updateConfig();
}


function fixAnisotropy(mat, value) {
	if (!mat) return;
	value = value || CONFIG.anisotropy;

	function fixAnisotropyTex(tex) {
		if (!tex) return;
		tex.anisotropy = value;
		tex.needsUpdate = true;
	}

	if (mat instanceof THREE.ShaderMaterial) {
		fixAnisotropyTex(mat.uniforms.tDiffuse.value);
		fixAnisotropyTex(mat.uniforms.tNormal.value);
		fixAnisotropyTex(mat.uniforms.tSpecular.value);
		fixAnisotropyTex(mat.uniforms.tAO.value);
		fixAnisotropyTex(mat.uniforms.tCube.value);
		fixAnisotropyTex(mat.uniforms.tDisplacement.value);
	} else {
		fixAnisotropyTex(mat.map);
		fixAnisotropyTex(mat.normalMap);
		fixAnisotropyTex(mat.specularMap);
		fixAnisotropyTex(mat.lightMap);
	}
}


function updateMaterials() {
	for (var i in cache.materials) {
		if (!cache.materials.hasOwnProperty(i)) continue;
		cache.materials[i].needsUpdate = true;
		// Also affected: shadows, soft shadows, physical shading
	}
	updateConfig();
}


function createMaterial(name) {
	var texture_path = "assets/textures/";
	if (CONFIG.textureQuality === 0) texture_path = "assets/textures-256/";
	else if (CONFIG.textureQuality == 1) texture_path = "assets/textures-512/";
	var ambient = 0xaaaaaa, diffuse = 0xaaaaaa, specular = 0xffffff, shininess = 30, scale = 1.0;
	/*var shader = THREE.ShaderUtils.lib["normal"];
	var uniforms = THREE.UniformsUtils.clone(shader.uniforms);

	uniforms["tDiffuse"].value = loadTexture(texture_path + name + ".jpg");
	uniforms["tSpecular"].value = loadTexture(texture_path + "specular/" + name + ".jpg");
	uniforms["tNormal"].value = loadTexture(texture_path + "normal/"  + name + ".jpg");
	uniforms["uShininess"].value = shininess;
	//uniforms["uNormalScale"].value = new THREE.Vector2(1, 1);

	//uniforms["tDisplacement"].texture = loadTexture(texture_path + "height/"  + name + ".jpg");
	//uniforms["uDisplacementBias"].value = - 0.428408 * scale;
	//uniforms["uDisplacementScale"].value = 2.436143 * scale;

	uniforms["enableAO"].value = false;
	uniforms["enableDiffuse"].value = true;
	uniforms["enableSpecular"].value = true;
	uniforms["enableReflection"].value = false;
	uniforms["enableDisplacement"].value = false;<commit_msg>Cover model materials in updateMaterials().<commit_after>"use strict";
var _textures = [];

var _resizeCanvas = document.createElement("canvas");
_resizeCanvas.style.display = "none";
document.body.appendChild(_resizeCanvas);
var _resizeCtx = _resizeCanvas.getContext("2d");

function _resize(img, ratio) {
	_resizeCanvas.width = (img.width * ratio)|0;
	_resizeCanvas.height = (img.height * ratio)|0;
	_resizeCanvas.style.width = _resizeCanvas.width + "px";
	_resizeCanvas.style.height = _resizeCanvas.height + "px";
	_resizeCtx.drawImage(img, 0, 0, _resizeCanvas.width, _resizeCanvas.height);
	img.sized = true;
	img.src = _resizeCanvas.toDataURL("image/png");
};

function loadTexture(path, opts) {
	opts = opts || {};
	var image = new Image();
	image.sized = true;
	image.onload = function() {
		if (!image.sized) _resize(image, 0.0625);
		else texture.needsUpdate = true;
	};
	image.src = path;
	var texture = new THREE.Texture(
		image,
		new THREE.UVMapping(),
		THREE.RepeatWrapping,
		THREE.RepeatWrapping,
		CONFIG.linearTextureFilter ? THREE.LinearFilter : THREE.NearestFilter,
		CONFIG.linearTextureFilter ? THREE.LinearMipMapLinearFilter : THREE.NearestFilter,
		opts.alpha ? THREE.RGBAFormat : THREE.RGBFormat,
		THREE.UnsignedByteType,
		CONFIG.anisotropy
	);
	_textures.push(texture);
	return texture;
}


function updateTextures() {
	for (var i = 0; i < _textures.length; ++i) {
		_textures[i].magFilter = CONFIG.linearTextureFilter ? THREE.LinearFilter : THREE.NearestFilter;
		_textures[i].minFilter = CONFIG.linearTextureFilter ? THREE.LinearMipMapLinearFilter : THREE.NearestFilter;
		_textures[i].anisotropy = CONFIG.anisotropy;
		_textures[i].needsUpdate = true;
	}
	updateConfig();
}


function fixAnisotropy(mat, value) {
	if (!mat) return;
	value = value || CONFIG.anisotropy;

	function fixAnisotropyTex(tex) {
		if (!tex) return;
		tex.anisotropy = value;
		tex.needsUpdate = true;
	}

	if (mat instanceof THREE.ShaderMaterial) {
		fixAnisotropyTex(mat.uniforms.tDiffuse.value);
		fixAnisotropyTex(mat.uniforms.tNormal.value);
		fixAnisotropyTex(mat.uniforms.tSpecular.value);
		fixAnisotropyTex(mat.uniforms.tAO.value);
		fixAnisotropyTex(mat.uniforms.tCube.value);
		fixAnisotropyTex(mat.uniforms.tDisplacement.value);
	} else {
		fixAnisotropyTex(mat.map);
		fixAnisotropyTex(mat.normalMap);
		fixAnisotropyTex(mat.specularMap);
		fixAnisotropyTex(mat.lightMap);
	}
}


function updateMaterials() {
	var m;
	for (m in cache.materials) {
		if (!cache.materials.hasOwnProperty(m)) continue;
		cache.materials[m].needsUpdate = true;
	}
	for (m in cache.modelMaterials) {
		var mm = cache.modelMaterials[m];
		for (var i = 0; i < mm.length; ++i)
			mm[i].needsUpdate = true;
	}
	updateConfig();
}


function createMaterial(name) {
	var texture_path = "assets/textures/";
	if (CONFIG.textureQuality === 0) texture_path = "assets/textures-256/";
	else if (CONFIG.textureQuality == 1) texture_path = "assets/textures-512/";
	var ambient = 0xaaaaaa, diffuse = 0xaaaaaa, specular = 0xffffff, shininess = 30, scale = 1.0;
	/*var shader = THREE.ShaderUtils.lib["normal"];
	var uniforms = THREE.UniformsUtils.clone(shader.uniforms);

	uniforms["tDiffuse"].value = loadTexture(texture_path + name + ".jpg");
	uniforms["tSpecular"].value = loadTexture(texture_path + "specular/" + name + ".jpg");
	uniforms["tNormal"].value = loadTexture(texture_path + "normal/"  + name + ".jpg");
	uniforms["uShininess"].value = shininess;
	//uniforms["uNormalScale"].value = new THREE.Vector2(1, 1);

	//uniforms["tDisplacement"].texture = loadTexture(texture_path + "height/"  + name + ".jpg");
	//uniforms["uDisplacementBias"].value = - 0.428408 * scale;
	//uniforms["uDisplacementScale"].value = 2.436143 * scale;

	uniforms["enableAO"].value = false;
	uniforms["enableDiffuse"].value = true;
	uniforms["enableSpecular"].value = true;
	uniforms["enableReflection"].value = false;
	uniforms["enableDisplacement"].value = false;
{'fraction_non_alphanumeric': 0.14547566800051634, 'fraction_numerical': 0.011230153607848199, 'mean_word_length': 5.223293172690763, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1395633', 'n_tokens_mistral': 2860, 'n_tokens_neox': 2627, 'n_words': 475}