-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Expand file tree
/
Copy pathBufferPolylineMaterial.js
More file actions
93 lines (81 loc) · 2.67 KB
/
BufferPolylineMaterial.js
File metadata and controls
93 lines (81 loc) · 2.67 KB
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
// @ts-check
import Frozen from "../Core/Frozen.js";
import BufferPrimitiveMaterial from "./BufferPrimitiveMaterial.js";
/** @import Color from "../Core/Color.js"; */
/** @import BufferPolyline from "./BufferPolyline.js"; */
/**
* @typedef {object} BufferPolylineMaterialOptions
* @property {Color} [color=Color.WHITE] Color of fill.
* @property {Color} [outlineColor=Color.WHITE] Color of outline.
* @property {number} [outlineWidth=0.0] Width of outline, 0-255px.
* @property {number} [width=1.0] Width of line, 0-255px.
*/
/**
* Material description for a {@link BufferPolyline}.
*
* <p>BufferPolylineMaterial objects are {@link Packable|packable}, stored
* when calling {@link BufferPolyline#setMaterial}. Subsequent changes to the
* material will not affect the polyline until setMaterial() is called again.</p>
*
* @experimental This feature is not final and is subject to change without Cesium's standard deprecation policy.
* @extends BufferPrimitiveMaterial
*/
class BufferPolylineMaterial extends BufferPrimitiveMaterial {
/** @ignore */
static Layout = {
...BufferPrimitiveMaterial.Layout,
WIDTH_U8: BufferPrimitiveMaterial.Layout.__BYTE_LENGTH,
__BYTE_LENGTH: BufferPrimitiveMaterial.Layout.__BYTE_LENGTH + 4,
};
/**
* @type {BufferPolylineMaterial}
* @ignore
*/
static DEFAULT_MATERIAL = Object.freeze(new BufferPolylineMaterial());
/**
* @param {BufferPolylineMaterialOptions} [options]
*/
constructor(options = Frozen.EMPTY_OBJECT) {
super(options);
/**
* Width of polyline, 0–255px.
* @type {number}
*/
this.width = options.width ?? 1;
}
/**
* @param {BufferPolylineMaterial} material
* @param {DataView} view
* @param {number} byteOffset
* @override
*/
static pack(material, view, byteOffset) {
super.pack(material, view, byteOffset);
view.setUint8(this.Layout.WIDTH_U8 + byteOffset, material.width);
}
/**
* @param {DataView} view
* @param {number} byteOffset
* @param {BufferPolylineMaterial} result
* @returns {BufferPolylineMaterial}
* @override
*/
static unpack(view, byteOffset, result) {
super.unpack(view, byteOffset, result);
result.width = view.getUint8(this.Layout.WIDTH_U8 + byteOffset);
return result;
}
/////////////////////////////////////////////////////////////////////////////
// DEBUG
/**
* Returns a JSON-serializable object representing the material. This encoding
* is not memory-efficient, and should generally be used for debugging and
* testing.
*
* @returns {Object} JSON-serializable object.
*/
toJSON() {
return { ...super.toJSON(), width: this.width };
}
}
export default BufferPolylineMaterial;