프로그래밍/Flex/AIR2008.09.23 09:47
source:
http://www.barbarayersin.com/2008/04/how-to-display-text-in-papervision.html


I've been looking for a tutorial to display a simple text field within papervision without much success. I finally tumbled on this blog post where it was quite well explained. The example however might be a little long to demonstrate my sole purpose: how to display text in papervision.

So I've decided to put here an even simpler example to make things crystal clear:


// 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;
var p:Plane = new Plane(material,100,100);
scene.addChild(p);


First observation is that it seems impossible to directly embed a UIComponent within papervision *sigh*. Whatever the UIComponent (Button, TextField, etc), it has to be put somehow in a texture and applied on a DisplayObject3D such as a Plane.

Or at least, I have no knowledge of another way to do it. Does anybody know better? My worry is that it may slow down the frame rate to display text in a texture rather than directly as what it really is: good old plain text.
Posted by 시난

댓글을 달아 주세요