1.0.0 • Published 8 years ago

aframe-asset-lazy-load v1.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
8 years ago

NOTE: this project is not mine. I just published it to npm because I was needing it. I would gladly pass the ownership to the real maintainer.

There is an open issue for this, if you are the owner you can mention me there: https://github.com/youmustfight/aframe-asset-lazy-load/issues/8

aframe-asset-lazy-load-component

An a-entity component to assign asset loading order and delays

Usage

Install (or directly include the browser files).

npm install --save aframe-asset-lazy-load

Register

require('aframe');
var layout = require('aframe-layout').Component;
AFRAME.registerComponent('layout', layout);

Use with delays or chunks.

  <a-entity
    lazy-load="delay: 1000; src:../background.png; id: sphere1"
    geometry="primitive: sphere;
              radius: 200;"
    ></a-entity>
  <a-entity
    lazy-load="chunk: 0; src:../background2.png; id: sphere2"
    geometry="primitive: sphere;
              radius: 300;"
    ></a-entity>
  <a-entity
    lazy-load="chunk: 1; src:../background3.png; id: sphere3"
    geometry="primitive: sphere;
              radius: 100;"
    ></a-entity>
  <a-entity
    lazy-load="chunk: 1; id: sphere3"
    geometry="primitive: sphere;
              radius: 400;"
    ></a-entity>

Chunking is simply a way to block asset loading. For example, Let's say you have a game with a cinematic opening. Currently, you have to load all your assets at the start, meaning textures for the game are taking up bandwith you might want to use to get a user in the door. With chunking, you can set what is to be loaded immediately, via chunk 1, and what is to then be loaded upon those being completed, via chunk 2. This lets you spread out asset loading to make the immediate experience smoother.

Attributes

AttributeDescriptionDefault Value
delayMilliseconds waited until an image is appened to a-assets.0
chunkSlot an asset is placed in for loading. Multiple assets can be assigned to the same chunk. Over-rides delays
srcPath to the image being loaded
idThe ID being associated with the entity's material property and element in a-assets.