⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 skateboard.as

📁 Papervision3d的源码
💻 AS
字号:
/**
 * Paperskated3d - simple skateboard simulator in Papervision3d
 * 
 * @author Bartek Drozdz 
 * @version 1.0
 * 
 * Released under Creative Commons Attribution-Non-Commercial-Share Alike 3.0 License.
 */
package com.paperskate3d.skate {

	import com.everydayflash.pv3d.modifiers.Bend;
	import flash.display.Bitmap;
	import org.papervision3d.core.proto.MaterialObject3D;
	import org.papervision3d.lights.PointLight3D;
	import org.papervision3d.materials.BitmapMaterial;
	import org.papervision3d.materials.ColorMaterial;
	import org.papervision3d.materials.shadematerials.FlatShadeMaterial;
	import org.papervision3d.materials.shadematerials.PhongMaterial;
	import org.papervision3d.objects.DisplayObject3D;
	import org.papervision3d.objects.primitives.Cylinder;
	import org.papervision3d.objects.primitives.Plane;
	
	public class SkateBoard extends DisplayObject3D {
		
		private var skate:DisplayObject3D;
		
		private var frontLeftWheel:Wheel;
		private var frontRightWheel:Wheel;
		private var backLeftWheel:Wheel;
		private var backRightWheel:Wheel;
		
		private var frontTruck:Truck;
		private var backTruck:Truck;
		
		public var deck:Deck;
		
		private var hiq:Boolean;

		private var truckHeight:Number = 35;
		private var wheelOffset:Number = 130;
		
		public function SkateBoard() {
			skate = new DisplayObject3D();
			addChild(skate);
			
			createWheels();
			createTrucks();
			createDeck();
			rotationX = -90;
			
			hiquality = false;
		}
		
		public function set hiquality(v:Boolean):void {
			hiq = v;
			frontTruck.hiquality = v;
			backTruck.hiquality = v;
			
			frontLeftWheel.hiquality = v;
			frontRightWheel.hiquality = v;
			backLeftWheel.hiquality = v;
			backRightWheel.hiquality = v;
			
			deck.hiquality = v;
		}
		
		public function get hiquality():Boolean {
			return hiq;
		}
		
		public function reset():void {
			x = y = z = 0;
			rotationX = -90;
			rotationY = 0;
			rotationZ = 0;
			internalRotationX = 0;
			internalRotationY = 0;
			internalRotationZ = 0;
		}

		private function createDeck():void {
			deck = new Deck();
			skate.addChild(deck);
		}
		
		private function createTrucks():void {
			frontTruck = new Truck();
			frontTruck.z = 34;
			frontTruck.y = wheelOffset;
			skate.addChild(frontTruck);
			
			backTruck = new Truck();
			backTruck.z = 34;
			backTruck.y = -wheelOffset;
			backTruck.rotationZ = 180;
			skate.addChild(backTruck);
		}
		
		private function createWheels():void {
			frontLeftWheel = new Wheel();
			frontLeftWheel.x = 50;
			frontLeftWheel.y = wheelOffset;
			frontLeftWheel.z = truckHeight;
			skate.addChild(frontLeftWheel);
			
			frontRightWheel = new Wheel();
			frontRightWheel.x = -50;
			frontRightWheel.y = wheelOffset;
			frontRightWheel.z = truckHeight;
			skate.addChild(frontRightWheel);
			
			backLeftWheel = new Wheel();
			backLeftWheel.x = 50;
			backLeftWheel.y = -wheelOffset;
			backLeftWheel.z = truckHeight;
			skate.addChild(backLeftWheel);
			
			backRightWheel = new Wheel();
			backRightWheel.x = -50;
			backRightWheel.y = -wheelOffset;
			backRightWheel.z = truckHeight;
			skate.addChild(backRightWheel);
		}
		
		public function move(speed:Number, situation:Object):void {
			
			frontLeftWheel.move(speed, situation.fl);
			frontRightWheel.move(speed, situation.fr);
			backLeftWheel.move(speed, situation.bl);
			backRightWheel.move(speed, situation.br);
			
			deck.move(speed);
		}
		
		public function get internalRotationZ():Number {
			return skate.rotationZ;
		}
		
		public function set internalRotationZ(r:Number):void {
			skate.rotationZ = r;
		}
		
		public function get internalRotationY():Number {
			return skate.rotationY;
		}
		
		public function set internalRotationY(r:Number):void {
			skate.rotationY = r;
		}
		
		public function get internalRotationX():Number {
			return skate.rotationX;
		}
		
		public function set internalRotationX(r:Number):void {
			skate.rotationX = r;
		}
	}
}












⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -