repo: janusweb
action: commit
revision: 
path_from: 
revision_from: 65f831306a51e25338b8610c921092baf5e64334:
path_to: 
revision_to: 
git.thebackupbox.net
janusweb
git clone git://git.thebackupbox.net/janusweb
commit 65f831306a51e25338b8610c921092baf5e64334
Author: James Baicoianu 
Date:   Tue Oct 31 05:05:04 2017 -0700

    Asset autocreation

diff --git a/scripts/janusbase.js b/scripts/janusbase.js
index ba636f7d4b11bc515845b8b31907f4e3c1830410..
index ..8bd88d678e56eb7a0b6e05cad7ca2247f4fadd69 100644
--- a/scripts/janusbase.js
+++ b/scripts/janusbase.js
@@ -346,22 +346,28 @@ elation.require(['engine.things.generic', 'utils.template'], function() {
       }
       return childproxies;
     }
-    this.getAsset = function(type, id, nocache) {
+    this.getAsset = function(type, id, autocreate) {
       var parent = this.parent || this.room;

       var asset;
       if (this.assetpack) {
         asset = this.assetpack.get(type, id);
       }
-      if (!asset) {
+      if (!asset && typeof parent.getAsset == 'function') {
         asset = parent.getAsset(type, id);
       }
-      if (asset && !nocache) {
-        if (!this.assets[type]) {
-          this.assets[type] = {};
-        }
-        this.assets[type][id] = asset;
+      if (!asset && autocreate) {
+        // Asset definition wasn't found, so we'll assume it's a URL and define a new asset
+        this.room.loadNewAsset(type, {id: id, src: id}, false);
+        asset = this.room.getAsset(type, id);
+      }
+
+      // Store a reference so we know which assets are in use by which objects
+      if (!this.assets[type]) {
+        this.assets[type] = {};
       }
+      this.assets[type][id] = asset;
+
       return asset;
     }
     this.getActiveAssets = function(assetlist) {

-----END OF PAGE-----