Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package {
- import away3d.animators.*;
- import away3d.animators.data.*;
- import away3d.animators.transitions.*;
- import away3d.cameras.*;
- import away3d.containers.*;
- import away3d.controllers.*;
- import away3d.debug.*;
- import away3d.entities.*;
- import away3d.events.*;
- import away3d.library.*;
- import away3d.lights.*;
- import away3d.loaders.*;
- import away3d.loaders.parsers.*;
- import away3d.materials.*;
- import away3d.materials.lightpickers.*;
- import away3d.materials.methods.*;
- import away3d.primitives.*;
- import away3d.textures.*;
- import flash.display.*;
- import flash.events.*;
- import flash.filters.*;
- import flash.geom.*;
- import flash.net.*;
- import flash.text.*;
- import flash.ui.*;
- [SWF(width=640, height=480, frameRate=60, backgroundColor="#e0e0e0")]
- public class MinecraftAway extends Sprite {
- [Embed(source="bottom.jpg")]
- private var I1:Class;
- [Embed(source="side.jpg")]
- private var I2:Class;
- [Embed(source="top.jpg")]
- private var I3:Class;
- private var view:View3D;
- private var cube:Mesh;
- private var hc:HoverController;
- private var awayStats:AwayStats;
- //DragEase
- private var destination:Point = new Point();
- private var dragging:Boolean = false;
- private var speed:Number = 20;
- private var offset:Point = new Point();
- private var cubeY:Number = 0;
- private var cubeX:Number = 0;
- public function MinecraftAway() {
- setupScene();
- }
- private function setupScene():void {
- view = new View3D();
- view.backgroundColor = 0xe0e0e0;
- view.antiAlias = 4;
- addChild(view);
- var bct:BitmapCubeTexture = new BitmapCubeTexture(new I2().bitmapData,
- new I2().bitmapData,
- new I3().bitmapData,
- new I1().bitmapData,
- new I2().bitmapData,
- new I2().bitmapData)
- cube = new Mesh(new CubeGeometry(), new SkyBoxMaterial(bct));
- view.scene.addChild(cube);
- view.camera.z = -500;
- view.camera.y = 300;
- view.camera.lookAt(new Vector3D());
- hc = new HoverController(view.camera, null, 150, 10, 200);
- addEventListener(Event.ENTER_FRAME, loop);
- cube.addEventListener(MouseEvent3D.MOUSE_DOWN, startDragCube);
- addEventListener(MouseEvent.MOUSE_UP, stopDragCube);
- addEventListener(MouseEvent.MOUSE_OUT, stopDragCube);
- awayStats = new AwayStats(view);
- addChild(awayStats);
- cube.mouseEnabled = true;
- }
- private function startDragCube(e:MouseEvent3D):void {
- /*offset.x = mouseX - cube.rotationY;
- offset.y = mouseY - cube.rotationX;*/
- offset.x = mouseX;
- cubeY = cube.rotationY;
- offset.y = mouseY;
- cubeX = cube.rotationX;
- dragging = true;
- }
- private function stopDragCube(e:MouseEvent):void {
- dragging = false;
- }
- protected function loop(e:Event):void {
- if (dragging) {
- destination.x = mouseX;
- destination.y = mouseY;
- }
- /*cube.rotationX -= (cube.rotationX - (destination.y - offset.y)) / speed;
- cube.rotationY -= (cube.rotationY - (destination.x - offset.x)) / speed;*/
- cube.rotationX -= (cube.rotationX - (cubeX - (destination.y - offset.y))) / speed;
- cube.rotationY -= (cube.rotationY - (cubeY - (destination.x - offset.x))) / speed;
- view.render();
- }
- }
- }
Advertisement