/
VoxelShapeType.js
105 lines (100 loc) · 2.77 KB
/
VoxelShapeType.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
import DeveloperError from "../Core/DeveloperError.js";
import VoxelBoxShape from "./VoxelBoxShape.js";
import VoxelCylinderShape from "./VoxelCylinderShape.js";
import VoxelEllipsoidShape from "./VoxelEllipsoidShape.js";
/**
* An enum of voxel shapes. The shape controls how the voxel grid is mapped to 3D space.
*
* @enum {string}
*
* @experimental This feature is not final and is subject to change without Cesium's standard deprecation policy.
*/
const VoxelShapeType = {
/**
* A box shape.
*
* @type {string}
* @constant
* @private
*/
BOX: "BOX",
/**
* An ellipsoid shape.
*
* @type {string}
* @constant
* @private
*/
ELLIPSOID: "ELLIPSOID",
/**
* A cylinder shape.
*
* @type {string}
* @constant
* @private
*/
CYLINDER: "CYLINDER",
};
/**
* Gets the minimum bounds.
* @param {VoxelShapeType} shapeType The voxel shape type.
* @returns {Cartesian3} The minimum bounds.
*/
VoxelShapeType.getMinBounds = function (shapeType) {
switch (shapeType) {
case VoxelShapeType.BOX:
return VoxelBoxShape.DefaultMinBounds;
case VoxelShapeType.ELLIPSOID:
return VoxelEllipsoidShape.DefaultMinBounds;
case VoxelShapeType.CYLINDER:
return VoxelCylinderShape.DefaultMinBounds;
//>>includeStart('debug', pragmas.debug);
default:
throw new DeveloperError(`Invalid shape type ${shapeType}`);
//>>includeEnd('debug');
}
};
/**
* Gets the maximum bounds.
* @param {VoxelShapeType} shapeType The voxel shape type.
* @returns {Cartesian3} The maximum bounds.
*/
VoxelShapeType.getMaxBounds = function (shapeType) {
switch (shapeType) {
case VoxelShapeType.BOX:
return VoxelBoxShape.DefaultMaxBounds;
case VoxelShapeType.ELLIPSOID:
return VoxelEllipsoidShape.DefaultMaxBounds;
case VoxelShapeType.CYLINDER:
return VoxelCylinderShape.DefaultMaxBounds;
//>>includeStart('debug', pragmas.debug);
default:
throw new DeveloperError(`Invalid shape type ${shapeType}`);
//>>includeEnd('debug');
}
};
/**
* Converts a shape type to a constructor that can be used to create a shape
* object or get per-shape properties like DefaultMinBounds and
* DefaultMaxBounds.
*
* @param {VoxelShapeType} shapeType The shape type.
* @returns {Function} The shape's constructor.
*
* @private
*/
VoxelShapeType.getShapeConstructor = function (shapeType) {
switch (shapeType) {
case VoxelShapeType.BOX:
return VoxelBoxShape;
case VoxelShapeType.ELLIPSOID:
return VoxelEllipsoidShape;
case VoxelShapeType.CYLINDER:
return VoxelCylinderShape;
//>>includeStart('debug', pragmas.debug);
default:
throw new DeveloperError(`Invalid shape type ${shapeType}`);
//>>includeEnd('debug');
}
};
export default Object.freeze(VoxelShapeType);