Search code examples
flashactionscript-3texttexturespapervision3d

How to use Text as texture on Cube inside papervision3d?


What is the best technique to apply anti-aliased text as texture on cube using papervision3d?

  1. make dynamic textfield, convert it to moviematerial then apply it to the faces of cube.

  2. Design a bitmap using any picture editor and make a bitmapFileMaterial to apply on faces of cube.

  3. Any other suggestions please.


Solution

  • // create your text field and set its content.
    var t:TextField = new TextField();
    t.text = "Hello world!";
    
    // create a BitmapData of your wished width and height
    var bitmap:BitmapData = new BitmapData(100,100);
    
    // Fill bmp with the content of your TextField. 
    //It's as if you took a picture of t.
    bitmap.draw(t);
    // Create a material with the resulting BitmapData and you can use it on any DisplayObject3D!
    var material:BitmapMaterial = new BitmapMaterial(bitmap);
    material.smooth = true;
    material.doubleSided = true;
    
    // Create cube
    var cube:Cube = new Cube(material)