├── pb ├── NormalizeSplats.pbj ├── RayTriangleKernel.pbj └── NormalizeSplats.pbk ├── src └── away3d │ ├── errors │ ├── CastError.as │ ├── AnimationSetError.as │ ├── InvalidTextureError.as │ ├── AbstractMethodError.as │ └── DeprecationError.as │ ├── arcane.as │ ├── core │ ├── data │ │ ├── EntityListItem.as │ │ ├── RenderableListItem.as │ │ ├── EntityListItemPool.as │ │ └── RenderableListItemPool.as │ ├── partition │ │ ├── Octree.as │ │ ├── QuadTree.as │ │ ├── NullNode.as │ │ ├── CameraNode.as │ │ ├── LightProbeNode.as │ │ ├── PointLightNode.as │ │ ├── LightNode.as │ │ ├── DirectionalLightNode.as │ │ ├── SkyBoxNode.as │ │ ├── RenderableNode.as │ │ ├── MeshNode.as │ │ ├── ViewVolumePartition.as │ │ └── EntityNode.as │ ├── base │ │ ├── ParticleGeometry.as │ │ ├── data │ │ │ ├── ParticleData.as │ │ │ ├── UV.as │ │ │ └── Vertex.as │ │ └── IMaterialOwner.as │ ├── math │ │ ├── PlaneClassification.as │ │ └── MathConsts.as │ ├── sort │ │ └── IEntitySorter.as │ ├── pick │ │ ├── PickingType.as │ │ ├── IPickingCollider.as │ │ ├── IPicker.as │ │ └── AutoPickingCollider.as │ └── traverse │ │ ├── SceneIterator.as │ │ └── RaycastCollector.as │ ├── animators │ ├── states │ │ ├── ISkeletonAnimationState.as │ │ ├── IAnimationState.as │ │ ├── ISpriteSheetAnimationState.as │ │ ├── IUVAnimationState.as │ │ ├── IVertexAnimationState.as │ │ ├── ParticleUVState.as │ │ ├── ParticleRotateToHeadingState.as │ │ ├── ParticleTimeState.as │ │ ├── UVClipState.as │ │ └── VertexClipState.as │ ├── transitions │ │ ├── IAnimationTransition.as │ │ ├── CrossfadeTransitionNode.as │ │ ├── CrossfadeTransition.as │ │ └── CrossfadeTransitionState.as │ ├── data │ │ ├── ColorSegmentPoint.as │ │ ├── VertexAnimationMode.as │ │ ├── ParticleAnimationData.as │ │ ├── ParticlePropertiesMode.as │ │ ├── SkeletonJoint.as │ │ ├── ParticleProperties.as │ │ ├── UVAnimationFrame.as │ │ ├── SpriteSheetAnimationFrame.as │ │ └── JointPose.as │ ├── nodes │ │ ├── ISpriteSheetAnimationNode.as │ │ ├── AnimationNodeBase.as │ │ ├── SkeletonBinaryLERPNode.as │ │ ├── SkeletonDifferenceNode.as │ │ ├── SkeletonDirectionalNode.as │ │ ├── SpriteSheetClipNode.as │ │ ├── UVClipNode.as │ │ ├── SkeletonNaryLERPNode.as │ │ └── VertexClipNode.as │ ├── utils │ │ └── SkeletonUtils.as │ ├── IAnimator.as │ └── SpriteSheetAnimationSet.as │ ├── Away3D.as │ ├── events │ ├── ShadingMethodEvent.as │ ├── LightEvent.as │ ├── Stage3DEvent.as │ ├── PathEvent.as │ ├── LensEvent.as │ ├── CameraEvent.as │ ├── Scene3DEvent.as │ ├── ParserEvent.as │ ├── AnimatorEvent.as │ ├── GeometryEvent.as │ ├── AnimationStateEvent.as │ └── Object3DEvent.as │ ├── loaders │ └── parsers │ │ ├── ParserDataFormat.as │ │ ├── utils │ │ └── ParserUtil.as │ │ └── Parsers.as │ ├── cameras │ └── lenses │ │ ├── CoordinateSystem.as │ │ └── FreeMatrixLens.as │ ├── paths │ ├── IPathSegment.as │ ├── QuadraticPathSegment.as │ ├── CubicPathSegment.as │ ├── IPath.as │ └── CubicPath.as │ ├── textures │ ├── Texture2DBase.as │ ├── CubeTextureBase.as │ ├── ATFTexture.as │ ├── ATFCubeTexture.as │ ├── RenderCubeTexture.as │ ├── BitmapTextureCache.as │ ├── RenderTexture.as │ ├── SplatBlendBitmapTexture.as │ └── ATFData.as │ ├── library │ ├── naming │ │ ├── IgnoreConflictStrategy.as │ │ ├── ErrorConflictStrategy.as │ │ ├── ConflictPrecedence.as │ │ ├── ConflictStrategy.as │ │ └── NumSuffixConflictStrategy.as │ ├── assets │ │ ├── IAsset.as │ │ ├── BitmapDataAsset.as │ │ └── AssetType.as │ └── utils │ │ └── AssetLibraryIterator.as │ ├── materials │ ├── SegmentMaterial.as │ ├── OrthoSegmentMaterial.as │ ├── ColorMultiPassMaterial.as │ ├── methods │ │ ├── MethodVOSet.as │ │ ├── EffectMethodBase.as │ │ ├── MethodVO.as │ │ ├── ShadowMapMethodBase.as │ │ └── ColorTransformMethod.as │ ├── SkyBoxMaterial.as │ ├── LightSources.as │ ├── compilation │ │ ├── ShaderRegisterData.as │ │ └── ShaderRegisterElement.as │ ├── OcclusionMaterial.as │ ├── ColorMaterial.as │ └── utils │ │ ├── DefaultMaterialManager.as │ │ └── MipmapGenerator.as │ ├── stereo │ └── methods │ │ ├── StereoRenderMethodBase.as │ │ ├── AnaglyphStereoRenderMethod.as │ │ └── InterleavedStereoRenderMethod.as │ ├── primitives │ ├── LineSegment.as │ ├── data │ │ └── NURBSVertex.as │ ├── ConeGeometry.as │ └── RegularPolygonGeometry.as │ ├── controllers │ ├── FollowController.as │ └── ControllerBase.as │ ├── tools │ ├── utils │ │ └── TextureUtils.as │ └── helpers │ │ └── data │ │ └── ParticleGeometryTransform.as │ ├── debug │ ├── data │ │ └── TridentLines.as │ └── Debug.as │ ├── filters │ ├── MotionBlurFilter3D.as │ ├── HBlurFilter3D.as │ ├── VBlurFilter3D.as │ ├── HueSaturationFilter3D.as │ ├── tasks │ │ ├── Filter3DBrightPassTask.as │ │ ├── Filter3DDoubleBufferCopyTask.as │ │ ├── Filter3DXFadeCompositeTask.as │ │ └── Filter3DBloomCompositeTask.as │ ├── RadialBlurFilter3D.as │ ├── BlurFilter3D.as │ ├── HDepthOfFieldFilter3D.as │ ├── VDepthOfFieldFilter3D.as │ └── Filter3DBase.as │ ├── lights │ ├── shadowmaps │ │ └── NearDirectionalShadowMapper.as │ └── LightProbe.as │ ├── audio │ └── drivers │ │ └── AbstractSound3DDriver.as │ └── bounds │ └── NullBounds.as ├── .gitignore ├── README.txt └── away3d-license.txt /pb/NormalizeSplats.pbj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/away3d/away3d-core-fp11/HEAD/pb/NormalizeSplats.pbj -------------------------------------------------------------------------------- /pb/RayTriangleKernel.pbj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/away3d/away3d-core-fp11/HEAD/pb/RayTriangleKernel.pbj -------------------------------------------------------------------------------- /src/away3d/errors/CastError.as: -------------------------------------------------------------------------------- 1 | package away3d.errors 2 | { 3 | 4 | public class CastError extends Error 5 | { 6 | public function CastError(message:String) 7 | { 8 | super(message); 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/away3d/errors/AnimationSetError.as: -------------------------------------------------------------------------------- 1 | package away3d.errors 2 | { 3 | 4 | public class AnimationSetError extends Error 5 | { 6 | public function AnimationSetError(message:String) 7 | { 8 | super(message); 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Build and Release Folders 2 | bin/ 3 | bin-debug/ 4 | bin-release/ 5 | out/ 6 | target/ 7 | 8 | # Project property files 9 | .actionScriptProperties 10 | .flexLibProperties 11 | .settings/ 12 | .idea/ 13 | .project 14 | .DS_Store 15 | *.iml -------------------------------------------------------------------------------- /src/away3d/arcane.as: -------------------------------------------------------------------------------- 1 | package away3d 2 | { 3 | /** 4 | * The namespace used to enclose properties and methods that should only be available within the Away3D library. 5 | * This keeps the public API clean and prevents the calling of methods that should never be called manually. 6 | */ 7 | public namespace arcane; 8 | } 9 | -------------------------------------------------------------------------------- /src/away3d/core/data/EntityListItem.as: -------------------------------------------------------------------------------- 1 | package away3d.core.data 2 | { 3 | 4 | import away3d.entities.Entity; 5 | 6 | public class EntityListItem 7 | { 8 | public var entity:Entity; 9 | public var next:EntityListItem; 10 | 11 | public function EntityListItem() 12 | { 13 | 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/away3d/core/partition/Octree.as: -------------------------------------------------------------------------------- 1 | package away3d.core.partition 2 | { 3 | import away3d.arcane; 4 | 5 | use namespace arcane; 6 | 7 | public class Octree extends Partition3D 8 | { 9 | public function Octree(maxDepth:int, size:Number) 10 | { 11 | super(new OctreeNode(maxDepth, size)); 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/away3d/core/partition/QuadTree.as: -------------------------------------------------------------------------------- 1 | package away3d.core.partition 2 | { 3 | import away3d.arcane; 4 | 5 | use namespace arcane; 6 | 7 | public class QuadTree extends Partition3D 8 | { 9 | public function QuadTree(maxDepth:int, size:Number, height:Number = 1000000) 10 | { 11 | super(new QuadTreeNode(maxDepth, size, height)); 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/away3d/animators/states/ISkeletonAnimationState.as: -------------------------------------------------------------------------------- 1 | package away3d.animators.states 2 | { 3 | import away3d.animators.data.*; 4 | 5 | public interface ISkeletonAnimationState extends IAnimationState 6 | { 7 | /** 8 | * Returns the output skeleton pose of the animation node. 9 | */ 10 | function getSkeletonPose(skeleton:Skeleton):SkeletonPose; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/away3d/animators/transitions/IAnimationTransition.as: -------------------------------------------------------------------------------- 1 | package away3d.animators.transitions 2 | { 3 | import away3d.animators.*; 4 | import away3d.animators.nodes.*; 5 | 6 | public interface IAnimationTransition 7 | { 8 | function getAnimationNode(animator:IAnimator, startNode:AnimationNodeBase, endNode:AnimationNodeBase, startTime:int):AnimationNodeBase 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/away3d/Away3D.as: -------------------------------------------------------------------------------- 1 | package away3d 2 | { 3 | /** 4 | * Helper class to track a few important library constants. 5 | */ 6 | public class Away3D 7 | { 8 | public static const WEBSITE_URL:String = "http://www.away3d.com"; 9 | 10 | public static const MAJOR_VERSION:uint = 4; 11 | 12 | public static const MINOR_VERSION:uint = 1; 13 | 14 | public static const REVISION:uint = 6; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/away3d/core/base/ParticleGeometry.as: -------------------------------------------------------------------------------- 1 | package away3d.core.base 2 | { 3 | import away3d.core.base.data.ParticleData; 4 | 5 | /** 6 | * ... 7 | */ 8 | public class ParticleGeometry extends Geometry 9 | { 10 | public var particles:Vector.; 11 | 12 | public var numParticles:uint; 13 | 14 | public function ParticleGeometry() 15 | { 16 | 17 | } 18 | 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/away3d/core/base/data/ParticleData.as: -------------------------------------------------------------------------------- 1 | package away3d.core.base.data 2 | { 3 | import away3d.core.base.CompactSubGeometry; 4 | 5 | public class ParticleData 6 | { 7 | public var particleIndex:uint; 8 | public var numVertices:uint; 9 | public var startVertexIndex:uint; 10 | public var subGeometry:CompactSubGeometry; 11 | 12 | public function ParticleData() 13 | { 14 | 15 | } 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/away3d/events/ShadingMethodEvent.as: -------------------------------------------------------------------------------- 1 | package away3d.events 2 | { 3 | import flash.events.Event; 4 | 5 | public class ShadingMethodEvent extends Event 6 | { 7 | public static const SHADER_INVALIDATED:String = "ShaderInvalidated"; 8 | 9 | public function ShadingMethodEvent(type:String, bubbles:Boolean = false, cancelable:Boolean = false) 10 | { 11 | super(type, bubbles, cancelable); 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/away3d/events/LightEvent.as: -------------------------------------------------------------------------------- 1 | package away3d.events 2 | { 3 | import flash.events.Event; 4 | 5 | public class LightEvent extends Event 6 | { 7 | public static const CASTS_SHADOW_CHANGE:String = "castsShadowChange"; 8 | 9 | public function LightEvent(type:String) 10 | { 11 | super(type); 12 | } 13 | 14 | override public function clone():Event 15 | { 16 | return new LightEvent(type); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/away3d/core/math/PlaneClassification.as: -------------------------------------------------------------------------------- 1 | package away3d.core.math 2 | { 3 | 4 | public class PlaneClassification 5 | { 6 | // "back" is synonymous with "in", but used for planes (back of plane is "inside" a solid volume walled by a plane) 7 | public static const BACK:int = 0; 8 | public static const FRONT:int = 1; 9 | 10 | public static const IN:int = 0; 11 | public static const OUT:int = 1; 12 | public static const INTERSECT:int = 2; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/away3d/loaders/parsers/ParserDataFormat.as: -------------------------------------------------------------------------------- 1 | package away3d.loaders.parsers 2 | { 3 | 4 | /** 5 | * An enumeration providing values to describe the data format of parsed data. 6 | */ 7 | public class ParserDataFormat 8 | { 9 | /** 10 | * Describes the format of a binary file. 11 | */ 12 | public static const BINARY:String = "binary"; 13 | 14 | /** 15 | * Describes the format of a plain text file. 16 | */ 17 | public static const PLAIN_TEXT:String = "plainText"; 18 | } 19 | } 20 | 21 | -------------------------------------------------------------------------------- /src/away3d/core/partition/NullNode.as: -------------------------------------------------------------------------------- 1 | package away3d.core.partition 2 | { 3 | 4 | /** 5 | * NullNode is a node that performs no space partitioning, but simply stores all objects in a 6 | * list of leaf nodes. This partitioning system is most useful for simple content, or content that is always in the 7 | * screen, such as a 3d user interface. 8 | */ 9 | public class NullNode extends NodeBase 10 | { 11 | /** 12 | * Creates a new NullNode object. 13 | */ 14 | public function NullNode() 15 | { 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/away3d/core/math/MathConsts.as: -------------------------------------------------------------------------------- 1 | package away3d.core.math 2 | { 3 | 4 | /** 5 | * MathConsts provides some commonly used mathematical constants 6 | */ 7 | public class MathConsts 8 | { 9 | /** 10 | * The amount to multiply with when converting radians to degrees. 11 | */ 12 | public static const RADIANS_TO_DEGREES:Number = 180/Math.PI; 13 | 14 | /** 15 | * The amount to multiply with when converting degrees to radians. 16 | */ 17 | public static const DEGREES_TO_RADIANS:Number = Math.PI/180; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/away3d/animators/states/IAnimationState.as: -------------------------------------------------------------------------------- 1 | package away3d.animators.states 2 | { 3 | import flash.geom.*; 4 | 5 | public interface IAnimationState 6 | { 7 | function get positionDelta():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:Number):void; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/away3d/core/sort/IEntitySorter.as: -------------------------------------------------------------------------------- 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 | public 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 | } 17 | } 18 | -------------------------------------------------------------------------------- /README.txt: -------------------------------------------------------------------------------- 1 | Copyright 2011 The Away3D Team 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. -------------------------------------------------------------------------------- /src/away3d/cameras/lenses/CoordinateSystem.as: -------------------------------------------------------------------------------- 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 | public class CoordinateSystem 9 | { 10 | /** 11 | * Default option, projects to a left-handed coordinate system 12 | */ 13 | public static const LEFT_HANDED:uint = 0; 14 | 15 | /** 16 | * Projects to a right-handed coordinate system 17 | */ 18 | public static const RIGHT_HANDED:uint = 1; 19 | } 20 | } -------------------------------------------------------------------------------- /src/away3d/paths/IPathSegment.as: -------------------------------------------------------------------------------- 1 | package away3d.paths 2 | { 3 | import flash.geom.Vector3D; 4 | 5 | public interface IPathSegment 6 | { 7 | /** 8 | * Destroys the segment 9 | */ 10 | 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 | function getPointOnSegment(phase:Number, target:Vector3D = null):Vector3D; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/away3d/textures/Texture2DBase.as: -------------------------------------------------------------------------------- 1 | package away3d.textures 2 | { 3 | import away3d.arcane; 4 | 5 | import flash.display3D.Context3D; 6 | import flash.display3D.Context3DTextureFormat; 7 | import flash.display3D.textures.TextureBase; 8 | 9 | use namespace arcane; 10 | 11 | public class Texture2DBase extends TextureProxyBase 12 | { 13 | public function Texture2DBase() 14 | { 15 | super(); 16 | } 17 | 18 | override protected function createTexture(context:Context3D):TextureBase 19 | { 20 | return context.createTexture(_width, _height, Context3DTextureFormat.BGRA, false); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/away3d/errors/InvalidTextureError.as: -------------------------------------------------------------------------------- 1 | package away3d.errors 2 | { 3 | 4 | /** 5 | * TextureError is thrown when an invalid texture is used regarding Stage3D limitations. 6 | */ 7 | public class InvalidTextureError extends Error 8 | { 9 | /** 10 | * Create a new TextureError. 11 | * @param message An optional message to override the default error message. 12 | * @param id The id of the error. 13 | */ 14 | public function InvalidTextureError(message:String = null, id:int = 0) 15 | { 16 | super(message || "Invalid bitmapData! Must be power of 2 and not exceeding 2048.", id); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /away3d-license.txt: -------------------------------------------------------------------------------- 1 | Copyright 2013 The Away Foundation (http://www.theawayfoundation.org) 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. -------------------------------------------------------------------------------- /src/away3d/events/Stage3DEvent.as: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package away3d.events 5 | { 6 | import flash.events.Event; 7 | 8 | public class Stage3DEvent extends Event 9 | { 10 | public static const CONTEXT3D_CREATED:String = "Context3DCreated"; 11 | public static const CONTEXT3D_DISPOSED:String = "Context3DDisposed"; 12 | public static const CONTEXT3D_RECREATED:String = "Context3DRecreated"; 13 | public static const VIEWPORT_UPDATED:String = "ViewportUpdated"; 14 | 15 | public function Stage3DEvent(type:String, bubbles:Boolean = false, cancelable:Boolean = false) 16 | { 17 | super(type, bubbles, cancelable); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/away3d/core/data/RenderableListItem.as: -------------------------------------------------------------------------------- 1 | package away3d.core.data 2 | { 3 | 4 | import away3d.core.base.IRenderable; 5 | 6 | import flash.geom.Matrix3D; 7 | 8 | public final class RenderableListItem 9 | { 10 | public var next:RenderableListItem; 11 | public var renderable:IRenderable; 12 | 13 | // for faster access while sorting or rendering (cached values) 14 | public var materialId:int; 15 | public var renderOrderId:int; 16 | public var zIndex:Number; 17 | public var renderSceneTransform:Matrix3D; 18 | 19 | public var cascaded:Boolean; 20 | 21 | public function RenderableListItem() 22 | { 23 | 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/away3d/animators/transitions/CrossfadeTransitionNode.as: -------------------------------------------------------------------------------- 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 | public class CrossfadeTransitionNode extends SkeletonBinaryLERPNode 9 | { 10 | public var blendSpeed:Number; 11 | 12 | public var startBlend:int; 13 | 14 | /** 15 | * Creates a new CrossfadeTransitionNode object. 16 | */ 17 | public function CrossfadeTransitionNode() 18 | { 19 | _stateClass = CrossfadeTransitionState; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/away3d/library/naming/IgnoreConflictStrategy.as: -------------------------------------------------------------------------------- 1 | package away3d.library.naming 2 | { 3 | import away3d.library.assets.IAsset; 4 | 5 | public class IgnoreConflictStrategy extends ConflictStrategyBase 6 | { 7 | public function IgnoreConflictStrategy() 8 | { 9 | super(); 10 | } 11 | 12 | public override function resolveConflict(changedAsset:IAsset, oldAsset:IAsset, assetsDictionary:Object, precedence:String):void 13 | { 14 | // Do nothing, ignore the fact that there is a conflict. 15 | return; 16 | } 17 | 18 | public override function create():ConflictStrategyBase 19 | { 20 | return new IgnoreConflictStrategy(); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/away3d/core/base/IMaterialOwner.as: -------------------------------------------------------------------------------- 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 | public interface IMaterialOwner 10 | { 11 | /** 12 | * The material with which to render the object. 13 | */ 14 | function get material():MaterialBase; 15 | 16 | function set material(value:MaterialBase):void; 17 | 18 | /** 19 | * The animation used by the material to assemble the vertex code. 20 | */ 21 | function get animator():IAnimator; // in most cases, this will in fact be null 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/away3d/animators/data/ColorSegmentPoint.as: -------------------------------------------------------------------------------- 1 | package away3d.animators.data 2 | { 3 | import flash.geom.ColorTransform; 4 | 5 | public class ColorSegmentPoint 6 | { 7 | private var _color:ColorTransform; 8 | private var _life:Number; 9 | 10 | public function ColorSegmentPoint(life:Number, color:ColorTransform) 11 | { 12 | //0= 1) 14 | throw(new Error("life exceeds range (0,1)")); 15 | _life = life; 16 | _color = color; 17 | } 18 | 19 | public function get color():ColorTransform 20 | { 21 | return _color; 22 | } 23 | 24 | public function get life():Number 25 | { 26 | return _life; 27 | } 28 | 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/away3d/animators/data/VertexAnimationMode.as: -------------------------------------------------------------------------------- 1 | package away3d.animators.data 2 | { 3 | 4 | /** 5 | * Options for setting the animation mode of a vertex animator object. 6 | * 7 | * @see away3d.animators.VertexAnimator 8 | */ 9 | public class VertexAnimationMode 10 | { 11 | /** 12 | * Animation mode that adds all outputs from active vertex animation state to form the current vertex animation pose. 13 | */ 14 | public static const ADDITIVE:String = "additive"; 15 | 16 | /** 17 | * Animation mode that picks the output from a single vertex animation state to form the current vertex animation pose. 18 | */ 19 | public static const ABSOLUTE:String = "absolute"; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/away3d/textures/CubeTextureBase.as: -------------------------------------------------------------------------------- 1 | package away3d.textures 2 | { 3 | import away3d.arcane; 4 | 5 | import flash.display3D.Context3D; 6 | import flash.display3D.Context3DTextureFormat; 7 | import flash.display3D.textures.TextureBase; 8 | 9 | use namespace arcane; 10 | 11 | public class CubeTextureBase extends TextureProxyBase 12 | { 13 | public function CubeTextureBase() 14 | { 15 | super(); 16 | } 17 | 18 | public function get size():int 19 | { 20 | return _width; 21 | } 22 | 23 | override protected function createTexture(context:Context3D):TextureBase 24 | { 25 | return context.createCubeTexture(width, Context3DTextureFormat.BGRA, false); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /pb/NormalizeSplats.pbk: -------------------------------------------------------------------------------- 1 | 2 | 3 | kernel NormalizeSplats 4 | < namespace : "com.away3d"; 5 | vendor : "Away3D"; 6 | version : 1; 7 | description : "Normalizes the content of splat alpha maps for up to 3 layers."; 8 | > 9 | { 10 | input image3 src; 11 | output pixel3 dst; 12 | 13 | parameter int numLayers < minValue: 1; 14 | maxValue: 3; 15 | defaultValue: 3; 16 | >; 17 | 18 | void evaluatePixel() 19 | { 20 | dst = sampleNearest(src, outCoord()); 21 | if (numLayers >= 3) dst.y += dst.z; 22 | if (numLayers >= 2) dst.x += dst.y; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/away3d/library/naming/ErrorConflictStrategy.as: -------------------------------------------------------------------------------- 1 | package away3d.library.naming 2 | { 3 | import away3d.library.assets.IAsset; 4 | 5 | public class ErrorConflictStrategy extends ConflictStrategyBase 6 | { 7 | public function ErrorConflictStrategy() 8 | { 9 | super(); 10 | } 11 | 12 | public override function resolveConflict(changedAsset:IAsset, oldAsset:IAsset, assetsDictionary:Object, precedence:String):void 13 | { 14 | throw new Error('Asset name collision while AssetLibrary.namingStrategy set to AssetLibrary.THROW_ERROR. Asset path: ' + changedAsset.assetFullPath); 15 | } 16 | 17 | public override function create():ConflictStrategyBase 18 | { 19 | return new ErrorConflictStrategy(); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/away3d/animators/nodes/ISpriteSheetAnimationNode.as: -------------------------------------------------------------------------------- 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 | public interface ISpriteSheetAnimationNode 11 | { 12 | /** 13 | * Returns the current SpriteSheetAnimationFrame of animation in the clip based on the internal playhead position. 14 | */ 15 | function get currentFrameData():SpriteSheetAnimationFrame; 16 | 17 | /** 18 | * Returns the current frame number. 19 | */ 20 | function get currentFrameNumber():uint; 21 | 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/away3d/animators/states/ISpriteSheetAnimationState.as: -------------------------------------------------------------------------------- 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 SpriteSheetAnimator class. 7 | * 8 | * @see away3d.animators.SpriteSheetAnimator 9 | */ 10 | public interface ISpriteSheetAnimationState extends IAnimationState 11 | { 12 | /** 13 | * Returns the current SpriteSheetAnimationFrame of animation in the clip based on the internal playhead position. 14 | */ 15 | function get currentFrameData():SpriteSheetAnimationFrame; 16 | 17 | /** 18 | * Returns the current frame number. 19 | */ 20 | function get currentFrameNumber():uint; 21 | 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/away3d/events/PathEvent.as: -------------------------------------------------------------------------------- 1 | package away3d.events 2 | { 3 | import flash.events.Event; 4 | 5 | public 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 const 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 const RANGE:String = "range"; 16 | 17 | /** 18 | * Dispatched when the time pointer enters a new PathSegment 19 | */ 20 | public static const CHANGE_SEGMENT:String = "change_segment"; 21 | 22 | public function PathEvent(type:String) 23 | { 24 | super(type); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/away3d/errors/AbstractMethodError.as: -------------------------------------------------------------------------------- 1 | package away3d.errors 2 | { 3 | 4 | /** 5 | * AbstractMethodError is thrown when an abstract method is called. The method in question should be overridden 6 | * by a concrete subclass. 7 | */ 8 | public class AbstractMethodError extends Error 9 | { 10 | /** 11 | * Create a new AbstractMethodError. 12 | * @param message An optional message to override the default error message. 13 | * @param id The id of the error. 14 | */ 15 | public function AbstractMethodError(message:String = null, id:int = 0) 16 | { 17 | super(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.", id); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/away3d/events/LensEvent.as: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package away3d.events 5 | { 6 | import away3d.cameras.lenses.LensBase; 7 | 8 | import flash.events.Event; 9 | 10 | public class LensEvent extends Event 11 | { 12 | public static const MATRIX_CHANGED:String = "matrixChanged"; 13 | 14 | private var _lens:LensBase; 15 | 16 | public function LensEvent(type:String, lens:LensBase, bubbles:Boolean = false, cancelable:Boolean = false) 17 | { 18 | super(type, bubbles, cancelable); 19 | _lens = lens; 20 | } 21 | 22 | public function get lens():LensBase 23 | { 24 | return _lens; 25 | } 26 | 27 | override public function clone():Event 28 | { 29 | return new LensEvent(type, _lens, bubbles, cancelable); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/away3d/events/CameraEvent.as: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package away3d.events 5 | { 6 | import flash.events.Event; 7 | 8 | import away3d.cameras.Camera3D; 9 | 10 | public class CameraEvent extends Event 11 | { 12 | public static const LENS_CHANGED:String = "lensChanged"; 13 | 14 | private var _camera:Camera3D; 15 | 16 | public function CameraEvent(type:String, camera:Camera3D, bubbles:Boolean = false, cancelable:Boolean = false) 17 | { 18 | super(type, bubbles, cancelable); 19 | _camera = camera; 20 | } 21 | 22 | public function get camera():Camera3D 23 | { 24 | return _camera; 25 | } 26 | 27 | override public function clone():Event 28 | { 29 | return new CameraEvent(type, _camera, bubbles, cancelable); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/away3d/core/partition/CameraNode.as: -------------------------------------------------------------------------------- 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 | public 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 CameraNode(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 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/away3d/errors/DeprecationError.as: -------------------------------------------------------------------------------- 1 | package away3d.errors 2 | { 3 | 4 | public class DeprecationError extends Error 5 | { 6 | private var _since:String; 7 | private var _source:String; 8 | private var _info:String; 9 | 10 | public function DeprecationError(source:String, since:String, info:String) 11 | { 12 | super(source + " has been marked as deprecated since version " + since + " and has been slated for removal. " + info); 13 | _since = since; 14 | _source = source; 15 | _info = info; 16 | } 17 | 18 | public function get since():String 19 | { 20 | return _since; 21 | } 22 | 23 | public function get source():String 24 | { 25 | return _source; 26 | } 27 | 28 | public function get info():String 29 | { 30 | return _info; 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/away3d/materials/SegmentMaterial.as: -------------------------------------------------------------------------------- 1 | package away3d.materials 2 | { 3 | import away3d.arcane; 4 | import away3d.materials.passes.SegmentPass; 5 | 6 | use namespace arcane; 7 | 8 | /** 9 | * SegmentMaterial is a material exclusively used to render wireframe objects 10 | * 11 | * @see away3d.entities.Lines 12 | */ 13 | public class SegmentMaterial extends MaterialBase 14 | { 15 | private var _screenPass:SegmentPass; 16 | 17 | /** 18 | * Creates a new SegmentMaterial object. 19 | * 20 | * @param thickness The thickness of the wireframe lines. 21 | */ 22 | public function SegmentMaterial(thickness:Number = 1.25) 23 | { 24 | super(); 25 | 26 | bothSides = true; 27 | addPass(_screenPass = new SegmentPass(thickness)); 28 | _screenPass.material = this; 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/away3d/core/data/EntityListItemPool.as: -------------------------------------------------------------------------------- 1 | package away3d.core.data 2 | { 3 | 4 | public class EntityListItemPool 5 | { 6 | private var _pool:Vector.; 7 | private var _index:int; 8 | private var _poolSize:int; 9 | 10 | public function EntityListItemPool() 11 | { 12 | _pool = new Vector.(); 13 | } 14 | 15 | public function getItem():EntityListItem 16 | { 17 | var item:EntityListItem; 18 | if (_index == _poolSize) { 19 | item = new EntityListItem(); 20 | _pool[_index++] = item; 21 | ++_poolSize; 22 | } else 23 | item = _pool[_index++]; 24 | return item; 25 | } 26 | 27 | public function freeAll():void 28 | { 29 | _index = 0; 30 | } 31 | 32 | public function dispose():void 33 | { 34 | _pool.length = 0; 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/away3d/core/data/RenderableListItemPool.as: -------------------------------------------------------------------------------- 1 | package away3d.core.data 2 | { 3 | 4 | public class RenderableListItemPool 5 | { 6 | private var _pool:Vector.; 7 | private var _index:int; 8 | private var _poolSize:int; 9 | 10 | public function RenderableListItemPool() 11 | { 12 | _pool = new Vector.(); 13 | } 14 | 15 | public function getItem():RenderableListItem 16 | { 17 | if (_index == _poolSize) { 18 | var item:RenderableListItem = new RenderableListItem(); 19 | _pool[_index++] = item; 20 | ++_poolSize; 21 | return item; 22 | } else 23 | return _pool[_index++]; 24 | } 25 | 26 | public function freeAll():void 27 | { 28 | _index = 0; 29 | } 30 | 31 | public function dispose():void 32 | { 33 | _pool.length = 0; 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/away3d/materials/OrthoSegmentMaterial.as: -------------------------------------------------------------------------------- 1 | package away3d.materials 2 | { 3 | import away3d.arcane; 4 | import away3d.materials.passes.OrthoSegmentPass; 5 | 6 | use namespace arcane; 7 | 8 | /** 9 | * OrthoSegmentMaterial is a material exclusively used to render wireframe objects 10 | * 11 | * @see away3d.entities.Lines 12 | */ 13 | public class OrthoSegmentMaterial extends MaterialBase 14 | { 15 | private var _screenPass:OrthoSegmentPass; 16 | 17 | /** 18 | * Creates a new OrthoSegmentMaterial object. 19 | * 20 | * @param thickness The thickness of the wireframe lines. 21 | */ 22 | public function OrthoSegmentMaterial(thickness:Number = 1.25) 23 | { 24 | super(); 25 | 26 | bothSides = true; 27 | addPass(_screenPass = new OrthoSegmentPass(thickness)); 28 | _screenPass.material = this; 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/away3d/animators/nodes/AnimationNodeBase.as: -------------------------------------------------------------------------------- 1 | package away3d.animators.nodes 2 | { 3 | import away3d.library.assets.*; 4 | 5 | /** 6 | * Provides an abstract base class for nodes in an animation blend tree. 7 | */ 8 | public class AnimationNodeBase extends NamedAssetBase implements IAsset 9 | { 10 | protected var _stateClass:Class; 11 | 12 | public function get stateClass():Class 13 | { 14 | return _stateClass; 15 | } 16 | 17 | /** 18 | * Creates a new AnimationNodeBase object. 19 | */ 20 | public function AnimationNodeBase() 21 | { 22 | } 23 | 24 | /** 25 | * @inheritDoc 26 | */ 27 | public function dispose():void 28 | { 29 | } 30 | 31 | /** 32 | * @inheritDoc 33 | */ 34 | public function get assetType():String 35 | { 36 | return AssetType.ANIMATION_NODE; 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/away3d/stereo/methods/StereoRenderMethodBase.as: -------------------------------------------------------------------------------- 1 | package away3d.stereo.methods 2 | { 3 | import away3d.core.managers.Stage3DProxy; 4 | import away3d.errors.AbstractMethodError; 5 | 6 | public class StereoRenderMethodBase 7 | { 8 | protected var _textureSizeInvalid:Boolean = true; 9 | 10 | public function StereoRenderMethodBase() 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 | } 26 | 27 | public function invalidateTextureSize():void 28 | { 29 | _textureSizeInvalid = true; 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/away3d/primitives/LineSegment.as: -------------------------------------------------------------------------------- 1 | package away3d.primitives 2 | { 3 | import away3d.primitives.data.Segment; 4 | 5 | import flash.geom.Vector3D; 6 | 7 | /** 8 | * A Line Segment primitive. 9 | */ 10 | public class LineSegment extends Segment 11 | { 12 | 13 | public const 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 LineSegment(v0:Vector3D, v1:Vector3D, color0:uint = 0x333333, color1:uint = 0x333333, thickness:Number = 1):void 24 | { 25 | super(v0, v1, null, color0, color1, thickness); 26 | } 27 | 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/away3d/animators/data/ParticleAnimationData.as: -------------------------------------------------------------------------------- 1 | package away3d.animators.data 2 | { 3 | import away3d.core.base.data.ParticleData; 4 | 5 | /** 6 | * ... 7 | */ 8 | public class ParticleAnimationData 9 | { 10 | public var index:uint; 11 | public var startTime:Number; 12 | public var totalTime:Number; 13 | public var duration:Number; 14 | public var delay:Number; 15 | public var startVertexIndex:uint; 16 | public var numVertices:uint; 17 | 18 | public function ParticleAnimationData(index:uint, startTime:Number, duration:Number, delay:Number, 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 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/away3d/events/Scene3DEvent.as: -------------------------------------------------------------------------------- 1 | package away3d.events 2 | { 3 | import away3d.containers.ObjectContainer3D; 4 | 5 | import flash.events.Event; 6 | 7 | public class Scene3DEvent extends Event 8 | { 9 | public static const ADDED_TO_SCENE:String = "addedToScene"; 10 | public static const REMOVED_FROM_SCENE:String = "removedFromScene"; 11 | public static const PARTITION_CHANGED:String = "partitionChanged"; 12 | 13 | public var objectContainer3D:ObjectContainer3D; 14 | 15 | override public function get target():Object 16 | { 17 | return objectContainer3D; 18 | } 19 | 20 | public function Scene3DEvent(type:String, objectContainer:ObjectContainer3D) 21 | { 22 | objectContainer3D = objectContainer; 23 | super(type); 24 | } 25 | 26 | public override function clone():Event 27 | { 28 | return new Scene3DEvent(type, objectContainer3D); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/away3d/animators/transitions/CrossfadeTransition.as: -------------------------------------------------------------------------------- 1 | package away3d.animators.transitions 2 | { 3 | import away3d.animators.*; 4 | import away3d.animators.nodes.*; 5 | 6 | public class CrossfadeTransition implements IAnimationTransition 7 | { 8 | public var blendSpeed:Number = 0.5; 9 | 10 | public function CrossfadeTransition(blendSpeed:Number) 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 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/away3d/controllers/FollowController.as: -------------------------------------------------------------------------------- 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 | public class FollowController extends HoverController 13 | { 14 | public function FollowController(targetObject:Entity = null, lookAtObject:ObjectContainer3D = null, tiltAngle:Number = 45, distance:Number = 700) 15 | { 16 | super(targetObject, lookAtObject, 0, tiltAngle, distance); 17 | } 18 | 19 | override public function update(interpolate:Boolean = true):void 20 | { 21 | interpolate = interpolate; // unused: prevents warning 22 | 23 | if (!lookAtObject) 24 | return; 25 | 26 | panAngle = _lookAtObject.rotationY - 180; 27 | super.update(); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/away3d/materials/ColorMultiPassMaterial.as: -------------------------------------------------------------------------------- 1 | package away3d.materials 2 | { 3 | import away3d.arcane; 4 | 5 | use namespace arcane; 6 | 7 | /** 8 | * ColorMultiPassMaterial is a multi-pass material that uses a flat color as the surface's diffuse reflection value. 9 | */ 10 | public class ColorMultiPassMaterial extends MultiPassMaterialBase 11 | { 12 | /** 13 | * Creates a new ColorMultiPassMaterial object. 14 | * 15 | * @param color The material's diffuse surface color. 16 | */ 17 | public function ColorMultiPassMaterial(color:uint = 0xcccccc) 18 | { 19 | super(); 20 | this.color = color; 21 | } 22 | 23 | /** 24 | * The diffuse reflectivity color of the surface. 25 | */ 26 | public function get color():uint 27 | { 28 | return diffuseMethod.diffuseColor; 29 | } 30 | 31 | public function set color(value:uint):void 32 | { 33 | diffuseMethod.diffuseColor = value; 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/away3d/animators/data/ParticlePropertiesMode.as: -------------------------------------------------------------------------------- 1 | package away3d.animators.data 2 | { 3 | 4 | /** 5 | * Options for setting the properties mode of a particle animation node. 6 | */ 7 | public class ParticlePropertiesMode 8 | { 9 | /** 10 | * Mode that defines the particle node as acting on global properties (ie. the properties set in the node constructor or the corresponding animation state). 11 | */ 12 | public static const GLOBAL:uint = 0; 13 | 14 | /** 15 | * 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). 16 | */ 17 | public static const LOCAL_STATIC:uint = 1; 18 | 19 | /** 20 | * Mode that defines the particle node as acting on local dynamic properties (ie. the properties of the particles set in the corresponding animation state). 21 | */ 22 | public static const LOCAL_DYNAMIC:uint = 2; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/away3d/tools/utils/TextureUtils.as: -------------------------------------------------------------------------------- 1 | package away3d.tools.utils 2 | { 3 | import flash.display.BitmapData; 4 | 5 | public class TextureUtils 6 | { 7 | private static const MAX_SIZE:uint = 4096; 8 | 9 | public static function isBitmapDataValid(bitmapData:BitmapData):Boolean 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:uint):Boolean 18 | { 19 | return d >= 1 && d <= MAX_SIZE && isPowerOfTwo(d); 20 | } 21 | 22 | public static function isPowerOfTwo(value:int):Boolean 23 | { 24 | return value? ((value & -value) == value) : false; 25 | } 26 | 27 | public static function getBestPowerOf2(value:uint):uint 28 | { 29 | var p:uint = 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 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/away3d/debug/data/TridentLines.as: -------------------------------------------------------------------------------- 1 | package away3d.debug.data 2 | { 3 | import away3d.entities.SegmentSet; 4 | import away3d.primitives.LineSegment; 5 | 6 | import flash.geom.Vector3D; 7 | 8 | public class TridentLines extends SegmentSet 9 | { 10 | public function TridentLines(vectors:Vector.>, colors:Vector.):void 11 | { 12 | super(); 13 | build(vectors, colors); 14 | } 15 | 16 | private function build(vectors:Vector.>, colors:Vector.):void 17 | { 18 | var letter:Vector.; 19 | var v0:Vector3D; 20 | var v1:Vector3D; 21 | var color:uint; 22 | var j:uint; 23 | 24 | for (var i:uint = 0; i < vectors.length; ++i) { 25 | color = colors[i]; 26 | letter = vectors[i]; 27 | 28 | for (j = 0; j < letter.length; j += 2) { 29 | v0 = letter[j]; 30 | v1 = letter[j + 1]; 31 | addSegment(new LineSegment(v0, v1, color, color, 1)); 32 | } 33 | } 34 | } 35 | 36 | } 37 | } 38 | 39 | -------------------------------------------------------------------------------- /src/away3d/library/naming/ConflictPrecedence.as: -------------------------------------------------------------------------------- 1 | package away3d.library.naming 2 | { 3 | 4 | /** 5 | * Enumaration class for precedence when resolving naming conflicts in the library. 6 | * 7 | * @see away3d.library.AssetLibrary.conflictPrecedence 8 | * @see away3d.library.AssetLibrary.conflictStrategy 9 | * @see away3d.library.naming.ConflictStrategy 10 | */ 11 | public class ConflictPrecedence 12 | { 13 | /** 14 | * Signals that in a conflict, the previous owner of the conflicting name 15 | * should be favored (and keep it's name) and that the newly renamed asset 16 | * is reverted to a non-conflicting name. 17 | */ 18 | public static const FAVOR_OLD:String = 'favorOld'; 19 | 20 | /** 21 | * Signales that in a conflict, the newly renamed asset is favored (and keeps 22 | * it's newly defined name) and that the previous owner of that name gets 23 | * renamed to a non-conflicting name. 24 | */ 25 | public static const FAVOR_NEW:String = 'favorNew'; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/away3d/debug/Debug.as: -------------------------------------------------------------------------------- 1 | package away3d.debug 2 | { 3 | 4 | /** Class for emmiting debuging messages, warnings and errors */ 5 | public class Debug 6 | { 7 | public static var active:Boolean = false; 8 | public static var warningsAsErrors:Boolean = false; 9 | 10 | public static function clear():void 11 | { 12 | } 13 | 14 | public static function delimiter():void 15 | { 16 | } 17 | 18 | public static function trace(message:Object):void 19 | { 20 | if (active) 21 | dotrace(message); 22 | } 23 | 24 | public static function warning(message:Object):void 25 | { 26 | if (warningsAsErrors) { 27 | error(message); 28 | return; 29 | } 30 | trace("WARNING: " + message); 31 | } 32 | 33 | public static function error(message:Object):void 34 | { 35 | trace("ERROR: " + message); 36 | throw new Error(message); 37 | } 38 | } 39 | } 40 | 41 | /** 42 | * @private 43 | */ 44 | function dotrace(message:Object):void 45 | { 46 | trace(message); 47 | } 48 | -------------------------------------------------------------------------------- /src/away3d/animators/data/SkeletonJoint.as: -------------------------------------------------------------------------------- 1 | package away3d.animators.data 2 | { 3 | 4 | /** 5 | * A value obect representing a single joint in a skeleton object. 6 | * 7 | * @see away3d.animators.data.Skeleton 8 | */ 9 | public class SkeletonJoint 10 | { 11 | /** 12 | * The index of the parent joint in the skeleton's joints vector. 13 | * 14 | * @see away3d.animators.data.Skeleton#joints 15 | */ 16 | public var parentIndex:int = -1; 17 | 18 | /** 19 | * The name of the joint 20 | */ 21 | public var name:String; // intention is that this should be used only at load time, not in the main loop 22 | 23 | /** 24 | * The inverse bind pose matrix, as raw data, used to transform vertices to bind joint space in preparation for transformation using the joint matrix. 25 | */ 26 | public var inverseBindPose:Vector.; 27 | 28 | /** 29 | * Creates a new SkeletonJoint object 30 | */ 31 | public function SkeletonJoint() 32 | { 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/away3d/animators/states/IUVAnimationState.as: -------------------------------------------------------------------------------- 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 | public 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 | function get currentUVFrame():UVAnimationFrame; 16 | 17 | /** 18 | * Returns the next UV frame of animation in the clip based on the internal playhead position. 19 | */ 20 | function get nextUVFrame():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 | function get blendWeight():Number; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/away3d/materials/methods/MethodVOSet.as: -------------------------------------------------------------------------------- 1 | package away3d.materials.methods 2 | { 3 | import away3d.arcane; 4 | 5 | /** 6 | * MethodVOSet provides a EffectMethodBase and MethodVO combination to be used by a material, allowing methods 7 | * to be shared across different materials while their internal state changes. 8 | */ 9 | public class MethodVOSet 10 | { 11 | use namespace arcane; 12 | 13 | /** 14 | * An instance of a concrete EffectMethodBase subclass. 15 | */ 16 | public var method:EffectMethodBase; 17 | 18 | /** 19 | * The MethodVO data for the given method containing the material-specific data for a given material/method combination. 20 | */ 21 | public var data:MethodVO; 22 | 23 | /** 24 | * Creates a new MethodVOSet object. 25 | * @param method The method for which we need to store a MethodVO object. 26 | */ 27 | public function MethodVOSet(method:EffectMethodBase) 28 | { 29 | this.method = method; 30 | data = method.createMethodVO(); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/away3d/core/pick/PickingType.as: -------------------------------------------------------------------------------- 1 | package away3d.core.pick 2 | { 3 | 4 | /** 5 | * Options for the different 3D object picking approaches available in Away3D. Can be used for automatic mouse picking on the view. 6 | * 7 | * @see away3d.containers.View3D#mousePicker 8 | */ 9 | public class PickingType 10 | { 11 | /** 12 | * Uses a render pass to pick objects based on a key color that is read back into the engine. 13 | * Performance can be variable on some GPUs. 14 | */ 15 | public static const SHADER:IPicker = new ShaderPicker(); 16 | 17 | /** 18 | * Uses AS3 and Pixel Bender to pick objects based on ray intersection. Returns the hit on the first encountered Entity. 19 | */ 20 | public static const RAYCAST_FIRST_ENCOUNTERED:IPicker = new RaycastPicker(false); 21 | 22 | /** 23 | * Uses AS3 and Pixel Bender to pick objects based on ray intersection. Returns the best (closest) hit on an Entity. 24 | */ 25 | public static const RAYCAST_BEST_HIT:IPicker = new RaycastPicker(true); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/away3d/animators/states/IVertexAnimationState.as: -------------------------------------------------------------------------------- 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 | public 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 | function get currentGeometry():Geometry; 16 | 17 | /** 18 | * Returns the current geometry frame of animation in the clip based on the internal playhead position. 19 | */ 20 | function get nextGeometry():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 | function get blendWeight():Number; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/away3d/core/partition/LightProbeNode.as: -------------------------------------------------------------------------------- 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 | public class LightProbeNode extends EntityNode 10 | { 11 | private var _light:LightProbe; 12 | 13 | /** 14 | * Creates a new LightNode object. 15 | * @param light The light to be contained in the node. 16 | */ 17 | public function LightProbeNode(light:LightProbe) 18 | { 19 | super(light); 20 | _light = light; 21 | } 22 | 23 | /** 24 | * The light object contained in this node. 25 | */ 26 | public function get light():LightProbe 27 | { 28 | return _light; 29 | } 30 | 31 | /** 32 | * @inheritDoc 33 | */ 34 | override public function acceptTraverser(traverser:PartitionTraverser):void 35 | { 36 | if (traverser.enterNode(this)) { 37 | super.acceptTraverser(traverser); 38 | traverser.applyLightProbe(_light); 39 | } 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/away3d/core/partition/PointLightNode.as: -------------------------------------------------------------------------------- 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 | public class PointLightNode extends EntityNode 10 | { 11 | private var _light:PointLight; 12 | 13 | /** 14 | * Creates a new LightNode object. 15 | * @param light The light to be contained in the node. 16 | */ 17 | public function PointLightNode(light:PointLight) 18 | { 19 | super(light); 20 | _light = light; 21 | } 22 | 23 | /** 24 | * The light object contained in this node. 25 | */ 26 | public function get light():PointLight 27 | { 28 | return _light; 29 | } 30 | 31 | /** 32 | * @inheritDoc 33 | */ 34 | override public function acceptTraverser(traverser:PartitionTraverser):void 35 | { 36 | if (traverser.enterNode(this)) { 37 | super.acceptTraverser(traverser); 38 | traverser.applyPointLight(_light); 39 | } 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/away3d/animators/nodes/SkeletonBinaryLERPNode.as: -------------------------------------------------------------------------------- 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 | public 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 SkeletonBinaryLERPNode() 25 | { 26 | _stateClass = SkeletonBinaryLERPState; 27 | } 28 | 29 | /** 30 | * @inheritDoc 31 | */ 32 | public function getAnimationState(animator:IAnimator):SkeletonBinaryLERPState 33 | { 34 | return animator.getAnimationState(this) as SkeletonBinaryLERPState; 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/away3d/core/partition/LightNode.as: -------------------------------------------------------------------------------- 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 | public class LightNode extends EntityNode 10 | { 11 | private var _light:LightBase; 12 | 13 | /** 14 | * Creates a new LightNode object. 15 | * @param light The light to be contained in the node. 16 | */ 17 | public function LightNode(light:LightBase) 18 | { 19 | super(light); 20 | _light = light; 21 | } 22 | 23 | /** 24 | * The light object contained in this node. 25 | */ 26 | public function get light():LightBase 27 | { 28 | return _light; 29 | } 30 | 31 | /** 32 | * @inheritDoc 33 | */ 34 | override public function acceptTraverser(traverser:PartitionTraverser):void 35 | { 36 | if (traverser.enterNode(this)) { 37 | super.acceptTraverser(traverser); 38 | traverser.applyUnknownLight(_light); 39 | } 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/away3d/core/partition/DirectionalLightNode.as: -------------------------------------------------------------------------------- 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 | public class DirectionalLightNode extends EntityNode 10 | { 11 | private var _light:DirectionalLight; 12 | 13 | /** 14 | * Creates a new LightNode object. 15 | * @param light The light to be contained in the node. 16 | */ 17 | public function DirectionalLightNode(light:DirectionalLight) 18 | { 19 | super(light); 20 | _light = light; 21 | } 22 | 23 | /** 24 | * The light object contained in this node. 25 | */ 26 | public function get light():DirectionalLight 27 | { 28 | return _light; 29 | } 30 | 31 | /** 32 | * @inheritDoc 33 | */ 34 | override public function acceptTraverser(traverser:PartitionTraverser):void 35 | { 36 | if (traverser.enterNode(this)) { 37 | super.acceptTraverser(traverser); 38 | traverser.applyDirectionalLight(_light); 39 | } 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/away3d/animators/nodes/SkeletonDifferenceNode.as: -------------------------------------------------------------------------------- 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 | public 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 SkeletonDifferenceNode() 25 | { 26 | _stateClass = SkeletonDifferenceState; 27 | } 28 | 29 | /** 30 | * @inheritDoc 31 | */ 32 | public function getAnimationState(animator:IAnimator):SkeletonDifferenceState 33 | { 34 | return animator.getAnimationState(this) as SkeletonDifferenceState; 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/away3d/core/partition/SkyBoxNode.as: -------------------------------------------------------------------------------- 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 | /** 8 | * SkyBoxNode is a space partitioning leaf node that contains a SkyBox object. 9 | */ 10 | public class SkyBoxNode extends EntityNode 11 | { 12 | private var _skyBox:SkyBox; 13 | 14 | /** 15 | * Creates a new SkyBoxNode object. 16 | * @param skyBox The SkyBox to be contained in the node. 17 | */ 18 | public function SkyBoxNode(skyBox:SkyBox) 19 | { 20 | super(skyBox); 21 | _skyBox = skyBox; 22 | } 23 | 24 | /** 25 | * @inheritDoc 26 | */ 27 | override public function acceptTraverser(traverser:PartitionTraverser):void 28 | { 29 | if (traverser.enterNode(this)) { 30 | super.acceptTraverser(traverser); 31 | traverser.applySkyBox(_skyBox); 32 | } 33 | } 34 | 35 | override public function isInFrustum(planes:Vector., numPlanes:int):Boolean 36 | { 37 | planes = planes; 38 | numPlanes = numPlanes; 39 | return true; 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/away3d/library/assets/IAsset.as: -------------------------------------------------------------------------------- 1 | package away3d.library.assets 2 | { 3 | import flash.events.IEventDispatcher; 4 | 5 | public interface IAsset extends IEventDispatcher 6 | { 7 | /** 8 | * The name of the asset. 9 | */ 10 | function get name():String; 11 | 12 | function set name(val:String):void; 13 | 14 | /** 15 | * The id of the asset. 16 | */ 17 | function get id():String; 18 | 19 | function set id(val:String):void; 20 | 21 | /** 22 | * The namespace of the asset. This allows several assets with the same name to coexist in different contexts. 23 | */ 24 | function get assetNamespace():String; 25 | 26 | /** 27 | * The type of the asset. 28 | */ 29 | function get assetType():String; 30 | 31 | /** 32 | * The full path of the asset. 33 | */ 34 | function get assetFullPath():Array; 35 | 36 | function assetPathEquals(name:String, ns:String):Boolean; 37 | 38 | function resetAssetPath(name:String, ns:String = null, overrideOriginal:Boolean = true):void; 39 | 40 | /** 41 | * Cleans up resources used by this asset. 42 | */ 43 | function dispose():void; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/away3d/core/partition/RenderableNode.as: -------------------------------------------------------------------------------- 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 | public 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 RenderableNode(renderable:IRenderable) 20 | { 21 | super(Entity(renderable)); 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 | 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/away3d/stereo/methods/AnaglyphStereoRenderMethod.as: -------------------------------------------------------------------------------- 1 | package away3d.stereo.methods 2 | { 3 | import away3d.core.managers.Stage3DProxy; 4 | 5 | import flash.display3D.Context3DProgramType; 6 | 7 | public class AnaglyphStereoRenderMethod extends StereoRenderMethodBase 8 | { 9 | private var _filterData:Vector.; 10 | 11 | public function AnaglyphStereoRenderMethod() 12 | { 13 | super(); 14 | 15 | _filterData = new [ 16 | 1.0, 0.0, 0.0, 1.0, 17 | 0.0, 1.0, 1.0, 1.0, 18 | 1.0, 1.0, 1.0, 1.0]; 19 | } 20 | 21 | override public function activate(stage3DProxy:Stage3DProxy):void 22 | { 23 | stage3DProxy.context3D.setProgramConstantsFromVector(Context3DProgramType.FRAGMENT, 0, _filterData, 3); 24 | } 25 | 26 | override public function getFragmentCode():String 27 | { 28 | return "tex ft0, v1, fs0 <2d,linear,nomip>\n" + 29 | "tex ft1, v1, fs1 <2d,linear,nomip>\n" + 30 | "mul ft0, ft0, fc0\n" + 31 | "sub ft0, fc2, ft0\n" + 32 | "mul ft1, ft1, fc1\n" + 33 | "sub ft1, fc2, ft1\n" + 34 | "mul ft2, ft0, ft1\n" + 35 | "div ft2, ft2, fc2\n" + 36 | "sub oc, fc2, ft2"; 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/away3d/primitives/data/NURBSVertex.as: -------------------------------------------------------------------------------- 1 | package away3d.primitives.data 2 | { 3 | import away3d.core.base.data.Vertex; 4 | import away3d.arcane; 5 | 6 | use namespace arcane; 7 | 8 | /** 9 | * A nurbvertex that simply extends vertex with a w weight property. 10 | * Properties x, y, z and w represent a 3d point in space with nurb weighting. 11 | */ 12 | public class NURBSVertex extends Vertex 13 | { 14 | 15 | private var _w:Number; 16 | 17 | public function get w():Number 18 | { 19 | return _w; 20 | } 21 | 22 | public function set w(w:Number):void 23 | { 24 | _w = w; 25 | } 26 | 27 | /** 28 | * Creates a new Vertex object. 29 | * 30 | * @param x [optional] The local x position of the vertex. Defaults to 0. 31 | * @param y [optional] The local y position of the vertex. Defaults to 0. 32 | * @param z [optional] The local z position of the vertex. Defaults to 0. 33 | * @param w [optional] The local w weight of the vertex. Defaults to 1. 34 | */ 35 | public function NURBSVertex(x:Number = 0, y:Number = 0, z:Number = 0, w:Number = 1) 36 | { 37 | _w = w; 38 | super(x, y, z); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/away3d/tools/helpers/data/ParticleGeometryTransform.as: -------------------------------------------------------------------------------- 1 | package away3d.tools.helpers.data 2 | { 3 | import flash.geom.Matrix; 4 | import flash.geom.Matrix3D; 5 | 6 | /** 7 | * ... 8 | */ 9 | public class ParticleGeometryTransform 10 | { 11 | private var _defaultVertexTransform:Matrix3D; 12 | private var _defaultInvVertexTransform:Matrix3D; 13 | private var _defaultUVTransform:Matrix; 14 | 15 | public function ParticleGeometryTransform() 16 | { 17 | } 18 | 19 | public function set vertexTransform(value:Matrix3D):void 20 | { 21 | _defaultVertexTransform = value; 22 | _defaultInvVertexTransform = value.clone(); 23 | _defaultInvVertexTransform.invert(); 24 | _defaultInvVertexTransform.transpose(); 25 | } 26 | 27 | public function set UVTransform(value:Matrix):void 28 | { 29 | _defaultUVTransform = value; 30 | } 31 | 32 | public function get UVTransform():Matrix 33 | { 34 | return _defaultUVTransform; 35 | } 36 | 37 | public function get vertexTransform():Matrix3D 38 | { 39 | return _defaultVertexTransform; 40 | } 41 | 42 | public function get invVertexTransform():Matrix3D 43 | { 44 | return _defaultInvVertexTransform; 45 | } 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/away3d/animators/transitions/CrossfadeTransitionState.as: -------------------------------------------------------------------------------- 1 | package away3d.animators.transitions 2 | { 3 | import away3d.animators.*; 4 | import away3d.animators.states.*; 5 | import away3d.events.*; 6 | 7 | /** 8 | * 9 | */ 10 | public class CrossfadeTransitionState extends SkeletonBinaryLERPState 11 | { 12 | private var _skeletonAnimationNode:CrossfadeTransitionNode; 13 | private var _animationStateTransitionComplete:AnimationStateEvent; 14 | 15 | function CrossfadeTransitionState(animator:IAnimator, skeletonAnimationNode:CrossfadeTransitionNode) 16 | { 17 | super(animator, skeletonAnimationNode); 18 | 19 | _skeletonAnimationNode = skeletonAnimationNode; 20 | } 21 | 22 | /** 23 | * @inheritDoc 24 | */ 25 | override protected function updateTime(time:int):void 26 | { 27 | blendWeight = Math.abs(time - _skeletonAnimationNode.startBlend)/(1000*_skeletonAnimationNode.blendSpeed); 28 | 29 | if (blendWeight >= 1) { 30 | blendWeight = 1; 31 | _skeletonAnimationNode.dispatchEvent(_animationStateTransitionComplete ||= new AnimationStateEvent(AnimationStateEvent.TRANSITION_COMPLETE, _animator, this, _skeletonAnimationNode)); 32 | } 33 | 34 | super.updateTime(time); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/away3d/primitives/ConeGeometry.as: -------------------------------------------------------------------------------- 1 | package away3d.primitives 2 | { 3 | 4 | /** 5 | * A UV Cone primitive mesh. 6 | */ 7 | public class ConeGeometry extends CylinderGeometry 8 | { 9 | 10 | /** 11 | * The radius of the bottom end of the cone. 12 | */ 13 | public function get radius():Number 14 | { 15 | return _bottomRadius; 16 | } 17 | 18 | public function set radius(value:Number):void 19 | { 20 | _bottomRadius = value; 21 | invalidateGeometry(); 22 | } 23 | 24 | /** 25 | * Creates a new Cone object. 26 | * @param radius The radius of the bottom end of the cone 27 | * @param height The height of the cone 28 | * @param segmentsW Defines the number of horizontal segments that make up the cone. Defaults to 16. 29 | * @param segmentsH Defines the number of vertical segments that make up the cone. Defaults to 1. 30 | * @param yUp Defines whether the cone poles should lay on the Y-axis (true) or on the Z-axis (false). 31 | */ 32 | public function ConeGeometry(radius:Number = 50, height:Number = 100, segmentsW:uint = 16, segmentsH:uint = 1, closed:Boolean = true, yUp:Boolean = true) 33 | { 34 | super(0, radius, height, segmentsW, segmentsH, false, closed, true, yUp); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/away3d/core/partition/MeshNode.as: -------------------------------------------------------------------------------- 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 | /** 8 | * MeshNode is a space partitioning leaf node that contains a Mesh object. 9 | */ 10 | public class MeshNode extends EntityNode 11 | { 12 | private var _mesh:Mesh; 13 | 14 | /** 15 | * Creates a new MeshNode object. 16 | * @param mesh The mesh to be contained in the node. 17 | */ 18 | public function MeshNode(mesh:Mesh) 19 | { 20 | super(mesh); 21 | _mesh = mesh; // also keep a stronger typed reference 22 | } 23 | 24 | /** 25 | * The mesh object contained in the partition node. 26 | */ 27 | public function get mesh():Mesh 28 | { 29 | return _mesh; 30 | } 31 | 32 | /** 33 | * @inheritDoc 34 | */ 35 | override public function acceptTraverser(traverser:PartitionTraverser):void 36 | { 37 | if (traverser.enterNode(this)) { 38 | super.acceptTraverser(traverser); 39 | var subs:Vector. = _mesh.subMeshes; 40 | var i:uint; 41 | var len:uint = subs.length; 42 | while (i < len) 43 | traverser.applyRenderable(subs[i++]); 44 | } 45 | } 46 | 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/away3d/textures/ATFTexture.as: -------------------------------------------------------------------------------- 1 | package away3d.textures 2 | { 3 | import away3d.arcane; 4 | 5 | import flash.display3D.Context3D; 6 | import flash.display3D.textures.Texture; 7 | import flash.display3D.textures.TextureBase; 8 | import flash.utils.ByteArray; 9 | 10 | use namespace arcane; 11 | 12 | public class ATFTexture extends Texture2DBase 13 | { 14 | private var _atfData:ATFData; 15 | 16 | public function ATFTexture(byteArray:ByteArray) 17 | { 18 | super(); 19 | 20 | atfData = new ATFData(byteArray); 21 | _format = atfData.format; 22 | _hasMipmaps = _atfData.numTextures > 1; 23 | } 24 | 25 | public function get atfData():ATFData 26 | { 27 | return _atfData; 28 | } 29 | 30 | public function set atfData(value:ATFData):void 31 | { 32 | _atfData = value; 33 | 34 | invalidateContent(); 35 | 36 | setSize(value.width, value.height); 37 | } 38 | 39 | override protected function uploadContent(texture:TextureBase):void 40 | { 41 | Texture(texture).uploadCompressedTextureFromByteArray(_atfData.data, 0, false); 42 | } 43 | 44 | override protected function createTexture(context:Context3D):TextureBase 45 | { 46 | return context.createTexture(_width, _height, atfData.format, false); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/away3d/filters/MotionBlurFilter3D.as: -------------------------------------------------------------------------------- 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 | public class MotionBlurFilter3D extends Filter3DBase 9 | { 10 | private var _compositeTask:Filter3DXFadeCompositeTask; 11 | private var _copyTask:Filter3DDoubleBufferCopyTask; 12 | 13 | public function MotionBlurFilter3D(strength:Number = .65) 14 | { 15 | super(); 16 | _compositeTask = new Filter3DXFadeCompositeTask(strength); 17 | _copyTask = new Filter3DDoubleBufferCopyTask(); 18 | 19 | addTask(_compositeTask); 20 | addTask(_copyTask); 21 | } 22 | 23 | public function get strength():Number 24 | { 25 | return _compositeTask.amount; 26 | } 27 | 28 | public function set strength(value:Number):void 29 | { 30 | _compositeTask.amount = value; 31 | } 32 | 33 | override public function update(stage:Stage3DProxy, camera:Camera3D):void 34 | { 35 | // TODO: not used 36 | camera = camera; 37 | 38 | _compositeTask.overlayTexture = _copyTask.getMainInputTexture(stage); 39 | _compositeTask.target = _copyTask.secondaryInputTexture; 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/away3d/loaders/parsers/utils/ParserUtil.as: -------------------------------------------------------------------------------- 1 | package away3d.loaders.parsers.utils 2 | { 3 | import flash.utils.ByteArray; 4 | 5 | public 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:*):ByteArray 17 | { 18 | if (data is Class) 19 | data = new data(); 20 | 21 | if (data is ByteArray) 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:*, length:uint = 0):String 37 | { 38 | var ba:ByteArray; 39 | 40 | length ||= uint.MAX_VALUE; 41 | 42 | if (data is String) 43 | return String(data).substr(0, length); 44 | 45 | ba = toByteArray(data); 46 | if (ba) { 47 | ba.position = 0; 48 | return ba.readUTFBytes(Math.min(ba.bytesAvailable, length)); 49 | } 50 | 51 | return null; 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/away3d/library/assets/BitmapDataAsset.as: -------------------------------------------------------------------------------- 1 | package away3d.library.assets 2 | { 3 | import flash.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 | public class BitmapDataAsset extends NamedAssetBase implements IAsset 10 | { 11 | private var _bitmapData:BitmapData; 12 | 13 | /** 14 | * Creates a new BitmapDataResource object. 15 | * @param bitmapData An optional BitmapData object to use as the resource data. 16 | */ 17 | public function BitmapDataAsset(bitmapData:BitmapData = null) 18 | { 19 | _bitmapData = bitmapData; 20 | } 21 | 22 | /** 23 | * The bitmapData to be treated as a resource. 24 | */ 25 | public function get bitmapData():BitmapData 26 | { 27 | return _bitmapData; 28 | } 29 | 30 | public function set bitmapData(value:BitmapData):void 31 | { 32 | _bitmapData = value; 33 | } 34 | 35 | public function get assetType():String 36 | { 37 | return AssetType.TEXTURE; 38 | } 39 | 40 | /** 41 | * Cleans up any resources used by the current object. 42 | */ 43 | public function dispose():void 44 | { 45 | _bitmapData.dispose(); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/away3d/filters/HBlurFilter3D.as: -------------------------------------------------------------------------------- 1 | package away3d.filters 2 | { 3 | import away3d.filters.tasks.Filter3DHBlurTask; 4 | 5 | public class HBlurFilter3D extends Filter3DBase 6 | { 7 | private var _blurTask:Filter3DHBlurTask; 8 | 9 | /** 10 | * Creates a new HBlurFilter3D object 11 | * @param amount The amount of blur in pixels 12 | * @param stepSize The distance between two blur samples. Set to -1 to autodetect with acceptable quality (default value). 13 | */ 14 | public function HBlurFilter3D(amount:uint, stepSize:int = -1) 15 | { 16 | super(); 17 | _blurTask = new Filter3DHBlurTask(amount, stepSize); 18 | addTask(_blurTask); 19 | } 20 | 21 | public function get amount():uint 22 | { 23 | return _blurTask.amount; 24 | } 25 | 26 | public function set amount(value:uint):void 27 | { 28 | _blurTask.amount = value; 29 | } 30 | 31 | /** 32 | * The distance between two blur samples. Set to -1 to autodetect with acceptable quality (default value). 33 | * Higher values provide better performance at the cost of reduces quality. 34 | */ 35 | public function get stepSize():int 36 | { 37 | return _blurTask.stepSize; 38 | } 39 | 40 | public function set stepSize(value:int):void 41 | { 42 | _blurTask.stepSize = value; 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/away3d/filters/VBlurFilter3D.as: -------------------------------------------------------------------------------- 1 | package away3d.filters 2 | { 3 | import away3d.filters.tasks.Filter3DVBlurTask; 4 | 5 | public class VBlurFilter3D extends Filter3DBase 6 | { 7 | private var _blurTask:Filter3DVBlurTask; 8 | 9 | /** 10 | * Creates a new VBlurFilter3D object 11 | * @param amount The amount of blur in pixels 12 | * @param stepSize The distance between two blur samples. Set to -1 to autodetect with acceptable quality (default value). 13 | */ 14 | public function VBlurFilter3D(amount:uint, stepSize:int = -1) 15 | { 16 | super(); 17 | _blurTask = new Filter3DVBlurTask(amount, stepSize); 18 | addTask(_blurTask); 19 | } 20 | 21 | public function get amount():uint 22 | { 23 | return _blurTask.amount; 24 | } 25 | 26 | public function set amount(value:uint):void 27 | { 28 | _blurTask.amount = value; 29 | } 30 | 31 | /** 32 | * The distance between two blur samples. Set to -1 to autodetect with acceptable quality (default value). 33 | * Higher values provide better performance at the cost of reduces quality. 34 | */ 35 | public function get stepSize():int 36 | { 37 | return _blurTask.stepSize; 38 | } 39 | 40 | public function set stepSize(value:int):void 41 | { 42 | _blurTask.stepSize = value; 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/away3d/events/ParserEvent.as: -------------------------------------------------------------------------------- 1 | package away3d.events 2 | { 3 | import flash.events.Event; 4 | 5 | public class ParserEvent extends Event 6 | { 7 | private var _message:String; 8 | 9 | /** 10 | * Dispatched when parsing of an asset completed. 11 | */ 12 | public static const PARSE_COMPLETE:String = 'parseComplete'; 13 | 14 | /** 15 | * Dispatched when an error occurs while parsing the data (e.g. because it's 16 | * incorrectly formatted.) 17 | */ 18 | public static const PARSE_ERROR:String = 'parseError'; 19 | 20 | /** 21 | * Dispatched when a parser is ready to have dependencies retrieved and resolved. 22 | * This is an internal event that should rarely (if ever) be listened for by 23 | * external classes. 24 | */ 25 | public static const READY_FOR_DEPENDENCIES:String = 'readyForDependencies'; 26 | 27 | public function ParserEvent(type:String, message:String = '') 28 | { 29 | super(type); 30 | 31 | _message = message; 32 | } 33 | 34 | /** 35 | * Additional human-readable message. Usually supplied for PARSE_ERROR events. 36 | */ 37 | public function get message():String 38 | { 39 | return _message; 40 | } 41 | 42 | public override function clone():Event 43 | { 44 | return new ParserEvent(type, message); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/away3d/materials/SkyBoxMaterial.as: -------------------------------------------------------------------------------- 1 | package away3d.materials 2 | { 3 | import away3d.arcane; 4 | import away3d.materials.passes.SkyBoxPass; 5 | import away3d.textures.CubeTextureBase; 6 | 7 | use namespace arcane; 8 | 9 | /** 10 | * SkyBoxMaterial is a material exclusively used to render skyboxes 11 | * 12 | * @see away3d.primitives.SkyBox 13 | */ 14 | public class SkyBoxMaterial extends MaterialBase 15 | { 16 | private var _cubeMap:CubeTextureBase; 17 | private var _skyboxPass:SkyBoxPass; 18 | 19 | /** 20 | * Creates a new SkyBoxMaterial object. 21 | * @param cubeMap The CubeMap to use as the skybox. 22 | */ 23 | public function SkyBoxMaterial(cubeMap:CubeTextureBase) 24 | { 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 | public function get cubeMap():CubeTextureBase 34 | { 35 | return _cubeMap; 36 | } 37 | 38 | public function set cubeMap(value:CubeTextureBase):void 39 | { 40 | if (value && _cubeMap && (value.hasMipMaps != _cubeMap.hasMipMaps || value.format != _cubeMap.format)) 41 | invalidatePasses(null); 42 | 43 | _cubeMap = value; 44 | 45 | _skyboxPass.cubeTexture = _cubeMap; 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/away3d/materials/LightSources.as: -------------------------------------------------------------------------------- 1 | package away3d.materials 2 | { 3 | 4 | /** 5 | * Enumeration class for defining which lighting types affect the specific material 6 | * lighting component (diffuse and specular). This can be useful if, for example, you 7 | * want to use light probes for diffuse global lighting, but want specular reflections from 8 | * traditional light sources without those affecting the diffuse light. 9 | * 10 | * @see away3d.materials.ColorMaterial.diffuseLightSources 11 | * @see away3d.materials.ColorMaterial.specularLightSources 12 | * @see away3d.materials.TextureMaterial.diffuseLightSources 13 | * @see away3d.materials.TextureMaterial.specularLightSources 14 | */ 15 | public class LightSources 16 | { 17 | /** 18 | * Defines normal lights are to be used as the source for the lighting 19 | * component. 20 | */ 21 | public static const LIGHTS:uint = 0x01; 22 | 23 | /** 24 | * Defines that global lighting probes are to be used as the source for the 25 | * lighting component. 26 | */ 27 | public static const PROBES:uint = 0x02; 28 | 29 | /** 30 | * Defines that both normal and global lighting probes are to be used as the 31 | * source for the lighting component. This is equivalent to LIGHTS | PROBES. 32 | */ 33 | public static const ALL:uint = 0x03; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/away3d/animators/nodes/SkeletonDirectionalNode.as: -------------------------------------------------------------------------------- 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 | public 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 SkeletonDirectionalNode() 32 | { 33 | _stateClass = SkeletonDirectionalState; 34 | } 35 | 36 | /** 37 | * @inheritDoc 38 | */ 39 | public function getAnimationState(animator:IAnimator):SkeletonDirectionalState 40 | { 41 | return animator.getAnimationState(this) as SkeletonDirectionalState; 42 | } 43 | 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/away3d/library/assets/AssetType.as: -------------------------------------------------------------------------------- 1 | package away3d.library.assets 2 | { 3 | 4 | public class AssetType 5 | { 6 | public static const ENTITY:String = 'entity'; 7 | public static const SKYBOX:String = 'skybox'; 8 | public static const CAMERA:String = 'camera'; 9 | public static const SEGMENT_SET:String = 'segmentSet'; 10 | public static const MESH:String = 'mesh'; 11 | public static const GEOMETRY:String = 'geometry'; 12 | public static const SKELETON:String = 'skeleton'; 13 | public static const SKELETON_POSE:String = 'skeletonPose'; 14 | public static const CONTAINER:String = 'container'; 15 | public static const TEXTURE:String = 'texture';; 16 | public static const TEXTURE_PROJECTOR:String = 'textureProjector'; 17 | public static const MATERIAL:String = 'material'; 18 | public static const ANIMATION_SET:String = 'animationSet'; 19 | public static const ANIMATION_STATE:String = 'animationState'; 20 | public static const ANIMATION_NODE:String = 'animationNode'; 21 | public static const ANIMATOR:String = 'animator'; 22 | public static const STATE_TRANSITION:String = 'stateTransition'; 23 | public static const LIGHT:String = 'light'; 24 | public static const LIGHT_PICKER:String = 'lightPicker'; 25 | public static const SHADOW_MAP_METHOD:String = 'shadowMapMethod'; 26 | public static const EFFECTS_METHOD:String = 'effectsMethod'; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/away3d/materials/compilation/ShaderRegisterData.as: -------------------------------------------------------------------------------- 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 | public 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 ShaderRegisterData() 29 | { 30 | 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/away3d/textures/ATFCubeTexture.as: -------------------------------------------------------------------------------- 1 | package away3d.textures 2 | { 3 | import away3d.arcane; 4 | 5 | import flash.display3D.Context3D; 6 | import flash.display3D.textures.CubeTexture; 7 | import flash.display3D.textures.TextureBase; 8 | import flash.utils.ByteArray; 9 | 10 | use namespace arcane; 11 | 12 | public class ATFCubeTexture extends CubeTextureBase 13 | { 14 | private var _atfData:ATFData; 15 | 16 | public function ATFCubeTexture(byteArray:ByteArray) 17 | { 18 | super(); 19 | atfData = new ATFData(byteArray); 20 | if (atfData.type != ATFData.TYPE_CUBE) 21 | throw new Error("ATF isn't cubetexture"); 22 | _format = atfData.format; 23 | _hasMipmaps = _atfData.numTextures > 1; 24 | } 25 | 26 | public function get atfData():ATFData 27 | { 28 | return _atfData; 29 | } 30 | 31 | public function set atfData(value:ATFData):void 32 | { 33 | _atfData = value; 34 | 35 | invalidateContent(); 36 | 37 | setSize(value.width, value.height); 38 | } 39 | 40 | override protected function uploadContent(texture:TextureBase):void 41 | { 42 | CubeTexture(texture).uploadCompressedTextureFromByteArray(_atfData.data, 0, false); 43 | } 44 | 45 | override protected function createTexture(context:Context3D):TextureBase 46 | { 47 | return context.createCubeTexture(_atfData.width, _atfData.format, false); 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/away3d/animators/data/ParticleProperties.as: -------------------------------------------------------------------------------- 1 | package away3d.animators.data 2 | { 3 | 4 | /** 5 | * Dynamic class for holding the local properties of a particle, used for processing the static properties 6 | * of particles in the particle animation set before beginning upload to the GPU. 7 | */ 8 | dynamic public class ParticleProperties 9 | { 10 | /** 11 | * The index of the current particle being set. 12 | */ 13 | public var index:uint; 14 | 15 | /** 16 | * The total number of particles being processed by the particle animation set. 17 | */ 18 | public var total:uint; 19 | 20 | /** 21 | * The start time of the particle. 22 | */ 23 | public var startTime:Number; 24 | 25 | /** 26 | * The duration of the particle, an optional value used when the particle aniamtion set settings for useDuration are enabled in the constructor. 27 | * 28 | * @see away3d.animators.ParticleAnimationSet 29 | */ 30 | public var duration:Number; 31 | 32 | /** 33 | * 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. 34 | * 35 | * @see away3d.animators.ParticleAnimationSet 36 | */ 37 | public var delay:Number; 38 | 39 | public function ParticleProperties() 40 | { 41 | 42 | } 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/away3d/materials/methods/EffectMethodBase.as: -------------------------------------------------------------------------------- 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 | use namespace arcane; 9 | 10 | /** 11 | * EffectMethodBase forms an abstract base class for shader methods that are not dependent on light sources, 12 | * and are in essence post-process effects on the materials. 13 | */ 14 | public class EffectMethodBase extends ShadingMethodBase implements IAsset 15 | { 16 | public function EffectMethodBase() 17 | { 18 | super(); 19 | } 20 | 21 | /** 22 | * @inheritDoc 23 | */ 24 | public function get assetType():String 25 | { 26 | return AssetType.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 | arcane function getFragmentCode(vo:MethodVO, regCache:ShaderRegisterCache, targetReg:ShaderRegisterElement):String 37 | { 38 | throw new AbstractMethodError(); 39 | return ""; 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/away3d/core/pick/IPickingCollider.as: -------------------------------------------------------------------------------- 1 | package away3d.core.pick 2 | { 3 | import away3d.core.base.SubMesh; 4 | 5 | import flash.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 | public 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:Number):Boolean 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/away3d/cameras/lenses/FreeMatrixLens.as: -------------------------------------------------------------------------------- 1 | package away3d.cameras.lenses 2 | { 3 | import away3d.arcane; 4 | 5 | use namespace arcane; 6 | 7 | /** 8 | * FreeMatrixLens provides a projection lens that exposes a full projection matrix, rather than provide one through 9 | * more user-friendly settings. Whenever the matrix is updated, it needs to be reset in order to trigger an update. 10 | */ 11 | public class FreeMatrixLens extends LensBase 12 | { 13 | /** 14 | * Creates a new FreeMatrixLens object. 15 | */ 16 | public function FreeMatrixLens() 17 | { 18 | super(); 19 | _matrix.copyFrom(new PerspectiveLens().matrix); 20 | } 21 | 22 | override public function set near(value:Number):void 23 | { 24 | _near = value; 25 | } 26 | 27 | override public function set far(value:Number):void 28 | { 29 | _far = value; 30 | } 31 | 32 | arcane override function set aspectRatio(value:Number):void 33 | { 34 | _aspectRatio = value; 35 | } 36 | 37 | override public function clone():LensBase 38 | { 39 | var clone:FreeMatrixLens = new FreeMatrixLens(); 40 | clone._matrix.copyFrom(_matrix); 41 | clone._near = _near; 42 | clone._far = _far; 43 | clone._aspectRatio = _aspectRatio; 44 | clone.invalidateMatrix(); 45 | return clone; 46 | } 47 | 48 | override protected function updateMatrix():void 49 | { 50 | _matrixInvalid = false; 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/away3d/animators/states/ParticleUVState.as: -------------------------------------------------------------------------------- 1 | package away3d.animators.states 2 | { 3 | import flash.geom.Vector3D; 4 | 5 | import away3d.arcane; 6 | import away3d.cameras.Camera3D; 7 | import away3d.animators.data.AnimationRegisterCache; 8 | import away3d.animators.data.AnimationSubGeometry; 9 | import away3d.core.base.IRenderable; 10 | import away3d.core.managers.Stage3DProxy; 11 | import away3d.animators.nodes.ParticleUVNode; 12 | import away3d.animators.ParticleAnimator; 13 | 14 | use namespace arcane; 15 | 16 | /** 17 | * ... 18 | */ 19 | public class ParticleUVState extends ParticleStateBase 20 | { 21 | 22 | private var _particleUVNode:ParticleUVNode; 23 | 24 | public function ParticleUVState(animator:ParticleAnimator, particleUVNode:ParticleUVNode) 25 | { 26 | super(animator, particleUVNode); 27 | 28 | _particleUVNode = particleUVNode; 29 | } 30 | 31 | override public function setRenderState(stage3DProxy:Stage3DProxy, renderable:IRenderable, animationSubGeometry:AnimationSubGeometry, animationRegisterCache:AnimationRegisterCache, camera:Camera3D):void 32 | { 33 | if (animationRegisterCache.needUVAnimation) { 34 | var index:int = animationRegisterCache.getRegisterIndex(_animationNode, ParticleUVNode.UV_INDEX); 35 | var data:Vector3D = _particleUVNode._uvData; 36 | animationRegisterCache.setVertexConst(index, data.x, data.y); 37 | } 38 | } 39 | 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/away3d/lights/shadowmaps/NearDirectionalShadowMapper.as: -------------------------------------------------------------------------------- 1 | package away3d.lights.shadowmaps 2 | { 3 | import away3d.arcane; 4 | import away3d.cameras.Camera3D; 5 | 6 | use namespace arcane; 7 | 8 | public class NearDirectionalShadowMapper extends DirectionalShadowMapper 9 | { 10 | private var _coverageRatio:Number; 11 | 12 | public function NearDirectionalShadowMapper(coverageRatio:Number = .5) 13 | { 14 | super(); 15 | this.coverageRatio = coverageRatio; 16 | } 17 | 18 | /** 19 | * A value between 0 and 1 to indicate the ratio of the view frustum that needs to be covered by the shadow map. 20 | */ 21 | public function get coverageRatio():Number 22 | { 23 | return _coverageRatio; 24 | } 25 | 26 | public function set coverageRatio(value:Number):void 27 | { 28 | if (value > 1) 29 | value = 1; 30 | else if (value < 0) 31 | value = 0; 32 | 33 | _coverageRatio = value; 34 | } 35 | 36 | override protected function updateDepthProjection(viewCamera:Camera3D):void 37 | { 38 | var corners:Vector. = viewCamera.lens.frustumCorners; 39 | 40 | for (var i:int = 0; i < 12; ++i) { 41 | var v:Number = corners[i]; 42 | _localFrustum[i] = v; 43 | _localFrustum[uint(i + 12)] = v + (corners[uint(i + 12)] - v)*_coverageRatio; 44 | } 45 | 46 | updateProjectionFromFrustumCorners(viewCamera, _localFrustum, _matrix); 47 | _overallDepthLens.matrix = _matrix; 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/away3d/core/base/data/UV.as: -------------------------------------------------------------------------------- 1 | package away3d.core.base.data 2 | { 3 | 4 | /** 5 | * Texture coordinates value object. 6 | */ 7 | public class UV 8 | { 9 | private var _u:Number; 10 | private var _v:Number; 11 | 12 | /** 13 | * Creates a new UV object. 14 | * 15 | * @param u [optional] The horizontal coordinate of the texture value. Defaults to 0. 16 | * @param v [optional] The vertical coordinate of the texture value. Defaults to 0. 17 | */ 18 | public function UV(u:Number = 0, v:Number = 0) 19 | { 20 | _u = u; 21 | _v = v; 22 | } 23 | 24 | /** 25 | * Defines the vertical coordinate of the texture value. 26 | */ 27 | public function get v():Number 28 | { 29 | return _v; 30 | } 31 | 32 | public function set v(value:Number):void 33 | { 34 | _v = value; 35 | } 36 | 37 | /** 38 | * Defines the horizontal coordinate of the texture value. 39 | */ 40 | public function get u():Number 41 | { 42 | return _u; 43 | } 44 | 45 | public function set u(value:Number):void 46 | { 47 | _u = value; 48 | } 49 | 50 | /** 51 | * returns a new UV value Object 52 | */ 53 | public function clone():UV 54 | { 55 | return new UV(_u, _v); 56 | } 57 | 58 | /** 59 | * returns the value object as a string for trace/debug purpose 60 | */ 61 | public function toString():String 62 | { 63 | return _u + "," + _v; 64 | } 65 | 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/away3d/textures/RenderCubeTexture.as: -------------------------------------------------------------------------------- 1 | package away3d.textures 2 | { 3 | import away3d.arcane; 4 | import away3d.materials.utils.MipmapGenerator; 5 | import away3d.tools.utils.TextureUtils; 6 | 7 | import flash.display.BitmapData; 8 | import flash.display3D.Context3D; 9 | import flash.display3D.Context3DTextureFormat; 10 | import flash.display3D.textures.TextureBase; 11 | 12 | use namespace arcane; 13 | 14 | public class RenderCubeTexture extends CubeTextureBase 15 | { 16 | public function RenderCubeTexture(size:Number) 17 | { 18 | super(); 19 | setSize(size, size); 20 | } 21 | 22 | public function set size(value:int):void 23 | { 24 | if (value == _width) 25 | return; 26 | 27 | if (!TextureUtils.isDimensionValid(value)) 28 | throw new Error("Invalid size: Width and height must be power of 2 and cannot exceed 2048"); 29 | 30 | invalidateContent(); 31 | setSize(value, value); 32 | } 33 | 34 | override protected 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 (var i:int = 0; i < 6; ++i) 39 | MipmapGenerator.generateMipMaps(bmd, texture, null, false, i); 40 | bmd.dispose(); 41 | } 42 | 43 | override protected function createTexture(context:Context3D):TextureBase 44 | { 45 | return context.createCubeTexture(_width, Context3DTextureFormat.BGRA, true); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/away3d/core/pick/IPicker.as: -------------------------------------------------------------------------------- 1 | package away3d.core.pick 2 | { 3 | import away3d.containers.*; 4 | 5 | import flash.geom.*; 6 | 7 | /** 8 | * Provides an interface for picking objects that can pick 3d objects from a view or scene. 9 | */ 10 | public interface IPicker 11 | { 12 | /** 13 | * Gets the collision object from the screen coordinates of the picking ray. 14 | * 15 | * @param x The x coordinate of the picking ray in screen-space. 16 | * @param y The y coordinate of the picking ray in screen-space. 17 | * @param view The view on which the picking object acts. 18 | */ 19 | function getViewCollision(x:Number, y:Number, view:View3D):PickingCollisionVO; 20 | 21 | /** 22 | * Gets the collision object from the scene position and direction of the picking ray. 23 | * 24 | * @param position The position of the picking ray in scene-space. 25 | * @param direction The direction of the picking ray in scene-space. 26 | * @param scene The scene on which the picking object acts. 27 | */ 28 | function getSceneCollision(position:Vector3D, direction:Vector3D, scene:Scene3D):PickingCollisionVO; 29 | 30 | /** 31 | * Determines whether the picker takes account of the mouseEnabled properties of entities. Defaults to true. 32 | */ 33 | function get onlyMouseEnabled():Boolean; 34 | 35 | function set onlyMouseEnabled(value:Boolean):void; 36 | 37 | /** 38 | * Disposes memory used by the IPicker object 39 | */ 40 | function dispose():void; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/away3d/events/AnimatorEvent.as: -------------------------------------------------------------------------------- 1 | package away3d.events 2 | { 3 | import away3d.animators.*; 4 | 5 | import flash.events.*; 6 | 7 | /** 8 | * Dispatched to notify changes in an animator's state. 9 | */ 10 | public class AnimatorEvent extends Event 11 | { 12 | /** 13 | * Defines the value of the type property of a start event object. 14 | */ 15 | public static const START:String = "start"; 16 | 17 | /** 18 | * Defines the value of the type property of a stop event object. 19 | */ 20 | public static const STOP:String = "stop"; 21 | 22 | /** 23 | * Defines the value of the type property of a cycle complete event object. 24 | */ 25 | public static const CYCLE_COMPLETE:String = "cycle_complete"; 26 | 27 | private var _animator:AnimatorBase; 28 | 29 | /** 30 | * Create a new AnimatorEvent object. 31 | * 32 | * @param type The event type. 33 | * @param animator The animator object that is the subject of this event. 34 | */ 35 | public function AnimatorEvent(type:String, animator:AnimatorBase):void 36 | { 37 | super(type, false, false); 38 | _animator = animator; 39 | } 40 | 41 | public function get animator():AnimatorBase 42 | { 43 | return _animator; 44 | } 45 | 46 | /** 47 | * Clones the event. 48 | * 49 | * @return An exact duplicate of the current event object. 50 | */ 51 | override public function clone():Event 52 | { 53 | return new AnimatorEvent(type, _animator); 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/away3d/animators/nodes/SpriteSheetClipNode.as: -------------------------------------------------------------------------------- 1 | package away3d.animators.nodes 2 | { 3 | import away3d.animators.states.*; 4 | import away3d.animators.data.*; 5 | 6 | /** 7 | * A SpriteSheetClipNode containing time-based animation data as individual sprite sheet animation frames. 8 | */ 9 | public class SpriteSheetClipNode extends AnimationClipNodeBase 10 | { 11 | private var _frames:Vector. = new Vector.(); 12 | 13 | /** 14 | * Creates a new SpriteSheetClipNode object. 15 | */ 16 | public function SpriteSheetClipNode() 17 | { 18 | _stateClass = SpriteSheetAnimationState; 19 | } 20 | 21 | /** 22 | * Returns a vector of SpriteSheetAnimationFrame representing the uv values of each animation frame in the clip. 23 | */ 24 | public function get frames():Vector. 25 | { 26 | return _frames; 27 | } 28 | 29 | /** 30 | * Adds a SpriteSheetAnimationFrame object to the internal timeline of the animation node. 31 | * 32 | * @param spriteSheetAnimationFrame The frame object to add to the timeline of the node. 33 | * @param duration The specified duration of the frame in milliseconds. 34 | */ 35 | public function addFrame(spriteSheetAnimationFrame:SpriteSheetAnimationFrame, duration:uint):void 36 | { 37 | _frames.push(spriteSheetAnimationFrame); 38 | _durations.push(duration); 39 | _numFrames = _durations.length; 40 | 41 | _stitchDirty = false; 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/away3d/core/partition/ViewVolumePartition.as: -------------------------------------------------------------------------------- 1 | package away3d.core.partition 2 | { 3 | import away3d.arcane; 4 | import away3d.entities.Entity; 5 | 6 | use namespace arcane; 7 | 8 | public class ViewVolumePartition extends Partition3D 9 | { 10 | public function ViewVolumePartition() 11 | { 12 | super(new ViewVolumeRootNode()); 13 | } 14 | 15 | override arcane function markForUpdate(entity:Entity):void 16 | { 17 | // ignore if static, will be handled separately by visibility list 18 | if (!entity.staticNode) 19 | super.markForUpdate(entity); 20 | } 21 | 22 | /** 23 | * Adds a view volume to provide visibility info for a given region. 24 | */ 25 | public function addViewVolume(viewVolume:ViewVolume):void 26 | { 27 | ViewVolumeRootNode(_rootNode).addViewVolume(viewVolume); 28 | } 29 | 30 | public function removeViewVolume(viewVolume:ViewVolume):void 31 | { 32 | ViewVolumeRootNode(_rootNode).removeViewVolume(viewVolume); 33 | } 34 | 35 | /** 36 | * A dynamic grid to be able to determine visibility of dynamic objects. If none is provided, dynamic objects are only frustum-culled. 37 | * If provided, ViewVolumes need to have visible grid cells assigned from the same DynamicGrid instance. 38 | */ 39 | public function get dynamicGrid():DynamicGrid 40 | { 41 | return ViewVolumeRootNode(_rootNode).dynamicGrid; 42 | } 43 | 44 | public function set dynamicGrid(value:DynamicGrid):void 45 | { 46 | ViewVolumeRootNode(_rootNode).dynamicGrid = value; 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/away3d/animators/states/ParticleRotateToHeadingState.as: -------------------------------------------------------------------------------- 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 flash.geom.Matrix3D; 13 | 14 | import away3d.arcane; 15 | 16 | use namespace arcane; 17 | 18 | /** 19 | * ... 20 | */ 21 | public class ParticleRotateToHeadingState extends ParticleStateBase 22 | { 23 | 24 | private var _matrix:Matrix3D = new Matrix3D; 25 | 26 | public function ParticleRotateToHeadingState(animator:ParticleAnimator, particleNode:ParticleNodeBase) 27 | { 28 | super(animator, particleNode); 29 | } 30 | 31 | override public function setRenderState(stage3DProxy:Stage3DProxy, renderable:IRenderable, animationSubGeometry:AnimationSubGeometry, animationRegisterCache:AnimationRegisterCache, camera:Camera3D):void 32 | { 33 | if (animationRegisterCache.hasBillboard) { 34 | _matrix.copyFrom(renderable.getRenderSceneTransform(camera)); 35 | _matrix.append(camera.inverseSceneTransform); 36 | animationRegisterCache.setVertexConstFromMatrix(animationRegisterCache.getRegisterIndex(_animationNode, ParticleRotateToHeadingNode.MATRIX_INDEX), _matrix); 37 | } 38 | } 39 | 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/away3d/filters/HueSaturationFilter3D.as: -------------------------------------------------------------------------------- 1 | package away3d.filters 2 | { 3 | import away3d.filters.tasks.Filter3DHueSaturationTask; 4 | 5 | public class HueSaturationFilter3D extends Filter3DBase 6 | { 7 | private var _hslTask:Filter3DHueSaturationTask; 8 | 9 | public function HueSaturationFilter3D(saturation:Number = 1, r:Number = 1, g:Number = 1, b:Number = 1) 10 | { 11 | super(); 12 | 13 | _hslTask = new Filter3DHueSaturationTask(); 14 | this.saturation = saturation; 15 | this.r = r; 16 | this.g = g; 17 | this.b = b; 18 | addTask(_hslTask); 19 | } 20 | 21 | public function get saturation():Number 22 | { 23 | return _hslTask.saturation; 24 | } 25 | 26 | public function set saturation(value:Number):void 27 | { 28 | if (_hslTask.saturation == value) 29 | return; 30 | _hslTask.saturation = value; 31 | } 32 | 33 | public function get r():Number 34 | { 35 | return _hslTask.r; 36 | } 37 | 38 | public function set r(value:Number):void 39 | { 40 | if (_hslTask.r == value) 41 | return; 42 | _hslTask.r = value; 43 | } 44 | 45 | public function get b():Number 46 | { 47 | return _hslTask.b; 48 | } 49 | 50 | public function set b(value:Number):void 51 | { 52 | if (_hslTask.b == value) 53 | return; 54 | _hslTask.b = value; 55 | } 56 | 57 | public function get g():Number 58 | { 59 | return _hslTask.g; 60 | } 61 | 62 | public function set g(value:Number):void 63 | { 64 | if (_hslTask.g == value) 65 | return; 66 | _hslTask.g = value; 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/away3d/primitives/RegularPolygonGeometry.as: -------------------------------------------------------------------------------- 1 | package away3d.primitives 2 | { 3 | 4 | /** 5 | * A UV RegularPolygon primitive mesh. 6 | */ 7 | public class RegularPolygonGeometry extends CylinderGeometry 8 | { 9 | 10 | /** 11 | * The radius of the regular polygon. 12 | */ 13 | public function get radius():Number 14 | { 15 | return _bottomRadius; 16 | } 17 | 18 | public function set radius(value:Number):void 19 | { 20 | _bottomRadius = value; 21 | invalidateGeometry(); 22 | } 23 | 24 | /** 25 | * The number of sides of the regular polygon. 26 | */ 27 | public function get sides():uint 28 | { 29 | return _segmentsW; 30 | } 31 | 32 | public function set sides(value:uint):void 33 | { 34 | segmentsW = value; 35 | } 36 | 37 | /** 38 | * The number of subdivisions from the edge to the center of the regular polygon. 39 | */ 40 | public function get subdivisions():uint 41 | { 42 | return _segmentsH; 43 | } 44 | 45 | public function set subdivisions(value:uint):void 46 | { 47 | segmentsH = value; 48 | } 49 | 50 | /** 51 | * Creates a new RegularPolygon disc object. 52 | * @param radius The radius of the regular polygon 53 | * @param sides Defines the number of sides of the regular polygon. 54 | * @param yUp Defines whether the regular polygon should lay on the Y-axis (true) or on the Z-axis (false). 55 | */ 56 | public function RegularPolygonGeometry(radius:Number = 100, sides:uint = 16, yUp:Boolean = true) 57 | { 58 | super(radius, 0, 0, sides, 1, true, false, false, yUp); 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/away3d/filters/tasks/Filter3DBrightPassTask.as: -------------------------------------------------------------------------------- 1 | package away3d.filters.tasks 2 | { 3 | import away3d.cameras.Camera3D; 4 | import away3d.core.managers.Stage3DProxy; 5 | 6 | import flash.display3D.Context3DProgramType; 7 | 8 | import flash.display3D.textures.Texture; 9 | 10 | public class Filter3DBrightPassTask extends Filter3DTaskBase 11 | { 12 | private var _brightPassData:Vector.; 13 | private var _threshold:Number; 14 | 15 | public function Filter3DBrightPassTask(threshold:Number = .75) 16 | { 17 | super(); 18 | _threshold = threshold; 19 | _brightPassData = Vector.([threshold, 1/(1 - threshold), 0, 0]); 20 | } 21 | 22 | public function get threshold():Number 23 | { 24 | return _threshold; 25 | } 26 | 27 | public function set threshold(value:Number):void 28 | { 29 | _threshold = value; 30 | _brightPassData[0] = value; 31 | _brightPassData[1] = 1/(1 - value); 32 | } 33 | 34 | override protected function getFragmentCode():String 35 | { 36 | return "tex ft0, v0, fs0 <2d,linear,clamp> \n" + 37 | "dp3 ft1.x, ft0.xyz, ft0.xyz \n" + 38 | "sqt ft1.x, ft1.x \n" + 39 | "sub ft1.y, ft1.x, fc0.x \n" + 40 | "mul ft1.y, ft1.y, fc0.y \n" + 41 | "sat ft1.y, ft1.y \n" + 42 | "mul ft0.xyz, ft0.xyz, ft1.y \n" + 43 | "mov oc, ft0 \n"; 44 | } 45 | 46 | override public function activate(stage3DProxy:Stage3DProxy, camera3D:Camera3D, depthTexture:Texture):void 47 | { 48 | stage3DProxy.context3D.setProgramConstantsFromVector(Context3DProgramType.FRAGMENT, 0, _brightPassData, 1); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/away3d/audio/drivers/AbstractSound3DDriver.as: -------------------------------------------------------------------------------- 1 | package away3d.audio.drivers 2 | { 3 | import flash.events.EventDispatcher; 4 | import flash.geom.*; 5 | import flash.media.*; 6 | 7 | public class AbstractSound3DDriver extends EventDispatcher 8 | { 9 | protected var _ref_v:Vector3D; 10 | protected var _src:Sound; 11 | protected var _volume:Number; 12 | protected var _scale:Number; 13 | 14 | protected var _mute:Boolean; 15 | protected var _paused:Boolean; 16 | protected var _playing:Boolean; 17 | 18 | public function AbstractSound3DDriver() 19 | { 20 | _volume = 1; 21 | _scale = 1000; 22 | _playing = false; 23 | } 24 | 25 | public function get sourceSound():Sound 26 | { 27 | return _src; 28 | } 29 | 30 | public function set sourceSound(val:Sound):void 31 | { 32 | if (_src == val) 33 | return; 34 | 35 | _src = val; 36 | } 37 | 38 | public function get volume():Number 39 | { 40 | return _volume; 41 | } 42 | 43 | public function set volume(val:Number):void 44 | { 45 | _volume = val; 46 | } 47 | 48 | public function get scale():Number 49 | { 50 | return _scale; 51 | } 52 | 53 | public function set scale(val:Number):void 54 | { 55 | _scale = val; 56 | } 57 | 58 | public function get mute():Boolean 59 | { 60 | return _mute; 61 | } 62 | 63 | public function set mute(val:Boolean):void 64 | { 65 | if (_mute == val) 66 | return; 67 | 68 | _mute = val; 69 | } 70 | 71 | public function updateReferenceVector(v:Vector3D):void 72 | { 73 | this._ref_v = v; 74 | } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/away3d/materials/compilation/ShaderRegisterElement.as: -------------------------------------------------------------------------------- 1 | package away3d.materials.compilation 2 | { 3 | 4 | /** 5 | * A single register element (an entire register or a single register's component) used by the RegisterPool. 6 | */ 7 | public class ShaderRegisterElement 8 | { 9 | private var _regName:String; 10 | private var _index:int; 11 | private var _toStr:String; 12 | 13 | private static const COMPONENTS:Array = ["x", "y", "z", "w"]; 14 | 15 | internal var _component:int; 16 | 17 | /** 18 | * Creates a new ShaderRegisterElement object. 19 | * @param regName The name of the register. 20 | * @param index The index of the register. 21 | * @param component The register's component, if not the entire register is represented. 22 | */ 23 | public function ShaderRegisterElement(regName:String, index:int, component:int = -1) 24 | { 25 | _component = component; 26 | _regName = regName; 27 | _index = index; 28 | 29 | _toStr = _regName; 30 | 31 | if (_index >= 0) 32 | _toStr += _index; 33 | 34 | if (component > -1) 35 | _toStr += "." + COMPONENTS[component]; 36 | } 37 | 38 | /** 39 | * Converts the register or the components AGAL string representation. 40 | */ 41 | public function toString():String 42 | { 43 | return _toStr; 44 | } 45 | 46 | /** 47 | * The register's name. 48 | */ 49 | public function get regName():String 50 | { 51 | return _regName; 52 | } 53 | 54 | /** 55 | * The register's index. 56 | */ 57 | public function get index():int 58 | { 59 | return _index; 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/away3d/paths/QuadraticPathSegment.as: -------------------------------------------------------------------------------- 1 | package away3d.paths 2 | { 3 | import flash.geom.Vector3D; 4 | 5 | /** 6 | * Creates a curved line segment definition required for the Path class. 7 | */ 8 | 9 | public class QuadraticPathSegment implements IPathSegment 10 | { 11 | /** 12 | * Defines the first vector of the PathSegment 13 | */ 14 | public var start:Vector3D; 15 | 16 | /** 17 | * Defines the control vector of the PathSegment 18 | */ 19 | public var control:Vector3D; 20 | 21 | /** 22 | * Defines the control vector of the PathSegment 23 | */ 24 | public var end:Vector3D; 25 | 26 | public function QuadraticPathSegment(pStart:Vector3D, pControl:Vector3D, pEnd:Vector3D) 27 | { 28 | this.start = pStart; 29 | this.control = pControl; 30 | this.end = pEnd; 31 | } 32 | 33 | public function toString():String 34 | { 35 | return start + ", " + control + ", " + end; 36 | } 37 | 38 | /** 39 | * nulls the 3 vectors 40 | */ 41 | public function dispose():void 42 | { 43 | start = control = end = null; 44 | } 45 | 46 | public function getPointOnSegment(t:Number, target:Vector3D = null):Vector3D 47 | { 48 | const sx:Number = start.x; 49 | const sy:Number = start.y; 50 | const sz:Number = start.z; 51 | const t2Inv:Number = 2*(1 - t); 52 | 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 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/away3d/events/GeometryEvent.as: -------------------------------------------------------------------------------- 1 | package away3d.events 2 | { 3 | import away3d.core.base.ISubGeometry; 4 | 5 | import flash.events.Event; 6 | 7 | /** 8 | * Dispatched to notify changes in a geometry object's state. 9 | * 10 | * @see away3d.core.base.Geometry 11 | */ 12 | public class GeometryEvent extends Event 13 | { 14 | /** 15 | * Dispatched when a SubGeometry was added from the dispatching Geometry. 16 | */ 17 | public static const SUB_GEOMETRY_ADDED:String = "SubGeometryAdded"; 18 | 19 | /** 20 | * Dispatched when a SubGeometry was removed from the dispatching Geometry. 21 | */ 22 | public static const SUB_GEOMETRY_REMOVED:String = "SubGeometryRemoved"; 23 | 24 | public static const BOUNDS_INVALID:String = "BoundsInvalid"; 25 | 26 | private var _subGeometry:ISubGeometry; 27 | 28 | /** 29 | * Create a new GeometryEvent 30 | * @param type The event type. 31 | * @param subGeometry An optional SubGeometry object that is the subject of this event. 32 | */ 33 | public function GeometryEvent(type:String, subGeometry:ISubGeometry = null):void 34 | { 35 | super(type, false, false); 36 | _subGeometry = subGeometry; 37 | } 38 | 39 | /** 40 | * The SubGeometry object that is the subject of this event, if appropriate. 41 | */ 42 | public function get subGeometry():ISubGeometry 43 | { 44 | return _subGeometry; 45 | } 46 | 47 | /** 48 | * Clones the event. 49 | * @return An exact duplicate of the current object. 50 | */ 51 | override public function clone():Event 52 | { 53 | return new GeometryEvent(type, _subGeometry); 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/away3d/animators/states/ParticleTimeState.as: -------------------------------------------------------------------------------- 1 | package away3d.animators.states 2 | { 3 | import away3d.arcane; 4 | import away3d.cameras.Camera3D; 5 | import away3d.animators.data.AnimationRegisterCache; 6 | import away3d.animators.data.AnimationSubGeometry; 7 | import away3d.core.base.IRenderable; 8 | import away3d.core.managers.Stage3DProxy; 9 | import away3d.animators.nodes.ParticleTimeNode; 10 | import away3d.animators.ParticleAnimator; 11 | 12 | import flash.display3D.Context3DVertexBufferFormat; 13 | 14 | use namespace arcane; 15 | 16 | /** 17 | * ... 18 | */ 19 | public class ParticleTimeState extends ParticleStateBase 20 | { 21 | private var _particleTimeNode:ParticleTimeNode; 22 | 23 | public function ParticleTimeState(animator:ParticleAnimator, particleTimeNode:ParticleTimeNode) 24 | { 25 | super(animator, particleTimeNode, true); 26 | 27 | _particleTimeNode = particleTimeNode; 28 | } 29 | 30 | override public function setRenderState(stage3DProxy:Stage3DProxy, renderable:IRenderable, animationSubGeometry:AnimationSubGeometry, animationRegisterCache:AnimationRegisterCache, camera:Camera3D):void 31 | { 32 | animationSubGeometry.activateVertexBuffer(animationRegisterCache.getRegisterIndex(_animationNode, ParticleTimeNode.TIME_STREAM_INDEX), _particleTimeNode.dataOffset, stage3DProxy, Context3DVertexBufferFormat.FLOAT_4); 33 | 34 | var particleTime:Number = _time/1000; 35 | animationRegisterCache.setVertexConst(animationRegisterCache.getRegisterIndex(_animationNode, ParticleTimeNode.TIME_CONSTANT_INDEX), particleTime, particleTime, particleTime, particleTime); 36 | } 37 | 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/away3d/textures/BitmapTextureCache.as: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package away3d.textures 5 | { 6 | import away3d.textures.BitmapTexture; 7 | 8 | import flash.display.BitmapData; 9 | import flash.utils.Dictionary; 10 | 11 | /** 12 | * DEPRECRATED along with BitmapMaterial. Will be removed along with BitmapMaterial 13 | */ 14 | public class BitmapTextureCache 15 | { 16 | private static var _instance:BitmapTextureCache; 17 | 18 | private var _textures:Dictionary; 19 | private var _usages:Dictionary; 20 | 21 | public function BitmapTextureCache(singletonEnforcer:SingletonEnforcer) 22 | { 23 | if (!singletonEnforcer) 24 | throw new Error("Cannot instantiate a singleton class. Use static getInstance instead."); 25 | 26 | _textures = new Dictionary(); 27 | _usages = new Dictionary(); 28 | } 29 | 30 | public static function getInstance():BitmapTextureCache 31 | { 32 | return _instance ||= new BitmapTextureCache(new SingletonEnforcer()); 33 | } 34 | 35 | public function getTexture(bitmapData:BitmapData):BitmapTexture 36 | { 37 | var texture:BitmapTexture; 38 | if (!_textures[bitmapData]) { 39 | texture = new BitmapTexture(bitmapData); 40 | _textures[bitmapData] = texture; 41 | _usages[texture] = 0; 42 | } 43 | _usages[texture]++; 44 | return _textures[bitmapData]; 45 | } 46 | 47 | public function freeTexture(texture:BitmapTexture):void 48 | { 49 | _usages[texture]--; 50 | if (_usages[texture] == 0) { 51 | _textures[BitmapTexture(texture).bitmapData] = null; 52 | texture.dispose(); 53 | } 54 | } 55 | } 56 | } 57 | 58 | class SingletonEnforcer 59 | { 60 | } 61 | -------------------------------------------------------------------------------- /src/away3d/animators/data/UVAnimationFrame.as: -------------------------------------------------------------------------------- 1 | package away3d.animators.data 2 | { 3 | 4 | /** 5 | * A value object for a single frame of animation in a UVClipNode object. 6 | * 7 | * @see away3d.animators.nodes.UVClipNode 8 | */ 9 | public class UVAnimationFrame 10 | { 11 | /** 12 | * The u-component offset of the UV animation frame. 13 | */ 14 | public var offsetU:Number; 15 | 16 | /** 17 | * The v-component offset of the UV animation frame. 18 | */ 19 | public var offsetV:Number; 20 | 21 | /** 22 | * The u-component scale of the UV animation frame. 23 | */ 24 | public var scaleU:Number; 25 | 26 | /** 27 | * The v-component scale of the UV animation frame. 28 | */ 29 | public var scaleV:Number; 30 | 31 | /** 32 | * The rotation value (in degrees) of the UV animation frame. 33 | */ 34 | public var rotation:Number; 35 | 36 | /** 37 | * Creates a new UVAnimationFrame object. 38 | * 39 | * @param offsetU The u-component offset of the UV animation frame. 40 | * @param offsetV The v-component offset of the UV animation frame. 41 | * @param scaleU The u-component scale of the UV animation frame. 42 | * @param scaleV The v-component scale of the UV animation frame. 43 | * @param rotation The rotation value (in degrees) of the UV animation frame. 44 | */ 45 | public function UVAnimationFrame(offsetU:Number = 0, offsetV:Number = 0, scaleU:Number = 1, scaleV:Number = 1, rotation:Number = 0) 46 | { 47 | this.offsetU = offsetU; 48 | this.offsetV = offsetV; 49 | this.scaleU = scaleU; 50 | this.scaleV = scaleV; 51 | this.rotation = rotation; 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/away3d/animators/data/SpriteSheetAnimationFrame.as: -------------------------------------------------------------------------------- 1 | package away3d.animators.data 2 | { 3 | 4 | /** 5 | * A value object for a single frame of animation in a SpriteSheetClipNode object. 6 | * 7 | * @see away3d.animators.nodes.SpriteSheetClipNode 8 | */ 9 | public class SpriteSheetAnimationFrame 10 | { 11 | /** 12 | * The u-component offset of the spritesheet frame. 13 | */ 14 | public var offsetU:Number; 15 | 16 | /** 17 | * The v-component offset of the spritesheet frame. 18 | */ 19 | public var offsetV:Number; 20 | 21 | /** 22 | * The u-component scale of the spritesheet frame. 23 | */ 24 | public var scaleU:Number; 25 | 26 | /** 27 | * The v-component scale of the spritesheet frame. 28 | */ 29 | public var scaleV:Number; 30 | 31 | /** 32 | * The mapID, zero based, if the animation is spreaded over more bitmapData's 33 | */ 34 | public var mapID:uint; 35 | 36 | /** 37 | * Creates a new SpriteSheetAnimationFrame object. 38 | * 39 | * @param offsetU The u-component offset of the spritesheet frame. 40 | * @param offsetV The v-component offset of the spritesheet frame. 41 | * @param scaleU The u-component scale of the spritesheet frame. 42 | * @param scaleV The v-component scale of the spritesheet frame. 43 | * @param mapID The v-component scale of the spritesheet frame. 44 | */ 45 | public function SpriteSheetAnimationFrame(offsetU:Number = 0, offsetV:Number = 0, scaleU:Number = 1, scaleV:Number = 1, mapID:uint = 0) 46 | { 47 | this.offsetU = offsetU; 48 | this.offsetV = offsetV; 49 | this.scaleU = scaleU; 50 | this.scaleV = scaleV; 51 | this.mapID = mapID; 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/away3d/animators/nodes/UVClipNode.as: -------------------------------------------------------------------------------- 1 | package away3d.animators.nodes 2 | { 3 | import away3d.animators.states.*; 4 | import away3d.animators.data.*; 5 | 6 | /** 7 | * A uv animation node containing time-based animation data as individual uv animation frames. 8 | */ 9 | public class UVClipNode extends AnimationClipNodeBase 10 | { 11 | private var _frames:Vector. = new Vector.(); 12 | 13 | /** 14 | * Returns a vector of UV frames representing the uv values of each animation frame in the clip. 15 | */ 16 | public function get frames():Vector. 17 | { 18 | return _frames; 19 | } 20 | 21 | /** 22 | * Creates a new UVClipNode object. 23 | */ 24 | public function UVClipNode() 25 | { 26 | _stateClass = UVClipState; 27 | } 28 | 29 | /** 30 | * Adds a UV frame object to the internal timeline of the animation node. 31 | * 32 | * @param uvFrame The uv frame object to add to the timeline of the node. 33 | * @param duration The specified duration of the frame in milliseconds. 34 | */ 35 | public function addFrame(uvFrame:UVAnimationFrame, duration:uint):void 36 | { 37 | _frames.push(uvFrame); 38 | _durations.push(duration); 39 | _numFrames = _durations.length; 40 | 41 | _stitchDirty = true; 42 | } 43 | 44 | /** 45 | * @inheritDoc 46 | */ 47 | override protected function updateStitch():void 48 | { 49 | super.updateStitch(); 50 | var i:uint; 51 | 52 | if (_durations.length > 0) { 53 | 54 | i = _numFrames - 1; 55 | while (i--) 56 | _totalDuration += _durations[i]; 57 | 58 | if (_stitchFinalFrame || !_looping) 59 | _totalDuration += _durations[_numFrames - 1]; 60 | } 61 | 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/away3d/library/naming/ConflictStrategy.as: -------------------------------------------------------------------------------- 1 | package away3d.library.naming 2 | { 3 | 4 | /** 5 | * Enumeration class for bundled conflict strategies. Set one of these values (or an 6 | * instance of a self-defined sub-class of ConflictStrategyBase) to the conflictStrategy 7 | * property on an AssetLibrary to define how that library resolves naming conflicts. 8 | * 9 | * The value of the AssetLibrary.conflictPrecedence property defines which 10 | * of the conflicting assets will get to keep it's name, and which is renamed (if any.) 11 | * 12 | * @see away3d.library.AssetLibrary.conflictStrategy 13 | * @see away3d.library.naming.ConflictStrategyBase 14 | */ 15 | public class ConflictStrategy 16 | { 17 | /** 18 | * Specifies that in case of a naming conflict, one of the assets will be renamed and 19 | * a numeric suffix appended to the base name. 20 | */ 21 | public static const APPEND_NUM_SUFFIX:ConflictStrategyBase = new NumSuffixConflictStrategy(); 22 | 23 | /** 24 | * Specifies that naming conflicts should be ignored. This is not recommended in most 25 | * cases, unless it can be 100% guaranteed that the application does not cause naming 26 | * conflicts in the library (i.e. when an app-level system is in place to prevent this.) 27 | */ 28 | public static const IGNORE:ConflictStrategyBase = new IgnoreConflictStrategy(); 29 | 30 | /** 31 | * Specifies that an error should be thrown if a naming conflict is discovered. Use this 32 | * to be 100% sure that naming conflicts never occur unnoticed, and when it's undesirable 33 | * to have the library automatically rename assets to avoid such conflicts. 34 | */ 35 | public static const THROW_ERROR:ConflictStrategyBase = new ErrorConflictStrategy(); 36 | 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/away3d/animators/states/UVClipState.as: -------------------------------------------------------------------------------- 1 | package away3d.animators.states 2 | { 3 | import away3d.animators.*; 4 | import away3d.animators.data.*; 5 | import away3d.animators.nodes.*; 6 | 7 | public class UVClipState extends AnimationClipState implements IUVAnimationState 8 | { 9 | private var _frames:Vector.; 10 | private var _uvClipNode:UVClipNode; 11 | private var _currentUVFrame:UVAnimationFrame; 12 | private var _nextUVFrame:UVAnimationFrame; 13 | 14 | /** 15 | * @inheritDoc 16 | */ 17 | public function get currentUVFrame():UVAnimationFrame 18 | { 19 | if (_framesDirty) 20 | updateFrames(); 21 | 22 | return _currentUVFrame; 23 | } 24 | 25 | /** 26 | * @inheritDoc 27 | */ 28 | public function get nextUVFrame():UVAnimationFrame 29 | { 30 | if (_framesDirty) 31 | updateFrames(); 32 | 33 | return _nextUVFrame; 34 | } 35 | 36 | function UVClipState(animator:IAnimator, uvClipNode:UVClipNode) 37 | { 38 | super(animator, uvClipNode); 39 | 40 | _uvClipNode = uvClipNode; 41 | _frames = _uvClipNode.frames; 42 | } 43 | 44 | /** 45 | * @inheritDoc 46 | */ 47 | override protected function updateFrames():void 48 | { 49 | super.updateFrames(); 50 | 51 | if (_frames.length > 0) { 52 | 53 | if (_frames.length == 2 && _currentFrame == 0) { 54 | 55 | _currentUVFrame = _frames[1]; 56 | _nextUVFrame = _frames[0]; 57 | 58 | } else { 59 | 60 | _currentUVFrame = _frames[_currentFrame]; 61 | 62 | if (_uvClipNode.looping && _nextFrame >= _uvClipNode.lastFrame) 63 | _nextUVFrame = _frames[0]; 64 | else 65 | _nextUVFrame = _frames[_nextFrame]; 66 | 67 | } 68 | 69 | } 70 | } 71 | 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/away3d/core/traverse/SceneIterator.as: -------------------------------------------------------------------------------- 1 | package away3d.core.traverse 2 | { 3 | import away3d.arcane; 4 | import away3d.containers.ObjectContainer3D; 5 | import away3d.containers.Scene3D; 6 | 7 | use namespace arcane; 8 | 9 | public class SceneIterator 10 | { 11 | private static const PRE:int = 0; 12 | private static const IN:int = 1; 13 | private static const POST:int = 2; 14 | 15 | private var _childIndex:int; 16 | private var _scene:Scene3D; 17 | private var _node:ObjectContainer3D; 18 | private var _traverseState:int; 19 | private var _childIndexStack:Vector.; 20 | private var _stackPos:int; 21 | 22 | public function SceneIterator(scene:Scene3D) 23 | { 24 | _scene = scene; 25 | reset(); 26 | } 27 | 28 | public function reset():void 29 | { 30 | _childIndexStack = new Vector.(); 31 | _node = _scene._sceneGraphRoot; 32 | _childIndex = 0; 33 | _stackPos = 0; 34 | _traverseState = PRE; 35 | } 36 | 37 | public function next():ObjectContainer3D 38 | { 39 | do { 40 | switch (_traverseState) { 41 | case PRE: 42 | // just entered a node 43 | _childIndexStack[_stackPos++] = _childIndex; 44 | _childIndex = 0; 45 | _traverseState = IN; 46 | return _node; 47 | case IN: 48 | if (_childIndex == _node.numChildren) 49 | _traverseState = POST; 50 | else { 51 | _node = _node.getChildAt(_childIndex); 52 | _traverseState = PRE; 53 | } 54 | break; 55 | case POST: 56 | _node = _node.parent; 57 | _childIndex = _childIndexStack[--_stackPos] + 1; 58 | _traverseState = IN; 59 | break; 60 | } 61 | } while (!(_node == _scene._sceneGraphRoot && _traverseState == POST)); 62 | 63 | return null; 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/away3d/textures/RenderTexture.as: -------------------------------------------------------------------------------- 1 | package away3d.textures 2 | { 3 | import away3d.arcane; 4 | import away3d.materials.utils.MipmapGenerator; 5 | import away3d.tools.utils.TextureUtils; 6 | 7 | import flash.display.BitmapData; 8 | import flash.display3D.Context3D; 9 | import flash.display3D.Context3DTextureFormat; 10 | import flash.display3D.textures.TextureBase; 11 | 12 | use namespace arcane; 13 | 14 | public class RenderTexture extends Texture2DBase 15 | { 16 | public function RenderTexture(width:Number, height:Number) 17 | { 18 | super(); 19 | setSize(width, height); 20 | } 21 | 22 | public function set width(value:int):void 23 | { 24 | if (value == _width) 25 | return; 26 | 27 | if (!TextureUtils.isDimensionValid(value)) 28 | throw new Error("Invalid size: Width and height must be power of 2 and cannot exceed 2048"); 29 | 30 | invalidateContent(); 31 | setSize(value, _height); 32 | } 33 | 34 | public function set height(value:int):void 35 | { 36 | if (value == _height) 37 | return; 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 | } 45 | 46 | override protected function uploadContent(texture:TextureBase):void 47 | { 48 | // fake data, to complete texture for sampling 49 | var bmp:BitmapData = new BitmapData(width, height, false, 0xff0000); 50 | MipmapGenerator.generateMipMaps(bmp, texture); 51 | bmp.dispose(); 52 | } 53 | 54 | override protected function createTexture(context:Context3D):TextureBase 55 | { 56 | return context.createTexture(width, height, Context3DTextureFormat.BGRA, true); 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/away3d/materials/OcclusionMaterial.as: -------------------------------------------------------------------------------- 1 | package away3d.materials 2 | { 3 | import away3d.arcane; 4 | import away3d.cameras.Camera3D; 5 | import away3d.core.managers.Stage3DProxy; 6 | 7 | use namespace arcane; 8 | 9 | /** 10 | * OcclusionMaterial is a ColorMaterial for an object to prevents drawing anything that is placed behind it. 11 | */ 12 | public class OcclusionMaterial extends ColorMaterial 13 | { 14 | private var _occlude:Boolean = true; 15 | 16 | /** 17 | * Creates a new OcclusionMaterial object. 18 | * @param occlude Whether or not to occlude other objects. 19 | * @param color The material's diffuse surface color. 20 | * @param alpha The material's surface alpha. 21 | */ 22 | public function OcclusionMaterial(occlude:Boolean = true, color:uint = 0xcccccc, alpha:Number = 1) 23 | { 24 | super(color, alpha); 25 | this.occlude = occlude; 26 | } 27 | 28 | /** 29 | * Whether or not an object with this material applied hides other objects. 30 | */ 31 | public function get occlude():Boolean 32 | { 33 | return _occlude; 34 | } 35 | 36 | public function set occlude(value:Boolean):void 37 | { 38 | _occlude = value; 39 | } 40 | 41 | /** 42 | * @inheritDoc 43 | */ 44 | override arcane function activatePass(index:uint, 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 arcane function deactivatePass(index:uint, stage3DProxy:Stage3DProxy):void 55 | { 56 | super.deactivatePass(index, stage3DProxy); 57 | stage3DProxy._context3D.setColorMask(true, true, true, true); 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/away3d/animators/states/VertexClipState.as: -------------------------------------------------------------------------------- 1 | package away3d.animators.states 2 | { 3 | import away3d.core.base.Geometry; 4 | import away3d.animators.*; 5 | import away3d.animators.nodes.*; 6 | 7 | /** 8 | * 9 | */ 10 | public class VertexClipState extends AnimationClipState implements IVertexAnimationState 11 | { 12 | private var _frames:Vector.; 13 | private var _vertexClipNode:VertexClipNode; 14 | private var _currentGeometry:Geometry; 15 | private var _nextGeometry:Geometry; 16 | 17 | /** 18 | * @inheritDoc 19 | */ 20 | public function get currentGeometry():Geometry 21 | { 22 | if (_framesDirty) 23 | updateFrames(); 24 | 25 | return _currentGeometry; 26 | } 27 | 28 | /** 29 | * @inheritDoc 30 | */ 31 | public function get nextGeometry():Geometry 32 | { 33 | if (_framesDirty) 34 | updateFrames(); 35 | 36 | return _nextGeometry; 37 | } 38 | 39 | function VertexClipState(animator:IAnimator, vertexClipNode:VertexClipNode) 40 | { 41 | super(animator, vertexClipNode); 42 | 43 | _vertexClipNode = vertexClipNode; 44 | _frames = _vertexClipNode.frames; 45 | } 46 | 47 | /** 48 | * @inheritDoc 49 | */ 50 | override protected function updateFrames():void 51 | { 52 | super.updateFrames(); 53 | 54 | _currentGeometry = _frames[_currentFrame]; 55 | 56 | if (_vertexClipNode.looping && _nextFrame >= _vertexClipNode.lastFrame) { 57 | _nextGeometry = _frames[0]; 58 | VertexAnimator(_animator).dispatchCycleEvent(); 59 | } else 60 | _nextGeometry = _frames[_nextFrame]; 61 | } 62 | 63 | /** 64 | * @inheritDoc 65 | */ 66 | override protected function updatePositionDelta():void 67 | { 68 | //TODO:implement positiondelta functionality for vertex animations 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/away3d/materials/ColorMaterial.as: -------------------------------------------------------------------------------- 1 | package away3d.materials 2 | { 3 | import away3d.arcane; 4 | 5 | import flash.display.BlendMode; 6 | 7 | use namespace arcane; 8 | 9 | /** 10 | * ColorMaterial is a single-pass material that uses a flat color as the surface's diffuse reflection value. 11 | */ 12 | public class ColorMaterial extends SinglePassMaterialBase 13 | { 14 | private var _diffuseAlpha:Number = 1; 15 | 16 | /** 17 | * Creates a new ColorMaterial object. 18 | * @param color The material's diffuse surface color. 19 | * @param alpha The material's surface alpha. 20 | */ 21 | public function ColorMaterial(color:uint = 0xcccccc, alpha:Number = 1) 22 | { 23 | super(); 24 | this.color = color; 25 | this.alpha = alpha; 26 | } 27 | 28 | /** 29 | * The alpha of the surface. 30 | */ 31 | public function get alpha():Number 32 | { 33 | return _screenPass.diffuseMethod.diffuseAlpha; 34 | } 35 | 36 | public function set alpha(value:Number):void 37 | { 38 | if (value > 1) 39 | value = 1; 40 | else if (value < 0) 41 | value = 0; 42 | _screenPass.diffuseMethod.diffuseAlpha = _diffuseAlpha = value; 43 | _screenPass.preserveAlpha = requiresBlending; 44 | _screenPass.setBlendMode(blendMode == BlendMode.NORMAL && requiresBlending? BlendMode.LAYER : blendMode); 45 | } 46 | 47 | /** 48 | * The diffuse reflectivity color of the surface. 49 | */ 50 | public function get color():uint 51 | { 52 | return _screenPass.diffuseMethod.diffuseColor; 53 | } 54 | 55 | public function set color(value:uint):void 56 | { 57 | _screenPass.diffuseMethod.diffuseColor = value; 58 | } 59 | 60 | /** 61 | * @inheritDoc 62 | */ 63 | override public function get requiresBlending():Boolean 64 | { 65 | return super.requiresBlending || _diffuseAlpha < 1; 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/away3d/filters/RadialBlurFilter3D.as: -------------------------------------------------------------------------------- 1 | package away3d.filters 2 | { 3 | import away3d.filters.tasks.Filter3DRadialBlurTask; 4 | 5 | public class RadialBlurFilter3D extends Filter3DBase 6 | { 7 | private var _blurTask:Filter3DRadialBlurTask; 8 | 9 | public function RadialBlurFilter3D(intensity:Number = 8.0, glowGamma:Number = 1.6, blurStart:Number = 1.0, blurWidth:Number = -0.3, cx:Number = 0.5, cy:Number = 0.5) 10 | { 11 | super(); 12 | _blurTask = new Filter3DRadialBlurTask(intensity, glowGamma, blurStart, blurWidth, cx, cy); 13 | addTask(_blurTask); 14 | } 15 | 16 | public function get intensity():Number 17 | { 18 | return _blurTask.intensity; 19 | } 20 | 21 | public function set intensity(intensity:Number):void 22 | { 23 | _blurTask.intensity = intensity; 24 | } 25 | 26 | public function get glowGamma():Number 27 | { 28 | return _blurTask.glowGamma; 29 | } 30 | 31 | public function set glowGamma(glowGamma:Number):void 32 | { 33 | _blurTask.glowGamma = glowGamma; 34 | } 35 | 36 | public function get blurStart():Number 37 | { 38 | return _blurTask.blurStart; 39 | } 40 | 41 | public function set blurStart(blurStart:Number):void 42 | { 43 | _blurTask.blurStart = blurStart; 44 | } 45 | 46 | public function get blurWidth():Number 47 | { 48 | return _blurTask.blurWidth; 49 | } 50 | 51 | public function set blurWidth(blurWidth:Number):void 52 | { 53 | _blurTask.blurWidth = blurWidth; 54 | } 55 | 56 | public function get cx():Number 57 | { 58 | return _blurTask.cx; 59 | } 60 | 61 | public function set cx(cx:Number):void 62 | { 63 | _blurTask.cx = cx; 64 | } 65 | 66 | public function get cy():Number 67 | { 68 | return _blurTask.cy; 69 | } 70 | 71 | public function set cy(cy:Number):void 72 | { 73 | _blurTask.cy = cy; 74 | } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/away3d/filters/tasks/Filter3DDoubleBufferCopyTask.as: -------------------------------------------------------------------------------- 1 | package away3d.filters.tasks 2 | { 3 | import away3d.arcane; 4 | import away3d.cameras.Camera3D; 5 | import away3d.core.managers.Stage3DProxy; 6 | 7 | import flash.display.BitmapData; 8 | 9 | import flash.display3D.Context3DTextureFormat; 10 | 11 | import flash.display3D.textures.Texture; 12 | 13 | use namespace arcane; 14 | 15 | public class Filter3DDoubleBufferCopyTask extends Filter3DTaskBase 16 | { 17 | private var _secondaryInputTexture:Texture; 18 | 19 | public function Filter3DDoubleBufferCopyTask() 20 | { 21 | super(); 22 | } 23 | 24 | public function get secondaryInputTexture():Texture 25 | { 26 | return _secondaryInputTexture; 27 | } 28 | 29 | override protected function getFragmentCode():String 30 | { 31 | return "tex oc, v0, fs0 <2d,nearest,clamp>\n"; 32 | } 33 | 34 | override protected function updateTextures(stage:Stage3DProxy):void 35 | { 36 | super.updateTextures(stage); 37 | 38 | if (_secondaryInputTexture) 39 | _secondaryInputTexture.dispose(); 40 | 41 | _secondaryInputTexture = stage.context3D.createTexture(_textureWidth >> _textureScale, _textureHeight >> _textureScale, Context3DTextureFormat.BGRA, true); 42 | 43 | var dummy:BitmapData = new BitmapData(_textureWidth >> _textureScale, _textureHeight >> _textureScale, false, 0); 44 | _mainInputTexture.uploadFromBitmapData(dummy); 45 | _secondaryInputTexture.uploadFromBitmapData(dummy); 46 | dummy.dispose(); 47 | } 48 | 49 | override public function activate(stage3DProxy:Stage3DProxy, camera:Camera3D, depthTexture:Texture):void 50 | { 51 | swap(); 52 | super.activate(stage3DProxy, camera, depthTexture); 53 | } 54 | 55 | private function swap():void 56 | { 57 | var tmp:Texture = _secondaryInputTexture; 58 | _secondaryInputTexture = _mainInputTexture; 59 | _mainInputTexture = tmp; 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/away3d/stereo/methods/InterleavedStereoRenderMethod.as: -------------------------------------------------------------------------------- 1 | package away3d.stereo.methods 2 | { 3 | import away3d.arcane; 4 | import away3d.core.managers.RTTBufferManager; 5 | import away3d.core.managers.Stage3DProxy; 6 | 7 | import flash.display3D.Context3DProgramType; 8 | 9 | use namespace arcane; 10 | 11 | public class InterleavedStereoRenderMethod extends StereoRenderMethodBase 12 | { 13 | private var _shaderData:Vector.; 14 | 15 | public function InterleavedStereoRenderMethod() 16 | { 17 | super(); 18 | 19 | _shaderData = new [1, 1, 1, 1]; 20 | } 21 | 22 | override public function activate(stage3DProxy:Stage3DProxy):void 23 | { 24 | if (_textureSizeInvalid) { 25 | var minV:Number; 26 | var rttManager:RTTBufferManager; 27 | 28 | rttManager = RTTBufferManager.getInstance(stage3DProxy); 29 | _textureSizeInvalid = false; 30 | 31 | minV = rttManager.renderToTextureRect.bottom/rttManager.textureHeight; 32 | 33 | _shaderData[0] = 2; 34 | _shaderData[1] = rttManager.renderToTextureRect.height; 35 | _shaderData[2] = 1; 36 | _shaderData[3] = .5; 37 | } 38 | 39 | stage3DProxy.context3D.setProgramConstantsFromVector(Context3DProgramType.FRAGMENT, 0, _shaderData); 40 | } 41 | 42 | override public function deactivate(stage3DProxy:Stage3DProxy):void 43 | { 44 | stage3DProxy._context3D.setTextureAt(2, null); 45 | } 46 | 47 | override public function getFragmentCode():String 48 | { 49 | return "tex ft0, v1, fs0 <2d,linear,nomip>\n" + 50 | "tex ft1, v1, fs1 <2d,linear,nomip>\n" + 51 | "add ft2, v0.y, fc0.z\n" + 52 | "div ft2, ft2, fc0.x\n" + 53 | "mul ft2, ft2, fc0.y\n" + 54 | "div ft3, ft2, fc0.x\n" + 55 | "frc ft3, ft3\n" + 56 | "slt ft4, ft3, fc0.w\n" + 57 | "sge ft5, ft3, fc0.w\n" + 58 | "mul ft6, ft0, ft4\n" + 59 | "mul ft7, ft1, ft5\n" + 60 | "add oc, ft7, ft6"; 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/away3d/textures/SplatBlendBitmapTexture.as: -------------------------------------------------------------------------------- 1 | package away3d.textures 2 | { 3 | import flash.display.BitmapData; 4 | import flash.display.BitmapDataChannel; 5 | import flash.display.Shader; 6 | import flash.display.ShaderJob; 7 | import flash.geom.Point; 8 | import flash.geom.Rectangle; 9 | 10 | public class SplatBlendBitmapTexture extends BitmapTexture 11 | { 12 | [Embed(source="/../pb/NormalizeSplats.pbj", mimeType="application/octet-stream")] 13 | private var NormalizeKernel:Class; 14 | 15 | private var _numSplattingLayers:int; 16 | 17 | /** 18 | * 19 | * @param blendingData An array of BitmapData objects to be used for the blend data, as required by TerrainDiffuseMethod. 20 | */ 21 | public function SplatBlendBitmapTexture(blendingData:Array, normalize:Boolean = false) 22 | { 23 | var bitmapData:BitmapData = blendingData[0].clone(); 24 | var channels:Array = [ BitmapDataChannel.RED, BitmapDataChannel.GREEN, BitmapDataChannel.BLUE ]; 25 | 26 | super(bitmapData); 27 | 28 | _numSplattingLayers = blendingData.length; 29 | if (_numSplattingLayers > 3) 30 | throw new Error("blendingData can not have more than 3 elements!"); 31 | 32 | var rect:Rectangle = bitmapData.rect; 33 | var origin:Point = new Point(); 34 | 35 | for (var i:int = 1; i < blendingData.length; ++i) 36 | bitmapData.copyChannel(blendingData[i], rect, origin, BitmapDataChannel.RED, channels[i]); 37 | 38 | if (normalize) 39 | normalizeSplats(); 40 | } 41 | 42 | private function normalizeSplats():void 43 | { 44 | if (_numSplattingLayers <= 1) 45 | return; 46 | var shader:Shader = new Shader(new NormalizeKernel()); 47 | shader.data.numLayers = _numSplattingLayers; 48 | shader.data.src.input = bitmapData; 49 | new ShaderJob(shader, bitmapData).start(true); 50 | } 51 | 52 | override public function dispose():void 53 | { 54 | super.dispose(); 55 | bitmapData.dispose(); 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/away3d/animators/utils/SkeletonUtils.as: -------------------------------------------------------------------------------- 1 | package away3d.animators.utils 2 | { 3 | import away3d.arcane; 4 | import away3d.animators.data.*; 5 | import away3d.animators.nodes.*; 6 | 7 | import flash.geom.*; 8 | 9 | use namespace arcane; 10 | 11 | public class SkeletonUtils 12 | { 13 | public static function generateDifferenceClip(source:SkeletonClipNode, referencePose:SkeletonPose):SkeletonClipNode 14 | { 15 | var diff:SkeletonClipNode = new SkeletonClipNode(); 16 | var numFrames:uint = source.frames.length; 17 | 18 | for (var i:uint = 0; i < numFrames; ++i) 19 | diff.addFrame(generateDifferencePose(source.frames[i], referencePose), source.durations[i]); 20 | 21 | return diff; 22 | } 23 | 24 | public static function generateDifferencePose(source:SkeletonPose, reference:SkeletonPose):SkeletonPose 25 | { 26 | if (source.numJointPoses != reference.numJointPoses) 27 | throw new Error("joint counts don't match!"); 28 | 29 | var numJoints:uint = source.numJointPoses; 30 | var diff:SkeletonPose = new SkeletonPose(); 31 | var srcPose:JointPose; 32 | var refPose:JointPose; 33 | var diffPose:JointPose; 34 | var mtx:Matrix3D = new Matrix3D(); 35 | var tempMtx:Matrix3D = new Matrix3D(); 36 | var vec:Vector.; 37 | 38 | for (var i:int = 0; i < numJoints; ++i) { 39 | srcPose = source.jointPoses[i]; 40 | refPose = reference.jointPoses[i]; 41 | diffPose = new JointPose(); 42 | diff.jointPoses[i] = diffPose; 43 | diffPose.name = srcPose.name; 44 | 45 | refPose.toMatrix3D(mtx); 46 | mtx.invert(); 47 | mtx.append(srcPose.toMatrix3D(tempMtx)); 48 | vec = mtx.decompose(Orientation3D.QUATERNION); 49 | diffPose.translation.copyFrom(vec[0]); 50 | diffPose.orientation.x = vec[1].x; 51 | diffPose.orientation.y = vec[1].y; 52 | diffPose.orientation.z = vec[1].z; 53 | diffPose.orientation.w = vec[1].w; 54 | } 55 | 56 | return diff; 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/away3d/textures/ATFData.as: -------------------------------------------------------------------------------- 1 | package away3d.textures 2 | { 3 | import flash.display3D.Context3DTextureFormat; 4 | import flash.utils.ByteArray; 5 | 6 | public class ATFData 7 | { 8 | public static const TYPE_NORMAL:int = 0x0; 9 | public static const TYPE_CUBE:int = 0x1; 10 | 11 | public var type:int; 12 | public var format:String; 13 | public var width:int; 14 | public var height:int; 15 | public var numTextures:int; 16 | public var data:ByteArray; 17 | 18 | /** Create a new instance by parsing the given byte array. */ 19 | public function ATFData(data:ByteArray) 20 | { 21 | var sign:String = data.readUTFBytes(3); 22 | if (sign != "ATF") 23 | throw new Error("ATF parsing error, unknown format " + sign); 24 | 25 | if (data[6] == 255) 26 | data.position = 12; // new file version 27 | else 28 | data.position = 6; // old file version 29 | 30 | var tdata:uint = data.readUnsignedByte(); 31 | var _type:int = tdata >> 7; // UB[1] 32 | var _format:int = tdata & 0x7f; // UB[7] 33 | 34 | switch (_format) { 35 | case 0: 36 | case 1: 37 | format = Context3DTextureFormat.BGRA; 38 | break; 39 | case 2: 40 | case 3: 41 | format = Context3DTextureFormat.COMPRESSED; 42 | break; 43 | case 4: 44 | case 5: 45 | format = "compressedAlpha"; 46 | break; // explicit string to stay compatible 47 | // with older versions 48 | default: 49 | throw new Error("Invalid ATF format"); 50 | } 51 | 52 | switch (_type) { 53 | case 0: 54 | type = ATFData.TYPE_NORMAL; 55 | break; 56 | case 1: 57 | type = ATFData.TYPE_CUBE; 58 | break; 59 | 60 | default: 61 | throw new Error("Invalid ATF type"); 62 | } 63 | 64 | this.width = Math.pow(2, data.readUnsignedByte()); 65 | this.height = Math.pow(2, data.readUnsignedByte()); 66 | this.numTextures = data.readUnsignedByte(); 67 | this.data = data; 68 | } 69 | 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/away3d/library/naming/NumSuffixConflictStrategy.as: -------------------------------------------------------------------------------- 1 | package away3d.library.naming 2 | { 3 | import away3d.arcane; 4 | import away3d.library.assets.IAsset; 5 | 6 | use namespace arcane; 7 | 8 | public class NumSuffixConflictStrategy extends ConflictStrategyBase 9 | { 10 | private var _separator:String; 11 | private var _next_suffix:Object; 12 | 13 | public function NumSuffixConflictStrategy(separator:String = '.') 14 | { 15 | super(); 16 | 17 | _separator = separator; 18 | _next_suffix = {}; 19 | } 20 | 21 | public override function resolveConflict(changedAsset:IAsset, oldAsset:IAsset, assetsDictionary:Object, precedence:String):void 22 | { 23 | var orig:String; 24 | var new_name:String; 25 | var base:String, suffix:int; 26 | 27 | orig = changedAsset.name; 28 | if (orig.indexOf(_separator) >= 0) { 29 | // Name has an ocurrence of the separator, so get base name and suffix, 30 | // unless suffix is non-numerical, in which case revert to zero and 31 | // use entire name as base 32 | base = orig.substring(0, orig.lastIndexOf(_separator)); 33 | suffix = parseInt(orig.substring(base.length - 1)); 34 | if (isNaN(suffix)) { 35 | base = orig; 36 | suffix = 0; 37 | } 38 | } else { 39 | base = orig; 40 | suffix = 0; 41 | } 42 | 43 | if (suffix == 0 && _next_suffix.hasOwnProperty(base)) 44 | suffix = _next_suffix[base]; 45 | 46 | // Find the first suffixed name that does 47 | // not collide with other names. 48 | do { 49 | suffix++; 50 | new_name = base.concat(_separator, suffix); 51 | } while (assetsDictionary.hasOwnProperty(new_name)); 52 | 53 | _next_suffix[base] = suffix; 54 | 55 | updateNames(oldAsset.assetNamespace, new_name, oldAsset, changedAsset, assetsDictionary, precedence); 56 | } 57 | 58 | public override function create():ConflictStrategyBase 59 | { 60 | return new NumSuffixConflictStrategy(_separator); 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/away3d/paths/CubicPathSegment.as: -------------------------------------------------------------------------------- 1 | package away3d.paths 2 | { 3 | import flash.geom.Vector3D; 4 | 5 | /** 6 | * Defines a single segment of a cubic path 7 | * @see away3d.paths.CubicPath 8 | */ 9 | public 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 CubicPathSegment(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:Number, target:Vector3D = null):Vector3D 57 | { 58 | const td:Number = 1 - phase; 59 | const t_2:Number = phase*phase; 60 | const a:Number = td*td*td; 61 | const b:Number = 3*phase*td*td; 62 | const c:Number = 3*t_2*td; 63 | const t_3:Number = t_2*phase; 64 | 65 | target ||= new Vector3D(); 66 | target.x = a*start.x + b*control1.x + c*control2.x + t_3*end.x; 67 | target.y = a*start.y + b*control1.y + c*control2.y + t_3*end.y; 68 | target.z = a*start.z + b*control1.z + c*control2.z + t_3*end.z; 69 | 70 | return target; 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/away3d/animators/nodes/SkeletonNaryLERPNode.as: -------------------------------------------------------------------------------- 1 | package away3d.animators.nodes 2 | { 3 | import away3d.arcane; 4 | import away3d.animators.*; 5 | import away3d.animators.states.*; 6 | 7 | use namespace arcane; 8 | 9 | /** 10 | * A skeleton animation node that uses an n-dimensional array of animation node inputs to blend a lineraly interpolated output of a skeleton pose. 11 | */ 12 | public class SkeletonNaryLERPNode extends AnimationNodeBase 13 | { 14 | arcane var _inputs:Vector. = new Vector.(); 15 | private var _numInputs:uint; 16 | 17 | public function get numInputs():uint 18 | { 19 | return _numInputs; 20 | } 21 | 22 | /** 23 | * Creates a new SkeletonNaryLERPNode object. 24 | */ 25 | public function SkeletonNaryLERPNode() 26 | { 27 | _stateClass = SkeletonNaryLERPState; 28 | } 29 | 30 | /** 31 | * Returns an integer representing the input index of the given skeleton animation node. 32 | * 33 | * @param input The skeleton animation node for with the input index is requested. 34 | */ 35 | public function getInputIndex(input:AnimationNodeBase):int 36 | { 37 | return _inputs.indexOf(input); 38 | } 39 | 40 | /** 41 | * Returns the skeleton animation node object that resides at the given input index. 42 | * 43 | * @param index The input index for which the skeleton animation node is requested. 44 | */ 45 | public function getInputAt(index:uint):AnimationNodeBase 46 | { 47 | return _inputs[index]; 48 | } 49 | 50 | /** 51 | * Adds a new skeleton animation node input to the animation node. 52 | */ 53 | public function addInput(input:AnimationNodeBase):void 54 | { 55 | _inputs[_numInputs++] = input; 56 | } 57 | 58 | /** 59 | * @inheritDoc 60 | */ 61 | public function getAnimationState(animator:IAnimator):SkeletonNaryLERPState 62 | { 63 | return animator.getAnimationState(this) as SkeletonNaryLERPState; 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/away3d/paths/IPath.as: -------------------------------------------------------------------------------- 1 | package away3d.paths 2 | { 3 | import flash.geom.Vector3D; 4 | 5 | public interface IPath 6 | { 7 | /** 8 | * The number of CubicPathSegment instances in the path. 9 | */ 10 | function get numSegments():uint; 11 | 12 | /** 13 | * The IPathSegment instances which make up this path. 14 | */ 15 | function get segments():Vector.; 16 | 17 | /** 18 | * Returns the CubicPathSegment at the specified index 19 | * @param index The index of the segment 20 | * @return A CubicPathSegment instance 21 | */ 22 | function getSegmentAt(index:uint):IPathSegment; 23 | 24 | /** 25 | * Adds a CubicPathSegment to the end of the path 26 | * @param segment 27 | */ 28 | function addSegment(segment:IPathSegment):void; 29 | 30 | /** 31 | * Removes a segment from the path 32 | * @param index The index of the CubicPathSegment to be removed 33 | * @param join Determines if the segments on either side of the removed segment should be adjusted so there is no gap. 34 | */ 35 | function removeSegment(index:uint, join:Boolean = false):void; 36 | 37 | /** 38 | * Disposes the path and all the segments 39 | */ 40 | function dispose():void; 41 | 42 | /** 43 | * Discretizes the segment into a set of sample points. 44 | * 45 | * @param numSegments The amount of segments to split the sampling in. The amount of points returned is numSegments + 1 46 | */ 47 | function getPointsOnCurvePerSegment(numSegments:uint):Vector.>; 48 | 49 | /** 50 | * Gets a point on the curve 51 | * @param t The phase for which to get the point. A number between 0 and 1. 52 | * @param target An optional parameter to store the calculation, to avoid creating a new Vector3D object 53 | * @return The point on the curve for the given phase 54 | */ 55 | function getPointOnCurve(t:Number, target:Vector3D = null):Vector3D; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/away3d/materials/utils/DefaultMaterialManager.as: -------------------------------------------------------------------------------- 1 | package away3d.materials.utils 2 | { 3 | import away3d.core.base.*; 4 | import away3d.materials.*; 5 | import away3d.textures.*; 6 | 7 | import flash.display.*; 8 | 9 | public class DefaultMaterialManager 10 | { 11 | private static var _defaultTextureBitmapData:BitmapData; 12 | private static var _defaultMaterial:TextureMaterial; 13 | private static var _defaultTexture:BitmapTexture; 14 | 15 | //private static var _defaultMaterialRenderables:Vector. = new Vector.(); 16 | 17 | public static function getDefaultMaterial(renderable:IMaterialOwner = null):TextureMaterial 18 | { 19 | if (!_defaultTexture) 20 | createDefaultTexture(); 21 | 22 | if (!_defaultMaterial) 23 | createDefaultMaterial(); 24 | 25 | //_defaultMaterialRenderables.push(renderable); 26 | 27 | return _defaultMaterial; 28 | } 29 | 30 | public static function getDefaultTexture(renderable:IMaterialOwner = null):BitmapTexture 31 | { 32 | if (!_defaultTexture) 33 | createDefaultTexture(); 34 | 35 | //_defaultMaterialRenderables.push(renderable); 36 | 37 | return _defaultTexture; 38 | } 39 | 40 | private static function createDefaultTexture():void 41 | { 42 | _defaultTextureBitmapData = new BitmapData(8, 8, false, 0x0); 43 | 44 | //create chekerboard 45 | var i:uint, j:uint; 46 | for (i = 0; i < 8; i++) { 47 | for (j = 0; j < 8; j++) { 48 | if ((j & 1) ^ (i & 1)) 49 | _defaultTextureBitmapData.setPixel(i, j, 0XFFFFFF); 50 | } 51 | } 52 | 53 | _defaultTexture = new BitmapTexture(_defaultTextureBitmapData); 54 | _defaultTexture.name = "defaultTexture"; 55 | } 56 | 57 | private static function createDefaultMaterial():void 58 | { 59 | _defaultMaterial = new TextureMaterial(_defaultTexture); 60 | _defaultMaterial.mipmap = false; 61 | _defaultMaterial.smooth = false; 62 | _defaultMaterial.name = "defaultMaterial"; 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/away3d/materials/utils/MipmapGenerator.as: -------------------------------------------------------------------------------- 1 | package away3d.materials.utils 2 | { 3 | import flash.display.*; 4 | import flash.display3D.textures.CubeTexture; 5 | import flash.display3D.textures.Texture; 6 | import flash.display3D.textures.TextureBase; 7 | import flash.geom.*; 8 | 9 | /** 10 | * MipmapGenerator is a helper class that uploads BitmapData to a Texture including mipmap levels. 11 | */ 12 | public class MipmapGenerator 13 | { 14 | private static var _matrix:Matrix = new Matrix(); 15 | private static var _rect:Rectangle = new Rectangle(); 16 | 17 | /** 18 | * Uploads a BitmapData with mip maps to a target Texture object. 19 | * @param source The source BitmapData to upload. 20 | * @param target The target Texture to upload to. 21 | * @param mipmap An optional mip map holder to avoids creating new instances for fe animated materials. 22 | * @param alpha Indicate whether or not the uploaded bitmapData is transparent. 23 | */ 24 | public static function generateMipMaps(source:BitmapData, target:TextureBase, mipmap:BitmapData = null, alpha:Boolean = false, side:int = -1):void 25 | { 26 | var w:uint = source.width, 27 | h:uint = source.height; 28 | var i:uint; 29 | var regen:Boolean = mipmap != null; 30 | mipmap ||= new BitmapData(w, h, alpha); 31 | 32 | _rect.width = w; 33 | _rect.height = h; 34 | 35 | while (w >= 1 || h >= 1) { 36 | if (alpha) 37 | mipmap.fillRect(_rect, 0); 38 | 39 | _matrix.a = _rect.width/source.width; 40 | _matrix.d = _rect.height/source.height; 41 | 42 | mipmap.draw(source, _matrix, null, null, null, true); 43 | 44 | if (target is Texture) 45 | Texture(target).uploadFromBitmapData(mipmap, i++); 46 | else 47 | CubeTexture(target).uploadFromBitmapData(mipmap, side, i++); 48 | 49 | w >>= 1; 50 | h >>= 1; 51 | 52 | _rect.width = w > 1? w : 1; 53 | _rect.height = h > 1? h : 1; 54 | } 55 | 56 | if (!regen) 57 | mipmap.dispose(); 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/away3d/animators/data/JointPose.as: -------------------------------------------------------------------------------- 1 | package away3d.animators.data 2 | { 3 | import away3d.core.math.*; 4 | 5 | import flash.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 | public 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 JointPose() 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 | target ||= new Matrix3D(); 46 | orientation.toMatrix3D(target); 47 | target.appendTranslation(translation.x, translation.y, translation.z); 48 | return target; 49 | } 50 | 51 | /** 52 | * Copies the transformation data from a source pose object into the existing pose object. 53 | * 54 | * @param pose The source pose to copy from. 55 | */ 56 | public function copyFrom(pose:JointPose):void 57 | { 58 | var or:Quaternion = pose.orientation; 59 | var tr:Vector3D = pose.translation; 60 | orientation.x = or.x; 61 | orientation.y = or.y; 62 | orientation.z = or.z; 63 | orientation.w = or.w; 64 | translation.x = tr.x; 65 | translation.y = tr.y; 66 | translation.z = tr.z; 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/away3d/filters/tasks/Filter3DXFadeCompositeTask.as: -------------------------------------------------------------------------------- 1 | package away3d.filters.tasks 2 | { 3 | import away3d.arcane; 4 | import away3d.cameras.Camera3D; 5 | import away3d.core.managers.Stage3DProxy; 6 | 7 | import flash.display3D.Context3D; 8 | 9 | import flash.display3D.Context3DProgramType; 10 | 11 | import flash.display3D.textures.Texture; 12 | import flash.display3D.textures.TextureBase; 13 | 14 | use namespace arcane; 15 | 16 | public class Filter3DXFadeCompositeTask extends Filter3DTaskBase 17 | { 18 | private var _data:Vector.; 19 | private var _overlayTexture:TextureBase; 20 | 21 | public function Filter3DXFadeCompositeTask(amount:Number) 22 | { 23 | super(); 24 | if (amount < 0) 25 | amount = 0; 26 | else if (amount > 1) 27 | amount = 1; 28 | _data = Vector.([ amount, 0, 0, 0 ]); 29 | } 30 | 31 | public function get overlayTexture():TextureBase 32 | { 33 | return _overlayTexture; 34 | } 35 | 36 | public function set overlayTexture(value:TextureBase):void 37 | { 38 | _overlayTexture = value; 39 | } 40 | 41 | public function get amount():Number 42 | { 43 | return _data[0]; 44 | } 45 | 46 | public function set amount(value:Number):void 47 | { 48 | _data[0] = value; 49 | } 50 | 51 | override protected function getFragmentCode():String 52 | { 53 | return "tex ft0, v0, fs0 <2d,nearest> \n" + 54 | "tex ft1, v0, fs1 <2d,nearest> \n" + 55 | "sub ft1, ft1, ft0 \n" + 56 | "mul ft1, ft1, fc0.x \n" + 57 | "add oc, ft1, ft0 \n"; 58 | } 59 | 60 | override public function activate(stage3DProxy:Stage3DProxy, camera3D:Camera3D, depthTexture:Texture):void 61 | { 62 | var context:Context3D = stage3DProxy._context3D; 63 | context.setProgramConstantsFromVector(Context3DProgramType.FRAGMENT, 0, _data, 1); 64 | context.setTextureAt(1, _overlayTexture); 65 | } 66 | 67 | override public function deactivate(stage3DProxy:Stage3DProxy):void 68 | { 69 | stage3DProxy._context3D.setTextureAt(1, null); 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/away3d/filters/BlurFilter3D.as: -------------------------------------------------------------------------------- 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 flash.display3D.textures.Texture; 8 | 9 | public class BlurFilter3D extends Filter3DBase 10 | { 11 | private var _hBlurTask:Filter3DHBlurTask; 12 | private var _vBlurTask:Filter3DVBlurTask; 13 | 14 | /** 15 | * Creates a new BlurFilter3D object 16 | * @param blurX The amount of horizontal blur to apply 17 | * @param blurY The amount of vertical blur to apply 18 | * @param stepSize The distance between samples. Set to -1 to autodetect with acceptable quality. 19 | */ 20 | public function BlurFilter3D(blurX:uint = 3, blurY:uint = 3, stepSize:int = -1) 21 | { 22 | super(); 23 | addTask(_hBlurTask = new Filter3DHBlurTask(blurX, stepSize)); 24 | addTask(_vBlurTask = new Filter3DVBlurTask(blurY, stepSize)); 25 | } 26 | 27 | public function get blurX():uint 28 | { 29 | return _hBlurTask.amount; 30 | } 31 | 32 | public function set blurX(value:uint):void 33 | { 34 | _hBlurTask.amount = value; 35 | } 36 | 37 | public function get blurY():uint 38 | { 39 | return _vBlurTask.amount; 40 | } 41 | 42 | public function set blurY(value:uint):void 43 | { 44 | _vBlurTask.amount = value; 45 | } 46 | 47 | /** 48 | * The distance between two blur samples. Set to -1 to autodetect with acceptable quality (default value). 49 | * Higher values provide better performance at the cost of reduces quality. 50 | */ 51 | public function get stepSize():int 52 | { 53 | return _hBlurTask.stepSize; 54 | } 55 | 56 | public function set stepSize(value:int):void 57 | { 58 | _hBlurTask.stepSize = value; 59 | _vBlurTask.stepSize = value; 60 | } 61 | 62 | override public function setRenderTargets(mainTarget:Texture, stage3DProxy:Stage3DProxy):void 63 | { 64 | _hBlurTask.target = _vBlurTask.getMainInputTexture(stage3DProxy); 65 | super.setRenderTargets(mainTarget, stage3DProxy); 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/away3d/lights/LightProbe.as: -------------------------------------------------------------------------------- 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 flash.geom.*; 11 | 12 | use namespace arcane; 13 | 14 | public class LightProbe extends LightBase 15 | { 16 | private var _diffuseMap:CubeTextureBase; 17 | private var _specularMap:CubeTextureBase; 18 | 19 | /** 20 | * Creates a new LightProbe object. 21 | */ 22 | public function LightProbe(diffuseMap:CubeTextureBase, specularMap:CubeTextureBase = null) 23 | { 24 | super(); 25 | _diffuseMap = diffuseMap; 26 | _specularMap = specularMap; 27 | } 28 | 29 | override protected function createEntityPartitionNode():EntityNode 30 | { 31 | return new LightProbeNode(this); 32 | } 33 | 34 | public function get diffuseMap():CubeTextureBase 35 | { 36 | return _diffuseMap; 37 | } 38 | 39 | public function set diffuseMap(value:CubeTextureBase):void 40 | { 41 | _diffuseMap = value; 42 | } 43 | 44 | public function get specularMap():CubeTextureBase 45 | { 46 | return _specularMap; 47 | } 48 | 49 | public function set specularMap(value:CubeTextureBase):void 50 | { 51 | _specularMap = value; 52 | } 53 | 54 | /** 55 | * @inheritDoc 56 | */ 57 | override protected function updateBounds():void 58 | { 59 | // super.updateBounds(); 60 | _boundsInvalid = false; 61 | } 62 | 63 | /** 64 | * @inheritDoc 65 | */ 66 | override protected function getDefaultBoundingVolume():BoundingVolumeBase 67 | { 68 | // todo: consider if this can be culled? 69 | return new NullBounds(); 70 | } 71 | 72 | /** 73 | * @inheritDoc 74 | */ 75 | override arcane function getObjectProjectionMatrix(renderable:IRenderable, camera:Camera3D, target:Matrix3D = null):Matrix3D 76 | { 77 | // TODO: not used 78 | renderable = renderable; 79 | target = target; 80 | 81 | throw new Error("Object projection matrices are not supported for LightProbe objects!"); 82 | return null; 83 | } 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /src/away3d/filters/HDepthOfFieldFilter3D.as: -------------------------------------------------------------------------------- 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 | 8 | import flash.geom.Vector3D; 9 | 10 | public class HDepthOfFieldFilter3D extends Filter3DBase 11 | { 12 | private var _dofTask:Filter3DHDepthOfFFieldTask; 13 | private var _focusTarget:ObjectContainer3D; 14 | 15 | /** 16 | * Creates a new HDepthOfFieldFilter3D object 17 | * @param amount The amount of blur to apply in pixels 18 | * @param stepSize The distance between samples. Set to -1 to autodetect with acceptable quality. 19 | */ 20 | public function HDepthOfFieldFilter3D(maxBlur:uint = 3, stepSize:int = -1) 21 | { 22 | super(); 23 | _dofTask = new Filter3DHDepthOfFFieldTask(maxBlur, stepSize); 24 | addTask(_dofTask); 25 | } 26 | 27 | public function get focusTarget():ObjectContainer3D 28 | { 29 | return _focusTarget; 30 | } 31 | 32 | public function set focusTarget(value:ObjectContainer3D):void 33 | { 34 | _focusTarget = value; 35 | } 36 | 37 | public function get focusDistance():Number 38 | { 39 | return _dofTask.focusDistance; 40 | } 41 | 42 | public function set focusDistance(value:Number):void 43 | { 44 | _dofTask.focusDistance = value; 45 | } 46 | 47 | public function get range():Number 48 | { 49 | return _dofTask.range; 50 | } 51 | 52 | public function set range(value:Number):void 53 | { 54 | _dofTask.range = value; 55 | } 56 | 57 | public function get maxBlur():uint 58 | { 59 | return _dofTask.maxBlur; 60 | } 61 | 62 | public function set maxBlur(value:uint):void 63 | { 64 | _dofTask.maxBlur = value; 65 | } 66 | 67 | override public function update(stage:Stage3DProxy, camera:Camera3D):void 68 | { 69 | if (_focusTarget) 70 | updateFocus(camera); 71 | } 72 | 73 | private function updateFocus(camera:Camera3D):void 74 | { 75 | var target:Vector3D = camera.inverseSceneTransform.transformVector(_focusTarget.scenePosition); 76 | _dofTask.focusDistance = target.z; 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/away3d/filters/VDepthOfFieldFilter3D.as: -------------------------------------------------------------------------------- 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 flash.geom.Vector3D; 9 | 10 | public class VDepthOfFieldFilter3D extends Filter3DBase 11 | { 12 | private var _dofTask:Filter3DVDepthOfFFieldTask; 13 | private var _focusTarget:ObjectContainer3D; 14 | 15 | /** 16 | * Creates a new VDepthOfFieldFilter3D object 17 | * @param amount The amount of blur to apply in pixels 18 | * @param stepSize The distance between samples. Set to -1 to autodetect with acceptable quality. 19 | */ 20 | public function VDepthOfFieldFilter3D(maxBlur:uint = 3, stepSize:int = -1) 21 | { 22 | super(); 23 | _dofTask = new Filter3DVDepthOfFFieldTask(maxBlur, stepSize); 24 | addTask(_dofTask); 25 | } 26 | 27 | public function get focusTarget():ObjectContainer3D 28 | { 29 | return _focusTarget; 30 | } 31 | 32 | public function set focusTarget(value:ObjectContainer3D):void 33 | { 34 | _focusTarget = value; 35 | } 36 | 37 | public function get focusDistance():Number 38 | { 39 | return _dofTask.focusDistance; 40 | } 41 | 42 | public function set focusDistance(value:Number):void 43 | { 44 | _dofTask.focusDistance = value; 45 | } 46 | 47 | public function get range():Number 48 | { 49 | return _dofTask.range; 50 | } 51 | 52 | public function set range(value:Number):void 53 | { 54 | _dofTask.range = value; 55 | } 56 | 57 | public function get maxBlur():uint 58 | { 59 | return _dofTask.maxBlur; 60 | } 61 | 62 | public function set maxBlur(value:uint):void 63 | { 64 | _dofTask.maxBlur = value; 65 | } 66 | 67 | override public function update(stage:Stage3DProxy, camera:Camera3D):void 68 | { 69 | if (_focusTarget) 70 | updateFocus(camera); 71 | } 72 | 73 | private function updateFocus(camera:Camera3D):void 74 | { 75 | var target:Vector3D = camera.inverseSceneTransform.transformVector(_focusTarget.scenePosition); 76 | _dofTask.focusDistance = target.z; 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/away3d/controllers/ControllerBase.as: -------------------------------------------------------------------------------- 1 | package away3d.controllers 2 | { 3 | import away3d.arcane; 4 | import away3d.entities.*; 5 | import away3d.errors.AbstractMethodError; 6 | 7 | use namespace arcane; 8 | 9 | public class ControllerBase 10 | { 11 | protected var _autoUpdate:Boolean = true; 12 | protected var _targetObject:Entity; 13 | 14 | protected function notifyUpdate():void 15 | { 16 | if (_targetObject && _targetObject.implicitPartition && _autoUpdate) 17 | _targetObject.implicitPartition.markForUpdate(_targetObject); 18 | } 19 | 20 | /** 21 | * Target object on which the controller acts. Defaults to null. 22 | */ 23 | public function get targetObject():Entity 24 | { 25 | return _targetObject; 26 | } 27 | 28 | public function set targetObject(val:Entity):void 29 | { 30 | if (_targetObject == val) 31 | return; 32 | 33 | if (_targetObject && _autoUpdate) 34 | _targetObject._controller = null; 35 | 36 | _targetObject = val; 37 | 38 | if (_targetObject && _autoUpdate) 39 | _targetObject._controller = this; 40 | 41 | notifyUpdate(); 42 | } 43 | 44 | /** 45 | * Determines whether the controller applies updates automatically. Defaults to true 46 | */ 47 | public function get autoUpdate():Boolean 48 | { 49 | return _autoUpdate; 50 | } 51 | 52 | public function set autoUpdate(val:Boolean):void 53 | { 54 | if (_autoUpdate == val) 55 | return; 56 | 57 | _autoUpdate = val; 58 | 59 | if (_targetObject) { 60 | if (_autoUpdate) 61 | _targetObject._controller = this; 62 | else 63 | _targetObject._controller = null; 64 | } 65 | } 66 | 67 | /** 68 | * Base controller class for dynamically adjusting the propeties of a 3D object. 69 | * 70 | * @param targetObject The 3D object on which to act. 71 | */ 72 | public function ControllerBase(targetObject:Entity = null):void 73 | { 74 | this.targetObject = targetObject; 75 | } 76 | 77 | /** 78 | * Manually applies updates to the target 3D object. 79 | */ 80 | public function update(interpolate:Boolean = true):void 81 | { 82 | throw new AbstractMethodError(); 83 | } 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /src/away3d/filters/tasks/Filter3DBloomCompositeTask.as: -------------------------------------------------------------------------------- 1 | package away3d.filters.tasks 2 | { 3 | import away3d.arcane; 4 | import away3d.cameras.Camera3D; 5 | import away3d.core.managers.Stage3DProxy; 6 | 7 | import flash.display3D.Context3D; 8 | 9 | import flash.display3D.Context3DProgramType; 10 | 11 | import flash.display3D.textures.Texture; 12 | import flash.display3D.textures.TextureBase; 13 | 14 | use namespace arcane; 15 | 16 | public class Filter3DBloomCompositeTask extends Filter3DTaskBase 17 | { 18 | private var _data:Vector.; 19 | private var _overlayTexture:TextureBase; 20 | private var _exposure:Number; 21 | 22 | public function Filter3DBloomCompositeTask(exposure:Number) 23 | { 24 | super(); 25 | _data = Vector.([ 0.299, 0.587, 0.114, 1 ]); // luminance projection, 1 26 | this.exposure = exposure; 27 | } 28 | 29 | public function get overlayTexture():TextureBase 30 | { 31 | return _overlayTexture; 32 | } 33 | 34 | public function set overlayTexture(value:TextureBase):void 35 | { 36 | _overlayTexture = value; 37 | } 38 | 39 | override protected 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 | public function get exposure():Number 64 | { 65 | return _exposure; 66 | } 67 | 68 | public function set exposure(exposure:Number):void 69 | { 70 | _exposure = exposure; 71 | _data[3] = 1 + _exposure / 10; 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/away3d/filters/Filter3DBase.as: -------------------------------------------------------------------------------- 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 flash.display3D.textures.Texture; 8 | 9 | public class Filter3DBase 10 | { 11 | private var _tasks:Vector.; 12 | private var _requireDepthRender:Boolean; 13 | private var _textureWidth:int; 14 | private var _textureHeight:int; 15 | 16 | public function Filter3DBase() 17 | { 18 | _tasks = new Vector.(); 19 | } 20 | 21 | public function get requireDepthRender():Boolean 22 | { 23 | return _requireDepthRender; 24 | } 25 | 26 | protected function addTask(filter:Filter3DTaskBase):void 27 | { 28 | _tasks.push(filter); 29 | _requireDepthRender ||= filter.requireDepthRender; 30 | } 31 | 32 | public function get tasks():Vector. 33 | { 34 | return _tasks; 35 | } 36 | 37 | public function getMainInputTexture(stage3DProxy:Stage3DProxy):Texture 38 | { 39 | return _tasks[0].getMainInputTexture(stage3DProxy); 40 | } 41 | 42 | public function get textureWidth():int 43 | { 44 | return _textureWidth; 45 | } 46 | 47 | public function set textureWidth(value:int):void 48 | { 49 | _textureWidth = value; 50 | 51 | for (var i:int = 0; i < _tasks.length; ++i) 52 | _tasks[i].textureWidth = value; 53 | } 54 | 55 | public function get textureHeight():int 56 | { 57 | return _textureHeight; 58 | } 59 | 60 | public function set textureHeight(value:int):void 61 | { 62 | _textureHeight = value; 63 | for (var i:int = 0; i < _tasks.length; ++i) 64 | _tasks[i].textureHeight = value; 65 | } 66 | 67 | // link up the filters correctly with the next filter 68 | public function setRenderTargets(mainTarget:Texture, stage3DProxy:Stage3DProxy):void 69 | { 70 | _tasks[_tasks.length - 1].target = mainTarget; 71 | } 72 | 73 | public function dispose():void 74 | { 75 | for (var i:int = 0; i < _tasks.length; ++i) 76 | _tasks[i].dispose(); 77 | } 78 | 79 | public function update(stage:Stage3DProxy, camera:Camera3D):void 80 | { 81 | 82 | } 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /src/away3d/library/utils/AssetLibraryIterator.as: -------------------------------------------------------------------------------- 1 | package away3d.library.utils 2 | { 3 | import away3d.library.assets.IAsset; 4 | 5 | public class AssetLibraryIterator 6 | { 7 | private var _assets:Vector.; 8 | private var _filtered:Vector.; 9 | 10 | private var _idx:uint; 11 | 12 | public function AssetLibraryIterator(assets:Vector., assetTypeFilter:String, namespaceFilter:String, filterFunc:Function) 13 | { 14 | _assets = assets; 15 | filter(assetTypeFilter, namespaceFilter, filterFunc); 16 | } 17 | 18 | public function get currentAsset():IAsset 19 | { 20 | // Return current, or null if no current 21 | return (_idx < _filtered.length)? 22 | _filtered[_idx] : null; 23 | } 24 | 25 | public function get numAssets():uint 26 | { 27 | return _filtered.length; 28 | } 29 | 30 | public function next():IAsset 31 | { 32 | var next:IAsset = null; 33 | 34 | if (_idx < _filtered.length) 35 | next = _filtered[_idx]; 36 | 37 | _idx++; 38 | 39 | return next; 40 | } 41 | 42 | public function reset():void 43 | { 44 | _idx = 0; 45 | } 46 | 47 | public function setIndex(index:uint):void 48 | { 49 | _idx = index; 50 | } 51 | 52 | private function filter(assetTypeFilter:String, namespaceFilter:String, filterFunc:Function):void 53 | { 54 | if (assetTypeFilter || namespaceFilter || filterFunc != null) { 55 | var idx:uint; 56 | var asset:IAsset; 57 | 58 | idx = 0; 59 | _filtered = new Vector.; 60 | 61 | for each (asset in _assets) { 62 | // Skip this assets if filtering on type and this is wrong type 63 | if (assetTypeFilter && asset.assetType != assetTypeFilter) 64 | continue; 65 | 66 | // Skip this asset if filtering on namespace and this is wrong namespace 67 | if (namespaceFilter && asset.assetNamespace != namespaceFilter) 68 | continue; 69 | 70 | // Skip this asset if a filter func has been provided and it returns false 71 | if (filterFunc != null && !filterFunc(asset)) 72 | continue; 73 | 74 | _filtered[idx++] = asset; 75 | } 76 | } else { 77 | _filtered = _assets; 78 | } 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/away3d/materials/methods/MethodVO.as: -------------------------------------------------------------------------------- 1 | package away3d.materials.methods 2 | { 3 | /** 4 | * MethodVO contains data for a given method for the use within a single material. 5 | * This allows methods to be shared across materials while their non-public state differs. 6 | */ 7 | public class MethodVO 8 | { 9 | public var vertexData:Vector.; 10 | public var fragmentData:Vector.; 11 | 12 | // public register indices 13 | public var texturesIndex:int; 14 | public var secondaryTexturesIndex:int; // sometimes needed for composites 15 | public var vertexConstantsIndex:int; 16 | public var secondaryVertexConstantsIndex:int; // sometimes needed for composites 17 | public var fragmentConstantsIndex:int; 18 | public var secondaryFragmentConstantsIndex:int; // sometimes needed for composites 19 | 20 | public var useMipmapping:Boolean; 21 | public var useSmoothTextures:Boolean; 22 | public var repeatTextures:Boolean; 23 | 24 | // internal stuff for the material to know before assembling code 25 | public var needsProjection:Boolean; 26 | public var needsView:Boolean; 27 | public var needsNormals:Boolean; 28 | public var needsTangents:Boolean; 29 | public var needsUV:Boolean; 30 | public var needsSecondaryUV:Boolean; 31 | public var needsGlobalVertexPos:Boolean; 32 | public var needsGlobalFragmentPos:Boolean; 33 | 34 | public var numLights:int; 35 | public var useLightFallOff:Boolean = true; 36 | 37 | /** 38 | * Creates a new MethodVO object. 39 | */ 40 | public function MethodVO() 41 | { 42 | 43 | } 44 | 45 | /** 46 | * Resets the values of the value object to their "unused" state. 47 | */ 48 | public function reset():void 49 | { 50 | texturesIndex = -1; 51 | vertexConstantsIndex = -1; 52 | fragmentConstantsIndex = -1; 53 | 54 | useMipmapping = true; 55 | useSmoothTextures = true; 56 | repeatTextures = false; 57 | 58 | needsProjection = false; 59 | needsView = false; 60 | needsNormals = false; 61 | needsTangents = false; 62 | needsUV = false; 63 | needsSecondaryUV = false; 64 | needsGlobalVertexPos = false; 65 | needsGlobalFragmentPos = false; 66 | 67 | numLights = 0; 68 | useLightFallOff = true; 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/away3d/core/pick/AutoPickingCollider.as: -------------------------------------------------------------------------------- 1 | package away3d.core.pick 2 | { 3 | import away3d.core.base.*; 4 | 5 | import flash.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 | public class AutoPickingCollider implements IPickingCollider 16 | { 17 | private var _pbPickingCollider:PBPickingCollider; 18 | private var _as3PickingCollider:AS3PickingCollider; 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:uint = 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 AutoPickingCollider(findClosestCollision:Boolean = false) 32 | { 33 | _as3PickingCollider = new AS3PickingCollider(findClosestCollision); 34 | _pbPickingCollider = new PBPickingCollider(findClosestCollision); 35 | } 36 | 37 | /** 38 | * @inheritDoc 39 | */ 40 | public function setLocalRay(localPosition:Vector3D, localDirection:Vector3D):void 41 | { 42 | _as3PickingCollider.setLocalRay(localPosition, localDirection); 43 | _pbPickingCollider.setLocalRay(localPosition, localDirection); 44 | } 45 | 46 | /** 47 | * @inheritDoc 48 | */ 49 | public function testSubMeshCollision(subMesh:SubMesh, pickingCollisionVO:PickingCollisionVO, shortestCollisionDistance:Number):Boolean 50 | { 51 | _activePickingCollider = (subMesh.numTriangles > triangleThreshold)? _pbPickingCollider : _as3PickingCollider; 52 | return _activePickingCollider.testSubMeshCollision(subMesh, pickingCollisionVO, shortestCollisionDistance); 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/away3d/core/partition/EntityNode.as: -------------------------------------------------------------------------------- 1 | package away3d.core.partition 2 | { 3 | import away3d.arcane; 4 | import away3d.core.math.Plane3D; 5 | import away3d.core.traverse.PartitionTraverser; 6 | import away3d.entities.Entity; 7 | 8 | import flash.geom.Vector3D; 9 | 10 | use namespace arcane; 11 | 12 | /** 13 | * The EntityNode class provides an abstract base class for leaf nodes in a partition tree, containing 14 | * entities to be fed to the EntityCollector traverser. 15 | * The concrete subtype of Entity is responsible for creating a matching subtype of EntityNode. 16 | * 17 | * @see away3d.scenegraph.Entity 18 | * @see away3d.core.traverse.EntityCollector 19 | */ 20 | public class EntityNode extends NodeBase 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 | arcane 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 EntityNode(entity:Entity) 35 | { 36 | super(); 37 | _entity = entity; 38 | _numEntities = 1; 39 | } 40 | 41 | /** 42 | * The entity contained in this leaf node. 43 | */ 44 | public 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) 63 | _parent.removeNode(this); 64 | 65 | _parent = null; 66 | } 67 | 68 | override public function isInFrustum(planes:Vector., numPlanes:int):Boolean 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):Boolean 80 | { 81 | if (!_entity.isVisible) 82 | return false; 83 | 84 | return _entity.isIntersectingRay(rayPosition, rayDirection); 85 | } 86 | 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /src/away3d/events/AnimationStateEvent.as: -------------------------------------------------------------------------------- 1 | package away3d.events 2 | { 3 | import away3d.animators.*; 4 | import away3d.animators.states.*; 5 | import away3d.animators.nodes.*; 6 | 7 | import flash.events.Event; 8 | 9 | /** 10 | * Dispatched to notify changes in an animation state's state. 11 | */ 12 | public class AnimationStateEvent extends Event 13 | { 14 | /** 15 | * Dispatched when a non-looping clip node inside an animation state reaches the end of its timeline. 16 | */ 17 | public static const PLAYBACK_COMPLETE:String = "playbackComplete"; 18 | 19 | public static const TRANSITION_COMPLETE:String = "transitionComplete"; 20 | 21 | private var _animator:IAnimator; 22 | private var _animationState:IAnimationState; 23 | private var _animationNode:AnimationNodeBase; 24 | 25 | /** 26 | * Create a new AnimatonStateEvent 27 | * 28 | * @param type The event type. 29 | * @param animator The animation state object that is the subject of this event. 30 | * @param animationNode The animation node inside the animation state from which the event originated. 31 | */ 32 | public function AnimationStateEvent(type:String, animator:IAnimator, animationState:IAnimationState, animationNode:AnimationNodeBase):void 33 | { 34 | super(type, false, false); 35 | 36 | _animator = animator; 37 | _animationState = animationState; 38 | _animationNode = animationNode; 39 | } 40 | 41 | /** 42 | * The animator object that is the subject of this event. 43 | */ 44 | public function get animator():IAnimator 45 | { 46 | return _animator; 47 | } 48 | 49 | /** 50 | * The animation state object that is the subject of this event. 51 | */ 52 | public function get animationState():IAnimationState 53 | { 54 | return _animationState; 55 | } 56 | 57 | /** 58 | * The animation node inside the animation state from which the event originated. 59 | */ 60 | public function get animationNode():AnimationNodeBase 61 | { 62 | return _animationNode; 63 | } 64 | 65 | /** 66 | * Clones the event. 67 | * 68 | * @return An exact duplicate of the current object. 69 | */ 70 | override public function clone():Event 71 | { 72 | return new AnimationStateEvent(type, _animator, _animationState, _animationNode); 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/away3d/events/Object3DEvent.as: -------------------------------------------------------------------------------- 1 | package away3d.events 2 | { 3 | import away3d.core.base.*; 4 | 5 | import flash.events.Event; 6 | 7 | /** 8 | * Passed as a parameter when a 3d object event occurs 9 | */ 10 | public class Object3DEvent extends Event 11 | { 12 | /** 13 | * Defines the value of the type property of a visiblityUpdated event object. 14 | */ 15 | public static const VISIBLITY_UPDATED:String = "visiblityUpdated"; 16 | 17 | /** 18 | * Defines the value of the type property of a scenetransformChanged event object. 19 | */ 20 | public static const SCENETRANSFORM_CHANGED:String = "scenetransformChanged"; 21 | 22 | /** 23 | * Defines the value of the type property of a sceneChanged event object. 24 | */ 25 | public static const SCENE_CHANGED:String = "sceneChanged"; 26 | 27 | /** 28 | * Defines the value of the type property of a positionChanged event object. 29 | */ 30 | public static const POSITION_CHANGED:String = "positionChanged"; 31 | 32 | /** 33 | * Defines the value of the type property of a rotationChanged event object. 34 | */ 35 | public static const ROTATION_CHANGED:String = "rotationChanged"; 36 | 37 | /** 38 | * Defines the value of the type property of a scaleChanged event object. 39 | */ 40 | public static const 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 Object3DEvent(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 | public override function clone():Event 63 | { 64 | return new Object3DEvent(type, object); 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/away3d/materials/methods/ShadowMapMethodBase.as: -------------------------------------------------------------------------------- 1 | package away3d.materials.methods 2 | { 3 | import away3d.*; 4 | import away3d.errors.*; 5 | import away3d.library.assets.*; 6 | import away3d.lights.*; 7 | import away3d.lights.shadowmaps.*; 8 | import away3d.materials.compilation.*; 9 | 10 | use namespace arcane; 11 | 12 | /** 13 | * ShadowMapMethodBase provides an abstract base method for shadow map methods. 14 | */ 15 | public class ShadowMapMethodBase extends ShadingMethodBase implements IAsset 16 | { 17 | protected var _castingLight:LightBase; 18 | protected var _shadowMapper:ShadowMapperBase; 19 | 20 | protected var _epsilon:Number = .02; 21 | protected var _alpha:Number = 1; 22 | 23 | /** 24 | * Creates a new ShadowMapMethodBase object. 25 | * @param castingLight The light used to cast shadows. 26 | */ 27 | public function ShadowMapMethodBase(castingLight:LightBase) 28 | { 29 | super(); 30 | _castingLight = castingLight; 31 | castingLight.castsShadows = true; 32 | _shadowMapper = castingLight.shadowMapper; 33 | } 34 | 35 | /** 36 | * @inheritDoc 37 | */ 38 | public function get assetType():String 39 | { 40 | return AssetType.SHADOW_MAP_METHOD; 41 | } 42 | 43 | /** 44 | * The "transparency" of the shadows. This allows making shadows less strong. 45 | */ 46 | public function get alpha():Number 47 | { 48 | return _alpha; 49 | } 50 | 51 | public function set alpha(value:Number):void 52 | { 53 | _alpha = value; 54 | } 55 | 56 | /** 57 | * The light casting the shadows. 58 | */ 59 | public function get castingLight():LightBase 60 | { 61 | return _castingLight; 62 | } 63 | 64 | /** 65 | * A small value to counter floating point precision errors when comparing values in the shadow map with the 66 | * calculated depth value. Increase this if shadow banding occurs, decrease it if the shadow seems to be too detached. 67 | */ 68 | public function get epsilon():Number 69 | { 70 | return _epsilon; 71 | } 72 | 73 | public function set epsilon(value:Number):void 74 | { 75 | _epsilon = value; 76 | } 77 | 78 | /** 79 | * @inheritDoc 80 | */ 81 | arcane function getFragmentCode(vo:MethodVO, regCache:ShaderRegisterCache, targetReg:ShaderRegisterElement):String 82 | { 83 | throw new AbstractMethodError(); 84 | return null; 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/away3d/paths/CubicPath.as: -------------------------------------------------------------------------------- 1 | package away3d.paths 2 | { 3 | import flash.geom.Vector3D; 4 | 5 | /** 6 | * Defines a cubic path. Each segment of the path has two control points as opposed to CubicPathSegment which being quadratic, has one control point. 7 | * @see away3d.animators.CubicPathAnimator 8 | * @see away3d.paths.CubicPathSegment 9 | */ 10 | public class CubicPath extends SegmentedPathBase implements IPath 11 | { 12 | /** 13 | * Creates a new CubicPath instance. 14 | * @param data See pointData 15 | */ 16 | public function CubicPath(data:Vector. = null) 17 | { 18 | super(4, data); 19 | } 20 | 21 | override protected function createSegmentFromArrayEntry(data:Vector., offset:uint):IPathSegment 22 | { 23 | return new CubicPathSegment(data[offset], data[offset + 1], data[offset + 2], data[offset + 3]); 24 | } 25 | 26 | override protected function stitchSegment(start:IPathSegment, middle:IPathSegment, end:IPathSegment):void 27 | { 28 | var seg:CubicPathSegment = CubicPathSegment(middle); 29 | var prevSeg:CubicPathSegment = CubicPathSegment(start); 30 | var nextSeg:CubicPathSegment = CubicPathSegment(end); 31 | 32 | prevSeg.control1.x = (prevSeg.control1.x + seg.control1.x)*0.5; 33 | prevSeg.control1.y = (prevSeg.control1.y + seg.control1.y)*0.5; 34 | prevSeg.control1.z = (prevSeg.control1.z + seg.control1.z)*0.5; 35 | 36 | nextSeg.control1.x = (nextSeg.control1.x + seg.control1.x)*0.5; 37 | nextSeg.control1.y = (nextSeg.control1.y + seg.control1.y)*0.5; 38 | nextSeg.control1.z = (nextSeg.control1.z + seg.control1.z)*0.5; 39 | 40 | prevSeg.control2.x = (prevSeg.control2.x + seg.control2.x)*0.5; 41 | prevSeg.control2.y = (prevSeg.control2.y + seg.control2.y)*0.5; 42 | prevSeg.control2.z = (prevSeg.control2.z + seg.control2.z)*0.5; 43 | 44 | nextSeg.control2.x = (nextSeg.control2.x + seg.control2.x)*0.5; 45 | nextSeg.control2.y = (nextSeg.control2.y + seg.control2.y)*0.5; 46 | nextSeg.control2.z = (nextSeg.control2.z + seg.control2.z)*0.5; 47 | 48 | prevSeg.end.x = (seg.start.x + seg.end.x)*0.5; 49 | prevSeg.end.y = (seg.start.y + seg.end.y)*0.5; 50 | prevSeg.end.z = (seg.start.z + seg.end.z)*0.5; 51 | 52 | nextSeg.start.x = prevSeg.end.x; 53 | nextSeg.start.y = prevSeg.end.y; 54 | nextSeg.start.z = prevSeg.end.z; 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/away3d/bounds/NullBounds.as: -------------------------------------------------------------------------------- 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 flash.geom.*; 9 | 10 | /** 11 | * NullBounds represents a debug bounding "volume" that is either considered always in, or always out of the frustum. 12 | * NullBounds is useful for entities that are always considered in the frustum, such as directional lights or skyboxes. 13 | */ 14 | public class NullBounds extends BoundingVolumeBase 15 | { 16 | private var _alwaysIn:Boolean; 17 | private var _renderable:WireframePrimitiveBase; 18 | 19 | public function NullBounds(alwaysIn:Boolean = true, renderable:WireframePrimitiveBase = null) 20 | { 21 | super(); 22 | _alwaysIn = alwaysIn; 23 | _renderable = renderable; 24 | _max.x = _max.y = _max.z = Number.POSITIVE_INFINITY; 25 | _min.x = _min.y = _min.z = _alwaysIn? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY; 26 | } 27 | 28 | override public function clone():BoundingVolumeBase 29 | { 30 | return new NullBounds(_alwaysIn); 31 | } 32 | 33 | override protected function createBoundingRenderable():WireframePrimitiveBase 34 | { 35 | return _renderable || new WireframeSphere(100, 16, 12, 0xffffff, 0.5); 36 | } 37 | 38 | /** 39 | * @inheritDoc 40 | */ 41 | override public function isInFrustum(planes:Vector., numPlanes:int):Boolean 42 | { 43 | planes = planes; 44 | numPlanes = numPlanes; 45 | return _alwaysIn; 46 | } 47 | 48 | /** 49 | * @inheritDoc 50 | */ 51 | override public function fromGeometry(geometry:Geometry):void 52 | { 53 | } 54 | 55 | /** 56 | * @inheritDoc 57 | */ 58 | override public function fromSphere(center:Vector3D, radius:Number):void 59 | { 60 | } 61 | 62 | /** 63 | * @inheritDoc 64 | */ 65 | override public function fromExtremes(minX:Number, minY:Number, minZ:Number, maxX:Number, maxY:Number, maxZ:Number):void 66 | { 67 | } 68 | 69 | override public function classifyToPlane(plane:Plane3D):int 70 | { 71 | plane = plane; 72 | return PlaneClassification.INTERSECT; 73 | } 74 | 75 | override public function transformFrom(bounds:BoundingVolumeBase, matrix:Matrix3D):void 76 | { 77 | matrix = matrix; 78 | _alwaysIn = NullBounds(bounds)._alwaysIn; 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/away3d/core/traverse/RaycastCollector.as: -------------------------------------------------------------------------------- 1 | package away3d.core.traverse 2 | { 3 | import away3d.arcane; 4 | import away3d.core.base.IRenderable; 5 | import away3d.core.partition.NodeBase; 6 | import away3d.lights.LightBase; 7 | 8 | import flash.geom.Vector3D; 9 | 10 | use namespace arcane; 11 | 12 | /** 13 | * The RaycastCollector class is a traverser for scene partitions that collects all scene graph entities that are 14 | * considered intersecting with the defined ray. 15 | * 16 | * @see away3d.partition.Partition3D 17 | * @see away3d.partition.Entity 18 | */ 19 | public class RaycastCollector extends EntityCollector 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 RaycastCollector() 28 | { 29 | } 30 | 31 | /** 32 | * Provides the starting position of the ray. 33 | */ 34 | public function get rayPosition():Vector3D 35 | { 36 | return _rayPosition; 37 | } 38 | 39 | public function set rayPosition(value:Vector3D):void 40 | { 41 | _rayPosition = value; 42 | } 43 | 44 | /** 45 | * Provides the direction vector of the ray. 46 | */ 47 | public function get rayDirection():Vector3D 48 | { 49 | return _rayDirection; 50 | } 51 | 52 | public function set rayDirection(value:Vector3D):void 53 | { 54 | _rayDirection = value; 55 | } 56 | 57 | /** 58 | * 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. 59 | * 60 | * @param node The Partition3DNode object to frustum-test. 61 | */ 62 | override public function enterNode(node:NodeBase):Boolean 63 | { 64 | return node.isIntersectingRay(_rayPosition, _rayDirection); 65 | } 66 | 67 | /** 68 | * @inheritDoc 69 | */ 70 | override public function applySkyBox(renderable:IRenderable):void 71 | { 72 | } 73 | 74 | /** 75 | * Adds an IRenderable object to the potentially visible objects. 76 | * @param renderable The IRenderable object to add. 77 | */ 78 | override public function applyRenderable(renderable:IRenderable):void 79 | { 80 | } 81 | 82 | /** 83 | * @inheritDoc 84 | */ 85 | override public function applyUnknownLight(light:LightBase):void 86 | { 87 | } 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /src/away3d/animators/IAnimator.as: -------------------------------------------------------------------------------- 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 | public interface IAnimator 17 | { 18 | /** 19 | * Returns the animation data set in use by the animator. 20 | */ 21 | function get animationSet():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 | 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 | function removeOwner(mesh:Mesh):void 52 | 53 | function getAnimationState(node:AnimationNodeBase):AnimationStateBase; 54 | 55 | function getAnimationStateByName(name:String):AnimationStateBase; 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 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/away3d/loaders/parsers/Parsers.as: -------------------------------------------------------------------------------- 1 | package away3d.loaders.parsers 2 | { 3 | import away3d.loaders.misc.SingleFileLoader; 4 | 5 | public class Parsers 6 | { 7 | /** 8 | * A list of all parsers that come bundled with Away3D. Use this to quickly 9 | * enable support for all bundled parsers to the file format auto-detection 10 | * feature, using any of the enableParsers() methods on loaders, e.g.: 11 | * 12 | * AssetLibrary.enableParsers(Parsers.ALL_BUNDLED); 13 | * 14 | * Beware however that this requires all parser classes to be included in the 15 | * SWF file, which will add 50-100 kb to the file. When only a limited set of 16 | * file formats are used, SWF file size can be saved by adding the parsers 17 | * individually using AssetLibrary.enableParser() 18 | * 19 | * A third way is to specify a parser for each loaded file, thereby bypassing 20 | * the auto-detection mechanisms altogether, while at the same time allowing 21 | * any properties that are unique to that parser to be set for that load. 22 | * 23 | * The bundled parsers are: 24 | * 25 | *
    26 | *
  • AC3D (.ac)
  • 27 | *
  • Away Data version 1 ASCII and version 2 binary (.awd). AWD1 BSP unsupported
  • 28 | *
  • 3DMax (.3ds)
  • 29 | *
  • DXF (.dxf)
  • 30 | *
  • Quake 2 MD2 models (.md2)
  • 31 | *
  • Doom 3 MD5 animation clips (.md5anim)
  • 32 | *
  • Doom 3 MD5 meshes (.md5mesh)
  • 33 | *
  • Wavefront OBJ (.obj)
  • 34 | *
  • Collada (.dae)
  • 35 | *
  • Images (.jpg, .png)
  • 36 | *
37 | * 38 | * @see away3d.loading.AssetLibrary.enableParser 39 | */ 40 | public static const ALL_BUNDLED:Vector. = Vector.([ 41 | AC3DParser, AWD1Parser, AWD2Parser, AWDParser, Max3DSParser, DXFParser, 42 | MD2Parser, MD5AnimParser, MD5MeshParser, OBJParser, 43 | DAEParser 44 | ]); 45 | 46 | /** 47 | * Short-hand function to enable all bundled parsers for auto-detection. In practice, 48 | * this is the same as invoking enableParsers(Parsers.ALL_BUNDLED) on any of the 49 | * loader classes SingleFileLoader, AssetLoader, AssetLibrary or Loader3D. 50 | * 51 | * See notes about file size in the documentation for the ALL_BUNDLED constant. 52 | * 53 | * @see away3d.loaders.parsers.Parsers.ALL_BUNDLED 54 | */ 55 | public static function enableAllBundled():void 56 | { 57 | SingleFileLoader.enableParsers(ALL_BUNDLED); 58 | } 59 | } 60 | } 61 | 62 | -------------------------------------------------------------------------------- /src/away3d/core/base/data/Vertex.as: -------------------------------------------------------------------------------- 1 | package away3d.core.base.data 2 | { 3 | 4 | /** 5 | * Vertex value object. 6 | */ 7 | public class Vertex 8 | { 9 | private var _x:Number; 10 | private var _y:Number; 11 | private var _z:Number; 12 | private var _index:uint; 13 | 14 | /** 15 | * Creates a new Vertex value object. 16 | * 17 | * @param x [optional] The x value. Defaults to 0. 18 | * @param y [optional] The y value. Defaults to 0. 19 | * @param z [optional] The z value. Defaults to 0. 20 | * @param index [optional] The index value. Defaults is NaN. 21 | */ 22 | public function Vertex(x:Number = 0, y:Number = 0, z:Number = 0, index:uint = 0) 23 | { 24 | _x = x; 25 | _y = y; 26 | _z = z; 27 | _index = index; 28 | } 29 | 30 | /** 31 | * To define/store the index of value object 32 | * @param ind The index 33 | */ 34 | public function set index(ind:uint):void 35 | { 36 | _index = ind; 37 | } 38 | 39 | public function get index():uint 40 | { 41 | return _index; 42 | } 43 | 44 | /** 45 | * To define/store the x value of the value object 46 | * @param value The x value 47 | */ 48 | public function get x():Number 49 | { 50 | return _x; 51 | } 52 | 53 | public function set x(value:Number):void 54 | { 55 | _x = value; 56 | } 57 | 58 | /** 59 | * To define/store the y value of the value object 60 | * @param value The y value 61 | */ 62 | public function get y():Number 63 | { 64 | return _y; 65 | } 66 | 67 | public function set y(value:Number):void 68 | { 69 | _y = value; 70 | } 71 | 72 | /** 73 | * To define/store the z value of the value object 74 | * @param value The z value 75 | */ 76 | public function get z():Number 77 | { 78 | return _z; 79 | } 80 | 81 | public function set z(value:Number):void 82 | { 83 | _z = value; 84 | } 85 | 86 | /** 87 | * returns a new Vertex value Object 88 | */ 89 | public function clone():Vertex 90 | { 91 | return new Vertex(_x, _y, _z); 92 | } 93 | 94 | /** 95 | * returns the value object as a string for trace/debug purpose 96 | */ 97 | public function toString():String 98 | { 99 | return _x + "," + _y + "," + _z; 100 | } 101 | 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /src/away3d/animators/SpriteSheetAnimationSet.as: -------------------------------------------------------------------------------- 1 | package away3d.animators 2 | { 3 | import away3d.core.managers.Stage3DProxy; 4 | import away3d.materials.passes.MaterialPassBase; 5 | 6 | import flash.display3D.Context3D; 7 | 8 | /** 9 | * The animation data set containing the Spritesheet animation state data. 10 | * 11 | * @see away3d.animators.SpriteSheetAnimator 12 | * @see away3d.animators.SpriteSheetAnimationState 13 | */ 14 | public class SpriteSheetAnimationSet extends AnimationSetBase implements IAnimationSet 15 | { 16 | private var _agalCode:String; 17 | 18 | function SpriteSheetAnimationSet() 19 | { 20 | } 21 | 22 | /** 23 | * @inheritDoc 24 | */ 25 | public function getAGALVertexCode(pass:MaterialPassBase, sourceRegisters:Vector., targetRegisters:Vector., profile:String):String 26 | { 27 | var len:uint = targetRegisters.length; 28 | _agalCode = ""; 29 | for(var i:uint = 0; i = vo.fragmentData; 63 | data[index] = _colorTransform.redMultiplier; 64 | data[index + 1] = _colorTransform.greenMultiplier; 65 | data[index + 2] = _colorTransform.blueMultiplier; 66 | data[index + 3] = _colorTransform.alphaMultiplier; 67 | data[index + 4] = _colorTransform.redOffset*inv; 68 | data[index + 5] = _colorTransform.greenOffset*inv; 69 | data[index + 6] = _colorTransform.blueOffset*inv; 70 | data[index + 7] = _colorTransform.alphaOffset*inv; 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/away3d/animators/nodes/VertexClipNode.as: -------------------------------------------------------------------------------- 1 | package away3d.animators.nodes 2 | { 3 | import away3d.animators.states.*; 4 | import away3d.core.base.*; 5 | 6 | import flash.geom.*; 7 | 8 | /** 9 | * A vertex animation node containing time-based animation data as individual geometry obejcts. 10 | */ 11 | public class VertexClipNode extends AnimationClipNodeBase 12 | { 13 | private var _frames:Vector. = new Vector.(); 14 | private var _translations:Vector. = new Vector.(); 15 | 16 | /** 17 | * Returns a vector of geometry frames representing the vertex values of each animation frame in the clip. 18 | */ 19 | public function get frames():Vector. 20 | { 21 | return _frames; 22 | } 23 | 24 | /** 25 | * Creates a new VertexClipNode object. 26 | */ 27 | public function VertexClipNode() 28 | { 29 | _stateClass = VertexClipState; 30 | } 31 | 32 | /** 33 | * Adds a geometry object to the internal timeline of the animation node. 34 | * 35 | * @param geometry The geometry object to add to the timeline of the node. 36 | * @param duration The specified duration of the frame in milliseconds. 37 | * @param translation The absolute translation of the frame, used in root delta calculations for mesh movement. 38 | */ 39 | public function addFrame(geometry:Geometry, duration:uint, translation:Vector3D = null):void 40 | { 41 | _frames.push(geometry); 42 | _durations.push(duration); 43 | _translations.push(translation || new Vector3D()); 44 | 45 | _numFrames = _durations.length; 46 | 47 | _stitchDirty = true; 48 | } 49 | 50 | /** 51 | * @inheritDoc 52 | */ 53 | override protected function updateStitch():void 54 | { 55 | super.updateStitch(); 56 | 57 | var i:uint = _numFrames - 1; 58 | var p1:Vector3D, p2:Vector3D, delta:Vector3D; 59 | while (i--) { 60 | _totalDuration += _durations[i]; 61 | p1 = _translations[i]; 62 | p2 = _translations[i + 1]; 63 | delta = p2.subtract(p1); 64 | _totalDelta.x += delta.x; 65 | _totalDelta.y += delta.y; 66 | _totalDelta.z += delta.z; 67 | } 68 | 69 | if (_stitchFinalFrame && _looping) { 70 | _totalDuration += _durations[_numFrames - 1]; 71 | if (_numFrames > 1) { 72 | p1 = _translations[0]; 73 | p2 = _translations[1]; 74 | delta = p2.subtract(p1); 75 | _totalDelta.x += delta.x; 76 | _totalDelta.y += delta.y; 77 | _totalDelta.z += delta.z; 78 | } 79 | } 80 | } 81 | } 82 | } 83 | --------------------------------------------------------------------------------