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

Clone NearFarScalar values in constructor for Billboard, Label and PointPrimitive #5654

Merged
merged 1 commit into from
Jul 19, 2017
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
55 changes: 40 additions & 15 deletions Source/Scene/Billboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,22 +76,47 @@ define([
options = defaultValue(options, defaultValue.EMPTY_OBJECT);

//>>includeStart('debug', pragmas.debug);
if (defined(options.scaleByDistance) && options.scaleByDistance.far <= options.scaleByDistance.near) {
throw new DeveloperError('scaleByDistance.far must be greater than scaleByDistance.near.');
if (defined(options.disableDepthTestDistance) && options.disableDepthTestDistance < 0.0) {
throw new DeveloperError('disableDepthTestDistance must be greater than or equal to 0.0.');
}
if (defined(options.translucencyByDistance) && options.translucencyByDistance.far <= options.translucencyByDistance.near) {
throw new DeveloperError('translucencyByDistance.far must be greater than translucencyByDistance.near.');
//>>includeEnd('debug');

var translucencyByDistance = options.translucencyByDistance;
var pixelOffsetScaleByDistance = options.pixelOffsetScaleByDistance;
var scaleByDistance = options.scaleByDistance;
var distanceDisplayCondition = options.distanceDisplayCondition;
if (defined(translucencyByDistance)) {
//>>includeStart('debug', pragmas.debug);
if (translucencyByDistance.far <= translucencyByDistance.near) {
throw new DeveloperError('translucencyByDistance.far must be greater than translucencyByDistance.near.');
}
//>>includeEnd('debug');
translucencyByDistance = NearFarScalar.clone(translucencyByDistance);
}
if (defined(options.pixelOffsetScaleByDistance) && options.pixelOffsetScaleByDistance.far <= options.pixelOffsetScaleByDistance.near) {
throw new DeveloperError('pixelOffsetScaleByDistance.far must be greater than pixelOffsetScaleByDistance.near.');
if (defined(pixelOffsetScaleByDistance)) {
//>>includeStart('debug', pragmas.debug);
if (pixelOffsetScaleByDistance.far <= pixelOffsetScaleByDistance.near) {
throw new DeveloperError('pixelOffsetScaleByDistance.far must be greater than pixelOffsetScaleByDistance.near.');
}
//>>includeEnd('debug');
pixelOffsetScaleByDistance = NearFarScalar.clone(pixelOffsetScaleByDistance);
}
if (defined(options.distanceDisplayCondition) && options.distanceDisplayCondition.far <= options.distanceDisplayCondition.near) {
throw new DeveloperError('distanceDisplayCondition.far must be greater than distanceDisplayCondition.near');
if (defined(scaleByDistance)) {
//>>includeStart('debug', pragmas.debug);
if (scaleByDistance.far <= scaleByDistance.near) {
throw new DeveloperError('scaleByDistance.far must be greater than scaleByDistance.near.');
}
//>>includeEnd('debug');
scaleByDistance = NearFarScalar.clone(scaleByDistance);
}
if (defined(options.disableDepthTestDistance) && options.disableDepthTestDistance < 0.0) {
throw new DeveloperError('disableDepthTestDistance must be greater than or equal to 0.0.');
if (defined(distanceDisplayCondition)) {
//>>includeStart('debug', pragmas.debug);
if (distanceDisplayCondition.far <= distanceDisplayCondition.near) {
throw new DeveloperError('distanceDisplayCondition.far must be greater than distanceDisplayCondition.near.');
}
//>>includeEnd('debug');
distanceDisplayCondition = DistanceDisplayCondition.clone(distanceDisplayCondition);
}
//>>includeEnd('debug');

this._show = defaultValue(options.show, true);
this._position = Cartesian3.clone(defaultValue(options.position, Cartesian3.ZERO));
Expand All @@ -108,11 +133,11 @@ define([
this._alignedAxis = Cartesian3.clone(defaultValue(options.alignedAxis, Cartesian3.ZERO));
this._width = options.width;
this._height = options.height;
this._scaleByDistance = options.scaleByDistance;
this._translucencyByDistance = options.translucencyByDistance;
this._pixelOffsetScaleByDistance = options.pixelOffsetScaleByDistance;
this._scaleByDistance = scaleByDistance;
this._translucencyByDistance = translucencyByDistance;
this._pixelOffsetScaleByDistance = pixelOffsetScaleByDistance;
this._sizeInMeters = defaultValue(options.sizeInMeters, false);
this._distanceDisplayCondition = options.distanceDisplayCondition;
this._distanceDisplayCondition = distanceDisplayCondition;
this._disableDepthTestDistance = defaultValue(options.disableDepthTestDistance, 0.0);
this._id = options.id;
this._collection = defaultValue(options.collection, billboardCollection);
Expand Down
55 changes: 40 additions & 15 deletions Source/Scene/Label.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,22 +68,47 @@ define([
options = defaultValue(options, defaultValue.EMPTY_OBJECT);

//>>includeStart('debug', pragmas.debug);
if (defined(options.translucencyByDistance) && options.translucencyByDistance.far <= options.translucencyByDistance.near) {
throw new DeveloperError('translucencyByDistance.far must be greater than translucencyByDistance.near.');
if (defined(options.disableDepthTestDistance) && options.disableDepthTestDistance < 0.0) {
throw new DeveloperError('disableDepthTestDistance must be greater than 0.0.');
}
if (defined(options.pixelOffsetScaleByDistance) && options.pixelOffsetScaleByDistance.far <= options.pixelOffsetScaleByDistance.near) {
throw new DeveloperError('pixelOffsetScaleByDistance.far must be greater than pixelOffsetScaleByDistance.near.');
//>>includeEnd('debug');

var translucencyByDistance = options.translucencyByDistance;
var pixelOffsetScaleByDistance = options.pixelOffsetScaleByDistance;
var scaleByDistance = options.scaleByDistance;
var distanceDisplayCondition = options.distanceDisplayCondition;
if (defined(translucencyByDistance)) {
//>>includeStart('debug', pragmas.debug);
if (translucencyByDistance.far <= translucencyByDistance.near) {
throw new DeveloperError('translucencyByDistance.far must be greater than translucencyByDistance.near.');
}
//>>includeEnd('debug');
translucencyByDistance = NearFarScalar.clone(translucencyByDistance);
}
if (defined(options.scaleByDistance) && options.scaleByDistance.far <= options.scaleByDistance.near) {
throw new DeveloperError('scaleByDistance.far must be greater than scaleByDistance.near.');
if (defined(pixelOffsetScaleByDistance)) {
//>>includeStart('debug', pragmas.debug);
if (pixelOffsetScaleByDistance.far <= pixelOffsetScaleByDistance.near) {
throw new DeveloperError('pixelOffsetScaleByDistance.far must be greater than pixelOffsetScaleByDistance.near.');
}
//>>includeEnd('debug');
pixelOffsetScaleByDistance = NearFarScalar.clone(pixelOffsetScaleByDistance);
}
if (defined(options.distanceDisplayCondition) && options.distanceDisplayCondition.far <= options.distanceDisplayCondition.near) {
throw new DeveloperError('distanceDisplayCondition.far must be greater than distanceDisplayCondition.near');
if (defined(scaleByDistance)) {
//>>includeStart('debug', pragmas.debug);
if (scaleByDistance.far <= scaleByDistance.near) {
throw new DeveloperError('scaleByDistance.far must be greater than scaleByDistance.near.');
}
//>>includeEnd('debug');
scaleByDistance = NearFarScalar.clone(scaleByDistance);
}
if (defined(options.disableDepthTestDistance) && options.disableDepthTestDistance < 0.0) {
throw new DeveloperError('disableDepthTestDistance must be greater than 0.0.');
if (defined(distanceDisplayCondition)) {
//>>includeStart('debug', pragmas.debug);
if (distanceDisplayCondition.far <= distanceDisplayCondition.near) {
throw new DeveloperError('distanceDisplayCondition.far must be greater than distanceDisplayCondition.near.');
}
//>>includeEnd('debug');
distanceDisplayCondition = DistanceDisplayCondition.clone(distanceDisplayCondition);
}
//>>includeEnd('debug');

this._text = defaultValue(options.text, '');
this._show = defaultValue(options.show, true);
Expand All @@ -102,11 +127,11 @@ define([
this._position = Cartesian3.clone(defaultValue(options.position, Cartesian3.ZERO));
this._scale = defaultValue(options.scale, 1.0);
this._id = options.id;
this._translucencyByDistance = options.translucencyByDistance;
this._pixelOffsetScaleByDistance = options.pixelOffsetScaleByDistance;
this._scaleByDistance = options.scaleByDistance;
this._translucencyByDistance = translucencyByDistance;
this._pixelOffsetScaleByDistance = pixelOffsetScaleByDistance;
this._scaleByDistance = scaleByDistance;
this._heightReference = defaultValue(options.heightReference, HeightReference.NONE);
this._distanceDisplayCondition = options.distanceDisplayCondition;
this._distanceDisplayCondition = distanceDisplayCondition;
this._disableDepthTestDistance = defaultValue(options.disableDepthTestDistance, 0.0);

this._labelCollection = labelCollection;
Expand Down
43 changes: 31 additions & 12 deletions Source/Scene/PointPrimitive.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,30 +59,49 @@ define([
options = defaultValue(options, defaultValue.EMPTY_OBJECT);

//>>includeStart('debug', pragmas.debug);
if (defined(options.scaleByDistance) && options.scaleByDistance.far <= options.scaleByDistance.near) {
throw new DeveloperError('scaleByDistance.far must be greater than scaleByDistance.near.');
}
if (defined(options.translucencyByDistance) && options.translucencyByDistance.far <= options.translucencyByDistance.near) {
throw new DeveloperError('translucencyByDistance.far must be greater than translucencyByDistance.near.');
}
if (defined(options.distanceDisplayCondition) && options.distanceDisplayCondition.far <= options.distanceDisplayCondition.near) {
throw new DeveloperError('distanceDisplayCondition.far must be greater than distanceDisplayCondition.near');
}
if (defined(options.disableDepthTestDistance) && options.disableDepthTestDistance < 0.0) {
throw new DeveloperError('disableDepthTestDistance must be greater than or equal to 0.0.');
}
//>>includeEnd('debug');

var translucencyByDistance = options.translucencyByDistance;
var scaleByDistance = options.scaleByDistance;
var distanceDisplayCondition = options.distanceDisplayCondition;
if (defined(translucencyByDistance)) {
//>>includeStart('debug', pragmas.debug);
if (translucencyByDistance.far <= translucencyByDistance.near) {
throw new DeveloperError('translucencyByDistance.far must be greater than translucencyByDistance.near.');
}
//>>includeEnd('debug');
translucencyByDistance = NearFarScalar.clone(translucencyByDistance);
}
if (defined(scaleByDistance)) {
//>>includeStart('debug', pragmas.debug);
if (scaleByDistance.far <= scaleByDistance.near) {
throw new DeveloperError('scaleByDistance.far must be greater than scaleByDistance.near.');
}
//>>includeEnd('debug');
scaleByDistance = NearFarScalar.clone(scaleByDistance);
}
if (defined(distanceDisplayCondition)) {
//>>includeStart('debug', pragmas.debug);
if (distanceDisplayCondition.far <= distanceDisplayCondition.near) {
throw new DeveloperError('distanceDisplayCondition.far must be greater than distanceDisplayCondition.near.');
}
//>>includeEnd('debug');
distanceDisplayCondition = DistanceDisplayCondition.clone(distanceDisplayCondition);
}

this._show = defaultValue(options.show, true);
this._position = Cartesian3.clone(defaultValue(options.position, Cartesian3.ZERO));
this._actualPosition = Cartesian3.clone(this._position); // For columbus view and 2D
this._color = Color.clone(defaultValue(options.color, Color.WHITE));
this._outlineColor = Color.clone(defaultValue(options.outlineColor, Color.TRANSPARENT));
this._outlineWidth = defaultValue(options.outlineWidth, 0.0);
this._pixelSize = defaultValue(options.pixelSize, 10.0);
this._scaleByDistance = options.scaleByDistance;
this._translucencyByDistance = options.translucencyByDistance;
this._distanceDisplayCondition = options.distanceDisplayCondition;
this._scaleByDistance = scaleByDistance;
this._translucencyByDistance = translucencyByDistance;
this._distanceDisplayCondition = distanceDisplayCondition;
this._disableDepthTestDistance = defaultValue(options.disableDepthTestDistance, 0.0);
this._id = options.id;
this._collection = defaultValue(options.collection, pointPrimitiveCollection);
Expand Down