Load OBJ instead embed OBJ

Software: Away3D 4.x

Roland, Newbie
Posted: 27 March 2012 10:10 PM   Total Posts: 9

Hi,

Im using the embed method to load my obj models, and all comes fine,  but the problem is that all the data is loaded when the swf is opened, so my project became really heavy to load at the first time. I would like to load the obj only when I need it, but i have no sucess.

I would like to change this:

[Embed(source=”/../embeds/myobj.obj”, mimeType=“application/octet-stream”)]
private var _myobj:Class;
private var _loader:Loader3D

Parsers.enableAllBundled()
_loader = new Loader3D();
_loader.loadData( new _myobj());
_loader.addEventListener(AssetEvent.ASSET_COMPLETE, loadComplete);
public function loadComplete(event:AssetEvent):void
{
trace(“sucess!’) //its fine
_model:Mesh = event.asset as Mesh;
_model.material = myMaterial
view.scene.addChild(_model);
}

to this:

Parsers.enableAllBundled()
_loader = new Loader3D();
_loader.loadData( new URLRequest(’/../embeds/myobj.obj’));
_loader.addEventListener(AssetEvent.ASSET_COMPLETE, loadComplete);
public function loadComplete(event:AssetEvent):void
{
trace(“sucess!’) //no feedback :(
_model:Mesh = event.asset as Mesh;
_model.material = myMaterial
view.scene.addChild(_model);
}

Someone can helpme with this?
Thanks in advance.

   

Donny, Jr. Member
Posted: 27 March 2012 11:03 PM   Total Posts: 34   [ # 1 ]

Hi Roland,

Using a URLRequest to load the obj rather than the embed won’t alter when it’s loaded. Rather, wrap the loading into a method that you can call at your choosing.

   

Roland, Newbie
Posted: 28 March 2012 12:47 PM   Total Posts: 9   [ # 2 ]

Hi Donny, sorry if Im wrong, but when I embed the obj it loads when the swf begin, but with the URLRequest, I can put the request inside a MouseEvent of a button, so it will only load when I want. Anyway, if you can show me other metod to load the obj I would be grateful.
Thanks.

   

Donny, Jr. Member
Posted: 30 March 2012 12:44 AM   Total Posts: 34   [ # 3 ]
[Embed(source="/myobj.obj"mimeType="application/octet-stream")]
private var _myobj:Class;

private function 
onButtonSelected (event:MouseEvent):void 
{
Parsers
.enableAllBundled()
_loader = new Loader3D();
_loader.loadData( new _myobj());
_loader.addEventListener(AssetEvent.ASSET_COMPLETEloadComplete);
   

Roland, Newbie
Posted: 30 March 2012 05:45 PM   Total Posts: 9   [ # 4 ]

No bro, I think you dont get it, cant embed the obj.

   

maricate, Jr. Member
Posted: 25 May 2013 12:05 AM   Total Posts: 36   [ # 5 ]

Same question… there is only examples using
[Embed(source=xxxxxxxxxxxxx”, mimeType=“application/octet-stream”)]

I need to load obj on demand.
In most of my projects I put the code directly into the swf and not in the .as files.
Matter of organization.
I found this:

http://away3d.com/forum/viewthread/737/

Its solve.

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X