I cannot load textures along with 3ds models…

Software: Away3D 4.x

Kicker, Member
Posted: 21 June 2015 02:28 PM   Total Posts: 52

Hi,

I have a file my_mesh.3ds, and a texture attached to it with specific coordinates, my_tex.png.

When I load the file offline, everything works just fine, but as soon as I upload them on a server, and loading takes more than a split second, my texture is replaced with a checkboard texture, and I get this error message:

TypeError: Error #1034: Type Coercion failed: cannot convert away3d.events::LoaderEvent@8a25d99 to flash.events.IOErrorEvent.

Here’s my code:

private function loadMesh(url:String):void
{
 _meshLoader 
= new Loader3D();
 
_meshLoader.addEventListener(ProgressEvent.PROGRESSonAssetLoadingProgress);
 
_meshLoader.addEventListener(AssetEvent.MESH_COMPLETEonAssetLoadingComplete);
 
_meshLoader.addEventListener(LoaderEvent.LOAD_ERRORonLoadingError);
 
_meshLoader.load(new URLRequest(url), new AssetLoaderContext());

 
state STATE_LOADING;

I also tried to listen to LoaderEvent.RESOURCE_COMPLETE instead of AssetEvent.MESH_COMPLETE, but then I get the error message offline too…

Thanks in advance

Edit: Sorry for double-post, didn’t do it on purpose…

   

Avatar
Fabrice Closier, Administrator
Posted: 21 June 2015 03:39 PM   Total Posts: 1265   [ # 1 ]

The error you have is the type of the receiving Event that you have defined in the handler.  onLoadingError(event:LoaderEvent) is probably what you have, it must be onLoaderError(event:IOErrorEvent) or e:Event.

The reason you get an error might be caused by the missing .3ds mimetype on your server. Try call the url of the 3ds directly into the browser, type http//server.com/myfile.3ds. If the browser gives error, define the mimeType and your project will run.
If the file is found and gets loaded, then you have set a faulty url in your project.

   

Kicker, Member
Posted: 21 June 2015 04:30 PM   Total Posts: 52   [ # 2 ]

Sorry, I should have precised: the .3ds file’s loading works. The model gets loaded and appears in the game. It’s the texture that is attached to it which doesn’t appear and is replaced by a checkboard.
Or maybe I just don’t understand how I am supposed to make this work.
I thought I just had to load the .3ds file and then Away3D would check the texture’s URL and download it too, since what I did above perfectly works offline.
But maybe I should also load the .png texture before trying to load the .3ds file?

Also, here’s my error handler:

private function onLoadingError($e:IOErrorEvent):void
{
 Console
.log($e.toString());
 
 
state STATE_ERROR;

 for 
each(var handler:CallbackWithParams in errorHandlers)
 
{
  
if (handler != null)
  
{
   handler
.apply();
  
}
 }
   

Avatar
Fabrice Closier, Administrator
Posted: 21 June 2015 06:51 PM   Total Posts: 1265   [ # 3 ]

If the 3ds does load, and you get the checker (default texture), it’s because the dependency (your png) isn’t found. So there must be some issues there, try a full url instead of relative then… or use exports from Prefab or AwayBuilder vs 3ds.

   

Kicker, Member
Posted: 21 June 2015 07:04 PM   Total Posts: 52   [ # 4 ]

I’m already using full URLs.
Can you explain to me exactly how Away3D handles these cases?
How does Away3D get the texture’s URL in the first place?
While reading the .3ds file I guess?
What happens then?
I read the engine’s source code, but I can’t find the exact line where it happens…
I can always give a shot to AwayBuilder or Prefab, but the fact that my code works offline makes me think that this is just a problem of loading things in the correct order, or listening to the correct events…

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X