Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 | 87x 87x 87x 87x 87x 87x 87x 87x 87x 87x 87x 87x 87x 87x 87x 87x 87x 87x 87x 87x 87x 87x 87x 87x 87x 87x 87x 87x 87x 87x 87x 87x 1x 2x 2x 304x 2x 2x 2x 120x 166x 1x 173x 132x 132x 66x 1x 66x 66x 66x 66x 66x 66x 44x 44x 44x 44x 44x 44x 44x 44x 44x 44x 44x 66x 66x 66x 66x 66x 66x 66x 66x 66x 66x 44x 66x 66x 66x 66x 66x 66x 66x 62x 62x 62x 62x 62x 62x 62x 4x 66x 66x 66x 66x 66x 66x 66x 66x 66x 66x 66x 66x 66x 66x 68x 68x 68x 68x 68x 68x 68x 68x 68x 68x 68x 68x 68x 68x 68x 68x 68x 68x 68x 68x 68x 68x 68x 68x 68x 68x 68x 68x 66x 66x 66x 66x 66x 68x 68x 68x 68x 66x 66x 66x 66x 66x 66x 66x 66x 66x 66x 66x 66x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 66x 66x 218x 298x 298x 298x 298x 298x 6x 6x 6x 6x 109x 109x 109x 109x 109x 109x 109x 109x 109x 106x 106x 212x 212x 148x 148x 212x 148x 148x 106x 2x 2x 2x 2x 2x 2x 109x 3x 3x 3x 6x 6x 6x 6x 6x 6x 1x 388x 1x 387x 387x 2x 387x 387x 387x 82x 82x 82x 82x 82x 82x 82x 82x 82x 82x 82x 82x 91x 91x 91x 88x 3x 2x 89x 80x 3x 77x 26x 26x 77x 77x 1x 76x 76x 76x 76x 76x 76x 81x 81x 76x 76x 76x 49x 47x 76x 66x 76x 66x 76x 66x 76x 49x 184x 27x 109x 76x 381x 381x 381x 1x 1x 380x 380x 380x 380x 379x 302x 302x 299x 1x 39x 1x 38x 1x 43x 1x 87x 87x 87x 87x 87x 87x 87x | import ColorGeometryInstanceAttribute from "../Core/ColorGeometryInstanceAttribute.js";
import combine from "../Core/combine.js";
import Frozen from "../Core/Frozen.js";
import defined from "../Core/defined.js";
import destroyObject from "../Core/destroyObject.js";
import DeveloperError from "../Core/DeveloperError.js";
import GeometryInstance from "../Core/GeometryInstance.js";
import DrawCommand from "../Renderer/DrawCommand.js";
import Pass from "../Renderer/Pass.js";
import RenderState from "../Renderer/RenderState.js";
import ShaderProgram from "../Renderer/ShaderProgram.js";
import ShaderSource from "../Renderer/ShaderSource.js";
import ShadowVolumeAppearanceVS from "../Shaders/ShadowVolumeAppearanceVS.js";
import ShadowVolumeFS from "../Shaders/ShadowVolumeFS.js";
import BlendingState from "./BlendingState.js";
import ClassificationType from "./ClassificationType.js";
import DepthFunction from "./DepthFunction.js";
import PerInstanceColorAppearance from "./PerInstanceColorAppearance.js";
import Primitive from "./Primitive.js";
import SceneMode from "./SceneMode.js";
import ShadowVolumeAppearance from "./ShadowVolumeAppearance.js";
import StencilConstants from "./StencilConstants.js";
import StencilFunction from "./StencilFunction.js";
import StencilOperation from "./StencilOperation.js";
/**
* A classification primitive represents a volume enclosing geometry in the {@link Scene} to be highlighted.
* <p>
* A primitive combines geometry instances with an {@link Appearance} that describes the full shading, including
* {@link Material} and {@link RenderState}. Roughly, the geometry instance defines the structure and placement,
* and the appearance defines the visual characteristics. Decoupling geometry and appearance allows us to mix
* and match most of them and add a new geometry or appearance independently of each other.
* Only {@link PerInstanceColorAppearance} with the same color across all instances is supported at this time when using
* ClassificationPrimitive directly.
* For full {@link Appearance} support when classifying terrain or 3D Tiles use {@link GroundPrimitive} instead.
* </p>
* <p>
* For correct rendering, this feature requires the EXT_frag_depth WebGL extension. For hardware that do not support this extension, there
* will be rendering artifacts for some viewing angles.
* </p>
* <p>
* Valid geometries are {@link BoxGeometry}, {@link CylinderGeometry}, {@link EllipsoidGeometry}, {@link PolylineVolumeGeometry}, and {@link SphereGeometry}.
* </p>
* <p>
* Geometries that follow the surface of the ellipsoid, such as {@link CircleGeometry}, {@link CorridorGeometry}, {@link EllipseGeometry}, {@link PolygonGeometry}, and {@link RectangleGeometry},
* are also valid if they are extruded volumes; otherwise, they will not be rendered.
* </p>
*
* @alias ClassificationPrimitive
* @constructor
*
* @param {object} [options] Object with the following properties:
* @param {Array|GeometryInstance} [options.geometryInstances] The geometry instances to render. This can either be a single instance or an array of length one.
* @param {Appearance} [options.appearance] The appearance used to render the primitive. Defaults to PerInstanceColorAppearance when GeometryInstances have a color attribute.
* @param {boolean} [options.show=true] Determines if this primitive will be shown.
* @param {boolean} [options.vertexCacheOptimize=false] When <code>true</code>, geometry vertices are optimized for the pre and post-vertex-shader caches.
* @param {boolean} [options.interleave=false] When <code>true</code>, geometry vertex attributes are interleaved, which can slightly improve rendering performance but increases load time.
* @param {boolean} [options.compressVertices=true] When <code>true</code>, the geometry vertices are compressed, which will save memory.
* @param {boolean} [options.releaseGeometryInstances=true] When <code>true</code>, the primitive does not keep a reference to the input <code>geometryInstances</code> to save memory.
* @param {boolean} [options.allowPicking=true] When <code>true</code>, each geometry instance will only be pickable with {@link Scene#pick}. When <code>false</code>, GPU memory is saved.
* @param {boolean} [options.asynchronous=true] Determines if the primitive will be created asynchronously or block until ready. If false initializeTerrainHeights() must be called first.
* @param {ClassificationType} [options.classificationType=ClassificationType.BOTH] Determines whether terrain, 3D Tiles or both will be classified.
* @param {boolean} [options.debugShowBoundingVolume=false] For debugging only. Determines if this primitive's commands' bounding spheres are shown.
* @param {boolean} [options.debugShowShadowVolume=false] For debugging only. Determines if the shadow volume for each geometry in the primitive is drawn. Must be <code>true</code> on
* creation for the volumes to be created before the geometry is released or options.releaseGeometryInstance must be <code>false</code>.
*
* @see Primitive
* @see GroundPrimitive
* @see GeometryInstance
* @see Appearance
*/
function ClassificationPrimitive(options) {
options = options ?? Frozen.EMPTY_OBJECT;
const geometryInstances = options.geometryInstances;
/**
* The geometry instance rendered with this primitive. This may
* be <code>undefined</code> if <code>options.releaseGeometryInstances</code>
* is <code>true</code> when the primitive is constructed.
* <p>
* Changing this property after the primitive is rendered has no effect.
* </p>
* <p>
* Because of the rendering technique used, all geometry instances must be the same color.
* If there is an instance with a differing color, a <code>DeveloperError</code> will be thrown
* on the first attempt to render.
* </p>
*
* @readonly
* @type {Array|GeometryInstance}
*
* @default undefined
*/
this.geometryInstances = geometryInstances;
/**
* Determines if the primitive will be shown. This affects all geometry
* instances in the primitive.
*
* @type {boolean}
*
* @default true
*/
this.show = options.show ?? true;
/**
* Determines whether terrain, 3D Tiles or both will be classified.
*
* @type {ClassificationType}
*
* @default ClassificationType.BOTH
*/
this.classificationType =
options.classificationType ?? ClassificationType.BOTH;
/**
* This property is for debugging only; it is not for production use nor is it optimized.
* <p>
* Draws the bounding sphere for each draw command in the primitive.
* </p>
*
* @type {boolean}
*
* @default false
*/
this.debugShowBoundingVolume = options.debugShowBoundingVolume ?? false;
/**
* This property is for debugging only; it is not for production use nor is it optimized.
* <p>
* Draws the shadow volume for each geometry in the primitive.
* </p>
*
* @type {boolean}
*
* @default false
*/
this.debugShowShadowVolume = options.debugShowShadowVolume ?? false;
this._debugShowShadowVolume = false;
// These are used by GroundPrimitive to augment the shader and uniform map.
this._extruded = options._extruded ?? false;
this._uniformMap = options._uniformMap;
this._sp = undefined;
this._spStencil = undefined;
this._spPick = undefined;
this._spColor = undefined;
this._spPick2D = undefined; // only derived if necessary
this._spColor2D = undefined; // only derived if necessary
this._rsStencilDepthPass = undefined;
this._rsStencilDepthPass3DTiles = undefined;
this._rsColorPass = undefined;
this._rsPickPass = undefined;
this._commandsIgnoreShow = [];
this._ready = false;
this._primitive = undefined;
this._pickPrimitive = options._pickPrimitive;
// Set in update
this._hasSphericalExtentsAttribute = false;
this._hasPlanarExtentsAttributes = false;
this._hasPerColorAttribute = false;
this.appearance = options.appearance;
this._createBoundingVolumeFunction = options._createBoundingVolumeFunction;
this._updateAndQueueCommandsFunction =
options._updateAndQueueCommandsFunction;
this._usePickOffsets = false;
this._primitiveOptions = {
geometryInstances: undefined,
appearance: undefined,
vertexCacheOptimize: options.vertexCacheOptimize ?? false,
interleave: options.interleave ?? false,
releaseGeometryInstances: options.releaseGeometryInstances ?? true,
allowPicking: options.allowPicking ?? true,
asynchronous: options.asynchronous ?? true,
compressVertices: options.compressVertices ?? true,
_createBoundingVolumeFunction: undefined,
_createRenderStatesFunction: undefined,
_createShaderProgramFunction: undefined,
_createCommandsFunction: undefined,
_updateAndQueueCommandsFunction: undefined,
_createPickOffsets: true,
};
}
Object.defineProperties(ClassificationPrimitive.prototype, {
/**
* When <code>true</code>, geometry vertices are optimized for the pre and post-vertex-shader caches.
*
* @memberof ClassificationPrimitive.prototype
*
* @type {boolean}
* @readonly
*
* @default true
*/
vertexCacheOptimize: {
get: function () {
return this._primitiveOptions.vertexCacheOptimize;
},
},
/**
* Determines if geometry vertex attributes are interleaved, which can slightly improve rendering performance.
*
* @memberof ClassificationPrimitive.prototype
*
* @type {boolean}
* @readonly
*
* @default false
*/
interleave: {
get: function () {
return this._primitiveOptions.interleave;
},
},
/**
* When <code>true</code>, the primitive does not keep a reference to the input <code>geometryInstances</code> to save memory.
*
* @memberof ClassificationPrimitive.prototype
*
* @type {boolean}
* @readonly
*
* @default true
*/
releaseGeometryInstances: {
get: function () {
return this._primitiveOptions.releaseGeometryInstances;
},
},
/**
* When <code>true</code>, each geometry instance will only be pickable with {@link Scene#pick}. When <code>false</code>, GPU memory is saved.
*
* @memberof ClassificationPrimitive.prototype
*
* @type {boolean}
* @readonly
*
* @default true
*/
allowPicking: {
get: function () {
return this._primitiveOptions.allowPicking;
},
},
/**
* Determines if the geometry instances will be created and batched on a web worker.
*
* @memberof ClassificationPrimitive.prototype
*
* @type {boolean}
* @readonly
*
* @default true
*/
asynchronous: {
get: function () {
return this._primitiveOptions.asynchronous;
},
},
/**
* When <code>true</code>, geometry vertices are compressed, which will save memory.
*
* @memberof ClassificationPrimitive.prototype
*
* @type {boolean}
* @readonly
*
* @default true
*/
compressVertices: {
get: function () {
return this._primitiveOptions.compressVertices;
},
},
/**
* Determines if the primitive is complete and ready to render. If this property is
* true, the primitive will be rendered the next time that {@link ClassificationPrimitive#update}
* is called.
*
* @memberof ClassificationPrimitive.prototype
*
* @type {boolean}
* @readonly
*/
ready: {
get: function () {
return this._ready;
},
},
/**
* Returns true if the ClassificationPrimitive needs a separate shader and commands for 2D.
* This is because texture coordinates on ClassificationPrimitives are computed differently,
* and are used for culling when multiple GeometryInstances are batched in one ClassificationPrimitive.
* @memberof ClassificationPrimitive.prototype
* @type {boolean}
* @readonly
* @private
*/
_needs2DShader: {
get: function () {
return (
this._hasPlanarExtentsAttributes || this._hasSphericalExtentsAttribute
);
},
},
});
/**
* Determines if ClassificationPrimitive rendering is supported.
*
* @param {Scene} scene The scene.
* @returns {boolean} <code>true</code> if ClassificationPrimitives are supported; otherwise, returns <code>false</code>
*/
ClassificationPrimitive.isSupported = function (scene) {
return scene.context.stencilBuffer;
};
function getStencilDepthRenderState(enableStencil, mask3DTiles) {
const stencilFunction = mask3DTiles
? StencilFunction.EQUAL
: StencilFunction.ALWAYS;
return {
colorMask: {
red: false,
green: false,
blue: false,
alpha: false,
},
stencilTest: {
enabled: enableStencil,
frontFunction: stencilFunction,
frontOperation: {
fail: StencilOperation.KEEP,
zFail: StencilOperation.DECREMENT_WRAP,
zPass: StencilOperation.KEEP,
},
backFunction: stencilFunction,
backOperation: {
fail: StencilOperation.KEEP,
zFail: StencilOperation.INCREMENT_WRAP,
zPass: StencilOperation.KEEP,
},
reference: StencilConstants.CESIUM_3D_TILE_MASK,
mask: StencilConstants.CESIUM_3D_TILE_MASK,
},
stencilMask: StencilConstants.CLASSIFICATION_MASK,
depthTest: {
enabled: true,
func: DepthFunction.LESS_OR_EQUAL,
},
depthMask: false,
};
}
function getColorRenderState(enableStencil) {
return {
stencilTest: {
enabled: enableStencil,
frontFunction: StencilFunction.NOT_EQUAL,
frontOperation: {
fail: StencilOperation.ZERO,
zFail: StencilOperation.ZERO,
zPass: StencilOperation.ZERO,
},
backFunction: StencilFunction.NOT_EQUAL,
backOperation: {
fail: StencilOperation.ZERO,
zFail: StencilOperation.ZERO,
zPass: StencilOperation.ZERO,
},
reference: 0,
mask: StencilConstants.CLASSIFICATION_MASK,
},
stencilMask: StencilConstants.CLASSIFICATION_MASK,
depthTest: {
enabled: false,
},
depthMask: false,
blending: BlendingState.PRE_MULTIPLIED_ALPHA_BLEND,
};
}
const pickRenderState = {
stencilTest: {
enabled: true,
frontFunction: StencilFunction.NOT_EQUAL,
frontOperation: {
fail: StencilOperation.ZERO,
zFail: StencilOperation.ZERO,
zPass: StencilOperation.ZERO,
},
backFunction: StencilFunction.NOT_EQUAL,
backOperation: {
fail: StencilOperation.ZERO,
zFail: StencilOperation.ZERO,
zPass: StencilOperation.ZERO,
},
reference: 0,
mask: StencilConstants.CLASSIFICATION_MASK,
},
stencilMask: StencilConstants.CLASSIFICATION_MASK,
depthTest: {
enabled: false,
},
depthMask: false,
};
function createRenderStates(
classificationPrimitive,
context,
appearance,
twoPasses,
) {
Iif (defined(classificationPrimitive._rsStencilDepthPass)) {
return;
}
const stencilEnabled = !classificationPrimitive.debugShowShadowVolume;
classificationPrimitive._rsStencilDepthPass = RenderState.fromCache(
getStencilDepthRenderState(stencilEnabled, false),
);
classificationPrimitive._rsStencilDepthPass3DTiles = RenderState.fromCache(
getStencilDepthRenderState(stencilEnabled, true),
);
classificationPrimitive._rsColorPass = RenderState.fromCache(
getColorRenderState(stencilEnabled, false),
);
classificationPrimitive._rsPickPass = RenderState.fromCache(pickRenderState);
}
function modifyForEncodedNormals(primitive, vertexShaderSource) {
Iif (!primitive.compressVertices) {
return vertexShaderSource;
}
Eif (vertexShaderSource.search(/in\s+vec3\s+extrudeDirection;/g) !== -1) {
const attributeName = "compressedAttributes";
//only shadow volumes use extrudeDirection, and shadow volumes use vertexFormat: POSITION_ONLY so we don't need to check other attributes
const attributeDecl = `in vec2 ${attributeName};`;
const globalDecl = "vec3 extrudeDirection;\n";
const decode = ` extrudeDirection = czm_octDecode(${attributeName}, 65535.0);\n`;
let modifiedVS = vertexShaderSource;
modifiedVS = modifiedVS.replace(/in\s+vec3\s+extrudeDirection;/g, "");
modifiedVS = ShaderSource.replaceMain(
modifiedVS,
"czm_non_compressed_main",
);
const compressedMain =
`${"void main() \n" + "{ \n"}${decode} czm_non_compressed_main(); \n` +
`}`;
return [attributeDecl, globalDecl, modifiedVS, compressedMain].join("\n");
}
}
function createShaderProgram(classificationPrimitive, frameState) {
const context = frameState.context;
const primitive = classificationPrimitive._primitive;
let vs = ShadowVolumeAppearanceVS;
vs =
classificationPrimitive._primitive._batchTable.getVertexShaderCallback()(
vs,
);
vs = Primitive._appendDistanceDisplayConditionToShader(primitive, vs);
vs = Primitive._modifyShaderPosition(
classificationPrimitive,
vs,
frameState.scene3DOnly,
);
vs = Primitive._updateColorAttribute(primitive, vs);
const planarExtents = classificationPrimitive._hasPlanarExtentsAttributes;
const cullFragmentsUsingExtents =
planarExtents || classificationPrimitive._hasSphericalExtentsAttribute;
if (classificationPrimitive._extruded) {
vs = modifyForEncodedNormals(primitive, vs);
}
const extrudedDefine = classificationPrimitive._extruded
? "EXTRUDED_GEOMETRY"
: "";
let vsSource = new ShaderSource({
defines: [extrudedDefine],
sources: [vs],
});
const fsSource = new ShaderSource({
sources: [ShadowVolumeFS],
});
const attributeLocations =
classificationPrimitive._primitive._attributeLocations;
const shadowVolumeAppearance = new ShadowVolumeAppearance(
cullFragmentsUsingExtents,
planarExtents,
classificationPrimitive.appearance,
);
classificationPrimitive._spStencil = ShaderProgram.replaceCache({
context: context,
shaderProgram: classificationPrimitive._spStencil,
vertexShaderSource: vsSource,
fragmentShaderSource: fsSource,
attributeLocations: attributeLocations,
});
if (classificationPrimitive._primitive.allowPicking) {
let vsPick = ShaderSource.createPickVertexShaderSource(vs);
vsPick = Primitive._appendShowToShader(primitive, vsPick);
vsPick = Primitive._updatePickColorAttribute(vsPick);
const pickFS3D = shadowVolumeAppearance.createPickFragmentShader(false);
const pickVS3D = shadowVolumeAppearance.createPickVertexShader(
[extrudedDefine],
vsPick,
false,
frameState.mapProjection,
);
classificationPrimitive._spPick = ShaderProgram.replaceCache({
context: context,
shaderProgram: classificationPrimitive._spPick,
vertexShaderSource: pickVS3D,
fragmentShaderSource: pickFS3D,
attributeLocations: attributeLocations,
});
// Derive a 2D pick shader if the primitive uses texture coordinate-based fragment culling,
// since texture coordinates are computed differently in 2D.
Iif (cullFragmentsUsingExtents) {
let pickProgram2D = context.shaderCache.getDerivedShaderProgram(
classificationPrimitive._spPick,
"2dPick",
);
if (!defined(pickProgram2D)) {
const pickFS2D = shadowVolumeAppearance.createPickFragmentShader(true);
const pickVS2D = shadowVolumeAppearance.createPickVertexShader(
[extrudedDefine],
vsPick,
true,
frameState.mapProjection,
);
pickProgram2D = context.shaderCache.createDerivedShaderProgram(
classificationPrimitive._spPick,
"2dPick",
{
vertexShaderSource: pickVS2D,
fragmentShaderSource: pickFS2D,
attributeLocations: attributeLocations,
},
);
}
classificationPrimitive._spPick2D = pickProgram2D;
}
} else {
classificationPrimitive._spPick = ShaderProgram.fromCache({
context: context,
vertexShaderSource: vsSource,
fragmentShaderSource: fsSource,
attributeLocations: attributeLocations,
});
}
vs = Primitive._appendShowToShader(primitive, vs);
vsSource = new ShaderSource({
defines: [extrudedDefine],
sources: [vs],
});
classificationPrimitive._sp = ShaderProgram.replaceCache({
context: context,
shaderProgram: classificationPrimitive._sp,
vertexShaderSource: vsSource,
fragmentShaderSource: fsSource,
attributeLocations: attributeLocations,
});
// Create a fragment shader that computes only required material hookups using screen space techniques
const fsColorSource = shadowVolumeAppearance.createFragmentShader(false);
const vsColorSource = shadowVolumeAppearance.createVertexShader(
[extrudedDefine],
vs,
false,
frameState.mapProjection,
);
classificationPrimitive._spColor = ShaderProgram.replaceCache({
context: context,
shaderProgram: classificationPrimitive._spColor,
vertexShaderSource: vsColorSource,
fragmentShaderSource: fsColorSource,
attributeLocations: attributeLocations,
});
// Derive a 2D shader if the primitive uses texture coordinate-based fragment culling,
// since texture coordinates are computed differently in 2D.
// Any material that uses texture coordinates will also equip texture coordinate-based fragment culling.
Iif (cullFragmentsUsingExtents) {
let colorProgram2D = context.shaderCache.getDerivedShaderProgram(
classificationPrimitive._spColor,
"2dColor",
);
if (!defined(colorProgram2D)) {
const fsColorSource2D = shadowVolumeAppearance.createFragmentShader(true);
const vsColorSource2D = shadowVolumeAppearance.createVertexShader(
[extrudedDefine],
vs,
true,
frameState.mapProjection,
);
colorProgram2D = context.shaderCache.createDerivedShaderProgram(
classificationPrimitive._spColor,
"2dColor",
{
vertexShaderSource: vsColorSource2D,
fragmentShaderSource: fsColorSource2D,
attributeLocations: attributeLocations,
},
);
}
classificationPrimitive._spColor2D = colorProgram2D;
}
}
function createColorCommands(classificationPrimitive, colorCommands) {
const primitive = classificationPrimitive._primitive;
let length = primitive._va.length * 2; // each geometry (pack of vertex attributes) needs 2 commands: front/back stencils and fill
colorCommands.length = length;
let i;
let command;
let derivedCommand;
let vaIndex = 0;
let uniformMap = primitive._batchTable.getUniformMapCallback()(
classificationPrimitive._uniformMap,
);
const needs2DShader = classificationPrimitive._needs2DShader;
for (i = 0; i < length; i += 2) {
const vertexArray = primitive._va[vaIndex++];
// Stencil depth command
command = colorCommands[i];
Eif (!defined(command)) {
command = colorCommands[i] = new DrawCommand({
owner: classificationPrimitive,
primitiveType: primitive._primitiveType,
});
}
command.vertexArray = vertexArray;
command.renderState = classificationPrimitive._rsStencilDepthPass;
command.shaderProgram = classificationPrimitive._sp;
command.uniformMap = uniformMap;
command.pass = Pass.TERRAIN_CLASSIFICATION;
derivedCommand = DrawCommand.shallowClone(
command,
command.derivedCommands.tileset,
);
derivedCommand.renderState =
classificationPrimitive._rsStencilDepthPass3DTiles;
derivedCommand.pass = Pass.CESIUM_3D_TILE_CLASSIFICATION;
command.derivedCommands.tileset = derivedCommand;
// Color command
command = colorCommands[i + 1];
Eif (!defined(command)) {
command = colorCommands[i + 1] = new DrawCommand({
owner: classificationPrimitive,
primitiveType: primitive._primitiveType,
});
}
command.vertexArray = vertexArray;
command.renderState = classificationPrimitive._rsColorPass;
command.shaderProgram = classificationPrimitive._spColor;
command.pass = Pass.TERRAIN_CLASSIFICATION;
const appearance = classificationPrimitive.appearance;
const material = appearance.material;
Iif (defined(material)) {
uniformMap = combine(uniformMap, material._uniforms);
}
command.uniformMap = uniformMap;
derivedCommand = DrawCommand.shallowClone(
command,
command.derivedCommands.tileset,
);
derivedCommand.pass = Pass.CESIUM_3D_TILE_CLASSIFICATION;
command.derivedCommands.tileset = derivedCommand;
// Derive for 2D if texture coordinates are ever computed
Iif (needs2DShader) {
// First derive from the terrain command
let derived2DCommand = DrawCommand.shallowClone(
command,
command.derivedCommands.appearance2D,
);
derived2DCommand.shaderProgram = classificationPrimitive._spColor2D;
command.derivedCommands.appearance2D = derived2DCommand;
// Then derive from the 3D Tiles command
derived2DCommand = DrawCommand.shallowClone(
derivedCommand,
derivedCommand.derivedCommands.appearance2D,
);
derived2DCommand.shaderProgram = classificationPrimitive._spColor2D;
derivedCommand.derivedCommands.appearance2D = derived2DCommand;
}
}
const commandsIgnoreShow = classificationPrimitive._commandsIgnoreShow;
const spStencil = classificationPrimitive._spStencil;
let commandIndex = 0;
length = commandsIgnoreShow.length = length / 2;
for (let j = 0; j < length; ++j) {
const commandIgnoreShow = (commandsIgnoreShow[j] = DrawCommand.shallowClone(
colorCommands[commandIndex],
commandsIgnoreShow[j],
));
commandIgnoreShow.shaderProgram = spStencil;
commandIgnoreShow.pass = Pass.CESIUM_3D_TILE_CLASSIFICATION_IGNORE_SHOW;
commandIndex += 2;
}
}
function createPickCommands(classificationPrimitive, pickCommands) {
const usePickOffsets = classificationPrimitive._usePickOffsets;
const primitive = classificationPrimitive._primitive;
let length = primitive._va.length * 2; // each geometry (pack of vertex attributes) needs 2 commands: front/back stencils and fill
// Fallback for batching same-color geometry instances
let pickOffsets;
let pickIndex = 0;
let pickOffset;
Eif (usePickOffsets) {
pickOffsets = primitive._pickOffsets;
length = pickOffsets.length * 2;
}
pickCommands.length = length;
let j;
let command;
let derivedCommand;
let vaIndex = 0;
const uniformMap = primitive._batchTable.getUniformMapCallback()(
classificationPrimitive._uniformMap,
);
const needs2DShader = classificationPrimitive._needs2DShader;
for (j = 0; j < length; j += 2) {
let vertexArray = primitive._va[vaIndex++];
Eif (usePickOffsets) {
pickOffset = pickOffsets[pickIndex++];
vertexArray = primitive._va[pickOffset.index];
}
// Stencil depth command
command = pickCommands[j];
Eif (!defined(command)) {
command = pickCommands[j] = new DrawCommand({
owner: classificationPrimitive,
primitiveType: primitive._primitiveType,
pickOnly: true,
});
}
command.vertexArray = vertexArray;
command.renderState = classificationPrimitive._rsStencilDepthPass;
command.shaderProgram = classificationPrimitive._sp;
command.uniformMap = uniformMap;
command.pass = Pass.TERRAIN_CLASSIFICATION;
Eif (usePickOffsets) {
command.offset = pickOffset.offset;
command.count = pickOffset.count;
}
// Derive for 3D Tiles classification
derivedCommand = DrawCommand.shallowClone(
command,
command.derivedCommands.tileset,
);
derivedCommand.renderState =
classificationPrimitive._rsStencilDepthPass3DTiles;
derivedCommand.pass = Pass.CESIUM_3D_TILE_CLASSIFICATION;
command.derivedCommands.tileset = derivedCommand;
// Pick color command
command = pickCommands[j + 1];
Eif (!defined(command)) {
command = pickCommands[j + 1] = new DrawCommand({
owner: classificationPrimitive,
primitiveType: primitive._primitiveType,
pickOnly: true,
});
}
command.vertexArray = vertexArray;
command.renderState = classificationPrimitive._rsPickPass;
command.shaderProgram = classificationPrimitive._spPick;
command.uniformMap = uniformMap;
command.pass = Pass.TERRAIN_CLASSIFICATION;
Eif (usePickOffsets) {
command.offset = pickOffset.offset;
command.count = pickOffset.count;
}
derivedCommand = DrawCommand.shallowClone(
command,
command.derivedCommands.tileset,
);
derivedCommand.pass = Pass.CESIUM_3D_TILE_CLASSIFICATION;
command.derivedCommands.tileset = derivedCommand;
// Derive for 2D if texture coordinates are ever computed
Iif (needs2DShader) {
// First derive from the terrain command
let derived2DCommand = DrawCommand.shallowClone(
command,
command.derivedCommands.pick2D,
);
derived2DCommand.shaderProgram = classificationPrimitive._spPick2D;
command.derivedCommands.pick2D = derived2DCommand;
// Then derive from the 3D Tiles command
derived2DCommand = DrawCommand.shallowClone(
derivedCommand,
derivedCommand.derivedCommands.pick2D,
);
derived2DCommand.shaderProgram = classificationPrimitive._spPick2D;
derivedCommand.derivedCommands.pick2D = derived2DCommand;
}
}
}
function createCommands(
classificationPrimitive,
appearance,
material,
translucent,
twoPasses,
colorCommands,
pickCommands,
) {
createColorCommands(classificationPrimitive, colorCommands);
createPickCommands(classificationPrimitive, pickCommands);
}
function boundingVolumeIndex(commandIndex, length) {
return Math.floor((commandIndex % length) / 2);
}
function updateAndQueueRenderCommand(
command,
frameState,
modelMatrix,
cull,
boundingVolume,
debugShowBoundingVolume,
) {
command.modelMatrix = modelMatrix;
command.boundingVolume = boundingVolume;
command.cull = cull;
command.debugShowBoundingVolume = debugShowBoundingVolume;
frameState.commandList.push(command);
}
function updateAndQueuePickCommand(
command,
frameState,
modelMatrix,
cull,
boundingVolume,
) {
command.modelMatrix = modelMatrix;
command.boundingVolume = boundingVolume;
command.cull = cull;
frameState.commandList.push(command);
}
function updateAndQueueCommands(
classificationPrimitive,
frameState,
colorCommands,
pickCommands,
modelMatrix,
cull,
debugShowBoundingVolume,
twoPasses,
) {
const primitive = classificationPrimitive._primitive;
Primitive._updateBoundingVolumes(primitive, frameState, modelMatrix);
let boundingVolumes;
if (frameState.mode === SceneMode.SCENE3D) {
boundingVolumes = primitive._boundingSphereWC;
} else Eif (frameState.mode === SceneMode.COLUMBUS_VIEW) {
boundingVolumes = primitive._boundingSphereCV;
} else if (
frameState.mode === SceneMode.SCENE2D &&
defined(primitive._boundingSphere2D)
) {
boundingVolumes = primitive._boundingSphere2D;
} else if (defined(primitive._boundingSphereMorph)) {
boundingVolumes = primitive._boundingSphereMorph;
}
const classificationType = classificationPrimitive.classificationType;
const queueTerrainCommands =
classificationType !== ClassificationType.CESIUM_3D_TILE;
const queue3DTilesCommands =
classificationType !== ClassificationType.TERRAIN;
const passes = frameState.passes;
let i;
let boundingVolume;
let command;
if (passes.render) {
const colorLength = colorCommands.length;
for (i = 0; i < colorLength; ++i) {
boundingVolume = boundingVolumes[boundingVolumeIndex(i, colorLength)];
if (queueTerrainCommands) {
command = colorCommands[i];
updateAndQueueRenderCommand(
command,
frameState,
modelMatrix,
cull,
boundingVolume,
debugShowBoundingVolume,
);
}
if (queue3DTilesCommands) {
command = colorCommands[i].derivedCommands.tileset;
updateAndQueueRenderCommand(
command,
frameState,
modelMatrix,
cull,
boundingVolume,
debugShowBoundingVolume,
);
}
}
if (frameState.invertClassification) {
const ignoreShowCommands = classificationPrimitive._commandsIgnoreShow;
const ignoreShowCommandsLength = ignoreShowCommands.length;
for (i = 0; i < ignoreShowCommandsLength; ++i) {
boundingVolume = boundingVolumes[i];
command = ignoreShowCommands[i];
updateAndQueueRenderCommand(
command,
frameState,
modelMatrix,
cull,
boundingVolume,
debugShowBoundingVolume,
);
}
}
}
if (passes.pick) {
const pickLength = pickCommands.length;
const pickOffsets = primitive._pickOffsets;
for (i = 0; i < pickLength; ++i) {
const pickOffset = pickOffsets[boundingVolumeIndex(i, pickLength)];
boundingVolume = boundingVolumes[pickOffset.index];
Eif (queueTerrainCommands) {
command = pickCommands[i];
updateAndQueuePickCommand(
command,
frameState,
modelMatrix,
cull,
boundingVolume,
);
}
Iif (queue3DTilesCommands) {
command = pickCommands[i].derivedCommands.tileset;
updateAndQueuePickCommand(
command,
frameState,
modelMatrix,
cull,
boundingVolume,
);
}
}
}
}
/**
* Called when {@link Viewer} or {@link CesiumWidget} render the scene to
* get the draw commands needed to render this primitive.
* <p>
* Do not call this function directly. This is documented just to
* list the exceptions that may be propagated when the scene is rendered:
* </p>
*
* @exception {DeveloperError} All instance geometries must have the same primitiveType.
* @exception {DeveloperError} Appearance and material have a uniform with the same name.
* @exception {DeveloperError} Not all of the geometry instances have the same color attribute.
*/
ClassificationPrimitive.prototype.update = function (frameState) {
if (!defined(this._primitive) && !defined(this.geometryInstances)) {
return;
}
let appearance = this.appearance;
if (defined(appearance) && defined(appearance.material)) {
appearance.material.update(frameState.context);
}
const that = this;
const primitiveOptions = this._primitiveOptions;
if (!defined(this._primitive)) {
const instances = Array.isArray(this.geometryInstances)
? this.geometryInstances
: [this.geometryInstances];
const length = instances.length;
let i;
let instance;
let attributes;
let hasPerColorAttribute = false;
let allColorsSame = true;
let firstColor;
let hasSphericalExtentsAttribute = false;
let hasPlanarExtentsAttributes = false;
Eif (length > 0) {
attributes = instances[0].attributes;
// Not expecting these to be set by users, should only be set via GroundPrimitive.
// So don't check for mismatch.
hasSphericalExtentsAttribute =
ShadowVolumeAppearance.hasAttributesForSphericalExtents(attributes);
hasPlanarExtentsAttributes =
ShadowVolumeAppearance.hasAttributesForTextureCoordinatePlanes(
attributes,
);
firstColor = attributes.color;
}
for (i = 0; i < length; i++) {
instance = instances[i];
const color = instance.attributes.color;
if (defined(color)) {
hasPerColorAttribute = true;
}
//>>includeStart('debug', pragmas.debug);
else if (hasPerColorAttribute) {
throw new DeveloperError(
"All GeometryInstances must have color attributes to use per-instance color.",
);
}
//>>includeEnd('debug');
allColorsSame =
allColorsSame &&
defined(color) &&
ColorGeometryInstanceAttribute.equals(firstColor, color);
}
// If no attributes exist for computing spherical extents or fragment culling,
// throw if the colors aren't all the same.
if (
!allColorsSame &&
!hasSphericalExtentsAttribute &&
!hasPlanarExtentsAttributes
) {
throw new DeveloperError(
"All GeometryInstances must have the same color attribute except via GroundPrimitives",
);
}
// default to a color appearance
if (hasPerColorAttribute && !defined(appearance)) {
appearance = new PerInstanceColorAppearance({
flat: true,
});
this.appearance = appearance;
}
//>>includeStart('debug', pragmas.debug);
Iif (
!hasPerColorAttribute &&
appearance instanceof PerInstanceColorAppearance
) {
throw new DeveloperError(
"PerInstanceColorAppearance requires color GeometryInstanceAttributes on all GeometryInstances",
);
}
if (
defined(appearance.material) &&
!hasSphericalExtentsAttribute &&
!hasPlanarExtentsAttributes
) {
throw new DeveloperError(
"Materials on ClassificationPrimitives are not supported except via GroundPrimitives",
);
}
//>>includeEnd('debug');
this._usePickOffsets =
!hasSphericalExtentsAttribute && !hasPlanarExtentsAttributes;
this._hasSphericalExtentsAttribute = hasSphericalExtentsAttribute;
this._hasPlanarExtentsAttributes = hasPlanarExtentsAttributes;
this._hasPerColorAttribute = hasPerColorAttribute;
const geometryInstances = new Array(length);
for (i = 0; i < length; ++i) {
instance = instances[i];
geometryInstances[i] = new GeometryInstance({
geometry: instance.geometry,
attributes: instance.attributes,
modelMatrix: instance.modelMatrix,
id: instance.id,
pickPrimitive: this._pickPrimitive ?? that,
});
}
primitiveOptions.appearance = appearance;
primitiveOptions.geometryInstances = geometryInstances;
if (defined(this._createBoundingVolumeFunction)) {
primitiveOptions._createBoundingVolumeFunction = function (
frameState,
geometry,
) {
that._createBoundingVolumeFunction(frameState, geometry);
};
}
primitiveOptions._createRenderStatesFunction = function (
primitive,
context,
appearance,
twoPasses,
) {
createRenderStates(that, context);
};
primitiveOptions._createShaderProgramFunction = function (
primitive,
frameState,
appearance,
) {
createShaderProgram(that, frameState);
};
primitiveOptions._createCommandsFunction = function (
primitive,
appearance,
material,
translucent,
twoPasses,
colorCommands,
pickCommands,
) {
createCommands(
that,
undefined,
undefined,
true,
false,
colorCommands,
pickCommands,
);
};
if (defined(this._updateAndQueueCommandsFunction)) {
primitiveOptions._updateAndQueueCommandsFunction = function (
primitive,
frameState,
colorCommands,
pickCommands,
modelMatrix,
cull,
debugShowBoundingVolume,
twoPasses,
) {
that._updateAndQueueCommandsFunction(
primitive,
frameState,
colorCommands,
pickCommands,
modelMatrix,
cull,
debugShowBoundingVolume,
twoPasses,
);
};
} else {
primitiveOptions._updateAndQueueCommandsFunction = function (
primitive,
frameState,
colorCommands,
pickCommands,
modelMatrix,
cull,
debugShowBoundingVolume,
twoPasses,
) {
updateAndQueueCommands(
that,
frameState,
colorCommands,
pickCommands,
modelMatrix,
cull,
debugShowBoundingVolume,
twoPasses,
);
};
}
this._primitive = new Primitive(primitiveOptions);
}
Iif (
this.debugShowShadowVolume &&
!this._debugShowShadowVolume &&
this._ready
) {
this._debugShowShadowVolume = true;
this._rsStencilDepthPass = RenderState.fromCache(
getStencilDepthRenderState(false, false),
);
this._rsStencilDepthPass3DTiles = RenderState.fromCache(
getStencilDepthRenderState(false, true),
);
this._rsColorPass = RenderState.fromCache(getColorRenderState(false));
} else Iif (!this.debugShowShadowVolume && this._debugShowShadowVolume) {
this._debugShowShadowVolume = false;
this._rsStencilDepthPass = RenderState.fromCache(
getStencilDepthRenderState(true, false),
);
this._rsStencilDepthPass3DTiles = RenderState.fromCache(
getStencilDepthRenderState(true, true),
);
this._rsColorPass = RenderState.fromCache(getColorRenderState(true));
}
// Update primitive appearance
if (this._primitive.appearance !== appearance) {
//>>includeStart('debug', pragmas.debug);
// Check if the appearance is supported by the geometry attributes
Eif (
!this._hasSphericalExtentsAttribute &&
!this._hasPlanarExtentsAttributes &&
defined(appearance.material)
) {
throw new DeveloperError(
"Materials on ClassificationPrimitives are not supported except via GroundPrimitive",
);
}
if (
!this._hasPerColorAttribute &&
appearance instanceof PerInstanceColorAppearance
) {
throw new DeveloperError(
"PerInstanceColorAppearance requires color GeometryInstanceAttribute",
);
}
//>>includeEnd('debug');
this._primitive.appearance = appearance;
}
this._primitive.show = this.show;
this._primitive.debugShowBoundingVolume = this.debugShowBoundingVolume;
this._primitive.update(frameState);
frameState.afterRender.push(() => {
if (defined(this._primitive) && this._primitive.ready) {
this._ready = true;
if (this.releaseGeometryInstances) {
this.geometryInstances = undefined;
}
}
});
};
/**
* Returns the modifiable per-instance attributes for a {@link GeometryInstance}.
*
* @param {*} id The id of the {@link GeometryInstance}.
* @returns {object} The typed array in the attribute's format or undefined if the is no instance with id.
*
* @exception {DeveloperError} must call update before calling getGeometryInstanceAttributes.
*
* @example
* const attributes = primitive.getGeometryInstanceAttributes('an id');
* attributes.color = Cesium.ColorGeometryInstanceAttribute.toValue(Cesium.Color.AQUA);
* attributes.show = Cesium.ShowGeometryInstanceAttribute.toValue(true);
*/
ClassificationPrimitive.prototype.getGeometryInstanceAttributes = function (
id,
) {
//>>includeStart('debug', pragmas.debug);
if (!defined(this._primitive)) {
throw new DeveloperError(
"must call update before calling getGeometryInstanceAttributes",
);
}
//>>includeEnd('debug');
return this._primitive.getGeometryInstanceAttributes(id);
};
/**
* Returns true if this object was destroyed; otherwise, false.
* <p>
* If this object was destroyed, it should not be used; calling any function other than
* <code>isDestroyed</code> will result in a {@link DeveloperError} exception.
* </p>
*
* @returns {boolean} <code>true</code> if this object was destroyed; otherwise, <code>false</code>.
*
* @see ClassificationPrimitive#destroy
*/
ClassificationPrimitive.prototype.isDestroyed = function () {
return false;
};
/**
* Destroys the WebGL resources held by this object. Destroying an object allows for deterministic
* release of WebGL resources, instead of relying on the garbage collector to destroy this object.
* <p>
* Once an object is destroyed, it should not be used; calling any function other than
* <code>isDestroyed</code> will result in a {@link DeveloperError} exception. Therefore,
* assign the return value (<code>undefined</code>) to the object as done in the example.
* </p>
*
* @exception {DeveloperError} This object was destroyed, i.e., destroy() was called.
*
* @example
* e = e && e.destroy();
*
* @see ClassificationPrimitive#isDestroyed
*/
ClassificationPrimitive.prototype.destroy = function () {
this._primitive = this._primitive && this._primitive.destroy();
this._sp = this._sp && this._sp.destroy();
this._spPick = this._spPick && this._spPick.destroy();
this._spColor = this._spColor && this._spColor.destroy();
// Derived programs, destroyed above if they existed.
this._spPick2D = undefined;
this._spColor2D = undefined;
return destroyObject(this);
};
export default ClassificationPrimitive;
|