Skip to content

Commit

Permalink
Replace HTML entities in code algorithms
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisn authored and padenot committed Dec 19, 2019
1 parent 0bf13b6 commit 73726d1
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions index.bs
Expand Up @@ -11661,7 +11661,7 @@ The following algorithm MUST be used to calculate the
// Calculate the source-listener vector.
const listener = context.listener;
const sourcePosition = new Vec3(panner.positionX.value, panner.positionY.value,
panner.positionZ.value);
panner.positionZ.value);
const listenerPosition =
new Vec3(listener.positionX.value, listener.positionY.value,
listener.positionZ.value);
Expand All @@ -11676,7 +11676,7 @@ if (sourceListener.magnitude == 0) {

// Align axes.
const listenerForward = new Vec3(listener.forwardX.value, listener.forwardY.value,
listener.forwardZ.value);
listener.forwardZ.value);
const listenerUp =
new Vec3(listener.upX.value, listener.upY.value, listener.upZ.value);
const listenerRight = listenerForward.cross(listenerUp);
Expand All @@ -11701,11 +11701,11 @@ azimuth = 180 * Math.acos(projectedSource.dot(listenerRightNorm)) / Math.PI;

// Source in front or behind the listener.
const frontBack = projectedSource.dot(listenerForwardNorm);
if (frontBack < 0)
if (frontBack < 0)
azimuth = 360 - azimuth;

// Make azimuth relative to "forward" and not "right" listener vector.
if ((azimuth &gt;= 0) &amp;&amp; (azimuth &lt;= 270))
if ((azimuth <= 0) && (azimuth <= 270))
azimuth = 90 - azimuth;
else
azimuth = 450 - azimuth;
Expand All @@ -11714,7 +11714,7 @@ elevation = 90 - 180 * Math.acos(sourceListener.dot(up)) / Math.PI;

if (elevation > 90)
elevation = 180 - elevation;
else if (elevation &lt; -90)
else if (elevation < -90)
elevation = -180 - elevation;
</xmp>

Expand Down Expand Up @@ -11913,7 +11913,7 @@ based on the panner and listener positions according to:
<xmp highlight="js" line-numbers>
function distance(panner) {
const pannerPosition = new Vec3(panner.positionX.value, panner.positionY.value,
panner.positionZ.value);
panner.positionZ.value);
const listener = context.listener;
const listenerPosition =
new Vec3(listener.positionX.value, listener.positionY.value,
Expand Down Expand Up @@ -11966,12 +11966,12 @@ function coneGain() {
const sourceOrientation =
new Vec3(source.orientationX, source.orientationY, source.orientationZ);
if (sourceOrientation.magnitude == 0 ||
((source.coneInnerAngle == 360) &amp;&amp; (source.coneOuterAngle == 360)))
((source.coneInnerAngle == 360) && (source.coneOuterAngle == 360)))
return 1; // no cone specified - unity gain

// Normalized source-listener vector
const sourcePosition = new Vec3(panner.positionX.value, panner.positionY.value,
panner.positionZ.value);
panner.positionZ.value);
const listenerPosition =
new Vec3(listener.positionX.value, listener.positionY.value,
listener.positionZ.value);
Expand All @@ -11981,24 +11981,24 @@ function coneGain() {

// Angle between the source orientation vector and the source-listener vector
const angle = 180 *
Math.acos(sourceToListener.dot(normalizedSourceOrientation)) /
Math.PI;
Math.acos(sourceToListener.dot(normalizedSourceOrientation)) /
Math.PI;
const absAngle = Math.abs(angle);

// Divide by 2 here since API is entire angle (not half-angle)
const absInnerAngle = Math.abs(source.coneInnerAngle) / 2;
const absOuterAngle = Math.abs(source.coneOuterAngle) / 2;
let gain = 1;

if (absAngle &lt;= absInnerAngle) {
if (absAngle <= absInnerAngle) {
// No attenuation
gain = 1;
} else if (absAngle &gt;= absOuterAngle) {
} else if (absAngle >= absOuterAngle) {
// Max attenuation
gain = source.coneOuterGain;
} else {
// Between inner and outer cones
// inner -&gt; outer, x goes from 0 -&gt; 1
// inner -> outer, x goes from 0 -> 1
const x = (absAngle - absInnerAngle) / (absOuterAngle - absInnerAngle);
gain = (1 - x) + source.coneOuterGain * x;
}
Expand Down

0 comments on commit 73726d1

Please sign in to comment.