15832144755
2022-01-06 7b4c8991dca9cf2a809a95e239d144697d3afb56
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
import Check from "./Check.js";
import ComponentDatatype from "./ComponentDatatype.js";
import defaultValue from "./defaultValue.js";
import defined from "./defined.js";
 
/**
 * Value and type information for per-instance geometry attribute that determines the geometry instance offset
 *
 * @alias OffsetGeometryInstanceAttribute
 * @constructor
 *
 * @param {Number} [x=0] The x translation
 * @param {Number} [y=0] The y translation
 * @param {Number} [z=0] The z translation
 *
 * @private
 *
 * @see GeometryInstance
 * @see GeometryInstanceAttribute
 */
function OffsetGeometryInstanceAttribute(x, y, z) {
  x = defaultValue(x, 0);
  y = defaultValue(y, 0);
  z = defaultValue(z, 0);
 
  /**
   * The values for the attributes stored in a typed array.
   *
   * @type Float32Array
   */
  this.value = new Float32Array([x, y, z]);
}
 
Object.defineProperties(OffsetGeometryInstanceAttribute.prototype, {
  /**
   * The datatype of each component in the attribute, e.g., individual elements in
   * {@link OffsetGeometryInstanceAttribute#value}.
   *
   * @memberof OffsetGeometryInstanceAttribute.prototype
   *
   * @type {ComponentDatatype}
   * @readonly
   *
   * @default {@link ComponentDatatype.FLOAT}
   */
  componentDatatype: {
    get: function () {
      return ComponentDatatype.FLOAT;
    },
  },
 
  /**
   * The number of components in the attributes, i.e., {@link OffsetGeometryInstanceAttribute#value}.
   *
   * @memberof OffsetGeometryInstanceAttribute.prototype
   *
   * @type {Number}
   * @readonly
   *
   * @default 3
   */
  componentsPerAttribute: {
    get: function () {
      return 3;
    },
  },
 
  /**
   * When <code>true</code> and <code>componentDatatype</code> is an integer format,
   * indicate that the components should be mapped to the range [0, 1] (unsigned)
   * or [-1, 1] (signed) when they are accessed as floating-point for rendering.
   *
   * @memberof OffsetGeometryInstanceAttribute.prototype
   *
   * @type {Boolean}
   * @readonly
   *
   * @default false
   */
  normalize: {
    get: function () {
      return false;
    },
  },
});
 
/**
 * Creates a new {@link OffsetGeometryInstanceAttribute} instance given the provided an enabled flag and {@link DistanceDisplayCondition}.
 *
 * @param {Cartesian3} offset The cartesian offset
 * @returns {OffsetGeometryInstanceAttribute} The new {@link OffsetGeometryInstanceAttribute} instance.
 */
OffsetGeometryInstanceAttribute.fromCartesian3 = function (offset) {
  //>>includeStart('debug', pragmas.debug);
  Check.defined("offset", offset);
  //>>includeEnd('debug');
 
  return new OffsetGeometryInstanceAttribute(offset.x, offset.y, offset.z);
};
 
/**
 * Converts a distance display condition to a typed array that can be used to assign a distance display condition attribute.
 *
 * @param {Cartesian3} offset The cartesian offset
 * @param {Float32Array} [result] The array to store the result in, if undefined a new instance will be created.
 * @returns {Float32Array} The modified result parameter or a new instance if result was undefined.
 *
 * @example
 * var attributes = primitive.getGeometryInstanceAttributes('an id');
 * attributes.modelMatrix = Cesium.OffsetGeometryInstanceAttribute.toValue(modelMatrix, attributes.modelMatrix);
 */
OffsetGeometryInstanceAttribute.toValue = function (offset, result) {
  //>>includeStart('debug', pragmas.debug);
  Check.defined("offset", offset);
  //>>includeEnd('debug');
 
  if (!defined(result)) {
    result = new Float32Array([offset.x, offset.y, offset.z]);
  }
 
  result[0] = offset.x;
  result[1] = offset.y;
  result[2] = offset.z;
  return result;
};
export default OffsetGeometryInstanceAttribute;