package
{
import away3d.containers.View3D;
import away3d.controllers.HoverController;
import away3d.entities.Mesh;
import away3d.materials.TextureMaterial;
import away3d.primitives.SphereGeometry;
import away3d.utils.Cast; import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.events.MouseEvent; /**
* @author Frost.Yen
* @E-mail 871979853@qq.com
* @create 2015-9-23 下午3:18:40
*
*/
[SWF(width='800',height='600',frameRate="60", backgroundColor="0x000000")] public class Away3dOverall extends Sprite
{
[Embed(source = "assets/1.jpg")]
private static var BallMaterial:Class;
private var _startX:Number;
private var _startY:Number;
private var _mouseX:Number;
private var _mouseY:Number;
private var _view:View3D;
private var _cameraHoverController:HoverController;
private var _sphere:SphereGeometry;
private var _sphereMaterial:TextureMaterial;
private var _mesh:Mesh;
public function Away3dOverall()
{
if (stage) {
init();
}else {
this.addEventListener(Event.ADDED_TO_STAGE, init);
} }
private function init(e:Event = null):void {
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
this.removeEventListener(Event.ADDED_TO_STAGE, init); _view = new View3D();
addChild(_view);
_view.antiAlias = 6;
//摄像机渲染范围2000
_view.camera.lens.far = 2000; _cameraHoverController = new HoverController(_view.camera, null, 90, 0, 300);
_cameraHoverController.yFactor = 1;
_sphere = new SphereGeometry(1000, 64);
//_sphere.yUp = false;
_sphereMaterial = new TextureMaterial(Cast.bitmapTexture(BallMaterial));
_sphereMaterial.bothSides = true;
_sphereMaterial.smooth = true;
_mesh = new Mesh(_sphere, _sphereMaterial);
//MeshHelper.invertFaces(_mesh); _view.camera.position = _mesh.position; _view.scene.addChild(_mesh);this.addEventListener(Event.ENTER_FRAME, onEnterFrame);
stage.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownFunction);
stage.addEventListener(MouseEvent.MOUSE_WHEEL, onWheel);
}
private function onWheel(e:MouseEvent):void
{
if (e.delta > 0) {
if (_cameraHoverController.distance > 6) {
_cameraHoverController.distance -= 5;
}
}else if (e.delta < 0) {
if (_cameraHoverController.distance < 600) {
_cameraHoverController.distance += 5;
}
}
} private function mouseDownFunction(e:MouseEvent):void
{
_startX = _cameraHoverController.panAngle;
_startY = _cameraHoverController.tiltAngle;
_mouseX = mouseX;
_mouseY = mouseY;
stage.addEventListener(MouseEvent.MOUSE_MOVE,mouseMoveFunction);
stage.addEventListener(MouseEvent.MOUSE_UP,mouseUpFunction);
} private function mouseUpFunction(e:MouseEvent):void
{
stage.removeEventListener(MouseEvent.MOUSE_MOVE,mouseMoveFunction);
stage.removeEventListener(MouseEvent.MOUSE_UP,mouseUpFunction);
//stage.addEventListener(MouseEvent.MOUSE_DOWN,mouseDownFunction);
} private function mouseMoveFunction(e:MouseEvent):void
{
_cameraHoverController.panAngle = (mouseX - _mouseX) * .3 + _startX;
_cameraHoverController.tiltAngle = (mouseY - _mouseY) * .3 + _startY;
} private function onEnterFrame(e:Event):void
{
_view.render();
} }
}

需要一张无缝全景图,像这样的:

[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)例子

    /* SkyBox example in Away3d Demonstrates: How to use a CubeTexture to create a SkyBox object. How to ...

  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. [ActionScript 3.0] AS3.0 动态加载显示内容

    可以将下列任何外部显示资源加载到 ActionScript 3.0 应用程序中: 在 ActionScript 3.0 中创作的 SWF 文件 — 此文件可以是 Sprite.MovieClip 或扩 ...

  9. ActionScript 3.0 API 中的 Video 类

    注:这个类在Flash流媒体开发中使用的很频繁,在此记录一下它的使用方法. 包 flash.media 类 public class Video 继承 Video  DisplayObject  Ev ...

随机推荐

  1. 如何将maven项目导入myeclipse中

    在mvn的项目中 pom.xml 文件所在目录, 运行 mvn eclipse:clean eclipse:eclipse ,会自动将mvn工程转成eclipse工程, 然后在eclipse中 &qu ...

  2. 010. 使用.net框架提供的属性

    C#允许在类和类成员上声明特性(类), 可在运行时解释类和类的成员. 这个特性也称为属性, 使用Attribute.下面演示如何使用.net框架提供的属性. using System; using S ...

  3. jQuery.retryAjax

    Overload method for $.ajax that provides the ability to try the request over if it fails the first t ...

  4. Junit手动/自动加载spring配置文件

    分配置文件在classpath下和web-inf下两种情况的加载: ApplicationContext context = new FileSystemXmlApplicationContext(& ...

  5. Oracle 支持正则表达式的函数

    内容提要 oracle 10g 增加的正则表达式函数有以下四种: regexp_like() --返回满足条件的字段 regexp_instr() --返回满足条件的字符或字符串的位置 regexp_ ...

  6. 深入理解HashMap

    转自:http://annegu.iteye.com/blog/539465 Hashmap是一种非常常用的.应用广泛的数据类型,最近研究到相关的内容,就正好复习一下.网上关于hashmap的文章很多 ...

  7. HDP2.4安装(二):Centos7配置

    Centos7 Minimal Install 安装完成后是不支持上网的,并且大部分常用的软件也未安装,首先要解决的问题就是网络配置.当网络配通后,即可通过Xshell或其它工具来远程进行操作与管理, ...

  8. Neutron分析(6)—— neutron-openvswitch-agent

    neutron-openvswitch-agent代码分析 neutron.plugins.openvswitch.agent.ovs_neutron_agent:main # init ovs fi ...

  9. LintCode "Continuous Subarray Sum"

    A variation to a classical DP: LCS. class Solution { public: /** * @param A an integer array * @retu ...

  10. docker配置环境

    debian: curl -sSL https://get.docker.com/ | sh curl -sSL https://get.daocloud.io/docker | sh daoclou ...