/*

 SkyBox example in Away3d

 Demonstrates:

 How to use a CubeTexture to create a SkyBox object.
How to apply a CubeTexture to a material as an environment map. Code by Rob Bateman
rob@infiniteturtles.co.uk
http://www.infiniteturtles.co.uk This code is distributed under the MIT License Copyright (c) The Away Foundation http://www.theawayfoundation.org Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the “Software”), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. */ 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
{
// Environment map.
[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; //engine variables
private var _view:View3D; //scene objects
private var _skyBox:SkyBox;
private var _torus:Mesh; /**
* Constructor
*/
public function Basic_SkyBox()
{
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT; //setup the view
_view = new View3D();
addChild(_view); //setup the camera
_view.camera.z = -600;
_view.camera.y = 0;
_view.camera.lookAt(new Vector3D());
_view.camera.lens = new PerspectiveLens(90); //setup the cube texture
var cubeTexture:BitmapCubeTexture = new BitmapCubeTexture(Cast.bitmapData(EnvPosX), Cast.bitmapData(EnvNegX), Cast.bitmapData(EnvPosY), Cast.bitmapData(EnvNegY), Cast.bitmapData(EnvPosZ), Cast.bitmapData(EnvNegZ)); //setup the environment map material
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)); //setup the scene
_torus = new Mesh(new TorusGeometry(150, 60, 40, 20), material);
_view.scene.addChild(_torus); _skyBox = new SkyBox(cubeTexture);
_view.scene.addChild(_skyBox); //setup the render loop
addEventListener(Event.ENTER_FRAME, _onEnterFrame);
stage.addEventListener(Event.RESIZE, onResize);
onResize();
} /**
* render loop
*/
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();
} /**
* stage listener for resize events
*/
private function onResize(event:Event = null):void
{
_view.width = stage.stageWidth;
_view.height = stage.stageHeight;
}
}
}

[ActionScript 3.0] Away3D 天空盒(skybox)例子的更多相关文章

  1. [ActionScript 3.0] Away3D 天空盒(skybox)例子2

    所谓skybox就是六个面即六张图能够无缝的拼成一个正方体的盒子. package { import away3d.cameras.Camera3D; import away3d.cameras.le ...

  2. [ActionScript 3.0] Away3D 非skybox的全景例子

    package { import away3d.containers.View3D; import away3d.controllers.HoverController; import away3d. ...

  3. [ActionScript 3.0] Away3D 官网实例

    /* Dynamic tree generation and placement in a night-time scene Demonstrates: How to create a height ...

  4. [ActionScript 3.0] Away3D 灯光的使用

    package { import away3d.containers.View3D; import away3d.entities.Mesh; import away3d.events.MouseEv ...

  5. [ActionScript 3.0] Away3D 旋转效果

    package { import away3d.containers.View3D; import away3d.entities.Mesh; import away3d.events.MouseEv ...

  6. ActionScript 3.0入门:Hello World、文件读写、数据存储(SharedObject)、与JS互调

    近期项目中可能要用到Flash存取数据,并与JS互调,所以就看了一下ActionScript 3.0,现把学习结果分享一下,希望对新手有帮助. 目录 ActionScript 3.0简介 Hello ...

  7. [转]ActionScript 3.0入门:Hello World、文件读写、数据存储(SharedObject)、与JS互调

    本文转自:http://www.cnblogs.com/artwl/p/3396330.html 近期项目中可能要用到Flash存取数据,并与JS互调,所以就看了一下ActionScript 3.0, ...

  8. CSharpGL(43)环境映射(Environment Mapping)-天空盒(Skybox)反射(Reflection)和折射(Refraction)

    CSharpGL(43)环境映射(Environment Mapping)-天空盒(Skybox)反射(Reflection)和折射(Refraction) 开始 如图所示,本文围绕GLSL里的sam ...

  9. ActionScript 3.0 for the Lunder Algorithm

    package com.feiruo.Calendar.LunderCalendar { /* *@ClassName: package:com.feiruo.Calendar.LunderCalen ...

随机推荐

  1. python之selenium

    selenium是处理异步加载的一种方法 总的来说是操作浏览器访问来获取自己想要的资料 优点是浏览器能看到的都能爬下来,简单有效,不需要深入破解网页加载形式 缺点是加载的东西太多,导致爬取速度变慢 # ...

  2. Swift技术之如何在iOS 8下使用Swift设计一个自定义的输入法 (主要是NSLayoutConstraint 的使用)

    当前位置: > Swift新手入门 > Swift技术之如何在iOS 8下使用Swift设计一个自定义的输入法 时间:2014-09-10 16:49来源:未知 作者:啊成 举报 点击:5 ...

  3. 文件/文件夹比较工具 beyond compare 3.3.10

  4. 转:java日志组件介绍(common-logging,log4j,slf4j,logback )

    原网址:http://www.blogjava.net/daiyongzhi/archive/2014/04/13/412364.html common-logging common-logging是 ...

  5. App开发者必备的运营、原型、UI设计工具整理

    移动应用开发者们,Attention please!在接下来的内容里,我们将介绍一些能够提高你们的应用的知名度和品质水平的工具. 仔细看看,下面这些工具你们都知道吗,用过吗?如果你还不知道,或许可以尝 ...

  6. html简介

    什么是 HTML? HTML 是用来描述网页的一种语言. HTML 指的是超文本标记语言 (Hyper Text Markup Language) HTML 不是一种编程语言,而是一种标记语言 (ma ...

  7. 【linux】/etc/passwd文件

    /etc/passwd文件内容格式 /etc/passwd是保存用户信息的文件. 格式:用户名: 密码 : uid  : gid :用户描述:主目录:登陆shell 举个例子: root:x:0:0: ...

  8. [转]UOS 中的虚拟网络设备

    随着网络技术,虚拟化技术的发展,越来越多的高级网络设备被加入了到了 Linux 中,这些设备在 UOS 中起到了广泛而关键的作用,包括 Open vSwitch.TAP 设备.Veth 设备等等,梳理 ...

  9. MySQL存储引擎【InnoDB、MyISAM、Memory】

    数据库,MySQL这样存在多存储引擎的数据库软件,清楚常见的存储引擎的区别,使用合适的存储引擎,使得项目跑的更顺畅,有时候对于一个项目,甚至比项目本身都重要.这篇文章,旨在浅谈常见的三种存储引擎的区别 ...

  10. node.js的作用、回调、同步异步代码、事件循环

    http://www.nodeclass.com/articles/39274 一.node.js的作用 I/O的意义,(I/O是输入/输出的简写,如:键盘敲入文本,输入,屏幕上看到文本显示输出.鼠标 ...