Cesium3DTilesetGraphics.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. import defaultValue from "../Core/defaultValue.js";
  2. import defined from "../Core/defined.js";
  3. import DeveloperError from "../Core/DeveloperError.js";
  4. import Event from "../Core/Event.js";
  5. import createPropertyDescriptor from "./createPropertyDescriptor.js";
  6. /**
  7. * @typedef {object} Cesium3DTilesetGraphics.ConstructorOptions
  8. *
  9. * Initialization options for the Cesium3DTilesetGraphics constructor
  10. *
  11. * @property {Property | boolean} [show=true] A boolean Property specifying the visibility of the tileset.
  12. * @property {Property | string | Resource} [uri] A string or Resource Property specifying the URI of the tileset.
  13. * @property {Property | number} [maximumScreenSpaceError] A number or Property specifying the maximum screen space error used to drive level of detail refinement.
  14. */
  15. /**
  16. * A 3D Tiles tileset represented by an {@link Entity}.
  17. * The tileset modelMatrix is determined by the containing Entity position and orientation
  18. * or is left unset if position is undefined.
  19. *
  20. * @alias Cesium3DTilesetGraphics
  21. * @constructor
  22. *
  23. * @param {Cesium3DTilesetGraphics.ConstructorOptions} [options] Object describing initialization options
  24. */
  25. function Cesium3DTilesetGraphics(options) {
  26. this._definitionChanged = new Event();
  27. this._show = undefined;
  28. this._showSubscription = undefined;
  29. this._uri = undefined;
  30. this._uriSubscription = undefined;
  31. this._maximumScreenSpaceError = undefined;
  32. this._maximumScreenSpaceErrorSubscription = undefined;
  33. this.merge(defaultValue(options, defaultValue.EMPTY_OBJECT));
  34. }
  35. Object.defineProperties(Cesium3DTilesetGraphics.prototype, {
  36. /**
  37. * Gets the event that is raised whenever a property or sub-property is changed or modified.
  38. * @memberof Cesium3DTilesetGraphics.prototype
  39. * @type {Event}
  40. * @readonly
  41. */
  42. definitionChanged: {
  43. get: function () {
  44. return this._definitionChanged;
  45. },
  46. },
  47. /**
  48. * Gets or sets the boolean Property specifying the visibility of the model.
  49. * @memberof Cesium3DTilesetGraphics.prototype
  50. * @type {Property|undefined}
  51. * @default true
  52. */
  53. show: createPropertyDescriptor("show"),
  54. /**
  55. * Gets or sets the string Property specifying the URI of the glTF asset.
  56. * @memberof Cesium3DTilesetGraphics.prototype
  57. * @type {Property|undefined}
  58. */
  59. uri: createPropertyDescriptor("uri"),
  60. /**
  61. * Gets or sets the maximum screen space error used to drive level of detail refinement.
  62. * @memberof Cesium3DTilesetGraphics.prototype
  63. * @type {Property|undefined}
  64. */
  65. maximumScreenSpaceError: createPropertyDescriptor("maximumScreenSpaceError"),
  66. });
  67. /**
  68. * Duplicates this instance.
  69. *
  70. * @param {Cesium3DTilesetGraphics} [result] The object onto which to store the result.
  71. * @returns {Cesium3DTilesetGraphics} The modified result parameter or a new instance if one was not provided.
  72. */
  73. Cesium3DTilesetGraphics.prototype.clone = function (result) {
  74. if (!defined(result)) {
  75. return new Cesium3DTilesetGraphics(this);
  76. }
  77. result.show = this.show;
  78. result.uri = this.uri;
  79. result.maximumScreenSpaceError = this.maximumScreenSpaceError;
  80. return result;
  81. };
  82. /**
  83. * Assigns each unassigned property on this object to the value
  84. * of the same property on the provided source object.
  85. *
  86. * @param {Cesium3DTilesetGraphics} source The object to be merged into this object.
  87. */
  88. Cesium3DTilesetGraphics.prototype.merge = function (source) {
  89. //>>includeStart('debug', pragmas.debug);
  90. if (!defined(source)) {
  91. throw new DeveloperError("source is required.");
  92. }
  93. //>>includeEnd('debug');
  94. this.show = defaultValue(this.show, source.show);
  95. this.uri = defaultValue(this.uri, source.uri);
  96. this.maximumScreenSpaceError = defaultValue(
  97. this.maximumScreenSpaceError,
  98. source.maximumScreenSpaceError
  99. );
  100. };
  101. export default Cesium3DTilesetGraphics;