├── .gitignore
├── README.markdown
├── away3d
├── Away3D.hx
├── animators
│ ├── AnimationSetBase.hx
│ ├── AnimatorBase.hx
│ ├── IAnimationSet.hx
│ ├── IAnimator.hx
│ ├── ParticleAnimationSet.hx
│ ├── ParticleAnimator.hx
│ ├── PathAnimator.hx
│ ├── SkeletonAnimationSet.hx
│ ├── SkeletonAnimator.hx
│ ├── SpriteSheetAnimationSet.hx
│ ├── SpriteSheetAnimator.hx
│ ├── UVAnimationSet.hx
│ ├── UVAnimator.hx
│ ├── VertexAnimationSet.hx
│ ├── VertexAnimator.hx
│ ├── data
│ │ ├── AnimationRegisterCache.hx
│ │ ├── AnimationSubGeometry.hx
│ │ ├── ColorSegmentPoint.hx
│ │ ├── JointPose.hx
│ │ ├── ParticleAnimationData.hx
│ │ ├── ParticleProperties.hx
│ │ ├── ParticlePropertiesMode.hx
│ │ ├── Skeleton.hx
│ │ ├── SkeletonJoint.hx
│ │ ├── SkeletonPose.hx
│ │ ├── SpriteSheetAnimationFrame.hx
│ │ ├── UVAnimationFrame.hx
│ │ └── VertexAnimationMode.hx
│ ├── nodes
│ │ ├── AnimationClipNodeBase.hx
│ │ ├── AnimationNodeBase.hx
│ │ ├── ISpriteSheetAnimationNode.hx
│ │ ├── ParticleAccelerationNode.hx
│ │ ├── ParticleBezierCurveNode.hx
│ │ ├── ParticleBillboardNode.hx
│ │ ├── ParticleColorNode.hx
│ │ ├── ParticleFollowNode.hx
│ │ ├── ParticleInitialColorNode.hx
│ │ ├── ParticleNodeBase.hx
│ │ ├── ParticleOrbitNode.hx
│ │ ├── ParticleOscillatorNode.hx
│ │ ├── ParticlePositionNode.hx
│ │ ├── ParticleRotateToHeadingNode.hx
│ │ ├── ParticleRotateToPositionNode.hx
│ │ ├── ParticleRotationalVelocityNode.hx
│ │ ├── ParticleScaleNode.hx
│ │ ├── ParticleSegmentedColorNode.hx
│ │ ├── ParticleSegmentedScaleNode.hx
│ │ ├── ParticleSpriteSheetNode.hx
│ │ ├── ParticleTimeNode.hx
│ │ ├── ParticleUVNode.hx
│ │ ├── ParticleVelocityNode.hx
│ │ ├── SkeletonBinaryLERPNode.hx
│ │ ├── SkeletonClipNode.hx
│ │ ├── SkeletonDifferenceNode.hx
│ │ ├── SkeletonDirectionalNode.hx
│ │ ├── SkeletonNaryLERPNode.hx
│ │ ├── SpriteSheetClipNode.hx
│ │ ├── UVClipNode.hx
│ │ └── VertexClipNode.hx
│ ├── states
│ │ ├── AnimationClipState.hx
│ │ ├── AnimationStateBase.hx
│ │ ├── IAnimationState.hx
│ │ ├── ISkeletonAnimationState.hx
│ │ ├── ISpriteSheetAnimationState.hx
│ │ ├── IUVAnimationState.hx
│ │ ├── IVertexAnimationState.hx
│ │ ├── ParticleAccelerationState.hx
│ │ ├── ParticleBezierCurveState.hx
│ │ ├── ParticleBillboardState.hx
│ │ ├── ParticleColorState.hx
│ │ ├── ParticleFollowState.hx
│ │ ├── ParticleInitialColorState.hx
│ │ ├── ParticleOrbitState.hx
│ │ ├── ParticleOscillatorState.hx
│ │ ├── ParticlePositionState.hx
│ │ ├── ParticleRotateToHeadingState.hx
│ │ ├── ParticleRotateToPositionState.hx
│ │ ├── ParticleRotationalVelocityState.hx
│ │ ├── ParticleScaleState.hx
│ │ ├── ParticleSegmentedColorState.hx
│ │ ├── ParticleSegmentedScaleState.hx
│ │ ├── ParticleSpriteSheetState.hx
│ │ ├── ParticleStateBase.hx
│ │ ├── ParticleTimeState.hx
│ │ ├── ParticleUVState.hx
│ │ ├── ParticleVelocityState.hx
│ │ ├── SkeletonBinaryLERPState.hx
│ │ ├── SkeletonClipState.hx
│ │ ├── SkeletonDifferenceState.hx
│ │ ├── SkeletonDirectionalState.hx
│ │ ├── SkeletonNaryLERPState.hx
│ │ ├── SpriteSheetAnimationState.hx
│ │ ├── UVClipState.hx
│ │ └── VertexClipState.hx
│ ├── transitions
│ │ ├── CrossfadeTransition.hx
│ │ ├── CrossfadeTransitionNode.hx
│ │ ├── CrossfadeTransitionState.hx
│ │ └── IAnimationTransition.hx
│ └── utils
│ │ └── SkeletonUtils.hx
├── audio
│ ├── Sound3D.hx
│ ├── SoundTransform3D.hx
│ └── drivers
│ │ ├── AbstractSound3DDriver.hx
│ │ ├── ISound3DDriver.hx
│ │ └── SimplePanVolumeDriver.hx
├── bounds
│ ├── AxisAlignedBoundingBox.hx
│ ├── BoundingSphere.hx
│ ├── BoundingVolumeBase.hx
│ └── NullBounds.hx
├── cameras
│ ├── Camera3D.hx
│ └── lenses
│ │ ├── FreeMatrixLens.hx
│ │ ├── LensBase.hx
│ │ ├── ObliqueNearPlaneLens.hx
│ │ ├── OrthographicLens.hx
│ │ ├── OrthographicOffCenterLens.hx
│ │ ├── PerspectiveLens.hx
│ │ └── PerspectiveOffCenterLens.hx
├── containers
│ ├── ObjectContainer3D.hx
│ ├── Scene3D.hx
│ └── View3D.hx
├── controllers
│ ├── ControllerBase.hx
│ ├── FirstPersonController.hx
│ ├── FollowController.hx
│ ├── HoverController.hx
│ ├── LookAtController.hx
│ └── SpringController.hx
├── core
│ ├── base
│ │ ├── CompactSubGeometry.hx
│ │ ├── Geometry.hx
│ │ ├── IMaterialOwner.hx
│ │ ├── IRenderable.hx
│ │ ├── ISubGeometry.hx
│ │ ├── Object3D.hx
│ │ ├── ParticleGeometry.hx
│ │ ├── SkinnedSubGeometry.hx
│ │ ├── SubGeometry.hx
│ │ ├── SubGeometryBase.hx
│ │ ├── SubMesh.hx
│ │ └── data
│ │ │ ├── Face.hx
│ │ │ ├── ParticleData.hx
│ │ │ ├── UV.hx
│ │ │ └── Vertex.hx
│ ├── data
│ │ ├── EntityListItem.hx
│ │ ├── EntityListItemPool.hx
│ │ ├── RenderableListItem.hx
│ │ └── RenderableListItemPool.hx
│ ├── managers
│ │ ├── AGALProgram3DCache.hx
│ │ ├── Mouse3DManager.hx
│ │ ├── RTTBufferManager.hx
│ │ ├── Stage3DManager.hx
│ │ ├── Stage3DProxy.hx
│ │ └── Touch3DManager.hx
│ ├── math
│ │ ├── MathConsts.hx
│ │ ├── Matrix3DUtils.hx
│ │ ├── Plane3D.hx
│ │ ├── PlaneClassification.hx
│ │ ├── PoissonLookup.hx
│ │ ├── Quaternion.hx
│ │ └── Vector3DUtils.hx
│ ├── partition
│ │ ├── CameraNode.hx
│ │ ├── DirectionalLightNode.hx
│ │ ├── DynamicGrid.hx
│ │ ├── EntityNode.hx
│ │ ├── InvertedOctreeNode.hx
│ │ ├── LightNode.hx
│ │ ├── LightProbeNode.hx
│ │ ├── MeshNode.hx
│ │ ├── NodeBase.hx
│ │ ├── NullNode.hx
│ │ ├── Octree.hx
│ │ ├── OctreeNode.hx
│ │ ├── Partition3D.hx
│ │ ├── PointLightNode.hx
│ │ ├── QuadTree.hx
│ │ ├── QuadTreeNode.hx
│ │ ├── RenderableNode.hx
│ │ ├── SkyBoxNode.hx
│ │ ├── ViewVolume.hx
│ │ ├── ViewVolumePartition.hx
│ │ └── ViewVolumeRootNode.hx
│ ├── pick
│ │ ├── IPicker.hx
│ │ ├── IPickingCollider.hx
│ │ ├── PickingCollider.hx
│ │ ├── PickingColliderBase.hx
│ │ ├── PickingColliderType.hx
│ │ ├── PickingCollisionVO.hx
│ │ ├── PickingType.hx
│ │ ├── RaycastPicker.hx
│ │ └── ShaderPicker.hx
│ ├── render
│ │ ├── BackgroundImageRenderer.hx
│ │ ├── DefaultRenderer.hx
│ │ ├── DepthRenderer.hx
│ │ ├── Filter3DRenderer.hx
│ │ ├── PositionRenderer.hx
│ │ └── RendererBase.hx
│ ├── sort
│ │ ├── IEntitySorter.hx
│ │ └── RenderableMergeSort.hx
│ └── traverse
│ │ ├── EntityCollector.hx
│ │ ├── PartitionTraverser.hx
│ │ ├── RaycastCollector.hx
│ │ ├── SceneIterator.hx
│ │ └── ShadowCasterCollector.hx
├── debug
│ ├── AwayFPS.hx
│ ├── AwayStats.hx
│ ├── Debug.hx
│ ├── Trident.hx
│ ├── WireframeAxesGrid.hx
│ └── data
│ │ └── TridentLines.hx
├── entities
│ ├── Entity.hx
│ ├── Mesh.hx
│ ├── SegmentSet.hx
│ ├── Sprite3D.hx
│ └── TextureProjector.hx
├── errors
│ ├── AbstractMethodError.hx
│ ├── AnimationSetError.hx
│ ├── CastError.hx
│ ├── DeprecationError.hx
│ └── InvalidTextureError.hx
├── events
│ ├── AnimationStateEvent.hx
│ ├── AnimatorEvent.hx
│ ├── Asset3DEvent.hx
│ ├── CameraEvent.hx
│ ├── GeometryEvent.hx
│ ├── LensEvent.hx
│ ├── LightEvent.hx
│ ├── LoaderEvent.hx
│ ├── MouseEvent3D.hx
│ ├── Object3DEvent.hx
│ ├── ParserEvent.hx
│ ├── PathEvent.hx
│ ├── Scene3DEvent.hx
│ ├── ShadingMethodEvent.hx
│ ├── Stage3DEvent.hx
│ └── TouchEvent3D.hx
├── extrusions
│ ├── DelaunayMesh.hx
│ ├── Elevation.hx
│ ├── LatheExtrude.hx
│ ├── LinearExtrude.hx
│ ├── PathDuplicator.hx
│ ├── PathExtrude.hx
│ ├── SkinExtrude.hx
│ └── data
│ │ ├── FourPoints.hx
│ │ ├── Line.hx
│ │ ├── RenderSide.hx
│ │ └── SubGeometryList.hx
├── filters
│ ├── BloomFilter3D.hx
│ ├── BlurFilter3D.hx
│ ├── DepthOfFieldFilter3D.hx
│ ├── Filter3DBase.hx
│ ├── HBlurFilter3D.hx
│ ├── HDepthOfFieldFilter3D.hx
│ ├── HueSaturationFilter3D.hx
│ ├── MotionBlurFilter3D.hx
│ ├── RadialBlurFilter3D.hx
│ ├── VBlurFilter3D.hx
│ ├── VDepthOfFieldFilter3D.hx
│ └── tasks
│ │ ├── Filter3DBloomCompositeTask.hx
│ │ ├── Filter3DBrightPassTask.hx
│ │ ├── Filter3DCompositeTask.hx
│ │ ├── Filter3DDoubleBufferCopyTask.hx
│ │ ├── Filter3DHBlurTask.hx
│ │ ├── Filter3DHDepthOfFFieldTask.hx
│ │ ├── Filter3DHueSaturationTask.hx
│ │ ├── Filter3DRadialBlurTask.hx
│ │ ├── Filter3DTaskBase.hx
│ │ ├── Filter3DVBlurTask.hx
│ │ ├── Filter3DVDepthOfFFieldTask.hx
│ │ └── Filter3DXFadeCompositeTask.hx
├── library
│ ├── Asset3DLibrary.hx
│ ├── Asset3DLibraryBundle.hx
│ ├── assets
│ │ ├── Asset3DType.hx
│ │ ├── BitmapDataAsset.hx
│ │ ├── IAsset.hx
│ │ └── NamedAssetBase.hx
│ ├── naming
│ │ ├── ConflictPrecedence.hx
│ │ ├── ConflictStrategy.hx
│ │ ├── ConflictStrategyBase.hx
│ │ ├── ErrorConflictStrategy.hx
│ │ ├── IgnoreConflictStrategy.hx
│ │ └── NumSuffixConflictStrategy.hx
│ └── utils
│ │ ├── Asset3DLibraryIterator.hx
│ │ └── IDUtil.hx
├── lights
│ ├── DirectionalLight.hx
│ ├── LightBase.hx
│ ├── LightProbe.hx
│ ├── PointLight.hx
│ └── shadowmaps
│ │ ├── CascadeShadowMapper.hx
│ │ ├── CubeMapShadowMapper.hx
│ │ ├── DirectionalShadowMapper.hx
│ │ ├── NearDirectionalShadowMapper.hx
│ │ └── ShadowMapperBase.hx
├── loaders
│ ├── AssetLoader.hx
│ ├── Loader3D.hx
│ ├── misc
│ │ ├── AssetLoaderContext.hx
│ │ ├── AssetLoaderToken.hx
│ │ ├── ResourceDependency.hx
│ │ └── SingleFileLoader.hx
│ └── parsers
│ │ ├── AC3DParser.hx
│ │ ├── AWD1Parser.hx
│ │ ├── AWD2Parser.hx
│ │ ├── AWDParser.hx
│ │ ├── DAEParser.hx
│ │ ├── DXFParser.hx
│ │ ├── ImageParser.hx
│ │ ├── MD2Parser.hx
│ │ ├── MD5AnimParser.hx
│ │ ├── MD5MeshParser.hx
│ │ ├── Max3DSParser.hx
│ │ ├── OBJParser.hx
│ │ ├── ParserBase.hx
│ │ ├── ParserDataFormat.hx
│ │ ├── Parsers.hx
│ │ └── utils
│ │ └── ParserUtil.hx
├── materials
│ ├── ColorMaterial.hx
│ ├── ColorMultiPassMaterial.hx
│ ├── LightSources.hx
│ ├── MaterialBase.hx
│ ├── MultiPassMaterialBase.hx
│ ├── OcclusionMaterial.hx
│ ├── SegmentMaterial.hx
│ ├── SinglePassMaterialBase.hx
│ ├── SkyBoxMaterial.hx
│ ├── SpriteSheetMaterial.hx
│ ├── TextureMaterial.hx
│ ├── TextureMultiPassMaterial.hx
│ ├── compilation
│ │ ├── LightingShaderCompiler.hx
│ │ ├── MethodDependencyCounter.hx
│ │ ├── RegisterPool.hx
│ │ ├── ShaderCompiler.hx
│ │ ├── ShaderRegisterCache.hx
│ │ ├── ShaderRegisterData.hx
│ │ ├── ShaderRegisterElement.hx
│ │ └── SuperShaderCompiler.hx
│ ├── lightpickers
│ │ ├── LightPickerBase.hx
│ │ └── StaticLightPicker.hx
│ ├── methods
│ │ ├── AlphaMaskMethod.hx
│ │ ├── AnisotropicSpecularMethod.hx
│ │ ├── BasicAmbientMethod.hx
│ │ ├── BasicDiffuseMethod.hx
│ │ ├── BasicNormalMethod.hx
│ │ ├── BasicSpecularMethod.hx
│ │ ├── CascadeShadowMapMethod.hx
│ │ ├── CelDiffuseMethod.hx
│ │ ├── CelSpecularMethod.hx
│ │ ├── ColorMatrixMethod.hx
│ │ ├── ColorTransformMethod.hx
│ │ ├── CompositeDiffuseMethod.hx
│ │ ├── CompositeSpecularMethod.hx
│ │ ├── DepthDiffuseMethod.hx
│ │ ├── DitheredShadowMapMethod.hx
│ │ ├── EffectMethodBase.hx
│ │ ├── EnvMapAmbientMethod.hx
│ │ ├── EnvMapMethod.hx
│ │ ├── FilteredShadowMapMethod.hx
│ │ ├── FogMethod.hx
│ │ ├── FresnelEnvMapMethod.hx
│ │ ├── FresnelPlanarReflectionMethod.hx
│ │ ├── FresnelSpecularMethod.hx
│ │ ├── GradientDiffuseMethod.hx
│ │ ├── HardShadowMapMethod.hx
│ │ ├── HeightMapNormalMethod.hx
│ │ ├── LightMapDiffuseMethod.hx
│ │ ├── LightMapMethod.hx
│ │ ├── LightingMethodBase.hx
│ │ ├── MethodVO.hx
│ │ ├── MethodVOSet.hx
│ │ ├── NearShadowMapMethod.hx
│ │ ├── OutlineMethod.hx
│ │ ├── PhongSpecularMethod.hx
│ │ ├── PlanarReflectionMethod.hx
│ │ ├── ProjectiveTextureMethod.hx
│ │ ├── RefractionEnvMapMethod.hx
│ │ ├── RimLightMethod.hx
│ │ ├── ShaderMethodSetup.hx
│ │ ├── ShadingMethodBase.hx
│ │ ├── ShadowMapMethodBase.hx
│ │ ├── SimpleShadowMapMethodBase.hx
│ │ ├── SimpleWaterNormalMethod.hx
│ │ ├── SoftShadowMapMethod.hx
│ │ ├── SubsurfaceScatteringDiffuseMethod.hx
│ │ ├── TerrainDiffuseMethod.hx
│ │ ├── TripleFilteredShadowMapMethod.hx
│ │ └── WrapDiffuseMethod.hx
│ ├── passes
│ │ ├── CompiledPass.hx
│ │ ├── DepthMapPass.hx
│ │ ├── DistanceMapPass.hx
│ │ ├── LightingPass.hx
│ │ ├── MaterialPassBase.hx
│ │ ├── OutlinePass.hx
│ │ ├── SegmentPass.hx
│ │ ├── ShadowCasterPass.hx
│ │ ├── SingleObjectDepthPass.hx
│ │ ├── SkyBoxPass.hx
│ │ └── SuperShaderPass.hx
│ └── utils
│ │ ├── DefaultMaterialManager.hx
│ │ ├── IVideoPlayer.hx
│ │ ├── MipmapGenerator.hx
│ │ ├── MultipleMaterials.hx
│ │ ├── SimpleVideoPlayer.hx
│ │ └── WireframeMapGenerator.hx
├── paths
│ ├── CubicPath.hx
│ ├── CubicPathSegment.hx
│ ├── IPath.hx
│ ├── IPathSegment.hx
│ ├── QuadraticPath.hx
│ ├── QuadraticPathSegment.hx
│ └── SegmentedPathBase.hx
├── primitives
│ ├── CapsuleGeometry.hx
│ ├── ConeGeometry.hx
│ ├── CubeGeometry.hx
│ ├── CylinderGeometry.hx
│ ├── LineSegment.hx
│ ├── NURBSGeometry.hx
│ ├── PlaneGeometry.hx
│ ├── PrimitiveBase.hx
│ ├── RegularPolygonGeometry.hx
│ ├── SkyBox.hx
│ ├── SphereGeometry.hx
│ ├── TorusGeometry.hx
│ ├── WireframeCube.hx
│ ├── WireframeCylinder.hx
│ ├── WireframePlane.hx
│ ├── WireframePrimitiveBase.hx
│ ├── WireframeRegularPolygon.hx
│ ├── WireframeSphere.hx
│ ├── WireframeTetrahedron.hx
│ └── data
│ │ ├── NURBSVertex.hx
│ │ └── Segment.hx
├── stereo
│ ├── StereoCamera3D.hx
│ ├── StereoRenderer.hx
│ ├── StereoView3D.hx
│ └── methods
│ │ ├── AnaglyphStereoRenderMethod.hx
│ │ ├── InterleavedStereoRenderMethod.hx
│ │ ├── SBSStereoRenderMethod.hx
│ │ └── StereoRenderMethodBase.hx
├── textfield
│ ├── BitmapChar.hx
│ ├── BitmapFont.hx
│ ├── CharLocation.hx
│ ├── CleanMasterString.hx
│ ├── HAlign.hx
│ ├── MiniBitmapFont.hx
│ ├── RectangleBitmapTexture.hx
│ ├── TextField.hx
│ ├── VAlign.hx
│ └── utils
│ │ ├── AwayFont.hx
│ │ ├── FontContainer.hx
│ │ └── FontSize.hx
├── textures
│ ├── ATFCubeTexture.hx
│ ├── ATFData.hx
│ ├── ATFTexture.hx
│ ├── Anisotropy.hx
│ ├── BitmapCubeTexture.hx
│ ├── BitmapTexture.hx
│ ├── BitmapTextureCache.hx
│ ├── CubeReflectionTexture.hx
│ ├── CubeTextureBase.hx
│ ├── PlanarReflectionTexture.hx
│ ├── RenderCubeTexture.hx
│ ├── RenderTexture.hx
│ ├── SpecularBitmapTexture.hx
│ ├── Texture2DBase.hx
│ ├── TextureProxyBase.hx
│ ├── VideoTexture.hx
│ └── WebcamTexture.hx
├── tools
│ ├── commands
│ │ ├── Align.hx
│ │ ├── Explode.hx
│ │ ├── Merge.hx
│ │ ├── Mirror.hx
│ │ ├── SphereMaker.hx
│ │ └── Weld.hx
│ ├── helpers
│ │ ├── FaceHelper.hx
│ │ ├── LightsHelper.hx
│ │ ├── MeshDebugger.hx
│ │ ├── MeshHelper.hx
│ │ ├── ParticleGeometryHelper.hx
│ │ ├── SpriteSheetHelper.hx
│ │ └── data
│ │ │ ├── MeshDebug.hx
│ │ │ └── ParticleGeometryTransform.hx
│ ├── serialize
│ │ ├── Serialize.hx
│ │ ├── SerializerBase.hx
│ │ └── TraceSerializer.hx
│ └── utils
│ │ ├── Bounds.hx
│ │ ├── ColorHitMap.hx
│ │ ├── Drag3D.hx
│ │ ├── GeomUtil.hx
│ │ ├── Grid.hx
│ │ ├── Projector.hx
│ │ ├── Ray.hx
│ │ └── TextureUtils.hx
└── utils
│ ├── ArrayUtils.hx
│ └── Cast.hx
├── haxelib.json
└── include.xml
/.gitignore:
--------------------------------------------------------------------------------
1 | /*.DS_Store
2 |
--------------------------------------------------------------------------------
/away3d/Away3D.hx:
--------------------------------------------------------------------------------
1 | /**
2 | * Helper class to track a few important library constants.
3 | */
4 | package away3d;
5 |
6 | class Away3D {
7 |
8 | static public var WEBSITE_URL:String = "http://www.away3d.com";
9 | static public var MAJOR_VERSION:Int = 4;
10 | static public var MINOR_VERSION:Int = 1;
11 | static public var REVISION:Int = 5;
12 | }
13 |
14 |
--------------------------------------------------------------------------------
/away3d/animators/IAnimator.hx:
--------------------------------------------------------------------------------
1 | /**
2 | * Provides an interface for animator classes that control animation output from a data set subtype of AnimationSetBase
.
3 | *
4 | * @see away3d.animators.IAnimationSet
5 | */
6 | package away3d.animators;
7 | import away3d.animators.states.AnimationStateBase;
8 | import away3d.animators.nodes.AnimationNodeBase;
9 | import away3d.entities.Mesh;
10 | import away3d.core.managers.Stage3DProxy;
11 | import away3d.core.base.IRenderable;
12 | import away3d.cameras.Camera3D;
13 | import away3d.materials.passes.MaterialPassBase;
14 |
15 | interface IAnimator {
16 | var animationSet(get, never):IAnimationSet;
17 |
18 | /**
19 | * Returns the animation data set in use by the animator.
20 | */
21 | private function get_animationSet():IAnimationSet;
22 | /**
23 | * Sets the GPU render state required by the animation that is dependent of the rendered object.
24 | *
25 | * @param stage3DProxy The Stage3DProxy object which is currently being used for rendering.
26 | * @param renderable The object currently being rendered.
27 | * @param vertexConstantOffset The first available vertex register to write data to if running on the gpu.
28 | * @param vertexStreamOffset The first available vertex stream to write vertex data to if running on the gpu.
29 | */
30 | function setRenderState(stage3DProxy:Stage3DProxy, renderable:IRenderable, vertexConstantOffset:Int, vertexStreamOffset:Int, camera:Camera3D):Void;
31 | function testGPUCompatibility(pass:MaterialPassBase):Void;
32 | /**
33 | * Used by the mesh object to which the animator is applied, registers the owner for internal use.
34 | *
35 | * @private
36 | */
37 | function addOwner(mesh:Mesh):Void;
38 | function removeOwner(mesh:Mesh):Void;
39 | function getAnimationState(node:AnimationNodeBase):AnimationStateBase;
40 | function getAnimationStateByName(name:String):AnimationStateBase;
41 | /**
42 | * Returns a shallow clone (re-using the same IAnimationSet) of this IAnimator.
43 | */
44 | function clone():IAnimator;
45 | function dispose():Void;
46 | }
47 |
48 |
--------------------------------------------------------------------------------
/away3d/animators/SpriteSheetAnimationSet.hx:
--------------------------------------------------------------------------------
1 | /**
2 | * The animation data set containing the Spritesheet animation state data.
3 | *
4 | * @see away3d.animators.SpriteSheetAnimator
5 | * @see away3d.animators.SpriteSheetAnimationState
6 | */
7 | package away3d.animators;
8 |
9 | import away3d.core.managers.Stage3DProxy;
10 | import away3d.materials.passes.MaterialPassBase;
11 | import openfl.display3D.Context3D;
12 | import openfl.Vector;
13 |
14 | class SpriteSheetAnimationSet extends AnimationSetBase implements IAnimationSet {
15 |
16 | private var _agalCode:String;
17 |
18 | public function new() {
19 | super();
20 | }
21 |
22 | /**
23 | * @inheritDoc
24 | */
25 | public function getAGALVertexCode(pass:MaterialPassBase, sourceRegisters:Vector, targetRegisters:Vector, profile:String):String {
26 | _agalCode = "mov " + targetRegisters[0] + ", " + sourceRegisters[0] + "\n";
27 | return "";
28 | }
29 |
30 | /**
31 | * @inheritDoc
32 | */
33 | public function activate(stage3DProxy:Stage3DProxy, pass:MaterialPassBase):Void {
34 | }
35 |
36 | /**
37 | * @inheritDoc
38 | */
39 | public function deactivate(stage3DProxy:Stage3DProxy, pass:MaterialPassBase):Void {
40 | var context:Context3D = stage3DProxy.context3D;
41 | context.setVertexBufferAt(0, null);
42 | }
43 |
44 | /**
45 | * @inheritDoc
46 | */
47 | public function getAGALFragmentCode(pass:MaterialPassBase, shadedTarget:String, profile:String):String {
48 | return "";
49 | }
50 |
51 | /**
52 | * @inheritDoc
53 | */
54 | public function getAGALUVCode(pass:MaterialPassBase, UVSource:String, UVTarget:String):String {
55 | var tempUV:String = "vt" + UVSource.substring(2, 3);
56 | var idConstant:Int = pass.numUsedVertexConstants;
57 | var constantRegID:String = "vc" + idConstant;
58 | _agalCode += "mov " + tempUV + ", " + UVSource + "\n";
59 | _agalCode += "mul " + tempUV + ".xy, " + tempUV + ".xy, " + constantRegID + ".zw \n";
60 | _agalCode += "add " + tempUV + ".xy, " + tempUV + ".xy, " + constantRegID + ".xy \n";
61 | _agalCode += "mov " + UVTarget + ", " + tempUV + "\n";
62 | return _agalCode;
63 | }
64 |
65 | /**
66 | * @inheritDoc
67 | */
68 | public function doneAGALCode(pass:MaterialPassBase):Void {
69 | }
70 | }
71 |
72 |
--------------------------------------------------------------------------------
/away3d/animators/data/ColorSegmentPoint.hx:
--------------------------------------------------------------------------------
1 | package away3d.animators.data;
2 |
3 | import openfl.errors.Error;
4 | import openfl.geom.ColorTransform;
5 |
6 | class ColorSegmentPoint {
7 | public var color(get, never):ColorTransform;
8 | public var life(get, never):Float;
9 |
10 | private var _color:ColorTransform;
11 | private var _life:Float;
12 |
13 | public function new(life:Float, color:ColorTransform) {
14 | //0= 1) throw (new Error("life exceeds range (0,1)"));
16 | _life = life;
17 | _color = color;
18 | }
19 |
20 | private function get_color():ColorTransform {
21 | return _color;
22 | }
23 |
24 | private function get_life():Float {
25 | return _life;
26 | }
27 | }
28 |
29 |
--------------------------------------------------------------------------------
/away3d/animators/data/JointPose.hx:
--------------------------------------------------------------------------------
1 | /**
2 | * Contains transformation data for a skeleton joint, used for skeleton animation.
3 | *
4 | * @see away3d.animation.data.Skeleton
5 | * @see away3d.animation.data.SkeletonJoint
6 | *
7 | * todo: support (uniform) scale
8 | */
9 | package away3d.animators.data;
10 |
11 | import openfl.geom.Matrix3D;
12 | import openfl.geom.Vector3D;
13 | import away3d.core.math.Quaternion;
14 |
15 | class JointPose {
16 |
17 | /**
18 | * The name of the joint to which the pose is associated
19 | */
20 | public var name:String;
21 |
22 | // intention is that this should be used only at load time, not in the main loop
23 | /**
24 | * The rotation of the pose stored as a quaternion
25 | */
26 | public var orientation:Quaternion;
27 |
28 | /**
29 | * The translation of the pose
30 | */
31 | public var translation:Vector3D;
32 |
33 | public function new() {
34 | orientation = new Quaternion();
35 | translation = new Vector3D();
36 | }
37 |
38 | /**
39 | * Converts the transformation to a Matrix3D representation.
40 | *
41 | * @param target An optional target matrix to store the transformation. If not provided, it will create a new instance.
42 | * @return The transformation matrix of the pose.
43 | */
44 | public function toMatrix3D(target:Matrix3D = null):Matrix3D {
45 | if (target == null)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 | var or:Quaternion = pose.orientation;
58 | var tr:Vector3D = pose.translation;
59 | orientation.x = or.x;
60 | orientation.y = or.y;
61 | orientation.z = or.z;
62 | orientation.w = or.w;
63 | translation.x = tr.x;
64 | translation.y = tr.y;
65 | translation.z = tr.z;
66 | }
67 | }
68 |
69 |
--------------------------------------------------------------------------------
/away3d/animators/data/ParticleAnimationData.hx:
--------------------------------------------------------------------------------
1 | /**
2 | * ...
3 | */
4 | package away3d.animators.data;
5 |
6 | import away3d.core.base.data.ParticleData;
7 |
8 | class ParticleAnimationData {
9 |
10 | public var index:Int;
11 | public var startTime:Float;
12 | public var totalTime:Float;
13 | public var duration:Float;
14 | public var delay:Float;
15 | public var startVertexIndex:Int;
16 | public var numVertices:Int;
17 |
18 | public function new(index:Int, startTime:Float, duration:Float, delay:Float, particle:ParticleData) {
19 | this.index = index;
20 | this.startTime = startTime;
21 | this.totalTime = duration + delay;
22 | this.duration = duration;
23 | this.delay = delay;
24 | this.startVertexIndex = particle.startVertexIndex;
25 | this.numVertices = particle.numVertices;
26 | }
27 | }
28 |
29 |
--------------------------------------------------------------------------------
/away3d/animators/data/ParticleProperties.hx:
--------------------------------------------------------------------------------
1 | /**
2 | * Dynamic class for holding the local properties of a particle, used for processing the static properties
3 | * of particles in the particle animation set before beginning upload to the GPU.
4 | */
5 | package away3d.animators.data;
6 |
7 | import haxe.ds.StringMap;
8 |
9 | class ParticleProperties {
10 |
11 | /**
12 | * The index of the current particle being set.
13 | */
14 | public var index:Int;
15 |
16 | /**
17 | * The total number of particles being processed by the particle animation set.
18 | */
19 | public var total:Int;
20 |
21 | /**
22 | * The start time of the particle.
23 | */
24 | public var startTime:Float;
25 |
26 | /**
27 | * The duration of the particle, an optional value used when the particle aniamtion set settings for useDuration
are enabled in the constructor.
28 | *
29 | * @see away3d.animators.ParticleAnimationSet
30 | */
31 | public var duration:Float;
32 |
33 | /**
34 | * 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.
35 | *
36 | * @see away3d.animators.ParticleAnimationSet
37 | */
38 | public var delay:Float;
39 |
40 | /**
41 | * 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.
42 | *
43 | * @see away3d.animators.ParticleAnimationSet
44 | */
45 | public var nodes:StringMap;
46 |
47 | public function new() {
48 | nodes = new StringMap();
49 | }
50 | }
51 |
52 |
--------------------------------------------------------------------------------
/away3d/animators/data/ParticlePropertiesMode.hx:
--------------------------------------------------------------------------------
1 | /**
2 | * Options for setting the properties mode of a particle animation node.
3 | */
4 | package away3d.animators.data;
5 |
6 | class ParticlePropertiesMode {
7 |
8 | /**
9 | * Mode that defines the particle node as acting on global properties (ie. the properties set in the node constructor or the corresponding animation state).
10 | */
11 | static public var GLOBAL:Int = 0;
12 | /**
13 | * 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).
14 | */
15 | static public var LOCAL_STATIC:Int = 1;
16 | /**
17 | * Mode that defines the particle node as acting on local dynamic properties (ie. the properties of the particles set in the corresponding animation state).
18 | */
19 | static public var LOCAL_DYNAMIC:Int = 2;
20 | }
21 |
22 |
--------------------------------------------------------------------------------
/away3d/animators/data/SkeletonJoint.hx:
--------------------------------------------------------------------------------
1 | /**
2 | * A value obect representing a single joint in a skeleton object.
3 | *
4 | * @see away3d.animators.data.Skeleton
5 | */
6 | package away3d.animators.data;
7 |
8 | class SkeletonJoint {
9 |
10 | /**
11 | * The index of the parent joint in the skeleton's joints vector.
12 | *
13 | * @see away3d.animators.data.Skeleton#joints
14 | */
15 | public var parentIndex:Int;
16 |
17 | /**
18 | * The name of the joint
19 | */
20 | public var name:String;
21 |
22 | // intention is that this should be used only at load time, not in the main loop
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:Array;
27 |
28 | /**
29 | * Creates a new SkeletonJoint
object
30 | */
31 | public function new() {
32 | parentIndex = -1;
33 | }
34 | }
35 |
36 |
--------------------------------------------------------------------------------
/away3d/animators/data/SpriteSheetAnimationFrame.hx:
--------------------------------------------------------------------------------
1 | /**
2 | * A value object for a single frame of animation in a SpriteSheetClipNode
object.
3 | *
4 | * @see away3d.animators.nodes.SpriteSheetClipNode
5 | */
6 | package away3d.animators.data;
7 |
8 | class SpriteSheetAnimationFrame {
9 |
10 | /**
11 | * The u-component offset of the spritesheet frame.
12 | */
13 | public var offsetU:Float;
14 | /**
15 | * The v-component offset of the spritesheet frame.
16 | */
17 | public var offsetV:Float;
18 | /**
19 | * The u-component scale of the spritesheet frame.
20 | */
21 | public var scaleU:Float;
22 | /**
23 | * The v-component scale of the spritesheet frame.
24 | */
25 | public var scaleV:Float;
26 | /**
27 | * The mapID, zero based, if the animation is spreaded over more bitmapData's
28 | */
29 | public var mapID:Int;
30 | /**
31 | * Creates a new SpriteSheetAnimationFrame
object.
32 | *
33 | * @param offsetU The u-component offset of the spritesheet frame.
34 | * @param offsetV The v-component offset of the spritesheet frame.
35 | * @param scaleU The u-component scale of the spritesheet frame.
36 | * @param scaleV The v-component scale of the spritesheet frame.
37 | * @param mapID The v-component scale of the spritesheet frame.
38 | */
39 | public function new(offsetU:Float = 0, offsetV:Float = 0, scaleU:Float = 1, scaleV:Float = 1, mapID:Int = 0) {
40 | this.offsetU = offsetU;
41 | this.offsetV = offsetV;
42 | this.scaleU = scaleU;
43 | this.scaleV = scaleV;
44 | this.mapID = mapID;
45 | }
46 | }
47 |
48 |
--------------------------------------------------------------------------------
/away3d/animators/data/UVAnimationFrame.hx:
--------------------------------------------------------------------------------
1 | /**
2 | * A value object for a single frame of animation in a UVClipNode
object.
3 | *
4 | * @see away3d.animators.nodes.UVClipNode
5 | */
6 | package away3d.animators.data;
7 |
8 | class UVAnimationFrame {
9 |
10 | /**
11 | * The u-component offset of the UV animation frame.
12 | */
13 | public var offsetU:Float;
14 | /**
15 | * The v-component offset of the UV animation frame.
16 | */
17 | public var offsetV:Float;
18 | /**
19 | * The u-component scale of the UV animation frame.
20 | */
21 | public var scaleU:Float;
22 | /**
23 | * The v-component scale of the UV animation frame.
24 | */
25 | public var scaleV:Float;
26 | /**
27 | * The rotation value (in degrees) of the UV animation frame.
28 | */
29 | public var rotation:Float;
30 | /**
31 | * Creates a new UVAnimationFrame
object.
32 | *
33 | * @param offsetU The u-component offset of the UV animation frame.
34 | * @param offsetV The v-component offset of the UV animation frame.
35 | * @param scaleU The u-component scale of the UV animation frame.
36 | * @param scaleV The v-component scale of the UV animation frame.
37 | * @param rotation The rotation value (in degrees) of the UV animation frame.
38 | */
39 | public function new(offsetU:Float = 0, offsetV:Float = 0, scaleU:Float = 1, scaleV:Float = 1, rotation:Float = 0) {
40 | this.offsetU = offsetU;
41 | this.offsetV = offsetV;
42 | this.scaleU = scaleU;
43 | this.scaleV = scaleV;
44 | this.rotation = rotation;
45 | }
46 | }
47 |
48 |
--------------------------------------------------------------------------------
/away3d/animators/data/VertexAnimationMode.hx:
--------------------------------------------------------------------------------
1 | /**
2 | * Options for setting the animation mode of a vertex animator object.
3 | *
4 | * @see away3d.animators.VertexAnimator
5 | */
6 | package away3d.animators.data;
7 |
8 | class VertexAnimationMode {
9 |
10 | /**
11 | * Animation mode that adds all outputs from active vertex animation state to form the current vertex animation pose.
12 | */
13 | static public var ADDITIVE:String = "additive";
14 | /**
15 | * Animation mode that picks the output from a single vertex animation state to form the current vertex animation pose.
16 | */
17 | static public var ABSOLUTE:String = "absolute";
18 | }
19 |
20 |
--------------------------------------------------------------------------------
/away3d/animators/nodes/AnimationNodeBase.hx:
--------------------------------------------------------------------------------
1 | /**
2 | * Provides an abstract base class for nodes in an animation blend tree.
3 | */
4 | package away3d.animators.nodes;
5 |
6 | import away3d.animators.states.IAnimationState;
7 | import away3d.library.assets.Asset3DType;
8 | import away3d.library.assets.NamedAssetBase;
9 | import away3d.library.assets.IAsset;
10 |
11 | class AnimationNodeBase extends NamedAssetBase implements IAsset {
12 | public var stateClass(get, never):Class;
13 | public var assetType(get, never):String;
14 |
15 | private var _stateClass:Class;
16 |
17 | private function get_stateClass():Class {
18 | return _stateClass;
19 | }
20 |
21 | /**
22 | * Creates a new AnimationNodeBase
object.
23 | */
24 | public function new() {
25 | super();
26 | }
27 |
28 | /**
29 | * @inheritDoc
30 | */
31 | public function dispose():Void {
32 | }
33 |
34 | /**
35 | * @inheritDoc
36 | */
37 | private function get_assetType():String {
38 | return Asset3DType.ANIMATION_NODE;
39 | }
40 | }
41 |
42 |
--------------------------------------------------------------------------------
/away3d/animators/nodes/ISpriteSheetAnimationNode.hx:
--------------------------------------------------------------------------------
1 | /**
2 | * Provides an interface for animation node classes that hold animation data for use in the SpriteSheetAnimator class.
3 | *
4 | * @see away3d.animators.SpriteSheetAnimator
5 | */
6 | package away3d.animators.nodes;
7 |
8 | import away3d.animators.data.SpriteSheetAnimationFrame;
9 |
10 | interface ISpriteSheetAnimationNode {
11 | var currentFrameData(get, never):SpriteSheetAnimationFrame;
12 | var currentFrameNumber(get, never):Int;
13 |
14 | /**
15 | * Returns the current SpriteSheetAnimationFrame of animation in the clip based on the internal playhead position.
16 | */
17 | private function get_currentFrameData():SpriteSheetAnimationFrame;
18 | /**
19 | * Returns the current frame number.
20 | */
21 | private function get_currentFrameNumber():Int;
22 | }
23 |
24 |
--------------------------------------------------------------------------------
/away3d/animators/nodes/SkeletonBinaryLERPNode.hx:
--------------------------------------------------------------------------------
1 | /**
2 | * A skeleton animation node that uses two animation node inputs to blend a lineraly interpolated output of a skeleton pose.
3 | */
4 | package away3d.animators.nodes;
5 |
6 | import away3d.animators.states.SkeletonBinaryLERPState;
7 |
8 | class SkeletonBinaryLERPNode extends AnimationNodeBase {
9 |
10 | /**
11 | * Defines input node A to use for the blended output.
12 | */
13 | public var inputA:AnimationNodeBase;
14 |
15 | /**
16 | * Defines input node B to use for the blended output.
17 | */
18 | public var inputB:AnimationNodeBase;
19 |
20 | /**
21 | * Creates a new SkeletonBinaryLERPNode
object.
22 | */
23 | public function new() {
24 | super();
25 | _stateClass = SkeletonBinaryLERPState;
26 | }
27 |
28 | /**
29 | * @inheritDoc
30 | */
31 | public function getAnimationState(animator:IAnimator):SkeletonBinaryLERPState {
32 | return cast(animator.getAnimationState(this), SkeletonBinaryLERPState) ;
33 | }
34 | }
35 |
36 |
--------------------------------------------------------------------------------
/away3d/animators/nodes/SkeletonDifferenceNode.hx:
--------------------------------------------------------------------------------
1 | /**
2 | * 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.
3 | */
4 | package away3d.animators.nodes;
5 |
6 | import away3d.animators.states.SkeletonDifferenceState;
7 | class SkeletonDifferenceNode extends AnimationNodeBase {
8 |
9 | /**
10 | * Defines a base input node to use for the blended output.
11 | */
12 | public var baseInput:AnimationNodeBase;
13 | /**
14 | * Defines a difference input node to use for the blended output.
15 | */
16 | public var differenceInput:AnimationNodeBase;
17 | /**
18 | * Creates a new SkeletonAdditiveNode
object.
19 | */
20 | public function new() {
21 | _stateClass = SkeletonDifferenceState;
22 | super();
23 | }
24 |
25 | /**
26 | * @inheritDoc
27 | */
28 | public function getAnimationState(animator:IAnimator):SkeletonDifferenceState {
29 | return cast(animator.getAnimationState(this), SkeletonDifferenceState) ;
30 | }
31 | }
32 |
33 |
--------------------------------------------------------------------------------
/away3d/animators/nodes/SkeletonDirectionalNode.hx:
--------------------------------------------------------------------------------
1 | /**
2 | * A skeleton animation node that uses four directional input poses with an input direction to blend a linearly interpolated output of a skeleton pose.
3 | */
4 | package away3d.animators.nodes;
5 |
6 | import away3d.animators.states.SkeletonDirectionalState;
7 | class SkeletonDirectionalNode extends AnimationNodeBase {
8 |
9 | /**
10 | * Defines the forward configured input node to use for the blended output.
11 | */
12 | public var forward:AnimationNodeBase;
13 | /**
14 | * Defines the backwards configured input node to use for the blended output.
15 | */
16 | public var backward:AnimationNodeBase;
17 | /**
18 | * Defines the left configured input node to use for the blended output.
19 | */
20 | public var left:AnimationNodeBase;
21 | /**
22 | * Defines the right configured input node to use for the blended output.
23 | */
24 | public var right:AnimationNodeBase;
25 |
26 | public function new() {
27 | _stateClass = SkeletonDirectionalState;
28 | super();
29 | }
30 |
31 | /**
32 | * @inheritDoc
33 | */
34 | public function getAnimationState(animator:IAnimator):SkeletonDirectionalState {
35 | return cast(animator.getAnimationState(this), SkeletonDirectionalState) ;
36 | }
37 | }
38 |
39 |
--------------------------------------------------------------------------------
/away3d/animators/nodes/SkeletonNaryLERPNode.hx:
--------------------------------------------------------------------------------
1 | /**
2 | * A skeleton animation node that uses an n-dimensional array of animation node inputs to blend a lineraly interpolated output of a skeleton pose.
3 | */
4 | package away3d.animators.nodes;
5 |
6 | import away3d.animators.states.SkeletonNaryLERPState;
7 | import openfl.Vector;
8 |
9 | class SkeletonNaryLERPNode extends AnimationNodeBase {
10 | public var numInputs(get, never):Int;
11 |
12 | public var _inputs:Vector;
13 | private var _numInputs:Int;
14 |
15 | private function get_numInputs():Int {
16 | return _numInputs;
17 | }
18 |
19 | /**
20 | * Creates a new SkeletonNaryLERPNode
object.
21 | */
22 | public function new() {
23 | _inputs = new Vector();
24 | _stateClass = SkeletonNaryLERPState;
25 | super();
26 | }
27 |
28 | /**
29 | * Returns an integer representing the input index of the given skeleton animation node.
30 | *
31 | * @param input The skeleton animation node for with the input index is requested.
32 | */
33 | public function getInputIndex(input:AnimationNodeBase):Int {
34 | return _inputs.indexOf(input);
35 | }
36 |
37 | /**
38 | * Returns the skeleton animation node object that resides at the given input index.
39 | *
40 | * @param index The input index for which the skeleton animation node is requested.
41 | */
42 | public function getInputAt(index:Int):AnimationNodeBase {
43 | return _inputs[index];
44 | }
45 |
46 | /**
47 | * Adds a new skeleton animation node input to the animation node.
48 | */
49 | public function addInput(input:AnimationNodeBase):Void {
50 | _inputs[_numInputs++] = input;
51 | }
52 |
53 | /**
54 | * @inheritDoc
55 | */
56 | public function getAnimationState(animator:IAnimator):SkeletonNaryLERPState {
57 | return cast(animator.getAnimationState(this), SkeletonNaryLERPState) ;
58 | }
59 | }
60 |
61 |
--------------------------------------------------------------------------------
/away3d/animators/nodes/SpriteSheetClipNode.hx:
--------------------------------------------------------------------------------
1 | /**
2 | * A SpriteSheetClipNode containing time-based animation data as individual sprite sheet animation frames.
3 | */
4 | package away3d.animators.nodes;
5 |
6 | import away3d.animators.states.SpriteSheetAnimationState;
7 | import away3d.animators.data.SpriteSheetAnimationFrame;
8 | import openfl.Vector;
9 |
10 | class SpriteSheetClipNode extends AnimationClipNodeBase {
11 | public var frames(get, never):Vector;
12 |
13 | private var _frames:Vector;
14 | /**
15 | * Creates a new SpriteSheetClipNode
object.
16 | */
17 | public function new() {
18 | _frames = new Vector();
19 | _stateClass = SpriteSheetAnimationState;
20 | super();
21 | }
22 |
23 | /**
24 | * Returns a vector of SpriteSheetAnimationFrame representing the uv values of each animation frame in the clip.
25 | */
26 | private function get_frames():Vector {
27 | return _frames;
28 | }
29 |
30 | /**
31 | * Adds a SpriteSheetAnimationFrame object to the internal timeline of the animation node.
32 | *
33 | * @param spriteSheetAnimationFrame The frame object to add to the timeline of the node.
34 | * @param duration The specified duration of the frame in milliseconds.
35 | */
36 | public function addFrame(spriteSheetAnimationFrame:SpriteSheetAnimationFrame, duration:Int):Void {
37 | _frames.push(spriteSheetAnimationFrame);
38 | _durations.push(duration);
39 | _numFrames = _durations.length;
40 | _stitchDirty = false;
41 | }
42 | }
43 |
44 |
--------------------------------------------------------------------------------
/away3d/animators/nodes/UVClipNode.hx:
--------------------------------------------------------------------------------
1 | /**
2 | * A uv animation node containing time-based animation data as individual uv animation frames.
3 | */
4 | package away3d.animators.nodes;
5 |
6 | import away3d.animators.states.UVClipState;
7 | import away3d.animators.data.UVAnimationFrame;
8 |
9 | class UVClipNode extends AnimationClipNodeBase {
10 | public var frames(get, never):Array;
11 |
12 | private var _frames:Array;
13 |
14 | /**
15 | * Returns a vector of UV frames representing the uv values of each animation frame in the clip.
16 | */
17 | private function get_frames():Array {
18 | return _frames;
19 | }
20 |
21 | /**
22 | * Creates a new UVClipNode
object.
23 | */
24 | public function new() {
25 | _frames = new Array();
26 | _stateClass = UVClipState;
27 | super();
28 | }
29 |
30 | /**
31 | * Adds a UV frame object to the internal timeline of the animation node.
32 | *
33 | * @param uvFrame The uv frame object to add to the timeline of the node.
34 | * @param duration The specified duration of the frame in milliseconds.
35 | */
36 | public function addFrame(uvFrame:UVAnimationFrame, duration:Int):Void {
37 | _frames.push(uvFrame);
38 | _durations.push(duration);
39 | _numFrames = _durations.length;
40 | _stitchDirty = true;
41 | }
42 |
43 | /**
44 | * @inheritDoc
45 | */
46 | override private function updateStitch():Void {
47 | super.updateStitch();
48 | var i:Int;
49 | if (_durations.length > 0) {
50 | i = _numFrames - 1;
51 | while (i-- > 0)_totalDuration += _durations[i];
52 | if (_stitchFinalFrame || !_looping) _totalDuration += _durations[_numFrames - 1];
53 | }
54 | }
55 | }
56 |
57 |
--------------------------------------------------------------------------------
/away3d/animators/states/IAnimationState.hx:
--------------------------------------------------------------------------------
1 | package away3d.animators.states;
2 |
3 | import openfl.geom.Vector3D;
4 |
5 | interface IAnimationState {
6 | var positionDelta(get, never):Vector3D;
7 |
8 | private function get_positionDelta():Vector3D;
9 | function offset(startTime:Int):Void;
10 | function update(time:Int):Void;
11 | /**
12 | * Sets the animation phase of the node.
13 | *
14 | * @param value The phase value to use. 0 represents the beginning of an animation clip, 1 represents the end.
15 | */
16 | function phase(value:Float):Void;
17 | }
18 |
19 |
--------------------------------------------------------------------------------
/away3d/animators/states/ISkeletonAnimationState.hx:
--------------------------------------------------------------------------------
1 | package away3d.animators.states;
2 |
3 |
4 | import away3d.animators.data.SkeletonPose;
5 | import away3d.animators.data.Skeleton;
6 | interface ISkeletonAnimationState extends IAnimationState {
7 |
8 | /**
9 | * Returns the output skeleton pose of the animation node.
10 | */
11 | function getSkeletonPose(skeleton:Skeleton):SkeletonPose;
12 | }
13 |
14 |
--------------------------------------------------------------------------------
/away3d/animators/states/ISpriteSheetAnimationState.hx:
--------------------------------------------------------------------------------
1 | /**
2 | * Provides an interface for animation node classes that hold animation data for use in the SpriteSheetAnimator class.
3 | *
4 | * @see away3d.animators.SpriteSheetAnimator
5 | */
6 | package away3d.animators.states;
7 |
8 |
9 | import away3d.animators.data.SpriteSheetAnimationFrame;
10 | interface ISpriteSheetAnimationState extends IAnimationState {
11 | var currentFrameData(get, never):SpriteSheetAnimationFrame;
12 | var currentFrameNumber(get, never):Int;
13 |
14 | /**
15 | * Returns the current SpriteSheetAnimationFrame of animation in the clip based on the internal playhead position.
16 | */
17 | private function get_currentFrameData():SpriteSheetAnimationFrame;
18 | /**
19 | * Returns the current frame number.
20 | */
21 | private function get_currentFrameNumber():Int;
22 | }
23 |
24 |
--------------------------------------------------------------------------------
/away3d/animators/states/IUVAnimationState.hx:
--------------------------------------------------------------------------------
1 | /**
2 | * Provides an interface for animation node classes that hold animation data for use in the UV animator class.
3 | *
4 | * @see away3d.animators.UVAnimator
5 | */
6 | package away3d.animators.states;
7 |
8 |
9 | import away3d.animators.data.UVAnimationFrame;
10 | interface IUVAnimationState extends IAnimationState {
11 | var currentUVFrame(get, never):UVAnimationFrame;
12 | var nextUVFrame(get, never):UVAnimationFrame;
13 | var blendWeight(get, never):Float;
14 |
15 | /**
16 | * Returns the current UV frame of animation in the clip based on the internal playhead position.
17 | */
18 | private function get_currentUVFrame():UVAnimationFrame;
19 | /**
20 | * Returns the next UV frame of animation in the clip based on the internal playhead position.
21 | */
22 | private function get_nextUVFrame():UVAnimationFrame;
23 | /**
24 | * Returns a fractional value between 0 and 1 representing the blending ratio of the current playhead position
25 | * between the current uv frame (0) and next uv frame (1) of the animation.
26 | */
27 | private function get_blendWeight():Float;
28 | }
29 |
30 |
--------------------------------------------------------------------------------
/away3d/animators/states/IVertexAnimationState.hx:
--------------------------------------------------------------------------------
1 | /**
2 | * Provides an interface for animation node classes that hold animation data for use in the Vertex animator class.
3 | *
4 | * @see away3d.animators.VertexAnimator
5 | */
6 | package away3d.animators.states;
7 |
8 | import away3d.core.base.Geometry;
9 | interface IVertexAnimationState extends IAnimationState {
10 | var currentGeometry(get, never):Geometry;
11 | var nextGeometry(get, never):Geometry;
12 | var blendWeight(get, never):Float;
13 |
14 | /**
15 | * Returns the current geometry frame of animation in the clip based on the internal playhead position.
16 | */
17 | private function get_currentGeometry():Geometry;
18 | /**
19 | * Returns the current geometry frame of animation in the clip based on the internal playhead position.
20 | */
21 | private function get_nextGeometry():Geometry;
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 | private function get_blendWeight():Float;
27 | }
28 |
29 |
--------------------------------------------------------------------------------
/away3d/animators/states/ParticleRotateToHeadingState.hx:
--------------------------------------------------------------------------------
1 | /**
2 | * ...
3 | */
4 | package away3d.animators.states;
5 |
6 | import away3d.animators.data.AnimationRegisterCache;
7 | import away3d.animators.data.AnimationSubGeometry;
8 | import away3d.animators.nodes.ParticleRotateToHeadingNode;
9 | import away3d.animators.nodes.ParticleNodeBase;
10 | import away3d.animators.ParticleAnimator;
11 | import away3d.cameras.Camera3D;
12 | import away3d.core.base.IRenderable;
13 | import away3d.core.managers.Stage3DProxy;
14 | import openfl.geom.Matrix3D;
15 |
16 |
17 | class ParticleRotateToHeadingState extends ParticleStateBase {
18 |
19 | private var _matrix:Matrix3D;
20 |
21 | public function new(animator:ParticleAnimator, particleNode:ParticleNodeBase) {
22 | _matrix = new Matrix3D();
23 | super(animator, particleNode);
24 | }
25 |
26 | override public function setRenderState(stage3DProxy:Stage3DProxy, renderable:IRenderable, animationSubGeometry:AnimationSubGeometry, animationRegisterCache:AnimationRegisterCache, camera:Camera3D):Void {
27 | if (animationRegisterCache.hasBillboard) {
28 | _matrix.copyFrom(renderable.sceneTransform);
29 | _matrix.append(camera.inverseSceneTransform);
30 | animationRegisterCache.setVertexConstFromMatrix(animationRegisterCache.getRegisterIndex(_animationNode, ParticleRotateToHeadingNode.MATRIX_INDEX), _matrix);
31 | }
32 | }
33 | }
34 |
35 |
--------------------------------------------------------------------------------
/away3d/animators/states/ParticleTimeState.hx:
--------------------------------------------------------------------------------
1 | /**
2 | * ...
3 | */
4 | package away3d.animators.states;
5 |
6 |
7 | import away3d.cameras.Camera3D;
8 | import away3d.animators.data.AnimationRegisterCache;
9 | import away3d.animators.data.AnimationSubGeometry;
10 | import away3d.core.base.IRenderable;
11 | import away3d.core.managers.Stage3DProxy;
12 | import away3d.animators.nodes.ParticleTimeNode;
13 | import away3d.animators.ParticleAnimator;
14 | import openfl.display3D.Context3DVertexBufferFormat;
15 |
16 | class ParticleTimeState extends ParticleStateBase {
17 |
18 | private var _particleTimeNode:ParticleTimeNode;
19 |
20 | public function new(animator:ParticleAnimator, particleTimeNode:ParticleTimeNode) {
21 | super(animator, particleTimeNode, true);
22 | _particleTimeNode = particleTimeNode;
23 | }
24 |
25 | override public function setRenderState(stage3DProxy:Stage3DProxy, renderable:IRenderable, animationSubGeometry:AnimationSubGeometry, animationRegisterCache:AnimationRegisterCache, camera:Camera3D):Void {
26 | animationSubGeometry.activateVertexBuffer(animationRegisterCache.getRegisterIndex(_animationNode, ParticleTimeNode.TIME_STREAM_INDEX), _particleTimeNode.dataOffset, stage3DProxy, Context3DVertexBufferFormat.FLOAT_4);
27 | var particleTime:Float = _time / 1000;
28 | animationRegisterCache.setVertexConst(animationRegisterCache.getRegisterIndex(_animationNode, ParticleTimeNode.TIME_CONSTANT_INDEX), particleTime, particleTime, particleTime, particleTime);
29 | }
30 | }
31 |
32 |
--------------------------------------------------------------------------------
/away3d/animators/states/ParticleUVState.hx:
--------------------------------------------------------------------------------
1 | /**
2 | * ...
3 | */
4 | package away3d.animators.states;
5 |
6 | import openfl.geom.Vector3D;
7 |
8 | import away3d.cameras.Camera3D;
9 | import away3d.animators.data.AnimationRegisterCache;
10 | import away3d.animators.data.AnimationSubGeometry;
11 | import away3d.core.base.IRenderable;
12 | import away3d.core.managers.Stage3DProxy;
13 | import away3d.animators.nodes.ParticleUVNode;
14 | import away3d.animators.ParticleAnimator;
15 |
16 | class ParticleUVState extends ParticleStateBase {
17 |
18 | private var _particleUVNode:ParticleUVNode;
19 |
20 | public function new(animator:ParticleAnimator, particleUVNode:ParticleUVNode) {
21 | super(animator, particleUVNode);
22 | _particleUVNode = particleUVNode;
23 | }
24 |
25 | override public function setRenderState(stage3DProxy:Stage3DProxy, renderable:IRenderable, animationSubGeometry:AnimationSubGeometry, animationRegisterCache:AnimationRegisterCache, camera:Camera3D):Void {
26 | if (animationRegisterCache.needUVAnimation) {
27 | var index:Int = animationRegisterCache.getRegisterIndex(_animationNode, ParticleUVNode.UV_INDEX);
28 | var data:Vector3D = _particleUVNode._uvData;
29 | animationRegisterCache.setVertexConst(index, data.x, data.y);
30 | }
31 | }
32 | }
33 |
34 |
--------------------------------------------------------------------------------
/away3d/animators/states/UVClipState.hx:
--------------------------------------------------------------------------------
1 | package away3d.animators.states;
2 |
3 | import away3d.animators.nodes.UVClipNode;
4 | import away3d.animators.data.UVAnimationFrame;
5 |
6 | class UVClipState extends AnimationClipState implements IUVAnimationState {
7 | public var currentUVFrame(get, never):UVAnimationFrame;
8 | public var nextUVFrame(get, never):UVAnimationFrame;
9 |
10 | private var _frames:Array;
11 | private var _uvClipNode:UVClipNode;
12 | private var _currentUVFrame:UVAnimationFrame;
13 | private var _nextUVFrame:UVAnimationFrame;
14 | /**
15 | * @inheritDoc
16 | */
17 | private function get_currentUVFrame():UVAnimationFrame {
18 | if (_framesDirty) updateFrames();
19 | return _currentUVFrame;
20 | }
21 |
22 | /**
23 | * @inheritDoc
24 | */
25 | private function get_nextUVFrame():UVAnimationFrame {
26 | if (_framesDirty) updateFrames();
27 | return _nextUVFrame;
28 | }
29 |
30 | function new(animator:IAnimator, uvClipNode:UVClipNode) {
31 | super(animator, uvClipNode);
32 | _uvClipNode = uvClipNode;
33 | _frames = _uvClipNode.frames;
34 | }
35 |
36 | /**
37 | * @inheritDoc
38 | */
39 | override private function updateFrames():Void {
40 | super.updateFrames();
41 | if (_frames.length > 0) {
42 | if (_frames.length == 2 && _currentFrame == 0) {
43 | _currentUVFrame = _frames[1];
44 | _nextUVFrame = _frames[0];
45 | }
46 |
47 | else {
48 | _currentUVFrame = _frames[_currentFrame];
49 | if (_uvClipNode.looping && _nextFrame >= _uvClipNode.lastFrame) _nextUVFrame = _frames[0]
50 | else _nextUVFrame = _frames[_nextFrame];
51 | }
52 |
53 | }
54 | }
55 | }
56 |
57 |
--------------------------------------------------------------------------------
/away3d/animators/states/VertexClipState.hx:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package away3d.animators.states;
5 |
6 | import away3d.animators.nodes.VertexClipNode;
7 | import away3d.core.base.Geometry;
8 |
9 | class VertexClipState extends AnimationClipState implements IVertexAnimationState {
10 | public var currentGeometry(get, never):Geometry;
11 | public var nextGeometry(get, never):Geometry;
12 |
13 | private var _frames:Array;
14 | private var _vertexClipNode:VertexClipNode;
15 | private var _currentGeometry:Geometry;
16 | private var _nextGeometry:Geometry;
17 | /**
18 | * @inheritDoc
19 | */
20 | private function get_currentGeometry():Geometry {
21 | if (_framesDirty) updateFrames();
22 | return _currentGeometry;
23 | }
24 |
25 | /**
26 | * @inheritDoc
27 | */
28 | private function get_nextGeometry():Geometry {
29 | if (_framesDirty) updateFrames();
30 | return _nextGeometry;
31 | }
32 |
33 | public function new(animator:IAnimator, vertexClipNode:VertexClipNode) {
34 | super(animator, vertexClipNode);
35 | _vertexClipNode = vertexClipNode;
36 | _frames = _vertexClipNode.frames;
37 | }
38 |
39 | /**
40 | * @inheritDoc
41 | */
42 | override private function updateFrames():Void {
43 | super.updateFrames();
44 | _currentGeometry = _frames[_currentFrame];
45 | if (_vertexClipNode.looping && _nextFrame >= _vertexClipNode.lastFrame) {
46 | _nextGeometry = _frames[0];
47 | cast((_animator), VertexAnimator).dispatchCycleEvent();
48 | }
49 |
50 | else _nextGeometry = _frames[_nextFrame];
51 | }
52 |
53 | /**
54 | * @inheritDoc
55 | */
56 | override private function updatePositionDelta():Void {
57 | //TODO:implement positiondelta functionality for vertex animations
58 | }
59 | }
60 |
61 |
--------------------------------------------------------------------------------
/away3d/animators/transitions/CrossfadeTransition.hx:
--------------------------------------------------------------------------------
1 | package away3d.animators.transitions;
2 |
3 | import away3d.animators.nodes.AnimationNodeBase;
4 |
5 | class CrossfadeTransition implements IAnimationTransition {
6 |
7 | public var blendSpeed:Float;
8 |
9 | public function new(blendSpeed:Float) {
10 | blendSpeed = 0.5;
11 | this.blendSpeed = blendSpeed;
12 | }
13 |
14 | public function getAnimationNode(animator:IAnimator, startNode:AnimationNodeBase, endNode:AnimationNodeBase, startBlend:Int):AnimationNodeBase {
15 | var crossFadeTransitionNode:CrossfadeTransitionNode = new CrossfadeTransitionNode();
16 | crossFadeTransitionNode.inputA = startNode;
17 | crossFadeTransitionNode.inputB = endNode;
18 | crossFadeTransitionNode.blendSpeed = blendSpeed;
19 | crossFadeTransitionNode.startBlend = startBlend;
20 | return crossFadeTransitionNode;
21 | }
22 | }
23 |
24 |
--------------------------------------------------------------------------------
/away3d/animators/transitions/CrossfadeTransitionNode.hx:
--------------------------------------------------------------------------------
1 | /**
2 | * A skeleton animation node that uses two animation node inputs to blend a lineraly interpolated output of a skeleton pose.
3 | */
4 | package away3d.animators.transitions;
5 |
6 | import away3d.animators.nodes.SkeletonBinaryLERPNode;
7 |
8 | class CrossfadeTransitionNode extends SkeletonBinaryLERPNode {
9 |
10 | public var blendSpeed:Float;
11 | public var startBlend:Int;
12 |
13 | /**
14 | * Creates a new CrossfadeTransitionNode
object.
15 | */
16 | public function new() {
17 | super();
18 | _stateClass = CrossfadeTransitionState;
19 |
20 | }
21 | }
22 |
23 |
--------------------------------------------------------------------------------
/away3d/animators/transitions/CrossfadeTransitionState.hx:
--------------------------------------------------------------------------------
1 | package away3d.animators.transitions;
2 |
3 | import away3d.animators.states.SkeletonBinaryLERPState;
4 | import away3d.events.AnimationStateEvent;
5 |
6 | class CrossfadeTransitionState extends SkeletonBinaryLERPState {
7 |
8 | private var _crossfadeTransitionNode:CrossfadeTransitionNode;
9 | private var _animationStateTransitionComplete:AnimationStateEvent;
10 |
11 | function new(animator:IAnimator, crossfadeTransitionNode:CrossfadeTransitionNode) {
12 | super(animator, crossfadeTransitionNode);
13 | _crossfadeTransitionNode = crossfadeTransitionNode;
14 | }
15 |
16 | /**
17 | * @inheritDoc
18 | */
19 | override private function updateTime(time:Int):Void {
20 | blendWeight = Math.abs(time - _crossfadeTransitionNode.startBlend) / (1000 * _crossfadeTransitionNode.blendSpeed);
21 | if (blendWeight >= 1) {
22 | blendWeight = 1;
23 | if (_animationStateTransitionComplete == null) {
24 | _animationStateTransitionComplete = new AnimationStateEvent(AnimationStateEvent.TRANSITION_COMPLETE, _animator, this, _crossfadeTransitionNode);
25 | }
26 | _crossfadeTransitionNode.dispatchEvent(_animationStateTransitionComplete);
27 | }
28 | super.updateTime(time);
29 | }
30 | }
31 |
32 |
--------------------------------------------------------------------------------
/away3d/animators/transitions/IAnimationTransition.hx:
--------------------------------------------------------------------------------
1 | package away3d.animators.transitions;
2 |
3 |
4 | import away3d.animators.nodes.AnimationNodeBase;
5 |
6 | interface IAnimationTransition {
7 |
8 | function getAnimationNode(animator:IAnimator, startNode:AnimationNodeBase, endNode:AnimationNodeBase, startTime:Int):AnimationNodeBase;
9 | }
10 |
11 |
--------------------------------------------------------------------------------
/away3d/animators/utils/SkeletonUtils.hx:
--------------------------------------------------------------------------------
1 | package away3d.animators.utils;
2 |
3 |
4 | import openfl.geom.Orientation3D;
5 | import openfl.geom.Vector3D;
6 | import openfl.geom.Matrix3D;
7 | import away3d.animators.data.JointPose;
8 | import openfl.errors.Error;
9 | import away3d.animators.data.SkeletonPose;
10 | import away3d.animators.nodes.SkeletonClipNode;
11 | import openfl.Vector;
12 |
13 | class SkeletonUtils {
14 |
15 | static public function generateDifferenceClip(source:SkeletonClipNode, referencePose:SkeletonPose):SkeletonClipNode {
16 | var diff:SkeletonClipNode = new SkeletonClipNode();
17 | var numFrames:Int = source.frames.length;
18 | var i:Int = 0;
19 | while (i < numFrames) {
20 | diff.addFrame(generateDifferencePose(source.frames[i], referencePose), source.durations[i]);
21 | ++i;
22 | }
23 | return diff;
24 | }
25 |
26 | static public function generateDifferencePose(source:SkeletonPose, reference:SkeletonPose):SkeletonPose {
27 | if (source.numJointPoses != reference.numJointPoses) throw new Error("joint counts don't match!");
28 | var numJoints:Int = source.numJointPoses;
29 | var diff:SkeletonPose = new SkeletonPose();
30 | var srcPose:JointPose;
31 | var refPose:JointPose;
32 | var diffPose:JointPose;
33 | var mtx:Matrix3D = new Matrix3D();
34 | var tempMtx:Matrix3D = new Matrix3D();
35 | var vec:Vector;
36 | var i:Int = 0;
37 | while (i < numJoints) {
38 | srcPose = source.jointPoses[i];
39 | refPose = reference.jointPoses[i];
40 | diffPose = new JointPose();
41 | diff.jointPoses[i] = diffPose;
42 | diffPose.name = srcPose.name;
43 | refPose.toMatrix3D(mtx);
44 | mtx.invert();
45 | mtx.append(srcPose.toMatrix3D(tempMtx));
46 | vec = mtx.decompose(Orientation3D.QUATERNION);
47 | diffPose.translation.copyFrom(vec[0]);
48 | diffPose.orientation.x = vec[1].x;
49 | diffPose.orientation.y = vec[1].y;
50 | diffPose.orientation.z = vec[1].z;
51 | diffPose.orientation.w = vec[1].w;
52 | ++i;
53 | }
54 | return diff;
55 | }
56 | }
57 |
58 |
--------------------------------------------------------------------------------
/away3d/audio/drivers/AbstractSound3DDriver.hx:
--------------------------------------------------------------------------------
1 | package away3d.audio.drivers;
2 |
3 | import openfl.geom.Vector3D;
4 | import openfl.media.Sound;
5 | import openfl.events.EventDispatcher;
6 |
7 | class AbstractSound3DDriver extends EventDispatcher {
8 | public var sourceSound(get, set):Sound;
9 | public var volume(get, set):Float;
10 | public var scale(get, set):Float;
11 | public var mute(get, set):Bool;
12 |
13 | private var _ref_v:Vector3D;
14 | private var _src:Sound;
15 | private var _volume:Float;
16 | private var _scale:Float;
17 | private var _mute:Bool;
18 | private var _paused:Bool;
19 | private var _playing:Bool;
20 |
21 | public function new() {
22 | _volume = 1;
23 | _scale = 1000;
24 | _playing = false;
25 | super();
26 | }
27 |
28 | private function get_sourceSound():Sound {
29 | return _src;
30 | }
31 |
32 | private function set_sourceSound(val:Sound):Sound {
33 | if (_src == val) return val;
34 | _src = val;
35 | return val;
36 | }
37 |
38 | private function get_volume():Float {
39 | return _volume;
40 | }
41 |
42 | private function set_volume(val:Float):Float {
43 | _volume = val;
44 | return val;
45 | }
46 |
47 | private function get_scale():Float {
48 | return _scale;
49 | }
50 |
51 | private function set_scale(val:Float):Float {
52 | _scale = val;
53 | return val;
54 | }
55 |
56 | private function get_mute():Bool {
57 | return _mute;
58 | }
59 |
60 | private function set_mute(val:Bool):Bool {
61 | if (_mute == val) return val;
62 | _mute = val;
63 | return val;
64 | }
65 |
66 | public function updateReferenceVector(v:Vector3D):Void {
67 | this._ref_v = v;
68 | }
69 | }
70 |
71 |
--------------------------------------------------------------------------------
/away3d/bounds/NullBounds.hx:
--------------------------------------------------------------------------------
1 | /**
2 | * NullBounds represents a debug bounding "volume" that is either considered always in, or always out of the frustum.
3 | * NullBounds is useful for entities that are always considered in the frustum, such as directional lights or skyboxes.
4 | */
5 | package away3d.bounds;
6 |
7 |
8 | import openfl.geom.Vector3D;
9 | import openfl.geom.Matrix3D;
10 | import away3d.core.base.Geometry;
11 | import away3d.primitives.WireframeSphere;
12 | import away3d.core.math.MathConsts;
13 | import away3d.primitives.WireframePrimitiveBase;
14 | import away3d.core.math.Plane3D;
15 | import away3d.core.math.PlaneClassification;
16 | import openfl.Vector;
17 |
18 | class NullBounds extends BoundingVolumeBase {
19 |
20 | private var _alwaysIn:Bool;
21 | private var _renderable:WireframePrimitiveBase;
22 |
23 | public function new(alwaysIn:Bool = true, renderable:WireframePrimitiveBase = null) {
24 | super();
25 | _alwaysIn = alwaysIn;
26 | _renderable = renderable;
27 | _max.x = _max.y = _max.z = Math.POSITIVE_INFINITY;
28 | _min.x = _min.y = _min.z = (_alwaysIn) ? Math.NEGATIVE_INFINITY : Math.POSITIVE_INFINITY;
29 | }
30 |
31 | override public function clone():BoundingVolumeBase {
32 | return new NullBounds(_alwaysIn);
33 | }
34 |
35 | override private function createBoundingRenderable():WireframePrimitiveBase {
36 | return if (_renderable != null) _renderable; else new WireframeSphere(100, 16, 12, 0xffffff, 0.5);
37 | }
38 |
39 | /**
40 | * @inheritDoc
41 | */
42 | override public function isInFrustum(planes:Vector, numPlanes:Int):Bool {
43 |
44 | return _alwaysIn;
45 | }
46 |
47 | /**
48 | * @inheritDoc
49 | */
50 | override public function fromGeometry(geometry:Geometry):Void {
51 | }
52 |
53 | /**
54 | * @inheritDoc
55 | */
56 | override public function fromSphere(center:Vector3D, radius:Float):Void {
57 | }
58 |
59 | /**
60 | * @inheritDoc
61 | */
62 | override public function fromExtremes(minX:Float, minY:Float, minZ:Float, maxX:Float, maxY:Float, maxZ:Float):Void {
63 | }
64 |
65 | override public function classifyToPlane(plane:Plane3D):Int {
66 |
67 | return PlaneClassification.INTERSECT;
68 | }
69 |
70 | override public function transformFrom(bounds:BoundingVolumeBase, matrix:Matrix3D):Void {
71 |
72 | _alwaysIn = cast((bounds), NullBounds)._alwaysIn;
73 | }
74 | }
75 |
76 |
--------------------------------------------------------------------------------
/away3d/cameras/lenses/FreeMatrixLens.hx:
--------------------------------------------------------------------------------
1 | /**
2 | * FreeMatrixLens provides a projection lens that exposes a full projection matrix, rather than provide one through
3 | * more user-friendly settings. Whenever the matrix is updated, it needs to be reset in order to trigger an update.
4 | */
5 | package away3d.cameras.lenses;
6 |
7 |
8 | class FreeMatrixLens extends LensBase {
9 |
10 | /**
11 | * Creates a new FreeMatrixLens object.
12 | */
13 | public function new() {
14 | super();
15 | _matrix.copyFrom(new PerspectiveLens().matrix);
16 | }
17 |
18 | override private function set_near(value:Float):Float {
19 | _near = value;
20 | return value;
21 | }
22 |
23 | override private function set_far(value:Float):Float {
24 | _far = value;
25 | return value;
26 | }
27 |
28 | override private function set_aspectRatio(value:Float):Float {
29 | _aspectRatio = value;
30 | return value;
31 | }
32 |
33 | override public function clone():LensBase {
34 | var clone:FreeMatrixLens = new FreeMatrixLens();
35 | clone._matrix.copyFrom(_matrix);
36 | clone._near = _near;
37 | clone._far = _far;
38 | clone._aspectRatio = _aspectRatio;
39 | clone.invalidateMatrix();
40 | return clone;
41 | }
42 |
43 | override private function updateMatrix():Void {
44 | _matrixInvalid = false;
45 | }
46 | }
47 |
48 |
--------------------------------------------------------------------------------
/away3d/controllers/ControllerBase.hx:
--------------------------------------------------------------------------------
1 | package away3d.controllers;
2 |
3 |
4 | import away3d.entities.Entity;
5 | import away3d.errors.AbstractMethodError;
6 |
7 | class ControllerBase {
8 | public var targetObject(get, set):Entity;
9 | public var autoUpdate(get, set):Bool;
10 |
11 | private var _autoUpdate:Bool;
12 | private var _targetObject:Entity;
13 |
14 | private function notifyUpdate():Void {
15 | if (_targetObject != null && _targetObject.implicitPartition != null && _autoUpdate) _targetObject.implicitPartition.markForUpdate(_targetObject);
16 | }
17 |
18 | /**
19 | * Target object on which the controller acts. Defaults to null.
20 | */
21 | private function get_targetObject():Entity {
22 | return _targetObject;
23 | }
24 |
25 | private function set_targetObject(val:Entity):Entity {
26 | if (_targetObject == val) return val;
27 | if (_targetObject != null && _autoUpdate) _targetObject._controller = null;
28 | _targetObject = val;
29 | if (_targetObject != null && _autoUpdate) _targetObject._controller = this;
30 | notifyUpdate();
31 | return val;
32 | }
33 |
34 | /**
35 | * Determines whether the controller applies updates automatically. Defaults to true
36 | */
37 | private function get_autoUpdate():Bool {
38 | return _autoUpdate;
39 | }
40 |
41 | private function set_autoUpdate(val:Bool):Bool {
42 | if (_autoUpdate == val) return val;
43 | _autoUpdate = val;
44 | if (_targetObject != null) {
45 | if (_autoUpdate) _targetObject._controller = this
46 | else _targetObject._controller = null;
47 | }
48 | return val;
49 | }
50 |
51 | /**
52 | * Base controller class for dynamically adjusting the propeties of a 3D object.
53 | *
54 | * @param targetObject The 3D object on which to act.
55 | */
56 | public function new(targetObject:Entity = null) {
57 | _autoUpdate = true;
58 | this.targetObject = targetObject;
59 |
60 | }
61 |
62 | /**
63 | * Manually applies updates to the target 3D object.
64 | */
65 | public function update(interpolate:Bool = true):Void {
66 | throw new AbstractMethodError();
67 | }
68 | }
69 |
70 |
--------------------------------------------------------------------------------
/away3d/controllers/FollowController.hx:
--------------------------------------------------------------------------------
1 | /**
2 | * Controller used to follow behind an object on the XZ plane, with an optional
3 | * elevation (tiltAngle).
4 | *
5 | * @see away3d.containers.View3D
6 | */
7 | package away3d.controllers;
8 |
9 | import away3d.containers.ObjectContainer3D;
10 | import away3d.entities.Entity;
11 |
12 | class FollowController extends HoverController {
13 |
14 | public function new(targetObject:Entity = null, lookAtObject:ObjectContainer3D = null, tiltAngle:Float = 45, distance:Float = 700) {
15 | super(targetObject, lookAtObject, 0, tiltAngle, distance);
16 | }
17 |
18 | override public function update(interpolate:Bool = true):Void {
19 |
20 | // unused: prevents warning
21 | if (lookAtObject == null) return;
22 | panAngle = _lookAtObject.rotationY - 180;
23 | super.update();
24 | }
25 | }
26 |
27 |
--------------------------------------------------------------------------------
/away3d/core/base/IMaterialOwner.hx:
--------------------------------------------------------------------------------
1 | /**
2 | * IMaterialOwner provides an interface for objects that can use materials.
3 | */
4 | package away3d.core.base;
5 |
6 | import away3d.animators.IAnimator;
7 | import away3d.materials.MaterialBase;
8 |
9 | interface IMaterialOwner {
10 | var material(get, set):MaterialBase;
11 | var animator(get, never):IAnimator;
12 |
13 | /**
14 | * The material with which to render the object.
15 | */
16 | private function get_material():MaterialBase;
17 | private function set_material(value:MaterialBase):MaterialBase;
18 | /**
19 | * The animation used by the material to assemble the vertex code.
20 | */
21 | private function get_animator():IAnimator;
22 | // in most cases, this will in fact be null
23 | }
24 |
25 |
--------------------------------------------------------------------------------
/away3d/core/base/ParticleGeometry.hx:
--------------------------------------------------------------------------------
1 | /**
2 | * ...
3 | */
4 | package away3d.core.base;
5 |
6 | import away3d.core.base.data.ParticleData;
7 |
8 | class ParticleGeometry extends Geometry {
9 |
10 | public var particles:Array;
11 | public var numParticles:Int;
12 |
13 | public function new() {
14 | super();
15 | }
16 | }
17 |
18 |
--------------------------------------------------------------------------------
/away3d/core/base/data/ParticleData.hx:
--------------------------------------------------------------------------------
1 | package away3d.core.base.data;
2 |
3 | import away3d.core.base.CompactSubGeometry;
4 |
5 | class ParticleData {
6 |
7 | public var particleIndex:Int;
8 | public var numVertices:Int;
9 | public var startVertexIndex:Int;
10 | public var subGeometry:CompactSubGeometry;
11 |
12 | public function new() {
13 | }
14 | }
15 |
16 |
--------------------------------------------------------------------------------
/away3d/core/base/data/UV.hx:
--------------------------------------------------------------------------------
1 | /**
2 | * Texture coordinates value object.
3 | */
4 | package away3d.core.base.data;
5 |
6 | class UV {
7 | public var v(get, set):Float;
8 | public var u(get, set):Float;
9 |
10 | private var _u:Float;
11 | private var _v:Float;
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 new(u:Float = 0, v:Float = 0) {
19 | _u = u;
20 | _v = v;
21 | }
22 |
23 | /**
24 | * Defines the vertical coordinate of the texture value.
25 | */
26 | private function get_v():Float {
27 | return _v;
28 | }
29 |
30 | private function set_v(value:Float):Float {
31 | _v = value;
32 | return value;
33 | }
34 |
35 | /**
36 | * Defines the horizontal coordinate of the texture value.
37 | */
38 | private function get_u():Float {
39 | return _u;
40 | }
41 |
42 | private function set_u(value:Float):Float {
43 | _u = value;
44 | return value;
45 | }
46 |
47 | /**
48 | * returns a new UV value Object
49 | */
50 | public function clone():UV {
51 | return new UV(_u, _v);
52 | }
53 |
54 | /**
55 | * returns the value object as a string for trace/debug purpose
56 | */
57 | public function toString():String {
58 | return _u + "," + _v;
59 | }
60 | }
61 |
62 |
--------------------------------------------------------------------------------
/away3d/core/data/EntityListItem.hx:
--------------------------------------------------------------------------------
1 | package away3d.core.data;
2 |
3 | import away3d.entities.Entity;
4 |
5 | class EntityListItem {
6 |
7 | public var entity:Entity;
8 | public var next:EntityListItem;
9 |
10 | public function new() {
11 | }
12 | }
13 |
14 |
--------------------------------------------------------------------------------
/away3d/core/data/EntityListItemPool.hx:
--------------------------------------------------------------------------------
1 | package away3d.core.data;
2 |
3 | import openfl.Vector;
4 |
5 | class EntityListItemPool {
6 |
7 | private var _pool:Vector;
8 | private var _index:Int;
9 | private var _poolSize:Int;
10 |
11 | public function new() {
12 | _index = 0;
13 | _poolSize = 0;
14 | _pool = new Vector();
15 | }
16 |
17 | public function getItem():EntityListItem {
18 | var item:EntityListItem;
19 | if (_index == _poolSize) {
20 | item = new EntityListItem();
21 | _pool[_index++] = item;
22 | ++_poolSize;
23 | }
24 |
25 | else item = _pool[_index++];
26 | return item;
27 | }
28 |
29 | public function freeAll():Void {
30 | _index = 0;
31 | }
32 |
33 | public function dispose():Void {
34 | _pool = [];
35 | }
36 | }
37 |
38 |
--------------------------------------------------------------------------------
/away3d/core/data/RenderableListItem.hx:
--------------------------------------------------------------------------------
1 | package away3d.core.data;
2 |
3 | import away3d.core.base.IRenderable;
4 | import openfl.geom.Matrix3D;
5 |
6 | class RenderableListItem {
7 |
8 | public var next:RenderableListItem;
9 | public var renderable:IRenderable;
10 | // for faster access while sorting or rendering (cached values)
11 | public var materialId:Int;
12 | public var renderOrderId:Int;
13 | public var zIndex:Float;
14 | public var renderSceneTransform:Matrix3D;
15 | public var cascaded:Bool;
16 |
17 | public function new() {
18 | }
19 | }
20 |
21 |
--------------------------------------------------------------------------------
/away3d/core/data/RenderableListItemPool.hx:
--------------------------------------------------------------------------------
1 | package away3d.core.data;
2 |
3 | class RenderableListItemPool {
4 |
5 | private var _pool:Array;
6 | private var _index:Int;
7 | private var _poolSize:Int;
8 |
9 | public function new() {
10 | _index = 0;
11 | _poolSize = 0;
12 | _pool = new Array();
13 | }
14 |
15 | public function getItem():RenderableListItem {
16 | if (_index == _poolSize) {
17 | var item:RenderableListItem = new RenderableListItem();
18 | _pool[_index++] = item;
19 | ++_poolSize;
20 | return item;
21 | }
22 |
23 | else return _pool[_index++];
24 | }
25 |
26 | public function freeAll():Void {
27 | _index = 0;
28 | }
29 |
30 | public function dispose():Void {
31 | _pool = [];
32 | }
33 | }
34 |
35 |
--------------------------------------------------------------------------------
/away3d/core/math/MathConsts.hx:
--------------------------------------------------------------------------------
1 | /**
2 | * MathConsts provides some commonly used mathematical constants
3 | */
4 | package away3d.core.math;
5 |
6 | class MathConsts {
7 |
8 |
9 |
10 | /**
11 | * The amount to multiply with when converting radians to degrees.
12 | */
13 | static public var RADIANS_TO_DEGREES:Float = 180 / Math.PI;
14 | /**
15 | * The amount to multiply with when converting degrees to radians.
16 | */
17 | static public var DEGREES_TO_RADIANS:Float = Math.PI / 180;
18 | }
19 |
20 |
--------------------------------------------------------------------------------
/away3d/core/math/PlaneClassification.hx:
--------------------------------------------------------------------------------
1 | package away3d.core.math;
2 |
3 | class PlaneClassification {
4 |
5 | // "back" is synonymous with "in", but used for planes (back of plane is "inside" a solid volume walled by a plane)
6 | static public var BACK:Int = 0;
7 | static public var FRONT:Int = 1;
8 | static public var IN:Int = 0;
9 | static public var OUT:Int = 1;
10 | static public var INTERSECT:Int = 2;
11 | }
12 |
13 |
--------------------------------------------------------------------------------
/away3d/core/partition/CameraNode.hx:
--------------------------------------------------------------------------------
1 | /**
2 | * CameraNode is a space partitioning leaf node that contains a Camera3D object.
3 | */
4 | package away3d.core.partition;
5 |
6 | import away3d.cameras.Camera3D;
7 | import away3d.core.traverse.PartitionTraverser;
8 |
9 | class CameraNode extends EntityNode {
10 |
11 | /**
12 | * Creates a new CameraNode object.
13 | * @param camera The camera to be contained in the node.
14 | */
15 | public function new(camera:Camera3D) {
16 | super(camera);
17 | }
18 |
19 | /**
20 | * @inheritDoc
21 | */
22 | override public function acceptTraverser(traverser:PartitionTraverser):Void {
23 | // todo: dead end for now, if it has a debug mesh, then sure accept that
24 | }
25 | }
26 |
27 |
--------------------------------------------------------------------------------
/away3d/core/partition/DirectionalLightNode.hx:
--------------------------------------------------------------------------------
1 | /**
2 | * LightNode is a space partitioning leaf node that contains a LightBase object.
3 | */
4 | package away3d.core.partition;
5 |
6 | import away3d.core.traverse.PartitionTraverser;
7 | import away3d.lights.DirectionalLight;
8 |
9 | class DirectionalLightNode extends EntityNode {
10 | public var light(get, never):DirectionalLight;
11 |
12 | private var _light:DirectionalLight;
13 | /**
14 | * Creates a new LightNode object.
15 | * @param light The light to be contained in the node.
16 | */
17 | public function new(light:DirectionalLight) {
18 | super(light);
19 | _light = light;
20 | }
21 |
22 | /**
23 | * The light object contained in this node.
24 | */
25 | private function get_light():DirectionalLight {
26 | return _light;
27 | }
28 |
29 | /**
30 | * @inheritDoc
31 | */
32 | override public function acceptTraverser(traverser:PartitionTraverser):Void {
33 | if (traverser.enterNode(this)) {
34 | super.acceptTraverser(traverser);
35 | traverser.applyDirectionalLight(_light);
36 | }
37 | }
38 | }
39 |
40 |
--------------------------------------------------------------------------------
/away3d/core/partition/EntityNode.hx:
--------------------------------------------------------------------------------
1 | /**
2 | * The EntityNode class provides an abstract base class for leaf nodes in a partition tree, containing
3 | * entities to be fed to the EntityCollector traverser.
4 | * The concrete subtype of Entity is responsible for creating a matching subtype of EntityNode.
5 | *
6 | * @see away3d.scenegraph.Entity
7 | * @see away3d.core.traverse.EntityCollector
8 | */
9 | package away3d.core.partition;
10 |
11 |
12 | import away3d.core.math.Plane3D;
13 | import away3d.core.traverse.PartitionTraverser;
14 | import away3d.entities.Entity;
15 | import openfl.geom.Vector3D;
16 | import openfl.Vector;
17 |
18 | class EntityNode extends NodeBase {
19 | public var entity(get, never):Entity;
20 |
21 | private var _entity:Entity;
22 | /**
23 | * The link to the next object in the list to be updated
24 | * @private
25 | */
26 | public var _updateQueueNext:EntityNode;
27 | /**
28 | * Creates a new EntityNode object.
29 | * @param entity The Entity to be contained in this leaf node.
30 | */
31 | public function new(entity:Entity) {
32 | super();
33 | _entity = entity;
34 | _numEntities = 1;
35 | }
36 |
37 | /**
38 | * The entity contained in this leaf node.
39 | */
40 | private function get_entity():Entity {
41 | return _entity;
42 | }
43 |
44 | /**
45 | * @inheritDoc
46 | */
47 | override public function acceptTraverser(traverser:PartitionTraverser):Void {
48 | traverser.applyEntity(_entity);
49 | }
50 |
51 | /**
52 | * Detaches the node from its parent.
53 | */
54 | public function removeFromParent():Void {
55 | if (_parent != null) _parent.removeNode(this);
56 | _parent = null;
57 | }
58 |
59 | override public function isInFrustum(planes:Vector, numPlanes:Int):Bool {
60 | if (!_entity.isVisible) {
61 |
62 | return false;
63 | }
64 | return _entity.worldBounds.isInFrustum(planes, numPlanes);
65 |
66 |
67 | }
68 |
69 | /**
70 | * @inheritDoc
71 | */
72 | override public function isIntersectingRay(rayPosition:Vector3D, rayDirection:Vector3D):Bool {
73 | if (!_entity.isVisible) return false;
74 | return _entity.isIntersectingRay(rayPosition, rayDirection);
75 | }
76 | }
77 |
78 |
--------------------------------------------------------------------------------
/away3d/core/partition/LightNode.hx:
--------------------------------------------------------------------------------
1 | /**
2 | * LightNode is a space partitioning leaf node that contains a LightBase object. Used for lights that are not of default supported type.
3 | */
4 | package away3d.core.partition;
5 |
6 | import away3d.core.traverse.PartitionTraverser;
7 | import away3d.lights.LightBase;
8 |
9 | class LightNode extends EntityNode {
10 | public var light(get, never):LightBase;
11 |
12 | private var _light:LightBase;
13 | /**
14 | * Creates a new LightNode object.
15 | * @param light The light to be contained in the node.
16 | */
17 | public function new(light:LightBase) {
18 | super(light);
19 | _light = light;
20 | }
21 |
22 | /**
23 | * The light object contained in this node.
24 | */
25 | private function get_light():LightBase {
26 | return _light;
27 | }
28 |
29 | /**
30 | * @inheritDoc
31 | */
32 | override public function acceptTraverser(traverser:PartitionTraverser):Void {
33 | if (traverser.enterNode(this)) {
34 | super.acceptTraverser(traverser);
35 | traverser.applyUnknownLight(_light);
36 | }
37 | }
38 | }
39 |
40 |
--------------------------------------------------------------------------------
/away3d/core/partition/LightProbeNode.hx:
--------------------------------------------------------------------------------
1 | /**
2 | * LightNode is a space partitioning leaf node that contains a LightBase object.
3 | */
4 | package away3d.core.partition;
5 |
6 | import away3d.core.traverse.PartitionTraverser;
7 | import away3d.lights.LightProbe;
8 |
9 | class LightProbeNode extends EntityNode {
10 | public var light(get, never):LightProbe;
11 |
12 | private var _light:LightProbe;
13 | /**
14 | * Creates a new LightNode object.
15 | * @param light The light to be contained in the node.
16 | */
17 | public function new(light:LightProbe) {
18 | super(light);
19 | _light = light;
20 | }
21 |
22 | /**
23 | * The light object contained in this node.
24 | */
25 | private function get_light():LightProbe {
26 | return _light;
27 | }
28 |
29 | /**
30 | * @inheritDoc
31 | */
32 | override public function acceptTraverser(traverser:PartitionTraverser):Void {
33 | if (traverser.enterNode(this)) {
34 | super.acceptTraverser(traverser);
35 | traverser.applyLightProbe(_light);
36 | }
37 | }
38 | }
39 |
40 |
--------------------------------------------------------------------------------
/away3d/core/partition/MeshNode.hx:
--------------------------------------------------------------------------------
1 | /**
2 | * MeshNode is a space partitioning leaf node that contains a Mesh object.
3 | */
4 | package away3d.core.partition;
5 |
6 | import away3d.core.base.SubMesh;
7 | import away3d.core.traverse.PartitionTraverser;
8 | import away3d.entities.Mesh;
9 | import openfl.Vector;
10 |
11 | class MeshNode extends EntityNode {
12 | public var mesh(get, never):Mesh;
13 |
14 | private var _mesh:Mesh;
15 | /**
16 | * Creates a new MeshNode object.
17 | * @param mesh The mesh to be contained in the node.
18 | */
19 | public function new(mesh:Mesh) {
20 | super(mesh);
21 | _mesh = mesh;
22 | // also keep a stronger typed reference
23 | }
24 |
25 | /**
26 | * The mesh object contained in the partition node.
27 | */
28 | private function get_mesh():Mesh {
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:Int = 0;
41 | var len:Int = subs.length;
42 |
43 | while (i < len) {
44 | traverser.applyRenderable(subs[i++]);
45 | }
46 |
47 | }
48 | }
49 | }
50 |
51 |
--------------------------------------------------------------------------------
/away3d/core/partition/NullNode.hx:
--------------------------------------------------------------------------------
1 | /**
2 | * NullNode is a node that performs no space partitioning, but simply stores all objects in a
3 | * list of leaf nodes. This partitioning system is most useful for simple content, or content that is always in the
4 | * screen, such as a 3d user interface.
5 | */
6 | package away3d.core.partition;
7 |
8 | class NullNode extends NodeBase {
9 |
10 | /**
11 | * Creates a new NullNode object.
12 | */
13 | public function new() {
14 | super();
15 | }
16 | }
17 |
18 |
--------------------------------------------------------------------------------
/away3d/core/partition/Octree.hx:
--------------------------------------------------------------------------------
1 | package away3d.core.partition;
2 |
3 |
4 | class Octree extends Partition3D {
5 |
6 | public function new(maxDepth:Int, size:Float) {
7 | super(new OctreeNode(maxDepth, size));
8 | }
9 | }
10 |
11 |
--------------------------------------------------------------------------------
/away3d/core/partition/PointLightNode.hx:
--------------------------------------------------------------------------------
1 | /**
2 | * LightNode is a space partitioning leaf node that contains a LightBase object.
3 | */
4 | package away3d.core.partition;
5 |
6 | import away3d.core.traverse.PartitionTraverser;
7 | import away3d.lights.PointLight;
8 |
9 | class PointLightNode extends EntityNode {
10 | public var light(get, never):PointLight;
11 |
12 | private var _light:PointLight;
13 | /**
14 | * Creates a new LightNode object.
15 | * @param light The light to be contained in the node.
16 | */
17 | public function new(light:PointLight) {
18 | super(light);
19 | _light = light;
20 | }
21 |
22 | /**
23 | * The light object contained in this node.
24 | */
25 | private function get_light():PointLight {
26 | return _light;
27 | }
28 |
29 | /**
30 | * @inheritDoc
31 | */
32 | override public function acceptTraverser(traverser:PartitionTraverser):Void {
33 | if (traverser.enterNode(this)) {
34 | super.acceptTraverser(traverser);
35 | traverser.applyPointLight(_light);
36 | }
37 | }
38 | }
39 |
40 |
--------------------------------------------------------------------------------
/away3d/core/partition/QuadTree.hx:
--------------------------------------------------------------------------------
1 | package away3d.core.partition;
2 |
3 |
4 | class QuadTree extends Partition3D {
5 |
6 | public function new(maxDepth:Int, size:Float, height:Float = 1000000) {
7 | super(new QuadTreeNode(maxDepth, size, height));
8 | }
9 | }
10 |
11 |
--------------------------------------------------------------------------------
/away3d/core/partition/RenderableNode.hx:
--------------------------------------------------------------------------------
1 | /**
2 | * RenderableNode is a space partitioning leaf node that contains any Entity that is itself a IRenderable
3 | * object. This excludes Mesh (since the renderable objects are its SubMesh children).
4 | */
5 | package away3d.core.partition;
6 |
7 | import away3d.core.base.IRenderable;
8 | import away3d.core.traverse.PartitionTraverser;
9 | import away3d.entities.Entity;
10 |
11 | class RenderableNode extends EntityNode {
12 |
13 | private var _renderable:IRenderable;
14 | /**
15 | * Creates a new RenderableNode object.
16 | * @param mesh The mesh to be contained in the node.
17 | */
18 | public function new(renderable:IRenderable) {
19 | super(cast((renderable), Entity));
20 | _renderable = renderable;
21 | // also keep a stronger typed reference
22 | }
23 |
24 | /**
25 | * @inheritDoc
26 | */
27 | override public function acceptTraverser(traverser:PartitionTraverser):Void {
28 | if (traverser.enterNode(this)) {
29 | super.acceptTraverser(traverser);
30 | traverser.applyRenderable(_renderable);
31 | }
32 | }
33 | }
34 |
35 |
--------------------------------------------------------------------------------
/away3d/core/partition/SkyBoxNode.hx:
--------------------------------------------------------------------------------
1 | /**
2 | * SkyBoxNode is a space partitioning leaf node that contains a SkyBox object.
3 | */
4 | package away3d.core.partition;
5 |
6 | import away3d.core.math.Plane3D;
7 | import away3d.core.traverse.PartitionTraverser;
8 | import away3d.primitives.SkyBox;
9 | import openfl.Vector;
10 |
11 | class SkyBoxNode extends EntityNode {
12 |
13 | private var _skyBox:SkyBox;
14 | /**
15 | * Creates a new SkyBoxNode object.
16 | * @param skyBox The SkyBox to be contained in the node.
17 | */
18 | public function new(skyBox:SkyBox) {
19 | super(skyBox);
20 | _skyBox = skyBox;
21 | }
22 |
23 | /**
24 | * @inheritDoc
25 | */
26 | override public function acceptTraverser(traverser:PartitionTraverser):Void {
27 | if (traverser.enterNode(this)) {
28 | super.acceptTraverser(traverser);
29 | traverser.applySkyBox(_skyBox);
30 | }
31 | }
32 |
33 | override public function isInFrustum(planes:Vector, numPlanes:Int):Bool {
34 |
35 | return true;
36 | }
37 | }
38 |
39 |
--------------------------------------------------------------------------------
/away3d/core/partition/ViewVolumePartition.hx:
--------------------------------------------------------------------------------
1 | package away3d.core.partition;
2 |
3 |
4 | import away3d.entities.Entity;
5 |
6 | class ViewVolumePartition extends Partition3D {
7 | public var dynamicGrid(get, set):DynamicGrid;
8 |
9 | public function new() {
10 | super(new ViewVolumeRootNode());
11 | }
12 |
13 | override public function markForUpdate(entity:Entity):Void {
14 | // ignore if static, will be handled separately by visibility list
15 | if (!entity.staticNode) super.markForUpdate(entity);
16 | }
17 |
18 | /**
19 | * Adds a view volume to provide visibility info for a given region.
20 | */
21 | public function addViewVolume(viewVolume:ViewVolume):Void {
22 | cast((_rootNode), ViewVolumeRootNode).addViewVolume(viewVolume);
23 | }
24 |
25 | public function removeViewVolume(viewVolume:ViewVolume):Void {
26 | cast((_rootNode), ViewVolumeRootNode).removeViewVolume(viewVolume);
27 | }
28 |
29 | /**
30 | * A dynamic grid to be able to determine visibility of dynamic objects. If none is provided, dynamic objects are only frustum-culled.
31 | * If provided, ViewVolumes need to have visible grid cells assigned from the same DynamicGrid instance.
32 | */
33 | private function get_dynamicGrid():DynamicGrid {
34 | return cast((_rootNode), ViewVolumeRootNode).dynamicGrid;
35 | }
36 |
37 | private function set_dynamicGrid(value:DynamicGrid):DynamicGrid {
38 | cast((_rootNode), ViewVolumeRootNode).dynamicGrid = value;
39 | return value;
40 | }
41 | }
42 |
43 |
--------------------------------------------------------------------------------
/away3d/core/pick/IPicker.hx:
--------------------------------------------------------------------------------
1 | /**
2 | * Provides an interface for picking objects that can pick 3d objects from a view or scene.
3 | */
4 | package away3d.core.pick;
5 |
6 | import openfl.geom.Vector3D;
7 | import away3d.containers.Scene3D;
8 | import away3d.containers.View3D;
9 | interface IPicker {
10 | var onlyMouseEnabled(get, set):Bool;
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:Float, y:Float, view:View3D):PickingCollisionVO;
20 | /**
21 | * Gets the collision object from the scene position and direction of the picking ray.
22 | *
23 | * @param position The position of the picking ray in scene-space.
24 | * @param direction The direction of the picking ray in scene-space.
25 | * @param scene The scene on which the picking object acts.
26 | */
27 | function getSceneCollision(position:Vector3D, direction:Vector3D, scene:Scene3D):PickingCollisionVO;
28 | /**
29 | * Determines whether the picker takes account of the mouseEnabled properties of entities. Defaults to true.
30 | */
31 | private function get_onlyMouseEnabled():Bool;
32 | private function set_onlyMouseEnabled(value:Bool):Bool;
33 | /**
34 | * Disposes memory used by the IPicker object
35 | */
36 | function dispose():Void;
37 | }
38 |
39 |
--------------------------------------------------------------------------------
/away3d/core/pick/IPickingCollider.hx:
--------------------------------------------------------------------------------
1 | /**
2 | * Provides an interface for picking colliders that can be assigned to individual entities in a scene for specific picking behaviour.
3 | * Used with the RaycastPicker
picking object.
4 | *
5 | * @see away3d.entities.Entity#pickingCollider
6 | * @see away3d.core.pick.RaycastPicker
7 | */
8 | package away3d.core.pick;
9 |
10 | import away3d.core.base.SubMesh;
11 | import openfl.geom.Vector3D;
12 |
13 | interface IPickingCollider {
14 |
15 | /**
16 | * Sets the position and direction of a picking ray in local coordinates to the entity.
17 | *
18 | * @param localDirection The position vector in local coordinates
19 | * @param localPosition The direction vector in local coordinates
20 | */
21 | function setLocalRay(localPosition:Vector3D, localDirection:Vector3D):Void;
22 | function testSubMeshCollision(subMesh:SubMesh, pickingCollisionVO:PickingCollisionVO, shortestCollisionDistance:Float):Bool;
23 | }
24 |
25 |
--------------------------------------------------------------------------------
/away3d/core/pick/PickingColliderType.hx:
--------------------------------------------------------------------------------
1 | /**
2 | * Options for setting a picking collider for entity objects. Used with the RaycastPicker
picking object.
3 | *
4 | * @see away3d.entities.Entity#pickingCollider
5 | * @see away3d.core.pick.RaycastPicker
6 | */
7 | package away3d.core.pick;
8 |
9 | class PickingColliderType {
10 |
11 | /**
12 | * Default null collider that forces picker to only use entity bounds for hit calculations on an Entity
13 | */
14 | static public var BOUNDS_ONLY:IPickingCollider = null;
15 |
16 | /**
17 | * Picking collider that returns the first encountered hit on an Entity. Useful for low poly meshes and applying to many mesh instances.
18 | *
19 | * @see away3d.core.pick.PickingCollider
20 | */
21 | static public var FIRST_ENCOUNTERED:IPickingCollider = new PickingCollider(false);
22 |
23 | /**
24 | * Picking collider that returns the best (closest) hit on an Entity. Useful for low poly meshes and applying to many mesh instances.
25 | *
26 | * @see away3d.core.pick.PickingCollider
27 | */
28 | static public var BEST_HIT:IPickingCollider = new PickingCollider(true);
29 | }
30 |
31 |
--------------------------------------------------------------------------------
/away3d/core/pick/PickingType.hx:
--------------------------------------------------------------------------------
1 | /**
2 | * Options for the different 3D object picking approaches available in Away3D. Can be used for automatic mouse picking on the view.
3 | *
4 | * @see away3d.containers.View3D#mousePicker
5 | */
6 | package away3d.core.pick;
7 |
8 | class PickingType {
9 |
10 | /**
11 | * Uses a render pass to pick objects based on a key color that is read back into the engine.
12 | * Performance can be variable on some GPUs.
13 | */
14 | static public var SHADER:IPicker = new ShaderPicker();
15 | /**
16 | * Uses AS3 and Pixel Bender to pick objects based on ray intersection. Returns the hit on the first encountered Entity.
17 | */
18 | static public var RAYCAST_FIRST_ENCOUNTERED:IPicker = new RaycastPicker(false);
19 | /**
20 | * Uses AS3 and Pixel Bender to pick objects based on ray intersection. Returns the best (closest) hit on an Entity.
21 | */
22 | static public var RAYCAST_BEST_HIT:IPicker = new RaycastPicker(true);
23 | }
24 |
25 |
--------------------------------------------------------------------------------
/away3d/core/sort/IEntitySorter.hx:
--------------------------------------------------------------------------------
1 | /**
2 | * EntitySorterBase provides an abstract base class to sort geometry information in an EntityCollector object for
3 | * rendering.
4 | */
5 | package away3d.core.sort;
6 |
7 | import away3d.core.traverse.EntityCollector;
8 |
9 | interface IEntitySorter {
10 |
11 | /**
12 | * Sort the potentially visible data in an EntityCollector for rendering.
13 | * @param collector The EntityCollector object containing the potentially visible data.
14 | */
15 | function sort(collector:EntityCollector):Void;
16 | }
17 |
18 |
--------------------------------------------------------------------------------
/away3d/core/traverse/SceneIterator.hx:
--------------------------------------------------------------------------------
1 | package away3d.core.traverse;
2 |
3 |
4 | import away3d.containers.ObjectContainer3D;
5 | import away3d.containers.Scene3D;
6 | import openfl.Vector;
7 |
8 | class SceneIterator {
9 |
10 | static private var PRE:Int = 0;
11 | static private var IN:Int = 1;
12 | static private var POST:Int = 2;
13 | private var _childIndex:Int;
14 | private var _scene:Scene3D;
15 | private var _node:ObjectContainer3D;
16 | private var _traverseState:Int;
17 | private var _childIndexStack:Vector;
18 | private var _stackPos:Int;
19 |
20 | public function new(scene:Scene3D) {
21 | _scene = scene;
22 | reset();
23 | }
24 |
25 | public function reset():Void {
26 | _childIndexStack = new Vector();
27 | _node = _scene._sceneGraphRoot;
28 | _childIndex = 0;
29 | _stackPos = 0;
30 | _traverseState = PRE;
31 | }
32 |
33 | public function next():ObjectContainer3D {
34 | do {
35 | switch(_traverseState) {
36 | case SceneIterator.PRE, SceneIterator.IN:
37 | switch(_traverseState) {
38 | case SceneIterator.PRE:
39 | // just entered a node
40 | _childIndexStack[_stackPos++] = _childIndex;
41 | _childIndex = 0;
42 | _traverseState = SceneIterator.IN;
43 | return _node;
44 | }
45 | if (_childIndex == _node.numChildren) _traverseState = SceneIterator.POST
46 | else {
47 | _node = _node.getChildAt(_childIndex);
48 | _traverseState = SceneIterator.PRE;
49 | }
50 |
51 | case SceneIterator.POST:
52 | _node = _node.parent;
53 | _childIndex = _childIndexStack[--_stackPos] + 1;
54 | _traverseState = SceneIterator.IN;
55 | }
56 | }
57 | while ((!(_node == _scene._sceneGraphRoot && _traverseState == POST)));
58 | return null;
59 | }
60 | }
61 |
62 |
--------------------------------------------------------------------------------
/away3d/debug/AwayFPS.hx:
--------------------------------------------------------------------------------
1 | package away3d.debug;
2 |
3 | import openfl.display.FPS;
4 | import openfl.display.Sprite;
5 | import openfl.events.Event;
6 | import openfl.text.TextField;
7 | import openfl.text.TextFormat;
8 | import openfl.Lib;
9 | import haxe.Timer;
10 |
11 |
12 | import away3d.containers.View3D;
13 |
14 | class AwayFPS extends Sprite {
15 |
16 | var _fps:FPS;
17 | var _ply:TextField;
18 | var _view:View3D;
19 |
20 | public function new(view:View3D = null, xOff:Float = 10, yOff:Float = 10, color:Int = 0x000000, scale:Float = 4) {
21 | super();
22 |
23 | addChild(new FPS(0, 0, color));
24 |
25 | x = xOff;
26 | y = yOff;
27 |
28 | scaleX = scaleY = scale;
29 |
30 | _view = view;
31 | if (_view != null) {
32 | _ply = new TextField();
33 | _ply.defaultTextFormat = new TextFormat ("_sans", 12, color);
34 | _ply.y = 12;
35 | addChild(_ply);
36 |
37 | var timer = new haxe.Timer(500);
38 | timer.run = function() {
39 | _ply.text = "PLY:"+_view.renderedFacesCount;
40 | }
41 | }
42 | }
43 | }
--------------------------------------------------------------------------------
/away3d/debug/Debug.hx:
--------------------------------------------------------------------------------
1 | /** Class for emmiting debuging messages, warnings and errors */
2 | /**
3 | * @private
4 | */
5 | package away3d.debug;
6 |
7 | import openfl.errors.Error;
8 | class Debug {
9 |
10 | static public var active:Bool = false;
11 | static public var warningsAsErrors:Bool = false;
12 |
13 | static public function clear():Void {
14 | }
15 |
16 | static public function delimiter():Void {
17 | }
18 |
19 | static public function trace(message:Dynamic):Void {
20 | if (active) trace(message);
21 | }
22 |
23 | static public function warning(message:Dynamic):Void {
24 | if (warningsAsErrors) {
25 | error(message);
26 | return;
27 | }
28 | trace("WARNING: " + message);
29 | }
30 |
31 | static public function error(message:Dynamic):Void {
32 | trace("ERROR: " + message);
33 | throw new Error(message);
34 | }
35 | }
36 |
37 |
--------------------------------------------------------------------------------
/away3d/debug/data/TridentLines.hx:
--------------------------------------------------------------------------------
1 | package away3d.debug.data;
2 |
3 | import away3d.entities.SegmentSet;
4 | import away3d.primitives.LineSegment;
5 | import openfl.geom.Vector3D;
6 | import openfl.Vector;
7 |
8 | class TridentLines extends SegmentSet {
9 |
10 | public function new(vectors:Array>, colors:Array) {
11 | super();
12 |
13 | build(vectors, colors);
14 | }
15 |
16 | private function build(vectors:Array>, colors:Array):Void {
17 |
18 | var letter:Array;
19 | var v0:Vector3D;
20 | var v1:Vector3D;
21 | var color:Int;
22 |
23 | var j:Int;
24 | var i:Int = 0;
25 | while (i < vectors.length) {
26 | color = colors[i];
27 | letter = vectors[i];
28 |
29 | j = 0;
30 | while (j < letter.length) {
31 | v0 = letter[j];
32 | v1 = letter[j + 1];
33 | addSegment(new LineSegment(v0, v1, color, color, 1));
34 | j += 2;
35 | }
36 | ++i;
37 | }
38 | }
39 | }
40 |
41 |
--------------------------------------------------------------------------------
/away3d/errors/AbstractMethodError.hx:
--------------------------------------------------------------------------------
1 | /**
2 | * AbstractMethodError is thrown when an abstract method is called. The method in question should be overridden
3 | * by a concrete subclass.
4 | */
5 | package away3d.errors;
6 |
7 | import openfl.errors.Error;
8 | 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 new(message:String = null, id:Int = 0) {
16 | if (message == null) message = "An abstract method was called! Either an instance of an abstract class was created, or an abstract method was not overridden by the subclass.";
17 | super(message, id);
18 | }
19 | }
20 |
21 |
--------------------------------------------------------------------------------
/away3d/errors/AnimationSetError.hx:
--------------------------------------------------------------------------------
1 | package away3d.errors;
2 | import openfl.errors.Error;
3 | class AnimationSetError extends Error {
4 |
5 | public function new(message:String) {
6 | super(message);
7 | }
8 | }
9 |
10 |
--------------------------------------------------------------------------------
/away3d/errors/CastError.hx:
--------------------------------------------------------------------------------
1 | package away3d.errors;
2 | import openfl.errors.Error;
3 | class CastError extends Error {
4 |
5 | public function new(message:String) {
6 | super(message);
7 | }
8 | }
9 |
10 |
--------------------------------------------------------------------------------
/away3d/errors/DeprecationError.hx:
--------------------------------------------------------------------------------
1 | package away3d.errors;
2 | import openfl.errors.Error;
3 | class DeprecationError extends Error {
4 | public var since(get, never):String;
5 | public var source(get, never):String;
6 | public var info(get, never):String;
7 |
8 | private var _since:String;
9 | private var _source:String;
10 | private var _info:String;
11 |
12 | public function new(source:String, since:String, info:String) {
13 | super(source + " has been marked as deprecated since version " + since + " and has been slated for removal. " + info);
14 | _since = since;
15 | _source = source;
16 | _info = info;
17 | }
18 |
19 | private function get_since():String {
20 | return _since;
21 | }
22 |
23 | private function get_source():String {
24 | return _source;
25 | }
26 |
27 | private function get_info():String {
28 | return _info;
29 | }
30 | }
31 |
32 |
--------------------------------------------------------------------------------
/away3d/errors/InvalidTextureError.hx:
--------------------------------------------------------------------------------
1 | /**
2 | * TextureError is thrown when an invalid texture is used regarding Stage3D limitations.
3 | */
4 | package away3d.errors;
5 | import openfl.errors.Error;
6 | class InvalidTextureError extends Error {
7 |
8 | /**
9 | * Create a new TextureError.
10 | * @param message An optional message to override the default error message.
11 | * @param id The id of the error.
12 | */
13 | public function new(message:String = null, id:Int = 0) {
14 | if (message == null) {
15 | message = "Invalid bitmapData! Must be power of 2 and not exceeding 2048.";
16 | }
17 | super(message, id);
18 | }
19 | }
20 |
21 |
--------------------------------------------------------------------------------
/away3d/events/AnimationStateEvent.hx:
--------------------------------------------------------------------------------
1 | /**
2 | * Dispatched to notify changes in an animation state's state.
3 | */
4 | package away3d.events;
5 |
6 | import away3d.animators.nodes.AnimationNodeBase;
7 | import away3d.animators.states.IAnimationState;
8 | import away3d.animators.IAnimator;
9 | import openfl.events.Event;
10 |
11 | class AnimationStateEvent extends Event {
12 | public var animator(get, never):IAnimator;
13 | public var animationState(get, never):IAnimationState;
14 | public var animationNode(get, never):AnimationNodeBase;
15 |
16 | /**
17 | * Dispatched when a non-looping clip node inside an animation state reaches the end of its timeline.
18 | */
19 | static public var PLAYBACK_COMPLETE:String = "playbackComplete";
20 | static public var TRANSITION_COMPLETE:String = "transitionComplete";
21 | private var _animator:IAnimator;
22 | private var _animationState:IAnimationState;
23 | private var _animationNode:AnimationNodeBase;
24 | /**
25 | * Create a new AnimatonStateEvent
26 | *
27 | * @param type The event type.
28 | * @param animator The animation state object that is the subject of this event.
29 | * @param animationNode The animation node inside the animation state from which the event originated.
30 | */
31 | public function new(type:String, animator:IAnimator, animationState:IAnimationState, animationNode:AnimationNodeBase) {
32 | super(type, false, false);
33 | _animator = animator;
34 | _animationState = animationState;
35 | _animationNode = animationNode;
36 | }
37 |
38 | /**
39 | * The animator object that is the subject of this event.
40 | */
41 | private function get_animator():IAnimator {
42 | return _animator;
43 | }
44 |
45 | /**
46 | * The animation state object that is the subject of this event.
47 | */
48 | private function get_animationState():IAnimationState {
49 | return _animationState;
50 | }
51 |
52 | /**
53 | * The animation node inside the animation state from which the event originated.
54 | */
55 | private function get_animationNode():AnimationNodeBase {
56 | return _animationNode;
57 | }
58 |
59 | /**
60 | * Clones the event.
61 | *
62 | * @return An exact duplicate of the current object.
63 | */
64 | override public function clone():Event {
65 | return new AnimationStateEvent(type, _animator, _animationState, _animationNode);
66 | }
67 | }
68 |
69 |
--------------------------------------------------------------------------------
/away3d/events/AnimatorEvent.hx:
--------------------------------------------------------------------------------
1 | /**
2 | * Dispatched to notify changes in an animator's state.
3 | */
4 | package away3d.events;
5 |
6 |
7 | import away3d.animators.AnimatorBase;
8 | import away3d.animators.AnimatorBase;
9 | import openfl.events.Event;
10 | class AnimatorEvent extends Event {
11 | public var animator(get, never):AnimatorBase;
12 |
13 | /**
14 | * Defines the value of the type property of a start event object.
15 | */
16 | static public var START:String = "start";
17 | /**
18 | * Defines the value of the type property of a stop event object.
19 | */
20 | static public var STOP:String = "stop";
21 | /**
22 | * Defines the value of the type property of a cycle complete event object.
23 | */
24 | static public var CYCLE_COMPLETE:String = "cycle_complete";
25 | private var _animator:AnimatorBase;
26 | /**
27 | * Create a new AnimatorEvent
object.
28 | *
29 | * @param type The event type.
30 | * @param animator The animator object that is the subject of this event.
31 | */
32 | public function new(type:String, animator:AnimatorBase) {
33 | super(type, false, false);
34 | _animator = animator;
35 | }
36 |
37 | private function get_animator():AnimatorBase {
38 | return _animator;
39 | }
40 |
41 | /**
42 | * Clones the event.
43 | *
44 | * @return An exact duplicate of the current event object.
45 | */
46 | override public function clone():Event {
47 | return new AnimatorEvent(type, _animator);
48 | }
49 | }
50 |
51 |
--------------------------------------------------------------------------------
/away3d/events/CameraEvent.hx:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package away3d.events;
5 |
6 | import openfl.events.Event;
7 | import away3d.cameras.Camera3D;
8 |
9 | class CameraEvent extends Event {
10 | public var camera(get, never):Camera3D;
11 |
12 | static public var LENS_CHANGED:String = "lensChanged";
13 | private var _camera:Camera3D;
14 |
15 | public function new(type:String, camera:Camera3D, bubbles:Bool = false, cancelable:Bool = false) {
16 | super(type, bubbles, cancelable);
17 | _camera = camera;
18 | }
19 |
20 | private function get_camera():Camera3D {
21 | return _camera;
22 | }
23 |
24 | override public function clone():Event {
25 | return new CameraEvent(type, _camera, bubbles, cancelable);
26 | }
27 | }
28 |
29 |
--------------------------------------------------------------------------------
/away3d/events/GeometryEvent.hx:
--------------------------------------------------------------------------------
1 | /**
2 | * Dispatched to notify changes in a geometry object's state.
3 | *
4 | * @see away3d.core.base.Geometry
5 | */
6 | package away3d.events;
7 |
8 | import away3d.core.base.ISubGeometry;
9 | import openfl.events.Event;
10 |
11 | class GeometryEvent extends Event {
12 | public var subGeometry(get, never):ISubGeometry;
13 |
14 | /**
15 | * Dispatched when a SubGeometry was added from the dispatching Geometry.
16 | */
17 | static public var SUB_GEOMETRY_ADDED:String = "SubGeometryAdded";
18 | /**
19 | * Dispatched when a SubGeometry was removed from the dispatching Geometry.
20 | */
21 | static public var SUB_GEOMETRY_REMOVED:String = "SubGeometryRemoved";
22 | static public var BOUNDS_INVALID:String = "BoundsInvalid";
23 | private var _subGeometry:ISubGeometry;
24 | /**
25 | * Create a new GeometryEvent
26 | * @param type The event type.
27 | * @param subGeometry An optional SubGeometry object that is the subject of this event.
28 | */
29 | public function new(type:String, subGeometry:ISubGeometry = null) {
30 | super(type, false, false);
31 | _subGeometry = subGeometry;
32 | }
33 |
34 | /**
35 | * The SubGeometry object that is the subject of this event, if appropriate.
36 | */
37 | private function get_subGeometry():ISubGeometry {
38 | return _subGeometry;
39 | }
40 |
41 | /**
42 | * Clones the event.
43 | * @return An exact duplicate of the current object.
44 | */
45 | override public function clone():Event {
46 | return new GeometryEvent(type, _subGeometry);
47 | }
48 | }
49 |
50 |
--------------------------------------------------------------------------------
/away3d/events/LensEvent.hx:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package away3d.events;
5 |
6 | import away3d.cameras.lenses.LensBase;
7 | import openfl.events.Event;
8 |
9 | class LensEvent extends Event {
10 | public var lens(get, never):LensBase;
11 |
12 | static public var MATRIX_CHANGED:String = "matrixChanged";
13 | private var _lens:LensBase;
14 |
15 | public function new(type:String, lens:LensBase, bubbles:Bool = false, cancelable:Bool = false) {
16 | super(type, bubbles, cancelable);
17 | _lens = lens;
18 | }
19 |
20 | private function get_lens():LensBase {
21 | return _lens;
22 | }
23 |
24 | override public function clone():Event {
25 | return new LensEvent(type, _lens, bubbles, cancelable);
26 | }
27 | }
28 |
29 |
--------------------------------------------------------------------------------
/away3d/events/LightEvent.hx:
--------------------------------------------------------------------------------
1 | package away3d.events;
2 |
3 | import openfl.events.Event;
4 |
5 | class LightEvent extends Event {
6 |
7 | static public var CASTS_SHADOW_CHANGE:String = "castsShadowChange";
8 |
9 | public function new(type:String) {
10 | super(type);
11 | }
12 |
13 | override public function clone():Event {
14 | return new LightEvent(type);
15 | }
16 | }
17 |
18 |
--------------------------------------------------------------------------------
/away3d/events/Object3DEvent.hx:
--------------------------------------------------------------------------------
1 | /**
2 | * Passed as a parameter when a 3d object event occurs
3 | */
4 | package away3d.events;
5 |
6 | import away3d.core.base.Object3D;
7 | import openfl.events.Event;
8 |
9 | class Object3DEvent extends Event {
10 |
11 | /**
12 | * Defines the value of the type property of a visiblityUpdated event object.
13 | */
14 | static public inline var VISIBLITY_UPDATED:String = "visiblityUpdated";
15 | /**
16 | * Defines the value of the type property of a scenetransformChanged event object.
17 | */
18 | static public inline var SCENETRANSFORM_CHANGED:String = "scenetransformChanged";
19 | /**
20 | * Defines the value of the type property of a sceneChanged event object.
21 | */
22 | static public inline var SCENE_CHANGED:String = "sceneChanged";
23 | /**
24 | * Defines the value of the type property of a positionChanged event object.
25 | */
26 | static public inline var POSITION_CHANGED:String = "positionChanged";
27 | /**
28 | * Defines the value of the type property of a rotationChanged event object.
29 | */
30 | static public inline var ROTATION_CHANGED:String = "rotationChanged";
31 | /**
32 | * Defines the value of the type property of a scaleChanged event object.
33 | */
34 | static public inline var SCALE_CHANGED:String = "scaleChanged";
35 | /**
36 | * A reference to the 3d object that is relevant to the event.
37 | */
38 | public var object:Object3D;
39 | /**
40 | * Creates a new MaterialEvent
object.
41 | *
42 | * @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
.
43 | * @param object A reference to the 3d object that is relevant to the event.
44 | */
45 | public function new(type:String, object:Object3D) {
46 | super(type);
47 | this.object = object;
48 | }
49 |
50 | /**
51 | * Creates a copy of the Object3DEvent object and sets the value of each property to match that of the original.
52 | */
53 | override public function clone():Event {
54 | return new Object3DEvent(type, object);
55 | }
56 | }
57 |
58 |
--------------------------------------------------------------------------------
/away3d/events/ParserEvent.hx:
--------------------------------------------------------------------------------
1 | package away3d.events;
2 |
3 | import openfl.events.Event;
4 |
5 | class ParserEvent extends Event {
6 | public var message(get, never):String;
7 |
8 | private var _message:String;
9 | /**
10 | * Dispatched when parsing of an asset completed.
11 | */
12 | static public var PARSE_COMPLETE:String = "parseComplete";
13 | /**
14 | * Dispatched when an error occurs while parsing the data (e.g. because it's
15 | * incorrectly formatted.)
16 | */
17 | static public var PARSE_ERROR:String = "parseError";
18 | /**
19 | * Dispatched when a parser is ready to have dependencies retrieved and resolved.
20 | * This is an internal event that should rarely (if ever) be listened for by
21 | * external classes.
22 | */
23 | static public var READY_FOR_DEPENDENCIES:String = "readyForDependencies";
24 |
25 | public function new(type:String, message:String = "") {
26 | super(type);
27 | _message = message;
28 | }
29 |
30 | /**
31 | * Additional human-readable message. Usually supplied for PARSE_ERROR events.
32 | */
33 | private function get_message():String {
34 | return _message;
35 | }
36 |
37 | override public function clone():Event {
38 | return new ParserEvent(type, message);
39 | }
40 | }
41 |
42 |
--------------------------------------------------------------------------------
/away3d/events/PathEvent.hx:
--------------------------------------------------------------------------------
1 | package away3d.events;
2 |
3 | import openfl.events.Event;
4 |
5 | class PathEvent extends Event {
6 |
7 | /**
8 | * Dispatched when the time pointer enter a new cycle at time 0, after last time was greater than 0.99
9 | */
10 | static public var CYCLE:String = "cycle";
11 | /**
12 | * Dispatched when the time pointer is included a given from/to time region on a path
13 | */
14 | static public var RANGE:String = "range";
15 | /**
16 | * Dispatched when the time pointer enters a new PathSegment
17 | */
18 | static public var CHANGE_SEGMENT:String = "change_segment";
19 |
20 | public function new(type:String) {
21 | super(type);
22 | }
23 | }
24 |
25 |
--------------------------------------------------------------------------------
/away3d/events/Scene3DEvent.hx:
--------------------------------------------------------------------------------
1 | package away3d.events;
2 |
3 | import away3d.containers.ObjectContainer3D;
4 | import openfl.events.Event;
5 |
6 | class Scene3DEvent extends Event {
7 |
8 | static public var ADDED_TO_SCENE:String = "addedToScene";
9 | static public var REMOVED_FROM_SCENE:String = "removedFromScene";
10 | static public var PARTITION_CHANGED:String = "partitionChanged";
11 | public var objectContainer3D:ObjectContainer3D;
12 | //@:getter(target)
13 | #if flash
14 | private function get_target():Dynamic {
15 | return objectContainer3D;
16 | }
17 | #end
18 |
19 | public function new(type:String, objectContainer:ObjectContainer3D) {
20 | objectContainer3D = objectContainer;
21 | super(type);
22 | }
23 |
24 | override public function clone():Event {
25 | return new Scene3DEvent(type, objectContainer3D);
26 | }
27 | }
28 |
29 |
--------------------------------------------------------------------------------
/away3d/events/ShadingMethodEvent.hx:
--------------------------------------------------------------------------------
1 | package away3d.events;
2 |
3 | import openfl.events.Event;
4 |
5 | class ShadingMethodEvent extends Event {
6 |
7 | static public var SHADER_INVALIDATED:String = "ShaderInvalidated";
8 |
9 | public function new(type:String, bubbles:Bool = false, cancelable:Bool = false) {
10 | super(type, bubbles, cancelable);
11 | }
12 | }
13 |
14 |
--------------------------------------------------------------------------------
/away3d/events/Stage3DEvent.hx:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package away3d.events;
5 |
6 | import openfl.events.Event;
7 |
8 | class Stage3DEvent extends Event {
9 |
10 | static public var CONTEXT3D_CREATED:String = "Context3DCreated";
11 | static public var CONTEXT3D_DISPOSED:String = "Context3DDisposed";
12 | static public var CONTEXT3D_RECREATED:String = "Context3DRecreated";
13 | static public var VIEWPORT_UPDATED:String = "ViewportUpdated";
14 |
15 | public function new(type:String, bubbles:Bool = false, cancelable:Bool = false) {
16 | super(type, bubbles, cancelable);
17 | }
18 | }
19 |
20 |
--------------------------------------------------------------------------------
/away3d/extrusions/data/FourPoints.hx:
--------------------------------------------------------------------------------
1 | package away3d.extrusions.data;
2 | import openfl.geom.Point;
3 | class FourPoints {
4 |
5 | public var pt1:Point;
6 | public var pt2:Point;
7 | public var pt3:Point;
8 | public var pt4:Point;
9 |
10 | public function new() {}
11 | }
--------------------------------------------------------------------------------
/away3d/extrusions/data/Line.hx:
--------------------------------------------------------------------------------
1 | package away3d.extrusions.data;
2 | class Line {
3 |
4 | public var ax:Float;
5 | public var ay:Float;
6 | public var bx:Float;
7 | public var by:Float;
8 |
9 | public function new() {}
10 | }
11 |
--------------------------------------------------------------------------------
/away3d/extrusions/data/RenderSide.hx:
--------------------------------------------------------------------------------
1 | package away3d.extrusions.data;
2 | class RenderSide {
3 |
4 | public var top:Bool;
5 | public var bottom:Bool;
6 | public var right:Bool;
7 | public var left:Bool;
8 | public var front:Bool;
9 | public var back:Bool;
10 |
11 | public function new() {}
12 | }
13 |
--------------------------------------------------------------------------------
/away3d/extrusions/data/SubGeometryList.hx:
--------------------------------------------------------------------------------
1 | package away3d.extrusions.data;
2 |
3 | import away3d.materials.MaterialBase;
4 | import away3d.core.base.SubGeometry;
5 | import openfl.Vector;
6 |
7 | class SubGeometryList {
8 |
9 | public var id:Int;
10 | public var uvs:Vector;
11 | public var vertices:Vector;
12 | public var normals:Vector;
13 | public var indices:Vector;
14 | public var subGeometry:SubGeometry;
15 | public var material:MaterialBase;
16 |
17 | public function new() {}
18 | }
19 |
--------------------------------------------------------------------------------
/away3d/filters/BlurFilter3D.hx:
--------------------------------------------------------------------------------
1 | package away3d.filters;
2 |
3 | import away3d.core.managers.Stage3DProxy;
4 | import away3d.filters.tasks.Filter3DHBlurTask;
5 | import away3d.filters.tasks.Filter3DVBlurTask;
6 | import openfl.display3D.textures.Texture;
7 |
8 | class BlurFilter3D extends Filter3DBase {
9 | public var blurX(get, set):Int;
10 | public var blurY(get, set):Int;
11 | public var stepSize(get, set):Int;
12 |
13 | private var _hBlurTask:Filter3DHBlurTask;
14 | private var _vBlurTask:Filter3DVBlurTask;
15 | /**
16 | * Creates a new BlurFilter3D object
17 | * @param blurX The amount of horizontal blur to apply
18 | * @param blurY The amount of vertical blur to apply
19 | * @param stepSize The distance between samples. Set to -1 to autodetect with acceptable quality.
20 | */
21 | public function new(blurX:Int = 3, blurY:Int = 3, stepSize:Int = -1) {
22 | super();
23 |
24 | addTask(_hBlurTask = new Filter3DHBlurTask(blurX, stepSize));
25 | addTask(_vBlurTask = new Filter3DVBlurTask(blurY, stepSize));
26 | }
27 |
28 | private function get_blurX():Int {
29 | return _hBlurTask.amount;
30 | }
31 |
32 | private function set_blurX(value:Int):Int {
33 | _hBlurTask.amount = value;
34 | return value;
35 | }
36 |
37 | private function get_blurY():Int {
38 | return _vBlurTask.amount;
39 | }
40 |
41 | private function set_blurY(value:Int):Int {
42 | _vBlurTask.amount = value;
43 | return value;
44 | }
45 |
46 | /**
47 | * The distance between two blur samples. Set to -1 to autodetect with acceptable quality (default value).
48 | * Higher values provide better performance at the cost of reduces quality.
49 | */
50 | private function get_stepSize():Int {
51 | return _hBlurTask.stepSize;
52 | }
53 |
54 | private function set_stepSize(value:Int):Int {
55 | _hBlurTask.stepSize = value;
56 | _vBlurTask.stepSize = value;
57 | return value;
58 | }
59 |
60 | override public function setRenderTargets(mainTarget:Texture, stage3DProxy:Stage3DProxy):Void {
61 | _hBlurTask.target = _vBlurTask.getMainInputTexture(stage3DProxy);
62 | super.setRenderTargets(mainTarget, stage3DProxy);
63 | }
64 | }
65 |
66 |
--------------------------------------------------------------------------------
/away3d/filters/HBlurFilter3D.hx:
--------------------------------------------------------------------------------
1 | package away3d.filters;
2 |
3 | import away3d.filters.tasks.Filter3DHBlurTask;
4 |
5 | class HBlurFilter3D extends Filter3DBase {
6 | public var amount(get, set):Int;
7 | public var stepSize(get, set):Int;
8 |
9 | private var _blurTask:Filter3DHBlurTask;
10 | /**
11 | * Creates a new HBlurFilter3D object
12 | * @param amount The amount of blur in pixels
13 | * @param stepSize The distance between two blur samples. Set to -1 to autodetect with acceptable quality (default value).
14 | */
15 | public function new(amount:Int, stepSize:Int = -1) {
16 | super();
17 | _blurTask = new Filter3DHBlurTask(amount, stepSize);
18 | addTask(_blurTask);
19 | }
20 |
21 | private function get_amount():Int {
22 | return _blurTask.amount;
23 | }
24 |
25 | private function set_amount(value:Int):Int {
26 | _blurTask.amount = value;
27 | return value;
28 | }
29 |
30 | /**
31 | * The distance between two blur samples. Set to -1 to autodetect with acceptable quality (default value).
32 | * Higher values provide better performance at the cost of reduces quality.
33 | */
34 | private function get_stepSize():Int {
35 | return _blurTask.stepSize;
36 | }
37 |
38 | private function set_stepSize(value:Int):Int {
39 | _blurTask.stepSize = value;
40 | return value;
41 | }
42 | }
43 |
44 |
--------------------------------------------------------------------------------
/away3d/filters/HDepthOfFieldFilter3D.hx:
--------------------------------------------------------------------------------
1 | package away3d.filters;
2 |
3 | import away3d.cameras.Camera3D;
4 | import away3d.containers.ObjectContainer3D;
5 | import away3d.core.managers.Stage3DProxy;
6 | import away3d.filters.tasks.Filter3DHDepthOfFFieldTask;
7 | import openfl.geom.Vector3D;
8 |
9 | class HDepthOfFieldFilter3D extends Filter3DBase {
10 | public var focusTarget(get, set):ObjectContainer3D;
11 | public var focusDistance(get, set):Float;
12 | public var range(get, set):Float;
13 | public var maxBlur(get, set):Int;
14 |
15 | private var _dofTask:Filter3DHDepthOfFFieldTask;
16 | private var _focusTarget:ObjectContainer3D;
17 | /**
18 | * Creates a new HDepthOfFieldFilter3D object
19 | * @param amount The amount of blur to apply in pixels
20 | * @param stepSize The distance between samples. Set to -1 to autodetect with acceptable quality.
21 | */
22 | public function new(maxBlur:Int = 3, stepSize:Int = -1) {
23 | super();
24 | _dofTask = new Filter3DHDepthOfFFieldTask(maxBlur, stepSize);
25 | addTask(_dofTask);
26 | }
27 |
28 | private function get_focusTarget():ObjectContainer3D {
29 | return _focusTarget;
30 | }
31 |
32 | private function set_focusTarget(value:ObjectContainer3D):ObjectContainer3D {
33 | _focusTarget = value;
34 | return value;
35 | }
36 |
37 | private function get_focusDistance():Float {
38 | return _dofTask.focusDistance;
39 | }
40 |
41 | private function set_focusDistance(value:Float):Float {
42 | _dofTask.focusDistance = value;
43 | return value;
44 | }
45 |
46 | private function get_range():Float {
47 | return _dofTask.range;
48 | }
49 |
50 | private function set_range(value:Float):Float {
51 | _dofTask.range = value;
52 | return value;
53 | }
54 |
55 | private function get_maxBlur():Int {
56 | return _dofTask.maxBlur;
57 | }
58 |
59 | private function set_maxBlur(value:Int):Int {
60 | _dofTask.maxBlur = value;
61 | return value;
62 | }
63 |
64 | override public function update(stage:Stage3DProxy, camera:Camera3D):Void {
65 | if (_focusTarget != null) updateFocus(camera);
66 | }
67 |
68 | private function updateFocus(camera:Camera3D):Void {
69 | var target:Vector3D = camera.inverseSceneTransform.transformVector(_focusTarget.scenePosition);
70 | _dofTask.focusDistance = target.z;
71 | }
72 | }
73 |
74 |
--------------------------------------------------------------------------------
/away3d/filters/HueSaturationFilter3D.hx:
--------------------------------------------------------------------------------
1 | package away3d.filters;
2 |
3 | import away3d.filters.tasks.Filter3DHueSaturationTask;
4 |
5 | class HueSaturationFilter3D extends Filter3DBase {
6 |
7 | public var saturation(get, set):Float;
8 | public var r(get, set):Float;
9 | public var b(get, set):Float;
10 | public var g(get, set):Float;
11 |
12 | private var _hslTask:Filter3DHueSaturationTask;
13 |
14 | public function new(saturation:Float = 1, r:Float = 1, g:Float = 1, b:Float = 1) {
15 | super();
16 |
17 | _hslTask = new Filter3DHueSaturationTask();
18 |
19 | this.saturation = saturation;
20 | this.r = r;
21 | this.g = g;
22 | this.b = b;
23 |
24 | addTask(_hslTask);
25 | }
26 |
27 | private function get_saturation():Float {
28 | return _hslTask.saturation;
29 | }
30 |
31 | private function set_saturation(value:Float):Float {
32 | if (_hslTask.saturation == value) return value;
33 | _hslTask.saturation = value;
34 | return value;
35 | }
36 |
37 | private function get_r():Float {
38 | return _hslTask.r;
39 | }
40 |
41 | private function set_r(value:Float):Float {
42 | if (_hslTask.r == value) return value;
43 | _hslTask.r = value;
44 | return value;
45 | }
46 |
47 | private function get_b():Float {
48 | return _hslTask.b;
49 | }
50 |
51 | private function set_b(value:Float):Float {
52 | if (_hslTask.b == value) return value;
53 | _hslTask.b = value;
54 | return value;
55 | }
56 |
57 | private function get_g():Float {
58 | return _hslTask.g;
59 | }
60 |
61 | private function set_g(value:Float):Float {
62 | if (_hslTask.g == value) return value;
63 | _hslTask.g = value;
64 | return value;
65 | }
66 | }
67 |
68 |
--------------------------------------------------------------------------------
/away3d/filters/MotionBlurFilter3D.hx:
--------------------------------------------------------------------------------
1 | package away3d.filters;
2 |
3 | import away3d.cameras.Camera3D;
4 | import away3d.core.managers.Stage3DProxy;
5 | import away3d.filters.tasks.Filter3DDoubleBufferCopyTask;
6 | import away3d.filters.tasks.Filter3DXFadeCompositeTask;
7 |
8 | class MotionBlurFilter3D extends Filter3DBase {
9 | public var strength(get, set):Float;
10 |
11 | private var _compositeTask:Filter3DXFadeCompositeTask;
12 | private var _copyTask:Filter3DDoubleBufferCopyTask;
13 |
14 | public function new(strength:Float = .65) {
15 | super();
16 | _compositeTask = new Filter3DXFadeCompositeTask(strength);
17 | _copyTask = new Filter3DDoubleBufferCopyTask();
18 | addTask(_compositeTask);
19 | addTask(_copyTask);
20 | }
21 |
22 | private function get_strength():Float {
23 | return _compositeTask.amount;
24 | }
25 |
26 | private function set_strength(value:Float):Float {
27 | _compositeTask.amount = value;
28 | return value;
29 | }
30 |
31 | override public function update(stage:Stage3DProxy, camera:Camera3D):Void {
32 | // TODO: not used
33 |
34 | _compositeTask.overlayTexture = _copyTask.getMainInputTexture(stage);
35 | _compositeTask.target = _copyTask.secondaryInputTexture;
36 | }
37 | }
38 |
39 |
--------------------------------------------------------------------------------
/away3d/filters/RadialBlurFilter3D.hx:
--------------------------------------------------------------------------------
1 | package away3d.filters;
2 |
3 | import away3d.filters.tasks.Filter3DRadialBlurTask;
4 |
5 | class RadialBlurFilter3D extends Filter3DBase {
6 | public var intensity(get, set):Float;
7 | public var glowGamma(get, set):Float;
8 | public var blurStart(get, set):Float;
9 | public var blurWidth(get, set):Float;
10 | public var cx(get, set):Float;
11 | public var cy(get, set):Float;
12 |
13 | private var _blurTask:Filter3DRadialBlurTask;
14 |
15 | public function new(intensity:Float = 8.0, glowGamma:Float = 1.6, blurStart:Float = 1.0, blurWidth:Float = -0.3, cx:Float = 0.5, cy:Float = 0.5) {
16 | super();
17 | _blurTask = new Filter3DRadialBlurTask(intensity, glowGamma, blurStart, blurWidth, cx, cy);
18 | addTask(_blurTask);
19 | }
20 |
21 | private function get_intensity():Float {
22 | return _blurTask.intensity;
23 | }
24 |
25 | private function set_intensity(intensity:Float):Float {
26 | _blurTask.intensity = intensity;
27 | return intensity;
28 | }
29 |
30 | private function get_glowGamma():Float {
31 | return _blurTask.glowGamma;
32 | }
33 |
34 | private function set_glowGamma(glowGamma:Float):Float {
35 | _blurTask.glowGamma = glowGamma;
36 | return glowGamma;
37 | }
38 |
39 | private function get_blurStart():Float {
40 | return _blurTask.blurStart;
41 | }
42 |
43 | private function set_blurStart(blurStart:Float):Float {
44 | _blurTask.blurStart = blurStart;
45 | return blurStart;
46 | }
47 |
48 | private function get_blurWidth():Float {
49 | return _blurTask.blurWidth;
50 | }
51 |
52 | private function set_blurWidth(blurWidth:Float):Float {
53 | _blurTask.blurWidth = blurWidth;
54 | return blurWidth;
55 | }
56 |
57 | private function get_cx():Float {
58 | return _blurTask.cx;
59 | }
60 |
61 | private function set_cx(cx:Float):Float {
62 | _blurTask.cx = cx;
63 | return cx;
64 | }
65 |
66 | private function get_cy():Float {
67 | return _blurTask.cy;
68 | }
69 |
70 | private function set_cy(cy:Float):Float {
71 | _blurTask.cy = cy;
72 | return cy;
73 | }
74 | }
75 |
76 |
--------------------------------------------------------------------------------
/away3d/filters/VBlurFilter3D.hx:
--------------------------------------------------------------------------------
1 | package away3d.filters;
2 |
3 | import away3d.filters.tasks.Filter3DVBlurTask;
4 |
5 | class VBlurFilter3D extends Filter3DBase {
6 | public var amount(get, set):Int;
7 | public var stepSize(get, set):Int;
8 |
9 | private var _blurTask:Filter3DVBlurTask;
10 | /**
11 | * Creates a new VBlurFilter3D object
12 | * @param amount The amount of blur in pixels
13 | * @param stepSize The distance between two blur samples. Set to -1 to autodetect with acceptable quality (default value).
14 | */
15 | public function new(amount:Int, stepSize:Int = -1) {
16 | super();
17 | _blurTask = new Filter3DVBlurTask(amount, stepSize);
18 | addTask(_blurTask);
19 | }
20 |
21 | private function get_amount():Int {
22 | return _blurTask.amount;
23 | }
24 |
25 | private function set_amount(value:Int):Int {
26 | _blurTask.amount = value;
27 | return value;
28 | }
29 |
30 | /**
31 | * The distance between two blur samples. Set to -1 to autodetect with acceptable quality (default value).
32 | * Higher values provide better performance at the cost of reduces quality.
33 | */
34 | private function get_stepSize():Int {
35 | return _blurTask.stepSize;
36 | }
37 |
38 | private function set_stepSize(value:Int):Int {
39 | _blurTask.stepSize = value;
40 | return value;
41 | }
42 | }
43 |
44 |
--------------------------------------------------------------------------------
/away3d/filters/VDepthOfFieldFilter3D.hx:
--------------------------------------------------------------------------------
1 | package away3d.filters;
2 |
3 | import away3d.cameras.Camera3D;
4 | import away3d.containers.ObjectContainer3D;
5 | import away3d.core.managers.Stage3DProxy;
6 | import away3d.filters.tasks.Filter3DVDepthOfFFieldTask;
7 | import openfl.geom.Vector3D;
8 |
9 | class VDepthOfFieldFilter3D extends Filter3DBase {
10 | public var focusTarget(get, set):ObjectContainer3D;
11 | public var focusDistance(get, set):Float;
12 | public var range(get, set):Float;
13 | public var maxBlur(get, set):Int;
14 |
15 | private var _dofTask:Filter3DVDepthOfFFieldTask;
16 | private var _focusTarget:ObjectContainer3D;
17 | /**
18 | * Creates a new VDepthOfFieldFilter3D object
19 | * @param amount The amount of blur to apply in pixels
20 | * @param stepSize The distance between samples. Set to -1 to autodetect with acceptable quality.
21 | */
22 | public function new(maxBlur:Int = 3, stepSize:Int = -1) {
23 | super();
24 | _dofTask = new Filter3DVDepthOfFFieldTask(maxBlur, stepSize);
25 | addTask(_dofTask);
26 | }
27 |
28 | private function get_focusTarget():ObjectContainer3D {
29 | return _focusTarget;
30 | }
31 |
32 | private function set_focusTarget(value:ObjectContainer3D):ObjectContainer3D {
33 | _focusTarget = value;
34 | return value;
35 | }
36 |
37 | private function get_focusDistance():Float {
38 | return _dofTask.focusDistance;
39 | }
40 |
41 | private function set_focusDistance(value:Float):Float {
42 | _dofTask.focusDistance = value;
43 | return value;
44 | }
45 |
46 | private function get_range():Float {
47 | return _dofTask.range;
48 | }
49 |
50 | private function set_range(value:Float):Float {
51 | _dofTask.range = value;
52 | return value;
53 | }
54 |
55 | private function get_maxBlur():Int {
56 | return _dofTask.maxBlur;
57 | }
58 |
59 | private function set_maxBlur(value:Int):Int {
60 | _dofTask.maxBlur = value;
61 | return value;
62 | }
63 |
64 | override public function update(stage:Stage3DProxy, camera:Camera3D):Void {
65 | if (_focusTarget != null) updateFocus(camera);
66 | }
67 |
68 | private function updateFocus(camera:Camera3D):Void {
69 | var target:Vector3D = camera.inverseSceneTransform.transformVector(_focusTarget.scenePosition);
70 | _dofTask.focusDistance = target.z;
71 | }
72 | }
73 |
74 |
--------------------------------------------------------------------------------
/away3d/filters/tasks/Filter3DBloomCompositeTask.hx:
--------------------------------------------------------------------------------
1 | package away3d.filters.tasks;
2 |
3 |
4 | import away3d.cameras.Camera3D;
5 | import away3d.core.managers.Stage3DProxy;
6 | import openfl.display3D.Context3D;
7 | import openfl.display3D.Context3DProgramType;
8 | import openfl.display3D.textures.Texture;
9 | import openfl.display3D.textures.TextureBase;
10 | import openfl.Vector;
11 |
12 | class Filter3DBloomCompositeTask extends Filter3DTaskBase {
13 | public var overlayTexture(get, set):TextureBase;
14 | public var exposure(get, set):Float;
15 |
16 | private var _data:Vector;
17 | private var _overlayTexture:TextureBase;
18 | private var _exposure:Float;
19 |
20 | public function new(exposure:Float) {
21 | super();
22 |
23 | _data = [ 0.299, 0.587, 0.114, 1.0 ];
24 |
25 | // luminance projection, 1
26 | this.exposure = exposure;
27 | }
28 |
29 | private function get_overlayTexture():TextureBase {
30 | return _overlayTexture;
31 | }
32 |
33 | private function set_overlayTexture(value:TextureBase):TextureBase {
34 | _overlayTexture = value;
35 | return value;
36 | }
37 |
38 | override public function getFragmentCode():String {
39 | var code:String;
40 | code = "tex ft0, v0, fs0 <2d,linear,clamp> \n" + "tex ft1, v0, fs1 <2d,linear,clamp> \n" + "dp3 ft2.x, ft1, fc0\n" + "sub ft2.x, fc0.w, ft2.x\n" + "mul ft0, ft0, ft2.x\n";
41 | code += "add oc, ft0, ft1 \n";
42 | return code;
43 | }
44 |
45 | override public function activate(stage3DProxy:Stage3DProxy, camera3D:Camera3D, depthTexture:Texture):Void {
46 | var context:Context3D = stage3DProxy.context3D;
47 | context.setProgramConstantsFromVector(Context3DProgramType.FRAGMENT, 0, _data, 1);
48 | context.setTextureAt(1, _overlayTexture);
49 | }
50 |
51 | override public function deactivate(stage3DProxy:Stage3DProxy):Void {
52 | stage3DProxy.context3D.setTextureAt(1, null);
53 | }
54 |
55 | private function get_exposure():Float {
56 | return _exposure;
57 | }
58 |
59 | private function set_exposure(exposure:Float):Float {
60 | _exposure = exposure;
61 | _data[3] = 1 + _exposure / 10;
62 | return exposure;
63 | }
64 | }
65 |
66 |
--------------------------------------------------------------------------------
/away3d/filters/tasks/Filter3DBrightPassTask.hx:
--------------------------------------------------------------------------------
1 | package away3d.filters.tasks;
2 |
3 | import away3d.cameras.Camera3D;
4 | import away3d.core.managers.Stage3DProxy;
5 | import openfl.display3D.Context3DProgramType;
6 | import openfl.display3D.textures.Texture;
7 | import openfl.Vector;
8 |
9 | class Filter3DBrightPassTask extends Filter3DTaskBase {
10 | public var threshold(get, set):Float;
11 |
12 | private var _brightPassData:Vector;
13 | private var _threshold:Float;
14 |
15 | public function new(threshold:Float = .75) {
16 | super();
17 | _threshold = threshold;
18 | _brightPassData = Vector.ofArray(cast [threshold, 1 / (1 - threshold), 0, 0]);
19 | }
20 |
21 | private function get_threshold():Float {
22 | return _threshold;
23 | }
24 |
25 | private function set_threshold(value:Float):Float {
26 | _threshold = value;
27 | _brightPassData[0] = value;
28 | _brightPassData[1] = 1 / (1 - value);
29 | return value;
30 | }
31 |
32 | override public function getFragmentCode():String {
33 | return "tex ft0, v0, fs0 <2d,linear,clamp> \n" + "dp3 ft1.x, ft0.xyz, ft0.xyz \n" + "sqt ft1.x, ft1.x \n" + "sub ft1.y, ft1.x, fc0.x \n" + "mul ft1.y, ft1.y, fc0.y \n" + "sat ft1.y, ft1.y \n" + "mul ft0.xyz, ft0.xyz, ft1.y \n" + "mov oc, ft0 \n";
34 | }
35 |
36 | override public function activate(stage3DProxy:Stage3DProxy, camera3D:Camera3D, depthTexture:Texture):Void {
37 | stage3DProxy.context3D.setProgramConstantsFromVector(Context3DProgramType.FRAGMENT, 0, _brightPassData, 1);
38 | }
39 | }
40 |
41 |
--------------------------------------------------------------------------------
/away3d/filters/tasks/Filter3DDoubleBufferCopyTask.hx:
--------------------------------------------------------------------------------
1 | package away3d.filters.tasks;
2 |
3 |
4 | import away3d.cameras.Camera3D;
5 | import away3d.core.managers.Stage3DProxy;
6 | import openfl.display.BitmapData;
7 | import openfl.display3D.Context3DTextureFormat;
8 | import openfl.display3D.textures.Texture;
9 |
10 | class Filter3DDoubleBufferCopyTask extends Filter3DTaskBase {
11 | public var secondaryInputTexture(get, never):Texture;
12 |
13 | private var _secondaryInputTexture:Texture;
14 |
15 | public function new() {
16 | super();
17 | }
18 |
19 | private function get_secondaryInputTexture():Texture {
20 | return _secondaryInputTexture;
21 | }
22 |
23 | override public function getFragmentCode():String {
24 | return "tex oc, v0, fs0 <2d,nearest,clamp>\n";
25 | }
26 |
27 | override private function updateTextures(stage:Stage3DProxy):Void {
28 | super.updateTextures(stage);
29 | if (_secondaryInputTexture != null) _secondaryInputTexture.dispose();
30 | _secondaryInputTexture = stage.context3D.createTexture(_textureWidth >> _textureScale, _textureHeight >> _textureScale, Context3DTextureFormat.BGRA, true);
31 | var dummy:BitmapData = new BitmapData(_textureWidth >> _textureScale, _textureHeight >> _textureScale, false, 0);
32 | _mainInputTexture.uploadFromBitmapData(dummy);
33 | _secondaryInputTexture.uploadFromBitmapData(dummy);
34 | dummy.dispose();
35 | }
36 |
37 | override public function activate(stage3DProxy:Stage3DProxy, camera:Camera3D, depthTexture:Texture):Void {
38 | swap();
39 | super.activate(stage3DProxy, camera, depthTexture);
40 | }
41 |
42 | private function swap():Void {
43 | var tmp:Texture = _secondaryInputTexture;
44 | _secondaryInputTexture = _mainInputTexture;
45 | _mainInputTexture = tmp;
46 | }
47 | }
48 |
49 |
--------------------------------------------------------------------------------
/away3d/filters/tasks/Filter3DXFadeCompositeTask.hx:
--------------------------------------------------------------------------------
1 | package away3d.filters.tasks;
2 |
3 |
4 | import away3d.cameras.Camera3D;
5 | import away3d.core.managers.Stage3DProxy;
6 | import openfl.display3D.Context3D;
7 | import openfl.display3D.Context3DProgramType;
8 | import openfl.display3D.textures.Texture;
9 | import openfl.display3D.textures.TextureBase;
10 | import openfl.Vector;
11 |
12 | class Filter3DXFadeCompositeTask extends Filter3DTaskBase {
13 | public var overlayTexture(get, set):TextureBase;
14 | public var amount(get, set):Float;
15 |
16 | private var _data:Vector;
17 | private var _overlayTexture:TextureBase;
18 |
19 | public function new(amount:Float) {
20 | super();
21 | if (amount < 0) amount = 0
22 | else if (amount > 1) amount = 1;
23 | _data = [amount, 0, 0, 0];
24 | }
25 |
26 | private function get_overlayTexture():TextureBase {
27 | return _overlayTexture;
28 | }
29 |
30 | private function set_overlayTexture(value:TextureBase):TextureBase {
31 | _overlayTexture = value;
32 | return value;
33 | }
34 |
35 | private function get_amount():Float {
36 | return _data[0];
37 | }
38 |
39 | private function set_amount(value:Float):Float {
40 | _data[0] = value;
41 | return value;
42 | }
43 |
44 | override public function getFragmentCode():String {
45 | return "tex ft0, v0, fs0 <2d,nearest> \n" + "tex ft1, v0, fs1 <2d,nearest> \n" + "sub ft1, ft1, ft0 \n" + "mul ft1, ft1, fc0.x \n" + "add oc, ft1, ft0 \n";
46 | }
47 |
48 | override public function activate(stage3DProxy:Stage3DProxy, camera3D:Camera3D, depthTexture:Texture):Void {
49 | var context:Context3D = stage3DProxy.context3D;
50 | context.setProgramConstantsFromVector(Context3DProgramType.FRAGMENT, 0, _data, 1);
51 | context.setTextureAt(1, _overlayTexture);
52 | }
53 |
54 | override public function deactivate(stage3DProxy:Stage3DProxy):Void {
55 | stage3DProxy.context3D.setTextureAt(1, null);
56 | }
57 | }
58 |
59 |
--------------------------------------------------------------------------------
/away3d/library/assets/Asset3DType.hx:
--------------------------------------------------------------------------------
1 | package away3d.library.assets;
2 |
3 | class Asset3DType {
4 |
5 | static public inline var ENTITY:String = "entity";
6 | static public inline var SKYBOX:String = "skybox";
7 | static public inline var CAMERA:String = "camera";
8 | static public inline var SEGMENT_SET:String = "segmentSet";
9 | static public inline var MESH:String = "mesh";
10 | static public inline var GEOMETRY:String = "geometry";
11 | static public inline var SKELETON:String = "skeleton";
12 | static public inline var SKELETON_POSE:String = "skeletonPose";
13 | static public inline var CONTAINER:String = "container";
14 | static public inline var TEXTURE:String = "texture";
15 | static public inline var TEXTURE_PROJECTOR:String = "textureProjector";
16 | static public inline var MATERIAL:String = "material";
17 | static public inline var ANIMATION_SET:String = "animationSet";
18 | static public inline var ANIMATION_STATE:String = "animationState";
19 | static public inline var ANIMATION_NODE:String = "animationNode";
20 | static public inline var ANIMATOR:String = "animator";
21 | static public inline var STATE_TRANSITION:String = "stateTransition";
22 | static public inline var LIGHT:String = "light";
23 | static public inline var LIGHT_PICKER:String = "lightPicker";
24 | static public inline var SHADOW_MAP_METHOD:String = "shadowMapMethod";
25 | static public inline var EFFECTS_METHOD:String = "effectsMethod";
26 | }
27 |
28 |
--------------------------------------------------------------------------------
/away3d/library/assets/BitmapDataAsset.hx:
--------------------------------------------------------------------------------
1 | /**
2 | * BitmapDataResource is a wrapper for loaded BitmapData, allowing it to be used uniformly as a resource when
3 | * loading, parsing, and listing/resolving dependencies.
4 | */
5 | package away3d.library.assets;
6 |
7 | import openfl.display.BitmapData;
8 |
9 | class BitmapDataAsset extends NamedAssetBase implements IAsset {
10 | public var bitmapData(get, set):BitmapData;
11 | public var assetType(get, never):String;
12 |
13 | private var _bitmapData:BitmapData;
14 | /**
15 | * Creates a new BitmapDataResource object.
16 | * @param bitmapData An optional BitmapData object to use as the resource data.
17 | */
18 | public function new(bitmapData:BitmapData = null) {
19 | _bitmapData = bitmapData;
20 | super();
21 | }
22 |
23 | /**
24 | * The bitmapData to be treated as a resource.
25 | */
26 | private function get_bitmapData():BitmapData {
27 | return _bitmapData;
28 | }
29 |
30 | private function set_bitmapData(value:BitmapData):BitmapData {
31 | _bitmapData = value;
32 | return value;
33 | }
34 |
35 | private function get_assetType():String {
36 | return Asset3DType.TEXTURE;
37 | }
38 |
39 | /**
40 | * Cleans up any resources used by the current object.
41 | */
42 | public function dispose():Void {
43 | _bitmapData.dispose();
44 | }
45 | }
46 |
47 |
--------------------------------------------------------------------------------
/away3d/library/assets/IAsset.hx:
--------------------------------------------------------------------------------
1 | package away3d.library.assets;
2 |
3 | import openfl.events.IEventDispatcher;
4 | import openfl.Vector;
5 |
6 | interface IAsset extends IEventDispatcher {
7 | var name(get, set):String;
8 | var id(get, set):String;
9 | var assetNamespace(get, never):String;
10 | var assetType(get, never):String;
11 | var assetFullPath(get, never):Array;
12 |
13 | /**
14 | * The name of the asset.
15 | */
16 | private function get_name():String;
17 | private function set_name(val:String):String;
18 | /**
19 | * The id of the asset.
20 | */
21 | private function get_id():String;
22 | private function set_id(val:String):String;
23 | /**
24 | * The namespace of the asset. This allows several assets with the same name to coexist in different contexts.
25 | */
26 | private function get_assetNamespace():String;
27 | /**
28 | * The type of the asset.
29 | */
30 | private function get_assetType():String;
31 | /**
32 | * The full path of the asset.
33 | */
34 | private function get_assetFullPath():Array;
35 | function assetPathEquals(name:String, ns:String):Bool;
36 | function resetAssetPath(name:String, ns:String = null, ?overrideOriginal:Bool = true):Void;
37 | /**
38 | * Cleans up resources used by this asset.
39 | */
40 | function dispose():Void;
41 | }
42 |
43 |
--------------------------------------------------------------------------------
/away3d/library/naming/ConflictPrecedence.hx:
--------------------------------------------------------------------------------
1 | /**
2 | * Enumaration class for precedence when resolving naming conflicts in the library.
3 | *
4 | * @see away3d.library.Asset3DLibrary.conflictPrecedence
5 | * @see away3d.library.Asset3DLibrary.conflictStrategy
6 | * @see away3d.library.naming.ConflictStrategy
7 | */
8 | package away3d.library.naming;
9 |
10 | class ConflictPrecedence {
11 |
12 | /**
13 | * Signals that in a conflict, the previous owner of the conflicting name
14 | * should be favored (and keep it's name) and that the newly renamed asset
15 | * is reverted to a non-conflicting name.
16 | */
17 | static public var FAVOR_OLD:String = "favorOld";
18 | /**
19 | * Signales that in a conflict, the newly renamed asset is favored (and keeps
20 | * it's newly defined name) and that the previous owner of that name gets
21 | * renamed to a non-conflicting name.
22 | */
23 | static public var FAVOR_NEW:String = "favorNew";
24 | }
25 |
26 |
--------------------------------------------------------------------------------
/away3d/library/naming/ConflictStrategy.hx:
--------------------------------------------------------------------------------
1 | /**
2 | * Enumeration class for bundled conflict strategies. Set one of these values (or an
3 | * instance of a self-defined sub-class of ConflictStrategyBase) to the conflictStrategy
4 | * property on an Asset3DLibrary to define how that library resolves naming conflicts.
5 | *
6 | * The value of the Asset3DLibrary.conflictPrecedence
property defines which
7 | * of the conflicting assets will get to keep it's name, and which is renamed (if any.)
8 | *
9 | * @see away3d.library.Asset3DLibrary.conflictStrategy
10 | * @see away3d.library.naming.ConflictStrategyBase
11 | */
12 | package away3d.library.naming;
13 |
14 | class ConflictStrategy {
15 |
16 | /**
17 | * Specifies that in case of a naming conflict, one of the assets will be renamed and
18 | * a numeric suffix appended to the base name.
19 | */
20 | static public var APPEND_NUM_SUFFIX:ConflictStrategyBase = new NumSuffixConflictStrategy();
21 | /**
22 | * Specifies that naming conflicts should be ignored. This is not recommended in most
23 | * cases, unless it can be 100% guaranteed that the application does not cause naming
24 | * conflicts in the library (i.e. when an app-level system is in place to prevent this.)
25 | */
26 | static public var IGNORE:ConflictStrategyBase = new IgnoreConflictStrategy();
27 | /**
28 | * Specifies that an error should be thrown if a naming conflict is discovered. Use this
29 | * to be 100% sure that naming conflicts never occur unnoticed, and when it's undesirable
30 | * to have the library automatically rename assets to avoid such conflicts.
31 | */
32 | static public var THROW_ERROR:ConflictStrategyBase = new ErrorConflictStrategy();
33 | }
34 |
35 |
--------------------------------------------------------------------------------
/away3d/library/naming/ErrorConflictStrategy.hx:
--------------------------------------------------------------------------------
1 | package away3d.library.naming;
2 |
3 | import openfl.errors.Error;
4 | import away3d.library.assets.IAsset;
5 |
6 | class ErrorConflictStrategy extends ConflictStrategyBase {
7 |
8 | public function new() {
9 | super();
10 | }
11 |
12 | override public function resolveConflict(changedAsset:IAsset, oldAsset:IAsset, assetsDictionary:Dynamic, precedence:String):Void {
13 | throw new Error("Asset name collision while Asset3DLibrary.namingStrategy set to Asset3DLibrary.THROW_ERROR. Asset path: " + changedAsset.assetFullPath);
14 | }
15 |
16 | override public function create():ConflictStrategyBase {
17 | return new ErrorConflictStrategy();
18 | }
19 | }
20 |
21 |
--------------------------------------------------------------------------------
/away3d/library/naming/IgnoreConflictStrategy.hx:
--------------------------------------------------------------------------------
1 | package away3d.library.naming;
2 |
3 | import away3d.library.assets.IAsset;
4 |
5 | class IgnoreConflictStrategy extends ConflictStrategyBase {
6 |
7 | public function new() {
8 | super();
9 | }
10 |
11 | override public function resolveConflict(changedAsset:IAsset, oldAsset:IAsset, assetsDictionary:Dynamic, precedence:String):Void {
12 | // Do nothing, ignore the fact that there is a conflict.
13 | return;
14 | }
15 |
16 | override public function create():ConflictStrategyBase {
17 | return new IgnoreConflictStrategy();
18 | }
19 | }
20 |
21 |
--------------------------------------------------------------------------------
/away3d/library/naming/NumSuffixConflictStrategy.hx:
--------------------------------------------------------------------------------
1 | package away3d.library.naming;
2 |
3 |
4 | import away3d.library.assets.IAsset;
5 | import haxe.ds.StringMap;
6 |
7 | class NumSuffixConflictStrategy extends ConflictStrategyBase {
8 | private var _separator:String;
9 | private var _next_suffix:StringMap;
10 |
11 | public function new(separator:String = '.') {
12 | super();
13 |
14 | _separator = separator;
15 | _next_suffix = new StringMap();
16 | }
17 |
18 |
19 | override public function resolveConflict(changedAsset:IAsset, oldAsset:IAsset, assetsDictionary:Dynamic, precedence:String):Void
20 | {
21 | var assetsDictionary2:StringMap = cast assetsDictionary;
22 | var orig:String;
23 | var new_name:String;
24 | var base:String, suffix:Int;
25 |
26 | orig = changedAsset.name;
27 | if (orig.indexOf(_separator) >= 0) {
28 | // Name has an ocurrence of the separator, so get base name and suffix,
29 | // unless suffix is non-numerical, in which case revert to zero and
30 | // use entire name as base
31 | base = orig.substring(0, orig.lastIndexOf(_separator));
32 | suffix = Std.parseInt(orig.substring(base.length - 1));
33 | if (Math.isNaN(suffix)) {
34 | base = orig;
35 | suffix = 0;
36 | }
37 | }
38 | else {
39 | base = orig;
40 | suffix = 0;
41 | }
42 |
43 | if (suffix == 0 && _next_suffix.exists(base))
44 | suffix = _next_suffix.get(base);
45 |
46 | // Find the first suffixed name that does
47 | // not collide with other names.
48 | do {
49 | suffix++;
50 | new_name = base + _separator + suffix;
51 | } while (assetsDictionary2.exists(new_name));
52 |
53 | _next_suffix.set(base, suffix);
54 |
55 | updateNames(oldAsset.assetNamespace, new_name, oldAsset, changedAsset, assetsDictionary2, precedence);
56 | }
57 |
58 |
59 | override public function create():ConflictStrategyBase {
60 | return new NumSuffixConflictStrategy(_separator);
61 | }
62 | }
63 |
64 |
--------------------------------------------------------------------------------
/away3d/library/utils/Asset3DLibraryIterator.hx:
--------------------------------------------------------------------------------
1 | package away3d.library.utils;
2 |
3 | import away3d.library.assets.IAsset;
4 |
5 | class Asset3DLibraryIterator {
6 | public var currentAsset(get, never):IAsset;
7 | public var numAssets(get, never):Int;
8 |
9 | private var _assets:Array;
10 | private var _filtered:Array;
11 | private var _idx:Int;
12 |
13 | public function new(assets:Array, assetTypeFilter:String, namespaceFilter:String, filterFunc:Dynamic -> Dynamic) {
14 | _assets = assets;
15 | filter(assetTypeFilter, namespaceFilter, filterFunc);
16 | }
17 |
18 | private function get_currentAsset():IAsset {
19 | // Return current, or null if no current
20 | return ((_idx < _filtered.length)) ? _filtered[_idx] : null;
21 | }
22 |
23 | private function get_numAssets():Int {
24 | return _filtered.length;
25 | }
26 |
27 | public function next():IAsset {
28 | var next:IAsset = null;
29 | if (_idx < _filtered.length) next = _filtered[_idx];
30 | _idx++;
31 | return next;
32 | }
33 |
34 | public function reset():Void {
35 | _idx = 0;
36 | }
37 |
38 | public function setIndex(index:Int):Void {
39 | _idx = index;
40 | }
41 |
42 | private function filter(assetTypeFilter:String, namespaceFilter:String, filterFunc:Dynamic -> Dynamic):Void {
43 | if (assetTypeFilter != null || namespaceFilter != null || filterFunc != null) {
44 | var idx:Int;
45 | var asset:IAsset;
46 | idx = 0;
47 | _filtered = new Array();
48 | for (asset in _assets) {
49 | // Skip this assets if filtering on type and this is wrong type
50 | if (assetTypeFilter != null && asset.assetType != assetTypeFilter) continue;
51 | if (namespaceFilter != null && asset.assetNamespace != namespaceFilter) continue;
52 | if (filterFunc != null && filterFunc(asset) == null) continue;
53 | _filtered[idx++] = asset;
54 | }
55 |
56 | }
57 |
58 | else {
59 | _filtered = _assets;
60 | }
61 |
62 | }
63 | }
64 |
65 |
--------------------------------------------------------------------------------
/away3d/lights/LightProbe.hx:
--------------------------------------------------------------------------------
1 | package away3d.lights;
2 |
3 |
4 | import openfl.errors.Error;
5 | import away3d.bounds.BoundingVolumeBase;
6 | import away3d.bounds.NullBounds;
7 | import away3d.core.base.IRenderable;
8 | import away3d.core.partition.EntityNode;
9 | import away3d.core.partition.LightProbeNode;
10 | import away3d.textures.CubeTextureBase;
11 | import openfl.geom.Matrix3D;
12 |
13 | class LightProbe extends LightBase {
14 | public var diffuseMap(get, set):CubeTextureBase;
15 | public var specularMap(get, set):CubeTextureBase;
16 |
17 | private var _diffuseMap:CubeTextureBase;
18 | private var _specularMap:CubeTextureBase;
19 | /**
20 | * Creates a new LightProbe object.
21 | */
22 | public function new(diffuseMap:CubeTextureBase, specularMap:CubeTextureBase = null) {
23 | super();
24 | _diffuseMap = diffuseMap;
25 | _specularMap = specularMap;
26 | }
27 |
28 | override private function createEntityPartitionNode():EntityNode {
29 | return new LightProbeNode(this);
30 | }
31 |
32 | private function get_diffuseMap():CubeTextureBase {
33 | return _diffuseMap;
34 | }
35 |
36 | private function set_diffuseMap(value:CubeTextureBase):CubeTextureBase {
37 | _diffuseMap = value;
38 | return value;
39 | }
40 |
41 | private function get_specularMap():CubeTextureBase {
42 | return _specularMap;
43 | }
44 |
45 | private function set_specularMap(value:CubeTextureBase):CubeTextureBase {
46 | _specularMap = value;
47 | return value;
48 | }
49 |
50 | /**
51 | * @inheritDoc
52 | */
53 | override private function updateBounds():Void {
54 | // super.updateBounds();
55 | _boundsInvalid = false;
56 | }
57 |
58 | /**
59 | * @inheritDoc
60 | */
61 | override private function getDefaultBoundingVolume():BoundingVolumeBase {
62 | // todo: consider if this can be culled?
63 | return new NullBounds();
64 | }
65 |
66 | /**
67 | * @inheritDoc
68 | */
69 | override public function getObjectProjectionMatrix(renderable:IRenderable, target:Matrix3D = null):Matrix3D {
70 | // TODO: not used
71 |
72 | throw new Error("Object projection matrices are not supported for LightProbe objects!");
73 | return null;
74 | }
75 | }
76 |
77 |
--------------------------------------------------------------------------------
/away3d/lights/shadowmaps/NearDirectionalShadowMapper.hx:
--------------------------------------------------------------------------------
1 | package away3d.lights.shadowmaps;
2 |
3 |
4 | import away3d.cameras.Camera3D;
5 |
6 | class NearDirectionalShadowMapper extends DirectionalShadowMapper {
7 | public var coverageRatio(get, set):Float;
8 |
9 | private var _coverageRatio:Float;
10 |
11 | public function new(coverageRatio:Float = .5) {
12 | super();
13 | this.coverageRatio = coverageRatio;
14 | }
15 |
16 | /**
17 | * A value between 0 and 1 to indicate the ratio of the view frustum that needs to be covered by the shadow map.
18 | */
19 | private function get_coverageRatio():Float {
20 | return _coverageRatio;
21 | }
22 |
23 | private function set_coverageRatio(value:Float):Float {
24 | if (value > 1) value = 1
25 | else if (value < 0) value = 0;
26 | _coverageRatio = value;
27 | return value;
28 | }
29 |
30 | override private function updateDepthProjection(viewCamera:Camera3D):Void {
31 | var corners:Array = viewCamera.lens.frustumCorners;
32 | var i:Int = 0;
33 | while (i < 12) {
34 | var v:Float = corners[i];
35 | _localFrustum[i] = v;
36 | _localFrustum[(i + 12)] = v + (corners[(i + 12)] - v) * _coverageRatio;
37 | ++i;
38 | }
39 | updateProjectionFromFrustumCorners(viewCamera, _localFrustum, _matrix);
40 | _overallDepthLens.matrix = _matrix;
41 | }
42 | }
43 |
44 |
--------------------------------------------------------------------------------
/away3d/loaders/parsers/ParserDataFormat.hx:
--------------------------------------------------------------------------------
1 | package away3d.loaders.parsers;
2 |
3 |
4 | /**
5 | * An enumeration providing values to describe the data format of parsed data.
6 | */
7 | class ParserDataFormat
8 | {
9 | /**
10 | * Describes the format of a binary file.
11 | */
12 | public static inline var BINARY:String = "binary";
13 |
14 | /**
15 | * Describes the format of a plain text file.
16 | */
17 | public static inline var PLAIN_TEXT:String = "plainText";
18 | }
19 |
20 |
21 |
--------------------------------------------------------------------------------
/away3d/loaders/parsers/Parsers.hx:
--------------------------------------------------------------------------------
1 | package away3d.loaders.parsers;
2 |
3 | import away3d.loaders.misc.SingleFileLoader;
4 |
5 | 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 | * Asset3DLibrary.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 Asset3DLibrary.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.Asset3DLibrary.enableParser
39 | */
40 | public static var ALL_BUNDLED:Array = [
41 | //AC3DParser, AWD1Parser, AWD2Parser, AWDParser, Max3DSParser, DXFParser,
42 | //MD2Parser, MD5AnimParser, MD5MeshParser, OBJParser,
43 | //DAEParser
44 | Max3DSParser
45 | ];
46 |
47 | /**
48 | * Short-hand function to enable all bundled parsers for auto-detection. In practice,
49 | * this is the same as invoking enableParsers(Parsers.ALL_BUNDLED) on any of the
50 | * loader classes SingleFileLoader, AssetLoader, Asset3DLibrary or Loader3D.
51 | *
52 | * See notes about file size in the documentation for the ALL_BUNDLED constant.
53 | *
54 | * @see away3d.loaders.parsers.Parsers.ALL_BUNDLED
55 | */
56 | public static function enableAllBundled():Void
57 | {
58 | SingleFileLoader.enableParsers(ALL_BUNDLED);
59 | }
60 | }
61 |
62 |
--------------------------------------------------------------------------------
/away3d/loaders/parsers/utils/ParserUtil.hx:
--------------------------------------------------------------------------------
1 | package away3d.loaders.parsers.utils;
2 |
3 | import openfl.utils.ByteArray;
4 |
5 | class ParserUtil
6 | {
7 |
8 | /**
9 | * Returns a object as ByteArray, if possible.
10 | *
11 | * @param data The object to return as ByteArray
12 | *
13 | * @return The ByteArray or null
14 | *
15 | */
16 | public static function toByteArray(data:Dynamic):ByteArray
17 | {
18 | if (Std.is(data, Class)) {
19 | //data = new data();
20 | data = Type.createInstance(data,[]);
21 | }
22 |
23 | if (Std.is(data, ByteArrayData))
24 | return data;
25 | else
26 | return null;
27 | }
28 |
29 | /**
30 | * Returns a object as String, if possible.
31 | *
32 | * @param data The object to return as String
33 | * @param length The length of the returned String
34 | *
35 | * @return The String or null
36 | *
37 | */
38 | public static function toString(data:Dynamic, length:UInt = 0):String
39 | {
40 | var ba:ByteArray;
41 |
42 | if (length==0) length = 0xffffffff;
43 |
44 | if (Std.is(data, String)) {
45 | var dS:String = cast data;
46 | return dS.substr(0, Std.int(Math.min(length, dS.length)));
47 | }
48 |
49 | ba = toByteArray(data);
50 | if (ba!=null) {
51 | ba.position = 0;
52 | return ba.readUTFBytes(Std.int(Math.min(ba.bytesAvailable, length)));
53 | }
54 |
55 | return null;
56 | }
57 | }
58 |
59 |
--------------------------------------------------------------------------------
/away3d/materials/ColorMaterial.hx:
--------------------------------------------------------------------------------
1 | /**
2 | * ColorMaterial is a single-pass material that uses a flat color as the surface's diffuse reflection value.
3 | */
4 | package away3d.materials;
5 |
6 |
7 | import openfl.display.BlendMode;
8 |
9 | class ColorMaterial extends SinglePassMaterialBase {
10 | public var alpha(get, set):Float;
11 | public var color(get, set):Int;
12 |
13 | private var _diffuseAlpha:Float;
14 | /**
15 | * Creates a new ColorMaterial object.
16 | * @param color The material's diffuse surface color.
17 | * @param alpha The material's surface alpha.
18 | */
19 | public function new(color:Int = 0xcccccc, alpha:Float = 1) {
20 | _diffuseAlpha = 1;
21 | super();
22 | this.color = color;
23 | this.alpha = alpha;
24 | }
25 |
26 | /**
27 | * The alpha of the surface.
28 | */
29 | private function get_alpha():Float {
30 | return _screenPass.diffuseMethod.diffuseAlpha;
31 | }
32 |
33 | private function set_alpha(value:Float):Float {
34 | if (value > 1) value = 1
35 | else if (value < 0) value = 0;
36 | _screenPass.diffuseMethod.diffuseAlpha = _diffuseAlpha = value;
37 | _screenPass.preserveAlpha = requiresBlending;
38 | _screenPass.setBlendMode(blendMode == BlendMode.NORMAL && (requiresBlending) ? BlendMode.LAYER : blendMode);
39 | return value;
40 | }
41 |
42 | /**
43 | * The diffuse reflectivity color of the surface.
44 | */
45 | private function get_color():Int {
46 | return _screenPass.diffuseMethod.diffuseColor;
47 | }
48 |
49 | private function set_color(value:Int):Int {
50 | _screenPass.diffuseMethod.diffuseColor = value;
51 | return value;
52 | }
53 |
54 | /**
55 | * @inheritDoc
56 | */
57 | override private function get_requiresBlending():Bool {
58 | return super.requiresBlending || _diffuseAlpha < 1;
59 | }
60 | }
61 |
62 |
--------------------------------------------------------------------------------
/away3d/materials/ColorMultiPassMaterial.hx:
--------------------------------------------------------------------------------
1 | /**
2 | * ColorMultiPassMaterial is a multi-pass material that uses a flat color as the surface's diffuse reflection value.
3 | */
4 | package away3d.materials;
5 |
6 |
7 | class ColorMultiPassMaterial extends MultiPassMaterialBase {
8 | public var color(get, set):Int;
9 |
10 | /**
11 | * Creates a new ColorMultiPassMaterial object.
12 | *
13 | * @param color The material's diffuse surface color.
14 | */
15 | public function new(color:Int = 0xcccccc) {
16 | super();
17 | this.color = color;
18 | }
19 |
20 | /**
21 | * The diffuse reflectivity color of the surface.
22 | */
23 | private function get_color():Int {
24 | return diffuseMethod.diffuseColor;
25 | }
26 |
27 | private function set_color(value:Int):Int {
28 | diffuseMethod.diffuseColor = value;
29 | return value;
30 | }
31 | }
32 |
33 |
--------------------------------------------------------------------------------
/away3d/materials/LightSources.hx:
--------------------------------------------------------------------------------
1 | /**
2 | * Enumeration class for defining which lighting types affect the specific material
3 | * lighting component (diffuse and specular). This can be useful if, for example, you
4 | * want to use light probes for diffuse global lighting, but want specular reflections from
5 | * traditional light sources without those affecting the diffuse light.
6 | *
7 | * @see away3d.materials.ColorMaterial.diffuseLightSources
8 | * @see away3d.materials.ColorMaterial.specularLightSources
9 | * @see away3d.materials.TextureMaterial.diffuseLightSources
10 | * @see away3d.materials.TextureMaterial.specularLightSources
11 | */
12 | package away3d.materials;
13 |
14 | class LightSources {
15 |
16 | /**
17 | * Defines normal lights are to be used as the source for the lighting
18 | * component.
19 | */
20 | static public var LIGHTS:Int = 0x01;
21 | /**
22 | * Defines that global lighting probes are to be used as the source for the
23 | * lighting component.
24 | */
25 | static public var PROBES:Int = 0x02;
26 | /**
27 | * Defines that both normal and global lighting probes are to be used as the
28 | * source for the lighting component. This is equivalent to LIGHTS | PROBES.
29 | */
30 | static public var ALL:Int = 0x03;
31 | }
32 |
33 |
--------------------------------------------------------------------------------
/away3d/materials/OcclusionMaterial.hx:
--------------------------------------------------------------------------------
1 | /**
2 | * OcclusionMaterial is a ColorMaterial for an object to prevents drawing anything that is placed behind it.
3 | */
4 | package away3d.materials;
5 |
6 |
7 | import away3d.cameras.Camera3D;
8 | import away3d.core.managers.Stage3DProxy;
9 |
10 | class OcclusionMaterial extends ColorMaterial {
11 | public var occlude(get, set):Bool;
12 |
13 | private var _occlude:Bool;
14 | /**
15 | * Creates a new OcclusionMaterial object.
16 | * @param occlude Whether or not to occlude other objects.
17 | * @param color The material's diffuse surface color.
18 | * @param alpha The material's surface alpha.
19 | */
20 | public function new(occlude:Bool = true, color:Int = 0xcccccc, alpha:Float = 1) {
21 | _occlude = true;
22 | super(color, alpha);
23 | this.occlude = occlude;
24 | }
25 |
26 | /**
27 | * Whether or not an object with this material applied hides other objects.
28 | */
29 | private function get_occlude():Bool {
30 | return _occlude;
31 | }
32 |
33 | private function set_occlude(value:Bool):Bool {
34 | _occlude = value;
35 | return value;
36 | }
37 |
38 | /**
39 | * @inheritDoc
40 | */
41 | override public function activatePass(index:Int, stage3DProxy:Stage3DProxy, camera:Camera3D):Void {
42 | if (occlude) stage3DProxy.context3D.setColorMask(false, false, false, false);
43 | super.activatePass(index, stage3DProxy, camera);
44 | }
45 |
46 | /**
47 | * @inheritDoc
48 | */
49 | override public function deactivatePass(index:Int, stage3DProxy:Stage3DProxy):Void {
50 | super.deactivatePass(index, stage3DProxy);
51 | stage3DProxy.context3D.setColorMask(true, true, true, true);
52 | }
53 | }
54 |
55 |
--------------------------------------------------------------------------------
/away3d/materials/SegmentMaterial.hx:
--------------------------------------------------------------------------------
1 | /**
2 | * SegmentMaterial is a material exclusively used to render wireframe objects
3 | *
4 | * @see away3d.entities.Lines
5 | */
6 | package away3d.materials;
7 |
8 |
9 | import away3d.materials.passes.SegmentPass;
10 |
11 | class SegmentMaterial extends MaterialBase {
12 |
13 | private var _screenPass:SegmentPass;
14 | /**
15 | * Creates a new SegmentMaterial object.
16 | *
17 | * @param thickness The thickness of the wireframe lines.
18 | */
19 | public function new(thickness:Float = 1.25) {
20 | super();
21 | bothSides = true;
22 | addPass(_screenPass = new SegmentPass(thickness));
23 | _screenPass.material = this;
24 | }
25 | }
26 |
27 |
--------------------------------------------------------------------------------
/away3d/materials/SkyBoxMaterial.hx:
--------------------------------------------------------------------------------
1 | /**
2 | * SkyBoxMaterial is a material exclusively used to render skyboxes
3 | *
4 | * @see away3d.primitives.SkyBox
5 | */
6 | package away3d.materials;
7 |
8 |
9 | import away3d.materials.passes.SkyBoxPass;
10 | import away3d.textures.CubeTextureBase;
11 |
12 | class SkyBoxMaterial extends MaterialBase {
13 | public var cubeMap(get, set):CubeTextureBase;
14 |
15 | private var _cubeMap:CubeTextureBase;
16 | private var _skyboxPass:SkyBoxPass;
17 | /**
18 | * Creates a new SkyBoxMaterial object.
19 | * @param cubeMap The CubeMap to use as the skybox.
20 | */
21 | public function new(cubeMap:CubeTextureBase) {
22 | super();
23 | _cubeMap = cubeMap;
24 | addPass(_skyboxPass = new SkyBoxPass());
25 | _skyboxPass.cubeTexture = _cubeMap;
26 |
27 | }
28 |
29 | /**
30 | * The cube texture to use as the skybox.
31 | */
32 | private function get_cubeMap():CubeTextureBase {
33 | return _cubeMap;
34 | }
35 |
36 | private function set_cubeMap(value:CubeTextureBase):CubeTextureBase {
37 | if (value != null && _cubeMap != null && (value.hasMipMaps != _cubeMap.hasMipMaps || value.format != _cubeMap.format)) invalidatePasses(null);
38 | _cubeMap = value;
39 | _skyboxPass.cubeTexture = _cubeMap;
40 | return value;
41 | }
42 | }
43 |
44 |
--------------------------------------------------------------------------------
/away3d/materials/compilation/ShaderRegisterData.hx:
--------------------------------------------------------------------------------
1 | /**
2 | * ShaderRegisterData contains the "named" registers, generated by the compiler and to be passed on to the methods.
3 | */
4 | package away3d.materials.compilation;
5 |
6 | class ShaderRegisterData {
7 |
8 | public var normalVarying:ShaderRegisterElement;
9 | public var tangentVarying:ShaderRegisterElement;
10 | public var bitangentVarying:ShaderRegisterElement;
11 | public var uvVarying:ShaderRegisterElement;
12 | public var secondaryUVVarying:ShaderRegisterElement;
13 | public var viewDirVarying:ShaderRegisterElement;
14 | public var shadedTarget:ShaderRegisterElement;
15 | public var globalPositionVertex:ShaderRegisterElement;
16 | public var globalPositionVarying:ShaderRegisterElement;
17 | public var localPosition:ShaderRegisterElement;
18 | public var normalInput:ShaderRegisterElement;
19 | public var tangentInput:ShaderRegisterElement;
20 | public var animatedNormal:ShaderRegisterElement;
21 | public var animatedTangent:ShaderRegisterElement;
22 | public var commons:ShaderRegisterElement;
23 | public var projectionFragment:ShaderRegisterElement;
24 | public var normalFragment:ShaderRegisterElement;
25 | public var viewDirFragment:ShaderRegisterElement;
26 | public var bitangent:ShaderRegisterElement;
27 |
28 | public function new() {
29 | }
30 | }
31 |
32 |
--------------------------------------------------------------------------------
/away3d/materials/compilation/ShaderRegisterElement.hx:
--------------------------------------------------------------------------------
1 | /**
2 | * A single register element (an entire register or a single register's component) used by the RegisterPool.
3 | */
4 | package away3d.materials.compilation;
5 |
6 | import openfl.Vector;
7 |
8 | class ShaderRegisterElement {
9 | public var regName(get, never):String;
10 | public var index(get, never):Int;
11 |
12 | private var _regName:String;
13 | private var _index:Int;
14 | private var _toStr:String;
15 | static private var COMPONENTS:Array = ["x", "y", "z", "w"];
16 | public var _component:Int;
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 new(regName:String, index:Int, component:Int = -1) {
24 | _component = component;
25 | _regName = regName;
26 | _index = index;
27 | _toStr = _regName;
28 | if (_index >= 0) _toStr += _index;
29 | if (component > -1) _toStr += "." + COMPONENTS[component];
30 | }
31 |
32 | /**
33 | * Converts the register or the components AGAL string representation.
34 | */
35 | public function toString():String {
36 | return _toStr;
37 | }
38 |
39 | /**
40 | * The register's name.
41 | */
42 | private function get_regName():String {
43 | return _regName;
44 | }
45 |
46 | /**
47 | * The register's index.
48 | */
49 | private function get_index():Int {
50 | return _index;
51 | }
52 | }
53 |
54 |
--------------------------------------------------------------------------------
/away3d/materials/methods/EffectMethodBase.hx:
--------------------------------------------------------------------------------
1 | /**
2 | * EffectMethodBase forms an abstract base class for shader methods that are not dependent on light sources,
3 | * and are in essence post-process effects on the materials.
4 | */
5 | package away3d.materials.methods;
6 |
7 |
8 | import away3d.errors.AbstractMethodError;
9 | import away3d.materials.compilation.ShaderRegisterElement;
10 | import away3d.materials.compilation.ShaderRegisterCache;
11 | import away3d.library.assets.Asset3DType;
12 | import away3d.library.assets.IAsset;
13 | class EffectMethodBase extends ShadingMethodBase implements IAsset {
14 | public var assetType(get, never):String;
15 |
16 | public function new() {
17 | super();
18 | }
19 |
20 | /**
21 | * @inheritDoc
22 | */
23 | private function get_assetType():String {
24 | return Asset3DType.EFFECTS_METHOD;
25 | }
26 |
27 | /**
28 | * Get the fragment shader code that should be added after all per-light code. Usually composits everything to the target register.
29 | * @param vo The MethodVO object containing the method data for the currently compiled material pass.
30 | * @param regCache The register cache used during the compilation.
31 | * @param targetReg The register that will be containing the method's output.
32 | * @private
33 | */
34 | public function getFragmentCode(vo:MethodVO, regCache:ShaderRegisterCache, targetReg:ShaderRegisterElement):String {
35 | throw new AbstractMethodError();
36 | return "";
37 | }
38 | }
39 |
40 |
--------------------------------------------------------------------------------
/away3d/materials/methods/MethodVO.hx:
--------------------------------------------------------------------------------
1 | /**
2 | * MethodVO contains data for a given method for the use within a single material.
3 | * This allows methods to be shared across materials while their non-public state differs.
4 | */
5 | package away3d.materials.methods;
6 |
7 | import openfl.Vector;
8 | import away3d.textures.Anisotropy;
9 |
10 | class MethodVO {
11 |
12 | public var vertexData:Vector;
13 | public var fragmentData:Vector;
14 | // public register indices
15 | public var texturesIndex:Int;
16 | public var secondaryTexturesIndex:Int;
17 | // sometimes needed for composites
18 | public var vertexConstantsIndex:Int;
19 | public var secondaryVertexConstantsIndex:Int;
20 | // sometimes needed for composites
21 | public var fragmentConstantsIndex:Int;
22 | public var secondaryFragmentConstantsIndex:Int;
23 | // sometimes needed for composites
24 | public var useMipmapping:Bool;
25 | public var useSmoothTextures:Bool;
26 | public var repeatTextures:Bool;
27 | public var anisotropy:Anisotropy;
28 | // internal stuff for the material to know before assembling code
29 | public var needsProjection:Bool;
30 | public var needsView:Bool;
31 | public var needsNormals:Bool;
32 | public var needsTangents:Bool;
33 | public var needsUV:Bool;
34 | public var needsSecondaryUV:Bool;
35 | public var needsGlobalVertexPos:Bool;
36 | public var needsGlobalFragmentPos:Bool;
37 | public var numLights:Int;
38 | public var useLightFallOff:Bool;
39 |
40 | /**
41 | * Creates a new MethodVO object.
42 | */
43 | public function new() {
44 | useLightFallOff = true;
45 | }
46 |
47 | /**
48 | * Resets the values of the value object to their "unused" state.
49 | */
50 | public function reset():Void {
51 | texturesIndex = -1;
52 | vertexConstantsIndex = -1;
53 | fragmentConstantsIndex = -1;
54 | useMipmapping = true;
55 | anisotropy = Anisotropy.ANISOTROPIC2X;
56 | useSmoothTextures = true;
57 | repeatTextures = false;
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 | numLights = 0;
67 | useLightFallOff = true;
68 | }
69 | }
70 |
71 |
--------------------------------------------------------------------------------
/away3d/materials/methods/MethodVOSet.hx:
--------------------------------------------------------------------------------
1 | /**
2 | * MethodVOSet provides a EffectMethodBase and MethodVO combination to be used by a material, allowing methods
3 | * to be shared across different materials while their internal state changes.
4 | */
5 | package away3d.materials.methods;
6 |
7 |
8 | class MethodVOSet {
9 |
10 | /**
11 | * An instance of a concrete EffectMethodBase subclass.
12 | */
13 | public var method:EffectMethodBase;
14 | /**
15 | * The MethodVO data for the given method containing the material-specific data for a given material/method combination.
16 | */
17 | public var data:MethodVO;
18 | /**
19 | * Creates a new MethodVOSet object.
20 | * @param method The method for which we need to store a MethodVO object.
21 | */
22 | public function new(method:EffectMethodBase) {
23 | this.method = method;
24 | data = method.createMethodVO();
25 | }
26 | }
27 |
28 |
--------------------------------------------------------------------------------
/away3d/materials/utils/DefaultMaterialManager.hx:
--------------------------------------------------------------------------------
1 | package away3d.materials.utils;
2 |
3 |
4 | import openfl.display.BitmapData;
5 | import away3d.core.base.IMaterialOwner;
6 | import away3d.textures.BitmapTexture;
7 | class DefaultMaterialManager {
8 |
9 | static private var _defaultTextureBitmapData:BitmapData;
10 | static private var _defaultMaterial:TextureMaterial;
11 | static private var _defaultTexture:BitmapTexture;
12 | //private static var _defaultMaterialRenderables:Vector. = new Vector.();
13 |
14 | static public function getDefaultMaterial(renderable:IMaterialOwner = null):TextureMaterial {
15 | if (_defaultTexture == null) createDefaultTexture();
16 | if (_defaultMaterial == null) createDefaultMaterial();
17 | return _defaultMaterial;
18 | }
19 |
20 | static public function getDefaultTexture(renderable:IMaterialOwner = null):BitmapTexture {
21 | if (_defaultTexture == null) createDefaultTexture();
22 | return _defaultTexture;
23 | }
24 |
25 | static private function createDefaultTexture():Void {
26 | _defaultTextureBitmapData = new BitmapData(8, 8, false, 0x0);
27 | //create chekerboard
28 | var i:Int = 0;
29 | var j:Int;
30 | i = 0;
31 | while (i < 8) {
32 | j = 0;
33 | while (j < 8) {
34 | if ((j & 1) ^ (i & 1) == 1) _defaultTextureBitmapData.setPixel(i, j, 0xFFFFFF);
35 | j++;
36 | }
37 | i++;
38 | }
39 | _defaultTexture = new BitmapTexture(_defaultTextureBitmapData);
40 | _defaultTexture.name = "defaultTexture";
41 | }
42 |
43 | static private function createDefaultMaterial():Void {
44 | _defaultMaterial = new TextureMaterial(_defaultTexture);
45 | _defaultMaterial.mipmap = false;
46 | _defaultMaterial.smooth = false;
47 | _defaultMaterial.name = "defaultMaterial";
48 | }
49 | }
50 |
51 |
--------------------------------------------------------------------------------
/away3d/materials/utils/MipmapGenerator.hx:
--------------------------------------------------------------------------------
1 | /**
2 | * MipmapGenerator is a helper class that uploads BitmapData to a Texture including mipmap levels.
3 | */
4 | package away3d.materials.utils;
5 |
6 | import openfl.display.BitmapData;
7 | import openfl.geom.Matrix;
8 | import openfl.geom.Rectangle;
9 | import openfl.display3D.textures.CubeTexture;
10 | import openfl.display3D.textures.Texture;
11 | import openfl.display3D.textures.TextureBase;
12 |
13 | class MipmapGenerator {
14 |
15 | static private var _matrix:Matrix = new Matrix();
16 | static private var _rect:Rectangle = new Rectangle();
17 |
18 | /**
19 | * Uploads a BitmapData with mip maps to a target Texture object.
20 | * @param source The source BitmapData to upload.
21 | * @param target The target Texture to upload to.
22 | * @param mipmap An optional mip map holder to avoids creating new instances for fe animated materials.
23 | * @param alpha Indicate whether or not the uploaded bitmapData is transparent.
24 | */
25 | static public function generateMipMaps(source:BitmapData, target:TextureBase, mipmap:BitmapData = null, alpha:Bool = false, side:Int = -1):Void {
26 |
27 | var w = source.width;
28 | var h = source.height;
29 | var i = 0;
30 | var regen:Bool = mipmap != null;
31 |
32 | _rect.width = w;
33 | _rect.height = h;
34 |
35 | while (w >= 1 || h >= 1) {
36 | mipmap = new BitmapData(w > 1 ? w : 1, h > 1 ? h : 1, alpha, 0x0);
37 |
38 | _matrix.a = _rect.width / source.width;
39 | _matrix.d = _rect.height / source.height;
40 | mipmap.draw(source, _matrix, null, null, null, true);
41 |
42 | if (Std.is(target, Texture))
43 | cast((target), Texture).uploadFromBitmapData(mipmap, i++);
44 | else
45 | cast((target), CubeTexture).uploadFromBitmapData(mipmap, side, i++);
46 |
47 | w >>= 1;
48 | h >>= 1;
49 |
50 | _rect.width = w > 1 ? w : 1;
51 | _rect.height = h > 1 ? h : 1;
52 | }
53 |
54 | //if (!regen)
55 | // mipmap.dispose();
56 | }
57 | }
58 |
59 |
--------------------------------------------------------------------------------
/away3d/paths/CubicPath.hx:
--------------------------------------------------------------------------------
1 | /**
2 | * Defines a cubic path. Each segment of the path has two control points as opposed to CubicPathSegment
which being quadratic, has one control point.
3 | * @see away3d.animators.CubicPathAnimator
4 | * @see away3d.paths.CubicPathSegment
5 | */
6 | package away3d.paths;
7 |
8 | import openfl.geom.Vector3D;
9 | import openfl.Vector;
10 |
11 | class CubicPath extends SegmentedPathBase implements IPath {
12 |
13 | /**
14 | * Creates a new CubicPath instance.
15 | * @param data See pointData
16 | */
17 | public function new(data:Vector = null) {
18 | super(4, data);
19 | }
20 |
21 | override private function createSegmentFromArrayEntry(data:Vector, offset:Int):IPathSegment {
22 | return new CubicPathSegment(data[offset], data[offset + 1], data[offset + 2], data[offset + 3]);
23 | }
24 |
25 | override private function stitchSegment(start:IPathSegment, middle:IPathSegment, end:IPathSegment):Void {
26 | var seg:CubicPathSegment = cast((middle), CubicPathSegment);
27 | var prevSeg:CubicPathSegment = cast((start), CubicPathSegment);
28 | var nextSeg:CubicPathSegment = cast((end), CubicPathSegment);
29 | prevSeg.control1.x = (prevSeg.control1.x + seg.control1.x) * 0.5;
30 | prevSeg.control1.y = (prevSeg.control1.y + seg.control1.y) * 0.5;
31 | prevSeg.control1.z = (prevSeg.control1.z + seg.control1.z) * 0.5;
32 | nextSeg.control1.x = (nextSeg.control1.x + seg.control1.x) * 0.5;
33 | nextSeg.control1.y = (nextSeg.control1.y + seg.control1.y) * 0.5;
34 | nextSeg.control1.z = (nextSeg.control1.z + seg.control1.z) * 0.5;
35 | prevSeg.control2.x = (prevSeg.control2.x + seg.control2.x) * 0.5;
36 | prevSeg.control2.y = (prevSeg.control2.y + seg.control2.y) * 0.5;
37 | prevSeg.control2.z = (prevSeg.control2.z + seg.control2.z) * 0.5;
38 | nextSeg.control2.x = (nextSeg.control2.x + seg.control2.x) * 0.5;
39 | nextSeg.control2.y = (nextSeg.control2.y + seg.control2.y) * 0.5;
40 | nextSeg.control2.z = (nextSeg.control2.z + seg.control2.z) * 0.5;
41 | prevSeg.end.x = (seg.start.x + seg.end.x) * 0.5;
42 | prevSeg.end.y = (seg.start.y + seg.end.y) * 0.5;
43 | prevSeg.end.z = (seg.start.z + seg.end.z) * 0.5;
44 | nextSeg.start.x = prevSeg.end.x;
45 | nextSeg.start.y = prevSeg.end.y;
46 | nextSeg.start.z = prevSeg.end.z;
47 | }
48 | }
49 |
50 |
--------------------------------------------------------------------------------
/away3d/paths/CubicPathSegment.hx:
--------------------------------------------------------------------------------
1 | /**
2 | * Defines a single segment of a cubic path
3 | * @see away3d.paths.CubicPath
4 | */
5 | package away3d.paths;
6 |
7 | import openfl.geom.Vector3D;
8 |
9 | class CubicPathSegment implements IPathSegment {
10 |
11 | /**
12 | * The first anchor point.
13 | */
14 | public var start:Vector3D;
15 | /**
16 | * The first control point.
17 | */
18 | public var control1:Vector3D;
19 | /**
20 | * The second control point.
21 | */
22 | public var control2:Vector3D;
23 | /**
24 | * The last anchor point.
25 | */
26 | public var end:Vector3D;
27 | /**
28 | *
29 | * @param start The first anchor point.
30 | * @param control1 The first control point.
31 | * @param control2 The second control point.
32 | * @param end The last anchor point.
33 | */
34 | public function new(start:Vector3D, control1:Vector3D, control2:Vector3D, end:Vector3D) {
35 | this.start = start;
36 | this.control1 = control1;
37 | this.control2 = control2;
38 | this.end = end;
39 | }
40 |
41 | public function toString():String {
42 | return start + ", " + control1 + ", " + control2 + ", " + end;
43 | }
44 |
45 | public function dispose():Void {
46 | start = control1 = control2 = end = null;
47 | }
48 |
49 | public function getPointOnSegment(phase:Float, target:Vector3D = null):Vector3D {
50 | var td:Float = 1 - phase;
51 | var t_2:Float = phase * phase;
52 | var a:Float = td * td * td;
53 | var b:Float = 3 * phase * td * td;
54 | var c:Float = 3 * t_2 * td;
55 | var t_3:Float = t_2 * phase;
56 | if (target == null)
57 | target = new Vector3D();
58 | target.x = a * start.x + b * control1.x + c * control2.x + t_3 * end.x;
59 | target.y = a * start.y + b * control1.y + c * control2.y + t_3 * end.y;
60 | target.z = a * start.z + b * control1.z + c * control2.z + t_3 * end.z;
61 | return target;
62 | }
63 | }
64 |
65 |
--------------------------------------------------------------------------------
/away3d/paths/IPath.hx:
--------------------------------------------------------------------------------
1 | package away3d.paths;
2 |
3 | import openfl.geom.Vector3D;
4 | import openfl.Vector;
5 |
6 | interface IPath {
7 | var numSegments(get, never):Int;
8 | var segments(get, never):Vector;
9 |
10 | /**
11 | * The number of CubicPathSegment
instances in the path.
12 | */
13 | private function get_numSegments():Int;
14 | /**
15 | * The IPathSegment
instances which make up this path.
16 | */
17 | private function get_segments():Vector;
18 | /**
19 | * Returns the CubicPathSegment
at the specified index
20 | * @param index The index of the segment
21 | * @return A CubicPathSegment
instance
22 | */
23 | function getSegmentAt(index:Int):IPathSegment;
24 | /**
25 | * Adds a CubicPathSegment
to the end of the path
26 | * @param segment
27 | */
28 | function addSegment(segment:IPathSegment):Void;
29 | /**
30 | * Removes a segment from the path
31 | * @param index The index of the CubicPathSegment
to be removed
32 | * @param join Determines if the segments on either side of the removed segment should be adjusted so there is no gap.
33 | */
34 | function removeSegment(index:Int, join:Bool = false):Void;
35 | /**
36 | * Disposes the path and all the segments
37 | */
38 | function dispose():Void;
39 | /**
40 | * Discretizes the segment into a set of sample points.
41 | *
42 | * @param numSegments The amount of segments to split the sampling in. The amount of points returned is numSegments + 1
43 | */
44 | function getPointsOnCurvePerSegment(numSegments:Int):Vector>;
45 | /**
46 | * Gets a point on the curve
47 | * @param t The phase for which to get the point. A number between 0 and 1.
48 | * @param target An optional parameter to store the calculation, to avoid creating a new Vector3D object
49 | * @return The point on the curve for the given phase
50 | */
51 | function getPointOnCurve(t:Float, target:Vector3D = null):Vector3D;
52 | }
53 |
54 |
--------------------------------------------------------------------------------
/away3d/paths/IPathSegment.hx:
--------------------------------------------------------------------------------
1 | package away3d.paths;
2 |
3 | import openfl.geom.Vector3D;
4 |
5 | interface IPathSegment {
6 |
7 | /**
8 | * Destroys the segment
9 | */
10 | function dispose():Void;
11 | /**
12 | * Calculates the position of the curve on this segment.
13 | *
14 | * @param phase The ratio between the start and end point.
15 | * @param target An optional target to store the calculation, to prevent creating a new Vector3D object.
16 | * @return
17 | */
18 | function getPointOnSegment(phase:Float, target:Vector3D = null):Vector3D;
19 | }
20 |
21 |
--------------------------------------------------------------------------------
/away3d/paths/QuadraticPathSegment.hx:
--------------------------------------------------------------------------------
1 | /**
2 | * Creates a curved line segment definition required for the Path class.
3 | */
4 | package away3d.paths;
5 |
6 | import openfl.geom.Vector3D;
7 |
8 | class QuadraticPathSegment implements IPathSegment {
9 |
10 | /**
11 | * Defines the first vector of the PathSegment
12 | */
13 | public var start:Vector3D;
14 | /**
15 | * Defines the control vector of the PathSegment
16 | */
17 | public var control:Vector3D;
18 | /**
19 | * Defines the control vector of the PathSegment
20 | */
21 | public var end:Vector3D;
22 |
23 | public function new(pStart:Vector3D, pControl:Vector3D, pEnd:Vector3D) {
24 | this.start = pStart;
25 | this.control = pControl;
26 | this.end = pEnd;
27 | }
28 |
29 | public function toString():String {
30 | return start + ", " + control + ", " + end;
31 | }
32 |
33 | /**
34 | * nulls the 3 vectors
35 | */
36 | public function dispose():Void {
37 | start = control = end = null;
38 | }
39 |
40 | public function getPointOnSegment(t:Float, target:Vector3D = null):Vector3D {
41 | var sx:Float = start.x;
42 | var sy:Float = start.y;
43 | var sz:Float = start.z;
44 | var t2Inv:Float = 2 * (1 - t);
45 | if (target == null)
46 | target = new Vector3D();
47 | target.x = sx + t * (t2Inv * (control.x - sx) + t * (end.x - sx));
48 | target.y = sy + t * (t2Inv * (control.y - sy) + t * (end.y - sy));
49 | target.z = sz + t * (t2Inv * (control.z - sz) + t * (end.z - sz));
50 | return target;
51 | }
52 | }
53 |
54 |
--------------------------------------------------------------------------------
/away3d/primitives/ConeGeometry.hx:
--------------------------------------------------------------------------------
1 | /**
2 | * A UV Cone primitive mesh.
3 | */
4 | package away3d.primitives;
5 |
6 | class ConeGeometry extends CylinderGeometry {
7 | public var radius(get, set):Float;
8 |
9 | /**
10 | * The radius of the bottom end of the cone.
11 | */
12 | private function get_radius():Float {
13 | return _bottomRadius;
14 | }
15 |
16 | private function set_radius(value:Float):Float {
17 | _bottomRadius = value;
18 | invalidateGeometry();
19 | return value;
20 | }
21 |
22 | /**
23 | * Creates a new Cone object.
24 | * @param radius The radius of the bottom end of the cone
25 | * @param height The height of the cone
26 | * @param segmentsW Defines the number of horizontal segments that make up the cone. Defaults to 16.
27 | * @param segmentsH Defines the number of vertical segments that make up the cone. Defaults to 1.
28 | * @param yUp Defines whether the cone poles should lay on the Y-axis (true) or on the Z-axis (false).
29 | */
30 | public function new(radius:Float = 50, height:Float = 100, segmentsW:Int = 16, segmentsH:Int = 1, closed:Bool = true, yUp:Bool = true) {
31 | super(0, radius, height, segmentsW, segmentsH, false, closed, true, yUp);
32 | }
33 | }
34 |
35 |
--------------------------------------------------------------------------------
/away3d/primitives/LineSegment.hx:
--------------------------------------------------------------------------------
1 | /**
2 | * A Line Segment primitive.
3 | */
4 | package away3d.primitives;
5 |
6 | import away3d.primitives.data.Segment;
7 | import openfl.geom.Vector3D;
8 |
9 | class LineSegment extends Segment {
10 |
11 | public var TYPE:String;
12 | /**
13 | * Create a line segment
14 | * @param v0 Start position of the line segment
15 | * @param v1 Ending position of the line segment
16 | * @param color0 Starting color of the line segment
17 | * @param color1 Ending colour of the line segment
18 | * @param thickness Thickness of the line
19 | */
20 | public function new(v0:Vector3D, v1:Vector3D, color0:Int = 0x333333, color1:Int = 0x333333, thickness:Float = 1) {
21 | TYPE = "line";
22 | super(v0, v1, null, color0, color1, thickness);
23 | }
24 | }
25 |
26 |
--------------------------------------------------------------------------------
/away3d/primitives/RegularPolygonGeometry.hx:
--------------------------------------------------------------------------------
1 | /**
2 | * A UV RegularPolygon primitive mesh.
3 | */
4 | package away3d.primitives;
5 |
6 | class RegularPolygonGeometry extends CylinderGeometry {
7 | public var radius(get, set):Float;
8 | public var sides(get, set):Int;
9 | public var subdivisions(get, set):Int;
10 |
11 | /**
12 | * The radius of the regular polygon.
13 | */
14 | private function get_radius():Float {
15 | return _bottomRadius;
16 | }
17 |
18 | private function set_radius(value:Float):Float {
19 | _bottomRadius = value;
20 | invalidateGeometry();
21 | return value;
22 | }
23 |
24 | /**
25 | * The number of sides of the regular polygon.
26 | */
27 | private function get_sides():Int {
28 | return _segmentsW;
29 | }
30 |
31 | private function set_sides(value:Int):Int {
32 | segmentsW = value;
33 | return value;
34 | }
35 |
36 | /**
37 | * The number of subdivisions from the edge to the center of the regular polygon.
38 | */
39 | private function get_subdivisions():Int {
40 | return _segmentsH;
41 | }
42 |
43 | private function set_subdivisions(value:Int):Int {
44 | segmentsH = value;
45 | return value;
46 | }
47 |
48 | /**
49 | * Creates a new RegularPolygon disc object.
50 | * @param radius The radius of the regular polygon
51 | * @param sides Defines the number of sides of the regular polygon.
52 | * @param yUp Defines whether the regular polygon should lay on the Y-axis (true) or on the Z-axis (false).
53 | */
54 | public function new(radius:Float = 100, sides:Int = 16, yUp:Bool = true) {
55 | super(radius, 0, 0, sides, 1, true, false, false, yUp);
56 | }
57 | }
58 |
59 |
--------------------------------------------------------------------------------
/away3d/primitives/data/NURBSVertex.hx:
--------------------------------------------------------------------------------
1 | /**
2 | * A nurbvertex that simply extends vertex with a w weight property.
3 | * Properties x, y, z and w represent a 3d point in space with nurb weighting.
4 | */
5 | package away3d.primitives.data;
6 |
7 | import away3d.core.base.data.Vertex;
8 |
9 |
10 | class NURBSVertex extends Vertex {
11 | public var w(get, set):Float;
12 |
13 | private var _w:Float;
14 |
15 | private function get_w():Float {
16 | return _w;
17 | }
18 |
19 | private function set_w(w:Float):Float {
20 | _w = w;
21 | return w;
22 | }
23 |
24 | /**
25 | * Creates a new Vertex
object.
26 | *
27 | * @param x [optional] The local x position of the vertex. Defaults to 0.
28 | * @param y [optional] The local y position of the vertex. Defaults to 0.
29 | * @param z [optional] The local z position of the vertex. Defaults to 0.
30 | * @param w [optional] The local w weight of the vertex. Defaults to 1.
31 | */
32 | public function new(x:Float = 0, y:Float = 0, z:Float = 0, w:Float = 1) {
33 | _w = w;
34 | super(x, y, z);
35 | }
36 | }
37 |
38 |
--------------------------------------------------------------------------------
/away3d/stereo/methods/AnaglyphStereoRenderMethod.hx:
--------------------------------------------------------------------------------
1 | package away3d.stereo.methods;
2 |
3 | import away3d.core.managers.Stage3DProxy;
4 | import openfl.display3D.Context3DProgramType;
5 | import openfl.Vector;
6 |
7 | class AnaglyphStereoRenderMethod extends StereoRenderMethodBase {
8 |
9 | private var _filterData:Vector;
10 |
11 | public function new() {
12 | super();
13 | _filterData = Vector.ofArray([1.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]);
14 | }
15 |
16 | override public function activate(stage3DProxy:Stage3DProxy):Void {
17 | stage3DProxy.context3D.setProgramConstantsFromVector(Context3DProgramType.FRAGMENT, 0, _filterData, 3);
18 | }
19 |
20 | override public function deactivate(stage3DProxy:Stage3DProxy):Void {
21 | stage3DProxy.context3D.setTextureAt(2, null);
22 | }
23 |
24 | override public function getFragmentCode():String {
25 | return "tex ft0, v1, fs0 <2d,linear,nomip>\n" +
26 | "tex ft1, v1, fs1 <2d,linear,nomip>\n" +
27 | "mul ft0, ft0, fc0\n" +
28 | "sub ft0, fc2, ft0\n" +
29 | "mul ft1, ft1, fc1\n" +
30 | "sub ft1, fc2, ft1\n" +
31 | "mul ft2, ft0, ft1\n" +
32 | "div ft2, ft2, fc2\n" +
33 | "sub oc, fc2, ft2\n";
34 | }
35 | }
36 |
37 |
--------------------------------------------------------------------------------
/away3d/stereo/methods/InterleavedStereoRenderMethod.hx:
--------------------------------------------------------------------------------
1 | package away3d.stereo.methods;
2 |
3 | import away3d.core.managers.RTTBufferManager;
4 | import away3d.core.managers.Stage3DProxy;
5 | import openfl.display3D.Context3DProgramType;
6 | import openfl.Vector;
7 |
8 | class InterleavedStereoRenderMethod extends StereoRenderMethodBase {
9 |
10 | private var _shaderData:Vector;
11 |
12 | public function new() {
13 | super();
14 | _shaderData = Vector.ofArray( [ 1., 1, 1, 1 ] );
15 | }
16 |
17 | override public function activate(stage3DProxy:Stage3DProxy):Void {
18 | if (_textureSizeInvalid) {
19 | var minV:Float;
20 | var rttManager:RTTBufferManager;
21 |
22 | rttManager = RTTBufferManager.getInstance(stage3DProxy);
23 | _textureSizeInvalid = false;
24 |
25 | minV = rttManager.renderToTextureRect.bottom / rttManager.textureHeight;
26 |
27 | _shaderData[0] = 2;
28 | _shaderData[1] = rttManager.renderToTextureRect.height;
29 | _shaderData[2] = 1;
30 | _shaderData[3] = .5;
31 | }
32 | stage3DProxy.context3D.setProgramConstantsFromVector(Context3DProgramType.FRAGMENT, 0, _shaderData);
33 | }
34 |
35 | override public function deactivate(stage3DProxy:Stage3DProxy):Void {
36 | stage3DProxy.context3D.setTextureAt(2, null);
37 | }
38 |
39 | override public function getFragmentCode():String {
40 | return "tex ft0, v1, fs0 <2d,linear,nomip>\n" +
41 | "tex ft1, v1, fs1 <2d,linear,nomip>\n" +
42 | "add ft2, v0.y, fc0.z\n" +
43 | "div ft2, ft2, fc0.x\n" +
44 | "mul ft2, ft2, fc0.y\n" +
45 | "div ft3, ft2, fc0.x\n" +
46 | "frc ft3, ft3\n" +
47 | "slt ft4, ft3, fc0.w\n" +
48 | "sge ft5, ft3, fc0.w\n" +
49 | "mul ft6, ft0, ft4\n" +
50 | "mul ft7, ft1, ft5\n" +
51 | "add oc, ft7, ft6\n";
52 | }
53 | }
54 |
55 |
--------------------------------------------------------------------------------
/away3d/stereo/methods/StereoRenderMethodBase.hx:
--------------------------------------------------------------------------------
1 | package away3d.stereo.methods;
2 |
3 | import away3d.core.managers.Stage3DProxy;
4 | import away3d.errors.AbstractMethodError;
5 |
6 | class StereoRenderMethodBase {
7 |
8 | private var _textureSizeInvalid:Bool;
9 |
10 | public function new() {
11 | _textureSizeInvalid = true;
12 | }
13 |
14 | public function activate(stage3DProxy:Stage3DProxy):Void {
15 | }
16 |
17 | public function deactivate(stage3DProxy:Stage3DProxy):Void {
18 | }
19 |
20 | public function getFragmentCode():String {
21 | throw new AbstractMethodError("Concrete implementation of StereoRenderMethodBase must be used and extend getFragmentCode().");
22 | return "";
23 | }
24 |
25 | public function invalidateTextureSize():Void {
26 | _textureSizeInvalid = true;
27 | }
28 | }
29 |
30 |
--------------------------------------------------------------------------------
/away3d/textfield/CharLocation.hx:
--------------------------------------------------------------------------------
1 | package away3d.textfield;
2 |
3 | import openfl.Vector;
4 |
5 | /**
6 | * ...
7 | * @author P.J.Shand
8 | */
9 | class CharLocation
10 | {
11 | public var char:BitmapChar;
12 | public var scale:Float;
13 | public var x:Float;
14 | public var y:Float;
15 |
16 | public function new(char:BitmapChar)
17 | {
18 | reset(char);
19 | }
20 |
21 | private function reset(char:BitmapChar):CharLocation
22 | {
23 | this.char = char;
24 | return this;
25 | }
26 |
27 | public function getChar():BitmapChar {
28 | return char;
29 | }
30 |
31 | // pooling
32 |
33 | private static var sInstancePool = new Array();
34 | private static var sVectorPool = new Array();
35 |
36 | private static var sInstanceLoan = new Array();
37 | private static var sVectorLoan = new Array();
38 |
39 | public static function instanceFromPool(char:BitmapChar):CharLocation
40 | {
41 | var instance:CharLocation = sInstancePool.length > 0 ?
42 | sInstancePool.pop() : new CharLocation(char);
43 |
44 | instance.reset(char);
45 | sInstanceLoan[sInstanceLoan.length] = instance;
46 |
47 | return instance;
48 | }
49 |
50 | public static function vectorFromPool():Vector
51 | {
52 | var vector:Vector = sVectorPool.length > 0 ?
53 | sVectorPool.pop() : [];
54 |
55 | vector.length = 0;
56 | sVectorLoan[sVectorLoan.length] = vector;
57 |
58 | return vector;
59 | }
60 |
61 | public static function rechargePool():Void
62 | {
63 | var instance:CharLocation;
64 | var vector:Vector;
65 |
66 | while (sInstanceLoan.length > 0)
67 | {
68 | instance = sInstanceLoan.pop();
69 | instance.char = null;
70 | sInstancePool[sInstancePool.length] = instance;
71 | }
72 |
73 | while (sVectorLoan.length > 0)
74 | {
75 | vector = sVectorLoan.pop();
76 | vector.length = 0;
77 | sVectorPool[sVectorPool.length] = vector;
78 | }
79 | }
80 | }
--------------------------------------------------------------------------------
/away3d/textfield/CleanMasterString.hx:
--------------------------------------------------------------------------------
1 | // =================================================================================================
2 | //
3 | // Starling Framework
4 | // Copyright 2014 Gamua GmbH. All Rights Reserved.
5 | //
6 | // This program is free software. You can redistribute and/or modify it
7 | // in accordance with the terms of the accompanying license agreement.
8 | //
9 | // =================================================================================================
10 |
11 | package away3d.textfield;
12 |
13 | class CleanMasterString
14 | {
15 | /** Replaces a string's "master string" — the string it was built from —
16 | * with a single character to save memory. Find more information about this AS3 oddity
17 | * here.
18 | *
19 | * @param str String to clean
20 | * @return The input string, but with a master string only one character larger than it.
21 | * @author Jackson Dunstan, JacksonDunstan.com
22 | */
23 | public function new()
24 | {
25 |
26 | }
27 |
28 | public function call(str:String):String
29 | {
30 | return ("_" + str).substr(1);
31 | }
32 | }
--------------------------------------------------------------------------------
/away3d/textfield/HAlign.hx:
--------------------------------------------------------------------------------
1 | // =================================================================================================
2 | //
3 | // Starling Framework
4 | // Copyright 2011-2014 Gamua. All Rights Reserved.
5 | //
6 | // This program is free software. You can redistribute and/or modify it
7 | // in accordance with the terms of the accompanying license agreement.
8 | //
9 | // =================================================================================================
10 |
11 | package away3d.textfield;
12 |
13 | import openfl.errors.Error;
14 |
15 | /** A class that provides constant values for horizontal alignment of objects. */
16 | class HAlign
17 | {
18 | /** @private */
19 | public function new() { throw new Error(); }
20 |
21 | /** Left alignment. */
22 | public static var LEFT:String = "left";
23 |
24 | /** Centered alignement. */
25 | public static var CENTER:String = "center";
26 |
27 | /** Right alignment. */
28 | public static var RIGHT:String = "right";
29 |
30 | /** Indicates whether the given alignment string is valid. */
31 | public static function isValid(hAlign:String):Bool
32 | {
33 | return hAlign == HAlign.LEFT || hAlign == HAlign.CENTER || hAlign == HAlign.RIGHT;
34 | }
35 | }
--------------------------------------------------------------------------------
/away3d/textfield/RectangleBitmapTexture.hx:
--------------------------------------------------------------------------------
1 | package away3d.textfield;
2 |
3 | import away3d.textures.Texture2DBase;
4 | import openfl.display.BitmapData;
5 | import openfl.display3D.Context3D;
6 | import openfl.display3D.Context3DTextureFormat;
7 | import openfl.display3D.textures.RectangleTexture;
8 | import openfl.display3D.textures.TextureBase;
9 |
10 | class RectangleBitmapTexture extends Texture2DBase {
11 | private var _bitmapData:BitmapData;
12 |
13 | public function new(bitmapData:BitmapData) {
14 | this.bitmapData = bitmapData;
15 | super();
16 | }
17 |
18 | public var bitmapData(get, set):BitmapData;
19 | private function get_bitmapData():BitmapData {
20 | return _bitmapData;
21 | }
22 |
23 | private function set_bitmapData(value:BitmapData):BitmapData {
24 | if (value == _bitmapData)
25 | return value;
26 |
27 | invalidateContent();
28 | setSize(value.width, value.height);
29 |
30 | _bitmapData = value;
31 | return value;
32 | }
33 |
34 | override private function uploadContent(texture:TextureBase):Void {
35 | cast(texture, RectangleTexture).uploadFromBitmapData(_bitmapData);
36 | }
37 |
38 | override private function createTexture(context:Context3D):TextureBase {
39 | return context.createRectangleTexture(_width, _height, Context3DTextureFormat.BGRA, false);
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/away3d/textfield/VAlign.hx:
--------------------------------------------------------------------------------
1 | // =================================================================================================
2 | //
3 | // Starling Framework
4 | // Copyright 2011-2014 Gamua. All Rights Reserved.
5 | //
6 | // This program is free software. You can redistribute and/or modify it
7 | // in accordance with the terms of the accompanying license agreement.
8 | //
9 | // =================================================================================================
10 |
11 | package away3d.textfield;
12 |
13 | import openfl.errors.Error;
14 |
15 | /** A class that provides constant values for vertical alignment of objects. */
16 | class VAlign
17 | {
18 | /** @private */
19 | public function new() { throw new Error(); }
20 |
21 | /** Top alignment. */
22 | public static var TOP:String = "top";
23 |
24 | /** Centered alignment. */
25 | public static var CENTER:String = "center";
26 |
27 | /** Bottom alignment. */
28 | public static var BOTTOM:String = "bottom";
29 |
30 | /** Indicates whether the given alignment string is valid. */
31 | public static function isValid(vAlign:String):Bool
32 | {
33 | return vAlign == VAlign.TOP || vAlign == VAlign.CENTER || vAlign == VAlign.BOTTOM;
34 | }
35 | }
--------------------------------------------------------------------------------
/away3d/textfield/utils/FontContainer.hx:
--------------------------------------------------------------------------------
1 | package away3d.textfield.utils;
2 |
3 | import openfl.Vector;
4 |
5 | /**
6 | * ...
7 | * @author P.J.Shand
8 | * @author Thomas Byrne
9 | */
10 | class FontContainer
11 | {
12 | private var fontSizes:Vector = new Vector();
13 |
14 | public function FontContainer()
15 | {
16 |
17 | }
18 |
19 | private function addSize(fontSize:FontSize):FontSize
20 | {
21 | fontSizes.push(fontSize);
22 | return fontSize;
23 | }
24 |
25 | public function best(size:Int):FontSize
26 | {
27 | var best:FontSize = null;
28 | var lowestDif:Float = Math.POSITIVE_INFINITY;
29 | for (i in 0...fontSizes.length)
30 | {
31 | var fontSize:FontSize = fontSizes[i];
32 | var dif:Int = cast Math.abs(fontSize.size - size);
33 | if (dif < lowestDif) {
34 | best = fontSize;
35 | lowestDif = dif;
36 | }
37 | }
38 | return best;
39 | }
40 | }
--------------------------------------------------------------------------------
/away3d/textfield/utils/FontSize.hx:
--------------------------------------------------------------------------------
1 | package away3d.textfield.utils;
2 |
3 | import flash.display.Bitmap;
4 | import flash.display.BitmapData;
5 | import haxe.io.Bytes;
6 | import openfl.errors.Error;
7 | /**
8 | * ...
9 | * @author P.J.Shand
10 | * @author Thomas Byrne
11 | */
12 | class FontSize
13 | {
14 | public var family:String;
15 | public var size:Int;
16 | public var data:Xml;
17 | public var texture:BitmapData;
18 |
19 | public function FontSize(searchClass:Bool=true)
20 | {
21 | if (searchClass) {
22 | var type:Class = Type.getClass(this);
23 | try {
24 | family = Reflect.getProperty(type, "FAMILY");
25 | size = Reflect.getProperty(type, "SIZE");
26 |
27 | var dataType:Class = Reflect.getProperty(type, "DATA");
28 | var textureType:Class = Reflect.getProperty(type, "TEXTURE");
29 | data = cast(Type.createInstance(dataType, null), Xml);
30 | //texture = cast(Type.createInstance(textureType, null), Bitmap).bitmapData;
31 | texture = cast(Type.createInstance(textureType, null), Bytes);
32 |
33 | }catch (e:Error) {
34 | throw new Error("Class inheriting from FontSize ("+type+") should have PUBLIC static members FAMILY, SIZE, DATA and TEXTURE.");
35 | }
36 | }
37 | }
38 | }
--------------------------------------------------------------------------------
/away3d/textures/ATFCubeTexture.hx:
--------------------------------------------------------------------------------
1 | package away3d.textures;
2 |
3 |
4 | import openfl.errors.Error;
5 | import openfl.display3D.Context3D;
6 | import openfl.display3D.textures.CubeTexture;
7 | import openfl.display3D.textures.TextureBase;
8 | import openfl.utils.ByteArray;
9 |
10 | class ATFCubeTexture extends CubeTextureBase {
11 | public var atfData(get, set):ATFData;
12 |
13 | private var _atfData:ATFData;
14 |
15 | public function new(byteArray:ByteArray) {
16 | super();
17 | atfData = new ATFData(byteArray);
18 | if (atfData.type != ATFData.TYPE_CUBE) throw new Error("ATF isn't cubetexture");
19 | _format = atfData.format;
20 | _hasMipmaps = _atfData.numTextures > 1;
21 | }
22 |
23 | private function get_atfData():ATFData {
24 | return _atfData;
25 | }
26 |
27 | private function set_atfData(value:ATFData):ATFData {
28 | _atfData = value;
29 | invalidateContent();
30 | setSize(value.width, value.height);
31 | return value;
32 | }
33 |
34 | override private function uploadContent(texture:TextureBase):Void {
35 | cast((texture), CubeTexture).uploadCompressedTextureFromByteArray(_atfData.data, 0, false);
36 | }
37 |
38 | override private function createTexture(context:Context3D):TextureBase {
39 | return context.createCubeTexture(_atfData.width, _atfData.format, false);
40 | }
41 | }
42 |
43 |
--------------------------------------------------------------------------------
/away3d/textures/ATFData.hx:
--------------------------------------------------------------------------------
1 | package away3d.textures;
2 |
3 | import openfl.errors.Error;
4 | import openfl.display3D.Context3DTextureFormat;
5 | import openfl.utils.ByteArray;
6 |
7 | class ATFData {
8 |
9 | static public var TYPE_NORMAL:Int = 0x0;
10 | static public var TYPE_CUBE:Int = 0x1;
11 | public var type:Int;
12 | public var format:Context3DTextureFormat;
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 new(data:ByteArray) {
20 | var sign:String = data.readUTFBytes(3);
21 | if (sign != "ATF") throw new Error("ATF parsing error, unknown format " + sign);
22 |
23 | data.position = 6;
24 | var newFileVersion = data.readUnsignedByte();
25 | if (newFileVersion == 255) data.position = 12; // new file version
26 | else data.position = 6; // old file version
27 | // old file version
28 | var tdata:Int = data.readUnsignedByte();
29 | var _type:Int = tdata >> 7;
30 | // UB[1]
31 | var _format:Int = tdata & 0x7f;
32 | // UB[7]
33 | switch(_format) {
34 | case 0, 1:
35 | format = Context3DTextureFormat.BGRA;
36 | case 2, 3:
37 | format = Context3DTextureFormat.COMPRESSED;
38 | case 4, 5:
39 | format = Context3DTextureFormat.COMPRESSED_ALPHA;
40 |
41 | // explicit string to stay compatible
42 | // with older versions
43 | throw new Error("Invalid ATF format");
44 | default:
45 | throw new Error("Invalid ATF format");
46 | }
47 | switch(_type) {
48 | case 0:
49 | type = ATFData.TYPE_NORMAL;
50 | case 1:
51 | type = ATFData.TYPE_CUBE;
52 | default:
53 | throw new Error("Invalid ATF type");
54 | }
55 | this.width = Std.int(Math.pow(2, data.readUnsignedByte()));
56 | this.height = Std.int(Math.pow(2, data.readUnsignedByte()));
57 | this.numTextures = data.readUnsignedByte();
58 | this.data = data;
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/away3d/textures/ATFTexture.hx:
--------------------------------------------------------------------------------
1 | package away3d.textures;
2 |
3 |
4 | import openfl.display3D.Context3D;
5 | import openfl.display3D.textures.Texture;
6 | import openfl.display3D.textures.TextureBase;
7 | import openfl.utils.ByteArray;
8 |
9 | class ATFTexture extends Texture2DBase {
10 | public var atfData(get, set):ATFData;
11 |
12 | private var _atfData:ATFData;
13 |
14 | public function new(byteArray:ByteArray) {
15 | super();
16 | atfData = new ATFData(byteArray);
17 | _format = atfData.format;
18 | _hasMipmaps = _atfData.numTextures > 1;
19 | }
20 |
21 | private function get_atfData():ATFData {
22 | return _atfData;
23 | }
24 |
25 | private function set_atfData(value:ATFData):ATFData {
26 | _atfData = value;
27 | invalidateContent();
28 | setSize(value.width, value.height);
29 | return value;
30 | }
31 |
32 | override private function uploadContent(texture:TextureBase):Void {
33 | cast((texture), Texture).uploadCompressedTextureFromByteArray(_atfData.data, 0, false);
34 | }
35 |
36 | override private function createTexture(context:Context3D):TextureBase {
37 | return context.createTexture(_width, _height, atfData.format, false);
38 | }
39 | }
40 |
41 |
--------------------------------------------------------------------------------
/away3d/textures/Anisotropy.hx:
--------------------------------------------------------------------------------
1 | package away3d.textures;
2 |
3 | enum Anisotropy {
4 | NONE;
5 | ANISOTROPIC2X;
6 | ANISOTROPIC4X;
7 | ANISOTROPIC8X;
8 | ANISOTROPIC16X;
9 | }
--------------------------------------------------------------------------------
/away3d/textures/BitmapTextureCache.hx:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | /**
5 | * DEPRECRATED along with BitmapMaterial. Will be removed along with BitmapMaterial
6 | */
7 | package away3d.textures;
8 |
9 | import openfl.errors.Error;
10 | import away3d.textures.BitmapTexture;
11 | import openfl.display.BitmapData;
12 | import haxe.ds.WeakMap;
13 |
14 | class BitmapTextureCache {
15 |
16 | static private var _instance:BitmapTextureCache;
17 | private var _textures:WeakMap;
18 | private var _usages:WeakMap;
19 |
20 | public function new(singletonEnforcer:SingletonEnforcer) {
21 | if (singletonEnforcer == null) throw new Error("Cannot instantiate a singleton class. Use static getInstance instead.");
22 | _textures = new WeakMap();
23 | _usages = new WeakMap();
24 |
25 | }
26 |
27 | static public function getInstance():BitmapTextureCache {
28 | if (_instance == null) _instance = new BitmapTextureCache(new SingletonEnforcer());
29 | return _instance ;
30 | }
31 |
32 | public function getTexture(bitmapData:BitmapData):BitmapTexture {
33 | var texture:BitmapTexture = null;
34 |
35 | if (!_textures.exists(bitmapData)) {
36 | texture = new BitmapTexture(bitmapData);
37 | _textures.set(bitmapData, texture);
38 | _usages.set(texture, 0);
39 | }
40 | _usages.set(texture, _usages.get(texture) + 1);
41 | return _textures.get(bitmapData);
42 | }
43 |
44 | public function freeTexture(texture:BitmapTexture):Void {
45 | _usages.set(texture, _usages.get(texture) - 1);
46 | if (_usages.get(texture) == 0) {
47 | _textures.set(cast((texture), BitmapTexture).bitmapData, null);
48 | texture.dispose();
49 | }
50 | }
51 | }
52 |
53 | class SingletonEnforcer {
54 | public function new() {}
55 | }
56 |
57 |
--------------------------------------------------------------------------------
/away3d/textures/CubeTextureBase.hx:
--------------------------------------------------------------------------------
1 | package away3d.textures;
2 |
3 |
4 | import openfl.display3D.Context3D;
5 | import openfl.display3D.Context3DTextureFormat;
6 | import openfl.display3D.textures.TextureBase;
7 |
8 | class CubeTextureBase extends TextureProxyBase {
9 | public var size(get, never):Int;
10 |
11 | public function new() {
12 | super();
13 | }
14 |
15 | private function get_size():Int {
16 | return _width;
17 | }
18 |
19 | override private function createTexture(context:Context3D):TextureBase {
20 | return context.createCubeTexture(width, Context3DTextureFormat.BGRA, false);
21 | }
22 | }
23 |
24 |
--------------------------------------------------------------------------------
/away3d/textures/RenderCubeTexture.hx:
--------------------------------------------------------------------------------
1 | package away3d.textures;
2 |
3 |
4 | import openfl.errors.Error;
5 | import away3d.materials.utils.MipmapGenerator;
6 | import away3d.tools.utils.TextureUtils;
7 | import openfl.display.BitmapData;
8 | import openfl.display3D.Context3D;
9 | import openfl.display3D.Context3DTextureFormat;
10 | import openfl.display3D.textures.TextureBase;
11 | import openfl.display3D.textures.CubeTexture;
12 |
13 | class RenderCubeTexture extends CubeTextureBase {
14 |
15 |
16 | public function new(size:Int) {
17 | super();
18 | setSize(size, size);
19 | }
20 |
21 | private function set_size(value:Int):Int {
22 | if (value == _width) return value;
23 | if (!TextureUtils.isDimensionValid(value)) throw new Error("Invalid size: Width and height must be power of 2 and cannot exceed 2048");
24 | invalidateContent();
25 | setSize(value, value);
26 | return value;
27 | }
28 |
29 | override private function uploadContent(texture:TextureBase):Void {
30 | // fake data, to complete texture for sampling
31 | var bmd:BitmapData = new BitmapData(_width, _height, false, 0);
32 | var i:Int = 0;
33 | while (i < 6) {
34 | #if flash
35 | MipmapGenerator.generateMipMaps(bmd, texture, null, false, i);
36 | #else
37 | cast((texture), CubeTexture).uploadFromBitmapData(bmd, i, 0);
38 | #end
39 | ++i;
40 | }
41 | bmd.dispose();
42 | }
43 |
44 | override private function createTexture(context:Context3D):TextureBase {
45 | return context.createCubeTexture(_width, Context3DTextureFormat.BGRA, true);
46 | }
47 | }
48 |
49 |
--------------------------------------------------------------------------------
/away3d/textures/RenderTexture.hx:
--------------------------------------------------------------------------------
1 | package away3d.textures;
2 |
3 | import openfl.errors.Error;
4 | import away3d.materials.utils.MipmapGenerator;
5 | import away3d.tools.utils.TextureUtils;
6 | import openfl.display.BitmapData;
7 | import openfl.display3D.Context3D;
8 | import openfl.display3D.Context3DTextureFormat;
9 | import openfl.display3D.textures.TextureBase;
10 | import openfl.display3D.textures.Texture;
11 |
12 | class RenderTexture extends Texture2DBase {
13 |
14 | public function new(_width:Int, _height:Int) {
15 | super();
16 | setSize(_width, _height);
17 | }
18 |
19 | override private function set_width(value:Int):Int {
20 | if (value == _width) return value;
21 | if (!TextureUtils.isDimensionValid(value)) throw new Error("Invalid size: Width and height must be power of 2 and cannot exceed 2048");
22 | invalidateContent();
23 | setSize(value, _height);
24 | return value;
25 | }
26 |
27 | override private function set_height(value:Int):Int {
28 | if (value == _height) return value;
29 | if (!TextureUtils.isDimensionValid(value)) throw new Error("Invalid size: Width and height must be power of 2 and cannot exceed 2048");
30 | invalidateContent();
31 | setSize(_width, value);
32 | return value;
33 | }
34 |
35 | override private function uploadContent(texture:TextureBase):Void {
36 | // fake data, to complete texture for sampling
37 | //var bmp:BitmapData = new BitmapData(width, height, false, 0xff0000);
38 | //MipmapGenerator.generateMipMaps(bmp, texture);
39 | //cast((texture), Texture).uploadFromBitmapData(bmp);
40 | //bmp.dispose();
41 | }
42 |
43 | override private function createTexture(context:Context3D):TextureBase {
44 | return context.createTexture(width, height, Context3DTextureFormat.BGRA, true);
45 | }
46 | }
47 |
48 |
--------------------------------------------------------------------------------
/away3d/textures/Texture2DBase.hx:
--------------------------------------------------------------------------------
1 | package away3d.textures;
2 |
3 |
4 | import openfl.display3D.Context3D;
5 | import openfl.display3D.Context3DTextureFormat;
6 | import openfl.display3D.textures.TextureBase;
7 |
8 | class Texture2DBase extends TextureProxyBase {
9 |
10 | public function new() {
11 | super();
12 | }
13 |
14 | override private function createTexture(context:Context3D):TextureBase {
15 | return context.createTexture(_width, _height, Context3DTextureFormat.BGRA, false);
16 | }
17 | }
18 |
19 |
--------------------------------------------------------------------------------
/away3d/tools/helpers/data/ParticleGeometryTransform.hx:
--------------------------------------------------------------------------------
1 | /**
2 | * ...
3 | */
4 | package away3d.tools.helpers.data;
5 |
6 | import openfl.geom.Matrix;
7 | import openfl.geom.Matrix3D;
8 |
9 | class ParticleGeometryTransform {
10 | public var vertexTransform(get, set):Matrix3D;
11 | public var UVTransform(get, set):Matrix;
12 | public var invVertexTransform(get, never):Matrix3D;
13 |
14 | private var _defaultVertexTransform:Matrix3D;
15 | private var _defaultInvVertexTransform:Matrix3D;
16 | private var _defaultUVTransform:Matrix;
17 |
18 | public function new() {
19 | }
20 |
21 | private function set_vertexTransform(value:Matrix3D):Matrix3D {
22 | _defaultVertexTransform = value;
23 | _defaultInvVertexTransform = value.clone();
24 | _defaultInvVertexTransform.invert();
25 | _defaultInvVertexTransform.transpose();
26 | return value;
27 | }
28 |
29 | private function set_UVTransform(value:Matrix):Matrix {
30 | _defaultUVTransform = value;
31 | return value;
32 | }
33 |
34 | private function get_UVTransform():Matrix {
35 | return _defaultUVTransform;
36 | }
37 |
38 | private function get_vertexTransform():Matrix3D {
39 | return _defaultVertexTransform;
40 | }
41 |
42 | private function get_invVertexTransform():Matrix3D {
43 | return _defaultInvVertexTransform;
44 | }
45 | }
46 |
47 |
--------------------------------------------------------------------------------
/away3d/tools/utils/TextureUtils.hx:
--------------------------------------------------------------------------------
1 | package away3d.tools.utils;
2 |
3 | import openfl.display.BitmapData;
4 |
5 | class TextureUtils {
6 |
7 | static private var MAX_SIZE:Int = 4096;
8 |
9 | static public function isBitmapDataValid(bitmapData:BitmapData):Bool {
10 | if (bitmapData == null) return true;
11 | return isDimensionValid(bitmapData.width) && isDimensionValid(bitmapData.height);
12 | }
13 |
14 | static public function isDimensionValid(d:Int):Bool {
15 | return d >= 1 && d <= MAX_SIZE && isPowerOfTwo(d);
16 | }
17 |
18 | static public function isPowerOfTwo(value:Int):Bool {
19 | return (value > 0) ? ((value & -value) == value) : false;
20 | }
21 |
22 | static public function getBestPowerOf2(value:Int):Int {
23 | var p:Int = 1;
24 | while (p < value)p <<= 1;
25 | if (p > MAX_SIZE) p = MAX_SIZE;
26 | return p;
27 | }
28 | }
29 |
30 |
--------------------------------------------------------------------------------
/away3d/utils/ArrayUtils.hx:
--------------------------------------------------------------------------------
1 | package away3d.utils;
2 | import openfl.geom.Matrix3D;
3 | import openfl.Vector;
4 | import openfl.Lib;
5 |
6 | class ArrayUtils {
7 | #if flash
8 | inline public static function reSize(arr:Dynamic, count:Int, ?defaultValue:Dynamic = null) {
9 | arr.length = count;
10 | }
11 |
12 | inline public static function Prefill(arr:Dynamic, count:Int, ?defaultValue:Dynamic = null):Dynamic {
13 | var c:Int = 0;
14 | while (c < count) {
15 | arr[c] = defaultValue;
16 | c++;
17 | }
18 | return arr;
19 | }
20 | #else
21 | public static function reSize( either:AcceptEither,Vector>, count:Int, ?defaultValue:Dynamic = null) {
22 | var t = Lib.getTimer();
23 | switch either.type {
24 | case Left(arr):
25 | var c = arr.length;
26 | while (c < count) {
27 | arr.push(defaultValue);
28 | c++;
29 | }
30 | while (c > count) {
31 | arr.pop();
32 | c--;
33 | }
34 | case Right(vec):
35 | var c = vec.length;
36 | vec.length = count;
37 | while (c < count) {
38 | vec[c++] = defaultValue;
39 | }
40 | }
41 | }
42 |
43 |
44 | public static function Prefill( either:AcceptEither,Vector>, count:Int, ?elem:T ):Dynamic {
45 | var t = Lib.getTimer();
46 | switch either.type {
47 | case Left(arr):
48 | arr.splice(0, arr.length);
49 | var c:Int = 0;
50 | while (c++ < count) {
51 | arr.push(elem);
52 | }
53 | return arr;
54 | case Right(vec):
55 | vec.length = count;
56 | var c:Int = 0;
57 | while (c < count) {
58 | vec[c++] = elem;
59 | }
60 | return vec;
61 | }
62 | }
63 | #end
64 | }
65 |
66 | abstract AcceptEither (Either) {
67 |
68 | public inline function new( e:Either ) this = e;
69 |
70 | public var value(get,never):Dynamic;
71 | public var type(get,never):Either;
72 |
73 | inline function get_value() switch this { case Left(v) | Right(v): return v; }
74 | @:to inline function get_type() return this;
75 |
76 | @:from static function fromA( v:A ):AcceptEither return new AcceptEither( Left(v) );
77 | @:from static function fromB( v:B ):AcceptEither return new AcceptEither( Right(v) );
78 | }
79 |
80 | enum Either {
81 | Left( v:A );
82 | Right( v:B );
83 | }
84 |
--------------------------------------------------------------------------------
/haxelib.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "away3d",
3 | "url": "http://away3d.com",
4 | "license": "MIT",
5 | "tags": [ "away3d", "3d", "engine", "openfl", "cross", "cpp", "flash", "game", "js", "web", "ios", "android" ],
6 | "description": "Away3D is an open source, real time 3D engine for the Flash Platform and has been ported to OpenFL 2.x/Haxe",
7 | "version": "1.3.2",
8 | "releasenote": "Updates for Haxe 3.3, OpenFl 3.6.1 and Lime 2.9.1 with backwards compatibility",
9 | "contributors": [ "Greg209", "p.j.shand" ],
10 | "dependencies": {
11 | "openfl": ""
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/include.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------