Tips: Change PV3D material at runtime
If you want to replace a material-list or just a material from a rendered object at runtime, you might have tried to remove the old material by the new instance like this:
myObj.materials = myNewMaterialsList;
Unfortunately, that doesn’t work (in PV3d 1, fixed by v2 if I’m not wrong) An other way to proceed is to use bitmapMaterial and bitmapData.
You just have to create a BitmapMaterial with a bitmapData inside:
var bd1:BitmapData=new BitmapData(100, 100, false, 0xFFFFFF); var material2:BitmapMaterial = new BitmapMaterial(bd1); material2.name="faceToSwitch"
Then, swap the targeted material (alreday rendered) at runtime, on rollover action for example, simply by calling:
var bd2:BitmapData=new BitmapData(100, 100, false, 0x000000);
myObj.materials.getMaterialByName("faceToSwitch").bitmap = bd2;
About this entry
You’re currently reading “Tips: Change PV3D material at runtime,” an entry on Make me pulse - Making a better life for web developer since 2006
- Published:
- 03.03.08 / 12pm
- Category:
- AS3, Papervision3D, Tips, Tutorial


No comments
Jump to comment form | comments rss [?] | trackback uri [?]