Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Object3D: Updated static class properties to ALL_CAPS #25188

Merged
merged 3 commits into from
Jan 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions docs/api/en/core/Object3D.html
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ <h3>[property:Matrix4 matrix]</h3>
<h3>[property:Boolean matrixAutoUpdate]</h3>
<p>
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_MATRIX_AUTO_UPDATE] (true).
</p>

<h3>[property:Matrix4 matrixWorld]</h3>
Expand Down Expand Up @@ -169,7 +169,7 @@ <h3>[property:Vector3 scale]</h3>
<h3>[property:Vector3 up]</h3>
<p>
This is used by the [page:.lookAt lookAt] method, for example, to determine the orientation of the result.<br />
Default is [page:Object3D.DefaultUp] - that is, `( 0, 1, 0 )`.
Default is [page:Object3D.DEFAULT_UP] - that is, `( 0, 1, 0 )`.
</p>

<h3>[property:Object userData]</h3>
Expand All @@ -193,20 +193,20 @@ <h3>[property:Boolean visible]</h3>
<h2>Static Properties</h2>
<p>
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_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).
</p>

<h3>[property:Vector3 DefaultUp]</h3>
<h3>[property:Vector3 DEFAULT_UP]</h3>
<p>
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).<br />
Set to ( 0, 1, 0 ) by default.
</p>

<h3>[property:Boolean DefaultMatrixAutoUpdate]</h3>
<h3>[property:Boolean DEFAULT_MATRIX_AUTO_UPDATE]</h3>
<p>
The default setting for [page:.matrixAutoUpdate matrixAutoUpdate] for newly created Object3Ds.<br />

Expand Down
2 changes: 1 addition & 1 deletion docs/api/en/lights/DirectionalLight.html
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ <h3>[property:Boolean isDirectionalLight]</h3>

<h3>[property:Vector3 position]</h3>
<p>
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.
</p>

<h3>[property:DirectionalLightShadow shadow]</h3>
Expand Down
2 changes: 1 addition & 1 deletion docs/api/en/lights/HemisphereLight.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ <h3>[property:Boolean isHemisphereLight]</h3>

<h3>[property:Vector3 position]</h3>
<p>
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.
</p>


Expand Down
2 changes: 1 addition & 1 deletion docs/api/en/lights/SpotLight.html
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ <h3>[property:Float penumbra]</h3>

<h3>[property:Vector3 position]</h3>
<p>
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.
</p>

<h3>[property:Float power]</h3>
Expand Down
2 changes: 1 addition & 1 deletion examples/webgl_loader_3dm.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
12 changes: 6 additions & 6 deletions src/core/Object3D.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -97,10 +97,10 @@ class Object3D extends EventDispatcher {
this.matrix = new Matrix4();
this.matrixWorld = new Matrix4();

this.matrixAutoUpdate = Object3D.DefaultMatrixAutoUpdate;
this.matrixAutoUpdate = Object3D.DEFAULT_MATRIX_AUTO_UPDATE;
this.matrixWorldNeedsUpdate = false;

this.matrixWorldAutoUpdate = Object3D.DefaultMatrixWorldAutoUpdate; // checked by the renderer
this.matrixWorldAutoUpdate = Object3D.DEFAULT_MATRIX_WORLD_AUTO_UPDATE; // checked by the renderer

this.layers = new Layers();
this.visible = true;
Expand Down Expand Up @@ -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_MATRIX_AUTO_UPDATE = true;
Object3D.DEFAULT_MATRIX_WORLD_AUTO_UPDATE = true;

export { Object3D };
2 changes: 1 addition & 1 deletion src/lights/DirectionalLight.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/lights/HemisphereLight.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
2 changes: 1 addition & 1 deletion src/lights/SpotLight.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
28 changes: 14 additions & 14 deletions test/unit/src/core/Object3D.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -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_MATRIX_AUTO_UPDATE', ( assert ) => {

const currentDefaultMatrixAutoUpdate = Object3D.DefaultMatrixAutoUpdate;
const currentDefaultMatrixAutoUpdate = Object3D.DEFAULT_MATRIX_AUTO_UPDATE;

try {

assert.equal( currentDefaultMatrixAutoUpdate, true, 'default DefaultMatrixAutoUpdate 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.DefaultMatrixAutoUpdate = true' );
assert.equal( object.matrixAutoUpdate, true, '.matrixAutoUpdate of a new object inherits Object3D.DEFAULT_MATRIX_AUTO_UPDATE = true' );

Object3D.DefaultMatrixAutoUpdate = false;
Object3D.DEFAULT_MATRIX_AUTO_UPDATE = 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_MATRIX_AUTO_UPDATE = false' );

} finally {

Object3D.DefaultMatrixAutoUpdate = currentDefaultMatrixAutoUpdate;
Object3D.DEFAULT_MATRIX_AUTO_UPDATE = currentDefaultMatrixAutoUpdate;

}

Expand Down