From b8e84820a9f5a68f4b48f2a1c47c2e7487e7cbeb Mon Sep 17 00:00:00 2001 From: WestLangley Date: Fri, 23 Dec 2022 14:33:40 -0500 Subject: [PATCH 1/2] Updated static class properties to ALL_CAPS --- docs/api/en/core/Object3D.html | 10 ++++----- docs/api/en/lights/DirectionalLight.html | 2 +- docs/api/en/lights/HemisphereLight.html | 2 +- docs/api/en/lights/SpotLight.html | 2 +- examples/webgl_loader_3dm.html | 2 +- src/core/Object3D.js | 12 +++++----- src/lights/DirectionalLight.js | 2 +- src/lights/HemisphereLight.js | 2 +- src/lights/SpotLight.js | 2 +- test/unit/src/core/Object3D.tests.js | 28 ++++++++++++------------ 10 files changed, 32 insertions(+), 32 deletions(-) diff --git a/docs/api/en/core/Object3D.html b/docs/api/en/core/Object3D.html index c13b061691b3fc..d04ef50fb1d497 100644 --- a/docs/api/en/core/Object3D.html +++ b/docs/api/en/core/Object3D.html @@ -75,7 +75,7 @@

[property:Matrix4 matrix]

[property:Boolean matrixAutoUpdate]

When this is set, it calculates the matrix of position, (rotation or quaternion) and - scale every frame and also recalculates the matrixWorld property. Default is [page:Object3D.DefaultMatrixAutoUpdate] (true). + scale every frame and also recalculates the matrixWorld property. Default is [page:Object3D.DEFAULT_MATRIXAUTOUPDATE] (true).

[property:Matrix4 matrixWorld]

@@ -169,7 +169,7 @@

[property:Vector3 scale]

[property:Vector3 up]

This is used by the [page:.lookAt lookAt] method, for example, to determine the orientation of the result.
- Default is [page:Object3D.DefaultUp] - that is, `( 0, 1, 0 )`. + Default is [page:Object3D.DEFAULT_UP] - that is, `( 0, 1, 0 )`.

[property:Object userData]

@@ -193,20 +193,20 @@

[property:Boolean visible]

Static Properties

Static properties and methods are defined per class rather than per instance of that class. - This means that changing [page:Object3D.DefaultUp] or [page:Object3D.DefaultMatrixAutoUpdate] + This means that changing [page:Object3D.DEFAULT_UP] or [page:Object3D.DEFAULT_MATRIXAUTOUPDATE] will change the values of [page:.up up] and [page:.matrixAutoUpdate matrixAutoUpdate] for `every` instance of Object3D (or derived classes) created after the change has been made (already created Object3Ds will not be affected).

-

[property:Vector3 DefaultUp]

+

[property:Vector3 DEFAULT_UP]

The default [page:.up up] direction for objects, also used as the default position for [page:DirectionalLight], [page:HemisphereLight] and [page:Spotlight] (which creates lights shining from the top down).
Set to ( 0, 1, 0 ) by default.

-

[property:Boolean DefaultMatrixAutoUpdate]

+

[property:Boolean DEFAULT_MATRIXAUTOUPDATE]

The default setting for [page:.matrixAutoUpdate matrixAutoUpdate] for newly created Object3Ds.
diff --git a/docs/api/en/lights/DirectionalLight.html b/docs/api/en/lights/DirectionalLight.html index 3abf6627806d0a..1eee76d0374beb 100644 --- a/docs/api/en/lights/DirectionalLight.html +++ b/docs/api/en/lights/DirectionalLight.html @@ -81,7 +81,7 @@

[property:Boolean isDirectionalLight]

[property:Vector3 position]

- This is set equal to [page:Object3D.DefaultUp] (0, 1, 0), so that the light shines from the top down. + This is set equal to [page:Object3D.DEFAULT_UP] (0, 1, 0), so that the light shines from the top down.

[property:DirectionalLightShadow shadow]

diff --git a/docs/api/en/lights/HemisphereLight.html b/docs/api/en/lights/HemisphereLight.html index a4d11031367010..fd0c82e544a7f2 100644 --- a/docs/api/en/lights/HemisphereLight.html +++ b/docs/api/en/lights/HemisphereLight.html @@ -69,7 +69,7 @@

[property:Boolean isHemisphereLight]

[property:Vector3 position]

- This is set equal to [page:Object3D.DefaultUp] (0, 1, 0), so that the light shines from the top down. + This is set equal to [page:Object3D.DEFAULT_UP] (0, 1, 0), so that the light shines from the top down.

diff --git a/docs/api/en/lights/SpotLight.html b/docs/api/en/lights/SpotLight.html index bc3932bcc26c27..103bffd75901e6 100644 --- a/docs/api/en/lights/SpotLight.html +++ b/docs/api/en/lights/SpotLight.html @@ -126,7 +126,7 @@

[property:Float penumbra]

[property:Vector3 position]

- This is set equal to [page:Object3D.DefaultUp] (0, 1, 0), so that the light shines from the top down. + This is set equal to [page:Object3D.DEFAULT_UP] (0, 1, 0), so that the light shines from the top down.

[property:Float power]

diff --git a/examples/webgl_loader_3dm.html b/examples/webgl_loader_3dm.html index 7684027872c689..6dfc75ee147742 100644 --- a/examples/webgl_loader_3dm.html +++ b/examples/webgl_loader_3dm.html @@ -62,7 +62,7 @@ function init() { - THREE.Object3D.DefaultUp = new THREE.Vector3( 0, 0, 1 ); + THREE.Object3D.DEFAULT_UP.set( 0, 0, 1 ); renderer = new THREE.WebGLRenderer( { antialias: true } ); renderer.setPixelRatio( window.devicePixelRatio ); diff --git a/src/core/Object3D.js b/src/core/Object3D.js index 5c64f0a6ccb464..7fd4ad7387b4a0 100644 --- a/src/core/Object3D.js +++ b/src/core/Object3D.js @@ -43,7 +43,7 @@ class Object3D extends EventDispatcher { this.parent = null; this.children = []; - this.up = Object3D.DefaultUp.clone(); + this.up = Object3D.DEFAULT_UP.clone(); const position = new Vector3(); const rotation = new Euler(); @@ -97,10 +97,10 @@ class Object3D extends EventDispatcher { this.matrix = new Matrix4(); this.matrixWorld = new Matrix4(); - this.matrixAutoUpdate = Object3D.DefaultMatrixAutoUpdate; + this.matrixAutoUpdate = Object3D.DEFAULT_MATRIXAUTOUPDATE; this.matrixWorldNeedsUpdate = false; - this.matrixWorldAutoUpdate = Object3D.DefaultMatrixWorldAutoUpdate; // checked by the renderer + this.matrixWorldAutoUpdate = Object3D.DEFAULT_MATRIXWORLDAUTOUPDATE; // checked by the renderer this.layers = new Layers(); this.visible = true; @@ -963,8 +963,8 @@ class Object3D extends EventDispatcher { } -Object3D.DefaultUp = /*@__PURE__*/ new Vector3( 0, 1, 0 ); -Object3D.DefaultMatrixAutoUpdate = true; -Object3D.DefaultMatrixWorldAutoUpdate = true; +Object3D.DEFAULT_UP = /*@__PURE__*/ new Vector3( 0, 1, 0 ); +Object3D.DEFAULT_MATRIXAUTOUPDATE = true; +Object3D.DEFAULT_MATRIXWORLDAUTOUPDATE = true; export { Object3D }; diff --git a/src/lights/DirectionalLight.js b/src/lights/DirectionalLight.js index 7031c8bbacfcfa..11c31cb745cad8 100644 --- a/src/lights/DirectionalLight.js +++ b/src/lights/DirectionalLight.js @@ -12,7 +12,7 @@ class DirectionalLight extends Light { this.type = 'DirectionalLight'; - this.position.copy( Object3D.DefaultUp ); + this.position.copy( Object3D.DEFAULT_UP ); this.updateMatrix(); this.target = new Object3D(); diff --git a/src/lights/HemisphereLight.js b/src/lights/HemisphereLight.js index abd3828cabf641..014907f811a36b 100644 --- a/src/lights/HemisphereLight.js +++ b/src/lights/HemisphereLight.js @@ -12,7 +12,7 @@ class HemisphereLight extends Light { this.type = 'HemisphereLight'; - this.position.copy( Object3D.DefaultUp ); + this.position.copy( Object3D.DEFAULT_UP ); this.updateMatrix(); this.groundColor = new Color( groundColor ); diff --git a/src/lights/SpotLight.js b/src/lights/SpotLight.js index 49ac6a081211a7..37a464c4463f60 100644 --- a/src/lights/SpotLight.js +++ b/src/lights/SpotLight.js @@ -12,7 +12,7 @@ class SpotLight extends Light { this.type = 'SpotLight'; - this.position.copy( Object3D.DefaultUp ); + this.position.copy( Object3D.DEFAULT_UP ); this.updateMatrix(); this.target = new Object3D(); diff --git a/test/unit/src/core/Object3D.tests.js b/test/unit/src/core/Object3D.tests.js index 896cce93df7847..81ff4d468a7c44 100644 --- a/test/unit/src/core/Object3D.tests.js +++ b/test/unit/src/core/Object3D.tests.js @@ -71,54 +71,54 @@ export default QUnit.module( 'Core', () => { } ); // STATIC STUFF - QUnit.test( 'DefaultUp', ( assert ) => { + QUnit.test( 'DEFAULT_UP', ( assert ) => { - const currentDefaultUp = new Vector3().copy( Object3D.DefaultUp ); + const currentDefaultUp = new Vector3().copy( Object3D.DEFAULT_UP ); const v = new Vector3(); try { - assert.deepEqual( Object3D.DefaultUp, v.set( 0, 1, 0 ), 'default DefaultUp is Y-up' ); + assert.deepEqual( Object3D.DEFAULT_UP, v.set( 0, 1, 0 ), 'default DEFAULT_UP is Y-up' ); const object = new Object3D(); - assert.deepEqual( object.up, v.set( 0, 1, 0 ), '.up of a new object inherits Object3D.DefaultUp = Y-up' ); + assert.deepEqual( object.up, v.set( 0, 1, 0 ), '.up of a new object inherits Object3D.DEFAULT_UP = Y-up' ); - Object3D.DefaultUp.set( 0, 0, 1 ); + Object3D.DEFAULT_UP.set( 0, 0, 1 ); const object2 = new Object3D(); - assert.deepEqual( object2.up, v.set( 0, 0, 1 ), '.up of a new object inherits Object3D.DefaultUp = Z-up' ); + assert.deepEqual( object2.up, v.set( 0, 0, 1 ), '.up of a new object inherits Object3D.DEFAULT_UP = Z-up' ); } finally { - Object3D.DefaultUp.copy( currentDefaultUp ); + Object3D.DEFAULT_UP.copy( currentDefaultUp ); } } ); - QUnit.test( 'DefaultMatrixAutoUpdate', ( assert ) => { + QUnit.test( 'DEFAULT_MATRIXAUTOUPDATE', ( assert ) => { - const currentDefaultMatrixAutoUpdate = Object3D.DefaultMatrixAutoUpdate; + const currentDefaultMatrixAutoUpdate = Object3D.DEFAULT_MATRIXAUTOUPDATE; try { - assert.equal( currentDefaultMatrixAutoUpdate, true, 'default DefaultMatrixAutoUpdate is true' ); + assert.equal( currentDefaultMatrixAutoUpdate, true, 'default DEFAULT_MATRIXAUTOUPDATE is true' ); const object = new Object3D(); - assert.equal( object.matrixAutoUpdate, true, '.matrixAutoUpdate of a new object inherits Object3D.DefaultMatrixAutoUpdate = true' ); + assert.equal( object.matrixAutoUpdate, true, '.matrixAutoUpdate of a new object inherits Object3D.DEFAULT_MATRIXAUTOUPDATE = true' ); - Object3D.DefaultMatrixAutoUpdate = false; + Object3D.DEFAULT_MATRIXAUTOUPDATE = false; const object2 = new Object3D(); - assert.equal( object2.matrixAutoUpdate, false, '.matrixAutoUpdate of a new object inherits Object3D.DefaultMatrixAutoUpdate = false' ); + assert.equal( object2.matrixAutoUpdate, false, '.matrixAutoUpdate of a new object inherits Object3D.DEFAULT_MATRIXAUTOUPDATE = false' ); } finally { - Object3D.DefaultMatrixAutoUpdate = currentDefaultMatrixAutoUpdate; + Object3D.DEFAULT_MATRIXAUTOUPDATE = currentDefaultMatrixAutoUpdate; } From de677ea57865118c2992a7786d6505ee04b24840 Mon Sep 17 00:00:00 2001 From: WestLangley Date: Sun, 1 Jan 2023 20:33:56 -0500 Subject: [PATCH 2/2] Updated nomenclature --- docs/api/en/core/Object3D.html | 6 +++--- src/core/Object3D.js | 8 ++++---- test/unit/src/core/Object3D.tests.js | 14 +++++++------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/docs/api/en/core/Object3D.html b/docs/api/en/core/Object3D.html index d04ef50fb1d497..16acabfd024200 100644 --- a/docs/api/en/core/Object3D.html +++ b/docs/api/en/core/Object3D.html @@ -75,7 +75,7 @@

[property:Matrix4 matrix]

[property:Boolean matrixAutoUpdate]

When this is set, it calculates the matrix of position, (rotation or quaternion) and - scale every frame and also recalculates the matrixWorld property. Default is [page:Object3D.DEFAULT_MATRIXAUTOUPDATE] (true). + scale every frame and also recalculates the matrixWorld property. Default is [page:Object3D.DEFAULT_MATRIX_AUTO_UPDATE] (true).

[property:Matrix4 matrixWorld]

@@ -193,7 +193,7 @@

[property:Boolean visible]

Static Properties

Static properties and methods are defined per class rather than per instance of that class. - This means that changing [page:Object3D.DEFAULT_UP] or [page:Object3D.DEFAULT_MATRIXAUTOUPDATE] + This means that changing [page:Object3D.DEFAULT_UP] or [page:Object3D.DEFAULT_MATRIX_AUTO_UPDATE] will change the values of [page:.up up] and [page:.matrixAutoUpdate matrixAutoUpdate] for `every` instance of Object3D (or derived classes) created after the change has been made (already created Object3Ds will not be affected). @@ -206,7 +206,7 @@

[property:Vector3 DEFAULT_UP]

Set to ( 0, 1, 0 ) by default.

-

[property:Boolean DEFAULT_MATRIXAUTOUPDATE]

+

[property:Boolean DEFAULT_MATRIX_AUTO_UPDATE]

The default setting for [page:.matrixAutoUpdate matrixAutoUpdate] for newly created Object3Ds.
diff --git a/src/core/Object3D.js b/src/core/Object3D.js index 7fd4ad7387b4a0..37c0cc2d9e9be8 100644 --- a/src/core/Object3D.js +++ b/src/core/Object3D.js @@ -97,10 +97,10 @@ class Object3D extends EventDispatcher { this.matrix = new Matrix4(); this.matrixWorld = new Matrix4(); - this.matrixAutoUpdate = Object3D.DEFAULT_MATRIXAUTOUPDATE; + this.matrixAutoUpdate = Object3D.DEFAULT_MATRIX_AUTO_UPDATE; this.matrixWorldNeedsUpdate = false; - this.matrixWorldAutoUpdate = Object3D.DEFAULT_MATRIXWORLDAUTOUPDATE; // checked by the renderer + this.matrixWorldAutoUpdate = Object3D.DEFAULT_MATRIX_WORLD_AUTO_UPDATE; // checked by the renderer this.layers = new Layers(); this.visible = true; @@ -964,7 +964,7 @@ class Object3D extends EventDispatcher { } Object3D.DEFAULT_UP = /*@__PURE__*/ new Vector3( 0, 1, 0 ); -Object3D.DEFAULT_MATRIXAUTOUPDATE = true; -Object3D.DEFAULT_MATRIXWORLDAUTOUPDATE = true; +Object3D.DEFAULT_MATRIX_AUTO_UPDATE = true; +Object3D.DEFAULT_MATRIX_WORLD_AUTO_UPDATE = true; export { Object3D }; diff --git a/test/unit/src/core/Object3D.tests.js b/test/unit/src/core/Object3D.tests.js index 81ff4d468a7c44..19ab72f3ffe2a9 100644 --- a/test/unit/src/core/Object3D.tests.js +++ b/test/unit/src/core/Object3D.tests.js @@ -98,27 +98,27 @@ export default QUnit.module( 'Core', () => { } ); - QUnit.test( 'DEFAULT_MATRIXAUTOUPDATE', ( assert ) => { + QUnit.test( 'DEFAULT_MATRIX_AUTO_UPDATE', ( assert ) => { - const currentDefaultMatrixAutoUpdate = Object3D.DEFAULT_MATRIXAUTOUPDATE; + const currentDefaultMatrixAutoUpdate = Object3D.DEFAULT_MATRIX_AUTO_UPDATE; try { - assert.equal( currentDefaultMatrixAutoUpdate, true, 'default DEFAULT_MATRIXAUTOUPDATE is true' ); + assert.equal( currentDefaultMatrixAutoUpdate, true, 'default DEFAULT_MATRIX_AUTO_UPDATE is true' ); const object = new Object3D(); - assert.equal( object.matrixAutoUpdate, true, '.matrixAutoUpdate of a new object inherits Object3D.DEFAULT_MATRIXAUTOUPDATE = true' ); + assert.equal( object.matrixAutoUpdate, true, '.matrixAutoUpdate of a new object inherits Object3D.DEFAULT_MATRIX_AUTO_UPDATE = true' ); - Object3D.DEFAULT_MATRIXAUTOUPDATE = false; + Object3D.DEFAULT_MATRIX_AUTO_UPDATE = false; const object2 = new Object3D(); - assert.equal( object2.matrixAutoUpdate, false, '.matrixAutoUpdate of a new object inherits Object3D.DEFAULT_MATRIXAUTOUPDATE = false' ); + assert.equal( object2.matrixAutoUpdate, false, '.matrixAutoUpdate of a new object inherits Object3D.DEFAULT_MATRIX_AUTO_UPDATE = false' ); } finally { - Object3D.DEFAULT_MATRIXAUTOUPDATE = currentDefaultMatrixAutoUpdate; + Object3D.DEFAULT_MATRIX_AUTO_UPDATE = currentDefaultMatrixAutoUpdate; }