|
oladitan, Member
Posted: 22 July 2012 05:53 PM Total Posts: 71
hello I am working on the CharacterDemo example for Away3dPhysics. the scene loads using a loader and url. I am trying to embed the scene. I changed the LoaderEvent to an AssetEvent and modified the funtion
var container : ObjectContainer3D = event.target ObjectContainer3D;
when i try this i get two erros so far.
the first is solved by placing “scene.mtl” into the “bin” folder.
then i get another error:
exception, information=Error: Parameter child cannot be null.
pointing to this line:
_view.scene.addChild(container);
changing all the code back to regular then using loadData instead worked, but I still needed to place “scene.mtl” in the “bin” folder or modify the obj file and comment out the refference to “scene.mtl”.
my question is how do i properly embed scene.obj using the AssetLibrary.loadData? thank you.
|
Richard Olsson, Administrator
Posted: 23 July 2012 08:38 AM Total Posts: 1192
[ # 1 ]
As far as loading embedded files with dependencies is concerned, read the following thread as well as most of the examples in the away3d-examples-fp11 repository: http://away3d.com/forum/viewthread/2665/
Whether a resource is loaded from embedded files, external files, or a combination of both embedded and external files, does not in any way change the way you should handle events or work with the assets that get loaded. So although I’m not entirely sure what you are referring to with your changes, you should probably undo all of them and only change the load() method for loadData(), with the possible addition of using a AssetLoaderContext to map dependency URLs to embedded data.
The LoaderEvent class contains events that relate to the loading of resources, regardless of whether they’re loaded from external files or embedded data.
The AssetEvent class contains events that are dispatched when assets (e.g. meshes, geometries, texture, materials) are found within resources.
These two event types are not mutually exclusive. In most cases, you’ll be listening for both categories of events on your loaders.
|
oladitan, Member
Posted: 24 July 2012 12:04 AM Total Posts: 71
[ # 2 ]
Thank you for the response Richard.
switching “_loader.load()” to “loader.loadData()” works, but when i try to switch “_loader.load()” to “AssetLibrary.loadData()” (as well as embdding the resources and changing the event lister function to an AssetEvent) i still get the error :
exception, information=Error: Parameter child cannot be null.
at this line:
_view.scene.addChild(container);
|
Richard Olsson, Administrator
Posted: 24 July 2012 09:06 AM Total Posts: 1192
[ # 3 ]
Yes, that means that container is null. Where are you getting “container” from, and what are you expecting it to be?
And again, you shouldn’t be switching any events. AssetLibrary and Loader3D dispatch the same events, so if you had events that worked with the Loader3D, they will be dispatched from AssetLibrary as well. Be sure that you understand what the “Event.target” property is though. That’s the object that dispatched the event, and from the look of your code, you are assuming that to be a container. When you’re using Loader3D it will be a container, because Loader3D is a container. But when you’re using any of the other loader classes it will not be a container.
Have a look at this (old) document that describes the general concepts behind the Away3D loading framework. I think you may have misunderstood some of it’s parts. http://markmail.org/download.xqy?id=ts3i6hsnusqsrnb6&number=1
After you have read that PDF you might be in a better position to decide whether you want to use AssetLoader, AssetLibrary or Loader3D (and whether you want Loader3D to use AssetLibrary internally.)
|
Drewbaka, Newbie
Posted: 18 August 2012 02:47 AM Total Posts: 11
[ # 4 ]
Could you give me an example of how to use this AssetLoader…I am unable to understand how to use it completely.
|
oladitan, Member
Posted: 18 August 2012 04:41 AM Total Posts: 71
[ # 5 ]
i feel more comfortable with the asset loader now. did you download the example files? one way I was able to understand the asset loader was to erase all the logic in the assetevent function and just put:
trace(event.asset.name);
this should show you the name of each asset as it is being loaded.
“I think that what oladitan means is:”
yes. I have made the correction. thanks.
|
Richard Olsson, Administrator
Posted: 18 August 2012 09:53 AM Total Posts: 1192
[ # 6 ]
I think that what oladitan means is:
trace(event.asset.name);
But to answer your question @Drewbaka, you should really go look at the examples in the away3d-examples-fp11 repository on GitHub:
http://github.com/away3d/away3d-examples-fp11
Most of them (if not all) load data in one way or another. The AssetLoader, AssetLibrary and Loader3D all work the same, except the Loader3D is a container that you can add straight to the scene. AssetLoader is the most barebone of the three, and the only way to access the assets that it parses is by listening for asset events.
|
Drewbaka, Newbie
Posted: 18 August 2012 04:48 PM Total Posts: 11
[ # 7 ]
|