Skip to content

Commit

Permalink
Make Euler and Quaternion .onChange() methods private
Browse files Browse the repository at this point in the history
  • Loading branch information
WestLangley committed Jun 10, 2019
1 parent 6737d0d commit 1b544f0
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 96 deletions.
33 changes: 4 additions & 29 deletions docs/api/en/math/Euler.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,29 +58,21 @@ <h3>[property:String order]</h3>
to the <em>local</em> coordinate system. That is, for order 'XYZ', the rotation is first around the local-X
axis (which is the same as the world-X axis), then around local-Y (which may now be different from the
world Y-axis), then local-Z (which may be different from the world Z-axis).<br /><br />

If the order is changed, [page:.onChangeCallback onChangeCallback] will be called.
</p>

<h3>[property:Float x]</h3>
<p>
The current value of the x component.<br /><br />

If this is changed, [page:.onChangeCallback onChangeCallback] will be called.
</p>

<h3>[property:Float y]</h3>
<p>
The current value of the y component.<br /><br />

If this is changed, [page:.onChangeCallback onChangeCallback] will be called.
</p>

<h3>[property:Float z]</h3>
<p>
The current value of the z component.<br /><br />

If this is changed, [page:.onChangeCallback onChangeCallback] will be called.
</p>

<h2>Methods</h2>
Expand All @@ -104,18 +96,6 @@ <h3>[method:Euler fromArray]( [param:Array array] )</h3>
Optionally assigns this euler's [page:.order order] to array[3].
</p>

<h3>[method:Euler onChange]( [param:Function onChangeCallback] )</h3>
<p>
[page:Function onChangeCallback] - set the value of the onChangeCallback() function.
</p>

<h3>[method:Euler onChangeCallback]( )</h3>
<p>
By default this is an empty function, however it can be set via [page:.onChange onChange]().<br />
It gets called after changing the [page:.x x], [page:.y y], [page:.z z] or [page:.order order] properties,
and also after calling most setter functions (see those for details).
</p>

<h3>[method:Euler reorder]( [param:String newOrder] )</h3>
<p>
Resets the euler angle with a new order by creating a quaternion from this euler angle
Expand All @@ -131,27 +111,23 @@ <h3>[method:Euler set]( [param:Float x], [param:Float y], [param:Float z], [para
[page:.z z] - the angle of the z axis in radians.<br />
[page:.order order] - (optional) a string representing the order that the rotations are applied.<br /><br />

Sets the angles of this euler transform and optionally the [page:.order order] and then call [page:.onChangeCallback onChangeCallback]().
Sets the angles of this euler transform and optionally the [page:.order order].
</p>

<h3>[method:Euler setFromRotationMatrix]( [param:Matrix4 m], [param:String order], [param:Boolean update] )</h3>
<h3>[method:Euler setFromRotationMatrix]( [param:Matrix4 m], [param:String order] )</h3>
<p>
[page:Matrix4 m] - a [page:Matrix4] of which the upper 3x3 of matrix is a pure
[link:https://en.wikipedia.org/wiki/Rotation_matrix rotation matrix] (i.e. unscaled).<br />
[page:.order order] - (optional) a string representing the order that the rotations are applied.<br />
[page:Boolean update] - (optional) whether to call [page:.onChangeCallback onChangeCallback]() after applying
the matrix.<br /><br />

Sets the angles of this euler transform from a pure rotation matrix based on the orientation
specified by order.
</p>

<h3>[method:Euler setFromQuaternion]( [param:Quaternion q], [param:String order], [param:Boolean update] )</h3>
<h3>[method:Euler setFromQuaternion]( [param:Quaternion q], [param:String order] )</h3>
<p>
[page:Quaternion q] - a normalized quaternion.<br />
[page:.order order] - (optional) a string representing the order that the rotations are applied.<br />
[page:Boolean update] - (optional) whether to call [page:.onChangeCallback onChangeCallback]() after applying
the matrix.<br /><br />

Sets the angles of this euler transform from a normalized quaternion based on the orientation
specified by [page:.order order].
Expand All @@ -163,8 +139,7 @@ <h3>[method:Euler setFromVector3]( [param:Vector3 vector], [param:String order]
[page:Vector3 vector] - [page:Vector3].<br />
[page:.order order] - (optional) a string representing the order that the rotations are applied.<br /><br />

Set the [page:.x x], [page:.y y] and [page:.z z], and optionally update the [page:.order order]. [page:.onChangeCallback onChangeCallback]()
is called after these changes are made.
Set the [page:.x x], [page:.y y] and [page:.z z], and optionally update the [page:.order order].
</p>


Expand Down
30 changes: 0 additions & 30 deletions docs/api/en/math/Quaternion.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,12 @@ <h3>[property:Boolean isQuaternion]</h3>
</p>

<h3>[property:Float x]</h3>
<p>Changing this property will result in [page:.onChangeCallback onChangeCallback] being called.</p>

<h3>[property:Float y]</h3>
<p>Changing this property will result in [page:.onChangeCallback onChangeCallback] being called.</p>

<h3>[property:Float z]</h3>
<p>Changing this property will result in [page:.onChangeCallback onChangeCallback] being called.</p>

<h3>[property:Float w]</h3>
<p>Changing this property will result in [page:.onChangeCallback onChangeCallback] being called.</p>


<h2>Methods</h2>
Expand Down Expand Up @@ -146,32 +142,6 @@ <h3>[method:Quaternion multiplyQuaternions]( [param:Quaternion a], [param:Quater
Adapted from the method outlined [link:http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/code/index.htm here].
</p>

<h3>[method:Quaternion onChange]( [param:Function onChangeCallback] )</h3>
<p>Sets the [page:.onChangeCallback onChangeCallback]() method.</p>

<h3>[method:Quaternion onChangeCallback]( )</h3>
<p>
This function is called whenever any of the following occurs:
<ul>
<li>
The [page:.x x], [page:.y y], [page:.z z] or
[page:.w w] properties are changed.
</li>
<li>
The [page:.set set](), [page:.copy copy](), [page:.clone clone](),
[page:.setFromAxisAngle setFromAxisAngle](), [page:.setFromRotationMatrix setFromRotationMatrix](),
[page:.conjugate conjugate](), [page:.normalize normalize](),
[page:.multiplyQuaternions multiplyQuaternions](), [page:.slerp slerp]() or [page:.fromArray fromArray]()
functions are called.
</li>
<li>
[page:.setFromEuler setFromEuler]() function is called with its *update* argument not set to false.
</li>
</ul>
By default it is the empty function, however you can change it if needed using [page:.onChange onChange]( [page:Function onChangeCallback] ).
</p>


<h3>[method:Quaternion premultiply]( [param:Quaternion q] )</h3>
<p>Pre-multiplies this quaternion by [page:Quaternion q].</p>

Expand Down
2 changes: 1 addition & 1 deletion examples/webgl_interactive_cubes_gpu.html
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
scale.y = Math.random() * 200 + 100;
scale.z = Math.random() * 200 + 100;

quaternion.setFromEuler( rotation, false );
quaternion.setFromEuler( rotation );
matrix.compose( position, quaternion, scale );

geometry.applyMatrix( matrix );
Expand Down
2 changes: 1 addition & 1 deletion examples/webgl_interactive_instances_gpu.html
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@
rotation.y = Math.random() * 2 * Math.PI;
rotation.z = Math.random() * 2 * Math.PI;

quaternion.setFromEuler( rotation, false );
quaternion.setFromEuler( rotation );

scale.x = scale.y = scale.z = Math.random() * 1;

Expand Down
2 changes: 1 addition & 1 deletion examples/webgl_postprocessing_crossfade.html
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
rotation.x = Math.random() * 2 * Math.PI;
rotation.y = Math.random() * 2 * Math.PI;
rotation.z = Math.random() * 2 * Math.PI;
quaternion.setFromEuler( rotation, false );
quaternion.setFromEuler( rotation );

scale.x = Math.random() * 200 + 100;

Expand Down
4 changes: 2 additions & 2 deletions src/core/Object3D.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ function Object3D() {

}

rotation.onChange( onRotationChange );
quaternion.onChange( onQuaternionChange );
rotation._onChange( onRotationChange );
quaternion._onChange( onQuaternionChange );

Object.defineProperties( this, {
position: {
Expand Down
4 changes: 2 additions & 2 deletions src/math/Euler.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ export class Euler {
y: number;
z: number;
order: string;
onChangeCallback: Function;
_onChangeCallback: Function;

set( x: number, y: number, z: number, order?: string ): Euler;
clone(): this;
Expand All @@ -173,7 +173,7 @@ export class Euler {
fromArray( xyzo: any[] ): Euler;
toArray( array?: number[], offset?: number ): number[];
toVector3( optionalResult?: Vector3 ): Vector3;
onChange( callback: Function ): this;
_onChange( callback: Function ): this;

static RotationOrders: string[];
static DefaultOrder: string;
Expand Down
22 changes: 11 additions & 11 deletions src/math/Euler.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Object.defineProperties( Euler.prototype, {
set: function ( value ) {

this._x = value;
this.onChangeCallback();
this._onChangeCallback();

}

Expand All @@ -52,7 +52,7 @@ Object.defineProperties( Euler.prototype, {
set: function ( value ) {

this._y = value;
this.onChangeCallback();
this._onChangeCallback();

}

Expand All @@ -69,7 +69,7 @@ Object.defineProperties( Euler.prototype, {
set: function ( value ) {

this._z = value;
this.onChangeCallback();
this._onChangeCallback();

}

Expand All @@ -86,7 +86,7 @@ Object.defineProperties( Euler.prototype, {
set: function ( value ) {

this._order = value;
this.onChangeCallback();
this._onChangeCallback();

}

Expand All @@ -105,7 +105,7 @@ Object.assign( Euler.prototype, {
this._z = z;
this._order = order || this._order;

this.onChangeCallback();
this._onChangeCallback();

return this;

Expand All @@ -124,7 +124,7 @@ Object.assign( Euler.prototype, {
this._z = euler._z;
this._order = euler._order;

this.onChangeCallback();
this._onChangeCallback();

return this;

Expand Down Expand Up @@ -247,7 +247,7 @@ Object.assign( Euler.prototype, {

this._order = order;

if ( update !== false ) this.onChangeCallback();
if ( update !== false ) this._onChangeCallback();

return this;

Expand Down Expand Up @@ -302,7 +302,7 @@ Object.assign( Euler.prototype, {
this._z = array[ 2 ];
if ( array[ 3 ] !== undefined ) this._order = array[ 3 ];

this.onChangeCallback();
this._onChangeCallback();

return this;

Expand Down Expand Up @@ -336,15 +336,15 @@ Object.assign( Euler.prototype, {

},

onChange: function ( callback ) {
_onChange: function ( callback ) {

this.onChangeCallback = callback;
this._onChangeCallback = callback;

return this;

},

onChangeCallback: function () {}
_onChangeCallback: function () {}

} );

Expand Down
4 changes: 2 additions & 2 deletions src/math/Quaternion.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ export class Quaternion {
fromArray( xyzw: number[], offset?: number ): Quaternion;
toArray( xyzw?: number[], offset?: number ): number[];

onChange( callback: Function ): Quaternion;
onChangeCallback: Function;
_onChange( callback: Function ): Quaternion;
_onChangeCallback: Function;

/**
* Adapted from http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/slerp/.
Expand Down
Loading

0 comments on commit 1b544f0

Please sign in to comment.