A FlxSound that pans left and right based on the camera position in 3D.

Note: Due to OpenAL limitations, this only works with sounds that doesn't have stereo audio channels.

Constructor

new(target:FlxSound)

Variables

sound:FlxSound

private@:value(new FlxObject())attenObj:FlxObject = new FlxObject()

@:value(0.85)panStrength:Float = 0.85

The strength of the stereo panning.

A value of 1.0 means pan fully left or right,

A value of 0.5 means pan left, while right is still audible, and viceversa.

A value of 0.0 means no panning, and negative values inverts the panning.

@:value(100)range:Float = 100

The sound range in world units.

Note: The attenuation power follows the Inverse Square Law for realistic effects.

@:value(0)dopplerStrength:Float = 0

Pitch up/down the sound based on its velocity towards/away from the camera.

It's the same effect when an ambulance is passing in front of you; its siren sounds pitched up when it's getting closer, and pitched down when it's going away

Keep in mind that this effect overwrites pitch, use dopplerPitchOffset to use a custom pitch.

@:value(0)dopplerPitchOffset:Float = 0

@:value(343)propagationSpeed:Float = 343

The speed the sound travels at sea level in meters per second (m/s)

To disable it, set it to 0

private@:value(0)prevDistance:Float = 0

@:value(0)playDistance:Float = 0

Distance from camera that was set since the last play() call

@:value({ currentTime : 0, targetTime : 0, queuedStartTime : 0 })queued:PropagationQueue = { currentTime : 0, targetTime : 0, queuedStartTime : 0 }

The queued sound parameters for propagation

@:value(0)cameraIndex:Int = 0

The index of the camera to follow in the scene.

@:value(new FlxTypedSignalImpl())onSoundReached:FlxTypedSignalImpl<() ‑> Void> = new FlxTypedSignalImpl()

If playing with realistic propagation, this event will fire when the sound "reaches" the camera

Methods

privateinlinegetDelayFromDistance(dist:Float):Float

Returns the delay in seconds the sound would take to reach the camera to be heard

This distance can change based on propagationSpeed and if the camera has been moved since the last play() call

privateinlinegetDopplerShiftStrength(listenerSpeed:Float):Float

Returns the doppler shifting strength based on the doppler formula:

f' = f0 * ( (C+Vo) / (C-Vs) )

Wave speeds are converted to pitch, which is 1 for simplification

Parameters:

listenerSpeed

The speed of the listener towards the sound

@:value({ startTime : 0 })play(startTime:Float = 0, ?endTime:Float):Void

Plays the sound. Unlike FlxSound.play(), this function takes into account realistic sound propagation and will queue the sound.

Note: Calling this will force the sound to play from the beginning, if you want to pause/resume the sound use its play() function directly and after the timer has been finished, if you need to stop the sound or the queue, call stop()

stop():Void

private_play():Void

Inherited Variables

Defined by FoxObject

parent:FoxObject

If set, will adapt parent transform. Make sure the parent has a higher priority so it updates in order

position:Vector3D

@:value(new Vector3D())rotation:Vector3D = new Vector3D()

@:value(new Vector3D(1, 1, 1))scale:Vector3D = new Vector3D(1, 1, 1)

x:Float

y:Float

z:Float

angleX:Float

angleY:Float

angleZ:Float

@:value(EulerOrder.ZYX)rotationOrder:EulerOrder = EulerOrder.ZYX

This controls the way this object is rotated (via rotation)

The rotation is applied per-axis sequentially, meaning the way one axis rotate can influence the next rotation.

By default, the Z axis rotates first, this makes the object roll.

Then the Y axis is rotated next, this orients the rolled object horizontally, think of it as a swiveling floor fan.

And last, the X axis is rotated, this has the effect of tilting the Y rotation.

This is done in this order so there is no gimbal-lock when converting euler angles from quaternions. However, this order affects camera rotations.

Custom camera controllers should use ZXY order instead so no tilting occurs.

@:value(new Matrix3D())transform:Matrix3D = new Matrix3D()

This is the global transform for this Object, it encodes position, rotation and scale in a 4x4 matrix

@:value(new Vector3D())read onlyglobalPosition:Vector3D = new Vector3D()

@:value(new Vector3D())read onlyglobalRotation:Vector3D = new Vector3D()

@:value(new Vector3D())read onlyglobalScale:Vector3D = new Vector3D()

Defined by FoxBasic

@:value("FoxBasic")name:String = "FoxBasic"

@:value(true)visible:Bool = true

@:value(true)active:Bool = true

@:value(null)scene:FoxScene = null

@:value(false)__destroyed:Bool = false

animation:FoxAnimationPlayer

An animation controller for this basic. Although properties have to be manually linked, this is intended to be a general-purpose animator for this object

Inherited Methods

Defined by FoxObject

@:value({ z : 0, y : 0, x : 0 })setPosition(x:Float = 0, y:Float = 0, z:Float = 0):Void

@:value({ z : 0, y : 0, x : 0 })setRotation(x:Float = 0, y:Float = 0, z:Float = 0):Void

@:value({ z : 0, y : 0, x : 0 })setAngle(x:Float = 0, y:Float = 0, z:Float = 0):Void

Same as setRotation() but for angle degrees.

setAngleFromVector(angles:Vector3D):Void

Sets the object's angle degrees from a Vector3D

getAngle(?output:Vector3D):Vector3D

Gets the object's rotation as degrees, as a Vector3D

Parameters:

output

(Optional) the output vector to store the angles without allocating a new one

Returns:

a Vector3D containing angleX, angleY and angleZ

@:value({ w : 1, z : 0, y : 0, x : 0 })setRotationQuaternion(x:Float = 0, y:Float = 0, z:Float = 0, w:Float = 1):Vector3D

Sets the object's rotation from a Quaternion, which is needed for accurate rotation representation when interpolating.

How dows it work? hell if i know

setRotationQuaternionFromVector(quat:Vector3D):Vector3D

@:value({ z : 1, y : 1, x : 1 })setScale(x:Float = 1, y:Float = 1, z:Float = 1):Void

copyComponentsFrom(object:FoxObject):Void

Copies position, rotation and scale from another FoxObject, so the other object's components doesn't affect this one when changing them

privateget_globalPosition():Vector3D

privateget_globalRotation():Vector3D

privateget_globalScale():Vector3D

privateget_x():Float

privateget_y():Float

privateget_z():Float

privateinlineset_x(v:Float):Float

privateinlineset_y(v:Float):Float

privateinlineset_z(v:Float):Float

privateset_angleX(v:Float):Float

privateset_angleY(v:Float):Float

privateset_angleZ(v:Float):Float

privateget_angleX():Float

privateget_angleY():Float

privateget_angleZ():Float

Defined by FoxBasic

physicsUpdate(dt:Float):Void

Called when a physics frame occurs, this is a constant update regardless of framerate for a consistant physics simulation.

draw(camera:FoxCamera):Void

Intended for transforms, actual drawing happens in the camera render pass

pushDrawData(scene:FoxScene):Void

This function gets called when the scene starts building draw groups.

It should call the scene's addToDrawGroups() function for every drawable of this object.

Override this with your custom draw data function.

Note: Internal use only, it is a performance critical operation, keep it fast.

computeBounds(output:BoundingBox):Void

Gets the bounding box of all meshes and models inside groups

In FoxBasic this is just a template, do the actual implementation in your models and groups

Parameters:

output

the Bounding Box where to store the result

testAndCull(camera:FoxCamera):Void

Performs frustum culling by checking the bounding box against a camera frustum

isVisible():Bool

Template function that returns the final visibility for the basic. Frustum culling can affect this.

isActive():Bool

Template function that returns the final activated state for the basic. Frustum culling can affect this.