package com.hclown.earth3d.map
{
import org.papervision3d.objec ts.Plane;
import org.papervision3d.materials.BitmapFileMaterial;
import org.papervision3d.events.FileLoadEvent;
import org.papervision3d.materials.ColorMaterial;
import org.papervision3d.materials.BitmapMaterial;
import flash.display.BitmapData;
/**
* 瓦片对象
**/
public class TilePlane extends Plane
{
private var imgUrl:String = null;
private var bitmapMaterial:BitmapFileMaterial = null;
/**
* 构建一个瓦片面板
* @parm imgUrl 渲染面板的图片
**/
public function TilePlane(imgUrl:String,width:Number,height:Number){
this.bitmapMaterial = new BitmapFileMaterial();
this.bitmapMaterial.addEventListener(FileLoadEvent.LOAD_COMPLETE, handleFileLoaded);
this.bitmapMaterial.doubleSided = true;
this.bitmapMaterial.smooth = true;
this.imgUrl = imgUrl;
super(this.bitmapMaterial,width,height,4,4);
}
/**
* 设置TilePlane的定位点,默认z=0
**/
public function setPosition(x:Number,y:Number,z:Number):void{
this.x = x;
this.y = y;
this.z = z;
}
/**
* 设置TilePlane的图片地址
**/
public function setImgUrl(url:String):void{
this.imgUrl = url;
refreshPlane();
}
/**
* 获取TilePlane的图片地址
**/
public function getImgUrl():String{
return this.imgUrl;
}
//初始化Plane
private function refreshPlane():void{
trace("1");
this.bitmapMaterial = new BitmapFileMaterial();
this.bitmapMaterial.addEventListener(FileLoadEvent.LOAD_COMPLETE, handleFileLoaded);
this.bitmapMaterial.texture = this.imgUrl;
trace("2");
}
protected function handleFileLoaded(e:FileLoadEvent):void
{
trace("3");
this.bitmapMaterial.texture = this.imgUrl;
//var plane:Plane = new Plane(this.material,256,256,4,4);
//this.addChild(plane);
trace("4");
}
}
}
{
import org.papervision3d.objec ts.Plane;
import org.papervision3d.materials.BitmapFileMaterial;
import org.papervision3d.events.FileLoadEvent;
import org.papervision3d.materials.ColorMaterial;
import org.papervision3d.materials.BitmapMaterial;
import flash.display.BitmapData;
/**
* 瓦片对象
**/
public class TilePlane extends Plane
{
private var imgUrl:String = null;
private var bitmapMaterial:BitmapFileMaterial = null;
/**
* 构建一个瓦片面板
* @parm imgUrl 渲染面板的图片
**/
public function TilePlane(imgUrl:String,width:Number,height:Number){
this.bitmapMaterial = new BitmapFileMaterial();
this.bitmapMaterial.addEventListener(FileLoadEvent.LOAD_COMPLETE, handleFileLoaded);
this.bitmapMaterial.doubleSided = true;
this.bitmapMaterial.smooth = true;
this.imgUrl = imgUrl;
super(this.bitmapMaterial,width,height,4,4);
}
/**
* 设置TilePlane的定位点,默认z=0
**/
public function setPosition(x:Number,y:Number,z:Number):void{
this.x = x;
this.y = y;
this.z = z;
}
/**
* 设置TilePlane的图片地址
**/
public function setImgUrl(url:String):void{
this.imgUrl = url;
refreshPlane();
}
/**
* 获取TilePlane的图片地址
**/
public function getImgUrl():String{
return this.imgUrl;
}
//初始化Plane
private function refreshPlane():void{
trace("1");
this.bitmapMaterial = new BitmapFileMaterial();
this.bitmapMaterial.addEventListener(FileLoadEvent.LOAD_COMPLETE, handleFileLoaded);
this.bitmapMaterial.texture = this.imgUrl;
trace("2");
}
protected function handleFileLoaded(e:FileLoadEvent):void
{
trace("3");
this.bitmapMaterial.texture = this.imgUrl;
//var plane:Plane = new Plane(this.material,256,256,4,4);
//this.addChild(plane);
trace("4");
}
}
}