Skip to content

Commit 8492e25

Browse files
committed
fix: opt-out of default components rather than opt-in
1 parent 076d913 commit 8492e25

File tree

1 file changed

+25
-25
lines changed

1 file changed

+25
-25
lines changed

core/Node.js

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,14 @@ function Node () {
9595
this._transformID = null;
9696
this._sizeID = null;
9797

98-
if (this.constructor.INIT_DEFAULT_COMPONENTS) this._init();
98+
if (!this.constructor.NO_DEFAULT_COMPONENTS) this._init();
9999
}
100100

101101
Node.RELATIVE_SIZE = 0;
102102
Node.ABSOLUTE_SIZE = 1;
103103
Node.RENDER_SIZE = 2;
104104
Node.DEFAULT_SIZE = 0;
105-
Node.INIT_DEFAULT_COMPONENTS = true;
105+
Node.NO_DEFAULT_COMPONENTS = false;
106106

107107
/**
108108
* Protected method. Initializes a node with a default Transform and Size component
@@ -440,7 +440,7 @@ Node.prototype.getOpacity = function getOpacity () {
440440
* @return {Float32Array} An array representing the mount point.
441441
*/
442442
Node.prototype.getMountPoint = function getMountPoint () {
443-
if (this.constructor.INIT_DEFAULT_COMPONENTS)
443+
if (!this.constructor.NO_DEFAULT_COMPONENTS)
444444
return this.getComponent(this._transformID).getMountPoint();
445445
else if (this.isMounted())
446446
return TransformSystem.get(this.getLocation()).getMountPoint();
@@ -455,7 +455,7 @@ Node.prototype.getMountPoint = function getMountPoint () {
455455
* @return {Float32Array} An array representing the align.
456456
*/
457457
Node.prototype.getAlign = function getAlign () {
458-
if (this.constructor.INIT_DEFAULT_COMPONENTS)
458+
if (!this.constructor.NO_DEFAULT_COMPONENTS)
459459
return this.getComponent(this._transformID).getAlign();
460460
else if (this.isMounted())
461461
return TransformSystem.get(this.getLocation()).getAlign();
@@ -470,7 +470,7 @@ Node.prototype.getAlign = function getAlign () {
470470
* @return {Float32Array} An array representing the origin.
471471
*/
472472
Node.prototype.getOrigin = function getOrigin () {
473-
if (this.constructor.INIT_DEFAULT_COMPONENTS)
473+
if (!this.constructor.NO_DEFAULT_COMPONENTS)
474474
return this.getComponent(this._transformID).getOrigin();
475475
else if (this.isMounted())
476476
return TransformSystem.get(this.getLocation()).getOrigin();
@@ -485,7 +485,7 @@ Node.prototype.getOrigin = function getOrigin () {
485485
* @return {Float32Array} An array representing the position.
486486
*/
487487
Node.prototype.getPosition = function getPosition () {
488-
if (this.constructor.INIT_DEFAULT_COMPONENTS)
488+
if (!this.constructor.NO_DEFAULT_COMPONENTS)
489489
return this.getComponent(this._transformID).getPosition();
490490
else if (this.isMounted())
491491
return TransformSystem.get(this.getLocation()).getPosition();
@@ -500,7 +500,7 @@ Node.prototype.getPosition = function getPosition () {
500500
* @return {Float32Array} an array of four values, showing the rotation as a quaternion
501501
*/
502502
Node.prototype.getRotation = function getRotation () {
503-
if (this.constructor.INIT_DEFAULT_COMPONENTS)
503+
if (!this.constructor.NO_DEFAULT_COMPONENTS)
504504
return this.getComponent(this._transformID).getRotation();
505505
else if (this.isMounted())
506506
return TransformSystem.get(this.getLocation()).getRotation();
@@ -515,7 +515,7 @@ Node.prototype.getRotation = function getRotation () {
515515
* @return {Float32Array} an array showing the current scale vector
516516
*/
517517
Node.prototype.getScale = function getScale () {
518-
if (this.constructor.INIT_DEFAULT_COMPONENTS)
518+
if (!this.constructor.NO_DEFAULT_COMPONENTS)
519519
return this.getComponent(this._transformID).getScale();
520520
else if (this.isMounted())
521521
return TransformSystem.get(this.getLocation()).getScale();
@@ -530,7 +530,7 @@ Node.prototype.getScale = function getScale () {
530530
* @return {Float32Array} an array of numbers showing the current size mode
531531
*/
532532
Node.prototype.getSizeMode = function getSizeMode () {
533-
if (this.constructor.INIT_DEFAULT_COMPONENTS)
533+
if (!this.constructor.NO_DEFAULT_COMPONENTS)
534534
return this.getComponent(this._sizeID).getSizeMode();
535535
else if (this.isMounted())
536536
return SizeSystem.get(this.getLocation()).getSizeMode();
@@ -545,7 +545,7 @@ Node.prototype.getSizeMode = function getSizeMode () {
545545
* @return {Float32Array} a vector 3 showing the current proportional size
546546
*/
547547
Node.prototype.getProportionalSize = function getProportionalSize () {
548-
if (this.constructor.INIT_DEFAULT_COMPONENTS)
548+
if (!this.constructor.NO_DEFAULT_COMPONENTS)
549549
return this.getComponent(this._sizeID).getProportional();
550550
else if (this.isMounted())
551551
return SizeSystem.get(this.getLocation()).getProportional();
@@ -560,7 +560,7 @@ Node.prototype.getProportionalSize = function getProportionalSize () {
560560
* @return {Float32Array} a vector 3 showing the current differential size
561561
*/
562562
Node.prototype.getDifferentialSize = function getDifferentialSize () {
563-
if (this.constructor.INIT_DEFAULT_COMPONENTS)
563+
if (!this.constructor.NO_DEFAULT_COMPONENTS)
564564
return this.getComponent(this._sizeID).getDifferential();
565565
else if (this.isMounted())
566566
return SizeSystem.get(this.getLocation()).getDifferential();
@@ -575,7 +575,7 @@ Node.prototype.getDifferentialSize = function getDifferentialSize () {
575575
* @return {Float32Array} a vector 3 showing the current absolute size of the node
576576
*/
577577
Node.prototype.getAbsoluteSize = function getAbsoluteSize () {
578-
if (this.constructor.INIT_DEFAULT_COMPONENTS)
578+
if (!this.constructor.NO_DEFAULT_COMPONENTS)
579579
return this.getComponent(this._sizeID).getAbsolute();
580580
else if (this.isMounted())
581581
return SizeSystem.get(this.getLocation()).getAbsolute();
@@ -592,7 +592,7 @@ Node.prototype.getAbsoluteSize = function getAbsoluteSize () {
592592
* @return {Float32Array} a vector 3 showing the current render size
593593
*/
594594
Node.prototype.getRenderSize = function getRenderSize () {
595-
if (this.constructor.INIT_DEFAULT_COMPONENTS)
595+
if (!this.constructor.NO_DEFAULT_COMPONENTS)
596596
return this.getComponent(this._sizeID).getRender();
597597
else if (this.isMounted())
598598
return SizeSystem.get(this.getLocation()).getRender();
@@ -607,7 +607,7 @@ Node.prototype.getRenderSize = function getRenderSize () {
607607
* @return {Float32Array} a vector 3 of the final calculated side of the node
608608
*/
609609
Node.prototype.getSize = function getSize () {
610-
if (this.constructor.INIT_DEFAULT_COMPONENTS)
610+
if (!this.constructor.NO_DEFAULT_COMPONENTS)
611611
return this.getComponent(this._sizeID).get();
612612
else if (this.isMounted())
613613
return SizeSystem.get(this.getLocation()).get();
@@ -885,7 +885,7 @@ Node.prototype.hide = function hide () {
885885
* @return {Node} this
886886
*/
887887
Node.prototype.setAlign = function setAlign (x, y, z) {
888-
if (this.constructor.INIT_DEFAULT_COMPONENTS)
888+
if (!this.constructor.NO_DEFAULT_COMPONENTS)
889889
this.getComponent(this._transformID).setAlign(x, y, z);
890890
else if (this.isMounted())
891891
TransformSystem.get(this.getLocation()).setAlign(x, y, z);
@@ -906,7 +906,7 @@ Node.prototype.setAlign = function setAlign (x, y, z) {
906906
* @return {Node} this
907907
*/
908908
Node.prototype.setMountPoint = function setMountPoint (x, y, z) {
909-
if (this.constructor.INIT_DEFAULT_COMPONENTS)
909+
if (!this.constructor.NO_DEFAULT_COMPONENTS)
910910
this.getComponent(this._transformID).setMountPoint(x, y, z);
911911
else if (this.isMounted())
912912
TransformSystem.get(this.getLocation()).setMountPoint(x, y, z);
@@ -927,7 +927,7 @@ Node.prototype.setMountPoint = function setMountPoint (x, y, z) {
927927
* @return {Node} this
928928
*/
929929
Node.prototype.setOrigin = function setOrigin (x, y, z) {
930-
if (this.constructor.INIT_DEFAULT_COMPONENTS)
930+
if (!this.constructor.NO_DEFAULT_COMPONENTS)
931931
this.getComponent(this._transformID).setOrigin(x, y, z);
932932
else if (this.isMounted())
933933
TransformSystem.get(this.getLocation()).setOrigin(x, y, z);
@@ -948,7 +948,7 @@ Node.prototype.setOrigin = function setOrigin (x, y, z) {
948948
* @return {Node} this
949949
*/
950950
Node.prototype.setPosition = function setPosition (x, y, z) {
951-
if (this.constructor.INIT_DEFAULT_COMPONENTS)
951+
if (!this.constructor.NO_DEFAULT_COMPONENTS)
952952
this.getComponent(this._transformID).setPosition(x, y, z);
953953
else if (this.isMounted())
954954
TransformSystem.get(this.getLocation()).setPosition(x, y, z);
@@ -972,7 +972,7 @@ Node.prototype.setPosition = function setPosition (x, y, z) {
972972
* @return {Node} this
973973
*/
974974
Node.prototype.setRotation = function setRotation (x, y, z, w) {
975-
if (this.constructor.INIT_DEFAULT_COMPONENTS)
975+
if (!this.constructor.NO_DEFAULT_COMPONENTS)
976976
this.getComponent(this._transformID).setRotation(x, y, z, w);
977977
else if (this.isMounted())
978978
TransformSystem.get(this.getLocation()).setRotation(x, y, z, w);
@@ -993,7 +993,7 @@ Node.prototype.setRotation = function setRotation (x, y, z, w) {
993993
* @return {Node} this
994994
*/
995995
Node.prototype.setScale = function setScale (x, y, z) {
996-
if (this.constructor.INIT_DEFAULT_COMPONENTS)
996+
if (!this.constructor.NO_DEFAULT_COMPONENTS)
997997
this.getComponent(this._transformID).setScale(x, y, z);
998998
else if (this.isMounted())
999999
TransformSystem.get(this.getLocation()).setScale(x, y, z);
@@ -1054,7 +1054,7 @@ Node.prototype.setOpacity = function setOpacity (val) {
10541054
* @return {Node} this
10551055
*/
10561056
Node.prototype.setSizeMode = function setSizeMode (x, y, z) {
1057-
if (this.constructor.INIT_DEFAULT_COMPONENTS)
1057+
if (!this.constructor.NO_DEFAULT_COMPONENTS)
10581058
this.getComponent(this._sizeID).setSizeMode(x, y, z);
10591059
else if (this.isMounted())
10601060
SizeSystem.get(this.getLocation()).setSizeMode(x, y, z);
@@ -1076,7 +1076,7 @@ Node.prototype.setSizeMode = function setSizeMode (x, y, z) {
10761076
* @return {Node} this
10771077
*/
10781078
Node.prototype.setProportionalSize = function setProportionalSize (x, y, z) {
1079-
if (this.constructor.INIT_DEFAULT_COMPONENTS)
1079+
if (!this.constructor.NO_DEFAULT_COMPONENTS)
10801080
this.getComponent(this._sizeID).setProportional(x, y, z);
10811081
else if (this.isMounted())
10821082
SizeSystem.get(this.getLocation()).setProportional(x, y, z);
@@ -1103,7 +1103,7 @@ Node.prototype.setProportionalSize = function setProportionalSize (x, y, z) {
11031103
* @return {Node} this
11041104
*/
11051105
Node.prototype.setDifferentialSize = function setDifferentialSize (x, y, z) {
1106-
if (this.constructor.INIT_DEFAULT_COMPONENTS)
1106+
if (!this.constructor.NO_DEFAULT_COMPONENTS)
11071107
this.getComponent(this._sizeID).setDifferential(x, y, z);
11081108
else if (this.isMounted())
11091109
SizeSystem.get(this.getLocation()).setDifferential(x, y, z);
@@ -1123,7 +1123,7 @@ Node.prototype.setDifferentialSize = function setDifferentialSize (x, y, z) {
11231123
* @return {Node} this
11241124
*/
11251125
Node.prototype.setAbsoluteSize = function setAbsoluteSize (x, y, z) {
1126-
if (this.constructor.INIT_DEFAULT_COMPONENTS)
1126+
if (!this.constructor.NO_DEFAULT_COMPONENTS)
11271127
this.getComponent(this._sizeID).setAbsolute(x, y, z);
11281128
else if (this.isMounted())
11291129
SizeSystem.get(this.getLocation()).setAbsolute(x, y, z);
@@ -1208,7 +1208,7 @@ Node.prototype.mount = function mount (path) {
12081208
if (this.isMounted())
12091209
throw new Error('Node is already mounted at: ' + this.getLocation());
12101210

1211-
if (this.constructor.INIT_DEFAULT_COMPONENTS){
1211+
if (!this.constructor.NO_DEFAULT_COMPONENTS){
12121212
TransformSystem.registerTransformAtPath(path, this.getComponent(this._transformID));
12131213
SizeSystem.registerSizeAtPath(path, this.getComponent(this._sizeID));
12141214
}

0 commit comments

Comments
 (0)