Commits

abrie  committed 4fd6847

lazy load assets

  • Participants
  • Parent commits 7bab5b4

Comments (0)

Files changed (2)

         }
     }
 
-    var warpHoleSpriteFiles =
+    var warpHoleSpriteIds =
     {
-        8: assets.sprites.starhole,
-        2: assets.sprites.pentagonhole,
+        8: "starhole",
+        2: "pentagonhole",
     }
     var createWarpHole = function(id,x,y) {
         var warpHole = bodies.createDoor(world, x,y, {
                 isWarpHole:true,
                 isOpen:false
             },
-            sprite:warpHoleSpriteFiles[id].generateAnimation(),
+            sprite:assets.sprites[warpHoleSpriteIds[id]].generateAnimation(),
         });
         queueSprite(3, warpHole.body.userData.sprite );
         warpHole.body.userData.sprite.gotoAndPlay("closed");
             return object;
         }
 
-        var meshA = generateDoor( 1, height/2, images.a );
-        var meshB = generateDoor( -1, height/2, images.b );
+        var meshA = generateDoor( 1, height/2, assets.textures[images.a].data );
+        var meshB = generateDoor( -1, height/2, assets.textures[images.b].data );
 
         var that = createBaseModel();
         that.model.add( meshA );
     };
 
     var pentagonImages = {
-        a: assets.textures.pentagon_a.data,
-        b: assets.textures.pentagon_b.data,
+        a: "pentagon_a",
+        b: "pentagon_b",
     }
 
     var starImages = {
-        a: assets.textures.star_a.data,
-        b: assets.textures.star_b.data,
-    }
-
-    var markImages = {
-        correct: assets.textures.correct.data,
-        incorrect: assets.textures.incorrect.data,
+        a: "star_a",
+        b: "star_b",
     }
 
     scene.add(createReticule());
 
     var marks = [];
     var addMark = function( position, correct ) {
-        var mark = createMarkModel(5, correct ? markImages.correct : markImages.incorrect );
+        var id = correct ? "correct" : "incorrect";
+        var texture = assets.textures[id].data;
+        var mark = createMarkModel(5, texture );
         mark.position.set( position.x, position.y, position.z );
         scene.add(mark);
         marks.push(mark);