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

Replace defaultValue with ?? #12207

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 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
85 changes: 29 additions & 56 deletions packages/engine/Source/DataSources/BillboardGraphics.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,7 @@ function BillboardGraphics(options) {
this._disableDepthTestDistanceSubscription = undefined;
this._splitDirection = undefined;
this._splitDirectionSubscription = undefined;

this.merge(defaultValue(options, defaultValue.EMPTY_OBJECT));
this.merge(options ?? defaultValue.EMPTY_OBJECT);
}

Object.defineProperties(BillboardGraphics.prototype, {
Expand Down Expand Up @@ -303,7 +302,7 @@ Object.defineProperties(BillboardGraphics.prototype, {
* @type {Property|undefined}
*/
pixelOffsetScaleByDistance: createPropertyDescriptor(
"pixelOffsetScaleByDistance"
"pixelOffsetScaleByDistance",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like you have the wrong version of prettier installed or your editor configuration is wrong. These changes are distracting from the intended change of this PR (I'm working on the update in #12206). Can you do a npm install and make sure to run npm run prettier? Also probably worth checking that the pre-commit hook is working as intended so these can't even be committed.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay. I see the pre-commit hook. There was probably something I did wrong. But it looks like it is preventing commits now.

I ran prettier and merged the changes into my pull request.

image

),

/**
Expand All @@ -321,7 +320,7 @@ Object.defineProperties(BillboardGraphics.prototype, {
* @type {Property|undefined}
*/
distanceDisplayCondition: createPropertyDescriptor(
"distanceDisplayCondition"
"distanceDisplayCondition",
),

/**
Expand All @@ -331,7 +330,7 @@ Object.defineProperties(BillboardGraphics.prototype, {
* @type {Property|undefined}
*/
disableDepthTestDistance: createPropertyDescriptor(
"disableDepthTestDistance"
"disableDepthTestDistance",
),

/**
Expand Down Expand Up @@ -390,56 +389,30 @@ BillboardGraphics.prototype.merge = function (source) {
}
//>>includeEnd('debug');

this.show = defaultValue(this._show, source.show);
this.image = defaultValue(this._image, source.image);
this.scale = defaultValue(this._scale, source.scale);
this.pixelOffset = defaultValue(this._pixelOffset, source.pixelOffset);
this.eyeOffset = defaultValue(this._eyeOffset, source.eyeOffset);
this.horizontalOrigin = defaultValue(
this._horizontalOrigin,
source.horizontalOrigin
);
this.verticalOrigin = defaultValue(
this._verticalOrigin,
source.verticalOrigin
);
this.heightReference = defaultValue(
this._heightReference,
source.heightReference
);
this.color = defaultValue(this._color, source.color);
this.rotation = defaultValue(this._rotation, source.rotation);
this.alignedAxis = defaultValue(this._alignedAxis, source.alignedAxis);
this.sizeInMeters = defaultValue(this._sizeInMeters, source.sizeInMeters);
this.width = defaultValue(this._width, source.width);
this.height = defaultValue(this._height, source.height);
this.scaleByDistance = defaultValue(
this._scaleByDistance,
source.scaleByDistance
);
this.translucencyByDistance = defaultValue(
this._translucencyByDistance,
source.translucencyByDistance
);
this.pixelOffsetScaleByDistance = defaultValue(
this._pixelOffsetScaleByDistance,
source.pixelOffsetScaleByDistance
);
this.imageSubRegion = defaultValue(
this._imageSubRegion,
source.imageSubRegion
);
this.distanceDisplayCondition = defaultValue(
this._distanceDisplayCondition,
source.distanceDisplayCondition
);
this.disableDepthTestDistance = defaultValue(
this._disableDepthTestDistance,
source.disableDepthTestDistance
);
this.splitDirection = defaultValue(
this.splitDirection,
source.splitDirection
);
this.show = this._show ?? source.show;
this.image = this._image ?? source.image;
this.scale = this._scale ?? source.scale;
this.pixelOffset = this._pixelOffset ?? source.pixelOffset;
this.eyeOffset = this._eyeOffset ?? source.eyeOffset;
this.horizontalOrigin = this._horizontalOrigin ?? source.horizontalOrigin;
this.verticalOrigin = this._verticalOrigin ?? source.verticalOrigin;
this.heightReference = this._heightReference ?? source.heightReference;
this.color = this._color ?? source.color;
this.rotation = this._rotation ?? source.rotation;
this.alignedAxis = this._alignedAxis ?? source.alignedAxis;
this.sizeInMeters = this._sizeInMeters ?? source.sizeInMeters;
this.width = this._width ?? source.width;
this.height = this._height ?? source.height;
this.scaleByDistance = this._scaleByDistance ?? source.scaleByDistance;
this.translucencyByDistance =
this._translucencyByDistance ?? source.translucencyByDistance;
this.pixelOffsetScaleByDistance =
this._pixelOffsetScaleByDistance ?? source.pixelOffsetScaleByDistance;
this.imageSubRegion = this._imageSubRegion ?? source.imageSubRegion;
this.distanceDisplayCondition =
this._distanceDisplayCondition ?? source.distanceDisplayCondition;
this.disableDepthTestDistance =
this._disableDepthTestDistance ?? source.disableDepthTestDistance;
this.splitDirection = this.splitDirection ?? source.splitDirection;
};
export default BillboardGraphics;
8 changes: 4 additions & 4 deletions packages/engine/Source/DataSources/BoxGraphics.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function BoxGraphics(options) {
this._distanceDisplayCondition = undefined;
this._distanceDisplayConditionSubscription = undefined;

this.merge(defaultValue(options, defaultValue.EMPTY_OBJECT));
this.merge(options ?? defaultValue.EMPTY_OBJECT);
}

Object.defineProperties(BoxGraphics.prototype, {
Expand Down Expand Up @@ -153,7 +153,7 @@ Object.defineProperties(BoxGraphics.prototype, {
* @type {Property|undefined}
*/
distanceDisplayCondition: createPropertyDescriptor(
"distanceDisplayCondition"
"distanceDisplayCondition",
),
});

Expand Down Expand Up @@ -197,7 +197,7 @@ BoxGraphics.prototype.merge = function (source) {
this.dimensions = defaultValue(this.dimensions, source.dimensions);
this.heightReference = defaultValue(
this.heightReference,
source.heightReference
source.heightReference,
);
this.fill = defaultValue(this.fill, source.fill);
this.material = defaultValue(this.material, source.material);
Expand All @@ -207,7 +207,7 @@ BoxGraphics.prototype.merge = function (source) {
this.shadows = defaultValue(this.shadows, source.shadows);
this.distanceDisplayCondition = defaultValue(
this.distanceDisplayCondition,
source.distanceDisplayCondition
source.distanceDisplayCondition,
);
};
export default BoxGraphics;
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Cartesian3 from "../Core/Cartesian3.js";
import defaultValue from "../Core/defaultValue.js";
import defined from "../Core/defined.js";
import DeveloperError from "../Core/DeveloperError.js";
import Event from "../Core/Event.js";
Expand All @@ -20,7 +19,7 @@ import PositionProperty from "./PositionProperty.js";
function ConstantPositionProperty(value, referenceFrame) {
this._definitionChanged = new Event();
this._value = Cartesian3.clone(value);
this._referenceFrame = defaultValue(referenceFrame, ReferenceFrame.FIXED);
this._referenceFrame = referenceFrame ?? ReferenceFrame.FIXED;
}

Object.defineProperties(ConstantPositionProperty.prototype, {
Expand Down Expand Up @@ -114,7 +113,7 @@ ConstantPositionProperty.prototype.setValue = function (value, referenceFrame) {
ConstantPositionProperty.prototype.getValueInReferenceFrame = function (
time,
referenceFrame,
result
result,
) {
//>>includeStart('debug', pragmas.debug);
if (!defined(time)) {
Expand All @@ -130,7 +129,7 @@ ConstantPositionProperty.prototype.getValueInReferenceFrame = function (
this._value,
this._referenceFrame,
referenceFrame,
result
result,
);
};

Expand Down
Loading
Loading