Embedding Collada and texture files to Papervision3D

One bad thing about not embedding collada and texture files in your swf file is that it can take quite a while for flash to load in external files, even if they’re pretty small.

To embed collada and material files, declare them as a class.
The paths are relative to your flash src file, rather than the deployed swf file.

public class KakesPapervision3DTest extends PaperBase
[Embed(source="dae/blue_ball.dae", mimeType = "application/octet-stream")]
private var daeBlueBall:Class;
private var matBlueBall:Class;

Create your DAE as ByteArray where you initialise your models…

private function init3dModels():void
var byteArray1:ByteArray = new daeBlueBall() as ByteArray;
_model_balls_blue = new DAE();
_model_balls_blue.scale = 100 ;
_model_balls_blue.rotationY = 180;

Use BitmapMaterial instead of BitmapFileMaterial…

private function initMaterials():void
var bitmap1:Bitmap = new matBlueBall() as Bitmap;
var bitmapMaterial1:BitmapMaterial = new BitmapMaterial(bitmap1.bitmapData, true);
_model_balls_blue.materials.addMaterial(bitmapMaterial1, "blue_ball");
_model_balls_blue.materials.addMaterial(bitmapMaterial1, "blue_white");

Before embedding external files, my scene was taking several seconds to load, even though they were not even 1mb including all the texture files. After embedding dae and jpg/png files, the load time was instant.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s