Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with getting resource in AssetLibrary #38

Closed
volzh opened this issue Aug 8, 2011 · 1 comment
Closed

Problem with getting resource in AssetLibrary #38

volzh opened this issue Aug 8, 2011 · 1 comment

Comments

@volzh
Copy link

volzh commented Aug 8, 2011

this is related a litte bit with issue #37.

I want to load external resource by using AssetLibrary.load before application initializing.
So, I made some kind of preload class.
Here is a problem.
After loading multiple 3d resources, I tried to find assets by AssetLibrary.getAsset().

AssetLibrary.load() doesn't have any 'name' parameter.
So, what i do is make instance of Loader3D and assign 'name',
and put it into AssetLibrary by addAsset().
Atfer that, in some other class, I try to found resource by getAsset('name').

Is there any good example for indexing resources that are already loaded in AssetLibrary?

Thanks in advance.

@richardolsson
Copy link
Member

I'll answer this question, but please don't use the issue tracker as a support channel. Questions like these can be asked in the Away3D forum instead, at away3d.com/forum.

When you load something, that something is called a "resource" (i.e. a master file and any other file dependencies.) One resource may contain many assets. For instance, an OBJ resource (which is two files, file.obj and file.mtl) can contain for example four assets, mesh1, mesh2, material1, material2.

The AssetLibrary doesn't care about resources, it cares about assets. Actually, you shouldn't be caring about resources either, because where the assets came from is rarely (if ever) relevant in your application logic.

So if you load a resource with AssetLibrary, the way to then retrieve a single asset from that resource is using that asset's name. The name is taken from within the file, which probably means that it was chosen by your artist.

If you really want to "tag" all the assets in a resource as you load them, load them into a separate namespace using the AssetLibrary.load() fourth parameter. You can then retrieve all the assets from that namespace using the AssetLibrary.createIterator() method.

If you need to further discuss this or have any further questions, please start a thread in the forums and refer to this issue with a link.

Cheers!
/R

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants