Section 1
//SkinController (away3d.animators.data.SkinController)
package away3d.animators.data {
import away3d.core.math.*;
import away3d.containers.*;
public class SkinController {
private var _sceneTransform:Matrix3D;
private var _sceneTransformDirty:Boolean;
public var name:String;
public var joint:ObjectContainer3D;
public var bindMatrix:Matrix3D;
public var skinVertices:Array;
public var inverseTransform:Matrix3D;
public function SkinController(){
_sceneTransform = new Matrix3D();
skinVertices = new Array();
super();
}
public function get sceneTransform():Matrix3D{
if (_sceneTransformDirty){
_sceneTransformDirty = false;
sceneTransform.multiply(joint.sceneTransform, bindMatrix);
sceneTransform.multiply(inverseTransform, sceneTransform);
};
return (_sceneTransform);
}
public function update():void{
var _local1:Bone;
var _local2:SkinVertex;
if (((!(joint)) || (_sceneTransformDirty))){
return;
};
_sceneTransformDirty = true;
for each (_local1 in joint.children) {
if (((_local1) && (_local1.controller))){
_local1.controller.update();
};
};
for each (_local2 in skinVertices) {
_local2.skinnedVertex._positionDirty = true;
};
}
}
}//package away3d.animators.data
Section 2
//SkinVertex (away3d.animators.data.SkinVertex)
package away3d.animators.data {
import away3d.core.math.*;
import away3d.core.base.*;
public class SkinVertex {
private var _i:int;
private var _position:Number3D;
public var baseVertex:Vertex;
public var skinnedVertex:Vertex;
public var weights:Array;
public var controllers:Array;
public function SkinVertex(_arg1:Vertex){
_position = new Number3D();
weights = [];
controllers = [];
super();
skinnedVertex = _arg1;
baseVertex = _arg1.clone();
}
public function update():void{
skinnedVertex.reset();
_i = weights.length;
while (_i--) {
_position.transform(baseVertex.position, (controllers[_i] as SkinController).sceneTransform);
_position.scale(_position, weights[_i]);
skinnedVertex.add(_position);
};
}
}
}//package away3d.animators.data
Section 3
//Animator (away3d.animators.Animator)
package away3d.animators {
import flash.display.*;
import flash.events.*;
import away3d.core.base.*;
import away3d.core.utils.*;
import flash.utils.*;
import away3d.events.*;
public class Animator extends EventDispatcher {
var _totalFrames:Number;// = 0
private var _broadcaster:Sprite;
private var _startTime:Number;
private var _startEvent:AnimatorEvent;
private var _stopEvent:AnimatorEvent;
private var _enterKeyFrameEvent:AnimatorEvent;
private var _cycleEvent:AnimatorEvent;
private var _isPlaying:Boolean;
private var _cycleNumber:int;
private var _oldProgress:Number;
private var _oldFrame:int;
protected var _progress:Number;// = 0
protected var _target:Object3D;
protected var _time:Number;
protected var _currentFrame:int;
protected var _fraction:Number;
protected var _invFraction:Number;
protected var ini:Init;
public var fps:Number;
public var loop:Boolean;
public var interpolate:Boolean;
public var delay:Number;
public function Animator(_arg1:Object3D=null, _arg2:Object=null){
_broadcaster = new Sprite();
super();
this.target = _arg1;
ini = Init.parse(_arg2);
progress = ini.getNumber("progress", 0);
fps = ini.getNumber("fps", getDefaultFps());
loop = ini.getBoolean("loop", true);
interpolate = ini.getBoolean("interpolate", true);
delay = ini.getNumber("delay", 0);
}
private function notifyStart():void{
if (!hasEventListener(AnimatorEvent.START)){
return;
};
if (!_startEvent){
_startEvent = new AnimatorEvent(AnimatorEvent.START, this);
};
dispatchEvent(_startEvent);
}
private function notifyStop():void{
if (!hasEventListener(AnimatorEvent.STOP)){
return;
};
if (!_stopEvent){
_stopEvent = new AnimatorEvent(AnimatorEvent.STOP, this);
};
dispatchEvent(_stopEvent);
}
private function notifyEnterKeyFrame():void{
if (!hasEventListener(AnimatorEvent.ENTER_KEY_FRAME)){
return;
};
if (!_enterKeyFrameEvent){
_enterKeyFrameEvent = new AnimatorEvent(AnimatorEvent.ENTER_KEY_FRAME, this);
};
dispatchEvent(_enterKeyFrameEvent);
}
private function notifyCycle():void{
if (!hasEventListener(AnimatorEvent.CYCLE)){
return;
};
if (!_cycleEvent){
_cycleEvent = new AnimatorEvent(AnimatorEvent.CYCLE, this);
};
dispatchEvent(_cycleEvent);
}
private function _onEnterFrame(_arg1:Event=null):void{
update((_startTime + (getTimer() / 1000)));
}
protected function getDefaultFps():Number{
return (25);
}
protected function updateTarget():void{
throw (new Error("Not implemented"));
}
protected function updateProgress(_arg1:Number):void{
if (_arg1 < 0){
if (loop){
_progress = ((_arg1 % 1) + 1);
} else {
_progress = 0;
};
} else {
if (_arg1 >= 1){
if (loop){
_progress = (_arg1 % 1);
} else {
_progress = 1;
};
} else {
_progress = _arg1;
};
};
if (_cycleNumber != int((_arg1 / _progress))){
if (!isNaN(_cycleNumber)){
notifyCycle();
};
_cycleNumber = int((_arg1 / _progress));
};
if (_isPlaying != !((_oldProgress == _progress))){
if (_isPlaying){
notifyStop();
} else {
notifyStart();
};
_isPlaying = !((_oldProgress == _progress));
};
_oldProgress = _progress;
_time = (_progress * length);
_currentFrame = int((_time * fps));
_fraction = ((_time * fps) - _currentFrame);
_invFraction = (1 - _fraction);
if (_oldFrame != _currentFrame){
_oldFrame = _currentFrame;
notifyEnterKeyFrame();
};
}
public function get progress():Number{
return (_progress);
}
public function set progress(_arg1:Number):void{
if (_progress == _arg1){
return;
};
updateProgress(_arg1);
}
public function get target():Object3D{
return (_target);
}
public function set target(_arg1:Object3D):void{
if (_target == _arg1){
return;
};
_target = _arg1;
addEventListener(AnimatorEvent.START, _target.onAnimatorStart);
addEventListener(AnimatorEvent.STOP, _target.onAnimatorStop);
updateTarget();
}
public function get length():Number{
return ((_totalFrames / fps));
}
public function set length(_arg1:Number):void{
fps = (_totalFrames / _arg1);
}
public function get totalFrames():Number{
return (_totalFrames);
}
public function get currentFrame():int{
return (_currentFrame);
}
public function get cycleNumber():int{
return (_cycleNumber);
}
public function get isPlaying():Boolean{
return (_isPlaying);
}
public function update(_arg1:Number):void{
progress = ((_arg1 - delay) / length);
}
public function stop():void{
_broadcaster.removeEventListener(Event.ENTER_FRAME, _onEnterFrame);
_onEnterFrame();
}
public function play():void{
_startTime = (((_progress * length) + delay) - (getTimer() / 1000));
_broadcaster.addEventListener(Event.ENTER_FRAME, _onEnterFrame);
}
public function gotoAndStop(_arg1:uint):void{
update((_arg1 / fps));
_broadcaster.removeEventListener(Event.ENTER_FRAME, _onEnterFrame);
}
public function gotoAndPlay(_arg1:uint):void{
update((_arg1 / fps));
_startTime = (((_progress * length) + delay) - (getTimer() / 1000));
_broadcaster.addEventListener(Event.ENTER_FRAME, _onEnterFrame);
}
public function clone(_arg1:Animator=null):Animator{
var _local2:Animator = (((_arg1 as Animator)) || (new Animator()));
_local2.progress = _progress;
_local2.fps = fps;
_local2.loop = loop;
_local2.interpolate = interpolate;
_local2.delay = delay;
return (_local2);
}
public function addOnCycle(_arg1:Function):void{
addEventListener(AnimatorEvent.CYCLE, _arg1, false, 0, false);
}
public function removeOnCycle(_arg1:Function):void{
removeEventListener(AnimatorEvent.CYCLE, _arg1, false);
}
public function addOnEnterKeyFrame(_arg1:Function):void{
addEventListener(AnimatorEvent.ENTER_KEY_FRAME, _arg1, false, 0, false);
}
public function removeOnEnterKeyFrame(_arg1:Function):void{
removeEventListener(AnimatorEvent.ENTER_KEY_FRAME, _arg1, false);
}
}
}//package away3d.animators
Section 4
//ConvexBlock (away3d.blockers.ConvexBlock)
package away3d.blockers {
import away3d.core.base.*;
import away3d.core.project.*;
public class ConvexBlock extends Object3D {
public var debug:Boolean;
public var vertices:Array;
public function ConvexBlock(_arg1:Array, _arg2:Object=null){
vertices = [];
super(_arg2);
this.vertices = _arg1;
debug = ini.getBoolean("debug", false);
projectorType = ProjectorType.CONVEX_BLOCK;
}
}
}//package away3d.blockers
Section 5
//AbstractLens (away3d.cameras.lenses.AbstractLens)
package away3d.cameras.lenses {
import away3d.core.math.*;
import away3d.core.base.*;
import away3d.core.utils.*;
import away3d.containers.*;
import away3d.core.geom.*;
import away3d.cameras.*;
import away3d.core.clip.*;
public class AbstractLens {
protected const toRADIANS:Number = 0.0174532925199433;
protected const toDEGREES:Number = 57.2957795130823;
protected var _view:View3D;
protected var _drawPrimitiveStore:DrawPrimitiveStore;
protected var _cameraVarsStore:CameraVarsStore;
protected var _camera:Camera3D;
protected var _clipping:Clipping;
protected var _clipTop:Number;
protected var _clipBottom:Number;
protected var _clipLeft:Number;
protected var _clipRight:Number;
protected var _clipHeight:Number;
protected var _clipWidth:Number;
protected var _focusOverZoom:Number;
protected var _zoom2:Number;
protected var _frustum:Frustum;
protected var _near:Number;
protected var _far:Number;
protected var _plane:Plane3D;
protected var _len:Number;
protected var _vertex:Vertex;
protected var _sx:Number;
protected var _sy:Number;
protected var _sz:Number;
protected var _sw:Number;
protected var _vx:Number;
protected var _vy:Number;
protected var _vz:Number;
protected var _scz:Number;
protected var _persp:Number;
protected var classification:int;
protected var viewTransform:Matrix3D;
protected var view:Matrix3D;
public function AbstractLens(){
view = new Matrix3D();
super();
}
function get near():Number{
return (_near);
}
function get far():Number{
return (_far);
}
function setView(_arg1:View3D):void{
_view = _arg1;
_drawPrimitiveStore = _arg1.drawPrimitiveStore;
_cameraVarsStore = _arg1.cameraVarsStore;
_camera = _arg1.camera;
_clipping = _arg1.screenClipping;
_clipTop = _clipping.minY;
_clipBottom = _clipping.maxY;
_clipLeft = _clipping.minX;
_clipRight = _clipping.maxX;
_clipHeight = (_clipBottom - _clipTop);
_clipWidth = (_clipRight - _clipLeft);
_far = _clipping.maxZ;
}
function getFrustum(_arg1:Object3D, _arg2:Matrix3D):Frustum{
throw (new Error("Not implemented"));
}
function getFOV():Number{
throw (new Error("Not implemented"));
}
function getZoom():Number{
throw (new Error("Not implemented"));
}
function getPerspective(_arg1:Number):Number{
throw (new Error("Not implemented"));
}
function project(_arg1:Matrix3D, _arg2:Array, _arg3:Array):void{
throw (new Error("Not implemented"));
}
}
}//package away3d.cameras.lenses
Section 6
//PerspectiveLens (away3d.cameras.lenses.PerspectiveLens)
package away3d.cameras.lenses {
import away3d.core.math.*;
import away3d.core.base.*;
import away3d.containers.*;
import away3d.core.geom.*;
import away3d.core.clip.*;
public class PerspectiveLens extends AbstractLens {
private var _length:int;
override function setView(_arg1:View3D):void{
super.setView(_arg1);
if (_clipping.minZ == -(Infinity)){
_near = (_camera.focus / 2);
} else {
_near = _clipping.minZ;
};
}
override function getFrustum(_arg1:Object3D, _arg2:Matrix3D):Frustum{
_frustum = _cameraVarsStore.createFrustum(_arg1);
_focusOverZoom = (_camera.focus / _camera.zoom);
_zoom2 = (_camera.zoom * _camera.zoom);
_plane = _frustum.planes[Frustum.NEAR];
_plane.a = 0;
_plane.b = 0;
_plane.c = 1;
_plane.d = -(_near);
_plane.transform(_arg2);
_plane = _frustum.planes[Frustum.FAR];
_plane.a = 0;
_plane.b = 0;
_plane.c = -1;
_plane.d = _far;
_plane.transform(_arg2);
_plane = _frustum.planes[Frustum.LEFT];
_plane.a = (_clipHeight * _focusOverZoom);
_plane.b = 0;
_plane.c = ((-(_clipHeight) * _clipLeft) / _zoom2);
_plane.d = 0;
_plane.transform(_arg2);
_plane = _frustum.planes[Frustum.RIGHT];
_plane.a = (-(_clipHeight) * _focusOverZoom);
_plane.b = 0;
_plane.c = ((_clipHeight * _clipRight) / _zoom2);
_plane.d = 0;
_plane.transform(_arg2);
_plane = _frustum.planes[Frustum.TOP];
_plane.a = 0;
_plane.b = (_clipWidth * _focusOverZoom);
_plane.c = ((-(_clipWidth) * _clipTop) / _zoom2);
_plane.d = 0;
_plane.transform(_arg2);
_plane = _frustum.planes[Frustum.BOTTOM];
_plane.a = 0;
_plane.b = (-(_clipWidth) * _focusOverZoom);
_plane.c = ((_clipWidth * _clipBottom) / _zoom2);
_plane.d = 0;
_plane.transform(_arg2);
return (_frustum);
}
override function getFOV():Number{
return ((Math.atan2(_clipHeight, ((_camera.focus * _camera.zoom) + ((_clipTop * _clipBottom) / (_camera.focus * _camera.zoom)))) * toDEGREES));
}
override function getZoom():Number{
var _local1:Number = (_clipHeight / Math.tan((_camera.fov * toRADIANS)));
return (((_local1 + Math.sqrt((Math.pow(_local1, 2) - (((4 * _clipTop) * _clipBottom) / _camera.zoom)))) / (2 * _camera.focus)));
}
override function getPerspective(_arg1:Number):Number{
return (((_camera.focus * _camera.zoom) / _arg1));
}
override function project(_arg1:Matrix3D, _arg2:Array, _arg3:Array):void{
_length = 0;
for each (_vertex in _arg2) {
_vx = _vertex.x;
_vy = _vertex.y;
_vz = _vertex.z;
_sz = ((((_vx * _arg1.szx) + (_vy * _arg1.szy)) + (_vz * _arg1.szz)) + _arg1.tz);
if (isNaN(_sz)){
throw (new Error("isNaN(sz)"));
};
if ((((_sz < _near)) && ((_clipping is RectangleClipping)))){
_arg3[_length] = null;
_arg3[(_length + 1)] = null;
_arg3[(_length + 2)] = null;
_length = (_length + 3);
} else {
_persp = ((_camera.focus * _camera.zoom) / _sz);
_arg3[_length] = (((((_vx * _arg1.sxx) + (_vy * _arg1.sxy)) + (_vz * _arg1.sxz)) + _arg1.tx) * _persp);
_arg3[(_length + 1)] = (((((_vx * _arg1.syx) + (_vy * _arg1.syy)) + (_vz * _arg1.syz)) + _arg1.ty) * _persp);
_arg3[(_length + 2)] = _sz;
_length = (_length + 3);
};
};
}
}
}//package away3d.cameras.lenses
Section 7
//ZoomFocusLens (away3d.cameras.lenses.ZoomFocusLens)
package away3d.cameras.lenses {
import away3d.core.math.*;
import away3d.core.base.*;
import away3d.containers.*;
import away3d.core.geom.*;
import away3d.core.clip.*;
public class ZoomFocusLens extends AbstractLens {
private var _length:int;
override function setView(_arg1:View3D):void{
super.setView(_arg1);
if (_clipping.minZ == -(Infinity)){
_near = (-(_camera.focus) / 2);
} else {
_near = _clipping.minZ;
};
}
override function getFrustum(_arg1:Object3D, _arg2:Matrix3D):Frustum{
_frustum = _cameraVarsStore.createFrustum(_arg1);
_focusOverZoom = (_camera.focus / _camera.zoom);
_zoom2 = (_camera.zoom * _camera.zoom);
_plane = _frustum.planes[Frustum.NEAR];
_plane.a = 0;
_plane.b = 0;
_plane.c = 1;
_plane.d = -(_near);
_plane.transform(_arg2);
_plane = _frustum.planes[Frustum.FAR];
_plane.a = 0;
_plane.b = 0;
_plane.c = -1;
_plane.d = _far;
_plane.transform(_arg2);
_plane = _frustum.planes[Frustum.LEFT];
_plane.a = (_clipHeight * _focusOverZoom);
_plane.b = 0;
_plane.c = ((-(_clipHeight) * _clipLeft) / _zoom2);
_plane.d = (_plane.c * _camera.focus);
_plane.transform(_arg2);
_plane = _frustum.planes[Frustum.RIGHT];
_plane.a = (-(_clipHeight) * _focusOverZoom);
_plane.b = 0;
_plane.c = ((_clipHeight * _clipRight) / _zoom2);
_plane.d = (_plane.c * _camera.focus);
_plane.transform(_arg2);
_plane = _frustum.planes[Frustum.TOP];
_plane.a = 0;
_plane.b = (_clipWidth * _focusOverZoom);
_plane.c = ((-(_clipWidth) * _clipTop) / _zoom2);
_plane.d = (_plane.c * _camera.focus);
_plane.transform(_arg2);
_plane = _frustum.planes[Frustum.BOTTOM];
_plane.a = 0;
_plane.b = (-(_clipWidth) * _focusOverZoom);
_plane.c = ((_clipWidth * _clipBottom) / _zoom2);
_plane.d = (_plane.c * _camera.focus);
_plane.transform(_arg2);
return (_frustum);
}
override function getFOV():Number{
return ((Math.atan2(_clipHeight, ((_camera.focus * _camera.zoom) + ((_clipTop * _clipBottom) / (_camera.focus * _camera.zoom)))) * toDEGREES));
}
override function getZoom():Number{
var _local1:Number = (_clipHeight / Math.tan((_camera.fov * toRADIANS)));
return (((_local1 + Math.sqrt((Math.pow(_local1, 2) - (((4 * _clipTop) * _clipBottom) / _camera.zoom)))) / (2 * _camera.focus)));
}
override function getPerspective(_arg1:Number):Number{
return ((_camera.zoom / (1 + (_arg1 / _camera.focus))));
}
override function project(_arg1:Matrix3D, _arg2:Array, _arg3:Array):void{
_length = 0;
for each (_vertex in _arg2) {
_vx = _vertex.x;
_vy = _vertex.y;
_vz = _vertex.z;
_sz = ((((_vx * _arg1.szx) + (_vy * _arg1.szy)) + (_vz * _arg1.szz)) + _arg1.tz);
if (isNaN(_sz)){
throw (new Error("isNaN(sz)"));
};
if ((((_sz < _near)) && ((_clipping is RectangleClipping)))){
_arg3[_length] = null;
_arg3[(_length + 1)] = null;
_arg3[(_length + 2)] = null;
_length = (_length + 3);
} else {
_persp = (_camera.zoom / (1 + (_sz / _camera.focus)));
_arg3[_length] = (((((_vx * _arg1.sxx) + (_vy * _arg1.sxy)) + (_vz * _arg1.sxz)) + _arg1.tx) * _persp);
_arg3[(_length + 1)] = (((((_vx * _arg1.syx) + (_vy * _arg1.syy)) + (_vz * _arg1.syz)) + _arg1.ty) * _persp);
_arg3[(_length + 2)] = _sz;
_length = (_length + 3);
};
};
}
}
}//package away3d.cameras.lenses
Section 8
//Camera3D (away3d.cameras.Camera3D)
package away3d.cameras {
import away3d.core.math.*;
import away3d.core.base.*;
import away3d.core.utils.*;
import away3d.core.draw.*;
import away3d.containers.*;
import away3d.core.clip.*;
import away3d.events.*;
import away3d.cameras.lenses.*;
public class Camera3D extends Object3D {
protected const toRADIANS:Number = 0.0174532925199433;
protected const toDEGREES:Number = 57.2957795130823;
private var _fovDirty:Boolean;
private var _zoomDirty:Boolean;
private var _aperture:Number;// = 22
private var _dof:Boolean;// = false
private var _flipY:Matrix3D;
private var _focus:Number;
private var _zoom:Number;// = 10
private var _lens:AbstractLens;
private var _fov:Number;// = 0
private var _clipping:Clipping;
private var _clipTop:Number;
private var _clipBottom:Number;
private var _clipLeft:Number;
private var _clipRight:Number;
private var _viewMatrix:Matrix3D;
private var _view:View3D;
private var _drawPrimitiveStore:DrawPrimitiveStore;
private var _cameraVarsStore:CameraVarsStore;
private var _vertices:Array;
private var _screenVertices:Array;
private var _cameraupdated:CameraEvent;
public var invViewMatrix:Matrix3D;
public var fixedZoom:Boolean;
public var maxblur:Number;// = 150
public var doflevels:Number;// = 16
public function Camera3D(_arg1:Object=null){
_flipY = new Matrix3D();
_viewMatrix = new Matrix3D();
_vertices = new Array();
_screenVertices = new Array();
invViewMatrix = new Matrix3D();
super(_arg1);
fov = ini.getNumber("fov", _fov);
focus = ini.getNumber("focus", 100);
zoom = ini.getNumber("zoom", _zoom);
fixedZoom = ini.getBoolean("fixedZoom", true);
lens = (((ini.getObject("lens", AbstractLens) as AbstractLens)) || (new ZoomFocusLens()));
aperture = ini.getNumber("aperture", 22);
maxblur = ini.getNumber("maxblur", 150);
doflevels = ini.getNumber("doflevels", 16);
dof = ini.getBoolean("dof", false);
var _local2:Number3D = ini.getPosition("lookat");
_flipY.syy = -1;
if (_local2){
lookAt(_local2);
};
}
private function notifyCameraUpdate():void{
if (!hasEventListener(CameraEvent.CAMERA_UPDATED)){
return;
};
if (_cameraupdated == null){
_cameraupdated = new CameraEvent(CameraEvent.CAMERA_UPDATED, this);
};
dispatchEvent(_cameraupdated);
}
public function get aperture():Number{
return (_aperture);
}
public function set aperture(_arg1:Number):void{
_aperture = _arg1;
DofCache.aperture = _aperture;
}
public function get dof():Boolean{
return (_dof);
}
public function set dof(_arg1:Boolean):void{
_dof = _arg1;
if (_dof){
enableDof();
} else {
disableDof();
};
}
public function get focus():Number{
return (_focus);
}
public function set focus(_arg1:Number):void{
if (_focus == _arg1){
return;
};
_focus = _arg1;
DofCache.focus = _focus;
_zoomDirty = false;
_fovDirty = true;
notifyCameraUpdate();
}
public function get zoom():Number{
return (_zoom);
}
public function set zoom(_arg1:Number):void{
if (_zoom == _arg1){
return;
};
_zoom = _arg1;
_zoomDirty = false;
_fovDirty = true;
notifyCameraUpdate();
}
public function get lens():AbstractLens{
return (_lens);
}
public function set lens(_arg1:AbstractLens):void{
if (_lens == _arg1){
return;
};
_lens = _arg1;
notifyCameraUpdate();
}
public function get fov():Number{
return (_fov);
}
public function set fov(_arg1:Number):void{
if (_fov == _arg1){
return;
};
_fov = _arg1;
_fovDirty = false;
_zoomDirty = true;
notifyCameraUpdate();
}
public function get view():View3D{
return (_view);
}
public function set view(_arg1:View3D):void{
if (_view == _arg1){
return;
};
_view = _arg1;
_drawPrimitiveStore = _arg1.drawPrimitiveStore;
_cameraVarsStore = _arg1.cameraVarsStore;
}
public function get viewMatrix():Matrix3D{
invViewMatrix.multiply(sceneTransform, _flipY);
_viewMatrix.inverse(invViewMatrix);
return (_viewMatrix);
}
public function enableDof():void{
DofCache.doflevels = doflevels;
DofCache.aperture = aperture;
DofCache.maxblur = maxblur;
DofCache.focus = focus;
DofCache.resetDof(true);
}
public function disableDof():void{
DofCache.resetDof(false);
}
public function screen(_arg1:Object3D, _arg2:Vertex=null):ScreenVertex{
update();
if (_arg2 == null){
_vertices = _arg1.center;
} else {
_vertices[0] = _arg2;
};
_cameraVarsStore.createViewTransform(_arg1).multiply(viewMatrix, _arg1.sceneTransform);
_screenVertices.length = 0;
_lens.project(_cameraVarsStore.viewTransformDictionary[_arg1], _vertices, _screenVertices);
return (new ScreenVertex(_screenVertices[0], _screenVertices[1], _screenVertices[2]));
}
public function update():void{
_view.updateScreenClipping();
_clipping = _view.screenClipping;
if (((((((!((_clipTop == _clipping.minY))) || (!((_clipBottom == _clipping.maxY))))) || (!((_clipLeft == _clipping.minX))))) || (!((_clipRight == _clipping.maxX))))){
if (((!(_fovDirty)) && (!(_zoomDirty)))){
if (fixedZoom){
_fovDirty = true;
} else {
_zoomDirty = true;
};
};
_clipTop = _clipping.minY;
_clipBottom = _clipping.maxY;
_clipLeft = _clipping.minX;
_clipRight = _clipping.maxX;
};
lens.setView(_view);
if (_fovDirty){
_fovDirty = false;
_fov = lens.getFOV();
};
if (_zoomDirty){
_zoomDirty = false;
_zoom = lens.getZoom();
};
}
public function tilt(_arg1:Number):void{
super.pitch(_arg1);
}
public function pan(_arg1:Number):void{
super.yaw(_arg1);
}
override public function clone(_arg1:Object3D=null):Object3D{
var _local2:Camera3D = (((_arg1 as Camera3D)) || (new Camera3D()));
super.clone(_local2);
_local2.zoom = zoom;
_local2.focus = focus;
_local2.lens = lens;
return (_local2);
}
public function unproject(_arg1:Number, _arg2:Number):Number3D{
var _local3:Number = ((focus * zoom) / focus);
var _local4:Number3D = new Number3D((_arg1 / _local3), (-(_arg2) / _local3), focus);
transform.multiplyVector3x3(_local4);
return (_local4);
}
public function addOnCameraUpdate(_arg1:Function):void{
addEventListener(CameraEvent.CAMERA_UPDATED, _arg1, false, 0, false);
}
public function removeOnCameraUpdate(_arg1:Function):void{
removeEventListener(CameraEvent.CAMERA_UPDATED, _arg1, false);
}
}
}//package away3d.cameras
Section 9
//HoverCamera3D (away3d.cameras.HoverCamera3D)
package away3d.cameras {
public class HoverCamera3D extends TargetCamera3D {
var _currentPanAngle:Number;// = 0
var _currentTiltAngle:Number;// = 90
public var panAngle:Number;// = 0
public var tiltAngle:Number;// = 90
public var distance:Number;// = 800
public var minTiltAngle:Number;// = -90
public var maxTiltAngle:Number;// = 90
public var steps:Number;// = 8
public var yfactor:Number;// = 1
public var wrapPanAngle:Boolean;// = false
public function HoverCamera3D(_arg1:Object=null){
super(_arg1);
yfactor = ini.getNumber("yfactor", yfactor);
distance = ini.getNumber("distance", distance);
wrapPanAngle = ini.getBoolean("wrapPanAngle", false);
panAngle = ini.getNumber("panAngle", panAngle);
tiltAngle = ini.getNumber("tiltAngle", tiltAngle);
minTiltAngle = ini.getNumber("minTiltAngle", minTiltAngle);
maxTiltAngle = ini.getNumber("maxTiltAngle", maxTiltAngle);
steps = ini.getNumber("steps", steps);
moveCamera();
}
public function hover(_arg1:Boolean=false):Boolean{
if (((!((tiltAngle == _currentTiltAngle))) || (!((panAngle == _currentPanAngle))))){
tiltAngle = Math.max(minTiltAngle, Math.min(maxTiltAngle, tiltAngle));
if (wrapPanAngle){
if (panAngle < 0){
panAngle = ((panAngle % 360) + 360);
} else {
panAngle = (panAngle % 360);
};
if ((panAngle - _currentPanAngle) < -180){
panAngle = (panAngle + 360);
} else {
if ((panAngle - _currentPanAngle) > 180){
panAngle = (panAngle - 360);
};
};
};
if (_arg1){
_currentTiltAngle = tiltAngle;
_currentPanAngle = panAngle;
} else {
_currentTiltAngle = (_currentTiltAngle + ((tiltAngle - _currentTiltAngle) / (steps + 1)));
_currentPanAngle = (_currentPanAngle + ((panAngle - _currentPanAngle) / (steps + 1)));
};
if ((((Math.abs((tiltAngle - _currentTiltAngle)) < 0.01)) && ((Math.abs((panAngle - _currentPanAngle)) < 0.01)))){
_currentTiltAngle = tiltAngle;
_currentPanAngle = panAngle;
};
};
var _local2:Number = (target.x + ((distance * Math.sin((_currentPanAngle * toRADIANS))) * Math.cos((_currentTiltAngle * toRADIANS))));
var _local3:Number = (target.z + ((distance * Math.cos((_currentPanAngle * toRADIANS))) * Math.cos((_currentTiltAngle * toRADIANS))));
var _local4:Number = (target.y + ((distance * Math.sin((_currentTiltAngle * toRADIANS))) * yfactor));
if ((((((x == _local2)) && ((y == _local4)))) && ((z == _local3)))){
return (false);
};
x = _local2;
y = _local4;
z = _local3;
return (true);
}
public function moveCamera():Boolean{
var _local1:Number = ((distance * Math.sin((panAngle * toRADIANS))) * Math.cos((tiltAngle * toRADIANS)));
var _local2:Number = ((distance * Math.cos((panAngle * toRADIANS))) * Math.cos((tiltAngle * toRADIANS)));
var _local3:Number = ((distance * Math.sin((tiltAngle * toRADIANS))) * yfactor);
_local1 = (_local1 + target.x);
_local3 = (_local3 + target.y);
_local2 = (_local2 + target.z);
if ((((((x == _local1)) && ((y == _local3)))) && ((z == _local2)))){
return (false);
};
x = _local1;
y = _local3;
z = _local2;
return (true);
}
}
}//package away3d.cameras
Section 10
//TargetCamera3D (away3d.cameras.TargetCamera3D)
package away3d.cameras {
import away3d.core.math.*;
import away3d.core.base.*;
import away3d.containers.*;
public class TargetCamera3D extends Camera3D {
public var target:Object3D;
public function TargetCamera3D(_arg1:Object=null){
super(_arg1);
target = ((ini.getObject3D("target")) || (new Object3D()));
}
override public function get viewMatrix():Matrix3D{
if (target != null){
lookAt((target.scene) ? target.scenePosition : target.position);
};
return (super.viewMatrix);
}
override public function set parent(_arg1:ObjectContainer3D):void{
if (_arg1 != null){
throw (new Error("TargetCamera can't be parented"));
};
}
}
}//package away3d.cameras
Section 11
//Bone (away3d.containers.Bone)
package away3d.containers {
import away3d.core.math.*;
import away3d.core.base.*;
import away3d.animators.data.*;
public class Bone extends ObjectContainer3D {
public var joint:ObjectContainer3D;
public var controller:SkinController;
public var boneId:String;
public function Bone(_arg1:Object=null, ... _args):void{
super(_arg1);
addChild((joint = new ObjectContainer3D()));
}
public function get jointRotationX():Number{
return (joint.rotationX);
}
public function set jointRotationX(_arg1:Number):void{
joint.rotationX = _arg1;
if (controller){
controller.update();
};
}
public function get jointRotationY():Number{
return (joint.rotationY);
}
public function set jointRotationY(_arg1:Number):void{
joint.rotationY = _arg1;
if (controller){
controller.update();
};
}
public function get jointRotationZ():Number{
return (joint.rotationZ);
}
public function set jointRotationZ(_arg1:Number):void{
joint.rotationZ = _arg1;
if (controller){
controller.update();
};
}
public function get jointScaleX():Number{
return (joint.scaleX);
}
public function set jointScaleX(_arg1:Number):void{
joint.scaleX = _arg1;
if (controller){
controller.update();
};
}
public function get jointScaleY():Number{
return (joint.scaleY);
}
public function set jointScaleY(_arg1:Number):void{
joint.scaleY = _arg1;
if (controller){
controller.update();
};
}
public function get jointScaleZ():Number{
return (joint.scaleZ);
}
public function set jointScaleZ(_arg1:Number):void{
joint.scaleZ = _arg1;
if (controller){
controller.update();
};
}
override public function set x(_arg1:Number):void{
super.x = _arg1;
if (controller){
controller.update();
};
}
override public function set y(_arg1:Number):void{
super.y = _arg1;
if (controller){
controller.update();
};
}
override public function set z(_arg1:Number):void{
super.z = _arg1;
if (controller){
controller.update();
};
}
override public function set rotationX(_arg1:Number):void{
super.rotationX = _arg1;
if (controller){
controller.update();
};
}
override public function set rotationY(_arg1:Number):void{
super.rotationY = _arg1;
if (controller){
controller.update();
};
}
override public function set rotationZ(_arg1:Number):void{
super.rotationZ = _arg1;
if (controller){
controller.update();
};
}
override public function set scaleX(_arg1:Number):void{
super.scaleX = _arg1;
if (controller){
controller.update();
};
}
override public function set scaleY(_arg1:Number):void{
super.scaleY = _arg1;
if (controller){
controller.update();
};
}
override public function set scaleZ(_arg1:Number):void{
super.scaleZ = _arg1;
if (controller){
controller.update();
};
}
override public function set transform(_arg1:Matrix3D):void{
super.transform = _arg1;
if (controller){
controller.update();
};
}
override public function clone(_arg1:Object3D=null):Object3D{
var _local2:Bone = (((_arg1 as Bone)) || (new Bone()));
super.clone(_local2);
_local2.joint = _local2.children[0];
return (_local2);
}
override public function cloneAll(_arg1:Object3D=null):Object3D{
var _local2:Bone = (((_arg1 as Bone)) || (new Bone()));
_local2.removeChild(joint);
super.cloneAll(_local2);
_local2.boneId = boneId;
_local2.joint = _local2.children[0];
return (_local2);
}
}
}//package away3d.containers
Section 12
//ILODObject (away3d.containers.ILODObject)
package away3d.containers {
import away3d.cameras.*;
public interface ILODObject {
function matchLOD(_arg1:Camera3D):Boolean;
}
}//package away3d.containers
Section 13
//IPhysicsScene (away3d.containers.IPhysicsScene)
package away3d.containers {
public interface IPhysicsScene {
function updateTime(_arg1:int):void;
}
}//package away3d.containers
Section 14
//ObjectContainer3D (away3d.containers.ObjectContainer3D)
package away3d.containers {
import away3d.core.math.*;
import away3d.core.base.*;
import away3d.core.utils.*;
import away3d.loaders.data.*;
import away3d.events.*;
import away3d.loaders.utils.*;
import away3d.lights.*;
import away3d.core.traverse.*;
import away3d.animators.data.*;
import away3d.core.project.*;
public class ObjectContainer3D extends Mesh {
private var _children:Array;
private var _lights:Array;
private var _polyCount:int;
public function ObjectContainer3D(... _args){
var _local2:Object;
var _local4:Object;
var _local5:Object3D;
_children = [];
_lights = [];
var _local3:Array = [];
for each (_local4 in _args) {
if ((_local4 is Object3D)){
_local3.push(_local4);
} else {
_local2 = _local4;
};
};
super(_local2);
projectorType = ProjectorType.OBJECT_CONTAINER;
for each (_local5 in _local3) {
addChild(_local5);
};
}
function internalAddChild(_arg1:Object3D):void{
_children.push(_arg1);
_arg1.addOnTransformChange(onChildChange);
_arg1.addOnDimensionsChange(onChildChange);
notifyDimensionsChange();
if (((_session) && (!(_arg1.ownCanvas)))){
session.internalAddOwnSession(_arg1);
};
_sessionDirty = true;
}
function internalRemoveChild(_arg1:Object3D):void{
var _local2:int = children.indexOf(_arg1);
if (_local2 == -1){
return;
};
_arg1.removeOnTransformChange(onChildChange);
_arg1.removeOnDimensionsChange(onChildChange);
_children.splice(_local2, 1);
notifyDimensionsChange();
if (((session) && (!(_arg1.ownCanvas)))){
session.internalRemoveOwnSession(_arg1);
};
_sessionDirty = true;
}
function incrementPolyCount(_arg1:int):void{
_polyCount = (_polyCount + _arg1);
if (this.parent){
parent.incrementPolyCount(_arg1);
};
}
private function onChildChange(_arg1:Object3DEvent):void{
notifyDimensionsChange();
}
private function updatePolyCount(_arg1:Object3D, _arg2:Boolean=true):void{
var _local4:int;
var _local3:int = (_arg2) ? 1 : -1;
if ((_arg1 is Mesh)){
_local4 = (_local3 * Mesh(_arg1).elements.length);
} else {
if ((_arg1 is ObjectContainer3D)){
_local4 = (_local3 * ObjectContainer3D(_arg1).polyCount);
};
};
incrementPolyCount(_local4);
}
override protected function updateDimensions():void{
var _local1:Array;
var _local2:Number;
var _local3:Number;
var _local4:Number3D;
var _local5:Object3D;
_local1 = _children.concat();
if (_local1.length){
if (_scaleX < 0){
_boundingScale = -(_scaleX);
} else {
_boundingScale = _scaleX;
};
if ((((_scaleY < 0)) && ((_boundingScale < -(_scaleY))))){
_boundingScale = -(_scaleY);
} else {
if (_boundingScale < _scaleY){
_boundingScale = _scaleY;
};
};
if ((((_scaleZ < 0)) && ((_boundingScale < -(_scaleZ))))){
_boundingScale = -(_scaleZ);
} else {
if (_boundingScale < _scaleZ){
_boundingScale = _scaleZ;
};
};
_local2 = 0;
_local4 = new Number3D();
for each (_local5 in _local1) {
_local4.sub(_local5.position, _pivotPoint);
_local3 = (_local4.modulo + _local5.parentBoundingRadius);
if (_local2 < _local3){
_local2 = _local3;
};
};
_boundingRadius = _local2;
_local1.sortOn("parentmaxX", (Array.DESCENDING | Array.NUMERIC));
_maxX = _local1[0].parentmaxX;
_local1.sortOn("parentminX", Array.NUMERIC);
_minX = _local1[0].parentminX;
_local1.sortOn("parentmaxY", (Array.DESCENDING | Array.NUMERIC));
_maxY = _local1[0].parentmaxY;
_local1.sortOn("parentminY", Array.NUMERIC);
_minY = _local1[0].parentminY;
_local1.sortOn("parentmaxZ", (Array.DESCENDING | Array.NUMERIC));
_maxZ = _local1[0].parentmaxZ;
_local1.sortOn("parentminZ", Array.NUMERIC);
_minZ = _local1[0].parentminZ;
};
super.updateDimensions();
}
public function get children():Array{
return (_children);
}
public function get lights():Array{
return (_lights);
}
public function get polyCount():int{
return (_polyCount);
}
public function addChildren(... _args):void{
var _local2:Object3D;
for each (_local2 in _args) {
addChild(_local2);
};
}
public function addChild(_arg1:Object3D):void{
if (_arg1 == null){
throw (new Error("ObjectContainer3D.addChild(null)"));
};
updatePolyCount(_arg1);
_arg1.parent = this;
}
public function removeChild(_arg1:Object3D):void{
if (_arg1 == null){
throw (new Error("ObjectContainer3D.removeChild(null)"));
};
if (_arg1.parent != this){
return;
};
updatePolyCount(_arg1, false);
_arg1.parent = null;
}
public function addLight(_arg1:AbstractLight):void{
if (_arg1 == null){
throw (new Error("ObjectContainer3D.addLight(null)"));
};
_lights.push(_arg1);
_arg1.parent = this;
}
public function removeLight(_arg1:AbstractLight):void{
if (_arg1 == null){
throw (new Error("ObjectContainer3D.removeLight(null)"));
};
if (_arg1.parent != this){
return;
};
var _local2:int = _lights.indexOf(_arg1);
if (_local2 == -1){
return;
};
_lights.splice(_local2, 1);
_arg1.parent = null;
}
public function getChildByName(_arg1:String):Object3D{
var _local2:Object3D;
var _local3:Object3D;
for each (_local3 in children) {
if (_local3.name){
if (_local3.name == _arg1){
return (_local3);
};
};
if ((_local3 is ObjectContainer3D)){
_local2 = (_local3 as ObjectContainer3D).getChildByName(_arg1);
if (_local2){
return (_local2);
};
};
};
return (null);
}
public function getBoneByName(_arg1:String):Bone{
var _local2:Bone;
var _local3:Object3D;
for each (_local3 in children) {
if ((_local3 is Bone)){
_local2 = (_local3 as Bone);
if (_local2.name){
if (_local2.name == _arg1){
return (_local2);
};
};
if (_local2.boneId){
if (_local2.boneId == _arg1){
return (_local2);
};
};
};
if ((_local3 is ObjectContainer3D)){
_local2 = (_local3 as ObjectContainer3D).getBoneByName(_arg1);
if (_local2){
return (_local2);
};
};
};
return (null);
}
public function removeChildByName(_arg1:String):void{
removeChild(getChildByName(_arg1));
}
override public function traverse(_arg1:Traverser):void{
var _local2:Object3D;
if (_arg1.match(this)){
_arg1.enter(this);
_arg1.apply(this);
for each (_local2 in children) {
_local2.traverse(_arg1);
};
_arg1.leave(this);
};
}
public function centerMeshes():void{
var _local1:Object3D;
for each (_local1 in children) {
_local1.centerPivot();
};
}
override public function centerPivot():void{
var _local1:Object3D;
for each (_local1 in children) {
_local1.centerPivot();
};
super.centerPivot();
}
override public function applyRotations():void{
var _local1:Number;
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local16:Object3D;
var _local6:Number = (Math.PI / 180);
var _local7:Number = (rotationX * _local6);
var _local8:Number = (rotationY * _local6);
var _local9:Number = (rotationZ * _local6);
var _local10:Number = Math.sin(_local7);
var _local11:Number = Math.cos(_local7);
var _local12:Number = Math.sin(_local8);
var _local13:Number = Math.cos(_local8);
var _local14:Number = Math.sin(_local9);
var _local15:Number = Math.cos(_local9);
for each (_local16 in children) {
_local1 = _local16.x;
_local2 = _local16.y;
_local3 = _local16.z;
_local5 = _local2;
_local2 = ((_local5 * _local11) + (_local3 * -(_local10)));
_local3 = ((_local5 * _local10) + (_local3 * _local11));
_local4 = _local1;
_local1 = ((_local4 * _local13) + (_local3 * _local12));
_local3 = ((_local4 * -(_local12)) + (_local3 * _local13));
_local4 = _local1;
_local1 = ((_local4 * _local15) + (_local2 * -(_local14)));
_local2 = ((_local4 * _local14) + (_local2 * _local15));
_local16.moveTo(_local1, _local2, _local3);
};
rotationX = 0;
rotationY = 0;
rotationZ = 0;
}
override public function applyPosition(_arg1:Number, _arg2:Number, _arg3:Number):void{
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Object3D;
var _local8:Number3D;
for each (_local7 in children) {
_local4 = _local7.x;
_local5 = _local7.y;
_local6 = _local7.z;
_local7.moveTo((_local4 - _arg1), (_local5 - _arg2), (_local6 - _arg3));
};
_local8 = new Number3D(_arg1, _arg2, _arg3);
new Number3D(_arg1, _arg2, _arg3).rotate(_local8, _transform);
_local8.add(_local8, position);
moveTo(_local8.x, _local8.y, _local8.z);
}
override public function clone(_arg1:Object3D=null):Object3D{
var _local3:Object3D;
var _local2:ObjectContainer3D = (((_arg1 as ObjectContainer3D)) || (new ObjectContainer3D()));
super.clone(_local2);
for each (_local3 in children) {
if (!(_local3 is Bone)){
_local2.addChild(_local3.clone());
};
};
return (_local2);
}
override public function cloneAll(_arg1:Object3D=null):Object3D{
var _local3:ObjectContainer3D;
var _local4:Object3D;
var _local6:AnimationData;
var _local7:MaterialData;
var _local2:ObjectContainer3D = (((_arg1 as ObjectContainer3D)) || (new ObjectContainer3D()));
super.clone(_local2);
for each (_local4 in children) {
if ((_local4 is Bone)){
_local3 = new Bone();
_local2.addChild(_local3);
(_local4 as Bone).cloneAll(_local3);
} else {
if ((_local4 is ObjectContainer3D)){
_local3 = new ObjectContainer3D();
_local2.addChild(_local3);
(_local4 as ObjectContainer3D).cloneAll(_local3);
} else {
if ((_local4 is Mesh)){
_local2.addChild((_local4 as Mesh).cloneAll());
} else {
_local2.addChild(_local4.clone());
};
};
};
};
if (animationLibrary){
_local2.animationLibrary = new AnimationLibrary();
for each (_local6 in animationLibrary) {
_local6.clone(_local2);
};
};
if (materialLibrary){
_local2.materialLibrary = new MaterialLibrary();
for each (_local7 in materialLibrary) {
_local7.clone(_local2);
};
};
var _local5:ObjectContainer3D = _local2;
while (_local5.parent) {
_local5 = _local5.parent;
};
if (_local2 == _local5){
cloneBones(_local2, _local5);
};
return (_local2);
}
private function cloneBones(_arg1:ObjectContainer3D, _arg2:ObjectContainer3D):void{
var _local4:Object3D;
var _local5:Geometry;
var _local6:Array;
var _local7:Bone;
var _local8:SkinController;
var _local9:Bone;
var _local3:Array = _arg1.children;
for each (_local4 in _local3) {
if ((_local4 is ObjectContainer3D)){
(_local4 as ObjectContainer3D).cloneBones((_local4 as ObjectContainer3D), _arg2);
} else {
if ((_local4 is Mesh)){
_local5 = (_local4 as Mesh).geometry;
_local6 = _local5.skinControllers;
for each (_local8 in _local6) {
_local9 = _arg2.getBoneByName(_local8.name);
if (_local9){
_local8.joint = _local9.joint;
if (!(_local9.parent.parent is Bone)){
_local7 = _local9;
};
} else {
Debug.warning(("no joint found for " + _local8.name));
};
};
for each (_local8 in _local6) {
_local8.inverseTransform = _local4.parent.inverseSceneTransform;
};
};
};
};
}
}
}//package away3d.containers
Section 15
//Scene3D (away3d.containers.Scene3D)
package away3d.containers {
import away3d.core.math.*;
import away3d.core.base.*;
import away3d.core.utils.*;
import flash.utils.*;
import away3d.events.*;
import away3d.core.traverse.*;
public class Scene3D extends ObjectContainer3D {
private var _objects:Array;
private var _currentView:View3D;
private var _mesh:Mesh;
private var _projtraverser:ProjectionTraverser;
private var _sessiontraverser:SessionTraverser;
private var _lighttraverser:LightTraverser;
public var viewDictionary:Dictionary;
public var tickTraverser:TickTraverser;
public var updatedObjects:Dictionary;
public var updatedSessions:Dictionary;
public var meshes:Dictionary;
public var geometries:Dictionary;
public var autoUpdate:Boolean;
public var updateLight:Boolean;
public var physics:IPhysicsScene;
public function Scene3D(... _args){
var _local2:Object;
var _local4:Object;
var _local6:Object3D;
_objects = new Array();
_projtraverser = new ProjectionTraverser();
_sessiontraverser = new SessionTraverser();
_lighttraverser = new LightTraverser();
viewDictionary = new Dictionary(true);
tickTraverser = new TickTraverser();
var _local3:Array = [];
for each (_local4 in _args) {
if ((_local4 is Object3D)){
_local3.push(_local4);
} else {
_local2 = _local4;
};
};
if (_local2){
_local2["ownCanvas"] = true;
_local2["ownLights"] = true;
} else {
_local2 = {ownCanvas:true, ownLights:true};
};
super(_local2);
autoUpdate = ini.getBoolean("autoUpdate", true);
updateLight = ini.getBoolean("updateLight", true);
var _local5:Object = ini.getObject("physics");
if ((_local5 is IPhysicsScene)){
physics = (_local5 as IPhysicsScene);
};
if ((_local5 is Boolean)){
if (_local5 == true){
physics = null;
};
};
if ((_local5 is Object)){
physics = null;
};
for each (_local6 in _local3) {
addChild(_local6);
};
}
function setId(_arg1:Object3D):void{
var _local2:int;
while (_objects[_local2]) {
_local2++;
};
_objects[_local2] = _arg1;
_arg1._id = _local2;
}
function clearId(_arg1:int):void{
delete _objects[_arg1];
}
function internalRemoveView(_arg1:View3D):void{
_arg1.removeEventListener(ViewEvent.UPDATE_SCENE, onUpdate);
}
function internalAddView(_arg1:View3D):void{
_arg1.addEventListener(ViewEvent.UPDATE_SCENE, onUpdate);
}
private function onUpdate(_arg1:ViewEvent):void{
if (autoUpdate){
if (((_currentView) && (!((_currentView == _arg1.view))))){
Debug.warning("Multiple views detected! Should consider switching to manual update");
};
_currentView = _arg1.view;
update();
};
}
override public function get sceneTransform():Matrix3D{
if (_transformDirty){
_sceneTransformDirty = true;
};
if (_sceneTransformDirty){
notifySceneTransformChange();
};
return (transform);
}
public function update():void{
var _local1:View3D;
var _local2:Array;
var _local3:Geometry;
var _local4:Object;
updatedObjects = new Dictionary(true);
updatedSessions = new Dictionary(true);
meshes = new Dictionary(true);
geometries = new Dictionary(true);
if (updateLight){
traverse(_lighttraverser);
};
for each (_local1 in viewDictionary) {
_local1.camera.update();
_local1.blockers = new Dictionary(true);
_local1.drawPrimitiveStore.blockerDictionary = new Dictionary(true);
_local1.cameraVarsStore.reset();
_local1.blockerarray.clip = _local1.screenClipping;
_projtraverser.view = _local1;
traverse(_projtraverser);
};
for (_local4 in meshes) {
_mesh = (_local4 as Mesh);
_local2 = meshes[_mesh];
for each (_local1 in _local2) {
_mesh.updateMaterials(_mesh, _local1);
};
};
for each (_local3 in geometries) {
_local3.updateElements();
};
traverse(_sessiontraverser);
}
public function updateTime(_arg1:int=-1):void{
if (_arg1 == -1){
_arg1 = getTimer();
};
tickTraverser.now = _arg1;
traverse(tickTraverser);
if (physics != null){
physics.updateTime(_arg1);
};
}
}
}//package away3d.containers
Section 16
//View3D (away3d.containers.View3D)
package away3d.containers {
import flash.display.*;
import flash.events.*;
import away3d.core.math.*;
import away3d.core.base.*;
import away3d.core.utils.*;
import away3d.materials.*;
import away3d.core.draw.*;
import away3d.core.block.*;
import away3d.core.render.*;
import flash.utils.*;
import away3d.cameras.*;
import away3d.core.clip.*;
import away3d.events.*;
import flash.geom.*;
import away3d.core.traverse.*;
import away3d.overlays.*;
import away3d.core.project.*;
import away3d.blockers.*;
import away3d.core.stats.*;
public class View3D extends Sprite {
var _screenClipping:Clipping;
var _interactiveLayer:Sprite;
var _convexBlockProjector:ConvexBlockProjector;
var _dirSpriteProjector:DirSpriteProjector;
var _dofSpriteProjector:DofSpriteProjector;
var _meshProjector:MeshProjector;
var _movieClipSpriteProjector:MovieClipSpriteProjector;
var _objectContainerProjector:ObjectContainerProjector;
var _spriteProjector:SpriteProjector;
private var _loaderWidth:Number;
private var _loaderHeight:Number;
private var _loaderDirty:Boolean;
private var _screenClippingDirty:Boolean;
private var _viewZero:Point;
private var _x:Number;
private var _y:Number;
private var _stageWidth:Number;
private var _stageHeight:Number;
private var _newStageWidth:Number;
private var _newStageHeight:Number;
private var _drawPrimitiveStore:DrawPrimitiveStore;
private var _cameraVarsStore:CameraVarsStore;
private var _scene:Scene3D;
private var _session:AbstractRenderSession;
private var _clipping:Clipping;
private var _camera:Camera3D;
private var _renderer:IRenderer;
private var _ini:Init;
private var _mousedown:Boolean;
private var _lastmove_mouseX:Number;
private var _lastmove_mouseY:Number;
private var _internalsession:AbstractRenderSession;
private var _updatescene:ViewEvent;
private var _renderComplete:ViewEvent;
private var _updated:Boolean;
private var _pritraverser:PrimitiveTraverser;
private var _ddo:DrawDisplayObject;
private var _container:DisplayObject;
private var _hitPointX:Number;
private var _hitPointY:Number;
private var _consumer:IPrimitiveConsumer;
private var screenX:Number;
private var screenY:Number;
private var screenZ:Number;// = INF
private var element:Element;
private var drawpri:DrawPrimitive;
private var material:Material;
private var object:Object3D;
private var uv:UV;
private var sceneX:Number;
private var sceneY:Number;
private var sceneZ:Number;
private var inv:Matrix3D;
private var persp:Number;
private var _mouseIsOverView:Boolean;
private var _overlays:Dictionary;
public var background:Sprite;
public var overlay:Sprite;
public var foreground:Sprite;
public var stats:Boolean;
public var mouseEvents:Boolean;
public var statsOpen:Boolean;
public var statsPanel:Stats;
public var sourceURL:String;
public var mouseZeroMove:Boolean;
public var mouseObject:Object3D;
public var mouseMaterial:Material;
public var forceUpdate:Boolean;
public var blockerarray:BlockerArray;
public var blockers:Dictionary;
public function View3D(_arg1:Object=null){
_interactiveLayer = new Sprite();
_convexBlockProjector = new ConvexBlockProjector();
_dirSpriteProjector = new DirSpriteProjector();
_dofSpriteProjector = new DofSpriteProjector();
_meshProjector = new MeshProjector();
_movieClipSpriteProjector = new MovieClipSpriteProjector();
_objectContainerProjector = new ObjectContainerProjector();
_spriteProjector = new SpriteProjector();
_viewZero = new Point();
_drawPrimitiveStore = new DrawPrimitiveStore();
_cameraVarsStore = new CameraVarsStore();
_pritraverser = new PrimitiveTraverser();
_ddo = new DrawDisplayObject();
inv = new Matrix3D();
_overlays = new Dictionary();
background = new Sprite();
overlay = new Sprite();
foreground = new Sprite();
blockerarray = new BlockerArray();
super();
_ini = (Init.parse(_arg1) as Init);
var _local2:Boolean = _ini.getBoolean("stats", true);
session = (((_ini.getObject("session") as AbstractRenderSession)) || (new SpriteRenderSession()));
scene = (((_ini.getObjectOrInit("scene", Scene3D) as Scene3D)) || (new Scene3D()));
camera = (((_ini.getObjectOrInit("camera", Camera3D) as Camera3D)) || (new Camera3D({x:0, y:0, z:-1000, lookat:"center"})));
renderer = (((_ini.getObject("renderer") as IRenderer)) || (new BasicRenderer()));
clipping = (((_ini.getObject("clipping", Clipping) as Clipping)) || (new RectangleClipping()));
x = _ini.getNumber("x", 0);
y = _ini.getNumber("y", 0);
forceUpdate = _ini.getBoolean("forceUpdate", false);
mouseZeroMove = _ini.getBoolean("mouseZeroMove", false);
mouseEvents = _ini.getBoolean("mouseEvents", true);
_interactiveLayer.blendMode = BlendMode.ALPHA;
_convexBlockProjector.view = this;
_dirSpriteProjector.view = this;
_dofSpriteProjector.view = this;
_meshProjector.view = this;
_movieClipSpriteProjector.view = this;
_objectContainerProjector.view = this;
_spriteProjector.view = this;
_drawPrimitiveStore.view = this;
_cameraVarsStore.view = this;
_pritraverser.view = this;
addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
addEventListener(MouseEvent.MOUSE_UP, onMouseUp);
addEventListener(MouseEvent.ROLL_OUT, onRollOut);
addEventListener(MouseEvent.ROLL_OVER, onRollOver);
if (_local2){
addEventListener(Event.ADDED_TO_STAGE, createStatsMenu);
};
}
function dispatchMouseEvent(_arg1:MouseEvent3D):void{
if (!hasEventListener(_arg1.type)){
return;
};
dispatchEvent(_arg1);
}
private function checkSession(_arg1:AbstractRenderSession):void{
var _local2:Array;
var _local3:DrawPrimitive;
var _local4:Array;
if (_arg1.getContainer(this).hitTestPoint(_hitPointX, _hitPointY)){
if ((_arg1 is BitmapRenderSession)){
_container = (_arg1 as BitmapRenderSession).getBitmapContainer(this);
_hitPointX = (_hitPointX + _container.x);
_hitPointY = (_hitPointY + _container.y);
};
_local2 = _arg1.getConsumer(this).list();
for each (_local3 in _local2) {
checkPrimitive(_local3);
};
_local4 = _arg1.sessions;
for each (_arg1 in _local4) {
checkSession(_arg1);
};
if ((_arg1 is BitmapRenderSession)){
_container = (_arg1 as BitmapRenderSession).getBitmapContainer(this);
_hitPointX = (_hitPointX - _container.x);
_hitPointY = (_hitPointY - _container.y);
};
};
}
private function checkPrimitive(_arg1:DrawPrimitive):void{
var _local2:Number;
var _local3:DrawTriangle;
var _local4:UV;
var _local5:BitmapMaterial;
if ((_arg1 is DrawFog)){
return;
};
if (((!(_arg1.source)) || (!(_arg1.source._mouseEnabled)))){
return;
};
if (_arg1.minX > screenX){
return;
};
if (_arg1.maxX < screenX){
return;
};
if (_arg1.minY > screenY){
return;
};
if (_arg1.maxY < screenY){
return;
};
if ((((_arg1 is DrawDisplayObject)) && (!((_arg1 as DrawDisplayObject).displayobject.hitTestPoint(_hitPointX, _hitPointY, true))))){
return;
};
if (_arg1.contains(screenX, screenY)){
_local2 = _arg1.getZ(screenX, screenY);
if (_local2 < screenZ){
if ((_arg1 is DrawTriangle)){
_local3 = (_arg1 as DrawTriangle);
_local4 = _local3.getUV(screenX, screenY);
if ((_local3.material is BitmapMaterial)){
_local5 = (_local3.material as BitmapMaterial);
if (((!((_local5.getPixel32(_local4.u, _local4.v) >> 24))) && (!((_local5 is CompositeMaterial))))){
return;
};
uv = _local4;
};
material = _local3.material;
} else {
if ((_arg1 is DrawSegment)){
material = (_arg1 as DrawSegment).material;
};
uv = null;
};
screenZ = _local2;
persp = (camera.zoom / (1 + (screenZ / camera.focus)));
inv = camera.invViewMatrix;
sceneX = (((((screenX / persp) * inv.sxx) + ((screenY / persp) * inv.sxy)) + (screenZ * inv.sxz)) + inv.tx);
sceneY = (((((screenX / persp) * inv.syx) + ((screenY / persp) * inv.syy)) + (screenZ * inv.syz)) + inv.ty);
sceneZ = (((((screenX / persp) * inv.szx) + ((screenY / persp) * inv.szy)) + (screenZ * inv.szz)) + inv.tz);
drawpri = _arg1;
object = _arg1.source;
element = null;
};
};
}
private function notifySceneUpdate():void{
if (!_updatescene){
_updatescene = new ViewEvent(ViewEvent.UPDATE_SCENE, this);
};
dispatchEvent(_updatescene);
}
private function notifyRenderComplete():void{
if (!hasEventListener(ViewEvent.RENDER_COMPLETE)){
return;
};
if (!_renderComplete){
_renderComplete = new ViewEvent(ViewEvent.RENDER_COMPLETE, this);
};
dispatchEvent(_renderComplete);
}
private function createStatsMenu(_arg1:Event):void{
statsPanel = new Stats(this, stage.frameRate);
statsOpen = false;
stage.addEventListener(Event.RESIZE, onStageResized);
}
private function onStageResized(_arg1:Event):void{
_screenClippingDirty = true;
}
private function onSessionUpdate(_arg1:SessionEvent):void{
if ((_arg1.target is BitmapRenderSession)){
_scene.updatedSessions[_arg1.target] = _arg1.target;
};
}
private function onCameraTransformChange(_arg1:Object3DEvent):void{
_updated = true;
}
private function onCameraUpdated(_arg1:CameraEvent):void{
_updated = true;
}
private function onClippingUpdated(_arg1:ClippingEvent):void{
_screenClippingDirty = true;
}
private function onScreenUpdated(_arg1:ClippingEvent):void{
_updated = true;
}
private function onSessionChange(_arg1:Object3DEvent):void{
_session.sessions = [_arg1.object.session];
}
private function onMouseDown(_arg1:MouseEvent):void{
_mousedown = true;
fireMouseEvent(MouseEvent3D.MOUSE_DOWN, mouseX, mouseY, _arg1.ctrlKey, _arg1.shiftKey);
}
private function onMouseUp(_arg1:MouseEvent):void{
_mousedown = false;
fireMouseEvent(MouseEvent3D.MOUSE_UP, mouseX, mouseY, _arg1.ctrlKey, _arg1.shiftKey);
}
private function onRollOut(_arg1:MouseEvent):void{
_mouseIsOverView = false;
fireMouseEvent(MouseEvent3D.MOUSE_OUT, mouseX, mouseY, _arg1.ctrlKey, _arg1.shiftKey);
}
private function onRollOver(_arg1:MouseEvent):void{
_mouseIsOverView = true;
fireMouseEvent(MouseEvent3D.MOUSE_OVER, mouseX, mouseY, _arg1.ctrlKey, _arg1.shiftKey);
}
private function bubbleMouseEvent(_arg1:MouseEvent3D):Array{
var _local2:Object3D = _arg1.object;
var _local3:Array = [];
while (_local2 != null) {
_local3.unshift(_local2);
_local2.dispatchMouseEvent(_arg1);
_local2 = _local2.parent;
};
return (_local3);
}
private function traverseRollEvent(_arg1:MouseEvent3D, _arg2:Array, _arg3:Boolean):void{
var _local4:Object3D;
for each (_local4 in _arg2) {
_local4.dispatchMouseEvent(_arg1);
if (_arg3){
buttonMode = ((buttonMode) || (_local4.useHandCursor));
} else {
if (((buttonMode) && (_local4.useHandCursor))){
buttonMode = false;
};
};
};
}
private function processOverlays():void{
var _local1:IOverlay;
for each (_local1 in _overlays) {
_local1.update();
};
}
public function get renderer():IRenderer{
return (_renderer);
}
public function set renderer(_arg1:IRenderer):void{
if (_renderer == _arg1){
return;
};
_renderer = _arg1;
_updated = true;
if (!_renderer){
throw (new Error("View cannot have renderer set to null"));
};
}
public function get updated():Boolean{
return (_updated);
}
public function get clipping():Clipping{
return (_clipping);
}
public function set clipping(_arg1:Clipping):void{
if (_clipping == _arg1){
return;
};
if (_clipping){
_clipping.removeOnClippingUpdate(onClippingUpdated);
_clipping.removeOnScreenUpdate(onScreenUpdated);
};
_clipping = _arg1;
_clipping.view = this;
if (_clipping){
_clipping.addOnClippingUpdate(onClippingUpdated);
_clipping.addOnScreenUpdate(onScreenUpdated);
} else {
throw (new Error("View cannot have clip set to null"));
};
_updated = true;
_screenClippingDirty = true;
}
public function get camera():Camera3D{
return (_camera);
}
public function set camera(_arg1:Camera3D):void{
if (_camera == _arg1){
return;
};
if (_camera){
_camera.removeOnSceneTransformChange(onCameraTransformChange);
_camera.removeOnCameraUpdate(onCameraUpdated);
};
_camera = _arg1;
_camera.view = this;
_updated = true;
if (_camera){
_camera.addOnSceneTransformChange(onCameraTransformChange);
_camera.addOnCameraUpdate(onCameraUpdated);
} else {
throw (new Error("View cannot have camera set to null"));
};
}
public function get scene():Scene3D{
return (_scene);
}
public function set scene(_arg1:Scene3D):void{
if (_scene == _arg1){
return;
};
if (_scene){
_scene.internalRemoveView(this);
delete _scene.viewDictionary[this];
_scene.removeOnSessionChange(onSessionChange);
if (_session){
_session.internalRemoveSceneSession(_scene.ownSession);
};
};
_scene = _arg1;
_updated = true;
if (_scene){
_scene.internalAddView(this);
_scene.addOnSessionChange(onSessionChange);
_scene.viewDictionary[this] = this;
if (_session){
_session.internalAddSceneSession(_scene.ownSession);
};
} else {
throw (new Error("View cannot have scene set to null"));
};
}
public function get session():AbstractRenderSession{
return (_session);
}
public function set session(_arg1:AbstractRenderSession):void{
if (_session == _arg1){
return;
};
if (_session){
_session.removeOnSessionUpdate(onSessionUpdate);
if (_scene){
_session.internalRemoveSceneSession(_scene.ownSession);
};
};
_session = _arg1;
_updated = true;
if (_session){
_session.addOnSessionUpdate(onSessionUpdate);
if (_scene){
_session.internalAddSceneSession(_scene.ownSession);
};
} else {
throw (new Error("View cannot have session set to null"));
};
while (numChildren) {
removeChildAt(0);
};
addChild(background);
addChild(_session.getContainer(this));
addChild(_interactiveLayer);
addChild(overlay);
addChild(foreground);
}
public function get screenClipping():Clipping{
if (_screenClippingDirty){
updateScreenClipping();
_screenClippingDirty = false;
return ((_screenClipping = _clipping.screen(this, _loaderWidth, _loaderHeight)));
};
return (_screenClipping);
}
public function get drawPrimitiveStore():DrawPrimitiveStore{
return (_drawPrimitiveStore);
}
public function get cameraVarsStore():CameraVarsStore{
return (_cameraVarsStore);
}
public function fireMouseEvent(_arg1:String, _arg2:Number, _arg3:Number, _arg4:Boolean=false, _arg5:Boolean=false):void{
var _local9:int;
if (!mouseEvents){
return;
};
findHit(_internalsession, _arg2, _arg3);
var _local6:MouseEvent3D = getMouseEvent(_arg1);
var _local7:Array = [];
var _local8:Array = [];
_local6.ctrlKey = _arg4;
_local6.shiftKey = _arg5;
if (((!((_arg1 == MouseEvent3D.MOUSE_OUT))) && (!((_arg1 == MouseEvent3D.MOUSE_OVER))))){
dispatchMouseEvent(_local6);
bubbleMouseEvent(_local6);
};
if (((!((mouseObject == object))) || (!((mouseMaterial == material))))){
if (mouseObject != null){
_local6 = getMouseEvent(MouseEvent3D.MOUSE_OUT);
_local6.object = mouseObject;
_local6.material = mouseMaterial;
_local6.ctrlKey = _arg4;
_local6.shiftKey = _arg5;
dispatchMouseEvent(_local6);
_local7 = bubbleMouseEvent(_local6);
};
if (object != null){
_local6 = getMouseEvent(MouseEvent3D.MOUSE_OVER);
_local6.ctrlKey = _arg4;
_local6.shiftKey = _arg5;
dispatchMouseEvent(_local6);
_local8 = bubbleMouseEvent(_local6);
};
if (mouseObject != object){
_local9 = 0;
while (((_local7[_local9]) && ((_local7[_local9] == _local8[_local9])))) {
_local9++;
};
if (mouseObject != null){
_local6 = getMouseEvent(MouseEvent3D.ROLL_OUT);
_local6.object = mouseObject;
_local6.material = mouseMaterial;
_local6.ctrlKey = _arg4;
_local6.shiftKey = _arg5;
traverseRollEvent(_local6, _local7.slice(_local9), false);
};
if (object != null){
_local6 = getMouseEvent(MouseEvent3D.ROLL_OVER);
_local6.ctrlKey = _arg4;
_local6.shiftKey = _arg5;
traverseRollEvent(_local6, _local8.slice(_local9), true);
};
};
mouseObject = object;
mouseMaterial = material;
};
}
public function addOverlay(_arg1:IOverlay):void{
if (_overlays[_arg1]){
return;
};
_overlays[_arg1] = _arg1;
overlay.addChild((_arg1 as Sprite));
}
public function removeOverlay(_arg1:IOverlay):void{
if (_overlays[_arg1]){
overlay.removeChild((_arg1 as Sprite));
_overlays[_arg1] = null;
};
}
public function findHit(_arg1:AbstractRenderSession, _arg2:Number, _arg3:Number):void{
screenX = _arg2;
screenY = _arg3;
screenZ = Infinity;
material = null;
object = null;
if (((!(_arg1)) || (!(_mouseIsOverView)))){
return;
};
var _local4:Point = new Point(_arg2, _arg3);
var _local5:Point = localToGlobal(_local4);
_hitPointX = _local5.x;
_hitPointY = _local5.y;
if ((this.session is BitmapRenderSession)){
_container = this.session.getContainer(this);
_hitPointX = (_hitPointX + _container.x);
_hitPointY = (_hitPointY + _container.y);
};
checkSession(_arg1);
}
public function getMouseEvent(_arg1:String):MouseEvent3D{
var _local2:MouseEvent3D = new MouseEvent3D(_arg1);
_local2.screenX = screenX;
_local2.screenY = screenY;
_local2.screenZ = screenZ;
_local2.sceneX = sceneX;
_local2.sceneY = sceneY;
_local2.sceneZ = sceneZ;
_local2.view = this;
_local2.drawpri = drawpri;
_local2.material = material;
_local2.element = element;
_local2.object = object;
_local2.uv = uv;
return (_local2);
}
public function getContainer():DisplayObject{
return (_session.getContainer(this));
}
public function getBitmapData():BitmapData{
if ((_session is BitmapRenderSession)){
return ((_session as BitmapRenderSession).getBitmapData(this));
};
throw (new Error("incorrect session object - require BitmapRenderSession"));
}
public function updateScreenClipping():void{
try {
_loaderWidth = loaderInfo.width;
_loaderHeight = loaderInfo.height;
if (_loaderDirty){
_loaderDirty = false;
_screenClippingDirty = true;
};
} catch(error:Error) {
_loaderDirty = true;
if (stage){
_loaderWidth = stage.stageWidth;
_loaderHeight = stage.stageHeight;
} else {
_loaderWidth = 550;
_loaderHeight = 400;
};
};
_viewZero.x = 0;
_viewZero.y = 0;
_viewZero = localToGlobal(_viewZero);
if (stage){
_newStageWidth = stage.stageWidth;
_newStageHeight = stage.stageHeight;
} else {
_newStageWidth = 550;
_newStageHeight = 400;
};
if (((((((!((_x == _viewZero.x))) || (!((_y == _viewZero.y))))) || (!((_stageWidth == _newStageWidth))))) || (!((_stageHeight == _newStageHeight))))){
_x = _viewZero.x;
_y = _viewZero.y;
_stageWidth = _newStageWidth;
_stageHeight = _newStageHeight;
_screenClippingDirty = true;
};
}
public function clear():void{
_updated = true;
if (_internalsession){
_internalsession.clear(this);
};
}
public function render():void{
var _local1:ConvexBlock;
notifySceneUpdate();
if (_internalsession != _session){
_internalsession = _session;
};
if (_session.renderer != (_renderer as IPrimitiveConsumer)){
_session.renderer = (_renderer as IPrimitiveConsumer);
};
_session.clear(this);
_drawPrimitiveStore.reset();
if (_session.updated){
if ((_scene.ownSession is SpriteRenderSession)){
(_scene.ownSession as SpriteRenderSession).cacheAsBitmap = true;
};
_ddo.view = this;
_ddo.displayobject = _scene.session.getContainer(this);
_ddo.session = _session;
_ddo.vx = 0;
_ddo.vy = 0;
_ddo.vz = 0;
_ddo.calc();
_consumer = _session.getConsumer(this);
_consumer.primitive(_ddo);
};
for each (_local1 in blockers) {
_convexBlockProjector.blockers(_local1, cameraVarsStore.viewTransformDictionary[_local1], blockerarray);
};
_scene.traverse(_pritraverser);
_session.render(this);
_updated = false;
if (statsOpen){
statsPanel.updateStats(_session.getTotalFaces(this), camera);
};
Init.checkUnusedArguments();
processOverlays();
fireMouseMoveEvent();
notifyRenderComplete();
}
public function addSourceURL(_arg1:String):void{
sourceURL = _arg1;
if (statsPanel){
statsPanel.addSourceURL(_arg1);
};
}
public function fireMouseMoveEvent(_arg1:Boolean=false):void{
if (!_mouseIsOverView){
return;
};
if (!((mouseZeroMove) || (_arg1))){
if ((((mouseX == _lastmove_mouseX)) && ((mouseY == _lastmove_mouseY)))){
return;
};
};
fireMouseEvent(MouseEvent3D.MOUSE_MOVE, mouseX, mouseY);
_lastmove_mouseX = mouseX;
_lastmove_mouseY = mouseY;
}
public function addOnMouseMove(_arg1:Function):void{
addEventListener(MouseEvent3D.MOUSE_MOVE, _arg1, false, 0, false);
}
public function removeOnMouseMove(_arg1:Function):void{
removeEventListener(MouseEvent3D.MOUSE_MOVE, _arg1, false);
}
public function addOnMouseDown(_arg1:Function):void{
addEventListener(MouseEvent3D.MOUSE_DOWN, _arg1, false, 0, false);
}
public function removeOnMouseDown(_arg1:Function):void{
removeEventListener(MouseEvent3D.MOUSE_DOWN, _arg1, false);
}
public function addOnMouseUp(_arg1:Function):void{
addEventListener(MouseEvent3D.MOUSE_UP, _arg1, false, 0, false);
}
public function removeOnMouseUp(_arg1:Function):void{
removeEventListener(MouseEvent3D.MOUSE_UP, _arg1, false);
}
public function addOnMouseOver(_arg1:Function):void{
addEventListener(MouseEvent3D.MOUSE_OVER, _arg1, false, 0, false);
}
public function removeOnMouseOver(_arg1:Function):void{
removeEventListener(MouseEvent3D.MOUSE_OVER, _arg1, false);
}
public function addOnMouseOut(_arg1:Function):void{
addEventListener(MouseEvent3D.MOUSE_OUT, _arg1, false, 0, false);
}
public function removeOnMouseOut(_arg1:Function):void{
removeEventListener(MouseEvent3D.MOUSE_OUT, _arg1, false);
}
}
}//package away3d.containers
Section 17
//Element (away3d.core.base.Element)
package away3d.core.base {
import flash.events.*;
import away3d.core.geom.*;
import away3d.events.*;
public class Element extends EventDispatcher {
protected var _index:int;
protected var _vertices:Array;
protected var _commands:Array;
protected var _pathCommands:Array;
protected var _lastAddedVertex:Vertex;
var _visible:Boolean;// = true
private var _vertexchanged:ElementEvent;
private var _vertexvaluechanged:ElementEvent;
private var _visiblechanged:ElementEvent;
private var _mappingchanged:ElementEvent;
public var vertexDirty:Boolean;
public var extra:Object;
public var parent:Geometry;
public function Element(){
_vertices = new Array();
_commands = new Array();
_pathCommands = new Array();
_lastAddedVertex = new Vertex();
super();
}
function notifyVertexChange():void{
if (!hasEventListener(ElementEvent.VERTEX_CHANGED)){
return;
};
if (_vertexchanged == null){
_vertexchanged = new ElementEvent(ElementEvent.VERTEX_CHANGED, this);
};
dispatchEvent(_vertexchanged);
}
function notifyVertexValueChange():void{
if (!hasEventListener(ElementEvent.VERTEXVALUE_CHANGED)){
return;
};
if (_vertexvaluechanged == null){
_vertexvaluechanged = new ElementEvent(ElementEvent.VERTEXVALUE_CHANGED, this);
};
dispatchEvent(_vertexvaluechanged);
}
function notifyVisibleChange():void{
if (!hasEventListener(ElementEvent.VISIBLE_CHANGED)){
return;
};
if (_visiblechanged == null){
_visiblechanged = new ElementEvent(ElementEvent.VISIBLE_CHANGED, this);
};
dispatchEvent(_visiblechanged);
}
function notifyMappingChange():void{
if (!hasEventListener(ElementEvent.MAPPING_CHANGED)){
return;
};
if (_mappingchanged == null){
_mappingchanged = new ElementEvent(ElementEvent.MAPPING_CHANGED, this);
};
dispatchEvent(_mappingchanged);
}
public function get vertices():Array{
throw (new Error("Not implemented"));
}
public function get commands():Array{
throw (new Error("Not implemented"));
}
public function get pathCommands():Array{
throw (new Error("Not implemented"));
}
public function get visible():Boolean{
return (_visible);
}
public function set visible(_arg1:Boolean):void{
if (_arg1 == _visible){
return;
};
_visible = _arg1;
notifyVisibleChange();
}
public function get radius2():Number{
var _local2:Vertex;
var _local3:Number;
var _local1:Number = 0;
for each (_local2 in vertices) {
_local3 = (((_local2._x * _local2._x) + (_local2._y * _local2._y)) + (_local2._z * _local2._z));
if (_local3 > _local1){
_local1 = _local3;
};
};
return (_local1);
}
public function get maxX():Number{
return (Math.sqrt(radius2));
}
public function get minX():Number{
return (-(Math.sqrt(radius2)));
}
public function get maxY():Number{
return (Math.sqrt(radius2));
}
public function get minY():Number{
return (-(Math.sqrt(radius2)));
}
public function get maxZ():Number{
return (Math.sqrt(radius2));
}
public function get minZ():Number{
return (-(Math.sqrt(radius2)));
}
public function offset(_arg1:Number, _arg2:Number, _arg3:Number):void{
var _local4:uint;
var _local5:Vertex;
var _local6:PathCommand;
while (_local4 < _pathCommands.length) {
_local6 = _pathCommands[_local4];
if (_local6.pControl){
_local6.pControl.x = (_local6.pControl.x + _arg1);
_local6.pControl.y = (_local6.pControl.y + _arg2);
_local6.pControl.z = (_local6.pControl.z + _arg3);
};
if (_local6.pEnd){
_local6.pEnd.x = (_local6.pEnd.x + _arg1);
_local6.pEnd.y = (_local6.pEnd.y + _arg2);
_local6.pEnd.z = (_local6.pEnd.z + _arg3);
};
_local4++;
};
for each (_local5 in _vertices) {
_local5.x = (_local5.x + _arg1);
_local5.y = (_local5.y + _arg2);
_local5.z = (_local5.z + _arg3);
};
}
public function addOnVertexChange(_arg1:Function):void{
addEventListener(ElementEvent.VERTEX_CHANGED, _arg1, false, 0, true);
}
public function removeOnVertexChange(_arg1:Function):void{
removeEventListener(ElementEvent.VERTEX_CHANGED, _arg1, false);
}
public function addOnVertexValueChange(_arg1:Function):void{
addEventListener(ElementEvent.VERTEXVALUE_CHANGED, _arg1, false, 0, true);
}
public function removeOnVertexValueChange(_arg1:Function):void{
removeEventListener(ElementEvent.VERTEXVALUE_CHANGED, _arg1, false);
}
public function addOnVisibleChange(_arg1:Function):void{
addEventListener(ElementEvent.VISIBLE_CHANGED, _arg1, false, 0, true);
}
public function removeOnVisibleChange(_arg1:Function):void{
removeEventListener(ElementEvent.VISIBLE_CHANGED, _arg1, false);
}
public function addOnMappingChange(_arg1:Function):void{
addEventListener(ElementEvent.MAPPING_CHANGED, _arg1, false, 0, true);
}
public function removeOnMappingChange(_arg1:Function):void{
removeEventListener(ElementEvent.MAPPING_CHANGED, _arg1, false);
}
}
}//package away3d.core.base
Section 18
//Face (away3d.core.base.Face)
package away3d.core.base {
import flash.events.*;
import away3d.core.math.*;
import away3d.core.utils.*;
import away3d.materials.*;
import away3d.core.geom.*;
import flash.geom.*;
public class Face extends Element {
var _v0:Vertex;
var _v1:Vertex;
var _v2:Vertex;
var _uv0:UV;
var _uv1:UV;
var _uv2:UV;
var _material:Material;
var _back:Material;
private var _normal:Number3D;
private var _normalDirty:Boolean;
private var _area:Number;
private var _areaDirty:Boolean;
private var _a:Number;
private var _b:Number;
private var _c:Number;
private var _s:Number;
var _plane:Plane3D;
public var isBack:Boolean;
public var bitmapRect:Rectangle;
public var faceVO:FaceVO;
public function Face(_arg1:Vertex=null, _arg2:Vertex=null, _arg3:Vertex=null, _arg4:Material=null, _arg5:UV=null, _arg6:UV=null, _arg7:UV=null){
_normal = new Number3D();
faceVO = new FaceVO();
super();
if (_arg1){
this.v0 = _arg1;
};
if (_arg2){
this.v1 = _arg2;
};
if (_arg3){
this.v2 = _arg3;
};
this.material = _arg4;
this.uv0 = _arg5;
this.uv1 = _arg6;
this.uv2 = _arg7;
faceVO.face = this;
vertexDirty = true;
}
private function onUVChange(_arg1:Event):void{
notifyMappingChange();
}
private function updateVertex():void{
vertexDirty = false;
_normalDirty = true;
_areaDirty = true;
}
private function updateNormal():void{
var _local9:Number;
var _local10:Number;
_normalDirty = false;
var _local1:Number = (_v1.x - _v0.x);
var _local2:Number = (_v1.y - _v0.y);
var _local3:Number = (_v1.z - _v0.z);
var _local4:Number = (_v2.x - _v0.x);
var _local5:Number = (_v2.y - _v0.y);
var _local6:Number = (_v2.z - _v0.z);
var _local7:Number = ((_local2 * _local6) - (_local3 * _local5));
var _local8:Number = ((_local3 * _local4) - (_local1 * _local6));
_local9 = ((_local1 * _local5) - (_local2 * _local4));
_local10 = Math.sqrt((((_local7 * _local7) + (_local8 * _local8)) + (_local9 * _local9)));
_normal.x = (_local7 / _local10);
_normal.y = (_local8 / _local10);
_normal.z = (_local9 / _local10);
}
private function updateArea():void{
_a = v0.position.distance(v1.position);
_b = v1.position.distance(v2.position);
_c = v2.position.distance(v0.position);
_s = (((_a + _b) + _c) / 2);
_area = Math.sqrt((((_s * (_s - _a)) * (_s - _b)) * (_s - _c)));
}
private function addVertexAt(_arg1:uint, _arg2:Vertex, _arg3:String):void{
if (((_vertices[_arg1]) && ((_vertices[_arg1] == _arg2)))){
return;
};
if (_vertices[_arg1]){
_index = _vertices[_arg1].parents.indexOf(this);
if (_index != -1){
_vertices[_arg1].parents.splice(_index, 1);
};
};
_commands[_arg1] = (faceVO.commands[_arg1] = _arg3);
_vertices[_arg1] = (faceVO.vertices[_arg1] = _arg2);
if (_arg1 == 0){
_v0 = (faceVO.v0 = _arg2);
} else {
if (_arg1 == 1){
_v1 = (faceVO.v1 = _arg2);
} else {
if (_arg1 == 2){
_v2 = (faceVO.v2 = _arg2);
};
};
};
if (_arg1 == 2){
if ((-0.5 * (((_v0.x * (_v2.y - _v1.y)) + (_v1.x * (_v0.y - _v2.y))) + (_v2.x * (_v1.y - _v0.y)))) < 0){
faceVO.reverseArea = true;
};
};
_arg2._index = _arg1;
_arg2.parents.push(this);
vertexDirty = true;
}
public function moveTo(_arg1:Number, _arg2:Number, _arg3:Number):void{
var _local4:Vertex = new Vertex(_arg1, _arg2, _arg3);
addVertexAt(_vertices.length, _local4, PathCommand.MOVE);
_pathCommands.push(new PathCommand(PathCommand.MOVE, _lastAddedVertex.position, null, _local4.position));
_lastAddedVertex = _local4;
}
public function lineTo(_arg1:Number, _arg2:Number, _arg3:Number):void{
var _local4:Vertex = new Vertex(_arg1, _arg2, _arg3);
addVertexAt(_vertices.length, _local4, PathCommand.LINE);
_pathCommands.push(new PathCommand(PathCommand.LINE, _lastAddedVertex.position, null, _local4.position));
_lastAddedVertex = _local4;
}
public function curveTo(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:Number):void{
var _local7:Vertex = new Vertex(_arg1, _arg2, _arg3);
var _local8:Vertex = new Vertex(_arg4, _arg5, _arg6);
addVertexAt(_vertices.length, _local7, PathCommand.CURVE);
addVertexAt(_vertices.length, _local8, "P");
_pathCommands.push(new PathCommand(PathCommand.CURVE, _lastAddedVertex.position, _local7.position, _local8.position));
_lastAddedVertex = _local8;
}
public function set normalDirty(_arg1:Boolean):void{
vertexDirty = _arg1;
}
override public function get vertices():Array{
return (_vertices);
}
override public function get commands():Array{
return (_commands);
}
override public function get pathCommands():Array{
return (_pathCommands);
}
public function get uvs():Array{
return ([_uv0, _uv1, _uv2]);
}
public function get v0():Vertex{
return (_v0);
}
public function set v0(_arg1:Vertex):void{
addVertexAt(0, _arg1, "M");
}
public function get v1():Vertex{
return (_v1);
}
public function set v1(_arg1:Vertex):void{
addVertexAt(1, _arg1, "L");
}
public function get v2():Vertex{
return (_v2);
}
public function set v2(_arg1:Vertex):void{
addVertexAt(2, _arg1, "L");
}
public function get material():Material{
return (_material);
}
public function set material(_arg1:Material):void{
if (_arg1 == _material){
return;
};
if (((!((_material == null))) && (parent))){
parent.removeMaterial(this, _material);
};
_material = (faceVO.material = _arg1);
if (((!((_material == null))) && (parent))){
parent.addMaterial(this, _material);
};
notifyMappingChange();
}
public function get back():Material{
return (_back);
}
public function set back(_arg1:Material):void{
if (_arg1 == _back){
return;
};
if (_back != null){
parent.removeMaterial(this, _back);
};
_back = (faceVO.back = _arg1);
if (_back != null){
parent.addMaterial(this, _back);
};
notifyMappingChange();
}
public function get uv0():UV{
return (_uv0);
}
public function set uv0(_arg1:UV):void{
if (_arg1 == _uv0){
return;
};
if (_uv0 != null){
if (((!((_uv0 == _uv1))) && (!((_uv0 == _uv2))))){
_uv0.removeOnChange(onUVChange);
};
};
_uv0 = (faceVO.uv0 = _arg1);
if (_uv0 != null){
if (((!((_uv0 == _uv1))) && (!((_uv0 == _uv2))))){
_uv0.addOnChange(onUVChange);
};
};
notifyMappingChange();
}
public function get uv1():UV{
return (_uv1);
}
public function set uv1(_arg1:UV):void{
if (_arg1 == _uv1){
return;
};
if (_uv1 != null){
if (((!((_uv1 == _uv0))) && (!((_uv1 == _uv2))))){
_uv1.removeOnChange(onUVChange);
};
};
_uv1 = (faceVO.uv1 = _arg1);
if (_uv1 != null){
if (((!((_uv1 == _uv0))) && (!((_uv1 == _uv2))))){
_uv1.addOnChange(onUVChange);
};
};
notifyMappingChange();
}
public function get uv2():UV{
return (_uv2);
}
public function set uv2(_arg1:UV):void{
if (_arg1 == _uv2){
return;
};
if (_uv2 != null){
if (((!((_uv2 == _uv1))) && (!((_uv2 == _uv0))))){
_uv2.removeOnChange(onUVChange);
};
};
_uv2 = (faceVO.uv2 = _arg1);
if (_uv2 != null){
if (((!((_uv2 == _uv1))) && (!((_uv2 == _uv0))))){
_uv2.addOnChange(onUVChange);
};
};
notifyMappingChange();
}
public function get area():Number{
if (vertexDirty){
updateVertex();
};
if (_areaDirty){
updateArea();
};
return (_area);
}
public function get normal():Number3D{
if (vertexDirty){
updateVertex();
};
if (_normalDirty){
updateNormal();
};
return (_normal);
}
override public function get radius2():Number{
var _local1:Number = (((_v0._x * _v0._x) + (_v0._y * _v0._y)) + (_v0._z * _v0._z));
var _local2:Number = (((_v1._x * _v1._x) + (_v1._y * _v1._y)) + (_v1._z * _v1._z));
var _local3:Number = (((_v2._x * _v2._x) + (_v2._y * _v2._y)) + (_v2._z * _v2._z));
if (_local1 > _local2){
if (_local1 > _local3){
return (_local1);
};
return (_local3);
//unresolved jump
};
if (_local2 > _local3){
return (_local2);
};
return (_local3);
}
override public function get maxX():Number{
if (_v0._x > _v1._x){
if (_v0._x > _v2._x){
return (_v0._x);
};
return (_v2._x);
//unresolved jump
};
if (_v1._x > _v2._x){
return (_v1._x);
};
return (_v2._x);
}
override public function get minX():Number{
if (_v0._x < _v1._x){
if (_v0._x < _v2._x){
return (_v0._x);
};
return (_v2._x);
//unresolved jump
};
if (_v1._x < _v2._x){
return (_v1._x);
};
return (_v2._x);
}
override public function get maxY():Number{
if (_v0._y > _v1._y){
if (_v0._y > _v2._y){
return (_v0._y);
};
return (_v2._y);
//unresolved jump
};
if (_v1._y > _v2._y){
return (_v1._y);
};
return (_v2._y);
}
override public function get minY():Number{
if (_v0._y < _v1._y){
if (_v0._y < _v2._y){
return (_v0._y);
};
return (_v2._y);
//unresolved jump
};
if (_v1._y < _v2._y){
return (_v1._y);
};
return (_v2._y);
}
override public function get maxZ():Number{
if (_v0._z > _v1._z){
if (_v0._z > _v2._z){
return (_v0._z);
};
return (_v2._z);
//unresolved jump
};
if (_v1._z > _v2._z){
return (_v1._z);
};
return (_v2._z);
}
override public function get minZ():Number{
if (_v0._z < _v1._z){
if (_v0._z < _v2._z){
return (_v0._z);
};
return (_v2._z);
//unresolved jump
};
if (_v1._z < _v2._z){
return (_v1._z);
};
return (_v2._z);
}
public function invert():void{
faceVO.v2 = this._v1;
faceVO.v1 = this._v2;
faceVO.uv2 = this._uv1;
faceVO.uv1 = this._uv2;
_vertices[1] = (this._v1 = faceVO.v1);
_vertices[2] = (this._v2 = faceVO.v2);
this._uv1 = faceVO.uv1;
this._uv2 = faceVO.uv2;
vertexDirty = true;
notifyMappingChange();
}
public function clone():Face{
var _local2:uint;
var _local3:PathCommand;
var _local1:Face = new Face();
while (_local2 < _pathCommands.length) {
_local3 = _pathCommands[_local2];
switch (_local3.type){
case PathCommand.MOVE:
_local1.moveTo(_local3.pEnd.x, _local3.pEnd.y, _local3.pEnd.z);
break;
case PathCommand.LINE:
_local1.lineTo(_local3.pEnd.x, _local3.pEnd.y, _local3.pEnd.z);
break;
case PathCommand.CURVE:
_local1.curveTo(_local3.pControl.x, _local3.pControl.y, _local3.pControl.z, _local3.pEnd.x, _local3.pEnd.y, _local3.pEnd.z);
break;
};
_local2++;
};
return (_local1);
}
public function scaleAboutCenter(_arg1:Number):void{
var _local8:uint;
var _local9:PathCommand;
var _local11:Number3D;
var _local12:Number3D;
var _local2:Number = Number.MAX_VALUE;
var _local3:Number = -(Number.MAX_VALUE);
var _local4:Number = Number.MAX_VALUE;
var _local5:Number = -(Number.MAX_VALUE);
var _local6:Number = Number.MAX_VALUE;
var _local7:Number = -(Number.MAX_VALUE);
_local8 = 0;
while (_local8 < _pathCommands.length) {
_local9 = _pathCommands[_local8];
if (_local9.pControl){
if (_local9.pControl.x < _local2){
_local2 = _local9.pControl.x;
};
if (_local9.pControl.x > _local3){
_local3 = _local9.pControl.x;
};
if (_local9.pControl.y < _local4){
_local4 = _local9.pControl.y;
};
if (_local9.pControl.y > _local5){
_local5 = _local9.pControl.y;
};
if (_local9.pControl.z < _local6){
_local6 = _local9.pControl.z;
};
if (_local9.pControl.z > _local7){
_local7 = _local9.pControl.z;
};
};
if (_local9.pEnd){
if (_local9.pEnd.x < _local2){
_local2 = _local9.pEnd.x;
};
if (_local9.pEnd.x > _local3){
_local3 = _local9.pEnd.x;
};
if (_local9.pEnd.y < _local4){
_local4 = _local9.pEnd.y;
};
if (_local9.pEnd.y > _local5){
_local5 = _local9.pEnd.y;
};
if (_local9.pEnd.z < _local6){
_local6 = _local9.pEnd.z;
};
if (_local9.pEnd.z > _local7){
_local7 = _local9.pEnd.z;
};
};
_local8++;
};
var _local10:Number3D = new Number3D(((_local3 + _local2) / 2), ((_local5 + _local4) / 2), ((_local7 + _local6) / 2));
_local8 = 0;
while (_local8 < _pathCommands.length) {
_local9 = _pathCommands[_local8];
if (_local9.pControl){
_local11 = new Number3D(_local9.pControl.x, _local9.pControl.y, _local9.pControl.z);
new Number3D(_local9.pControl.x, _local9.pControl.y, _local9.pControl.z).sub(_local11, _local10);
_local11.scale(_local11, _arg1);
_local9.pControl.x = (_local10.x + _local11.x);
_local9.pControl.y = (_local10.y + _local11.y);
_local9.pControl.z = (_local10.z + _local11.z);
};
if (_local9.pEnd){
_local12 = new Number3D(_local9.pEnd.x, _local9.pEnd.y, _local9.pEnd.z);
new Number3D(_local9.pEnd.x, _local9.pEnd.y, _local9.pEnd.z).sub(_local12, _local10);
_local12.scale(_local12, _arg1);
_local9.pEnd.x = (_local10.x + _local12.x);
_local9.pEnd.y = (_local10.y + _local12.y);
_local9.pEnd.z = (_local10.z + _local12.z);
};
_local8++;
};
}
public function hasEdgeOnPlane(_arg1:Plane3D, _arg2:Number=0.001):Boolean{
var _local6:int;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local3:Vertex = _v0;
var _local4:Vertex = _v1;
var _local5:Vertex = _v2;
var _local10:int = _arg1._alignment;
var _local11:Number = _arg1.a;
var _local12:Number = _arg1.b;
var _local13:Number = _arg1.c;
var _local14:Number = _arg1.d;
if (_local10 == Plane3D.X_AXIS){
_local7 = ((_local11 * _local3._x) + _local14);
_local8 = ((_local11 * _local4._x) + _local14);
_local9 = ((_local11 * _local5._x) + _local14);
} else {
if (_local10 == Plane3D.Y_AXIS){
_local7 = ((_local12 * _local3._y) + _local14);
_local8 = ((_local12 * _local4._y) + _local14);
_local9 = ((_local12 * _local5._y) + _local14);
} else {
if (_local10 == Plane3D.Z_AXIS){
_local7 = ((_local13 * _local3._z) + _local14);
_local8 = ((_local13 * _local4._z) + _local14);
_local9 = ((_local13 * _local5._z) + _local14);
} else {
_local7 = ((((_local11 * _local3._x) + (_local12 * _local3._y)) + (_local13 * _local3._z)) + _local14);
_local8 = ((((_local11 * _local4._x) + (_local12 * _local4._y)) + (_local13 * _local4._z)) + _local14);
_local9 = ((((_local11 * _local5._x) + (_local12 * _local5._y)) + (_local13 * _local5._z)) + _local14);
};
};
};
if ((((_local7 <= _arg2)) && ((_local7 >= -(_arg2))))){
_local6++;
};
if ((((_local8 <= _arg2)) && ((_local8 >= -(_arg2))))){
_local6++;
};
if ((((_local9 <= _arg2)) && ((_local9 >= -(_arg2))))){
_local6++;
};
return ((_local6 > 1));
}
public function get plane():Plane3D{
var _local1:Number;
var _local2:Number;
var _local3:Number;
if (vertexDirty){
updateVertex();
};
if (((!(_plane)) || (_normalDirty))){
if (!_plane){
_plane = new Plane3D();
};
_local1 = normal.x;
_local2 = normal.y;
_local3 = normal.z;
_plane.a = -(_local1);
_plane.b = -(_local2);
_plane.c = -(_local3);
_plane.d = (((_v0._x * _local1) + (_v0._y * _local2)) + (_v0._z * _local3));
if ((((_local1 == 1)) || ((_local1 == -1)))){
_plane._alignment = Plane3D.X_AXIS;
} else {
if ((((_local2 == 1)) || ((_local2 == -1)))){
_plane._alignment = Plane3D.Y_AXIS;
} else {
if ((((_local3 == 1)) || ((_local3 == -1)))){
_plane._alignment = Plane3D.Z_AXIS;
} else {
_plane._alignment = Plane3D.ANY;
};
};
};
_plane.normalize();
};
return (_plane);
}
}
}//package away3d.core.base
Section 19
//Geometry (away3d.core.base.Geometry)
package away3d.core.base {
import flash.events.*;
import away3d.core.math.*;
import away3d.core.utils.*;
import away3d.materials.*;
import away3d.containers.*;
import flash.utils.*;
import away3d.loaders.data.*;
import away3d.events.*;
import away3d.animators.data.*;
import away3d.sprites.*;
public class Geometry extends EventDispatcher {
var commands:Array;
var indices:Array;
var startIndices:Array;
var faceVOs:Array;
var segmentVOs:Array;
var spriteVOs:Array;
private var _faces:Array;
private var _faceVO:FaceVO;
private var _segments:Array;
private var _segmentVO:SegmentVO;
private var _sprites:Array;
private var _spriteVO:SpriteVO;
private var _vertices:Array;
private var _processed:Dictionary;
private var _vertex:Vertex;
private var _element:Element;
private var _element_vertices:Array;
private var _element_commands:Array;
private var _verticesDirty:Boolean;// = true
private var _dispatchedDimensionsChange:Boolean;
private var _dimensionschanged:GeometryEvent;
private var _neighboursDirty:Boolean;// = true
private var _neighbour01:Dictionary;
private var _neighbour12:Dictionary;
private var _neighbour20:Dictionary;
private var _vertfacesDirty:Boolean;// = true
private var _vertfaces:Dictionary;
private var _vertnormalsDirty:Boolean;// = true
private var _vertnormals:Dictionary;
private var _fNormal:Number3D;
private var _fAngle:Number;
private var _fVectors:Array;
private var clonedvertices:Dictionary;
private var clonedskinvertices:Dictionary;
private var clonedskincontrollers:Dictionary;
private var cloneduvs:Dictionary;
private var _materialData:MaterialData;
private var _index:int;
private var _quarterFacesTotal:int;// = 0
protected var ini:Init;
public var rootBone:Bone;
public var skinVertices:Array;
public var skinControllers:Array;
public var materialDictionary:Dictionary;
public var cloneElementDictionary:Dictionary;
public var graphics:Graphics3D;
public function Geometry():void{
commands = [];
indices = [];
startIndices = [];
faceVOs = [];
segmentVOs = [];
spriteVOs = [];
_faces = [];
_segments = [];
_sprites = [];
_vertices = [];
materialDictionary = new Dictionary(true);
cloneElementDictionary = new Dictionary();
graphics = new Graphics3D();
super();
graphics.geometry = this;
}
function get vertexDirty():Boolean{
var _local2:Vertex;
var _local1:Boolean;
for each (_local2 in vertices) {
if (_local2.getVertexDirty()){
_local1 = true;
};
};
return (_local1);
}
function getFacesByVertex(_arg1:Vertex):Array{
if (_vertfacesDirty){
findVertFaces();
};
return (_vertfaces[_arg1]);
}
function getVertexNormal(_arg1:Vertex):Number3D{
if (_vertfacesDirty){
findVertFaces();
};
if (_vertnormalsDirty){
findVertNormals();
};
return (_vertnormals[_arg1]);
}
public function neighbour01(_arg1:Face):Face{
if (_neighboursDirty){
findNeighbours();
};
return (_neighbour01[_arg1]);
}
public function neighbour12(_arg1:Face):Face{
if (_neighboursDirty){
findNeighbours();
};
return (_neighbour12[_arg1]);
}
public function neighbour20(_arg1:Face):Face{
if (_neighboursDirty){
findNeighbours();
};
return (_neighbour20[_arg1]);
}
function notifyDimensionsChange():void{
if (((_dispatchedDimensionsChange) || (!(hasEventListener(GeometryEvent.DIMENSIONS_CHANGED))))){
return;
};
if (!_dimensionschanged){
_dimensionschanged = new GeometryEvent(GeometryEvent.DIMENSIONS_CHANGED, this);
};
dispatchEvent(_dimensionschanged);
_dispatchedDimensionsChange = true;
}
function addMaterial(_arg1:Element, _arg2:Material):void{
if (!(_materialData = materialDictionary[_arg2])){
_materialData = (materialDictionary[_arg2] = new MaterialData());
_materialData.material = _arg2;
_arg2.addOnMaterialUpdate(onMaterialUpdate);
};
if (_materialData.elements.indexOf(_arg1) == -1){
_materialData.elements.push(_arg1);
};
}
function removeMaterial(_arg1:Element, _arg2:Material):void{
if ((_materialData = materialDictionary[_arg2])){
if ((_index = _materialData.elements.indexOf(_arg1)) != -1){
_materialData.elements.splice(_index, 1);
};
if (!_materialData.elements.length){
delete materialDictionary[_arg2];
_arg2.removeOnMaterialUpdate(onMaterialUpdate);
};
};
}
private function addElement(_arg1:Element):void{
_verticesDirty = true;
_arg1.addOnVertexChange(onVertexChange);
_arg1.addOnVertexValueChange(onVertexValueChange);
_arg1.addOnMappingChange(onMappingChange);
_arg1.parent = this;
notifyDimensionsChange();
}
private function removeElement(_arg1:Element):void{
_verticesDirty = true;
_arg1.removeOnVertexChange(onVertexChange);
_arg1.removeOnVertexValueChange(onVertexValueChange);
_arg1.notifyMappingChange();
_arg1.removeOnMappingChange(onMappingChange);
notifyDimensionsChange();
}
private function findVertFaces():void{
var _local1:Face;
var _local2:Vertex;
var _local3:Vertex;
var _local4:Vertex;
_vertfaces = new Dictionary();
for each (_local1 in faces) {
_local2 = _local1.v0;
if (_vertfaces[_local2] == null){
_vertfaces[_local2] = [_local1];
} else {
_vertfaces[_local2].push(_local1);
};
_local3 = _local1.v1;
if (_vertfaces[_local3] == null){
_vertfaces[_local3] = [_local1];
} else {
_vertfaces[_local3].push(_local1);
};
_local4 = _local1.v2;
if (_vertfaces[_local4] == null){
_vertfaces[_local4] = [_local1];
} else {
_vertfaces[_local4].push(_local1);
};
};
_vertfacesDirty = false;
_vertnormalsDirty = true;
}
private function findVertNormals():void{
var _local1:Vertex;
var _local2:Array;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Face;
var _local7:Number3D;
var _local8:Array;
var _local9:Vertex;
_vertnormals = new Dictionary();
for each (_local1 in vertices) {
_local2 = _vertfaces[_local1];
_local3 = 0;
_local4 = 0;
_local5 = 0;
for each (_local6 in _local2) {
_fNormal = _local6.normal;
_fVectors = [];
_local8 = _local6.vertices;
for each (_local9 in _local8) {
if (_local9 != _local1){
_fVectors.push(new Number3D((_local9.x - _local1.x), (_local9.y - _local1.y), (_local9.z - _local1.z), true));
};
};
_fAngle = Math.acos((_fVectors[0] as Number3D).dot((_fVectors[1] as Number3D)));
_local3 = (_local3 + (_fNormal.x * _fAngle));
_local4 = (_local4 + (_fNormal.y * _fAngle));
_local5 = (_local5 + (_fNormal.z * _fAngle));
};
_local7 = new Number3D(_local3, _local4, _local5);
_local7.normalize();
_vertnormals[_local1] = _local7;
};
_vertnormalsDirty = false;
}
private function onMaterialUpdate(_arg1:MaterialEvent):void{
dispatchEvent(_arg1);
}
private function onMappingChange(_arg1:ElementEvent):void{
dispatchEvent(_arg1);
}
private function onVertexChange(_arg1:ElementEvent):void{
_verticesDirty = true;
if ((_arg1.element is Face)){
(_arg1.element as Face).normalDirty = true;
_vertfacesDirty = true;
};
notifyDimensionsChange();
}
private function onVertexValueChange(_arg1:ElementEvent):void{
if ((_arg1.element is Face)){
(_arg1.element as Face).normalDirty = true;
};
notifyDimensionsChange();
}
private function cloneVertex(_arg1:Vertex):Vertex{
var _local2:Vertex = clonedvertices[_arg1];
if (_local2 == null){
_local2 = _arg1.clone();
_local2.extra = ((_arg1.extra is IClonable)) ? (_arg1.extra as IClonable).clone() : _arg1.extra;
clonedvertices[_arg1] = _local2;
};
return (_local2);
}
private function cloneSkinVertex(_arg1:SkinVertex):SkinVertex{
var _local3:Array;
var _local4:SkinController;
var _local2:SkinVertex = clonedskinvertices[_arg1];
if (_local2 == null){
_local2 = new SkinVertex(cloneVertex(_arg1.skinnedVertex));
_local2.weights = _arg1.weights.concat();
_local3 = _arg1.controllers;
for each (_local4 in _local3) {
_local2.controllers.push(cloneSkinController(_local4));
};
clonedskinvertices[_arg1] = _local2;
};
return (_local2);
}
private function cloneSkinController(_arg1:SkinController):SkinController{
var _local2:SkinController = clonedskincontrollers[_arg1];
if (_local2 == null){
_local2 = new SkinController();
_local2.name = _arg1.name;
_local2.bindMatrix = _arg1.bindMatrix;
clonedskincontrollers[_arg1] = _local2;
};
return (_local2);
}
private function cloneUV(_arg1:UV):UV{
if (_arg1 == null){
return (null);
};
var _local2:UV = cloneduvs[_arg1];
if (_local2 == null){
_local2 = new UV(_arg1._u, _arg1._v);
cloneduvs[_arg1] = _local2;
};
return (_local2);
}
public function set vertices(_arg1:Array):void{
var _local2:int;
var _local3:int = _arg1.length;
var _local4:int = _vertices.length;
if (_local3 == 0){
_vertices = [];
_local2 = 0;
while (_local2 < _local4) {
_vertices[_local2] = null;
_local2++;
};
return;
};
_local2 = 0;
while (_local2 < _local3) {
_vertices[_local2] = _arg1[_local2];
_local2++;
};
}
public function get quarterFacesTotal():int{
return (_quarterFacesTotal);
}
public function get faces():Array{
return (_faces);
}
public function get segments():Array{
return (_segments);
}
public function get sprites():Array{
return (_sprites);
}
public function get elements():Array{
return (_faces.concat(_segments, _sprites));
}
public function get vertices():Array{
if (_verticesDirty){
_verticesDirty = false;
_vertices.length = 0;
indices.length = 0;
commands.length = 0;
startIndices.length = 0;
faceVOs.length = 0;
segmentVOs.length = 0;
spriteVOs.length = 0;
_processed = new Dictionary(true);
for each (_element in elements) {
if (((_element.visible) && ((_element.vertices.length > 0)))){
_element_vertices = _element.vertices;
_element_commands = _element.commands;
startIndices[startIndices.length] = indices.length;
if ((_element is Face)){
_faceVO = (_element as Face).faceVO;
faceVOs[faceVOs.length] = _faceVO;
} else {
if ((_element is Segment)){
_segmentVO = (_element as Segment).segmentVO;
segmentVOs[segmentVOs.length] = _segmentVO;
} else {
if ((_element is Sprite3D)){
_spriteVO = (_element as Sprite3D).spriteVO;
spriteVOs[spriteVOs.length] = _spriteVO;
};
};
};
_index = 0;
while (_index < _element_vertices.length) {
_vertex = _element_vertices[_index];
if (!_processed[_vertex]){
_vertices[_vertices.length] = _vertex;
indices[indices.length] = ((_processed[_vertex] = _vertices.length) - 1);
} else {
indices[indices.length] = (_processed[_vertex] - 1);
};
commands[commands.length] = _element_commands[_index];
_index++;
};
};
};
startIndices[startIndices.length] = indices.length;
};
return (_vertices);
}
public function addFace(_arg1:Face):void{
addElement(_arg1);
if (_arg1.material){
addMaterial(_arg1, _arg1.material);
};
_vertfacesDirty = true;
if (_arg1.v0){
_arg1.v0.geometry = this;
};
if (_arg1.v1){
_arg1.v1.geometry = this;
};
if (_arg1.v2){
_arg1.v2.geometry = this;
};
_faces.push(_arg1);
}
public function removeFace(_arg1:Face):void{
var _local2:int = _faces.indexOf(_arg1);
if (_local2 == -1){
return;
};
removeElement(_arg1);
if (_arg1.material){
removeMaterial(_arg1, _arg1.material);
};
_vertfacesDirty = true;
if (_arg1.v0){
_arg1.v0.geometry = null;
};
if (_arg1.v1){
_arg1.v1.geometry = null;
};
if (_arg1.v2){
_arg1.v2.geometry = null;
};
_faces.splice(_local2, 1);
}
public function addSegment(_arg1:Segment):void{
addElement(_arg1);
if (_arg1.material){
addMaterial(_arg1, _arg1.material);
};
if (_arg1.v0){
_arg1.v0.geometry = this;
};
if (_arg1.v1){
_arg1.v1.geometry = this;
};
_segments.push(_arg1);
}
public function removeSegment(_arg1:Segment):void{
var _local2:int = _segments.indexOf(_arg1);
if (_local2 == -1){
return;
};
removeElement(_arg1);
if (_arg1.material){
removeMaterial(_arg1, _arg1.material);
};
_arg1.v0.geometry = null;
_arg1.v1.geometry = null;
_segments.splice(_local2, 1);
}
public function addSprite(_arg1:Sprite3D):void{
addElement(_arg1);
if (_arg1.material){
addMaterial(_arg1, _arg1.material);
};
_arg1.vertex.geometry = this;
_sprites.push(_arg1);
}
public function removeSprite(_arg1:Sprite3D):void{
var _local2:int = _sprites.indexOf(_arg1);
if (_local2 == -1){
return;
};
removeElement(_arg1);
if (_arg1.material){
removeMaterial(_arg1, _arg1.material);
};
_arg1.vertex.geometry = null;
_sprites.splice(_local2, 1);
}
public function invertFaces():void{
var _local1:Face;
for each (_local1 in _faces) {
_local1.invert();
};
}
public function quarterFaces():void{
var _local2:Face;
_quarterFacesTotal++;
var _local1:Dictionary = new Dictionary();
for each (_local2 in _faces.concat([])) {
quarterFace(_local2, _local1);
};
}
public function quarterFace(_arg1:Face, _arg2:Dictionary=null):void{
if (_arg2 == null){
_arg2 = new Dictionary();
};
var _local3:Vertex = _arg1.v0;
var _local4:Vertex = _arg1.v1;
var _local5:Vertex = _arg1.v2;
if (_arg2[_local3] == null){
_arg2[_local3] = new Dictionary();
};
if (_arg2[_local4] == null){
_arg2[_local4] = new Dictionary();
};
if (_arg2[_local5] == null){
_arg2[_local5] = new Dictionary();
};
var _local6:Vertex = _arg2[_local3][_local4];
if (_local6 == null){
_local6 = Vertex.median(_local3, _local4);
_arg2[_local3][_local4] = _local6;
_arg2[_local4][_local3] = _local6;
};
var _local7:Vertex = _arg2[_local4][_local5];
if (_local7 == null){
_local7 = Vertex.median(_local4, _local5);
_arg2[_local4][_local5] = _local7;
_arg2[_local5][_local4] = _local7;
};
var _local8:Vertex = _arg2[_local5][_local3];
if (_local8 == null){
_local8 = Vertex.median(_local5, _local3);
_arg2[_local5][_local3] = _local8;
_arg2[_local3][_local5] = _local8;
};
var _local9:UV = _arg1.uv0;
var _local10:UV = _arg1.uv1;
var _local11:UV = _arg1.uv2;
var _local12:UV = UV.median(_local9, _local10);
var _local13:UV = UV.median(_local10, _local11);
var _local14:UV = UV.median(_local11, _local9);
var _local15:Material = _arg1.material;
removeFace(_arg1);
addFace(new Face(_local3, _local6, _local8, _local15, _local9, _local12, _local14));
addFace(new Face(_local6, _local4, _local7, _local15, _local12, _local10, _local13));
addFace(new Face(_local8, _local7, _local5, _local15, _local14, _local13, _local11));
addFace(new Face(_local7, _local8, _local6, _local15, _local13, _local14, _local12));
}
public function triFaces():void{
var _local1:Face;
for each (_local1 in _faces.concat([])) {
triFace(_local1);
};
}
public function triFace(_arg1:Face):void{
var _local2:Vertex = _arg1.v0;
var _local3:Vertex = _arg1.v1;
var _local4:Vertex = _arg1.v2;
var _local5:Vertex = new Vertex((((_arg1.v0.x + _arg1.v1.x) + _arg1.v2.x) / 3), (((_arg1.v0.y + _arg1.v1.y) + _arg1.v2.y) / 3), (((_arg1.v0.z + _arg1.v1.z) + _arg1.v2.z) / 3));
var _local6:UV = _arg1.uv0;
var _local7:UV = _arg1.uv1;
var _local8:UV = _arg1.uv2;
var _local9:UV = new UV((((_local6.u + _local7.u) + _local8.u) / 3), (((_local6.v + _local7.v) + _local8.v) / 3));
var _local10:Material = _arg1.material;
removeFace(_arg1);
addFace(new Face(_local2, _local3, _local5, _local10, _local6, _local7, _local9));
addFace(new Face(_local5, _local3, _local4, _local10, _local9, _local7, _local8));
addFace(new Face(_local2, _local5, _local4, _local10, _local6, _local9, _local8));
}
public function splitFaces(_arg1:int=0):void{
var _local2:Face;
_arg1 = ((_arg1)<0) ? 0 : ((_arg1)>2) ? 2 : _arg1;
for each (_local2 in _faces.concat([])) {
splitFace(_local2, _arg1);
};
}
public function splitFace(_arg1:Face, _arg2:int=0):void{
var _local9:Vertex;
var _local10:UV;
var _local3:Vertex = _arg1.v0;
var _local4:Vertex = _arg1.v1;
var _local5:Vertex = _arg1.v2;
var _local6:UV = _arg1.uv0;
var _local7:UV = _arg1.uv1;
var _local8:UV = _arg1.uv2;
var _local11:Material = _arg1.material;
removeFace(_arg1);
switch (_arg2){
case 0:
_local9 = new Vertex(((_arg1.v0.x + _arg1.v1.x) * 0.5), ((_arg1.v0.y + _arg1.v1.y) * 0.5), ((_arg1.v0.z + _arg1.v1.z) * 0.5));
_local10 = new UV(((_local6.u + _local7.u) * 0.5), ((_local6.v + _local7.v) * 0.5));
addFace(new Face(_local9, _local4, _local5, _local11, _local10, _local7, _local8));
addFace(new Face(_local3, _local9, _local5, _local11, _local6, _local10, _local8));
break;
case 1:
_local9 = new Vertex(((_arg1.v1.x + _arg1.v2.x) * 0.5), ((_arg1.v1.y + _arg1.v2.y) * 0.5), ((_arg1.v1.z + _arg1.v2.z) * 0.5));
_local10 = new UV(((_local7.u + _local8.u) * 0.5), ((_local7.v + _local8.v) * 0.5));
addFace(new Face(_local3, _local4, _local9, _local11, _local6, _local7, _local10));
addFace(new Face(_local3, _local9, _local5, _local11, _local6, _local10, _local8));
break;
default:
_local9 = new Vertex(((_arg1.v2.x + _arg1.v0.x) * 0.5), ((_arg1.v2.y + _arg1.v0.y) * 0.5), ((_arg1.v2.z + _arg1.v0.z) * 0.5));
_local10 = new UV(((_local8.u + _local6.u) * 0.5), ((_local8.v + _local6.v) * 0.5));
addFace(new Face(_local3, _local4, _local9, _local11, _local6, _local7, _local10));
addFace(new Face(_local9, _local4, _local5, _local11, _local10, _local7, _local8));
};
}
private function findNeighbours():void{
var _local1:Face;
var _local2:Boolean;
var _local3:Face;
_neighbour01 = new Dictionary();
_neighbour12 = new Dictionary();
_neighbour20 = new Dictionary();
for each (_local1 in _faces) {
_local2 = true;
for each (_local3 in _faces) {
if (_local2){
if (_local1 == _local3){
_local2 = false;
};
} else {
if ((((_local1._v0 == _local3._v2)) && ((_local1._v1 == _local3._v1)))){
_neighbour01[_local1] = _local3;
_neighbour12[_local3] = _local1;
};
if ((((_local1._v0 == _local3._v0)) && ((_local1._v1 == _local3._v2)))){
_neighbour01[_local1] = _local3;
_neighbour20[_local3] = _local1;
};
if ((((_local1._v0 == _local3._v1)) && ((_local1._v1 == _local3._v0)))){
_neighbour01[_local1] = _local3;
_neighbour01[_local3] = _local1;
};
if ((((_local1._v1 == _local3._v2)) && ((_local1._v2 == _local3._v1)))){
_neighbour12[_local1] = _local3;
_neighbour12[_local3] = _local1;
};
if ((((_local1._v1 == _local3._v0)) && ((_local1._v2 == _local3._v2)))){
_neighbour12[_local1] = _local3;
_neighbour20[_local3] = _local1;
};
if ((((_local1._v1 == _local3._v1)) && ((_local1._v2 == _local3._v0)))){
_neighbour12[_local1] = _local3;
_neighbour01[_local3] = _local1;
};
if ((((_local1._v2 == _local3._v2)) && ((_local1._v0 == _local3._v1)))){
_neighbour20[_local1] = _local3;
_neighbour12[_local3] = _local1;
};
if ((((_local1._v2 == _local3._v0)) && ((_local1._v0 == _local3._v2)))){
_neighbour20[_local1] = _local3;
_neighbour20[_local3] = _local1;
};
if ((((_local1._v2 == _local3._v1)) && ((_local1._v0 == _local3._v0)))){
_neighbour20[_local1] = _local3;
_neighbour01[_local3] = _local1;
};
};
};
};
_neighboursDirty = false;
}
public function updateElements():void{
_dispatchedDimensionsChange = false;
if (vertexDirty){
notifyDimensionsChange();
};
}
public function updateMaterials(_arg1:Object3D, _arg2:View3D):void{
var _local3:MaterialData;
for each (_local3 in materialDictionary) {
_local3.material.updateMaterial(_arg1, _arg2);
};
}
public function clone():Geometry{
var _local2:Face;
var _local3:Segment;
var _local4:SkinVertex;
var _local5:SkinController;
var _local6:Face;
var _local7:Segment;
var _local1:Geometry = new Geometry();
clonedvertices = new Dictionary();
cloneduvs = new Dictionary();
if (skinVertices){
clonedskinvertices = new Dictionary(true);
clonedskincontrollers = new Dictionary(true);
_local1.skinVertices = [];
_local1.skinControllers = [];
for each (_local4 in skinVertices) {
_local1.skinVertices.push(cloneSkinVertex(_local4));
};
for each (_local5 in clonedskincontrollers) {
_local1.skinControllers.push(_local5);
};
};
for each (_local2 in _faces) {
_local6 = new Face(cloneVertex(_local2._v0), cloneVertex(_local2._v1), cloneVertex(_local2._v2), _local2.material, cloneUV(_local2._uv0), cloneUV(_local2._uv1), cloneUV(_local2._uv2));
_local1.addFace(_local6);
cloneElementDictionary[_local2] = _local6;
};
for each (_local3 in _segments) {
_local7 = new Segment(cloneVertex(_local3._v0), cloneVertex(_local3._v1), _local3.material);
_local1.addSegment(_local7);
cloneElementDictionary[_local3] = _local7;
};
return (_local1);
}
public function updateVertex(_arg1:Vertex, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Boolean=false):void{
_arg1.setValue(_arg2, _arg3, _arg4);
if (_arg5){
_vertnormalsDirty = true;
};
}
public function addOnDimensionsChange(_arg1:Function):void{
addEventListener(GeometryEvent.DIMENSIONS_CHANGED, _arg1, false, 0, true);
}
public function removeOnDimensionsChange(_arg1:Function):void{
removeEventListener(GeometryEvent.DIMENSIONS_CHANGED, _arg1, false);
}
public function addOnMaterialUpdate(_arg1:Function):void{
addEventListener(MaterialEvent.MATERIAL_UPDATED, _arg1, false, 0, true);
}
public function removeOnMaterialUpdate(_arg1:Function):void{
removeEventListener(MaterialEvent.MATERIAL_UPDATED, _arg1, false);
}
public function addOnMappingChange(_arg1:Function):void{
addEventListener(ElementEvent.MAPPING_CHANGED, _arg1, false, 0, true);
}
public function removeOnMappingChange(_arg1:Function):void{
removeEventListener(ElementEvent.MAPPING_CHANGED, _arg1, false);
}
}
}//package away3d.core.base
Section 20
//Graphics3D (away3d.core.base.Graphics3D)
package away3d.core.base {
import away3d.materials.*;
public class Graphics3D {
private var _geometry:Geometry;
private var _currentFace:Face;
private var _currentMaterial:ColorMaterial;
private var _zOffset:Number;// = 0
public function set geometry(_arg1:Geometry):void{
_geometry = _arg1;
}
public function lineStyle(_arg1:Number=-1, _arg2:int=-1, _arg3:Number=-1):void{
}
public function beginFill(_arg1:int=-1, _arg2:Number=-1):void{
_currentMaterial = new ColorMaterial();
if (_arg1 != -1){
_currentMaterial.color = _arg1;
};
if (_arg2 != -1){
_currentMaterial.alpha = _arg2;
};
if (_currentFace){
_currentFace.material = _currentMaterial;
};
}
public function endFill():void{
}
public function moveTo(_arg1:Number, _arg2:Number):void{
_currentFace.moveTo(_arg1, -(_arg2), _zOffset);
}
public function lineTo(_arg1:Number, _arg2:Number):void{
_currentFace.lineTo(_arg1, -(_arg2), _zOffset);
}
public function curveTo(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):void{
_currentFace.curveTo(_arg1, -(_arg2), _zOffset, _arg3, -(_arg4), _zOffset);
}
public function clear():void{
var _local1:Face;
for each (_local1 in _geometry.faces) {
_geometry.removeFace(_local1);
};
}
public function startNewShape():void{
_currentFace = new Face();
_currentFace.material = _currentMaterial;
_geometry.addFace(_currentFace);
}
}
}//package away3d.core.base
Section 21
//Mesh (away3d.core.base.Mesh)
package away3d.core.base {
import away3d.core.math.*;
import away3d.materials.*;
import away3d.containers.*;
import flash.utils.*;
import away3d.events.*;
import away3d.sprites.*;
import away3d.core.project.*;
public class Mesh extends Object3D {
var _geometry:Geometry;
private var _face:Face;
private var _material:Material;
private var _bitmapMaterial:BitmapMaterial;
private var _back:Material;
public var url:String;
public var type:String;// = "mesh"
public var outline:Material;
public var bothsides:Boolean;
public var indexes:Array;
public function Mesh(_arg1:Object=null){
super(_arg1);
geometry = new Geometry();
outline = ini.getMaterial("outline");
material = ini.getMaterial("material");
back = (ini.getMaterial("back") as Material);
bothsides = ini.getBoolean("bothsides", false);
projectorType = ProjectorType.MESH;
}
private function onMaterialUpdate(_arg1:MaterialEvent):void{
_sessionDirty = true;
}
private function onMappingChange(_arg1:ElementEvent):void{
_sessionDirty = true;
if ((_face = (_arg1.element as Face))){
if (_face.material){
_bitmapMaterial = (_face.material as BitmapMaterial);
} else {
_bitmapMaterial = (_material as BitmapMaterial);
};
if (_bitmapMaterial){
_bitmapMaterial.getFaceMaterialVO(_face.faceVO, this).invalidated = true;
};
};
}
private function onDimensionsChange(_arg1:GeometryEvent):void{
_sessionDirty = true;
notifyDimensionsChange();
}
private function removeMaterial(_arg1:Material):void{
if (!_arg1){
return;
};
_arg1.removeOnMaterialUpdate(onMaterialUpdate);
}
private function addMaterial(_arg1:Material):void{
if (!_arg1){
return;
};
_arg1.addOnMaterialUpdate(onMaterialUpdate);
}
override protected function updateDimensions():void{
var _local2:int;
var _local3:Number;
var _local4:Number;
var _local5:Number3D;
var _local6:Vertex;
var _local1:Array = geometry.vertices.concat();
_local2 = _local1.length;
if (_local2){
if (_scaleX < 0){
_boundingScale = -(_scaleX);
} else {
_boundingScale = _scaleX;
};
if ((((_scaleY < 0)) && ((_boundingScale < -(_scaleY))))){
_boundingScale = -(_scaleY);
} else {
if (_boundingScale < _scaleY){
_boundingScale = _scaleY;
};
};
if ((((_scaleZ < 0)) && ((_boundingScale < -(_scaleZ))))){
_boundingScale = -(_scaleZ);
} else {
if (_boundingScale < _scaleZ){
_boundingScale = _scaleZ;
};
};
_local3 = 0;
_local5 = new Number3D();
for each (_local6 in _local1) {
_local5.sub(_local6.position, _pivotPoint);
_local4 = _local5.modulo2;
if (_local3 < _local4){
_local3 = _local4;
};
};
if (_local3){
_boundingRadius = Math.sqrt(_local3);
} else {
_boundingRadius = 0;
};
_local1.sortOn("x", (Array.DESCENDING | Array.NUMERIC));
_maxX = _local1[0].x;
_minX = _local1[(_local2 - 1)].x;
_local1.sortOn("y", (Array.DESCENDING | Array.NUMERIC));
_maxY = _local1[0].y;
_minY = _local1[(_local2 - 1)].y;
_local1.sortOn("z", (Array.DESCENDING | Array.NUMERIC));
_maxZ = _local1[0].z;
_minZ = _local1[(_local2 - 1)].z;
};
super.updateDimensions();
}
public function get vertices():Array{
return (_geometry.vertices);
}
public function set vertices(_arg1:Array):void{
_geometry.vertices = _arg1;
}
public function get commands():Array{
return (_geometry.commands);
}
public function get indices():Array{
return (_geometry.indices);
}
public function get startIndices():Array{
return (_geometry.startIndices);
}
public function get faceVOs():Array{
return (_geometry.faceVOs);
}
public function get segmentVOs():Array{
return (_geometry.segmentVOs);
}
public function get spriteVOs():Array{
return (_geometry.spriteVOs);
}
public function get faces():Array{
return (_geometry.faces);
}
public function get segments():Array{
return (_geometry.segments);
}
public function get sprites():Array{
return (_geometry.sprites);
}
public function get elements():Array{
return (_geometry.elements);
}
public function get geometry():Geometry{
return (_geometry);
}
public function set geometry(_arg1:Geometry):void{
if (_geometry == _arg1){
return;
};
if (_geometry != null){
_geometry.removeOnMaterialUpdate(onMaterialUpdate);
_geometry.removeOnMappingChange(onMappingChange);
_geometry.removeOnDimensionsChange(onDimensionsChange);
};
_geometry = _arg1;
if (_geometry != null){
_geometry.addOnMaterialUpdate(onMaterialUpdate);
_geometry.addOnMappingChange(onMappingChange);
_geometry.addOnDimensionsChange(onDimensionsChange);
};
}
public function get material():Material{
return (_material);
}
public function set material(_arg1:Material):void{
if ((((_material == _arg1)) && (!((_material == null))))){
return;
};
removeMaterial(_material);
if (_arg1 == null){
_arg1 = new WireColorMaterial();
};
addMaterial((_material = _arg1));
_sessionDirty = true;
}
public function get back():Material{
return (_back);
}
public function set back(_arg1:Material):void{
if (_back == _arg1){
return;
};
removeMaterial(_back);
addMaterial((_back = _arg1));
}
public function addFace(_arg1:Face):void{
_geometry.addFace(_arg1);
if (this.parent){
this.parent.incrementPolyCount(1);
};
}
public function removeFace(_arg1:Face):void{
_geometry.removeFace(_arg1);
if (this.parent){
this.parent.incrementPolyCount(-1);
};
}
public function addSegment(_arg1:Segment):void{
_geometry.addSegment(_arg1);
if (this.parent){
this.parent.incrementPolyCount(1);
};
}
public function removeSegment(_arg1:Segment):void{
_geometry.removeSegment(_arg1);
if (this.parent){
this.parent.incrementPolyCount(-1);
};
}
public function addSprite(_arg1:Sprite3D):void{
_geometry.addSprite(_arg1);
if (this.parent){
this.parent.incrementPolyCount(1);
};
}
public function removeSprite(_arg1:Sprite3D):void{
_geometry.removeSprite(_arg1);
if (this.parent){
this.parent.incrementPolyCount(-1);
};
}
public function invertFaces():void{
_geometry.invertFaces();
}
public function quarterFaces():void{
var _local1:uint = this.faces.length;
_geometry.quarterFaces();
if (this.parent){
this.parent.incrementPolyCount((this.faces.length - _local1));
};
}
public function quarterFace(_arg1:Face):void{
_geometry.quarterFace(_arg1);
if (this.parent){
this.parent.incrementPolyCount(3);
};
}
public function triFaces():void{
var _local1:uint = this.faces.length;
_geometry.triFaces();
if (this.parent){
this.parent.incrementPolyCount((this.faces.length - _local1));
};
}
public function triFace(_arg1:Face):void{
_geometry.triFace(_arg1);
if (this.parent){
this.parent.incrementPolyCount(2);
};
}
public function splitFaces(_arg1:int=0):void{
var _local2:uint = this.faces.length;
_geometry.splitFaces(_arg1);
if (this.parent){
this.parent.incrementPolyCount((this.faces.length - _local2));
};
}
public function splitFace(_arg1:Face, _arg2:int=0):void{
_geometry.splitFace(_arg1, _arg2);
if (this.parent){
this.parent.incrementPolyCount(1);
};
}
public function updateMaterials(_arg1:Object3D, _arg2:View3D):void{
if (_material){
_material.updateMaterial(_arg1, _arg2);
};
if (back){
back.updateMaterial(_arg1, _arg2);
};
geometry.updateMaterials(_arg1, _arg2);
}
override public function clone(_arg1:Object3D=null):Object3D{
var _local2:Mesh = (((_arg1 as Mesh)) || (new Mesh()));
super.clone(_local2);
_local2.type = type;
_local2.material = material;
_local2.outline = outline;
_local2.back = back;
_local2.bothsides = bothsides;
_local2.debugbb = debugbb;
_local2.geometry = geometry;
return (_local2);
}
public function cloneAll(_arg1:Object3D=null):Object3D{
var _local2:Mesh = (((_arg1 as Mesh)) || (new Mesh()));
super.clone(_local2);
_local2.type = type;
_local2.material = material;
_local2.outline = outline;
_local2.back = back;
_local2.bothsides = bothsides;
_local2.debugbb = debugbb;
_local2.geometry = geometry.clone();
return (_local2);
}
public function asAS3Class(_arg1:String=null, _arg2:String="", _arg3:Boolean=false, _arg4:Boolean=false):String{
var refvertices:Dictionary;
var verticeslist:Array;
var refuvs:Dictionary;
var uvslist:Array;
var face:Face;
var uv:UV;
var v:Vertex;
var myPattern:RegExp;
var myPattern2:RegExp;
var f:Face;
var tmp:String;
var classname = _arg1;
var packagename = _arg2;
var round = _arg3;
var animated = _arg4;
classname = ((((classname) || (name))) || ("Away3DObject"));
var source = ((((("package " + packagename) + "\n{\n\timport away3d.core.base.*;\n\timport away3d.core.utils.*;\n") + "\n\tpublic class ") + classname) + " extends Mesh\n\t{\n");
source = (source + "\t\tprivate var varr:Array = [];\n\t\tprivate var uvarr:Array = [];\n\t\tprivate var scaling:Number;\n");
source = (source + "\n\t\tprivate function v(x:Number,y:Number,z:Number):void\n\t\t{\n");
source = (source + "\t\t\tvarr.push(new Vertex(x*scaling, y*scaling, z*scaling));\n\t\t}\n\n");
source = (source + "\t\tprivate function uv(u:Number,v:Number):void\n\t\t{\n");
source = (source + "\t\t\tuvarr.push(new UV(u,v));\n\t\t}\n\n");
source = (source + "\t\tprivate function f(vn0:int, vn1:int, vn2:int, uvn0:int, uvn1:int, uvn2:int):void\n\t\t{\n");
source = (source + "\t\t\taddFace(new Face(varr[vn0],varr[vn1],varr[vn2], null, uvarr[uvn0],uvarr[uvn1],uvarr[uvn2]));\n\t\t}\n\n");
source = (source + (((("\t\tpublic function " + classname) + "(init:Object = null)\n\t\t{\n\t\t\tsuper(init);\n\t\t\tinit = Init.parse(init);\n\t\t\tscaling = init.getNumber(\"scaling\", 1);\n\t\t\tbuild();\n\t\t\ttype = \"") + classname) + "\";\n\t\t}\n\n"));
source = (source + "\t\tprivate function build():void\n\t\t{\n");
refvertices = new Dictionary();
verticeslist = [];
var remembervertex:Function = function (_arg1:Vertex):void{
if (refvertices[_arg1] == null){
refvertices[_arg1] = verticeslist.length;
verticeslist.push(_arg1);
};
};
refuvs = new Dictionary();
uvslist = [];
var rememberuv:Function = function (_arg1:UV):void{
if (_arg1 == null){
return;
};
if (refuvs[_arg1] == null){
refuvs[_arg1] = uvslist.length;
uvslist.push(_arg1);
};
};
for each (face in _geometry.faces) {
remembervertex(face._v0);
remembervertex(face._v1);
remembervertex(face._v2);
rememberuv(face._uv0);
rememberuv(face._uv1);
rememberuv(face._uv2);
};
for each (v in verticeslist) {
source = (source + (round) ? (((((("\t\t\tv(" + v._x.toFixed(4)) + ",") + v._y.toFixed(4)) + ",") + v._z.toFixed(4)) + ");\n") : (((((("\t\t\tv(" + v._x) + ",") + v._y) + ",") + v._z) + ");\n"));
};
for each (uv in uvslist) {
source = (source + (round) ? (((("\t\t\tuv(" + uv._u.toFixed(4)) + ",") + uv._v.toFixed(4)) + ");\n") : (((("\t\t\tuv(" + uv._u) + ",") + uv._v) + ");\n"));
};
if (round){
myPattern2 = new RegExp(".0000", "g");
};
for each (f in _geometry.faces) {
source = (source + (((((((((((("\t\t\tf(" + refvertices[f._v0]) + ",") + refvertices[f._v1]) + ",") + refvertices[f._v2]) + ",") + refuvs[f._uv0]) + ",") + refuvs[f._uv1]) + ",") + refuvs[f._uv2]) + ");\n"));
};
if (round){
source = source.replace(myPattern2, "");
};
source = (source + "\n\t\t}\n\t}\n}");
return (source);
}
public function asXML():XML{
var refvertices:Dictionary;
var verticeslist:Array;
var refuvs:Dictionary;
var uvslist:Array;
var face:Face;
var vn:int;
var v:Vertex;
var uvn:int;
var uv:UV;
var f:Face;
var result:XML = <mesh></mesh>
;
refvertices = new Dictionary();
verticeslist = [];
var remembervertex:Function = function (_arg1:Vertex):void{
if (refvertices[_arg1] == null){
refvertices[_arg1] = verticeslist.length;
verticeslist.push(_arg1);
};
};
refuvs = new Dictionary();
uvslist = [];
var rememberuv:Function = function (_arg1:UV):void{
if (_arg1 == null){
return;
};
if (refuvs[_arg1] == null){
refuvs[_arg1] = uvslist.length;
uvslist.push(_arg1);
};
};
for each (face in _geometry.faces) {
remembervertex(face._v0);
remembervertex(face._v1);
remembervertex(face._v2);
rememberuv(face._uv0);
rememberuv(face._uv1);
rememberuv(face._uv2);
};
vn = 0;
for each (v in verticeslist) {
result.appendChild(new XML((((((((("<vertex id=\"" + ??esc_xattr
) + "\" x=\"") + ??esc_xattr
) + "\" y=\"") + ??esc_xattr
) + "\" z=\"") + ??esc_xattr
) + "\"/>")));
vn = (vn + 1);
};
uvn = 0;
for each (uv in uvslist) {
result.appendChild(new XML((((((("<uv id=\"" + ??esc_xattr
) + "\" u=\"") + ??esc_xattr
) + "\" v=\"") + ??esc_xattr
) + "\"/>")));
uvn = (uvn + 1);
};
for each (f in _geometry.faces) {
result.appendChild(new XML((((((((((((("<face v0=\"" + ??esc_xattr
) + "\" v1=\"") + ??esc_xattr
) + "\" v2=\"") + ??esc_xattr
) + "\" uv0=\"") + ??esc_xattr
) + "\" uv1=\"") + ??esc_xattr
) + "\" uv2=\"") + ??esc_xattr
) + "\"/>")));
};
return (result);
}
public function updateVertex(_arg1:Vertex, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Boolean=false):void{
_geometry.updateVertex(_arg1, _arg2, _arg3, _arg4, _arg5);
}
override public function applyRotations():void{
var _local2:Vertex;
var _local1:Number3D = new Number3D();
for each (_local2 in vertices) {
_local1.x = _local2.x;
_local1.y = _local2.y;
_local1.z = _local2.z;
_local1.rotate(_local1, transform);
updateVertex(_local2, _local1.x, _local1.y, _local1.z, true);
};
geometry.notifyDimensionsChange();
rotationX = 0;
rotationY = 0;
rotationZ = 0;
}
override public function applyPosition(_arg1:Number, _arg2:Number, _arg3:Number):void{
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Vertex;
var _local8:Number3D;
for each (_local7 in vertices) {
_local4 = _local7.x;
_local5 = _local7.y;
_local6 = _local7.z;
_local7.setValue((_local4 - _arg1), (_local5 - _arg2), (_local6 - _arg3));
};
_local8 = new Number3D(_arg1, _arg2, _arg3);
new Number3D(_arg1, _arg2, _arg3).rotate(_local8, _transform);
_local8.add(_local8, position);
moveTo(_local8.x, _local8.y, _local8.z);
}
}
}//package away3d.core.base
Section 22
//Object3D (away3d.core.base.Object3D)
package away3d.core.base {
import flash.display.*;
import flash.events.*;
import away3d.core.math.*;
import away3d.core.light.*;
import away3d.core.utils.*;
import away3d.core.draw.*;
import away3d.containers.*;
import away3d.core.render.*;
import away3d.events.*;
import away3d.animators.*;
import away3d.loaders.utils.*;
import away3d.primitives.*;
import away3d.core.traverse.*;
public class Object3D extends EventDispatcher implements IClonable {
var _mouseEnabled:Boolean;// = true
var _transformDirty:Boolean;
var _transform:Matrix3D;
var _sceneTransformDirty:Boolean;// = true
var _sceneTransform:Matrix3D;
var _localTransformDirty:Boolean;
var _dimensionsDirty:Boolean;// = false
var _boundingRadius:Number;// = 0
var _boundingScale:Number;// = 1
var _maxX:Number;// = 0
var _minX:Number;// = 0
var _maxY:Number;// = 0
var _minY:Number;// = 0
var _maxZ:Number;// = 0
var _minZ:Number;// = 0
var _lookingAtTarget:Number3D;
var _sceneGraphMark:int;// = -1
var _preCulled:Boolean;
var _preCullClassification:int;
var _preSorted:Boolean;
var _collider:Boolean;
var _id:int;
private var _eulers:Number3D;
private var _rotationDirty:Boolean;
var _sessionDirty:Boolean;
var _objectDirty:Boolean;
var _rotationX:Number;// = 0
var _rotationY:Number;// = 0
var _rotationZ:Number;// = 0
var _scaleX:Number;// = 1
var _scaleY:Number;// = 1
var _scaleZ:Number;// = 1
protected var _pivotPoint:Number3D;
private var _scenePivotPoint:Number3D;
var _scene:Scene3D;
private var _oldscene:Scene3D;
private var _parent:ObjectContainer3D;
private var _quaternion:Quaternion;
private var _rot:Number3D;
private var _sca:Number3D;
private var _pivotZero:Boolean;
private var _vector:Number3D;
private var _m:Matrix3D;
private var _xAxis:Number3D;
private var _yAxis:Number3D;
private var _zAxis:Number3D;
private var _parentupdated:Object3DEvent;
private var _transformchanged:Object3DEvent;
private var _scenetransformchanged:Object3DEvent;
private var _scenechanged:Object3DEvent;
private var _sessionchanged:Object3DEvent;
private var _sessionupdated:Object3DEvent;
private var _dimensionschanged:Object3DEvent;
private var _dispatchedDimensionsChange:Boolean;
var _session:AbstractRenderSession;
private var _ownSession:AbstractRenderSession;
private var _ownCanvas:Boolean;
private var _filters:Array;
private var _alpha:Number;
private var _blendMode:String;
private var _renderer:IPrimitiveConsumer;
private var _ownLights:Boolean;
private var _lightsDirty:Boolean;
private var _lightarray:ILightConsumer;
private var _debugBoundingSphere:WireSphere;
private var _debugBoundingBox:WireCube;
private var _visible:Boolean;
private var _playingAnimator:Animator;
protected var ini:Init;
public var pushback:Boolean;
public var pushfront:Boolean;
public var screenXOffset:Number;
public var screenYOffset:Number;
public var screenZOffset:Number;
public var inverseSceneTransform:Matrix3D;
public var name:String;
public var extra:Object;
public var mouseEnabled:Boolean;// = true
public var useHandCursor:Boolean;// = false
public var materialLibrary:MaterialLibrary;
public var animationLibrary:AnimationLibrary;
public var geometryLibrary:GeometryLibrary;
public var debugbb:Boolean;
public var debugbs:Boolean;
public var center:Array;
public var projectorType:String;
private static var toDEGREES:Number = 57.2957795130823;
private static var toRADIANS:Number = 0.0174532925199433;
public function Object3D(_arg1:Object=null):void{
_transform = new Matrix3D();
_sceneTransform = new Matrix3D();
_lookingAtTarget = new Number3D();
_eulers = new Number3D();
_pivotPoint = new Number3D();
_scenePivotPoint = new Number3D();
_quaternion = new Quaternion();
_rot = new Number3D();
_sca = new Number3D();
_vector = new Number3D();
_m = new Matrix3D();
_xAxis = new Number3D();
_yAxis = new Number3D();
_zAxis = new Number3D();
inverseSceneTransform = new Matrix3D();
center = [new Vertex()];
super();
ini = Init.parse(_arg1);
name = ini.getString("name", name);
ownSession = (ini.getObject("ownSession", AbstractRenderSession) as AbstractRenderSession);
ownCanvas = ini.getBoolean("ownCanvas", ownCanvas);
ownLights = ini.getBoolean("ownLights", false);
visible = ini.getBoolean("visible", true);
mouseEnabled = ini.getBoolean("mouseEnabled", mouseEnabled);
useHandCursor = ini.getBoolean("useHandCursor", useHandCursor);
renderer = (ini.getObject("renderer", IPrimitiveConsumer) as IPrimitiveConsumer);
filters = ini.getArray("filters");
alpha = ini.getNumber("alpha", 1);
blendMode = ini.getString("blendMode", BlendMode.NORMAL);
debugbb = ini.getBoolean("debugbb", false);
debugbs = ini.getBoolean("debugbs", false);
pushback = ini.getBoolean("pushback", false);
pushfront = ini.getBoolean("pushfront", false);
screenXOffset = ini.getNumber("screenXOffset", 0);
screenYOffset = ini.getNumber("screenYOffset", 0);
screenZOffset = ini.getNumber("screenZOffset", 0);
x = ini.getNumber("x", 0);
y = ini.getNumber("y", 0);
z = ini.getNumber("z", 0);
rotationX = ini.getNumber("rotationX", 0);
rotationY = ini.getNumber("rotationY", 0);
rotationZ = ini.getNumber("rotationZ", 0);
pivotPoint = ((ini.getNumber3D("pivotPoint")) || (new Number3D()));
extra = ini.getObject("extra");
scale(ini.getNumber("scale", 1));
if ((this is Scene3D)){
_scene = (this as Scene3D);
} else {
parent = (ini.getObject3D("parent") as ObjectContainer3D);
};
_sceneTransformDirty = false;
}
public function get collider():Boolean{
return (_collider);
}
public function set collider(_arg1:Boolean):void{
_collider = _arg1;
}
public function get lookingAtTarget():Number3D{
return (_lookingAtTarget);
}
public function get parentmaxX():Number{
return (((boundingRadius * _boundingScale) + _transform.tx));
}
public function get parentminX():Number{
return (((-(boundingRadius) * _boundingScale) + _transform.tx));
}
public function get parentmaxY():Number{
return (((boundingRadius * _boundingScale) + _transform.ty));
}
public function get parentminY():Number{
return (((-(boundingRadius) * _boundingScale) + _transform.ty));
}
public function get parentmaxZ():Number{
return (((boundingRadius * _boundingScale) + _transform.tz));
}
public function get parentminZ():Number{
return (((-(boundingRadius) * _boundingScale) + _transform.tz));
}
public function get parentBoundingRadius():Number{
return ((boundingRadius * _boundingScale));
}
function notifyParentUpdate():void{
if (((_ownCanvas) && (_parent))){
_parent._sessionDirty = true;
};
if (!hasEventListener(Object3DEvent.PARENT_UPDATED)){
return;
};
if (!_parentupdated){
_parentupdated = new Object3DEvent(Object3DEvent.PARENT_UPDATED, this);
};
dispatchEvent(_parentupdated);
}
function notifyTransformChange():void{
_localTransformDirty = false;
if (!hasEventListener(Object3DEvent.TRANSFORM_CHANGED)){
return;
};
if (!_transformchanged){
_transformchanged = new Object3DEvent(Object3DEvent.TRANSFORM_CHANGED, this);
};
dispatchEvent(_transformchanged);
}
function notifySceneTransformChange():void{
if (_sceneTransformDirty){
return;
};
_sceneTransformDirty = true;
_objectDirty = true;
if (!hasEventListener(Object3DEvent.SCENETRANSFORM_CHANGED)){
return;
};
if (!_scenetransformchanged){
_scenetransformchanged = new Object3DEvent(Object3DEvent.SCENETRANSFORM_CHANGED, this);
};
dispatchEvent(_scenetransformchanged);
}
function notifySceneChange():void{
notifySceneTransformChange();
if (!hasEventListener(Object3DEvent.SCENE_CHANGED)){
return;
};
if (!_scenechanged){
_scenechanged = new Object3DEvent(Object3DEvent.SCENE_CHANGED, this);
};
dispatchEvent(_scenechanged);
}
function notifySessionChange():void{
changeSession();
if (!hasEventListener(Object3DEvent.SESSION_CHANGED)){
return;
};
if (!_sessionchanged){
_sessionchanged = new Object3DEvent(Object3DEvent.SESSION_CHANGED, this);
};
dispatchEvent(_sessionchanged);
}
function notifySessionUpdate():void{
if (_scene){
_scene.updatedSessions[_session] = _session;
};
if (!hasEventListener(Object3DEvent.SESSION_UPDATED)){
return;
};
if (!_sessionupdated){
_sessionupdated = new Object3DEvent(Object3DEvent.SESSION_UPDATED, this);
};
dispatchEvent(_sessionupdated);
}
function notifyDimensionsChange():void{
_dimensionsDirty = true;
if (((_dispatchedDimensionsChange) || (!(hasEventListener(Object3DEvent.DIMENSIONS_CHANGED))))){
return;
};
if (!_dimensionschanged){
_dimensionschanged = new Object3DEvent(Object3DEvent.DIMENSIONS_CHANGED, this);
};
dispatchEvent(_dimensionschanged);
_dispatchedDimensionsChange = true;
}
function dispatchMouseEvent(_arg1:MouseEvent3D):Boolean{
if (!hasEventListener(_arg1.type)){
return (false);
};
dispatchEvent(_arg1);
return (true);
}
function onAnimatorStart(_arg1:AnimatorEvent):void{
if (_playingAnimator){
_playingAnimator.stop();
};
_playingAnimator = _arg1.animator;
}
function onAnimatorStop(_arg1:AnimatorEvent):void{
_playingAnimator = null;
}
private function onSessionUpdate(_arg1:SessionEvent):void{
if ((_arg1.target is BitmapRenderSession)){
_scene.updatedSessions[_arg1.target] = _arg1.target;
};
}
private function updateSceneTransform():void{
_sceneTransform.multiply(_parent.sceneTransform, transform);
if (!_pivotZero){
_scenePivotPoint.rotate(_pivotPoint, _sceneTransform);
_sceneTransform.tx = (_sceneTransform.tx - _scenePivotPoint.x);
_sceneTransform.ty = (_sceneTransform.ty - _scenePivotPoint.y);
_sceneTransform.tz = (_sceneTransform.tz - _scenePivotPoint.z);
};
inverseSceneTransform.inverse(_sceneTransform);
_sceneTransformDirty = false;
}
private function updateRotation():void{
_rot.matrix2euler(_transform);
_rotationX = _rot.x;
_rotationY = _rot.y;
_rotationZ = _rot.z;
_rotationDirty = false;
}
private function onParentUpdate(_arg1:Object3DEvent):void{
_sessionDirty = true;
dispatchEvent(_arg1);
}
private function onParentSessionChange(_arg1:Object3DEvent):void{
if (((_ownSession) && (_arg1.object.parent))){
_arg1.object.parent.session.removeChildSession(_ownSession);
};
if (((_ownSession) && (_parent.session))){
_parent.session.addChildSession(_ownSession);
};
if (((!(_ownSession)) && (!((_session == _parent.session))))){
changeSession();
dispatchEvent(_arg1);
};
}
private function onParentSceneChange(_arg1:Object3DEvent):void{
if (_scene){
_scene.clearId(_id);
};
_scene = _parent.scene;
if (_scene){
_scene.setId(this);
};
notifySceneChange();
}
private function onParentTransformChange(_arg1:Object3DEvent):void{
notifySceneTransformChange();
}
private function updateLights():void{
if (!_ownLights){
_lightarray = parent.lightarray;
} else {
_lightarray = new LightArray();
};
_lightsDirty = false;
}
private function changeSession():void{
if (_ownSession){
_session = _ownSession;
} else {
if (_parent){
_session = _parent.session;
} else {
_session = null;
};
};
_sessionDirty = true;
}
protected function updateTransform():void{
if (_rotationDirty){
updateRotation();
};
_quaternion.euler2quaternion(_rotationY, _rotationZ, -(_rotationX));
_transform.quaternion2matrix(_quaternion);
_transform.scale(_transform, _scaleX, _scaleY, _scaleZ);
_transformDirty = false;
_localTransformDirty = true;
}
protected function updateDimensions():void{
_dimensionsDirty = false;
_dispatchedDimensionsChange = false;
if (debugbb){
if (!_debugBoundingBox){
_debugBoundingBox = new WireCube({material:"#333333"});
_scene.setId(_debugBoundingBox);
};
if (_boundingRadius){
_debugBoundingBox.visible = true;
_debugBoundingBox.v000.setValue(_minX, _minY, _minZ);
_debugBoundingBox.v100.setValue(_maxX, _minY, _minZ);
_debugBoundingBox.v010.setValue(_minX, _maxY, _minZ);
_debugBoundingBox.v110.setValue(_maxX, _maxY, _minZ);
_debugBoundingBox.v001.setValue(_minX, _minY, _maxZ);
_debugBoundingBox.v101.setValue(_maxX, _minY, _maxZ);
_debugBoundingBox.v011.setValue(_minX, _maxY, _maxZ);
_debugBoundingBox.v111.setValue(_maxX, _maxY, _maxZ);
} else {
debugBoundingBox.visible = false;
};
};
if (debugbs){
if (!_debugBoundingSphere){
_debugBoundingSphere = new WireSphere({material:"#cyan", segmentsW:16, segmentsH:12});
_scene.setId(_debugBoundingSphere);
};
if (_boundingRadius){
_debugBoundingSphere.visible = true;
_debugBoundingSphere.radius = _boundingRadius;
_debugBoundingSphere._primitiveDirty = true;
_debugBoundingSphere.updateObject();
_debugBoundingSphere.applyPosition(-(_pivotPoint.x), -(_pivotPoint.y), -(_pivotPoint.z));
} else {
debugBoundingSphere.visible = false;
};
};
}
public function get debugBoundingBox():WireCube{
if (((_dimensionsDirty) || (!(_debugBoundingBox)))){
updateDimensions();
};
return (_debugBoundingBox);
}
public function get debugBoundingSphere():WireSphere{
if (((_dimensionsDirty) || (!(_debugBoundingSphere)))){
updateDimensions();
};
return (_debugBoundingSphere);
}
public function get session():AbstractRenderSession{
return (_session);
}
public function get boundingRadius():Number{
if (_dimensionsDirty){
updateDimensions();
};
return (_boundingRadius);
}
public function get maxX():Number{
if (_dimensionsDirty){
updateDimensions();
};
return (_maxX);
}
public function get minX():Number{
if (_dimensionsDirty){
updateDimensions();
};
return (_minX);
}
public function get maxY():Number{
if (_dimensionsDirty){
updateDimensions();
};
return (_maxY);
}
public function get minY():Number{
if (_dimensionsDirty){
updateDimensions();
};
return (_minY);
}
public function get maxZ():Number{
if (_dimensionsDirty){
updateDimensions();
};
return (_maxZ);
}
public function get minZ():Number{
if (_dimensionsDirty){
updateDimensions();
};
return (_minZ);
}
public function get objectWidth():Number{
if (_dimensionsDirty){
updateDimensions();
};
return ((_maxX - _minX));
}
public function get objectHeight():Number{
if (_dimensionsDirty){
updateDimensions();
};
return ((_maxY - _minY));
}
public function get objectDepth():Number{
if (_dimensionsDirty){
updateDimensions();
};
return ((_maxZ - _minZ));
}
public function get visible():Boolean{
return (_visible);
}
public function set visible(_arg1:Boolean):void{
if (_visible == _arg1){
return;
};
_visible = _arg1;
_sessionDirty = true;
notifyParentUpdate();
}
public function get ownCanvas():Boolean{
return (_ownCanvas);
}
public function set ownCanvas(_arg1:Boolean):void{
if (_ownCanvas == _arg1){
return;
};
if (_arg1){
ownSession = new SpriteRenderSession();
} else {
if ((this is Scene3D)){
throw (new Error("Scene cannot have ownCanvas set to false"));
};
ownSession = null;
};
}
public function get renderer():IPrimitiveConsumer{
return (_renderer);
}
public function set renderer(_arg1:IPrimitiveConsumer):void{
if (_renderer == _arg1){
return;
};
_renderer = _arg1;
if (_ownSession){
_ownSession.renderer = _renderer;
};
_sessionDirty = true;
}
public function get filters():Array{
return (_filters);
}
public function set filters(_arg1:Array):void{
if (_filters == _arg1){
return;
};
_filters = _arg1;
if (_ownSession){
_ownSession.filters = _filters;
};
}
public function get alpha():Number{
return (_alpha);
}
public function set alpha(_arg1:Number):void{
if (_alpha == _arg1){
return;
};
_alpha = _arg1;
if (_ownSession){
_ownSession.alpha = _alpha;
};
}
public function get blendMode():String{
return (_blendMode);
}
public function set blendMode(_arg1:String):void{
if (_blendMode == _arg1){
return;
};
_blendMode = _arg1;
if (_ownSession){
_ownSession.blendMode = _blendMode;
};
}
public function get ownSession():AbstractRenderSession{
return (_ownSession);
}
public function set ownSession(_arg1:AbstractRenderSession):void{
if (_ownSession == _arg1){
return;
};
if (_ownSession){
if (((_parent) && (_parent.session))){
_parent.session.removeChildSession(_ownSession);
};
_ownSession.clearChildSessions();
_ownSession.renderer = null;
_ownSession.internalRemoveOwnSession(this);
_ownSession.removeOnSessionUpdate(onSessionUpdate);
} else {
if (((_parent) && (_parent.session))){
_parent.session.internalRemoveOwnSession(this);
};
};
_ownSession = _arg1;
if (_ownSession){
if (((_parent) && (_parent.session))){
_parent.session.addChildSession(_ownSession);
};
_ownSession.clearChildSessions();
_ownSession.renderer = _renderer;
_ownSession.filters = _filters;
_ownSession.alpha = _alpha;
_ownSession.blendMode = _blendMode;
_ownSession.internalAddOwnSession(this);
_ownSession.addOnSessionUpdate(onSessionUpdate);
} else {
if ((this is Scene3D)){
throw (new Error("Scene cannot have ownSession set to null"));
};
if (((_parent) && (_parent.session))){
_parent.session.internalAddOwnSession(this);
};
};
if (_ownSession){
_ownCanvas = true;
} else {
_ownCanvas = false;
};
notifySessionChange();
}
public function get x():Number{
return (_transform.tx);
}
public function set x(_arg1:Number):void{
if (isNaN(_arg1)){
throw (new Error("isNaN(x)"));
};
if (_transform.tx == _arg1){
return;
};
if (_arg1 == Infinity){
Debug.warning("x == Infinity");
};
if (_arg1 == -(Infinity)){
Debug.warning("x == -Infinity");
};
_transform.tx = _arg1;
_localTransformDirty = true;
notifySceneTransformChange();
}
public function get y():Number{
return (_transform.ty);
}
public function set y(_arg1:Number):void{
if (isNaN(_arg1)){
throw (new Error("isNaN(y)"));
};
if (_transform.ty == _arg1){
return;
};
if (_arg1 == Infinity){
Debug.warning("y == Infinity");
};
if (_arg1 == -(Infinity)){
Debug.warning("y == -Infinity");
};
_transform.ty = _arg1;
_localTransformDirty = true;
notifySceneTransformChange();
}
public function get z():Number{
return (_transform.tz);
}
public function set z(_arg1:Number):void{
if (isNaN(_arg1)){
throw (new Error("isNaN(z)"));
};
if (_transform.tz == _arg1){
return;
};
if (_arg1 == Infinity){
Debug.warning("z == Infinity");
};
if (_arg1 == -(Infinity)){
Debug.warning("z == -Infinity");
};
_transform.tz = _arg1;
_localTransformDirty = true;
notifySceneTransformChange();
}
public function get rotationX():Number{
if (_rotationDirty){
updateRotation();
};
return ((_rotationX * toDEGREES));
}
public function set rotationX(_arg1:Number):void{
if (rotationX == _arg1){
return;
};
_rotationX = (_arg1 * toRADIANS);
_transformDirty = true;
notifySceneTransformChange();
}
public function get rotationY():Number{
if (_rotationDirty){
updateRotation();
};
return ((_rotationY * toDEGREES));
}
public function set rotationY(_arg1:Number):void{
if (rotationY == _arg1){
return;
};
_rotationY = (_arg1 * toRADIANS);
_transformDirty = true;
notifySceneTransformChange();
}
public function get rotationZ():Number{
if (_rotationDirty){
updateRotation();
};
return ((_rotationZ * toDEGREES));
}
public function set rotationZ(_arg1:Number):void{
if (rotationZ == _arg1){
return;
};
_rotationZ = (_arg1 * toRADIANS);
_transformDirty = true;
notifySceneTransformChange();
}
public function get scaleX():Number{
return (_scaleX);
}
public function set scaleX(_arg1:Number):void{
if (_scaleX == _arg1){
return;
};
_scaleX = _arg1;
_transformDirty = true;
_dimensionsDirty = true;
notifySceneTransformChange();
}
public function get scaleY():Number{
return (_scaleY);
}
public function set scaleY(_arg1:Number):void{
if (_scaleY == _arg1){
return;
};
_scaleY = _arg1;
_transformDirty = true;
_dimensionsDirty = true;
notifySceneTransformChange();
}
public function get scaleZ():Number{
return (_scaleZ);
}
public function set scaleZ(_arg1:Number):void{
if (_scaleZ == _arg1){
return;
};
_scaleZ = _arg1;
_transformDirty = true;
_dimensionsDirty = true;
notifySceneTransformChange();
}
public function get position():Number3D{
return (transform.position);
}
public function set position(_arg1:Number3D):void{
_transform.tx = _arg1.x;
_transform.ty = _arg1.y;
_transform.tz = _arg1.z;
_localTransformDirty = true;
notifySceneTransformChange();
}
public function get eulers():Number3D{
if (_rotationDirty){
updateRotation();
};
_eulers.x = (_rotationX * toDEGREES);
_eulers.y = (_rotationY * toDEGREES);
_eulers.z = (_rotationZ * toDEGREES);
return (_eulers);
}
public function set eulers(_arg1:Number3D):void{
_rotationX = (_arg1.x * toRADIANS);
_rotationY = (_arg1.y * toRADIANS);
_rotationZ = (_arg1.z * toRADIANS);
_transformDirty = true;
notifySceneTransformChange();
}
public function get transform():Matrix3D{
if (_transformDirty){
updateTransform();
};
return (_transform);
}
public function set transform(_arg1:Matrix3D):void{
if (_transform.compare(_arg1)){
return;
};
_transform.clone(_arg1);
_transformDirty = false;
_rotationDirty = true;
_localTransformDirty = true;
_sca.matrix2scale(_transform);
if (((((!((_scaleX == _sca.x))) || (!((_scaleY == _sca.y))))) || (!((_scaleZ == _sca.z))))){
_scaleX = _sca.x;
_scaleY = _sca.y;
_scaleZ = _sca.z;
_dimensionsDirty = true;
};
notifySceneTransformChange();
}
public function get parent():ObjectContainer3D{
return (_parent);
}
public function set parent(_arg1:ObjectContainer3D):void{
if ((this is Scene3D)){
throw (new Error("Scene cannot be parented"));
};
if (_arg1 == _parent){
return;
};
_oldscene = _scene;
if (_parent != null){
_parent.removeOnParentUpdate(onParentUpdate);
_parent.removeOnSessionChange(onParentSessionChange);
_parent.removeOnSceneChange(onParentSceneChange);
_parent.removeOnSceneTransformChange(onParentTransformChange);
_parent.internalRemoveChild(this);
if (((_ownSession) && (_parent.session))){
_parent.session.removeChildSession(_ownSession);
};
};
_parent = _arg1;
_scene = (_parent) ? _parent.scene : null;
if (_parent != null){
_parent.internalAddChild(this);
_parent.addOnParentUpdate(onParentUpdate);
_parent.addOnSessionChange(onParentSessionChange);
_parent.addOnSceneChange(onParentSceneChange);
_parent.addOnSceneTransformChange(onParentTransformChange);
if (((_ownSession) && (_parent.session))){
_parent.session.addChildSession(_ownSession);
};
notifySceneTransformChange();
};
if (_scene != _oldscene){
if (_oldscene){
_oldscene.clearId(_id);
};
if (_scene){
_scene.setId(this);
};
notifySceneChange();
};
if (((!(_ownSession)) && (((!(_parent)) || (!((_session == _parent.session))))))){
notifySessionChange();
};
_localTransformDirty = true;
}
public function get sceneTransform():Matrix3D{
if ((((_scene == null)) || ((_scene == this)))){
_sceneTransformDirty = false;
return (transform);
};
if (_transformDirty){
updateTransform();
};
if (_sceneTransformDirty){
updateSceneTransform();
};
if (_localTransformDirty){
notifyTransformChange();
};
return (_sceneTransform);
}
public function get ownLights():Boolean{
return (_ownLights);
}
public function set ownLights(_arg1:Boolean):void{
_ownLights = _arg1;
_lightsDirty = true;
}
public function get pivotPoint():Number3D{
return (_pivotPoint);
}
public function set pivotPoint(_arg1:Number3D):void{
_pivotPoint.clone(_arg1);
_pivotZero = ((((!(_pivotPoint.x)) && (!(_pivotPoint.y)))) && (!(_pivotPoint.z)));
_dimensionsDirty = true;
notifyParentUpdate();
notifySceneTransformChange();
}
public function get lightarray():ILightConsumer{
if (_lightsDirty){
updateLights();
};
return (_lightarray);
}
public function get scenePosition():Number3D{
return (sceneTransform.position);
}
public function get scene():Scene3D{
return (_scene);
}
public function get pivotZero():Boolean{
return (_pivotZero);
}
public function get scenePivotPoint():Number3D{
if (_sceneTransformDirty){
updateSceneTransform();
};
return (_scenePivotPoint);
}
public function get id():int{
return (_id);
}
public function updateObject():void{
if (_objectDirty){
if (_scene){
_scene.updatedObjects[this] = this;
};
_objectDirty = false;
_sessionDirty = true;
};
}
public function updateSession():void{
if (_sessionDirty){
notifySessionUpdate();
_sessionDirty = false;
};
}
public function scale(_arg1:Number):void{
_scaleX = (_scaleY = (_scaleZ = _arg1));
_transformDirty = true;
_dimensionsDirty = true;
notifySceneTransformChange();
}
public function distanceTo(_arg1:Object3D):Number{
var _local2:Matrix3D = ((_scene == this)) ? transform : sceneTransform;
var _local3:Matrix3D = ((_arg1.scene == _arg1)) ? _arg1.transform : _arg1.sceneTransform;
var _local4:Number = (_local2.tx - _local3.tx);
var _local5:Number = (_local2.ty - _local3.ty);
var _local6:Number = (_local2.tz - _local3.tz);
return (Math.sqrt((((_local4 * _local4) + (_local5 * _local5)) + (_local6 * _local6))));
}
public function traverse(_arg1:Traverser):void{
if (_arg1.match(this)){
_arg1.enter(this);
_arg1.apply(this);
_arg1.leave(this);
};
}
public function moveForward(_arg1:Number):void{
translate(Number3D.FORWARD, _arg1);
}
public function moveBackward(_arg1:Number):void{
translate(Number3D.BACKWARD, _arg1);
}
public function moveLeft(_arg1:Number):void{
translate(Number3D.LEFT, _arg1);
}
public function moveRight(_arg1:Number):void{
translate(Number3D.RIGHT, _arg1);
}
public function moveUp(_arg1:Number):void{
translate(Number3D.UP, _arg1);
}
public function moveDown(_arg1:Number):void{
translate(Number3D.DOWN, _arg1);
}
public function moveTo(_arg1:Number, _arg2:Number, _arg3:Number):void{
if ((((((_transform.tx == _arg1)) && ((_transform.ty == _arg2)))) && ((_transform.tz == _arg3)))){
return;
};
_transform.tx = _arg1;
_transform.ty = _arg2;
_transform.tz = _arg3;
_localTransformDirty = true;
notifySceneTransformChange();
}
public function centerPivot():void{
var _local1:Number3D = new Number3D(((maxX + minX) / 2), ((maxY + minY) / 2), ((maxZ + minZ) / 2));
movePivot(_local1.x, _local1.y, _local1.z);
_local1.transform(_local1, transform);
moveTo((x + _local1.x), (y + _local1.y), (z + _local1.z));
}
public function movePivot(_arg1:Number, _arg2:Number, _arg3:Number):void{
_pivotPoint.x = _arg1;
_pivotPoint.y = _arg2;
_pivotPoint.z = _arg3;
_pivotZero = ((((!(_arg1)) && (!(_arg2)))) && (!(_arg3)));
_dimensionsDirty = true;
notifyParentUpdate();
notifySceneTransformChange();
}
public function translate(_arg1:Number3D, _arg2:Number):void{
_arg1.normalize();
_vector.rotate(_arg1, transform);
x = (x + (_arg2 * _vector.x));
y = (y + (_arg2 * _vector.y));
z = (z + (_arg2 * _vector.z));
}
public function pitch(_arg1:Number):void{
rotate(Number3D.RIGHT, _arg1);
}
public function yaw(_arg1:Number):void{
rotate(Number3D.UP, _arg1);
}
public function roll(_arg1:Number):void{
rotate(Number3D.FORWARD, _arg1);
}
public function rotateTo(_arg1:Number, _arg2:Number, _arg3:Number):void{
_rotationX = (_arg1 * toRADIANS);
_rotationY = (_arg2 * toRADIANS);
_rotationZ = (_arg3 * toRADIANS);
_rotationDirty = false;
_transformDirty = true;
}
public function rotate(_arg1:Number3D, _arg2:Number):void{
_arg1.normalize();
_m.rotationMatrix(_arg1.x, _arg1.y, _arg1.z, (_arg2 * toRADIANS));
_transform.multiply3x3(transform, _m);
_rotationDirty = true;
_localTransformDirty = true;
notifySceneTransformChange();
}
public function lookAt(_arg1:Number3D, _arg2:Number3D=null):void{
_lookingAtTarget = _arg1;
_zAxis.sub(_arg1, position);
_zAxis.normalize();
if ((((_zAxis.modulo > 0.1)) && (((((!((_zAxis.x == _transform.sxz))) || (!((_zAxis.y == _transform.syz))))) || (!((_zAxis.z == _transform.szz))))))){
_xAxis.cross(_zAxis, ((_arg2) || (Number3D.UP)));
if (!_xAxis.modulo2){
_xAxis.cross(_zAxis, Number3D.BACKWARD);
};
_xAxis.normalize();
_yAxis.cross(_zAxis, _xAxis);
_yAxis.normalize();
_transform.sxx = (_xAxis.x * _scaleX);
_transform.syx = (_xAxis.y * _scaleX);
_transform.szx = (_xAxis.z * _scaleX);
_transform.sxy = (-(_yAxis.x) * _scaleY);
_transform.syy = (-(_yAxis.y) * _scaleY);
_transform.szy = (-(_yAxis.z) * _scaleY);
_transform.sxz = (_zAxis.x * _scaleZ);
_transform.syz = (_zAxis.y * _scaleZ);
_transform.szz = (_zAxis.z * _scaleZ);
_transformDirty = false;
_rotationDirty = true;
_localTransformDirty = true;
notifySceneTransformChange();
};
}
public function applyRotations():void{
throw (new Error("Not implemented in Object3D - Use Mesh or ObjectContainer3D"));
}
public function applyPosition(_arg1:Number, _arg2:Number, _arg3:Number):void{
throw (new Error("Not implemented in Object3D - Use Mesh or ObjectContainer3D"));
}
override public function toString():String{
return ((((((((name) ? name : "$" + ": x:") + Math.round(x)) + " y:") + Math.round(y)) + " z:") + Math.round(z)));
}
public function tick(_arg1:int):void{
}
public function clone(_arg1:Object3D=null):Object3D{
var _local2:Object3D = ((_arg1) || (new Object3D()));
_local2.transform = transform;
_local2.name = name;
_local2.ownCanvas = _ownCanvas;
_local2.renderer = _renderer;
_local2.filters = _filters.concat();
_local2.blendMode = blendMode;
_local2.alpha = _alpha;
_local2.visible = visible;
_local2.mouseEnabled = mouseEnabled;
_local2.useHandCursor = useHandCursor;
_local2.pushback = pushback;
_local2.pushfront = pushfront;
_local2.screenZOffset = screenZOffset;
_local2.pivotPoint = pivotPoint;
_local2.projectorType = projectorType;
_local2.extra = ((extra is IClonable)) ? (extra as IClonable).clone() : extra;
return (_local2);
}
public function addOnParentUpdate(_arg1:Function):void{
addEventListener(Object3DEvent.PARENT_UPDATED, _arg1, false, 0, true);
}
public function removeOnParentUpdate(_arg1:Function):void{
removeEventListener(Object3DEvent.PARENT_UPDATED, _arg1, false);
}
public function addOnTransformChange(_arg1:Function):void{
addEventListener(Object3DEvent.TRANSFORM_CHANGED, _arg1, false, 0, true);
}
public function removeOnTransformChange(_arg1:Function):void{
removeEventListener(Object3DEvent.TRANSFORM_CHANGED, _arg1, false);
}
public function addOnSceneTransformChange(_arg1:Function):void{
addEventListener(Object3DEvent.SCENETRANSFORM_CHANGED, _arg1, false, 0, true);
}
public function removeOnSceneTransformChange(_arg1:Function):void{
removeEventListener(Object3DEvent.SCENETRANSFORM_CHANGED, _arg1, false);
}
public function addOnSceneChange(_arg1:Function):void{
addEventListener(Object3DEvent.SCENE_CHANGED, _arg1, false, 0, true);
}
public function removeOnSceneChange(_arg1:Function):void{
removeEventListener(Object3DEvent.SCENE_CHANGED, _arg1, false);
}
public function addOnSessionChange(_arg1:Function):void{
addEventListener(Object3DEvent.SESSION_CHANGED, _arg1, false, 0, true);
}
public function removeOnSessionChange(_arg1:Function):void{
removeEventListener(Object3DEvent.SESSION_CHANGED, _arg1, false);
}
public function addOnDimensionsChange(_arg1:Function):void{
addEventListener(Object3DEvent.DIMENSIONS_CHANGED, _arg1, false, 0, true);
}
public function removeOnDimensionsChange(_arg1:Function):void{
removeEventListener(Object3DEvent.DIMENSIONS_CHANGED, _arg1, false);
}
public function addOnMouseMove(_arg1:Function):void{
addEventListener(MouseEvent3D.MOUSE_MOVE, _arg1, false, 0, false);
}
public function removeOnMouseMove(_arg1:Function):void{
removeEventListener(MouseEvent3D.MOUSE_MOVE, _arg1, false);
}
public function addOnMouseDown(_arg1:Function):void{
addEventListener(MouseEvent3D.MOUSE_DOWN, _arg1, false, 0, false);
}
public function removeOnMouseDown(_arg1:Function):void{
removeEventListener(MouseEvent3D.MOUSE_DOWN, _arg1, false);
}
public function addOnMouseUp(_arg1:Function):void{
addEventListener(MouseEvent3D.MOUSE_UP, _arg1, false, 0, false);
}
public function removeOnMouseUp(_arg1:Function):void{
removeEventListener(MouseEvent3D.MOUSE_UP, _arg1, false);
}
public function addOnMouseOver(_arg1:Function):void{
addEventListener(MouseEvent3D.MOUSE_OVER, _arg1, false, 0, false);
}
public function removeOnMouseOver(_arg1:Function):void{
removeEventListener(MouseEvent3D.MOUSE_OVER, _arg1, false);
}
public function addOnMouseOut(_arg1:Function):void{
addEventListener(MouseEvent3D.MOUSE_OUT, _arg1, false, 0, false);
}
public function removeOnMouseOut(_arg1:Function):void{
removeEventListener(MouseEvent3D.MOUSE_OUT, _arg1, false);
}
public function addOnRollOver(_arg1:Function):void{
addEventListener(MouseEvent3D.ROLL_OVER, _arg1, false, 0, false);
}
public function removeOnRollOver(_arg1:Function):void{
removeEventListener(MouseEvent3D.ROLL_OVER, _arg1, false);
}
public function addOnRollOut(_arg1:Function):void{
addEventListener(MouseEvent3D.ROLL_OUT, _arg1, false, 0, false);
}
public function removeOnRollOut(_arg1:Function):void{
removeEventListener(MouseEvent3D.ROLL_OUT, _arg1, false);
}
}
}//package away3d.core.base
Section 23
//Segment (away3d.core.base.Segment)
package away3d.core.base {
import flash.events.*;
import away3d.core.math.*;
import away3d.core.utils.*;
import away3d.materials.*;
import away3d.core.geom.*;
public class Segment extends Element {
var _v0:Vertex;
var _v1:Vertex;
var _material:Material;
public var segmentVO:SegmentVO;
public function Segment(_arg1:Vertex=null, _arg2:Vertex=null, _arg3:Material=null){
segmentVO = new SegmentVO();
super();
if (_arg1){
this.v0 = _arg1;
};
if (_arg2){
this.v1 = _arg2;
};
this.material = _arg3;
vertexDirty = true;
}
private function onVertexValueChange(_arg1:Event):void{
notifyVertexValueChange();
}
private function addVertexAt(_arg1:uint, _arg2:Vertex, _arg3:String):void{
if (((_vertices[_arg1]) && ((_vertices[_arg1] == _arg2)))){
return;
};
if (_vertices[_arg1]){
_index = _vertices[_arg1].parents.indexOf(this);
if (_index != -1){
_vertices[_arg1].parents.splice(_index, 1);
};
};
_commands[_arg1] = (segmentVO.commands[_arg1] = _arg3);
_vertices[_arg1] = (segmentVO.vertices[_arg1] = _arg2);
if (_arg1 == 0){
_v0 = (segmentVO.v0 = _arg2);
} else {
if (_arg1 == 1){
_v1 = (segmentVO.v1 = _arg2);
};
};
_arg2.parents.push(this);
vertexDirty = true;
}
public function moveTo(_arg1:Number, _arg2:Number, _arg3:Number):void{
var _local4:Vertex = new Vertex(_arg1, _arg2, _arg3);
addVertexAt(_vertices.length, _local4, PathCommand.MOVE);
_pathCommands.push(new PathCommand(PathCommand.MOVE, _lastAddedVertex.position, null, _local4.position));
_lastAddedVertex = _local4;
}
public function lineTo(_arg1:Number, _arg2:Number, _arg3:Number):void{
var _local4:Vertex = new Vertex(_arg1, _arg2, _arg3);
addVertexAt(_vertices.length, _local4, PathCommand.LINE);
_pathCommands.push(new PathCommand(PathCommand.LINE, _lastAddedVertex.position, null, _local4.position));
_lastAddedVertex = _local4;
}
public function curveTo(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:Number):void{
var _local7:Vertex = new Vertex(_arg1, _arg2, _arg3);
var _local8:Vertex = new Vertex(_arg4, _arg5, _arg6);
addVertexAt(_vertices.length, _local7, PathCommand.CURVE);
addVertexAt(_vertices.length, _local8, "P");
_pathCommands.push(new PathCommand(PathCommand.CURVE, _lastAddedVertex.position, _local7.position, _local8.position));
_lastAddedVertex = _local8;
}
public function defineSingleCurve(_arg1:Vertex, _arg2:Vertex, _arg3:Vertex):void{
addVertexAt(_vertices.length, _arg1, PathCommand.MOVE);
addVertexAt(_vertices.length, _arg2, PathCommand.CURVE);
addVertexAt(_vertices.length, _arg3, "P");
_commands.splice(0, 1);
segmentVO.commands.splice(0, 1);
_commands[0] = (segmentVO.commands[0] = "NONE");
_vertices.splice(0, 1);
segmentVO.vertices.splice(0, 1);
}
override public function get vertices():Array{
return (_vertices);
}
override public function get commands():Array{
return (_commands);
}
override public function get pathCommands():Array{
return (_pathCommands);
}
public function get v0():Vertex{
return (_v0);
}
public function set v0(_arg1:Vertex):void{
addVertexAt(0, _arg1, "M");
}
public function get v1():Vertex{
return (_v1);
}
public function set v1(_arg1:Vertex):void{
addVertexAt(1, _arg1, "L");
}
public function get material():Material{
return (_material);
}
public function set material(_arg1:Material):void{
if (_arg1 == _material){
return;
};
if (((!((_material == null))) && (parent))){
parent.removeMaterial(this, _material);
};
_material = (segmentVO.material = _arg1);
if (((!((_material == null))) && (parent))){
parent.addMaterial(this, _material);
};
}
override public function get radius2():Number{
var _local1:Number = (((_v0._x * _v0._x) + (_v0._y * _v0._y)) + (_v0._z * _v0._z));
var _local2:Number = (((_v1._x * _v1._x) + (_v1._y * _v1._y)) + (_v1._z * _v1._z));
if (_local1 > _local2){
return (_local1);
};
return (_local2);
}
override public function get maxX():Number{
if (_v0._x > _v1._x){
return (_v0._x);
};
return (_v1._x);
}
override public function get minX():Number{
if (_v0._x < _v1._x){
return (_v0._x);
};
return (_v1._x);
}
override public function get maxY():Number{
if (_v0._y > _v1._y){
return (_v0._y);
};
return (_v1._y);
}
override public function get minY():Number{
if (_v0._y < _v1._y){
return (_v0._y);
};
return (_v1._y);
}
override public function get maxZ():Number{
if (_v0._z > _v1._z){
return (_v0._z);
};
return (_v1._z);
}
override public function get minZ():Number{
if (_v0._z < _v1._z){
return (_v0._z);
};
return (_v1._z);
}
public function drawPath(_arg1:Path):void{
var _local2:PathCommand;
for each (_local2 in _arg1.array) {
moveTo(_local2.pStart.x, _local2.pStart.y, _local2.pStart.z);
curveTo(_local2.pControl.x, _local2.pControl.y, _local2.pControl.z, _local2.pEnd.x, _local2.pEnd.y, _local2.pEnd.z);
};
}
}
}//package away3d.core.base
Section 24
//UV (away3d.core.base.UV)
package away3d.core.base {
import away3d.core.utils.*;
public class UV extends ValueObject {
var _u:Number;
var _v:Number;
public var extra:Object;
public function UV(_arg1:Number=0, _arg2:Number=0){
_u = _arg1;
_v = _arg2;
}
public function get v():Number{
return (_v);
}
public function set v(_arg1:Number):void{
if (_arg1 == _v){
return;
};
_v = _arg1;
notifyChange();
}
public function get u():Number{
return (_u);
}
public function set u(_arg1:Number):void{
if (_arg1 == _u){
return;
};
_u = _arg1;
notifyChange();
}
public function clone():UV{
return (new UV(_u, _v));
}
override public function toString():String{
return ((((("new UV(" + _u) + ", ") + _v) + ")"));
}
static function median(_arg1:UV, _arg2:UV):UV{
if (_arg1 == null){
return (null);
};
if (_arg2 == null){
return (null);
};
return (new UV(((_arg1._u + _arg2._u) / 2), ((_arg1._v + _arg2._v) / 2)));
}
static function weighted(_arg1:UV, _arg2:UV, _arg3:Number, _arg4:Number):UV{
if (_arg1 == null){
return (null);
};
if (_arg2 == null){
return (null);
};
var _local5:Number = (_arg3 + _arg4);
var _local6:Number = (_arg3 / _local5);
var _local7:Number = (_arg4 / _local5);
return (new UV(((_arg1._u * _local6) + (_arg2._u * _local7)), ((_arg1._v * _local6) + (_arg2._v * _local7))));
}
}
}//package away3d.core.base
Section 25
//Vertex (away3d.core.base.Vertex)
package away3d.core.base {
import away3d.core.math.*;
import away3d.core.utils.*;
import away3d.core.draw.*;
import away3d.animators.data.*;
public class Vertex extends ValueObject {
var _distance:Number;
var _index:int;
var _x:Number;
var _y:Number;
var _z:Number;
var _positionDirty:Boolean;
private var _position:Number3D;
private var _vertexDirty:Boolean;
private var _persp:Number;
public var parents:Array;
public var geometry:Geometry;
public var skinVertex:SkinVertex;
public var extra:Object;
public function Vertex(_arg1:Number=0, _arg2:Number=0, _arg3:Number=0){
_position = new Number3D();
parents = [];
super();
_x = _arg1;
_y = _arg2;
_z = _arg3;
_positionDirty = true;
}
function getVertexDirty():Boolean{
if (_positionDirty){
updatePosition();
};
if (_vertexDirty){
_vertexDirty = false;
return (true);
};
return (false);
}
private function updatePosition():void{
var _local1:Element;
if (skinVertex){
skinVertex.update();
};
_positionDirty = false;
for each (_local1 in parents) {
_local1.vertexDirty = true;
};
_vertexDirty = true;
_position.x = _x;
_position.y = _y;
_position.z = _z;
}
public function get x():Number{
if (_positionDirty){
updatePosition();
};
return (_x);
}
public function set x(_arg1:Number):void{
if (_x == _arg1){
return;
};
_x = _arg1;
_positionDirty = true;
}
public function get y():Number{
if (_positionDirty){
updatePosition();
};
return (_y);
}
public function set y(_arg1:Number):void{
if (_y == _arg1){
return;
};
_y = _arg1;
_positionDirty = true;
}
public function get z():Number{
if (_positionDirty){
updatePosition();
};
return (_z);
}
public function set z(_arg1:Number):void{
if (_z == _arg1){
return;
};
_z = _arg1;
_positionDirty = true;
}
public function get position():Number3D{
if (_positionDirty){
updatePosition();
};
return (_position);
}
public function clone():Vertex{
return (new Vertex(_x, _y, _z));
}
public function reset():void{
_x = 0;
_y = 0;
_z = 0;
_positionDirty = true;
}
public function transform(_arg1:Matrix3D):void{
setValue(((((_x * _arg1.sxx) + (_y * _arg1.sxy)) + (_z * _arg1.sxz)) + _arg1.tx), ((((_x * _arg1.syx) + (_y * _arg1.syy)) + (_z * _arg1.syz)) + _arg1.ty), ((((_x * _arg1.szx) + (_y * _arg1.szy)) + (_z * _arg1.szz)) + _arg1.tz));
}
public function add(_arg1:Number3D):void{
_x = (_x + _arg1.x);
_y = (_y + _arg1.y);
_z = (_z + _arg1.z);
_positionDirty = true;
}
public function adjust(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number=1):void{
setValue(((_x * (1 - _arg4)) + (_arg1 * _arg4)), ((_y * (1 - _arg4)) + (_arg2 * _arg4)), ((_z * (1 - _arg4)) + (_arg3 * _arg4)));
}
public function perspective(_arg1:Number):ScreenVertex{
_persp = (1 / (1 + (_z / _arg1)));
return (new ScreenVertex((_x * _persp), (_y * _persp), _z));
}
public function setValue(_arg1:Number, _arg2:Number, _arg3:Number):void{
_x = _arg1;
_y = _arg2;
_z = _arg3;
_positionDirty = true;
}
override public function toString():String{
return ((((((("new Vertex(" + _x) + ", ") + _y) + ", ") + _z) + ")"));
}
public static function median(_arg1:Vertex, _arg2:Vertex):Vertex{
return (new Vertex(((_arg1._x + _arg2._x) / 2), ((_arg1._y + _arg2._y) / 2), ((_arg1._z + _arg2._z) / 2)));
}
public static function distanceSqr(_arg1:Vertex, _arg2:Vertex):Number{
return (((((_arg1._x + _arg2._x) * (_arg1._x + _arg2._x)) + ((_arg1._y + _arg2._y) * (_arg1._y + _arg2._y))) + ((_arg1._z + _arg2._z) * (_arg1._z + _arg2._z))));
}
public static function weighted(_arg1:Vertex, _arg2:Vertex, _arg3:Number, _arg4:Number):Vertex{
var _local5:Number = (_arg3 + _arg4);
var _local6:Number = (_arg3 / _local5);
var _local7:Number = (_arg4 / _local5);
return (new Vertex(((_arg1._x * _local6) + (_arg2._x * _local7)), ((_arg1._y * _local6) + (_arg2._y * _local7)), ((_arg1._z * _local6) + (_arg2._z * _local7))));
}
}
}//package away3d.core.base
Section 26
//VertexClassification (away3d.core.base.VertexClassification)
package away3d.core.base {
import away3d.core.geom.*;
public class VertexClassification {
public var distance:Number;
public var vertex:Vertex;
public var plane:Plane3D;
public function getDistance(_arg1:Plane3D):Number{
var _local2:Number = _arg1.distance(vertex.position);
if ((((_local2 < 0)) && (!(isNaN(_local2))))){
plane = _arg1;
distance = _local2;
};
return (_local2);
}
}
}//package away3d.core.base
Section 27
//Blocker (away3d.core.block.Blocker)
package away3d.core.block {
import away3d.core.draw.*;
public class Blocker extends DrawPrimitive {
public function block(_arg1:DrawPrimitive):Boolean{
return (false);
}
}
}//package away3d.core.block
Section 28
//BlockerArray (away3d.core.block.BlockerArray)
package away3d.core.block {
import away3d.core.clip.*;
public class BlockerArray implements IBlockerConsumer {
private var _blockers:Array;
private var _clip:Clipping;
public function BlockerArray(){
_blockers = [];
super();
}
public function get clip():Clipping{
return (_clip);
}
public function set clip(_arg1:Clipping):void{
_clip = _arg1;
_blockers = [];
}
public function blocker(_arg1:Blocker):void{
if (_clip.checkPrimitive(_arg1)){
_blockers.push(_arg1);
};
}
public function list():Array{
_blockers.sortOn("screenZ", Array.NUMERIC);
return (_blockers);
}
}
}//package away3d.core.block
Section 29
//ConvexBlocker (away3d.core.block.ConvexBlocker)
package away3d.core.block {
import flash.display.*;
import away3d.core.utils.*;
import away3d.core.draw.*;
import away3d.core.render.*;
import away3d.core.geom.*;
import flash.utils.*;
public class ConvexBlocker extends Blocker {
private var _boundlines:Array;
public var vertices:Array;
override public function calc():void{
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:int;
_boundlines = [];
screenZ = 0;
maxX = -(Infinity);
maxY = -(Infinity);
minX = Infinity;
minY = Infinity;
var _local1:int = (vertices.length / 3);
var _local2:int;
while (_local2 < _local1) {
_local3 = vertices[_local2];
_local4 = vertices[(_local2 + 1)];
_local5 = vertices[(_local2 + 2)];
_local6 = ((_local2 + 3) % _local1);
_boundlines.push(Line2D.from2points(_local3, _local4, vertices[_local6], vertices[(_local6 + 1)]));
if (screenZ < _local5){
screenZ = _local5;
};
if (minX > _local3){
minX = _local3;
};
if (maxX < _local3){
maxX = _local3;
};
if (minY > _local4){
minY = _local4;
};
if (maxY < _local4){
maxY = _local4;
};
_local2++;
};
maxZ = screenZ;
minZ = screenZ;
}
override public function contains(_arg1:Number, _arg2:Number):Boolean{
var _local3:Line2D;
for each (_local3 in _boundlines) {
if (_local3.side(_arg1, _arg2) < 0){
return (false);
};
};
return (true);
}
override public function block(_arg1:DrawPrimitive):Boolean{
var _local2:DrawTriangle;
if ((_arg1 is DrawTriangle)){
_local2 = (_arg1 as DrawTriangle);
return (((((contains(_local2.v0x, _local2.v0y)) && (contains(_local2.v1x, _local2.v1y)))) && (contains(_local2.v2x, _local2.v2y))));
};
return (((((((contains(_arg1.minX, _arg1.minY)) && (contains(_arg1.minX, _arg1.maxY)))) && (contains(_arg1.maxX, _arg1.maxY)))) && (contains(_arg1.maxX, _arg1.minY))));
}
override public function render():void{
var _local6:Line2D;
var _local7:Line2D;
var _local8:Line2D;
var _local9:ScreenVertex;
var _local10:ScreenVertex;
var _local11:Number;
var _local12:Number;
var _local1:Graphics = source.session.graphics;
_local1.lineStyle(2, Color.fromHSV(0, 0, ((Math.sin((getTimer() / 1000)) + 1) / 2)));
var _local2:int = _boundlines.length;
var _local3:int;
while (_local3 < _local2) {
_local6 = _boundlines[_local3];
_local7 = _boundlines[(((_local3 - 1) + _local2) % _local2)];
_local8 = _boundlines[(((_local3 + 1) + _local2) % _local2)];
_local9 = Line2D.cross(_local7, _local6);
_local10 = Line2D.cross(_local6, _local8);
_local1.moveTo(_local9.x, _local9.y);
_local1.lineTo(_local10.x, _local10.y);
_local1.moveTo(_local9.x, _local9.y);
_local3++;
};
var _local4:int = (((maxX - minX) * (maxY - minY)) / 2000);
if (_local4 > 50){
_local4 = 50;
};
var _local5:int;
while (_local5 < _local4) {
_local11 = (minX + ((maxX - minX) * Math.random()));
_local12 = (minY + ((maxY - minY) * Math.random()));
if (contains(_local11, _local12)){
_local1.lineStyle(1, Color.fromHSV(0, 0, Math.random()));
_local1.drawCircle(_local11, _local12, 3);
};
_local5++;
};
}
}
}//package away3d.core.block
Section 30
//IBlockerConsumer (away3d.core.block.IBlockerConsumer)
package away3d.core.block {
public interface IBlockerConsumer {
function blocker(_arg1:Blocker):void;
}
}//package away3d.core.block
Section 31
//IBlockerProvider (away3d.core.block.IBlockerProvider)
package away3d.core.block {
import away3d.core.math.*;
import away3d.core.base.*;
public interface IBlockerProvider {
function blockers(_arg1:Object3D, _arg2:Matrix3D, _arg3:IBlockerConsumer):void;
}
}//package away3d.core.block
Section 32
//Clipping (away3d.core.clip.Clipping)
package away3d.core.clip {
import flash.display.*;
import flash.events.*;
import away3d.core.base.*;
import away3d.core.utils.*;
import away3d.core.draw.*;
import away3d.containers.*;
import away3d.events.*;
import flash.geom.*;
public class Clipping extends EventDispatcher {
var _cameraVarsStore:CameraVarsStore;
var _objectCulling:Boolean;
private var _clippingClone:Clipping;
private var _stage:Stage;
private var _stageWidth:Number;
private var _stageHeight:Number;
private var _localPointTL:Point;
private var _localPointBR:Point;
private var _globalPointTL:Point;
private var _globalPointBR:Point;
private var _view:View3D;
private var _minX:Number;
private var _minY:Number;
private var _minZ:Number;
private var _maxX:Number;
private var _maxY:Number;
private var _maxZ:Number;
private var _miX:Number;
private var _miY:Number;
private var _maX:Number;
private var _maY:Number;
private var _clippingupdated:ClippingEvent;
private var _screenupdated:ClippingEvent;
protected var ini:Init;
public function Clipping(_arg1:Object=null){
_localPointTL = new Point(0, 0);
_localPointBR = new Point(0, 0);
_globalPointTL = new Point(0, 0);
_globalPointBR = new Point(0, 0);
super();
ini = (Init.parse(_arg1) as Init);
minX = ini.getNumber("minX", -(Infinity));
minY = ini.getNumber("minY", -(Infinity));
minZ = ini.getNumber("minZ", -(Infinity));
maxX = ini.getNumber("maxX", Infinity);
maxY = ini.getNumber("maxY", Infinity);
maxZ = ini.getNumber("maxZ", Infinity);
}
private function onScreenUpdate(_arg1:ClippingEvent):void{
notifyScreenUpdate();
}
private function notifyClippingUpdate():void{
if (!hasEventListener(ClippingEvent.CLIPPING_UPDATED)){
return;
};
if (_clippingupdated == null){
_clippingupdated = new ClippingEvent(ClippingEvent.CLIPPING_UPDATED, this);
};
dispatchEvent(_clippingupdated);
}
private function notifyScreenUpdate():void{
if (!hasEventListener(ClippingEvent.SCREEN_UPDATED)){
return;
};
if (_screenupdated == null){
_screenupdated = new ClippingEvent(ClippingEvent.SCREEN_UPDATED, this);
};
dispatchEvent(_screenupdated);
}
public function get objectCulling():Boolean{
return (_objectCulling);
}
public function set objectCulling(_arg1:Boolean):void{
_objectCulling = _arg1;
}
public function get view():View3D{
return (_view);
}
public function set view(_arg1:View3D):void{
_view = _arg1;
_cameraVarsStore = view.cameraVarsStore;
}
public function get minX():Number{
return (_minX);
}
public function set minX(_arg1:Number):void{
if (_minX == _arg1){
return;
};
_minX = _arg1;
notifyClippingUpdate();
}
public function get minY():Number{
return (_minY);
}
public function set minY(_arg1:Number):void{
if (_minY == _arg1){
return;
};
_minY = _arg1;
notifyClippingUpdate();
}
public function get minZ():Number{
return (_minZ);
}
public function set minZ(_arg1:Number):void{
if (_minZ == _arg1){
return;
};
_minZ = _arg1;
notifyClippingUpdate();
}
public function get maxX():Number{
return (_maxX);
}
public function set maxX(_arg1:Number):void{
if (_maxX == _arg1){
return;
};
_maxX = _arg1;
notifyClippingUpdate();
}
public function get maxY():Number{
return (_maxY);
}
public function set maxY(_arg1:Number):void{
if (_maxY == _arg1){
return;
};
_maxY = _arg1;
notifyClippingUpdate();
}
public function get maxZ():Number{
return (_maxZ);
}
public function set maxZ(_arg1:Number):void{
if (_maxZ == _arg1){
return;
};
_maxZ = _arg1;
notifyClippingUpdate();
}
public function checkPrimitive(_arg1:DrawPrimitive):Boolean{
return (true);
}
public function checkElements(_arg1:Mesh, _arg2:Array, _arg3:Array, _arg4:Array, _arg5:Array, _arg6:Array, _arg7:Array, _arg8:Array):void{
throw (new Error("Not implemented"));
}
public function rect(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Boolean{
if (this.maxX < _arg1){
return (false);
};
if (this.minX > _arg3){
return (false);
};
if (this.maxY < _arg2){
return (false);
};
if (this.minY > _arg4){
return (false);
};
return (true);
}
public function screen(_arg1:Sprite, _arg2:Number, _arg3:Number):Clipping{
if (!_clippingClone){
_clippingClone = clone();
_clippingClone.addOnClippingUpdate(onScreenUpdate);
};
_stage = _arg1.stage;
if (_stage){
if (_stage.scaleMode == StageScaleMode.NO_SCALE){
_stageWidth = _stage.stageWidth;
_stageHeight = _stage.stageHeight;
} else {
if (_stage.scaleMode == StageScaleMode.EXACT_FIT){
_stageWidth = _arg2;
_stageHeight = _arg3;
} else {
if (_stage.scaleMode == StageScaleMode.SHOW_ALL){
if ((_stage.stageWidth / _arg2) < (_stage.stageHeight / _arg3)){
_stageWidth = _arg2;
_stageHeight = ((_stage.stageHeight * _stageWidth) / _stage.stageWidth);
} else {
_stageHeight = _arg3;
_stageWidth = ((_stage.stageWidth * _stageHeight) / _stage.stageHeight);
};
} else {
if (_stage.scaleMode == StageScaleMode.NO_BORDER){
if ((_stage.stageWidth / _arg2) > (_stage.stageHeight / _arg3)){
_stageWidth = _arg2;
_stageHeight = ((_stage.stageHeight * _stageWidth) / _stage.stageWidth);
} else {
_stageHeight = _arg3;
_stageWidth = ((_stage.stageWidth * _stageHeight) / _stage.stageHeight);
};
};
};
};
};
if (_stage.align == StageAlign.TOP_LEFT){
_localPointTL.x = 0;
_localPointTL.y = 0;
_localPointBR.x = _stageWidth;
_localPointBR.y = _stageHeight;
} else {
if (_stage.align == StageAlign.TOP_RIGHT){
_localPointTL.x = (_arg2 - _stageWidth);
_localPointTL.y = 0;
_localPointBR.x = _arg2;
_localPointBR.y = _stageHeight;
} else {
if (_stage.align == StageAlign.BOTTOM_LEFT){
_localPointTL.x = 0;
_localPointTL.y = (_arg3 - _stageHeight);
_localPointBR.x = _stageWidth;
_localPointBR.y = _arg3;
} else {
if (_stage.align == StageAlign.BOTTOM_RIGHT){
_localPointTL.x = (_arg2 - _stageWidth);
_localPointTL.y = (_arg3 - _stageHeight);
_localPointBR.x = _arg2;
_localPointBR.y = _arg3;
} else {
if (_stage.align == StageAlign.TOP){
_localPointTL.x = ((_arg2 / 2) - (_stageWidth / 2));
_localPointTL.y = 0;
_localPointBR.x = ((_arg2 / 2) + (_stageWidth / 2));
_localPointBR.y = _stageHeight;
} else {
if (_stage.align == StageAlign.BOTTOM){
_localPointTL.x = ((_arg2 / 2) - (_stageWidth / 2));
_localPointTL.y = (_arg3 - _stageHeight);
_localPointBR.x = ((_arg2 / 2) + (_stageWidth / 2));
_localPointBR.y = _arg3;
} else {
if (_stage.align == StageAlign.LEFT){
_localPointTL.x = 0;
_localPointTL.y = ((_arg3 / 2) - (_stageHeight / 2));
_localPointBR.x = _stageWidth;
_localPointBR.y = ((_arg3 / 2) + (_stageHeight / 2));
} else {
if (_stage.align == StageAlign.RIGHT){
_localPointTL.x = (_arg2 - _stageWidth);
_localPointTL.y = ((_arg3 / 2) - (_stageHeight / 2));
_localPointBR.x = _arg2;
_localPointBR.y = ((_arg3 / 2) + (_stageHeight / 2));
} else {
_localPointTL.x = ((_arg2 / 2) - (_stageWidth / 2));
_localPointTL.y = ((_arg3 / 2) - (_stageHeight / 2));
_localPointBR.x = ((_arg2 / 2) + (_stageWidth / 2));
_localPointBR.y = ((_arg3 / 2) + (_stageHeight / 2));
};
};
};
};
};
};
};
};
} else {
_localPointTL.x = 0;
_localPointTL.y = 0;
_localPointBR.x = _arg2;
_localPointBR.y = _arg3;
};
_globalPointTL = _arg1.globalToLocal(_localPointTL);
_globalPointBR = _arg1.globalToLocal(_localPointBR);
_miX = _globalPointTL.x;
_miY = _globalPointTL.y;
_maX = _globalPointBR.x;
_maY = _globalPointBR.y;
if (((((!(_stage)) && (!((_minX == -(Infinity)))))) || ((_minX > _miX)))){
_clippingClone.minX = _minX;
} else {
_clippingClone.minX = _miX;
};
if (((((!(_stage)) && (!((_maxX == Infinity))))) || ((_maxX < _maX)))){
_clippingClone.maxX = _maxX;
} else {
_clippingClone.maxX = _maX;
};
if (((((!(_stage)) && (!((_minY == -(Infinity)))))) || ((_minY > _miY)))){
_clippingClone.minY = _minY;
} else {
_clippingClone.minY = _miY;
};
if (((((!(_stage)) && (!((_maxY == Infinity))))) || ((_maxY < _maY)))){
_clippingClone.maxY = _maxY;
} else {
_clippingClone.maxY = _maY;
};
_clippingClone.minZ = _minZ;
_clippingClone.maxZ = _maxZ;
_clippingClone.objectCulling = _objectCulling;
return (_clippingClone);
}
public function clone(_arg1:Clipping=null):Clipping{
var _local2:Clipping = ((_arg1) || (new Clipping()));
_local2.minX = minX;
_local2.minY = minY;
_local2.minZ = minZ;
_local2.maxX = maxX;
_local2.maxY = maxY;
_local2.maxZ = maxZ;
_local2.objectCulling = objectCulling;
_local2._cameraVarsStore = _cameraVarsStore;
return (_local2);
}
override public function toString():String{
return ((((((((((((("{minX:" + minX) + " maxX:") + maxX) + " minY:") + minY) + " maxY:") + maxY) + " minZ:") + minZ) + " maxZ:") + maxZ) + "}"));
}
public function addOnClippingUpdate(_arg1:Function):void{
addEventListener(ClippingEvent.CLIPPING_UPDATED, _arg1, false, 0, false);
}
public function removeOnClippingUpdate(_arg1:Function):void{
removeEventListener(ClippingEvent.CLIPPING_UPDATED, _arg1, false);
}
public function addOnScreenUpdate(_arg1:Function):void{
addEventListener(ClippingEvent.SCREEN_UPDATED, _arg1, false, 0, false);
}
public function removeOnScreenUpdate(_arg1:Function):void{
removeEventListener(ClippingEvent.SCREEN_UPDATED, _arg1, false);
}
}
}//package away3d.core.clip
Section 33
//FrustumClipping (away3d.core.clip.FrustumClipping)
package away3d.core.clip {
import away3d.core.base.*;
import away3d.core.utils.*;
import away3d.core.render.*;
import away3d.core.geom.*;
import flash.utils.*;
public class FrustumClipping extends Clipping {
private var _faces:Array;
private var _face:Face;
private var _faceVOs:Array;
private var _faceVO:FaceVO;
private var _newFaceVO:FaceVO;
private var _v0C:VertexClassification;
private var _v1C:VertexClassification;
private var _v2C:VertexClassification;
private var _v0d:Number;
private var _v1d:Number;
private var _v2d:Number;
private var _v0w:Number;
private var _v1w:Number;
private var _v2w:Number;
private var _d:Number;
private var _session:AbstractRenderSession;
private var _frustum:Frustum;
private var _processed:Dictionary;
private var _pass:Boolean;
private var _v0:Vertex;
private var _v01:Vertex;
private var _v1:Vertex;
private var _v12:Vertex;
private var _v2:Vertex;
private var _v20:Vertex;
private var _uv0:UV;
private var _uv01:UV;
private var _uv1:UV;
private var _uv12:UV;
private var _uv2:UV;
private var _uv20:UV;
private var _verticesC:Array;
private var _distances:Array;
public function FrustumClipping(_arg1:Object=null){
_faceVOs = new Array();
super(_arg1);
objectCulling = ini.getBoolean("objectCulling", true);
}
override public function set objectCulling(_arg1:Boolean):void{
if (!_arg1){
throw (new Error("objectCulling requires setting to true for FrustumClipping"));
};
_objectCulling = _arg1;
}
override public function checkElements(_arg1:Mesh, _arg2:Array, _arg3:Array, _arg4:Array, _arg5:Array, _arg6:Array, _arg7:Array, _arg8:Array):void{
_session = _arg1.session;
_frustum = _cameraVarsStore.frustumDictionary[_arg1];
_processed = new Dictionary(true);
_faces = _arg1.faces;
_faceVOs.length = 0;
for each (_face in _faces) {
if (!_face.visible){
} else {
_faceVOs[_faceVOs.length] = _face.faceVO;
};
};
for each (_faceVO in _faceVOs) {
checkNormalFace(_arg2, _arg3, _arg4, _arg5, _arg6, _arg7, _arg8);
};
_arg8[_arg8.length] = _arg7.length;
}
private function checkIrregularFace(_arg1:Array, _arg2:Array, _arg3:Array, _arg4:Array, _arg5:Array, _arg6:Array, _arg7:Array):void{
var _local8:uint;
var _local9:Plane3D;
var _local15:Array;
var _local16:Boolean;
var _local17:Vertex;
_pass = true;
_verticesC = [];
_local8 = 0;
while (_local8 < _faceVO.vertices.length) {
_verticesC.push(_cameraVarsStore.createVertexClassification(_faceVO.vertices[_local8]));
_local8++;
};
var _local10 = -1;
_local8 = 0;
while (_local8 < _faceVO.vertices.length) {
_v0C = _verticesC[_local8];
if (_v0C.plane){
_local9 = _v0C.plane;
_local10 = _local8;
break;
};
_local8++;
};
_distances = [];
var _local11:Boolean;
var _local12:Boolean;
if (_local10 != -1){
_local8 = 0;
while (_local8 < _faceVO.vertices.length) {
_v0C = _verticesC[_local8];
if (_local8 == _local10){
_distances.push(_v0C.distance);
} else {
_distances.push(_v0C.getDistance(_local9));
};
_local8++;
};
_local8 = 0;
while (_local8 < _distances.length) {
if (_distances[_local8] >= 0){
_local11 = false;
} else {
if (_distances[_local8] < 0){
_local12 = true;
};
};
_local8++;
};
if (_local11){
return;
};
if (_local12){
_pass = false;
};
} else {
_local15 = _frustum.planes;
_local16 = false;
for each (_local9 in _local15) {
_local8 = 0;
while (_local8 < _faceVO.vertices.length) {
_v0C = _verticesC[_local8];
_distances.push(_v0C.getDistance(_local9));
_local8++;
};
_local11 = true;
_local12 = false;
_local8 = 0;
while (_local8 < _distances.length) {
if (_distances[_local8] >= 0){
_local11 = false;
} else {
if (_distances[_local8] < 0){
_local12 = true;
};
};
_local8++;
};
if (_local11){
_local16 = true;
break;
};
if (_local12){
_pass = false;
break;
};
};
if (_local16){
return;
};
};
if (_pass){
_arg1[_arg1.length] = _faceVO;
_arg7[_arg7.length] = _arg6.length;
for each (_local17 in _faceVO.vertices) {
if (!_processed[_local17]){
_arg4[_arg4.length] = _local17;
_arg6[_arg6.length] = ((_processed[_local17] = _arg4.length) - 1);
} else {
_arg6[_arg6.length] = (_processed[_local17] - 1);
};
};
return;
};
var _local13:Array = [];
_local8 = 0;
while (_local8 < (_distances.length - 1)) {
_v0d = _distances[_local8];
_v1d = _distances[(_local8 + 1)];
if (!(((_v0d >= 0)) && ((_v1d < 0)))){
_local13.push(_verticesC[_local8].vertex);
} else {
_d = (_v0d - _v1d);
};
_local8++;
};
var _local14:UV = new UV();
_newFaceVO = (_faceVOs[_faceVOs.length] = _cameraVarsStore.createFaceVO(_faceVO.face, _faceVO.material, _faceVO.back, _local14, _local14, _local14));
_local8 = 0;
while (_local8 < _local13.length) {
_newFaceVO.vertices.push(_local13[_local8]);
_local8++;
};
}
private function checkNormalFace(_arg1:Array, _arg2:Array, _arg3:Array, _arg4:Array, _arg5:Array, _arg6:Array, _arg7:Array):void{
var _local8:Plane3D;
var _local9:Array;
var _local10:Boolean;
_pass = true;
_v0C = _cameraVarsStore.createVertexClassification(_faceVO.v0);
_v1C = _cameraVarsStore.createVertexClassification(_faceVO.v1);
_v2C = _cameraVarsStore.createVertexClassification(_faceVO.v2);
if (((((_v0C.plane) || (_v1C.plane))) || (_v2C.plane))){
_local8 = _v0C.plane;
if (_local8){
_v0d = _v0C.distance;
_v1d = _v1C.getDistance(_local8);
_v2d = _v2C.getDistance(_local8);
} else {
_local8 = _v1C.plane;
if (_local8){
_v0d = _v0C.getDistance(_local8);
_v1d = _v1C.distance;
_v2d = _v2C.getDistance(_local8);
} else {
_local8 = _v2C.plane;
if (_local8){
_v0d = _v0C.getDistance(_local8);
_v1d = _v1C.getDistance(_local8);
_v2d = _v2C.distance;
};
};
};
if ((((((_v0d < 0)) && ((_v1d < 0)))) && ((_v2d < 0)))){
return;
};
if ((((((_v0d < 0)) || ((_v1d < 0)))) || ((_v2d < 0)))){
_pass = false;
};
} else {
_local9 = _frustum.planes;
_local10 = false;
for each (_local8 in _local9) {
_v0d = _v0C.getDistance(_local8);
_v1d = _v1C.getDistance(_local8);
_v2d = _v2C.getDistance(_local8);
if ((((((_v0d < 0)) && ((_v1d < 0)))) && ((_v2d < 0)))){
_local10 = true;
break;
};
if ((((((_v0d < 0)) || ((_v1d < 0)))) || ((_v2d < 0)))){
_pass = false;
break;
};
};
if (_local10){
return;
};
};
if (_pass){
_arg1[_arg1.length] = _faceVO;
_arg7[_arg7.length] = _arg6.length;
if (!_processed[_faceVO.v0]){
_arg4[_arg4.length] = _faceVO.v0;
_arg6[_arg6.length] = ((_processed[_faceVO.v0] = _arg4.length) - 1);
} else {
_arg6[_arg6.length] = (_processed[_faceVO.v0] - 1);
};
if (!_processed[_faceVO.v1]){
_arg4[_arg4.length] = _faceVO.v1;
_arg6[_arg6.length] = ((_processed[_faceVO.v1] = _arg4.length) - 1);
} else {
_arg6[_arg6.length] = (_processed[_faceVO.v1] - 1);
};
if (!_processed[_faceVO.v2]){
_arg4[_arg4.length] = _faceVO.v2;
_arg6[_arg6.length] = ((_processed[_faceVO.v2] = _arg4.length) - 1);
} else {
_arg6[_arg6.length] = (_processed[_faceVO.v2] - 1);
};
return;
};
if ((((_v0d >= 0)) && ((_v1d < 0)))){
_v0w = _v0d;
_v1w = _v1d;
_v2w = _v2d;
_v0 = _faceVO.v0;
_v1 = _faceVO.v1;
_v2 = _faceVO.v2;
_uv0 = _faceVO.uv0;
_uv1 = _faceVO.uv1;
_uv2 = _faceVO.uv2;
} else {
if ((((_v1d >= 0)) && ((_v2d < 0)))){
_v0w = _v1d;
_v1w = _v2d;
_v2w = _v0d;
_v0 = _faceVO.v1;
_v1 = _faceVO.v2;
_v2 = _faceVO.v0;
_uv0 = _faceVO.uv1;
_uv1 = _faceVO.uv2;
_uv2 = _faceVO.uv0;
} else {
if ((((_v2d >= 0)) && ((_v0d < 0)))){
_v0w = _v2d;
_v1w = _v0d;
_v2w = _v1d;
_v0 = _faceVO.v2;
_v1 = _faceVO.v0;
_v2 = _faceVO.v1;
_uv0 = _faceVO.uv2;
_uv1 = _faceVO.uv0;
_uv2 = _faceVO.uv1;
};
};
};
_d = (_v0w - _v1w);
_v01 = _cameraVarsStore.createVertex((((_v1.x * _v0w) - (_v0.x * _v1w)) / _d), (((_v1.y * _v0w) - (_v0.y * _v1w)) / _d), (((_v1.z * _v0w) - (_v0.z * _v1w)) / _d));
_uv01 = (_uv0) ? _cameraVarsStore.createUV((((_uv1.u * _v0w) - (_uv0.u * _v1w)) / _d), (((_uv1.v * _v0w) - (_uv0.v * _v1w)) / _d), _session) : null;
if (_v2w < 0){
_d = (_v0w - _v2w);
_v20 = _cameraVarsStore.createVertex((((_v2.x * _v0w) - (_v0.x * _v2w)) / _d), (((_v2.y * _v0w) - (_v0.y * _v2w)) / _d), (((_v2.z * _v0w) - (_v0.z * _v2w)) / _d));
_uv20 = (_uv0) ? _cameraVarsStore.createUV((((_uv2.u * _v0w) - (_uv0.u * _v2w)) / _d), (((_uv2.v * _v0w) - (_uv0.v * _v2w)) / _d), _session) : null;
_newFaceVO = (_faceVOs[_faceVOs.length] = _cameraVarsStore.createFaceVO(_faceVO.face, _faceVO.material, _faceVO.back, _uv0, _uv01, _uv20));
_newFaceVO.vertices[0] = (_newFaceVO.v0 = _v0);
_newFaceVO.vertices[1] = (_newFaceVO.v1 = _v01);
_newFaceVO.vertices[2] = (_newFaceVO.v2 = _v20);
} else {
_d = (_v2w - _v1w);
_v12 = _cameraVarsStore.createVertex((((_v1.x * _v2w) - (_v2.x * _v1w)) / _d), (((_v1.y * _v2w) - (_v2.y * _v1w)) / _d), (((_v1.z * _v2w) - (_v2.z * _v1w)) / _d));
_uv12 = (_uv0) ? _cameraVarsStore.createUV((((_uv1.u * _v2w) - (_uv2.u * _v1w)) / _d), (((_uv1.v * _v2w) - (_uv2.v * _v1w)) / _d), _session) : null;
_newFaceVO = (_faceVOs[_faceVOs.length] = _cameraVarsStore.createFaceVO(_faceVO.face, _faceVO.material, _faceVO.back, _uv0, _uv01, _uv2));
_newFaceVO.vertices[0] = (_newFaceVO.v0 = _v0);
_newFaceVO.vertices[1] = (_newFaceVO.v1 = _v01);
_newFaceVO.vertices[2] = (_newFaceVO.v2 = _v2);
_newFaceVO = (_faceVOs[_faceVOs.length] = _cameraVarsStore.createFaceVO(_faceVO.face, _faceVO.material, _faceVO.back, _uv01, _uv12, _uv2));
_newFaceVO.vertices[0] = (_newFaceVO.v0 = _v01);
_newFaceVO.vertices[1] = (_newFaceVO.v1 = _v12);
_newFaceVO.vertices[2] = (_newFaceVO.v2 = _v2);
};
}
override public function rect(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Boolean{
if (this.maxX < _arg1){
return (false);
};
if (this.minX > _arg3){
return (false);
};
if (this.maxY < _arg2){
return (false);
};
if (this.minY > _arg4){
return (false);
};
return (true);
}
override public function clone(_arg1:Clipping=null):Clipping{
var _local2:FrustumClipping = (((_arg1 as FrustumClipping)) || (new FrustumClipping()));
super.clone(_local2);
return (_local2);
}
}
}//package away3d.core.clip
Section 34
//RectangleClipping (away3d.core.clip.RectangleClipping)
package away3d.core.clip {
import away3d.core.draw.*;
public class RectangleClipping extends Clipping {
public function RectangleClipping(_arg1:Object=null){
super(_arg1);
objectCulling = ini.getBoolean("objectCulling", false);
}
override public function checkPrimitive(_arg1:DrawPrimitive):Boolean{
if (_arg1.maxX < minX){
return (false);
};
if (_arg1.minX > maxX){
return (false);
};
if (_arg1.maxY < minY){
return (false);
};
if (_arg1.minY > maxY){
return (false);
};
return (true);
}
override public function clone(_arg1:Clipping=null):Clipping{
var _local2:RectangleClipping = (((_arg1 as RectangleClipping)) || (new RectangleClipping()));
super.clone(_local2);
return (_local2);
}
}
}//package away3d.core.clip
Section 35
//DrawDisplayObject (away3d.core.draw.DrawDisplayObject)
package away3d.core.draw {
import flash.display.*;
import away3d.core.render.*;
import flash.geom.*;
public class DrawDisplayObject extends DrawPrimitive {
private var displayRect:Rectangle;
public var vx:Number;
public var vy:Number;
public var vz:Number;
public var displayobject:DisplayObject;
public var session:AbstractRenderSession;
override public function calc():void{
displayRect = displayobject.getBounds(displayobject);
screenZ = vz;
minZ = screenZ;
maxZ = screenZ;
minX = (vx + displayRect.left);
minY = (vy + displayRect.top);
maxX = (vx + displayRect.right);
maxY = (vy + displayRect.bottom);
}
override public function clear():void{
displayobject = null;
}
override public function render():void{
displayobject.x = vx;
displayobject.y = vy;
session.addDisplayObject(displayobject);
}
override public function contains(_arg1:Number, _arg2:Number):Boolean{
return (true);
}
}
}//package away3d.core.draw
Section 36
//DrawFog (away3d.core.draw.DrawFog)
package away3d.core.draw {
import away3d.materials.*;
import away3d.core.clip.*;
public class DrawFog extends DrawPrimitive {
public var material:ColorMaterial;
public var clip:Clipping;
override public function render():void{
material.renderFog(this);
}
}
}//package away3d.core.draw
Section 37
//DrawPrimitive (away3d.core.draw.DrawPrimitive)
package away3d.core.draw {
import away3d.core.base.*;
import away3d.containers.*;
public class DrawPrimitive {
public var view:View3D;
public var source:Object3D;
public var generated:Boolean;
public var create:Function;
public var minZ:Number;
public var maxZ:Number;
public var screenZ:Number;
public var minX:Number;
public var maxX:Number;
public var minY:Number;
public var maxY:Number;
public var quadrant:PrimitiveQuadrantTreeNode;
public var ignoreSort:Boolean;
public function calc():void{
throw (new Error("Not implemented"));
}
public function render():void{
throw (new Error("Not implemented"));
}
public function contains(_arg1:Number, _arg2:Number):Boolean{
throw (new Error("Not implemented"));
}
public function quarter(_arg1:Number):Array{
return ([this]);
}
public function getZ(_arg1:Number, _arg2:Number):Number{
return (screenZ);
}
public function clear():void{
throw (new Error("Not implemented"));
}
public function toString():String{
return ((((((("P{ screenZ = " + screenZ) + ", minZ = ") + minZ) + ", maxZ = ") + maxZ) + " }"));
}
}
}//package away3d.core.draw
Section 38
//DrawScaledBitmap (away3d.core.draw.DrawScaledBitmap)
package away3d.core.draw {
import flash.display.*;
import flash.geom.*;
public class DrawScaledBitmap extends DrawPrimitive {
private var cos:Number;
private var sin:Number;
private var cosw:Number;
private var cosh:Number;
private var sinw:Number;
private var sinh:Number;
private var pointMapping:Matrix;
private var mapping:Matrix;
private var width:Number;
private var height:Number;
public var bitmap:BitmapData;
public var vx:Number;
public var vy:Number;
public var vz:Number;
public var topleftx:Number;
public var toplefty:Number;
public var toprightx:Number;
public var toprighty:Number;
public var bottomleftx:Number;
public var bottomlefty:Number;
public var bottomrightx:Number;
public var bottomrighty:Number;
public var scale:Number;
public var rotation:Number;
public var smooth:Boolean;
public function DrawScaledBitmap(){
mapping = new Matrix();
super();
}
override public function calc():void{
var _local1:Array;
var _local2:int;
var _local3:Array;
var _local4:int;
screenZ = vz;
minZ = screenZ;
maxZ = screenZ;
width = (bitmap.width * scale);
height = (bitmap.height * scale);
if (rotation != 0){
cos = Math.cos(((rotation * Math.PI) / 180));
sin = Math.sin(((rotation * Math.PI) / 180));
cosw = ((cos * width) / 2);
cosh = ((cos * height) / 2);
sinw = ((sin * width) / 2);
sinh = ((sin * height) / 2);
topleftx = ((vx - cosw) - sinh);
toplefty = ((vy + sinw) - cosh);
toprightx = ((vx + cosw) - sinh);
toprighty = ((vy - sinw) - cosh);
bottomleftx = ((vx - cosw) + sinh);
bottomlefty = ((vy + sinw) + cosh);
bottomrightx = ((vx + cosw) + sinh);
bottomrighty = ((vy - sinw) + cosh);
_local1 = [];
_local1.push(topleftx);
_local1.push(toprightx);
_local1.push(bottomleftx);
_local1.push(bottomrightx);
minX = 100000;
maxX = -100000;
for each (_local2 in _local1) {
if (minX > _local2){
minX = _local2;
};
if (maxX < _local2){
maxX = _local2;
};
};
_local3 = [];
_local3.push(toplefty);
_local3.push(toprighty);
_local3.push(bottomlefty);
_local3.push(bottomrighty);
minY = 100000;
maxY = -100000;
for each (_local4 in _local3) {
if (minY > _local4){
minY = _local4;
};
if (maxY < _local4){
maxY = _local4;
};
};
mapping.a = (scale * cos);
mapping.b = (-(scale) * sin);
mapping.c = (scale * sin);
mapping.d = (scale * cos);
mapping.tx = topleftx;
mapping.ty = toplefty;
} else {
topleftx = (vx - (width / 2));
toplefty = (vy - (height / 2));
toprightx = (topleftx + width);
toprighty = toplefty;
bottomleftx = topleftx;
bottomlefty = (toplefty + height);
bottomrightx = toprightx;
bottomrighty = bottomlefty;
minX = topleftx;
minY = toplefty;
maxX = bottomrightx;
maxY = bottomrighty;
mapping.a = (mapping.d = scale);
mapping.c = (mapping.b = 0);
mapping.tx = topleftx;
mapping.ty = toplefty;
};
}
override public function clear():void{
bitmap = null;
}
override public function render():void{
source.session.renderScaledBitmap(this, bitmap, mapping, smooth);
}
override public function contains(_arg1:Number, _arg2:Number):Boolean{
if (rotation != 0){
if ((((topleftx * (_arg2 - toprighty)) + (toprightx * (toplefty - _arg2))) + (_arg1 * (toprighty - toplefty))) > 0.001){
return (false);
};
if ((((toprightx * (_arg2 - bottomrighty)) + (bottomrightx * (toprighty - _arg2))) + (_arg1 * (bottomrighty - toprighty))) > 0.001){
return (false);
};
if ((((bottomrightx * (_arg2 - bottomlefty)) + (bottomleftx * (bottomrighty - _arg2))) + (_arg1 * (bottomlefty - bottomrighty))) > 0.001){
return (false);
};
if ((((bottomleftx * (_arg2 - toplefty)) + (topleftx * (bottomlefty - _arg2))) + (_arg1 * (toplefty - bottomlefty))) > 0.001){
return (false);
};
};
if (!bitmap.transparent){
return (true);
};
pointMapping = mapping.clone();
pointMapping.invert();
var _local3:Point = pointMapping.transformPoint(new Point(_arg1, _arg2));
if (_local3.x < 0){
_local3.x = 0;
};
if (_local3.y < 0){
_local3.y = 0;
};
if (_local3.x >= bitmap.width){
_local3.x = (bitmap.width - 1);
};
if (_local3.y >= bitmap.height){
_local3.y = (bitmap.height - 1);
};
var _local4:uint = bitmap.getPixel32(int(_local3.x), int(_local3.y));
return ((uint((_local4 >> 24)) > 128));
}
}
}//package away3d.core.draw
Section 39
//DrawSegment (away3d.core.draw.DrawSegment)
package away3d.core.draw {
import away3d.core.utils.*;
import away3d.materials.*;
public class DrawSegment extends DrawPrimitive {
private var focus:Number;
private var ax:Number;
private var ay:Number;
private var az:Number;
private var bx:Number;
private var by:Number;
private var bz:Number;
private var dx:Number;
private var dy:Number;
private var azf:Number;
private var bzf:Number;
private var faz:Number;
private var fbz:Number;
private var xfocus:Number;
private var yfocus:Number;
private var axf:Number;
private var bxf:Number;
private var ayf:Number;
private var byf:Number;
private var det:Number;
private var db:Number;
private var da:Number;
private var _index:int;
public var v0x:Number;
public var v0y:Number;
public var v0z:Number;
public var v1x:Number;
public var v1y:Number;
public var v1z:Number;
public var length:Number;
public var segmentVO:SegmentVO;
public var material:Material;
public var screenVertices:Array;
public var screenIndices:Array;
public var screenCommands:Array;
public var startIndex:int;
public var endIndex:int;
function onepointcut(_arg1:Number, _arg2:Number, _arg3:Number):Array{
var _local4:int = screenIndices.length;
screenIndices[screenIndices.length] = startIndex;
screenIndices[screenIndices.length] = screenVertices.length;
var _local5:int = screenIndices.length;
screenIndices[screenIndices.length] = screenVertices.length;
screenIndices[screenIndices.length] = (startIndex + 1);
var _local6:int = screenIndices.length;
screenVertices[screenVertices.length] = _arg1;
screenVertices[screenVertices.length] = _arg2;
screenVertices[screenVertices.length] = _arg3;
return ([create(source, segmentVO, material, screenVertices, screenIndices, screenCommands, _local4, _local5, true), create(source, segmentVO, material, screenVertices, screenIndices, screenCommands, _local5, _local6, true)]);
}
private function distanceToCenter(_arg1:Number, _arg2:Number):Number{
var _local3:Number = ((v0x + v1x) / 2);
var _local4:Number = ((v0y + v1y) / 2);
return (Math.sqrt((((_local3 - _arg1) * (_local3 - _arg1)) + ((_local4 - _arg2) * (_local4 - _arg2)))));
}
override public function clear():void{
}
override public function render():void{
material.renderSegment(this);
}
override public function contains(_arg1:Number, _arg2:Number):Boolean{
if (Math.abs((((v0x * (_arg2 - v1y)) + (v1x * (v0y - _arg2))) + (_arg1 * (v1y - v0y)))) > ((0.001 * 1000) * 1000)){
return (false);
};
if ((distanceToCenter(_arg1, _arg2) * 2) > length){
return (false);
};
return (true);
}
override public function getZ(_arg1:Number, _arg2:Number):Number{
focus = view.camera.focus;
ax = v0x;
ay = v0y;
az = v0z;
bx = v1x;
by = v1y;
bz = v1z;
if ((((ax == _arg1)) && ((ay == _arg2)))){
return (az);
};
if ((((bx == _arg1)) && ((by == _arg2)))){
return (bz);
};
dx = (bx - ax);
dy = (by - ay);
azf = (az / focus);
bzf = (bz / focus);
faz = (1 + azf);
fbz = (1 + bzf);
xfocus = _arg1;
yfocus = _arg2;
axf = ((ax * faz) - (_arg1 * azf));
bxf = ((bx * fbz) - (_arg1 * bzf));
ayf = ((ay * faz) - (_arg2 * azf));
byf = ((by * fbz) - (_arg2 * bzf));
det = ((dx * (axf - bxf)) + (dy * (ayf - byf)));
db = ((dx * (axf - _arg1)) + (dy * (ayf - _arg2)));
da = ((dx * (_arg1 - bxf)) + (dy * (_arg2 - byf)));
return ((((da * az) + (db * bz)) / det));
}
override public function quarter(_arg1:Number):Array{
if (length < 5){
return (null);
};
var _local2:int = screenIndices.length;
screenIndices[screenIndices.length] = startIndex;
screenIndices[screenIndices.length] = screenVertices.length;
var _local3:int = screenIndices.length;
screenIndices[screenIndices.length] = screenVertices.length;
screenIndices[screenIndices.length] = (startIndex + 1);
var _local4:int = screenIndices.length;
ScreenVertex.median(startIndex, (startIndex + 1), screenVertices, screenIndices, _arg1);
return ([create(source, segmentVO, material, screenVertices, screenIndices, screenCommands, _local2, _local3, true), create(source, segmentVO, material, screenVertices, screenIndices, screenCommands, _local3, _local4, true)]);
}
override public function calc():void{
_index = (screenIndices[startIndex] * 3);
v0x = screenVertices[_index];
v0y = screenVertices[(_index + 1)];
v0z = screenVertices[(_index + 2)];
_index = (screenIndices[(startIndex + 1)] * 3);
v1x = screenVertices[_index];
v1y = screenVertices[(_index + 1)];
v1z = screenVertices[(_index + 2)];
if (v0z < v1z){
minZ = v0z;
maxZ = (v1z + 1);
} else {
minZ = v1z;
maxZ = (v0z + 1);
};
screenZ = ((v0z + v1z) / 2);
if (v0x < v1x){
minX = v0x;
maxX = (v1x + 1);
} else {
minX = v1x;
maxX = (v0x + 1);
};
if (v0y < v1y){
minY = v0y;
maxY = (v1y + 1);
} else {
minY = v1y;
maxY = (v0y + 1);
};
length = Math.sqrt((((maxX - minX) * (maxX - minX)) + ((maxY - minY) * (maxY - minY))));
}
override public function toString():String{
return ((((((("S{ screenZ = " + screenZ) + ", minZ = ") + minZ) + ", maxZ = ") + maxZ) + " }"));
}
}
}//package away3d.core.draw
Section 40
//DrawSprite (away3d.core.draw.DrawSprite)
package away3d.core.draw {
import away3d.core.utils.*;
import away3d.materials.*;
import flash.geom.*;
public class DrawSprite extends DrawPrimitive {
private var cos:Number;
private var sin:Number;
private var cosw:Number;
private var cosh:Number;
private var sinw:Number;
private var sinh:Number;
private var uvMaterial:BitmapMaterial;
private var pointMapping:Matrix;
private var w:Number;
private var h:Number;
private var _index:int;
public var mapping:Matrix;
public var index:int;
public var screenVertices:Array;
public var screenIndices:Array;
public var vx:Number;
public var vy:Number;
public var topleftx:Number;
public var toplefty:Number;
public var toprightx:Number;
public var toprighty:Number;
public var bottomleftx:Number;
public var bottomlefty:Number;
public var bottomrightx:Number;
public var bottomrighty:Number;
public var scale:Number;
public var width:Number;
public var height:Number;
public var rotation:Number;
public var spriteVO:SpriteVO;
public var material:Material;
public function DrawSprite(){
mapping = new Matrix();
super();
}
override public function calc():void{
var _local1:Array;
var _local2:int;
var _local3:Array;
var _local4:int;
_index = (screenIndices[index] * 3);
vx = screenVertices[_index];
vy = screenVertices[(_index + 1)];
screenZ = screenVertices[(_index + 2)];
minZ = screenZ;
maxZ = screenZ;
uvMaterial = (material as BitmapMaterial);
if (uvMaterial){
w = (uvMaterial.width * scale);
h = (uvMaterial.height * scale);
} else {
w = (width * scale);
h = (height * scale);
};
if (rotation != 0){
cos = Math.cos(((rotation * Math.PI) / 180));
sin = Math.sin(((rotation * Math.PI) / 180));
cosw = ((cos * w) / 2);
cosh = ((cos * h) / 2);
sinw = ((sin * w) / 2);
sinh = ((sin * h) / 2);
topleftx = ((vx - cosw) - sinh);
toplefty = ((vy + sinw) - cosh);
toprightx = ((vx + cosw) - sinh);
toprighty = ((vy - sinw) - cosh);
bottomleftx = ((vx - cosw) + sinh);
bottomlefty = ((vy + sinw) + cosh);
bottomrightx = ((vx + cosw) + sinh);
bottomrighty = ((vy - sinw) + cosh);
_local1 = [];
_local1.push(topleftx);
_local1.push(toprightx);
_local1.push(bottomleftx);
_local1.push(bottomrightx);
minX = 100000;
maxX = -100000;
for each (_local2 in _local1) {
if (minX > _local2){
minX = _local2;
};
if (maxX < _local2){
maxX = _local2;
};
};
_local3 = [];
_local3.push(toplefty);
_local3.push(toprighty);
_local3.push(bottomlefty);
_local3.push(bottomrighty);
minY = 100000;
maxY = -100000;
for each (_local4 in _local3) {
if (minY > _local4){
minY = _local4;
};
if (maxY < _local4){
maxY = _local4;
};
};
mapping.a = (scale * cos);
mapping.b = (-(scale) * sin);
mapping.c = (scale * sin);
mapping.d = (scale * cos);
mapping.tx = topleftx;
mapping.ty = toplefty;
} else {
bottomrightx = (toprightx = ((bottomleftx = (topleftx = (vx - (w / 2)))) + w));
bottomrighty = (bottomlefty = ((toprighty = (toplefty = (vy - (h / 2)))) + h));
minX = topleftx;
minY = toplefty;
maxX = bottomrightx;
maxY = bottomrighty;
mapping.a = (mapping.d = scale);
mapping.c = (mapping.b = 0);
mapping.tx = topleftx;
mapping.ty = toplefty;
};
}
override public function clear():void{
}
override public function render():void{
material.renderSprite(this);
}
override public function contains(_arg1:Number, _arg2:Number):Boolean{
if (rotation != 0){
if ((((topleftx * (_arg2 - toprighty)) + (toprightx * (toplefty - _arg2))) + (_arg1 * (toprighty - toplefty))) > 0.001){
return (false);
};
if ((((toprightx * (_arg2 - bottomrighty)) + (bottomrightx * (toprighty - _arg2))) + (_arg1 * (bottomrighty - toprighty))) > 0.001){
return (false);
};
if ((((bottomrightx * (_arg2 - bottomlefty)) + (bottomleftx * (bottomrighty - _arg2))) + (_arg1 * (bottomlefty - bottomrighty))) > 0.001){
return (false);
};
if ((((bottomleftx * (_arg2 - toplefty)) + (topleftx * (bottomlefty - _arg2))) + (_arg1 * (toplefty - bottomlefty))) > 0.001){
return (false);
};
};
uvMaterial = (material as BitmapMaterial);
if (((!(uvMaterial)) || (!(uvMaterial.bitmap.transparent)))){
return (true);
};
pointMapping = mapping.clone();
pointMapping.invert();
var _local3:Point = pointMapping.transformPoint(new Point(_arg1, _arg2));
if (_local3.x < 0){
_local3.x = 0;
};
if (_local3.y < 0){
_local3.y = 0;
};
if (_local3.x >= uvMaterial.width){
_local3.x = (uvMaterial.width - 1);
};
if (_local3.y >= uvMaterial.height){
_local3.y = (uvMaterial.height - 1);
};
var _local4:uint = uvMaterial.bitmap.getPixel32(int(_local3.x), int(_local3.y));
return ((uint((_local4 >> 24)) > 128));
}
}
}//package away3d.core.draw
Section 41
//DrawTriangle (away3d.core.draw.DrawTriangle)
package away3d.core.draw {
import away3d.core.base.*;
import away3d.core.utils.*;
import away3d.materials.*;
import away3d.core.geom.*;
import flash.geom.*;
public class DrawTriangle extends DrawPrimitive {
private var materialWidth:Number;
private var materialHeight:Number;
private var _u0:Number;
private var _u1:Number;
private var _u2:Number;
private var _v0:Number;
private var _v1:Number;
private var _v2:Number;
private var _areaSign:Number;
private var focus:Number;
private var ax:Number;
private var ay:Number;
private var az:Number;
private var bx:Number;
private var by:Number;
private var bz:Number;
private var cx:Number;
private var cy:Number;
private var cz:Number;
private var azf:Number;
private var bzf:Number;
private var czf:Number;
private var faz:Number;
private var fbz:Number;
private var fcz:Number;
private var axf:Number;
private var bxf:Number;
private var cxf:Number;
private var ayf:Number;
private var byf:Number;
private var cyf:Number;
private var det:Number;
private var da:Number;
private var db:Number;
private var dc:Number;
private var au:Number;
private var av:Number;
private var bu:Number;
private var bv:Number;
private var cu:Number;
private var cv:Number;
private var uv01:UV;
private var uv12:UV;
private var uv20:UV;
private var _invtexmapping:Matrix;
private var _index:int;
private var _vertex:int;
private var _x:Number;
private var _y:Number;
private var _z:Number;
private var _vertexCount:uint;
public var v0x:Number;
public var v0y:Number;
public var v0z:Number;
public var v1x:Number;
public var v1y:Number;
public var v1z:Number;
public var v2x:Number;
public var v2y:Number;
public var v2z:Number;
public var uv0:UV;
public var uv1:UV;
public var uv2:UV;
public var area:Number;
public var faceVO:FaceVO;
public var backface:Boolean;// = false
public var material:Material;
public var screenVertices:Array;
public var screenIndices:Array;
public var screenCommands:Array;
public var startIndex:int;
public var endIndex:int;
public var reverseArea:Boolean;
public function DrawTriangle(){
_invtexmapping = new Matrix();
super();
}
function fivepointcut(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:Number, _arg7:Number, _arg8:Number, _arg9:Number, _arg10:UV, _arg11:UV, _arg12:UV, _arg13:UV, _arg14:UV):Array{
var _local19:int;
var _local20:int;
var _local21:int;
var _local22:int;
var _local23:int;
var _local24:int;
var _local25:int;
var _local26:int;
var _local15:int = (screenVertices.length / 3);
var _local16:int = screenIndices[_arg1];
var _local17:int = screenIndices[_arg5];
var _local18:int = screenIndices[_arg9];
if (ScreenVertex.distanceSqr(screenVertices[(_local16 * 3)], screenVertices[((_local16 * 3) + 1)], _arg6, _arg7) < ScreenVertex.distanceSqr(_arg2, _arg3, screenVertices[(_local18 * 3)], screenVertices[((_local18 * 3) + 1)])){
_local19 = screenIndices.length;
screenIndices[screenIndices.length] = _local16;
screenIndices[screenIndices.length] = _local15;
screenIndices[screenIndices.length] = (_local15 + 1);
_local20 = screenIndices.length;
screenIndices[screenIndices.length] = _local15;
screenIndices[screenIndices.length] = _local17;
screenIndices[screenIndices.length] = (_local15 + 1);
_local21 = screenIndices.length;
screenIndices[screenIndices.length] = _local16;
screenIndices[screenIndices.length] = (_local15 + 1);
screenIndices[screenIndices.length] = _local18;
_local22 = screenIndices.length;
screenVertices[screenVertices.length] = _arg2;
screenVertices[screenVertices.length] = _arg3;
screenVertices[screenVertices.length] = _arg4;
screenVertices[screenVertices.length] = _arg6;
screenVertices[screenVertices.length] = _arg7;
screenVertices[screenVertices.length] = _arg8;
return ([create(source, faceVO, material, screenVertices, screenIndices, screenCommands, _local19, _local20, _arg10, _arg11, _arg13, true), create(source, faceVO, material, screenVertices, screenIndices, screenCommands, _local20, _local21, _arg11, _arg12, _arg13, true), create(source, faceVO, material, screenVertices, screenIndices, screenCommands, _local21, _local22, _arg10, _arg13, _arg14, true)]);
};
_local23 = screenIndices.length;
screenIndices[screenIndices.length] = _local16;
screenIndices[screenIndices.length] = _local15;
screenIndices[screenIndices.length] = _local18;
_local24 = screenIndices.length;
screenIndices[screenIndices.length] = _local15;
screenIndices[screenIndices.length] = _local17;
screenIndices[screenIndices.length] = (_local15 + 1);
_local25 = screenIndices.length;
screenIndices[screenIndices.length] = _local15;
screenIndices[screenIndices.length] = (_local15 + 1);
screenIndices[screenIndices.length] = _local18;
_local26 = screenIndices.length;
screenVertices[screenVertices.length] = _arg2;
screenVertices[screenVertices.length] = _arg3;
screenVertices[screenVertices.length] = _arg4;
screenVertices[screenVertices.length] = _arg6;
screenVertices[screenVertices.length] = _arg7;
screenVertices[screenVertices.length] = _arg8;
return ([create(source, faceVO, material, screenVertices, screenIndices, screenCommands, _local23, _local24, _arg10, _arg11, _arg14, true), create(source, faceVO, material, screenVertices, screenIndices, screenCommands, _local24, _local25, _arg11, _arg12, _arg13, true), create(source, faceVO, material, screenVertices, screenIndices, screenCommands, _local25, _local26, _arg11, _arg13, _arg14, true)]);
}
private function num(_arg1:Number):Number{
return ((int((_arg1 * 1000)) / 1000));
}
override public function clear():void{
uv0 = null;
uv1 = null;
uv2 = null;
}
override public function render():void{
material.renderTriangle(this);
}
final public function transformUV(_arg1:LayerMaterial):Matrix{
materialWidth = _arg1.width;
materialHeight = _arg1.height;
if ((((((uv0 == null)) || ((uv1 == null)))) || ((uv2 == null)))){
return (null);
};
_u0 = (materialWidth * uv0._u);
_u1 = (materialWidth * uv1._u);
_u2 = (materialWidth * uv2._u);
_v0 = (materialHeight * (1 - uv0._v));
_v1 = (materialHeight * (1 - uv1._v));
_v2 = (materialHeight * (1 - uv2._v));
if ((((((_u0 == _u1)) && ((_v0 == _v1)))) || ((((_u0 == _u2)) && ((_v0 == _v2)))))){
if (_u0 > 0.05){
_u0 = (_u0 - 0.05);
} else {
_u0 = (_u0 + 0.05);
};
if (_v0 > 0.07){
_v0 = (_v0 - 0.07);
} else {
_v0 = (_v0 + 0.07);
};
};
if ((((_u2 == _u1)) && ((_v2 == _v1)))){
if (_u2 > 0.04){
_u2 = (_u2 - 0.04);
} else {
_u2 = (_u2 + 0.04);
};
if (_v2 > 0.06){
_v2 = (_v2 - 0.06);
} else {
_v2 = (_v2 + 0.06);
};
};
_invtexmapping.a = (_u1 - _u0);
_invtexmapping.b = (_v1 - _v0);
_invtexmapping.c = (_u2 - _u0);
_invtexmapping.d = (_v2 - _v0);
if ((((_arg1 is CompositeMaterial)) && ((_arg1 as CompositeMaterial).surfaceCache))){
_invtexmapping.tx = (_u0 - faceVO.face.bitmapRect.x);
_invtexmapping.ty = (_v0 - faceVO.face.bitmapRect.y);
} else {
_invtexmapping.tx = _u0;
_invtexmapping.ty = _v0;
};
return (_invtexmapping);
}
final override public function getZ(_arg1:Number, _arg2:Number):Number{
focus = view.camera.focus;
if (_vertexCount > 3){
return (screenZ);
};
ax = v0x;
ay = v0y;
az = v0z;
bx = v1x;
by = v1y;
bz = v1z;
cx = v2x;
cy = v2y;
cz = v2z;
if ((((ax == _arg1)) && ((ay == _arg2)))){
return (az);
};
if ((((bx == _arg1)) && ((by == _arg2)))){
return (bz);
};
if ((((cx == _arg1)) && ((cy == _arg2)))){
return (cz);
};
azf = (az / focus);
bzf = (bz / focus);
czf = (cz / focus);
faz = (1 + azf);
fbz = (1 + bzf);
fcz = (1 + czf);
axf = ((ax * faz) - (_arg1 * azf));
bxf = ((bx * fbz) - (_arg1 * bzf));
cxf = ((cx * fcz) - (_arg1 * czf));
ayf = ((ay * faz) - (_arg2 * azf));
byf = ((by * fbz) - (_arg2 * bzf));
cyf = ((cy * fcz) - (_arg2 * czf));
det = (((axf * (byf - cyf)) + (bxf * (cyf - ayf))) + (cxf * (ayf - byf)));
da = (((_arg1 * (byf - cyf)) + (bxf * (cyf - _arg2))) + (cxf * (_arg2 - byf)));
db = (((axf * (_arg2 - cyf)) + (_arg1 * (cyf - ayf))) + (cxf * (ayf - _arg2)));
dc = (((axf * (byf - _arg2)) + (bxf * (_arg2 - ayf))) + (_arg1 * (ayf - byf)));
return (((((da * az) + (db * bz)) + (dc * cz)) / det));
}
public function getUV(_arg1:Number, _arg2:Number):UV{
if (uv0 == null){
return (null);
};
if (uv1 == null){
return (null);
};
if (uv2 == null){
return (null);
};
au = uv0._u;
av = uv0._v;
bu = uv1._u;
bv = uv1._v;
cu = uv2._u;
cv = uv2._v;
focus = view.camera.focus;
ax = v0x;
ay = v0y;
az = v0z;
bx = v1x;
by = v1y;
bz = v1z;
cx = v2x;
cy = v2y;
cz = v2z;
if ((((ax == _arg1)) && ((ay == _arg2)))){
return (uv0);
};
if ((((bx == _arg1)) && ((by == _arg2)))){
return (uv1);
};
if ((((cx == _arg1)) && ((cy == _arg2)))){
return (uv2);
};
azf = (az / focus);
bzf = (bz / focus);
czf = (cz / focus);
faz = (1 + azf);
fbz = (1 + bzf);
fcz = (1 + czf);
axf = ((ax * faz) - (_arg1 * azf));
bxf = ((bx * fbz) - (_arg1 * bzf));
cxf = ((cx * fcz) - (_arg1 * czf));
ayf = ((ay * faz) - (_arg2 * azf));
byf = ((by * fbz) - (_arg2 * bzf));
cyf = ((cy * fcz) - (_arg2 * czf));
det = (((axf * (byf - cyf)) + (bxf * (cyf - ayf))) + (cxf * (ayf - byf)));
da = (((_arg1 * (byf - cyf)) + (bxf * (cyf - _arg2))) + (cxf * (_arg2 - byf)));
db = (((axf * (_arg2 - cyf)) + (_arg1 * (cyf - ayf))) + (cxf * (ayf - _arg2)));
dc = (((axf * (byf - _arg2)) + (bxf * (_arg2 - ayf))) + (_arg1 * (ayf - byf)));
return (new UV(((((da * au) + (db * bu)) + (dc * cu)) / det), ((((da * av) + (db * bv)) + (dc * cv)) / det)));
}
final override public function quarter(_arg1:Number):Array{
if ((((area > -20)) && ((area < 20)))){
return (null);
};
var _local2:int = (screenVertices.length / 3);
var _local3:int = screenIndices.length;
screenIndices[screenIndices.length] = screenIndices[startIndex];
screenIndices[screenIndices.length] = _local2;
screenIndices[screenIndices.length] = (_local2 + 2);
var _local4:int = screenIndices.length;
screenIndices[screenIndices.length] = screenIndices[(startIndex + 1)];
screenIndices[screenIndices.length] = (_local2 + 1);
screenIndices[screenIndices.length] = _local2;
var _local5:int = screenIndices.length;
screenIndices[screenIndices.length] = screenIndices[(startIndex + 2)];
screenIndices[screenIndices.length] = (_local2 + 2);
screenIndices[screenIndices.length] = (_local2 + 1);
var _local6:int = screenIndices.length;
screenIndices[screenIndices.length] = _local2;
screenIndices[screenIndices.length] = (_local2 + 1);
screenIndices[screenIndices.length] = (_local2 + 2);
var _local7:int = screenIndices.length;
ScreenVertex.median(startIndex, (startIndex + 1), screenVertices, screenIndices, _arg1);
ScreenVertex.median((startIndex + 1), (startIndex + 2), screenVertices, screenIndices, _arg1);
ScreenVertex.median((startIndex + 2), startIndex, screenVertices, screenIndices, _arg1);
uv01 = UV.median(uv0, uv1);
uv12 = UV.median(uv1, uv2);
uv20 = UV.median(uv2, uv0);
return ([create(source, faceVO, material, screenVertices, screenIndices, screenCommands, _local3, _local4, uv0, uv01, uv20, true), create(source, faceVO, material, screenVertices, screenIndices, screenCommands, _local4, _local5, uv1, uv12, uv01, true), create(source, faceVO, material, screenVertices, screenIndices, screenCommands, _local5, _local6, uv2, uv20, uv12, true), create(source, faceVO, material, screenVertices, screenIndices, screenCommands, _local6, _local7, uv01, uv12, uv20, true)]);
}
final override public function contains(_arg1:Number, _arg2:Number):Boolean{
var _local3:Boolean;
var _local4:int;
var _local5:int;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:int;
var _local11:int;
if (_vertexCount > 3){
_local3 = false;
_local4 = startIndex;
_local5 = (endIndex - 1);
while (_local4 < endIndex) {
if (screenCommands[_local4] == PathCommand.CURVE){
_local4++;
};
_local10 = (screenIndices[_local4] * 3);
_local7 = screenVertices[(_local10 + 1)];
_local11 = (screenIndices[_local5] * 3);
_local9 = screenVertices[(_local11 + 1)];
if (((!(((_local7 > _arg2) == (_local9 > _arg2)))) && ((_arg1 < ((((screenVertices[_local11] - screenVertices[_local10]) * (_arg2 - _local7)) / (_local9 - _local7)) + _local6))))){
_local3 = !(_local3);
};
var _temp1 = _local4;
_local4 = (_local4 + 1);
_local5 = _temp1;
if (screenCommands[_local4] == PathCommand.MOVE){
var _temp2 = _local4;
_local4 = (_local4 + 1);
_local5 = _temp2;
};
};
return (_local3);
};
if (((((v0x * (_arg2 - v1y)) + (v1x * (v0y - _arg2))) + (_arg1 * (v1y - v0y))) * _areaSign) < -0.001){
return (false);
};
if (((((v0x * (v2y - _arg2)) + (_arg1 * (v0y - v2y))) + (v2x * (_arg2 - v0y))) * _areaSign) < -0.001){
return (false);
};
if (((((_arg1 * (v2y - v1y)) + (v1x * (_arg2 - v2y))) + (v2x * (v1y - _arg2))) * _areaSign) < -0.001){
return (false);
};
return (true);
}
final public function distanceToCenter(_arg1:Number, _arg2:Number):Number{
var _local3:Number = (((v0x + v1x) + v2x) / 3);
var _local4:Number = (((v0y + v1y) + v2y) / 3);
return (Math.sqrt((((_local3 - _arg1) * (_local3 - _arg1)) + ((_local4 - _arg2) * (_local4 - _arg2)))));
}
override public function calc():void{
_index = (screenIndices[startIndex] * 3);
v0x = screenVertices[_index];
v0y = screenVertices[(_index + 1)];
v0z = screenVertices[(_index + 2)];
_index = (screenIndices[(startIndex + 1)] * 3);
v1x = screenVertices[_index];
v1y = screenVertices[(_index + 1)];
v1z = screenVertices[(_index + 2)];
_index = (screenIndices[(startIndex + 2)] * 3);
v2x = screenVertices[_index];
v2y = screenVertices[(_index + 1)];
v2z = screenVertices[(_index + 2)];
_vertexCount = (endIndex - startIndex);
if (_vertexCount > 3){
screenZ = 0;
_index = endIndex;
minX = Infinity;
maxX = -(Infinity);
minY = Infinity;
maxY = -(Infinity);
minZ = Infinity;
maxZ = -(Infinity);
while (_index-- > startIndex) {
_vertex = (screenIndices[_index] * 3);
_x = screenVertices[_vertex];
_y = screenVertices[(_vertex + 1)];
_z = screenVertices[(_vertex + 2)];
if (minX > _x){
minX = _x;
};
if (maxX < _x){
maxX = _x;
};
if (minY > _y){
minY = _y;
};
if (maxY < _y){
maxY = _y;
};
if (minZ > _z){
minZ = _z;
};
if (maxZ < _z){
maxZ = _z;
};
screenZ = (screenZ + _z);
};
screenZ = (screenZ / _vertexCount);
} else {
if (v0x > v1x){
if (v0x > v2x){
maxX = v0x;
} else {
maxX = v2x;
};
} else {
if (v1x > v2x){
maxX = v1x;
} else {
maxX = v2x;
};
};
if (v0x < v1x){
if (v0x < v2x){
minX = v0x;
} else {
minX = v2x;
};
} else {
if (v1x < v2x){
minX = v1x;
} else {
minX = v2x;
};
};
if (v0y > v1y){
if (v0y > v2y){
maxY = v0y;
} else {
maxY = v2y;
};
} else {
if (v1y > v2y){
maxY = v1y;
} else {
maxY = v2y;
};
};
if (v0y < v1y){
if (v0y < v2y){
minY = v0y;
} else {
minY = v2y;
};
} else {
if (v1y < v2y){
minY = v1y;
} else {
minY = v2y;
};
};
if (v0z > v1z){
if (v0z > v2z){
maxZ = v0z;
} else {
maxZ = v2z;
};
} else {
if (v1z > v2z){
maxZ = v1z;
} else {
maxZ = v2z;
};
};
if (v0z < v1z){
if (v0z < v2z){
minZ = v0z;
} else {
minZ = v2z;
};
} else {
if (v1z < v2z){
minZ = v1z;
} else {
minZ = v2z;
};
};
screenZ = (((v0z + v1z) + v2z) / 3);
};
area = (0.5 * (((v0x * (v2y - v1y)) + (v1x * (v0y - v2y))) + (v2x * (v1y - v0y))));
if (area > 0){
_areaSign = 1;
} else {
_areaSign = -1;
};
}
override public function toString():String{
var _local1 = "";
if ((material is WireColorMaterial)){
switch ((material as WireColorMaterial).color){
case 0xFF00:
_local1 = "green";
break;
case 0xFFFF00:
_local1 = "yellow";
break;
case 0xFF0000:
_local1 = "red";
break;
case 0xFF:
_local1 = "blue";
break;
};
};
return (((((((((("T{" + _local1) + int(area)) + " screenZ = ") + num(screenZ)) + ", minZ = ") + num(minZ)) + ", maxZ = ") + num(maxZ)) + " }"));
}
}
}//package away3d.core.draw
Section 42
//IPrimitiveConsumer (away3d.core.draw.IPrimitiveConsumer)
package away3d.core.draw {
import away3d.containers.*;
public interface IPrimitiveConsumer {
function primitive(_arg1:DrawPrimitive):Boolean;
function list():Array;
function clear(_arg1:View3D):void;
function clone():IPrimitiveConsumer;
}
}//package away3d.core.draw
Section 43
//IPrimitiveProvider (away3d.core.draw.IPrimitiveProvider)
package away3d.core.draw {
import away3d.core.math.*;
import away3d.core.base.*;
public interface IPrimitiveProvider {
function primitives(_arg1:Object3D, _arg2:Matrix3D, _arg3:IPrimitiveConsumer):void;
}
}//package away3d.core.draw
Section 44
//PrimitiveQuadrantTreeNode (away3d.core.draw.PrimitiveQuadrantTreeNode)
package away3d.core.draw {
import away3d.core.base.*;
public final class PrimitiveQuadrantTreeNode {
private var render_center_length:int;// = -1
private var render_center_index:int;// = -1
private var halfwidth:Number;
private var halfheight:Number;
private var level:int;
private var maxlevel:int;// = 4
public var center:Array;
public var lefttop:PrimitiveQuadrantTreeNode;
public var leftbottom:PrimitiveQuadrantTreeNode;
public var righttop:PrimitiveQuadrantTreeNode;
public var rightbottom:PrimitiveQuadrantTreeNode;
public var lefttopFlag:Boolean;
public var leftbottomFlag:Boolean;
public var righttopFlag:Boolean;
public var rightbottomFlag:Boolean;
public var onlysourceFlag:Boolean;// = true
public var onlysource:Object3D;
public var xdiv:Number;
public var ydiv:Number;
public var parent:PrimitiveQuadrantTreeNode;
public var create:Function;
public function PrimitiveQuadrantTreeNode(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:int, _arg6:PrimitiveQuadrantTreeNode=null){
center = new Array();
super();
this.level = _arg5;
this.xdiv = _arg1;
this.ydiv = _arg2;
halfwidth = (_arg3 / 2);
halfheight = (_arg4 / 2);
this.parent = _arg6;
}
private function render_other(_arg1:Number):void{
if (lefttopFlag){
lefttop.render(_arg1);
};
if (leftbottomFlag){
leftbottom.render(_arg1);
};
if (righttopFlag){
righttop.render(_arg1);
};
if (rightbottomFlag){
rightbottom.render(_arg1);
};
}
public function push(_arg1:DrawPrimitive):void{
if (onlysourceFlag){
if (((!((onlysource == null))) && (!((onlysource == _arg1.source))))){
onlysourceFlag = false;
};
onlysource = _arg1.source;
};
if (level < maxlevel){
if (_arg1.maxX <= xdiv){
if (_arg1.maxY <= ydiv){
if (lefttop == null){
lefttopFlag = true;
lefttop = new PrimitiveQuadrantTreeNode((xdiv - (halfwidth / 2)), (ydiv - (halfheight / 2)), halfwidth, halfheight, (level + 1), this);
} else {
if (!lefttopFlag){
lefttopFlag = true;
lefttop.reset((xdiv - (halfwidth / 2)), (ydiv - (halfheight / 2)), halfwidth, halfheight);
};
};
lefttop.push(_arg1);
return;
} else {
if (_arg1.minY >= ydiv){
if (leftbottom == null){
leftbottomFlag = true;
leftbottom = new PrimitiveQuadrantTreeNode((xdiv - (halfwidth / 2)), (ydiv + (halfheight / 2)), halfwidth, halfheight, (level + 1), this);
} else {
if (!leftbottomFlag){
leftbottomFlag = true;
leftbottom.reset((xdiv - (halfwidth / 2)), (ydiv + (halfheight / 2)), halfwidth, halfheight);
};
};
leftbottom.push(_arg1);
return;
};
};
} else {
if (_arg1.minX >= xdiv){
if (_arg1.maxY <= ydiv){
if (righttop == null){
righttopFlag = true;
righttop = new PrimitiveQuadrantTreeNode((xdiv + (halfwidth / 2)), (ydiv - (halfheight / 2)), halfwidth, halfheight, (level + 1), this);
} else {
if (!righttopFlag){
righttopFlag = true;
righttop.reset((xdiv + (halfwidth / 2)), (ydiv - (halfheight / 2)), halfwidth, halfheight);
};
};
righttop.push(_arg1);
return;
} else {
if (_arg1.minY >= ydiv){
if (rightbottom == null){
rightbottomFlag = true;
rightbottom = new PrimitiveQuadrantTreeNode((xdiv + (halfwidth / 2)), (ydiv + (halfheight / 2)), halfwidth, halfheight, (level + 1), this);
} else {
if (!rightbottomFlag){
rightbottomFlag = true;
rightbottom.reset((xdiv + (halfwidth / 2)), (ydiv + (halfheight / 2)), halfwidth, halfheight);
};
};
rightbottom.push(_arg1);
return;
};
};
};
};
};
center.push(_arg1);
_arg1.quadrant = this;
}
public function reset(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):void{
this.xdiv = _arg1;
this.ydiv = _arg2;
halfwidth = (_arg3 / 2);
halfheight = (_arg4 / 2);
lefttopFlag = false;
leftbottomFlag = false;
righttopFlag = false;
rightbottomFlag = false;
center.length = 0;
onlysourceFlag = true;
onlysource = null;
render_center_length = -1;
render_center_index = -1;
}
public function render(_arg1:Number):void{
var _local2:DrawPrimitive;
if (render_center_length == -1){
render_center_length = center.length;
if (render_center_length){
if (render_center_length > 1){
center.sortOn("screenZ", (Array.DESCENDING | Array.NUMERIC));
};
};
render_center_index = 0;
};
while (render_center_index < render_center_length) {
_local2 = center[render_center_index];
if (_local2.screenZ < _arg1){
break;
};
render_other(_local2.screenZ);
_local2.render();
render_center_index++;
};
render_other(_arg1);
}
}
}//package away3d.core.draw
Section 45
//ScreenVertex (away3d.core.draw.ScreenVertex)
package away3d.core.draw {
import away3d.core.geom.*;
public final class ScreenVertex {
private var persp:Number;
private var faz:Number;
private var fbz:Number;
private var ifmz2:Number;
private var mx2:Number;
private var my2:Number;
private var dx:Number;
private var dy:Number;
public var vx:Number;
public var vy:Number;
public var x:Number;
public var y:Number;
public var z:Number;
public var visible:Boolean;
public var viewTimer:int;
public function ScreenVertex(_arg1:Number=0, _arg2:Number=0, _arg3:Number=0){
this.x = _arg1;
this.y = _arg2;
this.z = _arg3;
this.visible = false;
}
public function toString():String{
return ((((((("new ScreenVertex(" + x) + ", ") + y) + ", ") + z) + ")"));
}
public function distance(_arg1:ScreenVertex):Number{
return (Math.sqrt((((x - _arg1.x) * (x - _arg1.x)) + ((y - _arg1.y) * (y - _arg1.y)))));
}
public function distortSqr(_arg1:ScreenVertex, _arg2:Number):Number{
faz = (_arg2 + z);
fbz = (_arg2 + z);
ifmz2 = (2 / (faz + fbz));
mx2 = (((x * faz) + (_arg1.x * fbz)) * ifmz2);
my2 = (((y * faz) + (_arg1.y * fbz)) * ifmz2);
dx = ((x + _arg1.x) - mx2);
dy = ((y + _arg1.y) - my2);
return ((50 * (((dx * dx) + dy) + dy)));
}
public static function distanceSqr(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
return ((((_arg1 - _arg3) * (_arg1 - _arg3)) + ((_arg2 - _arg4) * (_arg2 - _arg4))));
}
public static function weighted(_arg1:ScreenVertex, _arg2:ScreenVertex, _arg3:Number, _arg4:Number, _arg5:Number):ScreenVertex{
if ((((_arg4 == 0)) && ((_arg3 == 0)))){
throw (new Error("Zero weights"));
};
if (_arg4 == 0){
return (new ScreenVertex(_arg1.x, _arg1.y, _arg1.z));
};
if (_arg3 == 0){
return (new ScreenVertex(_arg2.x, _arg2.y, _arg2.z));
};
var _local6:Number = (_arg3 + _arg4);
var _local7:Number = (_arg3 / _local6);
var _local8:Number = (_arg4 / _local6);
var _local9:Number = ((_arg1.x * _local7) + (_arg2.x * _local8));
var _local10:Number = ((_arg1.y * _local7) + (_arg2.y * _local8));
var _local11:Number = (_arg1.z / _arg5);
var _local12:Number = (_arg2.z / _arg5);
var _local13:Number = (1 + _local11);
var _local14:Number = (1 + _local12);
var _local15:Number = ((_arg1.x * _local13) - (_local9 * _local11));
var _local16:Number = ((_arg2.x * _local14) - (_local9 * _local12));
var _local17:Number = ((_arg1.y * _local13) - (_local10 * _local11));
var _local18:Number = ((_arg2.y * _local14) - (_local10 * _local12));
var _local19:Number = ((_local15 * _local18) - (_local16 * _local17));
var _local20:Number = ((_local9 * _local18) - (_local16 * _local10));
var _local21:Number = ((_local15 * _local10) - (_local9 * _local17));
return (new ScreenVertex(_local9, _local10, (((_local20 * _arg1.z) + (_local21 * _arg2.z)) / _local19)));
}
public static function median(_arg1:Number, _arg2:Number, _arg3:Array, _arg4:Array, _arg5:Number):void{
var _local6:int = (_arg4[_arg1] * 3);
var _local7:Number = _arg3[_local6];
var _local8:Number = _arg3[(_local6 + 1)];
var _local9:Number = _arg3[(_local6 + 2)];
var _local10:int = (_arg4[_arg2] * 3);
var _local11:Number = _arg3[_local10];
var _local12:Number = _arg3[(_local10 + 1)];
var _local13:Number = _arg3[(_local10 + 2)];
var _local14:Number = ((_local9 + _local13) / 2);
var _local15:Number = (_arg5 + _local9);
var _local16:Number = (_arg5 + _local13);
var _local17:Number = ((1 / (_arg5 + _local14)) / 2);
_arg3[_arg3.length] = (((_local7 * _local15) + (_local11 * _local16)) * _local17);
_arg3[_arg3.length] = (((_local8 * _local15) + (_local12 * _local16)) * _local17);
_arg3[_arg3.length] = _local14;
}
}
}//package away3d.core.draw
Section 46
//IPrimitiveFilter (away3d.core.filter.IPrimitiveFilter)
package away3d.core.filter {
import away3d.containers.*;
import away3d.cameras.*;
import away3d.core.clip.*;
public interface IPrimitiveFilter {
function filter(_arg1:Array, _arg2:Scene3D, _arg3:Camera3D, _arg4:Clipping):Array;
}
}//package away3d.core.filter
Section 47
//ZSortFilter (away3d.core.filter.ZSortFilter)
package away3d.core.filter {
import away3d.containers.*;
import away3d.cameras.*;
import away3d.core.clip.*;
public class ZSortFilter implements IPrimitiveFilter {
public function filter(_arg1:Array, _arg2:Scene3D, _arg3:Camera3D, _arg4:Clipping):Array{
_arg1.sortOn("screenZ", (Array.DESCENDING | Array.NUMERIC));
return (_arg1);
}
public function toString():String{
return ("ZSort");
}
}
}//package away3d.core.filter
Section 48
//Frustum (away3d.core.geom.Frustum)
package away3d.core.geom {
import away3d.core.math.*;
import away3d.core.base.*;
public class Frustum {
public var planes:Array;
private var _matrix:Matrix3D;
private var _distance:Number;
public static const LEFT:int = 0;
public static const RIGHT:int = 1;
public static const TOP:int = 2;
public static const BOTTOM:int = 3;
public static const NEAR:int = 4;
public static const FAR:int = 5;
public static const OUT:int = 0;
public static const IN:int = 1;
public static const INTERSECT:int = 2;
public function Frustum(){
_matrix = new Matrix3D();
super();
planes = new Array(6);
planes[LEFT] = new Plane3D();
planes[RIGHT] = new Plane3D();
planes[TOP] = new Plane3D();
planes[BOTTOM] = new Plane3D();
planes[NEAR] = new Plane3D();
planes[FAR] = new Plane3D();
}
public function classifyObject3D(_arg1:Object3D):int{
return (classifySphere(_arg1.sceneTransform.position, _arg1.boundingRadius));
}
public function classifySphere(_arg1:Number3D, _arg2:Number):int{
var _local3:Plane3D;
for each (_local3 in planes) {
_distance = _local3.distance(_arg1);
if (_distance < -(_arg2)){
return (OUT);
};
if (Math.abs(_distance) < _arg2){
return (INTERSECT);
};
};
return (IN);
}
public function classifyRadius(_arg1:Number):int{
var _local2:Plane3D;
for each (_local2 in planes) {
if (_local2.d < -(_arg1)){
return (OUT);
};
if (Math.abs(_local2.d) < _arg1){
return (INTERSECT);
};
};
return (IN);
}
public function classifyAABB(_arg1:Array):int{
var _local4:Plane3D;
var _local5:int;
var _local6:int;
var _local2:int;
var _local3:int;
while (_local3 < 6) {
_local4 = Plane3D(planes[_local3]);
_local5 = 0;
_local6 = 0;
while (_local6 < 8) {
if (_local4.classifyPoint(_arg1[_local6]) == Plane3D.FRONT){
_local5++;
};
_local6++;
};
if (_local5 == 0){
return (OUT);
};
if (_local5 == 8){
_local2++;
};
_local3++;
};
if (_local2 == 6){
return (IN);
};
return (INTERSECT);
}
public function extractFromMatrix(_arg1:Matrix3D):void{
var _local2:Number;
var _local3:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local19:Plane3D;
_matrix = _arg1;
_local2 = _arg1.sxx;
_local3 = _arg1.sxy;
var _local4:Number = _arg1.sxz;
var _local5:Number = _arg1.tx;
var _local6:Number = _arg1.syx;
var _local7:Number = _arg1.syy;
var _local8:Number = _arg1.syz;
var _local9:Number = _arg1.ty;
_local10 = _arg1.szx;
_local11 = _arg1.szy;
_local12 = _arg1.szz;
_local13 = _arg1.tz;
_local14 = _arg1.swx;
_local15 = _arg1.swy;
_local16 = _arg1.swz;
_local17 = _arg1.tw;
var _local18:Plane3D = Plane3D(planes[NEAR]);
_local18.a = (_local14 + _local10);
_local18.b = (_local15 + _local11);
_local18.c = (_local16 + _local12);
_local18.d = (_local17 + _local13);
_local18.normalize();
_local19 = Plane3D(planes[FAR]);
_local19.a = (-(_local10) + _local14);
_local19.b = (-(_local11) + _local15);
_local19.c = (-(_local12) + _local16);
_local19.d = (-(_local13) + _local17);
_local19.normalize();
var _local20:Plane3D = Plane3D(planes[LEFT]);
_local20.a = (_local14 + _local2);
_local20.b = (_local15 + _local3);
_local20.c = (_local16 + _local4);
_local20.d = (_local17 + _local5);
_local20.normalize();
var _local21:Plane3D = Plane3D(planes[RIGHT]);
_local21.a = (-(_local2) + _local14);
_local21.b = (-(_local3) + _local15);
_local21.c = (-(_local4) + _local16);
_local21.d = (-(_local5) + _local17);
_local21.normalize();
var _local22:Plane3D = Plane3D(planes[TOP]);
_local22.a = (_local14 + _local6);
_local22.b = (_local15 + _local7);
_local22.c = (_local16 + _local8);
_local22.d = (_local17 + _local9);
_local22.normalize();
var _local23:Plane3D = Plane3D(planes[BOTTOM]);
_local23.a = (-(_local6) + _local14);
_local23.b = (-(_local7) + _local15);
_local23.c = (-(_local8) + _local16);
_local23.d = (-(_local9) + _local17);
_local23.normalize();
}
}
}//package away3d.core.geom
Section 49
//Line2D (away3d.core.geom.Line2D)
package away3d.core.geom {
import away3d.core.draw.*;
public class Line2D {
public var a:Number;
public var b:Number;
public var c:Number;
public function Line2D(_arg1:Number, _arg2:Number, _arg3:Number){
this.a = _arg1;
this.b = _arg2;
this.c = _arg3;
}
public function sideV(_arg1:ScreenVertex):Number{
return ((((a * _arg1.x) + (b * _arg1.y)) + c));
}
public function side(_arg1:Number, _arg2:Number):Number{
return ((((a * _arg1) + (b * _arg2)) + c));
}
public function distance(_arg1:ScreenVertex):Number{
return ((sideV(_arg1) / Math.sqrt(((a * a) + (b * b)))));
}
public function toString():String{
return ((((((("line{ a: " + a) + " b: ") + b) + " c:") + c) + " }"));
}
public static function from2points(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Line2D{
var _local5:Number = (_arg4 - _arg2);
var _local6:Number = (_arg1 - _arg3);
var _local7:Number = -(((_local6 * _arg2) + (_local5 * _arg1)));
return (new Line2D(_local5, _local6, _local7));
}
public static function cross(_arg1:Line2D, _arg2:Line2D):ScreenVertex{
var _local3:Number = ((_arg1.a * _arg2.b) - (_arg1.b * _arg2.a));
var _local4:Number = ((_arg1.b * _arg2.c) - (_arg1.c * _arg2.b));
var _local5:Number = ((_arg2.a * _arg1.c) - (_arg1.a * _arg2.c));
return (new ScreenVertex((_local4 / _local3), (_local5 / _local3), 0));
}
}
}//package away3d.core.geom
Section 50
//NGon (away3d.core.geom.NGon)
package away3d.core.geom {
import away3d.core.math.*;
import away3d.core.base.*;
import away3d.materials.*;
import away3d.graphs.bsp.*;
public final class NGon {
public var vertices:Array;
public var uvs:Array;
public var normal:Number3D;
public var plane:Plane3D;
public var material:Material;
var _isSplitter:Boolean;
private static var _newVerts:Array;
private static var _newUVs:Array;
private static var _tempU:Number3D = new Number3D();
private static var _tempV:Number3D = new Number3D();
private static var _tempC:Number3D = new Number3D();
public function adjacent(_arg1:NGon):Boolean{
var _local3:int;
var _local4:int;
var _local5:int;
var _local6:int;
var _local7:Vertex;
var _local8:Vertex;
var _local9:Vertex;
var _local10:Vertex;
var _local2:int = vertices.length;
var _local11:Array = _arg1.vertices;
var _local12:int = _local11.length;
_local3 = _local2;
_local4 = (_local2 - 1);
var _temp1 = _local4;
_local4 = (_local4 - 1);
_local8 = vertices[_temp1];
while (--_local3 >= 0) {
_local7 = _local8;
_local8 = vertices[_local4];
_local5 = _local12;
_local6 = (_local12 - 1);
var _temp2 = _local6;
_local6 = (_local6 - 1);
_local10 = _local11[_temp2];
while (--_local5 >= 0) {
_local9 = _local10;
_local10 = _local11[_local6];
if (isEdgeOverlapping(_local7, _local8, _local9, _local10)){
return (true);
};
--_local6;
if (_local6 < 0){
_local6 = (_local12 - 1);
};
};
--_local4;
if (_local4 < 0){
_local4 = (_local2 - 1);
};
};
return (false);
}
private function isEdgeOverlapping(_arg1:Vertex, _arg2:Vertex, _arg3:Vertex, _arg4:Vertex):Boolean{
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:Number;
var _local20:Number;
var _local21:Number;
var _local22:Number;
var _local23:Number;
_local5 = (_arg2._x - _arg1._x);
_local6 = (_arg2._y - _arg1._y);
_local7 = (_arg2._z - _arg1._z);
_local8 = (_arg3._x - _arg1._x);
_local9 = (_arg3._y - _arg1._y);
_local10 = (_arg3._z - _arg1._z);
_local11 = (_arg4._x - _arg1._x);
_local12 = (_arg4._y - _arg1._y);
_local13 = (_arg4._z - _arg1._z);
_local14 = ((_local6 * _local10) - (_local7 * _local9));
_local15 = ((_local7 * _local8) - (_local5 * _local10));
_local16 = ((_local5 * _local9) - (_local6 * _local8));
_local17 = ((_local6 * _local13) - (_local7 * _local12));
_local18 = ((_local7 * _local11) - (_local5 * _local13));
_local19 = ((_local5 * _local12) - (_local6 * _local11));
if (((((((_local14 * _local14) + (_local15 * _local15)) + (_local16 * _local16)) < BSPTree.EPSILON)) && (((((_local17 * _local17) + (_local18 * _local18)) + (_local19 * _local19)) < BSPTree.EPSILON)))){
if ((((((((_local5 > 0)) && ((_local5 >= _local6)))) && ((_local5 >= _local7)))) || ((((((_local5 < 0)) && ((_local5 <= _local6)))) && ((_local5 <= _local7)))))){
_local5 = (1 / _local5);
_local22 = (_local8 * _local5);
_local23 = (_local11 * _local5);
} else {
if ((((((((_local6 > 0)) && ((_local6 >= _local5)))) && ((_local6 >= _local7)))) || ((((((_local6 < 0)) && ((_local6 <= _local5)))) && ((_local6 <= _local7)))))){
_local6 = (1 / _local6);
_local22 = (_local9 * _local6);
_local23 = (_local12 * _local6);
} else {
if ((((((((_local7 > 0)) && ((_local7 >= _local5)))) && ((_local7 >= _local6)))) || ((((((_local7 < 0)) && ((_local7 <= _local5)))) && ((_local7 <= _local6)))))){
_local7 = (1 / _local7);
_local22 = (_local10 * _local7);
_local23 = (_local13 * _local7);
};
};
};
_local20 = -(BSPTree.EPSILON);
_local21 = (1 + BSPTree.EPSILON);
return (!((((((_local22 <= _local20)) && ((_local23 <= _local20)))) || ((((_local22 >= _local21)) && ((_local23 >= _local21)))))));
};
return (false);
}
public function invert():void{
var _local1:int = vertices.length;
var _local2:Array = new Array(_local1);
var _local3:int = _local1;
var _local4:int;
plane.a = -(plane.a);
plane.b = -(plane.b);
plane.c = -(plane.c);
plane.d = -(plane.d);
while (--_local3 >= 0) {
var _temp1 = _local4;
_local4 = (_local4 + 1);
var _local5 = _temp1;
_local2[_local5] = vertices[_local3];
};
vertices = _local2;
}
public function classifyToPlane(_arg1:Plane3D):int{
var _local2:int;
var _local3:int;
var _local4:int;
var _local6:Number;
var _local7:Vertex;
var _local5:int = vertices.length;
var _local8:int = _local5;
var _local9:int = _arg1._alignment;
var _local10:Number = _arg1.a;
var _local11:Number = _arg1.b;
var _local12:Number = _arg1.c;
var _local13:Number = _arg1.d;
if (_local9 == Plane3D.X_AXIS){
while (--_local8 >= 0) {
_local6 = ((_local10 * vertices[_local8]._x) + _local13);
if (_local6 > BSPTree.EPSILON){
_local2++;
} else {
if (_local6 < -(BSPTree.EPSILON)){
_local3++;
} else {
_local4++;
};
};
if ((((_local3 > 0)) && ((_local2 > 0)))){
return (Plane3D.INTERSECT);
};
};
} else {
if (_local9 == Plane3D.Y_AXIS){
while (--_local8 >= 0) {
_local6 = ((_local11 * vertices[_local8]._y) + _local13);
if (_local6 > BSPTree.EPSILON){
_local2++;
} else {
if (_local6 < -(BSPTree.EPSILON)){
_local3++;
} else {
_local4++;
};
};
if ((((_local3 > 0)) && ((_local2 > 0)))){
return (Plane3D.INTERSECT);
};
};
} else {
if (_local9 == Plane3D.Z_AXIS){
while (--_local8 >= 0) {
_local6 = ((_local12 * vertices[_local8]._z) + _local13);
if (_local6 > BSPTree.EPSILON){
_local2++;
} else {
if (_local6 < -(BSPTree.EPSILON)){
_local3++;
} else {
_local4++;
};
};
if ((((_local3 > 0)) && ((_local2 > 0)))){
return (Plane3D.INTERSECT);
};
};
} else {
while (--_local8 >= 0) {
_local7 = vertices[_local8];
_local6 = ((((_local10 * _local7._x) + (_local11 * _local7._y)) + (_local12 * _local7._z)) + _local13);
if (_local6 > BSPTree.EPSILON){
_local2++;
} else {
if (_local6 < -(BSPTree.EPSILON)){
_local3++;
} else {
_local4++;
};
};
if ((((_local3 > 0)) && ((_local2 > 0)))){
return (Plane3D.INTERSECT);
};
};
};
};
};
if (_local4 == _local5){
return (-2);
};
if ((((_local2 > 0)) && ((_local3 == 0)))){
return (Plane3D.FRONT);
};
if ((((_local3 > 0)) && ((_local2 == 0)))){
return (Plane3D.BACK);
};
return (Plane3D.INTERSECT);
}
public function isCoinciding(_arg1:Plane3D):Boolean{
var _local2:Vertex;
var _local9:Number;
var _local3:int = vertices.length;
var _local4:int = _arg1._alignment;
var _local5:Number = _arg1.a;
var _local6:Number = _arg1.b;
var _local7:Number = _arg1.c;
var _local8:Number = _arg1.d;
if (_local4 == Plane3D.X_AXIS){
while (--_local3 >= 0) {
_local9 = ((_local5 * vertices[_local3]._x) + _local8);
if ((((_local9 > BSPTree.EPSILON)) || ((_local9 < -(BSPTree.EPSILON))))){
return (false);
};
};
} else {
if (_local4 == Plane3D.Y_AXIS){
while (--_local3 >= 0) {
_local9 = ((_local6 * vertices[_local3]._y) + _local8);
if ((((_local9 > BSPTree.EPSILON)) || ((_local9 < -(BSPTree.EPSILON))))){
return (false);
};
};
} else {
if (_local4 == Plane3D.Z_AXIS){
while (--_local3 >= 0) {
_local9 = ((_local7 * vertices[_local3]._z) + _local8);
if ((((_local9 > BSPTree.EPSILON)) || ((_local9 < -(BSPTree.EPSILON))))){
return (false);
};
};
} else {
while (--_local3 >= 0) {
_local2 = vertices[_local3];
_local9 = ((((_local5 * _local2._x) + (_local6 * _local2._y)) + (_local7 * _local2._z)) + _local8);
if ((((_local9 > BSPTree.EPSILON)) || ((_local9 < -(BSPTree.EPSILON))))){
return (false);
};
};
};
};
};
return (true);
}
public function classifyForPortalFront(_arg1:Plane3D):Boolean{
var _local2:Vertex;
var _local3:int = vertices.length;
var _local4:int = _arg1._alignment;
var _local5:Number = _arg1.a;
var _local6:Number = _arg1.b;
var _local7:Number = _arg1.c;
var _local8:Number = _arg1.d;
if (_local4 == Plane3D.X_AXIS){
while (--_local3 >= 0) {
if (((_local5 * vertices[_local3]._x) + _local8) > BSPTree.EPSILON){
return (true);
};
};
} else {
if (_local4 == Plane3D.Y_AXIS){
while (--_local3 >= 0) {
if (((_local6 * vertices[_local3]._y) + _local8) > BSPTree.EPSILON){
return (true);
};
};
} else {
if (_local4 == Plane3D.Z_AXIS){
while (--_local3 >= 0) {
if (((_local7 * vertices[_local3]._z) + _local8) > BSPTree.EPSILON){
return (true);
};
};
} else {
while (--_local3 >= 0) {
_local2 = vertices[_local3];
if (((((_local5 * _local2._x) + (_local6 * _local2._y)) + (_local7 * _local2._z)) + _local8) > BSPTree.EPSILON){
return (true);
};
};
};
};
};
return (false);
}
public function classifyForPortalBack(_arg1:Plane3D):Boolean{
var _local2:Vertex;
var _local3:int = vertices.length;
var _local4:int = _arg1._alignment;
var _local5:Number = _arg1.a;
var _local6:Number = _arg1.b;
var _local7:Number = _arg1.c;
var _local8:Number = _arg1.d;
if (_local4 == Plane3D.X_AXIS){
while (--_local3 >= 0) {
if (((_local5 * vertices[_local3]._x) + _local8) < -(BSPTree.EPSILON)){
return (true);
};
};
} else {
if (_local4 == Plane3D.Y_AXIS){
while (--_local3 >= 0) {
if (((_local6 * vertices[_local3]._y) + _local8) < -(BSPTree.EPSILON)){
return (true);
};
};
} else {
if (_local4 == Plane3D.Z_AXIS){
while (--_local3 >= 0) {
if (((_local7 * vertices[_local3]._z) + _local8) < -(BSPTree.EPSILON)){
return (true);
};
};
} else {
while (--_local3 >= 0) {
_local2 = vertices[_local3];
if (((((_local5 * _local2._x) + (_local6 * _local2._y)) + (_local7 * _local2._z)) + _local8) < -(BSPTree.EPSILON)){
return (true);
};
};
};
};
};
return (false);
}
public function isOutAntiPenumbra(_arg1:Plane3D):Boolean{
var _local2:Vertex;
var _local3:int = vertices.length;
while (--_local3 >= 0) {
_local2 = vertices[_local3];
if (((((_arg1.a * _local2._x) + (_arg1.b * _local2._y)) + (_arg1.c * _local2._z)) + _arg1.d) > BSPTree.EPSILON){
return (false);
};
};
return (true);
}
public function clone():NGon{
var _local1:NGon = new NGon();
_local1.vertices = vertices.concat();
if (uvs){
_local1.uvs = uvs.concat();
};
_local1.material = material;
_local1.plane = new Plane3D(plane.a, plane.b, plane.c, plane.d);
_local1.plane._alignment = plane._alignment;
_local1._isSplitter = _isSplitter;
return (_local1);
}
public function triangulate():Array{
var _local4:Vertex;
var _local5:Vertex;
var _local6:UV;
var _local7:UV;
var _local8:UV;
var _local1:int = (vertices.length - 1);
if (_local1 < 1){
return (null);
};
var _local2:Array = new Array();
var _local3:Vertex = vertices[0];
var _local9 = -1;
var _local10:Number = (BSPTree.EPSILON * BSPTree.EPSILON);
if (uvs){
_local6 = uvs[0];
};
var _local11 = 1;
while (_local11 < _local1) {
_local4 = vertices[_local11];
_local5 = vertices[(_local11 + 1)];
if (uvs){
_local7 = uvs[_local11];
};
if (uvs){
_local8 = uvs[(_local11 + 1)];
};
_tempU.x = (_local4.x - _local3.x);
_tempU.y = (_local4.y - _local3.y);
_tempU.z = (_local4.z - _local3.z);
_tempV.x = (_local5.x - _local3.x);
_tempV.y = (_local5.y - _local3.y);
_tempV.z = (_local5.z - _local3.z);
_tempC.cross(_tempU, _tempV);
if (_tempC.modulo2 > _local10){
++_local9;
var _local12 = _local9;
_local2[_local12] = new Face(_local3, _local4, _local5, material, _local6, _local7, _local8);
};
_local11++;
};
return (_local2);
}
public function fromTriangle(_arg1:Face):void{
var _local2:Plane3D = _arg1.plane;
vertices = new Array();
uvs = new Array();
vertices[0] = _arg1.v0;
vertices[1] = _arg1.v1;
vertices[2] = _arg1.v2;
uvs[0] = _arg1.uv0;
uvs[1] = _arg1.uv1;
uvs[2] = _arg1.uv2;
normal = _arg1.normal;
plane = new Plane3D(_local2.a, _local2.b, _local2.c, _local2.d);
plane._alignment = _local2._alignment;
material = _arg1.material;
}
public function split(_arg1:Plane3D):Array{
var _local4:Vertex;
var _local5:Vertex;
var _local8:Array;
var _local9:Array;
var _local10:Array;
var _local11:Array;
var _local12:int;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local2:Array = new Array(2);
var _local3:int = vertices.length;
var _local6:NGon = new NGon();
var _local7:NGon = new NGon();
var _local16:int = _local3;
_local2[0] = _local6;
_local2[1] = _local7;
_local7.plane = (_local6.plane = plane);
_local7.normal = (_local6.normal = normal);
_local7.material = (_local6.material = material);
_local8 = (_local6.vertices = new Array());
_local9 = (_local7.vertices = new Array());
_local6._isSplitter = _isSplitter;
_local7._isSplitter = _isSplitter;
if (uvs){
_local10 = (_local6.uvs = new Array());
_local11 = (_local7.uvs = new Array());
};
_local4 = vertices[0];
if (_arg1._alignment == Plane3D.X_AXIS){
_local15 = ((_arg1.a * _local4._x) + _arg1.d);
_local13 = _local15;
} else {
if (_arg1._alignment == Plane3D.Y_AXIS){
_local15 = ((_arg1.b * _local4._y) + _arg1.d);
_local13 = _local15;
} else {
if (_arg1._alignment == Plane3D.Z_AXIS){
_local15 = ((_arg1.c * _local4._z) + _arg1.d);
_local13 = _local15;
} else {
_local15 = ((((_arg1.a * _local4._x) + (_arg1.b * _local4._y)) + (_arg1.c * _local4._z)) + _arg1.d);
_local13 = _local15;
};
};
};
if ((((_local15 >= -(BSPTree.EPSILON))) && ((_local15 <= BSPTree.EPSILON)))){
_local15 = 0;
};
_local12 = 1;
_local16 = 0;
while (_local16 < _local3) {
_local4 = vertices[_local16];
_local5 = vertices[_local12];
_local14 = _local15;
if (_local12 == 0){
_local15 = _local13;
} else {
if (_arg1._alignment == Plane3D.X_AXIS){
_local15 = ((_arg1.a * _local5._x) + _arg1.d);
} else {
if (_arg1._alignment == Plane3D.Y_AXIS){
_local15 = ((_arg1.b * _local5._y) + _arg1.d);
} else {
if (_arg1._alignment == Plane3D.Z_AXIS){
_local15 = ((_arg1.c * _local5._z) + _arg1.d);
} else {
_local15 = ((((_arg1.a * _local5._x) + (_arg1.b * _local5._y)) + (_arg1.c * _local5._z)) + _arg1.d);
};
};
};
};
if ((((_local15 >= -(BSPTree.EPSILON))) && ((_local15 <= BSPTree.EPSILON)))){
_local15 = 0;
};
if (_local14 >= 0){
_local8.push(_local4);
if (uvs){
_local10.push(uvs[_local16]);
};
};
if (_local14 <= 0){
_local9.push(_local4);
if (uvs){
_local11.push(uvs[_local16]);
};
};
if ((_local14 * _local15) < 0){
if (uvs){
splitEdge(_arg1, _local4, _local5, uvs[_local16], uvs[_local12], _local6, _local7);
} else {
splitEdge(_arg1, _local4, _local5, null, null, _local6, _local7);
};
};
++_local12;
if (_local12 == _local3){
_local12 = 0;
};
_local16++;
};
if (_local8.length < 3){
_local2[0] = null;
};
if (_local9.length < 3){
_local2[1] = null;
};
return (_local2);
}
public function trim(_arg1:Plane3D):void{
var _local3:Vertex;
var _local4:Vertex;
var _local5:UV;
var _local6:UV;
var _local7:int;
var _local8:int;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Array;
var _local13:Array;
var _local2:int = vertices.length;
if (!_newVerts){
_newVerts = new Array();
};
if (((uvs) && (!(_newUVs)))){
_newUVs = new Array();
};
_local3 = vertices[0];
if (_arg1._alignment == Plane3D.X_AXIS){
_local11 = ((_arg1.a * _local3._x) + _arg1.d);
_local9 = _local11;
} else {
if (_arg1._alignment == Plane3D.Y_AXIS){
_local11 = ((_arg1.b * _local3._y) + _arg1.d);
_local9 = _local11;
} else {
if (_arg1._alignment == Plane3D.Z_AXIS){
_local11 = ((_arg1.c * _local3._z) + _arg1.d);
_local9 = _local11;
} else {
_local11 = ((((_arg1.a * _local3._x) + (_arg1.b * _local3._y)) + (_arg1.c * _local3._z)) + _arg1.d);
_local9 = _local11;
};
};
};
if ((((_local11 >= -(BSPTree.EPSILON))) && ((_local11 <= BSPTree.EPSILON)))){
_local11 = 0;
_local9 = _local11;
};
_local7 = 1;
_local8 = 0;
_local4 = vertices[0];
if (uvs){
_local6 = uvs[0];
};
do {
_local3 = _local4;
_local4 = vertices[_local7];
if (uvs){
_local5 = _local6;
_local6 = uvs[_local7];
};
_local10 = _local11;
if (_local7 == 0){
_local11 = _local9;
} else {
if (_arg1._alignment == Plane3D.X_AXIS){
_local11 = ((_arg1.a * _local4._x) + _arg1.d);
} else {
if (_arg1._alignment == Plane3D.Y_AXIS){
_local11 = ((_arg1.b * _local4._y) + _arg1.d);
} else {
if (_arg1._alignment == Plane3D.Z_AXIS){
_local11 = ((_arg1.c * _local4._z) + _arg1.d);
} else {
_local11 = ((((_arg1.a * _local4._x) + (_arg1.b * _local4._y)) + (_arg1.c * _local4._z)) + _arg1.d);
};
};
};
};
if ((((_local11 >= -(BSPTree.EPSILON))) && ((_local11 <= BSPTree.EPSILON)))){
_local11 = 0;
};
if (_local10 >= 0){
_newVerts.push(_local3);
if (uvs){
_newUVs.push(_local5);
};
};
if ((_local10 * _local11) < 0){
trimEdge(_arg1, _local3, _local4, _local5, _local6, _newVerts, _newUVs);
};
++_local7;
if (_local7 == _local2){
_local7 = 0;
};
++_local8;
} while (_local8 < _local2);
_local12 = vertices;
vertices = _newVerts;
_newVerts = _local12;
_newVerts.length = 0;
if (uvs){
_local13 = uvs;
uvs = _newUVs;
_newUVs = _local13;
_newUVs.length = 0;
};
}
public function trimBack(_arg1:Plane3D):void{
var _local3:Vertex;
var _local4:Vertex;
var _local5:UV;
var _local6:UV;
var _local7:int;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Array;
var _local13:Array;
var _local2:int = vertices.length;
var _local8:int = _local2;
if (!_newVerts){
_newVerts = new Array();
};
if (((uvs) && (!(_newUVs)))){
_newUVs = new Array();
};
_local3 = vertices[0];
if (_arg1._alignment == Plane3D.X_AXIS){
_local11 = ((_arg1.a * _local3._x) + _arg1.d);
_local9 = _local11;
} else {
if (_arg1._alignment == Plane3D.Y_AXIS){
_local11 = ((_arg1.b * _local3._y) + _arg1.d);
_local9 = _local11;
} else {
if (_arg1._alignment == Plane3D.Z_AXIS){
_local11 = ((_arg1.c * _local3._z) + _arg1.d);
_local9 = _local11;
} else {
_local11 = ((((_arg1.a * _local3._x) + (_arg1.b * _local3._y)) + (_arg1.c * _local3._z)) + _arg1.d);
_local9 = _local11;
};
};
};
if ((((_local11 >= -(BSPTree.EPSILON))) && ((_local11 <= BSPTree.EPSILON)))){
_local11 = 0;
_local9 = _local11;
};
_local7 = 1;
_local8 = 0;
_local4 = vertices[0];
if (uvs){
_local6 = uvs[0];
};
do {
_local3 = _local4;
_local4 = vertices[_local7];
if (uvs){
_local5 = _local6;
_local6 = uvs[_local7];
};
_local10 = _local11;
if (_local7 == 0){
_local11 = _local9;
} else {
if (_arg1._alignment == Plane3D.X_AXIS){
_local11 = ((_arg1.a * _local4._x) + _arg1.d);
} else {
if (_arg1._alignment == Plane3D.Y_AXIS){
_local11 = ((_arg1.b * _local4._y) + _arg1.d);
} else {
if (_arg1._alignment == Plane3D.Z_AXIS){
_local11 = ((_arg1.c * _local4._z) + _arg1.d);
} else {
_local11 = ((((_arg1.a * _local4._x) + (_arg1.b * _local4._y)) + (_arg1.c * _local4._z)) + _arg1.d);
};
};
};
};
if ((((_local11 >= -(BSPTree.EPSILON))) && ((_local11 <= BSPTree.EPSILON)))){
_local11 = 0;
};
if (_local10 <= 0){
_newVerts.push(_local3);
if (uvs){
_newUVs.push(_local5);
};
};
if ((_local10 * _local11) < 0){
trimEdge(_arg1, _local3, _local4, _local5, _local6, _newVerts, _newUVs);
};
++_local7;
if (_local7 == _local2){
_local7 = 0;
};
++_local8;
} while (_local8 < _local2);
_local12 = vertices;
vertices = _newVerts;
_newVerts = _local12;
_newVerts.length = 0;
if (uvs){
_local13 = uvs;
uvs = _newUVs;
_newUVs = _local13;
_newUVs.length = 0;
};
}
public function isNeglectable():Boolean{
var _local3:Vertex;
var _local4:Vertex;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:int;
var _local1:int = vertices.length;
var _local2:int = (_local1 - 2);
var _local9:Number = (BSPTree.EPSILON * BSPTree.EPSILON);
if (_local1 < 3){
return (true);
};
_local4 = vertices[(_local1 - 1)];
while (--_local1 >= 0) {
_local3 = _local4;
_local4 = vertices[_local2];
_local5 = (_local3._x - _local4._x);
_local6 = (_local3._y - _local4._y);
_local7 = (_local3._z - _local4._z);
if ((((_local5 * _local5) + (_local6 * _local6)) + (_local7 * _local7)) > _local9){
++_local8;
if (_local8 >= 3){
return (false);
};
};
--_local2;
if (_local2 < 0){
_local2 = (vertices.length - 1);
};
};
return (true);
}
public function get area():Number{
var _local3:Vertex;
var _local4:Vertex;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:int;
var _local16:int;
var _local1:Number = 0;
var _local2:Vertex = vertices[0];
var _local5:int = (vertices.length - 1);
do {
_local3 = vertices[_local15];
++_local16;
_local4 = vertices[_local16];
_local6 = (_local3._x - _local2._x);
_local7 = (_local3._y - _local2._y);
_local8 = (_local3._z - _local2._z);
_local9 = (_local4._x - _local2._x);
_local10 = (_local4._y - _local2._y);
_local11 = (_local4._z - _local2._z);
_local12 = ((_local10 * _local8) - (_local11 * _local7));
_local13 = ((_local11 * _local6) - (_local9 * _local8));
_local14 = ((_local9 * _local7) - (_local10 * _local6));
_local1 = (_local1 + Math.sqrt((((_local12 * _local12) + (_local13 * _local13)) + (_local14 * _local14))));
++_local15;
} while (_local15 < _local5);
return (_local1);
}
private function trimEdge(_arg1:Plane3D, _arg2:Vertex, _arg3:Vertex, _arg4:UV, _arg5:UV, _arg6:Array, _arg7:Array):void{
var _local8:Number;
var _local9:Number;
var _local10:Vertex;
var _local11:UV;
if (_arg1._alignment == Plane3D.X_AXIS){
_local8 = (_arg1.a * (_arg3._x - _arg2._x));
_local9 = (-(((_arg1.a * _arg2._x) + _arg1.d)) / _local8);
} else {
if (_arg1._alignment == Plane3D.Y_AXIS){
_local8 = (_arg1.b * (_arg3._y - _arg2._y));
_local9 = (-(((_arg1.b * _arg2._y) + _arg1.d)) / _local8);
} else {
if (_arg1._alignment == Plane3D.Z_AXIS){
_local8 = (_arg1.c * (_arg3._z - _arg2._z));
_local9 = (-(((_arg1.c * _arg2._z) + _arg1.d)) / _local8);
} else {
_local8 = (((_arg1.a * (_arg3._x - _arg2._x)) + (_arg1.b * (_arg3._y - _arg2._y))) + (_arg1.c * (_arg3._z - _arg2._z)));
_local9 = (-(((((_arg1.a * _arg2._x) + (_arg1.b * _arg2._y)) + (_arg1.c * _arg2._z)) + _arg1.d)) / _local8);
};
};
};
_local10 = new Vertex((_arg2._x + (_local9 * (_arg3._x - _arg2._x))), (_arg2._y + (_local9 * (_arg3._y - _arg2._y))), (_arg2._z + (_local9 * (_arg3._z - _arg2._z))));
_arg6.push(_local10);
if (((_arg4) && (_arg5))){
_local11 = new UV((_arg4._u + (_local9 * (_arg5._u - _arg4._u))), (_arg4._v + (_local9 * (_arg5._v - _arg4._v))));
_arg7.push(_local11);
};
}
private function splitEdge(_arg1:Plane3D, _arg2:Vertex, _arg3:Vertex, _arg4:UV, _arg5:UV, _arg6:NGon, _arg7:NGon):void{
var _local8:Number;
var _local9:Number;
var _local10:Vertex;
var _local11:UV;
_local8 = (((_arg1.a * (_arg3._x - _arg2._x)) + (_arg1.b * (_arg3._y - _arg2._y))) + (_arg1.c * (_arg3._z - _arg2._z)));
_local9 = (-(((((_arg1.a * _arg2._x) + (_arg1.b * _arg2._y)) + (_arg1.c * _arg2._z)) + _arg1.d)) / _local8);
_local10 = new Vertex((_arg2._x + (_local9 * (_arg3._x - _arg2._x))), (_arg2._y + (_local9 * (_arg3._y - _arg2._y))), (_arg2._z + (_local9 * (_arg3._z - _arg2._z))));
if (_arg6){
_arg6.vertices.push(_local10);
};
if (_arg7){
_arg7.vertices.push(_local10);
};
if (((_arg4) && (_arg5))){
_local11 = new UV((_arg4._u + (_local9 * (_arg5._u - _arg4._u))), (_arg4._v + (_local9 * (_arg5._v - _arg4._v))));
if (_arg6){
_arg6.uvs.push(_local11);
};
if (_arg7){
_arg7.uvs.push(_local11);
};
};
}
function removeColinears():void{
var _local3:Vertex;
var _local4:Vertex;
var _local5:Vertex;
var _local1 = 1;
var _local2 = 2;
var _local6:Number = (BSPTree.EPSILON * BSPTree.EPSILON);
var _local7:int = vertices.length;
var _local8:int;
while (_local8 < _local7) {
_local3 = vertices[_local8];
_local4 = vertices[_local1];
_local5 = vertices[_local2];
_tempU.x = (_local4._x - _local3._x);
_tempU.y = (_local4._y - _local3._y);
_tempU.z = (_local4._z - _local3._z);
_tempV.x = (_local5._x - _local3._x);
_tempV.y = (_local5._y - _local3._y);
_tempV.z = (_local5._z - _local3._z);
_tempC.cross(_tempU, _tempV);
if (_tempC.modulo2 <= _local6){
vertices.splice(_local1, 1);
if (uvs){
uvs.splice(_local1, 1);
};
_local8--;
_local7--;
} else {
_local1++;
_local2++;
};
if (_local1 >= _local7){
_local1 = 0;
};
if (_local2 >= _local7){
_local2 = 0;
};
_local8++;
};
}
}
}//package away3d.core.geom
Section 51
//Path (away3d.core.geom.Path)
package away3d.core.geom {
import away3d.core.math.*;
import away3d.containers.*;
public class Path {
public var _pathDebug:PathDebug;
public var aSegments:Array;
public var worldAxis:Number3D;
private var _smoothed:Boolean;
private var _averaged:Boolean;
public function Path(_arg1:Array=null){
var _local2:int;
worldAxis = new Number3D(0, 1, 0);
super();
if (((!((_arg1 == null))) && ((_arg1.length < 3)))){
throw (new Error("Path array must contain at least 3 Number3D's"));
};
this.aSegments = [];
if (_arg1 != null){
_local2 = 0;
while (_local2 < _arg1.length) {
this.aSegments.push(new PathCommand(PathCommand.CURVE, _arg1[_local2], _arg1[(_local2 + 1)], _arg1[(_local2 + 2)]));
_local2 = (_local2 + 3);
};
};
}
public function get smoothed():Boolean{
return (_smoothed);
}
public function get averaged():Boolean{
return (_averaged);
}
public function debugPath(_arg1:Scene3D):void{
_pathDebug = new PathDebug(_arg1, this);
}
public function get showAnchors():Boolean{
if (!_pathDebug){
throw (new Error("Patheditor not set yet! Use Path.debugPath() method first"));
};
return (_pathDebug.showAnchors);
}
public function set showAnchors(_arg1:Boolean):void{
if (!_pathDebug){
throw (new Error("Patheditor not set yet! Use Path.debugPath() method first"));
};
_pathDebug.showAnchors = _arg1;
}
public function get display():Boolean{
return (_pathDebug.display);
}
public function set display(_arg1:Boolean):void{
if (!_pathDebug){
throw (new Error("Patheditor not set yet! Use Path.debugPath() method first"));
};
_pathDebug.display = _arg1;
}
public function add(_arg1:PathCommand):void{
this.aSegments.push(_arg1);
}
public function get length():int{
return (this.aSegments.length);
}
public function get array():Array{
return (this.aSegments);
}
public function removeSegment(_arg1:int, _arg2:Boolean=false):void{
var _local3:PathCommand;
var _local4:PathCommand;
var _local5:PathCommand;
if ((((this.aSegments.length == 0)) || ((this.aSegments[_arg1] == null)))){
return;
};
if (((((_arg2) && ((_arg1 < (this.aSegments.length - 1))))) && ((_arg1 > 0)))){
_local3 = this.aSegments[_arg1];
_local4 = this.aSegments[(_arg1 - 1)];
_local5 = this.aSegments[(_arg1 + 1)];
_local4.pControl.x = ((_local4.pControl.x + _local3.pControl.x) * 0.5);
_local4.pControl.y = ((_local4.pControl.y + _local3.pControl.y) * 0.5);
_local4.pControl.z = ((_local4.pControl.z + _local3.pControl.z) * 0.5);
_local5.pControl.x = ((_local5.pControl.x + _local3.pControl.x) * 0.5);
_local5.pControl.y = ((_local5.pControl.y + _local3.pControl.y) * 0.5);
_local5.pControl.z = ((_local5.pControl.z + _local3.pControl.z) * 0.5);
_local4.pEnd.x = ((_local3.pStart.x + _local3.pEnd.x) * 0.5);
_local4.pEnd.y = ((_local3.pStart.y + _local3.pEnd.y) * 0.5);
_local4.pEnd.z = ((_local3.pStart.z + _local3.pEnd.z) * 0.5);
_local5.pStart.x = _local4.pEnd.x;
_local5.pStart.y = _local4.pEnd.y;
_local5.pStart.z = _local4.pEnd.z;
if (_pathDebug != null){
_pathDebug.updateAnchorAt((_arg1 - 1));
};
_pathDebug.updateAnchorAt((_arg1 + 1));
};
if (this.aSegments.length > 1){
this.aSegments.splice(_arg1, 1);
} else {
this.aSegments = [];
};
}
public function smoothPath():void{
var _local1:Number;
var _local2:Number;
var _local3:Number;
var _local4:Number3D;
var _local5:Number3D;
var _local7:int;
if (this.aSegments.length <= 2){
return;
};
_smoothed = true;
_averaged = false;
var _local6:Array = [];
var _local8:Number3D = new Number3D(this.aSegments[0].pStart.x, this.aSegments[0].pStart.y, this.aSegments[0].pStart.z);
var _local9:Number3D = new Number3D(this.aSegments[(this.aSegments.length - 1)].pEnd.x, this.aSegments[(this.aSegments.length - 1)].pEnd.y, this.aSegments[(this.aSegments.length - 1)].pEnd.z);
_local7 = 0;
while (_local7 < (length - 1)) {
if (this.aSegments[_local7].pControl == null){
this.aSegments[_local7].pControl = this.aSegments[_local7].pEnd;
};
if (this.aSegments[(_local7 + 1)].pControl == null){
this.aSegments[(_local7 + 1)].pControl = this.aSegments[(_local7 + 1)].pEnd;
};
_local4 = this.aSegments[_local7].pControl;
_local5 = this.aSegments[(_local7 + 1)].pControl;
_local1 = ((_local4.x + _local5.x) * 0.5);
_local2 = ((_local4.y + _local5.y) * 0.5);
_local3 = ((_local4.z + _local5.z) * 0.5);
_local6.push(_local8, new Number3D(_local4.x, _local4.y, _local4.z), new Number3D(_local1, _local2, _local3));
_local8 = new Number3D(_local1, _local2, _local3);
this.aSegments[_local7] = null;
_local7++;
};
_local4 = this.aSegments[(this.aSegments.length - 1)].pControl;
_local6.push(_local8, new Number3D(((_local4.x + _local5.x) * 0.5), ((_local4.y + _local5.y) * 0.5), ((_local4.z + _local5.z) * 0.5)), _local9);
this.aSegments[0] = null;
this.aSegments = [];
_local7 = 0;
while (_local7 < _local6.length) {
this.aSegments.push(new PathCommand(PathCommand.CURVE, _local6[_local7], _local6[(_local7 + 1)], _local6[(_local7 + 2)]));
_local7 = (_local7 + 3);
};
_local6[_local7] = (_local6[(_local7 + 1)] = (_local6[(_local7 + 2)] = null));
_local6 = null;
}
public function averagePath():void{
_averaged = true;
_smoothed = false;
var _local1:int;
while (_local1 < this.aSegments.length) {
this.aSegments[_local1].pControl.x = ((this.aSegments[_local1].pStart.x + this.aSegments[_local1].pEnd.x) * 0.5);
this.aSegments[_local1].pControl.y = ((this.aSegments[_local1].pStart.y + this.aSegments[_local1].pEnd.y) * 0.5);
this.aSegments[_local1].pControl.z = ((this.aSegments[_local1].pStart.z + this.aSegments[_local1].pEnd.z) * 0.5);
_local1++;
};
}
public function continuousCurve(_arg1:Array, _arg2:Boolean=false):void{
var _local4:int;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number3D;
var _local9:Number3D;
var _local10:Number3D;
var _local3:Array = [];
_local4 = 0;
while (_local4 < (_arg1.length - 1)) {
_local9 = _arg1[_local4];
_local10 = _arg1[(_local4 + 1)];
_local5 = ((_local9.x + _local10.x) / 2);
_local6 = ((_local9.y + _local10.y) / 2);
_local7 = ((_local9.z + _local10.z) / 2);
_local8 = new Number3D(_local5, _local6, _local7);
if (_local4){
_local3.push(_local8);
};
if ((((_local4 < (_arg1.length - 2))) || (_arg2))){
_local3.push(_local8);
_local3.push(_local10);
};
_local4++;
};
if (_arg2){
_local9 = _arg1[(_arg1.length - 1)];
_local10 = _arg1[0];
_local5 = ((_local9.x + _local10.x) / 2);
_local6 = ((_local9.y + _local10.y) / 2);
_local7 = ((_local9.z + _local10.z) / 2);
_local8 = new Number3D(_local5, _local6, _local7);
_local3.push(_local8);
_local3.push(_local8);
_local3.push(_arg1[0]);
_local3.push(_local3[0]);
};
this.aSegments = [];
_local4 = 0;
while (_local4 < _local3.length) {
this.aSegments.push(new PathCommand(PathCommand.CURVE, _local3[_local4], _local3[(_local4 + 1)], _local3[(_local4 + 2)]));
_local4 = (_local4 + 3);
};
}
}
}//package away3d.core.geom
Section 52
//PathCommand (away3d.core.geom.PathCommand)
package away3d.core.geom {
import away3d.core.math.*;
public class PathCommand {
public var pStart:Number3D;
public var pControl:Number3D;
public var pEnd:Number3D;
public var type:String;
public static const MOVE:String = "M";
public static const LINE:String = "L";
public static const CURVE:String = "C";
public function PathCommand(_arg1:String, _arg2:Number3D=null, _arg3:Number3D=null, _arg4:Number3D=null){
this.type = _arg1;
this.pStart = _arg2;
this.pControl = _arg3;
this.pEnd = _arg4;
}
public function toString():String{
return (((((((("PathCommand: " + type) + ", ") + pStart) + ", ") + pControl) + ", ") + pEnd));
}
}
}//package away3d.core.geom
Section 53
//PathDebug (away3d.core.geom.PathDebug)
package away3d.core.geom {
import flash.display.*;
import away3d.core.base.*;
import away3d.materials.*;
import away3d.containers.*;
import away3d.primitives.*;
public class PathDebug {
private var _path:Path;
private var _scene:Scene3D;
private var _displayAnchors:Boolean;// = true
private var _showPath:Boolean;// = true
public var _container:ObjectContainer3D;
private var _aCurves:Array;
private var _aSpheres:Array;
private var _matline:WireframeMaterial;
private var _matsphere:BitmapMaterial;
private var _matspherecontrol:BitmapMaterial;
public function PathDebug(_arg1:Scene3D, _arg2:Path){
var _local4:Vertex;
var _local5:Vertex;
var _local6:Vertex;
var _local7:PathCommand;
var _local8:CurveLineSegment;
super();
_scene = _arg1;
_path = _arg2;
_matline = new WireframeMaterial(16777113, {width:0});
_matsphere = new BitmapMaterial(new BitmapData(64, 64, false, 0xFF00));
_matspherecontrol = new BitmapMaterial(new BitmapData(64, 64, false, 0xFF9900));
_container = new ObjectContainer3D();
_aCurves = [];
_aSpheres = [];
var _local3:int = _path.aSegments.length;
var _local9:int;
while (_local9 < _local3) {
_local7 = _path.aSegments[_local9];
_local4 = new Vertex(_local7.pStart.x, _local7.pStart.y, _local7.pStart.z);
_local5 = new Vertex(_local7.pControl.x, _local7.pControl.y, _local7.pControl.z);
_local6 = new Vertex(_local7.pEnd.x, _local7.pEnd.y, _local7.pEnd.z);
_local8 = new CurveLineSegment(_local4, _local5, _local6, _matline);
_aCurves.push(_local8);
_container.addChild(_local8);
addAnchor(_local4, _matsphere);
addAnchor(_local5, _matspherecontrol);
if (_local9 == (_local3 - 1)){
addAnchor(_local6, _matsphere);
};
_local9++;
};
_scene.addChild(_container);
}
private function addAnchor(_arg1:Vertex, _arg2:BitmapMaterial):void{
var _local3:Sphere = new Sphere({material:_arg2, radius:50, segmentsH:2, segmentsW:2});
_aSpheres.push(_local3);
_local3.x = _arg1.x;
_local3.y = _arg1.y;
_local3.z = _arg1.z;
_container.addChild(_local3);
}
public function set showAnchors(_arg1:Boolean):void{
var _local2:int;
if (!_container){
return;
};
_displayAnchors = _arg1;
var _local3:int = _aSpheres.length;
_local2 = 0;
while (_local2 < _local3) {
_aSpheres[_local2].visible = _arg1;
_local2++;
};
}
public function get showAnchors():Boolean{
return (_displayAnchors);
}
public function set display(_arg1:Boolean):void{
if (!_container){
return;
};
_showPath = _arg1;
_container.visible = false;
}
public function get display():Boolean{
return (_showPath);
}
public function clearDebug(_arg1:Boolean):void{
var _local2:int;
if (!_container){
return;
};
var _local3:int = _aSpheres.length;
_local2 = 0;
while (_local2 < _local3) {
_container.removeChild(_aSpheres[_local2]);
_local2++;
};
_aSpheres[_local2] = null;
_local3 = _aCurves.length;
_local2 = 0;
while (_local2 < _local3) {
_container.removeChild(_aCurves[_local2]);
_local2++;
};
_aCurves[_local2] = null;
_scene.removeChild(_container);
_container = null;
_aSpheres = (_aCurves = []);
}
public function updateAnchorAt(_arg1:int):void{
}
}
}//package away3d.core.geom
Section 54
//Plane3D (away3d.core.geom.Plane3D)
package away3d.core.geom {
import away3d.core.math.*;
import away3d.core.base.*;
import away3d.graphs.bsp.*;
public class Plane3D {
private var _len:Number;
public var a:Number;
public var b:Number;
public var c:Number;
public var d:Number;
var _alignment:int;
private var _point:Number3D;
public static const FRONT:int = 1;
public static const BACK:int = -1;
public static const INTERSECT:int = 0;
static const ANY:int = 0;
static const X_AXIS:int = 1;
static const Y_AXIS:int = 2;
static const Z_AXIS:int = 3;
public function Plane3D(_arg1:Number=0, _arg2:Number=0, _arg3:Number=0, _arg4:Number=0){
_point = new Number3D();
super();
this.a = _arg1;
this.b = _arg2;
this.c = _arg3;
this.d = _arg4;
}
public function from3points(_arg1:Number3D, _arg2:Number3D, _arg3:Number3D):void{
var _local4:Number = (_arg2.x - _arg1.x);
var _local5:Number = (_arg2.y - _arg1.y);
var _local6:Number = (_arg2.z - _arg1.z);
var _local7:Number = (_arg3.x - _arg1.x);
var _local8:Number = (_arg3.y - _arg1.y);
var _local9:Number = (_arg3.z - _arg1.z);
a = ((_local5 * _local9) - (_local6 * _local8));
b = ((_local6 * _local7) - (_local4 * _local9));
c = ((_local4 * _local8) - (_local5 * _local7));
d = -((((a * _arg1.x) + (b * _arg1.y)) + (c * _arg1.z)));
}
public function from3vertices(_arg1:Vertex, _arg2:Vertex, _arg3:Vertex):void{
var _local4:Number = (_arg2.x - _arg1.x);
var _local5:Number = (_arg2.y - _arg1.y);
var _local6:Number = (_arg2.z - _arg1.z);
var _local7:Number = (_arg3.x - _arg1.x);
var _local8:Number = (_arg3.y - _arg1.y);
var _local9:Number = (_arg3.z - _arg1.z);
a = ((_local5 * _local9) - (_local6 * _local8));
b = ((_local6 * _local7) - (_local4 * _local9));
c = ((_local4 * _local8) - (_local5 * _local7));
d = -((((a * _arg1.x) + (b * _arg1.y)) + (c * _arg1.z)));
}
public function fromNormalAndPoint(_arg1:Number3D, _arg2:Number3D):void{
a = _arg1.x;
b = _arg1.y;
c = _arg1.z;
d = -((((a * _arg2.x) + (b * _arg2.y)) + (c * _arg2.z)));
_point = _arg1;
}
public function normalize():Plane3D{
var _local1:Number = Math.sqrt((((a * a) + (b * b)) + (c * c)));
a = (a / _local1);
b = (b / _local1);
c = (c / _local1);
d = (d / _local1);
return (this);
}
public function distance(_arg1:Number3D):Number{
_len = ((((a * _arg1.x) + (b * _arg1.y)) + (c * _arg1.z)) + d);
if ((((_len > -(BSPTree.EPSILON))) && ((_len < BSPTree.EPSILON)))){
_len = 0;
};
return (_len);
}
public function classifyPoint(_arg1:Number3D):int{
if (!(((d <= 0)) || ((d > 0)))){
return (Plane3D.FRONT);
};
var _local2:Number = ((((a * _arg1.x) + (b * _arg1.y)) + (c * _arg1.z)) + d);
if (_local2 < -(BSPTree.EPSILON)){
return (Plane3D.BACK);
};
if (_local2 > BSPTree.EPSILON){
return (Plane3D.FRONT);
};
return (Plane3D.INTERSECT);
}
public function closestPointFrom(_arg1:Number3D):Number3D{
var _local2:Number3D;
_point.x = 0;
_point.y = 0;
if (c != 0){
_point.z = (-(d) / c);
} else {
_point.z = (-(d) / b);
};
_local2 = new Number3D();
_local2.sub(_arg1, _point);
var _local3:Number = (((a * _point.x) + (b * _point.y)) + (c * _point.z));
_local2.x = (_local2.x - (_local3 * a));
_local2.y = (_local2.y - (_local3 * b));
_local2.z = (_local2.z - (_local3 * c));
return (_local2);
}
public function getIntersectionSegmentNumbers(_arg1:Number3D, _arg2:Number3D):Number3D{
var _local3:Number = (((a * (_arg2.x - _arg1.x)) + (b * (_arg2.y - _arg1.y))) + (c * (_arg2.z - _arg1.z)));
var _local4:Number = (-(((((a * _arg1.x) + (b * _arg1.y)) + (c * _arg1.z)) + d)) / _local3);
if ((((_local4 >= 0)) && ((_local4 <= 1)))){
return (new Number3D((_arg1.x + (_local4 * (_arg2.x - _arg1.x))), (_arg1.y + (_local4 * (_arg2.y - _arg1.y))), (_arg1.z + (_local4 * (_arg2.z - _arg1.z)))));
};
return (null);
}
public function getIntersectionLineNumbers(_arg1:Number3D, _arg2:Number3D):Number3D{
var _local3:Number = ((((_point.x * _arg1.x) + (_point.y * _arg1.y)) + (_point.z * _arg1.z)) - d);
var _local4:Number = ((((_point.x * _arg2.x) + (_point.y * _arg2.y)) + (_point.z * _arg2.z)) - d);
var _local5:Number = (((((_point.x * _arg2.x) + (_point.y * _arg2.y)) + (_point.z * _arg2.z)) - d) / (_local4 - _local3));
return (new Number3D((_arg2.x + ((_arg1.x - _arg2.x) * _local5)), (_arg2.y + ((_arg1.y - _arg2.y) * _local5)), (_arg2.z + ((_arg1.z - _arg2.z) * _local5))));
}
public function getIntersectionLine(_arg1:Vertex, _arg2:Vertex):Vertex{
var _local3:Number = ((((_point.x * _arg1.x) + (_point.y * _arg1.y)) + (_point.z * _arg1.z)) - d);
var _local4:Number = ((((_point.x * _arg2.x) + (_point.y * _arg2.y)) + (_point.z * _arg2.z)) - d);
var _local5:Number = (((((_point.x * _arg2.x) + (_point.y * _arg2.y)) + (_point.z * _arg2.z)) - d) / (_local4 - _local3));
return (new Vertex((_arg2.x + ((_arg1.x - _arg2.x) * _local5)), (_arg2.y + ((_arg1.y - _arg2.y) * _local5)), (_arg2.z + ((_arg1.z - _arg2.z) * _local5))));
}
public function transform(_arg1:Matrix3D):void{
var _local2:Number = a;
var _local3:Number = b;
var _local4:Number = c;
var _local5:Number = d;
a = ((((_local2 * _arg1.sxx) + (_local3 * _arg1.syx)) + (_local4 * _arg1.szx)) + (_local5 * _arg1.swx));
b = ((((_local2 * _arg1.sxy) + (_local3 * _arg1.syy)) + (_local4 * _arg1.szy)) + (_local5 * _arg1.swy));
c = ((((_local2 * _arg1.sxz) + (_local3 * _arg1.syz)) + (_local4 * _arg1.szz)) + (_local5 * _arg1.swz));
d = ((((_local2 * _arg1.tx) + (_local3 * _arg1.ty)) + (_local4 * _arg1.tz)) + (_local5 * _arg1.tw));
normalize();
}
public function toString():String{
return ((((((((("Plane3D [a:" + a) + ", b:") + b) + ", c:") + c) + ", d:") + d) + "]."));
}
}
}//package away3d.core.geom
Section 55
//AmbientLight (away3d.core.light.AmbientLight)
package away3d.core.light {
import flash.display.*;
public class AmbientLight extends LightPrimitive {
public function updateAmbientBitmap(_arg1:Number):void{
this.ambient = _arg1;
ambientBitmap = new BitmapData(0x0100, 0x0100, false, ((int(((_arg1 * red) << 16)) | int(((_arg1 * green) << 8))) | int((_arg1 * blue))));
ambientBitmap.lock();
}
}
}//package away3d.core.light
Section 56
//DirectionalLight (away3d.core.light.DirectionalLight)
package away3d.core.light {
import flash.display.*;
import away3d.core.math.*;
import away3d.core.base.*;
import away3d.containers.*;
import flash.utils.*;
import flash.geom.*;
import flash.filters.*;
public class DirectionalLight extends LightPrimitive {
private var _normalMatrix:ColorMatrixFilter;
private var _matrix:Matrix;
private var _shape:Shape;
private var transform:Matrix3D;
private var nx:Number;
private var ny:Number;
private var mod:Number;
private var cameraTransform:Matrix3D;
private var cameraDirection:Number3D;
private var halfVector:Number3D;
private var halfTransform:Matrix3D;
private var _red:Number;
private var _green:Number;
private var _blue:Number;
private var _sred:Number;
private var _sgreen:Number;
private var _sblue:Number;
private var _szx:Number;
private var _szy:Number;
private var _szz:Number;
public var direction:Number3D;
public var diffuseTransform:Dictionary;
public var specularTransform:Dictionary;
public var ambientColorTransform:ColorTransform;
public var diffuseColorTransform:ColorTransform;
public var normalMatrixDiffuseTransform:Dictionary;
public var normalMatrixSpecularTransform:Dictionary;
public function DirectionalLight(){
_normalMatrix = new ColorMatrixFilter();
_matrix = new Matrix();
_shape = new Shape();
transform = new Matrix3D();
cameraDirection = new Number3D();
halfVector = new Number3D();
halfTransform = new Matrix3D();
direction = new Number3D();
normalMatrixDiffuseTransform = new Dictionary(true);
normalMatrixSpecularTransform = new Dictionary(true);
super();
}
public function updateAmbientBitmap():void{
ambientBitmap = new BitmapData(0x0100, 0x0100, false, ((int((((ambient * red) * 0xFF) << 16)) | int((((ambient * green) * 0xFF) << 8))) | int(((ambient * blue) * 0xFF))));
ambientBitmap.lock();
ambientColorTransform = new ColorTransform(1, 1, 1, 1, ((ambient * red) * 0xFF), ((ambient * green) * 0xFF), ((ambient * blue) * 0xFF), 0);
}
public function updateDiffuseBitmap():void{
var _local5:Number;
var _local6:Number;
var _local7:Number;
diffuseBitmap = new BitmapData(0x0100, 0x0100, false, 0);
diffuseBitmap.lock();
_matrix.createGradientBox(0x0100, 0x0100, 0, 0, 0);
var _local1:Array = [];
var _local2:Array = [];
var _local3:Array = [];
var _local4 = 15;
while (_local4--) {
_local5 = ((_local4 * diffuse) / 14);
if (_local5 > 1){
_local5 = 1;
};
_local6 = ((_local4 * diffuse) / 14);
if (_local6 > 1){
_local6 = 1;
};
_local7 = ((_local4 * diffuse) / 14);
if (_local7 > 1){
_local7 = 1;
};
_local1.push((((((_local5 * red) * 0xFF) << 16) | (((_local6 * green) * 0xFF) << 8)) | ((_local7 * blue) * 0xFF)));
_local2.push(1);
_local3.push(int((30 + (((225 * 2) * Math.acos((_local4 / 14))) / Math.PI))));
};
_shape.graphics.clear();
_shape.graphics.beginGradientFill(GradientType.LINEAR, _local1, _local2, _local3, _matrix);
_shape.graphics.drawRect(0, 0, 0x0100, 0x0100);
diffuseBitmap.draw(_shape);
diffuseColorTransform = new ColorTransform((diffuse * red), (diffuse * green), (diffuse * blue), 1, 0, 0, 0, 0);
}
public function updateAmbientDiffuseBitmap():void{
var _local5:Number;
var _local6:Number;
var _local7:Number;
ambientDiffuseBitmap = new BitmapData(0x0100, 0x0100, false, 0);
ambientDiffuseBitmap.lock();
_matrix.createGradientBox(0x0100, 0x0100, 0, 0, 0);
var _local1:Array = [];
var _local2:Array = [];
var _local3:Array = [];
var _local4 = 15;
while (_local4--) {
_local5 = (((_local4 * diffuse) / 14) + ambient);
if (_local5 > 1){
_local5 = 1;
};
_local6 = (((_local4 * diffuse) / 14) + ambient);
if (_local6 > 1){
_local6 = 1;
};
_local7 = (((_local4 * diffuse) / 14) + ambient);
if (_local7 > 1){
_local7 = 1;
};
_local1.push((((((_local5 * red) * 0xFF) << 16) | (((_local6 * green) * 0xFF) << 8)) | ((_local7 * blue) * 0xFF)));
_local2.push(1);
_local3.push(int((30 + (((225 * 2) * Math.acos((_local4 / 14))) / Math.PI))));
};
_shape.graphics.clear();
_shape.graphics.beginGradientFill(GradientType.LINEAR, _local1, _local2, _local3, _matrix);
_shape.graphics.drawRect(0, 0, 0x0100, 0x0100);
ambientDiffuseBitmap.draw(_shape);
}
public function updateSpecularBitmap():void{
specularBitmap = new BitmapData(0x0200, 0x0200, false, 0);
specularBitmap.lock();
_matrix.createGradientBox(0x0200, 0x0200, 0, 0, 0);
var _local1:Array = [];
var _local2:Array = [];
var _local3:Array = [];
var _local4 = 15;
while (_local4--) {
_local1.push((((((((_local4 * specular) * red) * 0xFF) / 14) << 16) + (((((_local4 * specular) * green) * 0xFF) / 14) << 8)) + ((((_local4 * specular) * blue) * 0xFF) / 14)));
_local2.push(1);
_local3.push(int((30 + (((225 * 2) * Math.acos(Math.pow((_local4 / 14), (1 / 20)))) / Math.PI))));
};
_shape.graphics.clear();
_shape.graphics.beginGradientFill(GradientType.RADIAL, _local1, _local2, _local3, _matrix);
_shape.graphics.drawCircle(0xFF, 0xFF, 0xFF);
specularBitmap.draw(_shape);
}
public function clearTransform():void{
diffuseTransform = new Dictionary(true);
specularTransform = new Dictionary(true);
normalMatrixDiffuseTransform = new Dictionary(true);
normalMatrixSpecularTransform = new Dictionary(true);
}
public function setDirection(_arg1:Number3D):void{
direction.clone(_arg1);
direction.normalize(-1);
nx = direction.x;
ny = direction.y;
mod = Math.sqrt(((nx * nx) + (ny * ny)));
transform.rotationMatrix((ny / mod), (-(nx) / mod), 0, -(Math.acos(-(direction.z))));
clearTransform();
}
public function setDiffuseTransform(_arg1:Object3D):void{
if (!diffuseTransform[_arg1]){
diffuseTransform[_arg1] = new Matrix3D();
};
diffuseTransform[_arg1].multiply3x3(transform, _arg1.sceneTransform);
diffuseTransform[_arg1].normalize(diffuseTransform[_arg1]);
}
public function setSpecularTransform(_arg1:Object3D, _arg2:View3D):void{
cameraTransform = _arg2.camera.transform;
cameraDirection.x = -(cameraTransform.sxz);
cameraDirection.y = -(cameraTransform.syz);
cameraDirection.z = -(cameraTransform.szz);
halfVector.add(cameraDirection, direction);
halfVector.normalize();
nx = halfVector.x;
ny = halfVector.y;
mod = Math.sqrt(((nx * nx) + (ny * ny)));
halfTransform.rotationMatrix((-(ny) / mod), (nx / mod), 0, Math.acos(-(halfVector.z)));
if (!specularTransform[_arg1][_arg2]){
specularTransform[_arg1][_arg2] = new Matrix3D();
};
specularTransform[_arg1][_arg2].multiply3x3(halfTransform, _arg1.sceneTransform);
specularTransform[_arg1][_arg2].normalize(specularTransform[_arg1][_arg2]);
}
public function setNormalMatrixDiffuseTransform(_arg1:Object3D):void{
_red = ((red * 2) * diffuse);
_green = ((green * 2) * diffuse);
_blue = ((blue * 2) * diffuse);
_szx = diffuseTransform[_arg1].szx;
_szy = -(diffuseTransform[_arg1].szy);
_szz = diffuseTransform[_arg1].szz;
_normalMatrix.matrix = [(_red * _szx), (_red * _szy), (_red * _szz), 0, ((-(_red) * 127) * ((_szx + _szy) + _szz)), (_green * _szx), (_green * _szy), (_green * _szz), 0, ((-(_green) * 127) * ((_szx + _szy) + _szz)), (_blue * _szx), (_blue * _szy), (_blue * _szz), 0, ((-(_blue) * 127) * ((_szx + _szy) + _szz)), 0, 0, 0, 1, 0];
normalMatrixDiffuseTransform[_arg1] = _normalMatrix.clone();
}
public function setNormalMatrixSpecularTransform(_arg1:Object3D, _arg2:View3D, _arg3:uint, _arg4:Number):void{
if (!normalMatrixSpecularTransform[_arg1]){
normalMatrixSpecularTransform[_arg1] = new Dictionary(true);
};
_sred = ((this.specular * ((_arg3 & 0xFF0000) >> 16)) / 0xFF);
_sgreen = ((this.specular * ((_arg3 & 0xFF00) >> 8)) / 0xFF);
_sblue = ((this.specular * (_arg3 & 0xFF)) / 0xFF);
_red = (((red * 2) + _arg4) * _sred);
_green = (((green * 2) + _arg4) * _sgreen);
_blue = (((blue * 2) + _arg4) * _sblue);
_szx = specularTransform[_arg1][_arg2].szx;
_szy = -(specularTransform[_arg1][_arg2].szy);
_szz = specularTransform[_arg1][_arg2].szz;
_normalMatrix.matrix = [(_red * _szx), (_red * _szy), (_red * _szz), 0, (((-(_red) * 127) * ((_szx + _szy) + _szz)) - ((127 * _arg4) * _sred)), (_green * _szx), (_green * _szy), (_green * _szz), 0, (((-(_green) * 127) * ((_szx + _szy) + _szz)) - ((127 * _arg4) * _sgreen)), (_blue * _szx), (_blue * _szy), (_blue * _szz), 0, (((-(_blue) * 127) * ((_szx + _szy) + _szz)) - ((127 * _arg4) * _sblue)), 0, 0, 0, 1, 0];
normalMatrixSpecularTransform[_arg1][_arg2] = _normalMatrix.clone();
}
}
}//package away3d.core.light
Section 57
//ILightConsumer (away3d.core.light.ILightConsumer)
package away3d.core.light {
public interface ILightConsumer {
function get ambients():Array;
function get directionals():Array;
function get points():Array;
function get numLights():int;
function ambientLight(_arg1:AmbientLight):void;
function directionalLight(_arg1:DirectionalLight):void;
function pointLight(_arg1:PointLight):void;
function clear():void;
}
}//package away3d.core.light
Section 58
//ILightProvider (away3d.core.light.ILightProvider)
package away3d.core.light {
public interface ILightProvider {
function light(_arg1:ILightConsumer):void;
function get debug():Boolean;
}
}//package away3d.core.light
Section 59
//LightArray (away3d.core.light.LightArray)
package away3d.core.light {
public class LightArray implements ILightConsumer {
private var _ambients:Array;
private var _directionals:Array;
private var _points:Array;
private var _numLights:int;
public function get ambients():Array{
return (_ambients);
}
public function get directionals():Array{
return (_directionals);
}
public function get points():Array{
return (_points);
}
public function get numLights():int{
return (_numLights);
}
public function ambientLight(_arg1:AmbientLight):void{
_ambients.push(_arg1);
_numLights++;
}
public function directionalLight(_arg1:DirectionalLight):void{
_directionals.push(_arg1);
_numLights++;
}
public function pointLight(_arg1:PointLight):void{
_points.push(_arg1);
_numLights++;
}
public function clear():void{
_ambients = [];
_directionals = [];
_points = [];
_numLights = 0;
}
}
}//package away3d.core.light
Section 60
//LightPrimitive (away3d.core.light.LightPrimitive)
package away3d.core.light {
import flash.display.*;
import away3d.lights.*;
public class LightPrimitive {
public var light:AbstractLight;
public var red:Number;
public var green:Number;
public var blue:Number;
public var radius:Number;
public var fallOff:Number;
public var ambient:Number;
public var diffuse:Number;
public var specular:Number;
public var ambientBitmap:BitmapData;
public var diffuseBitmap:BitmapData;
public var ambientDiffuseBitmap:BitmapData;
public var specularBitmap:BitmapData;
}
}//package away3d.core.light
Section 61
//PointLight (away3d.core.light.PointLight)
package away3d.core.light {
import away3d.core.math.*;
import away3d.containers.*;
import flash.utils.*;
public class PointLight extends LightPrimitive {
public var position:Number3D;
public var viewPositions:Dictionary;
public function PointLight(){
position = new Number3D();
super();
}
public function setPosition(_arg1:Number3D):void{
position.clone(_arg1);
clearViewPositions();
}
public function clearViewPositions():void{
viewPositions = new Dictionary(true);
}
public function setViewPosition(_arg1:View3D):void{
if (!viewPositions[_arg1]){
viewPositions[_arg1] = new Number3D();
};
(viewPositions[_arg1] as Number3D).transform(position, _arg1.camera.viewMatrix);
}
}
}//package away3d.core.light
Section 62
//Matrix3D (away3d.core.math.Matrix3D)
package away3d.core.math {
public final class Matrix3D {
private var _position:Number3D;
private var _forward:Number3D;
private var _up:Number3D;
private var _right:Number3D;
private var m111:Number;
private var m211:Number;
private var m121:Number;
private var m221:Number;
private var m131:Number;
private var m231:Number;
private var m112:Number;
private var m212:Number;
private var m122:Number;
private var m222:Number;
private var m132:Number;
private var m232:Number;
private var m113:Number;
private var m213:Number;
private var m123:Number;
private var m223:Number;
private var m133:Number;
private var m233:Number;
private var m114:Number;
private var m214:Number;
private var m124:Number;
private var m224:Number;
private var m134:Number;
private var m234:Number;
private var m141:Number;
private var m241:Number;
private var m142:Number;
private var m242:Number;
private var m143:Number;
private var m243:Number;
private var m144:Number;
private var m244:Number;
private var nCos:Number;
private var nSin:Number;
private var scos:Number;
private var suv:Number;
private var svw:Number;
private var suw:Number;
private var sw:Number;
private var sv:Number;
private var su:Number;
private var d:Number;
private var x:Number;
private var y:Number;
private var z:Number;
private var w:Number;
private var xx:Number;
private var xy:Number;
private var xz:Number;
private var xw:Number;
private var yy:Number;
private var yz:Number;
private var yw:Number;
private var zz:Number;
private var zw:Number;
public var sxx:Number;// = 1
public var sxy:Number;// = 0
public var sxz:Number;// = 0
public var tx:Number;// = 0
public var syx:Number;// = 0
public var syy:Number;// = 1
public var syz:Number;// = 0
public var ty:Number;// = 0
public var szx:Number;// = 0
public var szy:Number;// = 0
public var szz:Number;// = 1
public var tz:Number;// = 0
public var swx:Number;// = 0
public var swy:Number;// = 0
public var swz:Number;// = 0
public var tw:Number;// = 1
public function Matrix3D(){
_position = new Number3D();
_forward = new Number3D();
_up = new Number3D();
_right = new Number3D();
super();
}
public function get position():Number3D{
_position.x = tx;
_position.y = ty;
_position.z = tz;
return (_position);
}
public function get det():Number{
return ((((((sxx * syy) - (syx * sxy)) * szz) - (((sxx * szy) - (szx * sxy)) * syz)) + (((syx * szy) - (szx * syy)) * sxz)));
}
public function get det4x4():Number{
return (((((((((sxx * syy) - (syx * sxy)) * ((szz * tw) - (swz * tz))) - (((sxx * szy) - (szx * sxy)) * ((syz * tw) - (swz * ty)))) + (((sxx * swy) - (swx * sxy)) * ((syz * tz) - (szz * ty)))) + (((syx * szy) - (szx * syy)) * ((sxz * tw) - (swz * tx)))) - (((syx * swy) - (swx * syy)) * ((sxz * tz) - (szz * tx)))) + (((szx * swy) - (swx * szy)) * ((sxz * ty) - (syz * tx)))));
}
public function array2matrix(_arg1:Array, _arg2:Boolean, _arg3:Number):void{
if (_arg1.length >= 12){
if (_arg2){
sxx = _arg1[0];
sxy = -(_arg1[1]);
sxz = -(_arg1[2]);
tx = (-(_arg1[3]) * _arg3);
syx = -(_arg1[4]);
syy = _arg1[5];
syz = _arg1[6];
ty = (_arg1[7] * _arg3);
szx = -(_arg1[8]);
szy = _arg1[9];
szz = _arg1[10];
tz = (_arg1[11] * _arg3);
} else {
sxx = _arg1[0];
sxz = _arg1[1];
sxy = _arg1[2];
tx = (_arg1[3] * _arg3);
szx = _arg1[4];
szz = _arg1[5];
szy = _arg1[6];
tz = (_arg1[7] * _arg3);
syx = _arg1[8];
syz = _arg1[9];
syy = _arg1[10];
ty = (_arg1[11] * _arg3);
};
};
if (_arg1.length >= 16){
swx = _arg1[12];
swy = _arg1[13];
swz = _arg1[14];
tw = _arg1[15];
} else {
swx = (swy = (swz = 0));
tw = 1;
};
}
public function toString():String{
var _local1 = "";
_local1 = (_local1 + ((((((((int((sxx * 1000)) / 1000) + "\t\t") + (int((sxy * 1000)) / 1000)) + "\t\t") + (int((sxz * 1000)) / 1000)) + "\t\t") + (int((tx * 1000)) / 1000)) + "\n"));
_local1 = (_local1 + ((((((((int((syx * 1000)) / 1000) + "\t\t") + (int((syy * 1000)) / 1000)) + "\t\t") + (int((syz * 1000)) / 1000)) + "\t\t") + (int((ty * 1000)) / 1000)) + "\n"));
_local1 = (_local1 + ((((((((int((szx * 1000)) / 1000) + "\t\t") + (int((szy * 1000)) / 1000)) + "\t\t") + (int((szz * 1000)) / 1000)) + "\t\t") + (int((tz * 1000)) / 1000)) + "\n"));
_local1 = (_local1 + ((((((((int((swx * 1000)) / 1000) + "\t\t") + (int((swy * 1000)) / 1000)) + "\t\t") + (int((swz * 1000)) / 1000)) + "\t\t") + (int((tw * 1000)) / 1000)) + "\n"));
return (_local1);
}
public function multiply3x3(_arg1:Matrix3D, _arg2:Matrix3D):void{
m111 = _arg1.sxx;
m211 = _arg2.sxx;
m121 = _arg1.syx;
m221 = _arg2.syx;
m131 = _arg1.szx;
m231 = _arg2.szx;
m112 = _arg1.sxy;
m212 = _arg2.sxy;
m122 = _arg1.syy;
m222 = _arg2.syy;
m132 = _arg1.szy;
m232 = _arg2.szy;
m113 = _arg1.sxz;
m213 = _arg2.sxz;
m123 = _arg1.syz;
m223 = _arg2.syz;
m133 = _arg1.szz;
m233 = _arg2.szz;
sxx = (((m111 * m211) + (m112 * m221)) + (m113 * m231));
sxy = (((m111 * m212) + (m112 * m222)) + (m113 * m232));
sxz = (((m111 * m213) + (m112 * m223)) + (m113 * m233));
syx = (((m121 * m211) + (m122 * m221)) + (m123 * m231));
syy = (((m121 * m212) + (m122 * m222)) + (m123 * m232));
syz = (((m121 * m213) + (m122 * m223)) + (m123 * m233));
szx = (((m131 * m211) + (m132 * m221)) + (m133 * m231));
szy = (((m131 * m212) + (m132 * m222)) + (m133 * m232));
szz = (((m131 * m213) + (m132 * m223)) + (m133 * m233));
tx = _arg1.tx;
ty = _arg1.ty;
tz = _arg1.tz;
}
public function multiply4x3(_arg1:Matrix3D, _arg2:Matrix3D):void{
m111 = _arg1.sxx;
m211 = _arg2.sxx;
m121 = _arg1.syx;
m221 = _arg2.syx;
m131 = _arg1.szx;
m231 = _arg2.szx;
m112 = _arg1.sxy;
m212 = _arg2.sxy;
m122 = _arg1.syy;
m222 = _arg2.syy;
m132 = _arg1.szy;
m232 = _arg2.szy;
m113 = _arg1.sxz;
m213 = _arg2.sxz;
m123 = _arg1.syz;
m223 = _arg2.syz;
m133 = _arg1.szz;
m233 = _arg2.szz;
m114 = _arg1.tx;
m214 = _arg2.tx;
m124 = _arg1.ty;
m224 = _arg2.ty;
m134 = _arg1.tz;
m234 = _arg2.tz;
m141 = _arg1.swx;
m241 = _arg2.swx;
m142 = _arg1.swy;
m242 = _arg2.swy;
m143 = _arg1.swz;
m243 = _arg2.swz;
m144 = _arg1.tw;
m244 = _arg2.tw;
sxx = (((m111 * m211) + (m112 * m221)) + (m113 * m231));
sxy = (((m111 * m212) + (m112 * m222)) + (m113 * m232));
sxz = (((m111 * m213) + (m112 * m223)) + (m113 * m233));
tx = ((((m111 * m214) + (m112 * m224)) + (m113 * m234)) + m114);
syx = (((m121 * m211) + (m122 * m221)) + (m123 * m231));
syy = (((m121 * m212) + (m122 * m222)) + (m123 * m232));
syz = (((m121 * m213) + (m122 * m223)) + (m123 * m233));
ty = ((((m121 * m214) + (m122 * m224)) + (m123 * m234)) + m124);
szx = (((m131 * m211) + (m132 * m221)) + (m133 * m231));
szy = (((m131 * m212) + (m132 * m222)) + (m133 * m232));
szz = (((m131 * m213) + (m132 * m223)) + (m133 * m233));
tz = ((((m131 * m214) + (m132 * m224)) + (m133 * m234)) + m134);
swx = (((m141 * m211) + (m142 * m221)) + (m143 * m231));
swy = (((m141 * m212) + (m142 * m222)) + (m143 * m232));
swz = (((m141 * m213) + (m142 * m223)) + (m143 * m233));
tw = ((((m141 * m214) + (m142 * m224)) + (m143 * m234)) + m144);
}
public function multiply4x4(_arg1:Matrix3D, _arg2:Matrix3D):void{
m111 = _arg1.sxx;
m211 = _arg2.sxx;
m121 = _arg1.syx;
m221 = _arg2.syx;
m131 = _arg1.szx;
m231 = _arg2.szx;
m141 = _arg1.swx;
m241 = _arg2.swx;
m112 = _arg1.sxy;
m212 = _arg2.sxy;
m122 = _arg1.syy;
m222 = _arg2.syy;
m132 = _arg1.szy;
m232 = _arg2.szy;
m142 = _arg1.swy;
m242 = _arg2.swy;
m113 = _arg1.sxz;
m213 = _arg2.sxz;
m123 = _arg1.syz;
m223 = _arg2.syz;
m133 = _arg1.szz;
m233 = _arg2.szz;
m143 = _arg1.swz;
m243 = _arg2.swz;
m114 = _arg1.tx;
m214 = _arg2.tx;
m124 = _arg1.ty;
m224 = _arg2.ty;
m134 = _arg1.tz;
m234 = _arg2.tz;
m144 = _arg1.tw;
m244 = _arg2.tw;
sxx = ((((m111 * m211) + (m112 * m221)) + (m113 * m231)) + (m114 * m241));
sxy = ((((m111 * m212) + (m112 * m222)) + (m113 * m232)) + (m114 * m242));
sxz = ((((m111 * m213) + (m112 * m223)) + (m113 * m233)) + (m114 * m243));
tx = ((((m111 * m214) + (m112 * m224)) + (m113 * m234)) + (m114 * m244));
syx = ((((m121 * m211) + (m122 * m221)) + (m123 * m231)) + (m124 * m241));
syy = ((((m121 * m212) + (m122 * m222)) + (m123 * m232)) + (m124 * m242));
syz = ((((m121 * m213) + (m122 * m223)) + (m123 * m233)) + (m124 * m243));
ty = ((((m121 * m214) + (m122 * m224)) + (m123 * m234)) + (m124 * m244));
szx = ((((m131 * m211) + (m132 * m221)) + (m133 * m231)) + (m134 * m241));
szy = ((((m131 * m212) + (m132 * m222)) + (m133 * m232)) + (m134 * m242));
szz = ((((m131 * m213) + (m132 * m223)) + (m133 * m233)) + (m134 * m243));
tz = ((((m131 * m214) + (m132 * m224)) + (m133 * m234)) + (m134 * m244));
swx = ((((m141 * m211) + (m142 * m221)) + (m143 * m231)) + (m144 * m241));
swy = ((((m141 * m212) + (m142 * m222)) + (m143 * m232)) + (m144 * m242));
swz = ((((m141 * m213) + (m142 * m223)) + (m143 * m233)) + (m144 * m243));
tw = ((((m141 * m214) + (m142 * m224)) + (m143 * m234)) + (m144 * m244));
}
public function multiply(_arg1:Matrix3D, _arg2:Matrix3D):void{
m111 = _arg1.sxx;
m211 = _arg2.sxx;
m121 = _arg1.syx;
m221 = _arg2.syx;
m131 = _arg1.szx;
m231 = _arg2.szx;
m112 = _arg1.sxy;
m212 = _arg2.sxy;
m122 = _arg1.syy;
m222 = _arg2.syy;
m132 = _arg1.szy;
m232 = _arg2.szy;
m113 = _arg1.sxz;
m213 = _arg2.sxz;
m123 = _arg1.syz;
m223 = _arg2.syz;
m133 = _arg1.szz;
m233 = _arg2.szz;
m114 = _arg1.tx;
m214 = _arg2.tx;
m124 = _arg1.ty;
m224 = _arg2.ty;
m134 = _arg1.tz;
m234 = _arg2.tz;
sxx = (((m111 * m211) + (m112 * m221)) + (m113 * m231));
sxy = (((m111 * m212) + (m112 * m222)) + (m113 * m232));
sxz = (((m111 * m213) + (m112 * m223)) + (m113 * m233));
tx = ((((m111 * m214) + (m112 * m224)) + (m113 * m234)) + m114);
syx = (((m121 * m211) + (m122 * m221)) + (m123 * m231));
syy = (((m121 * m212) + (m122 * m222)) + (m123 * m232));
syz = (((m121 * m213) + (m122 * m223)) + (m123 * m233));
ty = ((((m121 * m214) + (m122 * m224)) + (m123 * m234)) + m124);
szx = (((m131 * m211) + (m132 * m221)) + (m133 * m231));
szy = (((m131 * m212) + (m132 * m222)) + (m133 * m232));
szz = (((m131 * m213) + (m132 * m223)) + (m133 * m233));
tz = ((((m131 * m214) + (m132 * m224)) + (m133 * m234)) + m134);
}
public function scale(_arg1:Matrix3D, _arg2:Number, _arg3:Number, _arg4:Number):void{
sxx = (_arg1.sxx * _arg2);
syx = (_arg1.syx * _arg2);
szx = (_arg1.szx * _arg2);
sxy = (_arg1.sxy * _arg3);
syy = (_arg1.syy * _arg3);
szy = (_arg1.szy * _arg3);
sxz = (_arg1.sxz * _arg4);
syz = (_arg1.syz * _arg4);
szz = (_arg1.szz * _arg4);
}
public function copy3x3(_arg1:Matrix3D):Matrix3D{
sxx = _arg1.sxx;
sxy = _arg1.sxy;
sxz = _arg1.sxz;
syx = _arg1.syx;
syy = _arg1.syy;
syz = _arg1.syz;
szx = _arg1.szx;
szy = _arg1.szy;
szz = _arg1.szz;
return (this);
}
public function clone(_arg1:Matrix3D):Matrix3D{
sxx = _arg1.sxx;
sxy = _arg1.sxy;
sxz = _arg1.sxz;
tx = _arg1.tx;
syx = _arg1.syx;
syy = _arg1.syy;
syz = _arg1.syz;
ty = _arg1.ty;
szx = _arg1.szx;
szy = _arg1.szy;
szz = _arg1.szz;
tz = _arg1.tz;
swx = _arg1.swx;
swy = _arg1.swy;
swz = _arg1.swz;
tw = _arg1.tw;
return (_arg1);
}
public function rotationMatrix(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):void{
nCos = Math.cos(_arg4);
nSin = Math.sin(_arg4);
scos = (1 - nCos);
suv = ((_arg1 * _arg2) * scos);
svw = ((_arg2 * _arg3) * scos);
suw = ((_arg1 * _arg3) * scos);
sw = (nSin * _arg3);
sv = (nSin * _arg2);
su = (nSin * _arg1);
sxx = (nCos + ((_arg1 * _arg1) * scos));
sxy = (-(sw) + suv);
sxz = (sv + suw);
syx = (sw + suv);
syy = (nCos + ((_arg2 * _arg2) * scos));
syz = (-(su) + svw);
szx = (-(sv) + suw);
szy = (su + svw);
szz = (nCos + ((_arg3 * _arg3) * scos));
}
public function translationMatrix(_arg1:Number, _arg2:Number, _arg3:Number):void{
sxx = (syy = (szz = 1));
sxy = (sxz = (syz = (syz = (szx = (szy = 0)))));
tx = _arg1;
ty = _arg2;
tz = _arg3;
}
public function scaleMatrix(_arg1:Number, _arg2:Number, _arg3:Number):void{
tx = (sxy = (sxz = (syx = (ty = (syz = (szx = (szy = (tz = 0))))))));
sxx = _arg1;
syy = _arg2;
szz = _arg3;
}
public function clear():void{
tx = (sxy = (sxz = (syx = (ty = (syz = (szx = (szy = (tz = 0))))))));
sxx = (syy = (szz = 1));
}
public function compare(_arg1:Matrix3D):Boolean{
if (((((((((((((((((((((((!((sxx == _arg1.sxx))) || (!((sxy == _arg1.sxy))))) || (!((sxz == _arg1.sxz))))) || (!((tx == _arg1.tx))))) || (!((syx == _arg1.syx))))) || (!((syy == _arg1.syy))))) || (!((syz == _arg1.syz))))) || (!((ty == _arg1.ty))))) || (!((szx == _arg1.szx))))) || (!((szy == _arg1.szy))))) || (!((szz == _arg1.szz))))) || (!((tz == _arg1.tz))))){
return (false);
};
return (true);
}
public function perspectiveProjectionMatrix(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):void{
var _local5:Number = ((_arg1 / 2) * (Math.PI / 180));
var _local6:Number = Math.tan(_local5);
var _local7:Number = (1 / _local6);
sxx = (_local7 / _arg2);
sxy = (sxz = (tx = 0));
syy = _local7;
syx = (syz = (ty = 0));
szx = (szy = 0);
szz = -(((_arg3 + _arg4) / (_arg3 - _arg4)));
tz = (((2 * _arg4) * _arg3) / (_arg3 - _arg4));
swx = (swy = (tw = 0));
swz = 1;
}
public function orthographicProjectionMatrix(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:Number):void{
sxx = (2 / (_arg2 - _arg1));
sxy = (sxz = 0);
tx = ((_arg2 + _arg1) / (_arg2 - _arg1));
syy = (2 / (_arg4 - _arg3));
syx = (syz = 0);
ty = ((_arg4 + _arg3) / (_arg4 - _arg3));
szx = (szy = 0);
szz = (-2 / (_arg6 - _arg5));
tz = ((_arg6 + _arg5) / (_arg6 - _arg5));
swx = (swy = (swz = 0));
tw = 1;
var _local7:Matrix3D = new Matrix3D();
_local7.scaleMatrix(1, 1, -1);
this.multiply(_local7, this);
}
public function inverse(_arg1:Matrix3D):void{
d = _arg1.det;
if (Math.abs(d) < 1E-5){
return;
};
d = (1 / d);
m111 = _arg1.sxx;
m121 = _arg1.syx;
m131 = _arg1.szx;
m112 = _arg1.sxy;
m122 = _arg1.syy;
m132 = _arg1.szy;
m113 = _arg1.sxz;
m123 = _arg1.syz;
m133 = _arg1.szz;
m114 = _arg1.tx;
m124 = _arg1.ty;
m134 = _arg1.tz;
sxx = (d * ((m122 * m133) - (m132 * m123)));
sxy = (-(d) * ((m112 * m133) - (m132 * m113)));
sxz = (d * ((m112 * m123) - (m122 * m113)));
tx = (-(d) * (((m112 * ((m123 * m134) - (m133 * m124))) - (m122 * ((m113 * m134) - (m133 * m114)))) + (m132 * ((m113 * m124) - (m123 * m114)))));
syx = (-(d) * ((m121 * m133) - (m131 * m123)));
syy = (d * ((m111 * m133) - (m131 * m113)));
syz = (-(d) * ((m111 * m123) - (m121 * m113)));
ty = (d * (((m111 * ((m123 * m134) - (m133 * m124))) - (m121 * ((m113 * m134) - (m133 * m114)))) + (m131 * ((m113 * m124) - (m123 * m114)))));
szx = (d * ((m121 * m132) - (m131 * m122)));
szy = (-(d) * ((m111 * m132) - (m131 * m112)));
szz = (d * ((m111 * m122) - (m121 * m112)));
tz = (-(d) * (((m111 * ((m122 * m134) - (m132 * m124))) - (m121 * ((m112 * m134) - (m132 * m114)))) + (m131 * ((m112 * m124) - (m122 * m114)))));
}
public function inverse4x4(_arg1:Matrix3D):void{
d = _arg1.det4x4;
if (Math.abs(d) < 0.001){
return;
};
d = (1 / d);
m111 = _arg1.sxx;
m121 = _arg1.syx;
m131 = _arg1.szx;
m141 = _arg1.swx;
m112 = _arg1.sxy;
m122 = _arg1.syy;
m132 = _arg1.szy;
m142 = _arg1.swy;
m113 = _arg1.sxz;
m123 = _arg1.syz;
m133 = _arg1.szz;
m143 = _arg1.swz;
m114 = _arg1.tx;
m124 = _arg1.ty;
m134 = _arg1.tz;
m144 = _arg1.tw;
sxx = (d * (((m122 * ((m133 * m144) - (m143 * m134))) - (m132 * ((m123 * m144) - (m143 * m124)))) + (m142 * ((m123 * m134) - (m133 * m124)))));
sxy = (-(d) * (((m112 * ((m133 * m144) - (m143 * m134))) - (m132 * ((m113 * m144) - (m143 * m114)))) + (m142 * ((m113 * m134) - (m133 * m114)))));
sxz = (d * (((m112 * ((m123 * m144) - (m143 * m124))) - (m122 * ((m113 * m144) - (m143 * m114)))) + (m142 * ((m113 * m124) - (m123 * m114)))));
tx = (-(d) * (((m112 * ((m123 * m134) - (m133 * m124))) - (m122 * ((m113 * m134) - (m133 * m114)))) + (m132 * ((m113 * m124) - (m123 * m114)))));
syx = (-(d) * (((m121 * ((m133 * m144) - (m143 * m134))) - (m131 * ((m123 * m144) - (m143 * m124)))) + (m141 * ((m123 * m134) - (m133 * m124)))));
syy = (d * (((m111 * ((m133 * m144) - (m143 * m134))) - (m131 * ((m113 * m144) - (m143 * m114)))) + (m141 * ((m113 * m134) - (m133 * m114)))));
syz = (-(d) * (((m111 * ((m123 * m144) - (m143 * m124))) - (m121 * ((m113 * m144) - (m143 * m114)))) + (m141 * ((m113 * m124) - (m123 * m114)))));
ty = (d * (((m111 * ((m123 * m134) - (m133 * m124))) - (m121 * ((m113 * m134) - (m133 * m114)))) + (m131 * ((m113 * m124) - (m123 * m114)))));
szx = (d * (((m121 * ((m132 * m144) - (m142 * m134))) - (m131 * ((m122 * m144) - (m142 * m124)))) + (m141 * ((m122 * m134) - (m132 * m124)))));
szy = (-(d) * (((m111 * ((m132 * m144) - (m142 * m134))) - (m131 * ((m112 * m144) - (m142 * m114)))) + (m141 * ((m112 * m134) - (m132 * m114)))));
szz = (d * (((m111 * ((m122 * m144) - (m142 * m124))) - (m121 * ((m112 * m144) - (m142 * m114)))) + (m141 * ((m112 * m124) - (m122 * m114)))));
tz = (-(d) * (((m111 * ((m122 * m134) - (m132 * m124))) - (m121 * ((m112 * m134) - (m132 * m114)))) + (m131 * ((m112 * m124) - (m122 * m114)))));
swx = (-(d) * (((m121 * ((m132 * m143) - (m142 * m133))) - (m131 * ((m122 * m143) - (m142 * m123)))) + (m141 * ((m122 * m133) - (m132 * m123)))));
swy = (d * (((m111 * ((m132 * m143) - (m142 * m133))) - (m131 * ((m112 * m143) - (m142 * m113)))) + (m141 * ((m112 * m133) - (m132 * m113)))));
swz = (-(d) * (((m111 * ((m122 * m143) - (m142 * m123))) - (m121 * ((m112 * m143) - (m142 * m113)))) + (m141 * ((m112 * m123) - (m122 * m113)))));
tw = (d * (((m111 * ((m122 * m133) - (m132 * m123))) - (m121 * ((m112 * m133) - (m132 * m113)))) + (m131 * ((m112 * m123) - (m122 * m113)))));
}
public function quaternion2matrix(_arg1:Quaternion):void{
x = _arg1.x;
y = _arg1.y;
z = _arg1.z;
w = _arg1.w;
xx = (x * x);
xy = (x * y);
xz = (x * z);
xw = (x * w);
yy = (y * y);
yz = (y * z);
yw = (y * w);
zz = (z * z);
zw = (z * w);
sxx = (1 - (2 * (yy + zz)));
sxy = (2 * (xy - zw));
sxz = (2 * (xz + yw));
syx = (2 * (xy + zw));
syy = (1 - (2 * (xx + zz)));
syz = (2 * (yz - xw));
szx = (2 * (xz - yw));
szy = (2 * (yz + xw));
szz = (1 - (2 * (xx + yy)));
}
public function normalize(_arg1:Matrix3D):void{
d = Math.sqrt((((sxx * sxx) + (sxy * sxy)) + (sxz * sxz)));
sxx = (sxx / d);
sxy = (sxy / d);
sxz = (sxz / d);
d = Math.sqrt((((syx * syx) + (syy * syy)) + (syz * syz)));
syx = (syx / d);
syy = (syy / d);
syz = (syz / d);
d = Math.sqrt((((szx * szx) + (szy * szy)) + (szz * szz)));
szx = (szx / d);
szy = (szy / d);
szz = (szz / d);
}
public function get forward():Number3D{
_forward.x = szx;
_forward.y = szy;
_forward.z = szz;
return (_forward);
}
public function set forward(_arg1:Number3D):void{
this.szx = _arg1.x;
this.szy = _arg1.y;
this.szz = _arg1.z;
}
public function get up():Number3D{
_up.x = syx;
_up.y = syy;
_up.z = syz;
return (_up);
}
public function set up(_arg1:Number3D):void{
this.syx = _arg1.x;
this.syy = _arg1.y;
this.syz = _arg1.z;
}
public function get right():Number3D{
_right.x = sxx;
_right.y = sxy;
_right.z = sxz;
return (_right);
}
public function set right(_arg1:Number3D):void{
this.sxx = _arg1.x;
this.sxy = _arg1.y;
this.sxz = _arg1.z;
}
public function multiplyVector3x3(_arg1:Number3D):void{
var _local2:Number = _arg1.x;
var _local3:Number = _arg1.y;
var _local4:Number = _arg1.z;
_arg1.x = (((_local2 * sxx) + (_local3 * sxy)) + (_local4 * sxz));
_arg1.y = (((_local2 * syx) + (_local3 * syy)) + (_local4 * syz));
_arg1.z = (((_local2 * szx) + (_local3 * szy)) + (_local4 * szz));
}
}
}//package away3d.core.math
Section 63
//Number3D (away3d.core.math.Number3D)
package away3d.core.math {
public final class Number3D {
private const MathPI:Number = 3.14159265358979;
private var mod:Number;
private var dist:Number;
private var num:Number3D;
private var vx:Number;
private var vy:Number;
private var vz:Number;
private var m1:Matrix3D;
public var x:Number;
public var y:Number;
public var z:Number;
public static var FORWARD:Number3D = new Number3D(0, 0, 1);
;
public static var BACKWARD:Number3D = new Number3D(0, 0, -1);
;
public static var LEFT:Number3D = new Number3D(-1, 0, 0);
;
public static var RIGHT:Number3D = new Number3D(1, 0, 0);
;
public static var UP:Number3D = new Number3D(0, 1, 0);
;
public static var DOWN:Number3D = new Number3D(0, -1, 0);
;
public function Number3D(_arg1:Number=0, _arg2:Number=0, _arg3:Number=0, _arg4:Boolean=false){
this.x = _arg1;
this.y = _arg2;
this.z = _arg3;
if (_arg4){
normalize();
};
}
public function get modulo():Number{
return (Math.sqrt((((x * x) + (y * y)) + (z * z))));
}
public function get modulo2():Number{
return ((((x * x) + (y * y)) + (z * z)));
}
public function equals(_arg1:Number3D):Boolean{
return ((((((_arg1.x == x)) && ((_arg1.y == y)))) && ((_arg1.z == z))));
}
public function clone(_arg1:Number3D):void{
x = _arg1.x;
y = _arg1.y;
z = _arg1.z;
}
public function scale(_arg1:Number3D, _arg2:Number):void{
x = (_arg1.x * _arg2);
y = (_arg1.y * _arg2);
z = (_arg1.z * _arg2);
}
public function add(_arg1:Number3D, _arg2:Number3D):void{
x = (_arg1.x + _arg2.x);
y = (_arg1.y + _arg2.y);
z = (_arg1.z + _arg2.z);
}
public function sub(_arg1:Number3D, _arg2:Number3D):void{
x = (_arg1.x - _arg2.x);
y = (_arg1.y - _arg2.y);
z = (_arg1.z - _arg2.z);
}
public function distance(_arg1:Number3D):Number{
return (Math.sqrt(((((x - _arg1.x) * (x - _arg1.x)) + ((y - _arg1.y) * (y - _arg1.y))) + ((z - _arg1.z) * (z - _arg1.z)))));
}
public function dot(_arg1:Number3D):Number{
return ((((x * _arg1.x) + (y * _arg1.y)) + (z * _arg1.z)));
}
public function cross(_arg1:Number3D, _arg2:Number3D):void{
if ((((this == _arg1)) || ((this == _arg2)))){
throw (new Error("resultant cross product cannot be the same instance as an input"));
};
x = ((_arg2.y * _arg1.z) - (_arg2.z * _arg1.y));
y = ((_arg2.z * _arg1.x) - (_arg2.x * _arg1.z));
z = ((_arg2.x * _arg1.y) - (_arg2.y * _arg1.x));
}
public function getAngle(_arg1:Number3D=null):Number{
if (_arg1 == null){
_arg1 = new Number3D();
};
return (Math.acos((dot(_arg1) / (modulo * _arg1.modulo))));
}
public function normalize(_arg1:Number=1):void{
mod = (modulo / _arg1);
if (((!((mod == 0))) && (!((mod == 1))))){
x = (x / mod);
y = (y / mod);
z = (z / mod);
};
}
public function rotate(_arg1:Number3D, _arg2:Matrix3D):void{
vx = _arg1.x;
vy = _arg1.y;
vz = _arg1.z;
x = (((vx * _arg2.sxx) + (vy * _arg2.sxy)) + (vz * _arg2.sxz));
y = (((vx * _arg2.syx) + (vy * _arg2.syy)) + (vz * _arg2.syz));
z = (((vx * _arg2.szx) + (vy * _arg2.szy)) + (vz * _arg2.szz));
}
public function transform(_arg1:Number3D, _arg2:Matrix3D):void{
vx = _arg1.x;
vy = _arg1.y;
vz = _arg1.z;
x = ((((vx * _arg2.sxx) + (vy * _arg2.sxy)) + (vz * _arg2.sxz)) + _arg2.tx);
y = ((((vx * _arg2.syx) + (vy * _arg2.syy)) + (vz * _arg2.syz)) + _arg2.ty);
z = ((((vx * _arg2.szx) + (vy * _arg2.szy)) + (vz * _arg2.szz)) + _arg2.tz);
}
public function matrix2euler(_arg1:Matrix3D):void{
if (!m1){
m1 = new Matrix3D();
};
x = -(Math.atan2(_arg1.szy, _arg1.szz));
m1.rotationMatrix(1, 0, 0, x);
m1.multiply(_arg1, m1);
var _local2:Number = Math.sqrt(((m1.sxx * m1.sxx) + (m1.syx * m1.syx)));
y = Math.atan2(-(m1.szx), _local2);
z = Math.atan2(-(m1.sxy), m1.syy);
if (Math.round((z / MathPI)) == 1){
if (y > 0){
y = -((y - MathPI));
} else {
y = -((y + MathPI));
};
z = (z - MathPI);
if (x > 0){
x = (x - MathPI);
} else {
x = (x + MathPI);
};
} else {
if (Math.round((z / MathPI)) == -1){
if (y > 0){
y = -((y - MathPI));
} else {
y = -((y + MathPI));
};
z = (z + MathPI);
if (x > 0){
x = (x - MathPI);
} else {
x = (x + MathPI);
};
} else {
if (Math.round((x / MathPI)) == 1){
if (y > 0){
y = -((y - MathPI));
} else {
y = -((y + MathPI));
};
x = (x - MathPI);
if (z > 0){
z = (z - MathPI);
} else {
z = (z + MathPI);
};
} else {
if (Math.round((x / MathPI)) == -1){
if (y > 0){
y = -((y - MathPI));
} else {
y = -((y + MathPI));
};
x = (x + MathPI);
if (z > 0){
z = (z - MathPI);
} else {
z = (z + MathPI);
};
};
};
};
};
}
public function quaternion2euler(_arg1:Quaternion):void{
var _local2:Number = ((_arg1.x * _arg1.y) + (_arg1.z * _arg1.w));
if (_local2 > 0.499){
x = (2 * Math.atan2(_arg1.x, _arg1.w));
y = (Math.PI / 2);
z = 0;
return;
};
if (_local2 < -0.499){
x = (-2 * Math.atan2(_arg1.x, _arg1.w));
y = (-(Math.PI) / 2);
z = 0;
return;
};
var _local3:Number = (_arg1.x * _arg1.x);
var _local4:Number = (_arg1.y * _arg1.y);
var _local5:Number = (_arg1.z * _arg1.z);
x = Math.atan2((((2 * _arg1.y) * _arg1.w) - ((2 * _arg1.x) * _arg1.z)), ((1 - (2 * _local4)) - (2 * _local5)));
y = Math.asin((2 * _local2));
z = Math.atan2((((2 * _arg1.x) * _arg1.w) - ((2 * _arg1.y) * _arg1.z)), ((1 - (2 * _local3)) - (2 * _local5)));
}
public function matrix2scale(_arg1:Matrix3D):void{
x = Math.sqrt((((_arg1.sxx * _arg1.sxx) + (_arg1.syx * _arg1.syx)) + (_arg1.szx * _arg1.szx)));
y = Math.sqrt((((_arg1.sxy * _arg1.sxy) + (_arg1.syy * _arg1.syy)) + (_arg1.szy * _arg1.szy)));
z = Math.sqrt((((_arg1.sxz * _arg1.sxz) + (_arg1.syz * _arg1.syz)) + (_arg1.szz * _arg1.szz)));
}
public function interpolate(_arg1:Number3D, _arg2:Number):void{
var _local3:Number3D = new Number3D();
_local3.sub(_arg1, this);
_local3.scale(_local3, _arg2);
add(this, _local3);
}
public function closestPointOnPlane(_arg1:Number3D, _arg2:Number3D, _arg3:Number3D):Number3D{
if (!num){
num = new Number3D();
};
num.sub(_arg1, _arg2);
dist = _arg3.dot(num);
num.scale(_arg3, dist);
num.sub(_arg1, num);
return (num);
}
public function toString():String{
return (((((("x:" + x) + " y:") + y) + " z:") + z));
}
public static function getInterpolated(_arg1:Number3D, _arg2:Number3D, _arg3:Number):Number3D{
var _local4:Number3D = new (Number3D);
_local4.sub(_arg1, _arg2);
_local4.scale(_local4, _arg3);
_local4.add(_local4, _arg2);
return (_local4);
}
}
}//package away3d.core.math
Section 64
//Quaternion (away3d.core.math.Quaternion)
package away3d.core.math {
public final class Quaternion {
private var w1:Number;
private var w2:Number;
private var x1:Number;
private var x2:Number;
private var y1:Number;
private var y2:Number;
private var z1:Number;
private var z2:Number;
private var sin_a:Number;
private var cos_a:Number;
private var fSinPitch:Number;
private var fCosPitch:Number;
private var fSinYaw:Number;
private var fCosYaw:Number;
private var fSinRoll:Number;
private var fCosRoll:Number;
private var fCosPitchCosYaw:Number;
private var fSinPitchSinYaw:Number;
public var x:Number;
public var y:Number;
public var z:Number;
public var w:Number;
public function get magnitude():Number{
return (Math.sqrt(((((w * w) + (x * x)) + (y * y)) + (z * z))));
}
public function multiply(_arg1:Quaternion, _arg2:Quaternion):void{
w1 = _arg1.w;
x1 = _arg1.x;
y1 = _arg1.y;
z1 = _arg1.z;
w2 = _arg2.w;
x2 = _arg2.x;
y2 = _arg2.y;
z2 = _arg2.z;
w = ((((w1 * w2) - (x1 * x2)) - (y1 * y2)) - (z1 * z2));
x = ((((w1 * x2) + (x1 * w2)) + (y1 * z2)) - (z1 * y2));
y = ((((w1 * y2) + (y1 * w2)) + (z1 * x2)) - (x1 * z2));
z = ((((w1 * z2) + (z1 * w2)) + (x1 * y2)) - (y1 * x2));
}
public function axis2quaternion(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):void{
sin_a = Math.sin((_arg4 / 2));
cos_a = Math.cos((_arg4 / 2));
this.x = (_arg1 * sin_a);
this.y = (_arg2 * sin_a);
this.z = (_arg3 * sin_a);
w = cos_a;
normalize();
}
public function euler2quaternion(_arg1:Number, _arg2:Number, _arg3:Number):void{
fSinPitch = Math.sin((_arg1 * 0.5));
fCosPitch = Math.cos((_arg1 * 0.5));
fSinYaw = Math.sin((_arg2 * 0.5));
fCosYaw = Math.cos((_arg2 * 0.5));
fSinRoll = Math.sin((_arg3 * 0.5));
fCosRoll = Math.cos((_arg3 * 0.5));
fCosPitchCosYaw = (fCosPitch * fCosYaw);
fSinPitchSinYaw = (fSinPitch * fSinYaw);
x = ((fSinRoll * fCosPitchCosYaw) - (fCosRoll * fSinPitchSinYaw));
y = (((fCosRoll * fSinPitch) * fCosYaw) + ((fSinRoll * fCosPitch) * fSinYaw));
z = (((fCosRoll * fCosPitch) * fSinYaw) - ((fSinRoll * fSinPitch) * fCosYaw));
w = ((fCosRoll * fCosPitchCosYaw) + (fSinRoll * fSinPitchSinYaw));
}
public function normalize(_arg1:Number=1):void{
var _local2:Number = (magnitude * _arg1);
x = (x / _local2);
y = (y / _local2);
z = (z / _local2);
w = (w / _local2);
}
public function toString():String{
return ((((((((("{x:" + x) + " y:") + y) + " z:") + z) + " w:") + w) + "}"));
}
}
}//package away3d.core.math
Section 65
//ConvexBlockProjector (away3d.core.project.ConvexBlockProjector)
package away3d.core.project {
import away3d.core.math.*;
import away3d.core.base.*;
import away3d.core.utils.*;
import away3d.core.draw.*;
import away3d.containers.*;
import away3d.core.block.*;
import away3d.cameras.*;
import away3d.cameras.lenses.*;
import away3d.blockers.*;
public class ConvexBlockProjector implements IBlockerProvider, IPrimitiveProvider {
private var _view:View3D;
private var _drawPrimitiveStore:DrawPrimitiveStore;
private var _convexBlock:ConvexBlock;
private var _camera:Camera3D;
private var _lens:AbstractLens;
private var _vertices:Array;
private var _screenVertices:Array;
private var _index:int;
private var _i:int;
private var _points:Array;
private var _pointsN:Array;
private var _pointsS:Array;
private var _screenX:Number;
private var _screenY:Number;
private var _baseX:Number;
private var _baseY:Number;
private var _baseZ:Number;
private var _baseIndex:Number;
private var _s:String;
private var _p:String;
public function ConvexBlockProjector(){
_points = [];
_pointsN = [];
_pointsS = [];
super();
}
private function cross(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:Number):Number{
return ((((_arg3 - _arg1) * (_arg6 - _arg2)) - ((_arg5 - _arg1) * (_arg4 - _arg2))));
}
public function get view():View3D{
return (_view);
}
public function set view(_arg1:View3D):void{
_view = _arg1;
_drawPrimitiveStore = _view.drawPrimitiveStore;
}
public function blockers(_arg1:Object3D, _arg2:Matrix3D, _arg3:IBlockerConsumer):void{
var _local5:Number;
var _local6:int;
_screenVertices = _drawPrimitiveStore.getScreenVertices(_arg1.id);
_convexBlock = (_arg1 as ConvexBlock);
_camera = _view.camera;
_lens = _camera.lens;
_vertices = _convexBlock.vertices;
if (_vertices.length < 3){
return;
};
_points.length = 0;
_pointsN.length = 0;
_pointsS.length = 0;
_baseX = Infinity;
_baseY = Infinity;
_baseZ = Infinity;
_p = "";
_lens.project(_arg2, _vertices, _screenVertices);
_index = (_screenVertices.length / 3);
while (_index--) {
_screenX = _screenVertices[(_index * 3)];
_screenY = _screenVertices[((_index * 3) + 1)];
if ((((_baseY > _screenY)) || ((((_baseY == _screenY)) && ((_baseX > _screenX)))))){
_baseX = _screenX;
_baseY = _screenY;
_baseZ = _screenVertices[((_index * 3) + 2)];
_baseIndex = _index;
};
_points[_points.length] = _baseX;
_points[_points.length] = _baseY;
_points[_points.length] = _baseZ;
};
_index = (_points.length / 3);
while (_index--) {
_pointsN[_index] = ((_points[(_index * 3)] - _baseX) / (_points[((_index * 3) + 1)] - _baseY));
};
_pointsN[_baseIndex] = -(Infinity);
_pointsN = _pointsN.sort((Array.NUMERIC | Array.RETURNINDEXEDARRAY));
_index = 0;
while (_index < _pointsN.length) {
_i = (_pointsN[_index] * 3);
_pointsS[_pointsS.length] = _points[_i];
_pointsS[_pointsS.length] = _points[(_i + 1)];
_pointsS[_pointsS.length] = _points[(_i + 2)];
_index++;
};
var _local4:Array = [_pointsS[0], _pointsS[1], _pointsS[2], _pointsS[3], _pointsS[4], _pointsS[5]];
_i = 2;
while (_i < _pointsS.length) {
_local6 = _local4.length;
_local5 = cross(_local4[(_local6 - 6)], _local4[(_local6 - 5)], _local4[(_local6 - 3)], _local4[(_local6 - 2)], _pointsS[(_i * 3)], _pointsS[((_i * 3) + 1)]);
while (_local5 > 0) {
_local4.pop();
_local4.pop();
_local4.pop();
if (_local4.length == 6){
break;
};
_local6 = _local4.length;
_local5 = cross(_local4[(_local6 - 6)], _local4[(_local6 - 5)], _local4[(_local6 - 3)], _local4[(_local6 - 2)], _pointsS[(_i * 3)], _pointsS[((_i * 3) + 1)]);
};
_local4.push(_pointsS[(_i * 3)], _pointsS[((_i * 3) + 1)], _pointsS[((_i * 3) + 2)]);
_i++;
};
_local6 = _local4.length;
_local5 = cross(_local4[(_local6 - 6)], _local4[(_local6 - 5)], _local4[(_local6 - 3)], _local4[(_local6 - 2)], _local4[0], _local4[1]);
if (_local5 > 0){
_local4.pop();
_local4.pop();
_local4.pop();
};
_arg3.blocker(_drawPrimitiveStore.createConvexBlocker(_arg1, _local4));
}
public function primitives(_arg1:Object3D, _arg2:Matrix3D, _arg3:IPrimitiveConsumer):void{
_convexBlock = (_arg1 as ConvexBlock);
if (_convexBlock.debug){
_arg3.primitive(_drawPrimitiveStore.blockerDictionary[_arg1]);
};
}
}
}//package away3d.core.project
Section 66
//DirSpriteProjector (away3d.core.project.DirSpriteProjector)
package away3d.core.project {
import flash.display.*;
import away3d.core.math.*;
import away3d.core.base.*;
import away3d.core.utils.*;
import away3d.core.draw.*;
import away3d.containers.*;
import flash.utils.*;
import away3d.sprites.*;
import away3d.cameras.lenses.*;
public class DirSpriteProjector implements IPrimitiveProvider {
private var _view:View3D;
private var _drawPrimitiveStore:DrawPrimitiveStore;
private var _dirsprite:DirSprite2D;
private var _vertices:Array;
private var _bitmaps:Dictionary;
private var _lens:AbstractLens;
private var _screenVertices:Array;
private var _centerScreenVertices:Array;
private var _index:int;
public function DirSpriteProjector(){
_centerScreenVertices = new Array();
super();
}
public function get view():View3D{
return (_view);
}
public function set view(_arg1:View3D):void{
_view = _arg1;
_drawPrimitiveStore = view.drawPrimitiveStore;
}
public function primitives(_arg1:Object3D, _arg2:Matrix3D, _arg3:IPrimitiveConsumer):void{
var _local6:Number;
_screenVertices = _drawPrimitiveStore.getScreenVertices(_arg1.id);
_dirsprite = (_arg1 as DirSprite2D);
_vertices = _dirsprite.vertices;
_bitmaps = _dirsprite.bitmaps;
_lens = _view.camera.lens;
if (_vertices.length == 0){
return;
};
var _local4:Number = Infinity;
var _local5:BitmapData;
_lens.project(_arg2, _vertices, _screenVertices);
_index = (_screenVertices.length / 3);
while (_index--) {
_local6 = _screenVertices[((_index * 3) + 2)];
if (_local6 < _local4){
_local4 = _local6;
_local5 = _bitmaps[_vertices[_index]];
};
};
if (_local5 == null){
return;
};
_centerScreenVertices.length = 0;
_lens.project(_arg2, _dirsprite.center, _centerScreenVertices);
if (_centerScreenVertices[0] == null){
return;
};
_centerScreenVertices[2] = (_centerScreenVertices[2] + _dirsprite.deltaZ);
_arg3.primitive(_drawPrimitiveStore.createDrawScaledBitmap(_arg1, _centerScreenVertices, _dirsprite.smooth, _local5, ((_dirsprite.scaling * _view.camera.zoom) / (1 + (_screenVertices[2] / _view.camera.focus))), _dirsprite.rotation));
}
}
}//package away3d.core.project
Section 67
//DofSpriteProjector (away3d.core.project.DofSpriteProjector)
package away3d.core.project {
import away3d.core.math.*;
import away3d.core.base.*;
import away3d.core.utils.*;
import away3d.core.draw.*;
import away3d.containers.*;
import away3d.sprites.*;
import away3d.cameras.lenses.*;
public class DofSpriteProjector implements IPrimitiveProvider {
private var _view:View3D;
private var _drawPrimitiveStore:DrawPrimitiveStore;
private var _screenVertices:Array;
private var _dofsprite:DofSprite2D;
private var _lens:AbstractLens;
private var _dofcache:DofCache;
private var _screenZ:Number;
public function get view():View3D{
return (_view);
}
public function set view(_arg1:View3D):void{
_view = _arg1;
_drawPrimitiveStore = view.drawPrimitiveStore;
}
public function primitives(_arg1:Object3D, _arg2:Matrix3D, _arg3:IPrimitiveConsumer):void{
_screenVertices = _drawPrimitiveStore.getScreenVertices(_arg1.id);
_dofsprite = (_arg1 as DofSprite2D);
_lens = _view.camera.lens;
_lens.project(_arg2, _dofsprite.center, _screenVertices);
if (_screenVertices[0] == null){
return;
};
_screenZ = (_screenVertices[2] = (_screenVertices[2] + _dofsprite.deltaZ));
_dofcache = DofCache.getDofCache(_dofsprite.bitmap);
_arg3.primitive(_drawPrimitiveStore.createDrawScaledBitmap(_arg1, _screenVertices, _dofsprite.smooth, _dofcache.getBitmap(_screenZ), ((_dofsprite.scaling * _view.camera.zoom) / (1 + (_screenZ / _view.camera.focus))), _dofsprite.rotation));
}
}
}//package away3d.core.project
Section 68
//MeshProjector (away3d.core.project.MeshProjector)
package away3d.core.project {
import away3d.core.math.*;
import away3d.core.base.*;
import away3d.core.utils.*;
import away3d.materials.*;
import away3d.core.draw.*;
import away3d.containers.*;
import away3d.core.geom.*;
import flash.utils.*;
import away3d.cameras.*;
import away3d.core.clip.*;
import away3d.cameras.lenses.*;
public class MeshProjector implements IPrimitiveProvider {
var _view:View3D;
var _drawPrimitiveStore:DrawPrimitiveStore;
var _cameraVarsStore:CameraVarsStore;
private var _screenVertices:Array;
private var _screenIndices:Array;
private var _screenCommands:Array;
private var _mesh:Mesh;
private var _clipFlag:Boolean;
private var _vertex:Vertex;
private var _defaultStartIndices:Array;
private var _startIndices:Array;
private var _defaultVertices:Array;
private var _vertices:Array;
private var _defaultClippedFaceVOs:Array;
private var _faceVOs:Array;
private var _defaultClippedSegmentVOs:Array;
private var _segmentVOs:Array;
private var _defaultClippedBillboards:Array;
private var _spriteVOs:Array;
private var _camera:Camera3D;
private var _clipping:Clipping;
private var _lens:AbstractLens;
private var _focus:Number;
private var _zoom:Number;
private var _outlineIndices:Dictionary;
private var _material:Material;
private var _face:Face;
private var _faceVO:FaceVO;
private var _index:int;
private var _startIndex:int;
private var _endIndex:int;
private var _tri:DrawTriangle;
private var _backface:Boolean;
private var _backmat:Material;
private var _segment:Segment;
private var _segmentVO:SegmentVO;
private var _seg:DrawSegment;
private var _smaterial:Material;
private var _spriteVO:SpriteVO;
private var _spmaterial:Material;
private var _n01:Face;
private var _n12:Face;
private var _n20:Face;
private var _sv0x:Number;
private var _sv0y:Number;
private var _sv1x:Number;
private var _sv1y:Number;
private var _sv2x:Number;
private var _sv2y:Number;
private var _i:int;
public function MeshProjector(){
_defaultStartIndices = new Array();
_defaultVertices = new Array();
_defaultClippedFaceVOs = new Array();
_defaultClippedSegmentVOs = new Array();
_defaultClippedBillboards = new Array();
_outlineIndices = new Dictionary(true);
super();
}
private function front(_arg1:int):Number{
_index = (_screenIndices[_arg1] * 3);
_sv0x = _screenVertices[_index];
_sv0y = _screenVertices[(_index + 1)];
_index = (_screenIndices[(_arg1 + 1)] * 3);
_sv1x = _screenVertices[_index];
_sv1y = _screenVertices[(_index + 1)];
_index = (_screenIndices[(_arg1 + 2)] * 3);
_sv2x = _screenVertices[_index];
_sv2y = _screenVertices[(_index + 1)];
return ((((_sv0x * (_sv2y - _sv1y)) + (_sv1x * (_sv0y - _sv2y))) + (_sv2x * (_sv1y - _sv0y))));
}
public function get view():View3D{
return (_view);
}
public function set view(_arg1:View3D):void{
_view = _arg1;
_drawPrimitiveStore = view.drawPrimitiveStore;
_cameraVarsStore = view.cameraVarsStore;
}
public function primitives(_arg1:Object3D, _arg2:Matrix3D, _arg3:IPrimitiveConsumer):void{
_cameraVarsStore.createVertexClassificationDictionary(_arg1);
_mesh = (_arg1 as Mesh);
_camera = _view.camera;
_clipping = _view.screenClipping;
_lens = _camera.lens;
_focus = _camera.focus;
_zoom = _camera.zoom;
_material = _mesh.material;
_backmat = ((_mesh.back) || (_material));
_clipFlag = (((_cameraVarsStore.nodeClassificationDictionary[_arg1] == Frustum.INTERSECT)) && (!((_clipping is RectangleClipping))));
if (_clipFlag){
_vertices = _defaultVertices;
_vertices.length = 0;
_screenCommands = _drawPrimitiveStore.getScreenCommands(_arg1.id);
_screenCommands.length = 0;
_screenIndices = _drawPrimitiveStore.getScreenIndices(_arg1.id);
_screenIndices.length = 0;
_startIndices = _defaultStartIndices;
_startIndices.length = 0;
_faceVOs = _defaultClippedFaceVOs;
_faceVOs.length = 0;
_segmentVOs = _defaultClippedSegmentVOs;
_segmentVOs.length = 0;
_spriteVOs = _defaultClippedBillboards;
_spriteVOs.length = 0;
_clipping.checkElements(_mesh, _faceVOs, _segmentVOs, _spriteVOs, _vertices, _screenCommands, _screenIndices, _startIndices);
} else {
_vertices = _mesh.vertices;
_screenCommands = _mesh.commands;
_screenIndices = _mesh.indices;
_startIndices = _mesh.startIndices;
_faceVOs = _mesh.faceVOs;
_segmentVOs = _mesh.segmentVOs;
_spriteVOs = _mesh.spriteVOs;
};
_screenVertices = _drawPrimitiveStore.getScreenVertices(_arg1.id);
_screenVertices.length = 0;
_lens.project(_arg2, _vertices, _screenVertices);
if (_mesh.outline){
_i = _faceVOs.length;
while (_i--) {
_outlineIndices[_faceVOs[_i]] = _i;
};
};
_i = 0;
for each (_faceVO in _faceVOs) {
_startIndex = _startIndices[_i++];
_endIndex = _startIndices[_i];
if (!_clipFlag){
_index = _startIndex;
while (((!((_screenVertices[(_screenIndices[_index] * 3)] == null))) && ((_index < _endIndex)))) {
_index++;
};
//unresolved if
} else {
_face = _faceVO.face;
_tri = _drawPrimitiveStore.createDrawTriangle(_arg1, _faceVO, null, _screenVertices, _screenIndices, _screenCommands, _startIndex, _endIndex, _faceVO.uv0, _faceVO.uv1, _faceVO.uv2, _faceVO.generated);
_backface = (_tri.backface = (_tri.area < 0));
if (_backface){
if (!_mesh.bothsides){
continue;
};
_tri.material = _faceVO.back;
if (!_tri.material){
_tri.material = _faceVO.material;
};
} else {
_tri.material = _faceVO.material;
};
if (!_tri.material){
if (_backface){
_tri.material = _backmat;
} else {
_tri.material = _material;
};
};
if (((_tri.material) && (!(_tri.material.visible)))){
_tri.material = null;
};
if (((!(_mesh.outline)) && (!(_tri.material)))){
} else {
if (!_arg3.primitive(_tri)){
} else {
if (_mesh.pushback){
_tri.screenZ = _tri.maxZ;
};
if (_mesh.pushfront){
_tri.screenZ = _tri.minZ;
};
_tri.screenZ = (_tri.screenZ + _mesh.screenZOffset);
if (((_mesh.outline) && (!(_backface)))){
_n01 = _mesh.geometry.neighbour01(_face);
if ((((_n01 == null)) || ((front(_startIndices[_outlineIndices[_n01.faceVO]]) <= 0)))){
_segmentVO = _cameraVarsStore.createSegmentVO(_mesh.outline);
_startIndex = _screenIndices.length;
_screenIndices[_screenIndices.length] = _screenIndices[_tri.startIndex];
_screenIndices[_screenIndices.length] = _screenIndices[(_tri.startIndex + 1)];
_endIndex = _screenIndices.length;
_arg3.primitive(_drawPrimitiveStore.createDrawSegment(_arg1, _segmentVO, _mesh.outline, _screenVertices, _screenIndices, _screenCommands, _startIndex, _endIndex));
};
_n12 = _mesh.geometry.neighbour12(_face);
if ((((_n12 == null)) || ((front(_startIndices[_outlineIndices[_n12.faceVO]]) <= 0)))){
_segmentVO = _cameraVarsStore.createSegmentVO(_mesh.outline);
_startIndex = _screenIndices.length;
_screenIndices[_screenIndices.length] = _screenIndices[(_tri.startIndex + 1)];
_screenIndices[_screenIndices.length] = _screenIndices[(_tri.startIndex + 2)];
_endIndex = _screenIndices.length;
_arg3.primitive(_drawPrimitiveStore.createDrawSegment(_arg1, _segmentVO, _mesh.outline, _screenVertices, _screenIndices, _screenCommands, _startIndex, _endIndex));
};
_n20 = _mesh.geometry.neighbour20(_face);
if ((((_n20 == null)) || ((front(_startIndices[_outlineIndices[_n20.faceVO]]) <= 0)))){
_segmentVO = _cameraVarsStore.createSegmentVO(_mesh.outline);
_startIndex = _screenIndices.length;
_screenIndices[_screenIndices.length] = _screenIndices[(_tri.startIndex + 2)];
_screenIndices[_screenIndices.length] = _screenIndices[_tri.startIndex];
_endIndex = _screenIndices.length;
_arg3.primitive(_drawPrimitiveStore.createDrawSegment(_arg1, _segmentVO, _mesh.outline, _screenVertices, _screenIndices, _screenCommands, _startIndex, _endIndex));
};
};
};
};
};
};
for each (_segmentVO in _segmentVOs) {
_startIndex = _startIndices[_i++];
_endIndex = _startIndices[_i];
if (!_clipFlag){
_index = _startIndex;
while (((!((_screenVertices[(_screenIndices[_index] * 3)] == null))) && ((_index < _endIndex)))) {
_index++;
};
//unresolved if
} else {
_smaterial = ((_segmentVO.material) || (_material));
if (!_smaterial.visible){
} else {
_seg = _drawPrimitiveStore.createDrawSegment(_arg1, _segmentVO, _smaterial, _screenVertices, _screenIndices, _screenCommands, _startIndex, _endIndex, _segmentVO.generated);
if (!_arg3.primitive(_seg)){
} else {
if (_mesh.pushback){
_seg.screenZ = _seg.maxZ;
};
if (_mesh.pushfront){
_seg.screenZ = _seg.minZ;
};
_seg.screenZ = (_seg.screenZ + _mesh.screenZOffset);
};
};
};
};
for each (_spriteVO in _spriteVOs) {
_index = _startIndices[_i++];
if (((!(_clipFlag)) && ((_screenVertices[(_screenIndices[_index] * 3)] == null)))){
} else {
_spmaterial = ((_spriteVO.material) || (_material));
if (!_spmaterial.visible){
} else {
_arg3.primitive(_drawPrimitiveStore.createDrawSprite(_arg1, _spriteVO, _spmaterial, _screenVertices, _screenIndices, _index, ((_spriteVO.scaling * _zoom) / (1 + (_screenVertices[((_screenIndices[_index] * 3) + 2)] / _focus)))));
};
};
};
}
}
}//package away3d.core.project
Section 69
//MovieClipSpriteProjector (away3d.core.project.MovieClipSpriteProjector)
package away3d.core.project {
import flash.display.*;
import away3d.core.math.*;
import away3d.core.base.*;
import away3d.core.utils.*;
import away3d.core.draw.*;
import away3d.containers.*;
import away3d.sprites.*;
import away3d.cameras.lenses.*;
public class MovieClipSpriteProjector implements IPrimitiveProvider {
private var _view:View3D;
private var _drawPrimitiveStore:DrawPrimitiveStore;
private var _movieClipSprite:MovieClipSprite;
private var _lens:AbstractLens;
private var _movieclip:DisplayObject;
private var _screenVertices:Array;
private var _screenX:Number;
private var _screenY:Number;
private var _screenZ:Number;
public function get view():View3D{
return (_view);
}
public function set view(_arg1:View3D):void{
_view = _arg1;
_drawPrimitiveStore = view.drawPrimitiveStore;
}
public function primitives(_arg1:Object3D, _arg2:Matrix3D, _arg3:IPrimitiveConsumer):void{
_screenVertices = _drawPrimitiveStore.getScreenVertices(_arg1.id);
_movieClipSprite = (_arg1 as MovieClipSprite);
_lens = _view.camera.lens;
_movieclip = _movieClipSprite.movieclip;
_lens.project(_arg2, _movieClipSprite.center, _screenVertices);
_screenX = _screenVertices[0];
_screenY = _screenVertices[1];
_screenZ = (_screenVertices[2] = (_screenVertices[2] + _movieClipSprite.deltaZ));
if (_movieClipSprite.align != "none"){
switch (_movieClipSprite.align){
case "center":
_screenX = (_screenX - (_movieclip.width / 2));
_screenY = (_screenY - (_movieclip.height / 2));
break;
case "topcenter":
_screenX = (_screenX - (_movieclip.width / 2));
break;
case "bottomcenter":
_screenX = (_screenX - (_movieclip.width / 2));
_screenY = (_screenY - _movieclip.height);
break;
case "right":
_screenX = (_screenX - _movieclip.width);
_screenY = (_screenY - (_movieclip.height / 2));
break;
case "topright":
_screenX = (_screenX - _movieclip.width);
break;
case "bottomright":
_screenX = (_screenX - _movieclip.width);
_screenY = (_screenY - _movieclip.height);
break;
case "left":
_screenY = (_screenY - (_movieclip.height / 2));
break;
case "topleft":
break;
case "bottomleft":
_screenY = (_screenY - _movieclip.height);
break;
};
};
if (_movieClipSprite.rescale){
_movieclip.scaleX = (_movieclip.scaleY = ((_movieClipSprite.scaling * view.camera.zoom) / (1 + (_screenZ / view.camera.focus))));
};
_arg3.primitive(_drawPrimitiveStore.createDrawDisplayObject(_arg1, _screenX, _screenY, _screenZ, _movieClipSprite.session, _movieclip));
}
}
}//package away3d.core.project
Section 70
//ObjectContainerProjector (away3d.core.project.ObjectContainerProjector)
package away3d.core.project {
import away3d.core.math.*;
import away3d.core.base.*;
import away3d.core.utils.*;
import away3d.core.draw.*;
import away3d.containers.*;
import away3d.core.render.*;
import flash.utils.*;
public class ObjectContainerProjector extends MeshProjector implements IPrimitiveProvider {
private var _cameraViewMatrix:Matrix3D;
private var _viewTransformDictionary:Dictionary;
private var _container:ObjectContainer3D;
private var _vx:Number;
private var _vy:Number;
private var _vz:Number;
private var _depthPoint:Number3D;
public function ObjectContainerProjector(){
_depthPoint = new Number3D();
super();
}
override public function primitives(_arg1:Object3D, _arg2:Matrix3D, _arg3:IPrimitiveConsumer):void{
var _local5:Object3D;
super.primitives(_arg1, _arg2, _arg3);
_container = (_arg1 as ObjectContainer3D);
_cameraViewMatrix = _view.camera.viewMatrix;
_viewTransformDictionary = _view.cameraVarsStore.viewTransformDictionary;
var _local4:Array = _container.children;
for each (_local5 in _local4) {
if (((_local5.ownCanvas) && (_local5.visible))){
if ((_local5.ownSession is SpriteRenderSession)){
(_local5.ownSession as SpriteRenderSession).cacheAsBitmap = true;
};
_vx = _local5.screenXOffset;
_vy = _local5.screenYOffset;
if (!isNaN(_local5.ownSession.screenZ)){
_vz = _local5.ownSession.screenZ;
} else {
if (_local5.scenePivotPoint.modulo){
_depthPoint.clone(_local5.scenePivotPoint);
_depthPoint.rotate(_depthPoint, _cameraViewMatrix);
_depthPoint.add(_viewTransformDictionary[_local5].position, _depthPoint);
_vz = _depthPoint.modulo;
} else {
_vz = _viewTransformDictionary[_local5].position.modulo;
};
if (_local5.pushback){
_vz = (_vz + _local5.parentBoundingRadius);
};
if (_local5.pushfront){
_vz = (_vz - _local5.parentBoundingRadius);
};
_vz = (_vz + _local5.screenZOffset);
};
_arg3.primitive(_drawPrimitiveStore.createDrawDisplayObject(_arg1, _vx, _vy, _vz, _container.session, _local5.session.getContainer(view)));
};
};
}
}
}//package away3d.core.project
Section 71
//ProjectorType (away3d.core.project.ProjectorType)
package away3d.core.project {
public class ProjectorType {
public static const CONVEX_BLOCK:String = "ConvexBlock";
public static const DIR_SPRITE:String = "DirSprite";
public static const DOF_SPRITE:String = "DofSprite";
public static const MESH:String = "Mesh";
public static const MOVIE_CLIP_SPRITE:String = "MovieClipSprite";
public static const OBJECT_CONTAINER:String = "ObjectContainer";
public static const SPRITE:String = "Sprite";
}
}//package away3d.core.project
Section 72
//SpriteProjector (away3d.core.project.SpriteProjector)
package away3d.core.project {
import away3d.core.math.*;
import away3d.core.base.*;
import away3d.core.utils.*;
import away3d.core.draw.*;
import away3d.containers.*;
import away3d.sprites.*;
import away3d.cameras.lenses.*;
public class SpriteProjector implements IPrimitiveProvider {
private var _view:View3D;
private var _drawPrimitiveStore:DrawPrimitiveStore;
private var _screenVertices:Array;
private var _sprite:Sprite2D;
private var _lens:AbstractLens;
public function get view():View3D{
return (_view);
}
public function set view(_arg1:View3D):void{
_view = _arg1;
_drawPrimitiveStore = view.drawPrimitiveStore;
}
public function primitives(_arg1:Object3D, _arg2:Matrix3D, _arg3:IPrimitiveConsumer):void{
_screenVertices = _drawPrimitiveStore.getScreenVertices(_arg1.id);
_sprite = (_arg1 as Sprite2D);
_lens = _view.camera.lens;
_lens.project(_arg2, _sprite.center, _screenVertices);
if (_screenVertices[0] == null){
return;
};
_screenVertices[2] = (_screenVertices[2] + _sprite.deltaZ);
_arg3.primitive(_drawPrimitiveStore.createDrawScaledBitmap(_arg1, _screenVertices, _sprite.smooth, _sprite.bitmap, ((_sprite.scaling * _view.camera.zoom) / (1 + (_screenVertices[2] / _view.camera.focus))), _sprite.rotation));
}
}
}//package away3d.core.project
Section 73
//AbstractRenderSession (away3d.core.render.AbstractRenderSession)
package away3d.core.render {
import flash.display.*;
import flash.events.*;
import away3d.core.light.*;
import away3d.core.base.*;
import away3d.materials.*;
import away3d.core.draw.*;
import away3d.containers.*;
import flash.utils.*;
import away3d.core.clip.*;
import away3d.events.*;
import flash.geom.*;
public class AbstractRenderSession extends EventDispatcher {
var _containers:Dictionary;
var _shape:Shape;
var _sprite:Sprite;
var _level:int;// = -1
var _material:Material;
var _renderSource:Object3D;
var _layerDirty:Boolean;
var _shapeStore:Array;
var _shapeActive:Array;
var _spriteStore:Array;
var _spriteActive:Array;
private var _consumer:IPrimitiveConsumer;
private var _shapeStores:Dictionary;
private var _shapeActives:Dictionary;
private var _spriteStores:Dictionary;
private var _spriteActives:Dictionary;
private var _spriteLayers:Dictionary;
private var _spriteLayer:Dictionary;
private var _shapeLayers:Dictionary;
private var _shapeLayer:Dictionary;
private var _lightShapeLayers:Dictionary;
private var _lightShapeLayer:Dictionary;
private var _dictionary:Dictionary;
private var _array:Array;
private var _defaultColorTransform:ColorTransform;
private var _layerGraphics:Graphics;
private var _renderers:Dictionary;
private var _renderer:IPrimitiveConsumer;
private var _session:AbstractRenderSession;
private var _sessionupdated:SessionEvent;
private var a:Number;
private var b:Number;
private var c:Number;
private var d:Number;
private var tx:Number;
private var ty:Number;
private var _i:int;
private var _index0:int;
private var _index1:int;
private var _index2:int;
private var v0x:Number;
private var v0y:Number;
private var v1x:Number;
private var v1y:Number;
private var v2x:Number;
private var v2y:Number;
private var a2:Number;
private var b2:Number;
private var c2:Number;
private var d2:Number;
private var m:Matrix;
private var area:Number;
protected var i:int;
public var layer:DisplayObject;
public var parent:AbstractRenderSession;
public var updated:Boolean;
public var primitives:Array;
public var screenZ:Number;
public var filters:Array;
public var alpha:Number;// = 1
public var blendMode:String;
public var sessions:Array;
public var graphics:Graphics;
public var priconsumers:Dictionary;
public var consumer:IPrimitiveConsumer;
public function AbstractRenderSession(){
_containers = new Dictionary(true);
_shapeStores = new Dictionary(true);
_shapeActives = new Dictionary(true);
_spriteStores = new Dictionary(true);
_spriteActives = new Dictionary(true);
_spriteLayers = new Dictionary(true);
_shapeLayers = new Dictionary(true);
_lightShapeLayers = new Dictionary(true);
_defaultColorTransform = new ColorTransform();
_renderers = new Dictionary(true);
m = new Matrix();
sessions = new Array();
priconsumers = new Dictionary(true);
super();
}
function notifySessionUpdate():void{
if (!hasEventListener(SessionEvent.SESSION_UPDATED)){
return;
};
if (!_sessionupdated){
_sessionupdated = new SessionEvent(SessionEvent.SESSION_UPDATED, this);
};
dispatchEvent(_sessionupdated);
}
function internalAddSceneSession(_arg1:AbstractRenderSession):void{
sessions = [_arg1];
_arg1.addOnSessionUpdate(onSessionUpdate);
}
function internalRemoveSceneSession(_arg1:AbstractRenderSession):void{
sessions = [];
_arg1.removeOnSessionUpdate(onSessionUpdate);
}
function internalAddOwnSession(_arg1:Object3D):void{
_arg1.addEventListener(Object3DEvent.SESSION_UPDATED, onObjectSessionUpdate);
}
function internalRemoveOwnSession(_arg1:Object3D):void{
_arg1.removeEventListener(Object3DEvent.SESSION_UPDATED, onObjectSessionUpdate);
}
private function onObjectSessionUpdate(_arg1:Object3DEvent):void{
notifySessionUpdate();
}
private function getShapeStore(_arg1:View3D):Array{
if (!_shapeStores[_arg1]){
return ((_shapeStores[_arg1] = new Array()));
};
return (_shapeStores[_arg1]);
}
private function getShapeActive(_arg1:View3D):Array{
if (!_shapeActives[_arg1]){
return ((_shapeActives[_arg1] = new Array()));
};
return (_shapeActives[_arg1]);
}
private function getSpriteStore(_arg1:View3D):Array{
if (!_spriteStores[_arg1]){
return ((_spriteStores[_arg1] = new Array()));
};
return (_spriteStores[_arg1]);
}
private function getSpriteActive(_arg1:View3D):Array{
if (!_spriteActives[_arg1]){
return ((_spriteActives[_arg1] = new Array()));
};
return (_spriteActives[_arg1]);
}
public function getSpriteLayer(_arg1:View3D):Dictionary{
if (!_spriteLayers[_arg1]){
return ((_spriteLayers[_arg1] = new Dictionary(true)));
};
return (_spriteLayers[_arg1]);
}
public function getShapeLayer(_arg1:View3D):Dictionary{
if (!_shapeLayers[_arg1]){
return ((_shapeLayers[_arg1] = new Dictionary(true)));
};
return (_shapeLayers[_arg1]);
}
public function getLightShapeLayer(_arg1:View3D):Dictionary{
if (!_lightShapeLayers[_arg1]){
return ((_lightShapeLayers[_arg1] = new Dictionary(true)));
};
return (_lightShapeLayers[_arg1]);
}
protected function onSessionUpdate(_arg1:SessionEvent):void{
dispatchEvent(_arg1);
}
public function get renderer():IPrimitiveConsumer{
return (_renderer);
}
public function set renderer(_arg1:IPrimitiveConsumer):void{
var _local2:AbstractRenderSession;
if (_renderer == _arg1){
return;
};
_renderer = _arg1;
clearRenderers();
for each (_local2 in sessions) {
_local2.clearRenderers();
};
}
public function addChildSession(_arg1:AbstractRenderSession):void{
if (sessions.indexOf(_arg1) != -1){
return;
};
sessions.push(_arg1);
_arg1.addOnSessionUpdate(onSessionUpdate);
_arg1.parent = this;
}
public function removeChildSession(_arg1:AbstractRenderSession):void{
_arg1.removeOnSessionUpdate(onSessionUpdate);
var _local2:int = sessions.indexOf(_arg1);
if (_local2 == -1){
return;
};
sessions.splice(_local2, 1);
}
public function clearChildSessions():void{
for each (_session in sessions) {
_session.removeOnSessionUpdate(onSessionUpdate);
};
sessions = new Array();
}
protected function createLayer():void{
throw (new Error("Not implemented"));
}
public function getContainer(_arg1:View3D):DisplayObject{
throw (new Error("Not implemented"));
}
public function getConsumer(_arg1:View3D):IPrimitiveConsumer{
if (_renderers[_arg1]){
return (_renderers[_arg1]);
};
if (_renderer){
return ((_renderers[_arg1] = _renderer.clone()));
};
if (parent){
return ((_renderers[_arg1] = parent.getConsumer(_arg1).clone()));
};
return ((_renderers[_arg1] = (_arg1.session.renderer as IPrimitiveConsumer).clone()));
}
public function getTotalFaces(_arg1:View3D):int{
var _local2:int = getConsumer(_arg1).list().length;
for each (_session in sessions) {
_local2 = (_local2 + _session.getTotalFaces(_arg1));
};
return (_local2);
}
public function clear(_arg1:View3D):void{
updated = ((((_arg1.updated) || (_arg1.forceUpdate))) || (_arg1.scene.updatedSessions[this]));
for each (_session in sessions) {
_session.clear(_arg1);
};
if (updated){
_consumer = getConsumer(_arg1);
_spriteLayer = getSpriteLayer(_arg1);
for each (_array in _spriteLayer) {
_array.length = 0;
};
_shapeLayer = getShapeLayer(_arg1);
for each (_array in _shapeLayer) {
_array.length = 0;
};
_lightShapeLayer = getLightShapeLayer(_arg1);
for each (_dictionary in _lightShapeLayer) {
for each (_array in _dictionary) {
_array.length = 0;
};
};
_level = -1;
_shapeStore = getShapeStore(_arg1);
_shapeActive = getShapeActive(_arg1);
i = _shapeActive.length;
while (i--) {
_shape = _shapeActive.pop();
_shape.graphics.clear();
_shape.filters = [];
_shape.blendMode = BlendMode.NORMAL;
_shape.transform.colorTransform = _defaultColorTransform;
_shapeStore.push(_shape);
};
_spriteStore = getSpriteStore(_arg1);
_spriteActive = getSpriteActive(_arg1);
i = _spriteActive.length;
while (i--) {
_sprite = _spriteActive.pop();
_sprite.graphics.clear();
_sprite.filters = [];
while (_sprite.numChildren) {
_sprite.removeChildAt(0);
};
_spriteStore.push(_sprite);
};
_consumer.clear(_arg1);
};
}
public function render(_arg1:View3D):void{
for each (_session in sessions) {
_session.render(_arg1);
};
if (updated){
(getConsumer(_arg1) as IRenderer).render(_arg1);
};
}
public function clearRenderers():void{
_renderers = new Dictionary(true);
}
public function addDisplayObject(_arg1:DisplayObject):void{
throw (new Error("Not implemented"));
}
public function getSprite(_arg1:LayerMaterial, _arg2:int, _arg3:Sprite=null):Sprite{
if (!(_array = _spriteLayer[_arg1])){
_array = (_spriteLayer[_arg1] = new Array());
};
if (((!(_arg3)) && (!((_arg1 == _material))))){
_level = -1;
_material = _arg1;
};
if ((((_level >= _arg2)) && (_array.length))){
_sprite = _array[0];
} else {
_level = _arg2;
_array.unshift((_sprite = createSprite(_arg3)));
};
return (_sprite);
}
public function getShape(_arg1:LayerMaterial, _arg2:int, _arg3:Sprite):Shape{
if (!(_array = _shapeLayer[_arg1])){
_array = (_shapeLayer[_arg1] = new Array());
};
if ((((_level >= _arg2)) && (_array.length))){
_shape = _array[0];
} else {
_level = _arg2;
_array.unshift((_shape = createShape(_arg3)));
};
return (_shape);
}
public function getLightShape(_arg1:LayerMaterial, _arg2:int, _arg3:Sprite, _arg4:LightPrimitive):Shape{
if (!(_dictionary = _lightShapeLayer[_arg1])){
_dictionary = (_lightShapeLayer[_arg1] = new Dictionary(true));
};
if (!(_array = _dictionary[_arg4])){
_array = (_dictionary[_arg4] = new Array());
};
if ((((_level >= _arg2)) && (_array.length))){
_shape = _array[0];
} else {
_level = _arg2;
_array.unshift((_shape = createShape(_arg3)));
};
return (_shape);
}
protected function createSprite(_arg1:Sprite=null):Sprite{
throw (new Error("Not implemented"));
}
protected function createShape(_arg1:Sprite):Shape{
if (_shapeStore.length){
_shapeActive.push((_shape = _shapeStore.pop()));
} else {
_shapeActive.push((_shape = new Shape()));
};
_arg1.addChild(_shape);
_layerDirty = true;
return (_shape);
}
public function renderBitmap(_arg1:BitmapData, _arg2:ScreenVertex, _arg3:Boolean=false):void{
if (_layerDirty){
createLayer();
};
m.identity();
m.tx = (_arg2.x - (_arg1.width / 2));
m.ty = (_arg2.y - (_arg1.height / 2));
graphics.lineStyle();
graphics.beginBitmapFill(_arg1, m, false, _arg3);
graphics.drawRect((_arg2.x - (_arg1.width / 2)), (_arg2.y - (_arg1.height / 2)), _arg1.width, _arg1.height);
graphics.endFill();
}
public function renderScaledBitmap(_arg1:DrawScaledBitmap, _arg2:BitmapData, _arg3:Matrix, _arg4:Boolean=false):void{
if (_layerDirty){
createLayer();
};
graphics.lineStyle();
if (_arg1.rotation != 0){
graphics.beginBitmapFill(_arg2, _arg3, false, _arg4);
graphics.moveTo(_arg1.topleftx, _arg1.toplefty);
graphics.lineTo(_arg1.toprightx, _arg1.toprighty);
graphics.lineTo(_arg1.bottomrightx, _arg1.bottomrighty);
graphics.lineTo(_arg1.bottomleftx, _arg1.bottomlefty);
graphics.lineTo(_arg1.topleftx, _arg1.toplefty);
graphics.endFill();
} else {
graphics.beginBitmapFill(_arg2, _arg3, false, _arg4);
graphics.drawRect(_arg1.minX, _arg1.minY, (_arg1.maxX - _arg1.minX), (_arg1.maxY - _arg1.minY));
graphics.endFill();
};
}
public function renderLine(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:uint, _arg7:Number):void{
if (_layerDirty){
createLayer();
};
graphics.lineStyle(_arg5, _arg6, _arg7);
graphics.moveTo(_arg1, _arg2);
graphics.lineTo(_arg3, _arg4);
}
public function renderTriangleBitmap(_arg1:BitmapData, _arg2:Matrix, _arg3:Array, _arg4:Array, _arg5:Number, _arg6:Number, _arg7:Boolean, _arg8:Boolean, _arg9:Graphics=null):void{
if (((!(_arg9)) && (_layerDirty))){
createLayer();
};
_index0 = (_arg4[_arg5] * 3);
_index1 = (_arg4[(_arg5 + 1)] * 3);
_index2 = (_arg4[(_arg5 + 2)] * 3);
a2 = ((v1x = _arg3[_index1]) - (v0x = _arg3[_index0]));
b2 = ((v1y = _arg3[(_index1 + 1)]) - (v0y = _arg3[(_index0 + 1)]));
c2 = ((v2x = _arg3[_index2]) - v0x);
d2 = ((v2y = _arg3[(_index2 + 1)]) - v0y);
m.a = (((a = _arg2.a) * a2) + ((b = _arg2.b) * c2));
m.b = ((a * b2) + (b * d2));
m.c = (((c = _arg2.c) * a2) + ((d = _arg2.d) * c2));
m.d = ((c * b2) + (d * d2));
m.tx = ((((tx = _arg2.tx) * a2) + ((ty = _arg2.ty) * c2)) + v0x);
m.ty = (((tx * b2) + (ty * d2)) + v0y);
area = (((v0x * (d2 - b2)) - (v1x * d2)) + (v2x * b2));
if (area < 0){
area = -(area);
};
if (_arg9){
_arg9.lineStyle();
_arg9.moveTo(v0x, v0y);
_arg9.beginBitmapFill(_arg1, m, _arg8, ((_arg7) && ((area > 400))));
_arg9.lineTo(v1x, v1y);
_arg9.lineTo(v2x, v2y);
_arg9.endFill();
} else {
graphics.lineStyle();
graphics.moveTo(v0x, v0y);
graphics.beginBitmapFill(_arg1, m, _arg8, ((_arg7) && ((area > 400))));
graphics.lineTo(v1x, v1y);
graphics.lineTo(v2x, v2y);
graphics.endFill();
};
}
public function renderTriangleBitmapMask(_arg1:BitmapData, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Array, _arg6:Array, _arg7:Number, _arg8:Number, _arg9:Boolean, _arg10:Boolean, _arg11:Graphics=null):void{
if (_layerDirty){
createLayer();
};
_index0 = (_arg6[_arg7] * 3);
_index1 = (_arg6[(_arg7 + 1)] * 3);
_index2 = (_arg6[(_arg7 + 2)] * 3);
a2 = ((v1x = _arg5[_index1]) - (v0x = _arg5[_index0]));
b2 = ((v1y = _arg5[(_index1 + 1)]) - (v0y = _arg5[(_index0 + 1)]));
c2 = ((v2x = _arg5[_index2]) - v0x);
d2 = ((v2y = _arg5[(_index2 + 1)]) - v0y);
m.identity();
m.scale(_arg4, _arg4);
m.translate(_arg2, _arg3);
if (_arg11){
_arg11.lineStyle();
_arg11.moveTo(v0x, v0y);
_arg11.beginBitmapFill(_arg1, m, _arg10, ((_arg9) && (((((v0x * (d2 - b2)) - (v1x * d2)) + (v2x * b2)) > 400))));
_arg11.lineTo(v1x, v1y);
_arg11.lineTo(v2x, v2y);
_arg11.endFill();
} else {
graphics.lineStyle();
graphics.moveTo(v0x, v0y);
graphics.beginBitmapFill(_arg1, m, _arg10, ((_arg9) && (((((v0x * (d2 - b2)) - (v1x * d2)) + (v2x * b2)) > 400))));
graphics.lineTo(v1x, v1y);
graphics.lineTo(v2x, v2y);
graphics.endFill();
};
}
public function renderDot(_arg1:int, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Graphics=null, _arg6:int=1):void{
var _local8:Number;
if (((!(_arg5)) && (_layerDirty))){
createLayer();
};
var _local7:Graphics = (_arg5) ? _arg5 : graphics;
_local7.lineStyle();
_local7.beginFill(_arg1, _arg2);
if (_arg6 == 1){
_local7.drawRect(_arg3, _arg4, _arg6, _arg6);
} else {
_local8 = (_arg6 * 0.5);
_local7.drawRect((_arg3 - _local8), (_arg4 - _local8), _arg6, _arg6);
};
_local7.endFill();
}
public function renderTriangleColor(_arg1:int, _arg2:Number, _arg3:Array, _arg4:Array, _arg5:Array, _arg6:Number, _arg7:Number, _arg8:Graphics=null):void{
if (((!(_arg8)) && (_layerDirty))){
createLayer();
};
var _local9:Graphics = (_arg8) ? _arg8 : graphics;
if ((_arg7 - _arg6) > 3){
_local9.lineStyle();
_i = _arg6;
while (_i < _arg7) {
_index0 = (_arg5[_i] * 3);
switch (_arg4[_i++]){
case "M":
_local9.moveTo(_arg3[_index0], _arg3[(_index0 + 1)]);
if ((_i - 1) == _arg6){
_local9.beginFill(_arg1, _arg2);
};
break;
case "L":
_local9.lineTo(_arg3[_index0], _arg3[(_index0 + 1)]);
break;
case "C":
_index1 = (_arg5[_i++] * 3);
_local9.curveTo(_arg3[_index0], _arg3[(_index0 + 1)], _arg3[_index1], _arg3[(_index1 + 1)]);
break;
};
};
_local9.endFill();
} else {
_index0 = (_arg5[_arg6] * 3);
_index1 = (_arg5[(_arg6 + 1)] * 3);
_index2 = (_arg5[(_arg6 + 2)] * 3);
_local9.lineStyle();
_local9.moveTo(_arg3[_index0], _arg3[(_index0 + 1)]);
_local9.beginFill(_arg1, _arg2);
_local9.lineTo(_arg3[_index1], _arg3[(_index1 + 1)]);
_local9.lineTo(_arg3[_index2], _arg3[(_index2 + 1)]);
_local9.endFill();
};
}
public function renderTriangleLine(_arg1:Number, _arg2:int, _arg3:Number, _arg4:Array, _arg5:Array, _arg6:Array, _arg7:Number, _arg8:Number):void{
if (_layerDirty){
createLayer();
};
graphics.lineStyle(_arg1, _arg2, _arg3);
if ((_arg8 - _arg7) > 3){
while (_arg7 < _arg8) {
_index0 = (_arg6[_arg7] * 3);
switch (_arg5[_temp2]){
case "M":
graphics.moveTo(_arg4[_index0], _arg4[(_index0 + 1)]);
break;
case "L":
graphics.lineTo(_arg4[_index0], _arg4[(_index0 + 1)]);
break;
case "C":
var _temp1 = _arg7;
_arg7 = (_arg7 + 1);
_index1 = (_arg6[_temp1] * 3);
graphics.curveTo(_arg4[_index0], _arg4[(_index0 + 1)], _arg4[_index1], _arg4[(_index1 + 1)]);
break;
};
};
} else {
if ((_arg8 - _arg7) > 2){
_index0 = (_arg6[_arg7] * 3);
_index1 = (_arg6[(_arg7 + 1)] * 3);
_index2 = (_arg6[(_arg7 + 2)] * 3);
graphics.moveTo((v0x = _arg4[_index0]), (v0y = _arg4[(_index0 + 1)]));
graphics.lineTo(_arg4[_index1], _arg4[(_index1 + 1)]);
graphics.lineTo(_arg4[_index2], _arg4[(_index2 + 1)]);
graphics.lineTo(v0x, v0y);
} else {
_index0 = (_arg6[_arg7] * 3);
_index1 = (_arg6[(_arg7 + 1)] * 3);
graphics.moveTo(_arg4[_index0], _arg4[(_index0 + 1)]);
graphics.lineTo(_arg4[_index1], _arg4[(_index1 + 1)]);
};
};
}
public function renderTriangleLineFill(_arg1:Number, _arg2:int, _arg3:Number, _arg4:int, _arg5:Number, _arg6:Array, _arg7:Array, _arg8:Array, _arg9:int, _arg10:int):void{
if (_layerDirty){
createLayer();
};
if (_arg5 > 0){
graphics.lineStyle(_arg1, _arg4, _arg5);
} else {
graphics.lineStyle();
};
if ((_arg10 - _arg9) > 3){
_i = _arg9;
while (_i < _arg10) {
_index0 = (_arg8[_i] * 3);
switch (_arg7[_i++]){
case "M":
graphics.moveTo(_arg6[_index0], _arg6[(_index0 + 1)]);
if (((((_i - 1) == _arg9)) && ((_arg3 > 0)))){
graphics.beginFill(_arg2, _arg3);
};
break;
case "L":
graphics.lineTo(_arg6[_index0], _arg6[(_index0 + 1)]);
break;
case "C":
_index1 = (_arg8[_i++] * 3);
graphics.curveTo(_arg6[_index0], _arg6[(_index0 + 1)], _arg6[_index1], _arg6[(_index1 + 1)]);
break;
};
};
} else {
_index0 = (_arg8[_arg9] * 3);
_index1 = (_arg8[(_arg9 + 1)] * 3);
_index2 = (_arg8[(_arg9 + 2)] * 3);
graphics.moveTo((v0x = _arg6[_index0]), (v0y = _arg6[(_index0 + 1)]));
if (_arg3 > 0){
graphics.beginFill(_arg2, _arg3);
};
graphics.lineTo(_arg6[_index1], _arg6[(_index1 + 1)]);
graphics.lineTo(_arg6[_index2], _arg6[(_index2 + 1)]);
if (_arg5 > 0){
graphics.lineTo(v0x, v0y);
};
};
if (_arg3 > 0){
graphics.endFill();
};
}
public function renderSpriteColor(_arg1:int, _arg2:Number, _arg3:DrawSprite):void{
if (_layerDirty){
createLayer();
};
if (_arg3.rotation != 0){
graphics.beginFill(_arg1, _arg2);
graphics.moveTo(_arg3.topleftx, _arg3.toplefty);
graphics.lineTo(_arg3.toprightx, _arg3.toprighty);
graphics.lineTo(_arg3.bottomrightx, _arg3.bottomrighty);
graphics.lineTo(_arg3.bottomleftx, _arg3.bottomlefty);
graphics.lineTo(_arg3.topleftx, _arg3.toplefty);
graphics.endFill();
} else {
graphics.beginFill(_arg1, _arg2);
graphics.drawRect(_arg3.minX, _arg3.minY, (_arg3.maxX - _arg3.minX), (_arg3.maxY - _arg3.minY));
graphics.endFill();
};
}
public function renderSpriteBitmap(_arg1:BitmapData, _arg2:DrawSprite, _arg3:Boolean):void{
if (_layerDirty){
createLayer();
};
if (_arg2.rotation != 0){
graphics.beginBitmapFill(_arg1, _arg2.mapping, false, _arg3);
graphics.moveTo(_arg2.topleftx, _arg2.toplefty);
graphics.lineTo(_arg2.toprightx, _arg2.toprighty);
graphics.lineTo(_arg2.bottomrightx, _arg2.bottomrighty);
graphics.lineTo(_arg2.bottomleftx, _arg2.bottomlefty);
graphics.lineTo(_arg2.topleftx, _arg2.toplefty);
graphics.endFill();
} else {
graphics.beginBitmapFill(_arg1, _arg2.mapping, false, _arg3);
graphics.drawRect(_arg2.minX, _arg2.minY, (_arg2.maxX - _arg2.minX), (_arg2.maxY - _arg2.minY));
graphics.endFill();
};
}
public function renderFogColor(_arg1:Clipping, _arg2:int, _arg3:Number):void{
if (_layerDirty){
createLayer();
};
graphics.lineStyle();
graphics.beginFill(_arg2, _arg3);
graphics.drawRect(_arg1.minX, _arg1.minY, (_arg1.maxX - _arg1.minX), (_arg1.maxY - _arg1.minY));
graphics.endFill();
}
public function clone():AbstractRenderSession{
throw (new Error("Not implemented"));
}
public function addOnSessionUpdate(_arg1:Function):void{
addEventListener(SessionEvent.SESSION_UPDATED, _arg1, false, 0, false);
}
public function removeOnSessionUpdate(_arg1:Function):void{
removeEventListener(SessionEvent.SESSION_UPDATED, _arg1, false);
}
}
}//package away3d.core.render
Section 74
//BasicRenderer (away3d.core.render.BasicRenderer)
package away3d.core.render {
import away3d.core.draw.*;
import away3d.containers.*;
import away3d.core.block.*;
import away3d.cameras.*;
import away3d.core.clip.*;
import away3d.core.filter.*;
public class BasicRenderer implements IRenderer, IPrimitiveConsumer {
private var _filters:Array;
private var _filter:IPrimitiveFilter;
private var _primitives:Array;
private var _primitive:DrawPrimitive;
private var _scene:Scene3D;
private var _camera:Camera3D;
private var _screenClipping:Clipping;
private var _blockers:Array;
public function BasicRenderer(... _args){
_primitives = new Array();
super();
_filters = _args;
_filters.push(new ZSortFilter());
}
public function get filters():Array{
return (_filters.slice(0, (_filters.length - 1)));
}
public function set filters(_arg1:Array):void{
_filters = _arg1;
_filters.push(new ZSortFilter());
}
public function primitive(_arg1:DrawPrimitive):Boolean{
var _local2:Blocker;
if (!_screenClipping.checkPrimitive(_arg1)){
return (false);
};
for each (_local2 in _blockers) {
if (_local2.screenZ > _arg1.minZ){
} else {
if (_local2.block(_arg1)){
return (false);
};
};
};
_primitives.push(_arg1);
return (true);
}
public function list():Array{
return (_primitives);
}
public function clear(_arg1:View3D):void{
_primitives.length = 0;
_scene = _arg1.scene;
_camera = _arg1.camera;
_screenClipping = _arg1.screenClipping;
_blockers = _arg1.blockerarray.list();
}
public function render(_arg1:View3D):void{
for each (_filter in _filters) {
_primitives = _filter.filter(_primitives, _scene, _camera, _screenClipping);
};
for each (_primitive in _primitives) {
_primitive.render();
};
}
public function toString():String{
return ((("Basic [" + _filters.join("+")) + "]"));
}
public function clone():IPrimitiveConsumer{
var _local1:BasicRenderer = new BasicRenderer();
_local1.filters = filters;
return (_local1);
}
}
}//package away3d.core.render
Section 75
//BitmapRenderSession (away3d.core.render.BitmapRenderSession)
package away3d.core.render {
import flash.display.*;
import away3d.containers.*;
import flash.utils.*;
import flash.geom.*;
public class BitmapRenderSession extends AbstractRenderSession {
private var _container:Sprite;
private var _bitmapContainer:Bitmap;
private var _bitmapContainers:Dictionary;
private var _width:int;
private var _height:int;
private var _bitmapwidth:int;
private var _bitmapheight:int;
private var _scale:Number;
private var _cm:Matrix;
private var _cx:Number;
private var _cy:Number;
private var _base:BitmapData;
private var layers:Array;
public function BitmapRenderSession(_arg1:Number=2){
_bitmapContainers = new Dictionary(true);
layers = new Array();
super();
if (_scale <= 0){
throw (new Error("scale cannot be negative or zero"));
};
_scale = _arg1;
}
override public function getContainer(_arg1:View3D):DisplayObject{
_bitmapContainer = getBitmapContainer(_arg1);
if (!_containers[_arg1]){
_container = (_containers[_arg1] = new Sprite());
_container.addChild(_bitmapContainer);
return (_container);
};
return (_containers[_arg1]);
}
public function getBitmapContainer(_arg1:View3D):Bitmap{
if (!_bitmapContainers[_arg1]){
return ((_bitmapContainers[_arg1] = new Bitmap()));
};
return (_bitmapContainers[_arg1]);
}
public function getBitmapData(_arg1:View3D):BitmapData{
_container = (getContainer(_arg1) as Sprite);
if (!_bitmapContainer.bitmapData){
_bitmapwidth = int(((_width = (_arg1.screenClipping.maxX - _arg1.screenClipping.minX)) / _scale));
_bitmapheight = int(((_height = (_arg1.screenClipping.maxY - _arg1.screenClipping.minY)) / _scale));
return ((_bitmapContainer.bitmapData = new BitmapData(_bitmapwidth, _bitmapheight, true, 0)));
};
return (_bitmapContainer.bitmapData);
}
override public function addDisplayObject(_arg1:DisplayObject):void{
layers.push(_arg1);
_arg1.visible = true;
_layerDirty = true;
}
override protected function createSprite(_arg1:Sprite=null):Sprite{
if (_spriteStore.length){
_spriteActive.push((_sprite = _spriteStore.pop()));
} else {
_spriteActive.push((_sprite = new Sprite()));
};
if (_arg1){
_arg1.addChild(_sprite);
} else {
layers.push(_sprite);
};
_layerDirty = true;
return (_sprite);
}
override protected function createLayer():void{
if (_shapeStore.length){
_shapeActive.push((_shape = _shapeStore.pop()));
} else {
_shapeActive.push((_shape = new Shape()));
};
layer = _shape;
graphics = _shape.graphics;
layers.push(_shape);
_layerDirty = false;
}
override public function clear(_arg1:View3D):void{
super.clear(_arg1);
if (updated){
_base = getBitmapData(_arg1);
_cx = (_bitmapContainer.x = _arg1.screenClipping.minX);
_cy = (_bitmapContainer.y = _arg1.screenClipping.minY);
_bitmapContainer.scaleX = _scale;
_bitmapContainer.scaleY = _scale;
_cm = new Matrix();
_cm.scale((1 / _scale), (1 / _scale));
_cm.translate((-(_arg1.screenClipping.minX) / _scale), (-(_arg1.screenClipping.minY) / _scale));
_base.lock();
_base.fillRect(_base.rect, 0);
layers.length = 0;
_layerDirty = true;
layer = null;
};
if (((((filters) && (filters.length))) || (((_bitmapContainer.filters) && (_bitmapContainer.filters.length))))){
_bitmapContainer.filters = filters;
};
_bitmapContainer.alpha = ((alpha) || (1));
_bitmapContainer.blendMode = ((blendMode) || (BlendMode.NORMAL));
}
override public function render(_arg1:View3D):void{
var _local2:DisplayObject;
super.render(_arg1);
if (updated){
for each (_local2 in layers) {
_base.draw(_local2, _cm, _local2.transform.colorTransform, _local2.blendMode, _base.rect);
};
_base.unlock();
};
}
override public function clone():AbstractRenderSession{
return (new BitmapRenderSession(_scale));
}
}
}//package away3d.core.render
Section 76
//BSPRenderer (away3d.core.render.BSPRenderer)
package away3d.core.render {
import away3d.core.draw.*;
import away3d.containers.*;
import away3d.core.block.*;
import away3d.cameras.*;
import away3d.core.clip.*;
import away3d.core.filter.*;
public class BSPRenderer implements IRenderer, IPrimitiveConsumer {
private var _filters:Array;
private var _filter:IPrimitiveFilter;
private var _primitives:Array;
private var _newPrimitives:Array;
private var _scene:Scene3D;
private var _camera:Camera3D;
private var _screenClipping:Clipping;
private var _blockers:Array;
private var _sorting:Boolean;
public function BSPRenderer(... _args){
_primitives = new Array();
_newPrimitives = new Array();
super();
_filters = _args;
_filters.push(new ZSortFilter());
}
public function get filters():Array{
return (_filters.slice(0, (_filters.length - 1)));
}
public function set filters(_arg1:Array):void{
_filters = _arg1;
_filters.push(new ZSortFilter());
}
public function primitive(_arg1:DrawPrimitive):Boolean{
if (!_screenClipping.checkPrimitive(_arg1)){
return (false);
};
if (_arg1.ignoreSort){
if (_sorting){
for each (_filter in _filters) {
_newPrimitives = _filter.filter(_newPrimitives, _scene, _camera, _screenClipping);
};
_primitives = _primitives.concat(_newPrimitives);
_newPrimitives.length = 0;
_sorting = false;
};
_primitives.push(_arg1);
} else {
_sorting = true;
_newPrimitives.push(_arg1);
};
return (true);
}
public function list():Array{
return (_primitives);
}
public function clear(_arg1:View3D):void{
_primitives.length = 0;
_scene = _arg1.scene;
_camera = _arg1.camera;
_screenClipping = _arg1.screenClipping;
_blockers = _arg1.blockerarray.list();
}
public function render(_arg1:View3D):void{
var _local2:int;
var _local3:int;
if (_sorting){
for each (_filter in _filters) {
_newPrimitives = _filter.filter(_newPrimitives, _scene, _camera, _screenClipping);
};
_primitives = _primitives.concat(_newPrimitives);
_newPrimitives.length = 0;
};
_sorting = false;
_local2 = -1;
_local3 = _primitives.length;
while (++_local2 < _local3) {
DrawPrimitive(_primitives[_local2]).render();
};
}
public function toString():String{
return ("BSPRenderer");
}
public function clone():IPrimitiveConsumer{
return (new BSPRenderer());
}
}
}//package away3d.core.render
Section 77
//IRenderer (away3d.core.render.IRenderer)
package away3d.core.render {
import away3d.containers.*;
public interface IRenderer {
function render(_arg1:View3D):void;
function toString():String;
}
}//package away3d.core.render
Section 78
//SpriteRenderSession (away3d.core.render.SpriteRenderSession)
package away3d.core.render {
import flash.display.*;
import away3d.containers.*;
import away3d.core.clip.*;
import away3d.events.*;
import flash.geom.*;
public class SpriteRenderSession extends AbstractRenderSession {
private var _container:Sprite;
private var _clip:Clipping;
public var cacheAsBitmap:Boolean;
public function SpriteRenderSession():void{
}
override protected function onSessionUpdate(_arg1:SessionEvent):void{
super.onSessionUpdate(_arg1);
cacheAsBitmap = false;
}
override public function getContainer(_arg1:View3D):DisplayObject{
if (!_containers[_arg1]){
return ((_containers[_arg1] = new Sprite()));
};
return (_containers[_arg1]);
}
override public function addDisplayObject(_arg1:DisplayObject):void{
_container.addChild(_arg1);
_arg1.visible = true;
layer = null;
_level = -1;
_layerDirty = true;
}
override protected function createSprite(_arg1:Sprite=null):Sprite{
if (_spriteStore.length){
_spriteActive.push((_sprite = _spriteStore.pop()));
} else {
_spriteActive.push((_sprite = new Sprite()));
};
if (_arg1){
_arg1.addChild(_sprite);
} else {
_container.addChild(_sprite);
layer = _sprite;
};
_layerDirty = true;
return (_sprite);
}
override protected function createLayer():void{
if (_shapeStore.length){
_shapeActive.push((_shape = _shapeStore.pop()));
} else {
_shapeActive.push((_shape = new Shape()));
};
layer = _shape;
graphics = _shape.graphics;
_container.addChild(_shape);
_layerDirty = false;
_level = -1;
}
override public function clear(_arg1:View3D):void{
super.clear(_arg1);
_container = (getContainer(_arg1) as Sprite);
if (updated){
layer = _container;
graphics = _container.graphics;
if (this == _arg1.session){
_clip = _arg1.screenClipping;
_container.scrollRect = new Rectangle((_clip.minX - 1), (_clip.minY - 1), ((_clip.maxX - _clip.minX) + 2), ((_clip.maxY - _clip.minY) + 2));
_container.x = (_clip.minX - 1);
_container.y = (_clip.minY - 1);
};
_container.cacheAsBitmap = false;
graphics.clear();
while (_container.numChildren) {
_container.removeChildAt(0);
};
} else {
_container.cacheAsBitmap = cacheAsBitmap;
};
if (((((filters) && (filters.length))) || (((_container.filters) && (_container.filters.length))))){
_container.filters = filters;
};
_container.alpha = alpha;
_container.blendMode = ((blendMode) || (BlendMode.NORMAL));
}
override public function clone():AbstractRenderSession{
return (new SpriteRenderSession());
}
}
}//package away3d.core.render
Section 79
//Logo (away3d.core.stats.Logo)
package away3d.core.stats {
import flash.display.*;
public class Logo extends Shape {
private var arr:Array;
public function Logo(){
arr = [[7, 1, 262151], [8, 1, 3215136], [9, 1, 2033436], [10, 1, 1], [7, 2, 2098723], [8, 2, 5908501], [9, 2, 4922400], [10, 2, 720913], [6, 3, 327691], [7, 3, 6957102], [8, 3, 5975556], [9, 3, 6368779], [10, 3, 4789809], [11, 3, 2], [6, 4, 2361127], [7, 4, 10833686], [8, 4, 4926728], [9, 4, 6239495], [10, 4, 9190690], [11, 4, 1114647], [5, 5, 786453], [6, 5, 7088423], [7, 5, 14055707], [8, 5, 2103310], [9, 5, 3877139], [10, 5, 13134098], [11, 5, 5577773], [12, 5, 131077], [4, 6, 1], [5, 6, 3608110], [6, 6, 11227664], [7, 6, 12748351], [8, 6, 65793], [9, 6, 986379], [10, 6, 14980667], [11, 6, 10044437], [12, 6, 2230306], [4, 7, 0x12001C], [5, 7, 8007967], [6, 7, 14911011], [7, 7, 6509633], [10, 7, 9138771], [11, 7, 13989655], [12, 7, 7350824], [13, 7, 327689], [3, 8, 262153], [4, 8, 4592689], [5, 8, 12016138], [6, 8, 15774570], [7, 8, 855309], [10, 8, 2434083], [11, 8, 16233056], [12, 8, 11489803], [13, 8, 3345958], [3, 9, 1966887], [4, 9, 8665113], [5, 9, 15636021], [6, 9, 6773581], [11, 9, 9140836], [12, 9, 15240489], [13, 9, 8467743], [14, 9, 852240], [2, 10, 458767], [3, 10, 5774639], [4, 10, 13265683], [5, 10, 10845518], [6, 10, 0x0101], [11, 10, 657931], [12, 10, 14396016], [13, 10, 12739344], [14, 10, 5184297], [15, 10, 2], [2, 11, 2557230], [3, 11, 10307863], [4, 11, 12548133], [5, 11, 723464], [12, 11, 1512721], [13, 11, 14651446], [14, 11, 10307352], [15, 11, 1508630], [1, 12, 983068], [2, 12, 7154221], [3, 12, 9522185], [4, 12, 1314568], [6, 12, 131586], [7, 12, 921102], [8, 12, 0x1A1A1A], [9, 12, 0x171717], [10, 12, 657930], [13, 12, 2892051], [14, 12, 12610067], [15, 12, 7220009], [16, 12, 196614], [1, 13, 3936052], [2, 13, 5908749], [3, 13, 1773570], [4, 13, 4402968], [5, 13, 10714191], [6, 13, 12884326], [7, 13, 14396274], [8, 13, 15053429], [9, 13, 14790257], [10, 13, 13935206], [11, 13, 12159571], [12, 13, 9265971], [13, 13, 2759432], [14, 13, 2561537], [15, 13, 8601360], [16, 13, 3346464], [1, 14, 3938326], [2, 14, 5712395], [3, 14, 10900499], [4, 14, 11951126], [5, 14, 11490833], [6, 14, 11358991], [7, 14, 11227662], [8, 14, 11161870], [9, 14, 11030286], [10, 14, 10964497], [11, 14, 10898963], [12, 14, 10833429], [13, 14, 11096344], [14, 14, 8797973], [15, 14, 4595726], [16, 14, 4594459], [17, 14, 327941], [1, 15, 2296596], [2, 15, 3280925], [3, 15, 2821148], [4, 15, 2624284], [5, 15, 2558749], [6, 15, 2624031], [7, 15, 2558496], [8, 15, 2558498], [9, 15, 2492705], [10, 15, 2361630], [11, 15, 2361374], [12, 15, 2295839], [13, 15, 2295840], [14, 15, 2427171], [15, 15, 2624036], [16, 15, 1377300]];
super();
graphics.beginFill(0);
graphics.drawRect(0, 0, 18, 17);
var _local1:int = arr.length;
var _local2:int;
while (_local2 < _local1) {
graphics.beginFill(Number(arr[_local2][2]));
graphics.drawRect(arr[_local2][0], arr[_local2][1], 1, 1);
_local2++;
};
graphics.endFill();
}
}
}//package away3d.core.stats
Section 80
//StaticTextField (away3d.core.stats.StaticTextField)
package away3d.core.stats {
import flash.text.*;
public class StaticTextField extends TextField {
public var defaultText:String;
public function StaticTextField(_arg1:String=null, _arg2:TextFormat=null){
defaultTextFormat = (_arg2) ? _arg2 : new TextFormat("Verdana", 10, 0);
selectable = false;
mouseEnabled = false;
mouseWheelEnabled = false;
autoSize = "left";
tabEnabled = false;
if (_arg1){
this.htmlText = _arg1;
};
}
}
}//package away3d.core.stats
Section 81
//Stats (away3d.core.stats.Stats)
package away3d.core.stats {
import flash.display.*;
import flash.events.*;
import away3d.core.base.*;
import away3d.containers.*;
import flash.utils.*;
import away3d.cameras.*;
import flash.geom.*;
import flash.net.*;
import flash.text.*;
import flash.system.*;
import flash.ui.*;
public class Stats extends Sprite {
private const VERSION:String = "2";
private const REVISION:String = "5.0";
private const APPLICATION_NAME:String = "Away3D.com";
private var totalElements:int;// = 0
private var meshes:int;// = 0
public var scopeMenu:View3D;// = null
public var displayMenu:Sprite;// = null
public var geomMenu:Sprite;// = null
private var lastrender:int;
private var fpsLabel:StaticTextField;
private var titleField:StaticTextField;
private var perfLabel:StaticTextField;
private var ramLabel:StaticTextField;
private var swfframerateLabel:StaticTextField;
private var avfpsLabel:StaticTextField;
private var peakLabel:StaticTextField;
private var faceLabel:StaticTextField;
private var faceRenderLabel:StaticTextField;
private var geomDetailsLabel:TextField;
private var meshLabel:StaticTextField;
private var fpstotal:int;// = 0
private var refreshes:int;// = 0
private var bestfps:int;// = 0
private var lowestfps:int;// = 999
private var bar:Sprite;
private var barwidth:int;// = 0
private var closebtn:Sprite;
private var cambtn:Sprite;
private var clearbtn:Sprite;
private var geombtn:Sprite;
private var barscale:int;// = 0
private var stageframerate:Number;
private var displayState:int;
private var camLabel:TextField;
private var camMenu:Sprite;
private var camProp:Array;
private var rectclose:Rectangle;
private var rectcam:Rectangle;
private var rectclear:Rectangle;
private var rectdetails:Rectangle;
private var geomLastAdded:String;
private var defautTF:TextFormat;
private var defautTFBold:TextFormat;
public var sourceURL:String;
private var menu0:ContextMenuItem;
private var menu1:ContextMenuItem;
private var menu2:ContextMenuItem;
var type:String;
var elementcount:int;
var url:String;
public var stats:String;// = ""
public function Stats(_arg1:View3D, _arg2:Number=0){
rectclose = new Rectangle(228, 4, 18, 17);
rectcam = new Rectangle(207, 4, 18, 17);
rectclear = new Rectangle(186, 4, 18, 17);
rectdetails = new Rectangle(165, 4, 18, 17);
defautTF = new TextFormat("Verdana", 10, 0);
defautTFBold = new TextFormat("Verdana", 10, 0, true);
super();
scopeMenu = _arg1;
stageframerate = (_arg2) ? _arg2 : 30;
displayState = 0;
sourceURL = _arg1.sourceURL;
tabEnabled = false;
menu0 = new ContextMenuItem("Away3D Project stats", true, true, true);
menu1 = new ContextMenuItem("View Source", true, true, true);
menu2 = new ContextMenuItem(((((APPLICATION_NAME + "\tv") + VERSION) + ".") + REVISION), true, true, true);
var _local3:ContextMenu = new ContextMenu();
_local3 = new ContextMenu();
_local3.customItems = (sourceURL) ? [menu0, menu1, menu2] : [menu0, menu2];
menu0.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, displayStats);
menu1.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, viewSource);
menu2.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, visitWebsite);
_local3.hideBuiltInItems();
scopeMenu.contextMenu = _local3;
}
public function addSourceURL(_arg1:String):void{
sourceURL = _arg1;
var _local2:ContextMenu = new ContextMenu();
_local2.customItems = (sourceURL) ? [menu0, menu1, menu2] : [menu0, menu2];
scopeMenu.contextMenu = _local2;
}
public function displayStats(_arg1:ContextMenuEvent=null):void{
if (!displayMenu){
scopeMenu.statsOpen = true;
generateSprite();
addEventMouse();
};
}
public function visitWebsite(_arg1:ContextMenuEvent):void{
var e = _arg1;
var url = "http://www.away3d.com";
var request:URLRequest = new URLRequest(url);
try {
navigateToURL(request);
} catch(error:Error) {
};
}
public function viewSource(_arg1:ContextMenuEvent):void{
var e = _arg1;
var request:URLRequest = new URLRequest(sourceURL);
try {
navigateToURL(request, "_blank");
} catch(error:Error) {
};
}
private function closeStats():void{
scopeMenu.statsOpen = false;
displayState = 0;
scopeMenu.removeEventListener(MouseEvent.MOUSE_DOWN, onCheckMouse);
scopeMenu.removeEventListener(MouseEvent.MOUSE_MOVE, updateTips);
scopeMenu.removeChild(displayMenu);
displayMenu = null;
}
private function addEventMouse():void{
scopeMenu.addEventListener(MouseEvent.MOUSE_DOWN, onCheckMouse);
scopeMenu.addEventListener(MouseEvent.MOUSE_MOVE, updateTips);
}
private function updateTips(_arg1:MouseEvent):void{
var x:Number;
var y:Number;
var pt:Point;
var me = _arg1;
if (scopeMenu != null){
x = displayMenu.mouseX;
y = displayMenu.mouseY;
pt = new Point(x, y);
try {
if (rectcam.containsPoint(pt)){
titleField.text = "CAMERA INFO";
} else {
if (rectclose.containsPoint(pt)){
titleField.text = "CLOSE STATS";
} else {
if (rectclear.containsPoint(pt)){
titleField.text = "CLEAR AVERAGES";
} else {
if (rectdetails.containsPoint(pt)){
titleField.text = "MESH INFO";
} else {
titleField.text = "AWAY3D PROJECT";
};
};
};
};
} catch(e:Error) {
};
};
}
private function onCheckMouse(_arg1:MouseEvent):void{
var _local2:Number = displayMenu.mouseX;
var _local3:Number = displayMenu.mouseY;
var _local4:Point = new Point(_local2, _local3);
if (rectcam.containsPoint(_local4)){
if (displayState != 1){
closeOtherScreen(displayState);
displayState = 1;
showCamInfo();
} else {
displayState = 0;
hideCamInfo();
};
} else {
if (rectdetails.containsPoint(_local4)){
if (displayState != 2){
closeOtherScreen(displayState);
displayState = 2;
showGeomInfo();
} else {
displayState = 0;
hideGeomInfo();
};
} else {
if (rectclose.containsPoint(_local4)){
closeStats();
} else {
if (rectclear.containsPoint(_local4)){
clearStats();
} else {
if (displayMenu.mouseY <= 20){
displayMenu.startDrag();
scopeMenu.addEventListener(MouseEvent.MOUSE_UP, mouseReleased);
};
};
};
};
};
}
private function closeOtherScreen(_arg1:int):void{
switch (_arg1){
case 1:
hideCamInfo();
break;
case 2:
hideGeomInfo();
};
}
private function mouseReleased(_arg1:MouseEvent):void{
displayMenu.stopDrag();
scopeMenu.removeEventListener(MouseEvent.MOUSE_UP, mouseReleased);
}
private function generateSprite():void{
displayMenu = new Sprite();
var _local1:Matrix = new Matrix();
_local1.rotate(((90 * Math.PI) / 180));
displayMenu.graphics.beginGradientFill("linear", [3355494, 0xCCCCCC], [1, 1], [0, 0xFF], _local1, "pad", "rgb", 0);
displayMenu.graphics.drawRect(0, 0, 250, 86);
displayMenu.graphics.beginFill(3355494);
displayMenu.graphics.drawRect(3, 3, 244, 20);
scopeMenu.addChild(displayMenu);
displayMenu.x = (displayMenu.x - (displayMenu.width * 0.5));
displayMenu.y = (displayMenu.y - (displayMenu.height * 0.5));
closebtn = new Sprite();
closebtn.graphics.beginFill(0x666666);
closebtn.graphics.drawRect(0, 0, 18, 17);
var _local2:Sprite = new Sprite();
_local2.graphics.beginFill(13029592);
_local2.graphics.drawRect(2, 7, 14, 4);
_local2.graphics.endFill();
_local2.graphics.beginFill(13029592);
_local2.graphics.drawRect(7, 2, 4, 14);
_local2.graphics.endFill();
_local2.rotation = 45;
_local2.x = (_local2.x + 9);
_local2.y = (_local2.y - 4);
closebtn.addChild(_local2);
displayMenu.addChild(closebtn);
closebtn.x = 228;
closebtn.y = 4;
cambtn = new Sprite();
var _local3:Graphics = cambtn.graphics;
_local3.beginFill(0x666666);
_local3.drawRect(0, 0, 18, 17);
_local3.endFill();
_local3.beginFill(13029592);
_local3.moveTo(10, 8);
_local3.lineTo(16, 4);
_local3.lineTo(16, 14);
_local3.lineTo(10, 10);
_local3.lineTo(10, 8);
_local3.drawRect(2, 6, 8, 6);
_local3.endFill();
displayMenu.addChild(cambtn);
cambtn.x = 207;
cambtn.y = 4;
clearbtn = new Sprite();
var _local4:Graphics = clearbtn.graphics;
_local4.beginFill(0x666666);
_local4.drawRect(0, 0, 18, 17);
_local4.endFill();
_local4.beginFill(13029592);
_local4.drawRect(6, 6, 6, 6);
_local4.endFill();
displayMenu.addChild(clearbtn);
clearbtn.x = 186;
clearbtn.y = 4;
geombtn = new Sprite();
var _local5:Graphics = geombtn.graphics;
_local5.beginFill(0x666666);
_local5.drawRect(0, 0, 18, 17);
_local5.endFill();
_local5.beginFill(13029592, 0.7);
_local5.moveTo(3, 4);
_local5.lineTo(11, 2);
_local5.lineTo(16, 5);
_local5.lineTo(7, 7);
_local5.lineTo(3, 4);
_local5.beginFill(8225929, 0.8);
_local5.moveTo(3, 4);
_local5.lineTo(7, 7);
_local5.lineTo(7, 16);
_local5.lineTo(3, 12);
_local5.lineTo(3, 4);
_local5.beginFill(13029592, 1);
_local5.moveTo(7, 7);
_local5.lineTo(16, 5);
_local5.lineTo(15, 13);
_local5.lineTo(7, 16);
_local5.lineTo(7, 7);
_local5.endFill();
_local5.endFill();
displayMenu.addChild(geombtn);
geombtn.x = 165;
geombtn.y = 4;
displayMenu.graphics.beginGradientFill("linear", [0, 0xFFFFFF], [1, 1], [0, 0xFF], new Matrix(), "pad", "rgb", 0);
displayMenu.graphics.drawRect(3, 22, 244, 4);
displayMenu.graphics.endFill();
bar = new Sprite();
bar.graphics.beginFill(0xFFFFFF);
bar.graphics.drawRect(0, 0, 244, 4);
displayMenu.addChild(bar);
bar.x = 3;
bar.y = 22;
barwidth = 244;
barscale = int((barwidth / stageframerate));
displayPicto();
titleField = new StaticTextField("AWAY3D PROJECT", new TextFormat("Verdana", 10, 0xFFFFFF, true));
titleField.height = 20;
titleField.width = 140;
titleField.x = 22;
titleField.y = 4;
displayMenu.addChild(titleField);
var _local6:StaticTextField = new StaticTextField("FPS:", defautTFBold);
fpsLabel = new StaticTextField();
displayMenu.addChild(_local6);
displayMenu.addChild(fpsLabel);
_local6.x = 3;
_local6.y = (fpsLabel.y = 30);
fpsLabel.x = ((_local6.x + _local6.width) - 2);
var _local7:StaticTextField = new StaticTextField("AFPS:", defautTFBold);
avfpsLabel = new StaticTextField();
displayMenu.addChild(_local7);
displayMenu.addChild(avfpsLabel);
_local7.x = 52;
_local7.y = (avfpsLabel.y = fpsLabel.y);
avfpsLabel.x = ((_local7.x + _local7.width) - 2);
var _local8:StaticTextField = new StaticTextField("Max:", defautTFBold);
peakLabel = new StaticTextField();
displayMenu.addChild(_local8);
displayMenu.addChild(peakLabel);
_local8.x = 107;
_local8.y = (peakLabel.y = avfpsLabel.y);
_local8.autoSize = "left";
peakLabel.x = ((_local8.x + _local8.width) - 2);
var _local9:StaticTextField = new StaticTextField("MS:", defautTFBold);
perfLabel = new StaticTextField();
perfLabel.defaultTextFormat = defautTF;
displayMenu.addChild(_local9);
displayMenu.addChild(perfLabel);
_local9.x = 177;
_local9.y = (perfLabel.y = fpsLabel.y);
_local9.autoSize = "left";
perfLabel.x = ((_local9.x + _local9.width) - 2);
var _local10:StaticTextField = new StaticTextField("RAM:", defautTFBold);
ramLabel = new StaticTextField();
displayMenu.addChild(_local10);
displayMenu.addChild(ramLabel);
_local10.x = 3;
_local10.y = (ramLabel.y = 46);
_local10.autoSize = "left";
ramLabel.x = ((_local10.x + _local10.width) - 2);
var _local11:StaticTextField = new StaticTextField("MESHES:", defautTFBold);
meshLabel = new StaticTextField();
displayMenu.addChild(_local11);
displayMenu.addChild(meshLabel);
_local11.x = 90;
_local11.y = (meshLabel.y = ramLabel.y);
_local11.autoSize = "left";
meshLabel.x = ((_local11.x + _local11.width) - 2);
var _local12:StaticTextField = new StaticTextField("SWF FR:", defautTFBold);
swfframerateLabel = new StaticTextField();
displayMenu.addChild(_local12);
displayMenu.addChild(swfframerateLabel);
_local12.x = 170;
_local12.y = (swfframerateLabel.y = ramLabel.y);
_local12.autoSize = "left";
swfframerateLabel.x = ((_local12.x + _local12.width) - 2);
var _local13:StaticTextField = new StaticTextField("T ELEMENTS:", defautTFBold);
faceLabel = new StaticTextField();
displayMenu.addChild(_local13);
displayMenu.addChild(faceLabel);
_local13.x = 3;
_local13.y = (faceLabel.y = 62);
_local13.autoSize = "left";
faceLabel.x = ((_local13.x + _local13.width) - 2);
var _local14:StaticTextField = new StaticTextField("R ELEMENTS:", defautTFBold);
faceRenderLabel = new StaticTextField();
displayMenu.addChild(_local14);
displayMenu.addChild(faceRenderLabel);
_local14.x = 115;
_local14.y = (faceRenderLabel.y = faceLabel.y);
_local14.autoSize = "left";
faceRenderLabel.x = ((_local14.x + _local14.width) - 2);
}
public function updateStats(_arg1:int, _arg2:Camera3D):void{
var fps:int;
var average:int;
var w:int;
var caminfo:String;
var _length:int;
var i:int;
var info:String;
var renderedfaces = _arg1;
var camera = _arg2;
var now:int = getTimer();
var perf:int = (now - lastrender);
lastrender = now;
if (perf < 1000){
fps = int((1000 / (perf + 0.001)));
fpstotal = (fpstotal + fps);
refreshes++;
average = (fpstotal / refreshes);
bestfps = ((fps)>bestfps) ? fps : bestfps;
lowestfps = ((fps)<lowestfps) ? fps : lowestfps;
w = (barscale * fps);
bar.width = ((w)<=barwidth) ? w : barwidth;
};
var procent:int = ((bar.width / barwidth) * 100);
var colorTransform:ColorTransform = bar.transform.colorTransform;
colorTransform.color = ((((0xFF - (2.55 * procent)) << 16) | ((2.55 * procent) << 8)) | 40);
bar.transform.colorTransform = colorTransform;
if (displayState == 0){
avfpsLabel.text = ("" + average);
ramLabel.text = (("" + (int(((System.totalMemory / 0x0400) / 102.4)) / 10)) + "MB");
peakLabel.text = ((lowestfps + "/") + bestfps);
fpsLabel.text = ("" + fps);
perfLabel.text = ("" + perf);
faceLabel.text = ("" + totalElements);
faceRenderLabel.text = ("" + renderedfaces);
meshLabel.text = ("" + meshes);
swfframerateLabel.text = ("" + stageframerate);
} else {
if (displayState == 1){
caminfo = "";
_length = camProp.length;
i = 0;
while (i < _length) {
try {
if (i > 12){
caminfo = (caminfo + (String(camera[camProp[i]]) + "\n"));
} else {
info = String(camera[camProp[i]]);
caminfo = (caminfo + (info.substring(0, 19) + "\n"));
};
} catch(e:Error) {
caminfo = (caminfo + "\n");
};
i = (i + 1);
};
camLabel.text = caminfo;
} else {
if (displayState == 2){
geomDetailsLabel.text = stats;
};
};
};
}
private function clearStats():void{
fpstotal = 0;
refreshes = 0;
bestfps = 0;
lowestfps = 999;
}
private function showGeomInfo():void{
if (geomMenu == null){
createGeometryMenu();
} else {
displayMenu.addChild(geomMenu);
geomMenu.y = 26;
};
}
private function hideGeomInfo():void{
if (geomMenu != null){
displayMenu.removeChild(geomMenu);
};
}
private function createGeometryMenu():void{
geomMenu = new Sprite();
var _local1:Matrix = new Matrix();
_local1.rotate(((90 * Math.PI) / 180));
geomMenu.graphics.beginGradientFill("linear", [3355494, 0xCCCCCC], [1, 1], [0, 0xFF], _local1, "pad", "rgb", 0);
geomMenu.graphics.drawRect(0, 0, 250, 200);
displayMenu.addChild(geomMenu);
geomMenu.y = 26;
geomDetailsLabel = new TextField();
geomDetailsLabel.x = 3;
geomDetailsLabel.y = 3;
geomDetailsLabel.defaultTextFormat = defautTF;
geomDetailsLabel.text = stats;
geomDetailsLabel.height = 200;
geomDetailsLabel.width = 235;
geomDetailsLabel.multiline = true;
geomDetailsLabel.selectable = true;
geomDetailsLabel.wordWrap = true;
geomMenu.addChild(geomDetailsLabel);
}
private function showCamInfo():void{
if (camMenu == null){
createCamMenu();
} else {
displayMenu.addChild(camMenu);
camMenu.y = 26;
};
}
private function hideCamInfo():void{
if (camMenu != null){
displayMenu.removeChild(camMenu);
};
}
private function createCamMenu():void{
camMenu = new Sprite();
var _local1:Matrix = new Matrix();
_local1.rotate(((90 * Math.PI) / 180));
camMenu.graphics.beginGradientFill("linear", [3355494, 0xCCCCCC], [1, 1], [0, 0xFF], _local1, "pad", "rgb", 0);
camMenu.graphics.drawRect(0, 0, 250, 220);
displayMenu.addChild(camMenu);
camMenu.y = 26;
camLabel = new TextField();
camLabel.height = 210;
camLabel.width = 170;
camLabel.multiline = true;
camLabel.selectable = false;
var _local2:TextFormat = defautTF;
_local2.leading = 1.5;
camLabel.defaultTextFormat = _local2;
camLabel.wordWrap = true;
camMenu.addChild(camLabel);
camLabel.x = 100;
camLabel.y = 3;
camProp = ["x", "y", "z", "rotationX", "rotationY", "rotationZ", "zoom", "focus", "distance", "panAngle", "tiltAngle", "minTiltAngle", "maxTiltAngle", "steps", "yfactor"];
var _local3:TextField = new TextField();
_local2 = new TextFormat("Verdana", 10, 0, true);
_local2.leading = 1.5;
_local2.align = "right";
_local3.defaultTextFormat = _local2;
_local3.x = (_local3.y = 3);
_local3.multiline = true;
_local3.selectable = false;
_local3.autoSize = "left";
_local3.height = 210;
var _local4:int = camProp.length;
var _local5:int;
while (_local5 < _local4) {
_local3.appendText((camProp[_local5] + ":\n"));
_local5++;
};
camMenu.addChild(_local3);
}
private function displayPicto():void{
var _local1:Shape = new Logo();
displayMenu.addChild(_local1);
_local1.x = (_local1.y = 4);
}
public function clearObjects():void{
stats = "";
totalElements = 0;
meshes = 0;
geomLastAdded = "";
}
public function addObject(_arg1:Mesh):void{
type = _arg1.type;
elementcount = _arg1.elements.length;
url = _arg1.url;
if (((!((type == null))) && (!((elementcount == 0))))){
stats = (stats + ((((((" - " + type) + " , elements: ") + elementcount) + ", url: ") + url) + "\n"));
geomLastAdded = ((((((" - " + type) + " , elements: ") + elementcount) + ", url: ") + url) + "\n");
totalElements = (totalElements + elementcount);
meshes = (meshes + 1);
} else {
stats = (stats + ((((" - " + type) + " , url: ") + url) + "\n"));
geomLastAdded = ((((" - " + type) + " , url: ") + url) + "\n");
};
}
}
}//package away3d.core.stats
Section 82
//LightTraverser (away3d.core.traverse.LightTraverser)
package away3d.core.traverse {
import away3d.core.light.*;
import away3d.core.base.*;
import away3d.containers.*;
public class LightTraverser extends Traverser {
override public function match(_arg1:Object3D):Boolean{
return (_arg1.visible);
}
override public function apply(_arg1:Object3D):void{
var _local2:ObjectContainer3D;
var _local3:ILightProvider;
if (_arg1.ownLights){
_arg1.lightarray.clear();
};
if ((_arg1 is ObjectContainer3D)){
_local2 = (_arg1 as ObjectContainer3D);
for each (_local3 in _local2.lights) {
_local3.light(_local2.lightarray);
};
};
}
}
}//package away3d.core.traverse
Section 83
//PrimitiveTraverser (away3d.core.traverse.PrimitiveTraverser)
package away3d.core.traverse {
import away3d.core.math.*;
import away3d.core.light.*;
import away3d.core.base.*;
import away3d.core.utils.*;
import away3d.materials.*;
import away3d.core.draw.*;
import away3d.containers.*;
import away3d.core.geom.*;
import flash.utils.*;
import away3d.core.clip.*;
import away3d.core.project.*;
public class PrimitiveTraverser extends Traverser {
private var _view:View3D;
private var _clipping:Clipping;
private var _viewTransform:Matrix3D;
private var _cameraVarsStore:CameraVarsStore;
private var _nodeClassification:int;
private var _consumer:IPrimitiveConsumer;
private var _mouseEnabled:Boolean;
private var _mouseEnableds:Array;
private var _projectorDictionary:Dictionary;
public function PrimitiveTraverser(){
_mouseEnableds = new Array();
_projectorDictionary = new Dictionary(true);
super();
}
public function get view():View3D{
return (_view);
}
public function set view(_arg1:View3D):void{
_view = _arg1;
_mouseEnabled = true;
_mouseEnableds.length = 0;
_cameraVarsStore = _view.cameraVarsStore;
_projectorDictionary[ProjectorType.CONVEX_BLOCK] = _view._convexBlockProjector;
_projectorDictionary[ProjectorType.DIR_SPRITE] = _view._dirSpriteProjector;
_projectorDictionary[ProjectorType.DOF_SPRITE] = _view._dofSpriteProjector;
_projectorDictionary[ProjectorType.MESH] = _view._meshProjector;
_projectorDictionary[ProjectorType.MOVIE_CLIP_SPRITE] = _view._movieClipSpriteProjector;
_projectorDictionary[ProjectorType.OBJECT_CONTAINER] = _view._objectContainerProjector;
_projectorDictionary[ProjectorType.SPRITE] = _view._spriteProjector;
}
override public function match(_arg1:Object3D):Boolean{
_clipping = _view.clipping;
if (_arg1._preCulled){
return (true);
};
if (((!(_arg1.visible)) || (((_clipping.objectCulling) && (!(_cameraVarsStore.nodeClassificationDictionary[_arg1])))))){
return (false);
};
if ((_arg1 is ILODObject)){
return ((_arg1 as ILODObject).matchLOD(_view.camera));
};
return (true);
}
override public function enter(_arg1:Object3D):void{
_mouseEnableds.push(_mouseEnabled);
}
override public function apply(_arg1:Object3D):void{
if (_arg1.session.updated){
_viewTransform = _cameraVarsStore.viewTransformDictionary[_arg1];
_consumer = _arg1.session.getConsumer(_view);
if (_arg1.projectorType){
(_projectorDictionary[_arg1.projectorType] as IPrimitiveProvider).primitives(_arg1, _viewTransform, _consumer);
};
if (((_arg1.debugbb) && (_arg1.debugBoundingBox.visible))){
_arg1.debugBoundingBox._session = _arg1.session;
if (_clipping.objectCulling){
_cameraVarsStore.frustumDictionary[_arg1.debugBoundingBox] = _cameraVarsStore.frustumDictionary[_arg1];
_nodeClassification = _cameraVarsStore.nodeClassificationDictionary[_arg1];
if (_nodeClassification == Frustum.INTERSECT){
(_arg1.debugBoundingBox.material as WireframeMaterial).wireColor = 0xFF0000;
} else {
(_arg1.debugBoundingBox.material as WireframeMaterial).wireColor = 0x333333;
};
};
_view._meshProjector.primitives(_arg1.debugBoundingBox, _viewTransform, _consumer);
};
if (((_arg1.debugbs) && (_arg1.debugBoundingSphere.visible))){
_arg1.debugBoundingSphere._session = _arg1.session;
if (_clipping.objectCulling){
_cameraVarsStore.frustumDictionary[_arg1.debugBoundingSphere] = _cameraVarsStore.frustumDictionary[_arg1];
_nodeClassification = _cameraVarsStore.nodeClassificationDictionary[_arg1];
if (_nodeClassification == Frustum.INTERSECT){
(_arg1.debugBoundingSphere.material as WireframeMaterial).wireColor = 0xFF0000;
} else {
(_arg1.debugBoundingSphere.material as WireframeMaterial).wireColor = 0xFFFF;
};
};
_view._meshProjector.primitives(_arg1.debugBoundingSphere, _viewTransform, _consumer);
};
};
_mouseEnabled = (_arg1._mouseEnabled = ((_mouseEnabled) && (_arg1.mouseEnabled)));
}
override public function leave(_arg1:Object3D):void{
_mouseEnabled = _mouseEnableds.pop();
}
}
}//package away3d.core.traverse
Section 84
//ProjectionTraverser (away3d.core.traverse.ProjectionTraverser)
package away3d.core.traverse {
import away3d.core.math.*;
import away3d.core.base.*;
import away3d.core.utils.*;
import away3d.containers.*;
import away3d.core.geom.*;
import away3d.cameras.*;
import away3d.core.clip.*;
import away3d.graphs.bsp.*;
import away3d.cameras.lenses.*;
import away3d.core.project.*;
public class ProjectionTraverser extends Traverser {
private var _view:View3D;
private var _frustum:Frustum;
private var _cameraVarsStore:CameraVarsStore;
private var _camera:Camera3D;
private var _lens:AbstractLens;
private var _clipping:Clipping;
private var _cameraViewMatrix:Matrix3D;
private var _viewTransform:Matrix3D;
private var _nodeClassification:int;
private var _mesh:Mesh;
public function get view():View3D{
return (_view);
}
public function set view(_arg1:View3D):void{
_view = _arg1;
_cameraVarsStore = _arg1.cameraVarsStore;
_clipping = _arg1.clipping;
_camera = _arg1.camera;
_lens = _camera.lens;
_cameraViewMatrix = _camera.viewMatrix;
if (_arg1.statsOpen){
_arg1.statsPanel.clearObjects();
};
}
override public function match(_arg1:Object3D):Boolean{
if (!_arg1.visible){
return (false);
};
_viewTransform = _cameraVarsStore.createViewTransform(_arg1);
_viewTransform.multiply(_cameraViewMatrix, _arg1.sceneTransform);
if ((_arg1 is BSPTree)){
BSPTree(_arg1).update(_view.camera, _lens.getFrustum(_arg1, _viewTransform), _cameraVarsStore);
_cameraVarsStore.nodeClassificationDictionary[_arg1] = Frustum.INTERSECT;
} else {
if (_clipping.objectCulling){
if (_arg1._preCulled){
_cameraVarsStore.nodeClassificationDictionary[_arg1] = _arg1._preCullClassification;
return (true);
};
_frustum = _lens.getFrustum(_arg1, _viewTransform);
if ((((_arg1 is Scene3D)) || ((_cameraVarsStore.nodeClassificationDictionary[_arg1.parent] == Frustum.INTERSECT)))){
if (_arg1.pivotZero){
_nodeClassification = (_cameraVarsStore.nodeClassificationDictionary[_arg1] = _frustum.classifyRadius(_arg1.boundingRadius));
} else {
_nodeClassification = (_cameraVarsStore.nodeClassificationDictionary[_arg1] = _frustum.classifySphere(_arg1.pivotPoint, _arg1.boundingRadius));
};
} else {
_nodeClassification = (_cameraVarsStore.nodeClassificationDictionary[_arg1] = _cameraVarsStore.nodeClassificationDictionary[_arg1.parent]);
};
if (_nodeClassification == Frustum.OUT){
_arg1.updateObject();
return (false);
};
if ((_arg1 is ILODObject)){
return ((_arg1 as ILODObject).matchLOD(_camera));
};
};
};
return (true);
}
override public function enter(_arg1:Object3D):void{
if (((_view.statsOpen) && ((_arg1 is Mesh)))){
_view.statsPanel.addObject((_arg1 as Mesh));
};
}
override public function apply(_arg1:Object3D):void{
if (_arg1.projectorType == ProjectorType.CONVEX_BLOCK){
_view.blockers[_arg1] = _arg1;
};
if ((_mesh = (_arg1 as Mesh))){
if (!_view.scene.meshes[_arg1]){
_view.scene.meshes[_arg1] = [];
};
_view.scene.meshes[_arg1].push(_view);
_view.scene.geometries[_mesh.geometry] = _mesh.geometry;
};
}
override public function leave(_arg1:Object3D):void{
_arg1.updateObject();
}
}
}//package away3d.core.traverse
Section 85
//SessionTraverser (away3d.core.traverse.SessionTraverser)
package away3d.core.traverse {
import away3d.core.base.*;
public class SessionTraverser extends Traverser {
override public function match(_arg1:Object3D):Boolean{
return (_arg1.visible);
}
override public function apply(_arg1:Object3D):void{
_arg1.updateSession();
}
}
}//package away3d.core.traverse
Section 86
//TickTraverser (away3d.core.traverse.TickTraverser)
package away3d.core.traverse {
import away3d.core.base.*;
public class TickTraverser extends Traverser {
public var now:int;
override public function enter(_arg1:Object3D):void{
_arg1.tick(now);
}
}
}//package away3d.core.traverse
Section 87
//Traverser (away3d.core.traverse.Traverser)
package away3d.core.traverse {
import away3d.core.base.*;
public class Traverser {
public function match(_arg1:Object3D):Boolean{
return (true);
}
public function enter(_arg1:Object3D):void{
}
public function apply(_arg1:Object3D):void{
}
public function leave(_arg1:Object3D):void{
}
}
}//package away3d.core.traverse
Section 88
//CacheStore (away3d.core.utils.CacheStore)
package away3d.core.utils {
import flash.utils.*;
public class CacheStore {
public static var whiteShadingCache:Dictionary = new Dictionary(true);
}
}//package away3d.core.utils
Section 89
//CameraVarsStore (away3d.core.utils.CameraVarsStore)
package away3d.core.utils {
import away3d.core.math.*;
import away3d.core.base.*;
import away3d.materials.*;
import away3d.containers.*;
import away3d.core.render.*;
import away3d.core.geom.*;
import flash.utils.*;
public class CameraVarsStore {
private var _sourceDictionary:Dictionary;
private var _vertexClassificationDictionary:Dictionary;
private var _vt:Matrix3D;
private var _frustum:Frustum;
private var _vertex:Vertex;
private var _uv:UV;
private var _vc:VertexClassification;
private var _faceVO:FaceVO;
private var _segmentVO:SegmentVO;
private var _object:Object;
private var _v:Object;
private var _source:Object3D;
private var _session:AbstractRenderSession;
private var _vtActive:Array;
private var _vtStore:Array;
private var _frActive:Array;
private var _frStore:Array;
private var _vActive:Array;
private var _vStore:Array;
private var _vcStore:Array;
private var _uvDictionary:Dictionary;
private var _uvArray:Array;
private var _uvStore:Array;
private var _fActive:Array;
private var _fStore:Array;
private var _sActive:Array;
private var _sStore:Array;
public var view:View3D;
public var viewTransformDictionary:Dictionary;
public var nodeClassificationDictionary:Dictionary;
public var frustumDictionary:Dictionary;
public function CameraVarsStore(){
_sourceDictionary = new Dictionary(true);
_vtActive = [];
_vtStore = [];
_frActive = [];
_frStore = [];
_vActive = [];
_vStore = [];
_vcStore = [];
_uvDictionary = new Dictionary(true);
_uvStore = [];
_fActive = [];
_fStore = [];
_sActive = [];
_sStore = [];
viewTransformDictionary = new Dictionary(true);
nodeClassificationDictionary = new Dictionary(true);
frustumDictionary = new Dictionary(true);
super();
}
public function createVertexClassificationDictionary(_arg1:Object3D):Dictionary{
if (!(_vertexClassificationDictionary = _sourceDictionary[_arg1])){
_vertexClassificationDictionary = (_sourceDictionary[_arg1] = new Dictionary(true));
};
return (_vertexClassificationDictionary);
}
public function createVertexClassification(_arg1:Vertex):VertexClassification{
if ((_vc = _vertexClassificationDictionary[_arg1])){
return (_vc);
};
if (_vcStore.length){
_vc = (_vertexClassificationDictionary[_arg1] = _vcStore.pop());
} else {
_vc = (_vertexClassificationDictionary[_arg1] = new VertexClassification());
};
_vc.vertex = _arg1;
_vc.plane = null;
return (_vc);
}
public function createViewTransform(_arg1:Object3D):Matrix3D{
if (_vtStore.length){
_vtActive.push((_vt = (viewTransformDictionary[_arg1] = _vtStore.pop())));
} else {
_vtActive.push((_vt = (viewTransformDictionary[_arg1] = new Matrix3D())));
};
return (_vt);
}
public function createFrustum(_arg1:Object3D):Frustum{
if (_frStore.length){
_frActive.push((_frustum = (frustumDictionary[_arg1] = _frStore.pop())));
} else {
_frActive.push((_frustum = (frustumDictionary[_arg1] = new Frustum())));
};
return (_frustum);
}
public function createVertex(_arg1:Number, _arg2:Number, _arg3:Number):Vertex{
if (_vStore.length){
_vActive.push((_vertex = _vStore.pop()));
_vertex.x = _arg1;
_vertex.y = _arg2;
_vertex.z = _arg3;
} else {
_vActive.push((_vertex = new Vertex(_arg1, _arg2, _arg3)));
};
return (_vertex);
}
public function createUV(_arg1:Number, _arg2:Number, _arg3:AbstractRenderSession):UV{
if (!(_uvArray = _uvDictionary[_arg3])){
_uvArray = (_uvDictionary[_arg3] = []);
};
if (_uvStore.length){
_uvArray.push((_uv = _uvStore.pop()));
_uv.u = _arg1;
_uv.v = _arg2;
} else {
_uvArray.push((_uv = new UV(_arg1, _arg2)));
};
return (_uv);
}
public function createFaceVO(_arg1:Face, _arg2:Material, _arg3:Material, _arg4:UV, _arg5:UV, _arg6:UV):FaceVO{
if (_fStore.length){
_fActive.push((_faceVO = _fStore.pop()));
} else {
_fActive.push((_faceVO = new FaceVO()));
};
_faceVO.face = _arg1;
_faceVO.uv0 = _arg4;
_faceVO.uv1 = _arg5;
_faceVO.uv2 = _arg6;
_faceVO.material = _arg2;
_faceVO.back = _arg3;
_faceVO.generated = true;
return (_faceVO);
}
public function createSegmentVO(_arg1:Material):SegmentVO{
if (_sStore.length){
_sActive.push((_segmentVO = _sStore.pop()));
} else {
_sActive.push((_segmentVO = new SegmentVO()));
};
_segmentVO.generated = true;
return (_segmentVO);
}
public function reset():void{
for (_object in _sourceDictionary) {
_source = (_object as Object3D);
if (((_source.session) && (_source.session.updated))){
for (_v in _sourceDictionary[_source]) {
_vcStore.push(_sourceDictionary[_source][_v]);
delete _sourceDictionary[_source][_v];
};
};
};
nodeClassificationDictionary = new Dictionary(true);
_vtStore = _vtStore.concat(_vtActive);
_vtActive.length = 0;
_frStore = _frStore.concat(_frActive);
_frActive.length = 0;
_vStore = _vStore.concat(_vActive);
_vActive.length = 0;
for (_object in _uvDictionary) {
_session = (_object as AbstractRenderSession);
if (_session.updated){
_uvArray = (_uvDictionary[_session] as Array);
_uvStore = _uvStore.concat();
_uvArray.length = 0;
};
};
_fStore = _fStore.concat(_fActive);
_fActive.length = 0;
_sStore = _sStore.concat(_sActive);
_sActive.length = 0;
}
}
}//package away3d.core.utils
Section 90
//Cast (away3d.core.utils.Cast)
package away3d.core.utils {
import flash.display.*;
import away3d.materials.*;
import flash.utils.*;
import flash.geom.*;
public class Cast {
private static var colornames:Dictionary;
private static var hexchars:String = "0123456789abcdefABCDEF";
private static var notclasses:Dictionary = new Dictionary();
private static var classes:Dictionary = new Dictionary();
public static function string(_arg1):String{
if ((_arg1 is Class)){
_arg1 = new (_arg1);
};
if ((_arg1 is String)){
return (_arg1);
};
return (String(_arg1));
}
public static function bytearray(_arg1):ByteArray{
if ((_arg1 is Class)){
_arg1 = new (_arg1);
};
if ((_arg1 is ByteArray)){
return (_arg1);
};
return (ByteArray(_arg1));
}
public static function xml(_arg1):XML{
if ((_arg1 is Class)){
_arg1 = new (_arg1);
};
if ((_arg1 is XML)){
return (_arg1);
};
return (XML(_arg1));
}
private static function hexstring(_arg1:String):Boolean{
var _local2:int = _arg1.length;
var _local3:int;
while (_local3 < _local2) {
if (hexchars.indexOf(_arg1.charAt(_local3)) == -1){
return (false);
};
_local3++;
};
return (true);
}
public static function trycolor(_arg1):uint{
if ((_arg1 is uint)){
return ((_arg1 as uint));
};
if ((_arg1 is int)){
return ((_arg1 as uint));
};
if ((_arg1 is String)){
if (_arg1 == "random"){
return (uint((Math.random() * 16777216)));
};
if (colornames == null){
colornames = new Dictionary();
colornames["steelblue"] = 4620980;
colornames["royalblue"] = 267920;
colornames["cornflowerblue"] = 6591981;
colornames["lightsteelblue"] = 11584734;
colornames["mediumslateblue"] = 8087790;
colornames["slateblue"] = 6970061;
colornames["darkslateblue"] = 4734347;
colornames["midnightblue"] = 1644912;
colornames["navy"] = 128;
colornames["darkblue"] = 139;
colornames["mediumblue"] = 205;
colornames["blue"] = 0xFF;
colornames["dodgerblue"] = 2003199;
colornames["deepskyblue"] = 49151;
colornames["lightskyblue"] = 8900346;
colornames["skyblue"] = 8900331;
colornames["lightblue"] = 11393254;
colornames["powderblue"] = 11591910;
colornames["azure"] = 15794175;
colornames["lightcyan"] = 14745599;
colornames["paleturquoise"] = 11529966;
colornames["mediumturquoise"] = 4772300;
colornames["lightseagreen"] = 2142890;
colornames["darkcyan"] = 0x8B8B;
colornames["teal"] = 0x8080;
colornames["cadetblue"] = 6266528;
colornames["darkturquoise"] = 52945;
colornames["aqua"] = 0xFFFF;
colornames["cyan"] = 0xFFFF;
colornames["turquoise"] = 4251856;
colornames["aquamarine"] = 8388564;
colornames["mediumaquamarine"] = 6737322;
colornames["darkseagreen"] = 9419919;
colornames["mediumseagreen"] = 3978097;
colornames["seagreen"] = 3050327;
colornames["darkgreen"] = 0x6400;
colornames["green"] = 0x8000;
colornames["forestgreen"] = 2263842;
colornames["limegreen"] = 3329330;
colornames["lime"] = 0xFF00;
colornames["chartreuse"] = 0x7FFF00;
colornames["lawngreen"] = 0x7CFC00;
colornames["greenyellow"] = 11403055;
colornames["yellowgreen"] = 10145074;
colornames["palegreen"] = 10025880;
colornames["lightgreen"] = 9498256;
colornames["springgreen"] = 65407;
colornames["mediumspringgreen"] = 64154;
colornames["darkolivegreen"] = 5597999;
colornames["olivedrab"] = 7048739;
colornames["olive"] = 0x808000;
colornames["darkkhaki"] = 12433259;
colornames["darkgoldenrod"] = 12092939;
colornames["goldenrod"] = 14329120;
colornames["gold"] = 0xFFD700;
colornames["yellow"] = 0xFFFF00;
colornames["khaki"] = 15787660;
colornames["palegoldenrod"] = 15657130;
colornames["blanchedalmond"] = 16772045;
colornames["moccasin"] = 16770229;
colornames["wheat"] = 16113331;
colornames["navajowhite"] = 16768685;
colornames["burlywood"] = 14596231;
colornames["tan"] = 13808780;
colornames["rosybrown"] = 12357519;
colornames["sienna"] = 10506797;
colornames["saddlebrown"] = 9127187;
colornames["chocolate"] = 13789470;
colornames["peru"] = 13468991;
colornames["sandybrown"] = 16032864;
colornames["darkred"] = 0x8B0000;
colornames["maroon"] = 0x800000;
colornames["brown"] = 10824234;
colornames["firebrick"] = 11674146;
colornames["indianred"] = 13458524;
colornames["lightcoral"] = 15761536;
colornames["salmon"] = 16416882;
colornames["darksalmon"] = 15308410;
colornames["lightsalmon"] = 16752762;
colornames["coral"] = 16744272;
colornames["tomato"] = 16737095;
colornames["darkorange"] = 0xFF8C00;
colornames["orange"] = 0xFFA500;
colornames["orangered"] = 0xFF4500;
colornames["crimson"] = 14423100;
colornames["red"] = 0xFF0000;
colornames["deeppink"] = 16716947;
colornames["fuchsia"] = 0xFF00FF;
colornames["magenta"] = 0xFF00FF;
colornames["hotpink"] = 16738740;
colornames["lightpink"] = 16758465;
colornames["pink"] = 16761035;
colornames["palevioletred"] = 14381203;
colornames["mediumvioletred"] = 13047173;
colornames["purple"] = 0x800080;
colornames["darkmagenta"] = 0x8B008B;
colornames["mediumpurple"] = 9662683;
colornames["blueviolet"] = 9055202;
colornames["indigo"] = 0x4B0082;
colornames["darkviolet"] = 0x9400D3;
colornames["darkorchid"] = 10040012;
colornames["mediumorchid"] = 12211667;
colornames["orchid"] = 14315734;
colornames["violet"] = 15631086;
colornames["plum"] = 14524637;
colornames["thistle"] = 14204888;
colornames["lavender"] = 15132410;
colornames["ghostwhite"] = 16316671;
colornames["aliceblue"] = 15792383;
colornames["mintcream"] = 16121850;
colornames["honeydew"] = 15794160;
colornames["lightgoldenrodyellow"] = 16448210;
colornames["lemonchiffon"] = 16775885;
colornames["cornsilk"] = 16775388;
colornames["lightyellow"] = 16777184;
colornames["ivory"] = 16777200;
colornames["floralwhite"] = 16775920;
colornames["linen"] = 16445670;
colornames["oldlace"] = 16643558;
colornames["antiquewhite"] = 16444375;
colornames["bisque"] = 16770244;
colornames["peachpuff"] = 16767673;
colornames["papayawhip"] = 16773077;
colornames["beige"] = 16119260;
colornames["seashell"] = 16774638;
colornames["lavenderblush"] = 16773365;
colornames["mistyrose"] = 16770273;
colornames["snow"] = 16775930;
colornames["white"] = 0xFFFFFF;
colornames["whitesmoke"] = 0xF5F5F5;
colornames["gainsboro"] = 0xDCDCDC;
colornames["lightgrey"] = 0xD3D3D3;
colornames["silver"] = 0xC0C0C0;
colornames["darkgrey"] = 0xA9A9A9;
colornames["grey"] = 0x808080;
colornames["lightslategrey"] = 7833753;
colornames["slategrey"] = 7372944;
colornames["dimgrey"] = 0x696969;
colornames["darkslategrey"] = 3100495;
colornames["black"] = 0;
colornames["transparent"] = 4278190080;
};
if (colornames[_arg1] != null){
return (colornames[_arg1]);
};
if (((((_arg1 as String).length == 6)) && (hexstring(_arg1)))){
return (parseInt(("0x" + _arg1)));
};
};
return (0xFFFFFF);
}
public static function color(_arg1):uint{
var _local2:uint = trycolor(_arg1);
if (_local2 == 4294967295){
throw (new CastError(("Can't cast to color: " + _arg1)));
};
return (_local2);
}
public static function bitmap(_arg1):BitmapData{
var ds:DisplayObject;
var bmd:BitmapData;
var mat:Matrix;
var data = _arg1;
if (data == null){
return (null);
};
if ((data is String)){
data = tryclass(data);
};
if ((data is Class)){
try {
data = new (data);
} catch(bitmaperror:ArgumentError) {
data = new data(0, 0);
};
};
if ((data is BitmapData)){
return (data);
};
if ((data is Bitmap)){
if ((data as Bitmap).hasOwnProperty("bitmapData")){
return ((data as Bitmap).bitmapData);
};
};
if ((data is DisplayObject)){
ds = (data as DisplayObject);
bmd = new BitmapData(ds.width, ds.height, true, 0xFFFFFF);
mat = ds.transform.matrix.clone();
mat.tx = 0;
mat.ty = 0;
bmd.draw(ds, mat, ds.transform.colorTransform, ds.blendMode, bmd.rect, true);
return (bmd);
};
throw (new CastError(("Can't cast to bitmap: " + data)));
}
public static function tryclass(_arg1:String):Object{
var name = _arg1;
if (notclasses[name]){
return (name);
};
var result:Class = classes[name];
if (result != null){
return (result);
};
try {
result = (getDefinitionByName(name) as Class);
classes[name] = result;
return (result);
} catch(error:ReferenceError) {
};
notclasses[name] = true;
return (name);
}
public static function material(_arg1):Material{
var hash:Array;
var line:Array;
var bmd:BitmapData;
var ini:Init;
var bitmap:BitmapData;
var color:uint;
var alpha:Number;
var lighting:Boolean;
var wire:WireframeMaterial;
var smooth:Boolean;
var precision:Number;
var data = _arg1;
if (data == null){
return (null);
};
if ((data is String)){
data = tryclass(data);
};
if ((data is Class)){
try {
data = new (data);
} catch(materialerror:ArgumentError) {
data = new data(0, 0);
};
};
if ((data is Material)){
return (data);
};
if ((data is int)){
return (new ColorMaterial(data));
};
if ((data is MovieClip)){
return (new MovieMaterial(data));
};
if ((data is String)){
if (data == ""){
return (null);
};
if ((data as String).indexOf("#") != -1){
hash = (data as String).split("#");
if (hash[1] == ""){
return (new WireColorMaterial(color(hash[0])));
};
if (hash[1].indexOf("|") == -1){
if (hash[0] == ""){
return (new WireframeMaterial(color(hash[1])));
};
return (new WireColorMaterial(color(hash[0]), {wirecolor:color(hash[1])}));
} else {
line = hash[1].split("|");
if (hash[0] == ""){
return (new WireframeMaterial(color(line[0]), {width:parseFloat(line[1])}));
};
return (new WireColorMaterial(color(hash[0]), {wirecolor:color(line[0]), width:parseFloat(line[1])}));
};
} else {
if ((data as String).indexOf("@") != -1){
hash = (data as String).split("@");
if (hash[1] == ""){
return (new ShadingColorMaterial({color:color(hash[0])}));
};
} else {
return (new ColorMaterial(color(data)));
};
};
};
try {
bmd = Cast.bitmap(data);
return (new BitmapMaterial(bmd));
} catch(error:CastError) {
};
if ((data is Object)){
ini = Init.parse(data);
bitmap = ini.getBitmap("bitmap");
color = ini.getColor("color", 4294967295);
alpha = ini.getNumber("alpha", 1, {min:0, max:1});
lighting = ini.getBoolean("lighting", false);
wire = (wirematerial(ini.getObject("wire")) as WireframeMaterial);
if (((!((bitmap == null))) && (!((color == 4294967295))))){
throw (new CastError(("Can't create material with color and bitmap: " + data)));
};
if (bitmap != null){
if (wire != null){
Debug.warning("Bitmap materials do not support wire");
};
smooth = ini.getBoolean("smooth", false);
precision = ini.getNumber("precision", 0);
if (precision){
if (lighting){
return (new WhiteShadingBitmapMaterial(bitmap, {smooth:smooth, precision:precision}));
};
if (alpha < 1){
Debug.warning("Can't create precise bitmap material with alpha (yet)");
};
return (new BitmapMaterial(bitmap, {smooth:smooth, precision:precision}));
};
if (lighting){
if (alpha < 1){
Debug.warning("Can't create bitmap material with lighting and alpha (yet)");
};
return (new WhiteShadingBitmapMaterial(bitmap, {smooth:smooth, alpha:alpha}));
};
return (new BitmapMaterial(bitmap, {smooth:smooth}));
};
if (color != 4294967295){
if (lighting){
if (wire != null){
Debug.warning("Can't create shading material with wire");
};
return (new ShadingColorMaterial({color:color, alpha:alpha}));
};
if (wire == null){
return (new ColorMaterial(color, {alpha:alpha}));
};
return (new WireColorMaterial(color, {alpha:alpha, wireColor:wire.wireColor, wireAlpha:wire.wireAlpha, thickness:wire.thickness}));
};
if (wire != null){
return (wire);
};
};
throw (new CastError(("Can't cast to material: " + data)));
}
public static function wirematerial(_arg1):Material{
var _local2:Array;
var _local3:Init;
var _local4:uint;
var _local5:Number;
var _local6:Number;
if (_arg1 == null){
return (null);
};
if ((_arg1 is Material)){
return (_arg1);
};
if ((_arg1 is int)){
return (new WireframeMaterial(_arg1));
};
if ((_arg1 is String)){
if (_arg1 == ""){
return (null);
};
if ((_arg1 as String).indexOf("#") == 0){
_arg1 = (_arg1 as String).substring(1);
};
if ((_arg1 as String).indexOf("|") == -1){
return (new WireframeMaterial(color(_arg1)));
};
_local2 = (_arg1 as String).split("|");
return (new WireframeMaterial(color(_local2[0]), {width:parseFloat(_local2[1])}));
};
if ((_arg1 is Object)){
_local3 = Init.parse(_arg1);
_local4 = _local3.getColor("color", 0);
_local5 = _local3.getNumber("alpha", 1, {min:0, max:1});
_local6 = _local3.getNumber("width", 1, {min:0});
return (new WireframeMaterial(_local4, {alpha:_local5, width:_local6}));
};
throw (new CastError(("Can't cast to wirematerial: " + _arg1)));
}
}
}//package away3d.core.utils
Section 91
//CastError (away3d.core.utils.CastError)
package away3d.core.utils {
public class CastError extends Error {
public function CastError(_arg1:String){
super(_arg1);
}
}
}//package away3d.core.utils
Section 92
//Color (away3d.core.utils.Color)
package away3d.core.utils {
public class Color {
public static const white:int = 0xFFFFFF;
public static const black:int = 0;
public static const red:int = 0xFF0000;
public static const green:int = 0xFF00;
public static const blue:int = 0xFF;
public static const yellow:int = 0xFFFF00;
public static const cyan:int = 0xFFFF;
public static const purple:int = 0xFF00FF;
public static function multiply(_arg1:int, _arg2:Number):int{
var _local3 = (_arg1 & (0xFF0000 >> 16));
var _local4 = (_arg1 & (0xFF00 >> 8));
var _local5 = (_arg1 & 0xFF);
return (fromIntsCheck(int((_local3 * _arg2)), int((_local4 * _arg2)), int((_local5 * _arg2))));
}
public static function add(_arg1:int, _arg2:int):int{
var _local3 = (_arg1 & (0xFF0000 >> 16));
var _local4 = (_arg1 & (0xFF00 >> 8));
var _local5 = (_arg1 & 0xFF);
var _local6 = (_arg2 & (0xFF0000 >> 16));
var _local7 = (_arg2 & (0xFF00 >> 8));
var _local8 = (_arg2 & 0xFF);
return (fromIntsCheck((_local3 + _local6), (_local4 + _local7), (_local5 + _local8)));
}
public static function inverseAdd(_arg1:int, _arg2:int):int{
var _local3 = ((0xFF - _arg1) & (0xFF0000 >> 16));
var _local4 = ((0xFF - _arg1) & (0xFF00 >> 8));
var _local5 = ((0xFF - _arg1) & 0xFF);
var _local6 = ((0xFF - _arg2) & (0xFF0000 >> 16));
var _local7 = ((0xFF - _arg2) & (0xFF00 >> 8));
var _local8 = ((0xFF - _arg2) & 0xFF);
return (fromIntsCheck((0xFF - (_local3 + _local6)), (0xFF - (_local4 + _local7)), (0xFF - (_local5 + _local8))));
}
public static function fromHSV(_arg1:Number, _arg2:Number, _arg3:Number):int{
var _local4:Number = (((_arg1 % 360) + 360) % 360);
var _local5:Number = _arg2;
var _local6:Number = _arg3;
var _local7:int = (int((_local4 / 60)) % 6);
var _local8:Number = ((_local4 / 60) - _local7);
var _local9:Number = (_local6 * (1 - _local5));
var _local10:Number = (_local6 * (1 - (_local8 * _local5)));
var _local11:Number = (_local6 * (1 - ((1 - _local8) * _local5)));
switch (_local7){
case 0:
return (fromFloats(_local6, _local11, _local9));
case 1:
return (fromFloats(_local10, _local6, _local9));
case 2:
return (fromFloats(_local9, _local6, _local11));
case 3:
return (fromFloats(_local9, _local10, _local6));
case 4:
return (fromFloats(_local11, _local9, _local6));
case 5:
return (fromFloats(_local6, _local9, _local10));
};
return (0);
}
public static function fromFloats(_arg1:Number, _arg2:Number, _arg3:Number):int{
return ((((65536 * int((_arg1 * 0xFF))) + (0x0100 * int((_arg2 * 0xFF)))) + int((_arg3 * 0xFF))));
}
public static function fromInts(_arg1:int, _arg2:int, _arg3:int):int{
return ((((65536 * _arg1) + (0x0100 * _arg2)) + _arg3));
}
public static function fromIntsCheck(_arg1:int, _arg2:int, _arg3:int):int{
_arg1 = Math.max(0, Math.min(0xFF, _arg1));
_arg2 = Math.max(0, Math.min(0xFF, _arg2));
_arg3 = Math.max(0, Math.min(0xFF, _arg3));
return ((((65536 * _arg1) + (0x0100 * _arg2)) + _arg3));
}
}
}//package away3d.core.utils
Section 93
//Debug (away3d.core.utils.Debug)
package away3d.core.utils {
public class Debug {
public static var active:Boolean = false;
public static var warningsAsErrors:Boolean = false;
public static function clear():void{
}
public static function delimiter():void{
}
public static function trace(_arg1:Object):void{
if (active){
dotrace(_arg1);
};
}
public static function warning(_arg1:Object):void{
if (warningsAsErrors){
error(_arg1);
return;
};
trace(("WARNING: " + _arg1));
}
public static function error(_arg1:Object):void{
trace(("ERROR: " + _arg1));
throw (new Error(_arg1));
}
}
}//package away3d.core.utils
private const dotrace:Function = function (_arg1:Object):void{
trace(_arg1);
};
Section 94
//DofCache (away3d.core.utils.DofCache)
package away3d.core.utils {
import flash.display.*;
import flash.utils.*;
import flash.geom.*;
import flash.filters.*;
public class DofCache {
private var bitmaps:Array;
private var levels:Number;
private var maxBitmap:BitmapData;
private var minBitmap:BitmapData;
public static var focus:Number;
public static var aperture:Number = 22;
public static var maxblur:Number = 150;
public static var doflevels:Number = 16;
public static var usedof:Boolean = false;
private static var caches:Dictionary = new Dictionary();
public function DofCache(_arg1:Number, _arg2:BitmapData){
var _local6:BlurFilter;
var _local7:int;
var _local8:BitmapData;
super();
this.levels = _arg1;
var _local3:Matrix = new Matrix();
var _local4:Point = new Point(0, 0);
bitmaps = new Array(_arg1);
var _local5:Number = 0;
while (_local5 < _arg1) {
_local6 = new BlurFilter((2 + ((maxblur * _local5) / _arg1)), (2 + ((maxblur * _local5) / _arg1)), 4);
_local3.identity();
_local7 = (_arg2.width * (1 + (_local5 / (_arg1 / 2))));
_local3.translate((-(_arg2.width) / 2), (-(_arg2.height) / 2));
_local3.translate((_local7 / 2), (_local7 / 2));
_local8 = new BitmapData(_local7, _local7, true, 0);
_local8.draw(_arg2, _local3);
_local8.applyFilter(_local8, _local8.rect, _local4, _local6);
bitmaps[_local5] = _local8;
_local5++;
};
minBitmap = bitmaps[0];
maxBitmap = bitmaps[(bitmaps.length - 1)];
}
public function getBitmap(_arg1:Number):BitmapData{
var _local2:Number = (focus - _arg1);
if ((focus - _arg1) < 0){
_local2 = -(_local2);
};
_local2 = (_local2 / aperture);
_local2 = Math.floor(_local2);
if (_local2 > (levels - 1)){
return (maxBitmap);
};
if (_local2 < 0){
return (minBitmap);
};
return (bitmaps[_local2]);
}
public static function resetDof(_arg1:Boolean):void{
var _local2:DofCache;
usedof = _arg1;
for each (_local2 in caches) {
if (!_arg1){
_local2 = new DofCache(1, _local2.bitmaps[0]);
} else {
_local2 = new DofCache(doflevels, _local2.bitmaps[0]);
};
};
}
public static function getDofCache(_arg1:BitmapData):DofCache{
if (caches[_arg1] == null){
if (!usedof){
caches[_arg1] = new DofCache(1, _arg1);
} else {
caches[_arg1] = new DofCache(doflevels, _arg1);
};
};
return (caches[_arg1]);
}
}
}//package away3d.core.utils
Section 95
//DrawPrimitiveStore (away3d.core.utils.DrawPrimitiveStore)
package away3d.core.utils {
import flash.display.*;
import away3d.core.base.*;
import away3d.materials.*;
import away3d.core.draw.*;
import away3d.containers.*;
import away3d.core.block.*;
import away3d.core.render.*;
import flash.utils.*;
public class DrawPrimitiveStore {
private var _screenVertices:Array;
private var _screenIndices:Array;
private var _screenCommands:Array;
private var _indexDictionary:Dictionary;
private var _index:int;
private var _length:int;
private var _object:Object;
private var _vertex:Object;
private var _source:Object3D;
private var _session:AbstractRenderSession;
private var _sv:ScreenVertex;
private var _sprite:DrawSprite;
private var _seg:DrawSegment;
private var _tri:DrawTriangle;
private var _array:Array;
private var _cblocker:ConvexBlocker;
private var _sbitmap:DrawScaledBitmap;
private var _dobject:DrawDisplayObject;
private var _svArray:Array;
private var _svStore:Array;
private var _dtDictionary:Dictionary;
private var _dtArray:Array;
private var _dtStore:Array;
private var _dsDictionary:Dictionary;
private var _dsArray:Array;
private var _dsStore:Array;
private var _dbDictionary:Dictionary;
private var _dbArray:Array;
private var _dbStore:Array;
private var _cbDictionary:Dictionary;
private var _cbArray:Array;
private var _cbStore:Array;
private var _sbDictionary:Dictionary;
private var _sbArray:Array;
private var _sbStore:Array;
private var _doDictionary:Dictionary;
private var _doArray:Array;
private var _doStore:Array;
public var view:View3D;
public var blockerDictionary:Dictionary;
public function DrawPrimitiveStore(){
_screenVertices = new Array();
_screenIndices = new Array();
_screenCommands = new Array();
_array = new Array();
_svStore = [];
_dtDictionary = new Dictionary(true);
_dtStore = [];
_dsDictionary = new Dictionary(true);
_dsStore = [];
_dbDictionary = new Dictionary(true);
_dbStore = [];
_cbDictionary = new Dictionary(true);
_cbStore = [];
_sbDictionary = new Dictionary(true);
_sbStore = [];
_doDictionary = new Dictionary(true);
_doStore = [];
blockerDictionary = new Dictionary(true);
super();
}
public function reset():void{
for (_object in _dtDictionary) {
_session = (_object as AbstractRenderSession);
if (_session.updated){
_dtArray = (_dtDictionary[_session] as Array);
if (_dtArray.length){
_dtStore = _dtStore.concat(_dtArray);
_dtArray.length = 0;
};
};
};
for (_object in _dsDictionary) {
_session = (_object as AbstractRenderSession);
if (_session.updated){
_dsArray = (_dsDictionary[_session] as Array);
if (_dsArray.length){
_dsStore = _dsStore.concat(_dsArray);
_dsArray.length = 0;
};
};
};
for (_object in _dbDictionary) {
_session = (_object as AbstractRenderSession);
if (_session.updated){
_dbArray = (_dbDictionary[_session] as Array);
if (_dbArray.length){
_dbStore = _dbStore.concat(_dbArray);
_dbArray.length = 0;
};
};
};
for (_object in _cbDictionary) {
_session = (_object as AbstractRenderSession);
if (_session.updated){
_cbArray = (_cbDictionary[_session] as Array);
if (_cbArray.length){
_cbStore = _cbStore.concat(_cbArray);
_cbArray.length = 0;
};
};
};
for (_object in _sbDictionary) {
_session = (_object as AbstractRenderSession);
if (_session.updated){
_sbArray = (_sbDictionary[_session] as Array);
if (_sbArray.length){
_sbStore = _sbStore.concat(_sbArray);
_sbArray.length = 0;
};
};
};
for (_object in _doDictionary) {
_session = (_object as AbstractRenderSession);
if (_session.updated){
_doArray = (_doDictionary[_session] as Array);
if (_doArray.length){
_doStore = _doStore.concat(_doArray);
_doArray.length = 0;
};
};
};
}
public function getScreenVertices(_arg1:int):Array{
return (((_screenVertices[_arg1]) || ((_screenVertices[_arg1] = []))));
}
public function getScreenIndices(_arg1:int):Array{
return (((_screenIndices[_arg1]) || ((_screenIndices[_arg1] = []))));
}
public function getScreenCommands(_arg1:int):Array{
return (((_screenCommands[_arg1]) || ((_screenCommands[_arg1] = []))));
}
public function createDrawSprite(_arg1:Object3D, _arg2:SpriteVO, _arg3:Material, _arg4:Array, _arg5:Array, _arg6:uint, _arg7:Number, _arg8:Boolean=false):DrawSprite{
if (!(_dbArray = _dbDictionary[_arg1.session])){
_dbArray = (_dbDictionary[_arg1.session] = []);
};
if (_dbStore.length){
_dbArray.push((_sprite = _dbStore.pop()));
} else {
_dbArray.push((_sprite = new DrawSprite()));
_sprite.view = view;
_sprite.create = createDrawSprite;
};
_sprite.generated = _arg8;
_sprite.source = _arg1;
_sprite.material = _arg3;
_sprite.spriteVO = _arg2;
_sprite.screenVertices = _arg4;
_sprite.screenIndices = _arg5;
_sprite.index = _arg6;
_sprite.width = _arg2.width;
_sprite.height = _arg2.height;
_sprite.rotation = _arg2.rotation;
_sprite.scale = _arg7;
_sprite.calc();
return (_sprite);
}
public function createDrawSegment(_arg1:Object3D, _arg2:SegmentVO, _arg3:Material, _arg4:Array, _arg5:Array, _arg6:Array, _arg7:int, _arg8:int, _arg9:Boolean=false):DrawSegment{
if (!(_dsArray = _dsDictionary[_arg1.session])){
_dsArray = (_dsDictionary[_arg1.session] = []);
};
if (_dsStore.length){
_dsArray[_dsArray.length] = (_seg = _dsStore.pop());
} else {
_dsArray[_dsArray.length] = (_seg = new DrawSegment());
_seg.view = view;
_seg.create = createDrawSegment;
};
_seg.generated = _arg9;
_seg.source = _arg1;
_seg.segmentVO = _arg2;
_seg.material = _arg3;
_seg.screenVertices = _arg4;
_seg.screenIndices = _arg5;
_seg.screenCommands = _arg6;
_seg.startIndex = _arg7;
_seg.endIndex = _arg8;
_seg.calc();
return (_seg);
}
public function createDrawTriangle(_arg1:Object3D, _arg2:FaceVO, _arg3:Material, _arg4:Array, _arg5:Array, _arg6:Array, _arg7:int, _arg8:int, _arg9:UV, _arg10:UV, _arg11:UV, _arg12:Boolean=false):DrawTriangle{
if (!(_dtArray = _dtDictionary[_arg1.session])){
_dtArray = (_dtDictionary[_arg1.session] = []);
};
if (_dtStore.length){
_dtArray[_dtArray.length] = (_tri = _dtStore.pop());
} else {
_dtArray[_dtArray.length] = (_tri = new DrawTriangle());
_tri.view = view;
_tri.create = createDrawTriangle;
};
_tri.reverseArea = _arg2.reverseArea;
_tri.generated = _arg12;
_tri.source = _arg1;
_tri.faceVO = _arg2;
_tri.material = _arg3;
_tri.screenVertices = _arg4;
_tri.screenIndices = _arg5;
_tri.screenCommands = _arg6;
_tri.startIndex = _arg7;
_tri.endIndex = _arg8;
_tri.uv0 = _arg9;
_tri.uv1 = _arg10;
_tri.uv2 = _arg11;
_tri.calc();
return (_tri);
}
public function createConvexBlocker(_arg1:Object3D, _arg2:Array):ConvexBlocker{
if (!(_cbArray = _cbDictionary[_arg1.session])){
_cbArray = (_cbDictionary[_arg1.session] = []);
};
if (_cbStore.length){
_cbArray[_cbArray.length] = (_cblocker = (blockerDictionary[_arg1] = _cbStore.pop()));
} else {
_cbArray[_cbArray.length] = (_cblocker = (blockerDictionary[_arg1] = new ConvexBlocker()));
_cblocker.view = view;
_cblocker.create = createConvexBlocker;
};
_cblocker.source = _arg1;
_cblocker.vertices = _arg2;
_cblocker.calc();
return (_cblocker);
}
public function createDrawScaledBitmap(_arg1:Object3D, _arg2:Array, _arg3:Boolean, _arg4:BitmapData, _arg5:Number, _arg6:Number, _arg7:Boolean=false):DrawScaledBitmap{
if (!(_sbArray = _sbDictionary[_arg1.session])){
_sbArray = (_sbDictionary[_arg1.session] = []);
};
if (_sbStore.length){
_sbArray[_sbArray.length] = (_sbitmap = _sbStore.pop());
} else {
_sbArray[_sbArray.length] = (_sbitmap = new DrawScaledBitmap());
_sbitmap.view = view;
_sbitmap.create = createDrawSegment;
};
_sbitmap.generated = _arg7;
_sbitmap.source = _arg1;
_sbitmap.vx = _arg2[0];
_sbitmap.vy = _arg2[1];
_sbitmap.vz = _arg2[2];
_sbitmap.smooth = _arg3;
_sbitmap.bitmap = _arg4;
_sbitmap.scale = _arg5;
_sbitmap.rotation = _arg6;
_sbitmap.calc();
return (_sbitmap);
}
public function createDrawDisplayObject(_arg1:Object3D, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:AbstractRenderSession, _arg6:DisplayObject, _arg7:Boolean=false):DrawDisplayObject{
if (!(_doArray = _doDictionary[_arg1.session])){
_doArray = (_doDictionary[_arg1.session] = []);
};
if (_doStore.length){
_doArray[_doArray.length] = (_dobject = _doStore.pop());
} else {
_doArray[_doArray.length] = (_dobject = new DrawDisplayObject());
_dobject.view = view;
_dobject.create = createDrawSegment;
};
_dobject.generated = _arg7;
_dobject.source = _arg1;
_dobject.vx = _arg2;
_dobject.vy = _arg3;
_dobject.vz = _arg4;
_dobject.session = _arg5;
_dobject.displayobject = _arg6;
_dobject.calc();
return (_dobject);
}
}
}//package away3d.core.utils
Section 96
//FaceMaterialVO (away3d.core.utils.FaceMaterialVO)
package away3d.core.utils {
import flash.display.*;
import away3d.core.base.*;
import away3d.containers.*;
import flash.geom.*;
public class FaceMaterialVO {
public var source:Object3D;
public var view:View3D;
public var invtexturemapping:Matrix;
public var texturemapping:Matrix;
public var width:int;
public var height:int;
public var color:uint;
public var bitmap:BitmapData;
public var cleared:Boolean;// = true
public var updated:Boolean;// = false
public var invalidated:Boolean;// = true
public var backface:Boolean;// = false
public var resized:Boolean;
public function FaceMaterialVO(_arg1:Object3D=null, _arg2:View3D=null){
texturemapping = new Matrix();
super();
this.source = _arg1;
this.view = _arg2;
}
public function clear():void{
cleared = true;
updated = true;
}
public function resize(_arg1:Number, _arg2:Number, _arg3:Boolean=true):void{
if ((((this.width == _arg1)) && ((this.height == _arg2)))){
return;
};
resized = true;
updated = true;
this.width = _arg1;
this.height = _arg2;
this.color = color;
if (bitmap){
bitmap.dispose();
};
bitmap = new BitmapData(_arg1, _arg2, _arg3, 0);
bitmap.lock();
}
}
}//package away3d.core.utils
Section 97
//FaceNormalShader (away3d.core.utils.FaceNormalShader)
package away3d.core.utils {
import flash.display.*;
import away3d.core.math.*;
import away3d.core.light.*;
import away3d.core.base.*;
import away3d.core.draw.*;
import away3d.containers.*;
import away3d.core.render.*;
public class FaceNormalShader {
private var session:AbstractRenderSession;
private var focus:Number;
private var zoom:Number;
private var persp:Number;
private var v0x:Number;
private var v0y:Number;
private var v0z:Number;
private var v1x:Number;
private var v1y:Number;
private var v1z:Number;
private var v2x:Number;
private var v2y:Number;
private var v2z:Number;
private var d1x:Number;
private var d1y:Number;
private var d1z:Number;
private var d2x:Number;
private var d2y:Number;
private var d2z:Number;
private var pa:Number;
private var pb:Number;
private var pc:Number;
private var pdd:Number;
private var c0x:Number;
private var c0y:Number;
private var c0z:Number;
private var kar:Number;
private var kag:Number;
private var kab:Number;
private var kdr:Number;
private var kdg:Number;
private var kdb:Number;
private var ksr:Number;
private var ksg:Number;
private var ksb:Number;
private var red:Number;
private var green:Number;
private var blue:Number;
private var dfx:Number;
private var dfy:Number;
private var dfz:Number;
private var df:Number;
private var nx:Number;
private var ny:Number;
private var nz:Number;
private var fade:Number;
private var amb:Number;
private var nf:Number;
private var diff:Number;
private var rfx:Number;
private var rfy:Number;
private var rfz:Number;
private var spec:Number;
private var rf:Number;
private var graphics:Graphics;
private var cz:Number;
private var cx:Number;
private var cy:Number;
private var ncz:Number;
private var ncx:Number;
private var ncy:Number;
private var sum:Number;
private var ffz:Number;
private var ffx:Number;
private var ffy:Number;
private var fz:Number;
private var fx:Number;
private var fy:Number;
private var rz:Number;
private var rx:Number;
private var ry:Number;
private var draw_normal:Boolean;// = false
private var draw_fall:Boolean;// = false
private var draw_fall_k:Number;// = 1
private var draw_reflect:Boolean;// = false
private var draw_reflect_k:Number;// = 1
private var _diffuseTransform:Matrix3D;
private var _specularTransform:Matrix3D;
private var _viewPosition:Number3D;
private var _source:Mesh;
private var _view:View3D;
public function getTriangleShade(_arg1:DrawTriangle, _arg2:Number):FaceNormalShaderVO{
var _local3:DirectionalLight;
var _local5:Array;
var _local6:PointLight;
var _local7:uint;
var _local8:uint;
var _local9:uint;
var _local10:Array;
session = _arg1.source.session;
focus = _arg1.view.camera.focus;
zoom = _arg1.view.camera.zoom;
if ((_arg1.endIndex - _arg1.startIndex) > 10){
_local7 = (_arg1.screenIndices[0] * 3);
_local8 = (_arg1.screenIndices[5] * 3);
_local9 = (_arg1.screenIndices[9] * 3);
v0z = _arg1.screenVertices[(_local7 + 2)];
persp = ((1 + (v0z / focus)) / zoom);
v0x = (_arg1.screenVertices[_local7] * persp);
v0y = (_arg1.screenVertices[(_local7 + 1)] * persp);
v1z = _arg1.screenVertices[(_local8 + 2)];
persp = ((1 + (v1z / focus)) / zoom);
v1x = (_arg1.screenVertices[_local8] * persp);
v1y = (_arg1.screenVertices[(_local8 + 1)] * persp);
v2z = _arg1.screenVertices[(_local9 + 2)];
persp = ((1 + (v2z / focus)) / zoom);
v2x = (_arg1.screenVertices[_local9] * persp);
v2y = (_arg1.screenVertices[(_local9 + 1)] * persp);
} else {
v0z = _arg1.v0z;
persp = ((1 + (v0z / focus)) / zoom);
v0x = (_arg1.v0x * persp);
v0y = (_arg1.v0y * persp);
v1z = _arg1.v1z;
persp = ((1 + (v1z / focus)) / zoom);
v1x = (_arg1.v1x * persp);
v1y = (_arg1.v1y * persp);
v2z = _arg1.v2z;
persp = ((1 + (v2z / focus)) / zoom);
v2x = (_arg1.v2x * persp);
v2y = (_arg1.v2y * persp);
};
d1x = (v1x - v0x);
d1y = (v1y - v0y);
d1z = (v1z - v0z);
d2x = (v2x - v0x);
d2y = (v2y - v0y);
d2z = (v2z - v0z);
pa = ((d1y * d2z) - (d1z * d2y));
pb = ((d1z * d2x) - (d1x * d2z));
pc = ((d1x * d2y) - (d1y * d2x));
pdd = Math.sqrt((((pa * pa) + (pb * pb)) + (pc * pc)));
pa = (pa / pdd);
pb = (pb / pdd);
pc = (pc / pdd);
c0x = (((v0x + v1x) + v2x) / 3);
c0y = (((v0y + v1y) + v2y) / 3);
c0z = (((v0z + v1z) + v2z) / 3);
kar = (kag = (kab = (kdr = (kdg = (kdb = (ksr = (ksg = (ksb = 0))))))));
_source = (_arg1.source as Mesh);
_view = _arg1.view;
var _local4:Array = _arg1.source.lightarray.directionals;
for each (_local3 in _local4) {
_diffuseTransform = _local3.diffuseTransform[_source];
red = _local3.red;
green = _local3.green;
blue = _local3.blue;
dfx = _diffuseTransform.szx;
dfy = _diffuseTransform.szy;
dfz = _diffuseTransform.szz;
nx = _arg1.faceVO.face.normal.x;
ny = _arg1.faceVO.face.normal.y;
nz = _arg1.faceVO.face.normal.z;
amb = _local3.ambient;
kar = (kar + (red * amb));
kag = (kag + (green * amb));
kab = (kab + (blue * amb));
nf = (((dfx * nx) + (dfy * ny)) + (dfz * nz));
if (nf < 0){
} else {
diff = (_local3.diffuse * nf);
kdr = (kdr + (red * diff));
kdg = (kdg + (green * diff));
kdb = (kdb + (blue * diff));
_specularTransform = _local3.specularTransform[_source][_view];
rfx = _specularTransform.szx;
rfy = _specularTransform.szy;
rfz = _specularTransform.szz;
rf = (((rfx * nx) + (rfy * ny)) + (rfz * nz));
spec = (_local3.specular * Math.pow(rf, _arg2));
ksr = (ksr + (red * spec));
ksg = (ksg + (green * spec));
ksb = (ksb + (blue * spec));
};
};
_local5 = _arg1.source.lightarray.points;
for each (_local6 in _local5) {
red = _local6.red;
green = _local6.green;
blue = _local6.blue;
_viewPosition = _local6.viewPositions[_arg1.view];
dfx = (_viewPosition.x - c0x);
dfy = (_viewPosition.y - c0y);
dfz = (_viewPosition.z - c0z);
df = Math.sqrt((((dfx * dfx) + (dfy * dfy)) + (dfz * dfz)));
dfx = (dfx / df);
dfy = (dfy / df);
dfz = (dfz / df);
fade = ((1 / df) / df);
amb = _local6.ambient;
kar = (kar + (red * amb));
kag = (kag + (green * amb));
kab = (kab + (blue * amb));
nf = (((dfx * pa) + (dfy * pb)) + (dfz * pc));
if (nf < 0){
} else {
diff = (((_local6.diffuse * fade) * nf) * 250000);
kdr = (kdr + (red * diff));
kdg = (kdg + (green * diff));
kdb = (kdb + (blue * diff));
rfz = (dfz - ((2 * nf) * pc));
if (rfz < 0){
} else {
rfx = (dfx - ((2 * nf) * pa));
rfy = (dfy - ((2 * nf) * pb));
spec = (((_local6.specular * fade) * Math.pow(rfz, _arg2)) * 250000);
ksr = (ksr + (red * spec));
ksg = (ksg + (green * spec));
ksb = (ksb + (blue * spec));
};
};
};
if (((((draw_fall) || (draw_reflect))) || (draw_normal))){
graphics = session.graphics;
cz = c0z;
cx = ((c0x * zoom) / (1 + (cz / focus)));
cy = ((c0y * zoom) / (1 + (cz / focus)));
if (draw_normal){
ncz = (c0z + (30 * pc));
ncx = ((((c0x + (30 * pa)) * zoom) * focus) / (focus + ncz));
ncy = ((((c0y + (30 * pb)) * zoom) * focus) / (focus + ncz));
graphics.lineStyle(1, 0, 1);
graphics.moveTo(cx, cy);
graphics.lineTo(ncx, ncy);
graphics.moveTo(cx, cy);
graphics.drawCircle(cx, cy, 2);
};
if (((draw_fall) || (draw_reflect))){
_local10 = _arg1.source.lightarray.points;
for each (_local6 in _local10) {
red = _local6.red;
green = _local6.green;
blue = _local6.blue;
sum = (((red + green) + blue) / 0xFF);
red = (red / sum);
green = (green / sum);
blue = (blue / sum);
dfx = (_viewPosition.x - c0x);
dfy = (_viewPosition.y - c0y);
dfz = (_viewPosition.z - c0z);
df = Math.sqrt((((dfx * dfx) + (dfy * dfy)) + (dfz * dfz)));
dfx = (dfx / df);
dfy = (dfy / df);
dfz = (dfz / df);
nf = (((dfx * pa) + (dfy * pb)) + (dfz * pc));
if (nf < 0){
} else {
if (draw_fall){
ffz = (c0z + ((30 * dfz) * (1 - draw_fall_k)));
ffx = ((((c0x + ((30 * dfx) * (1 - draw_fall_k))) * zoom) * focus) / (focus + ffz));
ffy = ((((c0y + ((30 * dfy) * (1 - draw_fall_k))) * zoom) * focus) / (focus + ffz));
fz = (c0z + (30 * dfz));
fx = ((((c0x + (30 * dfx)) * zoom) * focus) / (focus + fz));
fy = ((((c0y + (30 * dfy)) * zoom) * focus) / (focus + fz));
graphics.lineStyle(1, (((int(red) * 65536) + (int(green) * 0x0100)) + int(blue)), 1);
graphics.moveTo(ffx, ffy);
graphics.lineTo(fx, fy);
graphics.moveTo(ffx, ffy);
};
if (draw_reflect){
rfx = (dfx - ((2 * nf) * pa));
rfy = (dfy - ((2 * nf) * pb));
rfz = (dfz - ((2 * nf) * pc));
rz = (c0z - ((30 * rfz) * draw_reflect_k));
rx = ((((c0x - ((30 * rfx) * draw_reflect_k)) * zoom) * focus) / (focus + rz));
ry = ((((c0y - ((30 * rfy) * draw_reflect_k)) * zoom) * focus) / (focus + rz));
graphics.lineStyle(1, (((int((red * 0.5)) * 65536) + (int((green * 0.5)) * 0x0100)) + int((blue * 0.5))), 1);
graphics.moveTo(cx, cy);
graphics.lineTo(rx, ry);
graphics.moveTo(cx, cy);
};
};
};
};
};
return (new FaceNormalShaderVO(kar, kag, kab, kdr, kdg, kdb, ksr, ksg, ksb));
}
}
}//package away3d.core.utils
Section 98
//FaceNormalShaderVO (away3d.core.utils.FaceNormalShaderVO)
package away3d.core.utils {
public class FaceNormalShaderVO {
public var kar:Number;
public var kag:Number;
public var kab:Number;
public var kdr:Number;
public var kdg:Number;
public var kdb:Number;
public var ksr:Number;
public var ksg:Number;
public var ksb:Number;
public function FaceNormalShaderVO(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:Number, _arg7:Number, _arg8:Number, _arg9:Number){
this.kar = _arg1;
this.kag = _arg2;
this.kab = _arg3;
this.kdr = _arg4;
this.kdg = _arg5;
this.kdb = _arg6;
this.ksr = _arg7;
this.ksg = _arg8;
this.ksb = _arg9;
}
}
}//package away3d.core.utils
Section 99
//FaceVO (away3d.core.utils.FaceVO)
package away3d.core.utils {
import away3d.core.base.*;
import away3d.materials.*;
public class FaceVO {
public var generated:Boolean;
public var commands:Array;
public var vertices:Array;
public var v0:Vertex;
public var v1:Vertex;
public var v2:Vertex;
public var uv0:UV;
public var uv1:UV;
public var uv2:UV;
public var material:Material;
public var back:Material;
public var face:Face;
public var reverseArea:Boolean;
public function FaceVO(){
commands = new Array();
vertices = new Array();
super();
}
public function get maxU():Number{
if (uv0.u > uv1.u){
if (uv0.u > uv2.u){
return (uv0.u);
};
return (uv2.u);
//unresolved jump
};
if (uv1.u > uv2.u){
return (uv1.u);
};
return (uv2.u);
}
public function get minU():Number{
if (uv0.u < uv1.u){
if (uv0.u < uv2.u){
return (uv0.u);
};
return (uv2.u);
//unresolved jump
};
if (uv1.u < uv2.u){
return (uv1.u);
};
return (uv2.u);
}
public function get maxV():Number{
if (uv0.v > uv1.v){
if (uv0.v > uv2.v){
return (uv0.v);
};
return (uv2.v);
//unresolved jump
};
if (uv1.v > uv2.v){
return (uv1.v);
};
return (uv2.v);
}
public function get minV():Number{
if (uv0.v < uv1.v){
if (uv0.v < uv2.v){
return (uv0.v);
};
return (uv2.v);
//unresolved jump
};
if (uv1.v < uv2.v){
return (uv1.v);
};
return (uv2.v);
}
}
}//package away3d.core.utils
Section 100
//IClonable (away3d.core.utils.IClonable)
package away3d.core.utils {
import away3d.core.base.*;
public interface IClonable {
function clone(_arg1:Object3D=null):Object3D;
}
}//package away3d.core.utils
Section 101
//Init (away3d.core.utils.Init)
package away3d.core.utils {
import flash.display.*;
import away3d.core.math.*;
import away3d.core.base.*;
import away3d.primitives.data.*;
import away3d.materials.*;
public class Init {
var init:Object;
private static var inits:Array = [];
public function Init(_arg1:Object){
this.init = _arg1;
}
public function getInt(_arg1:String, _arg2:int, _arg3:Object=null):int{
var _local5:int;
var _local6:int;
if (init == null){
return (_arg2);
};
if (!init.hasOwnProperty(_arg1)){
return (_arg2);
};
var _local4:int = init[_arg1];
if (_arg3 != null){
if (_arg3.hasOwnProperty("min")){
_local5 = _arg3["min"];
if (_local4 < _local5){
_local4 = _local5;
};
};
if (_arg3.hasOwnProperty("max")){
_local6 = _arg3["max"];
if (_local4 > _local6){
_local4 = _local6;
};
};
};
delete init[_arg1];
return (_local4);
}
public function getNumber(_arg1:String, _arg2:Number, _arg3:Object=null):Number{
var _local5:Number;
var _local6:Number;
if (init == null){
return (_arg2);
};
if (!init.hasOwnProperty(_arg1)){
return (_arg2);
};
var _local4:Number = init[_arg1];
if (_arg3 != null){
if (_arg3.hasOwnProperty("min")){
_local5 = _arg3["min"];
if (_local4 < _local5){
_local4 = _local5;
};
};
if (_arg3.hasOwnProperty("max")){
_local6 = _arg3["max"];
if (_local4 > _local6){
_local4 = _local6;
};
};
};
delete init[_arg1];
return (_local4);
}
public function getString(_arg1:String, _arg2:String):String{
if (init == null){
return (_arg2);
};
if (!init.hasOwnProperty(_arg1)){
return (_arg2);
};
var _local3:String = init[_arg1];
delete init[_arg1];
return (_local3);
}
public function getBoolean(_arg1:String, _arg2:Boolean):Boolean{
if (init == null){
return (_arg2);
};
if (!init.hasOwnProperty(_arg1)){
return (_arg2);
};
var _local3:Boolean = init[_arg1];
delete init[_arg1];
return (_local3);
}
public function getObject(_arg1:String, _arg2:Class=null):Object{
if (init == null){
return (null);
};
if (!init.hasOwnProperty(_arg1)){
return (null);
};
var _local3:Object = init[_arg1];
delete init[_arg1];
if (_local3 == null){
return (null);
};
if (_arg2 != null){
if (!(_local3 is _arg2)){
throw (new CastError(((((("Parameter \"" + _arg1) + "\" is not of class ") + _arg2) + ": ") + _local3)));
};
};
return (_local3);
}
public function getObjectOrInit(_arg1:String, _arg2:Class=null):Object{
if (init == null){
return (null);
};
if (!init.hasOwnProperty(_arg1)){
return (null);
};
var _local3:Object = init[_arg1];
delete init[_arg1];
if (_local3 == null){
return (null);
};
if (_arg2 != null){
if (!(_local3 is _arg2)){
return (new _arg2(_local3));
};
};
return (_local3);
}
public function getObject3D(_arg1:String):Object3D{
return ((getObject(_arg1, Object3D) as Object3D));
}
public function getNumber3D(_arg1:String):Number3D{
return ((getObject(_arg1, Number3D) as Number3D));
}
public function getPosition(_arg1:String):Number3D{
var _local3:Object3D;
var _local2:Object = getObject(_arg1);
if (_local2 == null){
return (null);
};
if ((_local2 is Number3D)){
return ((_local2 as Number3D));
};
if ((_local2 is Object3D)){
_local3 = (_local2 as Object3D);
return ((_local3.scene) ? _local3.scenePosition : _local3.position);
};
if ((_local2 is String)){
if (_local2 == "center"){
return (new Number3D());
};
};
throw (new CastError(("Cast get position of " + _local2)));
}
public function getArray(_arg1:String):Array{
if (init == null){
return ([]);
};
if (!init.hasOwnProperty(_arg1)){
return ([]);
};
var _local2:Array = init[_arg1];
delete init[_arg1];
return (_local2);
}
public function getInit(_arg1:String):Init{
if (init == null){
return (new Init(null));
};
if (!init.hasOwnProperty(_arg1)){
return (new Init(null));
};
var _local2:Init = Init.parse(init[_arg1]);
delete init[_arg1];
return (_local2);
}
public function getCubeMaterials(_arg1:String):CubeMaterialsData{
var _local2:CubeMaterialsData;
if (init == null){
return (null);
};
if (!init.hasOwnProperty(_arg1)){
return (null);
};
if ((init[_arg1] is CubeMaterialsData)){
_local2 = (init[_arg1] as CubeMaterialsData);
} else {
if ((init[_arg1] is Object)){
_local2 = new CubeMaterialsData(init[_arg1]);
};
};
delete init[_arg1];
return (_local2);
}
public function getColor(_arg1:String, _arg2:uint):uint{
if (init == null){
return (_arg2);
};
if (!init.hasOwnProperty(_arg1)){
return (_arg2);
};
var _local3:uint = Cast.color(init[_arg1]);
delete init[_arg1];
return (_local3);
}
public function getBitmap(_arg1:String):BitmapData{
if (init == null){
return (null);
};
if (!init.hasOwnProperty(_arg1)){
return (null);
};
var _local2:BitmapData = Cast.bitmap(init[_arg1]);
delete init[_arg1];
return (_local2);
}
public function getMaterial(_arg1:String):Material{
if (init == null){
return (null);
};
if (!init.hasOwnProperty(_arg1)){
return (null);
};
var _local2:Material = Cast.material(init[_arg1]);
delete init[_arg1];
return (_local2);
}
function removeFromCheck():void{
if (init == null){
return;
};
init["dontCheckUnused"] = true;
}
function addForCheck():void{
if (init == null){
return;
};
init["dontCheckUnused"] = false;
inits.push(init);
}
public static function parse(_arg1:Object):Init{
if (_arg1 == null){
return (new Init(null));
};
if ((_arg1 is Init)){
return ((_arg1 as Init));
};
inits.push(_arg1);
return (new Init(_arg1));
}
static function checkUnusedArguments():void{
var _local2:Object;
var _local3:String;
var _local4:String;
if (inits.length == 0){
return;
};
var _local1:Array = inits;
inits = [];
for each (_local2 in _local1) {
if (_local2.hasOwnProperty("dontCheckUnused")){
//unresolved if
} else {
_local3 = null;
for (_local4 in _local2) {
if (_local4 == "dontCheckUnused"){
} else {
if (_local3 == null){
_local3 = "";
} else {
_local3 = (_local3 + ", ");
};
_local3 = (_local3 + ((_local4 + ":") + _local2[_local4]));
};
};
if (_local3 != null){
Debug.warning((("Unused arguments: {" + _local3) + "}"));
};
};
};
}
}
}//package away3d.core.utils
Section 102
//SegmentVO (away3d.core.utils.SegmentVO)
package away3d.core.utils {
import away3d.core.base.*;
import away3d.materials.*;
public class SegmentVO {
public var generated:Boolean;
public var commands:Array;
public var vertices:Array;
public var v0:Vertex;
public var v1:Vertex;
public var material:Material;
public function SegmentVO(){
commands = new Array();
vertices = new Array();
super();
}
}
}//package away3d.core.utils
Section 103
//SpriteVO (away3d.core.utils.SpriteVO)
package away3d.core.utils {
import away3d.core.base.*;
import away3d.materials.*;
import away3d.sprites.*;
public class SpriteVO {
public var vertex:Vertex;
public var command:String;
public var material:Material;
public var width:Number;
public var height:Number;
public var rotation:Number;
public var scaling:Number;
public var sprite3d:Sprite3D;
}
}//package away3d.core.utils
Section 104
//ValueObject (away3d.core.utils.ValueObject)
package away3d.core.utils {
import flash.events.*;
public class ValueObject extends EventDispatcher {
private static var changed:Event;
public function addOnChange(_arg1:Function):void{
addEventListener("changed", _arg1, false, 0, true);
}
public function removeOnChange(_arg1:Function):void{
removeEventListener("changed", _arg1, false);
}
protected function notifyChange():void{
if (!hasEventListener("changed")){
return;
};
if (changed == null){
changed = new Event("changed");
};
dispatchEvent(changed);
}
}
}//package away3d.core.utils
Section 105
//AnimatorEvent (away3d.events.AnimatorEvent)
package away3d.events {
import flash.events.*;
import away3d.animators.*;
public class AnimatorEvent extends Event {
public var animator:Animator;
public static const START:String = "start";
public static const STOP:String = "stop";
public static const CYCLE:String = "cycle";
public static const ENTER_KEY_FRAME:String = "enterKeyFrame";
public static const SEQUENCE_UPDATE:String = "sequenceUpdate";
public static const SEQUENCE_DONE:String = "sequenceDone";
public function AnimatorEvent(_arg1:String, _arg2:Animator){
super(_arg1);
this.animator = _arg2;
}
override public function clone():Event{
return (new AnimatorEvent(type, animator));
}
}
}//package away3d.events
Section 106
//BSPBuildEvent (away3d.events.BSPBuildEvent)
package away3d.events {
import flash.events.*;
public class BSPBuildEvent extends Event {
public var percent:Number;// = 0
public var count:int;// = 0
public var percentPart:Number;// = 0
public var totalParts:Number;// = 1
public var message:String;
public var data:Object;
public static const BUILD_COMPLETE:String = "buildcomplete";
public static const BUILD_PROGRESS:String = "buildprogress";
public static const BUILD_COUNT:String = "buildcount";
public static const BUILD_WARNING:String = "buildwarning";
public static const BUILD_ERROR:String = "builderror";
public static const BUILD_CANCELED:String = "buildCanceled";
public function BSPBuildEvent(_arg1:String, _arg2:Boolean=false, _arg3:Boolean=false){
super(_arg1, _arg2, _arg3);
}
override public function clone():Event{
var _local1:BSPBuildEvent = new BSPBuildEvent(type);
_local1.data = data;
_local1.message = message;
_local1.percent = percent;
_local1.count = count;
_local1.percentPart = percentPart;
_local1.totalParts = totalParts;
return (_local1);
}
}
}//package away3d.events
Section 107
//CameraEvent (away3d.events.CameraEvent)
package away3d.events {
import flash.events.*;
import away3d.cameras.*;
public class CameraEvent extends Event {
public var camera:Camera3D;
public static const CAMERA_UPDATED:String = "cameraUpdated";
public function CameraEvent(_arg1:String, _arg2:Camera3D){
super(_arg1);
this.camera = _arg2;
}
override public function clone():Event{
return (new CameraEvent(type, camera));
}
}
}//package away3d.events
Section 108
//ClippingEvent (away3d.events.ClippingEvent)
package away3d.events {
import flash.events.*;
import away3d.core.clip.*;
public class ClippingEvent extends Event {
public var clipping:Clipping;
public static const CLIPPING_UPDATED:String = "clippingUpdated";
public static const SCREEN_UPDATED:String = "screenUpdated";
public function ClippingEvent(_arg1:String, _arg2:Clipping){
super(_arg1);
this.clipping = _arg2;
}
override public function clone():Event{
return (new ClippingEvent(type, clipping));
}
}
}//package away3d.events
Section 109
//ElementEvent (away3d.events.ElementEvent)
package away3d.events {
import flash.events.*;
import away3d.core.base.*;
public class ElementEvent extends Event {
public var element:Element;
public static const MAPPING_CHANGED:String = "mappingChanged";
public static const VERTEX_CHANGED:String = "vertexChanged";
public static const VERTEXVALUE_CHANGED:String = "vertexvalueChanged";
public static const VISIBLE_CHANGED:String = "visibleChanged";
public function ElementEvent(_arg1:String, _arg2:Element){
super(_arg1);
this.element = _arg2;
}
override public function clone():Event{
return (new ElementEvent(type, element));
}
}
}//package away3d.events
Section 110
//GeometryEvent (away3d.events.GeometryEvent)
package away3d.events {
import flash.events.*;
import away3d.core.base.*;
public class GeometryEvent extends Event {
public var geometry:Geometry;
public static const DIMENSIONS_CHANGED:String = "dimensionsChanged";
public function GeometryEvent(_arg1:String, _arg2:Geometry){
super(_arg1);
this.geometry = _arg2;
}
override public function clone():Event{
return (new GeometryEvent(type, geometry));
}
}
}//package away3d.events
Section 111
//MaterialEvent (away3d.events.MaterialEvent)
package away3d.events {
import flash.events.*;
import away3d.materials.*;
public class MaterialEvent extends Event {
public var material:Material;
public var extra:Object;
public static const LOAD_ERROR:String = "loadError";
public static const LOAD_PROGRESS:String = "loadProgress";
public static const LOAD_SUCCESS:String = "loadSuccess";
public static const MATERIAL_UPDATED:String = "materialUpdated";
public static const MATERIAL_CHANGED:String = "materialChanged";
public function MaterialEvent(_arg1:String, _arg2:Material){
super(_arg1);
this.material = _arg2;
}
override public function clone():Event{
return (new MaterialEvent(type, material));
}
}
}//package away3d.events
Section 112
//MouseEvent3D (away3d.events.MouseEvent3D)
package away3d.events {
import flash.events.*;
import away3d.core.base.*;
import away3d.materials.*;
import away3d.core.draw.*;
import away3d.containers.*;
public class MouseEvent3D extends Event {
public var screenX:Number;
public var screenY:Number;
public var screenZ:Number;
public var sceneX:Number;
public var sceneY:Number;
public var sceneZ:Number;
public var view:View3D;
public var object:Object3D;
public var element:Element;
public var drawpri:DrawPrimitive;
public var material:Material;
public var uv:UV;
public var ctrlKey:Boolean;
public var shiftKey:Boolean;
public static const MOUSE_OVER:String = "mouseOver3d";
public static const MOUSE_OUT:String = "mouseOut3d";
public static const MOUSE_UP:String = "mouseUp3d";
public static const MOUSE_DOWN:String = "mouseDown3d";
public static const MOUSE_MOVE:String = "mouseMove3d";
public static const ROLL_OVER:String = "rollOver3d";
public static const ROLL_OUT:String = "rollOut3d";
public function MouseEvent3D(_arg1:String){
super(_arg1, false, true);
}
override public function clone():Event{
var _local1:MouseEvent3D = new MouseEvent3D(type);
if (isDefaultPrevented()){
_local1.preventDefault();
};
_local1.screenX = screenX;
_local1.screenY = screenY;
_local1.screenZ = screenZ;
_local1.sceneX = sceneX;
_local1.sceneY = sceneY;
_local1.sceneZ = sceneZ;
_local1.view = view;
_local1.object = object;
_local1.element = element;
_local1.drawpri = drawpri;
_local1.material = material;
_local1.uv = uv;
_local1.ctrlKey = ctrlKey;
_local1.shiftKey = shiftKey;
return (_local1);
}
}
}//package away3d.events
Section 113
//Object3DEvent (away3d.events.Object3DEvent)
package away3d.events {
import flash.events.*;
import away3d.core.base.*;
public class Object3DEvent extends Event {
public var object:Object3D;
public static const PARENT_UPDATED:String = "parentUpdated";
public static const TRANSFORM_CHANGED:String = "transformChanged";
public static const SCENETRANSFORM_CHANGED:String = "scenetransformChanged";
public static const SCENE_CHANGED:String = "sceneChanged";
public static const SESSION_CHANGED:String = "sessionChanged";
public static const SESSION_UPDATED:String = "sessionUpdated";
public static const DIMENSIONS_CHANGED:String = "dimensionsChanged";
public function Object3DEvent(_arg1:String, _arg2:Object3D){
super(_arg1);
this.object = _arg2;
}
override public function clone():Event{
return (new Object3DEvent(type, object));
}
}
}//package away3d.events
Section 114
//SessionEvent (away3d.events.SessionEvent)
package away3d.events {
import flash.events.*;
import away3d.core.render.*;
public class SessionEvent extends Event {
public var session:AbstractRenderSession;
public static const SESSION_UPDATED:String = "sessionUpdated";
public function SessionEvent(_arg1:String, _arg2:AbstractRenderSession){
super(_arg1);
this.session = _arg2;
}
override public function clone():Event{
return (new SessionEvent(type, session));
}
}
}//package away3d.events
Section 115
//ViewEvent (away3d.events.ViewEvent)
package away3d.events {
import flash.events.*;
import away3d.containers.*;
public class ViewEvent extends Event {
public var view:View3D;
public static const UPDATE_SCENE:String = "updateScene";
public static const RENDER_COMPLETE:String = "renderComplete";
public function ViewEvent(_arg1:String, _arg2:View3D){
super(_arg1);
this.view = _arg2;
}
override public function clone():Event{
return (new ViewEvent(type, view));
}
}
}//package away3d.events
Section 116
//BSPMeshManager (away3d.graphs.bsp.BSPMeshManager)
package away3d.graphs.bsp {
import flash.events.*;
import away3d.core.math.*;
import away3d.core.base.*;
import away3d.materials.*;
import away3d.core.geom.*;
import away3d.graphs.bsp.*;
import away3d.events.*;
import away3d.graphs.*;
class BSPMeshManager {
private var _mesh:Mesh;
private var _sourceMesh:Mesh;
private var _splitMeshes:Array;
private var _faces:Array;
private var _vertices:Array;
private var _centerX:Number;
private var _centerY:Number;
private var _centerZ:Number;
private var _extentX:Number;
private var _extentY:Number;
private var _extentZ:Number;
private var _posFaceVerts:Array;
private var _negFaceVerts:Array;
private var _posFaceUV:Array;
private var _negFaceUV:Array;
private var _bspLeaves:Array;
private var _tree:BSPTree;
private var _meshPool:Array;
private var _meshPoolLen:int;// = -1
private var _usedMeshes:Array;
private var _usedMeshLen:int;// = -1
private var _facePool:Array;
private var _facePoolLen:int;// = -1
private var _usedFaces:Array;
private var _usedFaceLen:int;// = -1
private var _vertexPool:Array;
private var _vertexPoolLen:int;// = -1
private var _usedVerts:Array;
private var _usedVertLen:int;// = -1
private var _uvPool:Array;
private var _uvPoolLen:int;// = -1
private var _usedUV:Array;
private var _usedUVLen:int;// = -1
function BSPMeshManager(_arg1:Mesh, _arg2:BSPTree){
_tree = _arg2;
_sourceMesh = (_mesh = _arg1);
_posFaceVerts = new Array();
_negFaceVerts = new Array();
_posFaceUV = new Array();
_negFaceUV = new Array();
_bspLeaves = new Array();
_meshPool = new Array();
_usedMeshes = new Array();
_facePool = new Array();
_usedFaces = new Array();
_vertexPool = new Array();
_usedVerts = new Array();
_uvPool = new Array();
_usedUV = new Array();
_arg1.addOnTransformChange(onTransformChange);
sendDownTree(_tree._rootNode);
}
public function destroy():void{
var _local1:int;
mesh.removeOnTransformChange(onTransformChange);
_local1 = _bspLeaves.length;
while (--_local1 >= 0) {
_bspLeaves[_local1].removeMesh(this);
};
_posFaceVerts = null;
_negFaceVerts = null;
_posFaceUV = null;
_negFaceUV = null;
_bspLeaves = null;
_meshPool = null;
_usedMeshes = null;
_facePool = null;
_usedFaces = null;
_vertexPool = null;
_usedVerts = null;
_uvPool = null;
_usedUV = null;
_splitMeshes = null;
_faces = null;
_vertices = null;
_sourceMesh = null;
_mesh = null;
}
private function onTransformChange(_arg1:Object3DEvent):void{
sendDownTree(_tree._rootNode);
}
private function sendDownTree(_arg1:BSPNode):void{
var _local2:int;
var _local3:Mesh;
if (_arg1 == _tree._rootNode){
update();
cleanUp();
};
do {
if (_arg1._isLeaf){
_local3 = getNewMesh();
addListeners(_local3);
buildMesh(_local3, _faces[_arg1.nodeId]);
_tree.addTemporaryChild(_local3);
_splitMeshes[_arg1.leafId] = _local3;
_bspLeaves.push(_arg1);
_arg1.addMesh(this);
return;
};
_local2 = split(_arg1);
if (_local2 == Plane3D.FRONT){
_arg1 = _arg1._positiveNode;
} else {
if (_local2 == Plane3D.BACK){
_arg1 = _arg1._negativeNode;
};
};
} while (((_arg1) && (!((_local2 == Plane3D.INTERSECT)))));
if (_local2 == Plane3D.INTERSECT){
sendDownTree(_arg1._positiveNode);
if (_arg1._negativeNode){
sendDownTree(_arg1._negativeNode);
};
};
}
private function buildMesh(_arg1:Mesh, _arg2:Array):void{
var _local3:Geometry = _arg1._geometry;
var _local4:Array = _local3.faces;
var _local5:int = _local4.length;
while (--_local5 >= 0) {
_local3.removeFace(Face(_local4[0]));
};
_local5 = _arg2.length;
while (--_local5 >= 0) {
_local3.addFace(Face(_arg2[_local5]));
};
}
private function update():void{
_splitMeshes = [];
_faces = [];
_vertices = [];
_centerX = ((_sourceMesh.maxX + _sourceMesh._minX) * 0.5);
_centerY = ((_sourceMesh._maxY + _sourceMesh._minY) * 0.5);
_centerZ = ((_sourceMesh._maxZ + _sourceMesh._minZ) * 0.5);
_extentX = ((_sourceMesh._maxX - _sourceMesh._minX) * 0.5);
_extentY = ((_sourceMesh._maxY - _sourceMesh._minY) * 0.5);
_extentZ = ((_sourceMesh._maxZ - _sourceMesh._minZ) * 0.5);
}
private function cleanUp():void{
var _local1:Mesh;
var _local2:Face;
var _local3:int;
_local3 = _bspLeaves.length;
while (--_local3 >= 0) {
_bspLeaves[_local3].removeMesh(this);
};
_bspLeaves.length = 0;
while (_usedMeshLen >= 0) {
var _local4 = ++_meshPoolLen;
var _temp1 = _local4;
_local1 = _usedMeshes[_usedMeshLen--];
_meshPool[_temp1] = _local1;
clearListeners(_local1);
_tree.removeTemporaryChild(_local1);
};
while (_usedFaceLen >= 0) {
_local4 = ++_facePoolLen;
var _temp2 = _local4;
_local2 = _usedFaces[_usedFaceLen--];
_facePool[_temp2] = _local2;
_local2.uv0 = (_local2.uv1 = (_local2.uv2 = null));
};
while (_usedVertLen >= 0) {
_local4 = ++_vertexPoolLen;
var _temp3 = _local4;
_vertexPool[_temp3] = _usedVerts[_usedVertLen--];
};
while (_usedUVLen >= 0) {
_local4 = ++_uvPoolLen;
var _temp4 = _local4;
_uvPool[_temp4] = _usedUV[_usedUVLen--];
};
}
private function addListeners(_arg1:Mesh):void{
_arg1.addEventListener(MouseEvent3D.MOUSE_DOWN, forwardEvent);
_arg1.addEventListener(MouseEvent3D.MOUSE_MOVE, forwardEvent);
_arg1.addEventListener(MouseEvent3D.MOUSE_UP, forwardEvent);
_arg1.addEventListener(MouseEvent3D.MOUSE_OUT, forwardEvent);
_arg1.addEventListener(MouseEvent3D.MOUSE_OVER, forwardEvent);
_arg1.addEventListener(MouseEvent3D.ROLL_OUT, forwardEvent);
_arg1.addEventListener(MouseEvent3D.ROLL_OVER, forwardEvent);
}
private function clearListeners(_arg1:Mesh):void{
_arg1.removeEventListener(MouseEvent3D.MOUSE_DOWN, forwardEvent);
_arg1.removeEventListener(MouseEvent3D.MOUSE_MOVE, forwardEvent);
_arg1.removeEventListener(MouseEvent3D.MOUSE_UP, forwardEvent);
_arg1.removeEventListener(MouseEvent3D.MOUSE_OUT, forwardEvent);
_arg1.removeEventListener(MouseEvent3D.MOUSE_OVER, forwardEvent);
_arg1.removeEventListener(MouseEvent3D.ROLL_OUT, forwardEvent);
_arg1.removeEventListener(MouseEvent3D.ROLL_OVER, forwardEvent);
}
private function forwardEvent(_arg1:Event):void{
_sourceMesh.dispatchEvent(_arg1);
}
public function split(_arg1:BSPNode):int{
var _local2:Array;
var _local3:Array;
var _local4:int;
var _local5:Vertex;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local19:Number;
var _local20:Number;
var _local23:Array;
var _local25:Array;
var _local26:int;
var _local6:Plane3D = _arg1._partitionPlane;
var _local18:Matrix3D = _sourceMesh.transform;
var _local21 = !((_arg1._negativeNode == null));
var _local22:Array = [];
var _local24:Array = [];
if (_arg1 == _tree._rootNode){
_local2 = _sourceMesh._geometry.vertices;
_local3 = _sourceMesh._geometry.faces;
} else {
_local2 = _vertices[_arg1.nodeId];
_local3 = _faces[_arg1.nodeId];
};
if (_local21){
_local23 = [];
_local25 = [];
};
_local9 = _local6.a;
_local10 = _local6.b;
_local11 = _local6.c;
_local12 = _local6.d;
_local13 = ((((_local9 * _local18.sxx) + (_local10 * _local18.syx)) + (_local11 * _local18.szx)) + (_local12 * _local18.swx));
_local14 = ((((_local9 * _local18.sxy) + (_local10 * _local18.syy)) + (_local11 * _local18.szy)) + (_local12 * _local18.swy));
_local15 = ((((_local9 * _local18.sxz) + (_local10 * _local18.syz)) + (_local11 * _local18.szz)) + (_local12 * _local18.swz));
_local16 = ((((_local9 * _local18.tx) + (_local10 * _local18.ty)) + (_local11 * _local18.tz)) + (_local12 * _local18.tw));
_local17 = (1 / Math.sqrt((((_local13 * _local13) + (_local14 * _local14)) + (_local15 * _local15))));
_local13 = (_local13 * _local17);
_local14 = (_local14 * _local17);
_local15 = (_local15 * _local17);
_local16 = (_local16 * _local17);
_local7 = ((((_local13 > 0)) ? (_local13 * _extentX) : (-(_local13) * _extentX) + ((_local14 > 0)) ? (_local14 * _extentY) : (-(_local14) * _extentY)) + ((_local15 > 0)) ? (_local15 * _extentZ) : (-(_local15) * _extentZ));
_local8 = ((((_local13 * _centerX) + (_local14 * _centerY)) + (_local15 * _centerZ)) + _local16);
if (_local8 > _local7){
_local26 = _arg1._positiveNode.nodeId;
_vertices[_local26] = _local2;
_faces[_local26] = _local3;
return (Plane3D.FRONT);
};
if (_local8 < -(_local7)){
if (_local21){
_local26 = _arg1._negativeNode.nodeId;
_vertices[_local26] = _local2;
_faces[_local26] = _local3;
};
return (Plane3D.BACK);
};
_local4 = _local2.length;
while (--_local4 >= 0) {
_local5 = Vertex(_local2[_local4]);
_local8 = (Vertex(_local2[_local4])._distance = ((((_local5._x * _local13) + (_local5._y * _local14)) + (_local5._z * _local15)) + _local16));
if (_local8 >= 0){
_local24.push(_local5);
_local19++;
};
if (_local8 <= 0){
if (_local21){
_local25.push(_local5);
};
_local20++;
};
};
if (_local19 == 0){
if (_local21){
_local26 = _arg1._negativeNode.nodeId;
_vertices[_local26] = _local2;
_faces[_local26] = _local3;
};
return (Plane3D.BACK);
};
if (_local20 == 0){
_local26 = _arg1._positiveNode.nodeId;
_vertices[_local26] = _local2;
_faces[_local26] = _local3;
return (Plane3D.FRONT);
};
_local4 = _local3.length;
while (--_local4 >= 0) {
splitFace(Face(_local3[_local4]), _local22, _local23, _local24, _local25);
};
_local26 = _arg1._positiveNode.nodeId;
_vertices[_local26] = _local24;
_faces[_local26] = _local22;
if (_local21){
_local26 = _arg1._negativeNode.nodeId;
_vertices[_local26] = _local25;
_faces[_local26] = _local23;
};
if (_local22.length == 0){
return (Plane3D.BACK);
};
if (((_local21) && ((_local23.length == 0)))){
return (Plane3D.FRONT);
};
return (Plane3D.INTERSECT);
}
private function splitFace(_arg1:Face, _arg2:Array, _arg3:Array, _arg4:Array, _arg5:Array):void{
var _local6:UV;
var _local7:UV;
var _local8:UV;
var _local9:Vertex;
var _local10:UV;
var _local17:Number;
var _local20:int;
var _local21:int;
var _local22:Material;
var _local11:Vertex = _arg1._v0;
var _local12:Vertex = _arg1._v1;
var _local13:Vertex = _arg1._v2;
var _local14:Number = _local11._distance;
var _local15:Number = _local12._distance;
var _local16:Number = _local13._distance;
var _local18 = -1;
var _local19 = -1;
if ((((((_local14 > 0)) && ((_local15 > 0)))) && ((_local16 > 0)))){
_arg2.push(_arg1);
return;
};
if ((((((_local14 < 0)) && ((_local15 < 0)))) && ((_local16 < 0)))){
if (_arg3){
_arg3.push(_arg1);
};
return;
};
_local6 = _arg1._uv0;
_local7 = _arg1._uv1;
_local8 = _arg1._uv2;
if (_local14 >= 0){
++_local18;
var _local23 = _local18;
_posFaceVerts[_local23] = _local11;
_posFaceUV[_local18] = _local6;
};
if ((((_local14 <= 0)) && (_arg3))){
++_local19;
_local23 = _local19;
_negFaceVerts[_local23] = _local11;
_negFaceUV[_local19] = _local6;
};
if ((_local14 * _local15) < 0){
_local17 = (_local14 / (_local14 - _local15));
_local9 = getNewVertex((_local11._x + (_local17 * (_local12._x - _local11._x))), (_local11._y + (_local17 * (_local12._y - _local11._y))), (_local11._z + (_local17 * (_local12._z - _local11._z))));
_local10 = getNewUV((_local6._u + (_local17 * (_local7._u - _local6._u))), (_local6._v + (_local17 * (_local7._v - _local6._v))));
_arg4.push(_local9);
++_local18;
_local23 = _local18;
_posFaceVerts[_local23] = _local9;
_posFaceUV[_local18] = _local10;
if (_arg3){
_arg5.push(_local9);
++_local19;
var _local24 = _local19;
_negFaceVerts[_local24] = _local9;
_negFaceUV[_local19] = _local10;
};
};
if (_local15 >= 0){
++_local18;
_local23 = _local18;
_posFaceVerts[_local23] = _local12;
_posFaceUV[_local18] = _local7;
};
if ((((_local15 <= 0)) && (_arg3))){
++_local19;
_local23 = _local19;
_negFaceVerts[_local23] = _local12;
_negFaceUV[_local19] = _local7;
};
if ((_local15 * _local16) < 0){
_local17 = (_local15 / (_local15 - _local16));
_local9 = getNewVertex((_local12._x + (_local17 * (_local13._x - _local12._x))), (_local12._y + (_local17 * (_local13._y - _local12._y))), (_local12._z + (_local17 * (_local13._z - _local12._z))));
_local10 = getNewUV((_local7._u + (_local17 * (_local8._u - _local7._u))), (_local7._v + (_local17 * (_local8._v - _local7._v))));
_arg4.push(_local9);
++_local18;
_local23 = _local18;
_posFaceVerts[_local23] = _local9;
_posFaceUV[_local18] = _local10;
if (_arg3){
_arg5.push(_local9);
++_local19;
_local24 = _local19;
_negFaceVerts[_local24] = _local9;
_negFaceUV[_local19] = _local10;
};
};
if (_local16 >= 0){
++_local18;
_local23 = _local18;
_posFaceVerts[_local23] = _local13;
_posFaceUV[_local18] = _local8;
};
if ((((_local16 <= 0)) && (_arg3))){
++_local19;
_local23 = _local19;
_negFaceVerts[_local23] = _local13;
_negFaceUV[_local19] = _local8;
};
if ((_local16 * _local14) < 0){
_local17 = (_local16 / (_local16 - _local14));
_local9 = getNewVertex((_local13._x + (_local17 * (_local11._x - _local13._x))), (_local13._y + (_local17 * (_local11._y - _local13._y))), (_local13._z + (_local17 * (_local11._z - _local13._z))));
_local10 = getNewUV((_local8._u + (_local17 * (_local6._u - _local8._u))), (_local8._v + (_local17 * (_local6._v - _local8._v))));
_arg4.push(_local9);
++_local18;
_local23 = _local18;
_posFaceVerts[_local23] = _local9;
_posFaceUV[_local18] = _local10;
if (_arg3){
_arg5.push(_local9);
++_local19;
_local24 = _local19;
_negFaceVerts[_local24] = _local9;
_negFaceUV[_local19] = _local10;
};
};
_local22 = _arg1.material;
_local11 = _posFaceVerts[0];
_local6 = _posFaceUV[0];
_local20 = 0;
_local21 = 1;
while (++_local20 < _local18) {
_local21++;
_arg2.push(getNewFace(_local11, _posFaceVerts[_local20], _posFaceVerts[_local21], _local22, _local6, _posFaceUV[_local20], _posFaceUV[_local21]));
};
if (_arg3){
_local11 = _negFaceVerts[0];
_local6 = _negFaceUV[0];
_local20 = 0;
_local21 = 1;
while (++_local20 < _local19) {
_local21++;
_arg3.push(getNewFace(_local11, _negFaceVerts[_local20], _negFaceVerts[_local21], _local22, _local6, _negFaceUV[_local20], _negFaceUV[_local21]));
};
};
}
public function setLeaf(_arg1:int):void{
if (_arg1 < 0){
_mesh = _sourceMesh;
} else {
_mesh = _splitMeshes[_arg1];
};
}
public function get sourceMesh():Mesh{
return (_sourceMesh);
}
public function get mesh():Mesh{
return (_mesh);
}
private function getNewMesh():Mesh{
var _local1:Mesh = ((_meshPoolLen == -1)) ? new Mesh() : _meshPool[_meshPoolLen--];
_local1.transform = _sourceMesh.transform;
_local1.type = _sourceMesh.type;
_local1.material = _sourceMesh.material;
_local1.outline = _sourceMesh.outline;
_local1.back = _sourceMesh.back;
_local1.bothsides = _sourceMesh.bothsides;
_local1.debugbb = _sourceMesh.debugbb;
var _local2 = ++_usedMeshLen;
_usedMeshes[_local2] = _local1;
return (_local1);
}
private function getNewFace(_arg1:Vertex, _arg2:Vertex, _arg3:Vertex, _arg4:Material, _arg5:UV, _arg6:UV, _arg7:UV):Face{
var _local8:Face = ((_facePoolLen == -1)) ? new Face() : _facePool[_facePoolLen--];
_local8.v0 = _arg1;
_local8.v1 = _arg2;
_local8.v2 = _arg3;
_local8.material = _arg4;
_local8.uv0 = _arg5;
_local8.uv1 = _arg6;
_local8.uv2 = _arg7;
var _local9 = ++_usedFaceLen;
_usedFaces[_local9] = _local8;
return (_local8);
}
private function getNewVertex(_arg1:Number, _arg2:Number, _arg3:Number):Vertex{
var _local4:Vertex = ((_vertexPoolLen == -1)) ? new Vertex() : _vertexPool[_vertexPoolLen--];
_local4.x = _arg1;
_local4.y = _arg2;
_local4.z = _arg3;
var _local5 = ++_usedVertLen;
_usedVerts[_local5] = _local4;
return (_local4);
}
private function getNewUV(_arg1:Number, _arg2:Number):UV{
var _local3:UV = ((_uvPoolLen == -1)) ? new UV() : _uvPool[_uvPoolLen--];
_local3._u = _arg1;
_local3._v = _arg2;
var _local4 = ++_usedUVLen;
_usedUV[_local4] = _local3;
return (_local3);
}
}
}//package away3d.graphs.bsp
Section 117
//BSPNode (away3d.graphs.bsp.BSPNode)
package away3d.graphs.bsp {
import flash.events.*;
import away3d.core.math.*;
import away3d.core.base.*;
import away3d.core.geom.*;
import flash.utils.*;
import away3d.events.*;
import away3d.graphs.*;
import away3d.core.traverse.*;
public final class BSPNode extends EventDispatcher implements ITreeNode {
public var leafId:int;// = -1
public var nodeId:int;
public var renderMark:int;// = -1
public var name:String;
var _isLeaf:Boolean;
var _culled:Boolean;
var _parent:BSPNode;
var _partitionPlane:Plane3D;
var _positiveNode:BSPNode;
var _negativeNode:BSPNode;
var _bevelPlanes:Array;
var _ngons:Array;
var _mesh:Mesh;
var _visList:Array;
var _lastIterationPositive:Boolean;
var _bounds:Array;
var _minX:Number;
var _minY:Number;
var _minZ:Number;
var _maxX:Number;
var _maxY:Number;
var _maxZ:Number;
var _children:Array;
var _meshes:Array;
var _colliders:Array;
var _hasChildren:Boolean;
var _splitWeight:Number;// = 10
var _balanceWeight:Number;// = 1
var _nonXZWeight:Number;// = 1.5
var _nonYWeight:Number;// = 1.2
private var _bestPlane:Plane3D;
private var _bestScore:Number;
private var _positiveFaces:Array;
private var _negativeFaces:Array;
var _convex:Boolean;
private var _solidPlanes:Array;
private var _planeCount:int;
var _maxTimeOut:int;// = 500
var _newFaces:int;
var _assignedFaces:int;
var _buildFaces:Array;
var _portals:Array;
var _backPortals:Array;
private static var _completeEvent:Event;
public function BSPNode(_arg1:BSPNode){
_parent = _arg1;
}
public function get leftChild():ITreeNode{
return (_positiveNode);
}
public function get rightChild():ITreeNode{
return (_negativeNode);
}
public function get parent():ITreeNode{
return (_parent);
}
public function get isLeaf():Boolean{
return (_isLeaf);
}
public function get visList():Array{
return (_visList);
}
public function get partitionPlane():Plane3D{
return (_partitionPlane);
}
public function get bevelPlanes():Array{
return (_bevelPlanes);
}
public function get faces():Array{
return ((_mesh) ? _mesh.faces : null);
}
public function traverseChildren(_arg1:Traverser):void{
var _local2:int;
var _local3:Object3D;
var _local4:BSPMeshManager;
if (_children){
_local2 = _children.length;
while (--_local2 >= 0) {
_local3 = Object3D(_children[_local2]);
if (_arg1.match(_local3)){
_arg1.enter(_local3);
_arg1.apply(_local3);
_arg1.leave(_local3);
};
};
};
if (_meshes){
_local2 = _meshes.length;
while (--_local2 >= 0) {
_local4 = BSPMeshManager(_meshes[_local2]);
_local4.setLeaf(leafId);
_local3 = _local4.mesh;
if (_arg1.match(_local3)){
_arg1.enter(_local3);
_arg1.apply(_local3);
_arg1.leave(_local3);
};
};
};
}
public function assignCollider(_arg1:Object3D, _arg2:Number3D, _arg3:Number):void{
var _local4:Number;
var _local5:int;
if (_isLeaf){
return;
};
_local5 = _partitionPlane._alignment;
if (_local5 == Plane3D.X_AXIS){
_local4 = ((_arg2.x * _partitionPlane.a) + _partitionPlane.d);
} else {
if (_local5 == Plane3D.Y_AXIS){
_local4 = ((_arg2.y * _partitionPlane.b) + _partitionPlane.d);
} else {
if (_local5 == Plane3D.Z_AXIS){
_local4 = ((_arg2.z * _partitionPlane.c) + _partitionPlane.d);
} else {
_local4 = ((((_arg2.x * _partitionPlane.a) + (_arg2.y * _partitionPlane.b)) + (_arg2.z * _partitionPlane.c)) + _partitionPlane.d);
};
};
};
if ((((_local4 < _arg3)) && (_negativeNode))){
_negativeNode.assignCollider(_arg1, _arg2, _arg3);
};
if ((((_local4 > -(_arg3))) && (_positiveNode))){
_positiveNode.assignCollider(_arg1, _arg2, _arg3);
};
}
public function addMesh(_arg1:BSPMeshManager):void{
if (!_meshes){
_meshes = [];
};
_meshes.push(_arg1);
if (_arg1.sourceMesh._collider){
if (!_colliders){
_colliders = [];
};
_colliders.push(_arg1.sourceMesh);
};
_hasChildren = true;
}
public function removeMesh(_arg1:BSPMeshManager):void{
var _local2:int = _meshes.indexOf(_arg1);
if (_local2 != -1){
_meshes.splice(_local2, 1);
};
if (_arg1.mesh._collider){
_local2 = _colliders.indexOf(_arg1.sourceMesh);
if (_local2 != -1){
_colliders.splice(_local2, 1);
};
};
_hasChildren = (((_meshes.length > 0)) || (((_children) && ((_children.length > 0)))));
}
public function addChild(_arg1:Object3D):void{
if (!_children){
_children = [];
};
_children.push(_arg1);
_arg1._sceneGraphMark = leafId;
_hasChildren = true;
}
public function removeChild(_arg1:Object3D):void{
var _local2:int = _children.indexOf(_arg1);
if (_local2 != -1){
_children.splice(_local2, 1);
_arg1._sceneGraphMark = -1;
};
_hasChildren = (((_children.length > 0)) || (((_meshes) && ((_meshes.length > 0)))));
}
public function get mesh():Mesh{
return (_mesh);
}
public function get bounds():Array{
return (_bounds);
}
function addFace(_arg1:Face):void{
_mesh.addFace(_arg1);
}
function removeFace(_arg1:Face):void{
_mesh.removeFace(_arg1);
}
function addFaces(_arg1:Array):void{
var _local3:Face;
var _local4:int;
var _local2:int = _arg1.length;
if (!_mesh){
_mesh = new Mesh();
_mesh._preCulled = true;
_mesh._preSorted = true;
_mesh.pushback = true;
};
if (_local2 == 0){
return;
};
do {
_local3 = _arg1[_local4];
_mesh.addFace(_local3);
++_local4;
} while (_local4 < _local2);
}
function addVisibleLeaf(_arg1:int):void{
if (!_visList){
_visList = new Array();
};
_visList.push(_arg1);
}
function propagateBounds():void{
if (!_isLeaf){
if (_positiveNode){
_positiveNode.propagateBounds();
_minX = _positiveNode._minX;
_minY = _positiveNode._minY;
_minZ = _positiveNode._minZ;
_maxX = _positiveNode._maxX;
_maxY = _positiveNode._maxY;
_maxZ = _positiveNode._maxZ;
} else {
_minX = Number.POSITIVE_INFINITY;
_maxX = Number.NEGATIVE_INFINITY;
_minY = Number.POSITIVE_INFINITY;
_maxY = Number.NEGATIVE_INFINITY;
_minZ = Number.POSITIVE_INFINITY;
_maxZ = Number.NEGATIVE_INFINITY;
};
if (_negativeNode){
_negativeNode.propagateBounds();
if (_negativeNode._minX < _minX){
_minX = _negativeNode._minX;
};
if (_negativeNode._minY < _minY){
_minY = _negativeNode._minY;
};
if (_negativeNode._minZ < _minZ){
_minZ = _negativeNode._minZ;
};
if (_negativeNode._maxX > _maxX){
_maxX = _negativeNode._maxX;
};
if (_negativeNode._maxY > _maxY){
_maxY = _negativeNode._maxY;
};
if (_negativeNode._maxZ > _maxZ){
_maxZ = _negativeNode._maxZ;
};
};
} else {
if (_mesh){
_minX = _mesh.minX;
_minY = _mesh.minY;
_minZ = _mesh.minZ;
_maxX = _mesh.maxX;
_maxY = _mesh.maxY;
_maxZ = _mesh.maxZ;
} else {
_minX = Number.POSITIVE_INFINITY;
_maxX = Number.NEGATIVE_INFINITY;
_minY = Number.POSITIVE_INFINITY;
_maxY = Number.NEGATIVE_INFINITY;
_minZ = Number.POSITIVE_INFINITY;
_maxZ = Number.NEGATIVE_INFINITY;
};
};
_bounds = [];
_bounds.push(new Number3D(_minX, _minY, _minZ));
_bounds.push(new Number3D(_maxX, _minY, _minZ));
_bounds.push(new Number3D(_maxX, _maxY, _minZ));
_bounds.push(new Number3D(_minX, _maxY, _minZ));
_bounds.push(new Number3D(_minX, _minY, _maxZ));
_bounds.push(new Number3D(_maxX, _minY, _maxZ));
_bounds.push(new Number3D(_maxX, _maxY, _maxZ));
_bounds.push(new Number3D(_minX, _maxY, _maxZ));
}
function isEmpty():Boolean{
return ((_mesh.geometry.faces.length == 0));
}
function gatherLeaves(_arg1:Array):void{
if (_isLeaf){
leafId = _arg1.length;
_arg1.push(this);
} else {
if (_positiveNode != null){
if (((_positiveNode._isLeaf) && (_positiveNode.isEmpty()))){
_positiveNode = null;
throw (new Error("An empty leaf was created. This could indicate the source geometry wasn't aligned properly to a grid."));
};
_positiveNode.gatherLeaves(_arg1);
};
if (_negativeNode != null){
if (((_negativeNode._isLeaf) && (_negativeNode.isEmpty()))){
_negativeNode = null;
} else {
_negativeNode.gatherLeaves(_arg1);
};
};
};
}
function build(_arg1:Array=null):void{
if (!_completeEvent){
_completeEvent = new Event(Event.COMPLETE);
};
if (_arg1){
_buildFaces = _arg1;
};
_bestScore = Number.POSITIVE_INFINITY;
if (_convex){
solidify(_buildFaces);
} else {
getBestPlane(_buildFaces);
};
}
private function getBestPlane(_arg1:Array):void{
var _local2:NGon;
var _local3:int = _arg1.length;
var _local4:int = getTimer();
do {
_local2 = _arg1[_planeCount];
if (_local2._isSplitter){
} else {
getPlaneScore(_local2.plane, _arg1);
if (_bestScore == 0){
_planeCount = _local3;
};
};
} while ((((++_planeCount < _local3)) && (((getTimer() - _local4) < _maxTimeOut))));
if (_planeCount >= _local3){
if (_bestPlane){
setTimeout(constructChildren, 40, _bestPlane, _arg1);
} else {
_convex = true;
_solidPlanes = gatherConvexPlanes(_arg1);
setTimeout(solidify, 40, _arg1);
};
} else {
setTimeout(getBestPlane, 40, _arg1);
};
}
private function gatherConvexPlanes(_arg1:Array):Array{
var _local4:int;
var _local5:Plane3D;
var _local6:Boolean;
var _local7:NGon;
var _local2:Array = new Array();
var _local3:int = _arg1.length;
while (--_local3 >= 0) {
_local7 = _arg1[_local3];
if (!_local7._isSplitter){
_local5 = _local7.plane;
_local4 = _local2.length;
_local6 = true;
while ((((--_local4 >= 0)) && (_local6))) {
if (_local7.isCoinciding(_local2[_local4])){
_local6 = false;
};
};
if (_local6){
_local2.push(_local5);
};
};
};
return (_local2);
}
private function solidify(_arg1:Array):void{
if (!_solidPlanes.length){
_isLeaf = true;
_ngons = _arg1;
if (_arg1.length > 0){
addNGons(_arg1);
};
} else {
_partitionPlane = _solidPlanes.pop();
_positiveNode = new BSPNode(this);
_positiveNode.name = (name + " -> +");
_positiveNode._convex = true;
_positiveNode._maxTimeOut = _maxTimeOut;
_positiveNode._buildFaces = _arg1;
_positiveNode._solidPlanes = _solidPlanes;
};
completeNode();
}
private function addNGons(_arg1:Array):void{
var _local3:Array;
var _local5:BSPBuildEvent;
var _local2:int = _arg1.length;
var _local4:int;
while (_local4 < _local2) {
_local3 = _arg1[_local4].triangulate();
if (((!(_local3)) || ((_local3.length == 0)))){
_local5 = new BSPBuildEvent(BSPBuildEvent.BUILD_ERROR);
_local5.message = "Empty faces were created. This could indicate the source geometry wasn't aligned properly to a grid.";
_local5.data = _arg1[_local4];
dispatchEvent(_local5);
};
addFaces(_local3);
_local4++;
};
_assignedFaces = _arg1.length;
}
private function getPlaneScore(_arg1:Plane3D, _arg2:Array):void{
var _local3:Number;
var _local4:int;
var _local5:Plane3D;
var _local6:NGon;
var _local8:int;
var _local9:int;
var _local10:int;
var _local7:int = _arg2.length;
while (--_local7 >= 0) {
_local6 = _arg2[_local7];
_local4 = _local6.classifyToPlane(_arg1);
if (_local4 == -2){
_local5 = _local6.plane;
if ((((_arg1.a * _local5.a) + (_arg1.b * _local5.b)) + (_arg1.c * _local5.c)) > 0){
_local8++;
} else {
_local9++;
};
} else {
if (_local4 == Plane3D.BACK){
_local9++;
} else {
if (_local4 == Plane3D.FRONT){
_local8++;
} else {
_local10++;
};
};
};
};
if ((((((_local8 == 0)) || ((_local9 == 0)))) && ((_local10 == 0)))){
return;
};
_local3 = ((Math.abs((_local9 - _local8)) * _balanceWeight) + (_local10 * _splitWeight));
if (((!((_arg1._alignment == Plane3D.X_AXIS))) || (!((_arg1._alignment == Plane3D.Z_AXIS))))){
if (_arg1._alignment != Plane3D.Y_AXIS){
_local3 = (_local3 * _nonXZWeight);
} else {
_local3 = (_local3 * _nonYWeight);
};
};
if ((((_local3 >= 0)) && ((_local3 < _bestScore)))){
_bestScore = _local3;
_bestPlane = _arg1;
};
}
private function constructChildren(_arg1:Plane3D, _arg2:Array):void{
var _local3:int;
var _local4:NGon;
var _local7:Plane3D;
var _local8:Array;
var _local5:int = _arg2.length;
var _local6:int;
_positiveFaces = new Array();
_negativeFaces = new Array();
_partitionPlane = _arg1;
do {
_local4 = _arg2[_local6];
_local3 = _local4.classifyToPlane(_arg1);
if (_local3 == -2){
_local7 = _local4.plane;
if ((((_arg1.a * _local7.a) + (_arg1.b * _local7.b)) + (_arg1.c * _local7.c)) > 0){
_positiveFaces.push(_local4);
_local4._isSplitter = true;
} else {
_negativeFaces.push(_local4);
};
} else {
if (_local3 == Plane3D.FRONT){
_positiveFaces.push(_local4);
} else {
if (_local3 == Plane3D.BACK){
_negativeFaces.push(_local4);
} else {
_local8 = _local4.split(_partitionPlane);
_positiveFaces.push(_local8[0]);
_negativeFaces.push(_local8[1]);
_newFaces++;
};
};
};
++_local6;
} while (_local6 < _local5);
_positiveNode = new BSPNode(this);
_positiveNode.name = (name + " -> +");
_positiveNode._maxTimeOut = _maxTimeOut;
_positiveNode._buildFaces = _positiveFaces;
_negativeNode = new BSPNode(this);
_negativeNode.name = (name + " -> -");
_negativeNode._maxTimeOut = _maxTimeOut;
_negativeNode._buildFaces = _negativeFaces;
completeNode();
}
private function completeNode():void{
_negativeFaces = null;
_positiveFaces = null;
_buildFaces = null;
_solidPlanes = null;
dispatchEvent(_completeEvent);
}
function generatePortals(_arg1:BSPNode):Array{
var _local3:Array;
var _local4:Array;
var _local5:Array;
var _local6:int;
if (((_isLeaf) || (_convex))){
return (null);
};
var _local2:BSPPortal = new BSPPortal();
if (!_local2.fromNode(this, _arg1)){
return (null);
};
_local2.frontNode = _positiveNode;
_local2.backNode = _negativeNode;
_local3 = _positiveNode.splitPortalByChildren(_local2, Plane3D.FRONT);
if (!_negativeNode){
return (_local3);
};
if (_local3){
_local6 = _local3.length;
while (--_local6 >= 0) {
_local5 = _negativeNode.splitPortalByChildren(_local3[_local6], Plane3D.BACK);
if (_local5){
if (!_local4){
_local4 = new Array();
};
_local4 = _local4.concat(_local5);
};
};
};
return (_local4);
}
function splitPortalByChildren(_arg1:BSPPortal, _arg2:int):Array{
var _local3:Array;
var _local4:Array;
var _local5:int;
if (!_arg1){
return (new Array());
};
if (_arg2 == Plane3D.FRONT){
_arg1.frontNode = this;
} else {
_arg1.backNode = this;
};
if (_isLeaf){
_local3 = new Array();
_local3.push(_arg1);
return (_local3);
};
if (_convex){
if (_arg1.nGon.classifyToPlane(_partitionPlane) != -2){
_arg1.nGon.trim(_partitionPlane);
};
if (_arg1.nGon.isNeglectable()){
return (null);
};
_local3 = _positiveNode.splitPortalByChildren(_arg1, _arg2);
return (_local3);
};
_local5 = _arg1.nGon.classifyToPlane(_partitionPlane);
switch (_local5){
case Plane3D.FRONT:
_local3 = _positiveNode.splitPortalByChildren(_arg1, _arg2);
break;
case Plane3D.BACK:
if (_negativeNode){
_local3 = _negativeNode.splitPortalByChildren(_arg1, _arg2);
} else {
_local3 = null;
};
break;
case Plane3D.INTERSECT:
_local4 = _arg1.split(_partitionPlane);
_local3 = _positiveNode.splitPortalByChildren(_local4[0], _arg2);
_local4 = _negativeNode.splitPortalByChildren(_local4[1], _arg2);
if (((_local3) && (_local4))){
_local3 = _local3.concat(_local4);
} else {
if (!_local3){
_local3 = _local4;
};
};
break;
};
return (_local3);
}
public function assignPortal(_arg1:BSPPortal):void{
if (!_portals){
_portals = new Array();
};
_portals.push(_arg1);
}
public function assignBackPortal(_arg1:BSPPortal):void{
if (!_backPortals){
_backPortals = new Array();
};
_backPortals.push(_arg1);
}
public function processVislist(_arg1:Array):void{
var _local3:BSPPortal;
var _local5:BSPPortal;
var _local8:int;
if (((!(_backPortals)) || (!(_arg1)))){
return;
};
var _local2:int = _backPortals.length;
var _local4:int = _arg1.length;
var _local6:int;
_visList = new Array();
var _local7:int;
while (_local7 < _local2) {
_local3 = _backPortals[_local7];
if (_visList.indexOf(_local3.frontNode.leafId) == -1){
var _temp1 = _local6;
_local6 = (_local6 + 1);
var _local9 = _temp1;
_visList[_local9] = _local3.frontNode.leafId;
};
_local8 = 0;
while (_local8 < _local4) {
_local5 = _arg1[_local8];
if (((_local3.isInList(_local3.visList, _local5.index)) && ((_visList.indexOf(_local5.frontNode.leafId) == -1)))){
var _temp2 = _local6;
_local6 = (_local6 + 1);
_local9 = _temp2;
_visList[_local9] = _arg1[_local8].frontNode.leafId;
};
_local8++;
};
_local7++;
};
_visList.sort(sortVisList);
_portals = null;
_backPortals = null;
}
private function sortVisList(_arg1:int, _arg2:int):Number{
return (((_arg1 < _arg2)) ? -1 : ((_arg1 == _arg2)) ? 0 : 1);
}
}
}//package away3d.graphs.bsp
Section 118
//BSPPortal (away3d.graphs.bsp.BSPPortal)
package away3d.graphs.bsp {
import flash.events.*;
import away3d.core.math.*;
import away3d.core.base.*;
import away3d.core.geom.*;
import flash.utils.*;
public final class BSPPortal extends EventDispatcher {
public var index:int;
public var nGon:NGon;
public var sourceNode:BSPNode;
public var frontNode:BSPNode;
public var backNode:BSPNode;
public var listLen:int;
public var frontList:Array;
public var visList:Array;
public var hasVisList:Boolean;
public var frontOrder:int;
public var maxTimeout:int;// = 0
public var antiPenumbrae:Array;
public var neighbours:Array;
private var _iterationIndex:int;
private var _state:int;
private var _currentPortal:BSPPortal;
private var _needCheck:Boolean;
private var _numPortals:int;
private var _backPortal:BSPPortal;
private var _portals:Array;
public var next:BSPPortal;
var _currentAntiPenumbra:Array;
var _currentParent:BSPPortal;
var _currentFrontList:Array;
public static const RECURSED_PORTAL_COMPLETE:String = "RecursedPortalComplete";
private static var TRAVERSE_PRE:int = 0;
private static var TRAVERSE_IN:int = 1;
private static var TRAVERSE_POST:int = 2;
private static var _sizeLookUp:Array;
private static var _planePool:Array = [];
public function BSPPortal(){
antiPenumbrae = [];
super();
if (!_sizeLookUp){
generateSizeLookUp();
};
nGon = new NGon();
nGon.vertices = new Array();
}
private function generateSizeLookUp():void{
var _local3:int;
var _local4:int;
var _local1 = 0xFF;
var _local2 = 1;
_sizeLookUp = new Array(0xFF);
_sizeLookUp[0] = 0;
do {
_local4 = 0;
_local3 = 8;
while (--_local3 >= 0) {
if ((_local2 & (1 << _local3))){
_local4++;
};
};
_sizeLookUp[_local2] = _local4;
++_local2;
} while (_local2 < _local1);
_sizeLookUp[0xFF] = 8;
}
public function fromNode(_arg1:BSPNode, _arg2:BSPNode):Boolean{
var _local5:Number;
var _local6:Number;
var _local7:Number3D;
var _local8:Number3D;
var _local9:Number3D;
var _local10:Number3D;
var _local3:Array = _arg2._bounds;
var _local4:Plane3D = (nGon.plane = _arg1._partitionPlane);
_local9 = new Number3D(((_arg2._minX + _arg2._maxX) * 0.5), ((_arg2._minY + _arg2._maxY) * 0.5), ((_arg2._minZ + _arg2._maxZ) * 0.5));
_local10 = new Number3D(_local4.a, _local4.b, _local4.c);
var _local11:int;
sourceNode = _arg1;
_local6 = _local9.distance(_local3[0]);
_local6 = Math.sqrt(((_local6 * _local6) + (_local6 * _local6)));
_local5 = _local4.distance(_local9);
_local9.x = (_local9.x - (_local5 * _local4.a));
_local9.y = (_local9.y - (_local5 * _local4.b));
_local9.z = (_local9.z - (_local5 * _local4.c));
_local7 = getPerpendicular(_local10);
_local7.normalize();
_local8 = new Number3D();
_local8.cross(_local10, _local7);
_local8.normalize();
var _temp1 = _local11;
_local11 = (_local11 + 1);
var _local13 = _temp1;
nGon.vertices[_local13] = new Vertex((_local9.x + (_local7.x * _local6)), (_local9.y + (_local7.y * _local6)), (_local9.z + (_local7.z * _local6)));
var _temp2 = _local11;
_local11 = (_local11 + 1);
var _local14 = _temp2;
nGon.vertices[_local14] = new Vertex((_local9.x + (_local8.x * _local6)), (_local9.y + (_local8.y * _local6)), (_local9.z + (_local8.z * _local6)));
_local7.normalize(-1);
_local8.normalize(-1);
var _temp3 = _local11;
_local11 = (_local11 + 1);
var _local15 = _temp3;
nGon.vertices[_local15] = new Vertex((_local9.x + (_local7.x * _local6)), (_local9.y + (_local7.y * _local6)), (_local9.z + (_local7.z * _local6)));
var _temp4 = _local11;
_local11 = (_local11 + 1);
var _local16 = _temp4;
nGon.vertices[_local16] = new Vertex((_local9.x + (_local8.x * _local6)), (_local9.y + (_local8.y * _local6)), (_local9.z + (_local8.z * _local6)));
trimToAABB(_arg2);
var _local12:BSPNode = _arg1;
while ((_arg1 = _arg1._parent)) {
if (((!(nGon)) || ((nGon.vertices.length < 3)))){
return (false);
};
if (_local12 == _arg1._positiveNode){
nGon.trim(_arg1._partitionPlane);
} else {
nGon.trimBack(_arg1._partitionPlane);
};
_local12 = _arg1;
};
return (true);
}
public function clone():BSPPortal{
var _local1:BSPPortal = new BSPPortal();
_local1.nGon = nGon.clone();
_local1.frontNode = frontNode;
_local1.backNode = backNode;
_local1.neighbours = neighbours;
_local1._currentParent = _currentParent;
_local1.frontList = frontList;
_local1.visList = visList;
_local1.index = index;
return (_local1);
}
private function trimToAABB(_arg1:BSPNode):void{
var _local2:Plane3D = new Plane3D(0, -1, 0, _arg1._maxY);
nGon.trim(_local2);
_local2.b = 1;
_local2.d = -(_arg1._minY);
nGon.trim(_local2);
_local2.a = 1;
_local2.b = 0;
_local2.d = -(_arg1._minX);
nGon.trim(_local2);
_local2.a = -1;
_local2.d = _arg1._maxX;
nGon.trim(_local2);
_local2.a = 0;
_local2.c = 1;
_local2.d = -(_arg1._minZ);
nGon.trim(_local2);
_local2.c = -1;
_local2.d = _arg1._maxZ;
nGon.trim(_local2);
}
private function getPerpendicular(_arg1:Number3D):Number3D{
var _local2:Number3D = new Number3D();
_local2.cross(new Number3D(1, 1, 0), _arg1);
if (_local2.modulo <= BSPTree.EPSILON){
_local2.cross(new Number3D(0, 1, 1), _arg1);
};
return (_local2);
}
public function split(_arg1:Plane3D):Array{
var _local2:BSPPortal;
var _local3:BSPPortal;
var _local5:NGon;
var _local4:Array = nGon.split(_arg1);
var _local6:Array = new Array();
_local5 = _local4[0];
if (_local5){
_local2 = new BSPPortal();
_local2.nGon = _local5;
_local2.sourceNode = sourceNode;
_local2.frontNode = frontNode;
_local2.backNode = backNode;
_local6[0] = _local2;
};
_local5 = _local4[1];
if (_local5){
_local3 = new BSPPortal();
_local3.nGon = _local5;
_local3.sourceNode = sourceNode;
_local3.frontNode = frontNode;
_local3.backNode = backNode;
_local6[1] = _local3;
};
return (_local6);
}
public function partition():Array{
var _local1:Array = new Array();
var _local2:BSPPortal = clone();
_local2.frontNode = backNode;
_local2.backNode = frontNode;
_local2.nGon.invert();
_local2._backPortal = this;
_backPortal = _local2;
_local1[0] = this;
_local1[1] = _local2;
return (_local1);
}
public function createLists(_arg1:int):void{
_numPortals = _arg1;
listLen = ((_arg1 >> 5) + 1);
frontList = new Array(listLen);
visList = new Array(listLen);
_currentFrontList = new Array(listLen);
}
public function addToList(_arg1:Array, _arg2:int):void{
_arg1[(_arg2 >> 5)] = (_arg1[(_arg2 >> 5)] | (1 << (_arg2 & 31)));
}
public function removeFromList(_arg1:Array, _arg2:int):void{
_arg1[(_arg2 >> 5)] = (_arg1[(_arg2 >> 5)] & ~((1 << (_arg2 & 31))));
}
public function isInList(_arg1:Array, _arg2:int):Boolean{
if (!_arg1){
return (false);
};
return (!(((_arg1[(_arg2 >> 5)] & (1 << (_arg2 & 31))) == 0)));
}
public function findInitialFrontList(_arg1:Array):void{
var _local4:int;
var _local5:NGon;
var _local6:int;
var _local7:int;
var _local8:BSPPortal;
var _local2:int = _arg1.length;
var _local3:Plane3D = nGon.plane;
do {
_local8 = _arg1[_local4];
_local5 = _local8.nGon;
if (((_local5.classifyForPortalFront(_local3)) && (nGon.classifyForPortalBack(_local5.plane)))){
_local6 = (index >> 5);
_local7 = (index & 31);
if ((_local8.frontList[_local6] & (1 << _local7)) != 0){
_local8.frontList[_local6] = (_local8.frontList[_local6] & ~((1 << _local7)));
_local8.frontOrder--;
} else {
frontList[(_local4 >> 5)] = (frontList[(_local4 >> 5)] | (1 << (_local4 & 31)));
frontOrder++;
};
};
++_local4;
} while (_local4 < _local2);
}
public function findNeighbours():void{
var _local3:BSPPortal;
var _local4:int;
var _local1:Array = frontNode._backPortals;
var _local2:int = _local1.length;
var _local5:int;
neighbours = new Array();
while (--_local2 >= 0) {
_local3 = _local1[_local2];
_local4 = _local3.index;
if ((frontList[(_local4 >> 5)] & (1 << (_local4 & 31)))){
var _temp1 = _local5;
_local5 = (_local5 + 1);
var _local6 = _temp1;
neighbours[_local6] = _local3;
antiPenumbrae[_local4] = generateAntiPenumbra(_local3.nGon);
};
};
if (_local5 == 0){
_local2 = listLen;
while (--_local2 >= 0) {
frontList[_local2] = 0;
};
neighbours = null;
frontOrder = 0;
};
}
public function findVisiblePortals(_arg1:Array):void{
var _local2:int = listLen;
_portals = _arg1;
_state = TRAVERSE_PRE;
_currentPortal = this;
_needCheck = false;
_iterationIndex = 0;
_currentParent = null;
while (--_local2 >= 0) {
_currentFrontList[_local2] = frontList[_local2];
};
findVisiblePortalStep();
}
private function findVisiblePortalStep():void{
var _local1:BSPPortal;
var _local3:Array;
var _local4:int;
var _local5:BSPPortal;
var _local6:Array;
var _local7:int;
var _local8:Plane3D;
var _local9:Array;
var _local2:int = getTimer();
do {
if (_currentPortal.frontOrder <= 0){
_state = TRAVERSE_POST;
};
if (_needCheck){
_local7 = _currentPortal.index;
_local5 = _currentPortal._currentParent;
_local6 = _local5._currentFrontList;
if (((!(((_local6[(_local7 >> 5)] & (1 << (_local7 & 31))) == 0))) && (determineVisibility(_currentPortal)))){
visList[(_local7 >> 5)] = (visList[(_local7 >> 5)] | (1 << (_local7 & 31)));
_local4 = listLen;
while (--_local4 >= 0) {
_currentPortal._currentFrontList[_local4] = (_local6[_local4] & _currentPortal.frontList[_local4]);
};
} else {
_state = TRAVERSE_POST;
};
};
if (_state == TRAVERSE_PRE){
_local3 = _currentPortal.neighbours;
if (_local3){
_local1 = _local3[0];
_local1._iterationIndex = 0;
_local1._currentParent = _currentPortal;
_currentPortal = _local1;
_needCheck = true;
} else {
_state = TRAVERSE_POST;
_needCheck = false;
};
} else {
if (_state == TRAVERSE_IN){
_local3 = _currentPortal.neighbours;
if (++_currentPortal._iterationIndex < _local3.length){
_local1 = _local3[_currentPortal._iterationIndex];
_local1._iterationIndex = 0;
_local1._currentParent = _currentPortal;
_currentPortal = _local1;
_needCheck = true;
_state = TRAVERSE_PRE;
} else {
_state = TRAVERSE_POST;
_needCheck = false;
};
} else {
if (_state == TRAVERSE_POST){
_local9 = _currentPortal._currentAntiPenumbra;
if (((_local9) && (!((_currentPortal._currentParent == this))))){
_local4 = _local9.length;
while (--_local4 >= 0) {
_local8 = _local9[_local4];
_local8._alignment = 0;
_planePool.push(_local8);
};
_currentPortal._currentAntiPenumbra = null;
};
_currentPortal = _currentPortal._currentParent;
if (_currentPortal._iterationIndex < (_currentPortal.neighbours.length - 1)){
_state = TRAVERSE_IN;
};
_needCheck = false;
};
};
};
} while (((((!((_currentPortal == this))) || (!((_state == TRAVERSE_POST))))) && (((getTimer() - _local2) < maxTimeout))));
if ((((_currentPortal == this)) && ((_state == TRAVERSE_POST)))){
_local4 = listLen;
while (--_local4 >= 0) {
frontList[_local4] = visList[_local4];
};
hasVisList = true;
setTimeout(updateBackPortals, 40);
} else {
setTimeout(findVisiblePortalStep, 40);
};
}
private function updateBackPortals():void{
var _local1:int;
var _local4:int;
var _local5:BSPPortal;
var _local2 = (_backPortal.index >> 5);
var _local3:uint = ~((1 << (_backPortal.index & 31)));
do {
_local5 = _portals[_local4];
_local1 = _local5.index;
if ((visList[(_local1 >> 5)] & (1 << (_local1 & 31))) == 0){
_local5._backPortal.frontList[_local2] = (_local5._backPortal.frontList[_local2] & _local3);
};
++_local4;
} while (_local4 < _numPortals);
setTimeout(notifyComplete, 40);
}
private function determineVisibility(_arg1:BSPPortal):Boolean{
var _local2:Array;
var _local3:int;
var _local5:int;
var _local7:NGon;
var _local8:NGon;
var _local10:Array;
var _local11:BSPPortal;
var _local12:int;
var _local13:Array;
var _local14:Plane3D;
var _local15:Vertex;
var _local16:Boolean;
var _local4:int = listLen;
var _local6:BSPPortal = _arg1._currentParent;
var _local9:int = _arg1.index;
if (_local6 == this){
_arg1._currentAntiPenumbra = antiPenumbrae[_local9];
return (true);
};
_local11 = _arg1._backPortal;
if (_local11.hasVisList){
_local10 = _local11.visList;
_local12 = _backPortal.index;
if ((_local10[(_local12 >> 5)] & (1 << (_local12 & 31))) == 0){
return (false);
};
};
_local7 = _arg1.nGon;
_local2 = _local6._currentAntiPenumbra;
_local3 = _local2.length;
_local3 = _local2.length;
_local4 = _local3;
_local13 = _local7.vertices;
while (--_local4 >= 0) {
_local14 = _local2[_local4];
_local5 = _local13.length;
while (--_local5 >= 0) {
_local16 = true;
_local15 = _local13[_local5];
if (((((_local14.a * _local15._x) + (_local14.b * _local15._y)) + (_local14.c * _local15._z)) + _local14.d) > BSPTree.EPSILON){
_local16 = false;
_local5 = 0;
};
};
if (_local16){
return (false);
};
};
_local8 = _local7.clone();
_local4 = _local3;
while (--_local4 >= 0) {
_local8.trim(_local2[_local4]);
if (_local8.vertices.length < 3){
return (false);
};
};
if (_local8.isNeglectable()){
return (false);
};
_arg1._currentAntiPenumbra = generateAntiPenumbra(_local8);
return (true);
}
private function notifyComplete():void{
dispatchEvent(new Event(Event.COMPLETE));
}
private function generateAntiPenumbra(_arg1:NGon):Array{
var _local8:int;
var _local9:int;
var _local10:int;
var _local11:int;
var _local12:Vertex;
var _local13:int;
var _local14:int;
var _local16:int;
var _local17:Number;
var _local18:Number;
var _local19:Number;
var _local20:Number;
var _local21:Number;
var _local22:Number;
var _local23:Vertex;
var _local24:Vertex;
var _local25:Number;
var _local26:Number;
var _local27:Number;
var _local28:Number;
var _local29:Number;
var _local30:Plane3D;
var _local31:Boolean;
var _local32:Number;
var _local33:Number;
var _local34:Number;
var _local35:Number;
var _local2:Array = new Array();
var _local3:Array = nGon.vertices;
var _local4:Array = _arg1.vertices;
var _local5:int = _local3.length;
var _local6:int = _local4.length;
var _local7:Plane3D = ((_planePool.length > 0)) ? _planePool.pop() : new Plane3D();
var _local15:int;
var _local36:Number = (BSPTree.EPSILON * BSPTree.EPSILON);
_local8 = _local6;
_local10 = (_local8 - 2);
_local23 = _local4[(_local8 - 1)];
while (--_local8 >= 0) {
_local12 = _local23;
_local23 = _local4[_local10];
_local9 = _local5;
while (--_local9 >= 0) {
_local24 = _local3[_local9];
_local17 = (_local23._x - _local12._x);
_local18 = (_local23._y - _local12._y);
_local19 = (_local23._z - _local12._z);
_local20 = (_local24._x - _local12._x);
_local21 = (_local24._y - _local12._y);
_local22 = (_local24._z - _local12._z);
_local25 = ((_local18 * _local22) - (_local19 * _local21));
_local26 = ((_local19 * _local20) - (_local17 * _local22));
_local27 = ((_local17 * _local21) - (_local18 * _local20));
_local28 = (1 / Math.sqrt((((_local25 * _local25) + (_local26 * _local26)) + (_local27 * _local27))));
_local25 = (_local25 * _local28);
_local26 = (_local26 * _local28);
_local27 = (_local27 * _local28);
_local7.a = _local25;
_local7.b = _local26;
_local7.c = _local27;
_local29 = -((((_local25 * _local12._x) + (_local26 * _local12._y)) + (_local27 * _local12._z)));
_local7.d = _local29;
_local13 = nGon.classifyToPlane(_local7);
_local14 = _arg1.classifyToPlane(_local7);
if ((((((_local13 == Plane3D.FRONT)) && ((_local14 == Plane3D.BACK)))) || ((((_local13 == Plane3D.BACK)) && ((_local14 == Plane3D.FRONT)))))){
if (_local14 == Plane3D.BACK){
_local7.a = -(_local25);
_local7.b = -(_local26);
_local7.c = -(_local27);
_local7.d = -(_local29);
};
var _temp1 = _local15;
_local15 = (_local15 + 1);
var _local37 = _temp1;
_local2[_local37] = _local7;
_local7 = ((_planePool.length > 0)) ? _planePool.pop() : new Plane3D();
_local9 = 0;
};
};
--_local10;
if (_local10 < 0){
_local10 = (_local6 - 1);
};
};
_local16 = _local15;
_local8 = _local5;
_local10 = (_local8 - 2);
_local23 = _local3[(_local8 - 1)];
while (--_local8 >= 0) {
_local12 = _local23;
_local23 = _local3[_local10];
_local9 = _local6;
while (--_local9 >= 0) {
_local24 = _local4[_local9];
_local17 = (_local23._x - _local12._x);
_local18 = (_local23._y - _local12._y);
_local19 = (_local23._z - _local12._z);
_local20 = (_local24._x - _local12._x);
_local21 = (_local24._y - _local12._y);
_local22 = (_local24._z - _local12._z);
_local25 = ((_local18 * _local22) - (_local19 * _local21));
_local26 = ((_local19 * _local20) - (_local17 * _local22));
_local27 = ((_local17 * _local21) - (_local18 * _local20));
_local28 = (1 / Math.sqrt((((_local25 * _local25) + (_local26 * _local26)) + (_local27 * _local27))));
_local25 = (_local25 * _local28);
_local26 = (_local26 * _local28);
_local27 = (_local27 * _local28);
_local29 = -((((_local25 * _local12._x) + (_local26 * _local12._y)) + (_local27 * _local12._z)));
_local7.a = _local25;
_local7.b = _local26;
_local7.c = _local27;
_local7.d = _local29;
_local13 = nGon.classifyToPlane(_local7);
_local14 = _arg1.classifyToPlane(_local7);
if ((((((_local13 == Plane3D.FRONT)) && ((_local14 == Plane3D.BACK)))) || ((((_local13 == Plane3D.BACK)) && ((_local14 == Plane3D.FRONT)))))){
if (_local14 == Plane3D.BACK){
_local7.a = -(_local25);
_local7.b = -(_local26);
_local7.c = -(_local27);
_local7.d = -(_local29);
};
_local11 = _local16;
_local31 = true;
while ((((--_local11 >= 0)) && (_local31))) {
_local30 = _local2[_local11];
_local32 = (_local30.a - _local25);
_local33 = (_local30.b - _local26);
_local34 = (_local30.c - _local27);
_local35 = (_local30.d - _local29);
if (((((((((_local32 * _local32) + (_local33 * _local33)) + (_local34 * _local34)) < _local36)) && ((_local35 <= BSPTree.EPSILON)))) && ((_local35 >= -(BSPTree.EPSILON))))){
_local31 = false;
};
};
if (_local31){
var _temp2 = _local15;
_local15 = (_local15 + 1);
_local37 = _temp2;
_local2[_local37] = _local7;
_local7 = ((_planePool.length > 0)) ? _planePool.pop() : new Plane3D();
};
_local9 = 0;
};
};
--_local10;
if (_local10 < 0){
_local10 = (_local5 - 1);
};
};
_planePool.push(_local7);
return (_local2);
}
public function removePortalsFromNeighbours(_arg1:Array):void{
var _local2:BSPPortal;
var _local5:int;
var _local6:int;
var _local7:BSPPortal;
if (frontOrder <= 0){
return;
};
var _local3:int = _arg1.length;
var _local4:int = neighbours.length;
while (--_local3 >= 0) {
_local2 = _arg1[_local3];
if (((isInList(frontList, _local3)) && ((neighbours.indexOf(_local2) == -1)))){
_local5 = 0;
_local6 = _local4;
while (--_local6 >= 0) {
_local7 = neighbours[_local6];
if (((isInList(_local7.frontList, _local3)) && (_local2.checkAgainstAntiPenumbra(antiPenumbrae[_local7.index])))){
_local6 = 0;
} else {
_local5++;
};
};
if (_local5 == _local4){
removeFromList(frontList, _local3);
frontOrder--;
};
};
};
}
public function propagateVisibility():void{
var _local1:int;
var _local2:int;
var _local4:BSPPortal;
var _local5:Array;
var _local6:int;
var _local7:uint;
var _local3:Array = new Array(listLen);
if (frontOrder <= 0){
return;
};
_local1 = (neighbours.length - 1);
_local4 = neighbours[_local1];
_local5 = _local4.frontList;
_local2 = listLen;
while (--_local2 >= 0) {
_local3[_local2] = _local5[_local2];
};
_local6 = _local4.index;
_local3[(_local6 >> 5)] = (_local3[(_local6 >> 5)] | (1 << (_local6 & 31)));
while (--_local1 >= 0) {
_local4 = neighbours[_local1];
_local5 = _local4.frontList;
_local2 = listLen;
while (--_local2 >= 0) {
_local3[_local2] = (_local3[_local2] | _local5[_local2]);
};
_local6 = _local4.index;
_local3[(_local6 >> 5)] = (_local3[(_local6 >> 5)] | (1 << (_local6 & 31)));
};
_local2 = listLen;
while (--_local2 >= 0) {
frontList[_local2] = (frontList[_local2] & _local3[_local2]);
};
frontOrder = 0;
_local2 = listLen;
while (--_local2 >= 0) {
_local7 = frontList[_local2];
frontOrder = (frontOrder + _sizeLookUp[(_local7 & 0xFF)]);
frontOrder = (frontOrder + _sizeLookUp[((_local7 >> 8) & 0xFF)]);
frontOrder = (frontOrder + _sizeLookUp[((_local7 >> 16) & 0xFF)]);
frontOrder = (frontOrder + _sizeLookUp[((_local7 >> 24) & 0xFF)]);
};
}
private function checkAgainstAntiPenumbra(_arg1:Array):Boolean{
var _local2:int = _arg1.length;
while (--_local2 >= 0) {
if (nGon.isOutAntiPenumbra(_arg1[_local2])){
return (false);
};
};
return (true);
}
}
}//package away3d.graphs.bsp
Section 119
//BSPTree (away3d.graphs.bsp.BSPTree)
package away3d.graphs.bsp {
import away3d.core.math.*;
import away3d.core.base.*;
import away3d.core.utils.*;
import away3d.containers.*;
import away3d.core.render.*;
import away3d.core.geom.*;
import flash.utils.*;
import away3d.cameras.*;
import away3d.events.*;
import away3d.core.traverse.*;
import away3d.cameras.lenses.*;
public class BSPTree extends ObjectContainer3D {
public var usePVS:Boolean;// = true
var _rootNode:BSPNode;
var _leaves:Array;
private var _activeLeaf:BSPNode;
private var _transformPt:Number3D;
private var _viewToLocal:Matrix3D;
private var _cameraVarsStore:CameraVarsStore;
private var _dynamics:Array;
private var _renderMark:int;
private var _obbCollisionTree:BSPTree;
private var _meshManagers:Dictionary;
private var _complete:Boolean;
private var _state:int;
private var _collisionDir:Number3D;
var _collisionPlane:Plane3D;
var _collisionRatio:Number;
var _collidedObject:Object3D;
private var _planeStack:Array;
private var _tMaxStack:Array;
private var _tMinStack:Array;
private var _nodeStack:Array;
private var _bevelStack:Array;
private var _bevelNode:BSPNode;
private var _posNode:BSPNode;
public static const TEST_METHOD_POINT:int = 0;
public static const TEST_METHOD_AABB:int = 1;
public static const TEST_METHOD_ELLIPSOID:int = 2;
public static const EPSILON:Number = 0.07;
public static const COLLISION_EPSILON:Number = 0.1;
private static const TRAVERSE_PRE:int = 0;
private static const TRAVERSE_IN:int = 1;
private static const TRAVERSE_POST:int = 2;
public function BSPTree(_arg1:Boolean=true){
_transformPt = new Number3D();
_viewToLocal = new Matrix3D();
_collisionDir = new Number3D();
_planeStack = new Array();
_tMaxStack = new Array();
_tMinStack = new Array();
_nodeStack = new Array();
_bevelStack = new Array();
_bevelNode = new BSPNode(null);
_posNode = new BSPNode(_bevelNode);
super();
_leaves = new Array();
_dynamics = new Array();
_preCulled = true;
_rootNode = new BSPNode(null);
_rootNode.name = "root";
if (_arg1){
buildCollisionTree();
};
}
public function get rootNode():BSPNode{
return (_rootNode);
}
private function buildCollisionTree():void{
var _local1:int;
var _local2:BSPNode;
_obbCollisionTree = new BSPTree(false);
_local2 = (_obbCollisionTree._rootNode = new BSPNode(null));
do {
_local2._partitionPlane = new Plane3D();
_local2._positiveNode = new BSPNode(_local2);
_local2._positiveNode._isLeaf = true;
if (_local1 < 5){
_local2._negativeNode = new BSPNode(_local2);
_local2 = _local2._negativeNode;
};
++_local1;
} while (_local1 < 6);
}
public function get activeLeaf():BSPNode{
return (_activeLeaf);
}
function get leaves():Array{
return (_leaves);
}
override public function set parent(_arg1:ObjectContainer3D):void{
ownCanvas = true;
renderer = new BSPRenderer();
super.parent = _arg1;
}
public function getLeafContaining(_arg1:Number3D, _arg2:Boolean=false):BSPNode{
var _local4:Number;
var _local5:Plane3D;
var _local3:BSPNode = _rootNode;
while (((_local3) && (!(_local3._isLeaf)))) {
if (((_arg2) && (_local3._culled))){
return (null);
};
_local5 = _local3._partitionPlane;
_local4 = (((_arg1.x * _local5.a) + (_arg1.y * _local5.b)) + (_arg1.z * _local5.c));
_local3 = ((_local4 > -(_local5.d))) ? _local3._positiveNode : _local3._negativeNode;
};
return (_local3);
}
function update(_arg1:Camera3D, _arg2:Frustum, _arg3:CameraVarsStore):void{
if (!(_arg1.lens is PerspectiveLens)){
throw (new Error("Lens is of incorrect type! BSP needs a PerspectiveLens instance assigned to Camera3D.lens"));
};
if (!_complete){
return;
};
var _local4:int = _dynamics.length;
while (--_local4 >= 0) {
_dynamics[_local4].sceneTransform;
};
var _local5:Matrix3D = inverseSceneTransform;
_viewToLocal.multiply(_local5, _arg1.transform);
_transformPt.transform(_arg1.position, _local5);
_activeLeaf = getLeafContaining(_transformPt);
doCulling(_activeLeaf, _arg2);
_renderMark++;
_cameraVarsStore = _arg3;
}
private function assignDynamic(_arg1:Object3D):void{
var _local2:BSPNode;
var _local3:int;
_local3 = _arg1._sceneGraphMark;
_local2 = getLeafContaining(_arg1.position);
if (((_local2) && ((_local2.leafId == _local3)))){
return;
};
if (_local3 != -1){
_leaves[_local3].removeChild(_arg1);
};
if (_local2){
_local2.addChild(_arg1);
};
}
override public function addChild(_arg1:Object3D):void{
super.addChild(_arg1);
_dynamics.push(_arg1);
if ((_arg1 is Mesh)){
if (!_meshManagers){
_meshManagers = new Dictionary(true);
};
_meshManagers[_arg1] = new BSPMeshManager(Mesh(_arg1), this);
} else {
_arg1._sceneGraphMark = -1;
assignDynamic(_arg1);
_arg1.addEventListener(Object3DEvent.TRANSFORM_CHANGED, onDynamicUpdate);
};
}
override public function removeChild(_arg1:Object3D):void{
var _local2:int = _dynamics.indexOf(_arg1);
if (_local2 >= 0){
_dynamics.splice(_local2, 1);
};
super.removeChild(_arg1);
_arg1._sceneGraphMark = -1;
if ((_arg1 is Mesh)){
_meshManagers[_arg1].destroy();
_meshManagers[_arg1] = null;
} else {
_arg1.removeEventListener(Object3DEvent.TRANSFORM_CHANGED, onDynamicUpdate);
};
}
private function onDynamicUpdate(_arg1:Object3DEvent):void{
assignDynamic(Object3D(_arg1.target));
}
override public function traverse(_arg1:Traverser):void{
if (!(((_arg1 is ProjectionTraverser)) || ((_arg1 is PrimitiveTraverser)))){
super.traverse(_arg1);
return;
};
if (((_complete) && (_arg1.match(this)))){
_arg1.enter(this);
_arg1.apply(this);
doTraverse(_arg1);
_arg1.leave(this);
};
}
private function doTraverse(_arg1:Traverser):void{
var _local2:Mesh;
var _local3:BSPNode;
var _local4:BSPNode;
var _local5:Boolean;
var _local10:Plane3D;
var _local6:Boolean;
var _local7:BSPNode = _rootNode;
var _local8:Dictionary = _cameraVarsStore.frustumDictionary;
var _local9:Frustum = _local8[this];
_state = TRAVERSE_PRE;
if (_local7._culled){
return;
};
do {
if (_local6){
_local5 = _local7._isLeaf;
if (_local5){
_local2 = _local7._mesh;
_local8[_local2] = _local9;
if (_arg1.match(_local2)){
_arg1.enter(_local2);
_arg1.apply(_local2);
_arg1.leave(_local2);
};
if (_local7._hasChildren){
_local7.traverseChildren(_arg1);
};
_state = TRAVERSE_POST;
} else {
if (_local7.renderMark != _renderMark){
_local10 = _local7._partitionPlane;
if (_local10._alignment == Plane3D.X_AXIS){
_local7._lastIterationPositive = ((_local10.a * _transformPt.x) > -(_local10.d));
} else {
if (_local10._alignment == Plane3D.Y_AXIS){
_local7._lastIterationPositive = ((_local10.b * _transformPt.y) > -(_local10.d));
} else {
if (_local10._alignment == Plane3D.Z_AXIS){
_local7._lastIterationPositive = ((_local10.c * _transformPt.z) > -(_local10.d));
} else {
_local7._lastIterationPositive = ((((_local10.a * _transformPt.x) + (_local10.b * _transformPt.y)) + (_local10.c * _transformPt.z)) > -(_local10.d));
};
};
};
};
if (_local7._lastIterationPositive){
_local3 = _local7._negativeNode;
_local4 = _local7._positiveNode;
} else {
_local3 = _local7._positiveNode;
_local4 = _local7._negativeNode;
};
};
};
if (_state == TRAVERSE_PRE){
if (((_local3) && (!(_local3._culled)))){
_local7 = _local3;
_local6 = true;
} else {
_state = TRAVERSE_IN;
_local6 = false;
};
} else {
if (_state == TRAVERSE_IN){
if (((_local4) && (!(_local4._culled)))){
_local7 = _local4;
_state = TRAVERSE_PRE;
_local6 = true;
} else {
_state = TRAVERSE_POST;
_local6 = false;
};
} else {
if (_state == TRAVERSE_POST){
if (((((_local7._parent._lastIterationPositive) && ((_local7 == _local7._parent._negativeNode)))) || (((!(_local7._parent._lastIterationPositive)) && ((_local7 == _local7._parent._positiveNode)))))){
_state = TRAVERSE_IN;
};
_local7 = _local7._parent;
_local6 = true;
};
};
};
} while (((!((_local7 == _rootNode))) || (!((_state == TRAVERSE_POST)))));
}
private function doCulling(_arg1:BSPNode, _arg2:Frustum):void{
var _local5:int;
var _local6:int;
var _local7:BSPNode;
var _local3:int = _leaves.length;
var _local4:Array = (_arg1) ? _arg1._visList : null;
var _local8:int = (_local4) ? _local4.length : 0;
_rootNode._culled = false;
if (((!(usePVS)) || ((_local8 == 0)))){
_local5 = 0;
while (_local5 < _local3) {
_leaves[_local5]._culled = false;
_local5++;
};
} else {
_local5 = 0;
while (_local5 < _local3) {
if ((((_local6 < _local8)) && ((_local5 == _local4[_local6])))){
_local7 = _leaves[_local5];
_local7._culled = false;
_local7._mesh._preCullClassification = Frustum.IN;
_local6++;
} else {
_local7 = _leaves[_local5];
_local7._culled = true;
};
_local5++;
};
};
if (_arg1){
_arg1._culled = false;
};
propagateCulled();
cullToFrustum(_arg2);
}
private function propagateCulled():void{
var _local1:BSPNode;
var _local2:BSPNode;
var _local3:BSPNode = _rootNode;
_state = TRAVERSE_PRE;
if (_local3._culled){
return;
};
do {
_local1 = _local3._positiveNode;
_local2 = _local3._negativeNode;
if (_state == TRAVERSE_PRE){
if (((_local1) && (!(_local1._isLeaf)))){
_local3 = _local1;
} else {
_state = TRAVERSE_IN;
};
} else {
if (_state == TRAVERSE_IN){
if (((_local2) && (!(_local2._isLeaf)))){
_local3 = _local2;
_state = TRAVERSE_PRE;
} else {
_state = TRAVERSE_POST;
};
} else {
if (_state == TRAVERSE_POST){
if (_local3._parent){
if (_local3 == _local3._parent._positiveNode){
_state = TRAVERSE_IN;
};
_local3 = _local3._parent;
};
};
};
};
if ((((_state == TRAVERSE_POST)) && (!(_local3._isLeaf)))){
_local1 = _local3._positiveNode;
_local2 = _local3._negativeNode;
_local3._culled = ((((!(_local1)) || (_local1._culled))) && (((!(_local2)) || (_local2._culled))));
};
} while (((!((_local3 == _rootNode))) || (!((_state == TRAVERSE_POST)))));
}
private function cullToFrustum(_arg1:Frustum):void{
var _local2:BSPNode;
var _local3:BSPNode;
var _local4:int;
var _local5:Boolean;
var _local6:BSPNode = _rootNode;
_state = TRAVERSE_PRE;
if (_local6._culled){
return;
};
do {
if (_local5){
_local4 = _arg1.classifyAABB(_local6._bounds);
_local6._culled = (_local4 == Frustum.OUT);
if (_local6._isLeaf){
_local6._mesh._preCullClassification = _local4;
_state = TRAVERSE_POST;
} else {
if (_local4 != Frustum.INTERSECT){
_state = TRAVERSE_POST;
};
};
};
_local2 = _local6._positiveNode;
_local3 = _local6._negativeNode;
if (_state == TRAVERSE_PRE){
if (((_local2) && (!(_local2._culled)))){
_local6 = _local2;
_local5 = true;
} else {
_state = TRAVERSE_IN;
_local5 = false;
};
} else {
if (_state == TRAVERSE_IN){
if (((_local3) && (!(_local3._culled)))){
_local6 = _local3;
_state = TRAVERSE_PRE;
_local5 = true;
} else {
_state = TRAVERSE_POST;
_local5 = false;
};
} else {
if (_state == TRAVERSE_POST){
if (_local6._parent){
if (_local6 == _local6._parent._positiveNode){
_state = TRAVERSE_IN;
};
_local6 = _local6._parent;
};
_local5 = false;
};
};
};
} while (((!((_local6 == _rootNode))) || (!((_state == TRAVERSE_POST)))));
_preCullClassification = Frustum.INTERSECT;
}
function init():void{
var _local1:int = _leaves.length;
var _local2:int;
while (_local2 < _local1) {
if (((_leaves[_local2]) && (_leaves[_local2].mesh))){
super.addChild(_leaves[_local2].mesh);
};
_local2++;
};
_rootNode.propagateBounds();
_maxX = _rootNode._maxX;
_maxY = _rootNode._maxY;
_maxZ = _rootNode._maxZ;
_minX = _rootNode._minX;
_minY = _rootNode._minY;
_minZ = _rootNode._minZ;
_dimensionsDirty = true;
_complete = true;
}
public function traceCollision(_arg1:Number3D, _arg2:Number3D, _arg3:int=0, _arg4:Number3D=null):Boolean{
_collisionDir.x = (_arg2.x - _arg1.x);
_collisionDir.y = (_arg2.y - _arg1.y);
_collisionDir.z = (_arg2.z - _arg1.z);
if (_arg3 == TEST_METHOD_POINT){
return (findCollision(_arg1, _collisionDir, _arg3));
};
return (findCollision(_arg1, _collisionDir, _arg3, _arg4));
}
public function get collisionRatio():Number{
return (_collisionRatio);
}
public function get collisionPlane():Plane3D{
return (_collisionPlane);
}
public function get collidedObject():Object3D{
return (_collidedObject);
}
private function findCollision(_arg1:Number3D, _arg2:Number3D, _arg3:int, _arg4:Number3D=null, _arg5:Number=0, _arg6:Number=1):Boolean{
var _local7:Plane3D;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:int;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:BSPNode;
var _local18:BSPNode;
var _local19:int;
var _local20:Plane3D;
var _local22:Number;
var _local23:Number;
var _local24:Number;
var _local25:Boolean;
var _local26:Number;
var _local27:Array;
var _local28:int;
var _local29:Array;
var _local8:BSPNode = _rootNode;
var _local21:Number = 0;
_bevelNode._positiveNode = _posNode;
_posNode._isLeaf = true;
_planeStack.length = 0;
_tMinStack.length = 0;
_tMaxStack.length = 0;
_nodeStack.length = 0;
_bevelStack.length = 0;
_collidedObject = null;
while (true) {
if (!_local8){
if ((((((_arg3 == BSPTree.TEST_METHOD_POINT)) || (!(_local27)))) || ((_local28 == _local27.length)))){
_collisionPlane = _local20;
_collisionRatio = _arg5;
return (true);
};
var _temp1 = _local28;
_local28 = (_local28 + 1);
_bevelNode._partitionPlane = _local27[_temp1];
_local8 = _bevelNode;
};
if (!_local8){
_collisionPlane = _local20;
_collisionRatio = _arg5;
return (true);
};
if (_local8._isLeaf){
_local29 = _local8._colliders;
if (((((_local29) && ((_local29.length > 0)))) && (traceColliders(_arg1, _arg2, _arg5, _arg6, _arg3, _arg4, _local29)))){
return (true);
};
if (_local19 == 0){
_collisionPlane = null;
_collisionRatio = 1;
return (false);
};
_local19--;
_local8 = _nodeStack[_local19];
_arg5 = _tMinStack[_local19];
_arg6 = _tMaxStack[_local19];
_local20 = _planeStack[_local19];
_local27 = _bevelStack[_local19];
} else {
if (_local8 != _bevelNode){
_local27 = _local8._bevelPlanes;
_local28 = 0;
};
_local7 = _local8._partitionPlane;
_local12 = _local7._alignment;
_local16 = _local7.d;
if (_local12 == Plane3D.X_AXIS){
_local13 = _local7.a;
_local9 = (_local13 * _arg2.x);
_local10 = ((_local13 * _arg1.x) + _local16);
if (_arg3 != TEST_METHOD_POINT){
_local21 = _arg4.x;
};
} else {
if (_local12 == Plane3D.Y_AXIS){
_local14 = _local7.b;
_local9 = (_local14 * _arg2.y);
_local10 = ((_local14 * _arg1.y) + _local16);
if (_arg3 != TEST_METHOD_POINT){
_local21 = _arg4.y;
};
} else {
if (_local12 == Plane3D.Z_AXIS){
_local15 = _local7.c;
_local9 = (_local15 * _arg2.z);
_local10 = ((_local15 * _arg1.z) + _local16);
if (_arg3 != TEST_METHOD_POINT){
_local21 = _arg4.z;
};
} else {
_local13 = _local7.a;
_local14 = _local7.b;
_local15 = _local7.c;
_local9 = (((_local13 * _arg2.x) + (_local14 * _arg2.y)) + (_local15 * _arg2.z));
_local10 = ((((_local13 * _arg1.x) + (_local14 * _arg1.y)) + (_local15 * _arg1.z)) + _local16);
if (_arg3 == TEST_METHOD_AABB){
_local21 = ((((_local13 > 0)) ? (_local13 * _arg4.x) : (-(_local13) * _arg4.x) + ((_local14 > 0)) ? (_local14 * _arg4.y) : (-(_local14) * _arg4.y)) + ((_local15 > 0)) ? (_local15 * _arg4.z) : (-(_local15) * _arg4.z));
} else {
if (_arg3 == TEST_METHOD_ELLIPSOID){
_local22 = (_local13 * _arg4.x);
_local23 = (_local14 * _arg4.y);
_local24 = (_local15 * _arg4.z);
_local21 = Math.sqrt((((_local22 * _local22) + (_local23 * _local23)) + (_local24 * _local24)));
};
};
};
};
};
_local10 = (_local10 - _local21);
if (_local9 != 0){
if (_local9 < 0){
_local17 = _local8._positiveNode;
_local18 = _local8._negativeNode;
} else {
_local17 = _local8._negativeNode;
_local18 = _local8._positiveNode;
};
_local11 = (-(_local10) / _local9);
_local26 = _arg6;
if (_local11 >= _arg5){
if (_local11 < _arg6){
_arg6 = _local11;
};
_local25 = true;
} else {
_local25 = false;
};
if (_local11 <= _local26){
if (_local25){
_nodeStack[_local19] = _local18;
_tMinStack[_local19] = ((_local11 > _arg5)) ? _local11 : _arg5;
_tMaxStack[_local19] = _local26;
_planeStack[_local19] = _local7;
_bevelStack[_local19] = _local27;
_local19++;
} else {
_local17 = _local18;
};
};
_local8 = _local17;
} else {
if (_local10 >= 0){
_local8 = _local8._positiveNode;
} else {
_local8 = _local8._negativeNode;
};
};
};
};
_collisionPlane = null;
return (false);
}
private function traceColliders(_arg1:Number3D, _arg2:Number3D, _arg3:Number, _arg4:Number, _arg5:int, _arg6:Number3D, _arg7:Array):Boolean{
var _local9:Object3D;
var _local8:int = _arg7.length;
while (--_local8 >= 0) {
_local9 = _arg7[_local8];
updateCollisionTree(_local9);
if (_obbCollisionTree.findCollision(_arg1, _arg2, _arg5, _arg6, _arg3, _arg4)){
_collisionPlane = _obbCollisionTree._collisionPlane;
_collisionRatio = _obbCollisionTree._collisionRatio;
_collidedObject = _local9;
return (true);
};
};
return (false);
}
private function updateCollisionTree(_arg1:Object3D):void{
var _local2:Plane3D;
var _local3:BSPNode = _obbCollisionTree._rootNode;
var _local4:Matrix3D = new Matrix3D();
_local4.inverse4x4(_arg1.transform);
_local2 = _local3._partitionPlane;
_local2.a = (_local2.b = 0);
_local2.c = -1;
_local2.d = _arg1._minZ;
_local2.transform(_local4);
_local3 = _local3._negativeNode;
_local2 = _local3._partitionPlane;
_local2.a = (_local2.b = 0);
_local2.c = 1;
_local2.d = -(_arg1._maxZ);
_local2.transform(_local4);
_local3 = _local3._negativeNode;
_local2 = _local3._partitionPlane;
_local2.a = -1;
_local2.b = (_local2.c = 0);
_local2.d = _arg1._minX;
_local2.transform(_local4);
_local3 = _local3._negativeNode;
_local2 = _local3._partitionPlane;
_local2.a = 1;
_local2.b = (_local2.c = 0);
_local2.d = -(_arg1._maxX);
_local2.transform(_local4);
_local3 = _local3._negativeNode;
_local2 = _local3._partitionPlane;
_local2.a = (_local2.c = 0);
_local2.b = 1;
_local2.d = -(_arg1._maxY);
_local2.transform(_local4);
_local3 = _local3._negativeNode;
_local2 = _local3._partitionPlane;
_local2.a = (_local2.c = 0);
_local2.b = -1;
_local2.d = _arg1._minY;
_local2.transform(_local4);
}
function addTemporaryChild(_arg1:Mesh):void{
super.addChild(_arg1);
}
function removeTemporaryChild(_arg1:Mesh):void{
super.removeChild(_arg1);
}
}
}//package away3d.graphs.bsp
Section 120
//ITreeNode (away3d.graphs.ITreeNode)
package away3d.graphs {
public interface ITreeNode {
function get leftChild():ITreeNode;
function get rightChild():ITreeNode;
function get parent():ITreeNode;
}
}//package away3d.graphs
Section 121
//AbstractLight (away3d.lights.AbstractLight)
package away3d.lights {
import away3d.core.light.*;
import away3d.core.utils.*;
import away3d.containers.*;
public class AbstractLight implements ILightProvider {
protected var ini:Init;
protected var _color:uint;
protected var _colorDirty:Boolean;
protected var _red:Number;
protected var _green:Number;
protected var _blue:Number;
protected var _parent:ObjectContainer3D;
protected var _debug:Boolean;
protected var _debugDirty:Boolean;
public function AbstractLight(_arg1:Object=null){
ini = Init.parse(_arg1);
color = ini.getColor("color", 0xFFFFFF);
debug = ini.getBoolean("debug", false);
}
protected function updateParent(_arg1:ObjectContainer3D):void{
throw (new Error("Not implemented"));
}
public function get color():uint{
return (_color);
}
public function set color(_arg1:uint):void{
_color = _arg1;
_red = (((_color & 0xFF0000) >> 16) / 0xFF);
_green = (((_color & 0xFF00) >> 8) / 0xFF);
_blue = ((_color & 0xFF) / 0xFF);
_colorDirty = true;
}
public function get debug():Boolean{
return (_debug);
}
public function set debug(_arg1:Boolean):void{
_debug = _arg1;
_debugDirty = true;
}
public function get parent():ObjectContainer3D{
return (_parent);
}
public function set parent(_arg1:ObjectContainer3D):void{
if (_arg1 == _parent){
return;
};
updateParent(_arg1);
}
public function light(_arg1:ILightConsumer):void{
throw (new Error("Not implemented"));
}
public function clone(_arg1:AbstractLight=null):AbstractLight{
var _local2:AbstractLight = (((_arg1 as AbstractLight)) || (new AbstractLight()));
super.clone(_local2);
_local2.color = color;
_local2.debug = debug;
return (_local2);
}
}
}//package away3d.lights
Section 122
//DirectionalLight3D (away3d.lights.DirectionalLight3D)
package away3d.lights {
import away3d.core.math.*;
import away3d.core.light.*;
import away3d.containers.*;
import away3d.events.*;
public class DirectionalLight3D extends AbstractLight {
private var _direction:Number3D;
private var _ambient:Number;
private var _diffuse:Number;
private var _specular:Number;
private var _brightness:Number;
private var _sceneDirection:Number3D;
private var _sceneDirectionDirty:Boolean;
private var _ambientDirty:Boolean;
private var _diffuseDirty:Boolean;
private var _specularDirty:Boolean;
private var _ls:DirectionalLight;
public function DirectionalLight3D(_arg1:Object=null){
_direction = new Number3D();
_sceneDirection = new Number3D();
_ls = new DirectionalLight();
super(_arg1);
direction = ((ini.getNumber3D("direction")) || (new Number3D()));
ambient = ini.getNumber("ambient", 0.5, {min:0, max:1});
diffuse = ini.getNumber("diffuse", 0.5, {min:0, max:10});
specular = ini.getNumber("specular", 1, {min:0, max:1});
brightness = ini.getNumber("brightness", 1);
debug = ini.getBoolean("debug", false);
}
private function onParentChange(_arg1:Object3DEvent):void{
_sceneDirectionDirty = true;
}
override protected function updateParent(_arg1:ObjectContainer3D):void{
if (_parent != null){
_parent.removeOnSceneChange(onParentChange);
_parent.removeOnSceneTransformChange(onParentChange);
};
_parent = _arg1;
if (_parent != null){
_parent.addOnSceneChange(onParentChange);
_parent.addOnSceneTransformChange(onParentChange);
_sceneDirectionDirty = true;
};
}
public function get direction():Number3D{
return (_direction);
}
public function set direction(_arg1:Number3D):void{
_direction.x = _arg1.x;
_direction.y = _arg1.y;
_direction.z = _arg1.z;
_sceneDirectionDirty = true;
}
public function get ambient():Number{
return (_ambient);
}
public function set ambient(_arg1:Number):void{
if (_arg1 < 0){
_arg1 = 0;
};
_ambient = _arg1;
_ambientDirty = true;
}
public function get diffuse():Number{
return (_diffuse);
}
public function set diffuse(_arg1:Number):void{
if (_arg1 < 0){
_arg1 = 0;
};
_diffuse = _arg1;
_diffuseDirty = true;
}
public function get specular():Number{
return (_specular);
}
public function set specular(_arg1:Number):void{
if (_arg1 < 0){
_arg1 = 0;
};
_specular = _arg1;
_specularDirty = true;
}
public function get brightness():Number{
return (_brightness);
}
public function set brightness(_arg1:Number):void{
_brightness = _arg1;
_ambientDirty = true;
_diffuseDirty = true;
_specularDirty = true;
}
public function get sceneDirection():Number3D{
if (_sceneDirectionDirty){
_sceneDirectionDirty = false;
_sceneDirection.rotate(_direction, _parent.sceneTransform);
_ls.setDirection(_sceneDirection);
};
return (_sceneDirection);
}
override public function light(_arg1:ILightConsumer):void{
if (_sceneDirectionDirty){
_sceneDirectionDirty = false;
_sceneDirection.rotate(_direction, _parent.sceneTransform);
_ls.setDirection(_sceneDirection);
};
if (_colorDirty){
_ls.red = _red;
_ls.green = _green;
_ls.blue = _blue;
_ambientDirty = true;
_diffuseDirty = true;
_specularDirty = true;
};
_ls.ambient = _ambient;
_ls.diffuse = (_diffuse * _brightness);
_ls.specular = (_specular * _brightness);
if (((_ambientDirty) || (_diffuseDirty))){
_ls.updateAmbientDiffuseBitmap();
};
if (_ambientDirty){
_ambientDirty = false;
_ls.updateAmbientBitmap();
};
if (_diffuseDirty){
_diffuseDirty = false;
_ls.updateDiffuseBitmap();
};
if (_specularDirty){
_specularDirty = false;
_ls.updateSpecularBitmap();
};
_arg1.directionalLight(_ls);
_colorDirty = false;
}
override public function clone(_arg1:AbstractLight=null):AbstractLight{
var _local2:DirectionalLight3D = (((_arg1 as DirectionalLight3D)) || (new DirectionalLight3D()));
super.clone(_local2);
_local2.brightness = brightness;
_local2.ambient = ambient;
_local2.diffuse = diffuse;
_local2.specular = specular;
return (_local2);
}
}
}//package away3d.lights
Section 123
//AnimationData (away3d.loaders.data.AnimationData)
package away3d.loaders.data {
import away3d.core.base.*;
import flash.utils.*;
import away3d.animators.*;
public class AnimationData {
public var name:String;
public var animator:Animator;
public var start:Number;// = INF
public var end:Number;// = 0
public var animationType:String;
public var channels:Dictionary;
public var frames:Array;
public var vertices:Array;
public function AnimationData(){
channels = new Dictionary(true);
frames = [];
vertices = [];
super();
}
public function clone(_arg1:Object3D):AnimationData{
var _local2:AnimationData = _arg1.animationLibrary.addAnimation(name);
_local2.start = start;
_local2.end = end;
_local2.animationType = animationType;
_local2.animator = animator.clone();
return (_local2);
}
}
}//package away3d.loaders.data
Section 124
//GeometryData (away3d.loaders.data.GeometryData)
package away3d.loaders.data {
import away3d.core.base.*;
public class GeometryData {
public var name:String;
public var vertices:Array;
public var uvs:Array;
public var faces:Array;
public var materials:Array;
public var bothsides:Boolean;
public var skinVertices:Array;
public var skinControllers:Array;
public var geometry:Geometry;
public var geoXML:XML;
public var ctrlXML:XML;
public var maxX:Number;
public var minX:Number;
public var maxY:Number;
public var minY:Number;
public var maxZ:Number;
public var minZ:Number;
public function GeometryData(){
vertices = [];
uvs = [];
faces = [];
materials = [];
skinVertices = [];
skinControllers = [];
super();
}
}
}//package away3d.loaders.data
Section 125
//MaterialData (away3d.loaders.data.MaterialData)
package away3d.loaders.data {
import flash.display.*;
import away3d.core.base.*;
import away3d.materials.*;
public class MaterialData {
private var _material:Material;
public var name:String;
public var ambientColor:uint;
public var diffuseColor:uint;
public var specularColor:uint;
public var shininess:Number;
public var textureFileName:String;
public var textureBitmap:BitmapData;
public var materialType:String;// = "wireframeMaterial"
public var elements:Array;
public static const TEXTURE_MATERIAL:String = "textureMaterial";
public static const SHADING_MATERIAL:String = "shadingMaterial";
public static const COLOR_MATERIAL:String = "colorMaterial";
public static const WIREFRAME_MATERIAL:String = "wireframeMaterial";
public function MaterialData(){
elements = [];
super();
}
public function get material():Material{
return (_material);
}
public function set material(_arg1:Material):void{
var _local2:Element;
if (_material == _arg1){
return;
};
_material = _arg1;
if ((_material is BitmapMaterial)){
textureBitmap = (_material as BitmapMaterial).bitmap;
};
if ((_material is Material)){
for each (_local2 in elements) {
(_local2 as Face).material = (_material as Material);
};
} else {
if ((_material is Material)){
for each (_local2 in elements) {
(_local2 as Segment).material = (_material as Material);
};
};
};
}
public function clone(_arg1:Object3D):MaterialData{
var _local3:Element;
var _local4:Geometry;
var _local5:Element;
var _local2:MaterialData = _arg1.materialLibrary.addMaterial(name);
_local2.materialType = materialType;
_local2.ambientColor = ambientColor;
_local2.diffuseColor = diffuseColor;
_local2.shininess = shininess;
_local2.specularColor = specularColor;
_local2.textureBitmap = textureBitmap;
_local2.textureFileName = textureFileName;
_local2.material = material;
for each (_local3 in elements) {
_local4 = _local3.parent;
_local5 = _local4.cloneElementDictionary[_local3];
_local2.elements.push(_local5);
};
return (_local2);
}
}
}//package away3d.loaders.data
Section 126
//AnimationLibrary (away3d.loaders.utils.AnimationLibrary)
package away3d.loaders.utils {
import away3d.core.utils.*;
import flash.utils.*;
import away3d.loaders.data.*;
public dynamic class AnimationLibrary extends Dictionary {
public function addAnimation(_arg1:String):AnimationData{
if (this[_arg1]){
return (this[_arg1]);
};
var _local2:AnimationData = new AnimationData();
var _local3 = (_local2.name = _arg1);
this[_local3] = _local2;
return (_local2);
}
public function getAnimation(_arg1:String):AnimationData{
if (this[_arg1]){
return (this[_arg1]);
};
Debug.warning((("Animation '" + _arg1) + "' does not exist"));
return (null);
}
}
}//package away3d.loaders.utils
Section 127
//GeometryLibrary (away3d.loaders.utils.GeometryLibrary)
package away3d.loaders.utils {
import away3d.core.utils.*;
import flash.utils.*;
import away3d.loaders.data.*;
public dynamic class GeometryLibrary extends Dictionary {
private var _geometryArray:Array;
private var _geometryArrayDirty:Boolean;
public var name:String;
private function updateGeometryArray():void{
var _local1:GeometryData;
_geometryArray = [];
for each (_local1 in this) {
_geometryArray.push(_local1);
};
}
public function addGeometry(_arg1:String, _arg2:XML=null, _arg3:XML=null):GeometryData{
if (this[_arg1]){
return (this[_arg1]);
};
_geometryArrayDirty = true;
var _local4:GeometryData = new GeometryData();
_local4.geoXML = _arg2;
_local4.ctrlXML = _arg3;
var _local5 = (_local4.name = _arg1);
this[_local5] = _local4;
return (_local4);
}
public function getGeometry(_arg1:String):GeometryData{
if (this[_arg1]){
return (this[_arg1]);
};
Debug.warning((("Geometry '" + _arg1) + "' does not exist"));
return (null);
}
public function getGeometryArray():Array{
if (_geometryArrayDirty){
updateGeometryArray();
};
return (_geometryArray);
}
}
}//package away3d.loaders.utils
Section 128
//MaterialLibrary (away3d.loaders.utils.MaterialLibrary)
package away3d.loaders.utils {
import flash.display.*;
import away3d.core.utils.*;
import away3d.materials.*;
import flash.utils.*;
import away3d.loaders.data.*;
public dynamic class MaterialLibrary extends Dictionary {
private var length:int;// = 0
public var texturePath:String;
public var textureLoadRequired:Boolean;
public var mtlLoadRequired:Boolean;
public var mtlFileName:String;
public function addMaterial(_arg1:String):MaterialData{
if (this[_arg1]){
return (this[_arg1]);
};
length++;
var _local2:MaterialData = new MaterialData();
var _local3 = (_local2.name = _arg1);
this[_local3] = _local2;
return (_local2);
}
public function getMaterial(_arg1:String):MaterialData{
if (this[_arg1]){
return (this[_arg1]);
};
Debug.warning((("Material '" + _arg1) + "' does not exist"));
return (null);
}
public function texturesLoaded(_arg1:TextureLoadQueue):void{
var _materialData:MaterialData;
var _image:TextureLoader;
var loadQueue = _arg1;
textureLoadRequired = false;
var images:Array = loadQueue.images;
for each (_materialData in this) {
for each (_image in images) {
if ((texturePath + _materialData.textureFileName) == _image.filename){
try {
_materialData.textureBitmap = new BitmapData(_image.width, _image.height, true, 0xFFFFFF);
_materialData.textureBitmap.draw(_image);
_materialData.material = new BitmapMaterial(_materialData.textureBitmap);
} catch(e) {
Debug.warning((("File not found : " + texturePath) + _materialData.textureFileName));
_materialData.material = new WireframeMaterial();
};
};
};
};
}
}
}//package away3d.loaders.utils
Section 129
//TextureLoader (away3d.loaders.utils.TextureLoader)
package away3d.loaders.utils {
import flash.display.*;
import flash.net.*;
import flash.system.*;
public class TextureLoader extends Loader {
private var _filename:String;
public function get filename():String{
return (_filename);
}
override public function load(_arg1:URLRequest, _arg2:LoaderContext=null):void{
_filename = _arg1.url;
super.load(_arg1, _arg2);
}
}
}//package away3d.loaders.utils
Section 130
//TextureLoadQueue (away3d.loaders.utils.TextureLoadQueue)
package away3d.loaders.utils {
import flash.events.*;
import flash.net.*;
public class TextureLoadQueue extends EventDispatcher {
private var _queue:Array;
private var _currentItemIndex:int;
public function TextureLoadQueue(){
_queue = [];
}
private function redispatchEvent(_arg1:Event):void{
dispatchEvent(_arg1);
}
private function onItemComplete(_arg1:Event):void{
cleanUpOldItem(currentLoader);
_currentItemIndex++;
loadNext();
}
private function loadNext():void{
var _local1:ProgressEvent;
if (_currentItemIndex >= numItems){
dispatchEvent(new Event(Event.COMPLETE));
} else {
_local1 = new ProgressEvent(ProgressEvent.PROGRESS);
_local1.bytesTotal = 100;
_local1.bytesLoaded = percentLoaded;
dispatchEvent(_local1);
if ((((currentLoader.contentLoaderInfo.bytesLoaded > 0)) && ((currentLoader.contentLoaderInfo.bytesLoaded == currentLoader.contentLoaderInfo.bytesTotal)))){
} else {
currentLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onItemComplete, false, int.MIN_VALUE, true);
currentLoader.contentLoaderInfo.addEventListener(HTTPStatusEvent.HTTP_STATUS, redispatchEvent, false, 0, true);
currentLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, redispatchEvent, false, 0, true);
currentLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, redispatchEvent, false, 0, true);
currentLoader.contentLoaderInfo.addEventListener(SecurityErrorEvent.SECURITY_ERROR, redispatchEvent, false, 0, true);
currentLoader.load(currentURLRequest);
};
};
}
private function calcProgress():Number{
var _local1:Number = (currentItemIndex / numItems);
var _local2:Number = (calcCurrentLoaderAmountLoaded() / numItems);
_local1 = _local2;
return (_local1);
}
private function calcCurrentLoaderAmountLoaded():Number{
if (currentLoader.contentLoaderInfo.bytesLoaded > 0){
return ((currentLoader.contentLoaderInfo.bytesLoaded / currentLoader.contentLoaderInfo.bytesTotal));
};
return (0);
}
private function cleanUpOldItem(_arg1:TextureLoader):void{
currentLoader.removeEventListener(Event.COMPLETE, onItemComplete, false);
currentLoader.removeEventListener(HTTPStatusEvent.HTTP_STATUS, redispatchEvent, false);
currentLoader.removeEventListener(IOErrorEvent.IO_ERROR, redispatchEvent, false);
currentLoader.removeEventListener(ProgressEvent.PROGRESS, redispatchEvent, false);
currentLoader.removeEventListener(SecurityErrorEvent.SECURITY_ERROR, redispatchEvent, false);
}
public function get numItems():int{
return (_queue.length);
}
public function get currentItemIndex():int{
return (_currentItemIndex);
}
public function get images():Array{
var _local2:LoaderAndRequest;
var _local1:Array = [];
for each (_local2 in _queue) {
_local1.push(_local2.loader);
};
return (_local1);
}
public function get currentLoader():TextureLoader{
return ((_queue[currentItemIndex] as LoaderAndRequest).loader);
}
public function get currentURLRequest():URLRequest{
return ((_queue[currentItemIndex] as LoaderAndRequest).request);
}
public function get progress():Number{
return (calcProgress());
}
public function get percentLoaded():Number{
return ((progress * 100));
}
public function addItem(_arg1:TextureLoader, _arg2:URLRequest):void{
var _local3:LoaderAndRequest;
for each (_local3 in _queue) {
if (_local3.request.url == _arg2.url){
return;
};
};
_queue.push(new LoaderAndRequest(_arg1, _arg2));
}
public function start():void{
_currentItemIndex = 0;
loadNext();
}
}
}//package away3d.loaders.utils
import flash.net.*;
class LoaderAndRequest {
public var loader:TextureLoader;
public var request:URLRequest;
private function LoaderAndRequest(_arg1:TextureLoader, _arg2:URLRequest){
this.loader = _arg1;
this.request = _arg2;
}
}
Section 131
//BitmapMaterial (away3d.materials.BitmapMaterial)
package away3d.materials {
import flash.display.*;
import away3d.core.math.*;
import away3d.core.base.*;
import away3d.core.utils.*;
import away3d.core.draw.*;
import away3d.containers.*;
import away3d.core.render.*;
import flash.utils.*;
import away3d.core.clip.*;
import flash.geom.*;
import away3d.cameras.lenses.*;
public class BitmapMaterial extends LayerMaterial {
var _texturemapping:Matrix;
var _view:View3D;
var _focus:Number;
var _bitmap:BitmapData;
var _renderBitmap:BitmapData;
var _bitmapDirty:Boolean;
var _colorTransform:ColorTransform;
var _colorTransformDirty:Boolean;
var _blendMode:String;
var _blendModeDirty:Boolean;
var _color:uint;// = 0xFFFFFF
var _red:Number;// = 1
var _green:Number;// = 1
var _blue:Number;// = 1
var _faceDictionary:Dictionary;
var _zeroPoint:Point;
var _faceMaterialVO:FaceMaterialVO;
var _mapping:Matrix;
var _s:Shape;
var _graphics:Graphics;
var _bitmapRect:Rectangle;
var _sourceVO:FaceMaterialVO;
var _session:AbstractRenderSession;
private var index:int;
protected var _screenVertices:Array;
protected var _screenCommands:Array;
protected var _screenIndices:Array;
private var _near:Number;
private var _smooth:Boolean;
private var _repeat:Boolean;
private var _precision:Number;
private var _shape:Shape;
private var map:Matrix;
private var x:Number;
private var y:Number;
private var faz:Number;
private var fbz:Number;
private var fcz:Number;
private var mabz:Number;
private var mbcz:Number;
private var mcaz:Number;
private var mabx:Number;
private var maby:Number;
private var mbcx:Number;
private var mbcy:Number;
private var mcax:Number;
private var mcay:Number;
private var dabx:Number;
private var daby:Number;
private var dbcx:Number;
private var dbcy:Number;
private var dcax:Number;
private var dcay:Number;
private var dsab:Number;
private var dsbc:Number;
private var dsca:Number;
private var dmax:Number;
private var ai:Number;
private var ax:Number;
private var ay:Number;
private var az:Number;
private var bi:Number;
private var bx:Number;
private var by:Number;
private var bz:Number;
private var ci:Number;
private var cx:Number;
private var cy:Number;
private var cz:Number;
private var _showNormals:Boolean;
private var _nn:Number3D;
private var _sv0x:Number;
private var _sv0y:Number;
private var _sv1x:Number;
private var _sv1y:Number;
public function BitmapMaterial(_arg1:BitmapData, _arg2:Object=null){
_faceDictionary = new Dictionary(true);
_zeroPoint = new Point(0, 0);
_s = new Shape();
map = new Matrix();
_nn = new Number3D();
_renderBitmap = (_bitmap = _arg1);
ini = Init.parse(_arg2);
wireColor = ini.getColor("wireColor", 0xFF);
super(ini);
smooth = ini.getBoolean("smooth", false);
debug = ini.getBoolean("debug", false);
repeat = ini.getBoolean("repeat", false);
precision = ini.getNumber("precision", 0);
_blendMode = ini.getString("blendMode", BlendMode.NORMAL);
colorTransform = (ini.getObject("colorTransform", ColorTransform) as ColorTransform);
showNormals = ini.getBoolean("showNormals", false);
_colorTransformDirty = true;
}
override function updateMaterial(_arg1:Object3D, _arg2:View3D):void{
_graphics = null;
if (_colorTransformDirty){
updateColorTransform();
};
if (_bitmapDirty){
updateRenderBitmap();
};
if (((_materialDirty) || (_blendModeDirty))){
updateFaces(_arg1, _arg2);
};
_blendModeDirty = false;
}
override function renderTriangle(_arg1:DrawTriangle):void{
_session = _arg1.source.session;
_screenCommands = _arg1.screenCommands;
_screenVertices = _arg1.screenVertices;
_screenIndices = _arg1.screenIndices;
_view = _arg1.view;
_near = _view.screenClipping.minZ;
_mapping = getMapping(_arg1);
if (precision){
if ((_view.camera.lens is ZoomFocusLens)){
_focus = _arg1.view.camera.focus;
} else {
_focus = 0;
};
map.a = _mapping.a;
map.b = _mapping.b;
map.c = _mapping.c;
map.d = _mapping.d;
map.tx = _mapping.tx;
map.ty = _mapping.ty;
index = 0;
renderRec(_arg1.startIndex, _arg1.endIndex);
} else {
_session.renderTriangleBitmap(_renderBitmap, _mapping, _screenVertices, _screenIndices, _arg1.startIndex, _arg1.endIndex, smooth, repeat, _graphics);
};
if (debug){
_session.renderTriangleLine(thickness, wireColor, wireAlpha, _screenVertices, _screenCommands, _screenIndices, _arg1.startIndex, _arg1.endIndex);
};
if (showNormals){
_nn.rotate(_arg1.faceVO.face.normal, _arg1.view.cameraVarsStore.viewTransformDictionary[_arg1.source]);
_sv0x = (((_arg1.v0x + _arg1.v1x) + _arg1.v2x) / 3);
_sv0y = (((_arg1.v0y + _arg1.v1y) + _arg1.v2y) / 3);
_sv1x = (_sv0x - (30 * _nn.x));
_sv1y = (_sv0y - (30 * _nn.y));
_session.renderLine(_sv0x, _sv0y, _sv1x, _sv1y, 0, 0xFF00FF, 1);
};
}
override function renderSprite(_arg1:DrawSprite):void{
_arg1.source.session.renderSpriteBitmap(_renderBitmap, _arg1, smooth);
}
override function renderLayer(_arg1:DrawTriangle, _arg2:Sprite, _arg3:int):int{
if (blendMode == BlendMode.NORMAL){
_graphics = _arg2.graphics;
} else {
_session = _arg1.source.session;
var _temp1 = _arg3;
_arg3 = (_arg3 + 1);
_shape = _session.getShape(this, _temp1, _arg2);
_shape.blendMode = _blendMode;
_graphics = _shape.graphics;
};
renderTriangle(_arg1);
return (_arg3);
}
override function renderBitmapLayer(_arg1:DrawTriangle, _arg2:Rectangle, _arg3:FaceMaterialVO):FaceMaterialVO{
renderSource(_arg1.source, _arg2, new Matrix());
_faceMaterialVO = getFaceMaterialVO(_arg1.faceVO.face.faceVO);
if (_arg3.resized){
_arg3.resized = false;
_faceMaterialVO.resized = true;
};
_faceMaterialVO.invtexturemapping = _arg3.invtexturemapping;
if (((((_arg3.updated) || (_faceMaterialVO.invalidated))) || (_faceMaterialVO.updated))){
_arg3.updated = false;
_faceMaterialVO.invalidated = false;
_faceMaterialVO.cleared = false;
_faceMaterialVO.updated = true;
_faceMaterialVO.bitmap = _arg3.bitmap.clone();
_faceMaterialVO.bitmap.copyPixels(_sourceVO.bitmap, _arg1.faceVO.face.bitmapRect, _zeroPoint, null, null, true);
};
return (_faceMaterialVO);
}
function getFaceMaterialVO(_arg1:FaceVO, _arg2:Object3D=null, _arg3:View3D=null):FaceMaterialVO{
if ((_faceMaterialVO = _faceDictionary[_arg1])){
return (_faceMaterialVO);
};
return ((_faceDictionary[_arg1] = new FaceMaterialVO()));
}
private function renderRec(_arg1:Number, _arg2:Number):void{
var _local12:int;
var _local13:int;
var _local14:int;
var _local3:int = _screenIndices[_arg1];
ai = (_local3 * 3);
ax = _screenVertices[ai];
ay = _screenVertices[(ai + 1)];
az = _screenVertices[(ai + 2)];
var _local4:int = _screenIndices[(_arg1 + 1)];
bi = (_local4 * 3);
bx = _screenVertices[bi];
by = _screenVertices[(bi + 1)];
bz = _screenVertices[(bi + 2)];
var _local5:int = _screenIndices[(_arg1 + 2)];
ci = (_local5 * 3);
cx = _screenVertices[ci];
cy = _screenVertices[(ci + 1)];
cz = _screenVertices[(ci + 2)];
if (((!((_view.screenClipping is FrustumClipping))) && (!(_view.screenClipping.rect(Math.min(ax, Math.min(bx, cx)), Math.min(ay, Math.min(by, cy)), Math.max(ax, Math.max(bx, cx)), Math.max(ay, Math.max(by, cy))))))){
return;
};
if ((((_view.screenClipping is RectangleClipping)) && ((((((az < _near)) || ((bz < _near)))) || ((cz < _near)))))){
return;
};
if ((((((((index >= 1000)) || ((_focus == Infinity)))) || (((Math.max(Math.max(ax, bx), cx) - Math.min(Math.min(ax, bx), cx)) < 10)))) || (((Math.max(Math.max(ay, by), cy) - Math.min(Math.min(ay, by), cy)) < 10)))){
_session.renderTriangleBitmap(_renderBitmap, map, _screenVertices, _screenIndices, _arg1, _arg2, smooth, repeat, _graphics);
if (debug){
_session.renderTriangleLine(1, 0xFF00, 1, _screenVertices, _screenCommands, _screenIndices, _arg1, _arg2);
};
return;
};
faz = (_focus + az);
fbz = (_focus + bz);
fcz = (_focus + cz);
mabz = (2 / (faz + fbz));
mbcz = (2 / (fbz + fcz));
mcaz = (2 / (fcz + faz));
dabx = ((ax + bx) - (mabx = (((ax * faz) + (bx * fbz)) * mabz)));
daby = ((ay + by) - (maby = (((ay * faz) + (by * fbz)) * mabz)));
dbcx = ((bx + cx) - (mbcx = (((bx * fbz) + (cx * fcz)) * mbcz)));
dbcy = ((by + cy) - (mbcy = (((by * fbz) + (cy * fcz)) * mbcz)));
dcax = ((cx + ax) - (mcax = (((cx * fcz) + (ax * faz)) * mcaz)));
dcay = ((cy + ay) - (mcay = (((cy * fcz) + (ay * faz)) * mcaz)));
dsab = ((dabx * dabx) + (daby * daby));
dsbc = ((dbcx * dbcx) + (dbcy * dbcy));
dsca = ((dcax * dcax) + (dcay * dcay));
if ((((((dsab <= precision)) && ((dsca <= precision)))) && ((dsbc <= precision)))){
_session.renderTriangleBitmap(_renderBitmap, map, _screenVertices, _screenIndices, _arg1, _arg2, smooth, repeat, _graphics);
if (debug){
_session.renderTriangleLine(1, 0xFF00, 1, _screenVertices, _screenCommands, _screenIndices, _arg1, _arg2);
};
return;
};
var _local6:Number = map.a;
var _local7:Number = map.b;
var _local8:Number = map.c;
var _local9:Number = map.d;
var _local10:Number = map.tx;
var _local11:Number = map.ty;
index++;
_local14 = (_screenVertices.length / 3);
_screenVertices[_screenVertices.length] = (mbcx / 2);
_screenVertices[_screenVertices.length] = (mbcy / 2);
_screenVertices[_screenVertices.length] = ((bz + cz) / 2);
if ((((((dsab > precision)) && ((dsca > precision)))) && ((dsbc > precision)))){
index = (index + 2);
_local12 = (_screenVertices.length / 3);
_screenVertices[_screenVertices.length] = (mabx / 2);
_screenVertices[_screenVertices.length] = (maby / 2);
_screenVertices[_screenVertices.length] = ((az + bz) / 2);
_local13 = (_screenVertices.length / 3);
_screenVertices[_screenVertices.length] = (mcax / 2);
_screenVertices[_screenVertices.length] = (mcay / 2);
_screenVertices[_screenVertices.length] = ((cz + az) / 2);
_arg1 = _screenIndices.length;
var _local15 = _arg1;
_screenIndices[_local15] = _local3;
_screenIndices[_screenIndices.length] = _local12;
_screenIndices[_screenIndices.length] = _local13;
_arg2 = _screenIndices.length;
_local6 = (_local6 * 2);
map.a = _local6;
_local7 = (_local7 * 2);
map.b = _local7;
_local8 = (_local8 * 2);
map.c = _local8;
_local9 = (_local9 * 2);
map.d = _local9;
_local10 = (_local10 * 2);
map.tx = _local10;
_local11 = (_local11 * 2);
map.ty = _local11;
renderRec(_arg1, _arg2);
_arg1 = _screenIndices.length;
var _local16 = _arg1;
_screenIndices[_local16] = _local12;
_screenIndices[_screenIndices.length] = _local4;
_screenIndices[_screenIndices.length] = _local14;
_arg2 = _screenIndices.length;
map.a = _local6;
map.b = _local7;
map.c = _local8;
map.d = _local9;
map.tx = (_local10 - 1);
map.ty = _local11;
renderRec(_arg1, _arg2);
_arg1 = _screenIndices.length;
var _local17 = _arg1;
_screenIndices[_local17] = _local13;
_screenIndices[_screenIndices.length] = _local14;
_screenIndices[_screenIndices.length] = _local5;
_arg2 = _screenIndices.length;
map.a = _local6;
map.b = _local7;
map.c = _local8;
map.d = _local9;
map.tx = _local10;
map.ty = (_local11 - 1);
renderRec(_arg1, _arg2);
_arg1 = _screenIndices.length;
var _local18 = _arg1;
_screenIndices[_local18] = _local14;
_screenIndices[_screenIndices.length] = _local13;
_screenIndices[_screenIndices.length] = _local12;
_arg2 = _screenIndices.length;
map.a = -(_local6);
map.b = -(_local7);
map.c = -(_local8);
map.d = -(_local9);
map.tx = (1 - _local10);
map.ty = (1 - _local11);
renderRec(_arg1, _arg2);
return;
};
dmax = Math.max(dsab, Math.max(dsca, dsbc));
if (dsab == dmax){
index++;
_local12 = (_screenVertices.length / 3);
_screenVertices[_screenVertices.length] = (mabx / 2);
_screenVertices[_screenVertices.length] = (maby / 2);
_screenVertices[_screenVertices.length] = ((az + bz) / 2);
_arg1 = _screenIndices.length;
_local15 = _arg1;
_screenIndices[_local15] = _local3;
_screenIndices[_screenIndices.length] = _local12;
_screenIndices[_screenIndices.length] = _local5;
_arg2 = _screenIndices.length;
_local6 = (_local6 * 2);
map.a = _local6;
_local8 = (_local8 * 2);
map.c = _local8;
_local10 = (_local10 * 2);
map.tx = _local10;
renderRec(_arg1, _arg2);
_arg1 = _screenIndices.length;
_local16 = _arg1;
_screenIndices[_local16] = _local12;
_screenIndices[_screenIndices.length] = _local4;
_screenIndices[_screenIndices.length] = _local5;
_arg2 = _screenIndices.length;
map.a = (_local6 + _local7);
map.b = _local7;
map.c = (_local8 + _local9);
map.d = _local9;
map.tx = ((_local10 + _local11) - 1);
map.ty = _local11;
renderRec(_arg1, _arg2);
return;
};
if (dsca == dmax){
index++;
_local13 = (_screenVertices.length / 3);
_screenVertices[_screenVertices.length] = (mcax / 2);
_screenVertices[_screenVertices.length] = (mcay / 2);
_screenVertices[_screenVertices.length] = ((cz + az) / 2);
_arg1 = _screenIndices.length;
_local15 = _arg1;
_screenIndices[_local15] = _local3;
_screenIndices[_screenIndices.length] = _local4;
_screenIndices[_screenIndices.length] = _local13;
_arg2 = _screenIndices.length;
_local7 = (_local7 * 2);
map.b = _local7;
_local9 = (_local9 * 2);
map.d = _local9;
_local11 = (_local11 * 2);
map.ty = _local11;
renderRec(_arg1, _arg2);
_arg1 = _screenIndices.length;
_local16 = _arg1;
_screenIndices[_local16] = _local13;
_screenIndices[_screenIndices.length] = _local4;
_screenIndices[_screenIndices.length] = _local5;
_arg2 = _screenIndices.length;
map.a = _local6;
map.b = (_local7 + _local6);
map.c = _local8;
map.d = (_local9 + _local8);
map.tx = _local10;
map.ty = ((_local11 + _local10) - 1);
renderRec(_arg1, _arg2);
return;
};
_arg1 = _screenIndices.length;
_local15 = _arg1;
_screenIndices[_local15] = _local3;
_screenIndices[_screenIndices.length] = _local4;
_screenIndices[_screenIndices.length] = _local14;
_arg2 = _screenIndices.length;
map.a = (_local6 - _local7);
map.b = (_local7 * 2);
map.c = (_local8 - _local9);
map.d = (_local9 * 2);
map.tx = (_local10 - _local11);
map.ty = (_local11 * 2);
renderRec(_arg1, _arg2);
_arg1 = _screenIndices.length;
_local16 = _arg1;
_screenIndices[_local16] = _local3;
_screenIndices[_screenIndices.length] = _local14;
_screenIndices[_screenIndices.length] = _local5;
_arg2 = _screenIndices.length;
map.a = (_local6 * 2);
map.b = (_local7 - _local6);
map.c = (_local8 * 2);
map.d = (_local9 - _local8);
map.tx = (_local10 * 2);
map.ty = (_local11 - _local10);
renderRec(_arg1, _arg2);
}
protected function renderSource(_arg1:Object3D, _arg2:Rectangle, _arg3:Matrix):void{
if (!(_sourceVO = _faceDictionary[_arg1])){
_sourceVO = (_faceDictionary[_arg1] = new FaceMaterialVO());
};
_sourceVO.resize(_arg2.width, _arg2.height);
if (((_sourceVO.invalidated) || (_sourceVO.updated))){
_arg3.scale((_arg2.width / width), (_arg2.height / height));
_sourceVO.invalidated = false;
_sourceVO.cleared = false;
_sourceVO.updated = false;
if ((((((((((((_arg3.a == 1)) && ((_arg3.d == 1)))) && ((_arg3.b == 0)))) && ((_arg3.c == 0)))) && ((_arg3.tx == 0)))) && ((_arg3.ty == 0)))){
_sourceVO.bitmap.copyPixels(_bitmap, _arg2, _zeroPoint);
} else {
_graphics = _s.graphics;
_graphics.clear();
_graphics.beginBitmapFill(_bitmap, _arg3, repeat, smooth);
_graphics.drawRect(0, 0, _arg2.width, _arg2.height);
_graphics.endFill();
_sourceVO.bitmap.draw(_s, null, _colorTransform, _blendMode, _sourceVO.bitmap.rect);
};
};
}
protected function updateFaces(_arg1:Object3D=null, _arg2:View3D=null):void{
notifyMaterialUpdate();
for each (_faceMaterialVO in _faceDictionary) {
if (!_faceMaterialVO.cleared){
_faceMaterialVO.clear();
};
};
}
protected function invalidateFaces(_arg1:Object3D=null, _arg2:View3D=null):void{
_materialDirty = true;
for each (_faceMaterialVO in _faceDictionary) {
_faceMaterialVO.invalidated = true;
};
}
protected function updateColorTransform():void{
_colorTransformDirty = false;
_bitmapDirty = true;
_materialDirty = true;
if ((((_alpha == 1)) && ((_color == 0xFFFFFF)))){
_renderBitmap = _bitmap;
if (((!(_colorTransform)) || (((((!(_colorTransform.redOffset)) && (!(_colorTransform.greenOffset)))) && (!(_colorTransform.blueOffset)))))){
_colorTransform = null;
return;
};
} else {
if (!_colorTransform){
_colorTransform = new ColorTransform();
};
};
_colorTransform.redMultiplier = _red;
_colorTransform.greenMultiplier = _green;
_colorTransform.blueMultiplier = _blue;
_colorTransform.alphaMultiplier = _alpha;
if (_alpha == 0){
_renderBitmap = null;
return;
};
}
protected function updateRenderBitmap():void{
_bitmapDirty = false;
if (_colorTransform){
if (((!(_bitmap.transparent)) && (!((_alpha == 1))))){
_renderBitmap = new BitmapData(_bitmap.width, _bitmap.height, true);
_renderBitmap.draw(_bitmap);
} else {
_renderBitmap = _bitmap.clone();
};
_renderBitmap.colorTransform(_renderBitmap.rect, _colorTransform);
} else {
_renderBitmap = _bitmap;
};
invalidateFaces();
}
protected function getMapping(_arg1:DrawTriangle):Matrix{
if (_arg1.generated){
_texturemapping = _arg1.transformUV(this).clone();
_texturemapping.invert();
return (_texturemapping);
};
_faceMaterialVO = getFaceMaterialVO(_arg1.faceVO);
if (!_faceMaterialVO.invalidated){
return (_faceMaterialVO.texturemapping);
};
_faceMaterialVO.invalidated = false;
_texturemapping = _arg1.transformUV(this).clone();
_texturemapping.invert();
return ((_faceMaterialVO.texturemapping = _texturemapping));
}
public function get smooth():Boolean{
return (_smooth);
}
public function set smooth(_arg1:Boolean):void{
if (_smooth == _arg1){
return;
};
_smooth = _arg1;
_materialDirty = true;
}
public function get repeat():Boolean{
return (_repeat);
}
public function set repeat(_arg1:Boolean):void{
if (_repeat == _arg1){
return;
};
_repeat = _arg1;
_materialDirty = true;
}
public function get precision():Number{
return (_precision);
}
public function set precision(_arg1:Number):void{
_precision = ((_arg1 * _arg1) * 1.4);
_materialDirty = true;
}
override public function get width():Number{
return (_bitmap.width);
}
override public function get height():Number{
return (_bitmap.height);
}
public function get bitmap():BitmapData{
return (_bitmap);
}
public function set bitmap(_arg1:BitmapData):void{
_bitmap = _arg1;
_bitmapDirty = true;
}
public function getPixel32(_arg1:Number, _arg2:Number):uint{
if (repeat){
x = (_arg1 % 1);
y = (1 - (_arg2 % 1));
} else {
x = _arg1;
y = (1 - _arg2);
};
return (_bitmap.getPixel32((x * _bitmap.width), (y * _bitmap.height)));
}
override public function get color():uint{
return (_color);
}
override public function set color(_arg1:uint):void{
if (_color == _arg1){
return;
};
_color = _arg1;
_red = (((_color & 0xFF0000) >> 16) / 0xFF);
_green = (((_color & 0xFF00) >> 8) / 0xFF);
_blue = ((_color & 0xFF) / 0xFF);
_colorTransformDirty = true;
}
override public function get alpha():Number{
return (_alpha);
}
override public function set alpha(_arg1:Number):void{
if (_arg1 > 1){
_arg1 = 1;
};
if (_arg1 < 0){
_arg1 = 0;
};
if (_alpha == _arg1){
return;
};
_alpha = _arg1;
_colorTransformDirty = true;
}
public function get colorTransform():ColorTransform{
return (_colorTransform);
}
public function set colorTransform(_arg1:ColorTransform):void{
_colorTransform = _arg1;
if (_colorTransform){
_red = _colorTransform.redMultiplier;
_green = _colorTransform.greenMultiplier;
_blue = _colorTransform.blueMultiplier;
_alpha = _colorTransform.alphaMultiplier;
_color = ((((_red * 0xFF) << 16) + ((_green * 0xFF) << 8)) + (_blue * 0xFF));
};
_colorTransformDirty = true;
}
public function get blendMode():String{
return (_blendMode);
}
public function set blendMode(_arg1:String):void{
if (_blendMode == _arg1){
return;
};
_blendMode = _arg1;
_blendModeDirty = true;
}
public function get showNormals():Boolean{
return (_showNormals);
}
public function set showNormals(_arg1:Boolean):void{
if (_showNormals == _arg1){
return;
};
_showNormals = _arg1;
_materialDirty = true;
}
}
}//package away3d.materials
Section 132
//ColorMaterial (away3d.materials.ColorMaterial)
package away3d.materials {
import away3d.core.draw.*;
public class ColorMaterial extends WireColorMaterial {
protected var _debug:Boolean;
public function ColorMaterial(_arg1=null, _arg2:Object=null){
super(_arg1, _arg2);
debug = ini.getBoolean("debug", false);
}
override function renderTriangle(_arg1:DrawTriangle):void{
if (debug){
_arg1.source.session.renderTriangleLineFill(_thickness, _color, _alpha, _wireColor, _wireAlpha, _arg1.screenVertices, _arg1.screenCommands, _arg1.screenIndices, _arg1.startIndex, _arg1.endIndex);
} else {
_arg1.source.session.renderTriangleColor(_color, _alpha, _arg1.screenVertices, _arg1.screenCommands, _arg1.screenIndices, _arg1.startIndex, _arg1.endIndex);
};
}
override function renderSprite(_arg1:DrawSprite):void{
_arg1.source.session.renderSpriteColor(_color, _alpha, _arg1);
}
function renderFog(_arg1:DrawFog):void{
_arg1.source.session.renderFogColor(_arg1.clip, _color, _alpha);
}
public function get debug():Boolean{
return (_debug);
}
public function set debug(_arg1:Boolean):void{
if (_debug == _arg1){
return;
};
_debug = _arg1;
_materialDirty = true;
}
override public function clone(_arg1:Material=null):Material{
var _local2:ColorMaterial = (((_arg1 as ColorMaterial)) || (new ColorMaterial()));
super.clone(_local2);
_local2.debug = _debug;
return (_local2);
}
}
}//package away3d.materials
Section 133
//CompositeMaterial (away3d.materials.CompositeMaterial)
package away3d.materials {
import flash.display.*;
import away3d.core.base.*;
import away3d.core.utils.*;
import away3d.core.draw.*;
import away3d.containers.*;
import flash.utils.*;
import away3d.events.*;
import flash.geom.*;
import away3d.cameras.lenses.*;
public class CompositeMaterial extends BitmapMaterial {
var _source:Object3D;
private var _defaultColorTransform:ColorTransform;
private var _width:Number;
private var _height:Number;
private var _surfaceCache:Boolean;
private var _fMaterialVO:FaceMaterialVO;
private var _containerDictionary:Dictionary;
private var _cacheDictionary:Dictionary;
private var _containerVO:FaceMaterialVO;
private var _faceWidth:int;
private var _faceHeight:int;
private var _faceVO:FaceVO;
protected var materials:Array;
public var transparent:Boolean;
public function CompositeMaterial(_arg1:Object=null){
var _local2:LayerMaterial;
_defaultColorTransform = new ColorTransform();
_containerDictionary = new Dictionary(true);
_cacheDictionary = new Dictionary(true);
ini = Init.parse(_arg1);
width = ini.getNumber("width", 128);
height = ini.getNumber("height", 128);
super(_bitmap, ini);
materials = ini.getArray("materials");
for each (_local2 in materials) {
_local2.addOnMaterialUpdate(onMaterialUpdate);
};
transparent = ini.getBoolean("transparent", true);
surfaceCache = ini.getBoolean("surfaceCache", false);
}
override function updateMaterial(_arg1:Object3D, _arg2:View3D):void{
var _local3:LayerMaterial;
for each (_local3 in materials) {
_local3.updateMaterial(_arg1, _arg2);
};
if (_colorTransformDirty){
updateColorTransform();
};
if (_bitmapDirty){
updateRenderBitmap();
};
if (((_materialDirty) || (_blendModeDirty))){
updateFaces();
};
_blendModeDirty = false;
}
override function renderTriangle(_arg1:DrawTriangle):void{
var _local2:int;
var _local3:Sprite;
var _local4:LayerMaterial;
if (_surfaceCache){
super.renderTriangle(_arg1);
} else {
_source = _arg1.source;
_session = _source.session;
_local2 = 0;
_local3 = (_session.layer as Sprite);
if (((((((!(_local3)) || (!((this == _session._material))))) || (_colorTransform))) || (!((blendMode == BlendMode.NORMAL))))){
var _temp1 = _local2;
_local2 = (_local2 + 1);
_local3 = _session.getSprite(this, _temp1);
_local3.blendMode = blendMode;
};
if (_colorTransform){
_local3.transform.colorTransform = _colorTransform;
} else {
_local3.transform.colorTransform = _defaultColorTransform;
};
for each (_local4 in materials) {
_local2 = _local4.renderLayer(_arg1, _local3, _local2);
};
};
}
override function renderLayer(_arg1:DrawTriangle, _arg2:Sprite, _arg3:int):int{
var _local4:Sprite;
var _local5:LayerMaterial;
if (((!(_colorTransform)) && ((blendMode == BlendMode.NORMAL)))){
_local4 = _arg2;
} else {
_source = _arg1.source;
_session = _source.session;
var _temp1 = _arg3;
_arg3 = (_arg3 + 1);
_local4 = _session.getSprite(this, _temp1, _arg2);
_local4.blendMode = blendMode;
if (_colorTransform){
_local4.transform.colorTransform = _colorTransform;
} else {
_local4.transform.colorTransform = _defaultColorTransform;
};
};
for each (_local5 in materials) {
_arg3 = _local5.renderLayer(_arg1, _local4, _arg3);
};
return (_arg3);
}
override function renderBitmapLayer(_arg1:DrawTriangle, _arg2:Rectangle, _arg3:FaceMaterialVO):FaceMaterialVO{
var _local4:LayerMaterial;
_faceMaterialVO = getFaceMaterialVO(_arg1.faceVO);
_faceWidth = _arg1.faceVO.face.bitmapRect.width;
_faceHeight = _arg1.faceVO.face.bitmapRect.height;
if (!(_containerVO = _containerDictionary[_arg1])){
_containerVO = (_containerDictionary[_arg1] = new FaceMaterialVO());
};
if (_arg3.resized){
_arg3.resized = false;
_containerVO.resize(_faceWidth, _faceHeight, transparent);
};
_faceMaterialVO.invtexturemapping = (_containerVO.invtexturemapping = _arg3.invtexturemapping);
for each (_local4 in materials) {
_containerVO = _local4.renderBitmapLayer(_arg1, _arg2, _containerVO);
};
if (((_arg3.updated) || (_containerVO.updated))){
_arg3.updated = false;
_containerVO.updated = false;
_faceMaterialVO.invalidated = false;
_faceMaterialVO.cleared = false;
_faceMaterialVO.updated = true;
_faceMaterialVO.bitmap = _arg3.bitmap.clone();
_faceMaterialVO.bitmap.lock();
_sourceVO = _faceMaterialVO;
if ((((_blendMode == BlendMode.NORMAL)) && (!(_colorTransform)))){
_faceMaterialVO.bitmap.copyPixels(_containerVO.bitmap, _containerVO.bitmap.rect, _zeroPoint, null, null, true);
} else {
_faceMaterialVO.bitmap.draw(_containerVO.bitmap, null, _colorTransform, _blendMode);
};
};
return (_faceMaterialVO);
}
private function onMaterialUpdate(_arg1:MaterialEvent):void{
_materialDirty = true;
}
override protected function updateRenderBitmap():void{
_bitmapDirty = false;
invalidateFaces();
_materialDirty = true;
}
override protected function getMapping(_arg1:DrawTriangle):Matrix{
var _local2:LayerMaterial;
_faceVO = _arg1.faceVO.face.faceVO;
if ((_view.camera.lens is ZoomFocusLens)){
_focus = _arg1.view.camera.focus;
} else {
_focus = 0;
};
_faceMaterialVO = getFaceMaterialVO(_faceVO, _arg1.source, _arg1.view);
if (((_faceMaterialVO.invalidated) || (_faceMaterialVO.updated))){
_faceMaterialVO.updated = true;
_faceMaterialVO.cleared = false;
if (_faceMaterialVO.invalidated){
_faceMaterialVO.invalidated = false;
_faceVO.face.bitmapRect = new Rectangle(int((_width * _faceVO.minU)), int((_height * (1 - _faceVO.maxV))), (_faceWidth = int(((_width * (_faceVO.maxU - _faceVO.minU)) + 2))), (_faceHeight = int(((_height * (_faceVO.maxV - _faceVO.minV)) + 2))));
_faceMaterialVO.invtexturemapping = _arg1.transformUV(this).clone();
_faceMaterialVO.texturemapping = _faceMaterialVO.invtexturemapping.clone();
_faceMaterialVO.texturemapping.invert();
_faceMaterialVO.resize(_faceWidth, _faceHeight, transparent);
};
_fMaterialVO = _faceMaterialVO;
for each (_local2 in materials) {
_fMaterialVO = _local2.renderBitmapLayer(_arg1, _bitmapRect, _fMaterialVO);
};
_cacheDictionary[_faceVO] = _fMaterialVO.bitmap;
_fMaterialVO.updated = false;
};
_renderBitmap = _cacheDictionary[_faceVO];
if (_arg1.generated){
_texturemapping = _arg1.transformUV(this).clone();
_texturemapping.invert();
return (_texturemapping);
};
return (_faceMaterialVO.texturemapping);
}
public function get surfaceCache():Boolean{
return (_surfaceCache);
}
public function set surfaceCache(_arg1:Boolean):void{
_surfaceCache = _arg1;
_materialDirty = true;
}
override public function get width():Number{
return (_width);
}
public function set width(_arg1:Number):void{
if (_width == _arg1){
return;
};
_width = _arg1;
if (((_width) && (_height))){
_bitmap = new BitmapData(_width, _height, true, 0xFFFFFF);
};
_bitmapRect = new Rectangle(0, 0, _width, _height);
}
override public function get height():Number{
return (_height);
}
public function set height(_arg1:Number):void{
if (_height == _arg1){
return;
};
_height = _arg1;
if (((_width) && (_height))){
_bitmap = new BitmapData(_width, _height, true, 0xFFFFFF);
};
_bitmapRect = new Rectangle(0, 0, _width, _height);
}
public function addMaterial(_arg1:LayerMaterial):void{
_arg1.addOnMaterialUpdate(onMaterialUpdate);
materials.push(_arg1);
_materialDirty = true;
}
public function removeMaterial(_arg1:LayerMaterial):void{
var _local2:int = materials.indexOf(_arg1);
if (_local2 == -1){
return;
};
_arg1.removeOnMaterialUpdate(onMaterialUpdate);
materials.splice(_local2, 1);
_materialDirty = true;
}
public function clearMaterials():void{
var _local1:int = materials.length;
while (_local1--) {
removeMaterial(materials[_local1]);
};
}
}
}//package away3d.materials
Section 134
//LayerMaterial (away3d.materials.LayerMaterial)
package away3d.materials {
import flash.display.*;
import away3d.core.utils.*;
import away3d.core.draw.*;
import flash.geom.*;
public class LayerMaterial extends ColorMaterial {
public function LayerMaterial(_arg1:Object=null){
ini = Init.parse(_arg1);
super(ini.getColor("color", 0xFFFFFF), ini);
}
function renderLayer(_arg1:DrawTriangle, _arg2:Sprite, _arg3:int):int{
throw (new Error("Not implemented"));
}
function renderBitmapLayer(_arg1:DrawTriangle, _arg2:Rectangle, _arg3:FaceMaterialVO):FaceMaterialVO{
throw (new Error("Not implemented"));
}
public function get width():Number{
return (0);
}
public function get height():Number{
return (0);
}
}
}//package away3d.materials
Section 135
//Material (away3d.materials.Material)
package away3d.materials {
import flash.events.*;
import away3d.core.base.*;
import away3d.core.draw.*;
import away3d.containers.*;
import away3d.events.*;
public class Material extends EventDispatcher {
var _id:int;
function updateMaterial(_arg1:Object3D, _arg2:View3D):void{
throw (new Error("Not implemented"));
}
function renderSegment(_arg1:DrawSegment):void{
throw (new Error("Not implemented"));
}
function renderTriangle(_arg1:DrawTriangle):void{
throw (new Error("Not implemented"));
}
function renderSprite(_arg1:DrawSprite):void{
throw (new Error("Not implemented"));
}
public function get visible():Boolean{
return (true);
}
public function get id():int{
return (_id);
}
public function clone(_arg1:Material=null):Material{
var _local2:Material = ((_arg1) || (new Material()));
return (_local2);
}
public function addOnMaterialUpdate(_arg1:Function):void{
addEventListener(MaterialEvent.MATERIAL_UPDATED, _arg1, false, 0, true);
}
public function removeOnMaterialUpdate(_arg1:Function):void{
removeEventListener(MaterialEvent.MATERIAL_UPDATED, _arg1, false);
}
}
}//package away3d.materials
Section 136
//MovieMaterial (away3d.materials.MovieMaterial)
package away3d.materials {
import flash.display.*;
import away3d.core.base.*;
import away3d.core.utils.*;
import away3d.containers.*;
import away3d.events.*;
import flash.geom.*;
public class MovieMaterial extends TransformBitmapMaterial {
public var _movie:Sprite;
private var _colTransform:ColorTransform;
private var _bMode:String;
private var x:Number;
private var y:Number;
private var t:Matrix;
public var transparent:Boolean;
public var autoUpdate:Boolean;
public var interactive:Boolean;
private var _clipRect:Rectangle;
private var _lockW:Number;
private var _lockH:Number;
private var rendered:Boolean;
public function MovieMaterial(_arg1:Sprite, _arg2:Object=null){
ini = Init.parse(_arg2);
transparent = ini.getBoolean("transparent", true);
autoUpdate = ini.getBoolean("autoUpdate", true);
interactive = ini.getBoolean("interactive", false);
_movie = _arg1;
_lockW = ini.getNumber("lockW", _arg1.width);
_lockH = ini.getNumber("lockH", _arg1.height);
_bitmap = new BitmapData(Math.max(1, _lockW), Math.max(1, _lockH), transparent, (transparent) ? 0xFFFFFF : 0);
super(_bitmap, ini);
}
override function updateMaterial(_arg1:Object3D, _arg2:View3D):void{
super.updateMaterial(_arg1, _arg2);
if (autoUpdate){
update();
};
_session = _arg1.session;
if (interactive){
if (!_arg2._interactiveLayer.contains(movie)){
_arg2._interactiveLayer.addChild(movie);
resetInteractiveLayer();
_arg1.addOnMouseOver(onMouseOver);
_arg1.addOnMouseOut(onMouseOut);
};
} else {
if (_arg2._interactiveLayer.contains(movie)){
_arg2._interactiveLayer.removeChild(movie);
_arg1.removeOnMouseOver(onMouseOver);
_arg1.removeOnMouseOut(onMouseOut);
};
};
}
private function onMouseOver(_arg1:MouseEvent3D):void{
if (_arg1.material == this){
_arg1.object.addOnMouseMove(onMouseMove);
onMouseMove(_arg1);
};
}
private function onMouseOut(_arg1:MouseEvent3D):void{
if (_arg1.material == this){
_arg1.object.removeOnMouseMove(onMouseMove);
resetInteractiveLayer();
};
}
private function onMouseMove(_arg1:MouseEvent3D):void{
x = (_arg1.uv.u * _renderBitmap.width);
y = ((1 - _arg1.uv.v) * _renderBitmap.height);
if (_transform){
t = _transform.clone();
t.invert();
movie.x = (((_arg1.screenX - (x * t.a)) - (y * t.c)) - t.tx);
movie.y = (((_arg1.screenY - (x * t.b)) - (y * t.d)) - t.ty);
} else {
movie.x = (_arg1.screenX - x);
movie.y = (_arg1.screenY - y);
};
}
private function resetInteractiveLayer():void{
movie.x = -10000;
movie.y = -10000;
}
override protected function updateRenderBitmap():void{
}
override public function get width():Number{
return (_renderBitmap.width);
}
override public function get height():Number{
return (_renderBitmap.height);
}
public function get movie():Sprite{
return (_movie);
}
public function set movie(_arg1:Sprite):void{
if (_movie == _arg1){
return;
};
if (((_movie) && (_movie.parent))){
_movie.parent.removeChild(_movie);
};
_movie = _arg1;
}
public function update():void{
var _local1:Rectangle;
if (_renderBitmap != null){
notifyMaterialUpdate();
_local1 = ((((_clipRect == null)) || (!(rendered)))) ? _renderBitmap.rect : _clipRect;
if (transparent){
_renderBitmap.fillRect(_local1, 0xFFFFFF);
};
if (((!((_alpha == 1))) || (!((_color == 0xFFFFFF))))){
_colTransform = _colorTransform;
} else {
_colTransform = movie.transform.colorTransform;
};
if (_blendMode != BlendMode.NORMAL){
_bMode = _blendMode;
} else {
_bMode = movie.blendMode;
};
_renderBitmap.draw(movie, new Matrix(movie.scaleX, 0, 0, movie.scaleY), _colTransform, _bMode, _local1);
if (!rendered){
rendered = true;
};
};
}
public function set clipRect(_arg1:Rectangle):void{
_clipRect = _arg1;
}
public function get clipRect():Rectangle{
return (_clipRect);
}
public function set lockW(_arg1:Number):void{
_lockW = (((!(isNaN(_arg1))) && ((_arg1 > 1)))) ? _arg1 : _lockW;
if (_renderBitmap != null){
_bitmap.dispose();
_renderBitmap.dispose();
_bitmap = new BitmapData(Math.max(1, _lockW), Math.max(1, _lockH), transparent, (transparent) ? 0xFFFFFF : 0);
_renderBitmap = _bitmap.clone();
update();
};
}
public function get lockW():Number{
return (_lockW);
}
public function set lockH(_arg1:Number):void{
_lockH = (((!(isNaN(_arg1))) && ((_arg1 > 1)))) ? _arg1 : _lockH;
if (_renderBitmap != null){
_bitmap.dispose();
_renderBitmap.dispose();
_bitmap = new BitmapData(Math.max(1, _lockW), Math.max(1, _lockH), transparent, (transparent) ? 0xFFFFFF : 0);
_renderBitmap = _bitmap.clone();
update();
};
}
public function get lockH():Number{
return (_lockH);
}
}
}//package away3d.materials
Section 137
//ShadingColorMaterial (away3d.materials.ShadingColorMaterial)
package away3d.materials {
import away3d.core.light.*;
import away3d.core.base.*;
import away3d.core.utils.*;
import away3d.core.draw.*;
import away3d.containers.*;
import away3d.core.render.*;
import flash.utils.*;
public class ShadingColorMaterial extends ColorMaterial {
private var fr:int;
private var fg:int;
private var fb:int;
private var sfr:int;
private var sfg:int;
private var sfb:int;
private var shader:FaceNormalShader;
public var ambient:uint;
public var diffuse:uint;
public var specular:uint;
public var shininess:Number;
public var cache:Boolean;
public function ShadingColorMaterial(_arg1=null, _arg2:Object=null){
shader = new FaceNormalShader();
super(_arg1, _arg2);
ambient = ini.getColor("ambient", _arg1);
diffuse = ini.getColor("diffuse", _arg1);
specular = ini.getColor("specular", _arg1);
shininess = ini.getNumber("shininess", 20);
cache = ini.getBoolean("cache", false);
}
override function updateMaterial(_arg1:Object3D, _arg2:View3D):void{
var _local4:DirectionalLight;
var _local5:Array;
var _local6:PointLight;
var _local3:Array = _arg1.lightarray.directionals;
for each (_local4 in _local3) {
if (((!(_local4.diffuseTransform[_arg1])) || (_arg2.scene.updatedObjects[_arg1]))){
_local4.setDiffuseTransform(_arg1);
_materialDirty = true;
};
if (!_local4.specularTransform[_arg1]){
_local4.specularTransform[_arg1] = new Dictionary(true);
};
if (((((!(_local4.specularTransform[_arg1][_arg2])) || (_arg2.scene.updatedObjects[_arg1]))) || (_arg2.updated))){
_local4.setSpecularTransform(_arg1, _arg2);
_materialDirty = true;
};
};
_local5 = _arg1.lightarray.points;
for each (_local6 in _local5) {
if (((((!(_local6.viewPositions[_arg2])) || (_arg2.scene.updatedObjects[_arg1]))) || (_arg2.updated))){
_local6.setViewPosition(_arg2);
_materialDirty = true;
};
};
if (_materialDirty){
notifyMaterialUpdate();
};
}
override function renderTriangle(_arg1:DrawTriangle):void{
var _local2:FaceNormalShaderVO = shader.getTriangleShade(_arg1, shininess);
fr = int((((((ambient & 0xFF0000) * _local2.kar) + ((diffuse & 0xFF0000) * _local2.kdr)) + ((specular & 0xFF0000) * _local2.ksr)) >> 16));
fg = int((((((ambient & 0xFF00) * _local2.kag) + ((diffuse & 0xFF00) * _local2.kdg)) + ((specular & 0xFF00) * _local2.ksg)) >> 8));
fb = int(((((ambient & 0xFF) * _local2.kab) + ((diffuse & 0xFF) * _local2.kdb)) + ((specular & 0xFF) * _local2.ksb)));
if (fr > 0xFF){
fr = 0xFF;
};
if (fg > 0xFF){
fg = 0xFF;
};
if (fb > 0xFF){
fb = 0xFF;
};
if (debug){
_arg1.source.session.renderTriangleLineFill(_thickness, (((fr << 16) | (fg << 8)) | fb), _alpha, _wireColor, _wireAlpha, _arg1.screenVertices, _arg1.screenCommands, _arg1.screenIndices, _arg1.startIndex, _arg1.endIndex);
} else {
_arg1.source.session.renderTriangleColor((((fr << 16) | (fg << 8)) | fb), alpha, _arg1.screenVertices, _arg1.screenCommands, _arg1.screenIndices, _arg1.startIndex, _arg1.endIndex);
};
if (cache){
if (_arg1.faceVO != null){
sfr = int(((((ambient & 0xFF0000) * _local2.kar) + ((diffuse & 0xFF0000) * _local2.kdr)) >> 16));
sfg = int(((((ambient & 0xFF00) * _local2.kag) + ((diffuse & 0xFF00) * _local2.kdg)) >> 8));
sfb = int((((ambient & 0xFF) * _local2.kab) + ((diffuse & 0xFF) * _local2.kdb)));
if (sfr > 0xFF){
sfr = 0xFF;
};
if (sfg > 0xFF){
sfg = 0xFF;
};
if (sfb > 0xFF){
sfb = 0xFF;
};
_arg1.faceVO.material = new ColorMaterial((((sfr << 16) | (sfg << 8)) | sfb), {alpha:_alpha});
};
};
}
override public function get color():uint{
return (_color);
}
override public function set color(_arg1:uint):void{
if (_color == _arg1){
return;
};
_color = _arg1;
ambient = (diffuse = (specular = _color));
_materialDirty = true;
}
}
}//package away3d.materials
Section 138
//TransformBitmapMaterial (away3d.materials.TransformBitmapMaterial)
package away3d.materials {
import flash.display.*;
import away3d.core.math.*;
import away3d.core.base.*;
import away3d.core.utils.*;
import away3d.core.draw.*;
import away3d.containers.*;
import flash.geom.*;
public class TransformBitmapMaterial extends BitmapMaterial {
var _transform:Matrix;
private var _scaleX:Number;// = 1
private var _scaleY:Number;// = 1
private var _offsetX:Number;// = 0
private var _offsetY:Number;// = 0
private var _rotation:Number;// = 0
private var _projectionVector:Number3D;
private var _projectionDirty:Boolean;
private var _N:Number3D;
private var _M:Number3D;
private var DOWN:Number3D;
private var RIGHT:Number3D;
private var _transformDirty:Boolean;
private var _throughProjection:Boolean;
private var _globalProjection:Boolean;
private var faceVO:FaceVO;
private var x:Number;
private var y:Number;
private var px:Number;
private var py:Number;
private var normalR:Number3D;
private var _u0:Number;
private var _u1:Number;
private var _u2:Number;
private var _v0:Number;
private var _v1:Number;
private var _v2:Number;
private var v0x:Number;
private var v0y:Number;
private var v0z:Number;
private var v1x:Number;
private var v1y:Number;
private var v1z:Number;
private var v2x:Number;
private var v2y:Number;
private var v2z:Number;
private var v0:Number3D;
private var v1:Number3D;
private var v2:Number3D;
private var t:Matrix;
private var _invtexturemapping:Matrix;
private var fPoint1:Point;
private var fPoint2:Point;
private var fPoint3:Point;
private var mapa:Number;
private var mapb:Number;
private var mapc:Number;
private var mapd:Number;
private var maptx:Number;
private var mapty:Number;
private var mPoint1:Point;
private var mPoint2:Point;
private var mPoint3:Point;
private var mPoint4:Point;
private var dot:Number;
private var line:Point;
private var zero:Number;
private var sign:Number;
private var point1:Point;
private var point2:Point;
private var point3:Point;
private var flag:Boolean;
public function TransformBitmapMaterial(_arg1:BitmapData, _arg2:Object=null){
_transform = new Matrix();
_N = new Number3D();
_M = new Number3D();
DOWN = new Number3D(0, -1, 0);
RIGHT = new Number3D(1, 0, 0);
normalR = new Number3D();
v0 = new Number3D();
v1 = new Number3D();
v2 = new Number3D();
fPoint1 = new Point();
fPoint2 = new Point();
fPoint3 = new Point();
mPoint1 = new Point();
mPoint2 = new Point();
mPoint3 = new Point();
mPoint4 = new Point();
line = new Point();
super(_arg1, _arg2);
transform = (ini.getObject("transform", Matrix) as Matrix);
scaleX = ini.getNumber("scaleX", _scaleX);
scaleY = ini.getNumber("scaleY", _scaleY);
offsetX = ini.getNumber("offsetX", _offsetX);
offsetY = ini.getNumber("offsetY", _offsetY);
rotation = ini.getNumber("rotation", _rotation);
projectionVector = (ini.getObject("projectionVector", Number3D) as Number3D);
throughProjection = ini.getBoolean("throughProjection", true);
globalProjection = ini.getBoolean("globalProjection", false);
}
override function updateMaterial(_arg1:Object3D, _arg2:View3D):void{
_graphics = null;
if (_colorTransformDirty){
updateColorTransform();
};
if (_bitmapDirty){
updateRenderBitmap();
};
if (((_projectionDirty) || (_transformDirty))){
invalidateFaces();
};
if (_transformDirty){
updateTransform();
};
if (((_materialDirty) || (_blendModeDirty))){
updateFaces();
};
_projectionDirty = false;
_blendModeDirty = false;
}
override function renderTriangle(_arg1:DrawTriangle):void{
if (((_projectionVector) && (!(throughProjection)))){
if (globalProjection){
normalR.rotate(_arg1.faceVO.face.normal, _arg1.source.sceneTransform);
if (normalR.dot(_projectionVector) < 0){
return;
};
} else {
if (_arg1.faceVO.face.normal.dot(_projectionVector) < 0){
return;
};
};
};
super.renderTriangle(_arg1);
}
override function renderBitmapLayer(_arg1:DrawTriangle, _arg2:Rectangle, _arg3:FaceMaterialVO):FaceMaterialVO{
if (_transform){
_mapping = _transform.clone();
} else {
_mapping = new Matrix();
};
if (!_projectionVector){
renderSource(_arg1.source, _arg2, _mapping);
};
_faceMaterialVO = getFaceMaterialVO(_arg1.faceVO.face.faceVO);
if (_arg3.resized){
_arg3.resized = false;
_faceMaterialVO.resized = true;
};
_faceMaterialVO.invtexturemapping = _arg3.invtexturemapping;
if (((((_arg3.updated) || (_faceMaterialVO.invalidated))) || (_faceMaterialVO.updated))){
_arg3.updated = false;
_bitmapRect = _arg1.faceVO.face.bitmapRect;
if (_faceMaterialVO.invalidated){
_faceMaterialVO.invalidated = false;
} else {
_faceMaterialVO.updated = true;
};
_faceMaterialVO.bitmap = _arg3.bitmap.clone();
if (_projectionVector){
_invtexturemapping = _faceMaterialVO.invtexturemapping;
_mapping.concat(projectUV(_arg1));
_mapping.concat(_invtexturemapping);
normalR.clone(_arg1.faceVO.face.normal);
if (_globalProjection){
normalR.rotate(normalR, _arg1.source.sceneTransform);
};
if (((((throughProjection) || ((normalR.dot(_projectionVector) >= 0)))) && (((repeat) || (!(findSeparatingAxis(getFacePoints(_invtexturemapping), getMappingPoints(_mapping)))))))){
if (_faceMaterialVO.cleared){
_faceMaterialVO.bitmap = _arg3.bitmap.clone();
};
_faceMaterialVO.cleared = false;
_faceMaterialVO.updated = true;
_graphics = _s.graphics;
_graphics.clear();
_graphics.beginBitmapFill(_bitmap, _mapping, repeat, smooth);
_graphics.drawRect(0, 0, _bitmapRect.width, _bitmapRect.height);
_graphics.endFill();
_faceMaterialVO.bitmap.draw(_s, null, _colorTransform, _blendMode, _faceMaterialVO.bitmap.rect);
};
} else {
if (((repeat) || (!(findSeparatingAxis(getContainerPoints(_arg2), getMappingPoints(_mapping)))))){
_faceMaterialVO.cleared = false;
_faceMaterialVO.updated = true;
_faceMaterialVO.bitmap.copyPixels(_sourceVO.bitmap, _bitmapRect, _zeroPoint, null, null, true);
};
};
};
return (_faceMaterialVO);
}
private function updateTransform():void{
_transformDirty = false;
if ((((((((((_scaleX == 1)) && ((_scaleY == 1)))) && ((_offsetX == 0)))) && ((_offsetY == 0)))) && ((_rotation == 0)))){
_transform = null;
} else {
_transform = new Matrix();
_transform.scale(_scaleX, _scaleY);
_transform.rotate(_rotation);
_transform.translate(_offsetX, _offsetY);
};
_materialDirty = true;
}
private function projectUV(_arg1:DrawTriangle):Matrix{
faceVO = _arg1.faceVO;
if (globalProjection){
v0.transform(faceVO.v0.position, _arg1.source.sceneTransform);
v1.transform(faceVO.v1.position, _arg1.source.sceneTransform);
v2.transform(faceVO.v2.position, _arg1.source.sceneTransform);
} else {
v0 = faceVO.v0.position;
v1 = faceVO.v1.position;
v2 = faceVO.v2.position;
};
v0x = v0.x;
v0y = v0.y;
v0z = v0.z;
v1x = v1.x;
v1y = v1.y;
v1z = v1.z;
v2x = v2.x;
v2y = v2.y;
v2z = v2.z;
_u0 = (((v0x * _N.x) + (v0y * _N.y)) + (v0z * _N.z));
_u1 = (((v1x * _N.x) + (v1y * _N.y)) + (v1z * _N.z));
_u2 = (((v2x * _N.x) + (v2y * _N.y)) + (v2z * _N.z));
_v0 = (((v0x * _M.x) + (v0y * _M.y)) + (v0z * _M.z));
_v1 = (((v1x * _M.x) + (v1y * _M.y)) + (v1z * _M.z));
_v2 = (((v2x * _M.x) + (v2y * _M.y)) + (v2z * _M.z));
if ((((((_u0 == _u1)) && ((_v0 == _v1)))) || ((((_u0 == _u2)) && ((_v0 == _v2)))))){
if (_u0 > 0.05){
_u0 = (_u0 - 0.05);
} else {
_u0 = (_u0 + 0.05);
};
if (_v0 > 0.07){
_v0 = (_v0 - 0.07);
} else {
_v0 = (_v0 + 0.07);
};
};
if ((((_u2 == _u1)) && ((_v2 == _v1)))){
if (_u2 > 0.04){
_u2 = (_u2 - 0.04);
} else {
_u2 = (_u2 + 0.04);
};
if (_v2 > 0.06){
_v2 = (_v2 - 0.06);
} else {
_v2 = (_v2 + 0.06);
};
};
t = new Matrix((_u1 - _u0), (_v1 - _v0), (_u2 - _u0), (_v2 - _v0), _u0, _v0);
t.invert();
return (t);
}
private function getContainerPoints(_arg1:Rectangle):Array{
return ([_arg1.topLeft, new Point(_arg1.top, _arg1.right), _arg1.bottomRight, new Point(_arg1.bottom, _arg1.left)]);
}
private function getFacePoints(_arg1:Matrix):Array{
fPoint1.x = (_u0 = _arg1.tx);
fPoint2.x = (_arg1.a + _u0);
fPoint3.x = (_arg1.c + _u0);
fPoint1.y = (_v0 = _arg1.ty);
fPoint2.y = (_arg1.b + _v0);
fPoint3.y = (_arg1.d + _v0);
return ([fPoint1, fPoint2, fPoint3]);
}
private function getMappingPoints(_arg1:Matrix):Array{
mapa = (_arg1.a * width);
mapb = (_arg1.b * width);
mapc = (_arg1.c * height);
mapd = (_arg1.d * height);
maptx = _arg1.tx;
mapty = _arg1.ty;
mPoint1.x = maptx;
mPoint1.y = mapty;
mPoint2.x = (maptx + mapc);
mPoint2.y = (mapty + mapd);
mPoint3.x = ((maptx + mapa) + mapc);
mPoint3.y = ((mapty + mapb) + mapd);
mPoint4.x = (maptx + mapa);
mPoint4.y = (mapty + mapb);
return ([mPoint1, mPoint2, mPoint3, mPoint4]);
}
private function findSeparatingAxis(_arg1:Array, _arg2:Array):Boolean{
if (checkEdge(_arg1, _arg2)){
return (true);
};
if (checkEdge(_arg2, _arg1)){
return (true);
};
return (false);
}
private function checkEdge(_arg1:Array, _arg2:Array):Boolean{
var _local4:String;
var _local5:Point;
var _local3:int = _arg1.length;
for (_local4 in _arg1) {
point2 = _arg1[_local4];
if (int(_local4) == 0){
point1 = _arg1[(_local3 - 1)];
point3 = _arg1[(_local3 - 2)];
} else {
point1 = _arg1[(int(_local4) - 1)];
if (int(_local4) == 1){
point3 = _arg1[(_local3 - 1)];
} else {
point3 = _arg1[(int(_local4) - 2)];
};
};
line.x = (point2.y - point1.y);
line.y = (point1.x - point2.x);
zero = ((point1.x * line.x) + (point1.y * line.y));
sign = ((zero - (point3.x * line.x)) - (point3.y * line.y));
flag = true;
for each (_local5 in _arg2) {
dot = ((_local5.x * line.x) + (_local5.y * line.y));
if ((zero * sign) > (dot * sign)){
flag = false;
break;
};
};
if (flag){
return (true);
};
};
return (false);
}
override protected function getMapping(_arg1:DrawTriangle):Matrix{
if (_arg1.generated){
if (projectionVector){
_texturemapping = projectUV(_arg1);
} else {
_texturemapping = _arg1.transformUV(this).clone();
_texturemapping.invert();
};
if (_transform){
_mapping = _transform.clone();
_mapping.concat(_texturemapping);
} else {
_mapping = _texturemapping;
};
return (_mapping);
};
_faceMaterialVO = getFaceMaterialVO(_arg1.faceVO, _arg1.source);
if (!_faceMaterialVO.invalidated){
return (_faceMaterialVO.texturemapping);
};
_faceMaterialVO.invalidated = false;
if (projectionVector){
_texturemapping = projectUV(_arg1);
} else {
_texturemapping = _arg1.transformUV(this).clone();
_texturemapping.invert();
};
if (_transform){
_faceMaterialVO.texturemapping = _transform.clone();
_faceMaterialVO.texturemapping.concat(_texturemapping);
return (_faceMaterialVO.texturemapping);
};
return ((_faceMaterialVO.texturemapping = _texturemapping));
}
public function get throughProjection():Boolean{
return (_throughProjection);
}
public function set throughProjection(_arg1:Boolean):void{
_throughProjection = _arg1;
_projectionDirty = true;
}
public function get globalProjection():Boolean{
return (_globalProjection);
}
public function set globalProjection(_arg1:Boolean):void{
_globalProjection = _arg1;
_projectionDirty = true;
}
public function get transform():Matrix{
return (_transform);
}
public function set transform(_arg1:Matrix):void{
_transform = _arg1;
if (_transform){
_rotation = Math.atan2(_transform.b, _transform.a);
_scaleX = (_transform.a / Math.cos(_rotation));
_scaleY = (_transform.d / Math.cos(_rotation));
_offsetX = _transform.tx;
_offsetY = _transform.ty;
} else {
_scaleX = (_scaleY = 1);
_offsetX = (_offsetY = (_rotation = 0));
};
}
public function get scaleX():Number{
return (_scaleX);
}
public function set scaleX(_arg1:Number):void{
if (isNaN(_arg1)){
throw (new Error("isNaN(scaleX)"));
};
if (_arg1 == Infinity){
Debug.warning("scaleX == Infinity");
};
if (_arg1 == -(Infinity)){
Debug.warning("scaleX == -Infinity");
};
if (_arg1 == 0){
Debug.warning("scaleX == 0");
};
_scaleX = _arg1;
_transformDirty = true;
}
public function get scaleY():Number{
return (_scaleY);
}
public function set scaleY(_arg1:Number):void{
if (isNaN(_arg1)){
throw (new Error("isNaN(scaleY)"));
};
if (_arg1 == Infinity){
Debug.warning("scaleY == Infinity");
};
if (_arg1 == -(Infinity)){
Debug.warning("scaleY == -Infinity");
};
if (_arg1 == 0){
Debug.warning("scaleY == 0");
};
_scaleY = _arg1;
_transformDirty = true;
}
public function get offsetX():Number{
return (_offsetX);
}
public function set offsetX(_arg1:Number):void{
if (isNaN(_arg1)){
throw (new Error("isNaN(offsetX)"));
};
if (_arg1 == Infinity){
Debug.warning("offsetX == Infinity");
};
if (_arg1 == -(Infinity)){
Debug.warning("offsetX == -Infinity");
};
_offsetX = _arg1;
_transformDirty = true;
}
public function get offsetY():Number{
return (_offsetY);
}
public function set offsetY(_arg1:Number):void{
if (isNaN(_arg1)){
throw (new Error("isNaN(offsetY)"));
};
if (_arg1 == Infinity){
Debug.warning("offsetY == Infinity");
};
if (_arg1 == -(Infinity)){
Debug.warning("offsetY == -Infinity");
};
_offsetY = _arg1;
_transformDirty = true;
}
public function get rotation():Number{
return (_rotation);
}
public function set rotation(_arg1:Number):void{
if (isNaN(_arg1)){
throw (new Error("isNaN(rotation)"));
};
if (_arg1 == Infinity){
Debug.warning("rotation == Infinity");
};
if (_arg1 == -(Infinity)){
Debug.warning("rotation == -Infinity");
};
_rotation = _arg1;
_transformDirty = true;
}
public function get projectionVector():Number3D{
return (_projectionVector);
}
public function set projectionVector(_arg1:Number3D):void{
_projectionVector = _arg1;
if (_projectionVector){
_N.cross(_projectionVector, DOWN);
if (!_N.modulo){
_N = RIGHT;
};
_M.cross(_N, _projectionVector);
_N.cross(_M, _projectionVector);
_N.normalize();
_M.normalize();
};
_projectionDirty = true;
}
override public function getPixel32(_arg1:Number, _arg2:Number):uint{
if (_transform){
x = (_arg1 * _bitmap.width);
y = ((1 - _arg2) * _bitmap.height);
t = _transform.clone();
t.invert();
if (repeat){
px = ((((x * t.a) + (y * t.c)) + t.tx) % _bitmap.width);
py = ((((x * t.b) + (y * t.d)) + t.ty) % _bitmap.height);
if (px < 0){
px = (px + _bitmap.width);
};
if (py < 0){
py = (py + _bitmap.height);
};
return (_bitmap.getPixel32(px, py));
} else {
return (_bitmap.getPixel32((((x * t.a) + (y * t.c)) + t.tx), (((x * t.b) + (y * t.d)) + t.ty)));
};
};
return (super.getPixel32(_arg1, _arg2));
}
}
}//package away3d.materials
Section 139
//WhiteShadingBitmapMaterial (away3d.materials.WhiteShadingBitmapMaterial)
package away3d.materials {
import flash.display.*;
import away3d.core.light.*;
import away3d.core.base.*;
import away3d.core.utils.*;
import away3d.core.draw.*;
import away3d.containers.*;
import flash.utils.*;
import flash.geom.*;
import flash.filters.*;
public class WhiteShadingBitmapMaterial extends BitmapMaterial {
private var blackrender:Boolean;
private var whiterender:Boolean;
private var whitek:Number;// = 0.2
private var bitmapPoint:Point;
private var colorMatrix:ColorMatrixFilter;
private var cache:Dictionary;
private var step:int;// = 1
private var br:Number;
private var shader:FaceNormalShader;
public var shininess:Number;
public function WhiteShadingBitmapMaterial(_arg1:BitmapData, _arg2:Object=null){
bitmapPoint = new Point(0, 0);
colorMatrix = new ColorMatrixFilter();
shader = new FaceNormalShader();
super(_arg1, _arg2);
if (!CacheStore.whiteShadingCache[_bitmap]){
CacheStore.whiteShadingCache[_bitmap] = new Dictionary(true);
};
cache = CacheStore.whiteShadingCache[_bitmap];
shininess = ini.getNumber("shininess", 20);
}
override function updateMaterial(_arg1:Object3D, _arg2:View3D):void{
var _local4:DirectionalLight;
var _local5:Array;
var _local6:PointLight;
var _local3:Array = _arg1.lightarray.directionals;
for each (_local4 in _local3) {
if (((!(_local4.diffuseTransform[_arg1])) || (_arg2.scene.updatedObjects[_arg1]))){
_local4.setDiffuseTransform(_arg1);
_materialDirty = true;
};
if (!_local4.specularTransform[_arg1]){
_local4.specularTransform[_arg1] = new Dictionary(true);
};
if (((((!(_local4.specularTransform[_arg1][_arg2])) || (_arg2.scene.updatedObjects[_arg1]))) || (_arg2.updated))){
_local4.setSpecularTransform(_arg1, _arg2);
_materialDirty = true;
};
};
_local5 = _arg1.lightarray.points;
for each (_local6 in _local5) {
if (((((!(_local6.viewPositions[_arg2])) || (_arg2.scene.updatedObjects[_arg1]))) || (_arg2.updated))){
_local6.setViewPosition(_arg2);
_materialDirty = true;
};
};
super.updateMaterial(_arg1, _arg2);
}
override function renderTriangle(_arg1:DrawTriangle):void{
var _local3:Number;
var _local4:BitmapData;
var _local2:FaceNormalShaderVO = shader.getTriangleShade(_arg1, shininess);
br = (((((((((_local2.kar + _local2.kag) + _local2.kab) + _local2.kdr) + _local2.kdg) + _local2.kdb) + _local2.ksr) + _local2.ksg) + _local2.ksb) / 3);
_view = _arg1.view;
_session = _arg1.source.session;
if ((((br < 1)) && (((blackrender) || ((((step < 16)) && (!(_bitmap.transparent)))))))){
_session.renderTriangleBitmap(bitmap, getMapping(_arg1), _arg1.screenVertices, _arg1.screenIndices, _arg1.startIndex, _arg1.endIndex, smooth, repeat);
_session.renderTriangleColor(0, (1 - br), _arg1.screenVertices, _arg1.screenCommands, _arg1.screenIndices, _arg1.startIndex, _arg1.endIndex);
} else {
if ((((br > 1)) && (whiterender))){
_session.renderTriangleBitmap(bitmap, getMapping(_arg1), _arg1.screenVertices, _arg1.screenIndices, _arg1.startIndex, _arg1.endIndex, smooth, repeat);
_session.renderTriangleColor(0xFFFFFF, ((br - 1) * whitek), _arg1.screenVertices, _arg1.screenCommands, _arg1.screenIndices, _arg1.startIndex, _arg1.endIndex);
} else {
if (step < 64){
if (Math.random() < 0.01){
doubleStepTo(64);
};
};
_local3 = ladder(br);
_local4 = cache[_local3];
if (_local4 == null){
_local4 = new BitmapData(_bitmap.width, _bitmap.height, true, 0);
colorMatrix.matrix = [_local3, 0, 0, 0, 0, 0, _local3, 0, 0, 0, 0, 0, _local3, 0, 0, 0, 0, 0, 1, 0];
_local4.applyFilter(_bitmap, _local4.rect, bitmapPoint, colorMatrix);
cache[_local3] = _local4;
};
_session.renderTriangleBitmap(_local4, getMapping(_arg1), _arg1.screenVertices, _arg1.screenIndices, _arg1.startIndex, _arg1.endIndex, smooth, repeat);
};
};
}
private function doubleStepTo(_arg1:int):void{
if (step < _arg1){
step = (step * 2);
};
}
private function ladder(_arg1:Number):Number{
if (_arg1 < (1 / 0xFF)){
return (0);
};
if (_arg1 > 0xFF){
_arg1 = 0xFF;
};
return (Math.exp((Math.round((Math.log(_arg1) * step)) / step)));
}
override protected function invalidateFaces(_arg1:Object3D=null, _arg2:View3D=null):void{
super.invalidateFaces(_arg1, _arg2);
CacheStore.whiteShadingCache[_bitmap] = new Dictionary(true);
}
}
}//package away3d.materials
Section 140
//WireColorMaterial (away3d.materials.WireColorMaterial)
package away3d.materials {
import away3d.core.utils.*;
import away3d.core.draw.*;
public class WireColorMaterial extends WireframeMaterial {
protected var _alpha:Number;
protected var _color:uint;
public function WireColorMaterial(_arg1=null, _arg2:Object=null){
if (_arg1 == null){
_arg1 = "random";
};
this.color = Cast.trycolor(_arg1);
ini = Init.parse(_arg2);
super(ini.getColor("wireColor", wireColor), ini);
alpha = ini.getNumber("alpha", 1, {min:0, max:1});
}
override function renderTriangle(_arg1:DrawTriangle):void{
_arg1.source.session.renderTriangleLineFill(_thickness, _color, _alpha, _wireColor, _wireAlpha, _arg1.screenVertices, _arg1.screenCommands, _arg1.screenIndices, _arg1.startIndex, _arg1.endIndex);
}
public function get color():uint{
return (_color);
}
public function set color(_arg1:uint):void{
if (_color == _arg1){
return;
};
_color = _arg1;
_materialDirty = true;
}
public function get alpha():Number{
return (_alpha);
}
public function set alpha(_arg1:Number):void{
if (_alpha == _arg1){
return;
};
_alpha = _arg1;
_materialDirty = true;
}
override public function get visible():Boolean{
return ((((alpha > 0)) || ((wireAlpha > 0))));
}
override public function clone(_arg1:Material=null):Material{
var _local2:WireColorMaterial = (((_arg1 as WireColorMaterial)) || (new WireColorMaterial()));
super.clone(_local2);
_local2.color = _color;
_local2.alpha = _alpha;
return (_local2);
}
}
}//package away3d.materials
Section 141
//WireframeMaterial (away3d.materials.WireframeMaterial)
package away3d.materials {
import away3d.core.base.*;
import away3d.core.utils.*;
import away3d.core.draw.*;
import away3d.containers.*;
import away3d.events.*;
public class WireframeMaterial extends Material {
var _materialDirty:Boolean;
private var _materialupdated:MaterialEvent;
protected var ini:Init;
protected var _wireAlpha:Number;
protected var _wireColor:uint;// = 0
protected var _thickness:Number;
public function WireframeMaterial(_arg1=null, _arg2:Object=null){
if (_arg1 == null){
_arg1 = "random";
};
this.wireColor = Cast.trycolor(_arg1);
ini = Init.parse(_arg2);
wireAlpha = ini.getNumber("wireAlpha", 1, {min:0, max:1});
thickness = ini.getNumber("thickness", getDefaultThickness(), {min:0});
}
function notifyMaterialUpdate():void{
_materialDirty = false;
if (!hasEventListener(MaterialEvent.MATERIAL_UPDATED)){
return;
};
if (_materialupdated == null){
_materialupdated = new MaterialEvent(MaterialEvent.MATERIAL_UPDATED, this);
};
dispatchEvent(_materialupdated);
}
override function updateMaterial(_arg1:Object3D, _arg2:View3D):void{
if (_materialDirty){
notifyMaterialUpdate();
};
}
override function renderSegment(_arg1:DrawSegment):void{
if (wireAlpha <= 0){
return;
};
_arg1.source.session.renderTriangleLine(_thickness, _wireColor, _wireAlpha, _arg1.screenVertices, _arg1.screenCommands, _arg1.screenIndices, _arg1.startIndex, _arg1.endIndex);
}
override function renderTriangle(_arg1:DrawTriangle):void{
if (wireAlpha <= 0){
return;
};
_arg1.source.session.renderTriangleLine(_thickness, _wireColor, _wireAlpha, _arg1.screenVertices, _arg1.screenCommands, _arg1.screenIndices, _arg1.startIndex, _arg1.endIndex);
}
protected function getDefaultThickness():Number{
return (1);
}
public function get wireColor():uint{
return (_wireColor);
}
public function set wireColor(_arg1:uint):void{
if (_wireColor == _arg1){
return;
};
_wireColor = _arg1;
_materialDirty = true;
}
public function get wireAlpha():Number{
return (_wireAlpha);
}
public function set wireAlpha(_arg1:Number):void{
if (_wireAlpha == _arg1){
return;
};
_wireAlpha = _arg1;
_materialDirty = true;
}
public function get thickness():Number{
return (_thickness);
}
public function set thickness(_arg1:Number):void{
if (_thickness == _arg1){
return;
};
_thickness = _arg1;
_materialDirty = true;
}
override public function get visible():Boolean{
return ((wireAlpha > 0));
}
override public function clone(_arg1:Material=null):Material{
var _local2:WireframeMaterial = (((_arg1 as WireframeMaterial)) || (new WireframeMaterial()));
_local2.wireColor = _wireColor;
_local2.wireAlpha = _wireAlpha;
_local2.thickness = _thickness;
return (_local2);
}
}
}//package away3d.materials
Section 142
//IOverlay (away3d.overlays.IOverlay)
package away3d.overlays {
public interface IOverlay {
function update():void;
}
}//package away3d.overlays
Section 143
//CubeMaterialsData (away3d.primitives.data.CubeMaterialsData)
package away3d.primitives.data {
import flash.events.*;
import away3d.core.utils.*;
import away3d.materials.*;
import away3d.events.*;
public class CubeMaterialsData extends EventDispatcher {
private var _materialchanged:MaterialEvent;
private var _left:Material;
private var _right:Material;
private var _bottom:Material;
private var _top:Material;
private var _front:Material;
private var _back:Material;
protected var ini:Init;
public function CubeMaterialsData(_arg1:Object=null){
ini = Init.parse(_arg1);
_left = (ini.getMaterial("left") as Material);
_right = (ini.getMaterial("right") as Material);
_bottom = (ini.getMaterial("bottom") as Material);
_top = (ini.getMaterial("top") as Material);
_front = (ini.getMaterial("front") as Material);
_back = (ini.getMaterial("back") as Material);
}
private function notifyMaterialChange(_arg1:Material, _arg2:String):void{
if (!hasEventListener(MaterialEvent.MATERIAL_CHANGED)){
return;
};
_materialchanged = new MaterialEvent(MaterialEvent.MATERIAL_CHANGED, _arg1);
_materialchanged.extra = _arg2;
dispatchEvent(_materialchanged);
}
public function get left():Material{
return (_left);
}
public function set left(_arg1:Material):void{
if (_left == _arg1){
return;
};
_left = _arg1;
notifyMaterialChange(_left, "left");
}
public function get right():Material{
return (_right);
}
public function set right(_arg1:Material):void{
if (_right == _arg1){
return;
};
_right = _arg1;
notifyMaterialChange(_right, "right");
}
public function get bottom():Material{
return (_bottom);
}
public function set bottom(_arg1:Material):void{
if (_bottom == _arg1){
return;
};
_bottom = _arg1;
notifyMaterialChange(_bottom, "bottom");
}
public function get top():Material{
return (_top);
}
public function set top(_arg1:Material):void{
if (_top == _arg1){
return;
};
_top = _arg1;
notifyMaterialChange(_top, "top");
}
public function get front():Material{
return (_front);
}
public function set front(_arg1:Material):void{
if (_front == _arg1){
return;
};
_front = _arg1;
notifyMaterialChange(_front, "front");
}
public function get back():Material{
return (_back);
}
public function set back(_arg1:Material):void{
if (_back == _arg1){
return;
};
_back = _arg1;
notifyMaterialChange(_back, "back");
}
public function addOnMaterialChange(_arg1:Function):void{
addEventListener(MaterialEvent.MATERIAL_CHANGED, _arg1, false, 0, false);
}
public function removeOnMaterialChange(_arg1:Function):void{
removeEventListener(MaterialEvent.MATERIAL_CHANGED, _arg1, false);
}
}
}//package away3d.primitives.data
Section 144
//AbstractPrimitive (away3d.primitives.AbstractPrimitive)
package away3d.primitives {
import away3d.core.base.*;
import away3d.materials.*;
import away3d.*;
public class AbstractPrimitive extends Mesh {
var _v:Vertex;
var _vStore:Array;
var _vActive:Array;
var _uv:UV;
var _uvStore:Array;
var _uvActive:Array;
var _face:Face;
var _faceStore:Array;
var _faceActive:Array;
var _segment:Segment;
var _segmentStore:Array;
var _segmentActive:Array;
var _primitiveDirty:Boolean;
private var _index:int;
public function AbstractPrimitive(_arg1:Object=null){
_vStore = [];
_vActive = [];
_uvStore = [];
_uvActive = [];
_faceStore = [];
_faceActive = [];
_segmentStore = [];
_segmentActive = [];
super(_arg1);
_primitiveDirty = true;
}
function createVertex(_arg1:Number=0, _arg2:Number=0, _arg3:Number=0):Vertex{
if (_vStore.length){
_vActive.push((_v = _vStore.pop()));
_v.x = _arg1;
_v.y = _arg2;
_v.z = _arg3;
} else {
_vActive.push((_v = new Vertex(_arg1, _arg2, _arg3)));
};
return (_v);
}
function createUV(_arg1:Number=0, _arg2:Number=0):UV{
if (_uvStore.length){
_uvActive.push((_uv = _uvStore.pop()));
_uv.u = _arg1;
_uv.v = _arg2;
} else {
_uvActive.push((_uv = new UV(_arg1, _arg2)));
};
return (_uv);
}
function createFace(_arg1:Vertex, _arg2:Vertex, _arg3:Vertex, _arg4:Material=null, _arg5:UV=null, _arg6:UV=null, _arg7:UV=null):Face{
if (_faceStore.length){
_faceActive.push((_face = _faceStore.pop()));
_face.v0 = _arg1;
_face.v1 = _arg2;
_face.v2 = _arg3;
_face.material = _arg4;
_face.uv0 = _arg5;
_face.uv1 = _arg6;
_face.uv2 = _arg7;
} else {
_faceActive.push((_face = new Face(_arg1, _arg2, _arg3, _arg4, _arg5, _arg6, _arg7)));
};
return (_face);
}
function createSegment(_arg1:Vertex, _arg2:Vertex, _arg3:Material=null):Segment{
if (_segmentStore.length){
_segmentActive.push((_segment = _segmentStore.pop()));
_segment.v0 = _arg1;
_segment.v1 = _arg2;
_segment.material = _arg3;
} else {
_segmentActive.push((_segment = new Segment(_arg1, _arg2, _arg3)));
};
return (_segment);
}
protected function updatePrimitive():void{
buildPrimitive();
var _local1:int = geometry.quarterFacesTotal;
while (_local1--) {
quarterFaces();
};
}
protected function buildPrimitive():void{
_primitiveDirty = false;
_objectDirty = true;
_index = faces.length;
while (_index--) {
removeFace(faces[_index]);
};
_index = segments.length;
while (_index--) {
removeSegment(segments[_index]);
};
_vStore = _vStore.concat(_vActive);
_vActive = [];
_uvStore = _uvStore.concat(_uvActive);
_uvActive = [];
_faceStore = _faceStore.concat(_faceActive);
_faceActive = [];
_segmentStore = _segmentStore.concat(_segmentActive);
_segmentActive = [];
}
override public function get vertices():Array{
if (_primitiveDirty){
updatePrimitive();
};
return (_geometry.vertices);
}
override public function get faces():Array{
if (_primitiveDirty){
updatePrimitive();
};
return (_geometry.faces);
}
override public function get segments():Array{
if (_primitiveDirty){
updatePrimitive();
};
return (_geometry.segments);
}
override public function get sprites():Array{
if (_primitiveDirty){
updatePrimitive();
};
return (_geometry.sprites);
}
override public function get elements():Array{
if (_primitiveDirty){
updatePrimitive();
};
return (_geometry.elements);
}
override public function get geometry():Geometry{
if (_primitiveDirty){
updatePrimitive();
};
return (_geometry);
}
override public function get boundingRadius():Number{
if (_primitiveDirty){
updatePrimitive();
};
return (super.boundingRadius);
}
override public function get maxX():Number{
if (_primitiveDirty){
updatePrimitive();
};
return (super.maxX);
}
override public function get minX():Number{
if (_primitiveDirty){
updatePrimitive();
};
return (super.minX);
}
override public function get maxY():Number{
if (_primitiveDirty){
updatePrimitive();
};
return (super.maxY);
}
override public function get minY():Number{
if (_primitiveDirty){
updatePrimitive();
};
return (super.minY);
}
override public function get maxZ():Number{
if (_primitiveDirty){
updatePrimitive();
};
return (super.maxZ);
}
override public function get minZ():Number{
if (_primitiveDirty){
updatePrimitive();
};
return (super.minZ);
}
override public function get objectWidth():Number{
if (_primitiveDirty){
updatePrimitive();
};
return (super.objectWidth);
}
override public function get objectHeight():Number{
if (_primitiveDirty){
updatePrimitive();
};
return (super.objectHeight);
}
override public function get objectDepth():Number{
if (_primitiveDirty){
updatePrimitive();
};
return (super.objectDepth);
}
override public function updateObject():void{
if (_primitiveDirty){
updatePrimitive();
};
super.updateObject();
}
}
}//package away3d.primitives
Section 145
//Cube (away3d.primitives.Cube)
package away3d.primitives {
import away3d.core.base.*;
import away3d.core.utils.*;
import away3d.primitives.data.*;
import away3d.materials.*;
import away3d.events.*;
public class Cube extends AbstractPrimitive {
private var _width:Number;
private var _height:Number;
private var _depth:Number;
private var _segmentsW:int;
private var _segmentsH:int;
private var _segmentsD:int;
private var _flip:Boolean;
private var _cubeMaterials:CubeMaterialsData;
private var _leftFaces:Array;
private var _rightFaces:Array;
private var _bottomFaces:Array;
private var _topFaces:Array;
private var _frontFaces:Array;
private var _backFaces:Array;
private var _cubeFaceArray:Array;
private var _mappingType:String;
private var _dbv:Array;
private var _dbu:Array;
private var _pixelBorder:int;// = 0
private var _varr:Array;
private var _uvarr:Array;
public function Cube(_arg1:Object=null){
_varr = [];
_uvarr = [];
super(_arg1);
_width = ini.getNumber("width", 100, {min:0});
_height = ini.getNumber("height", 100, {min:0});
_depth = ini.getNumber("depth", 100, {min:0});
_flip = ini.getBoolean("flip", false);
_cubeMaterials = ini.getCubeMaterials("faces");
_segmentsW = ini.getInt("segmentsW", 1, {min:1});
_segmentsH = ini.getInt("segmentsH", 1, {min:1});
_segmentsD = ini.getInt("segmentsD", 1, {min:1});
_mappingType = ini.getString("mappingType", CubeMappingType.NORMAL);
if (!_cubeMaterials){
_cubeMaterials = ini.getCubeMaterials("cubeMaterials");
};
if (!_cubeMaterials){
_cubeMaterials = new CubeMaterialsData();
};
_cubeMaterials.addOnMaterialChange(onCubeMaterialChange);
type = "Cube";
url = "primitive";
}
private function onCubeMaterialChange(_arg1:MaterialEvent):void{
var _local2:Face;
switch (_arg1.extra){
case "left":
_cubeFaceArray = _leftFaces;
break;
case "right":
_cubeFaceArray = _rightFaces;
break;
case "bottom":
_cubeFaceArray = _bottomFaces;
break;
case "top":
_cubeFaceArray = _topFaces;
break;
case "front":
_cubeFaceArray = _frontFaces;
break;
case "back":
_cubeFaceArray = _backFaces;
};
for each (_local2 in _cubeFaceArray) {
_local2.material = (_arg1.material as Material);
};
}
private function makeVertex(_arg1:Number, _arg2:Number, _arg3:Number):Vertex{
var _local4:int;
while (_local4 < _dbv.length) {
if ((((((_dbv[_local4].x == _arg1)) && ((_dbv[_local4].y == _arg2)))) && ((_dbv[_local4].z == _arg3)))){
return (_dbv[_local4]);
};
_local4++;
};
var _local5:Vertex = createVertex(_arg1, _arg2, _arg3);
_dbv[_dbv.length] = _local5;
return (_local5);
}
private function makeUV(_arg1:Number, _arg2:Number):UV{
var _local3:int;
while (_local3 < _dbu.length) {
if ((((_dbu[_local3].u == _arg1)) && ((_dbu[_local3].v == _arg2)))){
return (_dbu[_local3]);
};
_local3++;
};
var _local4:UV = createUV(_arg1, _arg2);
_dbu[_dbu.length] = _local4;
return (_local4);
}
private function buildFaces(_arg1:int, _arg2:int, _arg3:int, _arg4:int, _arg5:Material, _arg6:Boolean):void{
var _local7:UV = _uvarr[_arg1];
var _local8:UV = _uvarr[_arg2];
var _local9:UV = _uvarr[_arg3];
var _local10:UV = _uvarr[_arg4];
var _local11:Vertex = _varr[_arg1];
var _local12:Vertex = _varr[_arg2];
var _local13:Vertex = _varr[_arg3];
var _local14:Vertex = _varr[_arg4];
if (((_flip) || (_arg6))){
addFace(createFace(_local11, _local12, _local13, _arg5, _local7, _local8, _local9));
addFace(createFace(_local11, _local13, _local14, _arg5, _local7, _local9, _local10));
} else {
addFace(createFace(_local12, _local11, _local13, _arg5, _local8, _local7, _local9));
addFace(createFace(_local13, _local11, _local14, _arg5, _local9, _local7, _local10));
};
}
override protected function buildPrimitive():void{
var _local1:int;
var _local2:int;
var _local5:int;
var _local6:int;
var _local7:int;
var _local8:int;
var _local10:BitmapMaterial;
super.buildPrimitive();
var _local3:Number = (_pixelBorder / 600);
var _local4:Number = (_pixelBorder / 400);
var _local9:int;
_dbv = [];
_dbu = [];
_varr = [];
_uvarr = [];
if ((material is BitmapMaterial)){
_local10 = (material as BitmapMaterial);
_local3 = (_pixelBorder / _local10.width);
_local4 = (_pixelBorder / _local10.height);
};
_local1 = 0;
while (_local1 <= _segmentsW) {
_local2 = 0;
while (_local2 <= _segmentsH) {
_varr.push(makeVertex(((_width / 2) - ((_local1 * _width) / _segmentsW)), ((_height / 2) - ((_local2 * _height) / _segmentsH)), (-(_depth) / 2)));
_varr.push(makeVertex(((_width / 2) - ((_local1 * _width) / _segmentsW)), ((_height / 2) - ((_local2 * _height) / _segmentsH)), (_depth / 2)));
if (_mappingType == CubeMappingType.NORMAL){
_uvarr.push(makeUV((1 - (_local1 / _segmentsW)), (1 - (_local2 / _segmentsH))));
_uvarr.push(makeUV((_local1 / _segmentsW), (1 - (_local2 / _segmentsH))));
} else {
_uvarr.push(makeUV((((2 / 3) - _local3) - ((_local1 * (1 - (6 * _local3))) / (3 * _segmentsW))), ((1 - _local4) - ((_local2 * (1 - (4 * _local4))) / (2 * _segmentsH)))));
_uvarr.push(makeUV((_local3 + ((_local1 * (1 - (6 * _local3))) / (3 * _segmentsW))), (((1 / 2) - _local4) - ((_local2 * (1 - (4 * _local4))) / (2 * _segmentsH)))));
};
if (((_local1) && (_local2))){
_local5 = (2 * (((_segmentsH + 1) * _local1) + _local2));
_local6 = (2 * ((((_segmentsH + 1) * _local1) + _local2) - 1));
_local7 = (2 * ((((_segmentsH + 1) * (_local1 - 1)) + _local2) - 1));
_local8 = (2 * (((_segmentsH + 1) * (_local1 - 1)) + _local2));
buildFaces(_local5, _local6, _local7, _local8, _cubeMaterials.front, false);
buildFaces((_local5 + 1), (_local6 + 1), (_local7 + 1), (_local8 + 1), _cubeMaterials.back, true);
};
_local2++;
};
_local1++;
};
_local9 = (_local9 + ((2 * (_segmentsW + 1)) * (_segmentsH + 1)));
_local1 = 0;
while (_local1 <= _segmentsW) {
_local2 = 0;
while (_local2 <= _segmentsD) {
_varr.push(makeVertex(((_width / 2) - ((_local1 * _width) / _segmentsW)), (-(_height) / 2), ((-(_depth) / 2) + ((_local2 * _depth) / _segmentsD))));
_varr.push(makeVertex(((_width / 2) - ((_local1 * _width) / _segmentsW)), (_height / 2), ((-(_depth) / 2) + ((_local2 * _depth) / _segmentsD))));
if (_mappingType == CubeMappingType.NORMAL){
_uvarr.push(makeUV((_local2 / _segmentsW), (1 - (_local1 / _segmentsD))));
_uvarr.push(makeUV((_local2 / _segmentsW), (_local1 / _segmentsD)));
} else {
_uvarr.push(makeUV(((1 - _local3) - ((_local2 * (1 - (6 * _local3))) / (3 * _segmentsW))), (_local4 + ((_local1 * (1 - (4 * _local4))) / (2 * _segmentsD)))));
_uvarr.push(makeUV((((2 / 3) - _local3) - ((_local2 * (1 - (6 * _local3))) / (3 * _segmentsW))), (((1 / 2) - _local4) - ((_local1 * (1 - (4 * _local4))) / (2 * _segmentsD)))));
};
if (((_local1) && (_local2))){
_local5 = (_local9 + (2 * (((_segmentsD + 1) * _local1) + _local2)));
_local6 = (_local9 + (2 * ((((_segmentsD + 1) * _local1) + _local2) - 1)));
_local7 = (_local9 + (2 * ((((_segmentsD + 1) * (_local1 - 1)) + _local2) - 1)));
_local8 = (_local9 + (2 * (((_segmentsD + 1) * (_local1 - 1)) + _local2)));
buildFaces(_local5, _local6, _local7, _local8, _cubeMaterials.top, false);
buildFaces((_local5 + 1), (_local6 + 1), (_local7 + 1), (_local8 + 1), _cubeMaterials.bottom, true);
};
_local2++;
};
_local1++;
};
_local9 = (_local9 + ((2 * (_segmentsW + 1)) * (_segmentsD + 1)));
_local1 = 0;
while (_local1 <= _segmentsH) {
_local2 = 0;
while (_local2 <= _segmentsD) {
_varr.push(makeVertex((_width / 2), ((_height / 2) - ((_local1 * _height) / _segmentsH)), ((-(_depth) / 2) + ((_local2 * _depth) / _segmentsD))));
_varr.push(makeVertex((-(_width) / 2), ((_height / 2) - ((_local1 * _height) / _segmentsH)), ((-(_depth) / 2) + ((_local2 * _depth) / _segmentsD))));
if (_mappingType == CubeMappingType.NORMAL){
_uvarr.push(makeUV((_local2 / _segmentsH), (1 - (_local1 / _segmentsD))));
_uvarr.push(makeUV((1 - (_local2 / _segmentsH)), (1 - (_local1 / _segmentsD))));
} else {
_uvarr.push(makeUV((((2 / 3) + _local3) + ((_local2 * (1 - (6 * _local3))) / (3 * _segmentsH))), ((1 - _local4) - ((_local1 * (1 - (4 * _local4))) / (2 * _segmentsD)))));
_uvarr.push(makeUV((((1 / 3) - _local3) - ((_local2 * (1 - (6 * _local3))) / (3 * _segmentsH))), ((1 - _local4) - ((_local1 * (1 - (4 * _local4))) / (2 * _segmentsD)))));
};
if (((_local1) && (_local2))){
_local5 = (_local9 + (2 * (((_segmentsD + 1) * _local1) + _local2)));
_local6 = (_local9 + (2 * ((((_segmentsD + 1) * _local1) + _local2) - 1)));
_local7 = (_local9 + (2 * ((((_segmentsD + 1) * (_local1 - 1)) + _local2) - 1)));
_local8 = (_local9 + (2 * (((_segmentsD + 1) * (_local1 - 1)) + _local2)));
buildFaces(_local5, _local6, _local7, _local8, _cubeMaterials.left, false);
buildFaces((_local5 + 1), (_local6 + 1), (_local7 + 1), (_local8 + 1), _cubeMaterials.right, true);
};
_local2++;
};
_local1++;
};
}
public function get width():Number{
return (_width);
}
public function set width(_arg1:Number):void{
if (_width == _arg1){
return;
};
_width = _arg1;
_primitiveDirty = true;
}
public function get height():Number{
return (_height);
}
public function set height(_arg1:Number):void{
if (_height == _arg1){
return;
};
_height = _arg1;
_primitiveDirty = true;
}
public function get depth():Number{
return (_depth);
}
public function set depth(_arg1:Number):void{
if (_depth == _arg1){
return;
};
_depth = _arg1;
_primitiveDirty = true;
}
public function get segmentsW():Number{
return (_segmentsW);
}
public function set segmentsW(_arg1:Number):void{
if (_segmentsW == _arg1){
return;
};
_segmentsW = _arg1;
_primitiveDirty = true;
}
public function get mappingType():String{
return (_mappingType);
}
public function set mappingType(_arg1:String):void{
if (_mappingType == _arg1){
return;
};
_mappingType = _arg1;
_primitiveDirty = true;
}
public function get flip():Boolean{
return (_flip);
}
public function set flip(_arg1:Boolean):void{
_flip = _arg1;
}
public function get segmentsH():Number{
return (_segmentsH);
}
public function set segmentsH(_arg1:Number):void{
if (_segmentsH == _arg1){
return;
};
_segmentsH = _arg1;
_primitiveDirty = true;
}
public function get segmentsD():Number{
return (_segmentsD);
}
public function set segmentsD(_arg1:Number):void{
if (_segmentsD == _arg1){
return;
};
_segmentsD = _arg1;
_primitiveDirty = true;
}
public function get cubeMaterials():CubeMaterialsData{
return (_cubeMaterials);
}
public function set cubeMaterials(_arg1:CubeMaterialsData):void{
if (_cubeMaterials == _arg1){
return;
};
if (_cubeMaterials){
_cubeMaterials.addOnMaterialChange(onCubeMaterialChange);
};
_cubeMaterials = _arg1;
_cubeMaterials.addOnMaterialChange(onCubeMaterialChange);
}
}
}//package away3d.primitives
Section 146
//CubeMappingType (away3d.primitives.CubeMappingType)
package away3d.primitives {
public class CubeMappingType {
public static var MAP6:String = "map6";
public static var NORMAL:String = "normal";
}
}//package away3d.primitives
Section 147
//CurveLineSegment (away3d.primitives.CurveLineSegment)
package away3d.primitives {
import away3d.core.base.*;
import away3d.materials.*;
public class CurveLineSegment extends Mesh {
private var _segment:Segment;
public var _indexes:Array;
public var _start:Vertex;
public var _control:Vertex;
public var _end:Vertex;
public function CurveLineSegment(_arg1:Vertex, _arg2:Vertex, _arg3:Vertex, _arg4:Material=null):void{
_start = new Vertex(_arg1.x, _arg1.y, _arg1.z);
_control = new Vertex(_arg2.x, _arg2.y, _arg2.z);
_end = new Vertex(_arg3.x, _arg3.y, _arg3.z);
_segment = new Segment(_start, _end, _arg4);
_segment.defineSingleCurve(_start, _control, _end);
addSegment(_segment);
type = "CurveLineSegment";
url = "primitive";
}
public function get start():Vertex{
return (_start);
}
public function set start(_arg1:Vertex):void{
_start.x = _arg1.x;
_start.y = _arg1.y;
_start.z = _arg1.z;
}
public function get control():Vertex{
return (_control);
}
public function set control(_arg1:Vertex):void{
_control.x = _arg1.x;
_control.y = _arg1.y;
_control.z = _arg1.z;
}
public function get end():Vertex{
return (_end);
}
public function set end(_arg1:Vertex):void{
_end.x = _arg1.x;
_end.y = _arg1.y;
_end.z = _arg1.z;
}
public function set wireMaterial(_arg1:Material):void{
_segment.material = _arg1;
}
public function get wireMaterial():Material{
return (_segment.material);
}
}
}//package away3d.primitives
Section 148
//Plane (away3d.primitives.Plane)
package away3d.primitives {
import away3d.core.base.*;
import away3d.core.utils.*;
import away3d.materials.*;
public class Plane extends AbstractPrimitive {
private var grid:Array;
private var _width:Number;
private var _height:Number;
private var _segmentsW:int;
private var _segmentsH:int;
private var _yUp:Boolean;
public function Plane(_arg1:Object=null){
var _local3:BitmapMaterial;
super(_arg1);
_width = ini.getNumber("width", 100, {min:0});
_height = ini.getNumber("height", 100, {min:0});
var _local2:int = ini.getInt("segments", 1, {min:1});
_segmentsW = ini.getInt("segmentsW", _local2, {min:1});
_segmentsH = ini.getInt("segmentsH", _local2, {min:1});
_yUp = ini.getBoolean("yUp", true);
if ((width * height) == 0){
if ((material is BitmapMaterial)){
_local3 = (material as BitmapMaterial);
if (width == 0){
width = _local3.width;
};
if (height == 0){
height = _local3.height;
};
} else {
width = 100;
height = 100;
};
};
type = "Plane";
url = "primitive";
}
override protected function buildPrimitive():void{
var _local1:int;
var _local2:int;
var _local3:Vertex;
var _local4:Vertex;
var _local5:Vertex;
var _local6:Vertex;
var _local7:UV;
var _local8:UV;
var _local9:UV;
var _local10:UV;
super.buildPrimitive();
grid = new Array((_segmentsW + 1));
_local1 = 0;
while (_local1 <= _segmentsW) {
grid[_local1] = new Array((_segmentsH + 1));
_local2 = 0;
while (_local2 <= _segmentsH) {
if (_yUp){
grid[_local1][_local2] = createVertex((((_local1 / _segmentsW) - 0.5) * _width), 0, (((_local2 / _segmentsH) - 0.5) * _height));
} else {
grid[_local1][_local2] = createVertex((((_local1 / _segmentsW) - 0.5) * _width), (((_local2 / _segmentsH) - 0.5) * _height), 0);
};
_local2++;
};
_local1++;
};
_local1 = 0;
while (_local1 < _segmentsW) {
_local2 = 0;
while (_local2 < _segmentsH) {
_local3 = grid[_local1][_local2];
_local4 = grid[(_local1 + 1)][_local2];
_local5 = grid[_local1][(_local2 + 1)];
_local6 = grid[(_local1 + 1)][(_local2 + 1)];
_local7 = createUV((_local1 / _segmentsW), (_local2 / _segmentsH));
_local8 = createUV(((_local1 + 1) / _segmentsW), (_local2 / _segmentsH));
_local9 = createUV((_local1 / _segmentsW), ((_local2 + 1) / _segmentsH));
_local10 = createUV(((_local1 + 1) / _segmentsW), ((_local2 + 1) / _segmentsH));
addFace(createFace(_local3, _local4, _local5, null, _local7, _local8, _local9));
addFace(createFace(_local6, _local5, _local4, null, _local10, _local9, _local8));
_local2++;
};
_local1++;
};
}
public function get width():Number{
return (_width);
}
public function set width(_arg1:Number):void{
if (_width == _arg1){
return;
};
_width = _arg1;
_primitiveDirty = true;
}
public function get height():Number{
return (_height);
}
public function set height(_arg1:Number):void{
if (_height == _arg1){
return;
};
_height = _arg1;
_primitiveDirty = true;
}
public function get segmentsW():Number{
return (_segmentsW);
}
public function set segmentsW(_arg1:Number):void{
if (_segmentsW == _arg1){
return;
};
_segmentsW = _arg1;
_primitiveDirty = true;
}
public function get segmentsH():Number{
return (_segmentsH);
}
public function set segmentsH(_arg1:Number):void{
if (_segmentsH == _arg1){
return;
};
_segmentsH = _arg1;
_primitiveDirty = true;
}
public function get yUp():Boolean{
return (_yUp);
}
public function set yUp(_arg1:Boolean):void{
if (_yUp == _arg1){
return;
};
_yUp = _arg1;
_primitiveDirty = true;
}
public function vertex(_arg1:int, _arg2:int):Vertex{
if (_primitiveDirty){
updatePrimitive();
};
return (grid[_arg2][_arg1]);
}
}
}//package away3d.primitives
Section 149
//Sphere (away3d.primitives.Sphere)
package away3d.primitives {
import away3d.core.base.*;
import away3d.core.utils.*;
public class Sphere extends AbstractPrimitive {
private var grid:Array;
private var _radius:Number;
private var _segmentsW:int;
private var _segmentsH:int;
private var _yUp:Boolean;
public function Sphere(_arg1:Object=null){
super(_arg1);
_radius = ini.getNumber("radius", 100, {min:0});
_segmentsW = ini.getInt("segmentsW", 8, {min:3});
_segmentsH = ini.getInt("segmentsH", 6, {min:2});
_yUp = ini.getBoolean("yUp", true);
type = "Sphere";
url = "primitive";
}
override protected function buildPrimitive():void{
var _local1:int;
var _local2:int;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Vertex;
var _local12:Vertex;
var _local13:Vertex;
var _local14:Vertex;
var _local15:int;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:Number;
var _local20:UV;
var _local21:UV;
var _local22:UV;
var _local23:UV;
super.buildPrimitive();
grid = new Array((_segmentsH + 1));
var _local3:Vertex = (_yUp) ? createVertex(0, -(_radius), 0) : createVertex(0, 0, -(_radius));
grid[0] = new Array(_segmentsW);
_local1 = 0;
while (_local1 < _segmentsW) {
grid[0][_local1] = _local3;
_local1++;
};
_local2 = 1;
while (_local2 < _segmentsH) {
_local5 = ((_local2 / _segmentsH) * Math.PI);
_local6 = (-(_radius) * Math.cos(_local5));
_local7 = (_radius * Math.sin(_local5));
grid[_local2] = new Array(_segmentsW);
_local1 = 0;
while (_local1 < _segmentsW) {
_local8 = (((2 * _local1) / _segmentsW) * Math.PI);
_local9 = (_local7 * Math.sin(_local8));
_local10 = (_local7 * Math.cos(_local8));
if (_yUp){
grid[_local2][_local1] = createVertex(_local10, _local6, _local9);
} else {
grid[_local2][_local1] = createVertex(_local10, -(_local9), _local6);
};
_local1++;
};
_local2++;
};
var _local4:Vertex = (_yUp) ? createVertex(0, _radius, 0) : createVertex(0, 0, _radius);
grid[_segmentsH] = new Array(_segmentsW);
_local1 = 0;
while (_local1 < _segmentsW) {
grid[_segmentsH][_local1] = _local4;
_local1++;
};
_local2 = 1;
while (_local2 <= _segmentsH) {
_local1 = 0;
while (_local1 < _segmentsW) {
_local11 = grid[_local2][_local1];
_local12 = grid[_local2][(((_local1 - 1) + _segmentsW) % _segmentsW)];
_local13 = grid[(_local2 - 1)][(((_local1 - 1) + _segmentsW) % _segmentsW)];
_local14 = grid[(_local2 - 1)][_local1];
_local15 = _local1;
if (_local1 == 0){
_local15 = _segmentsW;
};
_local16 = (_local2 / _segmentsH);
_local17 = ((_local2 - 1) / _segmentsH);
_local18 = (_local15 / _segmentsW);
_local19 = ((_local15 - 1) / _segmentsW);
_local20 = createUV(_local18, _local16);
_local21 = createUV(_local19, _local16);
_local22 = createUV(_local19, _local17);
_local23 = createUV(_local18, _local17);
if (_local2 < _segmentsH){
addFace(createFace(_local11, _local12, _local13, null, _local20, _local21, _local22));
};
if (_local2 > 1){
addFace(createFace(_local11, _local13, _local14, null, _local20, _local22, _local23));
};
_local1++;
};
_local2++;
};
}
public function get radius():Number{
return (_radius);
}
public function set radius(_arg1:Number):void{
if (_radius == _arg1){
return;
};
_radius = _arg1;
_primitiveDirty = true;
}
public function get segmentsW():Number{
return (_segmentsW);
}
public function set segmentsW(_arg1:Number):void{
if (_segmentsW == _arg1){
return;
};
_segmentsW = _arg1;
_primitiveDirty = true;
}
public function get segmentsH():Number{
return (_segmentsH);
}
public function set segmentsH(_arg1:Number):void{
if (_segmentsH == _arg1){
return;
};
_segmentsH = _arg1;
_primitiveDirty = true;
}
public function get yUp():Boolean{
return (_yUp);
}
public function set yUp(_arg1:Boolean):void{
if (_yUp == _arg1){
return;
};
_yUp = _arg1;
_primitiveDirty = true;
}
public function vertex(_arg1:int, _arg2:int):Vertex{
if (_primitiveDirty){
updatePrimitive();
};
return (grid[_arg2][_arg1]);
}
}
}//package away3d.primitives
Section 150
//WireCube (away3d.primitives.WireCube)
package away3d.primitives {
import away3d.core.base.*;
public class WireCube extends AbstractPrimitive {
private var _width:Number;
private var _height:Number;
private var _depth:Number;
private var _v000:Vertex;
private var _v001:Vertex;
private var _v010:Vertex;
private var _v011:Vertex;
private var _v100:Vertex;
private var _v101:Vertex;
private var _v110:Vertex;
private var _v111:Vertex;
public function WireCube(_arg1:Object=null){
super(_arg1);
_width = ini.getNumber("width", 100, {min:0});
_height = ini.getNumber("height", 100, {min:0});
_depth = ini.getNumber("depth", 100, {min:0});
type = "WireCube";
url = "primitive";
}
override protected function buildPrimitive():void{
super.buildPrimitive();
_v000 = createVertex((-(_width) / 2), (-(_height) / 2), (-(_depth) / 2));
_v001 = createVertex((-(_width) / 2), (-(_height) / 2), (_depth / 2));
_v010 = createVertex((-(_width) / 2), (_height / 2), (-(_depth) / 2));
_v011 = createVertex((-(_width) / 2), (_height / 2), (_depth / 2));
_v100 = createVertex((_width / 2), (-(_height) / 2), (-(_depth) / 2));
_v101 = createVertex((_width / 2), (-(_height) / 2), (_depth / 2));
_v110 = createVertex((_width / 2), (_height / 2), (-(_depth) / 2));
_v111 = createVertex((_width / 2), (_height / 2), (_depth / 2));
addSegment(createSegment(v000, v001));
addSegment(createSegment(v011, v001));
addSegment(createSegment(v011, v010));
addSegment(createSegment(v000, v010));
addSegment(createSegment(v100, v000));
addSegment(createSegment(v101, v001));
addSegment(createSegment(v111, v011));
addSegment(createSegment(v110, v010));
addSegment(createSegment(v100, v101));
addSegment(createSegment(v111, v101));
addSegment(createSegment(v111, v110));
addSegment(createSegment(v100, v110));
}
public function get v000():Vertex{
if (_primitiveDirty){
updatePrimitive();
};
return (_v000);
}
public function get v001():Vertex{
if (_primitiveDirty){
updatePrimitive();
};
return (_v001);
}
public function get v010():Vertex{
if (_primitiveDirty){
updatePrimitive();
};
return (_v010);
}
public function get v011():Vertex{
if (_primitiveDirty){
updatePrimitive();
};
return (_v011);
}
public function get v100():Vertex{
if (_primitiveDirty){
updatePrimitive();
};
return (_v100);
}
public function get v101():Vertex{
if (_primitiveDirty){
updatePrimitive();
};
return (_v101);
}
public function get v110():Vertex{
if (_primitiveDirty){
updatePrimitive();
};
return (_v110);
}
public function get v111():Vertex{
if (_primitiveDirty){
updatePrimitive();
};
return (_v111);
}
public function get width():Number{
return (_width);
}
public function set width(_arg1:Number):void{
if (_width == _arg1){
return;
};
_width = _arg1;
_primitiveDirty = true;
}
public function get height():Number{
return (_height);
}
public function set height(_arg1:Number):void{
if (_height == _arg1){
return;
};
_height = _arg1;
_primitiveDirty = true;
}
public function get depth():Number{
return (_depth);
}
public function set depth(_arg1:Number):void{
if (_depth == _arg1){
return;
};
_depth = _arg1;
_primitiveDirty = true;
}
}
}//package away3d.primitives
Section 151
//WireSphere (away3d.primitives.WireSphere)
package away3d.primitives {
import away3d.core.base.*;
public class WireSphere extends AbstractPrimitive {
private var grid:Array;
private var _radius:Number;
private var _segmentsW:int;
private var _segmentsH:int;
private var _yUp:Boolean;
public function WireSphere(_arg1:Object=null){
super(_arg1);
_radius = ini.getNumber("radius", 100, {min:0});
_segmentsW = ini.getInt("segmentsW", 8, {min:3});
_segmentsH = ini.getInt("segmentsH", 6, {min:2});
_yUp = ini.getBoolean("yUp", true);
type = "WireSphere";
url = "primitive";
}
override protected function buildPrimitive():void{
var _local1:int;
var _local2:int;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Vertex;
var _local12:Vertex;
var _local13:Vertex;
var _local14:Vertex;
super.buildPrimitive();
grid = new Array((_segmentsH + 1));
var _local3:Vertex = (_yUp) ? createVertex(0, -(_radius), 0) : createVertex(0, 0, -(_radius));
grid[0] = new Array(_segmentsW);
_local1 = 0;
while (_local1 < _segmentsW) {
grid[0][_local1] = _local3;
_local1++;
};
_local2 = 1;
while (_local2 < _segmentsH) {
_local5 = ((_local2 / _segmentsH) * Math.PI);
_local6 = (-(_radius) * Math.cos(_local5));
_local7 = (_radius * Math.sin(_local5));
grid[_local2] = new Array(_segmentsW);
_local1 = 0;
while (_local1 < _segmentsW) {
_local8 = (((2 * _local1) / _segmentsW) * Math.PI);
_local9 = (_local7 * Math.sin(_local8));
_local10 = (_local7 * Math.cos(_local8));
if (_yUp){
grid[_local2][_local1] = createVertex(_local10, _local6, _local9);
} else {
grid[_local2][_local1] = createVertex(_local10, -(_local9), _local6);
};
_local1++;
};
_local2++;
};
var _local4:Vertex = (_yUp) ? createVertex(0, _radius, 0) : createVertex(0, 0, _radius);
grid[_segmentsH] = new Array(_segmentsW);
_local1 = 0;
while (_local1 < _segmentsW) {
grid[_segmentsH][_local1] = _local4;
_local1++;
};
_local2 = 1;
while (_local2 <= _segmentsH) {
_local1 = 0;
while (_local1 < _segmentsW) {
_local11 = grid[_local2][_local1];
_local12 = grid[_local2][(((_local1 - 1) + _segmentsW) % _segmentsW)];
_local13 = grid[(_local2 - 1)][(((_local1 - 1) + _segmentsW) % _segmentsW)];
_local14 = grid[(_local2 - 1)][_local1];
addSegment(createSegment(_local11, _local14));
addSegment(createSegment(_local12, _local13));
if (_local2 < _segmentsH){
addSegment(createSegment(_local11, _local12));
};
_local1++;
};
_local2++;
};
}
public function get radius():Number{
return (_radius);
}
public function set radius(_arg1:Number):void{
if (_radius == _arg1){
return;
};
_radius = _arg1;
_primitiveDirty = true;
}
public function get segmentsW():Number{
return (_segmentsW);
}
public function set segmentsW(_arg1:Number):void{
if (_segmentsW == _arg1){
return;
};
_segmentsW = _arg1;
_primitiveDirty = true;
}
public function get segmentsH():Number{
return (_segmentsH);
}
public function set segmentsH(_arg1:Number):void{
if (_segmentsH == _arg1){
return;
};
_segmentsH = _arg1;
_primitiveDirty = true;
}
public function get yUp():Boolean{
return (_yUp);
}
public function set yUp(_arg1:Boolean):void{
if (_yUp == _arg1){
return;
};
_yUp = _arg1;
_primitiveDirty = true;
}
public function vertex(_arg1:int, _arg2:int):Vertex{
if (_primitiveDirty){
updatePrimitive();
};
return (grid[_arg2][_arg1]);
}
}
}//package away3d.primitives
Section 152
//DirSprite2D (away3d.sprites.DirSprite2D)
package away3d.sprites {
import flash.display.*;
import away3d.core.base.*;
import away3d.core.utils.*;
import flash.utils.*;
import away3d.core.project.*;
public class DirSprite2D extends Object3D {
private var _vertices:Array;
private var _bitmaps:Dictionary;
public var scaling:Number;
public var rotation:Number;
public var smooth:Boolean;
public var deltaZ:Number;
public function DirSprite2D(_arg1:Object=null){
var _local3:Init;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:BitmapData;
_vertices = [];
_bitmaps = new Dictionary(true);
super(_arg1);
scaling = ini.getNumber("scaling", 1, {min:0});
rotation = ini.getNumber("rotation", 0);
smooth = ini.getBoolean("smooth", false);
deltaZ = ini.getNumber("deltaZ", 0);
var _local2:Array = ini.getArray("bitmaps");
for each (_local3 in _local2) {
_local3 = Init.parse(_local3);
_local4 = _local3.getNumber("x", 0);
_local5 = _local3.getNumber("y", 0);
_local6 = _local3.getNumber("z", 0);
_local7 = _local3.getBitmap("bitmap");
add(_local4, _local5, _local6, _local7);
};
projectorType = ProjectorType.DIR_SPRITE;
}
public function get vertices():Array{
return (_vertices);
}
public function get bitmaps():Dictionary{
return (_bitmaps);
}
public function add(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:BitmapData):void{
var _local6:Vertex;
if (_arg4){
for each (_local6 in _vertices) {
if ((((((_local6.x == _arg1)) && ((_local6.y == _arg2)))) && ((_local6.z == _arg3)))){
Debug.warning(("Same base point for two bitmaps: " + _local6));
return;
};
};
};
var _local5:Vertex = new Vertex(_arg1, _arg2, _arg3);
_vertices.push(_local5);
_bitmaps[_local5] = _arg4;
}
}
}//package away3d.sprites
Section 153
//DofSprite2D (away3d.sprites.DofSprite2D)
package away3d.sprites {
import flash.display.*;
import away3d.core.base.*;
import away3d.core.project.*;
public class DofSprite2D extends Object3D {
public var bitmap:BitmapData;
public var scaling:Number;
public var rotation:Number;
public var smooth:Boolean;
public var deltaZ:Number;
public function DofSprite2D(_arg1:BitmapData, _arg2:Object=null){
this.bitmap = _arg1;
super(_arg2);
scaling = ini.getNumber("scaling", 1, {min:0});
rotation = ini.getNumber("rotation", 0);
smooth = ini.getBoolean("smooth", false);
deltaZ = ini.getNumber("deltaZ", 0);
projectorType = ProjectorType.DOF_SPRITE;
}
}
}//package away3d.sprites
Section 154
//MovieClipSprite (away3d.sprites.MovieClipSprite)
package away3d.sprites {
import flash.display.*;
import away3d.core.base.*;
import away3d.core.project.*;
public class MovieClipSprite extends Object3D {
public var movieclip:DisplayObject;
public var scaling:Number;
public var deltaZ:Number;
public var rescale:Boolean;
public var align:String;
public function MovieClipSprite(_arg1:DisplayObject, _arg2:Object=null){
super(_arg2);
this.movieclip = _arg1;
scaling = ini.getNumber("scaling", 1);
deltaZ = ini.getNumber("deltaZ", 0);
rescale = ini.getBoolean("rescale", false);
align = ini.getString("align", "center");
projectorType = ProjectorType.MOVIE_CLIP_SPRITE;
}
}
}//package away3d.sprites
Section 155
//Sprite2D (away3d.sprites.Sprite2D)
package away3d.sprites {
import flash.display.*;
import away3d.core.base.*;
import away3d.core.project.*;
public class Sprite2D extends Object3D {
public var bitmap:BitmapData;
public var scaling:Number;
public var rotation:Number;
public var smooth:Boolean;
public var deltaZ:Number;
public function Sprite2D(_arg1:BitmapData, _arg2:Object=null){
this.bitmap = _arg1;
super(_arg2);
scaling = ini.getNumber("scaling", 1, {min:0});
rotation = ini.getNumber("rotation", 0);
smooth = ini.getBoolean("smooth", false);
deltaZ = ini.getNumber("deltaZ", 0);
projectorType = ProjectorType.SPRITE;
}
}
}//package away3d.sprites
Section 156
//Sprite3D (away3d.sprites.Sprite3D)
package away3d.sprites {
import away3d.core.base.*;
import away3d.core.utils.*;
import away3d.materials.*;
import away3d.events.*;
public class Sprite3D extends Element {
var _vertex:Vertex;
var _material:Material;
private var _width:Number;
private var _height:Number;
private var _rotation:Number;
private var _scaling:Number;
public var spriteVO:SpriteVO;
public function Sprite3D(_arg1:Material=null, _arg2:Number=10, _arg3:Number=10, _arg4:Number=0, _arg5:Number=1){
spriteVO = new SpriteVO();
super();
this.material = _arg1;
this.width = _arg2;
this.height = _arg3;
this.rotation = _arg4;
this.scaling = _arg5;
spriteVO.sprite3d = this;
_commands[0] = (spriteVO.command = "M");
_vertices[0] = (_vertex = (spriteVO.vertex = new Vertex()));
_vertex.parents.push(this);
vertexDirty = true;
}
override public function get vertices():Array{
return (_vertices);
}
override public function get commands():Array{
return (_commands);
}
public function get vertex():Vertex{
return (_vertex);
}
public function get x():Number{
return (_vertex.x);
}
public function set x(_arg1:Number):void{
if (isNaN(_arg1)){
throw (new Error("isNaN(x)"));
};
if (_vertex.x == _arg1){
return;
};
if (_arg1 == Infinity){
Debug.warning("x == Infinity");
};
if (_arg1 == -(Infinity)){
Debug.warning("x == -Infinity");
};
_vertex.x = _arg1;
}
public function get y():Number{
return (_vertex.y);
}
public function set y(_arg1:Number):void{
if (isNaN(_arg1)){
throw (new Error("isNaN(y)"));
};
if (_vertex.y == _arg1){
return;
};
if (_arg1 == Infinity){
Debug.warning("y == Infinity");
};
if (_arg1 == -(Infinity)){
Debug.warning("y == -Infinity");
};
_vertex.y = _arg1;
}
public function get z():Number{
return (_vertex.z);
}
public function set z(_arg1:Number):void{
if (isNaN(_arg1)){
throw (new Error("isNaN(z)"));
};
if (_vertex.z == _arg1){
return;
};
if (_arg1 == Infinity){
Debug.warning("z == Infinity");
};
if (_arg1 == -(Infinity)){
Debug.warning("z == -Infinity");
};
_vertex.z = _arg1;
}
public function get material():Material{
return (_material);
}
public function set material(_arg1:Material):void{
if (_material == _arg1){
return;
};
if (((!((_material == null))) && (parent))){
parent.removeMaterial(this, _material);
};
_material = (spriteVO.material = _arg1);
if (((!((_material == null))) && (parent))){
parent.addMaterial(this, _material);
};
}
public function get width():Number{
return (_width);
}
public function set width(_arg1:Number):void{
if (_width == _arg1){
return;
};
_width = (spriteVO.width = _arg1);
notifyMappingChange();
}
public function get height():Number{
return (_width);
}
public function set height(_arg1:Number):void{
if (_height == _arg1){
return;
};
_height = (spriteVO.height = _arg1);
notifyMappingChange();
}
public function get scaling():Number{
return (_scaling);
}
public function set scaling(_arg1:Number):void{
if (_scaling == _arg1){
return;
};
_scaling = (spriteVO.scaling = _arg1);
notifyMappingChange();
}
public function get rotation():Number{
return (_rotation);
}
public function set rotation(_arg1:Number):void{
if (_rotation == _arg1){
return;
};
_rotation = (spriteVO.rotation = _arg1);
notifyMappingChange();
}
override public function get radius2():Number{
return (0);
}
override public function get maxX():Number{
return (_vertex._x);
}
override public function get minX():Number{
return (_vertex._x);
}
override public function get maxY():Number{
return (_vertex._y);
}
override public function get minY():Number{
return (_vertex._y);
}
override public function get maxZ():Number{
return (_vertex._z);
}
override public function get minZ():Number{
return (_vertex._z);
}
}
}//package away3d.sprites
Section 157
//arcane (away3d.arcane)
package away3d {
public namespace arcane;
}//package away3d
Section 158
//BaseButton (fl.controls.BaseButton)
package fl.controls {
import flash.display.*;
import fl.core.*;
import flash.events.*;
import flash.utils.*;
import fl.events.*;
public class BaseButton extends UIComponent {
protected var _selected:Boolean;// = false
private var unlockedMouseState:String;
protected var pressTimer:Timer;
protected var mouseState:String;
protected var background:DisplayObject;
private var _mouseStateLocked:Boolean;// = false
protected var _autoRepeat:Boolean;// = false
private static var defaultStyles:Object = {upSkin:"Button_upSkin", downSkin:"Button_downSkin", overSkin:"Button_overSkin", disabledSkin:"Button_disabledSkin", selectedDisabledSkin:"Button_selectedDisabledSkin", selectedUpSkin:"Button_selectedUpSkin", selectedDownSkin:"Button_selectedDownSkin", selectedOverSkin:"Button_selectedOverSkin", focusRectSkin:null, focusRectPadding:null, repeatDelay:500, repeatInterval:35};
public function BaseButton(){
_selected = false;
_autoRepeat = false;
_mouseStateLocked = false;
super();
buttonMode = true;
mouseChildren = false;
useHandCursor = false;
setupMouseEvents();
setMouseState("up");
pressTimer = new Timer(1, 0);
pressTimer.addEventListener(TimerEvent.TIMER, buttonDown, false, 0, true);
}
protected function endPress():void{
pressTimer.reset();
}
public function set mouseStateLocked(_arg1:Boolean):void{
_mouseStateLocked = _arg1;
if (_arg1 == false){
setMouseState(unlockedMouseState);
} else {
unlockedMouseState = mouseState;
};
}
public function get autoRepeat():Boolean{
return (_autoRepeat);
}
public function set autoRepeat(_arg1:Boolean):void{
_autoRepeat = _arg1;
}
override public function set enabled(_arg1:Boolean):void{
super.enabled = _arg1;
mouseEnabled = _arg1;
}
public function get selected():Boolean{
return (_selected);
}
protected function mouseEventHandler(_arg1:MouseEvent):void{
if (_arg1.type == MouseEvent.MOUSE_DOWN){
setMouseState("down");
startPress();
} else {
if ((((_arg1.type == MouseEvent.ROLL_OVER)) || ((_arg1.type == MouseEvent.MOUSE_UP)))){
setMouseState("over");
endPress();
} else {
if (_arg1.type == MouseEvent.ROLL_OUT){
setMouseState("up");
endPress();
};
};
};
}
public function setMouseState(_arg1:String):void{
if (_mouseStateLocked){
unlockedMouseState = _arg1;
return;
};
if (mouseState == _arg1){
return;
};
mouseState = _arg1;
invalidate(InvalidationType.STATE);
}
protected function startPress():void{
if (_autoRepeat){
pressTimer.delay = Number(getStyleValue("repeatDelay"));
pressTimer.start();
};
dispatchEvent(new ComponentEvent(ComponentEvent.BUTTON_DOWN, true));
}
protected function buttonDown(_arg1:TimerEvent):void{
if (!_autoRepeat){
endPress();
return;
};
if (pressTimer.currentCount == 1){
pressTimer.delay = Number(getStyleValue("repeatInterval"));
};
dispatchEvent(new ComponentEvent(ComponentEvent.BUTTON_DOWN, true));
}
public function set selected(_arg1:Boolean):void{
if (_selected == _arg1){
return;
};
_selected = _arg1;
invalidate(InvalidationType.STATE);
}
override public function get enabled():Boolean{
return (super.enabled);
}
override protected function draw():void{
if (isInvalid(InvalidationType.STYLES, InvalidationType.STATE)){
drawBackground();
invalidate(InvalidationType.SIZE, false);
};
if (isInvalid(InvalidationType.SIZE)){
drawLayout();
};
super.draw();
}
protected function setupMouseEvents():void{
addEventListener(MouseEvent.ROLL_OVER, mouseEventHandler, false, 0, true);
addEventListener(MouseEvent.MOUSE_DOWN, mouseEventHandler, false, 0, true);
addEventListener(MouseEvent.MOUSE_UP, mouseEventHandler, false, 0, true);
addEventListener(MouseEvent.ROLL_OUT, mouseEventHandler, false, 0, true);
}
protected function drawLayout():void{
background.width = width;
background.height = height;
}
protected function drawBackground():void{
var _local1:String;
var _local2:DisplayObject;
_local1 = (enabled) ? mouseState : "disabled";
if (selected){
_local1 = (("selected" + _local1.substr(0, 1).toUpperCase()) + _local1.substr(1));
};
_local1 = (_local1 + "Skin");
_local2 = background;
background = getDisplayObjectInstance(getStyleValue(_local1));
addChildAt(background, 0);
if (((!((_local2 == null))) && (!((_local2 == background))))){
removeChild(_local2);
};
}
public static function getStyleDefinition():Object{
return (defaultStyles);
}
}
}//package fl.controls
Section 159
//Button (fl.controls.Button)
package fl.controls {
import flash.display.*;
import fl.core.*;
import fl.managers.*;
public class Button extends LabelButton implements IFocusManagerComponent {
protected var emphasizedBorder:DisplayObject;
protected var _emphasized:Boolean;// = false
private static var defaultStyles:Object = {emphasizedSkin:"Button_emphasizedSkin", emphasizedPadding:2};
public static var createAccessibilityImplementation:Function;
public function Button(){
_emphasized = false;
super();
}
override public function drawFocus(_arg1:Boolean):void{
var _local2:Number;
var _local3:*;
super.drawFocus(_arg1);
if (_arg1){
_local2 = Number(getStyleValue("emphasizedPadding"));
if ((((_local2 < 0)) || (!(_emphasized)))){
_local2 = 0;
};
_local3 = getStyleValue("focusRectPadding");
_local3 = ((_local3)==null) ? 2 : _local3;
_local3 = (_local3 + _local2);
uiFocusRect.x = -(_local3);
uiFocusRect.y = -(_local3);
uiFocusRect.width = (width + (_local3 * 2));
uiFocusRect.height = (height + (_local3 * 2));
};
}
public function set emphasized(_arg1:Boolean):void{
_emphasized = _arg1;
invalidate(InvalidationType.STYLES);
}
override protected function draw():void{
if (((isInvalid(InvalidationType.STYLES)) || (isInvalid(InvalidationType.SIZE)))){
drawEmphasized();
};
super.draw();
if (emphasizedBorder != null){
setChildIndex(emphasizedBorder, (numChildren - 1));
};
}
public function get emphasized():Boolean{
return (_emphasized);
}
override protected function initializeAccessibility():void{
if (Button.createAccessibilityImplementation != null){
Button.createAccessibilityImplementation(this);
};
}
protected function drawEmphasized():void{
var _local1:Object;
var _local2:Number;
if (emphasizedBorder != null){
removeChild(emphasizedBorder);
};
emphasizedBorder = null;
if (!_emphasized){
return;
};
_local1 = getStyleValue("emphasizedSkin");
if (_local1 != null){
emphasizedBorder = getDisplayObjectInstance(_local1);
};
if (emphasizedBorder != null){
addChildAt(emphasizedBorder, 0);
_local2 = Number(getStyleValue("emphasizedPadding"));
emphasizedBorder.x = (emphasizedBorder.y = -(_local2));
emphasizedBorder.width = (width + (_local2 * 2));
emphasizedBorder.height = (height + (_local2 * 2));
};
}
public static function getStyleDefinition():Object{
return (UIComponent.mergeStyles(LabelButton.getStyleDefinition(), defaultStyles));
}
}
}//package fl.controls
Section 160
//ButtonLabelPlacement (fl.controls.ButtonLabelPlacement)
package fl.controls {
public class ButtonLabelPlacement {
public static const TOP:String = "top";
public static const LEFT:String = "left";
public static const BOTTOM:String = "bottom";
public static const RIGHT:String = "right";
}
}//package fl.controls
Section 161
//LabelButton (fl.controls.LabelButton)
package fl.controls {
import flash.display.*;
import fl.core.*;
import flash.events.*;
import flash.text.*;
import fl.managers.*;
import fl.events.*;
import flash.ui.*;
public class LabelButton extends BaseButton implements IFocusManagerComponent {
protected var _labelPlacement:String;// = "right"
protected var _toggle:Boolean;// = false
protected var icon:DisplayObject;
protected var oldMouseState:String;
protected var mode:String;// = "center"
public var textField:TextField;
protected var _label:String;// = "Label"
private static var defaultStyles:Object = {icon:null, upIcon:null, downIcon:null, overIcon:null, disabledIcon:null, selectedDisabledIcon:null, selectedUpIcon:null, selectedDownIcon:null, selectedOverIcon:null, textFormat:null, disabledTextFormat:null, textPadding:5, embedFonts:false};
public static var createAccessibilityImplementation:Function;
public function LabelButton(){
_labelPlacement = ButtonLabelPlacement.RIGHT;
_toggle = false;
_label = "Label";
mode = "center";
super();
}
protected function toggleSelected(_arg1:MouseEvent):void{
selected = !(selected);
dispatchEvent(new Event(Event.CHANGE, true));
}
public function get labelPlacement():String{
return (_labelPlacement);
}
override protected function keyDownHandler(_arg1:KeyboardEvent):void{
if (!enabled){
return;
};
if (_arg1.keyCode == Keyboard.SPACE){
if (oldMouseState == null){
oldMouseState = mouseState;
};
setMouseState("down");
startPress();
};
}
protected function setEmbedFont(){
var _local1:Object;
_local1 = getStyleValue("embedFonts");
if (_local1 != null){
textField.embedFonts = _local1;
};
}
override protected function keyUpHandler(_arg1:KeyboardEvent):void{
if (!enabled){
return;
};
if (_arg1.keyCode == Keyboard.SPACE){
setMouseState(oldMouseState);
oldMouseState = null;
endPress();
dispatchEvent(new MouseEvent(MouseEvent.CLICK));
};
}
override public function get selected():Boolean{
return ((_toggle) ? _selected : false);
}
public function set labelPlacement(_arg1:String):void{
_labelPlacement = _arg1;
invalidate(InvalidationType.SIZE);
}
public function set toggle(_arg1:Boolean):void{
if (((!(_arg1)) && (super.selected))){
selected = false;
};
_toggle = _arg1;
if (_toggle){
addEventListener(MouseEvent.CLICK, toggleSelected, false, 0, true);
} else {
removeEventListener(MouseEvent.CLICK, toggleSelected);
};
invalidate(InvalidationType.STATE);
}
public function get label():String{
return (_label);
}
override public function set selected(_arg1:Boolean):void{
_selected = _arg1;
if (_toggle){
invalidate(InvalidationType.STATE);
};
}
override protected function draw():void{
if (textField.text != _label){
label = _label;
};
if (isInvalid(InvalidationType.STYLES, InvalidationType.STATE)){
drawBackground();
drawIcon();
drawTextFormat();
invalidate(InvalidationType.SIZE, false);
};
if (isInvalid(InvalidationType.SIZE)){
drawLayout();
};
if (isInvalid(InvalidationType.SIZE, InvalidationType.STYLES)){
if (((isFocused) && (focusManager.showFocusIndicator))){
drawFocus(true);
};
};
validate();
}
public function get toggle():Boolean{
return (_toggle);
}
override protected function configUI():void{
super.configUI();
textField = new TextField();
textField.type = TextFieldType.DYNAMIC;
textField.selectable = false;
addChild(textField);
}
override protected function drawLayout():void{
var _local1:Number;
var _local2:String;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
_local1 = Number(getStyleValue("textPadding"));
_local2 = ((((icon == null)) && ((mode == "center")))) ? ButtonLabelPlacement.TOP : _labelPlacement;
textField.height = (textField.textHeight + 4);
_local3 = (textField.textWidth + 4);
_local4 = (textField.textHeight + 4);
_local5 = ((icon)==null) ? 0 : (icon.width + _local1);
_local6 = ((icon)==null) ? 0 : (icon.height + _local1);
textField.visible = (label.length > 0);
if (icon != null){
icon.x = Math.round(((width - icon.width) / 2));
icon.y = Math.round(((height - icon.height) / 2));
};
if (textField.visible == false){
textField.width = 0;
textField.height = 0;
} else {
if ((((_local2 == ButtonLabelPlacement.BOTTOM)) || ((_local2 == ButtonLabelPlacement.TOP)))){
_local7 = Math.max(0, Math.min(_local3, (width - (2 * _local1))));
if ((height - 2) > _local4){
_local8 = _local4;
} else {
_local8 = (height - 2);
};
_local3 = _local7;
textField.width = _local3;
_local4 = _local8;
textField.height = _local4;
textField.x = Math.round(((width - _local3) / 2));
textField.y = Math.round(((((height - textField.height) - _local6) / 2) + ((_local2)==ButtonLabelPlacement.BOTTOM) ? _local6 : 0));
if (icon != null){
icon.y = Math.round(((_local2)==ButtonLabelPlacement.BOTTOM) ? (textField.y - _local6) : ((textField.y + textField.height) + _local1));
};
} else {
_local7 = Math.max(0, Math.min(_local3, ((width - _local5) - (2 * _local1))));
_local3 = _local7;
textField.width = _local3;
textField.x = Math.round(((((width - _local3) - _local5) / 2) + ((_local2)!=ButtonLabelPlacement.LEFT) ? _local5 : 0));
textField.y = Math.round(((height - textField.height) / 2));
if (icon != null){
icon.x = Math.round(((_local2)!=ButtonLabelPlacement.LEFT) ? (textField.x - _local5) : ((textField.x + _local3) + _local1));
};
};
};
super.drawLayout();
}
override protected function initializeAccessibility():void{
if (LabelButton.createAccessibilityImplementation != null){
LabelButton.createAccessibilityImplementation(this);
};
}
protected function drawIcon():void{
var _local1:DisplayObject;
var _local2:String;
var _local3:Object;
_local1 = icon;
_local2 = (enabled) ? mouseState : "disabled";
if (selected){
_local2 = (("selected" + _local2.substr(0, 1).toUpperCase()) + _local2.substr(1));
};
_local2 = (_local2 + "Icon");
_local3 = getStyleValue(_local2);
if (_local3 == null){
_local3 = getStyleValue("icon");
};
if (_local3 != null){
icon = getDisplayObjectInstance(_local3);
};
if (icon != null){
addChildAt(icon, 1);
};
if (((!((_local1 == null))) && (!((_local1 == icon))))){
removeChild(_local1);
};
}
public function set label(_arg1:String):void{
_label = _arg1;
if (textField.text != _label){
textField.text = _label;
dispatchEvent(new ComponentEvent(ComponentEvent.LABEL_CHANGE));
};
invalidate(InvalidationType.SIZE);
invalidate(InvalidationType.STYLES);
}
protected function drawTextFormat():void{
var _local1:Object;
var _local2:TextFormat;
var _local3:TextFormat;
_local1 = UIComponent.getStyleDefinition();
_local2 = (enabled) ? (_local1.defaultTextFormat as TextFormat) : (_local1.defaultDisabledTextFormat as TextFormat);
textField.setTextFormat(_local2);
_local3 = (getStyleValue((enabled) ? "textFormat" : "disabledTextFormat") as TextFormat);
if (_local3 != null){
textField.setTextFormat(_local3);
} else {
_local3 = _local2;
};
textField.defaultTextFormat = _local3;
setEmbedFont();
}
public static function getStyleDefinition():Object{
return (mergeStyles(defaultStyles, BaseButton.getStyleDefinition()));
}
}
}//package fl.controls
Section 162
//ComponentShim (fl.core.ComponentShim)
package fl.core {
import flash.display.*;
public dynamic class ComponentShim extends MovieClip {
}
}//package fl.core
Section 163
//InvalidationType (fl.core.InvalidationType)
package fl.core {
public class InvalidationType {
public static const SIZE:String = "size";
public static const ALL:String = "all";
public static const DATA:String = "data";
public static const SCROLL:String = "scroll";
public static const STATE:String = "state";
public static const STYLES:String = "styles";
public static const SELECTED:String = "selected";
public static const RENDERER_STYLES:String = "rendererStyles";
}
}//package fl.core
Section 164
//UIComponent (fl.core.UIComponent)
package fl.core {
import flash.display.*;
import flash.events.*;
import flash.utils.*;
import flash.text.*;
import fl.managers.*;
import flash.system.*;
import fl.events.*;
public class UIComponent extends Sprite {
protected var _enabled:Boolean;// = true
private var _mouseFocusEnabled:Boolean;// = true
protected var startHeight:Number;
protected var _height:Number;
protected var _oldIMEMode:String;// = null
protected var startWidth:Number;
public var focusTarget:IFocusManagerComponent;
protected var errorCaught:Boolean;// = false
protected var uiFocusRect:DisplayObject;
protected var _width:Number;
public var version:String;// = "3.0.0.15"
protected var isFocused:Boolean;// = false
protected var callLaterMethods:Dictionary;
private var _focusEnabled:Boolean;// = true
private var tempText:TextField;
protected var invalidateFlag:Boolean;// = false
protected var _inspector:Boolean;// = false
protected var sharedStyles:Object;
protected var invalidHash:Object;
protected var isLivePreview:Boolean;// = false
protected var _imeMode:String;// = null
protected var instanceStyles:Object;
protected var _x:Number;
protected var _y:Number;
public static var inCallLaterPhase:Boolean = false;
private static var defaultStyles:Object = {focusRectSkin:"focusRectSkin", focusRectPadding:2, textFormat:new TextFormat("_sans", 11, 0, false, false, false, "", "", TextFormatAlign.LEFT, 0, 0, 0, 0), disabledTextFormat:new TextFormat("_sans", 11, 0x999999, false, false, false, "", "", TextFormatAlign.LEFT, 0, 0, 0, 0), defaultTextFormat:new TextFormat("_sans", 11, 0, false, false, false, "", "", TextFormatAlign.LEFT, 0, 0, 0, 0), defaultDisabledTextFormat:new TextFormat("_sans", 11, 0x999999, false, false, false, "", "", TextFormatAlign.LEFT, 0, 0, 0, 0)};
public static var createAccessibilityImplementation:Function;
private static var focusManagers:Dictionary = new Dictionary(false);
public function UIComponent(){
version = "3.0.0.15";
isLivePreview = false;
invalidateFlag = false;
_enabled = true;
isFocused = false;
_focusEnabled = true;
_mouseFocusEnabled = true;
_imeMode = null;
_oldIMEMode = null;
errorCaught = false;
_inspector = false;
super();
instanceStyles = {};
sharedStyles = {};
invalidHash = {};
callLaterMethods = new Dictionary();
StyleManager.registerInstance(this);
configUI();
invalidate(InvalidationType.ALL);
tabEnabled = (this is IFocusManagerComponent);
focusRect = false;
if (tabEnabled){
addEventListener(FocusEvent.FOCUS_IN, focusInHandler);
addEventListener(FocusEvent.FOCUS_OUT, focusOutHandler);
addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
addEventListener(KeyboardEvent.KEY_UP, keyUpHandler);
};
initializeFocusManager();
addEventListener(Event.ENTER_FRAME, hookAccessibility, false, 0, true);
}
public function drawFocus(_arg1:Boolean):void{
var _local2:Number;
isFocused = _arg1;
if (((!((uiFocusRect == null))) && (contains(uiFocusRect)))){
removeChild(uiFocusRect);
uiFocusRect = null;
};
if (_arg1){
uiFocusRect = (getDisplayObjectInstance(getStyleValue("focusRectSkin")) as Sprite);
if (uiFocusRect == null){
return;
};
_local2 = Number(getStyleValue("focusRectPadding"));
uiFocusRect.x = -(_local2);
uiFocusRect.y = -(_local2);
uiFocusRect.width = (width + (_local2 * 2));
uiFocusRect.height = (height + (_local2 * 2));
addChildAt(uiFocusRect, 0);
};
}
private function callLaterDispatcher(_arg1:Event):void{
var _local2:Dictionary;
var _local3:Object;
if (_arg1.type == Event.ADDED_TO_STAGE){
removeEventListener(Event.ADDED_TO_STAGE, callLaterDispatcher);
stage.addEventListener(Event.RENDER, callLaterDispatcher, false, 0, true);
stage.invalidate();
return;
};
_arg1.target.removeEventListener(Event.RENDER, callLaterDispatcher);
if (stage == null){
addEventListener(Event.ADDED_TO_STAGE, callLaterDispatcher, false, 0, true);
return;
};
inCallLaterPhase = true;
_local2 = callLaterMethods;
for (_local3 in _local2) {
_local3();
delete _local2[_local3];
};
inCallLaterPhase = false;
}
private function addedHandler(_arg1:Event):void{
removeEventListener("addedToStage", addedHandler);
initializeFocusManager();
}
protected function getStyleValue(_arg1:String):Object{
return (((instanceStyles[_arg1])==null) ? sharedStyles[_arg1] : instanceStyles[_arg1]);
}
protected function isOurFocus(_arg1:DisplayObject):Boolean{
return ((_arg1 == this));
}
override public function get scaleX():Number{
return ((width / startWidth));
}
override public function get scaleY():Number{
return ((height / startHeight));
}
override public function set height(_arg1:Number):void{
if (_height == _arg1){
return;
};
setSize(width, _arg1);
}
protected function keyDownHandler(_arg1:KeyboardEvent):void{
}
protected function focusInHandler(_arg1:FocusEvent):void{
var _local2:IFocusManager;
if (isOurFocus((_arg1.target as DisplayObject))){
_local2 = focusManager;
if (((_local2) && (_local2.showFocusIndicator))){
drawFocus(true);
isFocused = true;
};
};
}
public function setStyle(_arg1:String, _arg2:Object):void{
if ((((instanceStyles[_arg1] === _arg2)) && (!((_arg2 is TextFormat))))){
return;
};
instanceStyles[_arg1] = _arg2;
invalidate(InvalidationType.STYLES);
}
override public function get visible():Boolean{
return (super.visible);
}
public function get componentInspectorSetting():Boolean{
return (_inspector);
}
override public function get x():Number{
return ((isNaN(_x)) ? super.x : _x);
}
override public function get y():Number{
return ((isNaN(_y)) ? super.y : _y);
}
protected function setIMEMode(_arg1:Boolean){
var enabled = _arg1;
if (_imeMode != null){
if (enabled){
IME.enabled = true;
_oldIMEMode = IME.conversionMode;
try {
if (((!(errorCaught)) && (!((IME.conversionMode == IMEConversionMode.UNKNOWN))))){
IME.conversionMode = _imeMode;
};
errorCaught = false;
} catch(e:Error) {
errorCaught = true;
throw (new Error(("IME mode not supported: " + _imeMode)));
};
} else {
if (((!((IME.conversionMode == IMEConversionMode.UNKNOWN))) && (!((_oldIMEMode == IMEConversionMode.UNKNOWN))))){
IME.conversionMode = _oldIMEMode;
};
IME.enabled = false;
};
};
}
public function set enabled(_arg1:Boolean):void{
if (_arg1 == _enabled){
return;
};
_enabled = _arg1;
invalidate(InvalidationType.STATE);
}
public function setSharedStyle(_arg1:String, _arg2:Object):void{
if ((((sharedStyles[_arg1] === _arg2)) && (!((_arg2 is TextFormat))))){
return;
};
sharedStyles[_arg1] = _arg2;
if (instanceStyles[_arg1] == null){
invalidate(InvalidationType.STYLES);
};
}
protected function keyUpHandler(_arg1:KeyboardEvent):void{
}
public function set focusEnabled(_arg1:Boolean):void{
_focusEnabled = _arg1;
}
override public function set scaleX(_arg1:Number):void{
setSize((startWidth * _arg1), height);
}
public function get mouseFocusEnabled():Boolean{
return (_mouseFocusEnabled);
}
override public function set scaleY(_arg1:Number):void{
setSize(width, (startHeight * _arg1));
}
protected function getDisplayObjectInstance(_arg1:Object):DisplayObject{
var classDef:Object;
var skin = _arg1;
classDef = null;
if ((skin is Class)){
return ((new (skin) as DisplayObject));
};
if ((skin is DisplayObject)){
(skin as DisplayObject).x = 0;
(skin as DisplayObject).y = 0;
return ((skin as DisplayObject));
};
try {
classDef = getDefinitionByName(skin.toString());
} catch(e:Error) {
try {
classDef = (loaderInfo.applicationDomain.getDefinition(skin.toString()) as Object);
} catch(e:Error) {
};
};
if (classDef == null){
return (null);
};
return ((new (classDef) as DisplayObject));
}
protected function copyStylesToChild(_arg1:UIComponent, _arg2:Object):void{
var _local3:String;
for (_local3 in _arg2) {
_arg1.setStyle(_local3, getStyleValue(_arg2[_local3]));
};
}
protected function beforeComponentParameters():void{
}
protected function callLater(_arg1:Function):void{
if (inCallLaterPhase){
return;
};
callLaterMethods[_arg1] = true;
if (stage != null){
stage.addEventListener(Event.RENDER, callLaterDispatcher, false, 0, true);
stage.invalidate();
} else {
addEventListener(Event.ADDED_TO_STAGE, callLaterDispatcher, false, 0, true);
};
}
protected function createFocusManager():void{
if (focusManagers[stage] == null){
focusManagers[stage] = new FocusManager(stage);
};
}
override public function set visible(_arg1:Boolean):void{
var _local2:String;
if (super.visible == _arg1){
return;
};
super.visible = _arg1;
_local2 = (_arg1) ? ComponentEvent.SHOW : ComponentEvent.HIDE;
dispatchEvent(new ComponentEvent(_local2, true));
}
protected function hookAccessibility(_arg1:Event):void{
removeEventListener(Event.ENTER_FRAME, hookAccessibility);
initializeAccessibility();
}
public function set componentInspectorSetting(_arg1:Boolean):void{
_inspector = _arg1;
if (_inspector){
beforeComponentParameters();
} else {
afterComponentParameters();
};
}
override public function set x(_arg1:Number):void{
move(_arg1, _y);
}
public function drawNow():void{
draw();
}
override public function set y(_arg1:Number):void{
move(_x, _arg1);
}
protected function checkLivePreview():Boolean{
var className:String;
if (parent == null){
return (false);
};
try {
className = getQualifiedClassName(parent);
} catch(e:Error) {
};
return ((className == "fl.livepreview::LivePreviewParent"));
}
protected function focusOutHandler(_arg1:FocusEvent):void{
if (isOurFocus((_arg1.target as DisplayObject))){
drawFocus(false);
isFocused = false;
};
}
public function set mouseFocusEnabled(_arg1:Boolean):void{
_mouseFocusEnabled = _arg1;
}
public function getFocus():InteractiveObject{
if (stage){
return (stage.focus);
};
return (null);
}
protected function validate():void{
invalidHash = {};
}
override public function get height():Number{
return (_height);
}
public function invalidate(_arg1:String="all", _arg2:Boolean=true):void{
invalidHash[_arg1] = true;
if (_arg2){
this.callLater(draw);
};
}
public function get enabled():Boolean{
return (_enabled);
}
protected function getScaleX():Number{
return (super.scaleX);
}
protected function getScaleY():Number{
return (super.scaleY);
}
public function get focusEnabled():Boolean{
return (_focusEnabled);
}
protected function afterComponentParameters():void{
}
protected function draw():void{
if (isInvalid(InvalidationType.SIZE, InvalidationType.STYLES)){
if (((isFocused) && (focusManager.showFocusIndicator))){
drawFocus(true);
};
};
validate();
}
protected function configUI():void{
var _local1:Number;
var _local2:Number;
var _local3:Number;
isLivePreview = checkLivePreview();
_local1 = rotation;
rotation = 0;
_local2 = super.width;
_local3 = super.height;
var _local4 = 1;
super.scaleY = _local4;
super.scaleX = _local4;
setSize(_local2, _local3);
move(super.x, super.y);
rotation = _local1;
startWidth = _local2;
startHeight = _local3;
if (numChildren > 0){
removeChildAt(0);
};
}
protected function setScaleX(_arg1:Number):void{
super.scaleX = _arg1;
}
protected function setScaleY(_arg1:Number):void{
super.scaleY = _arg1;
}
private function initializeFocusManager():void{
if (stage == null){
addEventListener(Event.ADDED_TO_STAGE, addedHandler, false, 0, true);
} else {
createFocusManager();
};
}
public function set focusManager(_arg1:IFocusManager):void{
UIComponent.focusManagers[this] = _arg1;
}
public function clearStyle(_arg1:String):void{
setStyle(_arg1, null);
}
protected function isInvalid(_arg1:String, ... _args):Boolean{
if (((invalidHash[_arg1]) || (invalidHash[InvalidationType.ALL]))){
return (true);
};
while (_args.length > 0) {
if (invalidHash[_args.pop()]){
return (true);
};
};
return (false);
}
public function setSize(_arg1:Number, _arg2:Number):void{
_width = _arg1;
_height = _arg2;
invalidate(InvalidationType.SIZE);
dispatchEvent(new ComponentEvent(ComponentEvent.RESIZE, false));
}
override public function set width(_arg1:Number):void{
if (_width == _arg1){
return;
};
setSize(_arg1, height);
}
public function setFocus():void{
if (stage){
stage.focus = this;
};
}
protected function initializeAccessibility():void{
if (UIComponent.createAccessibilityImplementation != null){
UIComponent.createAccessibilityImplementation(this);
};
}
public function get focusManager():IFocusManager{
var _local1:DisplayObject;
_local1 = this;
while (_local1) {
if (UIComponent.focusManagers[_local1] != null){
return (IFocusManager(UIComponent.focusManagers[_local1]));
};
_local1 = _local1.parent;
};
return (null);
}
override public function get width():Number{
return (_width);
}
public function move(_arg1:Number, _arg2:Number):void{
_x = _arg1;
_y = _arg2;
super.x = Math.round(_arg1);
super.y = Math.round(_arg2);
dispatchEvent(new ComponentEvent(ComponentEvent.MOVE));
}
public function validateNow():void{
invalidate(InvalidationType.ALL, false);
draw();
}
public function getStyle(_arg1:String):Object{
return (instanceStyles[_arg1]);
}
public static function getStyleDefinition():Object{
return (defaultStyles);
}
public static function mergeStyles(... _args):Object{
var _local2:Object;
var _local3:uint;
var _local4:uint;
var _local5:Object;
var _local6:String;
_local2 = {};
_local3 = _args.length;
_local4 = 0;
while (_local4 < _local3) {
_local5 = _args[_local4];
for (_local6 in _local5) {
if (_local2[_local6] != null){
} else {
_local2[_local6] = _args[_local4][_local6];
};
};
_local4++;
};
return (_local2);
}
}
}//package fl.core
Section 165
//ComponentEvent (fl.events.ComponentEvent)
package fl.events {
import flash.events.*;
public class ComponentEvent extends Event {
public static const HIDE:String = "hide";
public static const BUTTON_DOWN:String = "buttonDown";
public static const MOVE:String = "move";
public static const RESIZE:String = "resize";
public static const ENTER:String = "enter";
public static const LABEL_CHANGE:String = "labelChange";
public static const SHOW:String = "show";
public function ComponentEvent(_arg1:String, _arg2:Boolean=false, _arg3:Boolean=false){
super(_arg1, _arg2, _arg3);
}
override public function toString():String{
return (formatToString("ComponentEvent", "type", "bubbles", "cancelable"));
}
override public function clone():Event{
return (new ComponentEvent(type, bubbles, cancelable));
}
}
}//package fl.events
Section 166
//FocusManager (fl.managers.FocusManager)
package fl.managers {
import fl.controls.*;
import flash.display.*;
import fl.core.*;
import flash.events.*;
import flash.utils.*;
import flash.text.*;
import flash.ui.*;
public class FocusManager implements IFocusManager {
private var focusableObjects:Dictionary;
private var _showFocusIndicator:Boolean;// = true
private var defButton:Button;
private var focusableCandidates:Array;
private var _form:DisplayObjectContainer;
private var _defaultButtonEnabled:Boolean;// = true
private var activated:Boolean;// = false
private var _defaultButton:Button;
private var calculateCandidates:Boolean;// = true
private var lastFocus:InteractiveObject;
private var lastAction:String;
public function FocusManager(_arg1:DisplayObjectContainer){
activated = false;
calculateCandidates = true;
_showFocusIndicator = true;
_defaultButtonEnabled = true;
super();
focusableObjects = new Dictionary(true);
if (_arg1 != null){
_form = _arg1;
addFocusables(DisplayObject(_arg1));
_arg1.addEventListener(Event.ADDED, addedHandler);
_arg1.addEventListener(Event.REMOVED, removedHandler);
activate();
};
}
public function get showFocusIndicator():Boolean{
return (_showFocusIndicator);
}
private function getIndexOfNextObject(_arg1:int, _arg2:Boolean, _arg3:Boolean, _arg4:String):int{
var _local5:int;
var _local6:int;
var _local7:DisplayObject;
var _local8:IFocusManagerGroup;
var _local9:int;
var _local10:DisplayObject;
var _local11:IFocusManagerGroup;
_local5 = focusableCandidates.length;
_local6 = _arg1;
while (true) {
if (_arg2){
_arg1--;
} else {
_arg1++;
};
if (_arg3){
if (((_arg2) && ((_arg1 < 0)))){
break;
};
if (((!(_arg2)) && ((_arg1 == _local5)))){
break;
};
} else {
_arg1 = ((_arg1 + _local5) % _local5);
if (_local6 == _arg1){
break;
};
};
if (isValidFocusCandidate(focusableCandidates[_arg1], _arg4)){
_local7 = DisplayObject(findFocusManagerComponent(focusableCandidates[_arg1]));
if ((_local7 is IFocusManagerGroup)){
_local8 = IFocusManagerGroup(_local7);
_local9 = 0;
while (_local9 < focusableCandidates.length) {
_local10 = focusableCandidates[_local9];
if ((_local10 is IFocusManagerGroup)){
_local11 = IFocusManagerGroup(_local10);
if ((((_local11.groupName == _local8.groupName)) && (_local11.selected))){
_arg1 = _local9;
break;
};
};
_local9++;
};
};
return (_arg1);
};
};
return (_arg1);
}
public function set form(_arg1:DisplayObjectContainer):void{
_form = _arg1;
}
private function addFocusables(_arg1:DisplayObject, _arg2:Boolean=false):void{
var focusable:IFocusManagerComponent;
var io:InteractiveObject;
var doc:DisplayObjectContainer;
var i:int;
var child:DisplayObject;
var o = _arg1;
var skipTopLevel = _arg2;
if (!skipTopLevel){
if ((o is IFocusManagerComponent)){
focusable = IFocusManagerComponent(o);
if (focusable.focusEnabled){
if (((focusable.tabEnabled) && (isTabVisible(o)))){
focusableObjects[o] = true;
calculateCandidates = true;
};
o.addEventListener(Event.TAB_ENABLED_CHANGE, tabEnabledChangeHandler);
o.addEventListener(Event.TAB_INDEX_CHANGE, tabIndexChangeHandler);
};
} else {
if ((o is InteractiveObject)){
io = (o as InteractiveObject);
if (((((io) && (io.tabEnabled))) && ((findFocusManagerComponent(io) == io)))){
focusableObjects[io] = true;
calculateCandidates = true;
};
io.addEventListener(Event.TAB_ENABLED_CHANGE, tabEnabledChangeHandler);
io.addEventListener(Event.TAB_INDEX_CHANGE, tabIndexChangeHandler);
};
};
};
if ((o is DisplayObjectContainer)){
doc = DisplayObjectContainer(o);
o.addEventListener(Event.TAB_CHILDREN_CHANGE, tabChildrenChangeHandler);
if ((((((doc is Stage)) || ((doc.parent is Stage)))) || (doc.tabChildren))){
i = 0;
while (i < doc.numChildren) {
try {
child = doc.getChildAt(i);
if (child != null){
addFocusables(doc.getChildAt(i));
};
} catch(error:SecurityError) {
};
i = (i + 1);
};
};
};
}
private function getChildIndex(_arg1:DisplayObjectContainer, _arg2:DisplayObject):int{
return (_arg1.getChildIndex(_arg2));
}
private function mouseFocusChangeHandler(_arg1:FocusEvent):void{
if ((_arg1.relatedObject is TextField)){
return;
};
_arg1.preventDefault();
}
private function focusOutHandler(_arg1:FocusEvent):void{
var _local2:InteractiveObject;
_local2 = (_arg1.target as InteractiveObject);
}
private function isValidFocusCandidate(_arg1:DisplayObject, _arg2:String):Boolean{
var _local3:IFocusManagerGroup;
if (!isEnabledAndVisible(_arg1)){
return (false);
};
if ((_arg1 is IFocusManagerGroup)){
_local3 = IFocusManagerGroup(_arg1);
if (_arg2 == _local3.groupName){
return (false);
};
};
return (true);
}
public function findFocusManagerComponent(_arg1:InteractiveObject):InteractiveObject{
var _local2:InteractiveObject;
_local2 = _arg1;
while (_arg1) {
if ((((_arg1 is IFocusManagerComponent)) && (IFocusManagerComponent(_arg1).focusEnabled))){
return (_arg1);
};
_arg1 = _arg1.parent;
};
return (_local2);
}
private function sortFocusableObjectsTabIndex():void{
var _local1:Object;
var _local2:InteractiveObject;
focusableCandidates = [];
for (_local1 in focusableObjects) {
_local2 = InteractiveObject(_local1);
if (((_local2.tabIndex) && (!(isNaN(Number(_local2.tabIndex)))))){
focusableCandidates.push(_local2);
};
};
focusableCandidates.sort(sortByTabIndex);
}
private function removeFocusables(_arg1:DisplayObject):void{
var _local2:Object;
var _local3:DisplayObject;
if ((_arg1 is DisplayObjectContainer)){
_arg1.removeEventListener(Event.TAB_CHILDREN_CHANGE, tabChildrenChangeHandler);
_arg1.removeEventListener(Event.TAB_INDEX_CHANGE, tabIndexChangeHandler);
for (_local2 in focusableObjects) {
_local3 = DisplayObject(_local2);
if (DisplayObjectContainer(_arg1).contains(_local3)){
if (_local3 == lastFocus){
lastFocus = null;
};
_local3.removeEventListener(Event.TAB_ENABLED_CHANGE, tabEnabledChangeHandler);
delete focusableObjects[_local2];
calculateCandidates = true;
};
};
};
}
private function addedHandler(_arg1:Event):void{
var _local2:DisplayObject;
_local2 = DisplayObject(_arg1.target);
if (_local2.stage){
addFocusables(DisplayObject(_arg1.target));
};
}
private function getTopLevelFocusTarget(_arg1:InteractiveObject):InteractiveObject{
while (_arg1 != InteractiveObject(form)) {
if ((((((((_arg1 is IFocusManagerComponent)) && (IFocusManagerComponent(_arg1).focusEnabled))) && (IFocusManagerComponent(_arg1).mouseFocusEnabled))) && (UIComponent(_arg1).enabled))){
return (_arg1);
};
_arg1 = _arg1.parent;
if (_arg1 == null){
break;
};
};
return (null);
}
private function tabChildrenChangeHandler(_arg1:Event):void{
var _local2:DisplayObjectContainer;
if (_arg1.target != _arg1.currentTarget){
return;
};
calculateCandidates = true;
_local2 = DisplayObjectContainer(_arg1.target);
if (_local2.tabChildren){
addFocusables(_local2, true);
} else {
removeFocusables(_local2);
};
}
public function sendDefaultButtonEvent():void{
defButton.dispatchEvent(new MouseEvent(MouseEvent.CLICK));
}
public function getFocus():InteractiveObject{
var _local1:InteractiveObject;
_local1 = form.stage.focus;
return (findFocusManagerComponent(_local1));
}
private function isEnabledAndVisible(_arg1:DisplayObject):Boolean{
var _local2:DisplayObjectContainer;
var _local3:TextField;
var _local4:SimpleButton;
_local2 = DisplayObject(form).parent;
while (_arg1 != _local2) {
if ((_arg1 is UIComponent)){
if (!UIComponent(_arg1).enabled){
return (false);
};
} else {
if ((_arg1 is TextField)){
_local3 = TextField(_arg1);
if ((((_local3.type == TextFieldType.DYNAMIC)) || (!(_local3.selectable)))){
return (false);
};
} else {
if ((_arg1 is SimpleButton)){
_local4 = SimpleButton(_arg1);
if (!_local4.enabled){
return (false);
};
};
};
};
if (!_arg1.visible){
return (false);
};
_arg1 = _arg1.parent;
};
return (true);
}
public function set defaultButton(_arg1:Button):void{
var _local2:Button;
_local2 = (_arg1) ? Button(_arg1) : null;
if (_local2 != _defaultButton){
if (_defaultButton){
_defaultButton.emphasized = false;
};
if (defButton){
defButton.emphasized = false;
};
_defaultButton = _local2;
defButton = _local2;
if (_local2){
_local2.emphasized = true;
};
};
}
private function deactivateHandler(_arg1:Event):void{
var _local2:InteractiveObject;
_local2 = InteractiveObject(_arg1.target);
}
public function setFocus(_arg1:InteractiveObject):void{
if ((_arg1 is IFocusManagerComponent)){
IFocusManagerComponent(_arg1).setFocus();
} else {
form.stage.focus = _arg1;
};
}
private function setFocusToNextObject(_arg1:FocusEvent):void{
var _local2:InteractiveObject;
if (!hasFocusableObjects()){
return;
};
_local2 = getNextFocusManagerComponent(_arg1.shiftKey);
if (_local2){
setFocus(_local2);
};
}
private function hasFocusableObjects():Boolean{
var _local1:Object;
for (_local1 in focusableObjects) {
return (true);
};
return (false);
}
private function tabIndexChangeHandler(_arg1:Event):void{
calculateCandidates = true;
}
private function sortFocusableObjects():void{
var _local1:Object;
var _local2:InteractiveObject;
focusableCandidates = [];
for (_local1 in focusableObjects) {
_local2 = InteractiveObject(_local1);
if (((((_local2.tabIndex) && (!(isNaN(Number(_local2.tabIndex)))))) && ((_local2.tabIndex > 0)))){
sortFocusableObjectsTabIndex();
return;
};
focusableCandidates.push(_local2);
};
focusableCandidates.sort(sortByDepth);
}
private function keyFocusChangeHandler(_arg1:FocusEvent):void{
showFocusIndicator = true;
if ((((((_arg1.keyCode == Keyboard.TAB)) || ((_arg1.keyCode == 0)))) && (!(_arg1.isDefaultPrevented())))){
setFocusToNextObject(_arg1);
_arg1.preventDefault();
};
}
private function getIndexOfFocusedObject(_arg1:DisplayObject):int{
var _local2:int;
var _local3:int;
_local2 = focusableCandidates.length;
_local3 = 0;
_local3 = 0;
while (_local3 < _local2) {
if (focusableCandidates[_local3] == _arg1){
return (_local3);
};
_local3++;
};
return (-1);
}
public function hideFocus():void{
}
private function removedHandler(_arg1:Event):void{
var _local2:int;
var _local3:DisplayObject;
var _local4:InteractiveObject;
_local3 = DisplayObject(_arg1.target);
if ((((_local3 is IFocusManagerComponent)) && ((focusableObjects[_local3] == true)))){
if (_local3 == lastFocus){
IFocusManagerComponent(lastFocus).drawFocus(false);
lastFocus = null;
};
_local3.removeEventListener(Event.TAB_ENABLED_CHANGE, tabEnabledChangeHandler);
delete focusableObjects[_local3];
calculateCandidates = true;
} else {
if ((((_local3 is InteractiveObject)) && ((focusableObjects[_local3] == true)))){
_local4 = (_local3 as InteractiveObject);
if (_local4){
if (_local4 == lastFocus){
lastFocus = null;
};
delete focusableObjects[_local4];
calculateCandidates = true;
};
_local3.addEventListener(Event.TAB_ENABLED_CHANGE, tabEnabledChangeHandler);
};
};
removeFocusables(_local3);
}
private function sortByDepth(_arg1:InteractiveObject, _arg2:InteractiveObject):Number{
var _local3:String;
var _local4:String;
var _local5:int;
var _local6:String;
var _local7:String;
var _local8:String;
var _local9:DisplayObject;
var _local10:DisplayObject;
_local3 = "";
_local4 = "";
_local8 = "0000";
_local9 = DisplayObject(_arg1);
_local10 = DisplayObject(_arg2);
while (((!((_local9 == DisplayObject(form)))) && (_local9.parent))) {
_local5 = getChildIndex(_local9.parent, _local9);
_local6 = _local5.toString(16);
if (_local6.length < 4){
_local7 = (_local8.substring(0, (4 - _local6.length)) + _local6);
};
_local3 = (_local7 + _local3);
_local9 = _local9.parent;
};
while (((!((_local10 == DisplayObject(form)))) && (_local10.parent))) {
_local5 = getChildIndex(_local10.parent, _local10);
_local6 = _local5.toString(16);
if (_local6.length < 4){
_local7 = (_local8.substring(0, (4 - _local6.length)) + _local6);
};
_local4 = (_local7 + _local4);
_local10 = _local10.parent;
};
return (((_local3 > _local4)) ? 1 : ((_local3 < _local4)) ? -1 : 0);
}
public function get defaultButton():Button{
return (_defaultButton);
}
private function activateHandler(_arg1:Event):void{
var _local2:InteractiveObject;
_local2 = InteractiveObject(_arg1.target);
if (lastFocus){
if ((lastFocus is IFocusManagerComponent)){
IFocusManagerComponent(lastFocus).setFocus();
} else {
form.stage.focus = lastFocus;
};
};
lastAction = "ACTIVATE";
}
public function showFocus():void{
}
public function set defaultButtonEnabled(_arg1:Boolean):void{
_defaultButtonEnabled = _arg1;
}
public function getNextFocusManagerComponent(_arg1:Boolean=false):InteractiveObject{
var _local2:DisplayObject;
var _local3:String;
var _local4:int;
var _local5:Boolean;
var _local6:int;
var _local7:int;
var _local8:IFocusManagerGroup;
if (!hasFocusableObjects()){
return (null);
};
if (calculateCandidates){
sortFocusableObjects();
calculateCandidates = false;
};
_local2 = form.stage.focus;
_local2 = DisplayObject(findFocusManagerComponent(InteractiveObject(_local2)));
_local3 = "";
if ((_local2 is IFocusManagerGroup)){
_local8 = IFocusManagerGroup(_local2);
_local3 = _local8.groupName;
};
_local4 = getIndexOfFocusedObject(_local2);
_local5 = false;
_local6 = _local4;
if (_local4 == -1){
if (_arg1){
_local4 = focusableCandidates.length;
};
_local5 = true;
};
_local7 = getIndexOfNextObject(_local4, _arg1, _local5, _local3);
return (findFocusManagerComponent(focusableCandidates[_local7]));
}
private function mouseDownHandler(_arg1:MouseEvent):void{
var _local2:InteractiveObject;
if (_arg1.isDefaultPrevented()){
return;
};
_local2 = getTopLevelFocusTarget(InteractiveObject(_arg1.target));
if (!_local2){
return;
};
showFocusIndicator = false;
if (((((!((_local2 == lastFocus))) || ((lastAction == "ACTIVATE")))) && (!((_local2 is TextField))))){
setFocus(_local2);
};
lastAction = "MOUSEDOWN";
}
private function isTabVisible(_arg1:DisplayObject):Boolean{
var _local2:DisplayObjectContainer;
_local2 = _arg1.parent;
while (((((_local2) && (!((_local2 is Stage))))) && (!(((_local2.parent) && ((_local2.parent is Stage))))))) {
if (!_local2.tabChildren){
return (false);
};
_local2 = _local2.parent;
};
return (true);
}
public function get nextTabIndex():int{
return (0);
}
private function keyDownHandler(_arg1:KeyboardEvent):void{
if (_arg1.keyCode == Keyboard.TAB){
lastAction = "KEY";
if (calculateCandidates){
sortFocusableObjects();
calculateCandidates = false;
};
};
if (((((((defaultButtonEnabled) && ((_arg1.keyCode == Keyboard.ENTER)))) && (defaultButton))) && (defButton.enabled))){
sendDefaultButtonEvent();
};
}
private function focusInHandler(_arg1:FocusEvent):void{
var _local2:InteractiveObject;
var _local3:Button;
_local2 = InteractiveObject(_arg1.target);
if (form.contains(_local2)){
lastFocus = findFocusManagerComponent(InteractiveObject(_local2));
if ((lastFocus is Button)){
_local3 = Button(lastFocus);
if (defButton){
defButton.emphasized = false;
defButton = _local3;
_local3.emphasized = true;
};
} else {
if (((defButton) && (!((defButton == _defaultButton))))){
defButton.emphasized = false;
defButton = _defaultButton;
_defaultButton.emphasized = true;
};
};
};
}
private function tabEnabledChangeHandler(_arg1:Event):void{
var _local2:InteractiveObject;
var _local3:Boolean;
calculateCandidates = true;
_local2 = InteractiveObject(_arg1.target);
_local3 = (focusableObjects[_local2] == true);
if (_local2.tabEnabled){
if (((!(_local3)) && (isTabVisible(_local2)))){
if (!(_local2 is IFocusManagerComponent)){
_local2.focusRect = false;
};
focusableObjects[_local2] = true;
};
} else {
if (_local3){
delete focusableObjects[_local2];
};
};
}
public function set showFocusIndicator(_arg1:Boolean):void{
_showFocusIndicator = _arg1;
}
public function get form():DisplayObjectContainer{
return (_form);
}
private function sortByTabIndex(_arg1:InteractiveObject, _arg2:InteractiveObject):int{
return (((_arg1.tabIndex > _arg2.tabIndex)) ? 1 : ((_arg1.tabIndex < _arg2.tabIndex)) ? -1 : sortByDepth(_arg1, _arg2));
}
public function activate():void{
if (activated){
return;
};
form.stage.addEventListener(FocusEvent.MOUSE_FOCUS_CHANGE, mouseFocusChangeHandler, false, 0, true);
form.stage.addEventListener(FocusEvent.KEY_FOCUS_CHANGE, keyFocusChangeHandler, false, 0, true);
form.addEventListener(FocusEvent.FOCUS_IN, focusInHandler, true);
form.addEventListener(FocusEvent.FOCUS_OUT, focusOutHandler, true);
form.stage.addEventListener(Event.ACTIVATE, activateHandler, false, 0, true);
form.stage.addEventListener(Event.DEACTIVATE, deactivateHandler, false, 0, true);
form.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
form.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler, true);
activated = true;
if (lastFocus){
setFocus(lastFocus);
};
}
public function deactivate():void{
form.stage.removeEventListener(FocusEvent.MOUSE_FOCUS_CHANGE, mouseFocusChangeHandler);
form.stage.removeEventListener(FocusEvent.KEY_FOCUS_CHANGE, keyFocusChangeHandler);
form.removeEventListener(FocusEvent.FOCUS_IN, focusInHandler, true);
form.removeEventListener(FocusEvent.FOCUS_OUT, focusOutHandler, true);
form.stage.removeEventListener(Event.ACTIVATE, activateHandler);
form.stage.removeEventListener(Event.DEACTIVATE, deactivateHandler);
form.removeEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
form.removeEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler, true);
activated = false;
}
public function get defaultButtonEnabled():Boolean{
return (_defaultButtonEnabled);
}
}
}//package fl.managers
Section 167
//IFocusManager (fl.managers.IFocusManager)
package fl.managers {
import fl.controls.*;
import flash.display.*;
public interface IFocusManager {
function getFocus():InteractiveObject;
function deactivate():void;
function set defaultButton(_arg1:Button):void;
function set showFocusIndicator(_arg1:Boolean):void;
function get defaultButtonEnabled():Boolean;
function get nextTabIndex():int;
function get defaultButton():Button;
function get showFocusIndicator():Boolean;
function setFocus(_arg1:InteractiveObject):void;
function activate():void;
function showFocus():void;
function set defaultButtonEnabled(_arg1:Boolean):void;
function hideFocus():void;
function findFocusManagerComponent(_arg1:InteractiveObject):InteractiveObject;
function getNextFocusManagerComponent(_arg1:Boolean=false):InteractiveObject;
}
}//package fl.managers
Section 168
//IFocusManagerComponent (fl.managers.IFocusManagerComponent)
package fl.managers {
public interface IFocusManagerComponent {
function set focusEnabled(_arg1:Boolean):void;
function drawFocus(_arg1:Boolean):void;
function setFocus():void;
function get focusEnabled():Boolean;
function get tabEnabled():Boolean;
function get tabIndex():int;
function get mouseFocusEnabled():Boolean;
}
}//package fl.managers
Section 169
//IFocusManagerGroup (fl.managers.IFocusManagerGroup)
package fl.managers {
public interface IFocusManagerGroup {
function set groupName(_arg1:String):void;
function set selected(_arg1:Boolean):void;
function get groupName():String;
function get selected():Boolean;
}
}//package fl.managers
Section 170
//StyleManager (fl.managers.StyleManager)
package fl.managers {
import fl.core.*;
import flash.utils.*;
import flash.text.*;
public class StyleManager {
private var globalStyles:Object;
private var classToDefaultStylesDict:Dictionary;
private var styleToClassesHash:Object;
private var classToStylesDict:Dictionary;
private var classToInstancesDict:Dictionary;
private static var _instance:StyleManager;
public function StyleManager(){
styleToClassesHash = {};
classToInstancesDict = new Dictionary(true);
classToStylesDict = new Dictionary(true);
classToDefaultStylesDict = new Dictionary(true);
globalStyles = UIComponent.getStyleDefinition();
}
public static function clearComponentStyle(_arg1:Object, _arg2:String):void{
var _local3:Class;
var _local4:Object;
_local3 = getClassDef(_arg1);
_local4 = getInstance().classToStylesDict[_local3];
if (((!((_local4 == null))) && (!((_local4[_arg2] == null))))){
delete _local4[_arg2];
invalidateComponentStyle(_local3, _arg2);
};
}
private static function getClassDef(_arg1:Object):Class{
var component = _arg1;
if ((component is Class)){
return ((component as Class));
};
try {
return ((getDefinitionByName(getQualifiedClassName(component)) as Class));
} catch(e:Error) {
if ((component is UIComponent)){
try {
return ((component.loaderInfo.applicationDomain.getDefinition(getQualifiedClassName(component)) as Class));
} catch(e:Error) {
};
};
};
return (null);
}
public static function clearStyle(_arg1:String):void{
setStyle(_arg1, null);
}
public static function setComponentStyle(_arg1:Object, _arg2:String, _arg3:Object):void{
var _local4:Class;
var _local5:Object;
_local4 = getClassDef(_arg1);
_local5 = getInstance().classToStylesDict[_local4];
if (_local5 == null){
_local5 = (getInstance().classToStylesDict[_local4] = {});
};
if (_local5 == _arg3){
return;
};
_local5[_arg2] = _arg3;
invalidateComponentStyle(_local4, _arg2);
}
private static function setSharedStyles(_arg1:UIComponent):void{
var _local2:StyleManager;
var _local3:Class;
var _local4:Object;
var _local5:String;
_local2 = getInstance();
_local3 = getClassDef(_arg1);
_local4 = _local2.classToDefaultStylesDict[_local3];
for (_local5 in _local4) {
_arg1.setSharedStyle(_local5, getSharedStyle(_arg1, _local5));
};
}
public static function getComponentStyle(_arg1:Object, _arg2:String):Object{
var _local3:Class;
var _local4:Object;
_local3 = getClassDef(_arg1);
_local4 = getInstance().classToStylesDict[_local3];
return (((_local4)==null) ? null : _local4[_arg2]);
}
private static function getInstance(){
if (_instance == null){
_instance = new (StyleManager);
};
return (_instance);
}
private static function invalidateComponentStyle(_arg1:Class, _arg2:String):void{
var _local3:Dictionary;
var _local4:Object;
var _local5:UIComponent;
_local3 = getInstance().classToInstancesDict[_arg1];
if (_local3 == null){
return;
};
for (_local4 in _local3) {
_local5 = (_local4 as UIComponent);
if (_local5 == null){
} else {
_local5.setSharedStyle(_arg2, getSharedStyle(_local5, _arg2));
};
};
}
private static function invalidateStyle(_arg1:String):void{
var _local2:Dictionary;
var _local3:Object;
_local2 = getInstance().styleToClassesHash[_arg1];
if (_local2 == null){
return;
};
for (_local3 in _local2) {
invalidateComponentStyle(Class(_local3), _arg1);
};
}
public static function registerInstance(_arg1:UIComponent):void{
var inst:StyleManager;
var classDef:Class;
var target:Class;
var defaultStyles:Object;
var styleToClasses:Object;
var n:String;
var instance = _arg1;
inst = getInstance();
classDef = getClassDef(instance);
if (classDef == null){
return;
};
if (inst.classToInstancesDict[classDef] == null){
inst.classToInstancesDict[classDef] = new Dictionary(true);
target = classDef;
while (defaultStyles == null) {
if (target["getStyleDefinition"] != null){
defaultStyles = target["getStyleDefinition"]();
break;
};
try {
target = (instance.loaderInfo.applicationDomain.getDefinition(getQualifiedSuperclassName(target)) as Class);
} catch(err:Error) {
try {
target = (getDefinitionByName(getQualifiedSuperclassName(target)) as Class);
} catch(e:Error) {
defaultStyles = UIComponent.getStyleDefinition();
break;
};
};
};
styleToClasses = inst.styleToClassesHash;
for (n in defaultStyles) {
if (styleToClasses[n] == null){
styleToClasses[n] = new Dictionary(true);
};
styleToClasses[n][classDef] = true;
};
inst.classToDefaultStylesDict[classDef] = defaultStyles;
inst.classToStylesDict[classDef] = {};
};
inst.classToInstancesDict[classDef][instance] = true;
setSharedStyles(instance);
}
public static function getStyle(_arg1:String):Object{
return (getInstance().globalStyles[_arg1]);
}
private static function getSharedStyle(_arg1:UIComponent, _arg2:String):Object{
var _local3:Class;
var _local4:StyleManager;
var _local5:Object;
_local3 = getClassDef(_arg1);
_local4 = getInstance();
_local5 = _local4.classToStylesDict[_local3][_arg2];
if (_local5 != null){
return (_local5);
};
_local5 = _local4.globalStyles[_arg2];
if (_local5 != null){
return (_local5);
};
return (_local4.classToDefaultStylesDict[_local3][_arg2]);
}
public static function setStyle(_arg1:String, _arg2:Object):void{
var _local3:Object;
_local3 = getInstance().globalStyles;
if ((((_local3[_arg1] === _arg2)) && (!((_arg2 is TextFormat))))){
return;
};
_local3[_arg1] = _arg2;
invalidateStyle(_arg1);
}
}
}//package fl.managers
Section 171
//aaaa_1 (kwido_fla.aaaa_1)
package kwido_fla {
import flash.display.*;
import flash.net.*;
public dynamic class aaaa_1 extends MovieClip {
public var req2:URLRequest;
public var req1:URLRequest;
public function aaaa_1(){
addFrameScript(0, frame1);
}
function frame1(){
req2 = new URLRequest("http://www.pulsarr.com");
req1 = new URLRequest("http://www.pixzor.com");
}
}
}//package kwido_fla
Section 172
//flashgames1_21 (kwido_fla.flashgames1_21)
package kwido_fla {
import flash.display.*;
public dynamic class flashgames1_21 extends MovieClip {
public function flashgames1_21(){
addFrameScript(52, frame53);
}
function frame53(){
stop();
}
}
}//package kwido_fla
Section 173
//intro1_16 (kwido_fla.intro1_16)
package kwido_fla {
import flash.display.*;
public dynamic class intro1_16 extends MovieClip {
public function intro1_16(){
addFrameScript(71, frame72);
}
function frame72(){
stop();
}
}
}//package kwido_fla
Section 174
//logo1_18 (kwido_fla.logo1_18)
package kwido_fla {
import flash.display.*;
public dynamic class logo1_18 extends MovieClip {
public function logo1_18(){
addFrameScript(47, frame48);
}
function frame48(){
stop();
}
}
}//package kwido_fla
Section 175
//logo2_20 (kwido_fla.logo2_20)
package kwido_fla {
import flash.display.*;
public dynamic class logo2_20 extends MovieClip {
public function logo2_20(){
addFrameScript(29, frame30);
}
function frame30(){
stop();
}
}
}//package kwido_fla
Section 176
//star1_19 (kwido_fla.star1_19)
package kwido_fla {
import flash.display.*;
public dynamic class star1_19 extends MovieClip {
public function star1_19(){
addFrameScript(45, frame46);
}
function frame46(){
stop();
}
}
}//package kwido_fla
Section 177
//MochiCoins (mochi.as3.MochiCoins)
package mochi.as3 {
public class MochiCoins {
public static const STORE_SHOW:String = "StoreShow";
public static const STORE_HIDE:String = "StoreHide";
public static const ITEM_OWNED:String = "ItemOwned";
public static const ITEM_NEW:String = "ItemNew";
public static const STORE_ITEMS:String = "StoreItems";
public static const ERROR:String = "Error";
public static const IO_ERROR:String = "IOError";
public static const NO_USER:String = "NoUser";
public static var _inventory:MochiInventory;
public static function get inventory():MochiInventory{
return (_inventory);
}
public static function getVersion():String{
return (MochiServices.getVersion());
}
public static function showStore(_arg1:Object=null):void{
MochiServices.bringToTop();
MochiServices.send("coins_showStore", {options:_arg1}, null, null);
}
public static function showItem(_arg1:Object=null):void{
if (((!(_arg1)) || (!((typeof(_arg1.item) == "string"))))){
trace("ERROR: showItem call must pass an Object with an item key");
return;
};
MochiServices.bringToTop();
MochiServices.send("coins_showItem", {options:_arg1}, null, null);
}
public static function showVideo(_arg1:Object=null):void{
if (((!(_arg1)) || (!((typeof(_arg1.item) == "string"))))){
trace("ERROR: showVideo call must pass an Object with an item key");
return;
};
MochiServices.bringToTop();
MochiServices.send("coins_showVideo", {options:_arg1}, null, null);
}
public static function getStoreItems():void{
MochiServices.send("coins_getStoreItems");
}
public static function addEventListener(_arg1:String, _arg2:Function):void{
MochiSocial.addEventListener(_arg1, _arg2);
}
public static function triggerEvent(_arg1:String, _arg2:Object):void{
MochiSocial.triggerEvent(_arg1, _arg2);
}
public static function removeEventListener(_arg1:String, _arg2:Function):void{
MochiSocial.removeEventListener(_arg1, _arg2);
}
MochiSocial.addEventListener(MochiSocial.LOGGED_IN, function (_arg1:Object):void{
_inventory = new MochiInventory();
});
MochiSocial.addEventListener(MochiSocial.LOGGED_OUT, function (_arg1:Object):void{
_inventory = null;
});
}
}//package mochi.as3
Section 178
//MochiDigits (mochi.as3.MochiDigits)
package mochi.as3 {
public final class MochiDigits {
private var Fragment:Number;
private var Sibling:MochiDigits;
private var Encoder:Number;
public function MochiDigits(_arg1:Number=0, _arg2:uint=0):void{
Encoder = 0;
setValue(_arg1, _arg2);
}
public function get value():Number{
return (Number(this.toString()));
}
public function set value(_arg1:Number):void{
setValue(_arg1);
}
public function addValue(_arg1:Number):void{
value = (value + _arg1);
}
public function setValue(_arg1:Number=0, _arg2:uint=0):void{
var _local3:String = _arg1.toString();
var _temp1 = _arg2;
_arg2 = (_arg2 + 1);
Fragment = (_local3.charCodeAt(_temp1) ^ Encoder);
if (_arg2 < _local3.length){
Sibling = new MochiDigits(_arg1, _arg2);
} else {
Sibling = null;
};
reencode();
}
public function reencode():void{
var _local1:uint = int((2147483647 * Math.random()));
Fragment = (Fragment ^ (_local1 ^ Encoder));
Encoder = _local1;
}
public function toString():String{
var _local1:String = String.fromCharCode((Fragment ^ Encoder));
if (Sibling != null){
_local1 = (_local1 + Sibling.toString());
};
return (_local1);
}
}
}//package mochi.as3
Section 179
//MochiEventDispatcher (mochi.as3.MochiEventDispatcher)
package mochi.as3 {
public class MochiEventDispatcher {
private var eventTable:Object;
public function MochiEventDispatcher():void{
eventTable = {};
}
public function addEventListener(_arg1:String, _arg2:Function):void{
removeEventListener(_arg1, _arg2);
eventTable[_arg1].push(_arg2);
}
public function removeEventListener(_arg1:String, _arg2:Function):void{
var _local3:Object;
if (eventTable[_arg1] == undefined){
eventTable[_arg1] = [];
return;
};
for (_local3 in eventTable[_arg1]) {
if (eventTable[_arg1][_local3] != _arg2){
} else {
eventTable[_arg1].splice(Number(_local3), 1);
};
};
}
public function triggerEvent(_arg1:String, _arg2:Object):void{
var _local3:Object;
if (eventTable[_arg1] == undefined){
return;
};
for (_local3 in eventTable[_arg1]) {
var _local6 = eventTable[_arg1];
_local6[_local3](_arg2);
};
}
}
}//package mochi.as3
Section 180
//MochiEvents (mochi.as3.MochiEvents)
package mochi.as3 {
import flash.display.*;
public class MochiEvents {
public static const ACHIEVEMENT_RECEIVED:String = "AchievementReceived";
public static const ALIGN_TOP_LEFT:String = "ALIGN_TL";
public static const ALIGN_TOP:String = "ALIGN_T";
public static const ALIGN_TOP_RIGHT:String = "ALIGN_TR";
public static const ALIGN_LEFT:String = "ALIGN_L";
public static const ALIGN_CENTER:String = "ALIGN_C";
public static const ALIGN_RIGHT:String = "ALIGN_R";
public static const ALIGN_BOTTOM_LEFT:String = "ALIGN_BL";
public static const ALIGN_BOTTOM:String = "ALIGN_B";
public static const ALIGN_BOTTOM_RIGHT:String = "ALIGN_BR";
public static const FORMAT_SHORT:String = "ShortForm";
public static const FORMAT_LONG:String = "LongForm";
private static var gameStart:Number;
private static var levelStart:Number;
private static var _dispatcher:MochiEventDispatcher = new MochiEventDispatcher();
public static function getVersion():String{
return (MochiServices.getVersion());
}
public static function startSession(_arg1:String):void{
MochiServices.send("events_beginSession", {achievementID:_arg1}, null, null);
}
public static function setNotifications(_arg1:MovieClip, _arg2:Object):void{
var _local4:Object;
var _local3:Object = {};
for (_local4 in _arg2) {
_local3[_local4] = _arg2[_local4];
};
_local3.clip = _arg1;
MochiServices.send("events_setNotifications", _local3, null, null);
}
public static function addEventListener(_arg1:String, _arg2:Function):void{
_dispatcher.addEventListener(_arg1, _arg2);
}
public static function triggerEvent(_arg1:String, _arg2:Object):void{
_dispatcher.triggerEvent(_arg1, _arg2);
}
public static function removeEventListener(_arg1:String, _arg2:Function):void{
_dispatcher.removeEventListener(_arg1, _arg2);
}
public static function startPlay(_arg1:String="gameplay"):void{
MochiServices.send("events_setRoundID", {tag:String(_arg1)}, null, null);
}
public static function endPlay():void{
MochiServices.send("events_clearRoundID", null, null, null);
}
public static function trackEvent(_arg1:String, _arg2=null):void{
MochiServices.send("events_trackEvent", {tag:_arg1, value:_arg2}, null, null);
}
}
}//package mochi.as3
Section 181
//MochiInventory (mochi.as3.MochiInventory)
package mochi.as3 {
import flash.events.*;
import flash.utils.*;
public dynamic class MochiInventory extends Proxy {
private var _timer:Timer;
private var _consumableProperties:Object;
private var _syncPending:Boolean;
private var _outstandingID:Number;
private var _syncID:Number;
private var _names:Array;
private var _storeSync:Object;
private static const CONSUMER_KEY:String = "MochiConsumables";
private static const KEY_SALT:String = " syncMaint";
public static const READY:String = "InvReady";
public static const WRITTEN:String = "InvWritten";
public static const ERROR:String = "Error";
public static const IO_ERROR:String = "IoError";
public static const VALUE_ERROR:String = "InvValueError";
public static const NOT_READY:String = "InvNotReady";
private static var _dispatcher:MochiEventDispatcher = new MochiEventDispatcher();
public function MochiInventory():void{
MochiCoins.addEventListener(MochiCoins.ITEM_OWNED, itemOwned);
MochiCoins.addEventListener(MochiCoins.ITEM_NEW, newItems);
MochiSocial.addEventListener(MochiSocial.LOGGED_IN, loggedIn);
MochiSocial.addEventListener(MochiSocial.LOGGED_OUT, loggedOut);
_storeSync = new Object();
_syncPending = false;
_outstandingID = 0;
_syncID = 0;
_timer = new Timer(1000);
_timer.addEventListener(TimerEvent.TIMER, sync);
_timer.start();
if (MochiSocial.loggedIn){
loggedIn();
} else {
loggedOut();
};
}
public function release():void{
MochiCoins.removeEventListener(MochiCoins.ITEM_NEW, newItems);
MochiSocial.removeEventListener(MochiSocial.LOGGED_IN, loggedIn);
MochiSocial.removeEventListener(MochiSocial.LOGGED_OUT, loggedOut);
}
private function loggedOut(_arg1:Object=null):void{
_consumableProperties = null;
}
private function loggedIn(_arg1:Object=null):void{
MochiUserData.get(CONSUMER_KEY, getConsumableBag);
}
private function newItems(_arg1:Object):void{
if (!this[(_arg1.id + KEY_SALT)]){
this[(_arg1.id + KEY_SALT)] = 0;
};
if (!this[_arg1.id]){
this[_arg1.id] = 0;
};
this[(_arg1.id + KEY_SALT)] = (this[(_arg1.id + KEY_SALT)] + _arg1.count);
this[_arg1.id] = (this[_arg1.id] + _arg1.count);
if (_arg1.privateProperties.consumable){
if (!this[_arg1.privateProperties.tag]){
this[_arg1.privateProperties.tag] = 0;
};
this[_arg1.privateProperties.tag] = (this[_arg1.privateProperties.tag] + (_arg1.privateProperties.inc * _arg1.count));
};
}
private function itemOwned(_arg1:Object):void{
_storeSync[_arg1.id] = {properties:_arg1.properties, count:_arg1.count};
}
private function getConsumableBag(_arg1:MochiUserData):void{
var _local2:String;
var _local3:Number;
if (_arg1.error){
triggerEvent(ERROR, {type:IO_ERROR, error:_arg1.error});
return;
};
_consumableProperties = {};
_names = new Array();
if (_arg1.data){
for (_local2 in _arg1.data) {
_names.push(_local2);
_consumableProperties[_local2] = new MochiDigits(_arg1.data[_local2]);
};
};
for (_local2 in _storeSync) {
_local3 = _storeSync[_local2].count;
if (_consumableProperties[(_local2 + KEY_SALT)]){
_local3 = (_local3 - _consumableProperties[_local2]);
};
if (_local3 == 0){
} else {
newItems({id:_local2, count:_local3, properties:_storeSync[_local2].properties});
};
};
triggerEvent(READY, {});
}
private function putConsumableBag(_arg1:MochiUserData):void{
_syncPending = false;
if (_arg1.error){
triggerEvent(ERROR, {type:IO_ERROR, error:_arg1.error});
_outstandingID = -1;
};
triggerEvent(WRITTEN, {});
}
private function sync(_arg1:Event=null):void{
var _local3:String;
if (((_syncPending) || ((_syncID == _outstandingID)))){
return;
};
_outstandingID = _syncID;
var _local2:Object = {};
for (_local3 in _consumableProperties) {
_local2[_local3] = MochiDigits(_consumableProperties[_local3]).value;
};
MochiUserData.put(CONSUMER_KEY, _local2, putConsumableBag);
_syncPending = true;
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function getProperty(_arg1){
if (_consumableProperties == null){
triggerEvent(ERROR, {type:NOT_READY});
return (-1);
};
if (_consumableProperties[_arg1]){
return (MochiDigits(_consumableProperties[_arg1]).value);
};
return (undefined);
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function deleteProperty(_arg1):Boolean{
if (!_consumableProperties[_arg1]){
return (false);
};
_names.splice(_names.indexOf(_arg1), 1);
delete _consumableProperties[_arg1];
return (true);
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function hasProperty(_arg1):Boolean{
if (_consumableProperties == null){
triggerEvent(ERROR, {type:NOT_READY});
return (false);
};
if (_consumableProperties[_arg1] == undefined){
return (false);
};
return (true);
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function setProperty(_arg1, _arg2):void{
var _local3:MochiDigits;
if (_consumableProperties == null){
triggerEvent(ERROR, {type:NOT_READY});
return;
};
if (!(_arg2 is Number)){
triggerEvent(ERROR, {type:VALUE_ERROR, error:"Invalid type", arg:_arg2});
return;
};
if (_consumableProperties[_arg1]){
_local3 = MochiDigits(_consumableProperties[_arg1]);
if (_local3.value == _arg2){
return;
};
_local3.value = _arg2;
} else {
_names.push(_arg1);
_consumableProperties[_arg1] = new MochiDigits(_arg2);
};
_syncID++;
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function nextNameIndex(_arg1:int):int{
return (((_arg1)>=_names.length) ? 0 : (_arg1 + 1));
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function nextName(_arg1:int):String{
return (_names[(_arg1 - 1)]);
}
public static function addEventListener(_arg1:String, _arg2:Function):void{
_dispatcher.addEventListener(_arg1, _arg2);
}
public static function triggerEvent(_arg1:String, _arg2:Object):void{
_dispatcher.triggerEvent(_arg1, _arg2);
}
public static function removeEventListener(_arg1:String, _arg2:Function):void{
_dispatcher.removeEventListener(_arg1, _arg2);
}
}
}//package mochi.as3
Section 182
//MochiScores (mochi.as3.MochiScores)
package mochi.as3 {
import flash.display.*;
import flash.text.*;
public class MochiScores {
public static var onCloseHandler:Object;
public static var onErrorHandler:Object;
private static var boardID:String;
public static function onClose(_arg1:Object=null):void{
if (((((_arg1) && ((_arg1.error == true)))) && (onErrorHandler))){
if (_arg1.errorCode == null){
_arg1.errorCode = "IOError";
};
onErrorHandler(_arg1.errorCode);
MochiServices.doClose();
return;
};
onCloseHandler();
MochiServices.doClose();
}
public static function setBoardID(_arg1:String):void{
MochiServices.warnID(_arg1, true);
MochiScores.boardID = _arg1;
MochiServices.send("scores_setBoardID", {boardID:_arg1});
}
public static function showLeaderboard(_arg1:Object=null):void{
var n:Number;
var options = _arg1;
if (options != null){
delete options.clip;
MochiServices.setContainer();
MochiServices.bringToTop();
if (options.name != null){
if ((options.name is TextField)){
if (options.name.text.length > 0){
options.name = options.name.text;
};
};
};
if (options.score != null){
if ((options.score is TextField)){
if (options.score.text.length > 0){
options.score = options.score.text;
};
} else {
if ((options.score is MochiDigits)){
options.score = options.score.value;
};
};
n = Number(options.score);
if (isNaN(n)){
trace((("ERROR: Submitted score '" + options.score) + "' will be rejected, score is 'Not a Number'"));
} else {
if ((((n == Number.NEGATIVE_INFINITY)) || ((n == Number.POSITIVE_INFINITY)))){
trace((("ERROR: Submitted score '" + options.score) + "' will be rejected, score is an infinite"));
} else {
if (Math.floor(n) != n){
trace((("WARNING: Submitted score '" + options.score) + "' will be truncated"));
};
options.score = n;
};
};
};
if (options.onDisplay != null){
options.onDisplay();
} else {
if (MochiServices.clip != null){
if ((MochiServices.clip is MovieClip)){
MochiServices.clip.stop();
} else {
trace("Warning: Container is not a MovieClip, cannot call default onDisplay.");
};
};
};
} else {
options = {};
if ((MochiServices.clip is MovieClip)){
MochiServices.clip.stop();
} else {
trace("Warning: Container is not a MovieClip, cannot call default onDisplay.");
};
};
if (options.onClose != null){
onCloseHandler = options.onClose;
} else {
onCloseHandler = function ():void{
if ((MochiServices.clip is MovieClip)){
MochiServices.clip.play();
} else {
trace("Warning: Container is not a MovieClip, cannot call default onClose.");
};
};
};
if (options.onError != null){
onErrorHandler = options.onError;
} else {
onErrorHandler = null;
};
if (options.boardID == null){
if (MochiScores.boardID != null){
options.boardID = MochiScores.boardID;
};
};
MochiServices.warnID(options.boardID, true);
trace("[MochiScores] NOTE: Security Sandbox Violation errors below are normal");
MochiServices.send("scores_showLeaderboard", {options:options}, null, onClose);
}
public static function closeLeaderboard():void{
MochiServices.send("scores_closeLeaderboard");
}
public static function getPlayerInfo(_arg1:Object, _arg2:Object=null):void{
MochiServices.send("scores_getPlayerInfo", null, _arg1, _arg2);
}
public static function submit(_arg1:Number, _arg2:String, _arg3:Object=null, _arg4:Object=null):void{
_arg1 = Number(_arg1);
if (isNaN(_arg1)){
trace((("ERROR: Submitted score '" + String(_arg1)) + "' will be rejected, score is 'Not a Number'"));
} else {
if ((((_arg1 == Number.NEGATIVE_INFINITY)) || ((_arg1 == Number.POSITIVE_INFINITY)))){
trace((("ERROR: Submitted score '" + String(_arg1)) + "' will be rejected, score is an infinite"));
} else {
if (Math.floor(_arg1) != _arg1){
trace((("WARNING: Submitted score '" + String(_arg1)) + "' will be truncated"));
};
_arg1 = Number(_arg1);
};
};
MochiServices.send("scores_submit", {score:_arg1, name:_arg2}, _arg3, _arg4);
}
public static function requestList(_arg1:Object, _arg2:Object=null):void{
MochiServices.send("scores_requestList", null, _arg1, _arg2);
}
public static function scoresArrayToObjects(_arg1:Object):Object{
var _local3:Number;
var _local4:Number;
var _local5:Object;
var _local6:Object;
var _local7:String;
var _local8:String;
var _local2:Object = {};
for (_local7 in _arg1) {
if (typeof(_arg1[_local7]) == "object"){
if (((!((_arg1[_local7].cols == null))) && (!((_arg1[_local7].rows == null))))){
_local2[_local7] = [];
_local5 = _arg1[_local7];
_local4 = 0;
while (_local4 < _local5.rows.length) {
_local6 = {};
_local3 = 0;
while (_local3 < _local5.cols.length) {
_local6[_local5.cols[_local3]] = _local5.rows[_local4][_local3];
_local3++;
};
_local2[_local7].push(_local6);
_local4++;
};
} else {
_local2[_local7] = {};
for (_local8 in _arg1[_local7]) {
_local2[_local7][_local8] = _arg1[_local7][_local8];
};
};
} else {
_local2[_local7] = _arg1[_local7];
};
};
return (_local2);
}
}
}//package mochi.as3
Section 183
//MochiServices (mochi.as3.MochiServices)
package mochi.as3 {
import flash.display.*;
import flash.events.*;
import flash.utils.*;
import flash.geom.*;
import flash.net.*;
import flash.system.*;
public class MochiServices {
private static var _id:String;
private static var _container:Object;
private static var _clip:MovieClip;
private static var _loader:Loader;
private static var _timer:Timer;
private static var _preserved:Object;
private static var _servURL:String = "http://www.mochiads.com/static/lib/services/";
private static var _services:String = "services.swf";
private static var _mochiLC:String = "MochiLC.swf";
private static var _swfVersion:String;
private static var _listenChannelName:String = "__ms_";
private static var _sendChannel:LocalConnection;
private static var _sendChannelName:String;
private static var _connecting:Boolean = false;
private static var _connected:Boolean = false;
public static var netup:Boolean = true;
public static var netupAttempted:Boolean = false;
public static var onError:Object;
public static var widget:Boolean = false;
public static var servicesSync:MochiSync = new MochiSync();
private static var _mochiLocalConnection:MovieClip;
private static var _queue:Array;
private static var _nextCallbackID:Number;
private static var _callbacks:Object;
public static function get id():String{
return (_id);
}
public static function get clip():Object{
return (_container);
}
public static function get childClip():Object{
return (_clip);
}
public static function getVersion():String{
return ("3.8 as3");
}
public static function allowDomains(_arg1:String):String{
var _local2:String;
if (Security.sandboxType != "application"){
Security.allowDomain("*");
Security.allowInsecureDomain("*");
};
if (_arg1.indexOf("http://") != -1){
_local2 = _arg1.split("/")[2].split(":")[0];
if (Security.sandboxType != "application"){
Security.allowDomain(_local2);
Security.allowInsecureDomain(_local2);
};
};
return (_local2);
}
public static function isNetworkAvailable():Boolean{
return (!((Security.sandboxType == "localWithFile")));
}
public static function set comChannelName(_arg1:String):void{
if (_arg1 != null){
if (_arg1.length > 3){
_sendChannelName = (_arg1 + "_fromgame");
initComChannels();
};
};
}
public static function get connected():Boolean{
return (_connected);
}
public static function warnID(_arg1:String, _arg2:Boolean):void{
_arg1 = _arg1.toLowerCase();
if (_arg1.length != 16){
trace((("WARNING: " + (_arg2) ? "board" : "game") + " ID is not the appropriate length"));
return;
} else {
if (_arg1 == "1e113c7239048b3f"){
if (_arg2){
trace("WARNING: Using testing board ID");
} else {
trace("WARNING: Using testing board ID as game ID");
};
return;
} else {
if (_arg1 == "84993a1de4031cd8"){
if (_arg2){
trace("WARNING: Using testing game ID as board ID");
} else {
trace("WARNING: Using testing game ID");
};
return;
};
};
};
var _local3:Number = 0;
while (_local3 < _arg1.length) {
switch (_arg1.charAt(_local3)){
case "0":
case "1":
case "2":
case "3":
case "4":
case "5":
case "6":
case "7":
case "8":
case "9":
case "a":
case "b":
case "c":
case "d":
case "e":
case "f":
break;
default:
trace(("WARNING: Board ID contains illegal characters: " + _arg1));
return;
};
_local3++;
};
}
public static function connect(_arg1:String, _arg2:Object, _arg3:Object=null):void{
var id = _arg1;
var clip = _arg2;
var onError = _arg3;
warnID(id, false);
if ((clip is DisplayObject)){
if (clip.stage == null){
trace("MochiServices connect requires the containing clip be attached to the stage");
};
if (((!(_connected)) && ((_clip == null)))){
trace("MochiServices Connecting...");
_connecting = true;
init(id, clip);
};
} else {
trace("Error, MochiServices requires a Sprite, Movieclip or instance of the stage.");
};
if (onError != null){
MochiServices.onError = onError;
} else {
if (MochiServices.onError == null){
MochiServices.onError = function (_arg1:String):void{
trace(_arg1);
};
};
};
}
public static function disconnect():void{
if (((_connected) || (_connecting))){
if (_clip != null){
if (_clip.parent != null){
if ((_clip.parent is Sprite)){
Sprite(_clip.parent).removeChild(_clip);
_clip = null;
};
};
};
_connecting = (_connected = false);
flush(true);
try {
_mochiLocalConnection.close();
} catch(error:Error) {
};
};
if (_timer != null){
try {
_timer.stop();
} catch(error:Error) {
};
};
}
public static function stayOnTop():void{
_container.addEventListener(Event.ENTER_FRAME, MochiServices.bringToTop, false, 0, true);
if (_clip != null){
_clip.visible = true;
};
}
public static function doClose():void{
_container.removeEventListener(Event.ENTER_FRAME, MochiServices.bringToTop);
}
public static function bringToTop(_arg1:Event=null):void{
var e = _arg1;
if (((!((MochiServices.clip == null))) && (!((MochiServices.childClip == null))))){
try {
if (MochiServices.clip.numChildren > 1){
MochiServices.clip.setChildIndex(MochiServices.childClip, (MochiServices.clip.numChildren - 1));
};
} catch(errorObject:Error) {
trace("Warning: Depth sort error.");
_container.removeEventListener(Event.ENTER_FRAME, MochiServices.bringToTop);
};
};
}
private static function init(_arg1:String, _arg2:Object):void{
_id = _arg1;
if (_arg2 != null){
_container = _arg2;
loadCommunicator(_arg1, _container);
};
}
public static function setContainer(_arg1:Object=null, _arg2:Boolean=true):void{
if (_clip.parent){
_clip.parent.removeChild(_clip);
};
if (_arg1 != null){
if ((_arg1 is DisplayObjectContainer)){
_container = _arg1;
};
};
if (_arg2){
if ((_container is DisplayObjectContainer)){
DisplayObjectContainer(_container).addChild(_clip);
};
};
}
private static function loadCommunicator(_arg1:String, _arg2:Object):MovieClip{
if (_clip != null){
return (_clip);
};
if (!MochiServices.isNetworkAvailable()){
return (null);
};
if (urlOptions(_arg2).servURL){
_servURL = urlOptions(_arg2).servURL;
};
var _local3:String = (_servURL + _services);
if (urlOptions(_arg2).servicesURL){
_local3 = urlOptions(_arg2).servicesURL;
};
_listenChannelName = (_listenChannelName + ((Math.floor(new Date().time) + "_") + Math.floor((Math.random() * 99999))));
MochiServices.allowDomains(_local3);
_clip = new MovieClip();
loadLCBridge(_clip);
_loader = new Loader();
_loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, loadError);
var _local4:URLRequest = new URLRequest(_local3);
var _local5:URLVariables = new URLVariables();
_local5.listenLC = _listenChannelName;
_local5.mochiad_options = _arg2.loaderInfo.parameters.mochiad_options;
_local5.api_version = getVersion();
if (widget){
_local5.widget = true;
};
_local4.data = _local5;
_loader.load(_local4);
_clip.addChild(_loader);
_sendChannel = new LocalConnection();
_queue = [];
_nextCallbackID = 0;
_callbacks = {};
_timer = new Timer(10000, 1);
_timer.addEventListener(TimerEvent.TIMER, connectWait);
_timer.start();
return (_clip);
}
private static function loadLCBridge(_arg1:Object):void{
var loader:Loader;
var clip = _arg1;
loader = new Loader();
var mochiLCURL:String = (_servURL + _mochiLC);
var req:URLRequest = new URLRequest(mochiLCURL);
var complete:Function = function (_arg1:Object):void{
_mochiLocalConnection = MovieClip(loader.content);
listen();
};
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, complete);
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, loadError);
loader.load(req);
clip.addChild(loader);
}
private static function loadError(_arg1:Object):void{
_clip._mochiad_ctr_failed = true;
trace("MochiServices could not load.");
MochiServices.disconnect();
MochiServices.onError("IOError");
}
public static function connectWait(_arg1:TimerEvent):void{
if (!_connected){
_clip._mochiad_ctr_failed = true;
trace("MochiServices could not load. (timeout)");
MochiServices.disconnect();
MochiServices.onError("IOError");
};
}
private static function listen():void{
_mochiLocalConnection.connect(_listenChannelName);
_clip.handshake = function (_arg1:Object):void{
MochiServices.comChannelName = _arg1.newChannel;
};
trace("Waiting for MochiAds services to connect...");
}
private static function initComChannels():void{
if (!_connected){
trace("[SERVICES_API] connected!");
_connecting = false;
_connected = true;
_mochiLocalConnection.send(_sendChannelName, "onReceive", {methodName:"handshakeDone"});
_mochiLocalConnection.send(_sendChannelName, "onReceive", {methodName:"registerGame", preserved:_preserved, id:_id, version:getVersion(), parentURL:_container.loaderInfo.loaderURL});
_clip.onReceive = onReceive;
_clip.onEvent = onEvent;
_clip.onError = function ():void{
MochiServices.onError("IOError");
};
while (_queue.length > 0) {
_mochiLocalConnection.send(_sendChannelName, "onReceive", _queue.shift());
};
};
}
private static function onReceive(_arg1:Object):void{
var methodName:String;
var pkg = _arg1;
var cb:String = pkg.callbackID;
var cblst:Object = _callbacks[cb];
if (!cblst){
return;
};
var method:* = cblst.callbackMethod;
methodName = "";
var obj:Object = cblst.callbackObject;
if (((obj) && ((typeof(method) == "string")))){
methodName = method;
if (obj[method] != null){
method = obj[method];
} else {
trace((("Error: Method " + method) + " does not exist."));
};
};
if (method != undefined){
try {
method.apply(obj, pkg.args);
} catch(error:Error) {
trace(((("Error invoking callback method '" + methodName) + "': ") + error.toString()));
};
} else {
if (obj != null){
try {
obj(pkg.args);
} catch(error:Error) {
trace(("Error invoking method on object: " + error.toString()));
};
};
};
delete _callbacks[cb];
}
private static function onEvent(_arg1:Object):void{
var _local2:String = _arg1.target;
var _local3:String = _arg1.event;
switch (_local2){
case "events":
MochiEvents.triggerEvent(_arg1.event, _arg1.args);
break;
case "coins":
MochiCoins.triggerEvent(_arg1.event, _arg1.args);
break;
case "sync":
servicesSync.triggerEvent(_arg1.event, _arg1.args);
break;
};
}
public static function updateCopy(_arg1:Object):void{
MochiServices.send("coins_updateCopy", _arg1, null, null);
}
private static function flush(_arg1:Boolean):void{
var _local2:Object;
var _local3:Object;
if (((_clip) && (_queue))){
while (_queue.length > 0) {
_local2 = _queue.shift();
_local3 = null;
if (_local2 != null){
if (_local2.callbackID != null){
_local3 = _callbacks[_local2.callbackID];
};
delete _callbacks[_local2.callbackID];
if (((_arg1) && (!((_local3 == null))))){
handleError(_local2.args, _local3.callbackObject, _local3.callbackMethod);
};
};
};
};
}
private static function handleError(_arg1:Object, _arg2:Object, _arg3:Object):void{
var args = _arg1;
var callbackObject = _arg2;
var callbackMethod = _arg3;
if (args != null){
if (args.onError != null){
args.onError.apply(null, ["NotConnected"]);
};
if (((!((args.options == null))) && (!((args.options.onError == null))))){
args.options.onError.apply(null, ["NotConnected"]);
};
};
if (callbackMethod != null){
args = {};
args.error = true;
args.errorCode = "NotConnected";
if (((!((callbackObject == null))) && ((callbackMethod is String)))){
try {
var _local5 = callbackObject;
_local5[callbackMethod](args);
} catch(error:Error) {
};
} else {
if (callbackMethod != null){
try {
callbackMethod.apply(args);
} catch(error:Error) {
};
};
};
};
}
public static function send(_arg1:String, _arg2:Object=null, _arg3:Object=null, _arg4:Object=null):void{
if (_connected){
_mochiLocalConnection.send(_sendChannelName, "onReceive", {methodName:_arg1, args:_arg2, callbackID:_nextCallbackID});
} else {
if ((((_clip == null)) || (!(_connecting)))){
trace(("Error: MochiServices not connected. Please call MochiServices.connect(). Function: " + _arg1));
handleError(_arg2, _arg3, _arg4);
flush(true);
return;
};
_queue.push({methodName:_arg1, args:_arg2, callbackID:_nextCallbackID});
};
if (_clip != null){
if (_callbacks != null){
_callbacks[_nextCallbackID] = {callbackObject:_arg3, callbackMethod:_arg4};
_nextCallbackID++;
};
};
}
private static function urlOptions(_arg1:Object):Object{
var _local3:String;
var _local4:Array;
var _local5:Number;
var _local6:Array;
var _local2:Object = {};
if (_arg1.stage){
_local3 = _arg1.stage.loaderInfo.parameters.mochiad_options;
} else {
_local3 = _arg1.loaderInfo.parameters.mochiad_options;
};
if (_local3){
_local4 = _local3.split("&");
_local5 = 0;
while (_local5 < _local4.length) {
_local6 = _local4[_local5].split("=");
_local2[unescape(_local6[0])] = unescape(_local6[1]);
_local5++;
};
};
return (_local2);
}
public static function addLinkEvent(_arg1:String, _arg2:String, _arg3:DisplayObjectContainer, _arg4:Function=null):void{
var avm1Click:DisplayObject;
var x:String;
var req:URLRequest;
var loader:Loader;
var setURL:Function;
var err:Function;
var complete:Function;
var url = _arg1;
var burl = _arg2;
var btn = _arg3;
var onClick = _arg4;
var vars:Object = new Object();
vars["mav"] = getVersion();
vars["swfv"] = "9";
vars["swfurl"] = btn.loaderInfo.loaderURL;
vars["fv"] = Capabilities.version;
vars["os"] = Capabilities.os;
vars["lang"] = Capabilities.language;
vars["scres"] = ((Capabilities.screenResolutionX + "x") + Capabilities.screenResolutionY);
var s = "?";
var i:Number = 0;
for (x in vars) {
if (i != 0){
s = (s + "&");
};
i = (i + 1);
s = (((s + x) + "=") + escape(vars[x]));
};
req = new URLRequest("http://x.mochiads.com/linkping.swf");
loader = new Loader();
setURL = function (_arg1:String):void{
var _local2:Rectangle;
if (avm1Click){
btn.removeChild(avm1Click);
};
avm1Click = clickMovie(_arg1, onClick);
_local2 = btn.getBounds(btn);
btn.addChild(avm1Click);
avm1Click.x = _local2.x;
avm1Click.y = _local2.y;
avm1Click.scaleX = (0.01 * _local2.width);
avm1Click.scaleY = (0.01 * _local2.height);
};
err = function (_arg1:Object):void{
netup = false;
_arg1.target.removeEventListener(_arg1.type, arguments.callee);
setURL(burl);
};
complete = function (_arg1:Object):void{
_arg1.target.removeEventListener(_arg1.type, arguments.callee);
};
if (netup){
setURL((url + s));
} else {
setURL(burl);
};
if (!((netupAttempted) || (_connected))){
netupAttempted = true;
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, err);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, complete);
loader.load(req);
};
}
private static function clickMovie(_arg1:String, _arg2:Function):MovieClip{
var _local4:int;
var _local14:Loader;
var _local3:Array = [150, 21, 0, 7, 1, 0, 0, 0, 0, 98, 116, 110, 0, 7, 2, 0, 0, 0, 0, 116, 104, 105, 115, 0, 28, 150, 22, 0, 0, 99, 114, 101, 97, 116, 101, 69, 109, 112, 116, 121, 77, 111, 118, 105, 101, 67, 108, 105, 112, 0, 82, 135, 1, 0, 0, 23, 150, 13, 0, 4, 0, 0, 111, 110, 82, 101, 108, 101, 97, 115, 101, 0, 142, 8, 0, 0, 0, 0, 2, 42, 0, 114, 0, 150, 17, 0, 0, 32, 0, 7, 1, 0, 0, 0, 8, 0, 0, 115, 112, 108, 105, 116, 0, 82, 135, 1, 0, 1, 23, 150, 7, 0, 4, 1, 7, 0, 0, 0, 0, 78, 150, 8, 0, 0, 95, 98, 108, 97, 110, 107, 0, 154, 1, 0, 0, 150, 7, 0, 0, 99, 108, 105, 99, 107, 0, 150, 7, 0, 4, 1, 7, 1, 0, 0, 0, 78, 150, 27, 0, 7, 2, 0, 0, 0, 7, 0, 0, 0, 0, 0, 76, 111, 99, 97, 108, 67, 111, 110, 110, 101, 99, 116, 105, 111, 110, 0, 64, 150, 6, 0, 0, 115, 101, 110, 100, 0, 82, 79, 150, 15, 0, 4, 0, 0, 95, 97, 108, 112, 104, 97, 0, 7, 0, 0, 0, 0, 79, 150, 23, 0, 7, 0xFF, 0, 0xFF, 0, 7, 1, 0, 0, 0, 4, 0, 0, 98, 101, 103, 105, 110, 70, 105, 108, 108, 0, 82, 23, 150, 25, 0, 7, 0, 0, 0, 0, 7, 0, 0, 0, 0, 7, 2, 0, 0, 0, 4, 0, 0, 109, 111, 118, 101, 84, 111, 0, 82, 23, 150, 25, 0, 7, 100, 0, 0, 0, 7, 0, 0, 0, 0, 7, 2, 0, 0, 0, 4, 0, 0, 108, 105, 110, 101, 84, 111, 0, 82, 23, 150, 25, 0, 7, 100, 0, 0, 0, 7, 100, 0, 0, 0, 7, 2, 0, 0, 0, 4, 0, 0, 108, 105, 110, 101, 84, 111, 0, 82, 23, 150, 25, 0, 7, 0, 0, 0, 0, 7, 100, 0, 0, 0, 7, 2, 0, 0, 0, 4, 0, 0, 108, 105, 110, 101, 84, 111, 0, 82, 23, 150, 25, 0, 7, 0, 0, 0, 0, 7, 0, 0, 0, 0, 7, 2, 0, 0, 0, 4, 0, 0, 108, 105, 110, 101, 84, 111, 0, 82, 23, 150, 16, 0, 7, 0, 0, 0, 0, 4, 0, 0, 101, 110, 100, 70, 105, 108, 108, 0, 82, 23];
var _local5:Array = [104, 0, 31, 64, 0, 7, 208, 0, 0, 12, 1, 0, 67, 2, 0xFF, 0xFF, 0xFF, 63, 3];
var _local6:Array = [0, 64, 0, 0, 0];
var _local7:MovieClip = new MovieClip();
var _local8:LocalConnection = new LocalConnection();
var _local9:String = ((("_click_" + Math.floor((Math.random() * 999999))) + "_") + Math.floor(new Date().time));
_local8 = new LocalConnection();
_local7.lc = _local8;
_local7.click = _arg2;
_local8.client = _local7;
_local8.connect(_local9);
var _local10:ByteArray = new ByteArray();
var _local11:ByteArray = new ByteArray();
_local11.endian = Endian.LITTLE_ENDIAN;
_local11.writeShort(1);
_local11.writeUTFBytes(((_arg1 + " ") + _local9));
_local11.writeByte(0);
var _local12:uint = ((_local3.length + _local11.length) + 4);
var _local13:uint = (_local12 + 35);
_local10.endian = Endian.LITTLE_ENDIAN;
_local10.writeUTFBytes("FWS");
_local10.writeByte(8);
_local10.writeUnsignedInt(_local13);
for each (_local4 in _local5) {
_local10.writeByte(_local4);
};
_local10.writeUnsignedInt(_local12);
_local10.writeByte(136);
_local10.writeShort(_local11.length);
_local10.writeBytes(_local11);
for each (_local4 in _local3) {
_local10.writeByte(_local4);
};
for each (_local4 in _local6) {
_local10.writeByte(_local4);
};
_local14 = new Loader();
_local14.loadBytes(_local10);
_local7.addChild(_local14);
return (_local7);
}
}
}//package mochi.as3
Section 184
//MochiSocial (mochi.as3.MochiSocial)
package mochi.as3 {
public class MochiSocial {
public static const LOGGED_IN:String = "LoggedIn";
public static const LOGGED_OUT:String = "LoggedOut";
public static const LOGIN_SHOW:String = "LoginShow";
public static const LOGIN_HIDE:String = "LoginHide";
public static const LOGIN_SHOWN:String = "LoginShown";
public static const PROFILE_SHOW:String = "ProfileShow";
public static const PROFILE_HIDE:String = "ProfileHide";
public static const PROPERTIES_SAVED:String = "PropertySaved";
public static const WIDGET_LOADED:String = "WidgetLoaded";
public static const USER_INFO:String = "UserInfo";
public static const ERROR:String = "Error";
public static const IO_ERROR:String = "IOError";
public static const NO_USER:String = "NoUser";
public static const PROPERTIES_SIZE:String = "PropertiesSize";
private static var _dispatcher:MochiEventDispatcher = new MochiEventDispatcher();
public static var _user_info:Object = null;
public static function getVersion():String{
return (MochiServices.getVersion());
}
public static function getAPIURL():String{
if (!_user_info){
return (null);
};
return (_user_info.api_url);
}
public static function getAPIToken():String{
if (!_user_info){
return (null);
};
return (_user_info.api_token);
}
public static function showLoginWidget(_arg1:Object=null):void{
MochiServices.setContainer();
MochiServices.bringToTop();
MochiServices.send("coins_showLoginWidget", {options:_arg1});
}
public static function hideLoginWidget():void{
MochiServices.send("coins_hideLoginWidget");
}
public static function requestLogin():void{
MochiServices.send("coins_requestLogin");
}
public static function getUserInfo():void{
MochiServices.send("coins_getUserInfo");
}
public static function saveUserProperties(_arg1:Object):void{
MochiServices.send("coins_saveUserProperties", _arg1);
}
public static function addEventListener(_arg1:String, _arg2:Function):void{
_dispatcher.addEventListener(_arg1, _arg2);
}
public static function get loggedIn():Boolean{
return (!((_user_info == null)));
}
public static function triggerEvent(_arg1:String, _arg2:Object):void{
_dispatcher.triggerEvent(_arg1, _arg2);
}
public static function removeEventListener(_arg1:String, _arg2:Function):void{
_dispatcher.removeEventListener(_arg1, _arg2);
}
MochiSocial.addEventListener(MochiSocial.LOGGED_IN, function (_arg1:Object):void{
_user_info = _arg1;
});
MochiSocial.addEventListener(MochiSocial.LOGGED_OUT, function (_arg1:Object):void{
_user_info = null;
});
}
}//package mochi.as3
Section 185
//MochiSync (mochi.as3.MochiSync)
package mochi.as3 {
import flash.utils.*;
public dynamic class MochiSync extends Proxy {
private var _syncContainer:Object;
public static var SYNC_REQUEST:String = "SyncRequest";
public static var SYNC_PROPERTY:String = "UpdateProperty";
public function MochiSync():void{
_syncContainer = {};
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function getProperty(_arg1){
return (_syncContainer[_arg1]);
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function setProperty(_arg1, _arg2):void{
if (_syncContainer[_arg1] == _arg2){
return;
};
var _local3:String = _arg1.toString();
_syncContainer[_local3] = _arg2;
MochiServices.send("sync_propUpdate", {name:_local3, value:_arg2});
}
public function triggerEvent(_arg1:String, _arg2:Object):void{
switch (_arg1){
case SYNC_REQUEST:
MochiServices.send("sync_syncronize", _syncContainer);
break;
case SYNC_PROPERTY:
_syncContainer[_arg2.name] = _arg2.value;
break;
};
}
}
}//package mochi.as3
Section 186
//MochiUserData (mochi.as3.MochiUserData)
package mochi.as3 {
import flash.events.*;
import flash.utils.*;
import flash.net.*;
public class MochiUserData extends EventDispatcher {
public var _loader:URLLoader;
public var key:String;// = null
public var data;// = null
public var error:Event;// = null
public var operation:String;// = null
public var callback:Function;// = null
public function MochiUserData(_arg1:String="", _arg2:Function=null){
this.key = _arg1;
this.callback = _arg2;
}
public function serialize(_arg1):ByteArray{
var _local2:ByteArray = new ByteArray();
_local2.objectEncoding = ObjectEncoding.AMF3;
_local2.writeObject(_arg1);
_local2.compress();
return (_local2);
}
public function deserialize(_arg1:ByteArray){
_arg1.objectEncoding = ObjectEncoding.AMF3;
_arg1.uncompress();
return (_arg1.readObject());
}
public function request(_arg1:String, _arg2:ByteArray):void{
var _operation = _arg1;
var _data = _arg2;
operation = _operation;
var api_url:String = MochiSocial.getAPIURL();
var api_token:String = MochiSocial.getAPIToken();
if ((((api_url == null)) || ((api_token == null)))){
errorHandler(new IOErrorEvent(IOErrorEvent.IO_ERROR, false, false, "not logged in"));
return;
};
_loader = new URLLoader();
var args:URLVariables = new URLVariables();
args.op = _operation;
args.key = key;
var req:URLRequest = new URLRequest((((MochiSocial.getAPIURL() + "/") + "MochiUserData?") + args.toString()));
req.method = URLRequestMethod.POST;
req.contentType = "application/x-mochi-userdata";
req.requestHeaders = [new URLRequestHeader("x-mochi-services-version", MochiServices.getVersion()), new URLRequestHeader("x-mochi-api-token", api_token)];
req.data = _data;
_loader.dataFormat = URLLoaderDataFormat.BINARY;
_loader.addEventListener(Event.COMPLETE, completeHandler);
_loader.addEventListener(IOErrorEvent.IO_ERROR, errorHandler);
_loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
try {
_loader.load(req);
} catch(e:SecurityError) {
errorHandler(new IOErrorEvent(IOErrorEvent.IO_ERROR, false, false, ("security error: " + e.toString())));
};
}
public function completeHandler(_arg1:Event):void{
var event = _arg1;
try {
if (_loader.data.length){
data = deserialize(_loader.data);
} else {
data = null;
};
} catch(e:Error) {
errorHandler(new IOErrorEvent(IOErrorEvent.IO_ERROR, false, false, ("deserialize error: " + e.toString())));
return;
};
if (callback != null){
performCallback();
} else {
dispatchEvent(event);
};
close();
}
public function errorHandler(_arg1:IOErrorEvent):void{
data = null;
error = _arg1;
if (callback != null){
performCallback();
} else {
dispatchEvent(_arg1);
};
close();
}
public function securityErrorHandler(_arg1:SecurityErrorEvent):void{
errorHandler(new IOErrorEvent(IOErrorEvent.IO_ERROR, false, false, ("security error: " + _arg1.toString())));
}
public function performCallback():void{
try {
callback(this);
} catch(e:Error) {
trace(("[MochiUserData] exception during callback: " + e));
};
}
public function close():void{
if (_loader){
_loader.removeEventListener(Event.COMPLETE, completeHandler);
_loader.removeEventListener(IOErrorEvent.IO_ERROR, errorHandler);
_loader.removeEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
_loader.close();
_loader = null;
};
error = null;
callback = null;
}
public function getEvent():void{
request("get", serialize(null));
}
public function putEvent(_arg1):void{
request("put", serialize(_arg1));
}
override public function toString():String{
return ((((((((("[MochiUserData operation=" + operation) + " key=\"") + key) + "\" data=") + data) + " error=\"") + error) + "\"]"));
}
public static function get(_arg1:String, _arg2:Function):void{
var _local3:MochiUserData = new MochiUserData(_arg1, _arg2);
_local3.getEvent();
}
public static function put(_arg1:String, _arg2, _arg3:Function):void{
var _local4:MochiUserData = new MochiUserData(_arg1, _arg3);
_local4.putEvent(_arg2);
}
}
}//package mochi.as3
Section 187
//backdrop (backdrop)
package {
import flash.display.*;
public dynamic class backdrop extends MovieClip {
}
}//package
Section 188
//basic (basic)
package {
import flash.display.*;
import flash.events.*;
import away3d.core.math.*;
import away3d.core.utils.*;
import away3d.materials.*;
import away3d.containers.*;
import mochi.as3.*;
import away3d.cameras.*;
import away3d.events.*;
import away3d.lights.*;
import flash.geom.*;
import away3d.primitives.*;
import flash.net.*;
import flash.text.*;
import flash.media.*;
public class basic extends MovieClip {
public var m_colors:int;
private var m_view:View3D;
private var camera:HoverCamera3D;
private var lastMouseX:Number;
private var lastMouseY:Number;
private var lastPanAngle:Number;
private var lastTiltAngle:Number;
private var move:Boolean;// = false
public var m_stage:MovieClip;
public var m_start:Point;
public var m_dir_start:Point;
public var m_mvx;// = 0
public var m_mvy;// = 0
public var m_mvSide;// = -1
public var top:Array;
public var left:Array;
public var right:Array;
public var m_angle:Number;
public var m_topCount:Number;
public var m_leftCount:Number;
public var m_rightCount:Number;
public var m_clear:Array;
public var m_list:Array;
public var m_menu:MovieClip;
public var m_bonus:MovieClip;
public var m_score:int;
public var m_floor:Plane;
public var m_cubeSize:int;
public var m_pause:Boolean;
public var m_rotateCube:Boolean;
public var m_line:Plane;
public var m_lineWrap:Plane;
public var m_lineStart:Plane;
public var m_lineEnd:Plane;
public var m_soundNock:Object;
public var m_soundFinish:Object;
public var m_channel:SoundChannel;
var m_moveRow:Number;
var m_moveDir:int;
var m_row:int;
var m_disance:int;
var m_startMove:Boolean;
var m_snap:Number;
var m_leng:Number;
var m_oldLeng:Number;
public var m_dir:Number;
var m_reset:Boolean;
public var m_switch:int;
private var m_timer;
private var m_startup:Boolean;
public function basic(){
var _local4:*;
var _local5:*;
super();
m_leng = 0;
m_colors = 9;
m_timer = 0;
m_startup = true;
m_cubeSize = 100;
m_reset = false;
m_rotateCube = true;
m_pause = true;
m_startMove = false;
m_snap = -1;
m_angle = 0;
m_topCount = 0;
m_leftCount = 0;
m_rightCount = 0;
m_score = 0;
m_clear = new Array();
m_list = new Array();
m_stage = new backdrop();
this.addChild(m_stage);
m_start = new Point();
m_dir_start = new Point();
camera = new HoverCamera3D({zoom:1, focus:600, distance:10});
m_view = new View3D({camera:camera, x:250, y:250});
addChild(m_view);
m_menu = new menu();
m_menu.gameOver.visible = false;
m_menu.gameBtn.addEventListener(MouseEvent.CLICK, restartGame);
m_menu.pauseBtn.addEventListener(MouseEvent.CLICK, pauseGame);
m_menu.manuBtn.addEventListener(MouseEvent.CLICK, showMenu);
m_menu.mainMenu.visible = false;
m_menu.mainMenu.controlsBtn.addEventListener(MouseEvent.CLICK, showControls);
m_menu.mainMenu.rotateBtn.addEventListener(MouseEvent.CLICK, rotateCube);
m_menu.mainMenu.creditsBtn.addEventListener(MouseEvent.CLICK, showCredits);
m_menu.mainMenu.linkBtn.addEventListener(MouseEvent.CLICK, openLink);
m_menu.mainMenu.controlsBtn.addEventListener(MouseEvent.CLICK, showControls);
m_menu.mainMenu.boardBtn.addEventListener(MouseEvent.CLICK, showBoard);
m_menu.pulsarrLnk.addEventListener(MouseEvent.CLICK, openLink);
m_menu.pulsarrLnk.useHandCursor = true;
m_menu.pulsarrLnk.buttonMode = true;
m_menu.instructions.closeBtn.addEventListener(MouseEvent.CLICK, showControls);
m_menu.mainMenu.closeBtn.addEventListener(MouseEvent.CLICK, showMenu);
m_menu.credits.closeBtn.addEventListener(MouseEvent.CLICK, showCredits);
m_menu.gameOver.gameBtn.addEventListener(MouseEvent.CLICK, restartGame);
m_menu.gameOver.gameBtn.label = "Restart Game";
m_menu.gameOver.scoreBtn.addEventListener(MouseEvent.CLICK, saveScore);
m_menu.gameOver.scoreBtn.label = "Publish Score";
m_menu.mainMenu.linkBtn.label = "More Games";
m_menu.mainMenu.boardBtn.label = "Leaderboard";
m_menu.mainMenu.controlsBtn.label = "Instructions";
m_menu.mainMenu.creditsBtn.label = "Credits";
m_menu.mainMenu.rotateBtn.label = "Rotate Off";
m_menu.mainMenu.closeBtn.label = "x";
m_menu.credits.closeBtn.label = "x";
m_menu.instructions.closeBtn.label = "x";
m_menu.stoped.visible = false;
m_menu.credits.visible = false;
addChild(m_menu);
m_menu.x = 0;
m_menu.y = 0;
m_bonus = new BonusAnim();
addChild(m_bonus);
m_bonus.x = 250;
m_bonus.y = 250;
m_bonus.visible = false;
var _local1:* = new Cube({width:185, height:185, depth:185, segmentsH:1, segmentsW:1});
_local1.material = GetMat(0);
_local1.pushback = true;
m_view.scene.addChild(_local1);
var _local2:DirectionalLight3D = new DirectionalLight3D();
_local2.direction = new Number3D(-120, -120, -120);
_local2.specular = 2;
_local2.diffuse = 0.5;
_local2.ambient = 0.5;
m_view.scene.addLight(_local2);
m_line = new Plane({width:1, height:1, segmentsH:1, segmentsW:1});
m_line.material = new MyMat(1, new white(150, 150));
m_line.pushfront = true;
m_line.addOnMouseUp(resetDrawLine);
m_view.scene.addChild(m_line);
m_lineWrap = new Plane({width:1, height:1, segmentsH:1, segmentsW:1});
m_lineWrap.material = new MyMat(1, new white(150, 150));
m_lineWrap.pushfront = true;
m_lineWrap.addOnMouseUp(resetDrawLine);
m_view.scene.addChild(m_lineWrap);
m_lineStart = new Plane({width:1, height:1, segmentsH:1, segmentsW:1});
m_lineStart.material = new MyMov(1, new circle());
m_lineStart.pushfront = true;
m_lineStart.addOnMouseUp(resetDrawLine);
m_view.scene.addChild(m_lineStart);
m_lineEnd = new Plane({width:1, height:1, segmentsH:1, segmentsW:1});
m_lineEnd.material = new MyMov(1, new circle());
m_lineEnd.pushfront = true;
m_lineEnd.addOnMouseUp(resetDrawLine);
m_view.scene.addChild(m_lineEnd);
var _local3:* = 50;
top = new Array();
_local4 = 0;
while (_local4 < 4) {
_local5 = 0;
while (_local5 < 4) {
top[m_topCount] = new PlaneEx(false, {width:_local3, height:_local3, segmentsH:1, segmentsW:1});
top[m_topCount].material = getRandomBitmap();
top[m_topCount].x = ((_local5 * 50) - 75);
top[m_topCount].z = ((_local4 * 50) - 75);
top[m_topCount].y = m_cubeSize;
top[m_topCount].rotationY = 0;
top[m_topCount].rotationX = 0;
top[m_topCount].rotationZ = 0;
top[m_topCount].mouseEnabled = true;
top[m_topCount].useHandCursor = true;
top[m_topCount].addOnMouseDown(panelClicked);
top[m_topCount].addOnMouseUp(resetDrawLine);
top[m_topCount].addOnMouseOver(drawLine);
m_view.scene.addChild(top[m_topCount]);
m_topCount++;
_local5++;
};
_local4++;
};
right = new Array();
_local4 = 0;
while (_local4 < 4) {
_local5 = 0;
while (_local5 < 4) {
right[m_rightCount] = new PlaneEx(false, {width:_local3, height:_local3, segmentsH:1, segmentsW:1});
right[m_rightCount].material = getRandomBitmap();
right[m_rightCount].x = ((_local5 * 50) - 75);
right[m_rightCount].z = m_cubeSize;
right[m_rightCount].y = ((_local4 * 50) - 75);
right[m_rightCount].rotationX = -90;
right[m_rightCount].mouseEnabled = true;
right[m_rightCount].useHandCursor = true;
right[m_rightCount].addOnMouseDown(panelClicked);
right[m_rightCount].addOnMouseUp(resetDrawLine);
right[m_rightCount].addOnMouseOver(drawLine);
m_view.scene.addChild(right[m_rightCount]);
m_rightCount++;
_local5++;
};
_local4++;
};
left = new Array();
_local4 = 0;
while (_local4 < 4) {
_local5 = 0;
while (_local5 < 4) {
left[m_leftCount] = new PlaneEx(false, {width:_local3, height:_local3, segmentsH:1, segmentsW:1});
left[m_leftCount].material = getRandomBitmap();
left[m_leftCount].x = m_cubeSize;
left[m_leftCount].z = ((_local5 * 50) - 75);
left[m_leftCount].y = ((_local4 * 50) - 75);
left[m_leftCount].rotationZ = -90;
left[m_leftCount].mouseEnabled = true;
left[m_leftCount].useHandCursor = true;
left[m_leftCount].addOnMouseDown(panelClicked);
left[m_leftCount].addOnMouseUp(resetDrawLine);
left[m_leftCount].addOnMouseOver(drawLine);
m_view.scene.addChild(left[m_leftCount]);
m_leftCount++;
_local5++;
};
_local4++;
};
removeDuplicates();
m_view.render();
lastPanAngle = camera.panAngle;
lastTiltAngle = camera.tiltAngle;
addEventListener(Event.ENTER_FRAME, onEnterFrame);
this.addEventListener(MouseEvent.MOUSE_UP, resetLine);
m_soundNock = new nockSnd();
m_soundFinish = new finishSnd();
MochiServices.connect("d1ee9f5dac072c98", m_menu.leaderboard);
MochiScores.setBoardID("09b10950d1a95b84");
}
public function showBoard(_arg1:MouseEvent){
var event = _arg1;
m_menu.mainMenu.visible = false;
MochiScores.showLeaderboard({res:"550x400", onClose:hideBoard, onError:function ():void{
trace("error loading leaderboard!");
}});
}
public function hideBoard(){
m_menu.mainMenu.visible = true;
}
public function openLink(_arg1:MouseEvent){
var event = _arg1;
var req1:URLRequest = new URLRequest("http://www.pulsarr.com");
try {
navigateToURL(req1, "_blank");
} catch(e:Error) {
trace("Error occurred!");
};
}
public function showControls(_arg1:MouseEvent){
trace("showControls");
if (m_menu.instructions.visible){
m_menu.instructions.visible = false;
m_menu.mainMenu.visible = false;
m_pause = false;
m_menu.stoped.visible = false;
} else {
m_menu.instructions.visible = true;
m_menu.mainMenu.visible = false;
};
}
public function showCredits(_arg1:MouseEvent){
trace("showCredits");
if (m_menu.credits.visible){
m_menu.credits.visible = false;
m_menu.mainMenu.visible = true;
} else {
m_menu.credits.visible = true;
m_menu.mainMenu.visible = false;
};
}
public function showMenu(_arg1:MouseEvent){
trace("showMenu");
if (m_menu.mainMenu.visible){
m_menu.mainMenu.visible = false;
m_pause = false;
m_menu.stoped.visible = false;
} else {
m_menu.mainMenu.visible = true;
m_pause = true;
};
}
public function rotateCube(_arg1:MouseEvent){
if (m_rotateCube){
m_rotateCube = false;
m_menu.mainMenu.rotateBtn.label = "Rotate On";
} else {
m_rotateCube = true;
m_menu.stoped.visible = false;
m_menu.mainMenu.rotateBtn.label = "Rotate Off";
};
}
public function saveScore(_arg1:MouseEvent){
var event = _arg1;
m_menu.gameOver.visible = false;
MochiScores.showLeaderboard({res:"550x400", score:getTotalScore(), onClose:hideBoard, onError:function ():void{
trace("error loading leaderboard!");
}});
}
public function getTotalScore():int{
return (m_score);
}
public function pauseGame(_arg1:MouseEvent){
m_menu.credits.visible = false;
if (m_pause){
m_pause = false;
m_menu.stoped.visible = false;
} else {
m_pause = true;
m_menu.stoped.visible = true;
};
}
public function removeDuplicates(){
var _local1:* = 0;
while (matchColors(true)) {
if (_local1 > 30){
break;
};
_local1++;
};
}
public function showMouse(_arg1:MouseEvent3D){
}
public function moveCursor(_arg1:MouseEvent3D){
}
public function hideMouse(_arg1:MouseEvent3D){
}
public function GetMat(_arg1:int){
switch (_arg1){
case 0:
return (new MyMat(0, new woodBmp(150, 150)));
case 1:
return (new MyMat(1, new rockBmp(150, 150)));
case 2:
return (new MyMat(2, new cyanblue(150, 150)));
case 3:
return (new MyMat(3, new GreenLeaf(150, 150)));
case 4:
return (new MyMat(4, new goldBmp(150, 150)));
case 5:
return (new MyMat(5, new orangeBmp(150, 150)));
case 6:
return (new MyMat(6, new blueBmp(150, 150)));
case 7:
return (new MyMat(7, new purple(150, 150)));
case 8:
return (new MyMat(8, new blackBmp(150, 150)));
case 9:
return (new MyMat(9, new whiteBmp(150, 150)));
};
trace((("WARRNING " + _arg1) + " Not found"));
return (null);
}
public function AddScore(_arg1){
var _local2:* = Math.round(((_arg1 * _arg1) / 4));
m_score = (m_score + _local2);
m_timer = (m_timer + _local2);
m_menu.score.text = ("Score:" + m_score);
var _local3:TextFormat = new TextFormat();
_local3.bold = true;
m_menu.score.setTextFormat(_local3);
}
public function matchColors(_arg1:Boolean):Boolean{
var _local4:*;
var _local5:*;
var _local6:*;
var _local7:*;
var _local8:*;
var _local9:*;
var _local10:*;
var _local11:*;
var _local12:*;
var _local13:*;
var _local14:*;
var _local15:*;
var _local16:*;
var _local17:*;
var _local18:*;
var _local19:*;
var _local2:Boolean;
var _local3:* = 0;
while (_local3 < 4) {
_local4 = 0;
while (_local4 < 4) {
_local5 = top[GetIndex(_local4, _local3)].material.m_id;
_local6 = GetTopMaterial((_local4 + 1), _local3);
_local7 = GetTopMaterial((_local4 - 1), _local3);
_local8 = GetTopMaterial(_local4, (_local3 + 1));
_local9 = GetTopMaterial(_local4, (_local3 - 1));
if ((((_local5 == _local6)) && ((_local5 == _local7)))){
_local2 = true;
top[GetIndex(_local4, _local3)].material = getNewBitmap(_local5);
};
if ((((_local5 == _local8)) && ((_local5 == _local9)))){
_local2 = true;
top[GetIndex(_local4, _local3)].material = getNewBitmap(_local5);
};
if ((((_local5 == _local6)) && ((_local5 == _local8)))){
_local2 = true;
top[GetIndex(_local4, _local3)].material = getNewBitmap(_local5);
};
if ((((_local5 == _local8)) && ((_local5 == _local7)))){
_local2 = true;
top[GetIndex(_local4, _local3)].material = getNewBitmap(_local5);
};
if ((((_local5 == _local7)) && ((_local5 == _local9)))){
_local2 = true;
top[GetIndex(_local4, _local3)].material = getNewBitmap(_local5);
};
if ((((_local5 == _local6)) && ((_local5 == _local9)))){
_local2 = true;
top[GetIndex(_local4, _local3)].material = getNewBitmap(_local5);
};
_local10 = left[GetIndex(_local4, _local3)].material.m_id;
_local11 = GetLeftMaterial((_local4 + 1), _local3);
_local12 = GetLeftMaterial((_local4 - 1), _local3);
_local13 = GetLeftMaterial(_local4, (_local3 + 1));
_local14 = GetLeftMaterial(_local4, (_local3 - 1));
if ((((_local10 == _local11)) && ((_local10 == _local12)))){
_local2 = true;
if (_arg1){
left[GetIndex(_local4, _local3)].material = getNewBitmap(_local10);
};
};
if ((((_local10 == _local13)) && ((_local10 == _local14)))){
_local2 = true;
if (_arg1){
left[GetIndex(_local4, _local3)].material = getNewBitmap(_local10);
};
};
if ((((_local10 == _local11)) && ((_local10 == _local13)))){
_local2 = true;
if (_arg1){
left[GetIndex(_local4, _local3)].material = getNewBitmap(_local10);
};
};
if ((((_local10 == _local13)) && ((_local10 == _local12)))){
_local2 = true;
if (_arg1){
left[GetIndex(_local4, _local3)].material = getNewBitmap(_local10);
};
};
if ((((_local10 == _local12)) && ((_local10 == _local14)))){
_local2 = true;
if (_arg1){
left[GetIndex(_local4, _local3)].material = getNewBitmap(_local10);
};
};
if ((((_local10 == _local11)) && ((_local10 == _local14)))){
_local2 = true;
if (_arg1){
left[GetIndex(_local4, _local3)].material = getNewBitmap(_local10);
};
};
_local15 = right[GetIndex(_local4, _local3)].material.m_id;
_local16 = GetRightMaterial((_local4 + 1), _local3);
_local17 = GetRightMaterial((_local4 - 1), _local3);
_local18 = GetRightMaterial(_local4, (_local3 + 1));
_local19 = GetRightMaterial(_local4, (_local3 - 1));
if ((((_local15 == _local16)) && ((_local15 == _local17)))){
_local2 = true;
if (_arg1){
right[GetIndex(_local4, _local3)].material = getNewBitmap(_local15);
};
};
if ((((_local15 == _local18)) && ((_local15 == _local19)))){
_local2 = true;
if (_arg1){
right[GetIndex(_local4, _local3)].material = getNewBitmap(_local15);
};
};
if ((((_local15 == _local16)) && ((_local15 == _local18)))){
_local2 = true;
if (_arg1){
right[GetIndex(_local4, _local3)].material = getNewBitmap(_local15);
};
};
if ((((_local15 == _local18)) && ((_local15 == _local17)))){
_local2 = true;
if (_arg1){
right[GetIndex(_local4, _local3)].material = getNewBitmap(_local15);
};
};
if ((((_local15 == _local17)) && ((_local15 == _local19)))){
_local2 = true;
if (_arg1){
right[GetIndex(_local4, _local3)].material = getNewBitmap(_local15);
};
};
if ((((_local15 == _local16)) && ((_local15 == _local19)))){
_local2 = true;
if (_arg1){
right[GetIndex(_local4, _local3)].material = getNewBitmap(_local15);
};
};
_local4++;
};
_local3++;
};
if (_local2){
return (true);
};
return (false);
}
public function GetTopMaterial(_arg1, _arg2){
if (_arg2 > 3){
return (right[GetIndex(_arg1, 3)].material.m_id);
};
if (_arg1 > 3){
return (left[GetIndex(_arg2, 3)].material.m_id);
};
if (top[GetIndex(_arg1, _arg2)]){
return (top[GetIndex(_arg1, _arg2)].material.m_id);
};
return (null);
}
public function GetLeftMaterial(_arg1, _arg2){
if (_arg2 > 3){
return (top[GetIndex(3, _arg1)].material.m_id);
};
if (_arg1 > 3){
return (right[GetIndex(3, _arg2)].material.m_id);
};
if (left[GetIndex(_arg1, _arg2)]){
return (left[GetIndex(_arg1, _arg2)].material.m_id);
};
return (null);
}
public function GetRightMaterial(_arg1, _arg2){
if (_arg1 > 3){
};
if (_arg2 > 3){
return (top[GetIndex(_arg1, 3)].material.m_id);
};
if (right[GetIndex(_arg1, _arg2)]){
return (right[GetIndex(_arg1, _arg2)].material.m_id);
};
return (null);
}
function getNewBitmap(_arg1:int){
var _local6:int;
var _local7:int;
trace(("getNewBitmap:" + _arg1));
var _local2:* = new Array();
var _local3:* = 0;
while (_local3 < m_colors) {
_local2[_local3] = _local3;
_local3++;
};
var _local4:* = 0;
while (_local4 < m_colors) {
_local6 = Math.round((Math.random() * (m_colors - 1)));
if (_local6 != _local4){
_local7 = _local2[_local4];
_local2[_local4] = _local2[_local6];
_local2[_local6] = _local7;
};
_local4++;
};
var _local5:* = 0;
while (_local5 < m_colors) {
if (_local2[_local5] != _arg1){
return (GetMat((_local2[_local5] + 1)));
};
_local5++;
};
return (getRandomBitmap());
}
function getUnmatchingBitmap(_arg1:int, _arg2:int, _arg3:int, _arg4:int, _arg5:int){
var _local7:*;
var _local10:int;
var _local11:int;
var _local6:* = new Array();
_local7 = 0;
while (_local7 < m_colors) {
_local6[_local7] = _local7;
_local7++;
};
var _local8:* = 0;
while (_local8 < m_colors) {
_local10 = Math.round((Math.random() * (m_colors - 1)));
if (_local10 != _local8){
_local11 = _local6[_local8];
_local6[_local8] = _local6[_local10];
_local6[_local10] = _local11;
};
_local8++;
};
var _local9:* = 0;
while (_local9 < m_colors) {
_local7 = (_local6[_local9] + 1);
if (((((((((((((!((_local7 == null))) && (!((_local7 == undefined))))) && (!((_local7 == _arg1))))) && (!((_local7 == _arg2))))) && (!((_local7 == _arg3))))) && (!((_local7 == _arg4))))) && (!((_local7 == _arg5))))){
return (GetMat(_local7));
};
_local9++;
};
trace("Warning - UnmatchingBitmap Not Found..");
return (getRandomBitmap());
}
function getRandomBitmap(){
var _local1:* = (Math.round((Math.random() * (m_colors - 1))) + 1);
return (GetMat(_local1));
}
function MouseOverPanel(_arg1:MouseEvent3D):void{
_arg1.target.material._movie.play();
}
function MouseOutPanel(_arg1:MouseEvent3D):void{
_arg1.target.material._movie.gotoAndPlay(10);
}
function MoveBlocks(){
if (m_moveDir != -1){
if (m_moveDir == 0){
topHorzRow(m_moveRow, m_row);
leftVertRow(m_moveRow, m_row);
};
if (m_moveDir == 1){
topVertRow(-(m_moveRow), m_row);
rightVertRow(m_moveRow, m_row);
};
if (m_moveDir == 2){
leftHorzRow(m_moveRow, m_row);
rightHorzRow(-(m_moveRow), m_row);
};
};
}
function resetLine(_arg1:MouseEvent):void{
if (((((!(m_pause)) && (!(m_startMove)))) && ((m_timer > 0.5)))){
m_startMove = true;
clearLines();
};
}
function resetDrawLine(_arg1:MouseEvent3D):void{
if (((((!(m_pause)) && (!(m_startMove)))) && ((m_timer > 0.5)))){
m_startMove = true;
clearLines();
};
}
function clearLines(){
m_mvSide = -1;
m_mvx = -1;
m_mvy = -1;
m_lineStart.width = 0;
m_lineStart.height = 0;
m_lineEnd.width = 0;
m_lineStart.height = 0;
m_line.width = 0;
m_line.height = 0;
m_lineWrap.width = 0;
m_lineWrap.height = 0;
}
function drawLine(_arg1:MouseEvent3D):void{
var _local4:*;
var _local5:*;
var _local6:*;
var _local7:*;
var _local8:*;
var _local2:* = 10;
var _local3:* = 7;
m_lineEnd.rotationZ = 0;
m_lineEnd.rotationX = 0;
m_lineEnd.rotationY = 0;
m_lineWrap.width = 0;
m_lineWrap.height = 0;
if (m_mvSide != -1){
m_lineEnd.width = 20;
m_lineEnd.height = 20;
if (_arg1.target.y == 100){
_local4 = _arg1.target.x;
_local5 = _arg1.target.z;
m_lineEnd.x = _local4;
m_lineEnd.z = _local5;
m_lineEnd.y = 103;
};
if (_arg1.target.x == 100){
_local4 = _arg1.target.z;
_local5 = _arg1.target.y;
trace("Wrap round left side");
m_lineEnd.z = _local4;
m_lineEnd.y = _local5;
m_lineEnd.x = 103;
m_lineEnd.rotationZ = -90;
};
if (_arg1.target.z == 100){
trace("Wrap round right side");
_local4 = _arg1.target.x;
_local5 = _arg1.target.y;
m_lineEnd.x = _local4;
m_lineEnd.y = _local5;
m_lineEnd.z = 103;
m_lineEnd.rotationX = -90;
};
if (m_mvSide == 0){
m_disance = 0;
if (_arg1.target.y == 100){
_local6 = (_local4 - m_mvx);
_local7 = (_local5 - m_mvy);
};
if (_arg1.target.x == 100){
_local6 = ((100 - m_mvx) + 8);
_local7 = (_local4 - m_mvy);
if (_local7 == 0){
_local8 = ((100 - _local5) + 5);
m_disance = (m_disance + (100 - _local5));
m_lineWrap.x = 102;
m_lineWrap.z = _local4;
m_lineWrap.y = ((_local5 + (_local8 / 2)) + 2);
m_lineWrap.width = (Math.abs(_local8) - _local2);
m_lineWrap.height = _local3;
m_lineWrap.rotationZ = -90;
m_lineWrap.rotationX = 0;
m_lineWrap.rotationY = 0;
};
};
if (_arg1.target.z == 100){
_local6 = (_local4 - m_mvx);
_local7 = ((100 - m_mvy) + 8);
if (_local6 == 0){
_local8 = ((100 - _local5) + 5);
m_disance = (m_disance + (100 - _local5));
m_lineWrap.z = 102;
m_lineWrap.x = _local4;
m_lineWrap.y = ((_local5 + (_local8 / 2)) + 2);
m_lineWrap.width = _local3;
m_lineWrap.height = (Math.abs(_local8) - _local2);
m_lineWrap.rotationX = -90;
m_lineWrap.rotationY = 0;
m_lineWrap.rotationZ = 0;
};
};
trace(((("TOOO Top: x:" + _local4) + " z:") + _local5));
if (((!((_local6 == 0))) && (!((_local7 == 0))))){
m_moveDir = -1;
m_line.width = 0;
m_line.height = 0;
m_lineEnd.width = 0;
m_lineEnd.height = 0;
};
if (_local6 == 0){
m_moveDir = 1;
m_row = ((m_mvx / 50) + 2);
m_disance = (m_disance + _local7);
trace(((("Test:" + m_mvy) + ":") + m_row));
m_line.x = m_mvx;
m_line.z = (m_mvy + (_local7 / 2));
m_line.width = _local3;
m_line.height = (Math.abs(_local7) - _local2);
};
if (_local7 == 0){
m_moveDir = 0;
m_row = ((m_mvy / 50) + 2);
m_disance = (m_disance + _local6);
trace(((("Test:" + m_mvy) + ":") + m_row));
m_line.x = (m_mvx + (_local6 / 2));
m_line.z = m_mvy;
m_line.width = (Math.abs(_local6) - _local2);
m_line.height = _local3;
};
m_line.y = 102;
m_line.rotationY = 0;
m_line.rotationX = 0;
m_line.rotationZ = 0;
};
if (m_mvSide == 1){
m_disance = 0;
if (_arg1.target.y == 100){
_local6 = (_local5 - m_mvx);
_local7 = ((100 - m_mvy) + 8);
if (_local6 == 0){
_local8 = ((100 - _local4) + 8);
m_disance = (m_disance - (50 - _local4));
m_lineWrap.y = 102;
m_lineWrap.x = (_local4 + (_local8 / 2));
m_lineWrap.z = _local5;
m_lineWrap.width = (Math.abs(_local8) - _local2);
m_lineWrap.height = _local3;
m_lineWrap.rotationY = 0;
m_lineWrap.rotationX = 0;
m_lineWrap.rotationZ = 0;
};
};
if (_arg1.target.x == 100){
_local6 = (_local4 - m_mvx);
_local7 = (_local5 - m_mvy);
};
if (_arg1.target.z == 100){
_local6 = ((100 - m_mvx) + 8);
_local7 = (_local5 - m_mvy);
if (_local7 == 0){
_local8 = ((100 - _local4) + 5);
m_disance = (m_disance + (100 - _local4));
m_lineWrap.z = 102;
m_lineWrap.x = ((_local4 + (_local8 / 2)) + 2);
m_lineWrap.y = _local5;
m_lineWrap.width = (Math.abs(_local8) - _local2);
m_lineWrap.height = _local3;
m_lineWrap.rotationX = -90;
m_lineWrap.rotationY = 0;
m_lineWrap.rotationZ = 0;
};
};
trace(((("TOO Left: y:" + _local4) + " z:") + _local5));
trace(((("HV:" + _local6) + "|") + _local7));
if (((!((_local6 == 0))) && (!((_local7 == 0))))){
m_moveDir = -1;
m_line.width = 0;
m_line.height = 0;
m_lineEnd.width = 0;
m_lineEnd.height = 0;
};
if (_local6 == 0){
m_moveDir = 0;
m_row = ((m_mvx / 50) + 2);
m_disance = (m_disance + -(_local7));
m_line.z = m_mvx;
m_line.y = (m_mvy + (_local7 / 2));
m_line.width = (Math.abs(_local7) - _local2);
m_line.height = _local3;
};
if (_local7 == 0){
m_moveDir = 2;
m_row = ((m_mvy / 50) + 2);
m_disance = (m_disance + _local6);
m_line.z = (m_mvx + (_local6 / 2));
m_line.y = m_mvy;
m_line.width = _local3;
m_line.height = (Math.abs(_local6) - _local2);
};
m_line.x = 102;
m_line.rotationZ = -90;
m_line.rotationX = 0;
m_line.rotationY = 0;
};
if (m_mvSide == 2){
m_disance = 0;
if (_arg1.target.y == 100){
_local6 = (_local4 - m_mvx);
_local7 = ((100 - m_mvy) + 8);
if (_local6 == 0){
_local8 = ((100 - _local5) + 8);
m_disance = (m_disance - (50 - _local5));
m_lineWrap.y = 102;
m_lineWrap.x = _local4;
m_lineWrap.z = (_local5 + (_local8 / 2));
m_lineWrap.width = _local3;
m_lineWrap.height = (Math.abs(_local8) - _local2);
m_lineWrap.rotationY = 0;
m_lineWrap.rotationX = 0;
m_lineWrap.rotationZ = 0;
};
};
if (_arg1.target.x == 100){
_local6 = ((100 - m_mvx) + 8);
_local7 = (_local5 - m_mvy);
if (_local7 == 0){
_local8 = ((100 - _local4) + 5);
m_disance = (m_disance - (50 - _local4));
m_lineWrap.x = 102;
m_lineWrap.z = ((_local4 + (_local8 / 2)) + 2);
m_lineWrap.y = _local5;
m_lineWrap.width = _local3;
m_lineWrap.height = (Math.abs(_local8) - _local2);
m_lineWrap.rotationZ = -90;
m_lineWrap.rotationX = 0;
m_lineWrap.rotationY = 0;
};
};
if (_arg1.target.z == 100){
_local6 = (_local4 - m_mvx);
_local7 = (_local5 - m_mvy);
};
_local4 = _arg1.target.x;
_local5 = _arg1.target.y;
m_lineEnd.x = _local4;
m_lineEnd.y = _local5;
trace(((("TOOO Right: y:" + _local5) + " x:") + _local4));
if (((!((_local6 == 0))) && (!((_local7 == 0))))){
m_moveDir = -1;
m_line.width = 0;
m_line.height = 0;
m_lineEnd.width = 0;
m_lineEnd.height = 0;
};
if (_local6 == 0){
m_moveDir = 1;
m_row = ((m_mvx / 50) + 2);
m_disance = (m_disance + -(_local7));
m_line.x = m_mvx;
m_line.y = (m_mvy + (_local7 / 2));
m_line.width = _local3;
m_line.height = (Math.abs(_local7) - _local2);
};
if (_local7 == 0){
m_moveDir = 2;
m_row = ((m_mvy / 50) + 2);
m_disance = (m_disance + -(_local6));
m_line.x = (m_mvx + (_local6 / 2));
m_line.y = m_mvy;
m_line.width = (Math.abs(_local6) - _local2);
m_line.height = _local3;
trace(("disanceC:" + m_disance));
};
m_line.z = 102;
m_line.rotationX = -90;
m_line.rotationY = 0;
m_line.rotationZ = 0;
};
};
m_disance = (Math.floor((m_disance / 50)) * 50);
}
function panelClicked(_arg1:MouseEvent3D):void{
if (((((m_pause) || (m_startMove))) || ((m_timer < 0.5)))){
return;
};
m_moveDir = -1;
m_moveRow = 0;
m_row = -1;
m_startMove = false;
m_lineStart.rotationZ = 0;
m_lineStart.rotationX = 0;
m_lineStart.rotationY = 0;
m_lineStart.width = 20;
m_lineStart.height = 20;
m_lineEnd.width = 0;
m_lineEnd.height = 0;
if (_arg1.target.y == 100){
m_mvSide = 0;
m_mvx = _arg1.target.x;
m_mvy = _arg1.target.z;
m_lineStart.y = 103;
m_lineStart.x = m_mvx;
m_lineStart.z = m_mvy;
trace(((("Top: x:" + m_mvx) + " z:") + m_mvy));
};
if (_arg1.target.x == 100){
m_mvSide = 1;
m_mvx = _arg1.target.z;
m_mvy = _arg1.target.y;
m_lineStart.z = m_mvx;
m_lineStart.y = m_mvy;
m_lineStart.x = 102;
m_lineStart.rotationZ = -90;
trace(((("Left: y:" + m_mvx) + " z:") + m_mvy));
};
if (_arg1.target.z == 100){
m_mvSide = 2;
m_mvx = _arg1.target.x;
m_mvy = _arg1.target.y;
trace(((("Right: y:" + m_mvy) + " x:") + m_mvx));
m_lineStart.z = 102;
m_lineStart.y = m_mvy;
m_lineStart.x = m_mvx;
m_lineStart.rotationX = -90;
};
}
public function startWrap(_arg1:MouseEvent3D){
var _local2:*;
var _local3:*;
var _local4:*;
var _local5:*;
var _local6:*;
var _local7:*;
var _local8:*;
if (m_leng < 15){
_local2 = ((_arg1.uv.u * _arg1.target.width) - m_dir_start.x);
_local3 = ((_arg1.uv.v * _arg1.target.height) - m_dir_start.y);
m_snap = m_leng;
_local4 = Math.atan2(_local2, _local3);
_local5 = (_local4 / (Math.PI / 180));
_local6 = Math.round(((_local5 + 90) / 90));
if (m_angle != _local6){
m_angle = _local6;
};
_local7 = (mouseX - m_start.x);
_local8 = (mouseY - m_start.y);
m_dir = Math.atan2(_local7, _local8);
};
}
public function stopDirWrap(_arg1:MouseEvent3D){
}
public function stopWrap(_arg1:MouseEvent){
}
public function resetCube(){
var _local3:*;
var _local4:*;
var _local5:*;
var _local1:* = (m_view.scene.children.length - 1);
while (_local1 > -1) {
_local4 = m_view.scene.children[_local1];
if ((((_local4 is PlaneEx)) && (_local4.m_cleanup))){
m_view.scene.removeChild(_local4);
_local4.m_removed = true;
};
_local1--;
};
var _local2:* = 0;
_local3 = 0;
while (_local3 < 4) {
_local5 = 0;
while (_local5 < 4) {
if (top[_local2]){
top[_local2].x = ((_local5 * 50) - 75);
top[_local2].z = ((_local3 * 50) - 75);
top[_local2].y = m_cubeSize;
top[_local2].width = 50;
top[_local2].height = 50;
top[_local2].material.scaleX = 1;
top[_local2].material.scaleY = 1;
top[_local2].material.offsetX = 0;
top[_local2].material.offsetY = 0;
top[_local2].rotationY = 0;
top[_local2].rotationX = 0;
top[_local2].rotationZ = 0;
};
_local2++;
_local5++;
};
_local3++;
};
_local2 = 0;
_local3 = 0;
while (_local3 < 4) {
_local5 = 0;
while (_local5 < 4) {
if (left[_local2]){
left[_local2].z = ((_local5 * 50) - 75);
left[_local2].y = ((_local3 * 50) - 75);
left[_local2].width = 50;
left[_local2].height = 50;
left[_local2].material.scaleX = 1;
left[_local2].material.scaleY = 1;
left[_local2].material.offsetX = 0;
left[_local2].material.offsetY = 0;
left[_local2].rotationZ = -90;
};
_local2++;
_local5++;
};
_local3++;
};
_local2 = 0;
_local3 = 0;
while (_local3 < 4) {
_local5 = 0;
while (_local5 < 4) {
if (right[_local2]){
right[_local2].x = ((_local5 * 50) - 75);
right[_local2].y = ((_local3 * 50) - 75);
right[_local2].width = 50;
right[_local2].height = 50;
right[_local2].material.scaleX = 1;
right[_local2].material.scaleY = 1;
right[_local2].material.offsetX = 0;
right[_local2].material.offsetY = 0;
right[_local2].rotationX = -90;
};
_local2++;
_local5++;
};
_local3++;
};
}
public function FindMatch():Boolean{
var _local5:*;
var _local6:*;
var _local9:*;
var _local10:*;
var _local11:*;
var _local12:int;
var _local13:int;
var _local14:int;
var _local15:*;
var _local16:*;
var _local17:*;
var _local18:*;
var _local19:*;
var _local20:*;
var _local21:*;
var _local22:*;
var _local23:*;
var _local24:*;
var _local25:*;
var _local26:*;
var _local27:*;
var _local28:*;
var _local29:*;
var _local30:*;
var _local31:*;
var _local32:*;
var _local33:*;
var _local34:*;
var _local35:*;
var _local1:int = Math.floor((m_disance / 50));
if (!_local1){
_local1 = 0;
};
var _local2:* = new Array();
var _local3:* = new Array();
var _local4:* = new Array();
_local5 = 0;
while (_local5 < top.length) {
if (((top[_local5]) && (top[_local5].material))){
top[_local5].rotationY = 0;
_local2[_local5] = top[_local5].material.m_id;
};
_local5++;
};
_local5 = 0;
while (_local5 < left.length) {
if (((left[_local5]) && (left[_local5].material))){
left[_local5].rotationZ = -90;
_local3[_local5] = left[_local5].material.m_id;
};
_local5++;
};
_local5 = 0;
while (_local5 < right.length) {
if (((right[_local5]) && (right[_local5].material))){
right[_local5].rotationX = -90;
_local4[_local5] = right[_local5].material.m_id;
};
_local5++;
};
if (m_moveDir == 0){
trace((((("move top horz row:" + m_row) + " ") + _local1) + " spaces"));
_local9 = 0;
while (_local9 < 4) {
_local11 = GetIndex((_local9 - _local1), m_row);
if (top[_local11]){
top[GetIndex(_local9, m_row)].material = GetMat(_local2[_local11]);
} else {
trace(((((("Warning din't coppy TopX1 " + _local1) + " ") + _local11) + " : ") + top[_local11]));
return (false);
};
_local9++;
};
_local10 = 0;
while (_local10 < 4) {
_local11 = GetIndex(m_row, (_local10 + _local1));
if (left[_local11]){
left[GetIndex(m_row, _local10)].material = GetMat(_local3[_local11]);
} else {
trace(((((("Warning din't coppy LeftY1 " + _local1) + " ") + _local11) + " : ") + left[_local11]));
return (false);
};
_local10++;
};
};
if (m_moveDir == 1){
trace((((("move top vert m_row:" + m_row) + " ") + _local1) + " spaces"));
_local10 = 0;
while (_local10 < 4) {
_local11 = GetIndex(m_row, (_local10 - _local1));
if (top[_local11]){
top[GetIndex(m_row, _local10)].material = GetMat(_local2[_local11]);
} else {
trace(((((("Warning din't coppy TopY1 " + _local1) + " ") + _local11) + " : ") + top[_local11]));
return (false);
};
_local10++;
};
_local10 = 0;
while (_local10 < 4) {
_local11 = GetIndex(m_row, (_local10 + _local1));
if (right[_local11]){
right[GetIndex(m_row, _local10)].material = GetMat(_local4[_local11]);
} else {
trace(((((("Warning din't coppy RightY1 " + _local1) + " ") + _local11) + " : ") + right[_local11]));
return (false);
};
_local10++;
};
};
if (m_moveDir == 2){
_local9 = 0;
while (_local9 < 4) {
_local11 = GetIndex((_local9 - _local1), m_row);
if (left[_local11]){
left[GetIndex(_local9, m_row)].material = GetMat(_local3[_local11]);
} else {
trace(((((("Warning din't coppy LeftX1 " + _local1) + " ") + _local11) + " : ") + left[_local11]));
return (false);
};
_local9++;
};
_local9 = 0;
while (_local9 < 4) {
_local11 = GetIndex((_local9 + _local1), m_row);
if (right[_local11]){
right[GetIndex(_local9, m_row)].material = GetMat(_local4[_local11]);
} else {
trace(((((("Warning din't coppy RightX1 " + _local1) + " ") + _local11) + " : ") + right[_local11]));
return (false);
};
_local9++;
};
};
m_moveDir = -1;
_local6 = 0;
while (_local6 < m_list.length) {
m_list[_local6] = null;
_local6++;
};
m_list = new Array();
_local6 = 0;
while (_local6 < m_clear.length) {
m_clear[_local6] = null;
_local6++;
};
m_clear = new Array();
var _local7:Boolean;
var _local8:* = 0;
while (_local8 < 4) {
_local9 = 0;
while (_local9 < 4) {
_local12 = 0;
_local13 = 0;
_local14 = 0;
_local15 = null;
_local16 = null;
_local17 = null;
_local18 = null;
_local19 = null;
_local15 = top[GetIndex(_local9, _local8)].material.m_id;
if (((!((_local15 == null))) && (!((_local15 == 0))))){
_local30 = 0;
_local31 = 0;
_local32 = 0;
_local33 = 0;
if ((_local9 + 1) > 3){
if (_local15 == left[GetIndex(_local8, 3)].material.m_id){
_local30 = GetId(1, _local8, 3);
_local13++;
};
} else {
if (_local15 == top[GetIndex((_local9 + 1), _local8)].material.m_id){
_local30 = GetId(0, (_local9 + 1), _local8);
_local13++;
};
};
if (((((_local9 - 1) > -1)) && ((_local15 == top[GetIndex((_local9 - 1), _local8)].material.m_id)))){
_local31 = GetId(0, (_local9 - 1), _local8);
_local13++;
};
if ((_local8 + 1) > 3){
if (_local15 == right[GetIndex(_local9, 3)].material.m_id){
_local33 = GetId(2, _local9, 3);
_local13++;
};
} else {
if (_local15 == top[GetIndex(_local9, (_local8 + 1))].material.m_id){
_local33 = GetId(0, _local9, (_local8 + 1));
_local13++;
};
};
if (((((_local8 - 1) > -1)) && ((_local15 == top[GetIndex(_local9, (_local8 - 1))].material.m_id)))){
_local32 = GetId(0, _local9, (_local8 - 1));
_local13++;
};
if (_local13 > 0){
_local7 = true;
clearBlocks(new position(GetId(0, _local9, _local8), 0, _local9, _local8, _local30, _local31, _local32, _local33));
};
};
_local20 = null;
_local21 = null;
_local22 = null;
_local23 = null;
_local24 = null;
_local20 = left[GetIndex(_local9, _local8)].material.m_id;
if (((!((_local20 == null))) && (!((_local20 == 0))))){
_local30 = 0;
_local31 = 0;
_local32 = 0;
_local33 = 0;
if ((_local9 + 1) > 3){
if (_local20 == right[GetIndex(3, _local8)].material.m_id){
_local30 = GetId(2, 3, _local8);
_local14++;
};
} else {
if (_local20 == left[GetIndex((_local9 + 1), _local8)].material.m_id){
_local30 = GetId(1, (_local9 + 1), _local8);
_local14++;
};
};
if (((((_local9 - 1) > -1)) && ((_local20 == left[GetIndex((_local9 - 1), _local8)].material.m_id)))){
_local31 = GetId(1, (_local9 - 1), _local8);
_local14++;
};
if ((_local8 + 1) > 3){
if (_local20 == top[GetIndex(3, _local9)].material.m_id){
_local33 = GetId(0, 3, _local9);
_local14++;
};
} else {
if (_local20 == left[GetIndex(_local9, (_local8 + 1))].material.m_id){
_local33 = GetId(1, _local9, (_local8 + 1));
_local14++;
};
};
if ((_local8 - 1) > -1){
if (_local20 == left[GetIndex(_local9, (_local8 - 1))].material.m_id){
_local32 = GetId(1, _local9, (_local8 - 1));
_local14++;
};
};
if (_local14 > 0){
_local7 = true;
clearBlocks(new position(GetId(1, _local9, _local8), 1, _local9, _local8, _local30, _local31, _local32, _local33));
};
};
_local25 = null;
_local26 = null;
_local27 = null;
_local28 = null;
_local29 = null;
_local25 = right[GetIndex(_local9, _local8)].material.m_id;
if (((!((_local25 == null))) && (!((_local25 == 0))))){
_local30 = 0;
_local31 = 0;
_local32 = 0;
_local33 = 0;
if ((_local9 + 1) > 3){
if (_local25 == left[GetIndex(3, _local8)].material.m_id){
_local30 = GetId(1, 3, _local8);
_local12++;
};
} else {
if (_local25 == right[GetIndex((_local9 + 1), _local8)].material.m_id){
_local30 = GetId(2, (_local9 + 1), _local8);
_local12++;
};
};
if ((_local9 - 1) > -1){
if (_local25 == right[GetIndex((_local9 - 1), _local8)].material.m_id){
_local31 = GetId(2, (_local9 - 1), _local8);
_local12++;
};
};
if ((_local8 + 1) > 3){
if (_local25 == top[GetIndex(_local9, 3)].material.m_id){
_local33 = GetId(0, _local9, 3);
_local12++;
};
} else {
if (_local25 == right[GetIndex(_local9, (_local8 + 1))].material.m_id){
_local33 = GetId(2, _local9, (_local8 + 1));
_local12++;
};
};
if (((((_local8 - 1) > -1)) && ((_local25 == right[GetIndex(_local9, (_local8 - 1))].material.m_id)))){
_local32 = GetId(2, _local9, (_local8 - 1));
_local12++;
};
if (_local12 > 0){
_local7 = true;
clearBlocks(new position(GetId(2, _local9, _local8), 2, _local9, _local8, _local30, _local31, _local32, _local33));
};
};
_local9++;
};
_local8++;
};
if (_local7){
_local34 = 1;
_local6 = 0;
while (_local6 < m_list.length) {
if (m_list[_local6].m_tag == 0){
LableConnections(_local34, m_list[_local6]);
_local35 = 0;
_local15 = 0;
while (_local15 < m_list.length) {
if (m_list[_local15].m_tag == _local34){
_local35++;
};
_local15++;
};
if (_local35 > 4){
_local15 = 0;
while (_local15 < m_list.length) {
if (m_list[_local15].m_tag == _local34){
m_clear.push(m_list[_local15]);
};
_local15++;
};
};
_local34++;
};
_local6++;
};
if (m_clear.length > 4){
AddScore(m_clear.length);
m_switch = 20;
m_soundFinish.play();
};
};
return (false);
}
public function LableConnections(_arg1, _arg2){
if (((_arg2) && ((_arg2.m_tag == 0)))){
_arg2.m_tag = _arg1;
if (_arg2.m_up > 0){
LableConnections(_arg1, BlockFromId(_arg2.m_up));
};
if (_arg2.m_down > 0){
LableConnections(_arg1, BlockFromId(_arg2.m_down));
};
if (_arg2.m_left > 0){
LableConnections(_arg1, BlockFromId(_arg2.m_left));
};
if (_arg2.m_right > 0){
LableConnections(_arg1, BlockFromId(_arg2.m_right));
};
};
}
public function BlockFromId(_arg1){
var _local2:* = 0;
while (_local2 < m_list.length) {
if (m_list[_local2].m_id == _arg1){
return (m_list[_local2]);
};
_local2++;
};
trace(("Didn't find ID:" + _arg1));
return (null);
}
public function killCube(){
var _local2:*;
var _local1:* = (m_timer * 100);
trace(("m:" + _local1));
_local2 = 0;
while (_local2 < 18) {
if (top[_local2]){
top[_local2].width = _local1;
top[_local2].height = _local1;
};
_local2++;
};
_local2 = 0;
while (_local2 < 18) {
if (left[_local2]){
left[_local2].width = _local1;
left[_local2].height = _local1;
};
_local2++;
};
_local2 = 0;
while (_local2 < 18) {
if (right[_local2]){
right[_local2].width = _local1;
right[_local2].height = _local1;
};
_local2++;
};
}
public function UpdateMatchingColors(){
var _local2:*;
var _local3:*;
var _local4:*;
var _local5:*;
var _local6:*;
var _local7:*;
var _local8:*;
var _local9:*;
var _local10:*;
var _local11:*;
var _local1:* = 0;
while (_local1 < m_clear.length) {
_local2 = m_clear[_local1].side;
_local3 = m_clear[_local1].x;
_local4 = m_clear[_local1].y;
_local5 = GetIndex(_local3, _local4);
if ((((_local2 == 0)) && (top[_local5]))){
if (m_switch > 10){
top[_local5].width = (m_switch * 2.5);
top[_local5].height = (m_switch * 2.5);
};
if (m_switch == 10){
_local6 = top[_local5].material.m_id;
if ((_local3 + 1) > 3){
_local8 = left[GetIndex(_local4, 3)].material.m_id;
} else {
_local8 = top[GetIndex((_local3 + 1), _local4)].material.m_id;
};
if ((_local3 - 1) > -1){
_local9 = top[GetIndex((_local3 - 1), _local4)].material.m_id;
};
if ((_local4 + 1) > 3){
_local10 = right[GetIndex(_local3, 3)].material.m_id;
} else {
_local10 = top[GetIndex(_local3, (_local4 + 1))].material.m_id;
};
if ((_local4 - 1) > -1){
_local11 = top[GetIndex(_local3, (_local4 - 1))].material.m_id;
};
_local7 = getUnmatchingBitmap(_local6, _local8, _local9, _local10, _local11);
if (!_local7){
top[_local5].material = getRandomBitmap();
} else {
top[_local5].material = _local7;
};
};
if (m_switch < 10){
top[_local5].width = ((10 - m_switch) * 5);
top[_local5].height = ((10 - m_switch) * 5);
};
};
if ((((_local2 == 1)) && (left[_local5]))){
if (m_switch > 10){
left[_local5].width = (m_switch * 2.5);
left[_local5].height = (m_switch * 2.5);
};
if (m_switch == 10){
_local6 = left[_local5].material.m_id;
if ((_local3 + 1) > 3){
_local8 = right[GetIndex(3, _local4)].material.m_id;
} else {
_local8 = left[GetIndex((_local3 + 1), _local4)].material.m_id;
};
if ((_local3 - 1) > -1){
_local9 = left[GetIndex((_local3 - 1), _local4)].material.m_id;
};
if ((_local4 + 1) > 3){
_local10 = top[GetIndex(3, _local3)].material.m_id;
} else {
_local10 = left[GetIndex(_local3, (_local4 + 1))].material.m_id;
};
if ((_local4 - 1) > -1){
_local11 = left[GetIndex(_local3, (_local4 - 1))].material.m_id;
};
_local7 = getUnmatchingBitmap(_local6, _local8, _local9, _local10, _local11);
if (!_local7){
left[_local5].material = getRandomBitmap();
} else {
left[_local5].material = _local7;
};
};
if (m_switch < 10){
left[_local5].width = ((10 - m_switch) * 5);
left[_local5].height = ((10 - m_switch) * 5);
};
};
if ((((_local2 == 2)) && (right[_local5]))){
if (m_switch > 10){
right[_local5].width = (m_switch * 2.5);
right[_local5].height = (m_switch * 2.5);
};
if (m_switch == 10){
_local6 = right[_local5].material.m_id;
if ((_local3 + 1) > 3){
_local8 = left[GetIndex(3, _local4)].material.m_id;
} else {
_local8 = right[GetIndex((_local3 + 1), _local4)].material.m_id;
};
if ((_local3 - 1) > -1){
_local9 = right[GetIndex((_local3 - 1), _local4)].material.m_id;
};
if ((_local4 + 1) > 3){
_local10 = top[GetIndex(_local3, 3)].material.m_id;
} else {
_local10 = right[GetIndex(_local3, (_local4 + 1))].material.m_id;
};
if ((_local4 - 1) > -1){
_local11 = right[GetIndex(_local3, (_local4 - 1))].material.m_id;
};
_local7 = getUnmatchingBitmap(_local6, _local8, _local9, _local10, _local11);
if (!_local7){
right[_local5].material = getRandomBitmap();
} else {
right[_local5].material = _local7;
};
};
if (m_switch < 10){
right[_local5].width = ((10 - m_switch) * 5);
right[_local5].height = ((10 - m_switch) * 5);
};
};
_local1++;
};
}
public function clearBlocks(_arg1){
var _local2:* = 0;
while (_local2 < m_list.length) {
if ((((((m_list[_local2].side == _arg1.side)) && ((m_list[_local2].x == _arg1.x)))) && ((m_list[_local2].y == _arg1.y)))){
return;
};
_local2++;
};
m_list.push(_arg1);
}
public function topHorzRow(_arg1, _arg2){
var _local6:*;
var _local7:*;
var _local8:*;
var _local9:*;
var _local3:* = 4;
var _local4:* = 0;
if (_arg1 < 0){
_local3 = (5 + Math.round((Math.abs(_arg1) / 50)));
} else {
_local4 = (-(Math.round((Math.abs(_arg1) / 50))) - 1);
};
var _local5:* = _local4;
while (_local5 < _local3) {
_local6 = GetIndex(_local5, _arg2);
if (((!(top[_local6])) || (top[_local6].m_removed))){
_local7 = 50;
top[_local6] = new PlaneEx(true, {width:_local7, height:_local7, segmentsH:1, segmentsW:1});
if (_local5 > 3){
_local8 = GetIndex(_arg2, (4 - (_local5 - 3)));
top[_local6].material = GetMat(left[_local8].material.m_id);
} else {
_local8 = GetIndex(_arg2, (-(_local5) - 1));
top[_local6].material = GetMat(left[_local8].material.m_id);
};
top[_local6].material.alpha = 1;
top[_local6].z = ((_arg2 * 50) - 75);
top[_local6].y = m_cubeSize;
top[_local6].rotationY = 0;
top[_local6].rotationX = 0;
top[_local6].rotationZ = 0;
m_view.scene.addChild(top[_local6]);
m_topCount++;
};
top[_local6].x = (((_local5 * 50) - 75) + _arg1);
if (top[_local6].x < -75){
_local9 = (50 + (top[_local6].x + 75));
if (_local9 < 0){
_local9 = 0;
};
top[_local6].width = _local9;
top[_local6].material.scaleX = (50 / _local9);
top[_local6].material.offsetX = (-(((50 - _local9) * 3)) * top[_local6].material.scaleX);
top[_local6].x = (top[_local6].x - ((top[_local6].x + 75) / 2));
} else {
if (top[_local6].x > 75){
_local9 = (50 - (top[_local6].x - 75));
if (_local9 < 0){
_local9 = 0;
};
top[_local6].width = _local9;
top[_local6].material.scaleX = (50 / _local9);
top[_local6].material.offsetX = 0;
top[_local6].x = (top[_local6].x - ((top[_local6].x - 75) / 2));
} else {
top[_local6].width = 50;
top[_local6].material.scaleX = 1;
top[_local6].material.offsetX = 0;
};
};
_local5++;
};
}
public function topVertRow(_arg1, _arg2){
var _local6:*;
var _local7:*;
var _local8:*;
var _local9:*;
var _local3:* = 4;
var _local4:* = 0;
if (_arg1 > 0){
_local3 = (5 + Math.round((Math.abs(_arg1) / 50)));
} else {
_local4 = (-(Math.round((Math.abs(_arg1) / 50))) - 1);
_local6 = GetIndex(_arg2, _local4);
};
var _local5:* = _local4;
while (_local5 < _local3) {
_local6 = GetIndex(_arg2, _local5);
if (((!(top[_local6])) || (top[_local6].m_removed))){
_local7 = 50;
top[_local6] = new PlaneEx(true, {width:_local7, height:_local7, segmentsH:1, segmentsW:1});
if (_local5 > 3){
_local8 = GetIndex(_arg2, (4 - (_local5 - 3)));
top[_local6].material = GetMat(right[_local8].material.m_id);
} else {
_local8 = GetIndex(_arg2, (-(_local5) - 1));
top[_local6].material = GetMat(right[_local8].material.m_id);
};
top[_local6].material.alpha = 1;
top[_local6].x = ((_arg2 * 50) - 75);
top[_local6].y = m_cubeSize;
top[_local6].rotationY = 0;
top[_local6].rotationX = 0;
top[_local6].rotationZ = 0;
m_view.scene.addChild(top[_local6]);
};
top[_local6].z = (((_local5 * 50) - 75) - _arg1);
if (top[_local6].z < -75){
_local9 = (50 + (top[_local6].z + 75));
if (_local9 < 0){
_local9 = 0;
};
top[_local6].height = _local9;
top[_local6].material.scaleY = (50 / _local9);
top[_local6].material.offsetY = 0;
top[_local6].z = (top[_local6].z - ((top[_local6].z + 75) / 2));
} else {
if (top[_local6].z > 75){
_local9 = (50 - (top[_local6].z - 75));
if (_local9 < 0){
_local9 = 0;
};
top[_local6].height = _local9;
top[_local6].material.scaleY = (50 / _local9);
top[_local6].material.offsetY = (-(((50 - _local9) * 3)) * top[_local6].material.scaleY);
top[_local6].z = (top[_local6].z - ((top[_local6].z - 75) / 2));
} else {
top[_local6].height = 50;
top[_local6].material.scaleY = 1;
top[_local6].material.offsetY = 0;
};
};
_local5++;
};
}
public function leftHorzRow(_arg1, _arg2){
var _local6:*;
var _local7:*;
var _local8:*;
var _local9:*;
var _local3:* = 4;
var _local4:* = 0;
if (_arg1 < 0){
_local3 = (5 + Math.round((Math.abs(_arg1) / 50)));
} else {
_local4 = (-(Math.round((Math.abs(_arg1) / 50))) - 1);
};
var _local5:* = _local4;
while (_local5 < _local3) {
_local6 = GetIndex(_local5, _arg2);
if (((!(left[_local6])) || (left[_local6].m_removed))){
_local7 = 50;
left[_local6] = new PlaneEx(true, {width:_local7, height:_local7, segmentsH:1, segmentsW:1});
if (_local5 > 3){
_local8 = GetIndex((4 - (_local5 - 3)), _arg2);
left[_local6].material = GetMat(right[_local8].material.m_id);
} else {
_local8 = GetIndex((-(_local5) - 1), _arg2);
left[_local6].material = GetMat(right[_local8].material.m_id);
};
left[_local6].material.alpha = 1;
left[_local6].x = m_cubeSize;
left[_local6].y = ((_arg2 * 50) - 75);
left[_local6].rotationZ = -90;
m_view.scene.addChild(left[_local6]);
};
left[_local6].z = (((_local5 * 50) - 75) + _arg1);
if (left[_local6].z < -75){
_local9 = (50 + (left[_local6].z + 75));
if (_local9 < 0){
_local9 = 0;
};
left[_local6].height = _local9;
left[_local6].material.scaleY = (50 / _local9);
left[_local6].material.offsetY = 0;
left[_local6].z = (left[_local6].z - ((left[_local6].z + 75) / 2));
} else {
if (left[_local6].z > 75){
_local9 = (50 - (left[_local6].z - 75));
if (_local9 < 0){
_local9 = 0;
};
left[_local6].height = _local9;
left[_local6].material.scaleY = (50 / _local9);
left[_local6].material.offsetY = (-(((50 - _local9) * 3)) * left[_local6].material.scaleY);
left[_local6].z = (left[_local6].z - ((left[_local6].z - 75) / 2));
} else {
left[_local6].height = 50;
left[_local6].material.scaleY = 1;
left[_local6].material.offsetY = 0;
};
};
_local5++;
};
}
public function leftVertRow(_arg1, _arg2){
var _local6:*;
var _local7:*;
var _local8:*;
var _local9:*;
var _local3:* = 4;
var _local4:* = 0;
if (_arg1 > 0){
_local3 = (5 + Math.round((Math.abs(_arg1) / 50)));
} else {
_local4 = (-(Math.round((Math.abs(_arg1) / 50))) - 1);
_local6 = GetIndex(_arg2, _local4);
};
var _local5:* = _local4;
while (_local5 < _local3) {
_local6 = GetIndex(_arg2, _local5);
if (((!(left[_local6])) || (left[_local6].m_removed))){
_local7 = 50;
left[_local6] = new PlaneEx(true, {width:_local7, height:_local7, segmentsH:1, segmentsW:1});
if (_local5 > 3){
_local8 = GetIndex((4 - (_local5 - 3)), _arg2);
left[_local6].material = GetMat(top[_local8].material.m_id);
} else {
_local8 = GetIndex((-(_local5) - 1), _arg2);
left[_local6].material = GetMat(top[_local8].material.m_id);
};
left[_local6].material.alpha = 1;
left[_local6].x = m_cubeSize;
left[_local6].z = ((_arg2 * 50) - 75);
left[_local6].rotationZ = -90;
m_view.scene.addChild(left[_local6]);
};
left[_local6].y = (((_local5 * 50) - 75) - _arg1);
if (left[_local6].y < -75){
_local9 = (50 + (left[_local6].y + 75));
if (_local9 < 0){
_local9 = 0;
};
left[_local6].width = _local9;
left[_local6].material.scaleX = (50 / _local9);
left[_local6].material.offsetX = 0;
left[_local6].y = (left[_local6].y - ((left[_local6].y + 75) / 2));
} else {
if (left[_local6].y > 75){
_local9 = (50 - (left[_local6].y - 75));
if (_local9 < 0){
_local9 = 0;
};
left[_local6].width = _local9;
left[_local6].material.scaleX = (50 / _local9);
left[_local6].material.offsetX = (-(((50 - _local9) * 3)) * left[_local6].material.scaleX);
left[_local6].y = (left[_local6].y - ((left[_local6].y - 75) / 2));
} else {
left[_local6].width = 50;
left[_local6].material.scaleX = 1;
left[_local6].material.offsetX = 0;
};
};
_local5++;
};
}
public function rightHorzRow(_arg1, _arg2){
var _local6:*;
var _local7:*;
var _local8:*;
var _local9:*;
var _local3:* = 4;
var _local4:* = 0;
if (_arg1 < 0){
_local3 = (5 + Math.round((Math.abs(_arg1) / 50)));
} else {
_local4 = (-(Math.round((Math.abs(_arg1) / 50))) - 1);
};
var _local5:* = _local4;
while (_local5 < _local3) {
_local6 = GetIndex(_local5, _arg2);
if (((!(right[_local6])) || (right[_local6].m_removed))){
_local7 = 50;
right[_local6] = new PlaneEx(true, {width:_local7, height:_local7, segmentsH:1, segmentsW:1});
if (_local5 > 3){
_local8 = GetIndex((4 - (_local5 - 3)), _arg2);
right[_local6].material = GetMat(left[_local8].material.m_id);
} else {
_local8 = GetIndex((-(_local5) - 1), _arg2);
right[_local6].material = GetMat(left[_local8].material.m_id);
};
right[_local6].material.alpha = 1;
right[_local6].z = m_cubeSize;
right[_local6].y = ((_arg2 * 50) - 75);
right[_local6].rotationX = -90;
m_view.scene.addChild(right[_local6]);
};
right[_local6].x = (((_local5 * 50) - 75) + _arg1);
if (right[_local6].x < -75){
_local9 = (50 + (right[_local6].x + 75));
if (_local9 < 0){
_local9 = 0;
};
right[_local6].width = _local9;
right[_local6].material.scaleX = (50 / _local9);
right[_local6].material.offsetX = (-(((50 - _local9) * 3)) * right[_local6].material.scaleX);
right[_local6].x = (right[_local6].x - ((right[_local6].x + 75) / 2));
} else {
if (right[_local6].x > 75){
_local9 = (50 - (right[_local6].x - 75));
if (_local9 < 0){
_local9 = 0;
};
right[_local6].width = _local9;
right[_local6].material.scaleX = (50 / _local9);
right[_local6].material.offsetX = 0;
right[_local6].x = (right[_local6].x - ((right[_local6].x - 75) / 2));
} else {
right[_local6].width = 50;
right[_local6].material.scaleX = 1;
right[_local6].material.offsetX = 0;
};
};
_local5++;
};
}
public function rightVertRow(_arg1, _arg2){
var _local6:*;
var _local7:*;
var _local8:*;
var _local9:*;
var _local3:* = 4;
var _local4:* = 0;
if (_arg1 > 0){
_local3 = (5 + Math.round((Math.abs(_arg1) / 50)));
} else {
_local4 = (-(Math.round((Math.abs(_arg1) / 50))) - 1);
_local6 = GetIndex(_arg2, _local4);
};
var _local5:* = _local4;
while (_local5 < _local3) {
_local6 = GetIndex(_arg2, _local5);
if (((!(right[_local6])) || (right[_local6].m_removed))){
_local7 = 50;
right[_local6] = new PlaneEx(true, {width:_local7, height:_local7, segmentsH:1, segmentsW:1});
if (_local5 > 3){
_local8 = GetIndex(_arg2, (4 - (_local5 - 3)));
right[_local6].material = GetMat(top[_local8].material.m_id);
} else {
_local8 = GetIndex(_arg2, (-(_local5) - 1));
right[_local6].material = GetMat(top[_local8].material.m_id);
};
right[_local6].z = m_cubeSize;
right[_local6].x = ((_arg2 * 50) - 75);
right[_local6].rotationX = -90;
m_view.scene.addChild(right[_local6]);
};
right[_local6].y = (((_local5 * 50) - 75) - _arg1);
if (right[_local6].y < -75){
_local9 = (50 + (right[_local6].y + 75));
if (_local9 < 0){
_local9 = 0;
};
right[_local6].height = _local9;
right[_local6].material.scaleY = (50 / _local9);
right[_local6].material.offsetY = (-(((50 - _local9) * 3)) * right[_local6].material.scaleY);
right[_local6].y = (right[_local6].y - ((right[_local6].y + 75) / 2));
} else {
if (right[_local6].y > 75){
_local9 = (50 - (right[_local6].y - 75));
if (_local9 < 0){
_local9 = 0;
};
right[_local6].height = _local9;
right[_local6].material.scaleY = (50 / _local9);
right[_local6].material.offsetY = 0;
right[_local6].y = (right[_local6].y - ((right[_local6].y - 75) / 2));
} else {
right[_local6].height = 50;
right[_local6].material.scaleY = 1;
right[_local6].material.offsetY = 0;
};
};
_local5++;
};
}
public function GetId(_arg1, _arg2, _arg3):int{
return ((((_arg1 * 100) + ((_arg2 * 10) + _arg3)) + 1));
}
public function GetIndex(_arg1, _arg2):int{
var _local3:* = ((_arg2 * 4) + _arg1);
if ((((((((_arg1 > 3)) || ((_arg2 > 3)))) || ((_arg1 < 0)))) || ((_arg2 < 0)))){
_local3 = (_local3 + 40);
};
return (_local3);
}
private function restartGame(_arg1:MouseEvent):void{
var _local2:*;
m_menu.mainMenu.visible = false;
m_menu.credits.visible = false;
m_menu.stoped.visible = false;
m_menu.credits.visible = false;
m_menu.instructions.visible = false;
if (m_menu.gameOver){
m_menu.gameOver.visible = false;
};
m_timer = 0;
m_pause = false;
m_startup = true;
m_score = 0;
AddScore(0);
updateProgress();
_local2 = 0;
while (_local2 < 18) {
if (top[_local2]){
top[_local2].material = getRandomBitmap();
top[_local2].width = 50;
top[_local2].height = 50;
};
_local2++;
};
_local2 = 0;
while (_local2 < 18) {
if (left[_local2]){
left[_local2].material = getRandomBitmap();
left[_local2].width = 50;
left[_local2].height = 50;
};
_local2++;
};
_local2 = 0;
while (_local2 < 18) {
if (right[_local2]){
right[_local2].material = getRandomBitmap();
right[_local2].width = 50;
right[_local2].height = 50;
};
_local2++;
};
removeDuplicates();
}
private function onEnterFrame(_arg1:Event):void{
var _local2:*;
var _local3:Number;
var _local4:*;
var _local5:*;
var _local6:*;
if (!m_pause){
if (m_startMove){
if (m_moveRow != m_disance){
if (m_moveRow > m_disance){
if ((m_moveRow - m_disance) > 4){
m_moveRow = (m_moveRow - 5);
} else {
m_moveRow = m_disance;
};
} else {
if ((m_disance - m_moveRow) > 4){
m_moveRow = (m_moveRow + 5);
} else {
m_moveRow = m_disance;
};
};
if ((((m_moveRow > (m_disance - 5))) && ((m_moveRow < (m_disance + 5))))){
m_moveRow = m_disance;
};
MoveBlocks();
} else {
m_startMove = false;
m_soundNock.play();
trace("Now stop!!");
_local2 = FindMatch();
resetCube();
};
};
if (m_switch > 0){
m_switch--;
UpdateMatchingColors();
if (m_switch == 0){
trace("####### FIND MATCH #######");
FindMatch();
};
};
if (m_rotateCube){
_local3 = 10;
_local4 = ((((500 - stage.mouseX) / 500) * 180) - 45);
_local5 = (camera.panAngle - _local4);
if (_local5 > _local3){
_local5 = _local3;
};
if (_local5 < -(_local3)){
_local5 = -(_local3);
};
camera.panAngle = (camera.panAngle - _local5);
if (camera.panAngle < 30){
camera.panAngle = 30;
};
if (camera.panAngle > 60){
camera.panAngle = 60;
};
camera.tiltAngle = (((300 - stage.mouseY) / 250) * 180);
if (camera.tiltAngle < 25){
camera.tiltAngle = 25;
};
if (camera.tiltAngle > 50){
camera.tiltAngle = 50;
};
} else {
camera.panAngle = 45;
camera.tiltAngle = 35;
};
camera.hover();
m_view.render();
if (((m_startup) && ((m_timer < 50)))){
m_timer = (m_timer + 0.5);
updateProgress();
};
if (((m_startup) && ((m_timer > 49)))){
m_startup = false;
m_timer = 50;
updateProgress();
};
if (((((!(m_startup)) && ((m_timer < 0.5)))) && ((m_timer > 0)))){
killCube();
};
if ((((m_timer > 0)) && (!(m_startup)))){
_local6 = (0.01 + (m_score / 200000));
if (_local6 > 0.3){
_local6 = 0.3;
};
m_timer = (m_timer - _local6);
if (m_timer > 100){
m_bonus.gotoAndPlay(2);
m_bonus.visible = true;
m_timer = 0;
m_startup = true;
AddScore(50);
};
if (m_timer < 0){
m_menu.gameOver.visible = true;
};
updateProgress();
};
};
}
public function updateProgress(){
m_menu.bar.prog.width = ((m_timer / 100) * 250);
}
}
}//package
Section 189
//blackBmp (blackBmp)
package {
import flash.display.*;
public dynamic class blackBmp extends BitmapData {
public function blackBmp(_arg1:int=150, _arg2:int=150){
super(_arg1, _arg2);
}
}
}//package
Section 190
//blueBmp (blueBmp)
package {
import flash.display.*;
public dynamic class blueBmp extends BitmapData {
public function blueBmp(_arg1:int=150, _arg2:int=150){
super(_arg1, _arg2);
}
}
}//package
Section 191
//BonusAnim (BonusAnim)
package {
import flash.display.*;
public dynamic class BonusAnim extends MovieClip {
public function BonusAnim(){
addFrameScript(0, frame1, 56, frame57);
}
function frame1(){
stop();
}
function frame57(){
stop();
}
}
}//package
Section 192
//Button_disabledSkin (Button_disabledSkin)
package {
import flash.display.*;
public dynamic class Button_disabledSkin extends MovieClip {
}
}//package
Section 193
//Button_downSkin (Button_downSkin)
package {
import flash.display.*;
public dynamic class Button_downSkin extends MovieClip {
}
}//package
Section 194
//Button_emphasizedSkin (Button_emphasizedSkin)
package {
import flash.display.*;
public dynamic class Button_emphasizedSkin extends MovieClip {
}
}//package
Section 195
//Button_overSkin (Button_overSkin)
package {
import flash.display.*;
public dynamic class Button_overSkin extends MovieClip {
}
}//package
Section 196
//Button_selectedDisabledSkin (Button_selectedDisabledSkin)
package {
import flash.display.*;
public dynamic class Button_selectedDisabledSkin extends MovieClip {
}
}//package
Section 197
//Button_selectedDownSkin (Button_selectedDownSkin)
package {
import flash.display.*;
public dynamic class Button_selectedDownSkin extends MovieClip {
}
}//package
Section 198
//Button_selectedOverSkin (Button_selectedOverSkin)
package {
import flash.display.*;
public dynamic class Button_selectedOverSkin extends MovieClip {
}
}//package
Section 199
//Button_selectedUpSkin (Button_selectedUpSkin)
package {
import flash.display.*;
public dynamic class Button_selectedUpSkin extends MovieClip {
}
}//package
Section 200
//Button_upSkin (Button_upSkin)
package {
import flash.display.*;
public dynamic class Button_upSkin extends MovieClip {
}
}//package
Section 201
//circle (circle)
package {
import flash.display.*;
public dynamic class circle extends MovieClip {
}
}//package
Section 202
//cyanblue (cyanblue)
package {
import flash.display.*;
public dynamic class cyanblue extends BitmapData {
public function cyanblue(_arg1:int=150, _arg2:int=150){
super(_arg1, _arg2);
}
}
}//package
Section 203
//Engine (Engine)
package {
import flash.display.*;
import flash.events.*;
import flash.utils.*;
import flash.net.*;
public class Engine extends MovieClip {
private var preloader:ThePreloader;
public var m_timer;
public var ldrInfo:LoaderInfo;
public function Engine(){
addFrameScript(0, frame1, 2, frame3);
m_timer = getTimer();
ldrInfo = this.loaderInfo;
preloader = new ThePreloader();
preloader.pulsarrAdd.addEventListener(MouseEvent.CLICK, LoadWebsite);
preloader.pulsarrAdd.useHandCursor = true;
preloader.pulsarrAdd.buttonMode = true;
stage.addChild(preloader);
addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
function LoadWebsite(_arg1:MouseEvent){
var _local2:URLRequest = new URLRequest("http://www.pulsarr.com");
navigateToURL(_local2);
}
private function onEnterFrame(_arg1:Event):void{
var _local2:* = (getTimer() - m_timer);
var _local3:* = ((ldrInfo.bytesLoaded / ldrInfo.bytesTotal) * 313);
var _local4:* = ((_local2 / 8000) * 313);
if (_local3 < _local4){
preloader.mcPreloaderBar.width = _local3;
} else {
preloader.mcPreloaderBar.width = _local4;
};
if ((((((_local2 > 8000)) && ((ldrInfo.bytesLoaded == ldrInfo.bytesTotal)))) && (!((ldrInfo.bytesTotal == 0))))){
removeEventListener(Event.ENTER_FRAME, onEnterFrame);
stage.removeChild(preloader);
gotoAndPlay(3);
};
}
function frame1(){
stop();
}
function frame3(){
stop();
}
}
}//package
Section 204
//finishSnd (finishSnd)
package {
import flash.media.*;
public dynamic class finishSnd extends Sound {
}
}//package
Section 205
//focusRectSkin (focusRectSkin)
package {
import flash.display.*;
public dynamic class focusRectSkin extends MovieClip {
}
}//package
Section 206
//goldBmp (goldBmp)
package {
import flash.display.*;
public dynamic class goldBmp extends BitmapData {
public function goldBmp(_arg1:int=150, _arg2:int=150){
super(_arg1, _arg2);
}
}
}//package
Section 207
//GreenLeaf (GreenLeaf)
package {
import flash.display.*;
public dynamic class GreenLeaf extends BitmapData {
public function GreenLeaf(_arg1:int=150, _arg2:int=150){
super(_arg1, _arg2);
}
}
}//package
Section 208
//menu (menu)
package {
import fl.controls.*;
import flash.display.*;
import flash.text.*;
public class menu extends MovieClip {
public var leaderboard:MovieClip;
public var score:TextField;
public var stoped:TextField;
public var manuBtn:Button;
public var gameOver:MovieClip;
public var credits:MovieClip;
public var pulsarrLnk:MovieClip;
public var mainMenu:MovieClip;
public var bar:MovieClip;
public var pauseBtn:Button;
public var instructions:MovieClip;
public var gameBtn:Button;
public function menu(){
__setProp_pauseBtn_menu_menu_0();
__setProp_gameBtn_menu_Layer1_0();
__setProp_manuBtn_menu_Layer1_0();
}
function __setProp_pauseBtn_menu_menu_0(){
try {
pauseBtn["componentInspectorSetting"] = true;
} catch(e:Error) {
};
pauseBtn.emphasized = false;
pauseBtn.enabled = true;
pauseBtn.label = "Pause";
pauseBtn.labelPlacement = "right";
pauseBtn.selected = false;
pauseBtn.toggle = false;
pauseBtn.visible = true;
try {
pauseBtn["componentInspectorSetting"] = false;
} catch(e:Error) {
};
}
function __setProp_gameBtn_menu_Layer1_0(){
try {
gameBtn["componentInspectorSetting"] = true;
} catch(e:Error) {
};
gameBtn.emphasized = false;
gameBtn.enabled = true;
gameBtn.label = "New Game";
gameBtn.labelPlacement = "right";
gameBtn.selected = false;
gameBtn.toggle = false;
gameBtn.visible = true;
try {
gameBtn["componentInspectorSetting"] = false;
} catch(e:Error) {
};
}
function __setProp_manuBtn_menu_Layer1_0(){
try {
manuBtn["componentInspectorSetting"] = true;
} catch(e:Error) {
};
manuBtn.emphasized = false;
manuBtn.enabled = true;
manuBtn.label = "Menu";
manuBtn.labelPlacement = "right";
manuBtn.selected = false;
manuBtn.toggle = false;
manuBtn.visible = true;
try {
manuBtn["componentInspectorSetting"] = false;
} catch(e:Error) {
};
}
}
}//package
Section 209
//MyMat (MyMat)
package {
import flash.display.*;
import away3d.materials.*;
class MyMat extends TransformBitmapMaterial {
public var m_id:Number;
public var m_countdown:Number;
function MyMat(_arg1:int, _arg2:BitmapData, _arg3:Object=null):void{
super(_arg2, _arg3);
m_id = _arg1;
m_countdown = (Math.round((Math.random() * 50)) + 10);
}
}
}//package
Section 210
//MyMov (MyMov)
package {
import flash.display.*;
import away3d.materials.*;
class MyMov extends MovieMaterial {
public var m_id:Number;
public var m_countdown:Number;
function MyMov(_arg1:int, _arg2:Sprite, _arg3:Object=null):void{
super(_arg2, _arg3);
m_id = _arg1;
m_countdown = (Math.round((Math.random() * 50)) + 10);
}
}
}//package
Section 211
//nockSnd (nockSnd)
package {
import flash.media.*;
public dynamic class nockSnd extends Sound {
}
}//package
Section 212
//orangeBmp (orangeBmp)
package {
import flash.display.*;
public dynamic class orangeBmp extends BitmapData {
public function orangeBmp(_arg1:int=150, _arg2:int=150){
super(_arg1, _arg2);
}
}
}//package
Section 213
//PlaneEx (PlaneEx)
package {
import away3d.primitives.*;
class PlaneEx extends Plane {
public var m_cleanup:Boolean;
public var m_removed:Boolean;
function PlaneEx(_arg1, _arg2:Object=null):void{
super(_arg2);
m_cleanup = _arg1;
m_removed = false;
}
}
}//package
Section 214
//position (position)
package {
public class position {
var side:Number;
var x:Number;
var y:Number;
var m_id:Number;
var m_up:int;
var m_down:int;
var m_left:int;
var m_right:int;
var m_tag:int;
public function position(_arg1, _arg2, _arg3, _arg4, _arg5, _arg6, _arg7, _arg8){
side = _arg2;
x = _arg3;
y = _arg4;
m_up = _arg5;
m_down = _arg6;
m_left = _arg7;
m_right = _arg8;
m_id = _arg1;
m_tag = 0;
}
}
}//package
Section 215
//purple (purple)
package {
import flash.display.*;
public dynamic class purple extends BitmapData {
public function purple(_arg1:int=150, _arg2:int=150){
super(_arg1, _arg2);
}
}
}//package
Section 216
//rockBmp (rockBmp)
package {
import flash.display.*;
public dynamic class rockBmp extends BitmapData {
public function rockBmp(_arg1:int=150, _arg2:int=150){
super(_arg1, _arg2);
}
}
}//package
Section 217
//ThePreloader (ThePreloader)
package {
import flash.display.*;
public class ThePreloader extends MovieClip {
public var mcPreloaderBar:MovieClip;
public var pulsarrAdd:MovieClip;
}
}//package
Section 218
//white (white)
package {
import flash.display.*;
public dynamic class white extends BitmapData {
public function white(_arg1:int=150, _arg2:int=150){
super(_arg1, _arg2);
}
}
}//package
Section 219
//whiteBmp (whiteBmp)
package {
import flash.display.*;
public dynamic class whiteBmp extends BitmapData {
public function whiteBmp(_arg1:int=150, _arg2:int=150){
super(_arg1, _arg2);
}
}
}//package
Section 220
//woodBmp (woodBmp)
package {
import flash.display.*;
public dynamic class woodBmp extends BitmapData {
public function woodBmp(_arg1:int=150, _arg2:int=150){
super(_arg1, _arg2);
}
}
}//package