bruce-cesium 0.5.4 → 0.5.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bruce-cesium.es5.js +79 -23
- package/dist/bruce-cesium.es5.js.map +1 -1
- package/dist/bruce-cesium.umd.js +79 -23
- package/dist/bruce-cesium.umd.js.map +1 -1
- package/dist/lib/rendering/visuals-register.js +11 -1
- package/dist/lib/rendering/visuals-register.js.map +1 -1
- package/dist/lib/utils/entity-utils.js +68 -22
- package/dist/lib/utils/entity-utils.js.map +1 -1
- package/dist/types/rendering/visuals-register.d.ts +8 -1
- package/dist/types/utils/entity-utils.d.ts +10 -2
- package/package.json +1 -1
package/dist/bruce-cesium.es5.js
CHANGED
|
@@ -436,6 +436,7 @@ function traverseEntity(cEntity, arr) {
|
|
|
436
436
|
arr.push(cEntity);
|
|
437
437
|
}
|
|
438
438
|
var ORG_OPACITY_KEY = "_org_opacity_";
|
|
439
|
+
var NEW_OPACITY_KEY = "_new_opacity_";
|
|
439
440
|
function getColor(viewer, material) {
|
|
440
441
|
var _a;
|
|
441
442
|
var color;
|
|
@@ -462,37 +463,71 @@ function applyOpacityToGraphic(viewer, entity, graphicKey, opacity) {
|
|
|
462
463
|
}
|
|
463
464
|
}
|
|
464
465
|
function revertAppliedEntityOpacity(viewer, entity) {
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
if (
|
|
469
|
-
|
|
466
|
+
entity[NEW_OPACITY_KEY] = null;
|
|
467
|
+
if (entity instanceof Entity) {
|
|
468
|
+
var processKey = function (graphicKey) {
|
|
469
|
+
if (entity[graphicKey]) {
|
|
470
|
+
var orgOpacity = entity[graphicKey][ORG_OPACITY_KEY];
|
|
471
|
+
if (orgOpacity != null) {
|
|
472
|
+
applyOpacityToGraphic(viewer, entity, graphicKey, orgOpacity);
|
|
473
|
+
}
|
|
470
474
|
entity[graphicKey][ORG_OPACITY_KEY] = null;
|
|
471
475
|
}
|
|
476
|
+
};
|
|
477
|
+
processKey("polygon");
|
|
478
|
+
processKey("polyline");
|
|
479
|
+
processKey("point");
|
|
480
|
+
processKey("ellipse");
|
|
481
|
+
processKey("model");
|
|
482
|
+
}
|
|
483
|
+
else if (entity instanceof Cesium3DTileFeature) {
|
|
484
|
+
var orgOpacity = entity[ORG_OPACITY_KEY];
|
|
485
|
+
if (orgOpacity != null) {
|
|
486
|
+
var color = entity.color ? entity.color.clone() : new Color();
|
|
487
|
+
color.alpha = orgOpacity;
|
|
488
|
+
entity.color = color;
|
|
472
489
|
}
|
|
490
|
+
entity[ORG_OPACITY_KEY] = null;
|
|
473
491
|
}
|
|
474
|
-
processKey("polygon");
|
|
475
|
-
processKey("polyline");
|
|
476
|
-
processKey("point");
|
|
477
|
-
processKey("ellipse");
|
|
478
|
-
processKey("model");
|
|
479
492
|
}
|
|
480
493
|
function applyOpacityToEntity(viewer, opacity, entity) {
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
var
|
|
485
|
-
if (
|
|
486
|
-
|
|
494
|
+
entity[NEW_OPACITY_KEY] = opacity;
|
|
495
|
+
if (entity instanceof Entity) {
|
|
496
|
+
var processKey = function (graphicKey) {
|
|
497
|
+
var _a;
|
|
498
|
+
if (entity[graphicKey]) {
|
|
499
|
+
var orgOpacity = entity[graphicKey][ORG_OPACITY_KEY];
|
|
500
|
+
if (orgOpacity == null) {
|
|
501
|
+
entity[graphicKey][ORG_OPACITY_KEY] = (_a = getColor(viewer, entity[graphicKey].material)) === null || _a === void 0 ? void 0 : _a.alpha;
|
|
502
|
+
}
|
|
503
|
+
if (orgOpacity == null) {
|
|
504
|
+
orgOpacity = 1;
|
|
505
|
+
}
|
|
506
|
+
applyOpacityToGraphic(viewer, entity, graphicKey, opacity * orgOpacity);
|
|
487
507
|
}
|
|
488
|
-
|
|
508
|
+
};
|
|
509
|
+
processKey("polygon");
|
|
510
|
+
processKey("polyline");
|
|
511
|
+
processKey("point");
|
|
512
|
+
processKey("ellipse");
|
|
513
|
+
processKey("model");
|
|
514
|
+
}
|
|
515
|
+
else if (entity instanceof Cesium3DTileFeature) {
|
|
516
|
+
var orgOpacity = entity[ORG_OPACITY_KEY];
|
|
517
|
+
if (orgOpacity == null) {
|
|
518
|
+
entity[ORG_OPACITY_KEY] = entity.color ? entity.color.alpha : 1;
|
|
489
519
|
}
|
|
520
|
+
if (!orgOpacity) {
|
|
521
|
+
orgOpacity = 1;
|
|
522
|
+
}
|
|
523
|
+
var color = entity.color ? entity.color.clone() : new Color();
|
|
524
|
+
entity.color.alpha = opacity * orgOpacity;
|
|
525
|
+
entity.color = color;
|
|
490
526
|
}
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
processKey("model");
|
|
527
|
+
}
|
|
528
|
+
function findOpacity(entity) {
|
|
529
|
+
var _a;
|
|
530
|
+
return (_a = entity[NEW_OPACITY_KEY]) !== null && _a !== void 0 ? _a : 1;
|
|
496
531
|
}
|
|
497
532
|
var EntityUtils;
|
|
498
533
|
(function (EntityUtils) {
|
|
@@ -685,6 +720,17 @@ var EntityUtils;
|
|
|
685
720
|
revertAppliedEntityOpacity(viewer, entity);
|
|
686
721
|
}
|
|
687
722
|
EntityUtils.RevertOpacity = RevertOpacity;
|
|
723
|
+
/**
|
|
724
|
+
* Gets opacity of the entity.
|
|
725
|
+
* This does not count opacity that it was rendered with.
|
|
726
|
+
* This is the opacity that was set post-rendering.
|
|
727
|
+
* @param viewer
|
|
728
|
+
* @param entity
|
|
729
|
+
*/
|
|
730
|
+
function getOpacity(entity) {
|
|
731
|
+
return findOpacity(entity);
|
|
732
|
+
}
|
|
733
|
+
EntityUtils.getOpacity = getOpacity;
|
|
688
734
|
})(EntityUtils || (EntityUtils = {}));
|
|
689
735
|
|
|
690
736
|
var RenderManager;
|
|
@@ -2121,12 +2167,22 @@ var VisualsRegister;
|
|
|
2121
2167
|
}
|
|
2122
2168
|
(_b = this.onUpdate) === null || _b === void 0 ? void 0 : _b.Trigger({ rego: rego, isAdding: true });
|
|
2123
2169
|
};
|
|
2170
|
+
/**
|
|
2171
|
+
* Locates a visual corresponding to a given entity id.
|
|
2172
|
+
* If no menu item id is provided, then it will pick the "best" one.
|
|
2173
|
+
* @param entityId
|
|
2174
|
+
* @param menuItemId
|
|
2175
|
+
* @returns
|
|
2176
|
+
*/
|
|
2124
2177
|
Register.prototype.GetRego = function (entityId, menuItemId) {
|
|
2125
2178
|
var entityRegos = this.rego[entityId];
|
|
2126
2179
|
if (!entityRegos) {
|
|
2127
2180
|
return [];
|
|
2128
2181
|
}
|
|
2129
|
-
|
|
2182
|
+
if (menuItemId) {
|
|
2183
|
+
return entityRegos.find(function (r) { return r.menuItemId === menuItemId; });
|
|
2184
|
+
}
|
|
2185
|
+
return entityRegos.find(function (x) { return x.best; });
|
|
2130
2186
|
};
|
|
2131
2187
|
Register.prototype.GetRegos = function (entityId) {
|
|
2132
2188
|
var entityRegos = this.rego[entityId];
|