[PV3D]地球儀3
Papervision3Dで地球儀を作ってみた。一つはSwift3DからDAEファイルを読み込んだもの、もう一つはSphereに地表の画像をマテリアルとして貼り付けたもの。
DAEの地球
Swift3D ver5で球体に地表の画像を貼り付けたものをDAEで書き出した(PV3D書き出し)もの。ただし、DAEファイル内の日本語は全部アルファベットに置き換えること。
▼Wonderfl
DAEファイルを読み込ませるだけで、その中に記述してあるマテリアル類も自動的に読み込んで貼り付けるのはえらい。さすが。
ただ、スムージングのかけ方がわからない。
▼DAEの地球 ActionScript AS3(FP9)
/*
DAEファイルを読み込む。
うーん、スムージングのかけ方がわからない。
*/
package{
import org.papervision3d.view.BasicView;
import org.papervision3d.objects.parsers.DAE;
import flash.events.Event;
import net.hires.debug.Stats;
[SWF(width="465", height="465", frameRate="30", backgroundColor="0x000000")]
public class Main4 extends BasicView{
private var dae:DAE;
public function Main4(){
dae = new DAE();
dae.load("http://mztm.heteml.jp/umhr/wonderfl/earth.dae");
scene.addChild(dae);
camera.z = -1;
startRendering();
addChild(new Stats());
}
override protected function onRenderTick(event:Event=null):void{
var mouseY:Number = Math.min(Math.max(stage.mouseY, 0), stage.stageHeight) - stage.stageHeight / 2;
dae.rotationX += mouseY / 1000;
dae.localRotationY -= 0.2;
super.onRenderTick(event);
}
}
}
地球儀forked from: [PV3D] Simple Sphere
こちらはSphereのマテリアルとして地表画像を貼り付けたもの。
単に地球を作りたいだけなら、こちらのほうが細かいコントロールが効いてよい。
▼Wonderfl
▼地球儀forked from: [PV3D] Simple Sphere ActionScript AS3(FP9)
package {
import flash.events.Event;
import org.papervision3d.objects.primitives.Sphere;
import org.papervision3d.view.BasicView;
import org.papervision3d.materials.BitmapFileMaterial;
import net.hires.debug.Stats;
import flash.system.Security;
/**
* シンプルな球面デモ(BasicViewを継承すると最低限の必要な3D設定が済んでます)
*/
[SWF(width="465", height="465", frameRate="30", backgroundColor="0x000000")]
public class Main5 extends BasicView{
public function Main5():void {
Security.loadPolicyFile("http://mztm.heteml.jp/crossdomain.xml");
addChild(new Stats());
var material:BitmapFileMaterial = new BitmapFileMaterial("http://mztm.heteml.jp/umhr/wonderfl/er04.jpg");
material.smooth = true;
// 球面を作成(引数はテクスチャ、半径、横方向のポリゴン分割数、縦方向のポリゴン分割数)
var sphere:Sphere = new Sphere(material, 480, 24, 24);
// 3Dシーンに表示(PV3DではsceneにaddChildします)
scene.addChild(sphere);
// レンダリング開始
startRendering();
// ループ処理を設定します
addEventListener(Event.ENTER_FRAME, function(e:Event):void {
var mouseY:Number = Math.min(Math.max(stage.mouseY, 0), stage.stageHeight) - stage.stageHeight / 2;
sphere.rotationX += mouseY / 1000;
sphere.localRotationY += 0.2;});
}
}
}
関連
▼独自3Dによる実装例
http://www.mztm.jp/wp/?p=2519
http://www.mztm.jp/wp/?p=2485





