<commit_before>package h3d.prim;

class ModelCache {

	var models : Map<String, hxd.fmt.hmd.Library>;
	var textures : Map<String, h3d.mat.Texture>;
	var anims : Map<String, h3d.anim.Animation>;

	public function new() {
		models = new Map();
		textures = new Map();
		anims = new Map();
	}

	public function dispose() {
		anims = new Map();
		models = new Map();
		for( t in textures )
			t.dispose();
		textures = new Map();
	}

	function loadLibrary( res : hxd.res.Model ) : hxd.fmt.hmd.Library {
		var path = res.entry.path;
		var lib = models.get(path);
		if( lib == null ) {
			lib = res.toHmd();
			models.set(path, lib);
		}
		return lib;
	}

	public function loadModel( res : hxd.res.Model ) : h3d.scene.Object {
		var obj = loadLibrary(res).makeObject(loadTexture.bind(res));
		for( m in obj.getMaterials() )
			initMaterial(res, Std.instance(m, h3d.mat.MeshMaterial));
		return obj;
	}

	public function loadTexture( model : hxd.res.Model, texturePath ) : h3d.mat.Texture {<commit_msg>set loadLibrary as public<commit_after>package h3d.prim;

class ModelCache {

	var models : Map<String, hxd.fmt.hmd.Library>;
	var textures : Map<String, h3d.mat.Texture>;
	var anims : Map<String, h3d.anim.Animation>;

	public function new() {
		models = new Map();
		textures = new Map();
		anims = new Map();
	}

	public function dispose() {
		anims = new Map();
		models = new Map();
		for( t in textures )
			t.dispose();
		textures = new Map();
	}

	public function loadLibrary( res : hxd.res.Model ) : hxd.fmt.hmd.Library {
		var path = res.entry.path;
		var lib = models.get(path);
		if( lib == null ) {
			lib = res.toHmd();
			models.set(path, lib);
		}
		return lib;
	}

	public function loadModel( res : hxd.res.Model ) : h3d.scene.Object {
		var obj = loadLibrary(res).makeObject(loadTexture.bind(res));
		for( m in obj.getMaterials() )
			initMaterial(res, Std.instance(m, h3d.mat.MeshMaterial));
		return obj;
	}

	public function loadTexture( model : hxd.res.Model, texturePath ) : h3d.mat.Texture {
{'fraction_non_alphanumeric': 0.1483325037332006, 'fraction_numerical': 0.005973120955699353, 'mean_word_length': 3.4966442953020134, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '5287480', 'n_tokens_mistral': 792, 'n_tokens_neox': 725, 'n_words': 184}