papervision3d texture & shader

f:id:peroon:20100801130046j:image
周りの点はパーティクルです。
PhongShaderの部分をFlatShaderにすれば、
Flatシェーディングもできます。

import org.papervision3d.objects.primitives.*
import org.papervision3d.materials.*

//シェーダ
import org.papervision3d.materials.shadematerials.*
import org.papervision3d.materials.shaders.*;
import org.papervision3d.lights.*

//パーティクル
import org.papervision3d.objects.special.ParticleField;
import org.papervision3d.materials.special.ParticleMaterial;

//パーティクル生成
var particleMat:ParticleMaterial = new ParticleMaterial(0x0000FF, 1)
var particles:ParticleField = new ParticleField(particleMat, 500, 4, 2000, 2000, 2000)
world.scene.addChild( particles );

//ライト
var light:PointLight3D = new PointLight3D()

//texture&shader
var material = new BitmapAssetMaterial('EarthMap')
var shader = new PhongShader(light, 0xFFFFFF, 0x000000)
var shadedMaterial = new ShadedMaterial(material, shader)

//球作成
var sphere:Sphere = new Sphere(shadedMaterial, 400, 30, 30)
world.scene.addChild(sphere);

//描画
world.startRendering()

var rot:Number = 0//camera角度
addEventListener(Event.ENTER_FRAME, function(e){
	rot += 0.5
	// 角度に応じてカメラの位置
	world.camera.x = 1000 * Math.sin(rot * Math.PI / 180)
	world.camera.z = 1000 * Math.cos(rot * Math.PI / 180)
	//球の自転
	sphere.rotationY -= 0.25
})