-
Notifications
You must be signed in to change notification settings - Fork 3.5k
/
ShowGeometryInstanceAttribute.js
136 lines (128 loc) · 4.31 KB
/
ShowGeometryInstanceAttribute.js
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
127
128
129
130
131
132
133
134
135
136
/*global define*/
define([
'./ComponentDatatype',
'./defaultValue',
'./defined',
'./defineProperties',
'./DeveloperError'
], function(
ComponentDatatype,
defaultValue,
defined,
defineProperties,
DeveloperError) {
"use strict";
/**
* Value and type information for per-instance geometry attribute that determines if the geometry instance will be shown.
*
* @alias ShowGeometryInstanceAttribute
* @constructor
*
* @param {Boolean} [show=true] Determines if the geometry instance will be shown.
*
*
* @example
* var instance = new Cesium.GeometryInstance({
* geometry : new Cesium.BoxGeometry({
* vertexFormat : Cesium.VertexFormat.POSITION_AND_NORMAL,
* dimensions : new Cesium.Cartesian3(1000000.0, 1000000.0, 500000.0),
* minimum : new Cesium.Cartesian3(-250000.0, -250000.0, -250000.0),
* maximum : new Cesium.Cartesian3(250000.0, 250000.0, 250000.0)
* }),
* modelMatrix : Cesium.Matrix4.multiplyByTranslation(Cesium.Transforms.eastNorthUpToFixedFrame(
* Cesium.Cartesian3.fromDegrees(-75.59777, 40.03883)), new Cesium.Cartesian3(0.0, 0.0, 1000000.0), new Cesium.Matrix4()),
* id : 'box',
* attributes : {
* show : new Cesium.ShowGeometryInstanceAttribute(false)
* }
* });
*
* @see GeometryInstance
* @see GeometryInstanceAttribute
*/
function ShowGeometryInstanceAttribute(show) {
show = defaultValue(show, true);
/**
* The values for the attributes stored in a typed array.
*
* @type Uint8Array
*
* @default [1.0]
*/
this.value = ShowGeometryInstanceAttribute.toValue(show);
}
defineProperties(ShowGeometryInstanceAttribute.prototype, {
/**
* The datatype of each component in the attribute, e.g., individual elements in
* {@link ColorGeometryInstanceAttribute#value}.
*
* @memberof ShowGeometryInstanceAttribute.prototype
*
* @type {ComponentDatatype}
* @readonly
*
* @default {@link ComponentDatatype.UNSIGNED_BYTE}
*/
componentDatatype : {
get : function() {
return ComponentDatatype.UNSIGNED_BYTE;
}
},
/**
* The number of components in the attributes, i.e., {@link ColorGeometryInstanceAttribute#value}.
*
* @memberof ShowGeometryInstanceAttribute.prototype
*
* @type {Number}
* @readonly
*
* @default 1
*/
componentsPerAttribute : {
get : function() {
return 1;
}
},
/**
* 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 ShowGeometryInstanceAttribute.prototype
*
* @type {Boolean}
* @readonly
*
* @default true
*/
normalize : {
get : function() {
return false;
}
}
});
/**
* Converts a boolean show to a typed array that can be used to assign a show attribute.
*
* @param {Boolean} show The show value.
* @param {Uint8Array} [result] The array to store the result in, if undefined a new instance will be created.
* @returns {Uint8Array} The modified result parameter or a new instance if result was undefined.
*
* @example
* var attributes = primitive.getGeometryInstanceAttributes('an id');
* attributes.show = Cesium.ShowGeometryInstanceAttribute.toValue(true, attributes.show);
*/
ShowGeometryInstanceAttribute.toValue = function(show, result) {
//>>includeStart('debug', pragmas.debug);
if (!defined(show)) {
throw new DeveloperError('show is required.');
}
//>>includeEnd('debug');
if (!defined(result)) {
return new Uint8Array([show]);
}
result[0] = show;
return result;
};
return ShowGeometryInstanceAttribute;
});