-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Expand file tree
/
Copy pathBufferPointMaterial.js
More file actions
95 lines (83 loc) · 2.7 KB
/
BufferPointMaterial.js
File metadata and controls
95 lines (83 loc) · 2.7 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
94
95
// @ts-check
import Frozen from "../Core/Frozen.js";
import BufferPrimitiveMaterial from "./BufferPrimitiveMaterial.js";
/** @import Color from "../Core/Color.js"; */
/** @import BufferPoint from "./BufferPoint.js"; */
/**
* @typedef {object} BufferPointMaterialOptions
* @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} [pixelSize=1.0] Size of point, 0-255px.
*/
/**
* Material description for a {@link BufferPoint}.
*
* <p>BufferPointMaterial objects are {@link Packable|packable}, stored
* when calling {@link BufferPoint#setMaterial}. Subsequent changes to the
* material will not affect the point 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 BufferPointMaterial extends BufferPrimitiveMaterial {
/** @ignore */
static Layout = {
...BufferPrimitiveMaterial.Layout,
PIXEL_SIZE_U8: BufferPrimitiveMaterial.Layout.__BYTE_LENGTH,
__BYTE_LENGTH: BufferPrimitiveMaterial.Layout.__BYTE_LENGTH + 4,
};
/**
* @type {BufferPointMaterial}
* @ignore
*/
static DEFAULT_MATERIAL = Object.freeze(new BufferPointMaterial());
/**
* @param {BufferPointMaterialOptions} [options]
*/
constructor(options = Frozen.EMPTY_OBJECT) {
super(options);
/**
* Size of point, 0-255px.
* @type {number}
*/
this.pixelSize = options.pixelSize ?? 1;
}
/**
* @override
* @param {BufferPointMaterial} material
* @param {DataView} view
* @param {number} byteOffset
* @override
*/
static pack(material, view, byteOffset) {
super.pack(material, view, byteOffset);
view.setUint8(this.Layout.PIXEL_SIZE_U8 + byteOffset, material.pixelSize);
}
/**
* @override
* @param {DataView} view
* @param {number} byteOffset
* @param {BufferPointMaterial} result
* @returns {BufferPointMaterial}
* @override
*/
static unpack(view, byteOffset, result) {
super.unpack(view, byteOffset, result);
result.pixelSize = view.getUint8(this.Layout.PIXEL_SIZE_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(), pixelSize: this.pixelSize };
}
}
export default BufferPointMaterial;