From 1b544f048a63bdf4a9104441fa4566f79b24255a Mon Sep 17 00:00:00 2001 From: WestLangley Date: Mon, 10 Jun 2019 14:43:06 -0400 Subject: [PATCH] Make Euler and Quaternion .onChange() methods private --- docs/api/en/math/Euler.html | 33 +++--------------- docs/api/en/math/Quaternion.html | 30 ---------------- examples/webgl_interactive_cubes_gpu.html | 2 +- examples/webgl_interactive_instances_gpu.html | 2 +- examples/webgl_postprocessing_crossfade.html | 2 +- src/core/Object3D.js | 4 +-- src/math/Euler.d.ts | 4 +-- src/math/Euler.js | 22 ++++++------ src/math/Quaternion.d.ts | 4 +-- src/math/Quaternion.js | 34 +++++++++---------- 10 files changed, 41 insertions(+), 96 deletions(-) diff --git a/docs/api/en/math/Euler.html b/docs/api/en/math/Euler.html index 69e3aa42b3..6043a50da4 100644 --- a/docs/api/en/math/Euler.html +++ b/docs/api/en/math/Euler.html @@ -58,29 +58,21 @@ to the local 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).

- - If the order is changed, [page:.onChangeCallback onChangeCallback] will be called.

[property:Float x]

The current value of the x component.

- - If this is changed, [page:.onChangeCallback onChangeCallback] will be called.

[property:Float y]

The current value of the y component.

- - If this is changed, [page:.onChangeCallback onChangeCallback] will be called.

[property:Float z]

The current value of the z component.

- - If this is changed, [page:.onChangeCallback onChangeCallback] will be called.

Methods

@@ -104,18 +96,6 @@ Optionally assigns this euler's [page:.order order] to array[3].

-

[method:Euler onChange]( [param:Function onChangeCallback] )

-

- [page:Function onChangeCallback] - set the value of the onChangeCallback() function. -

- -

[method:Euler onChangeCallback]( )

-

- By default this is an empty function, however it can be set via [page:.onChange onChange]().
- 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). -

-

[method:Euler reorder]( [param:String newOrder] )

Resets the euler angle with a new order by creating a quaternion from this euler angle @@ -131,27 +111,23 @@ [page:.z z] - the angle of the z axis in radians.
[page:.order order] - (optional) a string representing the order that the rotations are applied.

- 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].

-

[method:Euler setFromRotationMatrix]( [param:Matrix4 m], [param:String order], [param:Boolean update] )

+

[method:Euler setFromRotationMatrix]( [param:Matrix4 m], [param:String order] )

[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).
[page:.order order] - (optional) a string representing the order that the rotations are applied.
- [page:Boolean update] - (optional) whether to call [page:.onChangeCallback onChangeCallback]() after applying - the matrix.

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

-

[method:Euler setFromQuaternion]( [param:Quaternion q], [param:String order], [param:Boolean update] )

+

[method:Euler setFromQuaternion]( [param:Quaternion q], [param:String order] )

[page:Quaternion q] - a normalized quaternion.
[page:.order order] - (optional) a string representing the order that the rotations are applied.
- [page:Boolean update] - (optional) whether to call [page:.onChangeCallback onChangeCallback]() after applying - the matrix.

Sets the angles of this euler transform from a normalized quaternion based on the orientation specified by [page:.order order]. @@ -163,8 +139,7 @@ [page:Vector3 vector] - [page:Vector3].
[page:.order order] - (optional) a string representing the order that the rotations are applied.

- 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].

diff --git a/docs/api/en/math/Quaternion.html b/docs/api/en/math/Quaternion.html index 3bb2cabc95..00d541bbbe 100644 --- a/docs/api/en/math/Quaternion.html +++ b/docs/api/en/math/Quaternion.html @@ -52,16 +52,12 @@

[property:Float x]

-

Changing this property will result in [page:.onChangeCallback onChangeCallback] being called.

[property:Float y]

-

Changing this property will result in [page:.onChangeCallback onChangeCallback] being called.

[property:Float z]

-

Changing this property will result in [page:.onChangeCallback onChangeCallback] being called.

[property:Float w]

-

Changing this property will result in [page:.onChangeCallback onChangeCallback] being called.

Methods

@@ -146,32 +142,6 @@ Adapted from the method outlined [link:http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/code/index.htm here].

-

[method:Quaternion onChange]( [param:Function onChangeCallback] )

-

Sets the [page:.onChangeCallback onChangeCallback]() method.

- -

[method:Quaternion onChangeCallback]( )

-

- This function is called whenever any of the following occurs: -

- By default it is the empty function, however you can change it if needed using [page:.onChange onChange]( [page:Function onChangeCallback] ). -

- -

[method:Quaternion premultiply]( [param:Quaternion q] )

Pre-multiplies this quaternion by [page:Quaternion q].

diff --git a/examples/webgl_interactive_cubes_gpu.html b/examples/webgl_interactive_cubes_gpu.html index 2c2a75a389..9f0d86da85 100644 --- a/examples/webgl_interactive_cubes_gpu.html +++ b/examples/webgl_interactive_cubes_gpu.html @@ -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 ); diff --git a/examples/webgl_interactive_instances_gpu.html b/examples/webgl_interactive_instances_gpu.html index 88bb6fa6cf..28fb134e91 100644 --- a/examples/webgl_interactive_instances_gpu.html +++ b/examples/webgl_interactive_instances_gpu.html @@ -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; diff --git a/examples/webgl_postprocessing_crossfade.html b/examples/webgl_postprocessing_crossfade.html index 3b8b068868..ec1aa89bd5 100644 --- a/examples/webgl_postprocessing_crossfade.html +++ b/examples/webgl_postprocessing_crossfade.html @@ -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; diff --git a/src/core/Object3D.js b/src/core/Object3D.js index 3fee8de649..6cfe12d438 100644 --- a/src/core/Object3D.js +++ b/src/core/Object3D.js @@ -49,8 +49,8 @@ function Object3D() { } - rotation.onChange( onRotationChange ); - quaternion.onChange( onQuaternionChange ); + rotation._onChange( onRotationChange ); + quaternion._onChange( onQuaternionChange ); Object.defineProperties( this, { position: { diff --git a/src/math/Euler.d.ts b/src/math/Euler.d.ts index b4d734b702..0e3a5472c1 100644 --- a/src/math/Euler.d.ts +++ b/src/math/Euler.d.ts @@ -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; @@ -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; diff --git a/src/math/Euler.js b/src/math/Euler.js index 8f8d3b6918..154b84f648 100644 --- a/src/math/Euler.js +++ b/src/math/Euler.js @@ -35,7 +35,7 @@ Object.defineProperties( Euler.prototype, { set: function ( value ) { this._x = value; - this.onChangeCallback(); + this._onChangeCallback(); } @@ -52,7 +52,7 @@ Object.defineProperties( Euler.prototype, { set: function ( value ) { this._y = value; - this.onChangeCallback(); + this._onChangeCallback(); } @@ -69,7 +69,7 @@ Object.defineProperties( Euler.prototype, { set: function ( value ) { this._z = value; - this.onChangeCallback(); + this._onChangeCallback(); } @@ -86,7 +86,7 @@ Object.defineProperties( Euler.prototype, { set: function ( value ) { this._order = value; - this.onChangeCallback(); + this._onChangeCallback(); } @@ -105,7 +105,7 @@ Object.assign( Euler.prototype, { this._z = z; this._order = order || this._order; - this.onChangeCallback(); + this._onChangeCallback(); return this; @@ -124,7 +124,7 @@ Object.assign( Euler.prototype, { this._z = euler._z; this._order = euler._order; - this.onChangeCallback(); + this._onChangeCallback(); return this; @@ -247,7 +247,7 @@ Object.assign( Euler.prototype, { this._order = order; - if ( update !== false ) this.onChangeCallback(); + if ( update !== false ) this._onChangeCallback(); return this; @@ -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; @@ -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 () {} } ); diff --git a/src/math/Quaternion.d.ts b/src/math/Quaternion.d.ts index c7c9e4f001..2138e3602e 100644 --- a/src/math/Quaternion.d.ts +++ b/src/math/Quaternion.d.ts @@ -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/. diff --git a/src/math/Quaternion.js b/src/math/Quaternion.js index 27e1ffedaf..ae66f9e220 100644 --- a/src/math/Quaternion.js +++ b/src/math/Quaternion.js @@ -101,7 +101,7 @@ Object.defineProperties( Quaternion.prototype, { set: function ( value ) { this._x = value; - this.onChangeCallback(); + this._onChangeCallback(); } @@ -118,7 +118,7 @@ Object.defineProperties( Quaternion.prototype, { set: function ( value ) { this._y = value; - this.onChangeCallback(); + this._onChangeCallback(); } @@ -135,7 +135,7 @@ Object.defineProperties( Quaternion.prototype, { set: function ( value ) { this._z = value; - this.onChangeCallback(); + this._onChangeCallback(); } @@ -152,7 +152,7 @@ Object.defineProperties( Quaternion.prototype, { set: function ( value ) { this._w = value; - this.onChangeCallback(); + this._onChangeCallback(); } @@ -171,7 +171,7 @@ Object.assign( Quaternion.prototype, { this._z = z; this._w = w; - this.onChangeCallback(); + this._onChangeCallback(); return this; @@ -190,7 +190,7 @@ Object.assign( Quaternion.prototype, { this._z = quaternion.z; this._w = quaternion.w; - this.onChangeCallback(); + this._onChangeCallback(); return this; @@ -265,7 +265,7 @@ Object.assign( Quaternion.prototype, { } - if ( update !== false ) this.onChangeCallback(); + if ( update !== false ) this._onChangeCallback(); return this; @@ -284,7 +284,7 @@ Object.assign( Quaternion.prototype, { this._z = axis.z * s; this._w = Math.cos( halfAngle ); - this.onChangeCallback(); + this._onChangeCallback(); return this; @@ -343,7 +343,7 @@ Object.assign( Quaternion.prototype, { } - this.onChangeCallback(); + this._onChangeCallback(); return this; @@ -426,7 +426,7 @@ Object.assign( Quaternion.prototype, { this._y *= - 1; this._z *= - 1; - this.onChangeCallback(); + this._onChangeCallback(); return this; @@ -472,7 +472,7 @@ Object.assign( Quaternion.prototype, { } - this.onChangeCallback(); + this._onChangeCallback(); return this; @@ -509,7 +509,7 @@ Object.assign( Quaternion.prototype, { this._z = qaz * qbw + qaw * qbz + qax * qby - qay * qbx; this._w = qaw * qbw - qax * qbx - qay * qby - qaz * qbz; - this.onChangeCallback(); + this._onChangeCallback(); return this; @@ -576,7 +576,7 @@ Object.assign( Quaternion.prototype, { this._y = ( y * ratioA + this._y * ratioB ); this._z = ( z * ratioA + this._z * ratioB ); - this.onChangeCallback(); + this._onChangeCallback(); return this; @@ -597,7 +597,7 @@ Object.assign( Quaternion.prototype, { this._z = array[ offset + 2 ]; this._w = array[ offset + 3 ]; - this.onChangeCallback(); + this._onChangeCallback(); return this; @@ -617,15 +617,15 @@ Object.assign( Quaternion.prototype, { }, - onChange: function ( callback ) { + _onChange: function ( callback ) { - this.onChangeCallback = callback; + this._onChangeCallback = callback; return this; }, - onChangeCallback: function () {} + _onChangeCallback: function () {} } ); -- GitLab