- 最后登录
- 2022-10-8
- 注册时间
- 2010-12-6
- 阅读权限
- 100
- 积分
- 14150
- 纳金币
- 76544
- 精华
- 23
|
应驰骋的风强烈要求,铁锹我找到神奇的away3D入门教程了,回击一下那个风子。
有NX人士表示,“以前接触过papervision3D,最近接触了away3D感觉比papervision3D简单。”是真是假?纳金网的纳米们最聪明了,自己学学看就知道了。
现在把教程发上来了,看完聊聊啊~
代码一:
import away3d.containers.*;// View3D所在位置
import away3d.core.base.*;// Object3D所在位置
import away3d.primitives.*;// Sphere所在位置
import away3d.core.math.*;// Number3D所在位置
// 创建三维试图方式
var view:View3D = new View3D({x:300, y:200});
addChild(view);
// 创建一个球体
var sphere:Object3D = new Sphere({material:"blue#cyan", radius:250, segmentsW:12, segmentsH:9, y:50, x:10, z:10});
view.scene.addChild(sphere);
// 设置摄像机的位置/**/
view.camera.position = new Number3D(1000, 1000, 1000);
view.camera.lookAt(sphere.position);
//添加运动事件
addEventListener(Event.ENTER_FRAME, onEnterFrame);
function onEnterFrame(event:Event):void {
// 将球体绕Y轴旋转
sphere.rotationY = getTimer() / 100;
view.render();
}
与papersion3D不同的是
package {
import flash.display.Sprite;
import flash.events.Event;
import org.papervision3d.cameras.Camera3D;
import org.papervision3d.scenes.MovieScene3D;
import org.papervision3d.materials.MaterialsList;
import org.papervision3d.materials.WireframeMaterial;
import org.papervision3d.core.proto.MaterialObject3D;
import org.papervision3d.objects.DisplayObject3D;
import org.papervision3d.objects.Sphere;
[SWF(width='200',height='200',backgroundColor='0xFFFFFF',frameRate='30')]
public class Main extends Sprite
{
private var _container :Sprite;
private var _scene :MovieScene3D;
private var _camera :Camera3D;
private var _material:MaterialObject3D;
private var _displayObjisplayObject3D;
public function Main()
{
Init3D();
}
private function Init3D():void {
// 创建3D舞台的容器
_container = new Sprite;
_container.x = 100;
_container.y = 100;
addChild( _container );
// 创建3D舞台
_scene = new MovieScene3D( _container );
// 创建摄像头
_camera = new Camera3D();
_camera.z = -500;
_camera.zoom = 5;
// 创建一个线框材质
_material = new WireframeMaterial(0x000000);
_displayObj = new Sphere(_material, 80, 10, 10);
_scene.addChild(_displayObj);
this.addEventListener(Event.ENTER_FRAME, OnEnterFrame);
}
private function OnEnterFrame(event:Event):void {
_displayObj.rotationX += 5;
_displayObj.rotationY += 5;
_scene.renderCamera(_camera);
}
}
}
|
|