BitmapFileMaterial
BitmapFileMaterial is an external bitmap file loaded as a texture.
Example
Instructions
- Import
import org.papervision3d.materials.BitmapFileMaterial;
- Declare
private var material :BitmapFileMaterial;
- Initialize
material = new BitmapFileMaterial(url, precise);
Parameter Default Description url "" bitmap file location precise false fix distortion
Code
package { import flash.display.Sprite; import flash.events.Event; import org.papervision3d.cameras.Camera3D; import org.papervision3d.events.FileLoadEvent; import org.papervision3d.materials.BitmapFileMaterial; import org.papervision3d.objects.primitives.Plane; import org.papervision3d.render.BasicRenderEngine; import org.papervision3d.scenes.Scene3D; import org.papervision3d.view.Viewport3D; public class Papervision3DBitmapFileMaterial extends Sprite { private var scene :Scene3D; private var camera :Camera3D; private var viewport :Viewport3D; private var renderer :BasicRenderEngine; private var material :BitmapFileMaterial; private var object :Plane; public function Papervision3DBitmapFileMaterial() { scene = new Scene3D(); camera = new Camera3D(); viewport = new Viewport3D(); viewport.autoScaleToStage = true; addChild(viewport); renderer = new BasicRenderEngine(); material = new BitmapFileMaterial("HappyFace.jpg", true); material.doubleSided = true; material.addEventListener(FileLoadEvent.LOAD_COMPLETE, handleLoadComplete); object = new Plane(); scene.addChild(object); } private function handleLoadComplete(e:FileLoadEvent):void { material.removeEventListener(FileLoadEvent.LOAD_COMPLETE, handleLoadComplete); object.material = material; addEventListener(Event.ENTER_FRAME, handleEnterFrame); } private function handleEnterFrame(e:Event):void { object.yaw(1); renderer.renderScene(scene, camera, viewport); } } }