Cache.hx 734 B

12345678910111213141516171819202122232425262728293031323334
  1. package hrt.prefab;
  2. typedef ShaderDef = {
  3. var shader : hxsl.SharedShader;
  4. var inits : Array<{ variable : hxsl.Ast.TVar, value : Dynamic }>;
  5. }
  6. typedef ShaderDefCache = Map<String, ShaderDef>;
  7. class Cache {
  8. static var inst : Cache;
  9. // Override this with your own cache objets
  10. public static dynamic function init() : Cache {
  11. var c = new Cache();
  12. c.modelCache = new h3d.prim.ModelCache();
  13. c.shaderDefCache = new ShaderDefCache();
  14. return c;
  15. }
  16. public function new() {
  17. }
  18. public static function get() : Cache {
  19. if (inst == null)
  20. inst = Cache.init();
  21. return inst;
  22. }
  23. public var modelCache : h3d.prim.ModelCache = new h3d.prim.ModelCache();
  24. public var shaderDefCache : ShaderDefCache = new ShaderDefCache();
  25. }