Skip to content

Commit

Permalink
Merge pull request #9271 from TerriaJS/node-commands-undefined2
Browse files Browse the repository at this point in the history
Fixed error when nodeCommands[0] is undefined in Model.updateColor()
  • Loading branch information
lilleyse authored Dec 20, 2020
2 parents 7a2b445 + 6d62b6f commit a3ef9de
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

### 1.77 - 2020-01-04

##### Fixes :wrench:

- Fixed an issue where Model.updateColor, Model.updateBackFaceCulling and Model.updateSilhouette threw errors when length of nodeCommands was 0 [#9271](https://github.com/CesiumGS/cesium/pull/9271)

##### Deprecated :hourglass_flowing_sand:

- `EasingFunction.QUADRACTIC_IN` was deprecated and will be removed in Cesium 1.79. It has been replaced with `EasingFunction.QUADRATIC_IN`. [#9220](https://github.com/CesiumGS/cesium/issues/9220)
Expand Down
23 changes: 15 additions & 8 deletions Source/Scene/Model.js
Original file line number Diff line number Diff line change
Expand Up @@ -4507,7 +4507,10 @@ function updateColor(model, frameState, forceDerive) {
if (alpha > 0.0 && alpha < 1.0) {
var nodeCommands = model._nodeCommands;
var length = nodeCommands.length;
if (!defined(nodeCommands[0].translucentCommand) || forceDerive) {
if (
length > 0 &&
(!defined(nodeCommands[0].translucentCommand) || forceDerive)
) {
for (var i = 0; i < length; ++i) {
var nodeCommand = nodeCommands[i];
var command = nodeCommand.command;
Expand Down Expand Up @@ -4543,7 +4546,10 @@ function updateBackFaceCulling(model, frameState, forceDerive) {
if (!backFaceCulling) {
var nodeCommands = model._nodeCommands;
var length = nodeCommands.length;
if (!defined(nodeCommands[0].disableCullingCommand) || forceDerive) {
if (
length > 0 &&
(!defined(nodeCommands[0].disableCullingCommand) || forceDerive)
) {
for (var i = 0; i < length; ++i) {
var nodeCommand = nodeCommands[i];
var command = nodeCommand.command;
Expand Down Expand Up @@ -4813,12 +4819,13 @@ function updateSilhouette(model, frameState, force) {

var nodeCommands = model._nodeCommands;
var dirty =
alphaDirty(model.color.alpha, model._colorPreviousAlpha) ||
alphaDirty(
model.silhouetteColor.alpha,
model._silhouetteColorPreviousAlpha
) ||
!defined(nodeCommands[0].silhouetteModelCommand);
nodeCommands.length > 0 &&
(alphaDirty(model.color.alpha, model._colorPreviousAlpha) ||
alphaDirty(
model.silhouetteColor.alpha,
model._silhouetteColorPreviousAlpha
) ||
!defined(nodeCommands[0].silhouetteModelCommand));

model._colorPreviousAlpha = model.color.alpha;
model._silhouetteColorPreviousAlpha = model.silhouetteColor.alpha;
Expand Down

0 comments on commit a3ef9de

Please sign in to comment.