3k visitas
Papervision 3D: How to embed a 3D model (3DS, Collada, etc...)
In Flash, you can embed 3D objects using the Embed functionality. In this example a 3DS model is loaded, but you can use this technique to embed almost any 3D format. It looks like this:
ActionScript 3
- // Path is relative to the file you put the Embed into
- [Embed (source="path/to/model.3ds", mimeType="application/octet-stream")]
This embeds the content of the 3ds file into a Class called Mesh. Then, you can use it this way:
ActionScript 3
- // Create a new instance of Mesh as an array of bytes
- var object:Max3DS = new Max3DS();
- // The load method accepts the 3d object as a ByteArray and loads it successfully
- object.load(byteArray);
You can also embed and load a texture:
ActionScript 3
- [Embed (source="path/to/texture.png")]
Flash "understands" the png format, so you don't need to set the mimeType. Then, you can load it and apply it to the 3d object this way:
ActionScript 3
- var materialList:MaterialsList = new MaterialsList();
- var bitmapMaterial:BitmapMaterial = new BitmapMaterial(bitmap.bitmapData, true);
- materialList.addMaterial(bitmapMaterial,"all");
- var object:Max3DS = new Max3DS();
- object.load(byteArray, materialList, ".");
Enviado por miguelSantirso hace about 1 year — modificado por última vez hace less than a minute