Browse Source

[cache] Live reload Anim Props

Clément Espeute 7 months ago
parent
commit
48735e6262
1 changed files with 7 additions and 1 deletions
  1. 7 1
      h3d/prim/ModelCache.hx

+ 7 - 1
h3d/prim/ModelCache.hx

@@ -38,7 +38,13 @@ class ModelCache {
 				var parts = path.split(".");
 				parts.pop();
 				parts.push("props");
-				haxe.Json.parse(hxd.res.Loader.currentInstance.load(parts.join(".")).toText());
+				var propsRes = hxd.res.Loader.currentInstance.load(parts.join("."));
+				propsRes.watch(() -> {
+					// Clear this anim cache so the anim and it's props are reloaded the next time they are requested
+					models.remove(path);
+					anims.remove(path);
+				});
+				haxe.Json.parse(propsRes.toText());
 			} catch( e : hxd.res.NotFound )
 				null;
 			m = { lib : res.toHmd(), props : props, col : null, lastTime : 0. };