Skip to content

Commit

Permalink
Merge branch 'master' into fix-empty-traversal
Browse files Browse the repository at this point in the history
  • Loading branch information
mramato authored Jul 9, 2020
2 parents f4ced37 + 2422b6b commit e047077
Show file tree
Hide file tree
Showing 39 changed files with 1,009 additions and 384 deletions.
25 changes: 19 additions & 6 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,40 @@
# Change Log

### 1.72 - 2020-08-03

##### Fixes :wrench:

- Fixed 3D Tileset replacement refinement when leaf is empty. [#8996](https://github.com/CesiumGS/cesium/8996)

### 1.71 - 2020-07-01

##### Breaking Changes :mega:

- Updated `WallGeometry` to respect the order of positions passed in, instead of making the positions respect a counter clockwise winding order. This will only effect the look of walls with an image material. If this changed the way your wall is drawing, reverse the order of the positions.
- Updated `WallGeometry` to respect the order of positions passed in, instead of making the positions respect a counter clockwise winding order. This will only affect the look of walls with an image material. If this changed the way your wall is drawing, reverse the order of the positions. [#8955](https://github.com/CesiumGS/cesium/pull/8955/)

##### Additions :tada:

- Added `backFaceCulling` property to `Cesium3DTileset` and `Model` to support viewing the underside or interior of a tileset or model. [#8981](https://github.com/CesiumGS/cesium/pull/8981)
- Added `Ellipsoid.surfaceArea` for computing the approximate surface area of a rectangle on the surface of an ellipsoid. [#8986](https://github.com/CesiumGS/cesium/pull/8986)
- Added support for PolylineVolume in CZML. [#8841](https://github.com/CesiumGS/cesium/pull/8841)
- Added `Color.toCssHexString` for getting the CSS hex string equivalent for a color. [#8987](https://github.com/CesiumGS/cesium/pull/8987)

##### Fixes :wrench:

- Fixed issue where tileset was not playing glTF animations [#8962](https://github.com/CesiumGS/cesium/issues/8962)
- Fixed issue where tileset was not playing glTF animations. [#8962](https://github.com/CesiumGS/cesium/issues/8962)
- Fixed a divide-by-zero bug in `Ellipsoid.geodeticSurfaceNormal` when given the origin as input. `undefined` is returned instead. [#8986](https://github.com/CesiumGS/cesium/pull/8986)
- Fixed error with `WallGeoemtry` when there were adjacent positions with very close values [#8952](https://github.com/CesiumGS/cesium/pull/8952)
- Fixed error with `WallGeometry` when there were adjacent positions with very close values. [#8952](https://github.com/CesiumGS/cesium/pull/8952)
- Fixed artifact for skinned model when log depth is enabled. [#6447](https://github.com/CesiumGS/cesium/issues/6447)
- Fixed a bug where certain rhumb arc polylines would lead to a crash. [#8787](https://github.com/CesiumGS/cesium/pull/8787)
- Fixed handling of Label's backgroundColor and backgroundPadding option [#8949](https://github.com/CesiumGS/cesium/8949)
- Fixed several bugs when rendering CesiumJS in a WebG 2 context. [#797](https://github.com/CesiumGS/cesium/issues/797)
- Fixed 3D Tileset replacement refinement when leaf is empty. [#8996](https://github.com/CesiumGS/cesium/8996)
- Fixed handling of Label's backgroundColor and backgroundPadding option [#8949](https://github.com/CesiumGS/cesium/pull/8949)
- Fixed several bugs when rendering CesiumJS in a WebGL 2 context. [#797](https://github.com/CesiumGS/cesium/issues/797)
- Fixed a bug where switching from perspective to orthographic caused triangles to overlap each other incorrectly. [#8346](https://github.com/CesiumGS/cesium/issues/8346)
- Fixed a bug where switching to orthographic camera on the first frame caused the zoom level to be incorrect. [#8853](https://github.com/CesiumGS/cesium/pull/8853)
- Fixed `scene.pickFromRay` intersection inaccuracies. [#8439](https://github.com/CesiumGS/cesium/issues/8439)
- Fixed a bug where a null or undefined name property passed to the `Entity` constructor would throw an exception.[#8832](https://github.com/CesiumGS/cesium/pull/8832)
- Fixed JSDoc and TypeScript type definitions for `ScreenSpaceEventHandler.getInputAction` which listed incorrect return type. [#9002](https://github.com/CesiumGS/cesium/pull/9002)
- Improved the style of the error panel. [#8739](https://github.com/CesiumGS/cesium/issues/8739)
- Fixed animation widget SVG icons not appearing in iOS 13.5.1. [#8993](https://github.com/CesiumGS/cesium/pull/8993)

### 1.70.1 - 2020-06-10

Expand Down
2 changes: 2 additions & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute to Cesiu
- [Orbit Logic](http://www.orbitlogic.com)
- [Roderick Green](https://github.com/roderickgreen/)
- [Sam Parrish](https://github.com/sgparrish/)
- [Sang Han](https://github.com/seoular/)
- [Hexastack](https://www.hexastack.com)
- [Mohamed Marrouchi](https://github.com/marrouchi/)
- [PropellerAero](https://www.propelleraero.com/)
Expand Down Expand Up @@ -268,3 +269,4 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute to Cesiu
- [Wang Bao](https://github.com/xiaobaogeit)
- [John Remsberg](https://github.com/easternmotors)
- [Bao Thien Tran](https://github.com/baothientran)
- [Yonatan Kra](https://github.com/yonatankra)
16 changes: 13 additions & 3 deletions Source/Core/Heap.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,20 @@ Object.defineProperties(Heap.prototype, {
return this._maximumLength;
},
set: function (value) {
this._maximumLength = value;
if (this._length > value && value > 0) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.number.greaterThanOrEquals("maximumLength", value, 0);
//>>includeEnd('debug');
var originalLength = this._length;
if (value < originalLength) {
var array = this._array;
// Remove trailing references
for (var i = value; i < originalLength; ++i) {
array[i] = undefined;
}
this._length = value;
this._array.length = value;
array.length = value;
}
this._maximumLength = value;
},
},

Expand Down Expand Up @@ -211,6 +220,7 @@ Heap.prototype.pop = function (index) {
var root = array[index];
swap(array, index, --this._length);
this.heapify(index);
array[this._length] = undefined; // Remove trailing reference
return root;
};

Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Ion.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Resource from "./Resource.js";

var defaultTokenCredit;
var defaultAccessToken =
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiIwNjk5ODcyYS00MWMyLTQ1NjctYTRhYS0zMmM3ZjYzMGM2ZGEiLCJpZCI6MjU5LCJzY29wZXMiOlsiYXNyIiwiZ2MiXSwiaWF0IjoxNTkxMDI3NDUwfQ.xUBBQH34cd86pfNMSQ6tBBelRx3g_RS51-nSUFlZq24";
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiI4NzdlNDVhMy1mNDAxLTQ5MWMtODhkYS00MTc1MTU4NzFmNzciLCJpZCI6MjU5LCJzY29wZXMiOlsiYXNyIiwiZ2MiXSwiaWF0IjoxNTkzNjI4MDI3fQ.sqnKP2DNn0soCyh1t9taAa2xkbZ6EIn0Z7_VwujTCtQ";
/**
* Default settings for accessing the Cesium ion API.
*
Expand Down
27 changes: 21 additions & 6 deletions Source/Core/ManagedArray.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,20 @@ Object.defineProperties(ManagedArray.prototype, {
return this._length;
},
set: function (length) {
this._length = length;
if (length > this._array.length) {
this._array.length = length;
//>>includeStart('debug', pragmas.debug);
Check.typeOf.number.greaterThanOrEquals("length", length, 0);
//>>includeEnd('debug');
var array = this._array;
var originalLength = this._length;
if (length < originalLength) {
// Remove trailing references
for (var i = length; i < originalLength; ++i) {
array[i] = undefined;
}
} else if (length > array.length) {
array.length = length;
}
this._length = length;
},
},

Expand Down Expand Up @@ -74,7 +84,7 @@ ManagedArray.prototype.set = function (index, element) {
Check.typeOf.number("index", index);
//>>includeEnd('debug');

if (index >= this.length) {
if (index >= this._length) {
this.length = index + 1;
}
this._array[index] = element;
Expand Down Expand Up @@ -105,7 +115,12 @@ ManagedArray.prototype.push = function (element) {
* @returns {*} The last element in the array.
*/
ManagedArray.prototype.pop = function () {
return this._array[--this.length];
if (this._length === 0) {
return undefined;
}
var element = this._array[this._length - 1];
--this.length;
return element;
};

/**
Expand Down Expand Up @@ -142,7 +157,7 @@ ManagedArray.prototype.resize = function (length) {
* @param {Number} [length] The length.
*/
ManagedArray.prototype.trim = function (length) {
length = defaultValue(length, this.length);
length = defaultValue(length, this._length);
this._array.length = length;
};
export default ManagedArray;
2 changes: 2 additions & 0 deletions Source/Core/ScreenSpaceEventHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -969,6 +969,8 @@ ScreenSpaceEventHandler.prototype.setInputAction = function (
* @param {Number} [modifier] A KeyboardEventModifier key that is held when a <code>type</code>
* event occurs.
*
* @returns {Function} The function to be executed on an input event.
*
* @see ScreenSpaceEventHandler#setInputAction
* @see ScreenSpaceEventHandler#removeInputAction
*/
Expand Down
6 changes: 4 additions & 2 deletions Source/DataSources/Entity.js
Original file line number Diff line number Diff line change
Expand Up @@ -594,8 +594,10 @@ Entity.prototype.merge = function (source) {
for (var i = 0; i < propertyNamesLength; i++) {
var name = sourcePropertyNames[i];

//Ignore parent when merging, this only happens at construction time.
if (name === "parent") {
//While source is required by the API to be an Entity, we internally call this method from the
//constructor with an options object to configure initial custom properties.
//So we need to ignore reserved-non-property.
if (name === "parent" || name === "name" || name === "availability") {
continue;
}

Expand Down
3 changes: 3 additions & 0 deletions Source/DataSources/SampledProperty.js
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,9 @@ SampledProperty.prototype.equals = function (other) {

var values = this._values;
var otherValues = other._values;
length = values.length;

//Since time lengths are equal, values length and other length are guaranteed to be equal.
for (i = 0; i < length; i++) {
if (values[i] !== otherValues[i]) {
return false;
Expand Down
2 changes: 2 additions & 0 deletions Source/Scene/Batched3DModel3DTileContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,7 @@ function initialize(content, arrayBuffer, byteOffset) {
luminanceAtZenith: tileset.luminanceAtZenith,
sphericalHarmonicCoefficients: tileset.sphericalHarmonicCoefficients,
specularEnvironmentMaps: tileset.specularEnvironmentMaps,
backFaceCulling: tileset.backFaceCulling,
});
content._model.readyPromise.then(function (model) {
model.activeAnimations.addAll({
Expand Down Expand Up @@ -539,6 +540,7 @@ Batched3DModel3DTileContent.prototype.update = function (tileset, frameState) {
this._model.luminanceAtZenith = this._tileset.luminanceAtZenith;
this._model.sphericalHarmonicCoefficients = this._tileset.sphericalHarmonicCoefficients;
this._model.specularEnvironmentMaps = this._tileset.specularEnvironmentMaps;
this._model.backFaceCulling = this._tileset.backFaceCulling;
this._model.debugWireframe = this._tileset.debugWireframe;

// Update clipping planes
Expand Down
108 changes: 47 additions & 61 deletions Source/Scene/Camera.js
Original file line number Diff line number Diff line change
Expand Up @@ -1112,78 +1112,68 @@ Camera.prototype._setTransform = function (transform) {
updateMembers(this);
};

var scratchAdjustOrtghographicFrustumMousePosition = new Cartesian2();
var pickGlobeScratchRay = new Ray();
var scratchAdjustOrthographicFrustumMousePosition = new Cartesian2();
var scratchPickRay = new Ray();
var scratchRayIntersection = new Cartesian3();
var scratchDepthIntersection = new Cartesian3();

Camera.prototype._adjustOrthographicFrustum = function (zooming) {
if (!(this.frustum instanceof OrthographicFrustum)) {
return;
function calculateOrthographicFrustumWidth(camera) {
// Camera is fixed to an object, so keep frustum width constant.
if (!Matrix4.equals(Matrix4.IDENTITY, camera.transform)) {
return Cartesian3.magnitude(camera.position);
}

if (!zooming && this._positionCartographic.height < 150000.0) {
return;
}
var scene = camera._scene;
var globe = scene.globe;

if (!Matrix4.equals(Matrix4.IDENTITY, this.transform)) {
this.frustum.width = Cartesian3.magnitude(this.position);
return;
}
var mousePosition = scratchAdjustOrthographicFrustumMousePosition;
mousePosition.x = scene.drawingBufferWidth / 2.0;
mousePosition.y = scene.drawingBufferHeight / 2.0;

var scene = this._scene;
var globe = scene.globe;
var rayIntersection;
var depthIntersection;

if (defined(globe)) {
var mousePosition = scratchAdjustOrtghographicFrustumMousePosition;
mousePosition.x = scene.drawingBufferWidth / 2.0;
mousePosition.y = scene.drawingBufferHeight / 2.0;

var ray = this.getPickRay(mousePosition, pickGlobeScratchRay);
var ray = camera.getPickRay(mousePosition, scratchPickRay);
rayIntersection = globe.pickWorldCoordinates(
ray,
scene,
true,
scratchRayIntersection
);
}

if (scene.pickPositionSupported) {
depthIntersection = scene.pickPositionWorldCoordinates(
mousePosition,
scratchDepthIntersection
);
}
var depthIntersection;
if (scene.pickPositionSupported) {
depthIntersection = scene.pickPositionWorldCoordinates(
mousePosition,
scratchDepthIntersection
);
}

if (defined(rayIntersection) && defined(depthIntersection)) {
var depthDistance = defined(depthIntersection)
? Cartesian3.distance(depthIntersection, this.positionWC)
: Number.POSITIVE_INFINITY;
var rayDistance = defined(rayIntersection)
? Cartesian3.distance(rayIntersection, this.positionWC)
: Number.POSITIVE_INFINITY;
this.frustum.width = Math.min(depthDistance, rayDistance);
} else if (defined(depthIntersection)) {
this.frustum.width = Cartesian3.distance(
depthIntersection,
this.positionWC
);
} else if (defined(rayIntersection)) {
this.frustum.width = Cartesian3.distance(
rayIntersection,
this.positionWC
);
}
var distance;
if (defined(rayIntersection) || defined(depthIntersection)) {
var depthDistance = defined(depthIntersection)
? Cartesian3.distance(depthIntersection, camera.positionWC)
: Number.POSITIVE_INFINITY;
var rayDistance = defined(rayIntersection)
? Cartesian3.distance(rayIntersection, camera.positionWC)
: Number.POSITIVE_INFINITY;
distance = Math.min(depthDistance, rayDistance);
} else {
distance = Math.max(camera.positionCartographic.height, 0.0);
}
return distance;
}

if (
!defined(globe) ||
(!defined(rayIntersection) && !defined(depthIntersection))
) {
var distance = Math.max(this.positionCartographic.height, 0.0);
this.frustum.width = distance;
Camera.prototype._adjustOrthographicFrustum = function (zooming) {
if (!(this.frustum instanceof OrthographicFrustum)) {
return;
}

if (!zooming && this._positionCartographic.height < 150000.0) {
return;
}

this.frustum.width = calculateOrthographicFrustumWidth(this);
};

var scratchSetViewCartesian = new Cartesian3();
Expand Down Expand Up @@ -3850,19 +3840,15 @@ Camera.prototype.switchToOrthographicFrustum = function () {
return;
}

// This must be called before changing the frustum because it uses the previous
// frustum to reconstruct the world space position from the depth buffer.
var frustumWidth = calculateOrthographicFrustumWidth(this);

var scene = this._scene;
this.frustum = new OrthographicFrustum();
this.frustum.aspectRatio =
scene.drawingBufferWidth / scene.drawingBufferHeight;

// It doesn't matter what we set this to. The adjust below will correct the width based on the camera position.
this.frustum.width = Cartesian3.magnitude(this.position);

// Check the projection matrix. It will always be defined, but we need to force an off-center update.
var projectionMatrix = this.frustum.projectionMatrix;
if (defined(projectionMatrix)) {
this._adjustOrthographicFrustum(true);
}
this.frustum.width = frustumWidth;
};

/**
Expand Down
10 changes: 10 additions & 0 deletions Source/Scene/Cesium3DTileset.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ import TileOrientedBoundingBox from "./TileOrientedBoundingBox.js";
* @param {Number} [options.luminanceAtZenith=0.2] The sun's luminance at the zenith in kilo candela per meter squared to use for this model's procedural environment map.
* @param {Cartesian3[]} [options.sphericalHarmonicCoefficients] The third order spherical harmonic coefficients used for the diffuse color of image-based lighting.
* @param {String} [options.specularEnvironmentMaps] A URL to a KTX file that contains a cube map of the specular lighting and the convoluted specular mipmaps.
* @param {Boolean} [options.backFaceCulling=true] Whether to cull back-facing geometry. When true, back face culling is determined by the glTF material's doubleSided property; when false, back face culling is disabled.
* @param {String} [options.debugHeatmapTilePropertyName] The tile variable to colorize as a heatmap. All rendered tiles will be colorized relative to each other's specified variable value.
* @param {Boolean} [options.debugFreezeFrame=false] For debugging only. Determines if only the tiles from last frame should be used for rendering.
* @param {Boolean} [options.debugColorizeTiles=false] For debugging only. When true, assigns a random color to each tile.
Expand Down Expand Up @@ -750,6 +751,15 @@ function Cesium3DTileset(options) {
*/
this.specularEnvironmentMaps = options.specularEnvironmentMaps;

/**
* Whether to cull back-facing geometry. When true, back face culling is determined
* by the glTF material's doubleSided property; when false, back face culling is disabled.
*
* @type {Boolean}
* @default true
*/
this.backFaceCulling = defaultValue(options.backFaceCulling, true);

/**
* This property is for debugging only; it is not optimized for production use.
* <p>
Expand Down
12 changes: 10 additions & 2 deletions Source/Scene/DerivedCommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,14 +189,22 @@ function getLogDepthShaderProgram(context, shaderProgram) {
sources.push(logMain);
}

var addExtension = true;
writesLogDepth = false;
sources = fs.sources;
length = sources.length;

writesLogDepth = false;
for (i = 0; i < length; ++i) {
if (writeLogDepthRegex.test(sources[i])) {
writesLogDepth = true;
}
}
// This define indicates that a log depth value is written by the shader but doesn't use czm_writeLogDepth.
if (fs.defines.indexOf("LOG_DEPTH_WRITE") !== -1) {
writesLogDepth = true;
}

var addExtension = true;
for (i = 0; i < length; ++i) {
if (extensionRegex.test(sources[i])) {
addExtension = false;
}
Expand Down
Loading

0 comments on commit e047077

Please sign in to comment.