├── .gitignore ├── away3d ├── errors │ ├── CastError.hx │ ├── AnimationSetError.hx │ ├── InvalidTextureError.hx │ ├── AbstractMethodError.hx │ └── DeprecationError.hx ├── core │ ├── partition │ │ ├── Octree.hx │ │ ├── QuadTree.hx │ │ ├── NullNode.hx │ │ ├── CameraNode.hx │ │ ├── SkyBoxNode.hx │ │ ├── LightProbeNode.hx │ │ ├── PointLightNode.hx │ │ ├── RenderableNode.hx │ │ ├── LightNode.hx │ │ ├── DirectionalLightNode.hx │ │ ├── MeshNode.hx │ │ ├── ViewVolumePartition.hx │ │ └── EntityNode.hx │ ├── data │ │ ├── EntityListItem.hx │ │ ├── RenderableListItem.hx │ │ ├── EntityListItemPool.hx │ │ └── RenderableListItemPool.hx │ ├── base │ │ ├── data │ │ │ ├── ParticleData.hx │ │ │ └── UV.hx │ │ ├── ParticleGeometry.hx │ │ └── IMaterialOwner.hx │ ├── math │ │ ├── PlaneClassification.hx │ │ └── MathConsts.hx │ ├── sort │ │ └── IEntitySorter.hx │ ├── pick │ │ ├── PickingType.hx │ │ ├── IPickingCollider.hx │ │ ├── IPicker.hx │ │ └── AutoPickingCollider.hx │ └── traverse │ │ ├── SceneIterator.hx │ │ └── RaycastCollector.hx ├── extrusions │ └── data │ │ ├── Line.hx │ │ ├── FourPoints.hx │ │ ├── RenderSide.hx │ │ └── SubGeometryList.hx ├── animators │ ├── transitions │ │ ├── IAnimationTransition.hx │ │ ├── CrossfadeTransitionNode.hx │ │ ├── CrossfadeTransition.hx │ │ └── CrossfadeTransitionState.hx │ ├── states │ │ ├── ISkeletonAnimationState.hx │ │ ├── IAnimationState.hx │ │ ├── ISpriteSheetAnimationState.hx │ │ ├── IUVAnimationState.hx │ │ ├── IVertexAnimationState.hx │ │ ├── ParticleUVState.hx │ │ ├── ParticleRotateToHeadingState.hx │ │ ├── ParticleTimeState.hx │ │ ├── UVClipState.hx │ │ └── VertexClipState.hx │ ├── data │ │ ├── VertexAnimationMode.hx │ │ ├── ColorSegmentPoint.hx │ │ ├── ParticleAnimationData.hx │ │ ├── ParticlePropertiesMode.hx │ │ ├── SkeletonJoint.hx │ │ ├── ParticleProperties.hx │ │ ├── UVAnimationFrame.hx │ │ ├── SpriteSheetAnimationFrame.hx │ │ └── JointPose.hx │ ├── nodes │ │ ├── ISpriteSheetAnimationNode.hx │ │ ├── SkeletonBinaryLERPNode.hx │ │ ├── SkeletonDifferenceNode.hx │ │ ├── AnimationNodeBase.hx │ │ ├── SkeletonDirectionalNode.hx │ │ ├── SpriteSheetClipNode.hx │ │ ├── UVClipNode.hx │ │ └── SkeletonNaryLERPNode.hx │ ├── utils │ │ └── SkeletonUtils.hx │ └── IAnimator.hx ├── events │ ├── ShadingMethodEvent.hx │ ├── LightEvent.hx │ ├── Stage3DEvent.hx │ ├── PathEvent.hx │ ├── LensEvent.hx │ ├── CameraEvent.hx │ ├── Scene3DEvent.hx │ ├── ParserEvent.hx │ ├── AnimatorEvent.hx │ ├── GeometryEvent.hx │ ├── Object3DEvent.hx │ └── AnimationStateEvent.hx ├── Away3D.hx ├── loaders │ └── parsers │ │ ├── ParserDataFormat.hx │ │ └── utils │ │ └── ParserUtil.hx ├── textures │ ├── Texture2DBase.hx │ ├── CubeTextureBase.hx │ ├── Anisotropy.hx │ ├── ATFTexture.hx │ ├── ATFCubeTexture.hx │ ├── RenderCubeTexture.hx │ ├── BitmapTextureCache.hx │ ├── RenderTexture.hx │ └── ATFData.hx ├── paths │ ├── IPathSegment.hx │ ├── QuadraticPathSegment.hx │ ├── CubicPathSegment.hx │ ├── IPath.hx │ └── CubicPath.hx ├── cameras │ └── lenses │ │ ├── CoordinateSystem.hx │ │ └── FreeMatrixLens.hx ├── library │ ├── naming │ │ ├── IgnoreConflictStrategy.hx │ │ ├── ErrorConflictStrategy.hx │ │ ├── ConflictPrecedence.hx │ │ ├── ConflictStrategy.hx │ │ └── NumSuffixConflictStrategy.hx │ ├── assets │ │ ├── BitmapDataAsset.hx │ │ ├── IAsset.hx │ │ └── Asset3DType.hx │ └── utils │ │ └── Asset3DLibraryIterator.hx ├── materials │ ├── SegmentMaterial.hx │ ├── OrthoSegmentMaterial.hx │ ├── ColorMultiPassMaterial.hx │ ├── methods │ │ ├── MethodVOSet.hx │ │ ├── EffectMethodBase.hx │ │ └── MethodVO.hx │ ├── LightSources.hx │ ├── SkyBoxMaterial.hx │ ├── compilation │ │ ├── ShaderRegisterData.hx │ │ └── ShaderRegisterElement.hx │ ├── OcclusionMaterial.hx │ ├── ColorMaterial.hx │ └── utils │ │ ├── DefaultMaterialManager.hx │ │ ├── MipmapGenerator.hx │ │ └── IVideoPlayer.hx ├── primitives │ ├── LineSegment.hx │ ├── data │ │ └── NURBSVertex.hx │ ├── ConeGeometry.hx │ └── RegularPolygonGeometry.hx ├── stereo │ └── methods │ │ ├── StereoRenderMethodBase.hx │ │ ├── AnaglyphStereoRenderMethod.hx │ │ └── InterleavedStereoRenderMethod.hx ├── controllers │ ├── FollowController.hx │ └── ControllerBase.hx ├── debug │ ├── Debug.hx │ ├── data │ │ └── TridentLines.hx │ └── AwayFPS.hx ├── textfield │ ├── utils │ │ ├── FontContainer.hx │ │ └── FontSize.hx │ ├── CleanMasterString.hx │ ├── VAlign.hx │ ├── HAlign.hx │ ├── RectangleBitmapTexture.hx │ └── CharLocation.hx ├── tools │ ├── utils │ │ └── TextureUtils.hx │ └── helpers │ │ └── data │ │ └── ParticleGeometryTransform.hx ├── filters │ ├── MotionBlurFilter3D.hx │ ├── HBlurFilter3D.hx │ ├── VBlurFilter3D.hx │ ├── tasks │ │ ├── Filter3DBrightPassTask.hx │ │ ├── Filter3DDoubleBufferCopyTask.hx │ │ ├── Filter3DXFadeCompositeTask.hx │ │ └── Filter3DBloomCompositeTask.hx │ ├── HueSaturationFilter3D.hx │ ├── RadialBlurFilter3D.hx │ ├── BlurFilter3D.hx │ ├── HDepthOfFieldFilter3D.hx │ ├── VDepthOfFieldFilter3D.hx │ └── Filter3DBase.hx ├── lights │ ├── shadowmaps │ │ └── NearDirectionalShadowMapper.hx │ └── LightProbe.hx ├── audio │ └── drivers │ │ ├── AbstractSound3DDriver.hx │ │ └── ISound3DDriver.hx └── bounds │ └── NullBounds.hx ├── include.xml ├── haxelib.json ├── README.md └── scripts └── docs.hxml /.gitignore: -------------------------------------------------------------------------------- 1 | /*.DS_Store 2 | docs 3 | scripts/xml 4 | scripts/pages -------------------------------------------------------------------------------- /away3d/errors/CastError.hx: -------------------------------------------------------------------------------- 1 | package away3d.errors; 2 | 3 | import openfl.errors.Error; 4 | 5 | class CastError extends Error 6 | { 7 | public function new(message:String) 8 | { 9 | super(message); 10 | } 11 | } -------------------------------------------------------------------------------- /away3d/core/partition/Octree.hx: -------------------------------------------------------------------------------- 1 | package away3d.core.partition; 2 | 3 | class Octree extends Partition3D 4 | { 5 | 6 | public function new(maxDepth:Int, size:Float) 7 | { 8 | super(new OctreeNode(maxDepth, size)); 9 | } 10 | } -------------------------------------------------------------------------------- /away3d/errors/AnimationSetError.hx: -------------------------------------------------------------------------------- 1 | package away3d.errors; 2 | 3 | import openfl.errors.Error; 4 | 5 | class AnimationSetError extends Error 6 | { 7 | public function new(message:String) 8 | { 9 | super(message); 10 | } 11 | } -------------------------------------------------------------------------------- /away3d/extrusions/data/Line.hx: -------------------------------------------------------------------------------- 1 | package away3d.extrusions.data; 2 | 3 | class Line 4 | { 5 | public var ax:Float; 6 | public var ay:Float; 7 | public var bx:Float; 8 | public var by:Float; 9 | 10 | public function new() {} 11 | } -------------------------------------------------------------------------------- /away3d/core/partition/QuadTree.hx: -------------------------------------------------------------------------------- 1 | package away3d.core.partition; 2 | 3 | class QuadTree extends Partition3D 4 | { 5 | public function new(maxDepth:Int, size:Float, height:Float = 1000000) 6 | { 7 | super(new QuadTreeNode(maxDepth, size, height)); 8 | } 9 | } -------------------------------------------------------------------------------- /away3d/core/data/EntityListItem.hx: -------------------------------------------------------------------------------- 1 | package away3d.core.data; 2 | 3 | import away3d.entities.Entity; 4 | 5 | class EntityListItem 6 | { 7 | public var entity:Entity; 8 | public var next:EntityListItem; 9 | 10 | public function new() 11 | { 12 | 13 | } 14 | } -------------------------------------------------------------------------------- /away3d/extrusions/data/FourPoints.hx: -------------------------------------------------------------------------------- 1 | package away3d.extrusions.data; 2 | 3 | import openfl.geom.Point; 4 | 5 | class FourPoints 6 | { 7 | public var pt1:Point; 8 | public var pt2:Point; 9 | public var pt3:Point; 10 | public var pt4:Point; 11 | 12 | public function new() {} 13 | } -------------------------------------------------------------------------------- /include.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /away3d/extrusions/data/RenderSide.hx: -------------------------------------------------------------------------------- 1 | package away3d.extrusions.data; 2 | 3 | class RenderSide 4 | { 5 | public var top:Bool; 6 | public var bottom:Bool; 7 | public var right:Bool; 8 | public var left:Bool; 9 | public var front:Bool; 10 | public var back:Bool; 11 | 12 | public function new() {} 13 | } -------------------------------------------------------------------------------- /away3d/animators/transitions/IAnimationTransition.hx: -------------------------------------------------------------------------------- 1 | package away3d.animators.transitions; 2 | 3 | import away3d.animators.*; 4 | import away3d.animators.nodes.*; 5 | 6 | interface IAnimationTransition 7 | { 8 | function getAnimationNode(animator:IAnimator, startNode:AnimationNodeBase, endNode:AnimationNodeBase, startTime:Int):AnimationNodeBase; 9 | } -------------------------------------------------------------------------------- /away3d/animators/states/ISkeletonAnimationState.hx: -------------------------------------------------------------------------------- 1 | package away3d.animators.states; 2 | 3 | import away3d.animators.data.*; 4 | 5 | interface ISkeletonAnimationState extends IAnimationState 6 | { 7 | 8 | /** 9 | * Returns the output skeleton pose of the animation node. 10 | */ 11 | function getSkeletonPose(skeleton:Skeleton):SkeletonPose; 12 | } -------------------------------------------------------------------------------- /away3d/core/base/data/ParticleData.hx: -------------------------------------------------------------------------------- 1 | package away3d.core.base.data; 2 | 3 | import away3d.core.base.CompactSubGeometry; 4 | 5 | class ParticleData 6 | { 7 | public var particleIndex:Int; 8 | public var numVertices:Int; 9 | public var startVertexIndex:Int; 10 | public var subGeometry:CompactSubGeometry; 11 | 12 | public function new() 13 | { 14 | 15 | } 16 | } -------------------------------------------------------------------------------- /away3d/events/ShadingMethodEvent.hx: -------------------------------------------------------------------------------- 1 | package away3d.events; 2 | 3 | import openfl.events.Event; 4 | 5 | class ShadingMethodEvent extends Event 6 | { 7 | public static inline var SHADER_INVALIDATED:String = "ShaderInvalidated"; 8 | 9 | public function new(type:String, bubbles:Bool = false, cancelable:Bool = false) 10 | { 11 | super(type, bubbles, cancelable); 12 | } 13 | } -------------------------------------------------------------------------------- /away3d/Away3D.hx: -------------------------------------------------------------------------------- 1 | package away3d; 2 | 3 | /** 4 | * Helper class to track a few important library constants. 5 | */ 6 | class Away3D 7 | { 8 | public static inline var WEBSITE_URL:String = "http://www.away3d.com"; 9 | 10 | public static inline var MAJOR_VERSION:Int = 4; 11 | 12 | public static inline var MINOR_VERSION:Int = 1; 13 | 14 | public static inline var REVISION:Int = 6; 15 | } -------------------------------------------------------------------------------- /away3d/core/base/ParticleGeometry.hx: -------------------------------------------------------------------------------- 1 | package away3d.core.base; 2 | 3 | import away3d.core.base.data.ParticleData; 4 | 5 | import openfl.Vector; 6 | 7 | /** 8 | * ... 9 | */ 10 | class ParticleGeometry extends Geometry 11 | { 12 | public var particles:Vector; 13 | 14 | public var numParticles:Int; 15 | 16 | public function new() 17 | { 18 | super(); 19 | } 20 | 21 | } -------------------------------------------------------------------------------- /away3d/events/LightEvent.hx: -------------------------------------------------------------------------------- 1 | package away3d.events; 2 | 3 | import openfl.events.Event; 4 | 5 | class LightEvent extends Event 6 | { 7 | public static inline var CASTS_SHADOW_CHANGE:String = "castsShadowChange"; 8 | 9 | public function new(type:String) 10 | { 11 | super(type); 12 | } 13 | 14 | override public function clone():Event 15 | { 16 | return new LightEvent(type); 17 | } 18 | } -------------------------------------------------------------------------------- /away3d/core/math/PlaneClassification.hx: -------------------------------------------------------------------------------- 1 | package away3d.core.math; 2 | 3 | class PlaneClassification 4 | { 5 | // "back" is synonymous with "in", but used for planes (back of plane is "inside" a solid volume walled by a plane) 6 | public static inline var BACK:Int = 0; 7 | public static inline var FRONT:Int = 1; 8 | 9 | public static inline var IN:Int = 0; 10 | public static inline var OUT:Int = 1; 11 | public static inline var INTERSECT:Int = 2; 12 | } -------------------------------------------------------------------------------- /away3d/loaders/parsers/ParserDataFormat.hx: -------------------------------------------------------------------------------- 1 | package away3d.loaders.parsers; 2 | 3 | /** 4 | * An enumeration providing values to describe the data format of parsed data. 5 | */ 6 | class ParserDataFormat 7 | { 8 | /** 9 | * Describes the format of a binary file. 10 | */ 11 | public static inline var BINARY:String = "binary"; 12 | 13 | /** 14 | * Describes the format of a plain text file. 15 | */ 16 | public static inline var PLAIN_TEXT:String = "plainText"; 17 | } -------------------------------------------------------------------------------- /away3d/core/math/MathConsts.hx: -------------------------------------------------------------------------------- 1 | package away3d.core.math; 2 | 3 | /** 4 | * MathConsts provides some commonly used mathematical constants 5 | */ 6 | class MathConsts 7 | { 8 | /** 9 | * The amount to multiply with when converting radians to degrees. 10 | */ 11 | public static var RADIANS_TO_DEGREES:Float = 180 / Math.PI; 12 | 13 | /** 14 | * The amount to multiply with when converting degrees to radians. 15 | */ 16 | public static var DEGREES_TO_RADIANS:Float = Math.PI / 180; 17 | } -------------------------------------------------------------------------------- /away3d/core/partition/NullNode.hx: -------------------------------------------------------------------------------- 1 | package away3d.core.partition; 2 | 3 | /** 4 | * NullNode is a node that performs no space partitioning, but simply stores all objects in a 5 | * list of leaf nodes. This partitioning system is most useful for simple content, or content that is always in the 6 | * screen, such as a 3d user interface. 7 | */ 8 | class NullNode extends NodeBase 9 | { 10 | /** 11 | * Creates a new NullNode object. 12 | */ 13 | public function new() 14 | { 15 | super(); 16 | } 17 | } -------------------------------------------------------------------------------- /away3d/textures/Texture2DBase.hx: -------------------------------------------------------------------------------- 1 | package away3d.textures; 2 | 3 | import openfl.display3D.Context3D; 4 | import openfl.display3D.Context3DTextureFormat; 5 | import openfl.display3D.textures.TextureBase; 6 | 7 | class Texture2DBase extends TextureProxyBase 8 | { 9 | public function new() 10 | { 11 | super(); 12 | } 13 | 14 | override private function createTexture(context:Context3D):TextureBase 15 | { 16 | return context.createTexture(_width, _height, Context3DTextureFormat.BGRA, false); 17 | } 18 | } -------------------------------------------------------------------------------- /away3d/animators/states/IAnimationState.hx: -------------------------------------------------------------------------------- 1 | package away3d.animators.states; 2 | 3 | import openfl.geom.*; 4 | 5 | interface IAnimationState 6 | { 7 | var positionDelta(get, never):Vector3D; 8 | 9 | function offset(startTime:Int):Void; 10 | 11 | function update(time:Int):Void; 12 | 13 | /** 14 | * Sets the animation phase of the node. 15 | * 16 | * @param value The phase value to use. 0 represents the beginning of an animation clip, 1 represents the end. 17 | */ 18 | function phase(value:Float):Void; 19 | } -------------------------------------------------------------------------------- /away3d/extrusions/data/SubGeometryList.hx: -------------------------------------------------------------------------------- 1 | package away3d.extrusions.data; 2 | 3 | import away3d.materials.MaterialBase; 4 | import away3d.core.base.SubGeometry; 5 | 6 | import openfl.Vector; 7 | 8 | class SubGeometryList 9 | { 10 | public var id:Int; 11 | public var uvs:Vector; 12 | public var vertices:Vector; 13 | public var normals:Vector; 14 | public var indices:Vector; 15 | public var subGeometry:SubGeometry; 16 | public var material:MaterialBase; 17 | 18 | public function new() {} 19 | } -------------------------------------------------------------------------------- /away3d/core/sort/IEntitySorter.hx: -------------------------------------------------------------------------------- 1 | package away3d.core.sort; 2 | 3 | import away3d.core.traverse.EntityCollector; 4 | 5 | /** 6 | * EntitySorterBase provides an abstract base class to sort geometry information in an EntityCollector object for 7 | * rendering. 8 | */ 9 | interface IEntitySorter 10 | { 11 | /** 12 | * Sort the potentially visible data in an EntityCollector for rendering. 13 | * @param collector The EntityCollector object containing the potentially visible data. 14 | */ 15 | function sort(collector:EntityCollector):Void; 16 | } -------------------------------------------------------------------------------- /haxelib.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "away3d", 3 | "url": "http://www.away3d.com", 4 | "license": "Apache", 5 | "tags": [ "away3d", "3d", "engine", "openfl", "cross", "cpp", "flash", "game", "js", "web", "ios", "android" ], 6 | "description": "Away3D is an open source platform for developing interactive 3D graphics for video games and applications.", 7 | "version": "5.1.0", 8 | "releasenote": "Fixed Haxe 4.3, OpenFL 9.2+ and Lime 8.0+ compatibility", 9 | "contributors": [ "Greg209", "singmajesty", "p.j.shand", "bowlerhat", "Dimensionscape" ] 10 | } 11 | -------------------------------------------------------------------------------- /away3d/core/base/IMaterialOwner.hx: -------------------------------------------------------------------------------- 1 | package away3d.core.base; 2 | 3 | import away3d.animators.IAnimator; 4 | import away3d.materials.MaterialBase; 5 | 6 | /** 7 | * IMaterialOwner provides an interface for objects that can use materials. 8 | */ 9 | interface IMaterialOwner 10 | { 11 | /** 12 | * The material with which to render the object. 13 | */ 14 | var material(get, set):MaterialBase; 15 | 16 | /** 17 | * The animation used by the material to assemble the vertex code. 18 | */ 19 | var animator(get, never):IAnimator; // in most cases, this will in fact be null 20 | } -------------------------------------------------------------------------------- /away3d/paths/IPathSegment.hx: -------------------------------------------------------------------------------- 1 | package away3d.paths; 2 | 3 | import openfl.geom.Vector3D; 4 | 5 | interface IPathSegment 6 | { 7 | /** 8 | * Destroys the segment 9 | */ 10 | public function dispose():Void; 11 | 12 | /** 13 | * Calculates the position of the curve on this segment. 14 | * 15 | * @param phase The ratio between the start and end point. 16 | * @param target An optional target to store the calculation, to prevent creating a new Vector3D object. 17 | * @return 18 | */ 19 | public function getPointOnSegment(phase:Float, target:Vector3D = null):Vector3D; 20 | } -------------------------------------------------------------------------------- /away3d/cameras/lenses/CoordinateSystem.hx: -------------------------------------------------------------------------------- 1 | package away3d.cameras.lenses; 2 | 3 | /** 4 | * Provides constant values for camera lens projection options use the the coordinateSystem property 5 | * 6 | * @see away3d.cameras.lenses.PerspectiveLens#coordinateSystem 7 | */ 8 | class CoordinateSystem 9 | { 10 | /** 11 | * Default option, projects to a left-handed coordinate system 12 | */ 13 | public static inline var LEFT_HANDED:Int = 0; 14 | 15 | /** 16 | * Projects to a right-handed coordinate system 17 | */ 18 | public static inline var RIGHT_HANDED:Int = 1; 19 | } -------------------------------------------------------------------------------- /away3d/core/data/RenderableListItem.hx: -------------------------------------------------------------------------------- 1 | package away3d.core.data; 2 | 3 | import away3d.core.base.IRenderable; 4 | 5 | import openfl.geom.Matrix3D; 6 | 7 | @:final class RenderableListItem 8 | { 9 | public var next:RenderableListItem; 10 | public var renderable:IRenderable; 11 | 12 | // for faster access while sorting or rendering (cached values) 13 | public var materialId:Int; 14 | public var renderOrderId:Int; 15 | public var zIndex:Float; 16 | public var renderSceneTransform:Matrix3D; 17 | 18 | public var cascaded:Bool; 19 | 20 | public function new() 21 | { 22 | 23 | } 24 | } -------------------------------------------------------------------------------- /away3d/library/naming/IgnoreConflictStrategy.hx: -------------------------------------------------------------------------------- 1 | package away3d.library.naming; 2 | 3 | import away3d.library.assets.IAsset; 4 | 5 | class IgnoreConflictStrategy extends ConflictStrategyBase 6 | { 7 | public function new() 8 | { 9 | super(); 10 | } 11 | 12 | override public function resolveConflict(changedAsset:IAsset, oldAsset:IAsset, assetsDictionary:Dynamic, precedence:String):Void 13 | { 14 | // Do nothing, ignore the fact that there is a conflict. 15 | return; 16 | } 17 | 18 | override public function create():ConflictStrategyBase 19 | { 20 | return new IgnoreConflictStrategy(); 21 | } 22 | } -------------------------------------------------------------------------------- /away3d/events/Stage3DEvent.hx: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package away3d.events; 5 | 6 | import openfl.events.Event; 7 | 8 | class Stage3DEvent extends Event 9 | { 10 | public static inline var CONTEXT3D_CREATED:String = "Context3DCreated"; 11 | public static inline var CONTEXT3D_DISPOSED:String = "Context3DDisposed"; 12 | public static inline var CONTEXT3D_RECREATED:String = "Context3DRecreated"; 13 | public static inline var VIEWPORT_UPDATED:String = "ViewportUpdated"; 14 | 15 | public function new(type:String, bubbles:Bool = false, cancelable:Bool = false) 16 | { 17 | super(type, bubbles, cancelable); 18 | } 19 | } -------------------------------------------------------------------------------- /away3d/textures/CubeTextureBase.hx: -------------------------------------------------------------------------------- 1 | package away3d.textures; 2 | 3 | import openfl.display3D.Context3D; 4 | import openfl.display3D.Context3DTextureFormat; 5 | import openfl.display3D.textures.TextureBase; 6 | 7 | class CubeTextureBase extends TextureProxyBase 8 | { 9 | public var size(get, never):Int; 10 | 11 | public function new() 12 | { 13 | super(); 14 | } 15 | 16 | private function get_size():Int 17 | { 18 | return _width; 19 | } 20 | 21 | override private function createTexture(context:Context3D):TextureBase 22 | { 23 | return context.createCubeTexture(width, Context3DTextureFormat.BGRA, false); 24 | } 25 | } -------------------------------------------------------------------------------- /away3d/animators/transitions/CrossfadeTransitionNode.hx: -------------------------------------------------------------------------------- 1 | package away3d.animators.transitions; 2 | 3 | import away3d.animators.nodes.*; 4 | 5 | /** 6 | * A skeleton animation node that uses two animation node inputs to blend a lineraly interpolated output of a skeleton pose. 7 | */ 8 | class CrossfadeTransitionNode extends SkeletonBinaryLERPNode 9 | { 10 | public var blendSpeed:Float; 11 | 12 | public var startBlend:Int; 13 | 14 | /** 15 | * Creates a new CrossfadeTransitionNode object. 16 | */ 17 | public function new() 18 | { 19 | super(); 20 | _stateConstructor = cast CrossfadeTransitionState.new; 21 | } 22 | } -------------------------------------------------------------------------------- /away3d/errors/InvalidTextureError.hx: -------------------------------------------------------------------------------- 1 | package away3d.errors; 2 | 3 | import openfl.errors.Error; 4 | 5 | /** 6 | * TextureError is thrown when an invalid texture is used regarding Stage3D limitations. 7 | */ 8 | class InvalidTextureError extends Error 9 | { 10 | /** 11 | * Create a new TextureError. 12 | * @param message An optional message to override the default error message. 13 | * @param id The id of the error. 14 | */ 15 | public function new(message:String = null, id:Int = 0) 16 | { 17 | if (message == null) 18 | message = "Invalid bitmapData! Must be power of 2 and not exceeding 2048."; 19 | super(message, id); 20 | } 21 | } -------------------------------------------------------------------------------- /away3d/animators/data/VertexAnimationMode.hx: -------------------------------------------------------------------------------- 1 | package away3d.animators.data; 2 | 3 | /** 4 | * Options for setting the animation mode of a vertex animator object. 5 | * 6 | * @see away3d.animators.VertexAnimator 7 | */ 8 | class VertexAnimationMode 9 | { 10 | /** 11 | * Animation mode that adds all outputs from active vertex animation state to form the current vertex animation pose. 12 | */ 13 | public static var ADDITIVE:String = "additive"; 14 | 15 | /** 16 | * Animation mode that picks the output from a single vertex animation state to form the current vertex animation pose. 17 | */ 18 | public static var ABSOLUTE:String = "absolute"; 19 | } 20 | -------------------------------------------------------------------------------- /away3d/materials/SegmentMaterial.hx: -------------------------------------------------------------------------------- 1 | package away3d.materials; 2 | 3 | import away3d.materials.passes.SegmentPass; 4 | 5 | /** 6 | * SegmentMaterial is a material exclusively used to render wireframe objects 7 | * 8 | * @see away3d.entities.Lines 9 | */ 10 | class SegmentMaterial extends MaterialBase 11 | { 12 | private var _screenPass:SegmentPass; 13 | 14 | /** 15 | * Creates a new SegmentMaterial object. 16 | * 17 | * @param thickness The thickness of the wireframe lines. 18 | */ 19 | public function new(thickness:Float = 1.25) 20 | { 21 | super(); 22 | 23 | bothSides = true; 24 | addPass(_screenPass = new SegmentPass(thickness)); 25 | _screenPass.material = this; 26 | } 27 | } -------------------------------------------------------------------------------- /away3d/animators/nodes/ISpriteSheetAnimationNode.hx: -------------------------------------------------------------------------------- 1 | package away3d.animators.nodes; 2 | 3 | import away3d.animators.data.SpriteSheetAnimationFrame; 4 | 5 | /** 6 | * Provides an interface for animation node classes that hold animation data for use in the SpriteSheetAnimator class. 7 | * 8 | * @see away3d.animators.SpriteSheetAnimator 9 | */ 10 | interface ISpriteSheetAnimationNode 11 | { 12 | /** 13 | * Returns the current SpriteSheetAnimationFrame of animation in the clip based on the internal playhead position. 14 | */ 15 | var currentFrameData(get, never):SpriteSheetAnimationFrame; 16 | 17 | /** 18 | * Returns the current frame number. 19 | */ 20 | var currentFrameNumber(get, never):Int; 21 | } 22 | -------------------------------------------------------------------------------- /away3d/animators/states/ISpriteSheetAnimationState.hx: -------------------------------------------------------------------------------- 1 | package away3d.animators.states; 2 | 3 | /** 4 | * Provides an interface for animation node classes that hold animation data for use in the SpriteSheetAnimator class. 5 | * 6 | * @see away3d.animators.SpriteSheetAnimator 7 | */ 8 | 9 | import away3d.animators.data.*; 10 | 11 | interface ISpriteSheetAnimationState extends IAnimationState 12 | { 13 | /** 14 | * Returns the current SpriteSheetAnimationFrame of animation in the clip based on the internal playhead position. 15 | */ 16 | var currentFrameData(get, never):SpriteSheetAnimationFrame; 17 | 18 | /** 19 | * Returns the current frame number. 20 | */ 21 | var currentFrameNumber(get, never):Int; 22 | } -------------------------------------------------------------------------------- /away3d/events/PathEvent.hx: -------------------------------------------------------------------------------- 1 | package away3d.events; 2 | 3 | import openfl.events.Event; 4 | 5 | class PathEvent extends Event 6 | { 7 | /** 8 | * Dispatched when the time pointer enter a new cycle at time 0, after last time was greater than 0.99 9 | */ 10 | public static inline var CYCLE:String = "cycle"; 11 | 12 | /** 13 | * Dispatched when the time pointer is included a given from/to time region on a path 14 | */ 15 | public static inline var RANGE:String = "range"; 16 | 17 | /** 18 | * Dispatched when the time pointer enters a new PathSegment 19 | */ 20 | public static inline var CHANGE_SEGMENT:String = "change_segment"; 21 | 22 | public function new(type:String) 23 | { 24 | super(type); 25 | } 26 | } -------------------------------------------------------------------------------- /away3d/library/naming/ErrorConflictStrategy.hx: -------------------------------------------------------------------------------- 1 | package away3d.library.naming; 2 | 3 | import away3d.library.assets.IAsset; 4 | 5 | import openfl.errors.Error; 6 | 7 | class ErrorConflictStrategy extends ConflictStrategyBase 8 | { 9 | public function new() 10 | { 11 | super(); 12 | } 13 | 14 | override public function resolveConflict(changedAsset:IAsset, oldAsset:IAsset, assetsDictionary:Dynamic, precedence:String):Void 15 | { 16 | throw new Error("Asset name collision while Asset3DLibrary.namingStrategy set to Asset3DLibrary.THROW_ERROR. Asset path: " + changedAsset.assetFullPath); 17 | } 18 | 19 | override public function create():ConflictStrategyBase 20 | { 21 | return new ErrorConflictStrategy(); 22 | } 23 | } -------------------------------------------------------------------------------- /away3d/core/partition/CameraNode.hx: -------------------------------------------------------------------------------- 1 | package away3d.core.partition; 2 | 3 | import away3d.cameras.Camera3D; 4 | import away3d.core.traverse.PartitionTraverser; 5 | 6 | /** 7 | * CameraNode is a space partitioning leaf node that contains a Camera3D object. 8 | */ 9 | class CameraNode extends EntityNode 10 | { 11 | /** 12 | * Creates a new CameraNode object. 13 | * @param camera The camera to be contained in the node. 14 | */ 15 | public function new(camera:Camera3D) 16 | { 17 | super(camera); 18 | } 19 | 20 | /** 21 | * @inheritDoc 22 | */ 23 | override public function acceptTraverser(traverser:PartitionTraverser):Void 24 | { 25 | // todo: dead end for now, if it has a debug mesh, then sure accept that 26 | } 27 | } -------------------------------------------------------------------------------- /away3d/materials/OrthoSegmentMaterial.hx: -------------------------------------------------------------------------------- 1 | package away3d.materials; 2 | 3 | import away3d.materials.passes.OrthoSegmentPass; 4 | 5 | /** 6 | * OrthoSegmentMaterial is a material exclusively used to render wireframe objects 7 | * 8 | * @see away3d.entities.Lines 9 | */ 10 | class OrthoSegmentMaterial extends MaterialBase 11 | { 12 | private var _screenPass:OrthoSegmentPass; 13 | 14 | /** 15 | * Creates a new OrthoSegmentMaterial object. 16 | * 17 | * @param thickness The thickness of the wireframe lines. 18 | */ 19 | public function new(thickness:Float = 1.25) 20 | { 21 | super(); 22 | 23 | bothSides = true; 24 | addPass(_screenPass = new OrthoSegmentPass(thickness)); 25 | _screenPass.material = this; 26 | } 27 | } -------------------------------------------------------------------------------- /away3d/animators/data/ColorSegmentPoint.hx: -------------------------------------------------------------------------------- 1 | package away3d.animators.data; 2 | 3 | import openfl.errors.Error; 4 | import openfl.geom.ColorTransform; 5 | 6 | class ColorSegmentPoint 7 | { 8 | public var color(get, never):ColorTransform; 9 | public var life(get, never):Float; 10 | 11 | private var _color:ColorTransform; 12 | private var _life:Float; 13 | 14 | public function new(life:Float, color:ColorTransform) 15 | { 16 | //0= 1) 18 | throw(new Error("life exceeds range (0,1)")); 19 | _life = life; 20 | _color = color; 21 | } 22 | 23 | private function get_color():ColorTransform 24 | { 25 | return _color; 26 | } 27 | 28 | private function get_life():Float 29 | { 30 | return _life; 31 | } 32 | } -------------------------------------------------------------------------------- /away3d/events/LensEvent.hx: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package away3d.events; 5 | 6 | import away3d.cameras.lenses.LensBase; 7 | 8 | import openfl.events.Event; 9 | 10 | class LensEvent extends Event 11 | { 12 | public var lens(get, never):LensBase; 13 | 14 | public static inline var MATRIX_CHANGED:String = "matrixChanged"; 15 | 16 | private var _lens:LensBase; 17 | 18 | public function new(type:String, lens:LensBase, bubbles:Bool = false, cancelable:Bool = false) 19 | { 20 | super(type, bubbles, cancelable); 21 | _lens = lens; 22 | } 23 | 24 | private function get_lens():LensBase 25 | { 26 | return _lens; 27 | } 28 | 29 | override public function clone():Event 30 | { 31 | return new LensEvent(type, _lens, bubbles, cancelable); 32 | } 33 | } -------------------------------------------------------------------------------- /away3d/events/CameraEvent.hx: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package away3d.events; 5 | 6 | import openfl.events.Event; 7 | 8 | import away3d.cameras.Camera3D; 9 | 10 | class CameraEvent extends Event 11 | { 12 | public var camera(get, never):Camera3D; 13 | 14 | public static inline var LENS_CHANGED:String = "lensChanged"; 15 | 16 | private var _camera:Camera3D; 17 | 18 | public function new(type:String, camera:Camera3D, bubbles:Bool = false, cancelable:Bool = false) 19 | { 20 | super(type, bubbles, cancelable); 21 | _camera = camera; 22 | } 23 | 24 | private function get_camera():Camera3D 25 | { 26 | return _camera; 27 | } 28 | 29 | override public function clone():Event 30 | { 31 | return new CameraEvent(type, _camera, bubbles, cancelable); 32 | } 33 | } -------------------------------------------------------------------------------- /away3d/errors/AbstractMethodError.hx: -------------------------------------------------------------------------------- 1 | package away3d.errors; 2 | 3 | import openfl.errors.Error; 4 | 5 | /** 6 | * AbstractMethodError is thrown when an abstract method is called. The method in question should be overridden 7 | * by a concrete subclass. 8 | */ 9 | class AbstractMethodError extends Error 10 | { 11 | /** 12 | * Create a new AbstractMethodError. 13 | * @param message An optional message to override the default error message. 14 | * @param id The id of the error. 15 | */ 16 | public function new(message:String = null, id:Int = 0) 17 | { 18 | if (message == null) message = "An abstract method was called! Either an instance of an abstract class was created, or an abstract method was not overridden by the subclass."; 19 | super(message, id); 20 | } 21 | } -------------------------------------------------------------------------------- /away3d/primitives/LineSegment.hx: -------------------------------------------------------------------------------- 1 | package away3d.primitives; 2 | 3 | import away3d.primitives.data.Segment; 4 | 5 | import openfl.geom.Vector3D; 6 | 7 | /** 8 | * A Line Segment primitive. 9 | */ 10 | class LineSegment extends Segment 11 | { 12 | 13 | public static inline var TYPE:String = "line"; 14 | 15 | /** 16 | * Create a line segment 17 | * @param v0 Start position of the line segment 18 | * @param v1 Ending position of the line segment 19 | * @param color0 Starting color of the line segment 20 | * @param color1 Ending colour of the line segment 21 | * @param thickness Thickness of the line 22 | */ 23 | public function new(v0:Vector3D, v1:Vector3D, color0:Int = 0x333333, color1:Int = 0x333333, thickness:Float = 1) 24 | { 25 | super(v0, v1, null, color0, color1, thickness); 26 | } 27 | } -------------------------------------------------------------------------------- /away3d/stereo/methods/StereoRenderMethodBase.hx: -------------------------------------------------------------------------------- 1 | package away3d.stereo.methods; 2 | 3 | import away3d.core.managers.Stage3DProxy; 4 | import away3d.errors.AbstractMethodError; 5 | 6 | class StereoRenderMethodBase 7 | { 8 | private var _textureSizeInvalid:Bool = true; 9 | 10 | public function new() 11 | { 12 | } 13 | 14 | public function activate(stage3DProxy:Stage3DProxy):Void 15 | { 16 | } 17 | 18 | public function deactivate(stage3DProxy:Stage3DProxy):Void 19 | { 20 | } 21 | 22 | public function getFragmentCode():String 23 | { 24 | throw new AbstractMethodError("Concrete implementation of StereoRenderMethodBase must be used and extend getFragmentCode()."); 25 | return ""; 26 | } 27 | 28 | public function invalidateTextureSize():Void 29 | { 30 | _textureSizeInvalid = true; 31 | } 32 | } -------------------------------------------------------------------------------- /away3d/animators/data/ParticleAnimationData.hx: -------------------------------------------------------------------------------- 1 | package away3d.animators.data; 2 | 3 | import away3d.core.base.data.ParticleData; 4 | 5 | /** 6 | * ... 7 | */ 8 | class ParticleAnimationData 9 | { 10 | public var index:Int; 11 | public var startTime:Float; 12 | public var totalTime:Float; 13 | public var duration:Float; 14 | public var delay:Float; 15 | public var startVertexIndex:Int; 16 | public var numVertices:Int; 17 | 18 | public function new(index:Int, startTime:Float, duration:Float, delay:Float, particle:ParticleData) 19 | { 20 | this.index = index; 21 | this.startTime = startTime; 22 | this.totalTime = duration + delay; 23 | this.duration = duration; 24 | this.delay = delay; 25 | this.startVertexIndex = particle.startVertexIndex; 26 | this.numVertices = particle.numVertices; 27 | } 28 | } -------------------------------------------------------------------------------- /away3d/controllers/FollowController.hx: -------------------------------------------------------------------------------- 1 | package away3d.controllers; 2 | 3 | import away3d.containers.ObjectContainer3D; 4 | import away3d.entities.Entity; 5 | 6 | /** 7 | * Controller used to follow behind an object on the XZ plane, with an optional 8 | * elevation (tiltAngle). 9 | * 10 | * @see away3d.containers.View3D 11 | */ 12 | class FollowController extends HoverController 13 | { 14 | public function new(targetObject:Entity = null, lookAtObject:ObjectContainer3D = null, tiltAngle:Float = 45, distance:Float = 700) 15 | { 16 | super(targetObject, lookAtObject, 0, tiltAngle, distance); 17 | } 18 | 19 | override public function update(interpolate:Bool = true):Void 20 | { 21 | if (lookAtObject == null) 22 | return; 23 | 24 | panAngle = _lookAtObject.rotationY - 180; 25 | super.update(); 26 | } 27 | } -------------------------------------------------------------------------------- /away3d/core/data/EntityListItemPool.hx: -------------------------------------------------------------------------------- 1 | package away3d.core.data; 2 | 3 | import openfl.Vector; 4 | 5 | class EntityListItemPool 6 | { 7 | private var _pool:Vector; 8 | private var _index:Int; 9 | private var _poolSize:Int; 10 | 11 | public function new() 12 | { 13 | _index = 0; 14 | _poolSize = 0; 15 | _pool = new Vector(); 16 | } 17 | 18 | public function getItem():EntityListItem 19 | { 20 | var item:EntityListItem; 21 | if (_index == _poolSize) { 22 | item = new EntityListItem(); 23 | _pool[_index++] = item; 24 | ++_poolSize; 25 | } else 26 | item = _pool[_index++]; 27 | return item; 28 | } 29 | 30 | public function freeAll():Void 31 | { 32 | _index = 0; 33 | } 34 | 35 | public function dispose():Void 36 | { 37 | _pool.length = 0; 38 | } 39 | } -------------------------------------------------------------------------------- /away3d/core/data/RenderableListItemPool.hx: -------------------------------------------------------------------------------- 1 | package away3d.core.data; 2 | 3 | import openfl.Vector; 4 | 5 | class RenderableListItemPool 6 | { 7 | private var _pool:Vector; 8 | private var _index:Int; 9 | private var _poolSize:Int; 10 | 11 | public function new() 12 | { 13 | _index = 0; 14 | _poolSize = 0; 15 | _pool = new Vector(); 16 | } 17 | 18 | public function getItem():RenderableListItem 19 | { 20 | if (_index == _poolSize) { 21 | var item:RenderableListItem = new RenderableListItem(); 22 | _pool[_index++] = item; 23 | ++_poolSize; 24 | return item; 25 | } else 26 | return _pool[_index++]; 27 | } 28 | 29 | public function freeAll():Void 30 | { 31 | _index = 0; 32 | } 33 | 34 | public function dispose():Void 35 | { 36 | _pool.length = 0; 37 | } 38 | } -------------------------------------------------------------------------------- /away3d/materials/ColorMultiPassMaterial.hx: -------------------------------------------------------------------------------- 1 | package away3d.materials; 2 | 3 | /** 4 | * ColorMultiPassMaterial is a multi-pass material that uses a flat color as the surface's diffuse reflection value. 5 | */ 6 | class ColorMultiPassMaterial extends MultiPassMaterialBase 7 | { 8 | public var color(get, set):Int; 9 | 10 | /** 11 | * Creates a new ColorMultiPassMaterial object. 12 | * 13 | * @param color The material's diffuse surface color. 14 | */ 15 | public function new(color:Int = 0xcccccc) 16 | { 17 | super(); 18 | this.color = color; 19 | } 20 | 21 | /** 22 | * The diffuse reflectivity color of the surface. 23 | */ 24 | private function get_color():Int 25 | { 26 | return diffuseMethod.diffuseColor; 27 | } 28 | 29 | private function set_color(value:Int):Int 30 | { 31 | diffuseMethod.diffuseColor = value; 32 | return value; 33 | } 34 | } -------------------------------------------------------------------------------- /away3d/debug/Debug.hx: -------------------------------------------------------------------------------- 1 | package away3d.debug; 2 | 3 | import openfl.errors.Error; 4 | 5 | /** 6 | * Class for emmiting debuging messages, warnings and errors 7 | */ 8 | class Debug 9 | { 10 | public static var active:Bool = false; 11 | public static var warningsAsErrors:Bool = false; 12 | 13 | public static function clear():Void 14 | { 15 | } 16 | 17 | public static function delimiter():Void 18 | { 19 | } 20 | 21 | public static function trace(message:Dynamic):Void 22 | { 23 | if (active) 24 | trace(message); 25 | } 26 | 27 | public static function warning(message:Dynamic):Void 28 | { 29 | if (warningsAsErrors) { 30 | error(message); 31 | return; 32 | } 33 | trace("WARNING: " + message); 34 | } 35 | 36 | public static function error(message:Dynamic):Void 37 | { 38 | trace("ERROR: " + message); 39 | throw new Error(message); 40 | } 41 | } -------------------------------------------------------------------------------- /away3d/animators/transitions/CrossfadeTransition.hx: -------------------------------------------------------------------------------- 1 | package away3d.animators.transitions; 2 | 3 | import away3d.animators.*; 4 | import away3d.animators.nodes.*; 5 | 6 | class CrossfadeTransition implements IAnimationTransition 7 | { 8 | public var blendSpeed:Float = 0.5; 9 | 10 | public function new(blendSpeed:Float) 11 | { 12 | this.blendSpeed = blendSpeed; 13 | } 14 | 15 | public function getAnimationNode(animator:IAnimator, startNode:AnimationNodeBase, endNode:AnimationNodeBase, startBlend:Int):AnimationNodeBase 16 | { 17 | var crossFadeTransitionNode:CrossfadeTransitionNode = new CrossfadeTransitionNode(); 18 | crossFadeTransitionNode.inputA = startNode; 19 | crossFadeTransitionNode.inputB = endNode; 20 | crossFadeTransitionNode.blendSpeed = blendSpeed; 21 | crossFadeTransitionNode.startBlend = startBlend; 22 | 23 | return crossFadeTransitionNode; 24 | } 25 | } -------------------------------------------------------------------------------- /away3d/materials/methods/MethodVOSet.hx: -------------------------------------------------------------------------------- 1 | package away3d.materials.methods; 2 | 3 | /** 4 | * MethodVOSet provides a EffectMethodBase and MethodVO combination to be used by a material, allowing methods 5 | * to be shared across different materials while their internal state changes. 6 | */ 7 | class MethodVOSet 8 | { 9 | /** 10 | * An instance of a concrete EffectMethodBase subclass. 11 | */ 12 | public var method:EffectMethodBase; 13 | 14 | /** 15 | * The MethodVO data for the given method containing the material-specific data for a given material/method combination. 16 | */ 17 | public var data:MethodVO; 18 | 19 | /** 20 | * Creates a new MethodVOSet object. 21 | * @param method The method for which we need to store a MethodVO object. 22 | */ 23 | public function new(method:EffectMethodBase) 24 | { 25 | this.method = method; 26 | data = method.createMethodVO(); 27 | } 28 | } -------------------------------------------------------------------------------- /away3d/errors/DeprecationError.hx: -------------------------------------------------------------------------------- 1 | package away3d.errors; 2 | 3 | import openfl.errors.Error; 4 | 5 | class DeprecationError extends Error 6 | { 7 | public var since(get, never):String; 8 | public var source(get, never):String; 9 | public var info(get, never):String; 10 | 11 | private var _since:String; 12 | private var _source:String; 13 | private var _info:String; 14 | 15 | public function new(source:String, since:String, info:String) 16 | { 17 | super(source + " has been marked as deprecated since version " + since + " and has been slated for removal. " + info); 18 | _since = since; 19 | _source = source; 20 | _info = info; 21 | } 22 | 23 | private function get_since():String 24 | { 25 | return _since; 26 | } 27 | 28 | private function get_source():String 29 | { 30 | return _source; 31 | } 32 | 33 | private function get_info():String 34 | { 35 | return _info; 36 | } 37 | } -------------------------------------------------------------------------------- /away3d/textfield/utils/FontContainer.hx: -------------------------------------------------------------------------------- 1 | package away3d.textfield.utils; 2 | 3 | import openfl.Vector; 4 | 5 | /** 6 | * ... 7 | * @author P.J.Shand 8 | * @author Thomas Byrne 9 | */ 10 | class FontContainer 11 | { 12 | private var fontSizes:Vector = new Vector(); 13 | 14 | public function FontContainer() 15 | { 16 | 17 | } 18 | 19 | private function addSize(fontSize:FontSize):FontSize 20 | { 21 | fontSizes.push(fontSize); 22 | return fontSize; 23 | } 24 | 25 | public function best(size:Int):FontSize 26 | { 27 | var best:FontSize = null; 28 | var lowestDif:Float = Math.POSITIVE_INFINITY; 29 | for (i in 0...fontSizes.length) 30 | { 31 | var fontSize:FontSize = fontSizes[i]; 32 | var dif:Int = cast Math.abs(fontSize.size - size); 33 | if (dif < lowestDif) { 34 | best = fontSize; 35 | lowestDif = dif; 36 | } 37 | } 38 | return best; 39 | } 40 | } -------------------------------------------------------------------------------- /away3d/animators/data/ParticlePropertiesMode.hx: -------------------------------------------------------------------------------- 1 | package away3d.animators.data; 2 | 3 | /** 4 | * Options for setting the properties mode of a particle animation node. 5 | */ 6 | class ParticlePropertiesMode 7 | { 8 | /** 9 | * Mode that defines the particle node as acting on global properties (ie. the properties set in the node constructor or the corresponding animation state). 10 | */ 11 | public static inline var GLOBAL:Int = 0; 12 | 13 | /** 14 | * Mode that defines the particle node as acting on local static properties (ie. the properties of particles set in the initialising function on the animation set). 15 | */ 16 | public static inline var LOCAL_STATIC:Int = 1; 17 | 18 | /** 19 | * Mode that defines the particle node as acting on local dynamic properties (ie. the properties of the particles set in the corresponding animation state). 20 | */ 21 | public static inline var LOCAL_DYNAMIC:Int = 2; 22 | 23 | } -------------------------------------------------------------------------------- /away3d/tools/utils/TextureUtils.hx: -------------------------------------------------------------------------------- 1 | package away3d.tools.utils; 2 | 3 | import openfl.display.BitmapData; 4 | 5 | class TextureUtils 6 | { 7 | private static inline var MAX_SIZE:Int = 4096; 8 | 9 | public static function isBitmapDataValid(bitmapData:BitmapData):Bool 10 | { 11 | if (bitmapData == null) 12 | return true; 13 | 14 | return isDimensionValid(bitmapData.width) && isDimensionValid(bitmapData.height); 15 | } 16 | 17 | public static function isDimensionValid(d:Int):Bool 18 | { 19 | return d >= 1 && d <= MAX_SIZE && isPowerOfTwo(d); 20 | } 21 | 22 | public static function isPowerOfTwo(value:Int):Bool 23 | { 24 | return (value > 0)? ((value & -value) == value) : false; 25 | } 26 | 27 | public static function getBestPowerOf2(value:Int):Int 28 | { 29 | var p:Int = 1; 30 | 31 | while (p < value) 32 | p <<= 1; 33 | 34 | if (p > MAX_SIZE) 35 | p = MAX_SIZE; 36 | 37 | return p; 38 | } 39 | } -------------------------------------------------------------------------------- /away3d/debug/data/TridentLines.hx: -------------------------------------------------------------------------------- 1 | package away3d.debug.data; 2 | 3 | import away3d.entities.SegmentSet; 4 | import away3d.primitives.LineSegment; 5 | 6 | import openfl.geom.Vector3D; 7 | import openfl.Vector; 8 | 9 | class TridentLines extends SegmentSet 10 | { 11 | public function new(vectors:Vector>, colors:Vector) 12 | { 13 | super(); 14 | build(vectors, colors); 15 | } 16 | 17 | private function build(vectors:Vector>, colors:Vector):Void 18 | { 19 | var letter:Vector; 20 | var v0:Vector3D; 21 | var v1:Vector3D; 22 | var color:Int; 23 | var j:Int; 24 | 25 | for (i in 0...vectors.length) { 26 | color = colors[i]; 27 | letter = vectors[i]; 28 | 29 | j = 0; 30 | while (j < letter.length) { 31 | v0 = letter[j]; 32 | v1 = letter[j + 1]; 33 | addSegment(new LineSegment(v0, v1, color, color, 1)); 34 | j += 2; 35 | } 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /away3d/library/naming/ConflictPrecedence.hx: -------------------------------------------------------------------------------- 1 | package away3d.library.naming; 2 | 3 | /** 4 | * Enumaration class for precedence when resolving naming conflicts in the library. 5 | * 6 | * @see away3d.library.Asset3DLibrary.conflictPrecedence 7 | * @see away3d.library.Asset3DLibrary.conflictStrategy 8 | * @see away3d.library.naming.ConflictStrategy 9 | */ 10 | class ConflictPrecedence 11 | { 12 | /** 13 | * Signals that in a conflict, the previous owner of the conflicting name 14 | * should be favored (and keep it's name) and that the newly renamed asset 15 | * is reverted to a non-conflicting name. 16 | */ 17 | public static inline var FAVOR_OLD:String = "favorOld"; 18 | 19 | /** 20 | * Signales that in a conflict, the newly renamed asset is favored (and keeps 21 | * it's newly defined name) and that the previous owner of that name gets 22 | * renamed to a non-conflicting name. 23 | */ 24 | public static inline var FAVOR_NEW:String = "favorNew"; 25 | } -------------------------------------------------------------------------------- /away3d/animators/states/IUVAnimationState.hx: -------------------------------------------------------------------------------- 1 | package away3d.animators.states; 2 | 3 | import away3d.animators.data.*; 4 | 5 | /** 6 | * Provides an interface for animation node classes that hold animation data for use in the UV animator class. 7 | * 8 | * @see away3d.animators.UVAnimator 9 | */ 10 | interface IUVAnimationState extends IAnimationState 11 | { 12 | /** 13 | * Returns the current UV frame of animation in the clip based on the internal playhead position. 14 | */ 15 | var currentUVFrame(get, never):UVAnimationFrame; 16 | 17 | /** 18 | * Returns the next UV frame of animation in the clip based on the internal playhead position. 19 | */ 20 | var nextUVFrame(get, never):UVAnimationFrame; 21 | 22 | /** 23 | * Returns a fractional value between 0 and 1 representing the blending ratio of the current playhead position 24 | * between the current uv frame (0) and next uv frame (1) of the animation. 25 | */ 26 | var blendWeight(get, never):Float; 27 | } -------------------------------------------------------------------------------- /away3d/animators/data/SkeletonJoint.hx: -------------------------------------------------------------------------------- 1 | package away3d.animators.data; 2 | 3 | import openfl.Vector; 4 | 5 | /** 6 | * A value obect representing a single joint in a skeleton object. 7 | * 8 | * @see away3d.animators.data.Skeleton 9 | */ 10 | class SkeletonJoint 11 | { 12 | /** 13 | * The index of the parent joint in the skeleton's joints vector. 14 | * 15 | * @see away3d.animators.data.Skeleton#joints 16 | */ 17 | public var parentIndex:Int = -1; 18 | 19 | /** 20 | * The name of the joint 21 | */ 22 | public var name:String; // intention is that this should be used only at load time, not in the main loop 23 | 24 | /** 25 | * The inverse bind pose matrix, as raw data, used to transform vertices to bind joint space in preparation for transformation using the joint matrix. 26 | */ 27 | public var inverseBindPose:Vector; 28 | 29 | /** 30 | * Creates a new SkeletonJoint object 31 | */ 32 | public function new() 33 | { 34 | 35 | } 36 | } -------------------------------------------------------------------------------- /away3d/core/pick/PickingType.hx: -------------------------------------------------------------------------------- 1 | package away3d.core.pick; 2 | 3 | /** 4 | * Options for the different 3D object picking approaches available in Away3D. Can be used for automatic mouse picking on the view. 5 | * 6 | * @see away3d.containers.View3D#mousePicker 7 | */ 8 | class PickingType 9 | { 10 | /** 11 | * Uses a render pass to pick objects based on a key color that is read back into the engine. 12 | * Performance can be variable on some GPUs. 13 | */ 14 | public static var SHADER:IPicker = new ShaderPicker(); 15 | 16 | /** 17 | * Uses AS3 and Pixel Bender to pick objects based on ray intersection. Returns the hit on the first encountered Entity. 18 | */ 19 | public static var RAYCAST_FIRST_ENCOUNTERED:IPicker = new RaycastPicker(false); 20 | 21 | /** 22 | * Uses AS3 and Pixel Bender to pick objects based on ray intersection. Returns the best (closest) hit on an Entity. 23 | */ 24 | public static var RAYCAST_BEST_HIT:IPicker = new RaycastPicker(true); 25 | 26 | } -------------------------------------------------------------------------------- /away3d/animators/states/IVertexAnimationState.hx: -------------------------------------------------------------------------------- 1 | package away3d.animators.states; 2 | 3 | import away3d.core.base.*; 4 | 5 | /** 6 | * Provides an interface for animation node classes that hold animation data for use in the Vertex animator class. 7 | * 8 | * @see away3d.animators.VertexAnimator 9 | */ 10 | interface IVertexAnimationState extends IAnimationState 11 | { 12 | /** 13 | * Returns the current geometry frame of animation in the clip based on the internal playhead position. 14 | */ 15 | var currentGeometry(get, never):Geometry; 16 | 17 | /** 18 | * Returns the current geometry frame of animation in the clip based on the internal playhead position. 19 | */ 20 | var nextGeometry(get, never):Geometry; 21 | 22 | /** 23 | * Returns a fractional value between 0 and 1 representing the blending ratio of the current playhead position 24 | * between the current geometry frame (0) and next geometry frame (1) of the animation. 25 | */ 26 | var blendWeight(get, never):Float; 27 | } -------------------------------------------------------------------------------- /away3d/events/Scene3DEvent.hx: -------------------------------------------------------------------------------- 1 | package away3d.events; 2 | 3 | import away3d.containers.ObjectContainer3D; 4 | 5 | import openfl.events.Event; 6 | import openfl.utils.Object; 7 | 8 | class Scene3DEvent extends Event 9 | { 10 | public static inline var ADDED_TO_SCENE:String = "addedToScene"; 11 | public static inline var REMOVED_FROM_SCENE:String = "removedFromScene"; 12 | public static inline var PARTITION_CHANGED:String = "partitionChanged"; 13 | 14 | public var objectContainer3D:ObjectContainer3D; 15 | 16 | #if flash 17 | #if (haxe_ver < 4.3) @:getter(target) #else override #end private function get_target(): #if (openfl >= "9.2.0") Object #else Dynamic #end { 18 | return objectContainer3D; 19 | } 20 | #end 21 | 22 | public function new(type:String, objectContainer:ObjectContainer3D) 23 | { 24 | objectContainer3D = objectContainer; 25 | super(type); 26 | } 27 | 28 | override public function clone():Event 29 | { 30 | return new Scene3DEvent(type, objectContainer3D); 31 | } 32 | } -------------------------------------------------------------------------------- /away3d/core/partition/SkyBoxNode.hx: -------------------------------------------------------------------------------- 1 | package away3d.core.partition; 2 | 3 | import away3d.core.math.Plane3D; 4 | import away3d.core.traverse.PartitionTraverser; 5 | import away3d.primitives.SkyBox; 6 | 7 | import openfl.Vector; 8 | 9 | /** 10 | * SkyBoxNode is a space partitioning leaf node that contains a SkyBox object. 11 | */ 12 | class SkyBoxNode extends EntityNode 13 | { 14 | private var _skyBox:SkyBox; 15 | 16 | /** 17 | * Creates a new SkyBoxNode object. 18 | * @param skyBox The SkyBox to be contained in the node. 19 | */ 20 | public function new(skyBox:SkyBox) 21 | { 22 | super(skyBox); 23 | _skyBox = skyBox; 24 | } 25 | 26 | /** 27 | * @inheritDoc 28 | */ 29 | override public function acceptTraverser(traverser:PartitionTraverser):Void 30 | { 31 | if (traverser.enterNode(this)) { 32 | super.acceptTraverser(traverser); 33 | traverser.applySkyBox(_skyBox); 34 | } 35 | } 36 | 37 | override public function isInFrustum(planes:Vector, numPlanes:Int):Bool 38 | { 39 | return true; 40 | } 41 | } -------------------------------------------------------------------------------- /away3d/debug/AwayFPS.hx: -------------------------------------------------------------------------------- 1 | package away3d.debug; 2 | 3 | import openfl.display.FPS; 4 | import openfl.display.Sprite; 5 | import openfl.events.Event; 6 | import openfl.text.TextField; 7 | import openfl.text.TextFormat; 8 | import openfl.Lib; 9 | import haxe.Timer; 10 | 11 | 12 | import away3d.containers.View3D; 13 | 14 | class AwayFPS extends Sprite { 15 | 16 | var _fps:FPS; 17 | var _ply:TextField; 18 | var _view:View3D; 19 | 20 | public function new(view:View3D = null, xOff:Float = 10, yOff:Float = 10, color:Int = 0x000000, scale:Float = 4) { 21 | super(); 22 | 23 | addChild(new FPS(0, 0, color)); 24 | 25 | x = xOff; 26 | y = yOff; 27 | 28 | scaleX = scaleY = scale; 29 | 30 | _view = view; 31 | if (_view != null) { 32 | _ply = new TextField(); 33 | _ply.defaultTextFormat = new TextFormat ("_sans", 12, color); 34 | _ply.y = 12; 35 | addChild(_ply); 36 | 37 | var timer = new haxe.Timer(500); 38 | timer.run = function() { 39 | _ply.text = "PLY:"+_view.renderedFacesCount; 40 | } 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /away3d/animators/nodes/SkeletonBinaryLERPNode.hx: -------------------------------------------------------------------------------- 1 | package away3d.animators.nodes; 2 | 3 | import away3d.animators.*; 4 | import away3d.animators.states.*; 5 | 6 | /** 7 | * A skeleton animation node that uses two animation node inputs to blend a lineraly interpolated output of a skeleton pose. 8 | */ 9 | class SkeletonBinaryLERPNode extends AnimationNodeBase 10 | { 11 | /** 12 | * Defines input node A to use for the blended output. 13 | */ 14 | public var inputA:AnimationNodeBase; 15 | 16 | /** 17 | * Defines input node B to use for the blended output. 18 | */ 19 | public var inputB:AnimationNodeBase; 20 | 21 | /** 22 | * Creates a new SkeletonBinaryLERPNode object. 23 | */ 24 | public function new() 25 | { 26 | super(); 27 | _stateConstructor = cast SkeletonBinaryLERPState.new; 28 | } 29 | 30 | /** 31 | * @inheritDoc 32 | */ 33 | public function getAnimationState(animator:IAnimator):SkeletonBinaryLERPState 34 | { 35 | return cast(animator.getAnimationState(this), SkeletonBinaryLERPState); 36 | } 37 | } -------------------------------------------------------------------------------- /away3d/core/partition/LightProbeNode.hx: -------------------------------------------------------------------------------- 1 | package away3d.core.partition; 2 | 3 | import away3d.core.traverse.PartitionTraverser; 4 | import away3d.lights.LightProbe; 5 | 6 | /** 7 | * LightNode is a space partitioning leaf node that contains a LightBase object. 8 | */ 9 | class LightProbeNode extends EntityNode 10 | { 11 | public var light(get, never):LightProbe; 12 | 13 | private var _light:LightProbe; 14 | 15 | /** 16 | * Creates a new LightNode object. 17 | * @param light The light to be contained in the node. 18 | */ 19 | public function new(light:LightProbe) 20 | { 21 | super(light); 22 | _light = light; 23 | } 24 | 25 | /** 26 | * The light object contained in this node. 27 | */ 28 | private function get_light():LightProbe 29 | { 30 | return _light; 31 | } 32 | 33 | /** 34 | * @inheritDoc 35 | */ 36 | override public function acceptTraverser(traverser:PartitionTraverser):Void 37 | { 38 | if (traverser.enterNode(this)) { 39 | super.acceptTraverser(traverser); 40 | traverser.applyLightProbe(_light); 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /away3d/core/partition/PointLightNode.hx: -------------------------------------------------------------------------------- 1 | package away3d.core.partition; 2 | 3 | import away3d.core.traverse.PartitionTraverser; 4 | import away3d.lights.PointLight; 5 | 6 | /** 7 | * LightNode is a space partitioning leaf node that contains a LightBase object. 8 | */ 9 | class PointLightNode extends EntityNode 10 | { 11 | public var light(get, never):PointLight; 12 | 13 | private var _light:PointLight; 14 | 15 | /** 16 | * Creates a new LightNode object. 17 | * @param light The light to be contained in the node. 18 | */ 19 | public function new(light:PointLight) 20 | { 21 | super(light); 22 | _light = light; 23 | } 24 | 25 | /** 26 | * The light object contained in this node. 27 | */ 28 | private function get_light():PointLight 29 | { 30 | return _light; 31 | } 32 | 33 | /** 34 | * @inheritDoc 35 | */ 36 | override public function acceptTraverser(traverser:PartitionTraverser):Void 37 | { 38 | if (traverser.enterNode(this)) { 39 | super.acceptTraverser(traverser); 40 | traverser.applyPointLight(_light); 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /away3d/animators/nodes/SkeletonDifferenceNode.hx: -------------------------------------------------------------------------------- 1 | package away3d.animators.nodes; 2 | 3 | import away3d.animators.*; 4 | import away3d.animators.states.*; 5 | 6 | /** 7 | * A skeleton animation node that uses a difference input pose with a base input pose to blend a linearly interpolated output of a skeleton pose. 8 | */ 9 | class SkeletonDifferenceNode extends AnimationNodeBase 10 | { 11 | /** 12 | * Defines a base input node to use for the blended output. 13 | */ 14 | public var baseInput:AnimationNodeBase; 15 | 16 | /** 17 | * Defines a difference input node to use for the blended output. 18 | */ 19 | public var differenceInput:AnimationNodeBase; 20 | 21 | /** 22 | * Creates a new SkeletonAdditiveNode object. 23 | */ 24 | public function new() 25 | { 26 | _stateConstructor = cast SkeletonDifferenceState.new; 27 | super(); 28 | } 29 | 30 | /** 31 | * @inheritDoc 32 | */ 33 | public function getAnimationState(animator:IAnimator):SkeletonDifferenceState 34 | { 35 | return cast(animator.getAnimationState(this), SkeletonDifferenceState); 36 | } 37 | } -------------------------------------------------------------------------------- /away3d/core/partition/RenderableNode.hx: -------------------------------------------------------------------------------- 1 | package away3d.core.partition; 2 | 3 | import away3d.core.base.IRenderable; 4 | import away3d.core.traverse.PartitionTraverser; 5 | import away3d.entities.Entity; 6 | 7 | /** 8 | * RenderableNode is a space partitioning leaf node that contains any Entity that is itself a IRenderable 9 | * object. This excludes Mesh (since the renderable objects are its SubMesh children). 10 | */ 11 | class RenderableNode extends EntityNode 12 | { 13 | private var _renderable:IRenderable; 14 | 15 | /** 16 | * Creates a new RenderableNode object. 17 | * @param mesh The mesh to be contained in the node. 18 | */ 19 | public function new(renderable:IRenderable) 20 | { 21 | super(cast(renderable, Entity)); 22 | _renderable = renderable; // also keep a stronger typed reference 23 | } 24 | 25 | /** 26 | * @inheritDoc 27 | */ 28 | override public function acceptTraverser(traverser:PartitionTraverser):Void 29 | { 30 | if (traverser.enterNode(this)) { 31 | super.acceptTraverser(traverser); 32 | traverser.applyRenderable(_renderable); 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /away3d/textures/Anisotropy.hx: -------------------------------------------------------------------------------- 1 | package away3d.textures; 2 | 3 | #if (haxe_ver >= 4.0) enum #else @:enum #end abstract Anisotropy(Null) 4 | { 5 | public var NONE = 0; 6 | public var ANISOTROPIC2X = 1; 7 | public var ANISOTROPIC4X = 2; 8 | public var ANISOTROPIC8X = 3; 9 | public var ANISOTROPIC16X = 4; 10 | 11 | @:from private static function fromString (value:String):Anisotropy 12 | { 13 | return switch (value) { 14 | case "none": NONE; 15 | case "anisotropic2x": ANISOTROPIC2X; 16 | case "anisotropic4x": ANISOTROPIC4X; 17 | case "anisotropic8x": ANISOTROPIC8X; 18 | case "anisotropic16x": ANISOTROPIC16X; 19 | default: null; 20 | 21 | } 22 | 23 | } 24 | 25 | @:to private function toString ():String 26 | { 27 | return switch (cast this : Anisotropy) { 28 | case Anisotropy.NONE: "bool"; 29 | case Anisotropy.ANISOTROPIC2X: "anisotropic2x"; 30 | case Anisotropy.ANISOTROPIC4X: "anisotropic4x"; 31 | case Anisotropy.ANISOTROPIC8X: "anisotropic8x"; 32 | case Anisotropy.ANISOTROPIC16X: "anisotropic16x"; 33 | default: null; 34 | } 35 | 36 | } 37 | } -------------------------------------------------------------------------------- /away3d/core/partition/LightNode.hx: -------------------------------------------------------------------------------- 1 | package away3d.core.partition; 2 | 3 | import away3d.core.traverse.PartitionTraverser; 4 | import away3d.lights.LightBase; 5 | 6 | /** 7 | * LightNode is a space partitioning leaf node that contains a LightBase object. Used for lights that are not of default supported type. 8 | */ 9 | class LightNode extends EntityNode 10 | { 11 | public var light(get, never):LightBase; 12 | 13 | private var _light:LightBase; 14 | 15 | /** 16 | * Creates a new LightNode object. 17 | * @param light The light to be contained in the node. 18 | */ 19 | public function new(light:LightBase) 20 | { 21 | super(light); 22 | _light = light; 23 | } 24 | 25 | /** 26 | * The light object contained in this node. 27 | */ 28 | private function get_light():LightBase 29 | { 30 | return _light; 31 | } 32 | 33 | /** 34 | * @inheritDoc 35 | */ 36 | override public function acceptTraverser(traverser:PartitionTraverser):Void 37 | { 38 | if (traverser.enterNode(this)) { 39 | super.acceptTraverser(traverser); 40 | traverser.applyUnknownLight(_light); 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /away3d/core/partition/DirectionalLightNode.hx: -------------------------------------------------------------------------------- 1 | package away3d.core.partition; 2 | 3 | import away3d.core.traverse.PartitionTraverser; 4 | import away3d.lights.DirectionalLight; 5 | 6 | /** 7 | * LightNode is a space partitioning leaf node that contains a LightBase object. 8 | */ 9 | class DirectionalLightNode extends EntityNode 10 | { 11 | public var light(get, never):DirectionalLight; 12 | 13 | private var _light:DirectionalLight; 14 | 15 | /** 16 | * Creates a new LightNode object. 17 | * @param light The light to be contained in the node. 18 | */ 19 | public function new(light:DirectionalLight) 20 | { 21 | super(light); 22 | _light = light; 23 | } 24 | 25 | /** 26 | * The light object contained in this node. 27 | */ 28 | private function get_light():DirectionalLight 29 | { 30 | return _light; 31 | } 32 | 33 | /** 34 | * @inheritDoc 35 | */ 36 | override public function acceptTraverser(traverser:PartitionTraverser):Void 37 | { 38 | if (traverser.enterNode(this)) { 39 | super.acceptTraverser(traverser); 40 | traverser.applyDirectionalLight(_light); 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /away3d/primitives/data/NURBSVertex.hx: -------------------------------------------------------------------------------- 1 | package away3d.primitives.data; 2 | 3 | import away3d.core.base.data.Vertex; 4 | 5 | /** 6 | * A nurbvertex that simply extends vertex with a w weight property. 7 | * Properties x, y, z and w represent a 3d point in space with nurb weighting. 8 | */ 9 | class NURBSVertex extends Vertex 10 | { 11 | public var w(get, set):Float; 12 | 13 | private var _w:Float; 14 | 15 | private function get_w():Float { 16 | return _w; 17 | } 18 | 19 | private function set_w(w:Float):Float 20 | { 21 | _w = w; 22 | return w; 23 | } 24 | 25 | /** 26 | * Creates a new Vertex object. 27 | * 28 | * @param x [optional] The local x position of the vertex. Defaults to 0. 29 | * @param y [optional] The local y position of the vertex. Defaults to 0. 30 | * @param z [optional] The local z position of the vertex. Defaults to 0. 31 | * @param w [optional] The local w weight of the vertex. Defaults to 1. 32 | */ 33 | public function new(x:Float = 0, y:Float = 0, z:Float = 0, w:Float = 1) 34 | { 35 | _w = w; 36 | super(x, y, z); 37 | } 38 | } -------------------------------------------------------------------------------- /away3d/animators/nodes/AnimationNodeBase.hx: -------------------------------------------------------------------------------- 1 | package away3d.animators.nodes; 2 | 3 | import away3d.animators.AnimatorBase; 4 | import away3d.animators.states.IAnimationState; 5 | import away3d.library.assets.*; 6 | 7 | /** 8 | * Provides an abstract base class for nodes in an animation blend tree. 9 | */ 10 | class AnimationNodeBase extends NamedAssetBase implements IAsset 11 | { 12 | public var stateConstructor(get, never):IAnimator -> AnimationNodeBase -> IAnimationState; 13 | public var assetType(get, never):String; 14 | 15 | private var _stateConstructor:IAnimator -> AnimationNodeBase -> IAnimationState; 16 | 17 | private function get_stateConstructor():IAnimator -> AnimationNodeBase -> IAnimationState 18 | { 19 | return _stateConstructor; 20 | } 21 | 22 | /** 23 | * Creates a new AnimationNodeBase object. 24 | */ 25 | public function new() 26 | { 27 | super(); 28 | } 29 | 30 | /** 31 | * @inheritDoc 32 | */ 33 | public function dispose():Void 34 | { 35 | } 36 | 37 | /** 38 | * @inheritDoc 39 | */ 40 | private function get_assetType():String 41 | { 42 | return Asset3DType.ANIMATION_NODE; 43 | } 44 | } -------------------------------------------------------------------------------- /away3d/textfield/CleanMasterString.hx: -------------------------------------------------------------------------------- 1 | // ================================================================================================= 2 | // 3 | // Starling Framework 4 | // Copyright 2014 Gamua GmbH. All Rights Reserved. 5 | // 6 | // This program is free software. You can redistribute and/or modify it 7 | // in accordance with the terms of the accompanying license agreement. 8 | // 9 | // ================================================================================================= 10 | 11 | package away3d.textfield; 12 | 13 | class CleanMasterString 14 | { 15 | /** Replaces a string's "master string" — the string it was built from — 16 | * with a single character to save memory. Find more information about this AS3 oddity 17 | * here. 18 | * 19 | * @param str String to clean 20 | * @return The input string, but with a master string only one character larger than it. 21 | * @author Jackson Dunstan, JacksonDunstan.com 22 | */ 23 | public function new() 24 | { 25 | 26 | } 27 | 28 | public function call(str:String):String 29 | { 30 | return ("_" + str).substr(1); 31 | } 32 | } -------------------------------------------------------------------------------- /away3d/textures/ATFTexture.hx: -------------------------------------------------------------------------------- 1 | package away3d.textures; 2 | 3 | import openfl.display3D.Context3D; 4 | import openfl.display3D.textures.Texture; 5 | import openfl.display3D.textures.TextureBase; 6 | import openfl.utils.ByteArray; 7 | 8 | class ATFTexture extends Texture2DBase 9 | { 10 | public var atfData(get, set):ATFData; 11 | 12 | private var _atfData:ATFData; 13 | 14 | public function new(byteArray:ByteArray) 15 | { 16 | super(); 17 | 18 | atfData = new ATFData(byteArray); 19 | _format = atfData.format; 20 | _hasMipmaps = _atfData.numTextures > 1; 21 | } 22 | 23 | private function get_atfData():ATFData 24 | { 25 | return _atfData; 26 | } 27 | 28 | private function set_atfData(value:ATFData):ATFData 29 | { 30 | _atfData = value; 31 | 32 | invalidateContent(); 33 | 34 | setSize(value.width, value.height); 35 | return value; 36 | } 37 | 38 | override private function uploadContent(texture:TextureBase):Void 39 | { 40 | cast(texture, Texture).uploadCompressedTextureFromByteArray(_atfData.data, 0, false); 41 | } 42 | 43 | override private function createTexture(context:Context3D):TextureBase 44 | { 45 | return context.createTexture(_width, _height, atfData.format, false); 46 | } 47 | } -------------------------------------------------------------------------------- /away3d/primitives/ConeGeometry.hx: -------------------------------------------------------------------------------- 1 | package away3d.primitives; 2 | 3 | /** 4 | * A UV Cone primitive mesh. 5 | */ 6 | class ConeGeometry extends CylinderGeometry 7 | { 8 | public var radius(get, set):Float; 9 | 10 | /** 11 | * The radius of the bottom end of the cone. 12 | */ 13 | private function get_radius():Float 14 | { 15 | return _bottomRadius; 16 | } 17 | 18 | private function set_radius(value:Float):Float 19 | { 20 | _bottomRadius = value; 21 | invalidateGeometry(); 22 | return value; 23 | } 24 | 25 | /** 26 | * Creates a new Cone object. 27 | * @param radius The radius of the bottom end of the cone 28 | * @param height The height of the cone 29 | * @param segmentsW Defines the number of horizontal segments that make up the cone. Defaults to 16. 30 | * @param segmentsH Defines the number of vertical segments that make up the cone. Defaults to 1. 31 | * @param yUp Defines whether the cone poles should lay on the Y-axis (true) or on the Z-axis (false). 32 | */ 33 | public function new(radius:Float = 50, height:Float = 100, segmentsW:Int = 16, segmentsH:Int = 1, closed:Bool = true, yUp:Bool = true) 34 | { 35 | super(0, radius, height, segmentsW, segmentsH, false, closed, true, yUp); 36 | } 37 | } -------------------------------------------------------------------------------- /away3d/textfield/VAlign.hx: -------------------------------------------------------------------------------- 1 | // ================================================================================================= 2 | // 3 | // Starling Framework 4 | // Copyright 2011-2014 Gamua. All Rights Reserved. 5 | // 6 | // This program is free software. You can redistribute and/or modify it 7 | // in accordance with the terms of the accompanying license agreement. 8 | // 9 | // ================================================================================================= 10 | 11 | package away3d.textfield; 12 | 13 | import openfl.errors.Error; 14 | 15 | /** A class that provides constant values for vertical alignment of objects. */ 16 | class VAlign 17 | { 18 | /** @private */ 19 | @:allow(away3d) private function new() { throw new Error(); } 20 | 21 | /** Top alignment. */ 22 | public static var TOP:String = "top"; 23 | 24 | /** Centered alignment. */ 25 | public static var CENTER:String = "center"; 26 | 27 | /** Bottom alignment. */ 28 | public static var BOTTOM:String = "bottom"; 29 | 30 | /** Indicates whether the given alignment string is valid. */ 31 | public static function isValid(vAlign:String):Bool 32 | { 33 | return vAlign == VAlign.TOP || vAlign == VAlign.CENTER || vAlign == VAlign.BOTTOM; 34 | } 35 | } -------------------------------------------------------------------------------- /away3d/textfield/HAlign.hx: -------------------------------------------------------------------------------- 1 | // ================================================================================================= 2 | // 3 | // Starling Framework 4 | // Copyright 2011-2014 Gamua. All Rights Reserved. 5 | // 6 | // This program is free software. You can redistribute and/or modify it 7 | // in accordance with the terms of the accompanying license agreement. 8 | // 9 | // ================================================================================================= 10 | 11 | package away3d.textfield; 12 | 13 | import openfl.errors.Error; 14 | 15 | /** A class that provides constant values for horizontal alignment of objects. */ 16 | class HAlign 17 | { 18 | /** @private */ 19 | @:allow(away3d) private function new() { throw new Error(); } 20 | 21 | /** Left alignment. */ 22 | public static var LEFT:String = "left"; 23 | 24 | /** Centered alignement. */ 25 | public static var CENTER:String = "center"; 26 | 27 | /** Right alignment. */ 28 | public static var RIGHT:String = "right"; 29 | 30 | /** Indicates whether the given alignment string is valid. */ 31 | public static function isValid(hAlign:String):Bool 32 | { 33 | return hAlign == HAlign.LEFT || hAlign == HAlign.CENTER || hAlign == HAlign.RIGHT; 34 | } 35 | } -------------------------------------------------------------------------------- /away3d/core/partition/MeshNode.hx: -------------------------------------------------------------------------------- 1 | package away3d.core.partition; 2 | 3 | import away3d.core.base.SubMesh; 4 | import away3d.core.traverse.PartitionTraverser; 5 | import away3d.entities.Mesh; 6 | 7 | import openfl.Vector; 8 | 9 | /** 10 | * MeshNode is a space partitioning leaf node that contains a Mesh object. 11 | */ 12 | class MeshNode extends EntityNode 13 | { 14 | public var mesh(get, never):Mesh; 15 | 16 | private var _mesh:Mesh; 17 | 18 | /** 19 | * Creates a new MeshNode object. 20 | * @param mesh The mesh to be contained in the node. 21 | */ 22 | public function new(mesh:Mesh) 23 | { 24 | super(mesh); 25 | _mesh = mesh; // also keep a stronger typed reference 26 | } 27 | 28 | /** 29 | * The mesh object contained in the partition node. 30 | */ 31 | private function get_mesh():Mesh 32 | { 33 | return _mesh; 34 | } 35 | 36 | /** 37 | * @inheritDoc 38 | */ 39 | override public function acceptTraverser(traverser:PartitionTraverser):Void 40 | { 41 | if (traverser.enterNode(this)) { 42 | super.acceptTraverser(traverser); 43 | var subs:Vector = _mesh.subMeshes; 44 | var i:Int = 0; 45 | var len:Int = subs.length; 46 | while (i < len) 47 | traverser.applyRenderable(subs[i++]); 48 | } 49 | } 50 | } -------------------------------------------------------------------------------- /away3d/filters/MotionBlurFilter3D.hx: -------------------------------------------------------------------------------- 1 | package away3d.filters; 2 | 3 | import away3d.cameras.Camera3D; 4 | import away3d.core.managers.Stage3DProxy; 5 | import away3d.filters.tasks.Filter3DDoubleBufferCopyTask; 6 | import away3d.filters.tasks.Filter3DXFadeCompositeTask; 7 | 8 | class MotionBlurFilter3D extends Filter3DBase 9 | { 10 | public var strength(get, set):Float; 11 | 12 | private var _compositeTask:Filter3DXFadeCompositeTask; 13 | private var _copyTask:Filter3DDoubleBufferCopyTask; 14 | 15 | public function new(strength:Float = .65) 16 | { 17 | super(); 18 | _compositeTask = new Filter3DXFadeCompositeTask(strength); 19 | _copyTask = new Filter3DDoubleBufferCopyTask(); 20 | 21 | addTask(_compositeTask); 22 | addTask(_copyTask); 23 | } 24 | 25 | private function get_strength():Float 26 | { 27 | return _compositeTask.amount; 28 | } 29 | 30 | private function set_strength(value:Float):Float 31 | { 32 | _compositeTask.amount = value; 33 | return value; 34 | } 35 | 36 | override public function update(stage:Stage3DProxy, camera:Camera3D):Void 37 | { 38 | // TODO: not used 39 | 40 | _compositeTask.overlayTexture = _copyTask.getMainInputTexture(stage); 41 | _compositeTask.target = _copyTask.secondaryInputTexture; 42 | } 43 | } -------------------------------------------------------------------------------- /away3d/stereo/methods/AnaglyphStereoRenderMethod.hx: -------------------------------------------------------------------------------- 1 | package away3d.stereo.methods; 2 | 3 | import away3d.core.managers.Stage3DProxy; 4 | 5 | import openfl.display3D.Context3DProgramType; 6 | import openfl.Vector; 7 | 8 | class AnaglyphStereoRenderMethod extends StereoRenderMethodBase 9 | { 10 | private var _filterData:Vector; 11 | 12 | public function new() 13 | { 14 | super(); 15 | 16 | _filterData = Vector.ofArray([ 17 | 1.0, 0.0, 0.0, 1.0, 18 | 0.0, 1.0, 1.0, 1.0, 19 | 1.0, 1.0, 1.0, 1.0]); 20 | } 21 | 22 | override public function activate(stage3DProxy:Stage3DProxy):Void 23 | { 24 | stage3DProxy.context3D.setProgramConstantsFromVector(Context3DProgramType.FRAGMENT, 0, _filterData, 3); 25 | } 26 | 27 | override public function deactivate(stage3DProxy:Stage3DProxy):Void 28 | { 29 | stage3DProxy.context3D.setTextureAt(2, null); 30 | } 31 | 32 | override public function getFragmentCode():String 33 | { 34 | return "tex ft0, v1, fs0 <2d,linear,nomip>\n" + 35 | "tex ft1, v1, fs1 <2d,linear,nomip>\n" + 36 | "mul ft0, ft0, fc0\n" + 37 | "sub ft0, fc2, ft0\n" + 38 | "mul ft1, ft1, fc1\n" + 39 | "sub ft1, fc2, ft1\n" + 40 | "mul ft2, ft0, ft1\n" + 41 | "div ft2, ft2, fc2\n" + 42 | "sub oc, fc2, ft2\n"; 43 | } 44 | } -------------------------------------------------------------------------------- /away3d/animators/states/ParticleUVState.hx: -------------------------------------------------------------------------------- 1 | package away3d.animators.states; 2 | 3 | import away3d.cameras.Camera3D; 4 | import away3d.animators.data.AnimationRegisterCache; 5 | import away3d.animators.data.AnimationSubGeometry; 6 | import away3d.core.base.IRenderable; 7 | import away3d.core.managers.Stage3DProxy; 8 | import away3d.animators.nodes.ParticleUVNode; 9 | import away3d.animators.ParticleAnimator; 10 | 11 | import openfl.geom.Vector3D; 12 | 13 | /** 14 | * ... 15 | */ 16 | class ParticleUVState extends ParticleStateBase 17 | { 18 | private var _particleUVNode:ParticleUVNode; 19 | 20 | public function new(animator:ParticleAnimator, particleUVNode:ParticleUVNode) 21 | { 22 | super(animator, particleUVNode); 23 | 24 | _particleUVNode = particleUVNode; 25 | } 26 | 27 | override public function setRenderState(stage3DProxy:Stage3DProxy, renderable:IRenderable, animationSubGeometry:AnimationSubGeometry, animationRegisterCache:AnimationRegisterCache, camera:Camera3D):Void 28 | { 29 | if (animationRegisterCache.needUVAnimation) { 30 | var index:Int = animationRegisterCache.getRegisterIndex(_animationNode, ParticleUVNode.UV_INDEX); 31 | var data:Vector3D = _particleUVNode._uvData; 32 | animationRegisterCache.setVertexConst(index, data.x, data.y); 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /away3d/animators/transitions/CrossfadeTransitionState.hx: -------------------------------------------------------------------------------- 1 | package away3d.animators.transitions; 2 | 3 | import away3d.animators.*; 4 | import away3d.animators.states.*; 5 | import away3d.events.*; 6 | 7 | /** 8 | * 9 | */ 10 | class CrossfadeTransitionState extends SkeletonBinaryLERPState 11 | { 12 | private var _crossfadeAnimationNode:CrossfadeTransitionNode; 13 | private var _animationStateTransitionComplete:AnimationStateEvent; 14 | 15 | public function new(animator:IAnimator, crossfadeAnimationNode:CrossfadeTransitionNode) 16 | { 17 | super(animator, crossfadeAnimationNode); 18 | 19 | _crossfadeAnimationNode = crossfadeAnimationNode; 20 | } 21 | 22 | /** 23 | * @inheritDoc 24 | */ 25 | override private function updateTime(time:Int):Void 26 | { 27 | blendWeight = Math.abs(time - _crossfadeAnimationNode.startBlend)/(1000*_crossfadeAnimationNode.blendSpeed); 28 | 29 | if (blendWeight >= 1) { 30 | blendWeight = 1; 31 | if (_animationStateTransitionComplete == null) { 32 | _animationStateTransitionComplete = new AnimationStateEvent(AnimationStateEvent.TRANSITION_COMPLETE, _animator, this, _crossfadeAnimationNode); 33 | } 34 | _crossfadeAnimationNode.dispatchEvent(_animationStateTransitionComplete); 35 | } 36 | 37 | super.updateTime(time); 38 | } 39 | } -------------------------------------------------------------------------------- /away3d/materials/LightSources.hx: -------------------------------------------------------------------------------- 1 | package away3d.materials; 2 | 3 | /** 4 | * Enumeration class for defining which lighting types affect the specific material 5 | * lighting component (diffuse and specular). This can be useful if, for example, you 6 | * want to use light probes for diffuse global lighting, but want specular reflections from 7 | * traditional light sources without those affecting the diffuse light. 8 | * 9 | * @see away3d.materials.ColorMaterial.diffuseLightSources 10 | * @see away3d.materials.ColorMaterial.specularLightSources 11 | * @see away3d.materials.TextureMaterial.diffuseLightSources 12 | * @see away3d.materials.TextureMaterial.specularLightSources 13 | */ 14 | class LightSources 15 | { 16 | /** 17 | * Defines normal lights are to be used as the source for the lighting 18 | * component. 19 | */ 20 | public static inline var LIGHTS:Int = 0x01; 21 | 22 | /** 23 | * Defines that global lighting probes are to be used as the source for the 24 | * lighting component. 25 | */ 26 | public static inline var PROBES:Int = 0x02; 27 | 28 | /** 29 | * Defines that both normal and global lighting probes are to be used as the 30 | * source for the lighting component. This is equivalent to LIGHTS | PROBES. 31 | */ 32 | public static inline var ALL:Int = 0x03; 33 | } -------------------------------------------------------------------------------- /away3d/textfield/utils/FontSize.hx: -------------------------------------------------------------------------------- 1 | package away3d.textfield.utils; 2 | 3 | import openfl.display.Bitmap; 4 | import openfl.display.BitmapData; 5 | import haxe.io.Bytes; 6 | import openfl.errors.Error; 7 | /** 8 | * ... 9 | * @author P.J.Shand 10 | * @author Thomas Byrne 11 | */ 12 | class FontSize 13 | { 14 | public var family:String; 15 | public var size:Int; 16 | public var data:Xml; 17 | public var texture:BitmapData; 18 | 19 | public function FontSize(searchClass:Bool=true) 20 | { 21 | if (searchClass) { 22 | var type:Class = Type.getClass(this); 23 | try { 24 | family = Reflect.getProperty(type, "FAMILY"); 25 | size = Reflect.getProperty(type, "SIZE"); 26 | 27 | var dataType:Class = Reflect.getProperty(type, "DATA"); 28 | var textureType:Class = Reflect.getProperty(type, "TEXTURE"); 29 | data = cast(Type.createInstance(dataType, null), Xml); 30 | //texture = cast(Type.createInstance(textureType, null), Bitmap).bitmapData; 31 | texture = BitmapData.fromBytes(cast(Type.createInstance(textureType, []), Bytes)); // is this correct? 32 | 33 | }catch (e:Error) { 34 | throw new Error("Class inheriting from FontSize ("+type+") should have PUBLIC static members FAMILY, SIZE, DATA and TEXTURE."); 35 | } 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /away3d/events/ParserEvent.hx: -------------------------------------------------------------------------------- 1 | package away3d.events; 2 | 3 | import openfl.events.Event; 4 | 5 | class ParserEvent extends Event 6 | { 7 | public var message(get, never):String; 8 | 9 | private var _message:String; 10 | 11 | /** 12 | * Dispatched when parsing of an asset completed. 13 | */ 14 | public static inline var PARSE_COMPLETE:String = "parseComplete"; 15 | 16 | /** 17 | * Dispatched when an error occurs while parsing the data (e.g. because it's 18 | * incorrectly formatted.) 19 | */ 20 | public static inline var PARSE_ERROR:String = "parseError"; 21 | 22 | /** 23 | * Dispatched when a parser is ready to have dependencies retrieved and resolved. 24 | * This is an internal event that should rarely (if ever) be listened for by 25 | * external classes. 26 | */ 27 | public static inline var READY_FOR_DEPENDENCIES:String = "readyForDependencies"; 28 | 29 | public function new(type:String, message:String = "") 30 | { 31 | super(type); 32 | 33 | _message = message; 34 | } 35 | 36 | /** 37 | * Additional human-readable message. Usually supplied for PARSE_ERROR events. 38 | */ 39 | private function get_message():String 40 | { 41 | return _message; 42 | } 43 | 44 | override public function clone():Event 45 | { 46 | return new ParserEvent(type, message); 47 | } 48 | } -------------------------------------------------------------------------------- /away3d/materials/SkyBoxMaterial.hx: -------------------------------------------------------------------------------- 1 | package away3d.materials; 2 | 3 | import away3d.materials.passes.SkyBoxPass; 4 | import away3d.textures.CubeTextureBase; 5 | 6 | /** 7 | * SkyBoxMaterial is a material exclusively used to render skyboxes 8 | * 9 | * @see away3d.primitives.SkyBox 10 | */ 11 | class SkyBoxMaterial extends MaterialBase 12 | { 13 | public var cubeMap(get, set):CubeTextureBase; 14 | 15 | private var _cubeMap:CubeTextureBase; 16 | private var _skyboxPass:SkyBoxPass; 17 | 18 | /** 19 | * Creates a new SkyBoxMaterial object. 20 | * @param cubeMap The CubeMap to use as the skybox. 21 | */ 22 | public function new(cubeMap:CubeTextureBase) 23 | { 24 | super(); 25 | _cubeMap = cubeMap; 26 | addPass(_skyboxPass = new SkyBoxPass()); 27 | _skyboxPass.cubeTexture = _cubeMap; 28 | } 29 | 30 | /** 31 | * The cube texture to use as the skybox. 32 | */ 33 | private function get_cubeMap():CubeTextureBase 34 | { 35 | return _cubeMap; 36 | } 37 | 38 | private function set_cubeMap(value:CubeTextureBase):CubeTextureBase 39 | { 40 | if (value != null && _cubeMap != null && (value.hasMipMaps != _cubeMap.hasMipMaps || value.format != _cubeMap.format)) 41 | invalidatePasses(null); 42 | 43 | _cubeMap = value; 44 | 45 | _skyboxPass.cubeTexture = _cubeMap; 46 | return value; 47 | } 48 | } -------------------------------------------------------------------------------- /away3d/textfield/RectangleBitmapTexture.hx: -------------------------------------------------------------------------------- 1 | package away3d.textfield; 2 | 3 | import away3d.textures.Texture2DBase; 4 | import openfl.display.BitmapData; 5 | import openfl.display3D.Context3D; 6 | import openfl.display3D.Context3DTextureFormat; 7 | import openfl.display3D.textures.RectangleTexture; 8 | import openfl.display3D.textures.TextureBase; 9 | 10 | class RectangleBitmapTexture extends Texture2DBase { 11 | private var _bitmapData:BitmapData; 12 | 13 | public function new(bitmapData:BitmapData) { 14 | this.bitmapData = bitmapData; 15 | super(); 16 | } 17 | 18 | public var bitmapData(get, set):BitmapData; 19 | private function get_bitmapData():BitmapData { 20 | return _bitmapData; 21 | } 22 | 23 | private function set_bitmapData(value:BitmapData):BitmapData { 24 | if (value == _bitmapData) 25 | return value; 26 | 27 | invalidateContent(); 28 | setSize(value.width, value.height); 29 | 30 | _bitmapData = value; 31 | return value; 32 | } 33 | 34 | override private function uploadContent(texture:TextureBase):Void { 35 | cast(texture, RectangleTexture).uploadFromBitmapData(_bitmapData); 36 | } 37 | 38 | override private function createTexture(context:Context3D):TextureBase { 39 | return context.createRectangleTexture(_width, _height, Context3DTextureFormat.BGRA, false); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /away3d/animators/nodes/SkeletonDirectionalNode.hx: -------------------------------------------------------------------------------- 1 | package away3d.animators.nodes; 2 | 3 | import away3d.animators.*; 4 | import away3d.animators.states.*; 5 | 6 | /** 7 | * A skeleton animation node that uses four directional input poses with an input direction to blend a linearly interpolated output of a skeleton pose. 8 | */ 9 | class SkeletonDirectionalNode extends AnimationNodeBase 10 | { 11 | /** 12 | * Defines the forward configured input node to use for the blended output. 13 | */ 14 | public var forward:AnimationNodeBase; 15 | 16 | /** 17 | * Defines the backwards configured input node to use for the blended output. 18 | */ 19 | public var backward:AnimationNodeBase; 20 | 21 | /** 22 | * Defines the left configured input node to use for the blended output. 23 | */ 24 | public var left:AnimationNodeBase; 25 | 26 | /** 27 | * Defines the right configured input node to use for the blended output. 28 | */ 29 | public var right:AnimationNodeBase; 30 | 31 | public function new() 32 | { 33 | _stateConstructor = cast SkeletonDirectionalState.new; 34 | super(); 35 | } 36 | 37 | /** 38 | * @inheritDoc 39 | */ 40 | public function getAnimationState(animator:IAnimator):SkeletonDirectionalState 41 | { 42 | return cast(animator.getAnimationState(this), SkeletonDirectionalState); 43 | } 44 | } -------------------------------------------------------------------------------- /away3d/materials/compilation/ShaderRegisterData.hx: -------------------------------------------------------------------------------- 1 | package away3d.materials.compilation; 2 | 3 | /** 4 | * ShaderRegisterData contains the "named" registers, generated by the compiler and to be passed on to the methods. 5 | */ 6 | class ShaderRegisterData 7 | { 8 | public var normalVarying:ShaderRegisterElement; 9 | public var tangentVarying:ShaderRegisterElement; 10 | public var bitangentVarying:ShaderRegisterElement; 11 | public var uvVarying:ShaderRegisterElement; 12 | public var secondaryUVVarying:ShaderRegisterElement; 13 | public var viewDirVarying:ShaderRegisterElement; 14 | public var shadedTarget:ShaderRegisterElement; 15 | public var globalPositionVertex:ShaderRegisterElement; 16 | public var globalPositionVarying:ShaderRegisterElement; 17 | public var localPosition:ShaderRegisterElement; 18 | public var normalInput:ShaderRegisterElement; 19 | public var tangentInput:ShaderRegisterElement; 20 | public var animatedNormal:ShaderRegisterElement; 21 | public var animatedTangent:ShaderRegisterElement; 22 | public var commons:ShaderRegisterElement; 23 | public var projectionFragment:ShaderRegisterElement; 24 | public var normalFragment:ShaderRegisterElement; 25 | public var viewDirFragment:ShaderRegisterElement; 26 | public var bitangent:ShaderRegisterElement; 27 | 28 | public function new() 29 | { 30 | 31 | } 32 | } -------------------------------------------------------------------------------- /away3d/cameras/lenses/FreeMatrixLens.hx: -------------------------------------------------------------------------------- 1 | package away3d.cameras.lenses; 2 | 3 | /** 4 | * FreeMatrixLens provides a projection lens that exposes a full projection matrix, rather than provide one through 5 | * more user-friendly settings. Whenever the matrix is updated, it needs to be reset in order to trigger an update. 6 | */ 7 | class FreeMatrixLens extends LensBase 8 | { 9 | /** 10 | * Creates a new FreeMatrixLens object. 11 | */ 12 | public function new() 13 | { 14 | super(); 15 | _matrix.copyFrom(new PerspectiveLens().matrix); 16 | } 17 | 18 | override private function set_near(value:Float):Float 19 | { 20 | _near = value; 21 | return value; 22 | } 23 | 24 | override private function set_far(value:Float):Float 25 | { 26 | _far = value; 27 | return value; 28 | } 29 | 30 | override private function set_aspectRatio(value:Float):Float 31 | { 32 | _aspectRatio = value; 33 | return value; 34 | } 35 | 36 | override public function clone():LensBase 37 | { 38 | var clone:FreeMatrixLens = new FreeMatrixLens(); 39 | clone._matrix.copyFrom(_matrix); 40 | clone._near = _near; 41 | clone._far = _far; 42 | clone._aspectRatio = _aspectRatio; 43 | clone.invalidateMatrix(); 44 | return clone; 45 | } 46 | 47 | override private function updateMatrix():Void 48 | { 49 | _matrixInvalid = false; 50 | } 51 | } -------------------------------------------------------------------------------- /away3d/tools/helpers/data/ParticleGeometryTransform.hx: -------------------------------------------------------------------------------- 1 | package away3d.tools.helpers.data; 2 | 3 | import openfl.geom.Matrix; 4 | import openfl.geom.Matrix3D; 5 | 6 | /** 7 | * ... 8 | */ 9 | class ParticleGeometryTransform 10 | { 11 | public var vertexTransform(get, set):Matrix3D; 12 | public var UVTransform(get, set):Matrix; 13 | public var invVertexTransform(get, never):Matrix3D; 14 | 15 | private var _defaultVertexTransform:Matrix3D; 16 | private var _defaultInvVertexTransform:Matrix3D; 17 | private var _defaultUVTransform:Matrix; 18 | 19 | public function new() 20 | { 21 | } 22 | 23 | private function set_vertexTransform(value:Matrix3D):Matrix3D 24 | { 25 | _defaultVertexTransform = value; 26 | _defaultInvVertexTransform = value.clone(); 27 | _defaultInvVertexTransform.invert(); 28 | _defaultInvVertexTransform.transpose(); 29 | return value; 30 | } 31 | 32 | private function set_UVTransform(value:Matrix):Matrix 33 | { 34 | _defaultUVTransform = value; 35 | return value; 36 | } 37 | 38 | private function get_UVTransform():Matrix 39 | { 40 | return _defaultUVTransform; 41 | } 42 | 43 | private function get_vertexTransform():Matrix3D 44 | { 45 | return _defaultVertexTransform; 46 | } 47 | 48 | private function get_invVertexTransform():Matrix3D 49 | { 50 | return _defaultInvVertexTransform; 51 | } 52 | } -------------------------------------------------------------------------------- /away3d/filters/HBlurFilter3D.hx: -------------------------------------------------------------------------------- 1 | package away3d.filters; 2 | 3 | import away3d.filters.tasks.Filter3DHBlurTask; 4 | 5 | class HBlurFilter3D extends Filter3DBase 6 | { 7 | public var amount(get, set):Int; 8 | public var stepSize(get, set):Int; 9 | 10 | private var _blurTask:Filter3DHBlurTask; 11 | 12 | /** 13 | * Creates a new HBlurFilter3D object 14 | * @param amount The amount of blur in pixels 15 | * @param stepSize The distance between two blur samples. Set to -1 to autodetect with acceptable quality (default value). 16 | */ 17 | public function new(amount:Int, stepSize:Int = -1) 18 | { 19 | super(); 20 | _blurTask = new Filter3DHBlurTask(amount, stepSize); 21 | addTask(_blurTask); 22 | } 23 | 24 | private function get_amount():Int 25 | { 26 | return _blurTask.amount; 27 | } 28 | 29 | private function set_amount(value:Int):Int 30 | { 31 | _blurTask.amount = value; 32 | return value; 33 | } 34 | 35 | /** 36 | * The distance between two blur samples. Set to -1 to autodetect with acceptable quality (default value). 37 | * Higher values provide better performance at the cost of reduces quality. 38 | */ 39 | private function get_stepSize():Int 40 | { 41 | return _blurTask.stepSize; 42 | } 43 | 44 | private function set_stepSize(value:Int):Int 45 | { 46 | _blurTask.stepSize = value; 47 | return value; 48 | } 49 | } -------------------------------------------------------------------------------- /away3d/filters/VBlurFilter3D.hx: -------------------------------------------------------------------------------- 1 | package away3d.filters; 2 | 3 | import away3d.filters.tasks.Filter3DVBlurTask; 4 | 5 | class VBlurFilter3D extends Filter3DBase 6 | { 7 | public var amount(get, set):Int; 8 | public var stepSize(get, set):Int; 9 | 10 | private var _blurTask:Filter3DVBlurTask; 11 | 12 | /** 13 | * Creates a new VBlurFilter3D object 14 | * @param amount The amount of blur in pixels 15 | * @param stepSize The distance between two blur samples. Set to -1 to autodetect with acceptable quality (default value). 16 | */ 17 | public function new(amount:Int, stepSize:Int = -1) 18 | { 19 | super(); 20 | _blurTask = new Filter3DVBlurTask(amount, stepSize); 21 | addTask(_blurTask); 22 | } 23 | 24 | private function get_amount():Int 25 | { 26 | return _blurTask.amount; 27 | } 28 | 29 | private function set_amount(value:Int):Int 30 | { 31 | _blurTask.amount = value; 32 | return value; 33 | } 34 | 35 | /** 36 | * The distance between two blur samples. Set to -1 to autodetect with acceptable quality (default value). 37 | * Higher values provide better performance at the cost of reduces quality. 38 | */ 39 | private function get_stepSize():Int 40 | { 41 | return _blurTask.stepSize; 42 | } 43 | 44 | private function set_stepSize(value:Int):Int 45 | { 46 | _blurTask.stepSize = value; 47 | return value; 48 | } 49 | } -------------------------------------------------------------------------------- /away3d/core/pick/IPickingCollider.hx: -------------------------------------------------------------------------------- 1 | package away3d.core.pick; 2 | 3 | import away3d.core.base.SubMesh; 4 | 5 | import openfl.geom.Vector3D; 6 | 7 | /** 8 | * Provides an interface for picking colliders that can be assigned to individual entities in a scene for specific picking behaviour. 9 | * Used with the RaycastPicker picking object. 10 | * 11 | * @see away3d.entities.Entity#pickingCollider 12 | * @see away3d.core.pick.RaycastPicker 13 | */ 14 | interface IPickingCollider 15 | { 16 | /** 17 | * Sets the position and direction of a picking ray in local coordinates to the entity. 18 | * 19 | * @param localDirection The position vector in local coordinates 20 | * @param localPosition The direction vector in local coordinates 21 | */ 22 | function setLocalRay(localPosition:Vector3D, localDirection:Vector3D):Void; 23 | 24 | /** 25 | * Tests a SubMesh object for a collision with the picking ray. 26 | * 27 | * @param subMesh The SubMesh instance to be tested. 28 | * @param pickingCollisionVO The collision object used to store the collision results 29 | * @param shortestCollisionDistance The current value of the shortest distance to a detected collision along the ray. 30 | */ 31 | function testSubMeshCollision(subMesh:SubMesh, pickingCollisionVO:PickingCollisionVO, shortestCollisionDistance:Float):Bool; 32 | } -------------------------------------------------------------------------------- /away3d/animators/data/ParticleProperties.hx: -------------------------------------------------------------------------------- 1 | package away3d.animators.data; 2 | 3 | /** 4 | * Dynamic class for holding the local properties of a particle, used for processing the static properties 5 | * of particles in the particle animation set before beginning upload to the GPU. 6 | */ 7 | class ParticleProperties 8 | { 9 | /** 10 | * The index of the current particle being set. 11 | */ 12 | public var index:Int; 13 | 14 | /** 15 | * The total number of particles being processed by the particle animation set. 16 | */ 17 | public var total:Int; 18 | 19 | /** 20 | * The start time of the particle. 21 | */ 22 | public var startTime:Float; 23 | 24 | /** 25 | * The duration of the particle, an optional value used when the particle aniamtion set settings for useDuration are enabled in the constructor. 26 | * 27 | * @see away3d.animators.ParticleAnimationSet 28 | */ 29 | public var duration:Float; 30 | 31 | /** 32 | * The delay between cycles of the particle, an optional value used when the particle aniamtion set settings for useLooping and useDelay are enabled in the constructor. 33 | * 34 | * @see away3d.animators.ParticleAnimationSet 35 | */ 36 | public var delay:Float; 37 | 38 | public var nodes:Map = new Map(); 39 | 40 | public function new() 41 | { 42 | 43 | } 44 | } -------------------------------------------------------------------------------- /away3d/library/assets/BitmapDataAsset.hx: -------------------------------------------------------------------------------- 1 | package away3d.library.assets; 2 | 3 | import openfl.display.BitmapData; 4 | 5 | /** 6 | * BitmapDataResource is a wrapper for loaded BitmapData, allowing it to be used uniformly as a resource when 7 | * loading, parsing, and listing/resolving dependencies. 8 | */ 9 | class BitmapDataAsset extends NamedAssetBase implements IAsset 10 | { 11 | public var bitmapData(get, set):BitmapData; 12 | public var assetType(get, never):String; 13 | 14 | private var _bitmapData:BitmapData; 15 | 16 | /** 17 | * Creates a new BitmapDataResource object. 18 | * @param bitmapData An optional BitmapData object to use as the resource data. 19 | */ 20 | public function new(bitmapData:BitmapData = null) 21 | { 22 | _bitmapData = bitmapData; 23 | super(); 24 | } 25 | 26 | /** 27 | * The bitmapData to be treated as a resource. 28 | */ 29 | private function get_bitmapData():BitmapData 30 | { 31 | return _bitmapData; 32 | } 33 | 34 | private function set_bitmapData(value:BitmapData):BitmapData 35 | { 36 | _bitmapData = value; 37 | return value; 38 | } 39 | 40 | private function get_assetType():String 41 | { 42 | return Asset3DType.TEXTURE; 43 | } 44 | 45 | /** 46 | * Cleans up any resources used by the current object. 47 | */ 48 | public function dispose():Void 49 | { 50 | _bitmapData.dispose(); 51 | } 52 | } -------------------------------------------------------------------------------- /away3d/textures/ATFCubeTexture.hx: -------------------------------------------------------------------------------- 1 | package away3d.textures; 2 | 3 | import openfl.errors.Error; 4 | import openfl.display3D.Context3D; 5 | import openfl.display3D.textures.CubeTexture; 6 | import openfl.display3D.textures.TextureBase; 7 | import openfl.utils.ByteArray; 8 | 9 | class ATFCubeTexture extends CubeTextureBase 10 | { 11 | public var atfData(get, set):ATFData; 12 | 13 | private var _atfData:ATFData; 14 | 15 | public function new(byteArray:ByteArray) 16 | { 17 | super(); 18 | atfData = new ATFData(byteArray); 19 | if (atfData.type != ATFData.TYPE_CUBE) 20 | throw new Error("ATF isn't cubetexture"); 21 | _format = atfData.format; 22 | _hasMipmaps = _atfData.numTextures > 1; 23 | } 24 | 25 | private function get_atfData():ATFData 26 | { 27 | return _atfData; 28 | } 29 | 30 | private function set_atfData(value:ATFData):ATFData 31 | { 32 | _atfData = value; 33 | 34 | invalidateContent(); 35 | 36 | setSize(value.width, value.height); 37 | return value; 38 | } 39 | 40 | override private function uploadContent(texture:TextureBase):Void 41 | { 42 | cast(texture, CubeTexture).uploadCompressedTextureFromByteArray(_atfData.data, 0, false); 43 | } 44 | 45 | override private function createTexture(context:Context3D):TextureBase 46 | { 47 | return context.createCubeTexture(_atfData.width, _atfData.format, false); 48 | } 49 | } -------------------------------------------------------------------------------- /away3d/library/assets/IAsset.hx: -------------------------------------------------------------------------------- 1 | package away3d.library.assets; 2 | 3 | import openfl.events.IEventDispatcher; 4 | import openfl.Vector; 5 | 6 | interface IAsset extends IEventDispatcher 7 | { 8 | var name(get, set):String; 9 | var id(get, set):String; 10 | var assetNamespace(get, never):String; 11 | var assetType(get, never):String; 12 | var assetFullPath(get, never):Array; 13 | 14 | /** 15 | * The name of the asset. 16 | */ 17 | private function get_name():String; 18 | 19 | private function set_name(val:String):String; 20 | 21 | /** 22 | * The id of the asset. 23 | */ 24 | private function get_id():String; 25 | 26 | private function set_id(val:String):String; 27 | 28 | /** 29 | * The namespace of the asset. This allows several assets with the same name to coexist in different contexts. 30 | */ 31 | private function get_assetNamespace():String; 32 | 33 | /** 34 | * The type of the asset. 35 | */ 36 | private function get_assetType():String; 37 | 38 | /** 39 | * The full path of the asset. 40 | */ 41 | private function get_assetFullPath():Array; 42 | 43 | function assetPathEquals(name:String, ns:String):Bool; 44 | 45 | function resetAssetPath(name:String, ns:String = null, ?overrideOriginal:Bool = true):Void; 46 | 47 | /** 48 | * Cleans up resources used by this asset. 49 | */ 50 | function dispose():Void; 51 | } -------------------------------------------------------------------------------- /away3d/animators/states/ParticleRotateToHeadingState.hx: -------------------------------------------------------------------------------- 1 | package away3d.animators.states; 2 | 3 | import away3d.animators.data.AnimationRegisterCache; 4 | import away3d.animators.data.AnimationSubGeometry; 5 | import away3d.animators.nodes.ParticleRotateToHeadingNode; 6 | import away3d.animators.nodes.ParticleNodeBase; 7 | import away3d.animators.ParticleAnimator; 8 | import away3d.cameras.Camera3D; 9 | import away3d.core.base.IRenderable; 10 | import away3d.core.managers.Stage3DProxy; 11 | 12 | import openfl.geom.Matrix3D; 13 | 14 | /** 15 | * ... 16 | */ 17 | class ParticleRotateToHeadingState extends ParticleStateBase 18 | { 19 | private var _matrix:Matrix3D = new Matrix3D(); 20 | 21 | public function new(animator:ParticleAnimator, particleNode:ParticleNodeBase) 22 | { 23 | super(animator, particleNode); 24 | } 25 | 26 | override public function setRenderState(stage3DProxy:Stage3DProxy, renderable:IRenderable, animationSubGeometry:AnimationSubGeometry, animationRegisterCache:AnimationRegisterCache, camera:Camera3D):Void 27 | { 28 | if (animationRegisterCache.hasBillboard) { 29 | _matrix.copyFrom(renderable.getRenderSceneTransform(camera)); 30 | _matrix.append(camera.inverseSceneTransform); 31 | animationRegisterCache.setVertexConstFromMatrix(animationRegisterCache.getRegisterIndex(_animationNode, ParticleRotateToHeadingNode.MATRIX_INDEX), _matrix); 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /away3d/materials/methods/EffectMethodBase.hx: -------------------------------------------------------------------------------- 1 | package away3d.materials.methods; 2 | 3 | import away3d.*; 4 | import away3d.errors.*; 5 | import away3d.library.assets.*; 6 | import away3d.materials.compilation.*; 7 | 8 | /** 9 | * EffectMethodBase forms an abstract base class for shader methods that are not dependent on light sources, 10 | * and are in essence post-process effects on the materials. 11 | */ 12 | class EffectMethodBase extends ShadingMethodBase implements IAsset 13 | { 14 | public var assetType(get, never):String; 15 | 16 | public function new() 17 | { 18 | super(); 19 | } 20 | 21 | /** 22 | * @inheritDoc 23 | */ 24 | private function get_assetType():String 25 | { 26 | return Asset3DType.EFFECTS_METHOD; 27 | } 28 | 29 | /** 30 | * Get the fragment shader code that should be added after all per-light code. Usually composits everything to the target register. 31 | * @param vo The MethodVO object containing the method data for the currently compiled material pass. 32 | * @param regCache The register cache used during the compilation. 33 | * @param targetReg The register that will be containing the method's output. 34 | * @private 35 | */ 36 | @:allow(away3d) private function getFragmentCode(vo:MethodVO, regCache:ShaderRegisterCache, targetReg:ShaderRegisterElement):String 37 | { 38 | throw new AbstractMethodError(); 39 | return ""; 40 | } 41 | } -------------------------------------------------------------------------------- /away3d/lights/shadowmaps/NearDirectionalShadowMapper.hx: -------------------------------------------------------------------------------- 1 | package away3d.lights.shadowmaps; 2 | 3 | import away3d.cameras.Camera3D; 4 | 5 | import openfl.Vector; 6 | 7 | class NearDirectionalShadowMapper extends DirectionalShadowMapper 8 | { 9 | public var coverageRatio(get, set):Float; 10 | 11 | private var _coverageRatio:Float; 12 | 13 | public function new(coverageRatio:Float = .5) 14 | { 15 | super(); 16 | this.coverageRatio = coverageRatio; 17 | } 18 | 19 | /** 20 | * A value between 0 and 1 to indicate the ratio of the view frustum that needs to be covered by the shadow map. 21 | */ 22 | private function get_coverageRatio():Float 23 | { 24 | return _coverageRatio; 25 | } 26 | 27 | private function set_coverageRatio(value:Float):Float 28 | { 29 | if (value > 1) 30 | value = 1; 31 | else if (value < 0) 32 | value = 0; 33 | 34 | _coverageRatio = value; 35 | return value; 36 | } 37 | 38 | override private function updateDepthProjection(viewCamera:Camera3D):Void 39 | { 40 | var corners:Vector = viewCamera.lens.frustumCorners; 41 | 42 | for (i in 0...12) { 43 | var v:Float = corners[i]; 44 | _localFrustum[i] = v; 45 | _localFrustum[i + 12] = v + (corners[i + 12] - v)*_coverageRatio; 46 | } 47 | 48 | updateProjectionFromFrustumCorners(viewCamera, _localFrustum, _matrix); 49 | _overallDepthLens.matrix = _matrix; 50 | } 51 | } -------------------------------------------------------------------------------- /away3d/library/assets/Asset3DType.hx: -------------------------------------------------------------------------------- 1 | package away3d.library.assets; 2 | 3 | class Asset3DType 4 | { 5 | public static inline var ENTITY:String = "entity"; 6 | public static inline var SKYBOX:String = "skybox"; 7 | public static inline var CAMERA:String = "camera"; 8 | public static inline var SEGMENT_SET:String = "segmentSet"; 9 | public static inline var MESH:String = "mesh"; 10 | public static inline var GEOMETRY:String = "geometry"; 11 | public static inline var SKELETON:String = "skeleton"; 12 | public static inline var SKELETON_POSE:String = "skeletonPose"; 13 | public static inline var CONTAINER:String = "container"; 14 | public static inline var TEXTURE:String = "texture"; 15 | public static inline var TEXTURE_PROJECTOR:String = "textureProjector"; 16 | public static inline var MATERIAL:String = "material"; 17 | public static inline var ANIMATION_SET:String = "animationSet"; 18 | public static inline var ANIMATION_STATE:String = "animationState"; 19 | public static inline var ANIMATION_NODE:String = "animationNode"; 20 | public static inline var ANIMATOR:String = "animator"; 21 | public static inline var STATE_TRANSITION:String = "stateTransition"; 22 | public static inline var LIGHT:String = "light"; 23 | public static inline var LIGHT_PICKER:String = "lightPicker"; 24 | public static inline var SHADOW_MAP_METHOD:String = "shadowMapMethod"; 25 | public static inline var EFFECTS_METHOD:String = "effectsMethod"; 26 | } -------------------------------------------------------------------------------- /away3d/core/pick/IPicker.hx: -------------------------------------------------------------------------------- 1 | package away3d.core.pick; 2 | 3 | import away3d.containers.Scene3D; 4 | import away3d.containers.View3D; 5 | 6 | import openfl.geom.Vector3D; 7 | 8 | /** 9 | * Provides an interface for picking objects that can pick 3d objects from a view or scene. 10 | */ 11 | interface IPicker 12 | { 13 | /** 14 | * Gets the collision object from the screen coordinates of the picking ray. 15 | * 16 | * @param x The x coordinate of the picking ray in screen-space. 17 | * @param y The y coordinate of the picking ray in screen-space. 18 | * @param view The view on which the picking object acts. 19 | */ 20 | function getViewCollision(x:Float, y:Float, view:View3D):PickingCollisionVO; 21 | 22 | /** 23 | * Gets the collision object from the scene position and direction of the picking ray. 24 | * 25 | * @param position The position of the picking ray in scene-space. 26 | * @param direction The direction of the picking ray in scene-space. 27 | * @param scene The scene on which the picking object acts. 28 | */ 29 | function getSceneCollision(position:Vector3D, direction:Vector3D, scene:Scene3D):PickingCollisionVO; 30 | 31 | /** 32 | * Determines whether the picker takes account of the mouseEnabled properties of entities. Defaults to true. 33 | */ 34 | var onlyMouseEnabled(get, set):Bool; 35 | 36 | /** 37 | * Disposes memory used by the IPicker object 38 | */ 39 | function dispose():Void; 40 | } -------------------------------------------------------------------------------- /away3d/textures/RenderCubeTexture.hx: -------------------------------------------------------------------------------- 1 | package away3d.textures; 2 | 3 | import away3d.materials.utils.MipmapGenerator; 4 | import away3d.tools.utils.TextureUtils; 5 | 6 | import openfl.display.BitmapData; 7 | import openfl.display3D.Context3D; 8 | import openfl.display3D.Context3DTextureFormat; 9 | import openfl.display3D.textures.TextureBase; 10 | import openfl.display3D.textures.CubeTexture; 11 | import openfl.errors.Error; 12 | 13 | class RenderCubeTexture extends CubeTextureBase 14 | { 15 | public function new(size:Int) 16 | { 17 | super(); 18 | setSize(size, size); 19 | } 20 | 21 | private function set_size(value:Int):Int 22 | { 23 | if (value == _width) 24 | return value; 25 | 26 | if (!TextureUtils.isDimensionValid(value)) 27 | throw new Error("Invalid size: Width and height must be power of 2 and cannot exceed 2048"); 28 | 29 | invalidateContent(); 30 | setSize(value, value); 31 | return value; 32 | } 33 | 34 | override private function uploadContent(texture:TextureBase):Void 35 | { 36 | // fake data, to complete texture for sampling 37 | var bmd:BitmapData = new BitmapData(_width, _height, false, 0); 38 | for (i in 0...6) 39 | MipmapGenerator.generateMipMaps(bmd, texture, null, false, i); 40 | bmd.dispose(); 41 | } 42 | 43 | override private function createTexture(context:Context3D):TextureBase 44 | { 45 | return context.createCubeTexture(_width, Context3DTextureFormat.BGRA, true); 46 | } 47 | } -------------------------------------------------------------------------------- /away3d/textures/BitmapTextureCache.hx: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package away3d.textures; 5 | 6 | import away3d.textures.BitmapTexture; 7 | 8 | import openfl.display.BitmapData; 9 | import openfl.errors.Error; 10 | 11 | /** 12 | * DEPRECRATED along with BitmapMaterial. Will be removed along with BitmapMaterial 13 | */ 14 | @:deprecated class BitmapTextureCache 15 | { 16 | private static var _instance:BitmapTextureCache; 17 | 18 | private var _textures:Map; 19 | private var _usages:Map; 20 | 21 | private function new() 22 | { 23 | _textures = new Map(); 24 | _usages = new Map(); 25 | } 26 | 27 | public static function getInstance():BitmapTextureCache 28 | { 29 | if (_instance == null) _instance = new BitmapTextureCache(); 30 | return _instance; 31 | } 32 | 33 | public function getTexture(bitmapData:BitmapData):BitmapTexture 34 | { 35 | var texture:BitmapTexture = null; 36 | if (!_textures.exists(bitmapData)) { 37 | texture = new BitmapTexture(bitmapData); 38 | _textures[bitmapData] = texture; 39 | _usages[texture] = 0; 40 | } 41 | _usages[texture] += 1; 42 | return _textures[bitmapData]; 43 | } 44 | 45 | public function freeTexture(texture:BitmapTexture):Void 46 | { 47 | _usages[texture] -= 1; 48 | if (_usages[texture] == 0) { 49 | _textures[cast(texture, BitmapTexture).bitmapData] = null; 50 | texture.dispose(); 51 | } 52 | } 53 | } -------------------------------------------------------------------------------- /away3d/loaders/parsers/utils/ParserUtil.hx: -------------------------------------------------------------------------------- 1 | package away3d.loaders.parsers.utils; 2 | 3 | import openfl.utils.ByteArray; 4 | 5 | class ParserUtil 6 | { 7 | 8 | /** 9 | * Returns a object as ByteArray, if possible. 10 | * 11 | * @param data The object to return as ByteArray 12 | * 13 | * @return The ByteArray or null 14 | * 15 | */ 16 | public static function toByteArray(data:Dynamic):ByteArray 17 | { 18 | if (#if (haxe_ver >= 4.2) Std.isOfType #else Std.is #end(data, Class)) 19 | data = Type.createInstance(data,[]); 20 | 21 | if (#if (haxe_ver >= 4.2) Std.isOfType #else Std.is #end(data, ByteArrayData)) 22 | return data; 23 | else 24 | return null; 25 | } 26 | 27 | /** 28 | * Returns a object as String, if possible. 29 | * 30 | * @param data The object to return as String 31 | * @param length The length of the returned String 32 | * 33 | * @return The String or null 34 | * 35 | */ 36 | public static function toString(data:Dynamic, length:UInt = 0):String 37 | { 38 | var ba:ByteArray; 39 | 40 | if (length==0) length = 0xffffffff; 41 | 42 | if (#if (haxe_ver >= 4.2) Std.isOfType #else Std.is #end(data, String)) { 43 | var dS:String = cast data; 44 | return dS.substr(0, Std.int(Math.min(length, dS.length))); 45 | } 46 | 47 | ba = toByteArray(data); 48 | if (ba != null) { 49 | ba.position = 0; 50 | return ba.readUTFBytes(Std.int(Math.min(ba.bytesAvailable, length))); 51 | } 52 | 53 | return null; 54 | } 55 | } -------------------------------------------------------------------------------- /away3d/events/AnimatorEvent.hx: -------------------------------------------------------------------------------- 1 | package away3d.events; 2 | 3 | import away3d.animators.*; 4 | 5 | import openfl.events.Event; 6 | 7 | /** 8 | * Dispatched to notify changes in an animator's state. 9 | */ 10 | class AnimatorEvent extends Event 11 | { 12 | public var animator(get, never):AnimatorBase; 13 | 14 | /** 15 | * Defines the value of the type property of a start event object. 16 | */ 17 | public static inline var START:String = "start"; 18 | 19 | /** 20 | * Defines the value of the type property of a stop event object. 21 | */ 22 | public static inline var STOP:String = "stop"; 23 | 24 | /** 25 | * Defines the value of the type property of a cycle complete event object. 26 | */ 27 | public static inline var CYCLE_COMPLETE:String = "cycle_complete"; 28 | 29 | private var _animator:AnimatorBase; 30 | 31 | /** 32 | * Create a new AnimatorEvent object. 33 | * 34 | * @param type The event type. 35 | * @param animator The animator object that is the subject of this event. 36 | */ 37 | public function new(type:String, animator:AnimatorBase) 38 | { 39 | super(type, false, false); 40 | _animator = animator; 41 | } 42 | 43 | private function get_animator():AnimatorBase 44 | { 45 | return _animator; 46 | } 47 | 48 | /** 49 | * Clones the event. 50 | * 51 | * @return An exact duplicate of the current event object. 52 | */ 53 | override public function clone():Event 54 | { 55 | return new AnimatorEvent(type, _animator); 56 | } 57 | } -------------------------------------------------------------------------------- /away3d/core/base/data/UV.hx: -------------------------------------------------------------------------------- 1 | package away3d.core.base.data; 2 | 3 | /** 4 | * Texture coordinates value object. 5 | */ 6 | class UV 7 | { 8 | public var v(get, set):Float; 9 | public var u(get, set):Float; 10 | 11 | private var _u:Float; 12 | private var _v:Float; 13 | 14 | /** 15 | * Creates a new UV object. 16 | * 17 | * @param u [optional] The horizontal coordinate of the texture value. Defaults to 0. 18 | * @param v [optional] The vertical coordinate of the texture value. Defaults to 0. 19 | */ 20 | public function new(u:Float = 0, v:Float = 0) 21 | { 22 | _u = u; 23 | _v = v; 24 | } 25 | 26 | /** 27 | * Defines the vertical coordinate of the texture value. 28 | */ 29 | private function get_v():Float 30 | { 31 | return _v; 32 | } 33 | 34 | private function set_v(value:Float):Float 35 | { 36 | _v = value; 37 | return value; 38 | } 39 | 40 | /** 41 | * Defines the horizontal coordinate of the texture value. 42 | */ 43 | private function get_u():Float 44 | { 45 | return _u; 46 | } 47 | 48 | private function set_u(value:Float):Float 49 | { 50 | _u = value; 51 | return value; 52 | } 53 | 54 | /** 55 | * returns a new UV value Object 56 | */ 57 | public function clone():UV 58 | { 59 | return new UV(_u, _v); 60 | } 61 | 62 | /** 63 | * returns the value object as a string for trace/debug purpose 64 | */ 65 | public function toString():String 66 | { 67 | return _u + "," + _v; 68 | } 69 | } -------------------------------------------------------------------------------- /away3d/animators/states/ParticleTimeState.hx: -------------------------------------------------------------------------------- 1 | package away3d.animators.states; 2 | 3 | import away3d.cameras.Camera3D; 4 | import away3d.animators.data.AnimationRegisterCache; 5 | import away3d.animators.data.AnimationSubGeometry; 6 | import away3d.core.base.IRenderable; 7 | import away3d.core.managers.Stage3DProxy; 8 | import away3d.animators.nodes.ParticleTimeNode; 9 | import away3d.animators.ParticleAnimator; 10 | 11 | import openfl.display3D.Context3DVertexBufferFormat; 12 | 13 | /** 14 | * ... 15 | */ 16 | class ParticleTimeState extends ParticleStateBase 17 | { 18 | private var _particleTimeNode:ParticleTimeNode; 19 | 20 | public function new(animator:ParticleAnimator, particleTimeNode:ParticleTimeNode) 21 | { 22 | super(animator, particleTimeNode, true); 23 | 24 | _particleTimeNode = particleTimeNode; 25 | } 26 | 27 | override public function setRenderState(stage3DProxy:Stage3DProxy, renderable:IRenderable, animationSubGeometry:AnimationSubGeometry, animationRegisterCache:AnimationRegisterCache, camera:Camera3D):Void 28 | { 29 | animationSubGeometry.activateVertexBuffer(animationRegisterCache.getRegisterIndex(_animationNode, ParticleTimeNode.TIME_STREAM_INDEX), _particleTimeNode.dataOffset, stage3DProxy, Context3DVertexBufferFormat.FLOAT_4); 30 | 31 | var particleTime:Float = _time/1000; 32 | animationRegisterCache.setVertexConst(animationRegisterCache.getRegisterIndex(_animationNode, ParticleTimeNode.TIME_CONSTANT_INDEX), particleTime, particleTime, particleTime, particleTime); 33 | } 34 | } -------------------------------------------------------------------------------- /away3d/core/partition/ViewVolumePartition.hx: -------------------------------------------------------------------------------- 1 | package away3d.core.partition; 2 | 3 | import away3d.entities.Entity; 4 | 5 | class ViewVolumePartition extends Partition3D 6 | { 7 | public var dynamicGrid(get, set):DynamicGrid; 8 | 9 | public function new() 10 | { 11 | super(new ViewVolumeRootNode()); 12 | } 13 | 14 | override private function markForUpdate(entity:Entity):Void 15 | { 16 | // ignore if static, will be handled separately by visibility list 17 | if (!entity.staticNode) 18 | super.markForUpdate(entity); 19 | } 20 | 21 | /** 22 | * Adds a view volume to provide visibility info for a given region. 23 | */ 24 | public function addViewVolume(viewVolume:ViewVolume):Void 25 | { 26 | cast(_rootNode, ViewVolumeRootNode).addViewVolume(viewVolume); 27 | } 28 | 29 | public function removeViewVolume(viewVolume:ViewVolume):Void 30 | { 31 | cast(_rootNode, ViewVolumeRootNode).removeViewVolume(viewVolume); 32 | } 33 | 34 | /** 35 | * A dynamic grid to be able to determine visibility of dynamic objects. If none is provided, dynamic objects are only frustum-culled. 36 | * If provided, ViewVolumes need to have visible grid cells assigned from the same DynamicGrid instance. 37 | */ 38 | private function get_dynamicGrid():DynamicGrid 39 | { 40 | return cast(_rootNode, ViewVolumeRootNode).dynamicGrid; 41 | } 42 | 43 | private function set_dynamicGrid(value:DynamicGrid):DynamicGrid 44 | { 45 | cast(_rootNode, ViewVolumeRootNode).dynamicGrid = value; 46 | return value; 47 | } 48 | } -------------------------------------------------------------------------------- /away3d/paths/QuadraticPathSegment.hx: -------------------------------------------------------------------------------- 1 | package away3d.paths; 2 | 3 | import openfl.geom.Vector3D; 4 | 5 | /** 6 | * Creates a curved line segment definition required for the Path class. 7 | */ 8 | class QuadraticPathSegment implements IPathSegment 9 | { 10 | /** 11 | * Defines the first vector of the PathSegment 12 | */ 13 | public var start:Vector3D; 14 | 15 | /** 16 | * Defines the control vector of the PathSegment 17 | */ 18 | public var control:Vector3D; 19 | 20 | /** 21 | * Defines the control vector of the PathSegment 22 | */ 23 | public var end:Vector3D; 24 | 25 | public function new(pStart:Vector3D, pControl:Vector3D, pEnd:Vector3D) 26 | { 27 | this.start = pStart; 28 | this.control = pControl; 29 | this.end = pEnd; 30 | } 31 | 32 | public function toString():String 33 | { 34 | return start + ", " + control + ", " + end; 35 | } 36 | 37 | /** 38 | * nulls the 3 vectors 39 | */ 40 | public function dispose():Void 41 | { 42 | start = control = end = null; 43 | } 44 | 45 | public function getPointOnSegment(t:Float, target:Vector3D = null):Vector3D 46 | { 47 | var sx:Float = start.x; 48 | var sy:Float = start.y; 49 | var sz:Float = start.z; 50 | var t2Inv:Float = 2*(1 - t); 51 | 52 | if (target == null) 53 | target = new Vector3D(); 54 | 55 | target.x = sx + t*(t2Inv*(control.x - sx) + t*(end.x - sx)); 56 | target.y = sy + t*(t2Inv*(control.y - sy) + t*(end.y - sy)); 57 | target.z = sz + t*(t2Inv*(control.z - sz) + t*(end.z - sz)); 58 | 59 | return target; 60 | } 61 | } -------------------------------------------------------------------------------- /away3d/animators/data/UVAnimationFrame.hx: -------------------------------------------------------------------------------- 1 | package away3d.animators.data; 2 | 3 | /** 4 | * A value object for a single frame of animation in a UVClipNode object. 5 | * 6 | * @see away3d.animators.nodes.UVClipNode 7 | */ 8 | class UVAnimationFrame 9 | { 10 | /** 11 | * The u-component offset of the UV animation frame. 12 | */ 13 | public var offsetU:Float; 14 | 15 | /** 16 | * The v-component offset of the UV animation frame. 17 | */ 18 | public var offsetV:Float; 19 | 20 | /** 21 | * The u-component scale of the UV animation frame. 22 | */ 23 | public var scaleU:Float; 24 | 25 | /** 26 | * The v-component scale of the UV animation frame. 27 | */ 28 | public var scaleV:Float; 29 | 30 | /** 31 | * The rotation value (in degrees) of the UV animation frame. 32 | */ 33 | public var rotation:Float; 34 | 35 | /** 36 | * Creates a new UVAnimationFrame object. 37 | * 38 | * @param offsetU The u-component offset of the UV animation frame. 39 | * @param offsetV The v-component offset of the UV animation frame. 40 | * @param scaleU The u-component scale of the UV animation frame. 41 | * @param scaleV The v-component scale of the UV animation frame. 42 | * @param rotation The rotation value (in degrees) of the UV animation frame. 43 | */ 44 | public function new(offsetU:Float = 0, offsetV:Float = 0, scaleU:Float = 1, scaleV:Float = 1, rotation:Float = 0) 45 | { 46 | this.offsetU = offsetU; 47 | this.offsetV = offsetV; 48 | this.scaleU = scaleU; 49 | this.scaleV = scaleV; 50 | this.rotation = rotation; 51 | } 52 | } -------------------------------------------------------------------------------- /away3d/animators/nodes/SpriteSheetClipNode.hx: -------------------------------------------------------------------------------- 1 | package away3d.animators.nodes; 2 | 3 | import away3d.animators.states.*; 4 | import away3d.animators.data.*; 5 | 6 | import openfl.Vector; 7 | 8 | /** 9 | * A SpriteSheetClipNode containing time-based animation data as individual sprite sheet animation frames. 10 | */ 11 | class SpriteSheetClipNode extends AnimationClipNodeBase 12 | { 13 | public var frames(get, never):Vector; 14 | 15 | private var _frames:Vector = new Vector(); 16 | 17 | /** 18 | * Creates a new SpriteSheetClipNode object. 19 | */ 20 | public function new() 21 | { 22 | _stateConstructor = cast SpriteSheetAnimationState.new; 23 | super(); 24 | } 25 | 26 | /** 27 | * Returns a vector of SpriteSheetAnimationFrame representing the uv values of each animation frame in the clip. 28 | */ 29 | private function get_frames():Vector 30 | { 31 | return _frames; 32 | } 33 | 34 | /** 35 | * Adds a SpriteSheetAnimationFrame object to the internal timeline of the animation node. 36 | * 37 | * @param spriteSheetAnimationFrame The frame object to add to the timeline of the node. 38 | * @param duration The specified duration of the frame in milliseconds. 39 | */ 40 | public function addFrame(spriteSheetAnimationFrame:SpriteSheetAnimationFrame, duration:Int):Void 41 | { 42 | _frames.push(spriteSheetAnimationFrame); 43 | _durations.push(duration); 44 | _numFrames = _durations.length; 45 | 46 | _stitchDirty = false; 47 | } 48 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Apache 2.0 License](https://img.shields.io/badge/license-Apache-blue.svg?style=flat)](LICENSE.md) [![Haxelib Version](https://img.shields.io/github/tag/openfl/away3d.svg?style=flat&label=haxelib)](http://lib.haxe.org/p/away3d) [![Build Status](https://img.shields.io/github/actions/workflow/status/openfl/away3d/main.yml?branch=master)](https://github.com/openfl/away3d/actions) 2 | 3 | Away3D 4 | ====== 5 | 6 | Away3D is an open source platform for developing interactive 3D graphics for video games and applications. 7 | 8 | 9 | Features 10 | -------- 11 | 12 | - Cross-platform target support (Flash, HTML5, iOS, Android, Windows, Mac, Linux) 13 | - Texture mapping with mipmapping 14 | - Lighting 15 | - Shadow mapping (in most cases) 16 | - Model loading: 3DS, AWD, MD5, MD2, DAE 17 | - Skeleton animation 18 | - Skinned animation 19 | - 3D particle system 20 | - Line drawing (Segments & SegmentSets) 21 | 22 | 23 | Installation 24 | ------------ 25 | 26 | You can easily install Away3D with OpenFL: 27 | 28 | openfl install away3d 29 | 30 | To add it to an OpenFL project, add this to your project file: 31 | 32 | ```xml 33 | 34 | ``` 35 | 36 | To list available samples, run: 37 | 38 | openfl create away3d 39 | 40 | 41 | Development Builds 42 | ------------------ 43 | 44 | Clone the Away3D repository: 45 | 46 | git clone https://github.com/openfl/away3d 47 | 48 | 49 | Tell haxelib where your development copy of Away3D is installed: 50 | 51 | haxelib dev away3d away3d 52 | 53 | 54 | To return to release builds: 55 | 56 | haxelib dev away3d 57 | 58 | -------------------------------------------------------------------------------- /away3d/filters/tasks/Filter3DBrightPassTask.hx: -------------------------------------------------------------------------------- 1 | package away3d.filters.tasks; 2 | 3 | import away3d.cameras.Camera3D; 4 | import away3d.core.managers.Stage3DProxy; 5 | 6 | import openfl.display3D.Context3DProgramType; 7 | import openfl.display3D.textures.Texture; 8 | import openfl.Vector; 9 | 10 | class Filter3DBrightPassTask extends Filter3DTaskBase 11 | { 12 | public var threshold(get, set):Float; 13 | 14 | private var _brightPassData:Vector; 15 | private var _threshold:Float; 16 | 17 | public function new(threshold:Float = .75) 18 | { 19 | super(); 20 | _threshold = threshold; 21 | _brightPassData = Vector.ofArray(cast [threshold, 1 / (1 - threshold), 0, 0]); 22 | } 23 | 24 | private function get_threshold():Float 25 | { 26 | return _threshold; 27 | } 28 | 29 | private function set_threshold(value:Float):Float 30 | { 31 | _threshold = value; 32 | _brightPassData[0] = value; 33 | _brightPassData[1] = 1 / (1 - value); 34 | return value; 35 | } 36 | 37 | override private function getFragmentCode():String 38 | { 39 | return "tex ft0, v0, fs0 <2d,linear,clamp> \n" + 40 | "dp3 ft1.x, ft0.xyz, ft0.xyz \n" + 41 | "sqt ft1.x, ft1.x \n" + 42 | "sub ft1.y, ft1.x, fc0.x \n" + 43 | "mul ft1.y, ft1.y, fc0.y \n" + 44 | "sat ft1.y, ft1.y \n" + 45 | "mul ft0.xyz, ft0.xyz, ft1.y \n" + 46 | "mov oc, ft0 \n"; 47 | } 48 | 49 | override public function activate(stage3DProxy:Stage3DProxy, camera3D:Camera3D, depthTexture:Texture):Void { 50 | stage3DProxy.context3D.setProgramConstantsFromVector(Context3DProgramType.FRAGMENT, 0, _brightPassData, 1); 51 | } 52 | } -------------------------------------------------------------------------------- /away3d/animators/data/SpriteSheetAnimationFrame.hx: -------------------------------------------------------------------------------- 1 | package away3d.animators.data; 2 | 3 | /** 4 | * A value object for a single frame of animation in a SpriteSheetClipNode object. 5 | * 6 | * @see away3d.animators.nodes.SpriteSheetClipNode 7 | */ 8 | class SpriteSheetAnimationFrame 9 | { 10 | /** 11 | * The u-component offset of the spritesheet frame. 12 | */ 13 | public var offsetU:Float; 14 | 15 | /** 16 | * The v-component offset of the spritesheet frame. 17 | */ 18 | public var offsetV:Float; 19 | 20 | /** 21 | * The u-component scale of the spritesheet frame. 22 | */ 23 | public var scaleU:Float; 24 | 25 | /** 26 | * The v-component scale of the spritesheet frame. 27 | */ 28 | public var scaleV:Float; 29 | 30 | /** 31 | * The mapID, zero based, if the animation is spreaded over more bitmapData's 32 | */ 33 | public var mapID:Int; 34 | 35 | /** 36 | * Creates a new SpriteSheetAnimationFrame object. 37 | * 38 | * @param offsetU The u-component offset of the spritesheet frame. 39 | * @param offsetV The v-component offset of the spritesheet frame. 40 | * @param scaleU The u-component scale of the spritesheet frame. 41 | * @param scaleV The v-component scale of the spritesheet frame. 42 | * @param mapID The v-component scale of the spritesheet frame. 43 | */ 44 | public function new(offsetU:Float = 0, offsetV:Float = 0, scaleU:Float = 1, scaleV:Float = 1, mapID:Int = 0) 45 | { 46 | this.offsetU = offsetU; 47 | this.offsetV = offsetV; 48 | this.scaleU = scaleU; 49 | this.scaleV = scaleV; 50 | this.mapID = mapID; 51 | } 52 | } -------------------------------------------------------------------------------- /away3d/events/GeometryEvent.hx: -------------------------------------------------------------------------------- 1 | package away3d.events; 2 | 3 | import away3d.core.base.ISubGeometry; 4 | 5 | import openfl.events.Event; 6 | 7 | /** 8 | * Dispatched to notify changes in a geometry object's state. 9 | * 10 | * @see away3d.core.base.Geometry 11 | */ 12 | class GeometryEvent extends Event 13 | { 14 | public var subGeometry(get, never):ISubGeometry; 15 | 16 | /** 17 | * Dispatched when a SubGeometry was added from the dispatching Geometry. 18 | */ 19 | public static inline var SUB_GEOMETRY_ADDED:String = "SubGeometryAdded"; 20 | 21 | /** 22 | * Dispatched when a SubGeometry was removed from the dispatching Geometry. 23 | */ 24 | public static inline var SUB_GEOMETRY_REMOVED:String = "SubGeometryRemoved"; 25 | 26 | public static inline var BOUNDS_INVALID:String = "BoundsInvalid"; 27 | 28 | private var _subGeometry:ISubGeometry; 29 | 30 | /** 31 | * Create a new GeometryEvent 32 | * @param type The event type. 33 | * @param subGeometry An optional SubGeometry object that is the subject of this event. 34 | */ 35 | public function new(type:String, subGeometry:ISubGeometry = null) 36 | { 37 | super(type, false, false); 38 | _subGeometry = subGeometry; 39 | } 40 | 41 | /** 42 | * The SubGeometry object that is the subject of this event, if appropriate. 43 | */ 44 | private function get_subGeometry():ISubGeometry 45 | { 46 | return _subGeometry; 47 | } 48 | 49 | /** 50 | * Clones the event. 51 | * @return An exact duplicate of the current object. 52 | */ 53 | override public function clone():Event 54 | { 55 | return new GeometryEvent(type, _subGeometry); 56 | } 57 | } -------------------------------------------------------------------------------- /away3d/materials/compilation/ShaderRegisterElement.hx: -------------------------------------------------------------------------------- 1 | package away3d.materials.compilation; 2 | 3 | import openfl.Vector; 4 | 5 | /** 6 | * A single register element (an entire register or a single register's component) used by the RegisterPool. 7 | */ 8 | class ShaderRegisterElement 9 | { 10 | public var regName(get, never):String; 11 | public var index(get, never):Int; 12 | 13 | private var _regName:String; 14 | private var _index:Int; 15 | private var _toStr:String; 16 | 17 | private static var COMPONENTS:Array = ["x", "y", "z", "w"]; 18 | 19 | @:allow(away3d) private var _component:Int; 20 | 21 | /** 22 | * Creates a new ShaderRegisterElement object. 23 | * @param regName The name of the register. 24 | * @param index The index of the register. 25 | * @param component The register's component, if not the entire register is represented. 26 | */ 27 | public function new(regName:String, index:Int, component:Int = -1) 28 | { 29 | _component = component; 30 | _regName = regName; 31 | _index = index; 32 | 33 | _toStr = _regName; 34 | 35 | if (_index >= 0) 36 | _toStr += _index; 37 | 38 | if (component > -1) 39 | _toStr += "." + COMPONENTS[component]; 40 | } 41 | 42 | /** 43 | * Converts the register or the components AGAL string representation. 44 | */ 45 | public function toString():String 46 | { 47 | return _toStr; 48 | } 49 | 50 | /** 51 | * The register's name. 52 | */ 53 | private function get_regName():String 54 | { 55 | return _regName; 56 | } 57 | 58 | /** 59 | * The register's index. 60 | */ 61 | private function get_index():Int 62 | { 63 | return _index; 64 | } 65 | } -------------------------------------------------------------------------------- /away3d/primitives/RegularPolygonGeometry.hx: -------------------------------------------------------------------------------- 1 | package away3d.primitives; 2 | 3 | /** 4 | * A UV RegularPolygon primitive mesh. 5 | */ 6 | class RegularPolygonGeometry extends CylinderGeometry 7 | { 8 | public var radius(get, set):Float; 9 | public var sides(get, set):Int; 10 | public var subdivisions(get, set):Int; 11 | 12 | /** 13 | * The radius of the regular polygon. 14 | */ 15 | private function get_radius():Float 16 | { 17 | return _bottomRadius; 18 | } 19 | 20 | private function set_radius(value:Float):Float 21 | { 22 | _bottomRadius = value; 23 | invalidateGeometry(); 24 | return value; 25 | } 26 | 27 | /** 28 | * The number of sides of the regular polygon. 29 | */ 30 | private function get_sides():Int 31 | { 32 | return _segmentsW; 33 | } 34 | 35 | private function set_sides(value:Int):Int 36 | { 37 | segmentsW = value; 38 | return value; 39 | } 40 | 41 | /** 42 | * The number of subdivisions from the edge to the center of the regular polygon. 43 | */ 44 | private function get_subdivisions():Int 45 | { 46 | return _segmentsH; 47 | } 48 | 49 | private function set_subdivisions(value:Int):Int 50 | { 51 | segmentsH = value; 52 | return value; 53 | } 54 | 55 | /** 56 | * Creates a new RegularPolygon disc object. 57 | * @param radius The radius of the regular polygon 58 | * @param sides Defines the number of sides of the regular polygon. 59 | * @param yUp Defines whether the regular polygon should lay on the Y-axis (true) or on the Z-axis (false). 60 | */ 61 | public function new(radius:Float = 100, sides:Int = 16, yUp:Bool = true) 62 | { 63 | super(radius, 0, 0, sides, 1, true, false, false, yUp); 64 | } 65 | } -------------------------------------------------------------------------------- /away3d/materials/OcclusionMaterial.hx: -------------------------------------------------------------------------------- 1 | package away3d.materials; 2 | 3 | import away3d.cameras.Camera3D; 4 | import away3d.core.managers.Stage3DProxy; 5 | 6 | /** 7 | * OcclusionMaterial is a ColorMaterial for an object to prevents drawing anything that is placed behind it. 8 | */ 9 | class OcclusionMaterial extends ColorMaterial 10 | { 11 | public var occlude(get, set):Bool; 12 | 13 | private var _occlude:Bool = true; 14 | 15 | /** 16 | * Creates a new OcclusionMaterial object. 17 | * @param occlude Whether or not to occlude other objects. 18 | * @param color The material's diffuse surface color. 19 | * @param alpha The material's surface alpha. 20 | */ 21 | public function new(occlude:Bool = true, color:Int = 0xcccccc, alpha:Float = 1) 22 | { 23 | super(color, alpha); 24 | this.occlude = occlude; 25 | } 26 | 27 | /** 28 | * Whether or not an object with this material applied hides other objects. 29 | */ 30 | private function get_occlude():Bool 31 | { 32 | return _occlude; 33 | } 34 | 35 | private function set_occlude(value:Bool):Bool 36 | { 37 | _occlude = value; 38 | return value; 39 | } 40 | 41 | /** 42 | * @inheritDoc 43 | */ 44 | override private function activatePass(index:Int, stage3DProxy:Stage3DProxy, camera:Camera3D):Void 45 | { 46 | if (occlude) 47 | stage3DProxy._context3D.setColorMask(false, false, false, false); 48 | super.activatePass(index, stage3DProxy, camera); 49 | } 50 | 51 | /** 52 | * @inheritDoc 53 | */ 54 | override private function deactivatePass(index:Int, stage3DProxy:Stage3DProxy):Void 55 | { 56 | super.deactivatePass(index, stage3DProxy); 57 | stage3DProxy._context3D.setColorMask(true, true, true, true); 58 | } 59 | } -------------------------------------------------------------------------------- /away3d/library/naming/ConflictStrategy.hx: -------------------------------------------------------------------------------- 1 | package away3d.library.naming; 2 | 3 | /** 4 | * Enumeration class for bundled conflict strategies. Set one of these values (or an 5 | * instance of a self-defined sub-class of ConflictStrategyBase) to the conflictStrategy 6 | * property on an Asset3DLibrary to define how that library resolves naming conflicts. 7 | * 8 | * The value of the Asset3DLibrary.conflictPrecedence property defines which 9 | * of the conflicting assets will get to keep it's name, and which is renamed (if any.) 10 | * 11 | * @see away3d.library.Asset3DLibrary.conflictStrategy 12 | * @see away3d.library.naming.ConflictStrategyBase 13 | */ 14 | class ConflictStrategy 15 | { 16 | /** 17 | * Specifies that in case of a naming conflict, one of the assets will be renamed and 18 | * a numeric suffix appended to the base name. 19 | */ 20 | public static var APPEND_NUM_SUFFIX:ConflictStrategyBase = new NumSuffixConflictStrategy(); 21 | 22 | /** 23 | * Specifies that naming conflicts should be ignored. This is not recommended in most 24 | * cases, unless it can be 100% guaranteed that the application does not cause naming 25 | * conflicts in the library (i.e. when an app-level system is in place to prevent this.) 26 | */ 27 | public static var IGNORE:ConflictStrategyBase = new IgnoreConflictStrategy(); 28 | 29 | /** 30 | * Specifies that an error should be thrown if a naming conflict is discovered. Use this 31 | * to be 100% sure that naming conflicts never occur unnoticed, and when it's undesirable 32 | * to have the library automatically rename assets to avoid such conflicts. 33 | */ 34 | public static var THROW_ERROR:ConflictStrategyBase = new ErrorConflictStrategy(); 35 | } -------------------------------------------------------------------------------- /away3d/core/traverse/SceneIterator.hx: -------------------------------------------------------------------------------- 1 | package away3d.core.traverse; 2 | 3 | import away3d.containers.ObjectContainer3D; 4 | import away3d.containers.Scene3D; 5 | 6 | import openfl.Vector; 7 | 8 | class SceneIterator 9 | { 10 | private static inline var PRE:Int = 0; 11 | private static inline var IN:Int = 1; 12 | private static inline var POST:Int = 2; 13 | 14 | private var _childIndex:Int; 15 | private var _scene:Scene3D; 16 | private var _node:ObjectContainer3D; 17 | private var _traverseState:Int; 18 | private var _childIndexStack:Vector; 19 | private var _stackPos:Int; 20 | 21 | public function new(scene:Scene3D) 22 | { 23 | _scene = scene; 24 | reset(); 25 | } 26 | 27 | public function reset():Void 28 | { 29 | _childIndexStack = new Vector(); 30 | _node = _scene._sceneGraphRoot; 31 | _childIndex = 0; 32 | _stackPos = 0; 33 | _traverseState = PRE; 34 | } 35 | 36 | public function next():ObjectContainer3D 37 | { 38 | do { 39 | switch (_traverseState) { 40 | case SceneIterator.PRE: // just entered a node 41 | _childIndexStack[_stackPos++] = _childIndex; 42 | _childIndex = 0; 43 | _traverseState = SceneIterator.IN; 44 | return _node; 45 | case SceneIterator.IN: 46 | if (_childIndex == _node.numChildren) 47 | _traverseState = SceneIterator.POST; 48 | else { 49 | _node = _node.getChildAt(_childIndex); 50 | _traverseState = SceneIterator.PRE; 51 | } 52 | case SceneIterator.POST: 53 | _node = _node.parent; 54 | _childIndex = _childIndexStack[--_stackPos] + 1; 55 | _traverseState = SceneIterator.IN; 56 | } 57 | } while (!(_node == _scene._sceneGraphRoot && _traverseState == POST)); 58 | 59 | return null; 60 | } 61 | } -------------------------------------------------------------------------------- /away3d/filters/HueSaturationFilter3D.hx: -------------------------------------------------------------------------------- 1 | package away3d.filters; 2 | 3 | import away3d.filters.tasks.Filter3DHueSaturationTask; 4 | 5 | class HueSaturationFilter3D extends Filter3DBase 6 | { 7 | public var saturation(get, set):Float; 8 | public var r(get, set):Float; 9 | public var b(get, set):Float; 10 | public var g(get, set):Float; 11 | 12 | private var _hslTask:Filter3DHueSaturationTask; 13 | 14 | public function new(saturation:Float = 1, r:Float = 1, g:Float = 1, b:Float = 1) 15 | { 16 | super(); 17 | 18 | _hslTask = new Filter3DHueSaturationTask(); 19 | this.saturation = saturation; 20 | this.r = r; 21 | this.g = g; 22 | this.b = b; 23 | addTask(_hslTask); 24 | } 25 | 26 | private function get_saturation():Float 27 | { 28 | return _hslTask.saturation; 29 | } 30 | 31 | private function set_saturation(value:Float):Float 32 | { 33 | if (_hslTask.saturation == value) 34 | return value; 35 | _hslTask.saturation = value; 36 | return value; 37 | } 38 | 39 | private function get_r():Float 40 | { 41 | return _hslTask.r; 42 | } 43 | 44 | private function set_r(value:Float):Float 45 | { 46 | if (_hslTask.r == value) 47 | return value; 48 | _hslTask.r = value; 49 | return value; 50 | } 51 | 52 | private function get_b():Float 53 | { 54 | return _hslTask.b; 55 | } 56 | 57 | private function set_b(value:Float):Float 58 | { 59 | if (_hslTask.b == value) 60 | return value; 61 | _hslTask.b = value; 62 | return value; 63 | } 64 | 65 | private function get_g():Float 66 | { 67 | return _hslTask.g; 68 | } 69 | 70 | private function set_g(value:Float):Float 71 | { 72 | if (_hslTask.g == value) 73 | return value; 74 | _hslTask.g = value; 75 | return value; 76 | } 77 | } -------------------------------------------------------------------------------- /away3d/audio/drivers/AbstractSound3DDriver.hx: -------------------------------------------------------------------------------- 1 | package away3d.audio.drivers; 2 | 3 | import openfl.geom.Vector3D; 4 | import openfl.media.Sound; 5 | import openfl.events.EventDispatcher; 6 | 7 | class AbstractSound3DDriver extends EventDispatcher 8 | { 9 | public var sourceSound(get, set):Sound; 10 | public var volume(get, set):Float; 11 | public var scale(get, set):Float; 12 | public var mute(get, set):Bool; 13 | 14 | private var _ref_v:Vector3D; 15 | private var _src:Sound; 16 | private var _volume:Float; 17 | private var _scale:Float; 18 | 19 | private var _mute:Bool; 20 | private var _paused:Bool; 21 | private var _playing:Bool; 22 | 23 | public function new() 24 | { 25 | _volume = 1; 26 | _scale = 1000; 27 | _playing = false; 28 | super(); 29 | } 30 | 31 | private function get_sourceSound():Sound 32 | { 33 | return _src; 34 | } 35 | 36 | private function set_sourceSound(val:Sound):Sound 37 | { 38 | if (_src == val) 39 | return val; 40 | 41 | _src = val; 42 | return val; 43 | } 44 | 45 | private function get_volume():Float 46 | { 47 | return _volume; 48 | } 49 | 50 | private function set_volume(val:Float):Float 51 | { 52 | _volume = val; 53 | return val; 54 | } 55 | 56 | private function get_scale():Float 57 | { 58 | return _scale; 59 | } 60 | 61 | private function set_scale(val:Float):Float 62 | { 63 | _scale = val; 64 | return val; 65 | } 66 | 67 | private function get_mute():Bool 68 | { 69 | return _mute; 70 | } 71 | 72 | private function set_mute(val:Bool):Bool 73 | { 74 | if (_mute == val) 75 | return val; 76 | 77 | _mute = val; 78 | return val; 79 | } 80 | 81 | public function updateReferenceVector(v:Vector3D):Void 82 | { 83 | this._ref_v = v; 84 | } 85 | } -------------------------------------------------------------------------------- /away3d/stereo/methods/InterleavedStereoRenderMethod.hx: -------------------------------------------------------------------------------- 1 | package away3d.stereo.methods; 2 | 3 | import away3d.core.managers.RTTBufferManager; 4 | import away3d.core.managers.Stage3DProxy; 5 | 6 | import openfl.display3D.Context3DProgramType; 7 | import openfl.Vector; 8 | 9 | class InterleavedStereoRenderMethod extends StereoRenderMethodBase 10 | { 11 | private var _shaderData:Vector; 12 | 13 | public function new() 14 | { 15 | super(); 16 | 17 | _shaderData = Vector.ofArray([ 1., 1, 1, 1 ]); 18 | } 19 | 20 | override public function activate(stage3DProxy:Stage3DProxy):Void 21 | { 22 | if (_textureSizeInvalid) { 23 | var minV:Float; 24 | var rttManager:RTTBufferManager; 25 | 26 | rttManager = RTTBufferManager.getInstance(stage3DProxy); 27 | _textureSizeInvalid = false; 28 | 29 | minV = rttManager.renderToTextureRect.bottom/rttManager.textureHeight; 30 | 31 | _shaderData[0] = 2; 32 | _shaderData[1] = rttManager.renderToTextureRect.height; 33 | _shaderData[2] = 1; 34 | _shaderData[3] = .5; 35 | } 36 | 37 | stage3DProxy.context3D.setProgramConstantsFromVector(Context3DProgramType.FRAGMENT, 0, _shaderData); 38 | } 39 | 40 | override public function deactivate(stage3DProxy:Stage3DProxy):Void 41 | { 42 | stage3DProxy._context3D.setTextureAt(2, null); 43 | } 44 | 45 | override public function getFragmentCode():String 46 | { 47 | return "tex ft0, v1, fs0 <2d,linear,nomip>\n" + 48 | "tex ft1, v1, fs1 <2d,linear,nomip>\n" + 49 | "add ft2, v0.y, fc0.z\n" + 50 | "div ft2, ft2, fc0.x\n" + 51 | "mul ft2, ft2, fc0.y\n" + 52 | "div ft3, ft2, fc0.x\n" + 53 | "frc ft3, ft3\n" + 54 | "slt ft4, ft3, fc0.w\n" + 55 | "sge ft5, ft3, fc0.w\n" + 56 | "mul ft6, ft0, ft4\n" + 57 | "mul ft7, ft1, ft5\n" + 58 | "add oc, ft7, ft6\n"; 59 | } 60 | } -------------------------------------------------------------------------------- /away3d/textures/RenderTexture.hx: -------------------------------------------------------------------------------- 1 | package away3d.textures; 2 | 3 | import away3d.materials.utils.MipmapGenerator; 4 | import away3d.tools.utils.TextureUtils; 5 | 6 | import openfl.display.BitmapData; 7 | import openfl.display3D.Context3D; 8 | import openfl.display3D.Context3DTextureFormat; 9 | import openfl.display3D.textures.TextureBase; 10 | import openfl.display3D.textures.Texture; 11 | import openfl.errors.Error; 12 | 13 | class RenderTexture extends Texture2DBase 14 | { 15 | public function new(width:Int, height:Int) 16 | { 17 | super(); 18 | setSize(width, height); 19 | } 20 | 21 | override private function set_width(value:Int):Int 22 | { 23 | if (value == _width) 24 | return value; 25 | 26 | if (!TextureUtils.isDimensionValid(value)) 27 | throw new Error("Invalid size: Width and height must be power of 2 and cannot exceed 2048"); 28 | 29 | invalidateContent(); 30 | setSize(value, _height); 31 | return value; 32 | } 33 | 34 | override private function set_height(value:Int):Int 35 | { 36 | if (value == _height) 37 | return value; 38 | 39 | if (!TextureUtils.isDimensionValid(value)) 40 | throw new Error("Invalid size: Width and height must be power of 2 and cannot exceed 2048"); 41 | 42 | invalidateContent(); 43 | setSize(_width, value); 44 | return value; 45 | } 46 | 47 | override private function uploadContent(texture:TextureBase):Void 48 | { 49 | // fake data, to complete texture for sampling 50 | #if flash 51 | var bmp:BitmapData = new BitmapData(width, height, false, 0xff0000); 52 | MipmapGenerator.generateMipMaps(bmp, texture); 53 | bmp.dispose(); 54 | #end 55 | } 56 | 57 | override private function createTexture(context:Context3D):TextureBase 58 | { 59 | return context.createTexture(width, height, Context3DTextureFormat.BGRA, true); 60 | } 61 | } -------------------------------------------------------------------------------- /away3d/animators/nodes/UVClipNode.hx: -------------------------------------------------------------------------------- 1 | package away3d.animators.nodes; 2 | 3 | import away3d.animators.states.*; 4 | import away3d.animators.data.*; 5 | 6 | import openfl.Vector; 7 | 8 | /** 9 | * A uv animation node containing time-based animation data as individual uv animation frames. 10 | */ 11 | class UVClipNode extends AnimationClipNodeBase 12 | { 13 | public var frames(get, never):Vector; 14 | 15 | private var _frames:Vector = new Vector(); 16 | 17 | /** 18 | * Returns a vector of UV frames representing the uv values of each animation frame in the clip. 19 | */ 20 | private function get_frames():Vector 21 | { 22 | return _frames; 23 | } 24 | 25 | /** 26 | * Creates a new UVClipNode object. 27 | */ 28 | public function new() 29 | { 30 | _stateConstructor = cast UVClipState.new; 31 | super(); 32 | } 33 | 34 | /** 35 | * Adds a UV frame object to the internal timeline of the animation node. 36 | * 37 | * @param uvFrame The uv frame object to add to the timeline of the node. 38 | * @param duration The specified duration of the frame in milliseconds. 39 | */ 40 | public function addFrame(uvFrame:UVAnimationFrame, duration:Int):Void 41 | { 42 | _frames.push(uvFrame); 43 | _durations.push(duration); 44 | _numFrames = _durations.length; 45 | 46 | _stitchDirty = true; 47 | } 48 | 49 | /** 50 | * @inheritDoc 51 | */ 52 | override private function updateStitch():Void 53 | { 54 | super.updateStitch(); 55 | var i:Int; 56 | 57 | if (_durations.length > 0) { 58 | 59 | i = _numFrames - 1; 60 | while (i-- > 0) 61 | _totalDuration += _durations[i]; 62 | 63 | if (_stitchFinalFrame || !_looping) 64 | _totalDuration += _durations[_numFrames - 1]; 65 | } 66 | 67 | } 68 | } -------------------------------------------------------------------------------- /away3d/filters/tasks/Filter3DDoubleBufferCopyTask.hx: -------------------------------------------------------------------------------- 1 | package away3d.filters.tasks; 2 | 3 | import away3d.cameras.Camera3D; 4 | import away3d.core.managers.Stage3DProxy; 5 | 6 | import openfl.display.BitmapData; 7 | import openfl.display3D.Context3DTextureFormat; 8 | import openfl.display3D.textures.Texture; 9 | 10 | class Filter3DDoubleBufferCopyTask extends Filter3DTaskBase 11 | { 12 | public var secondaryInputTexture(get, never):Texture; 13 | 14 | private var _secondaryInputTexture:Texture; 15 | 16 | public function new() 17 | { 18 | super(); 19 | } 20 | 21 | private function get_secondaryInputTexture():Texture { 22 | return _secondaryInputTexture; 23 | } 24 | 25 | override private function getFragmentCode():String 26 | { 27 | return "tex oc, v0, fs0 <2d,nearest,clamp>\n"; 28 | } 29 | 30 | override private function updateTextures(stage:Stage3DProxy):Void 31 | { 32 | super.updateTextures(stage); 33 | 34 | if (_secondaryInputTexture != null) 35 | _secondaryInputTexture.dispose(); 36 | 37 | _secondaryInputTexture = stage.context3D.createTexture(_textureWidth >> _textureScale, _textureHeight >> _textureScale, Context3DTextureFormat.BGRA, true); 38 | 39 | var dummy:BitmapData = new BitmapData(_textureWidth >> _textureScale, _textureHeight >> _textureScale, false, 0); 40 | _mainInputTexture.uploadFromBitmapData(dummy); 41 | _secondaryInputTexture.uploadFromBitmapData(dummy); 42 | dummy.dispose(); 43 | } 44 | 45 | override public function activate(stage3DProxy:Stage3DProxy, camera:Camera3D, depthTexture:Texture):Void 46 | { 47 | swap(); 48 | super.activate(stage3DProxy, camera, depthTexture); 49 | } 50 | 51 | private function swap():Void 52 | { 53 | var tmp:Texture = _secondaryInputTexture; 54 | _secondaryInputTexture = _mainInputTexture; 55 | _mainInputTexture = tmp; 56 | } 57 | } -------------------------------------------------------------------------------- /away3d/materials/ColorMaterial.hx: -------------------------------------------------------------------------------- 1 | package away3d.materials; 2 | 3 | import openfl.display.BlendMode; 4 | 5 | /** 6 | * ColorMaterial is a single-pass material that uses a flat color as the surface's diffuse reflection value. 7 | */ 8 | class ColorMaterial extends SinglePassMaterialBase 9 | { 10 | public var alpha(get, set):Float; 11 | public var color(get, set):Int; 12 | 13 | private var _diffuseAlpha:Float = 1; 14 | 15 | /** 16 | * Creates a new ColorMaterial object. 17 | * @param color The material's diffuse surface color. 18 | * @param alpha The material's surface alpha. 19 | */ 20 | public function new(color:Int = 0xcccccc, alpha:Float = 1) 21 | { 22 | super(); 23 | this.color = color; 24 | this.alpha = alpha; 25 | } 26 | 27 | /** 28 | * The alpha of the surface. 29 | */ 30 | private function get_alpha():Float 31 | { 32 | return _screenPass.diffuseMethod.diffuseAlpha; 33 | } 34 | 35 | private function set_alpha(value:Float):Float 36 | { 37 | if (value > 1) 38 | value = 1; 39 | else if (value < 0) 40 | value = 0; 41 | _screenPass.diffuseMethod.diffuseAlpha = _diffuseAlpha = value; 42 | _screenPass.preserveAlpha = requiresBlending; 43 | _screenPass.setBlendMode(blendMode == BlendMode.NORMAL && requiresBlending? BlendMode.LAYER : blendMode); 44 | return value; 45 | } 46 | 47 | /** 48 | * The diffuse reflectivity color of the surface. 49 | */ 50 | private function get_color():Int 51 | { 52 | return _screenPass.diffuseMethod.diffuseColor; 53 | } 54 | 55 | private function set_color(value:Int):Int 56 | { 57 | _screenPass.diffuseMethod.diffuseColor = value; 58 | return value; 59 | } 60 | 61 | /** 62 | * @inheritDoc 63 | */ 64 | override private function get_requiresBlending():Bool 65 | { 66 | return super.requiresBlending || _diffuseAlpha < 1; 67 | } 68 | } -------------------------------------------------------------------------------- /away3d/animators/states/UVClipState.hx: -------------------------------------------------------------------------------- 1 | package away3d.animators.states; 2 | 3 | import away3d.animators.*; 4 | import away3d.animators.data.*; 5 | import away3d.animators.nodes.*; 6 | 7 | import openfl.Vector; 8 | 9 | class UVClipState extends AnimationClipState implements IUVAnimationState 10 | { 11 | public var currentUVFrame(get, never):UVAnimationFrame; 12 | public var nextUVFrame(get, never):UVAnimationFrame; 13 | 14 | private var _frames:Vector; 15 | private var _uvClipNode:UVClipNode; 16 | private var _currentUVFrame:UVAnimationFrame; 17 | private var _nextUVFrame:UVAnimationFrame; 18 | 19 | /** 20 | * @inheritDoc 21 | */ 22 | private function get_currentUVFrame():UVAnimationFrame 23 | { 24 | if (_framesDirty) 25 | updateFrames(); 26 | 27 | return _currentUVFrame; 28 | } 29 | 30 | /** 31 | * @inheritDoc 32 | */ 33 | private function get_nextUVFrame():UVAnimationFrame 34 | { 35 | if (_framesDirty) 36 | updateFrames(); 37 | 38 | return _nextUVFrame; 39 | } 40 | 41 | public function new(animator:IAnimator, uvClipNode:UVClipNode) 42 | { 43 | super(animator, uvClipNode); 44 | 45 | _uvClipNode = uvClipNode; 46 | _frames = _uvClipNode.frames; 47 | } 48 | 49 | /** 50 | * @inheritDoc 51 | */ 52 | override private function updateFrames():Void 53 | { 54 | super.updateFrames(); 55 | 56 | if (_frames.length > 0) { 57 | 58 | if (_frames.length == 2 && _currentFrame == 0) { 59 | 60 | _currentUVFrame = _frames[1]; 61 | _nextUVFrame = _frames[0]; 62 | 63 | } else { 64 | 65 | _currentUVFrame = _frames[_currentFrame]; 66 | 67 | if (_uvClipNode.looping && _nextFrame >= _uvClipNode.lastFrame) 68 | _nextUVFrame = _frames[0]; 69 | else 70 | _nextUVFrame = _frames[_nextFrame]; 71 | 72 | } 73 | 74 | } 75 | } 76 | } -------------------------------------------------------------------------------- /away3d/animators/states/VertexClipState.hx: -------------------------------------------------------------------------------- 1 | package away3d.animators.states; 2 | 3 | import away3d.core.base.Geometry; 4 | import away3d.animators.*; 5 | import away3d.animators.nodes.*; 6 | 7 | import openfl.Vector; 8 | 9 | /** 10 | * 11 | */ 12 | class VertexClipState extends AnimationClipState implements IVertexAnimationState 13 | { 14 | public var currentGeometry(get, never):Geometry; 15 | public var nextGeometry(get, never):Geometry; 16 | 17 | private var _frames:Vector; 18 | private var _vertexClipNode:VertexClipNode; 19 | private var _currentGeometry:Geometry; 20 | private var _nextGeometry:Geometry; 21 | 22 | /** 23 | * @inheritDoc 24 | */ 25 | private function get_currentGeometry():Geometry 26 | { 27 | if (_framesDirty) 28 | updateFrames(); 29 | 30 | return _currentGeometry; 31 | } 32 | 33 | /** 34 | * @inheritDoc 35 | */ 36 | private function get_nextGeometry():Geometry 37 | { 38 | if (_framesDirty) 39 | updateFrames(); 40 | 41 | return _nextGeometry; 42 | } 43 | 44 | public function new(animator:IAnimator, vertexClipNode:VertexClipNode) 45 | { 46 | super(animator, vertexClipNode); 47 | 48 | _vertexClipNode = vertexClipNode; 49 | _frames = _vertexClipNode.frames; 50 | } 51 | 52 | /** 53 | * @inheritDoc 54 | */ 55 | override private function updateFrames():Void 56 | { 57 | super.updateFrames(); 58 | 59 | _currentGeometry = _frames[_currentFrame]; 60 | 61 | if (_vertexClipNode.looping && _nextFrame >= _vertexClipNode.lastFrame) { 62 | _nextGeometry = _frames[0]; 63 | cast(_animator, VertexAnimator).dispatchCycleEvent(); 64 | } else 65 | _nextGeometry = _frames[_nextFrame]; 66 | } 67 | 68 | /** 69 | * @inheritDoc 70 | */ 71 | override private function updatePositionDelta():Void 72 | { 73 | //TODO:implement positiondelta functionality for vertex animations 74 | } 75 | } -------------------------------------------------------------------------------- /away3d/animators/utils/SkeletonUtils.hx: -------------------------------------------------------------------------------- 1 | package away3d.animators.utils; 2 | 3 | import away3d.animators.data.*; 4 | import away3d.animators.nodes.*; 5 | 6 | import openfl.errors.Error; 7 | import openfl.geom.*; 8 | import openfl.Vector; 9 | 10 | class SkeletonUtils 11 | { 12 | public static function generateDifferenceClip(source:SkeletonClipNode, referencePose:SkeletonPose):SkeletonClipNode 13 | { 14 | var diff:SkeletonClipNode = new SkeletonClipNode(); 15 | var numFrames:Int = source.frames.length; 16 | 17 | for (i in 0...numFrames) 18 | diff.addFrame(generateDifferencePose(source.frames[i], referencePose), source.durations[i]); 19 | 20 | return diff; 21 | } 22 | 23 | public static function generateDifferencePose(source:SkeletonPose, reference:SkeletonPose):SkeletonPose 24 | { 25 | if (source.numJointPoses != reference.numJointPoses) 26 | throw new Error("joint counts don't match!"); 27 | 28 | var numJoints:Int = source.numJointPoses; 29 | var diff:SkeletonPose = new SkeletonPose(); 30 | var srcPose:JointPose; 31 | var refPose:JointPose; 32 | var diffPose:JointPose; 33 | var mtx:Matrix3D = new Matrix3D(); 34 | var tempMtx:Matrix3D = new Matrix3D(); 35 | var vec:Vector; 36 | 37 | for (i in 0...numJoints) { 38 | srcPose = source.jointPoses[i]; 39 | refPose = reference.jointPoses[i]; 40 | diffPose = new JointPose(); 41 | diff.jointPoses[i] = diffPose; 42 | diffPose.name = srcPose.name; 43 | 44 | refPose.toMatrix3D(mtx); 45 | mtx.invert(); 46 | mtx.append(srcPose.toMatrix3D(tempMtx)); 47 | vec = mtx.decompose(Orientation3D.QUATERNION); 48 | diffPose.translation.copyFrom(vec[0]); 49 | diffPose.orientation.x = vec[1].x; 50 | diffPose.orientation.y = vec[1].y; 51 | diffPose.orientation.z = vec[1].z; 52 | diffPose.orientation.w = vec[1].w; 53 | } 54 | 55 | return diff; 56 | } 57 | } -------------------------------------------------------------------------------- /away3d/textures/ATFData.hx: -------------------------------------------------------------------------------- 1 | package away3d.textures; 2 | 3 | import openfl.errors.Error; 4 | import openfl.display3D.Context3DTextureFormat; 5 | import openfl.utils.ByteArray; 6 | 7 | class ATFData 8 | { 9 | public static inline var TYPE_NORMAL:Int = 0x0; 10 | public static inline var TYPE_CUBE:Int = 0x1; 11 | 12 | public var type:Int; 13 | public var format:Context3DTextureFormat; 14 | public var width:Int; 15 | public var height:Int; 16 | public var numTextures:Int; 17 | public var data:ByteArray; 18 | 19 | /** Create a new instance by parsing the given byte array. */ 20 | public function new(data:ByteArray) 21 | { 22 | var sign:String = data.readUTFBytes(3); 23 | if (sign != "ATF") 24 | throw new Error("ATF parsing error, unknown format " + sign); 25 | 26 | if (data[6] == 255) 27 | data.position = 12; // new file version 28 | else 29 | data.position = 6; // old file version 30 | 31 | var tdata:Int = data.readUnsignedByte(); 32 | var _type:Int = tdata >> 7; // UB[1] 33 | var _format:Int = tdata & 0x7f; // UB[7] 34 | 35 | switch (_format) { 36 | case 0, 1: 37 | format = Context3DTextureFormat.BGRA; 38 | case 2, 3: 39 | format = Context3DTextureFormat.COMPRESSED; 40 | case 4, 5: 41 | format = Context3DTextureFormat.COMPRESSED_ALPHA; 42 | // explicit string to stay compatible 43 | // with older versions 44 | default: 45 | throw new Error("Invalid ATF format"); 46 | } 47 | 48 | switch (_type) { 49 | case 0: 50 | type = ATFData.TYPE_NORMAL; 51 | case 1: 52 | type = ATFData.TYPE_CUBE; 53 | 54 | default: 55 | throw new Error("Invalid ATF type"); 56 | } 57 | 58 | this.width = Std.int(Math.pow(2, data.readUnsignedByte())); 59 | this.height = Std.int(Math.pow(2, data.readUnsignedByte())); 60 | this.numTextures = data.readUnsignedByte(); 61 | this.data = data; 62 | } 63 | } -------------------------------------------------------------------------------- /away3d/paths/CubicPathSegment.hx: -------------------------------------------------------------------------------- 1 | package away3d.paths; 2 | 3 | import openfl.geom.Vector3D; 4 | 5 | /** 6 | * Defines a single segment of a cubic path 7 | * @see away3d.paths.CubicPath 8 | */ 9 | class CubicPathSegment implements IPathSegment 10 | { 11 | /** 12 | * The first anchor point. 13 | */ 14 | public var start:Vector3D; 15 | 16 | /** 17 | * The first control point. 18 | */ 19 | public var control1:Vector3D; 20 | 21 | /** 22 | * The second control point. 23 | */ 24 | public var control2:Vector3D; 25 | 26 | /** 27 | * The last anchor point. 28 | */ 29 | public var end:Vector3D; 30 | 31 | /** 32 | * 33 | * @param start The first anchor point. 34 | * @param control1 The first control point. 35 | * @param control2 The second control point. 36 | * @param end The last anchor point. 37 | */ 38 | public function new(start:Vector3D, control1:Vector3D, control2:Vector3D, end:Vector3D) 39 | { 40 | this.start = start; 41 | this.control1 = control1; 42 | this.control2 = control2; 43 | this.end = end; 44 | } 45 | 46 | public function toString():String 47 | { 48 | return start + ", " + control1 + ", " + control2 + ", " + end; 49 | } 50 | 51 | public function dispose():Void 52 | { 53 | start = control1 = control2 = end = null; 54 | } 55 | 56 | public function getPointOnSegment(phase:Float, target:Vector3D = null):Vector3D 57 | { 58 | var td:Float = 1 - phase; 59 | var t_2:Float = phase*phase; 60 | var a:Float = td*td*td; 61 | var b:Float = 3*phase*td*td; 62 | var c:Float = 3*t_2*td; 63 | var t_3:Float = t_2*phase; 64 | 65 | if (target == null) 66 | target = new Vector3D(); 67 | target.x = a*start.x + b*control1.x + c*control2.x + t_3*end.x; 68 | target.y = a*start.y + b*control1.y + c*control2.y + t_3*end.y; 69 | target.z = a*start.z + b*control1.z + c*control2.z + t_3*end.z; 70 | 71 | return target; 72 | } 73 | } -------------------------------------------------------------------------------- /away3d/library/naming/NumSuffixConflictStrategy.hx: -------------------------------------------------------------------------------- 1 | package away3d.library.naming; 2 | 3 | 4 | import away3d.library.assets.IAsset; 5 | 6 | class NumSuffixConflictStrategy extends ConflictStrategyBase 7 | { 8 | private var _separator:String; 9 | private var _next_suffix:Map; 10 | 11 | public function new(separator:String = '.') 12 | { 13 | super(); 14 | 15 | _separator = separator; 16 | _next_suffix = new Map(); 17 | } 18 | 19 | override public function resolveConflict(changedAsset:IAsset, oldAsset:IAsset, assetsDictionary:Dynamic, precedence:String):Void 20 | { 21 | var assetsDictionary2:Map = cast assetsDictionary; 22 | var orig:String; 23 | var new_name:String; 24 | var base:String, suffix:Int; 25 | 26 | orig = changedAsset.name; 27 | if (orig.indexOf(_separator) >= 0) { 28 | // Name has an ocurrence of the separator, so get base name and suffix, 29 | // unless suffix is non-numerical, in which case revert to zero and 30 | // use entire name as base 31 | base = orig.substring(0, orig.lastIndexOf(_separator)); 32 | suffix = Std.parseInt(orig.substring(base.length - 1)); 33 | if (Math.isNaN(suffix)) { 34 | base = orig; 35 | suffix = 0; 36 | } 37 | } else { 38 | base = orig; 39 | suffix = 0; 40 | } 41 | 42 | if (suffix == 0 && _next_suffix.exists(base)) 43 | suffix = _next_suffix[base]; 44 | 45 | // Find the first suffixed name that does 46 | // not collide with other names. 47 | do { 48 | suffix++; 49 | new_name = base + _separator + suffix; 50 | } while (assetsDictionary2.exists(new_name)); 51 | 52 | _next_suffix[base] = suffix; 53 | 54 | updateNames(oldAsset.assetNamespace, new_name, oldAsset, changedAsset, assetsDictionary2, precedence); 55 | } 56 | 57 | override public function create():ConflictStrategyBase 58 | { 59 | return new NumSuffixConflictStrategy(_separator); 60 | } 61 | } -------------------------------------------------------------------------------- /away3d/materials/utils/DefaultMaterialManager.hx: -------------------------------------------------------------------------------- 1 | package away3d.materials.utils; 2 | 3 | import away3d.core.base.IMaterialOwner; 4 | import away3d.textures.BitmapTexture; 5 | 6 | import openfl.display.BitmapData; 7 | 8 | class DefaultMaterialManager 9 | { 10 | private static var _defaultTextureBitmapData:BitmapData; 11 | private static var _defaultMaterial:TextureMaterial; 12 | private static var _defaultTexture:BitmapTexture; 13 | 14 | //private static var _defaultMaterialRenderables:Vector. = new Vector.(); 15 | 16 | public static function getDefaultMaterial(renderable:IMaterialOwner = null):TextureMaterial 17 | { 18 | if (_defaultTexture == null) 19 | createDefaultTexture(); 20 | 21 | if (_defaultMaterial == null) 22 | createDefaultMaterial(); 23 | 24 | //_defaultMaterialRenderables.push(renderable); 25 | 26 | return _defaultMaterial; 27 | } 28 | 29 | public static function getDefaultTexture(renderable:IMaterialOwner = null):BitmapTexture 30 | { 31 | if (_defaultTexture == null) 32 | createDefaultTexture(); 33 | 34 | //_defaultMaterialRenderables.push(renderable); 35 | 36 | return _defaultTexture; 37 | } 38 | 39 | private static function createDefaultTexture():Void 40 | { 41 | _defaultTextureBitmapData = new BitmapData(8, 8, false, 0x0); 42 | 43 | //create chekerboard 44 | for (i in 0...8) { 45 | for (j in 0...8) { 46 | if ((j & 1) ^ (i & 1) != 0) 47 | _defaultTextureBitmapData.setPixel(i, j, 0xFFFFFF); 48 | } 49 | } 50 | 51 | _defaultTexture = new BitmapTexture(_defaultTextureBitmapData); 52 | _defaultTexture.name = "defaultTexture"; 53 | } 54 | 55 | private static function createDefaultMaterial():Void 56 | { 57 | _defaultMaterial = new TextureMaterial(_defaultTexture); 58 | _defaultMaterial.mipmap = false; 59 | _defaultMaterial.smooth = false; 60 | _defaultMaterial.name = "defaultMaterial"; 61 | } 62 | } -------------------------------------------------------------------------------- /away3d/animators/nodes/SkeletonNaryLERPNode.hx: -------------------------------------------------------------------------------- 1 | package away3d.animators.nodes; 2 | 3 | import away3d.animators.*; 4 | import away3d.animators.states.*; 5 | 6 | import openfl.Vector; 7 | 8 | /** 9 | * A skeleton animation node that uses an n-dimensional array of animation node inputs to blend a lineraly interpolated output of a skeleton pose. 10 | */ 11 | class SkeletonNaryLERPNode extends AnimationNodeBase 12 | { 13 | public var numInputs(get, never):Int; 14 | 15 | public var _inputs:Vector = new Vector(); 16 | private var _numInputs:Int; 17 | 18 | private function get_numInputs():Int 19 | { 20 | return _numInputs; 21 | } 22 | 23 | /** 24 | * Creates a new SkeletonNaryLERPNode object. 25 | */ 26 | public function new() 27 | { 28 | _stateConstructor = cast SkeletonNaryLERPState.new; 29 | super(); 30 | } 31 | 32 | /** 33 | * Returns an integer representing the input index of the given skeleton animation node. 34 | * 35 | * @param input The skeleton animation node for with the input index is requested. 36 | */ 37 | public function getInputIndex(input:AnimationNodeBase):Int 38 | { 39 | return _inputs.indexOf(input); 40 | } 41 | 42 | /** 43 | * Returns the skeleton animation node object that resides at the given input index. 44 | * 45 | * @param index The input index for which the skeleton animation node is requested. 46 | */ 47 | public function getInputAt(index:Int):AnimationNodeBase 48 | { 49 | return _inputs[index]; 50 | } 51 | 52 | /** 53 | * Adds a new skeleton animation node input to the animation node. 54 | */ 55 | public function addInput(input:AnimationNodeBase):Void 56 | { 57 | _inputs[_numInputs++] = input; 58 | } 59 | 60 | /** 61 | * @inheritDoc 62 | */ 63 | public function getAnimationState(animator:IAnimator):SkeletonNaryLERPState 64 | { 65 | return cast(animator.getAnimationState(this), SkeletonNaryLERPState); 66 | } 67 | } -------------------------------------------------------------------------------- /away3d/textfield/CharLocation.hx: -------------------------------------------------------------------------------- 1 | package away3d.textfield; 2 | 3 | import openfl.Vector; 4 | 5 | /** 6 | * ... 7 | * @author P.J.Shand 8 | */ 9 | class CharLocation 10 | { 11 | public var char:BitmapChar; 12 | public var scale:Float; 13 | public var x:Float; 14 | public var y:Float; 15 | 16 | public function new(char:BitmapChar) 17 | { 18 | reset(char); 19 | } 20 | 21 | private function reset(char:BitmapChar):CharLocation 22 | { 23 | this.char = char; 24 | return this; 25 | } 26 | 27 | public function getChar():BitmapChar { 28 | return char; 29 | } 30 | 31 | // pooling 32 | 33 | private static var sInstancePool = new Array(); 34 | private static var sVectorPool = new Array(); 35 | 36 | private static var sInstanceLoan = new Array(); 37 | private static var sVectorLoan = new Array(); 38 | 39 | public static function instanceFromPool(char:BitmapChar):CharLocation 40 | { 41 | var instance:CharLocation = sInstancePool.length > 0 ? 42 | sInstancePool.pop() : new CharLocation(char); 43 | 44 | instance.reset(char); 45 | sInstanceLoan[sInstanceLoan.length] = instance; 46 | 47 | return instance; 48 | } 49 | 50 | public static function vectorFromPool():Vector 51 | { 52 | var vector:Vector = sVectorPool.length > 0 ? 53 | sVectorPool.pop() : new Vector (); 54 | 55 | vector.length = 0; 56 | sVectorLoan[sVectorLoan.length] = vector; 57 | 58 | return vector; 59 | } 60 | 61 | public static function rechargePool():Void 62 | { 63 | var instance:CharLocation; 64 | var vector:Vector; 65 | 66 | while (sInstanceLoan.length > 0) 67 | { 68 | instance = sInstanceLoan.pop(); 69 | instance.char = null; 70 | sInstancePool[sInstancePool.length] = instance; 71 | } 72 | 73 | while (sVectorLoan.length > 0) 74 | { 75 | vector = sVectorLoan.pop(); 76 | vector.length = 0; 77 | sVectorPool[sVectorPool.length] = vector; 78 | } 79 | } 80 | } -------------------------------------------------------------------------------- /away3d/animators/data/JointPose.hx: -------------------------------------------------------------------------------- 1 | package away3d.animators.data; 2 | 3 | import away3d.core.math.*; 4 | 5 | import openfl.geom.*; 6 | 7 | /** 8 | * Contains transformation data for a skeleton joint, used for skeleton animation. 9 | * 10 | * @see away3d.animation.data.Skeleton 11 | * @see away3d.animation.data.SkeletonJoint 12 | * 13 | * todo: support (uniform) scale 14 | */ 15 | class JointPose 16 | { 17 | /** 18 | * The name of the joint to which the pose is associated 19 | */ 20 | public var name:String; // intention is that this should be used only at load time, not in the main loop 21 | 22 | /** 23 | * The rotation of the pose stored as a quaternion 24 | */ 25 | public var orientation:Quaternion = new Quaternion(); 26 | 27 | /** 28 | * The translation of the pose 29 | */ 30 | public var translation:Vector3D = new Vector3D(); 31 | 32 | public function new() 33 | { 34 | 35 | } 36 | 37 | /** 38 | * Converts the transformation to a Matrix3D representation. 39 | * 40 | * @param target An optional target matrix to store the transformation. If not provided, it will create a new instance. 41 | * @return The transformation matrix of the pose. 42 | */ 43 | public function toMatrix3D(target:Matrix3D = null):Matrix3D 44 | { 45 | if (target == null) 46 | target = new Matrix3D(); 47 | 48 | orientation.toMatrix3D(target); 49 | target.appendTranslation(translation.x, translation.y, translation.z); 50 | return target; 51 | } 52 | 53 | /** 54 | * Copies the transformation data from a source pose object into the existing pose object. 55 | * 56 | * @param pose The source pose to copy from. 57 | */ 58 | public function copyFrom(pose:JointPose):Void 59 | { 60 | var or:Quaternion = pose.orientation; 61 | var tr:Vector3D = pose.translation; 62 | orientation.x = or.x; 63 | orientation.y = or.y; 64 | orientation.z = or.z; 65 | orientation.w = or.w; 66 | translation.x = tr.x; 67 | translation.y = tr.y; 68 | translation.z = tr.z; 69 | } 70 | } -------------------------------------------------------------------------------- /away3d/paths/IPath.hx: -------------------------------------------------------------------------------- 1 | package away3d.paths; 2 | 3 | import openfl.geom.Vector3D; 4 | import openfl.Vector; 5 | 6 | interface IPath 7 | { 8 | /** 9 | * The number of CubicPathSegment instances in the path. 10 | */ 11 | public var numSegments(get, never):Int; 12 | 13 | /** 14 | * The IPathSegment instances which make up this path. 15 | */ 16 | public var segments(get, never):Vector; 17 | 18 | /** 19 | * Returns the CubicPathSegment at the specified index 20 | * @param index The index of the segment 21 | * @return A CubicPathSegment instance 22 | */ 23 | public function getSegmentAt(index:Int):IPathSegment; 24 | 25 | /** 26 | * Adds a CubicPathSegment to the end of the path 27 | * @param segment 28 | */ 29 | public function addSegment(segment:IPathSegment):Void; 30 | 31 | /** 32 | * Removes a segment from the path 33 | * @param index The index of the CubicPathSegment to be removed 34 | * @param join Determines if the segments on either side of the removed segment should be adjusted so there is no gap. 35 | */ 36 | public function removeSegment(index:Int, join:Bool = false):Void; 37 | 38 | /** 39 | * Disposes the path and all the segments 40 | */ 41 | public function dispose():Void; 42 | 43 | /** 44 | * Discretizes the segment into a set of sample points. 45 | * 46 | * @param numSegments The amount of segments to split the sampling in. The amount of points returned is numSegments + 1 47 | */ 48 | public function getPointsOnCurvePerSegment(numSegments:Int):Vector>; 49 | 50 | /** 51 | * Gets a point on the curve 52 | * @param t The phase for which to get the point. A number between 0 and 1. 53 | * @param target An optional parameter to store the calculation, to avoid creating a new Vector3D object 54 | * @return The point on the curve for the given phase 55 | */ 56 | public function getPointOnCurve(t:Float, target:Vector3D = null):Vector3D; 57 | 58 | } -------------------------------------------------------------------------------- /away3d/filters/tasks/Filter3DXFadeCompositeTask.hx: -------------------------------------------------------------------------------- 1 | package away3d.filters.tasks; 2 | 3 | import away3d.cameras.Camera3D; 4 | import away3d.core.managers.Stage3DProxy; 5 | 6 | import openfl.display3D.Context3D; 7 | import openfl.display3D.Context3DProgramType; 8 | import openfl.display3D.textures.Texture; 9 | import openfl.display3D.textures.TextureBase; 10 | import openfl.Vector; 11 | 12 | class Filter3DXFadeCompositeTask extends Filter3DTaskBase 13 | { 14 | public var overlayTexture(get, set):TextureBase; 15 | public var amount(get, set):Float; 16 | 17 | private var _data:Vector; 18 | private var _overlayTexture:TextureBase; 19 | 20 | public function new(amount:Float) 21 | { 22 | super(); 23 | if (amount < 0) 24 | amount = 0 25 | else if (amount > 1) 26 | amount = 1; 27 | _data = Vector.ofArray([amount, 0, 0, 0]); 28 | } 29 | 30 | private function get_overlayTexture():TextureBase 31 | { 32 | return _overlayTexture; 33 | } 34 | 35 | private function set_overlayTexture(value:TextureBase):TextureBase 36 | { 37 | _overlayTexture = value; 38 | return value; 39 | } 40 | 41 | private function get_amount():Float 42 | { 43 | return _data[0]; 44 | } 45 | 46 | private function set_amount(value:Float):Float 47 | { 48 | _data[0] = value; 49 | return value; 50 | } 51 | 52 | override private function getFragmentCode():String 53 | { 54 | return "tex ft0, v0, fs0 <2d,nearest> \n" + 55 | "tex ft1, v0, fs1 <2d,nearest> \n" + 56 | "sub ft1, ft1, ft0 \n" + 57 | "mul ft1, ft1, fc0.x \n" + 58 | "add oc, ft1, ft0 \n"; 59 | } 60 | 61 | override public function activate(stage3DProxy:Stage3DProxy, camera3D:Camera3D, depthTexture:Texture):Void 62 | { 63 | var context:Context3D = stage3DProxy._context3D; 64 | context.setProgramConstantsFromVector(Context3DProgramType.FRAGMENT, 0, _data, 1); 65 | context.setTextureAt(1, _overlayTexture); 66 | } 67 | 68 | override public function deactivate(stage3DProxy:Stage3DProxy):Void 69 | { 70 | stage3DProxy._context3D.setTextureAt(1, null); 71 | } 72 | } -------------------------------------------------------------------------------- /away3d/materials/utils/MipmapGenerator.hx: -------------------------------------------------------------------------------- 1 | package away3d.materials.utils; 2 | 3 | import openfl.display.BitmapData; 4 | import openfl.geom.Matrix; 5 | import openfl.geom.Rectangle; 6 | import openfl.display3D.textures.CubeTexture; 7 | import openfl.display3D.textures.Texture; 8 | import openfl.display3D.textures.TextureBase; 9 | 10 | /** 11 | * MipmapGenerator is a helper class that uploads BitmapData to a Texture including mipmap levels. 12 | */ 13 | class MipmapGenerator 14 | { 15 | private static var _matrix:Matrix = new Matrix(); 16 | private static var _rect:Rectangle = new Rectangle(); 17 | 18 | /** 19 | * Uploads a BitmapData with mip maps to a target Texture object. 20 | * @param source The source BitmapData to upload. 21 | * @param target The target Texture to upload to. 22 | * @param mipmap An optional mip map holder to avoids creating new instances for fe animated materials. 23 | * @param alpha Indicate whether or not the uploaded bitmapData is transparent. 24 | */ 25 | public static function generateMipMaps(source:BitmapData, target:TextureBase, mipmap:BitmapData = null, alpha:Bool = false, side:Int = -1):Void 26 | { 27 | var w:UInt = source.width, 28 | h:UInt = source.height; 29 | var i = 0; 30 | var regen:Bool = mipmap != null; 31 | if (mipmap == null) mipmap = new BitmapData(w, h, alpha); 32 | 33 | _rect.width = w; 34 | _rect.height = h; 35 | 36 | while (w >= 1 || h >= 1) { 37 | if (alpha) 38 | mipmap.fillRect(_rect, 0); 39 | 40 | _matrix.a = _rect.width/source.width; 41 | _matrix.d = _rect.height/source.height; 42 | 43 | mipmap.draw(source, _matrix, null, null, null, true); 44 | 45 | if (#if (haxe_ver >= 4.2) Std.isOfType #else Std.is #end(target, Texture)) 46 | cast(target, Texture).uploadFromBitmapData(mipmap, i++); 47 | else 48 | cast(target, CubeTexture).uploadFromBitmapData(mipmap, side, i++); 49 | 50 | w >>= 1; 51 | h >>= 1; 52 | 53 | _rect.width = w > 1? w : 1; 54 | _rect.height = h > 1? h : 1; 55 | } 56 | 57 | if (!regen) 58 | mipmap.dispose(); 59 | } 60 | } -------------------------------------------------------------------------------- /away3d/controllers/ControllerBase.hx: -------------------------------------------------------------------------------- 1 | package away3d.controllers; 2 | 3 | 4 | import away3d.entities.Entity; 5 | import away3d.errors.AbstractMethodError; 6 | 7 | class ControllerBase { 8 | public var targetObject(get, set):Entity; 9 | public var autoUpdate(get, set):Bool; 10 | 11 | private var _autoUpdate:Bool; 12 | private var _targetObject:Entity; 13 | 14 | private function notifyUpdate():Void { 15 | if (_targetObject != null && _targetObject.implicitPartition != null && _autoUpdate) _targetObject.implicitPartition.markForUpdate(_targetObject); 16 | } 17 | 18 | /** 19 | * Target object on which the controller acts. Defaults to null. 20 | */ 21 | private function get_targetObject():Entity { 22 | return _targetObject; 23 | } 24 | 25 | private function set_targetObject(val:Entity):Entity { 26 | if (_targetObject == val) return val; 27 | if (_targetObject != null && _autoUpdate) _targetObject._controller = null; 28 | _targetObject = val; 29 | if (_targetObject != null && _autoUpdate) _targetObject._controller = this; 30 | notifyUpdate(); 31 | return val; 32 | } 33 | 34 | /** 35 | * Determines whether the controller applies updates automatically. Defaults to true 36 | */ 37 | private function get_autoUpdate():Bool { 38 | return _autoUpdate; 39 | } 40 | 41 | private function set_autoUpdate(val:Bool):Bool { 42 | if (_autoUpdate == val) return val; 43 | _autoUpdate = val; 44 | if (_targetObject != null) { 45 | if (_autoUpdate) _targetObject._controller = this 46 | else _targetObject._controller = null; 47 | } 48 | return val; 49 | } 50 | 51 | /** 52 | * Base controller class for dynamically adjusting the propeties of a 3D object. 53 | * 54 | * @param targetObject The 3D object on which to act. 55 | */ 56 | public function new(targetObject:Entity = null) { 57 | _autoUpdate = true; 58 | this.targetObject = targetObject; 59 | 60 | } 61 | 62 | /** 63 | * Manually applies updates to the target 3D object. 64 | */ 65 | public function update(interpolate:Bool = true):Void { 66 | throw new AbstractMethodError(); 67 | } 68 | } 69 | 70 | -------------------------------------------------------------------------------- /away3d/filters/RadialBlurFilter3D.hx: -------------------------------------------------------------------------------- 1 | package away3d.filters; 2 | 3 | import away3d.filters.tasks.Filter3DRadialBlurTask; 4 | 5 | class RadialBlurFilter3D extends Filter3DBase 6 | { 7 | public var intensity(get, set):Float; 8 | public var glowGamma(get, set):Float; 9 | public var blurStart(get, set):Float; 10 | public var blurWidth(get, set):Float; 11 | public var cx(get, set):Float; 12 | public var cy(get, set):Float; 13 | 14 | private var _blurTask:Filter3DRadialBlurTask; 15 | 16 | public function new(intensity:Float = 8.0, glowGamma:Float = 1.6, blurStart:Float = 1.0, blurWidth:Float = -0.3, cx:Float = 0.5, cy:Float = 0.5) 17 | { 18 | super(); 19 | _blurTask = new Filter3DRadialBlurTask(intensity, glowGamma, blurStart, blurWidth, cx, cy); 20 | addTask(_blurTask); 21 | } 22 | 23 | private function get_intensity():Float 24 | { 25 | return _blurTask.intensity; 26 | } 27 | 28 | private function set_intensity(intensity:Float):Float 29 | { 30 | _blurTask.intensity = intensity; 31 | return intensity; 32 | } 33 | 34 | private function get_glowGamma():Float 35 | { 36 | return _blurTask.glowGamma; 37 | } 38 | 39 | private function set_glowGamma(glowGamma:Float):Float 40 | { 41 | _blurTask.glowGamma = glowGamma; 42 | return glowGamma; 43 | } 44 | 45 | private function get_blurStart():Float 46 | { 47 | return _blurTask.blurStart; 48 | } 49 | 50 | private function set_blurStart(blurStart:Float):Float 51 | { 52 | _blurTask.blurStart = blurStart; 53 | return blurStart; 54 | } 55 | 56 | private function get_blurWidth():Float 57 | { 58 | return _blurTask.blurWidth; 59 | } 60 | 61 | private function set_blurWidth(blurWidth:Float):Float 62 | { 63 | _blurTask.blurWidth = blurWidth; 64 | return blurWidth; 65 | } 66 | 67 | private function get_cx():Float 68 | { 69 | return _blurTask.cx; 70 | } 71 | 72 | private function set_cx(cx:Float):Float 73 | { 74 | _blurTask.cx = cx; 75 | return cx; 76 | } 77 | 78 | private function get_cy():Float 79 | { 80 | return _blurTask.cy; 81 | } 82 | 83 | private function set_cy(cy:Float):Float 84 | { 85 | _blurTask.cy = cy; 86 | return cy; 87 | } 88 | } -------------------------------------------------------------------------------- /away3d/lights/LightProbe.hx: -------------------------------------------------------------------------------- 1 | package away3d.lights; 2 | 3 | import away3d.*; 4 | import away3d.bounds.*; 5 | import away3d.cameras.*; 6 | import away3d.core.base.*; 7 | import away3d.core.partition.*; 8 | import away3d.textures.*; 9 | 10 | import openfl.errors.Error; 11 | import openfl.geom.Matrix3D; 12 | 13 | class LightProbe extends LightBase 14 | { 15 | public var diffuseMap(get, set):CubeTextureBase; 16 | public var specularMap(get, set):CubeTextureBase; 17 | 18 | private var _diffuseMap:CubeTextureBase; 19 | private var _specularMap:CubeTextureBase; 20 | 21 | /** 22 | * Creates a new LightProbe object. 23 | */ 24 | public function new(diffuseMap:CubeTextureBase, specularMap:CubeTextureBase = null) 25 | { 26 | super(); 27 | _diffuseMap = diffuseMap; 28 | _specularMap = specularMap; 29 | } 30 | 31 | override private function createEntityPartitionNode():EntityNode 32 | { 33 | return new LightProbeNode(this); 34 | } 35 | 36 | private function get_diffuseMap():CubeTextureBase 37 | { 38 | return _diffuseMap; 39 | } 40 | 41 | private function set_diffuseMap(value:CubeTextureBase):CubeTextureBase 42 | { 43 | _diffuseMap = value; 44 | return value; 45 | } 46 | 47 | private function get_specularMap():CubeTextureBase 48 | { 49 | return _specularMap; 50 | } 51 | 52 | private function set_specularMap(value:CubeTextureBase):CubeTextureBase 53 | { 54 | _specularMap = value; 55 | return value; 56 | } 57 | 58 | /** 59 | * @inheritDoc 60 | */ 61 | override private function updateBounds():Void 62 | { 63 | // super.updateBounds(); 64 | _boundsInvalid = false; 65 | } 66 | 67 | /** 68 | * @inheritDoc 69 | */ 70 | override private function getDefaultBoundingVolume():BoundingVolumeBase 71 | { 72 | // todo: consider if this can be culled? 73 | return new NullBounds(); 74 | } 75 | 76 | /** 77 | * @inheritDoc 78 | */ 79 | override private function getObjectProjectionMatrix(renderable:IRenderable, camera:Camera3D, target:Matrix3D = null):Matrix3D 80 | { 81 | // TODO: not used 82 | 83 | throw new Error("Object projection matrices are not supported for LightProbe objects!"); 84 | return null; 85 | } 86 | } -------------------------------------------------------------------------------- /away3d/materials/utils/IVideoPlayer.hx: -------------------------------------------------------------------------------- 1 | package away3d.materials.utils; 2 | 3 | import openfl.display.Sprite; 4 | import openfl.media.SoundTransform; 5 | 6 | interface IVideoPlayer 7 | { 8 | 9 | /** 10 | * The source, url, to the video file 11 | */ 12 | public var source(get, set):String; 13 | 14 | /** 15 | * Indicates whether the player should loop when video finishes 16 | */ 17 | public var loop(get, set):Bool; 18 | 19 | /** 20 | * Master volume/gain 21 | */ 22 | public var volume(get, set):Float; 23 | 24 | /** 25 | * Panning 26 | */ 27 | public var pan(get, set):Float; 28 | 29 | /** 30 | * Mutes/unmutes the video's audio. 31 | */ 32 | public var mute(get, set):Bool; 33 | 34 | /** 35 | * Provides access to the SoundTransform of the video stream 36 | */ 37 | public var soundTransform(get, set):SoundTransform; 38 | 39 | /** 40 | * Get/Set access to the with of the video object 41 | */ 42 | public var width(get, set):Int; 43 | 44 | /** 45 | * Get/Set access to the height of the video object 46 | */ 47 | public var height(get, set):Int; 48 | 49 | /** 50 | * Provides access to the Video Object 51 | */ 52 | public var container(get, never):Sprite; 53 | 54 | /** 55 | * Indicates whether the video is playing 56 | */ 57 | public var playing(get, never):Bool; 58 | 59 | /** 60 | * Indicates whether the video is paused 61 | */ 62 | public var paused(get, never):Bool; 63 | 64 | /** 65 | * Returns the actual time of the netStream 66 | */ 67 | public var time(get, never):Float; 68 | 69 | /** 70 | * Start playing (or resume if paused) the video. 71 | */ 72 | public function play():Void; 73 | 74 | /** 75 | * Temporarily pause playback. Resume using play(). 76 | */ 77 | public function pause():Void; 78 | 79 | /** 80 | * Seeks to a given time in the video, specified in seconds, with a precision of three decimal places (milliseconds). 81 | */ 82 | public function seek(val:Float):Void; 83 | 84 | /** 85 | * Stop playback and reset playhead. 86 | */ 87 | public function stop():Void; 88 | 89 | /** 90 | * Called if the player is no longer needed 91 | */ 92 | public function dispose():Void; 93 | } -------------------------------------------------------------------------------- /away3d/filters/BlurFilter3D.hx: -------------------------------------------------------------------------------- 1 | package away3d.filters; 2 | 3 | import away3d.core.managers.Stage3DProxy; 4 | import away3d.filters.tasks.Filter3DHBlurTask; 5 | import away3d.filters.tasks.Filter3DVBlurTask; 6 | 7 | import openfl.display3D.textures.Texture; 8 | 9 | class BlurFilter3D extends Filter3DBase 10 | { 11 | public var blurX(get, set):Int; 12 | public var blurY(get, set):Int; 13 | public var stepSize(get, set):Int; 14 | 15 | private var _hBlurTask:Filter3DHBlurTask; 16 | private var _vBlurTask:Filter3DVBlurTask; 17 | 18 | /** 19 | * Creates a new BlurFilter3D object 20 | * @param blurX The amount of horizontal blur to apply 21 | * @param blurY The amount of vertical blur to apply 22 | * @param stepSize The distance between samples. Set to -1 to autodetect with acceptable quality. 23 | */ 24 | public function new(blurX:Int = 3, blurY:Int = 3, stepSize:Int = -1) 25 | { 26 | super(); 27 | addTask(_hBlurTask = new Filter3DHBlurTask(blurX, stepSize)); 28 | addTask(_vBlurTask = new Filter3DVBlurTask(blurY, stepSize)); 29 | } 30 | 31 | private function get_blurX():Int 32 | { 33 | return _hBlurTask.amount; 34 | } 35 | 36 | private function set_blurX(value:Int):Int 37 | { 38 | _hBlurTask.amount = value; 39 | return value; 40 | } 41 | 42 | private function get_blurY():Int 43 | { 44 | return _vBlurTask.amount; 45 | } 46 | 47 | private function set_blurY(value:Int):Int 48 | { 49 | _vBlurTask.amount = value; 50 | return value; 51 | } 52 | 53 | /** 54 | * The distance between two blur samples. Set to -1 to autodetect with acceptable quality (default value). 55 | * Higher values provide better performance at the cost of reduces quality. 56 | */ 57 | private function get_stepSize():Int 58 | { 59 | return _hBlurTask.stepSize; 60 | } 61 | 62 | private function set_stepSize(value:Int):Int 63 | { 64 | _hBlurTask.stepSize = value; 65 | _vBlurTask.stepSize = value; 66 | return value; 67 | } 68 | 69 | override public function setRenderTargets(mainTarget:Texture, stage3DProxy:Stage3DProxy):Void 70 | { 71 | _hBlurTask.target = _vBlurTask.getMainInputTexture(stage3DProxy); 72 | super.setRenderTargets(mainTarget, stage3DProxy); 73 | } 74 | } -------------------------------------------------------------------------------- /away3d/library/utils/Asset3DLibraryIterator.hx: -------------------------------------------------------------------------------- 1 | package away3d.library.utils; 2 | 3 | import away3d.library.assets.IAsset; 4 | 5 | import openfl.Vector; 6 | 7 | class Asset3DLibraryIterator 8 | { 9 | public var currentAsset(get, never):IAsset; 10 | public var numAssets(get, never):Int; 11 | 12 | private var _assets:Vector; 13 | private var _filtered:Vector; 14 | private var _idx:Int; 15 | 16 | public function new(assets:Vector, assetTypeFilter:String, namespaceFilter:String, filterFunc:Dynamic -> Dynamic) 17 | { 18 | _assets = assets; 19 | filter(assetTypeFilter, namespaceFilter, filterFunc); 20 | } 21 | 22 | private function get_currentAsset():IAsset 23 | { 24 | // Return current, or null if no current 25 | return ((_idx < _filtered.length))? 26 | _filtered[_idx] : null; 27 | } 28 | 29 | private function get_numAssets():Int 30 | { 31 | return _filtered.length; 32 | } 33 | 34 | public function next():IAsset 35 | { 36 | var next:IAsset = null; 37 | 38 | if (_idx < _filtered.length) 39 | next = _filtered[_idx]; 40 | 41 | _idx++; 42 | 43 | return next; 44 | } 45 | 46 | public function reset():Void 47 | { 48 | _idx = 0; 49 | } 50 | 51 | public function setIndex(index:Int):Void 52 | { 53 | _idx = index; 54 | } 55 | 56 | private function filter(assetTypeFilter:String, namespaceFilter:String, filterFunc:Dynamic -> Dynamic):Void 57 | { 58 | if (assetTypeFilter != null || namespaceFilter != null || filterFunc != null) { 59 | var idx:Int; 60 | var asset:IAsset; 61 | 62 | idx = 0; 63 | _filtered = new Vector(); 64 | 65 | for (asset in _assets) { 66 | // Skip this assets if filtering on type and this is wrong type 67 | if (assetTypeFilter != null && asset.assetType != assetTypeFilter) 68 | continue; 69 | 70 | // Skip this asset if filtering on namespace and this is wrong namespace 71 | if (namespaceFilter != null && asset.assetNamespace != namespaceFilter) 72 | continue; 73 | 74 | if (filterFunc != null && filterFunc(asset) == null) 75 | continue; 76 | 77 | _filtered[idx++] = asset; 78 | } 79 | } else { 80 | _filtered = _assets; 81 | } 82 | } 83 | } -------------------------------------------------------------------------------- /away3d/filters/tasks/Filter3DBloomCompositeTask.hx: -------------------------------------------------------------------------------- 1 | package away3d.filters.tasks; 2 | 3 | import away3d.cameras.Camera3D; 4 | import away3d.core.managers.Stage3DProxy; 5 | 6 | import openfl.display3D.Context3D; 7 | import openfl.display3D.Context3DProgramType; 8 | import openfl.display3D.textures.Texture; 9 | import openfl.display3D.textures.TextureBase; 10 | import openfl.Vector; 11 | 12 | class Filter3DBloomCompositeTask extends Filter3DTaskBase 13 | { 14 | public var overlayTexture(get, set):TextureBase; 15 | public var exposure(get, set):Float; 16 | 17 | private var _data:Vector; 18 | private var _overlayTexture:TextureBase; 19 | private var _exposure:Float; 20 | 21 | public function new(exposure:Float) 22 | { 23 | super(); 24 | _data = Vector.ofArray([ 0.299, 0.587, 0.114, 1.0 ]); // luminance projection, 1 25 | this.exposure = exposure; 26 | } 27 | 28 | private function get_overlayTexture():TextureBase 29 | { 30 | return _overlayTexture; 31 | } 32 | 33 | private function set_overlayTexture(value:TextureBase):TextureBase 34 | { 35 | _overlayTexture = value; 36 | return value; 37 | } 38 | 39 | override private function getFragmentCode():String 40 | { 41 | var code:String; 42 | code = "tex ft0, v0, fs0 <2d,linear,clamp> \n" + 43 | "tex ft1, v0, fs1 <2d,linear,clamp> \n" + 44 | "dp3 ft2.x, ft1, fc0\n" + 45 | "sub ft2.x, fc0.w, ft2.x\n" + 46 | "mul ft0, ft0, ft2.x\n"; 47 | code += "add oc, ft0, ft1 \n"; 48 | return code; 49 | } 50 | 51 | override public function activate(stage3DProxy:Stage3DProxy, camera3D:Camera3D, depthTexture:Texture):Void 52 | { 53 | var context:Context3D = stage3DProxy._context3D; 54 | context.setProgramConstantsFromVector(Context3DProgramType.FRAGMENT, 0, _data, 1); 55 | context.setTextureAt(1, _overlayTexture); 56 | } 57 | 58 | override public function deactivate(stage3DProxy:Stage3DProxy):Void 59 | { 60 | stage3DProxy._context3D.setTextureAt(1, null); 61 | } 62 | 63 | private function get_exposure():Float 64 | { 65 | return _exposure; 66 | } 67 | 68 | private function set_exposure(exposure:Float):Float 69 | { 70 | _exposure = exposure; 71 | _data[3] = 1 + _exposure / 10; 72 | return exposure; 73 | } 74 | } -------------------------------------------------------------------------------- /away3d/core/pick/AutoPickingCollider.hx: -------------------------------------------------------------------------------- 1 | package away3d.core.pick; 2 | 3 | import away3d.core.base.*; 4 | 5 | import openfl.geom.*; 6 | 7 | /** 8 | * Auto-selecting picking collider for entity objects. Used with the RaycastPicker picking object. 9 | * Chooses between pure AS3 picking and PixelBender picking based on a threshold property representing 10 | * the number of triangles encountered in a SubMesh object over which PixelBender is used. 11 | * 12 | * @see away3d.entities.Entity#pickingCollider 13 | * @see away3d.core.pick.RaycastPicker 14 | */ 15 | class AutoPickingCollider implements IPickingCollider 16 | { 17 | private var _pbPickingCollider:PBPickingCollider; 18 | private var _haxePickingCollider:HaxePickingCollider; 19 | private var _activePickingCollider:IPickingCollider; 20 | 21 | /** 22 | * Represents the number of triangles encountered in a SubMesh object over which PixelBender is used. 23 | */ 24 | public var triangleThreshold:Int = 1024; 25 | 26 | /** 27 | * Creates a new AutoPickingCollider object. 28 | * 29 | * @param findClosestCollision Determines whether the picking collider searches for the closest collision along the ray. Defaults to false. 30 | */ 31 | public function new(findClosestCollision:Bool = false) 32 | { 33 | _haxePickingCollider = new HaxePickingCollider(findClosestCollision); 34 | //_pbPickingCollider = new PBPickingCollider(findClosestCollision); 35 | } 36 | 37 | /** 38 | * @inheritDoc 39 | */ 40 | public function setLocalRay(localPosition:Vector3D, localDirection:Vector3D):Void 41 | { 42 | _haxePickingCollider.setLocalRay(localPosition, localDirection); 43 | //_pbPickingCollider.setLocalRay(localPosition, localDirection); 44 | } 45 | 46 | /** 47 | * @inheritDoc 48 | */ 49 | public function testSubMeshCollision(subMesh:SubMesh, pickingCollisionVO:PickingCollisionVO, shortestCollisionDistance:Float):Bool 50 | { 51 | _activePickingCollider = _haxePickingCollider; 52 | //_activePickingCollider = (subMesh.numTriangles > triangleThreshold)? _pbPickingCollider : _haxePickingCollider; 53 | return _activePickingCollider.testSubMeshCollision(subMesh, pickingCollisionVO, shortestCollisionDistance); 54 | } 55 | } -------------------------------------------------------------------------------- /away3d/bounds/NullBounds.hx: -------------------------------------------------------------------------------- 1 | package away3d.bounds; 2 | 3 | import away3d.core.base.*; 4 | import away3d.core.math.Plane3D; 5 | import away3d.core.math.PlaneClassification; 6 | import away3d.primitives.*; 7 | 8 | import openfl.geom.*; 9 | import openfl.Vector; 10 | 11 | /** 12 | * NullBounds represents a debug bounding "volume" that is either considered always in, or always out of the frustum. 13 | * NullBounds is useful for entities that are always considered in the frustum, such as directional lights or skyboxes. 14 | */ 15 | class NullBounds extends BoundingVolumeBase 16 | { 17 | private var _alwaysIn:Bool; 18 | private var _renderable:WireframePrimitiveBase; 19 | 20 | public function new(alwaysIn:Bool = true, renderable:WireframePrimitiveBase = null) 21 | { 22 | super(); 23 | _alwaysIn = alwaysIn; 24 | _renderable = renderable; 25 | _max.x = _max.y = _max.z = Math.POSITIVE_INFINITY; 26 | _min.x = _min.y = _min.z = _alwaysIn? Math.NEGATIVE_INFINITY : Math.POSITIVE_INFINITY; 27 | } 28 | 29 | override public function clone():BoundingVolumeBase 30 | { 31 | return new NullBounds(_alwaysIn); 32 | } 33 | 34 | override private function createBoundingRenderable():WireframePrimitiveBase 35 | { 36 | return if (_renderable != null) _renderable; else new WireframeSphere(100, 16, 12, 0xffffff, 0.5); 37 | } 38 | 39 | /** 40 | * @inheritDoc 41 | */ 42 | override public function isInFrustum(planes:Vector, numPlanes:Int):Bool 43 | { 44 | return _alwaysIn; 45 | } 46 | 47 | /** 48 | * @inheritDoc 49 | */ 50 | override public function fromGeometry(geometry:Geometry):Void 51 | { 52 | } 53 | 54 | /** 55 | * @inheritDoc 56 | */ 57 | override public function fromSphere(center:Vector3D, radius:Float):Void 58 | { 59 | } 60 | 61 | /** 62 | * @inheritDoc 63 | */ 64 | override public function fromExtremes(minX:Float, minY:Float, minZ:Float, maxX:Float, maxY:Float, maxZ:Float):Void 65 | { 66 | } 67 | 68 | override public function classifyToPlane(plane:Plane3D):Int 69 | { 70 | return PlaneClassification.INTERSECT; 71 | } 72 | 73 | override public function transformFrom(bounds:BoundingVolumeBase, matrix:Matrix3D):Void 74 | { 75 | _alwaysIn = cast(bounds, NullBounds)._alwaysIn; 76 | } 77 | } -------------------------------------------------------------------------------- /away3d/core/partition/EntityNode.hx: -------------------------------------------------------------------------------- 1 | package away3d.core.partition; 2 | 3 | import away3d.core.math.Plane3D; 4 | import away3d.core.traverse.PartitionTraverser; 5 | import away3d.entities.Entity; 6 | 7 | import openfl.geom.Vector3D; 8 | import openfl.Vector; 9 | 10 | /** 11 | * The EntityNode class provides an abstract base class for leaf nodes in a partition tree, containing 12 | * entities to be fed to the EntityCollector traverser. 13 | * The concrete subtype of Entity is responsible for creating a matching subtype of EntityNode. 14 | * 15 | * @see away3d.scenegraph.Entity 16 | * @see away3d.core.traverse.EntityCollector 17 | */ 18 | class EntityNode extends NodeBase 19 | { 20 | public var entity(get, never):Entity; 21 | 22 | private var _entity:Entity; 23 | 24 | /** 25 | * The link to the next object in the list to be updated 26 | * @private 27 | */ 28 | @:allow(away3d) private var _updateQueueNext:EntityNode; 29 | 30 | /** 31 | * Creates a new EntityNode object. 32 | * @param entity The Entity to be contained in this leaf node. 33 | */ 34 | public function new(entity:Entity) 35 | { 36 | super(); 37 | _entity = entity; 38 | _numEntities = 1; 39 | } 40 | 41 | /** 42 | * The entity contained in this leaf node. 43 | */ 44 | private function get_entity():Entity 45 | { 46 | return _entity; 47 | } 48 | 49 | /** 50 | * @inheritDoc 51 | */ 52 | override public function acceptTraverser(traverser:PartitionTraverser):Void 53 | { 54 | traverser.applyEntity(_entity); 55 | } 56 | 57 | /** 58 | * Detaches the node from its parent. 59 | */ 60 | public function removeFromParent():Void 61 | { 62 | if (_parent != null) 63 | _parent.removeNode(this); 64 | 65 | _parent = null; 66 | } 67 | 68 | override public function isInFrustum(planes:Vector, numPlanes:Int):Bool 69 | { 70 | if (!_entity.isVisible) 71 | return false; 72 | 73 | return _entity.worldBounds.isInFrustum(planes, numPlanes); 74 | } 75 | 76 | /** 77 | * @inheritDoc 78 | */ 79 | override public function isIntersectingRay(rayPosition:Vector3D, rayDirection:Vector3D):Bool 80 | { 81 | if (!_entity.isVisible) 82 | return false; 83 | 84 | return _entity.isIntersectingRay(rayPosition, rayDirection); 85 | } 86 | } -------------------------------------------------------------------------------- /away3d/audio/drivers/ISound3DDriver.hx: -------------------------------------------------------------------------------- 1 | package away3d.audio.drivers; 2 | 3 | import openfl.geom.Vector3D; 4 | import openfl.media.Sound; 5 | import openfl.events.IEventDispatcher; 6 | 7 | interface ISound3DDriver extends IEventDispatcher 8 | { 9 | /** 10 | * The sound object (flash.media.Sound) to play at the point of the sound 11 | * source. The output of this sound is modified by the driver before actual 12 | * sound output. 13 | */ 14 | var sourceSound(get, set):Sound; 15 | 16 | /** 17 | * Arbitrary value by which all distances are divided. The default value of 18 | * 1000 is usually suitable for scenes with a scale that roughly matches the 19 | * standard Away3D scale, i.e. that look good from the default camera position. 20 | */ 21 | var scale(get, set):Float; 22 | 23 | /** 24 | * Master volume/gain after 3D modifications to pan/volume have been applied. 25 | * Modify this to raise or lower the overall volume regardless of where the 26 | * sound source is located. 27 | */ 28 | var volume(get, set):Float; 29 | 30 | /** 31 | * Mutes/unmutes the driver completely, which is typically only done (internally 32 | * by Sound3D) whenever the sound source is removed from the scene. When true, 33 | * any values set to the volume property will be ignored. 34 | */ 35 | var mute(get, set):Bool; 36 | 37 | /** 38 | * Start playing (or resume if paused) the audio. This is NOT The same thing 39 | * as invoking play() on the flash.media.Sound object used as the source sound 40 | * for the driver. 41 | */ 42 | function play():Void; 43 | 44 | /** 45 | * Temporarily pause playback. Resume using play(). 46 | */ 47 | function pause():Void; 48 | 49 | /** 50 | * Stop playback and reset playhead. Subsequent play() calls will restart the 51 | * playback from the beginning of the sound file. 52 | */ 53 | function stop():Void; 54 | 55 | /** 56 | * Change the position of the sound source relative to the listener, known as 57 | * the reference vector. This is invoked by the Sound3D object when it's position 58 | * changes, and should typically not be called by any other code. 59 | * 60 | * @param v Sound source position vector relative to the listener. 61 | */ 62 | function updateReferenceVector(v:Vector3D):Void; 63 | } -------------------------------------------------------------------------------- /away3d/materials/methods/MethodVO.hx: -------------------------------------------------------------------------------- 1 | package away3d.materials.methods; 2 | 3 | import away3d.textures.Anisotropy; 4 | 5 | import openfl.Vector; 6 | 7 | /** 8 | * MethodVO contains data for a given method for the use within a single material. 9 | * This allows methods to be shared across materials while their non-public state differs. 10 | */ 11 | class MethodVO 12 | { 13 | public var vertexData:Vector; 14 | public var fragmentData:Vector; 15 | 16 | // public register indices 17 | public var texturesIndex:Int; 18 | public var secondaryTexturesIndex:Int; // sometimes needed for composites 19 | public var vertexConstantsIndex:Int; 20 | public var secondaryVertexConstantsIndex:Int; // sometimes needed for composites 21 | public var fragmentConstantsIndex:Int; 22 | public var secondaryFragmentConstantsIndex:Int; // sometimes needed for composites 23 | 24 | public var useMipmapping:Bool; 25 | public var useSmoothTextures:Bool; 26 | public var repeatTextures:Bool; 27 | 28 | public var anisotropy:Anisotropy; 29 | 30 | // internal stuff for the material to know before assembling code 31 | public var needsProjection:Bool; 32 | public var needsView:Bool; 33 | public var needsNormals:Bool; 34 | public var needsTangents:Bool; 35 | public var needsUV:Bool; 36 | public var needsSecondaryUV:Bool; 37 | public var needsGlobalVertexPos:Bool; 38 | public var needsGlobalFragmentPos:Bool; 39 | 40 | public var numLights:Int; 41 | public var useLightFallOff:Bool = true; 42 | 43 | /** 44 | * Creates a new MethodVO object. 45 | */ 46 | public function new() 47 | { 48 | 49 | } 50 | 51 | /** 52 | * Resets the values of the value object to their "unused" state. 53 | */ 54 | public function reset():Void 55 | { 56 | texturesIndex = -1; 57 | vertexConstantsIndex = -1; 58 | fragmentConstantsIndex = -1; 59 | 60 | useMipmapping = true; 61 | anisotropy = Anisotropy.ANISOTROPIC2X; 62 | useSmoothTextures = true; 63 | repeatTextures = false; 64 | 65 | needsProjection = false; 66 | needsView = false; 67 | needsNormals = false; 68 | needsTangents = false; 69 | needsUV = false; 70 | needsSecondaryUV = false; 71 | needsGlobalVertexPos = false; 72 | needsGlobalFragmentPos = false; 73 | 74 | numLights = 0; 75 | useLightFallOff = true; 76 | } 77 | } -------------------------------------------------------------------------------- /away3d/events/Object3DEvent.hx: -------------------------------------------------------------------------------- 1 | package away3d.events; 2 | 3 | import away3d.core.base.*; 4 | 5 | import openfl.events.Event; 6 | 7 | /** 8 | * Passed as a parameter when a 3d object event occurs 9 | */ 10 | class Object3DEvent extends Event 11 | { 12 | /** 13 | * Defines the value of the type property of a visiblityUpdated event object. 14 | */ 15 | public static inline var VISIBLITY_UPDATED:String = "visiblityUpdated"; 16 | 17 | /** 18 | * Defines the value of the type property of a scenetransformChanged event object. 19 | */ 20 | public static inline var SCENETRANSFORM_CHANGED:String = "scenetransformChanged"; 21 | 22 | /** 23 | * Defines the value of the type property of a sceneChanged event object. 24 | */ 25 | public static inline var SCENE_CHANGED:String = "sceneChanged"; 26 | 27 | /** 28 | * Defines the value of the type property of a positionChanged event object. 29 | */ 30 | public static inline var POSITION_CHANGED:String = "positionChanged"; 31 | 32 | /** 33 | * Defines the value of the type property of a rotationChanged event object. 34 | */ 35 | public static inline var ROTATION_CHANGED:String = "rotationChanged"; 36 | 37 | /** 38 | * Defines the value of the type property of a scaleChanged event object. 39 | */ 40 | public static inline var SCALE_CHANGED:String = "scaleChanged"; 41 | 42 | /** 43 | * A reference to the 3d object that is relevant to the event. 44 | */ 45 | public var object:Object3D; 46 | 47 | /** 48 | * Creates a new MaterialEvent object. 49 | * 50 | * @param type The type of the event. Possible values are: Object3DEvent.TRANSFORM_CHANGED, Object3DEvent.SCENETRANSFORM_CHANGED, Object3DEvent.SCENE_CHANGED, Object3DEvent.RADIUS_CHANGED and Object3DEvent.DIMENSIONS_CHANGED. 51 | * @param object A reference to the 3d object that is relevant to the event. 52 | */ 53 | public function new(type:String, object:Object3D) 54 | { 55 | super(type); 56 | this.object = object; 57 | } 58 | 59 | /** 60 | * Creates a copy of the Object3DEvent object and sets the value of each property to match that of the original. 61 | */ 62 | override public function clone():Event 63 | { 64 | return new Object3DEvent(type, object); 65 | } 66 | } -------------------------------------------------------------------------------- /away3d/paths/CubicPath.hx: -------------------------------------------------------------------------------- 1 | package away3d.paths; 2 | 3 | import openfl.geom.Vector3D; 4 | import openfl.Vector; 5 | 6 | /** 7 | * Defines a cubic path. Each segment of the path has two control points as opposed to CubicPathSegment which being quadratic, has one control point. 8 | * @see away3d.animators.CubicPathAnimator 9 | * @see away3d.paths.CubicPathSegment 10 | */ 11 | class CubicPath extends SegmentedPathBase implements IPath 12 | { 13 | /** 14 | * Creates a new CubicPath instance. 15 | * @param data See pointData 16 | */ 17 | public function new(data:Vector = null) 18 | { 19 | super(4, data); 20 | } 21 | 22 | override private function createSegmentFromArrayEntry(data:Vector, offset:Int):IPathSegment 23 | { 24 | return new CubicPathSegment(data[offset], data[offset + 1], data[offset + 2], data[offset + 3]); 25 | } 26 | 27 | override private function stitchSegment(start:IPathSegment, middle:IPathSegment, end:IPathSegment):Void 28 | { 29 | var seg:CubicPathSegment = cast(middle, CubicPathSegment); 30 | var prevSeg:CubicPathSegment = cast(start, CubicPathSegment); 31 | var nextSeg:CubicPathSegment = cast(end, CubicPathSegment); 32 | 33 | prevSeg.control1.x = (prevSeg.control1.x + seg.control1.x)*0.5; 34 | prevSeg.control1.y = (prevSeg.control1.y + seg.control1.y)*0.5; 35 | prevSeg.control1.z = (prevSeg.control1.z + seg.control1.z)*0.5; 36 | 37 | nextSeg.control1.x = (nextSeg.control1.x + seg.control1.x)*0.5; 38 | nextSeg.control1.y = (nextSeg.control1.y + seg.control1.y)*0.5; 39 | nextSeg.control1.z = (nextSeg.control1.z + seg.control1.z)*0.5; 40 | 41 | prevSeg.control2.x = (prevSeg.control2.x + seg.control2.x)*0.5; 42 | prevSeg.control2.y = (prevSeg.control2.y + seg.control2.y)*0.5; 43 | prevSeg.control2.z = (prevSeg.control2.z + seg.control2.z)*0.5; 44 | 45 | nextSeg.control2.x = (nextSeg.control2.x + seg.control2.x)*0.5; 46 | nextSeg.control2.y = (nextSeg.control2.y + seg.control2.y)*0.5; 47 | nextSeg.control2.z = (nextSeg.control2.z + seg.control2.z)*0.5; 48 | 49 | prevSeg.end.x = (seg.start.x + seg.end.x)*0.5; 50 | prevSeg.end.y = (seg.start.y + seg.end.y)*0.5; 51 | prevSeg.end.z = (seg.start.z + seg.end.z)*0.5; 52 | 53 | nextSeg.start.x = prevSeg.end.x; 54 | nextSeg.start.y = prevSeg.end.y; 55 | nextSeg.start.z = prevSeg.end.z; 56 | } 57 | } -------------------------------------------------------------------------------- /scripts/docs.hxml: -------------------------------------------------------------------------------- 1 | # Generate platform-specific XML for documentation output 2 | 3 | # -xml xml/Flash.xml 4 | # -swf obj/docs 5 | # -swf-version 17.0 6 | # -D display=usage 7 | # -D doc_gen 8 | # --macro include("away3d") 9 | # -lib lime 10 | # -lib openfl 11 | # -cp ../ 12 | # --no-output 13 | 14 | -xml xml/Flash.xml 15 | -cpp obj/docs 16 | -D display=usage 17 | -D doc_gen 18 | -D flash_doc_gen 19 | -D nocffi 20 | --macro include("away3d") 21 | -lib lime 22 | -lib openfl 23 | -cp ../ 24 | --no-output 25 | 26 | --next 27 | 28 | -xml xml/Windows.xml 29 | -cpp obj/docs 30 | -D display=usage 31 | -D windows 32 | -D doc_gen 33 | -D nocffi 34 | --macro include("away3d") 35 | -lib lime 36 | -lib openfl 37 | -cp ../ 38 | --no-output 39 | 40 | --next 41 | 42 | -xml xml/macOS.xml 43 | -cpp obj/docs 44 | -D display=usage 45 | -D mac 46 | -D doc_gen 47 | -D nocffi 48 | --macro include("away3d") 49 | -lib lime 50 | -lib openfl 51 | -cp ../ 52 | --no-output 53 | 54 | --next 55 | 56 | -xml xml/Linux.xml 57 | -cpp obj/docs 58 | -D display=usage 59 | -D linux 60 | -D doc_gen 61 | -D nocffi 62 | --macro include("away3d") 63 | -lib lime 64 | -lib openfl 65 | -cp ../ 66 | --no-output 67 | 68 | --next 69 | 70 | -xml xml/Neko.xml 71 | -neko obj/docs 72 | -D display=usage 73 | -D doc_gen 74 | -D nocffi 75 | --macro include("away3d") 76 | -lib lime 77 | -lib openfl 78 | -cp ../ 79 | --no-output 80 | 81 | --next 82 | 83 | -xml xml/iOS.xml 84 | -cpp obj/docs 85 | -D display=usage 86 | -D ios 87 | -D doc_gen 88 | -D nocffi 89 | --macro include("away3d") 90 | -lib lime 91 | -lib openfl 92 | -cp ../ 93 | --no-output 94 | 95 | --next 96 | 97 | -xml xml/Android.xml 98 | -cpp obj/docs 99 | -D display=usage 100 | -D android 101 | -D doc_gen 102 | -D nocffi 103 | --macro include("away3d") 104 | -lib lime 105 | -lib openfl 106 | -cp ../ 107 | --no-output 108 | 109 | --next 110 | 111 | -xml xml/HTML5.xml 112 | -js obj/docs 113 | -D display=usage 114 | -D html5 115 | -D doc_gen 116 | --macro include("away3d") 117 | -lib lime 118 | -lib openfl 119 | -cp ../ 120 | --no-output 121 | 122 | --next 123 | 124 | -cmd haxelib run dox -o ../docs -i xml -in away3d --toplevel-package away3d -D version 2.7 -D website "http://www.openfl.org" -D source-path "https://github.com/openfl/away3d/tree/master/src/" --title "Away3D API Reference" -------------------------------------------------------------------------------- /away3d/filters/HDepthOfFieldFilter3D.hx: -------------------------------------------------------------------------------- 1 | package away3d.filters; 2 | 3 | import away3d.cameras.Camera3D; 4 | import away3d.containers.ObjectContainer3D; 5 | import away3d.core.managers.Stage3DProxy; 6 | import away3d.filters.tasks.Filter3DHDepthOfFFieldTask; 7 | import openfl.geom.Vector3D; 8 | 9 | class HDepthOfFieldFilter3D extends Filter3DBase 10 | { 11 | public var focusTarget(get, set):ObjectContainer3D; 12 | public var focusDistance(get, set):Float; 13 | public var range(get, set):Float; 14 | public var maxBlur(get, set):Int; 15 | 16 | private var _dofTask:Filter3DHDepthOfFFieldTask; 17 | private var _focusTarget:ObjectContainer3D; 18 | 19 | /** 20 | * Creates a new HDepthOfFieldFilter3D object 21 | * @param amount The amount of blur to apply in pixels 22 | * @param stepSize The distance between samples. Set to -1 to autodetect with acceptable quality. 23 | */ 24 | public function new(maxBlur:Int = 3, stepSize:Int = -1) 25 | { 26 | super(); 27 | _dofTask = new Filter3DHDepthOfFFieldTask(maxBlur, stepSize); 28 | addTask(_dofTask); 29 | } 30 | 31 | private function get_focusTarget():ObjectContainer3D 32 | { 33 | return _focusTarget; 34 | } 35 | 36 | private function set_focusTarget(value:ObjectContainer3D):ObjectContainer3D 37 | { 38 | _focusTarget = value; 39 | return value; 40 | } 41 | 42 | private function get_focusDistance():Float 43 | { 44 | return _dofTask.focusDistance; 45 | } 46 | 47 | private function set_focusDistance(value:Float):Float 48 | { 49 | _dofTask.focusDistance = value; 50 | return value; 51 | } 52 | 53 | private function get_range():Float 54 | { 55 | return _dofTask.range; 56 | } 57 | 58 | private function set_range(value:Float):Float 59 | { 60 | _dofTask.range = value; 61 | return value; 62 | } 63 | 64 | private function get_maxBlur():Int 65 | { 66 | return _dofTask.maxBlur; 67 | } 68 | 69 | private function set_maxBlur(value:Int):Int 70 | { 71 | _dofTask.maxBlur = value; 72 | return value; 73 | } 74 | 75 | override public function update(stage:Stage3DProxy, camera:Camera3D):Void 76 | { 77 | if (_focusTarget != null) 78 | updateFocus(camera); 79 | } 80 | 81 | private function updateFocus(camera:Camera3D):Void 82 | { 83 | var target:Vector3D = camera.inverseSceneTransform.transformVector(_focusTarget.scenePosition); 84 | _dofTask.focusDistance = target.z; 85 | } 86 | } -------------------------------------------------------------------------------- /away3d/filters/VDepthOfFieldFilter3D.hx: -------------------------------------------------------------------------------- 1 | package away3d.filters; 2 | 3 | import away3d.cameras.Camera3D; 4 | import away3d.containers.ObjectContainer3D; 5 | import away3d.core.managers.Stage3DProxy; 6 | import away3d.filters.tasks.Filter3DVDepthOfFFieldTask; 7 | 8 | import openfl.geom.Vector3D; 9 | 10 | class VDepthOfFieldFilter3D extends Filter3DBase 11 | { 12 | public var focusTarget(get, set):ObjectContainer3D; 13 | public var focusDistance(get, set):Float; 14 | public var range(get, set):Float; 15 | public var maxBlur(get, set):Int; 16 | 17 | private var _dofTask:Filter3DVDepthOfFFieldTask; 18 | private var _focusTarget:ObjectContainer3D; 19 | 20 | /** 21 | * Creates a new VDepthOfFieldFilter3D object 22 | * @param amount The amount of blur to apply in pixels 23 | * @param stepSize The distance between samples. Set to -1 to autodetect with acceptable quality. 24 | */ 25 | public function new(maxBlur:Int = 3, stepSize:Int = -1) 26 | { 27 | super(); 28 | _dofTask = new Filter3DVDepthOfFFieldTask(maxBlur, stepSize); 29 | addTask(_dofTask); 30 | } 31 | 32 | private function get_focusTarget():ObjectContainer3D 33 | { 34 | return _focusTarget; 35 | } 36 | 37 | private function set_focusTarget(value:ObjectContainer3D):ObjectContainer3D 38 | { 39 | _focusTarget = value; 40 | return value; 41 | } 42 | 43 | private function get_focusDistance():Float 44 | { 45 | return _dofTask.focusDistance; 46 | } 47 | 48 | private function set_focusDistance(value:Float):Float 49 | { 50 | _dofTask.focusDistance = value; 51 | return value; 52 | } 53 | 54 | private function get_range():Float 55 | { 56 | return _dofTask.range; 57 | } 58 | 59 | private function set_range(value:Float):Float 60 | { 61 | _dofTask.range = value; 62 | return value; 63 | } 64 | 65 | private function get_maxBlur():Int 66 | { 67 | return _dofTask.maxBlur; 68 | } 69 | 70 | private function set_maxBlur(value:Int):Int 71 | { 72 | _dofTask.maxBlur = value; 73 | return value; 74 | } 75 | 76 | override public function update(stage:Stage3DProxy, camera:Camera3D):Void 77 | { 78 | if (_focusTarget != null) 79 | updateFocus(camera); 80 | } 81 | 82 | private function updateFocus(camera:Camera3D):Void 83 | { 84 | var target:Vector3D = camera.inverseSceneTransform.transformVector(_focusTarget.scenePosition); 85 | _dofTask.focusDistance = target.z; 86 | } 87 | } -------------------------------------------------------------------------------- /away3d/filters/Filter3DBase.hx: -------------------------------------------------------------------------------- 1 | package away3d.filters; 2 | 3 | import away3d.cameras.Camera3D; 4 | import away3d.core.managers.Stage3DProxy; 5 | import away3d.filters.tasks.Filter3DTaskBase; 6 | 7 | import openfl.display3D.textures.Texture; 8 | import openfl.Vector; 9 | 10 | class Filter3DBase 11 | { 12 | public var requireDepthRender(get, never):Bool; 13 | public var tasks(get, never):Vector; 14 | public var textureWidth(get, set):Int; 15 | public var textureHeight(get, set):Int; 16 | 17 | private var _tasks:Vector; 18 | private var _requireDepthRender:Bool; 19 | private var _textureWidth:Int; 20 | private var _textureHeight:Int; 21 | 22 | public function new() 23 | { 24 | _tasks = new Vector(); 25 | } 26 | 27 | private function get_requireDepthRender():Bool 28 | { 29 | return _requireDepthRender; 30 | } 31 | 32 | private function addTask(filter:Filter3DTaskBase):Void 33 | { 34 | _tasks.push(filter); 35 | if (!_requireDepthRender) 36 | _requireDepthRender = filter.requireDepthRender; 37 | } 38 | 39 | private function get_tasks():Vector 40 | { 41 | return _tasks; 42 | } 43 | 44 | public function getMainInputTexture(stage3DProxy:Stage3DProxy):Texture 45 | { 46 | return _tasks[0].getMainInputTexture(stage3DProxy); 47 | } 48 | 49 | private function get_textureWidth():Int 50 | { 51 | return _textureWidth; 52 | } 53 | 54 | private function set_textureWidth(value:Int):Int 55 | { 56 | _textureWidth = value; 57 | 58 | for (i in 0..._tasks.length) 59 | _tasks[i].textureWidth = value; 60 | 61 | return value; 62 | } 63 | 64 | private function get_textureHeight():Int 65 | { 66 | return _textureHeight; 67 | } 68 | 69 | private function set_textureHeight(value:Int):Int 70 | { 71 | _textureHeight = value; 72 | for (i in 0..._tasks.length) 73 | _tasks[i].textureHeight = value; 74 | 75 | return value; 76 | } 77 | 78 | // link up the filters correctly with the next filter 79 | public function setRenderTargets(mainTarget:Texture, stage3DProxy:Stage3DProxy):Void 80 | { 81 | _tasks[_tasks.length - 1].target = mainTarget; 82 | } 83 | 84 | public function dispose():Void 85 | { 86 | for (i in 0..._tasks.length) 87 | _tasks[i].dispose(); 88 | } 89 | 90 | public function update(stage:Stage3DProxy, camera:Camera3D):Void 91 | { 92 | 93 | } 94 | } -------------------------------------------------------------------------------- /away3d/animators/IAnimator.hx: -------------------------------------------------------------------------------- 1 | package away3d.animators; 2 | 3 | import away3d.animators.nodes.*; 4 | import away3d.animators.states.*; 5 | import away3d.cameras.Camera3D; 6 | import away3d.core.base.*; 7 | import away3d.core.managers.*; 8 | import away3d.entities.*; 9 | import away3d.materials.passes.*; 10 | 11 | /** 12 | * Provides an interface for animator classes that control animation output from a data set subtype of AnimationSetBase. 13 | * 14 | * @see away3d.animators.IAnimationSet 15 | */ 16 | interface IAnimator 17 | { 18 | /** 19 | * Returns the animation data set in use by the animator. 20 | */ 21 | var animationSet(get, never):IAnimationSet; 22 | 23 | /** 24 | * Sets the GPU render state required by the animation that is dependent of the rendered object. 25 | * 26 | * @param stage3DProxy The Stage3DProxy object which is currently being used for rendering. 27 | * @param renderable The object currently being rendered. 28 | * @param vertexConstantOffset The first available vertex register to write data to if running on the gpu. 29 | * @param vertexStreamOffset The first available vertex stream to write vertex data to if running on the gpu. 30 | */ 31 | function setRenderState(stage3DProxy:Stage3DProxy, renderable:IRenderable, vertexConstantOffset:Int, vertexStreamOffset:Int, camera:Camera3D):Void; 32 | 33 | /** 34 | * Verifies if the animation will be used on cpu. Needs to be true for all passes for a material to be able to use it on gpu. 35 | * Needs to be called if gpu code is potentially required. 36 | */ 37 | function testGPUCompatibility(pass:MaterialPassBase):Void; 38 | 39 | /** 40 | * Used by the mesh object to which the animator is applied, registers the owner for internal use. 41 | * 42 | * @private 43 | */ 44 | @:allow(away3d) private function addOwner(mesh:Mesh):Void; 45 | 46 | /** 47 | * Used by the mesh object from which the animator is removed, unregisters the owner for internal use. 48 | * 49 | * @private 50 | */ 51 | @:allow(away3d) private function removeOwner(mesh:Mesh):Void; 52 | 53 | function getAnimationState(node:AnimationNodeBase):IAnimationState; 54 | 55 | function getAnimationStateByName(name:String):IAnimationState; 56 | 57 | /** 58 | * Returns a shallow clone (re-using the same IAnimationSet) of this IAnimator. 59 | */ 60 | function clone():IAnimator; 61 | 62 | function dispose():Void; 63 | } -------------------------------------------------------------------------------- /away3d/events/AnimationStateEvent.hx: -------------------------------------------------------------------------------- 1 | package away3d.events; 2 | 3 | import away3d.animators.*; 4 | import away3d.animators.states.*; 5 | import away3d.animators.nodes.*; 6 | 7 | import openfl.events.Event; 8 | 9 | /** 10 | * Dispatched to notify changes in an animation state's state. 11 | */ 12 | class AnimationStateEvent extends Event 13 | { 14 | public var animator(get, never):IAnimator; 15 | public var animationState(get, never):IAnimationState; 16 | public var animationNode(get, never):AnimationNodeBase; 17 | 18 | /** 19 | * Dispatched when a non-looping clip node inside an animation state reaches the end of its timeline. 20 | */ 21 | public static inline var PLAYBACK_COMPLETE:String = "playbackComplete"; 22 | 23 | public static inline var TRANSITION_COMPLETE:String = "transitionComplete"; 24 | 25 | private var _animator:IAnimator; 26 | private var _animationState:IAnimationState; 27 | private var _animationNode:AnimationNodeBase; 28 | 29 | /** 30 | * Create a new AnimatonStateEvent 31 | * 32 | * @param type The event type. 33 | * @param animator The animation state object that is the subject of this event. 34 | * @param animationNode The animation node inside the animation state from which the event originated. 35 | */ 36 | public function new(type:String, animator:IAnimator, animationState:IAnimationState, animationNode:AnimationNodeBase) 37 | { 38 | super(type, false, false); 39 | 40 | _animator = animator; 41 | _animationState = animationState; 42 | _animationNode = animationNode; 43 | } 44 | 45 | /** 46 | * The animator object that is the subject of this event. 47 | */ 48 | private function get_animator():IAnimator 49 | { 50 | return _animator; 51 | } 52 | 53 | /** 54 | * The animation state object that is the subject of this event. 55 | */ 56 | private function get_animationState():IAnimationState 57 | { 58 | return _animationState; 59 | } 60 | 61 | /** 62 | * The animation node inside the animation state from which the event originated. 63 | */ 64 | private function get_animationNode():AnimationNodeBase 65 | { 66 | return _animationNode; 67 | } 68 | 69 | /** 70 | * Clones the event. 71 | * 72 | * @return An exact duplicate of the current object. 73 | */ 74 | override public function clone():Event 75 | { 76 | return new AnimationStateEvent(type, _animator, _animationState, _animationNode); 77 | } 78 | } -------------------------------------------------------------------------------- /away3d/core/traverse/RaycastCollector.hx: -------------------------------------------------------------------------------- 1 | package away3d.core.traverse; 2 | 3 | import away3d.core.base.IRenderable; 4 | import away3d.core.partition.NodeBase; 5 | import away3d.lights.LightBase; 6 | 7 | import openfl.geom.Vector3D; 8 | 9 | /** 10 | * The RaycastCollector class is a traverser for scene partitions that collects all scene graph entities that are 11 | * considered intersecting with the defined ray. 12 | * 13 | * @see away3d.partition.Partition3D 14 | * @see away3d.partition.Entity 15 | */ 16 | class RaycastCollector extends EntityCollector 17 | { 18 | public var rayPosition(get, set):Vector3D; 19 | public var rayDirection(get, set):Vector3D; 20 | 21 | private var _rayPosition:Vector3D = new Vector3D(); 22 | private var _rayDirection:Vector3D = new Vector3D(); 23 | 24 | /** 25 | * Creates a new RaycastCollector object. 26 | */ 27 | public function new() 28 | { 29 | super(); 30 | } 31 | 32 | /** 33 | * Provides the starting position of the ray. 34 | */ 35 | private function get_rayPosition():Vector3D 36 | { 37 | return _rayPosition; 38 | } 39 | 40 | private function set_rayPosition(value:Vector3D):Vector3D 41 | { 42 | _rayPosition = value; 43 | return value; 44 | } 45 | 46 | /** 47 | * Provides the direction vector of the ray. 48 | */ 49 | private function get_rayDirection():Vector3D 50 | { 51 | return _rayDirection; 52 | } 53 | 54 | private function set_rayDirection(value:Vector3D):Vector3D 55 | { 56 | _rayDirection = value; 57 | return value; 58 | } 59 | 60 | /** 61 | * Returns true if the current node is at least partly in the frustum. If so, the partition node knows to pass on the traverser to its children. 62 | * 63 | * @param node The Partition3DNode object to frustum-test. 64 | */ 65 | override public function enterNode(node:NodeBase):Bool 66 | { 67 | return node.isIntersectingRay(_rayPosition, _rayDirection); 68 | } 69 | 70 | /** 71 | * @inheritDoc 72 | */ 73 | override public function applySkyBox(renderable:IRenderable):Void 74 | { 75 | } 76 | 77 | /** 78 | * Adds an IRenderable object to the potentially visible objects. 79 | * @param renderable The IRenderable object to add. 80 | */ 81 | override public function applyRenderable(renderable:IRenderable):Void 82 | { 83 | } 84 | 85 | /** 86 | * @inheritDoc 87 | */ 88 | override public function applyUnknownLight(light:LightBase):Void 89 | { 90 | } 91 | } --------------------------------------------------------------------------------