智慧水务管理系统 - 精河县供水工程综合管理平台

PropertyAttributeProperty.js 4.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. import Check from "../Core/Check.js";
  2. import Frozen from "../Core/Frozen.js";
  3. import defined from "../Core/defined.js";
  4. /**
  5. * A property in a property attribute from EXT_structural_metadata.
  6. *
  7. * <p>
  8. * See the {@link https://github.com/CesiumGS/glTF/tree/3d-tiles-next/extensions/2.0/Vendor/EXT_structural_metadata|EXT_structural_metadata Extension}
  9. * </p>
  10. *
  11. * @param {object} options Object with the following properties:
  12. * @param {object} options.property The property JSON object.
  13. * @param {MetadataClassProperty} options.classProperty The class property.
  14. *
  15. * @alias PropertyAttributeProperty
  16. * @constructor
  17. *
  18. * @private
  19. * @experimental This feature is using part of the 3D Tiles spec that is not final and is subject to change without Cesium's standard deprecation policy.
  20. */
  21. function PropertyAttributeProperty(options) {
  22. options = options ?? Frozen.EMPTY_OBJECT;
  23. const property = options.property;
  24. const classProperty = options.classProperty;
  25. //>>includeStart('debug', pragmas.debug);
  26. Check.typeOf.object("options.property", property);
  27. Check.typeOf.object("options.classProperty", classProperty);
  28. //>>includeEnd('debug');
  29. this._attribute = property.attribute;
  30. this._classProperty = classProperty;
  31. this._min = property.min;
  32. this._max = property.max;
  33. let offset = property.offset;
  34. let scale = property.scale;
  35. // This needs to be set before handling default values
  36. const hasValueTransform =
  37. classProperty.hasValueTransform || defined(offset) || defined(scale);
  38. // If the property attribute does not define an offset/scale, it inherits from
  39. // the class property. The class property handles setting the default of
  40. // identity: (offset 0, scale 1) with the same scalar/vector/matrix types.
  41. // array types are disallowed by the spec.
  42. offset = offset ?? classProperty.offset;
  43. scale = scale ?? classProperty.scale;
  44. // offset and scale are applied on the GPU, so unpack the values
  45. // as math types we can use in uniform callbacks.
  46. offset = classProperty.unpackVectorAndMatrixTypes(offset);
  47. scale = classProperty.unpackVectorAndMatrixTypes(scale);
  48. this._offset = offset;
  49. this._scale = scale;
  50. this._hasValueTransform = hasValueTransform;
  51. this._extras = property.extras;
  52. this._extensions = property.extensions;
  53. }
  54. Object.defineProperties(PropertyAttributeProperty.prototype, {
  55. /**
  56. * The attribute semantic
  57. *
  58. * @memberof PropertyAttributeProperty.prototype
  59. * @type {string}
  60. * @readonly
  61. * @private
  62. */
  63. attribute: {
  64. get: function () {
  65. return this._attribute;
  66. },
  67. },
  68. /**
  69. * True if offset/scale should be applied. If both offset/scale were
  70. * undefined, they default to identity so this property is set false
  71. *
  72. * @memberof PropertyAttributeProperty.prototype
  73. * @type {boolean}
  74. * @readonly
  75. * @private
  76. */
  77. hasValueTransform: {
  78. get: function () {
  79. return this._hasValueTransform;
  80. },
  81. },
  82. /**
  83. * The offset to be added to property values as part of the value transform.
  84. *
  85. * This is always defined, even when `hasValueTransform` is `false`. If
  86. * the property JSON itself did not define it, then it will inherit the
  87. * value from the `MetadataClassProperty`. There, it also is always
  88. * defined, and initialized to the default value if it was not contained
  89. * in the class property JSON.
  90. *
  91. * @memberof PropertyAttributeProperty.prototype
  92. * @type {number|Cartesian2|Cartesian3|Cartesian4|Matrix2|Matrix3|Matrix4}
  93. * @readonly
  94. * @private
  95. */
  96. offset: {
  97. get: function () {
  98. return this._offset;
  99. },
  100. },
  101. /**
  102. * The scale to be multiplied to property values as part of the value transform.
  103. *
  104. * This is always defined, even when `hasValueTransform` is `false`. If
  105. * the property JSON itself did not define it, then it will inherit the
  106. * value from the `MetadataClassProperty`. There, it also is always
  107. * defined, and initialized to the default value if it was not contained
  108. * in the class property JSON.
  109. *
  110. * @memberof PropertyAttributeProperty.prototype
  111. * @type {number|Cartesian2|Cartesian3|Cartesian4|Matrix2|Matrix3|Matrix4}
  112. * @readonly
  113. * @private
  114. */
  115. scale: {
  116. get: function () {
  117. return this._scale;
  118. },
  119. },
  120. /**
  121. * The properties inherited from this property's class
  122. *
  123. * @memberof PropertyAttributeProperty.prototype
  124. * @type {MetadataClassProperty}
  125. * @readonly
  126. * @private
  127. */
  128. classProperty: {
  129. get: function () {
  130. return this._classProperty;
  131. },
  132. },
  133. /**
  134. * Extra user-defined properties.
  135. *
  136. * @memberof PropertyAttributeProperty.prototype
  137. * @type {*}
  138. * @readonly
  139. * @private
  140. */
  141. extras: {
  142. get: function () {
  143. return this._extras;
  144. },
  145. },
  146. /**
  147. * An object containing extensions.
  148. *
  149. * @memberof PropertyAttributeProperty.prototype
  150. * @type {*}
  151. * @readonly
  152. * @private
  153. */
  154. extensions: {
  155. get: function () {
  156. return this._extensions;
  157. },
  158. },
  159. });
  160. export default PropertyAttributeProperty;