away3D案例2
Posted 挨踢老干部的博客
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了away3D案例2相关的知识,希望对你有一定的参考价值。
package { import away3d.cameras.lenses.*; import away3d.containers.*; import away3d.entities.*; import away3d.materials.*; import away3d.materials.methods.*; import away3d.primitives.*; import away3d.textures.*; import away3d.utils.*; import flash.display.*; import flash.events.*; import flash.geom.Vector3D; [SWF(backgroundColor="#000000", frameRate="60", quality="LOW")] public class Basic_SkyBox extends Sprite { // 指定当前的材质信息 [Embed(source="../embeds/skybox/snow_positive_x.jpg")] private var EnvPosX:Class; [Embed(source="../embeds/skybox/snow_positive_y.jpg")] private var EnvPosY:Class; [Embed(source="../embeds/skybox/snow_positive_z.jpg")] private var EnvPosZ:Class; [Embed(source="../embeds/skybox/snow_negative_x.jpg")] private var EnvNegX:Class; [Embed(source="../embeds/skybox/snow_negative_y.jpg")] private var EnvNegY:Class; [Embed(source="../embeds/skybox/snow_negative_z.jpg")] private var EnvNegZ:Class; //定义三维场景 private var _view:View3D; //指定skybox对象 private var _skyBox:SkyBox; private var _torus:Mesh; /** * 构造函数 */ public function Basic_SkyBox() { stage.scaleMode = StageScaleMode.NO_SCALE; stage.align = StageAlign.TOP_LEFT; //指定当前的视图 _view = new View3D(); addChild(_view); //指定当前的摄像机信息 _view.camera.z = -600; _view.camera.y = 0; _view.camera.lookAt(new Vector3D()); _view.camera.lens = new PerspectiveLens(90); //指定一个基本材质 var cubeTexture:BitmapCubeTexture = new BitmapCubeTexture(Cast.bitmapData(EnvPosX), Cast.bitmapData(EnvNegX), Cast.bitmapData(EnvPosY), Cast.bitmapData(EnvNegY), Cast.bitmapData(EnvPosZ), Cast.bitmapData(EnvNegZ)); //指定颜色材质 var material:ColorMaterial = new ColorMaterial(0xFFFFFF, 1); material.specular = 0.5; material.ambient = 0.25; material.ambientColor = 0x111199; material.ambient = 1; material.addMethod(new EnvMapMethod(cubeTexture, 1)); //设置当前的材质信息 _torus = new Mesh(new TorusGeometry(150, 60, 40, 20), material); _view.scene.addChild(_torus); //指定天空的材质信息 _skyBox = new SkyBox(cubeTexture); _view.scene.addChild(_skyBox); //添加循环 addEventListener(Event.ENTER_FRAME, _onEnterFrame); stage.addEventListener(Event.RESIZE, onResize); onResize(); } /** * 帧动画 */ private function _onEnterFrame(e:Event):void { _torus.rotationX += 2; _torus.rotationY += 1; _view.camera.position = new Vector3D(); _view.camera.rotationY += 0.5*(stage.mouseX-stage.stageWidth/2)/800; _view.camera.moveBackward(600); _view.render(); } /** * 舞台的尺寸改变事件 */ private function onResize(event:Event = null):void { _view.width = stage.stageWidth; _view.height = stage.stageHeight; } } }
以上是关于away3D案例2的主要内容,如果未能解决你的问题,请参考以下文章
如何在 as3/away3d 中设置 360 度视频投影以保持叠加
ActionScript 3 Away3D本地3d到全球2d点
Express实战 - 应用案例- realworld-API - 路由设计 - mongoose - 数据验证 - 密码加密 - 登录接口 - 身份认证 - token - 增删改查API(代码片段