viewerVoxelInspectorMixin.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. import { Check } from "@cesium/engine";
  2. import VoxelInspector from "../VoxelInspector/VoxelInspector.js";
  3. /**
  4. * A mixin which adds the {@link VoxelInspector} widget to the {@link Viewer} widget.
  5. * Rather than being called directly, this function is normally passed as
  6. * a parameter to {@link Viewer#extend}, as shown in the example below.
  7. * @function
  8. *
  9. * @param {Viewer} viewer The viewer instance.
  10. *
  11. * @example
  12. * var viewer = new Cesium.Viewer('cesiumContainer');
  13. * viewer.extend(Cesium.viewerVoxelInspectorMixin);
  14. */
  15. function viewerVoxelInspectorMixin(viewer) {
  16. //>>includeStart('debug', pragmas.debug);
  17. Check.typeOf.object("viewer", viewer);
  18. //>>includeEnd('debug');
  19. const container = document.createElement("div");
  20. container.className = "cesium-viewer-voxelInspectorContainer";
  21. viewer.container.appendChild(container);
  22. const voxelInspector = new VoxelInspector(container, viewer.scene);
  23. Object.defineProperties(viewer, {
  24. voxelInspector: {
  25. get: function () {
  26. return voxelInspector;
  27. },
  28. },
  29. });
  30. }
  31. export default viewerVoxelInspectorMixin;