All files / engine/Source/Scene Cesium3DTileset.js

92.75% Statements 870/938
86.22% Branches 407/472
91.66% Functions 110/120
92.68% Lines 849/916

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 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933                                                                                                                                                                                                                                                                                                                                                                                                                      671x   671x 671x 671x 671x 671x 671x 671x 671x 671x 671x 671x 671x 671x 671x 671x 671x 671x 671x 671x 671x 671x 671x 671x 671x 671x 671x   671x   671x 671x   671x   671x 671x   671x 671x   671x   671x       671x   671x           671x   671x 671x   671x       671x   671x 671x 671x   671x 5368x     671x   671x           671x           671x                   671x 671x               671x                 671x                       671x   671x 671x   671x   671x 671x 671x   671x   671x 671x 671x   671x   671x                     671x                     671x                     671x 4x         671x 671x 671x 671x                         671x               671x               671x 671x                       671x                   671x 671x 671x                 671x                       671x                                             671x                                     671x                       671x       671x                           671x               671x                 671x                   671x   671x 671x                                                     671x                                     671x                                     671x                                         671x                                               671x                                                   671x                                                                         671x                           671x   671x                     671x                         671x                       671x                       671x                         671x   671x 671x               671x 671x               671x 501x 501x   170x 170x     671x                             671x                 671x   671x                   671x               671x               671x               671x 671x 671x                         671x                         671x   671x                     671x     671x                                   671x                       671x                       671x             671x 671x 671x 671x                     671x                     671x                       671x                     671x                 671x         671x   671x   671x 671x     671x     671x 671x     671x     1x                 3208x                                   557x                           188x                         42455x     17x                         41175x     4x                                                       35468x                                       3x                                                                               5x                                     3787x                           559x                                                                                                                                           14x     243x                                     11199x                                   243x       6015x     6015x                                 59469x                                             2946x                                 15x 15x                                         212x 182x     30x                                                   5337x       20x             19x 19x                                                                     6085x       12x     11x                                                 5843x       2x     1x                                       43104x                         17035x       1x                               38351x                                           5894x 5894x                                               12857x     19x                                                             12316x 12316x                         10060x       10060x 3456x         3456x     10060x                                   18679x                                                                                     3983x                                         47x                               47x                           8x                               22177x       2x 2x     2x                             269x                                                                 1x                         11201x                                                                   9938x                               1126x                                 69x                           11199x     4x 4x                                                       11203x       2x 1x       2x     2x                                       11203x       2x 1x       2x     2x                                                     1x   1x                                                                                                             1x   555x     554x   554x   554x 548x 6x 2x     554x 552x         552x 552x 552x 552x 552x     552x 552x   552x 552x 552x   552x     552x     552x 552x   552x 552x 552x 552x 552x   552x       550x       550x           550x 550x         450x     550x       550x                 1x 555x 555x             1x 12x                     1x         598x 598x     598x         1x         597x 61x     596x   596x 596x   133x 133x 133x         596x       596x 46x 46x     596x 596x   596x 1585x 1585x 1585x   1585x 1585x 300x 989x 989x 989x 989x 989x       1585x 1579x       596x                                   1585x     1585x 1535x     50x   50x         50x                       50x       50x 50x   50x           50x         50x   50x 50x 50x 50x                         552x         552x 3x     3x     549x 50x       499x     53x   53x         53x   53x     1x 1x 1x 1x 1x 1x 1x                           5767x 5767x 5767x   5767x 4876x 4876x 4876x 4876x 4876x     891x       891x 891x 891x         891x   321x         321x 321x 321x 321x 321x     570x         570x 570x         570x 570x 570x     451x         451x 451x 451x 119x 119x 119x 119x           5767x   5767x 5767x   5767x             5767x       5767x   5767x                   1796x       1796x 1796x   1796x 1796x 161x     1635x   1626x 75x     1551x 1551x     9x     1635x 4x 1x   3x 3x       1635x       1544x               1x 5865x 23x     5842x 5842x 5842x         5842x 5751x   5842x               1x 5866x 23x     5843x     5843x 5843x 5843x 20x       5843x 5843x       5843x 520x   5843x         5843x 5767x     5843x 5843x                   5842x 5842x 5842x 5379x     5379x 5379x   1622x 1622x 3757x   2x 2x 2x     3755x 1246x       5842x                   5772x 5772x 5772x 1796x                     12x         12x 12x     12x 12x 9x         3x 3x 3x                 5843x   5843x 5843x 7774x 7774x       1546x 1546x   6228x 1042x     5843x     1x 1x 1x     7250x 7250x                                                                                                               5843x 5843x   5843x 5843x   5843x 5843x 6228x 294x 294x     5934x 5934x 5934x   5931x 1548x 1548x     3x 3x       5843x 5329x 514x 294x           294x               294x 294x 294x 295x   294x       5329x           1x   1x                   6x 6x 6x                     29x   29x 29x 28x 28x 28x 1x 1x 1x         1x   29x                     30x 30x   30x 14x 14x     30x 3x 3x     3x 3x         3x 3x 3x 3x     3x 3x     30x 3x     3x     3x     30x 16x 2x 2x 2x 4x   2x   14x 14x       30x               30x                 12x 12x 12x 12x 12x   12x 2x 1x     1x         1x     10x 27x 27x   10x 3x 3x 2x       12x                   5994x 5994x   5994x 5994x 5994x     5994x         5994x   5994x 18x 4x               18x     5994x 5994x 5994x   5994x 7250x     7250x 6756x   7250x 7250x 7249x 7249x   5993x 5993x 2255x 2255x     5993x   5993x   5993x                                                 18x 18x   18x     18x 40x         18x 18x         5993x 5993x   5993x 253x       5740x                         5740x           12x 11x   12x   5728x         1x               1x 1x 1x 1x 6x 6x 6x 5x   6x 5x 5x     1x                 62x 62x 62x 62x                 5x 5x                       1x 13x                 5842x 5842x   5842x 5842x 5842x 5842x   5842x     5842x     5842x 2104x 2104x         2104x       5842x               5842x 533x 533x 533x   533x 506x 506x 506x 506x                     5994x 5994x 5994x 5994x 5994x 5994x 5994x 5994x 5994x                 5994x       244x     5750x 5750x       5750x 538x                               6018x 1x     6017x 23x     5994x 5994x     5994x     5994x   5994x 5994x     5994x       5994x 5772x     5994x     5993x   5993x 5740x 5740x 2863x             5993x       556x 556x 552x   556x   556x           556x 556x                       556x           556x               1x 5994x 5994x           5994x                 1x 6111x               1x         11993x 11992x     11991x   11991x 11991x                   5848x     6143x 6143x 6143x   6143x   6143x 6143x   6143x 6143x   6143x 6143x 6143x     6143x 5875x 5875x 5852x   5875x       6143x 6143x       6143x   6143x 6018x 6018x               6142x 31x     6142x 6142x 6142x                 1x 383x 232x     151x                         1x 3438x                                   1x 533x   533x 533x       533x 527x 527x   527x 3184x 3184x   3184x 3184x 2657x       533x   533x       34x   533x   533x 533x   533x   533x 533x     533x     533x     533x     533x   533x   533x     1x                                     1x 61x 62x 1x             1x 1x 1x                             1x   2x 2x     2x 2x       2x 2x       2x   2x 2x 2x           2x 2x       2x                                   1x         1869x   1869x             1869x 1341x 1341x 1341x 1379x 1341x 1341x       1341x 1341x       1869x 1869x     1x 1x                       1x 8x       8x 8x 8x   8x 8x 8x         8x       8x     8x 8x 1x       1x         1x       8x 7x 7x           7x 7x 7x                               1x 380x 148x 124x     24x   24x       24x     232x                           1x     379x   16x   16x       16x     363x                                
import ApproximateTerrainHeights from "../Core/ApproximateTerrainHeights.js";
import BoundingSphere from "../Core/BoundingSphere.js";
import Cartesian2 from "../Core/Cartesian2.js";
import Cartesian3 from "../Core/Cartesian3.js";
import Cartographic from "../Core/Cartographic.js";
import Check from "../Core/Check.js";
import clone from "../Core/clone.js";
import Color from "../Core/Color.js";
import Credit from "../Core/Credit.js";
import Frozen from "../Core/Frozen.js";
import defined from "../Core/defined.js";
import deprecationWarning from "../Core/deprecationWarning.js";
import destroyObject from "../Core/destroyObject.js";
import Ellipsoid from "../Core/Ellipsoid.js";
import Event from "../Core/Event.js";
import ImageBasedLighting from "./ImageBasedLighting.js";
import Interval from "../Core/Interval.js";
import IntersectionTests from "../Core/IntersectionTests.js";
import IonResource from "../Core/IonResource.js";
import JulianDate from "../Core/JulianDate.js";
import ManagedArray from "../Core/ManagedArray.js";
import CesiumMath from "../Core/Math.js";
import Matrix3 from "../Core/Matrix3.js";
import Matrix4 from "../Core/Matrix4.js";
import Resource from "../Core/Resource.js";
import RuntimeError from "../Core/RuntimeError.js";
import Transforms from "../Core/Transforms.js";
import ClearCommand from "../Renderer/ClearCommand.js";
import Pass from "../Renderer/Pass.js";
import RenderState from "../Renderer/RenderState.js";
import Axis from "./Axis.js";
import Cesium3DTile from "./Cesium3DTile.js";
import Cesium3DTileColorBlendMode from "./Cesium3DTileColorBlendMode.js";
import Cesium3DTileContentState from "./Cesium3DTileContentState.js";
import Cesium3DTilesetMetadata from "./Cesium3DTilesetMetadata.js";
import Cesium3DTileOptimizations from "./Cesium3DTileOptimizations.js";
import Cesium3DTilePass from "./Cesium3DTilePass.js";
import Cesium3DTileRefine from "./Cesium3DTileRefine.js";
import Cesium3DTilesetCache from "./Cesium3DTilesetCache.js";
import Cesium3DTilesetHeatmap from "./Cesium3DTilesetHeatmap.js";
import Cesium3DTilesetStatistics from "./Cesium3DTilesetStatistics.js";
import Cesium3DTileStyleEngine from "./Cesium3DTileStyleEngine.js";
import ClippingPlaneCollection from "./ClippingPlaneCollection.js";
import ClippingPolygonCollection from "./ClippingPolygonCollection.js";
import hasExtension from "./hasExtension.js";
import ImplicitTileset from "./ImplicitTileset.js";
import ImplicitTileCoordinates from "./ImplicitTileCoordinates.js";
import LabelCollection from "./LabelCollection.js";
import oneTimeWarning from "../Core/oneTimeWarning.js";
import PointCloudEyeDomeLighting from "./PointCloudEyeDomeLighting.js";
import PointCloudShading from "./PointCloudShading.js";
import ResourceCache from "./ResourceCache.js";
import SceneMode from "./SceneMode.js";
import ShadowMode from "./ShadowMode.js";
import SplitDirection from "./SplitDirection.js";
import StencilConstants from "./StencilConstants.js";
import TileBoundingRegion from "./TileBoundingRegion.js";
import TileBoundingSphere from "./TileBoundingSphere.js";
import TileOrientedBoundingBox from "./TileOrientedBoundingBox.js";
import Cesium3DTilesetMostDetailedTraversal from "./Cesium3DTilesetMostDetailedTraversal.js";
import Cesium3DTilesetBaseTraversal from "./Cesium3DTilesetBaseTraversal.js";
import Cesium3DTilesetSkipTraversal from "./Cesium3DTilesetSkipTraversal.js";
import Ray from "../Core/Ray.js";
import DynamicEnvironmentMapManager from "./DynamicEnvironmentMapManager.js";
import ImageryLayerCollection from "./ImageryLayerCollection.js";
 
/**
 * @typedef {object} Cesium3DTileset.ConstructorOptions
 *
 * Initialization options for the Cesium3DTileset constructor
 *
 * @property {boolean} [show=true] Determines if the tileset will be shown.
 * @property {Matrix4} [modelMatrix=Matrix4.IDENTITY] A 4x4 transformation matrix that transforms the tileset's root tile.
 * @property {Axis} [modelUpAxis=Axis.Y] Which axis is considered up when loading models for tile contents.
 * @property {Axis} [modelForwardAxis=Axis.X] Which axis is considered forward when loading models for tile contents.
 * @property {ShadowMode} [shadows=ShadowMode.ENABLED] Determines whether the tileset casts or receives shadows from light sources.
 * @property {number} [maximumScreenSpaceError=16] The maximum screen space error used to drive level of detail refinement.
 * @property {number} [cacheBytes=536870912] The size (in bytes) to which the tile cache will be trimmed, if the cache contains tiles not needed for the current view.
 * @property {number} [maximumCacheOverflowBytes=536870912] The maximum additional memory (in bytes) to allow for cache headroom, if more than {@link Cesium3DTileset#cacheBytes} are needed for the current view.
 * @property {boolean} [cullWithChildrenBounds=true] Optimization option. Whether to cull tiles using the union of their children bounding volumes.
 * @property {boolean} [cullRequestsWhileMoving=true] Optimization option. Don't request tiles that will likely be unused when they come back because of the camera's movement. This optimization only applies to stationary tilesets.
 * @property {number} [cullRequestsWhileMovingMultiplier=60.0] Optimization option. Multiplier used in culling requests while moving. Larger is more aggressive culling, smaller less aggressive culling.
 * @property {boolean} [preloadWhenHidden=false] Preload tiles when <code>tileset.show</code> is <code>false</code>. Loads tiles as if the tileset is visible but does not render them.
 * @property {boolean} [preloadFlightDestinations=true] Optimization option. Preload tiles at the camera's flight destination while the camera is in flight.
 * @property {boolean} [preferLeaves=false] Optimization option. Prefer loading of leaves first.
 * @property {boolean} [dynamicScreenSpaceError=true] Optimization option. For street-level horizon views, use lower resolution tiles far from the camera. This reduces the amount of data loaded and improves tileset loading time with a slight drop in visual quality in the distance.
 * @property {number} [dynamicScreenSpaceErrorDensity=2.0e-4] Similar to {@link Fog#density}, this option controls the camera distance at which the {@link Cesium3DTileset#dynamicScreenSpaceError} optimization applies. Larger values will cause tiles closer to the camera to be affected.
 * @property {number} [dynamicScreenSpaceErrorFactor=24.0] A parameter that controls the intensity of the {@link Cesium3DTileset#dynamicScreenSpaceError} optimization for tiles on the horizon. Larger values cause lower resolution tiles to load, improving runtime performance at a slight reduction of visual quality.
 * @property {number} [dynamicScreenSpaceErrorHeightFalloff=0.25] A ratio of the tileset's height that determines where "street level" camera views occur. When the camera is below this height, the {@link Cesium3DTileset#dynamicScreenSpaceError} optimization will have the maximum effect, and it will roll off above this value.
 * @property {number} [progressiveResolutionHeightFraction=0.3] Optimization option. If between (0.0, 0.5], tiles at or above the screen space error for the reduced screen resolution of <code>progressiveResolutionHeightFraction*screenHeight</code> will be prioritized first. This can help get a quick layer of tiles down while full resolution tiles continue to load.
 * @property {boolean} [foveatedScreenSpaceError=true] Optimization option. Prioritize loading tiles in the center of the screen by temporarily raising the screen space error for tiles around the edge of the screen. Screen space error returns to normal once all the tiles in the center of the screen as determined by the {@link Cesium3DTileset#foveatedConeSize} are loaded.
 * @property {number} [foveatedConeSize=0.1] Optimization option. Used when {@link Cesium3DTileset#foveatedScreenSpaceError} is true to control the cone size that determines which tiles are deferred. Tiles that are inside this cone are loaded immediately. Tiles outside the cone are potentially deferred based on how far outside the cone they are and their screen space error. This is controlled by {@link Cesium3DTileset#foveatedInterpolationCallback} and {@link Cesium3DTileset#foveatedMinimumScreenSpaceErrorRelaxation}. Setting this to 0.0 means the cone will be the line formed by the camera position and its view direction. Setting this to 1.0 means the cone encompasses the entire field of view of the camera, disabling the effect.
 * @property {number} [foveatedMinimumScreenSpaceErrorRelaxation=0.0] Optimization option. Used when {@link Cesium3DTileset#foveatedScreenSpaceError} is true to control the starting screen space error relaxation for tiles outside the foveated cone. The screen space error will be raised starting with tileset value up to {@link Cesium3DTileset#maximumScreenSpaceError} based on the provided {@link Cesium3DTileset#foveatedInterpolationCallback}.
 * @property {Cesium3DTileset.foveatedInterpolationCallback} [foveatedInterpolationCallback=Math.lerp] Optimization option. Used when {@link Cesium3DTileset#foveatedScreenSpaceError} is true to control how much to raise the screen space error for tiles outside the foveated cone, interpolating between {@link Cesium3DTileset#foveatedMinimumScreenSpaceErrorRelaxation} and {@link Cesium3DTileset#maximumScreenSpaceError}
 * @property {number} [foveatedTimeDelay=0.2] Optimization option. Used when {@link Cesium3DTileset#foveatedScreenSpaceError} is true to control how long in seconds to wait after the camera stops moving before deferred tiles start loading in. This time delay prevents requesting tiles around the edges of the screen when the camera is moving. Setting this to 0.0 will immediately request all tiles in any given view.
 * @property {boolean} [skipLevelOfDetail=false] Optimization option. Determines if level of detail skipping should be applied during the traversal.
 * @property {number} [baseScreenSpaceError=1024] When <code>skipLevelOfDetail</code> is <code>true</code>, the screen space error that must be reached before skipping levels of detail.
 * @property {number} [skipScreenSpaceErrorFactor=16] When <code>skipLevelOfDetail</code> is <code>true</code>, a multiplier defining the minimum screen space error to skip. Used in conjunction with <code>skipLevels</code> to determine which tiles to load.
 * @property {number} [skipLevels=1] When <code>skipLevelOfDetail</code> is <code>true</code>, a constant defining the minimum number of levels to skip when loading tiles. When it is 0, no levels are skipped. Used in conjunction with <code>skipScreenSpaceErrorFactor</code> to determine which tiles to load.
 * @property {boolean} [immediatelyLoadDesiredLevelOfDetail=false] When <code>skipLevelOfDetail</code> is <code>true</code>, only tiles that meet the maximum screen space error will ever be downloaded. Skipping factors are ignored and just the desired tiles are loaded.
 * @property {boolean} [loadSiblings=false] When <code>skipLevelOfDetail</code> is <code>true</code>, determines whether siblings of visible tiles are always downloaded during traversal.
 * @property {ClippingPlaneCollection} [clippingPlanes] The {@link ClippingPlaneCollection} used to selectively disable rendering the tileset.
 * @property {ClippingPolygonCollection} [clippingPolygons] The {@link ClippingPolygonCollection} used to selectively disable rendering the tileset.
 * @property {ClassificationType} [classificationType] Determines whether terrain, 3D Tiles or both will be classified by this tileset. See {@link Cesium3DTileset#classificationType} for details about restrictions and limitations.
 * @property {HeightReference} [heightReference] Sets the {@link HeightReference} for point features in vector tilesets.
 * @property {Scene} [scene] The {@link CesiumWidget#scene} that the tileset will be rendered in, required for tilesets that specify a {@link heightReference} value for clamping 3D Tiles vector data content- like points, lines, and labels- to terrain or 3D tiles.
 * @property {Ellipsoid} [ellipsoid=Ellipsoid.WGS84] The ellipsoid determining the size and shape of the globe.
 * @property {object} [pointCloudShading] Options for constructing a {@link PointCloudShading} object to control point attenuation based on geometric error and lighting.
 * @property {Cartesian3} [lightColor] The light color when shading models. When <code>undefined</code> the scene's light color is used instead.
 * @property {ImageBasedLighting} [imageBasedLighting] The properties for managing image-based lighting for this tileset.
 * @property {DynamicEnvironmentMapManager.ConstructorOptions} [environmentMapOptions] The properties for managing dynamic environment maps on this tileset.
 * @property {boolean} [backFaceCulling=true] Whether to cull back-facing geometry. When true, back face culling is determined by the glTF material's doubleSided property; when false, back face culling is disabled.
 * @property {boolean} [enableShowOutline=true] Whether to enable outlines for models using the {@link https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/CESIUM_primitive_outline|CESIUM_primitive_outline} extension. This can be set to false to avoid the additional processing of geometry at load time. When false, the showOutlines and outlineColor options are ignored.
 * @property {boolean} [showOutline=true] Whether to display the outline for models using the {@link https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/CESIUM_primitive_outline|CESIUM_primitive_outline} extension. When true, outlines are displayed. When false, outlines are not displayed.
 * @property {Color} [outlineColor=Color.BLACK] The color to use when rendering outlines.
 * @property {boolean} [vectorClassificationOnly=false] Indicates that only the tileset's vector tiles should be used for classification.
 * @property {boolean} [vectorKeepDecodedPositions=false] Whether vector tiles should keep decoded positions in memory. This is used with {@link Cesium3DTileFeature.getPolylinePositions}.
 * @property {string|number} [featureIdLabel="featureId_0"] Label of the feature ID set to use for picking and styling. For EXT_mesh_features, this is the feature ID's label property, or "featureId_N" (where N is the index in the featureIds array) when not specified. EXT_feature_metadata did not have a label field, so such feature ID sets are always labeled "featureId_N" where N is the index in the list of all feature Ids, where feature ID attributes are listed before feature ID textures. If featureIdLabel is an integer N, it is converted to the string "featureId_N" automatically. If both per-primitive and per-instance feature IDs are present, the instance feature IDs take priority.
 * @property {string|number} [instanceFeatureIdLabel="instanceFeatureId_0"] Label of the instance feature ID set used for picking and styling. If instanceFeatureIdLabel is set to an integer N, it is converted to the string "instanceFeatureId_N" automatically. If both per-primitive and per-instance feature IDs are present, the instance feature IDs take priority.
 * @property {boolean} [showCreditsOnScreen=false] Whether to display the credits of this tileset on screen.
 * @property {SplitDirection} [splitDirection=SplitDirection.NONE] The {@link SplitDirection} split to apply to this tileset.
 * @property {boolean} [enableCollision=false] When <code>true</code>, enables collisions for camera or CPU picking. While this is <code>true</code> the camera will be prevented from going below the tileset surface if {@link ScreenSpaceCameraController#enableCollisionDetection} is true. This also affects the behavior of {@link HeightReference.CLAMP_TO_GROUND} when clamping to 3D Tiles surfaces. If <code>enableCollision</code> is <code>false</code>, entities may not be correctly clamped to the tileset geometry.
 * @property {boolean} [projectTo2D=false] Whether to accurately project the tileset to 2D. If this is true, the tileset will be projected accurately to 2D, but it will use more memory to do so. If this is false, the tileset will use less memory and will still render in 2D / CV mode, but its projected positions may be inaccurate. This cannot be set after the tileset has been created.
 * @property {boolean} [enablePick=false] Whether to allow collision and CPU picking with <code>pick</code> when using WebGL 1. If using WebGL 2 or above, this option will be ignored. If using WebGL 1 and this is true, the <code>pick</code> operation will work correctly, but it will use more memory to do so. If running with WebGL 1 and this is false, the model will use less memory, but <code>pick</code> will always return <code>undefined</code>. This cannot be set after the tileset has loaded.
 * @property {boolean} [asynchronouslyLoadImagery=false] Whether loading imagery that is draped over the tileset should be done asynchronously. If this is <code>true</code>, then tile content will be displayed with its original texture until the imagery texture is loaded. If this is <code>false</code>, then the tile content will not be displayed until the imagery is ready.
 * @property {string} [debugHeatmapTilePropertyName] The tile variable to colorize as a heatmap. All rendered tiles will be colorized relative to each other's specified variable value.
 * @property {boolean} [debugFreezeFrame=false] For debugging only. Determines if only the tiles from last frame should be used for rendering.
 * @property {boolean} [debugColorizeTiles=false] For debugging only. When true, assigns a random color to each tile.
 * @property {boolean} [enableDebugWireframe=false] For debugging only. This must be true for debugWireframe to work in WebGL1. This cannot be set after the tileset has been created.
 * @property {boolean} [debugWireframe=false] For debugging only. When true, render's each tile's content as a wireframe.
 * @property {boolean} [debugShowBoundingVolume=false] For debugging only. When true, renders the bounding volume for each tile.
 * @property {boolean} [debugShowContentBoundingVolume=false] For debugging only. When true, renders the bounding volume for each tile's content.
 * @property {boolean} [debugShowViewerRequestVolume=false] For debugging only. When true, renders the viewer request volume for each tile.
 * @property {boolean} [debugShowGeometricError=false] For debugging only. When true, draws labels to indicate the geometric error of each tile.
 * @property {boolean} [debugShowRenderingStatistics=false] For debugging only. When true, draws labels to indicate the number of commands, points, triangles and features for each tile.
 * @property {boolean} [debugShowMemoryUsage=false] For debugging only. When true, draws labels to indicate the texture and geometry memory in megabytes used by each tile.
 * @property {boolean} [debugShowUrl=false] For debugging only. When true, draws labels to indicate the url of each tile.
 */
 
/**
 * A {@link https://github.com/CesiumGS/3d-tiles/tree/main/specification|3D Tiles tileset},
 * used for streaming massive heterogeneous 3D geospatial datasets.
 *
 * <div class="notice">
 * This object is normally not instantiated directly, use {@link Cesium3DTileset.fromUrl}.
 * </div>
 *
 * @alias Cesium3DTileset
 * @constructor
 * @experimental Support for loading Gaussian splats content encoded with SPZ compression using the draft glTF extensions {@link https://github.com/CesiumGS/glTF/tree/draft-splat-spz/extensions/2.0/Khronos/KHR_gaussian_splatting | KHR_gaussian_splatting} and {@link https://github.com/CesiumGS/glTF/tree/draft-splat-spz/extensions/2.0/Khronos/KHR_gaussian_splatting_compression_spz_2 | KHR_gaussian_splatting_compression_spz_2} is experimental and is subject change without Cesium's standard deprecation policy.
 * @param {Cesium3DTileset.ConstructorOptions} options An object describing initialization options
 *
 * @exception {DeveloperError} The tileset must be 3D Tiles version 0.0 or 1.0.
 *
 * @example
 * try {
 *   const tileset = await Cesium.Cesium3DTileset.fromUrl(
 *      "http://localhost:8002/tilesets/Seattle/tileset.json"
 *   );
 *   scene.primitives.add(tileset);
 * } catch (error) {
 *   console.error(`Error creating tileset: ${error}`);
 * }
 *
 * @example
 * // Turn on camera collisions with the tileset.
 * try {
 *   const tileset = await Cesium.Cesium3DTileset.fromUrl(
 *      "http://localhost:8002/tilesets/Seattle/tileset.json",
 *      { enableCollision: true }
 *   );
 *   scene.primitives.add(tileset);
 * } catch (error) {
 *   console.error(`Error creating tileset: ${error}`);
 * }
 *
 * @example
 * // Common setting for the skipLevelOfDetail optimization
 * const tileset = await Cesium.Cesium3DTileset.fromUrl(
 *   "http://localhost:8002/tilesets/Seattle/tileset.json", {
 *      skipLevelOfDetail: true,
 *      baseScreenSpaceError: 1024,
 *      skipScreenSpaceErrorFactor: 16,
 *      skipLevels: 1,
 *      immediatelyLoadDesiredLevelOfDetail: false,
 *      loadSiblings: false,
 *      cullWithChildrenBounds: true
 * });
 * scene.primitives.add(tileset);
 *
 * @example
 * // Common settings for the dynamicScreenSpaceError optimization
 * const tileset = await Cesium.Cesium3DTileset.fromUrl(
 *   "http://localhost:8002/tilesets/Seattle/tileset.json", {
 *      dynamicScreenSpaceError: true,
 *      dynamicScreenSpaceErrorDensity: 2.0e-4,
 *      dynamicScreenSpaceErrorFactor: 24.0,
 *      dynamicScreenSpaceErrorHeightFalloff: 0.25
 * });
 * scene.primitives.add(tileset);
 * @see {@link https://github.com/CesiumGS/3d-tiles/tree/main/specification|3D Tiles specification}
 */
function Cesium3DTileset(options) {
  options = options ?? Frozen.EMPTY_OBJECT;
 
  this._url = undefined;
  this._basePath = undefined;
  this._root = undefined;
  this._resource = undefined;
  this._asset = undefined; // Metadata for the entire tileset
  this._properties = undefined; // Metadata for per-model/point/etc properties
  this._geometricError = undefined; // Geometric error when the tree is not rendered at all
  this._scaledGeometricError = undefined; // Geometric error scaled by root tile scale
  this._extensionsUsed = undefined;
  this._extensions = undefined;
  this._modelUpAxis = undefined;
  this._modelForwardAxis = undefined;
  this._cache = new Cesium3DTilesetCache();
  this._processingQueue = [];
  this._selectedTiles = [];
  this._emptyTiles = [];
  this._requestedTiles = [];
  this._selectedTilesToStyle = [];
  this._loadTimestamp = undefined;
  this._timeSinceLoad = 0.0;
  this._updatedVisibilityFrame = 0;
  this._updatedModelMatrixFrame = 0;
  this._modelMatrixChanged = false;
  this._previousModelMatrix = undefined;
  this._extras = undefined;
  this._credits = undefined;
 
  this._showCreditsOnScreen = options.showCreditsOnScreen ?? false;
 
  this._cullWithChildrenBounds = options.cullWithChildrenBounds ?? true;
  this._allTilesAdditive = true;
 
  this._hasMixedContent = false;
 
  this._stencilClearCommand = undefined;
  this._backfaceCommands = new ManagedArray();
 
  this._maximumScreenSpaceError = options.maximumScreenSpaceError ?? 16;
  this._memoryAdjustedScreenSpaceError = this._maximumScreenSpaceError;
 
  this._cacheBytes = options.cacheBytes ?? 512 * 1024 * 1024;
  //>>includeStart('debug', pragmas.debug);
  Check.typeOf.number.greaterThanOrEquals("cacheBytes", this._cacheBytes, 0);
  //>>includeEnd('debug');
 
  const maximumCacheOverflowBytes =
    options.maximumCacheOverflowBytes ?? 512 * 1024 * 1024;
  //>>includeStart('debug', pragmas.debug);
  Check.typeOf.number.greaterThanOrEquals(
    "maximumCacheOverflowBytes",
    maximumCacheOverflowBytes,
    0,
  );
  //>>includeEnd('debug');
  this._maximumCacheOverflowBytes = maximumCacheOverflowBytes;
 
  this._styleEngine = new Cesium3DTileStyleEngine();
  this._styleApplied = false;
 
  this._modelMatrix = defined(options.modelMatrix)
    ? Matrix4.clone(options.modelMatrix)
    : Matrix4.clone(Matrix4.IDENTITY);
 
  this._addHeightCallbacks = [];
 
  this._statistics = new Cesium3DTilesetStatistics();
  this._statisticsLast = new Cesium3DTilesetStatistics();
  this._statisticsPerPass = new Array(Cesium3DTilePass.NUMBER_OF_PASSES);
 
  for (let i = 0; i < Cesium3DTilePass.NUMBER_OF_PASSES; ++i) {
    this._statisticsPerPass[i] = new Cesium3DTilesetStatistics();
  }
 
  this._requestedTilesInFlight = [];
 
  this._maximumPriority = {
    foveatedFactor: -Number.MAX_VALUE,
    depth: -Number.MAX_VALUE,
    distance: -Number.MAX_VALUE,
    reverseScreenSpaceError: -Number.MAX_VALUE,
  };
  this._minimumPriority = {
    foveatedFactor: Number.MAX_VALUE,
    depth: Number.MAX_VALUE,
    distance: Number.MAX_VALUE,
    reverseScreenSpaceError: Number.MAX_VALUE,
  };
  this._heatmap = new Cesium3DTilesetHeatmap(
    options.debugHeatmapTilePropertyName,
  );
 
  /**
   * Optimization option. Don't request tiles that will likely be unused when they come back because of the camera's movement. This optimization only applies to stationary tilesets.
   *
   * @type {boolean}
   * @default true
   */
  this.cullRequestsWhileMoving = options.cullRequestsWhileMoving ?? true;
  this._cullRequestsWhileMoving = false;
 
  /**
   * Optimization option. Multiplier used in culling requests while moving. Larger is more aggressive culling, smaller less aggressive culling.
   *
   * @type {number}
   * @default 60.0
   */
  this.cullRequestsWhileMovingMultiplier =
    options.cullRequestsWhileMovingMultiplier ?? 60.0;
 
  /**
   * Optimization option. If between (0.0, 0.5], tiles at or above the screen space error for the reduced screen resolution of <code>progressiveResolutionHeightFraction*screenHeight</code> will be prioritized first. This can help get a quick layer of tiles down while full resolution tiles continue to load.
   *
   * @type {number}
   * @default 0.3
   */
  this.progressiveResolutionHeightFraction = CesiumMath.clamp(
    options.progressiveResolutionHeightFraction ?? 0.3,
    0.0,
    0.5,
  );
 
  /**
   * Optimization option. Prefer loading of leaves first.
   *
   * @type {boolean}
   * @default false
   */
  this.preferLeaves = options.preferLeaves ?? false;
 
  this._tilesLoaded = false;
  this._initialTilesLoaded = false;
 
  this._tileDebugLabels = undefined;
 
  this._classificationType = options.classificationType;
  this._heightReference = options.heightReference;
  this._scene = options.scene;
 
  this._ellipsoid = options.ellipsoid ?? Ellipsoid.WGS84;
 
  this._initialClippingPlanesOriginMatrix = Matrix4.IDENTITY; // Computed from the tileset JSON.
  this._clippingPlanesOriginMatrix = undefined; // Combines the above with any run-time transforms.
  this._clippingPlanesOriginMatrixDirty = true;
 
  this._vectorClassificationOnly = options.vectorClassificationOnly ?? false;
 
  this._vectorKeepDecodedPositions =
    options.vectorKeepDecodedPositions ?? false;
 
  /**
   * The collection of <code>ImageryLayer</code> objects providing 2D georeferenced
   * image data that will be rendered over the tileset.
   *
   * @private
   * @type {ImageryLayerCollection}
   * @readonly
   */
  this._imageryLayers = new ImageryLayerCollection(this);
 
  /**
   * A counter that will be increased for each modification of the
   * imagery layers (i.e. for each layerAdded, layerRemoved,
   * layerMoved, or layerShownOrHidden event). This can be used
   * by the <code>ModelImagery</code> class to detect changes in
   * the imagery, and trigger the appropriate updates.
   *
   * @private
   */
  this._imageryLayersModificationCounter = 0;
 
  /**
   * A listener that will be attached to the layerAdded, layerRemoved,
   * layerMoved, and layerShownOrHidden events of the imagery layers,
   * and increment the imagery layers modification counter for each
   * event.
   *
   * @private
   * @readonly
   */
  this._imageryLayersListener = () => {
    this._imageryLayersModificationCounter++;
  };
 
  // Attach the imagery layers listener to all events of
  // the imagery layers collection
  this.imageryLayers.layerAdded.addEventListener(this._imageryLayersListener);
  this.imageryLayers.layerRemoved.addEventListener(this._imageryLayersListener);
  this.imageryLayers.layerMoved.addEventListener(this._imageryLayersListener);
  this.imageryLayers.layerShownOrHidden.addEventListener(
    this._imageryLayersListener,
  );
 
  /**
   * Whether loading imagery that is draped over the tileset should be
   * done asynchronously. If this is <code>true</code>, then tile content
   * will be displayed with its original texture until the imagery texture
   * is loaded. If this is <code>false</code>, then the tile content will
   * not be displayed until the imagery is ready.
   *
   * @private
   */
  this._asynchronouslyLoadImagery = options.asynchronouslyLoadImagery ?? false;
 
  /**
   * Preload tiles when <code>tileset.show</code> is <code>false</code>. Loads tiles as if the tileset is visible but does not render them.
   *
   * @type {boolean}
   * @default false
   */
  this.preloadWhenHidden = options.preloadWhenHidden ?? false;
 
  /**
   * Optimization option. Fetch tiles at the camera's flight destination while the camera is in flight.
   *
   * @type {boolean}
   * @default true
   */
  this.preloadFlightDestinations = options.preloadFlightDestinations ?? true;
  this._pass = undefined; // Cesium3DTilePass
 
  /**
   * Optimization option. For street-level horizon views, use lower resolution tiles far from the camera. This reduces
   * the amount of data loaded and improves tileset loading time with a slight drop in visual quality in the distance.
   * <p>
   * This optimization is strongest when the camera is close to the ground plane of the tileset and looking at the
   * horizon. Furthermore, the results are more accurate for tightly fitting bounding volumes like box and region.
   *
   * @type {boolean}
   * @default true
   */
  this.dynamicScreenSpaceError = options.dynamicScreenSpaceError ?? true;
 
  /**
   * Optimization option. Prioritize loading tiles in the center of the screen by temporarily raising the
   * screen space error for tiles around the edge of the screen. Screen space error returns to normal once all
   * the tiles in the center of the screen as determined by the {@link Cesium3DTileset#foveatedConeSize} are loaded.
   *
   * @type {boolean}
   * @default true
   */
  this.foveatedScreenSpaceError = options.foveatedScreenSpaceError ?? true;
  this._foveatedConeSize = options.foveatedConeSize ?? 0.1;
  this._foveatedMinimumScreenSpaceErrorRelaxation =
    options.foveatedMinimumScreenSpaceErrorRelaxation ?? 0.0;
 
  /**
   * Gets or sets a callback to control how much to raise the screen space error for tiles outside the foveated cone,
   * interpolating between {@link Cesium3DTileset#foveatedMinimumScreenSpaceErrorRelaxation} and {@link Cesium3DTileset#maximumScreenSpaceError}.
   *
   * @type {Cesium3DTileset.foveatedInterpolationCallback}
   */
  this.foveatedInterpolationCallback =
    options.foveatedInterpolationCallback ?? CesiumMath.lerp;
 
  /**
   * Optimization option. Used when {@link Cesium3DTileset#foveatedScreenSpaceError} is true to control
   * how long in seconds to wait after the camera stops moving before deferred tiles start loading in.
   * This time delay prevents requesting tiles around the edges of the screen when the camera is moving.
   * Setting this to 0.0 will immediately request all tiles in any given view.
   *
   * @type {number}
   * @default 0.2
   */
  this.foveatedTimeDelay = options.foveatedTimeDelay ?? 0.2;
 
  /**
   * Similar to {@link Fog#density}, this option controls the camera distance at which the {@link Cesium3DTileset#dynamicScreenSpaceError}
   * optimization applies. Larger values will cause tiles closer to the camera to be affected. This value must be
   * non-negative.
   * <p>
   * This optimization works by rolling off the tile screen space error (SSE) with camera distance like a bell curve.
   * This has the effect of selecting lower resolution tiles far from the camera. Near the camera, no adjustment is
   * made. For tiles further away, the SSE is reduced by up to {@link Cesium3DTileset#dynamicScreenSpaceErrorFactor}
   * (measured in pixels of error).
   * </p>
   * <p>
   * Increasing the density makes the bell curve narrower so tiles closer to the camera are affected. This is analagous
   * to moving fog closer to the camera.
   * </p>
   * <p>
   * When the density is 0, the optimization will have no effect on the tileset.
   * </p>
   *
   * @type {number}
   * @default 2.0e-4
   */
  this.dynamicScreenSpaceErrorDensity =
    options.dynamicScreenSpaceErrorDensity ?? 2.0e-4;
 
  /**
   * A parameter that controls the intensity of the {@link Cesium3DTileset#dynamicScreenSpaceError} optimization for
   * tiles on the horizon. Larger values cause lower resolution tiles to load, improving runtime performance at a slight
   * reduction of visual quality. The value must be non-negative.
   * <p>
   * More specifically, this parameter represents the maximum adjustment to screen space error (SSE) in pixels for tiles
   * far away from the camera. See {@link Cesium3DTileset#dynamicScreenSpaceErrorDensity} for more details about how
   * this optimization works.
   * </p>
   * <p>
   * When the SSE factor is set to 0, the optimization will have no effect on the tileset.
   * </p>
   *
   * @type {number}
   * @default 24.0
   */
  this.dynamicScreenSpaceErrorFactor =
    options.dynamicScreenSpaceErrorFactor ?? 24.0;
 
  /**
   * A ratio of the tileset's height that determines "street level" for the {@link Cesium3DTileset#dynamicScreenSpaceError}
   * optimization. When the camera is below this height, the dynamic screen space error optimization will have the maximum
   * effect, and it will roll off above this value. Valid values are between 0.0 and 1.0.
   * <p>
   *
   * @type {number}
   * @default 0.25
   */
  this.dynamicScreenSpaceErrorHeightFalloff =
    options.dynamicScreenSpaceErrorHeightFalloff ?? 0.25;
 
  // Updated based on the camera position and direction
  this._dynamicScreenSpaceErrorComputedDensity = 0.0;
 
  /**
   * Determines whether the tileset casts or receives shadows from light sources.
   * <p>
   * Enabling shadows has a performance impact. A tileset that casts shadows must be rendered twice, once from the camera and again from the light's point of view.
   * </p>
   * <p>
   * Shadows are rendered only when {@link Viewer#shadows} is <code>true</code>.
   * </p>
   *
   * @type {ShadowMode}
   * @default ShadowMode.ENABLED
   */
  this.shadows = options.shadows ?? ShadowMode.ENABLED;
 
  /**
   * Determines if the tileset will be shown.
   *
   * @type {boolean}
   * @default true
   */
  this.show = options.show ?? true;
 
  /**
   * Defines how per-feature colors set from the Cesium API or declarative styling blend with the source colors from
   * the original feature, e.g. glTF material or per-point color in the tile.
   *
   * @type {Cesium3DTileColorBlendMode}
   * @default Cesium3DTileColorBlendMode.HIGHLIGHT
   */
  this.colorBlendMode = Cesium3DTileColorBlendMode.HIGHLIGHT;
 
  /**
   * Defines the value used to linearly interpolate between the source color and feature color when the {@link Cesium3DTileset#colorBlendMode} is <code>MIX</code>.
   * A value of 0.0 results in the source color while a value of 1.0 results in the feature color, with any value in-between
   * resulting in a mix of the source color and feature color.
   *
   * @type {number}
   * @default 0.5
   */
  this.colorBlendAmount = 0.5;
 
  this._pointCloudShading = new PointCloudShading(options.pointCloudShading);
  this._pointCloudEyeDomeLighting = new PointCloudEyeDomeLighting();
 
  /**
   * The event fired to indicate progress of loading new tiles.  This event is fired when a new tile
   * is requested, when a requested tile is finished downloading, and when a downloaded tile has been
   * processed and is ready to render.
   * <p>
   * The number of pending tile requests, <code>numberOfPendingRequests</code>, and number of tiles
   * processing, <code>numberOfTilesProcessing</code> are passed to the event listener.
   * </p>
   * <p>
   * This event is fired at the end of the frame after the scene is rendered.
   * </p>
   *
   * @type {Event}
   * @default new Event()
   *
   * @example
   * tileset.loadProgress.addEventListener(function(numberOfPendingRequests, numberOfTilesProcessing) {
   *     if ((numberOfPendingRequests === 0) && (numberOfTilesProcessing === 0)) {
   *         console.log('Stopped loading');
   *         return;
   *     }
   *
   *     console.log(`Loading: requests: ${numberOfPendingRequests}, processing: ${numberOfTilesProcessing}`);
   * });
   */
  this.loadProgress = new Event();
 
  /**
   * The event fired to indicate that all tiles that meet the screen space error this frame are loaded. The tileset
   * is completely loaded for this view.
   * <p>
   * This event is fired at the end of the frame after the scene is rendered.
   * </p>
   *
   * @type {Event}
   * @default new Event()
   *
   * @example
   * tileset.allTilesLoaded.addEventListener(function() {
   *     console.log('All tiles are loaded');
   * });
   *
   * @see Cesium3DTileset#tilesLoaded
   */
  this.allTilesLoaded = new Event();
 
  /**
   * The event fired to indicate that all tiles that meet the screen space error this frame are loaded. This event
   * is fired once when all tiles in the initial view are loaded.
   * <p>
   * This event is fired at the end of the frame after the scene is rendered.
   * </p>
   *
   * @type {Event}
   * @default new Event()
   *
   * @example
   * tileset.initialTilesLoaded.addEventListener(function() {
   *     console.log('Initial tiles are loaded');
   * });
   *
   * @see Cesium3DTileset#allTilesLoaded
   */
  this.initialTilesLoaded = new Event();
 
  /**
   * The event fired to indicate that a tile's content was loaded.
   * <p>
   * The loaded {@link Cesium3DTile} is passed to the event listener.
   * </p>
   * <p>
   * This event is fired during the tileset traversal while the frame is being rendered
   * so that updates to the tile take effect in the same frame.  Do not create or modify
   * Cesium entities or primitives during the event listener.
   * </p>
   *
   * @type {Event}
   * @default new Event()
   *
   * @example
   * tileset.tileLoad.addEventListener(function(tile) {
   *     console.log('A tile was loaded.');
   * });
   */
  this.tileLoad = new Event();
 
  /**
   * The event fired to indicate that a tile's content was unloaded.
   * <p>
   * The unloaded {@link Cesium3DTile} is passed to the event listener.
   * </p>
   * <p>
   * This event is fired immediately before the tile's content is unloaded while the frame is being
   * rendered so that the event listener has access to the tile's content.  Do not create
   * or modify Cesium entities or primitives during the event listener.
   * </p>
   *
   * @type {Event}
   * @default new Event()
   *
   * @example
   * tileset.tileUnload.addEventListener(function(tile) {
   *     console.log('A tile was unloaded from the cache.');
   * });
   *
   * @see Cesium3DTileset#cacheBytes
   * @see Cesium3DTileset#trimLoadedTiles
   */
  this.tileUnload = new Event();
 
  /**
   * The event fired to indicate that a tile's content failed to load.
   * <p>
   * If there are no event listeners, error messages will be logged to the console.
   * </p>
   * <p>
   * The error object passed to the listener contains two properties:
   * <ul>
   * <li><code>url</code>: the url of the failed tile.</li>
   * <li><code>message</code>: the error message.</li>
   * </ul>
   * <p>
   * If multiple contents are present, this event is raised once per inner content with errors.
   * </p>
   *
   * @type {Event}
   * @default new Event()
   *
   * @example
   * tileset.tileFailed.addEventListener(function(error) {
   *     console.log(`An error occurred loading tile: ${error.url}`);
   *     console.log(`Error: ${error.message}`);
   * });
   */
  this.tileFailed = new Event();
 
  /**
   * This event fires once for each visible tile in a frame.  This can be used to manually
   * style a tileset.
   * <p>
   * The visible {@link Cesium3DTile} is passed to the event listener.
   * </p>
   * <p>
   * This event is fired during the tileset traversal while the frame is being rendered
   * so that updates to the tile take effect in the same frame.  Do not create or modify
   * Cesium entities or primitives during the event listener.
   * </p>
   *
   * @type {Event}
   * @default new Event()
   *
   * @example
   * tileset.tileVisible.addEventListener(function(tile) {
   *     if (tile.content instanceof Cesium.Model3DTileContent) {
   *         console.log('A 3D model tile is visible.');
   *     }
   * });
   *
   * @example
   * // Apply a red style and then manually set random colors for every other feature when the tile becomes visible.
   * tileset.style = new Cesium.Cesium3DTileStyle({
   *     color : 'color("red")'
   * });
   * tileset.tileVisible.addEventListener(function(tile) {
   *     const content = tile.content;
   *     const featuresLength = content.featuresLength;
   *     for (let i = 0; i < featuresLength; i+=2) {
   *         content.getFeature(i).color = Cesium.Color.fromRandom();
   *     }
   * });
   */
  this.tileVisible = new Event();
 
  /**
   * Optimization option. Determines if level of detail skipping should be applied during the traversal.
   * <p>
   * The common strategy for replacement-refinement traversal is to store all levels of the tree in memory and require
   * all children to be loaded before the parent can refine. With this optimization levels of the tree can be skipped
   * entirely and children can be rendered alongside their parents. The tileset requires significantly less memory when
   * using this optimization.
   * </p>
   *
   * @type {boolean}
   * @default false
   */
  this.skipLevelOfDetail = options.skipLevelOfDetail ?? false;
 
  this._disableSkipLevelOfDetail = false;
 
  /**
   * The screen space error that must be reached before skipping levels of detail.
   * <p>
   * Only used when {@link Cesium3DTileset#skipLevelOfDetail} is <code>true</code>.
   * </p>
   *
   * @type {number}
   * @default 1024
   */
  this.baseScreenSpaceError = options.baseScreenSpaceError ?? 1024;
 
  /**
   * Multiplier defining the minimum screen space error to skip.
   * For example, if a tile has screen space error of 100, no tiles will be loaded unless they
   * are leaves or have a screen space error <code><= 100 / skipScreenSpaceErrorFactor</code>.
   * <p>
   * Only used when {@link Cesium3DTileset#skipLevelOfDetail} is <code>true</code>.
   * </p>
   *
   * @type {number}
   * @default 16
   */
  this.skipScreenSpaceErrorFactor = options.skipScreenSpaceErrorFactor ?? 16;
 
  /**
   * Constant defining the minimum number of levels to skip when loading tiles. When it is 0, no levels are skipped.
   * For example, if a tile is level 1, no tiles will be loaded unless they are at level greater than 2.
   * <p>
   * Only used when {@link Cesium3DTileset#skipLevelOfDetail} is <code>true</code>.
   * </p>
   *
   * @type {number}
   * @default 1
   */
  this.skipLevels = options.skipLevels ?? 1;
 
  /**
   * When true, only tiles that meet the maximum screen space error will ever be downloaded.
   * Skipping factors are ignored and just the desired tiles are loaded.
   * <p>
   * Only used when {@link Cesium3DTileset#skipLevelOfDetail} is <code>true</code>.
   * </p>
   *
   * @type {boolean}
   * @default false
   */
  this.immediatelyLoadDesiredLevelOfDetail =
    options.immediatelyLoadDesiredLevelOfDetail ?? false;
 
  /**
   * Determines whether siblings of visible tiles are always downloaded during traversal.
   * This may be useful for ensuring that tiles are already available when the viewer turns left/right.
   * <p>
   * Only used when {@link Cesium3DTileset#skipLevelOfDetail} is <code>true</code>.
   * </p>
   *
   * @type {boolean}
   * @default false
   */
  this.loadSiblings = options.loadSiblings ?? false;
 
  this._clippingPlanes = undefined;
  Iif (defined(options.clippingPlanes)) {
    ClippingPlaneCollection.setOwner(
      options.clippingPlanes,
      this,
      "_clippingPlanes",
    );
  }
 
  this._clippingPolygons = undefined;
  Iif (defined(options.clippingPolygons)) {
    ClippingPolygonCollection.setOwner(
      options.clippingPolygons,
      this,
      "_clippingPolygons",
    );
  }
 
  if (defined(options.imageBasedLighting)) {
    this._imageBasedLighting = options.imageBasedLighting;
    this._shouldDestroyImageBasedLighting = false;
  } else {
    this._imageBasedLighting = new ImageBasedLighting();
    this._shouldDestroyImageBasedLighting = true;
  }
 
  this._environmentMapManager = new DynamicEnvironmentMapManager(
    options.environmentMapOptions,
  );
 
  /**
   * The light color when shading models. When <code>undefined</code> the scene's light color is used instead.
   * <p>
   * For example, disabling additional light sources by setting
   * <code>tileset.imageBasedLighting.imageBasedLightingFactor = new Cartesian2(0.0, 0.0)</code>
   * will make the tileset much darker. Here, increasing the intensity of the light source will make the tileset brighter.
   * </p>
   *
   * @type {Cartesian3}
   * @default undefined
   */
  this.lightColor = options.lightColor;
 
  /**
   * Whether to cull back-facing geometry. When true, back face culling is determined
   * by the glTF material's doubleSided property; when false, back face culling is disabled.
   *
   * @type {boolean}
   * @default true
   */
  this.backFaceCulling = options.backFaceCulling ?? true;
 
  this._enableShowOutline = options.enableShowOutline ?? true;
 
  /**
   * Whether to display the outline for models using the
   * {@link https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/CESIUM_primitive_outline|CESIUM_primitive_outline} extension.
   * When true, outlines are displayed. When false, outlines are not displayed.
   *
   * @type {boolean}
   * @default true
   */
  this.showOutline = options.showOutline ?? true;
 
  /**
   * The color to use when rendering outlines.
   *
   * @type {Color}
   * @default Color.BLACK
   */
  this.outlineColor = options.outlineColor ?? Color.BLACK;
 
  /**
   * The {@link SplitDirection} to apply to this tileset.
   *
   * @type {SplitDirection}
   * @default {@link SplitDirection.NONE}
   */
  this.splitDirection = options.splitDirection ?? SplitDirection.NONE;
 
  /**
   * If <code>true</code>, allows collisions for camera collisions or picking. While this is  <code>true</code> the camera will be prevented from going in or below the tileset surface if {@link ScreenSpaceCameraController#enableCollisionDetection} is true. This can have performance implecations if the tileset contains tile with a larger number of vertices.
   *
   * @type {boolean}
   * @default false
   */
  this.enableCollision = options.enableCollision ?? false;
  this._projectTo2D = options.projectTo2D ?? false;
  this._enablePick = options.enablePick ?? false;
 
  /**
   * This property is for debugging only; it is not optimized for production use.
   * <p>
   * Determines if only the tiles from last frame should be used for rendering.  This
   * effectively "freezes" the tileset to the previous frame so it is possible to zoom
   * out and see what was rendered.
   * </p>
   *
   * @type {boolean}
   * @default false
   */
  this.debugFreezeFrame = options.debugFreezeFrame ?? false;
 
  /**
   * This property is for debugging only; it is not optimized for production use.
   * <p>
   * When true, assigns a random color to each tile.  This is useful for visualizing
   * what features belong to what tiles, especially with additive refinement where features
   * from parent tiles may be interleaved with features from child tiles.
   * </p>
   *
   * @type {boolean}
   * @default false
   */
  this.debugColorizeTiles = options.debugColorizeTiles ?? false;
 
  this._enableDebugWireframe = options.enableDebugWireframe ?? false;
 
  /**
   * This property is for debugging only; it is not optimized for production use.
   * <p>
   * When true, renders each tile's content as a wireframe.
   * </p>
   *
   * @type {boolean}
   * @default false
   */
  this.debugWireframe = options.debugWireframe ?? false;
 
  // Warning for improper setup of debug wireframe
  Iif (this.debugWireframe === true && this._enableDebugWireframe === false) {
    oneTimeWarning(
      "tileset-debug-wireframe-ignored",
      "enableDebugWireframe must be set to true in the Cesium3DTileset constructor, otherwise debugWireframe will be ignored.",
    );
  }
 
  /**
   * This property is for debugging only; it is not optimized for production use.
   * <p>
   * When true, renders the bounding volume for each visible tile.  The bounding volume is
   * white if the tile has a content bounding volume or is empty; otherwise, it is red.  Tiles that don't meet the
   * screen space error and are still refining to their descendants are yellow.
   * </p>
   *
   * @type {boolean}
   * @default false
   */
  this.debugShowBoundingVolume = options.debugShowBoundingVolume ?? false;
 
  /**
   * This property is for debugging only; it is not optimized for production use.
   * <p>
   * When true, renders the bounding volume for each visible tile's content. The bounding volume is
   * blue if the tile has a content bounding volume; otherwise it is red.
   * </p>
   *
   * @type {boolean}
   * @default false
   */
  this.debugShowContentBoundingVolume =
    options.debugShowContentBoundingVolume ?? false;
 
  /**
   * This property is for debugging only; it is not optimized for production use.
   * <p>
   * When true, renders the viewer request volume for each tile.
   * </p>
   *
   * @type {boolean}
   * @default false
   */
  this.debugShowViewerRequestVolume =
    options.debugShowViewerRequestVolume ?? false;
 
  /**
   * @private
   * @type {LabelCollection|undefined}
   */
  this._tileDebugLabels = undefined;
  this.debugPickedTileLabelOnly = false;
  this.debugPickedTile = undefined;
  this.debugPickPosition = undefined;
 
  /**
   * This property is for debugging only; it is not optimized for production use.
   * <p>
   * When true, draws labels to indicate the geometric error of each tile.
   * </p>
   *
   * @type {boolean}
   * @default false
   */
  this.debugShowGeometricError = options.debugShowGeometricError ?? false;
 
  /**
   * This property is for debugging only; it is not optimized for production use.
   * <p>
   * When true, draws labels to indicate the number of commands, points, triangles and features of each tile.
   * </p>
   *
   * @type {boolean}
   * @default false
   */
  this.debugShowRenderingStatistics =
    options.debugShowRenderingStatistics ?? false;
 
  /**
   * This property is for debugging only; it is not optimized for production use.
   * <p>
   * When true, draws labels to indicate the geometry and texture memory usage of each tile.
   * </p>
   *
   * @type {boolean}
   * @default false
   */
  this.debugShowMemoryUsage = options.debugShowMemoryUsage ?? false;
 
  /**
   * This property is for debugging only; it is not optimized for production use.
   * <p>
   * When true, draws labels to indicate the url of each tile.
   * </p>
   *
   * @type {boolean}
   * @default false
   */
  this.debugShowUrl = options.debugShowUrl ?? false;
 
  /**
   * Function for examining vector lines as they are being streamed.
   *
   * @experimental This feature is using part of the 3D Tiles spec that is not final and is subject to change without Cesium's standard deprecation policy.
   *
   * @type {Function}
   */
  this.examineVectorLinesFunction = undefined;
 
  // this is the underlying Cesium3DTileMetadata object, whether it came from
  // the 3DTILES_metadata extension or a 3D Tiles 1.1 tileset JSON. Getters
  // like tileset.metadata and tileset.schema will delegate to this object.
  this._metadataExtension = undefined;
 
  this._customShader = options.customShader;
 
  let featureIdLabel = options.featureIdLabel ?? "featureId_0";
  Iif (typeof featureIdLabel === "number") {
    featureIdLabel = `featureId_${featureIdLabel}`;
  }
  this._featureIdLabel = featureIdLabel;
 
  let instanceFeatureIdLabel =
    options.instanceFeatureIdLabel ?? "instanceFeatureId_0";
  Iif (typeof instanceFeatureIdLabel === "number") {
    instanceFeatureIdLabel = `instanceFeatureId_${instanceFeatureIdLabel}`;
  }
  this._instanceFeatureIdLabel = instanceFeatureIdLabel;
}
 
Object.defineProperties(Cesium3DTileset.prototype, {
  /**
   * NOTE: This getter exists so that `Picking.js` can differentiate between
   *       PrimitiveCollection and Cesium3DTileset objects without inflating
   *       the size of the module via `instanceof Cesium3DTileset`
   * @private
   */
  isCesium3DTileset: {
    get: function () {
      return true;
    },
  },
 
  /**
   * Gets the tileset's asset object property, which contains metadata about the tileset.
   * <p>
   * See the {@link https://github.com/CesiumGS/3d-tiles/tree/main/specification#reference-asset|asset schema reference}
   * in the 3D Tiles spec for the full set of properties.
   * </p>
   *
   * @memberof Cesium3DTileset.prototype
   *
   * @type {object}
   * @readonly
   */
  asset: {
    get: function () {
      return this._asset;
    },
  },
 
  /**
   * Gets the tileset's extensions object property.
   *
   * @memberof Cesium3DTileset.prototype
   *
   * @type {object}
   * @readonly
   */
  extensions: {
    get: function () {
      return this._extensions;
    },
  },
 
  /**
   * The {@link ClippingPlaneCollection} used to selectively disable rendering the tileset.
   *
   * @memberof Cesium3DTileset.prototype
   *
   * @type {ClippingPlaneCollection}
   */
  clippingPlanes: {
    get: function () {
      return this._clippingPlanes;
    },
    set: function (value) {
      ClippingPlaneCollection.setOwner(value, this, "_clippingPlanes");
    },
  },
 
  /**
   * The {@link ClippingPolygonCollection} used to selectively disable rendering the tileset.
   *
   * @memberof Cesium3DTileset.prototype
   *
   * @type {ClippingPolygonCollection}
   */
  clippingPolygons: {
    get: function () {
      return this._clippingPolygons;
    },
    set: function (value) {
      ClippingPolygonCollection.setOwner(value, this, "_clippingPolygons");
    },
  },
 
  /**
   * The collection of <code>ImageryLayer</code> objects providing 2D georeferenced
   * image data that will be rendered over the tileset.
   *
   * The imagery will be draped over glTF, B3DM, PNTS, or GeoJSON tile content.
   *
   * @see ImageryLayer
   *
   * @memberof Cesium3DTileset.prototype
   * @readonly
   * @type {ImageryLayerCollection}
   *
   * @experimental This feature is not final and is subject to change without Cesium's standard deprecation policy.
   *
   * @example
   * // Drape Bing Maps Aerial imagery over the tileset
   * const imageryProvider = await Cesium.createWorldImageryAsync({
   *   style: Cesium.IonWorldImageryStyle.AERIAL,
   * });
   * const imageryLayer = new ImageryLayer(imageryProvider);
   * tileset.imageryLayers.add(imageryLayer);
   */
  imageryLayers: {
    get: function () {
      return this._imageryLayers;
    },
  },
 
  /**
   * The modification counter of the imagery layers.
   *
   * This is incremented for each modification (layerAdded, layerMoved,
   * layerRemoved, layerShownOrHidden) of the imagery layers, and can
   * be used <b>internally</b> (by <code>ModelPrimitiveImagery</code>)
   * to trigger updates whenever the collection of imagery layers
   * changes.
   *
   * @memberof Cesium3DTileset.prototype
   * @readonly
   * @type {number}
   * @private
   */
  imageryLayersModificationCounter: {
    get: function () {
      return this._imageryLayersModificationCounter;
    },
  },
 
  /**
   * Whether loading imagery that is draped over the tileset should be
   * done asynchronously.
   *
   * @memberof Cesium3DTileset.prototype
   * @readonly
   * @type {boolean}
   * @private
   */
  asynchronouslyLoadImagery: {
    get: function () {
      return this._asynchronouslyLoadImagery;
    },
  },
 
  /**
   * Gets the tileset's properties dictionary object, which contains metadata about per-feature properties.
   * <p>
   * See the {@link https://github.com/CesiumGS/3d-tiles/tree/main/specification#reference-properties|properties schema reference}
   * in the 3D Tiles spec for the full set of properties.
   * </p>
   *
   * @memberof Cesium3DTileset.prototype
   *
   * @type {object}
   * @readonly
   *
   * @example
   * console.log(`Maximum building height: ${tileset.properties.height.maximum}`);
   * console.log(`Minimum building height: ${tileset.properties.height.minimum}`);
   *
   * @see Cesium3DTileFeature#getProperty
   * @see Cesium3DTileFeature#setProperty
   */
  properties: {
    get: function () {
      return this._properties;
    },
  },
 
  /**
   * When <code>true</code>, all tiles that meet the screen space error this frame are loaded. The tileset is
   * completely loaded for this view.
   *
   * @memberof Cesium3DTileset.prototype
   *
   * @type {boolean}
   * @readonly
   *
   * @default false
   *
   * @see Cesium3DTileset#allTilesLoaded
   */
  tilesLoaded: {
    get: function () {
      return this._tilesLoaded;
    },
  },
 
  /**
   * The resource used to fetch the tileset JSON file
   *
   * @memberof Cesium3DTileset.prototype
   *
   * @type {Resource}
   * @readonly
   */
  resource: {
    get: function () {
      return this._resource;
    },
  },
 
  /**
   * The base path that non-absolute paths in tileset JSON file are relative to.
   *
   * @memberof Cesium3DTileset.prototype
   *
   * @type {string}
   * @readonly
   * @deprecated
   */
  basePath: {
    get: function () {
      deprecationWarning(
        "Cesium3DTileset.basePath",
        "Cesium3DTileset.basePath has been deprecated. All tiles are relative to the url of the tileset JSON file that contains them. Use the url property instead.",
      );
      return this._basePath;
    },
  },
 
  /**
   * The style, defined using the
   * {@link https://github.com/CesiumGS/3d-tiles/tree/main/specification/Styling|3D Tiles Styling language},
   * applied to each feature in the tileset.
   * <p>
   * Assign <code>undefined</code> to remove the style, which will restore the visual
   * appearance of the tileset to its default when no style was applied.
   * </p>
   * <p>
   * The style is applied to a tile before the {@link Cesium3DTileset#tileVisible}
   * event is raised, so code in <code>tileVisible</code> can manually set a feature's
   * properties (e.g. color and show) after the style is applied. When
   * a new style is assigned any manually set properties are overwritten.
   * </p>
   * <p>
   * Use an always "true" condition to specify the Color for all objects that are not
   * overridden by pre-existing conditions. Otherwise, the default color Cesium.Color.White
   * will be used. Similarly, use an always "true" condition to specify the show property
   * for all objects that are not overridden by pre-existing conditions. Otherwise, the
   * default show value true will be used.
   * </p>
   *
   * @memberof Cesium3DTileset.prototype
   *
   * @type {Cesium3DTileStyle|undefined}
   *
   * @default undefined
   *
   * @example
   * tileset.style = new Cesium.Cesium3DTileStyle({
   *    color : {
   *        conditions : [
   *            ['${Height} >= 100', 'color("purple", 0.5)'],
   *            ['${Height} >= 50', 'color("red")'],
   *            ['true', 'color("blue")']
   *        ]
   *    },
   *    show : '${Height} > 0',
   *    meta : {
   *        description : '"Building id ${id} has height ${Height}."'
   *    }
   * });
   *
   * @see {@link https://github.com/CesiumGS/3d-tiles/tree/main/specification/Styling|3D Tiles Styling language}
   */
  style: {
    get: function () {
      return this._styleEngine.style;
    },
    set: function (value) {
      this._styleEngine.style = value;
    },
  },
 
  /**
   * A custom shader to apply to all tiles in the tileset. Only used for
   * contents that use {@link Model}. Using custom shaders with a
   * {@link Cesium3DTileStyle} may lead to undefined behavior.
   *
   * @memberof Cesium3DTileset.prototype
   *
   * @type {CustomShader|undefined}
   *
   * @default undefined
   *
   * @experimental This feature is using part of the 3D Tiles spec that is not final and is subject to change without Cesium's standard deprecation policy.
   */
  customShader: {
    get: function () {
      return this._customShader;
    },
    set: function (value) {
      this._customShader = value;
    },
  },
 
  /**
   * Whether the tileset is rendering different levels of detail in the same view.
   * Only relevant if {@link Cesium3DTileset.isSkippingLevelOfDetail} is true.
   *
   * @memberof Cesium3DTileset.prototype
   *
   * @type {boolean}
   * @private
   */
  hasMixedContent: {
    get: function () {
      return this._hasMixedContent;
    },
    set: function (value) {
      //>>includeStart('debug', pragmas.debug);
      Check.typeOf.bool("value", value);
      //>>includeEnd('debug');
 
      this._hasMixedContent = value;
    },
  },
 
  /**
   * Whether this tileset is actually skipping levels of detail.
   * The user option may have been disabled if all tiles are using additive refinement,
   * or if some tiles have a content type for which rendering does not support skipping
   *
   * @memberof Cesium3DTileset.prototype
   *
   * @type {boolean}
   * @private
   * @readonly
   */
  isSkippingLevelOfDetail: {
    get: function () {
      return (
        this.skipLevelOfDetail &&
        !defined(this._classificationType) &&
        !this._disableSkipLevelOfDetail &&
        !this._allTilesAdditive
      );
    },
  },
 
  /**
   * The tileset's schema, groups, tileset metadata and other details from the
   * 3DTILES_metadata extension or a 3D Tiles 1.1 tileset JSON. This getter is
   * for internal use by other classes.
   *
   * @memberof Cesium3DTileset.prototype
   * @type {Cesium3DTilesetMetadata}
   * @private
   * @readonly
   *
   * @experimental This feature is using part of the 3D Tiles spec that is not final and is subject to change without Cesium's standard deprecation policy.
   */
  metadataExtension: {
    get: function () {
      return this._metadataExtension;
    },
  },
 
  /**
   * The metadata properties attached to the tileset as a whole.
   *
   * @memberof Cesium3DTileset.prototype
   *
   * @type {TilesetMetadata}
   * @private
   * @readonly
   *
   * @experimental This feature is using part of the 3D Tiles spec that is not final and is subject to change without Cesium's standard deprecation policy.
   */
  metadata: {
    get: function () {
      Eif (defined(this._metadataExtension)) {
        return this._metadataExtension.tileset;
      }
 
      return undefined;
    },
  },
 
  /**
   * The metadata schema used in this tileset. Shorthand for
   * <code>tileset.metadataExtension.schema</code>
   *
   * @memberof Cesium3DTileset.prototype
   *
   * @type {MetadataSchema}
   * @private
   * @readonly
   *
   * @experimental This feature is using part of the 3D Tiles spec that is not final and is subject to change without Cesium's standard deprecation policy.
   */
  schema: {
    get: function () {
      if (defined(this._metadataExtension)) {
        return this._metadataExtension.schema;
      }
 
      return undefined;
    },
  },
 
  /**
   * The maximum screen space error used to drive level of detail refinement.  This value helps determine when a tile
   * refines to its descendants, and therefore plays a major role in balancing performance with visual quality.
   * <p>
   * A tile's screen space error is roughly equivalent to the number of pixels wide that would be drawn if a sphere with a
   * radius equal to the tile's <b>geometric error</b> were rendered at the tile's position. If this value exceeds
   * <code>maximumScreenSpaceError</code> the tile refines to its descendants.
   * </p>
   * <p>
   * Depending on the tileset, <code>maximumScreenSpaceError</code> may need to be tweaked to achieve the right balance.
   * Higher values provide better performance but lower visual quality.
   * </p>
   *
   * @memberof Cesium3DTileset.prototype
   *
   * @type {number}
   * @default 16
   *
   * @exception {DeveloperError} <code>maximumScreenSpaceError</code> must be greater than or equal to zero.
   */
  maximumScreenSpaceError: {
    get: function () {
      return this._maximumScreenSpaceError;
    },
    set: function (value) {
      //>>includeStart('debug', pragmas.debug);
      Check.typeOf.number.greaterThanOrEquals(
        "maximumScreenSpaceError",
        value,
        0,
      );
      //>>includeEnd('debug');
 
      this._maximumScreenSpaceError = value;
      this._memoryAdjustedScreenSpaceError = value;
    },
  },
 
  /**
   * The amount of GPU memory (in bytes) used to cache tiles. This memory usage is estimated from
   * geometry, textures, and batch table textures of loaded tiles. For point clouds, this value also
   * includes per-point metadata.
   * <p>
   * Tiles not in view are unloaded to enforce this.
   * </p>
   * <p>
   * If decreasing this value results in unloading tiles, the tiles are unloaded the next frame.
   * </p>
   * <p>
   * If tiles sized more than <code>cacheBytes</code> are needed to meet the
   * desired screen space error, determined by {@link Cesium3DTileset#maximumScreenSpaceError},
   * for the current view, then the memory usage of the tiles loaded will exceed
   * <code>cacheBytes</code> by up to <code>maximumCacheOverflowBytes</code>.
   * For example, if <code>cacheBytes</code> is 500000, but 600000 bytes
   * of tiles are needed to meet the screen space error, then 600000 bytes of tiles
   * may be loaded (if <code>maximumCacheOverflowBytes</code> is at least 100000).
   * When these tiles go out of view, they will be unloaded.
   * </p>
   *
   * @memberof Cesium3DTileset.prototype
   *
   * @type {number}
   * @default 536870912
   *
   * @exception {DeveloperError} <code>cacheBytes</code> must be typeof 'number' and greater than or equal to 0
   * @see Cesium3DTileset#totalMemoryUsageInBytes
   */
  cacheBytes: {
    get: function () {
      return this._cacheBytes;
    },
    set: function (value) {
      //>>includeStart('debug', pragmas.debug);
      Check.typeOf.number.greaterThanOrEquals("value", value, 0);
      //>>includeEnd('debug');
 
      this._cacheBytes = value;
    },
  },
 
  /**
   * The maximum additional amount of GPU memory (in bytes) that will be used to cache tiles.
   * <p>
   * If tiles sized more than <code>cacheBytes</code> plus <code>maximumCacheOverflowBytes</code>
   * are needed to meet the desired screen space error, determined by
   * {@link Cesium3DTileset#maximumScreenSpaceError} for the current view, then
   * {@link Cesium3DTileset#memoryAdjustedScreenSpaceError} will be adjusted
   * until the tiles required to meet the adjusted screen space error use less
   * than <code>cacheBytes</code> plus <code>maximumCacheOverflowBytes</code>.
   * </p>
   *
   * @memberof Cesium3DTileset.prototype
   *
   * @type {number}
   * @default 536870912
   *
   * @exception {DeveloperError} <code>maximumCacheOverflowBytes</code> must be typeof 'number' and greater than or equal to 0
   * @see Cesium3DTileset#totalMemoryUsageInBytes
   */
  maximumCacheOverflowBytes: {
    get: function () {
      return this._maximumCacheOverflowBytes;
    },
    set: function (value) {
      //>>includeStart('debug', pragmas.debug);
      Check.typeOf.number.greaterThanOrEquals("value", value, 0);
      //>>includeEnd('debug');
 
      this._maximumCacheOverflowBytes = value;
    },
  },
 
  /**
   * If loading the level of detail required by @{link Cesium3DTileset#maximumScreenSpaceError}
   * results in the memory usage exceeding @{link Cesium3DTileset#cacheBytes}
   * plus @{link Cesium3DTileset#maximumCacheOverflowBytes}, level of detail refinement
   * will instead use this (larger) adjusted screen space error to achieve the
   * best possible visual quality within the available memory
   *
   * @memberof Cesium3DTileset.prototype
   *
   * @type {number}
   * @readonly
   *
   * @private
   */
  memoryAdjustedScreenSpaceError: {
    get: function () {
      return this._memoryAdjustedScreenSpaceError;
    },
  },
 
  /**
   * Options for controlling point size based on geometric error and eye dome lighting.
   *
   * @memberof Cesium3DTileset.prototype
   *
   * @type {PointCloudShading}
   */
  pointCloudShading: {
    get: function () {
      return this._pointCloudShading;
    },
    set: function (value) {
      //>>includeStart('debug', pragmas.debug);
      Check.defined("pointCloudShading", value);
      //>>includeEnd('debug');
      this._pointCloudShading = value;
    },
  },
 
  /**
   * The root tile.
   *
   * @memberOf Cesium3DTileset.prototype
   *
   * @type {Cesium3DTile}
   * @readonly
   */
  root: {
    get: function () {
      return this._root;
    },
  },
 
  /**
   * The tileset's bounding sphere.
   *
   * @memberof Cesium3DTileset.prototype
   *
   * @type {BoundingSphere}
   * @readonly
   *
   * @example
   * const tileset = await Cesium.Cesium3DTileset.fromUrl("http://localhost:8002/tilesets/Seattle/tileset.json");
   *
   * viewer.scene.primitives.add(tileset);
   *
   * // Set the camera to view the newly added tileset
   * viewer.camera.viewBoundingSphere(tileset.boundingSphere, new Cesium.HeadingPitchRange(0, -0.5, 0));
   */
  boundingSphere: {
    get: function () {
      this._root.updateTransform(this._modelMatrix);
      return this._root.boundingSphere;
    },
  },
 
  /**
   * A 4x4 transformation matrix that transforms the entire tileset.
   *
   * @memberof Cesium3DTileset.prototype
   *
   * @type {Matrix4}
   * @default Matrix4.IDENTITY
   *
   * @example
   * // Adjust a tileset's height from the globe's surface.
   * const heightOffset = 20.0;
   * const boundingSphere = tileset.boundingSphere;
   * const cartographic = Cesium.Cartographic.fromCartesian(boundingSphere.center);
   * const surface = Cesium.Cartesian3.fromRadians(cartographic.longitude, cartographic.latitude, 0.0);
   * const offset = Cesium.Cartesian3.fromRadians(cartographic.longitude, cartographic.latitude, heightOffset);
   * const translation = Cesium.Cartesian3.subtract(offset, surface, new Cesium.Cartesian3());
   * tileset.modelMatrix = Cesium.Matrix4.fromTranslation(translation);
   */
  modelMatrix: {
    get: function () {
      return this._modelMatrix;
    },
    set: function (value) {
      this._modelMatrix = Matrix4.clone(value, this._modelMatrix);
    },
  },
 
  /**
   * Returns the time, in milliseconds, since the tileset was loaded and first updated.
   *
   * @memberof Cesium3DTileset.prototype
   *
   * @type {number}
   * @readonly
   */
  timeSinceLoad: {
    get: function () {
      return this._timeSinceLoad;
    },
  },
 
  /**
   * The total amount of GPU memory in bytes used by the tileset. This value is estimated from
   * geometry, texture, batch table textures, and binary metadata of loaded tiles.
   *
   * @memberof Cesium3DTileset.prototype
   *
   * @type {number}
   * @readonly
   *
   * @see Cesium3DTileset#cacheBytes
   */
  totalMemoryUsageInBytes: {
    get: function () {
      const statistics = this._statistics;
      return (
        statistics.texturesByteLength +
        statistics.geometryByteLength +
        statistics.batchTableByteLength
      );
    },
  },
 
  /**
   * @private
   */
  clippingPlanesOriginMatrix: {
    get: function () {
      Iif (!defined(this._clippingPlanesOriginMatrix)) {
        return Matrix4.IDENTITY;
      }
 
      if (this._clippingPlanesOriginMatrixDirty) {
        Matrix4.multiply(
          this.root.computedTransform,
          this._initialClippingPlanesOriginMatrix,
          this._clippingPlanesOriginMatrix,
        );
        this._clippingPlanesOriginMatrixDirty = false;
      }
 
      return this._clippingPlanesOriginMatrix;
    },
  },
 
  /**
   * @private
   */
  styleEngine: {
    get: function () {
      return this._styleEngine;
    },
  },
 
  /**
   * @private
   */
  statistics: {
    get: function () {
      return this._statistics;
    },
  },
 
  /**
   * Determines whether terrain, 3D Tiles, or both will be classified by this tileset.
   * <p>
   * This option is only applied to tilesets containing batched 3D models,
   * glTF content, geometry data, or vector data. Even when undefined, vector
   * and geometry data must render as classifications and will default to
   * rendering on both terrain and other 3D Tiles tilesets.
   * </p>
   * <p>
   * When enabled for batched 3D model and glTF tilesets, there are a few
   * requirements/limitations on the glTF:
   * <ul>
   *     <li>The glTF cannot contain morph targets, skins, or animations.</li>
   *     <li>The glTF cannot contain the <code>EXT_mesh_gpu_instancing</code> extension.</li>
   *     <li>Only meshes with TRIANGLES can be used to classify other assets.</li>
   *     <li>The meshes must be watertight.</li>
   *     <li>The <code>POSITION</code> semantic is required.</li>
   *     <li>If <code>_BATCHID</code>s and an index buffer are both present, all indices with the same batch id must occupy contiguous sections of the index buffer.</li>
   *     <li>If <code>_BATCHID</code>s are present with no index buffer, all positions with the same batch id must occupy contiguous sections of the position buffer.</li>
   * </ul>
   * </p>
   * <p>
   * Additionally, classification is not supported for points or instanced 3D
   * models.
   * </p>
   * <p>
   * The 3D Tiles or terrain receiving the classification must be opaque.
   * </p>
   *
   * @memberof Cesium3DTileset.prototype
   *
   * @type {ClassificationType}
   * @default undefined
   *
   * @experimental This feature is using part of the 3D Tiles spec that is not final and is subject to change without Cesium's standard deprecation policy.
   * @readonly
   */
  classificationType: {
    get: function () {
      return this._classificationType;
    },
  },
 
  /**
   * Specifies if the height is relative to terrain, 3D Tiles, or both.
   * <p>
   * This option is only applied to point features in tilesets containing vector data.
   * This option requires the Viewer's scene to be passed in through options.scene.
   * </p>
   *
   * @memberof Cesium3DTileset.prototype
   *
   * @type {HeightReference | undefined}
   * @default undefined
   *
   * @experimental This feature is using part of the 3D Tiles spec that is not final and is subject to change without Cesium's standard deprecation policy.
   * @readonly
   */
  heightReference: {
    get: function () {
      return this._heightReference;
    },
  },
 
  /**
   * The {@link CesiumWidget#scene} that the tileset will be rendered in, required for tilesets that specify a {@link heightReference} value for clamping 3D Tiles vector data content- like points, lines, and labels- to terrain or 3D tiles.
   *
   * @member of Cesium3DTileset.prototype
   *
   * @type {Scene | undefined}
   * @default undefined
   * @readonly
   *
   */
  scene: {
    get: function () {
      return this._scene;
    },
  },
 
  /**
   * Gets an ellipsoid describing the shape of the globe.
   *
   * @memberof Cesium3DTileset.prototype
   *
   * @type {Ellipsoid}
   * @readonly
   */
  ellipsoid: {
    get: function () {
      return this._ellipsoid;
    },
  },
 
  /**
   * Optimization option. Used when {@link Cesium3DTileset#foveatedScreenSpaceError} is true to control the cone size that determines which tiles are deferred.
   * Tiles that are inside this cone are loaded immediately. Tiles outside the cone are potentially deferred based on how far outside the cone they are and {@link Cesium3DTileset#foveatedInterpolationCallback} and {@link Cesium3DTileset#foveatedMinimumScreenSpaceErrorRelaxation}.
   * Setting this to 0.0 means the cone will be the line formed by the camera position and its view direction. Setting this to 1.0 means the cone encompasses the entire field of view of the camera, essentially disabling the effect.
   *
   * @memberof Cesium3DTileset.prototype
   *
   * @type {number}
   * @default 0.3
   */
  foveatedConeSize: {
    get: function () {
      return this._foveatedConeSize;
    },
    set: function (value) {
      //>>includeStart('debug', pragmas.debug);
      Check.typeOf.number.greaterThanOrEquals("foveatedConeSize", value, 0.0);
      Check.typeOf.number.lessThanOrEquals("foveatedConeSize", value, 1.0);
      //>>includeEnd('debug');
 
      this._foveatedConeSize = value;
    },
  },
 
  /**
   * Optimization option. Used when {@link Cesium3DTileset#foveatedScreenSpaceError} is true to control the starting screen space error relaxation for tiles outside the foveated cone.
   * The screen space error will be raised starting with this value up to {@link Cesium3DTileset#maximumScreenSpaceError} based on the provided {@link Cesium3DTileset#foveatedInterpolationCallback}.
   *
   * @memberof Cesium3DTileset.prototype
   *
   * @type {number}
   * @default 0.0
   */
  foveatedMinimumScreenSpaceErrorRelaxation: {
    get: function () {
      return this._foveatedMinimumScreenSpaceErrorRelaxation;
    },
    set: function (value) {
      //>>includeStart('debug', pragmas.debug);
      Check.typeOf.number.greaterThanOrEquals(
        "foveatedMinimumScreenSpaceErrorRelaxation",
        value,
        0.0,
      );
      Check.typeOf.number.lessThanOrEquals(
        "foveatedMinimumScreenSpaceErrorRelaxation",
        value,
        this.maximumScreenSpaceError,
      );
      //>>includeEnd('debug');
 
      this._foveatedMinimumScreenSpaceErrorRelaxation = value;
    },
  },
 
  /**
   * Returns the <code>extras</code> property at the top-level of the tileset JSON, which contains application specific metadata.
   * Returns <code>undefined</code> if <code>extras</code> does not exist.
   *
   * @memberof Cesium3DTileset.prototype
   *
   * @type {*}
   * @readonly
   *
   * @see {@link https://github.com/CesiumGS/3d-tiles/tree/main/specification#specifying-extensions-and-application-specific-extras|Extras in the 3D Tiles specification.}
   */
  extras: {
    get: function () {
      return this._extras;
    },
  },
 
  /**
   * The properties for managing image-based lighting on this tileset.
   *
   * @memberof Cesium3DTileset.prototype
   *
   * @type {ImageBasedLighting}
   */
  imageBasedLighting: {
    get: function () {
      return this._imageBasedLighting;
    },
    set: function (value) {
      //>>includeStart('debug', pragmas.debug);
      Check.typeOf.object("imageBasedLighting", this._imageBasedLighting);
      //>>includeEnd('debug');
      if (value !== this._imageBasedLighting) {
        if (
          this._shouldDestroyImageBasedLighting &&
          !this._imageBasedLighting.isDestroyed()
        ) {
          this._imageBasedLighting.destroy();
        }
        this._imageBasedLighting = value;
        this._shouldDestroyImageBasedLighting = false;
      }
    },
  },
 
  /**
   * The properties for managing dynamic environment maps on this model. Affects lighting.
   *
   * @memberof Cesium3DTileset.prototype
   * @readonly
   *
   * @example
   * // Change the ground color used for a tileset's environment map to a forest green
   * const environmentMapManager = tileset.environmentMapManager;
   * environmentMapManager.groundColor = Cesium.Color.fromCssColorString("#203b34");
   *
   * @type {DynamicEnvironmentMapManager}
   */
  environmentMapManager: {
    get: function () {
      return this._environmentMapManager;
    },
  },
 
  /**
   * Indicates that only the tileset's vector tiles should be used for classification.
   *
   * @memberof Cesium3DTileset.prototype
   *
   * @experimental This feature is using part of the 3D Tiles spec that is not final and is subject to change without Cesium's standard deprecation policy.
   *
   * @type {boolean}
   * @default false
   */
  vectorClassificationOnly: {
    get: function () {
      return this._vectorClassificationOnly;
    },
  },
 
  /**
   * Whether vector tiles should keep decoded positions in memory.
   * This is used with {@link Cesium3DTileFeature.getPolylinePositions}.
   *
   * @memberof Cesium3DTileset.prototype
   *
   * @experimental This feature is using part of the 3D Tiles spec that is not final and is subject to change without Cesium's standard deprecation policy.
   *
   * @type {boolean}
   * @default false
   */
  vectorKeepDecodedPositions: {
    get: function () {
      return this._vectorKeepDecodedPositions;
    },
  },
 
  /**
   * Determines whether the credits of the tileset will be displayed on the screen
   *
   * @memberof Cesium3DTileset.prototype
   *
   * @type {boolean}
   * @default false
   */
  showCreditsOnScreen: {
    get: function () {
      return this._showCreditsOnScreen;
    },
    set: function (value) {
      this._showCreditsOnScreen = value;
      createCredits(this);
    },
  },
 
  /**
   * Label of the feature ID set to use for picking and styling.
   * <p>
   * For EXT_mesh_features, this is the feature ID's label property, or
   * "featureId_N" (where N is the index in the featureIds array) when not
   * specified. EXT_feature_metadata did not have a label field, so such
   * feature ID sets are always labeled "featureId_N" where N is the index in
   * the list of all feature Ids, where feature ID attributes are listed before
   * feature ID textures.
   * </p>
   * <p>
   * If featureIdLabel is set to an integer N, it is converted to
   * the string "featureId_N" automatically. If both per-primitive and
   * per-instance feature IDs are present, the instance feature IDs take
   * priority.
   * </p>
   *
   * @memberof Cesium3DTileset.prototype
   *
   * @type {string}
   * @experimental This feature is using part of the 3D Tiles spec that is not final and is subject to change without Cesium's standard deprecation policy.
   */
  featureIdLabel: {
    get: function () {
      return this._featureIdLabel;
    },
    set: function (value) {
      // indices get converted into featureId_N
      if (typeof value === "number") {
        value = `featureId_${value}`;
      }
 
      //>>includeStart('debug', pragmas.debug);
      Check.typeOf.string("value", value);
      //>>includeEnd('debug');
 
      this._featureIdLabel = value;
    },
  },
 
  /**
   * Label of the instance feature ID set used for picking and styling.
   * <p>
   * If instanceFeatureIdLabel is set to an integer N, it is converted to
   * the string "instanceFeatureId_N" automatically.
   * If both per-primitive and per-instance feature IDs are present, the
   * instance feature IDs take priority.
   * </p>
   *
   * @memberof Cesium3DTileset.prototype
   *
   * @type {string}
   * @experimental This feature is using part of the 3D Tiles spec that is not final and is subject to change without Cesium's standard deprecation policy.
   */
  instanceFeatureIdLabel: {
    get: function () {
      return this._instanceFeatureIdLabel;
    },
    set: function (value) {
      // indices get converted into instanceFeatureId_N
      if (typeof value === "number") {
        value = `instanceFeatureId_${value}`;
      }
 
      //>>includeStart('debug', pragmas.debug);
      Check.typeOf.string("value", value);
      //>>includeEnd('debug');
 
      this._instanceFeatureIdLabel = value;
    },
  },
});
 
/**
 * Creates a {@link https://github.com/CesiumGS/3d-tiles/tree/main/specification|3D Tiles tileset},
 * used for streaming massive heterogeneous 3D geospatial datasets, from a Cesium ion asset ID.
 *
 * @param {number} assetId The Cesium ion asset id.
 * @param {Cesium3DTileset.ConstructorOptions} [options] An object describing initialization options
 * @returns {Promise<Cesium3DTileset>}
 *
 * @exception {RuntimeError} When the tileset asset version is not 0.0, 1.0, or 1.1,
 * or when the tileset contains a required extension that is not supported.
 *
 * @see Cesium3DTileset#fromUrl
 *
 * @example
 * // Load a Cesium3DTileset with a Cesium ion asset ID of 124624234
 * try {
 *   const tileset = await Cesium.Cesium3DTileset.fromIonAssetId(124624234);
 *   scene.primitives.add(tileset);
 * } catch (error) {
 *   console.error(`Error creating tileset: ${error}`);
 * }
 */
Cesium3DTileset.fromIonAssetId = async function (assetId, options) {
  //>>includeStart('debug', pragmas.debug);
  Check.defined("assetId", assetId);
  //>>includeEnd('debug');
 
  const resource = await IonResource.fromAssetId(assetId);
  return Cesium3DTileset.fromUrl(resource, options);
};
 
/**
 * Creates a {@link https://github.com/CesiumGS/3d-tiles/tree/main/specification|3D Tiles tileset},
 * used for streaming massive heterogeneous 3D geospatial datasets.
 *
 * @param {Resource|string} url The url to a tileset JSON file.
 * @param {Cesium3DTileset.ConstructorOptions} [options] An object describing initialization options
 * @returns {Promise<Cesium3DTileset>}
 *
 * @exception {RuntimeError} When the tileset asset version is not 0.0, 1.0, or 1.1,
 * or when the tileset contains a required extension that is not supported.
 *
 * @see Cesium3DTileset#fromIonAssetId
 *
 * @example
 * try {
 *   const tileset = await Cesium.Cesium3DTileset.fromUrl(
 *      "http://localhost:8002/tilesets/Seattle/tileset.json"
 *   );
 *   scene.primitives.add(tileset);
 * } catch (error) {
 *   console.error(`Error creating tileset: ${error}`);
 * }
 *
 * @example
 * // Common setting for the skipLevelOfDetail optimization
 * const tileset = await Cesium.Cesium3DTileset.fromUrl(
 *   "http://localhost:8002/tilesets/Seattle/tileset.json", {
 *      skipLevelOfDetail: true,
 *      baseScreenSpaceError: 1024,
 *      skipScreenSpaceErrorFactor: 16,
 *      skipLevels: 1,
 *      immediatelyLoadDesiredLevelOfDetail: false,
 *      loadSiblings: false,
 *      cullWithChildrenBounds: true
 * });
 * scene.primitives.add(tileset);
 *
 * @example
 * // Common settings for the dynamicScreenSpaceError optimization
 * const tileset = await Cesium.Cesium3DTileset.fromUrl(
 *   "http://localhost:8002/tilesets/Seattle/tileset.json", {
 *      dynamicScreenSpaceError: true,
 *      dynamicScreenSpaceErrorDensity: 2.0e-4,
 *      dynamicScreenSpaceErrorFactor: 24.0,
 *      dynamicScreenSpaceErrorHeightFalloff: 0.25
 * });
 * scene.primitives.add(tileset);
 */
Cesium3DTileset.fromUrl = async function (url, options) {
  //>>includeStart('debug', pragmas.debug);
  Check.defined("url", url);
  //>>includeEnd('debug');
 
  options = options ?? Frozen.EMPTY_OBJECT;
 
  const resource = Resource.createIfNeeded(url);
  let basePath;
  if (resource.extension === "json") {
    basePath = resource.getBaseUri(true);
  } else if (resource.isDataUri) {
    basePath = "";
  }
 
  const tilesetJson = await Cesium3DTileset.loadJson(resource);
  const metadataExtension = await processMetadataExtension(
    resource,
    tilesetJson,
  );
 
  const tileset = new Cesium3DTileset(options);
  tileset._resource = resource;
  tileset._url = resource.url;
  tileset._basePath = basePath;
  tileset._metadataExtension = metadataExtension;
  // Set these before loading the tileset since _geometricError
  // and _scaledGeometricError get accessed during tile creation
  tileset._geometricError = tilesetJson.geometricError;
  tileset._scaledGeometricError = tilesetJson.geometricError;
 
  const asset = tilesetJson.asset;
  tileset._asset = asset;
  tileset._extras = tilesetJson.extras;
 
  createCredits(tileset);
 
  // Handle legacy gltfUpAxis option
  const gltfUpAxis = defined(tilesetJson.asset.gltfUpAxis)
    ? Axis.fromName(tilesetJson.asset.gltfUpAxis)
    : Axis.Y;
  const modelUpAxis = options.modelUpAxis ?? gltfUpAxis;
  const modelForwardAxis = options.modelForwardAxis ?? Axis.X;
 
  tileset._properties = tilesetJson.properties;
  tileset._extensionsUsed = tilesetJson.extensionsUsed;
  tileset._extensions = tilesetJson.extensions;
  tileset._modelUpAxis = modelUpAxis;
  tileset._modelForwardAxis = modelForwardAxis;
 
  tileset._root = tileset.loadTileset(resource, tilesetJson);
 
  // Save the original, untransformed bounding volume position so we can apply
  // the tile transform and model matrix at run time
  const boundingVolume = tileset._root.createBoundingVolume(
    tilesetJson.root.boundingVolume,
    Matrix4.IDENTITY,
  );
  const clippingPlanesOrigin = boundingVolume.boundingSphere.center;
  // If this origin is above the surface of the earth
  // we want to apply an ENU orientation as our best guess of orientation.
  // Otherwise, we assume it gets its position/orientation completely from the
  // root tile transform and the tileset's model matrix
  const originCartographic =
    tileset._ellipsoid.cartesianToCartographic(clippingPlanesOrigin);
  if (
    defined(originCartographic) &&
    originCartographic.height >
      ApproximateTerrainHeights._defaultMinTerrainHeight
  ) {
    tileset._initialClippingPlanesOriginMatrix =
      Transforms.eastNorthUpToFixedFrame(clippingPlanesOrigin);
  }
  tileset._clippingPlanesOriginMatrix = Matrix4.clone(
    tileset._initialClippingPlanesOriginMatrix,
  );
 
  return tileset;
};
 
/**
 * Provides a hook to override the method used to request the tileset json
 * useful when fetching tilesets from remote servers
 * @param {Resource|string} tilesetUrl The url of the json file to be fetched
 * @returns {Promise<object>} A promise that resolves with the fetched json data
 */
Cesium3DTileset.loadJson = function (tilesetUrl) {
  const resource = Resource.createIfNeeded(tilesetUrl);
  return resource.fetchJson();
};
 
/**
 * Marks the tileset's {@link Cesium3DTileset#style} as dirty, which forces all
 * features to re-evaluate the style in the next frame each is visible.
 */
Cesium3DTileset.prototype.makeStyleDirty = function () {
  this._styleEngine.makeDirty();
};
 
/**
 * Loads the main tileset JSON file or a tileset JSON file referenced from a tile.
 *
 * @exception {RuntimeError} When the tileset asset version is not 0.0, 1.0, or 1.1,
 * or when the tileset contains a required extension that is not supported.
 *
 * @private
 */
Cesium3DTileset.prototype.loadTileset = function (
  resource,
  tilesetJson,
  parentTile,
) {
  const asset = tilesetJson.asset;
  Iif (!defined(asset)) {
    throw new RuntimeError("Tileset must have an asset property.");
  }
  if (
    asset.version !== "0.0" &&
    asset.version !== "1.0" &&
    asset.version !== "1.1"
  ) {
    throw new RuntimeError(
      "The tileset must be 3D Tiles version 0.0, 1.0, or 1.1",
    );
  }
 
  if (defined(tilesetJson.extensionsRequired)) {
    Cesium3DTileset.checkSupportedExtensions(tilesetJson.extensionsRequired);
  }
 
  const statistics = this._statistics;
 
  const tilesetVersion = asset.tilesetVersion;
  if (defined(tilesetVersion)) {
    // Append the tileset version to the resource
    this._basePath += `?v=${tilesetVersion}`;
    resource = resource.clone();
    resource.setQueryParameters({ v: tilesetVersion });
  }
 
  // A tileset JSON file referenced from a tile may exist in a different directory than the root tileset.
  // Get the basePath relative to the external tileset.
  const rootTile = makeTile(this, resource, tilesetJson.root, parentTile);
 
  // If there is a parentTile, add the root of the currently loading tileset
  // to parentTile's children, and update its _depth.
  if (defined(parentTile)) {
    parentTile.children.push(rootTile);
    rootTile._depth = parentTile._depth + 1;
  }
 
  const stack = [];
  stack.push(rootTile);
 
  while (stack.length > 0) {
    const tile = stack.pop();
    ++statistics.numberOfTilesTotal;
    this._allTilesAdditive =
      this._allTilesAdditive && tile.refine === Cesium3DTileRefine.ADD;
    const children = tile._header.children;
    if (defined(children)) {
      for (let i = 0; i < children.length; ++i) {
        const childHeader = children[i];
        const childTile = makeTile(this, resource, childHeader, tile);
        tile.children.push(childTile);
        childTile._depth = tile._depth + 1;
        stack.push(childTile);
      }
    }
 
    if (this._cullWithChildrenBounds) {
      Cesium3DTileOptimizations.checkChildrenWithinParent(tile);
    }
  }
 
  return rootTile;
};
 
/**
 * Make a {@link Cesium3DTile} for a specific tile. If the tile's header has implicit
 * tiling (3D Tiles 1.1) or uses the <code>3DTILES_implicit_tiling</code> extension,
 * it creates a placeholder tile instead for lazy evaluation of the implicit tileset.
 *
 * @param {Cesium3DTileset} tileset The tileset
 * @param {Resource} baseResource The base resource for the tileset
 * @param {object} tileHeader The JSON header for the tile
 * @param {Cesium3DTile} [parentTile] The parent tile of the new tile
 * @returns {Cesium3DTile} The newly created tile
 *
 * @private
 */
function makeTile(tileset, baseResource, tileHeader, parentTile) {
  const hasImplicitTiling =
    defined(tileHeader.implicitTiling) ||
    hasExtension(tileHeader, "3DTILES_implicit_tiling");
 
  if (!hasImplicitTiling) {
    return new Cesium3DTile(tileset, baseResource, tileHeader, parentTile);
  }
 
  const metadataSchema = tileset.schema;
 
  const implicitTileset = new ImplicitTileset(
    baseResource,
    tileHeader,
    metadataSchema,
  );
  const rootCoordinates = new ImplicitTileCoordinates({
    subdivisionScheme: implicitTileset.subdivisionScheme,
    subtreeLevels: implicitTileset.subtreeLevels,
    level: 0,
    x: 0,
    y: 0,
    // The constructor will only use this for octrees.
    z: 0,
  });
 
  // Create a placeholder Cesium3DTile that has an ImplicitTileset
  // object and whose content will resolve to an Implicit3DTileContent
  const contentUri = implicitTileset.subtreeUriTemplate.getDerivedResource({
    templateValues: rootCoordinates.getTemplateValues(),
  }).url;
 
  const deepCopy = true;
  const tileJson = clone(tileHeader, deepCopy);
  // Replace contents with the subtree
  tileJson.contents = [
    {
      uri: contentUri,
    },
  ];
 
  delete tileJson.content;
 
  // The placeholder tile does not have any extensions. If there are any
  // extensions beyond 3DTILES_implicit_tiling, Implicit3DTileContent will
  // copy them to the transcoded tiles.
  delete tileJson.extensions;
 
  const tile = new Cesium3DTile(tileset, baseResource, tileJson, parentTile);
  tile.implicitTileset = implicitTileset;
  tile.implicitCoordinates = rootCoordinates;
  return tile;
}
 
/**
 * If tileset metadata is present, initialize the {@link Cesium3DTilesetMetadata}
 * instance. This is asynchronous since metadata schemas may be external.
 *
 * @param {Cesium3DTileset} tileset The tileset
 * @param {object} tilesetJson The tileset JSON
 * @return {Promise<Cesium3DTilesetMetadata>} The loaded Cesium3DTilesetMetadata
 * @private
 */
async function processMetadataExtension(resource, tilesetJson) {
  const metadataJson = hasExtension(tilesetJson, "3DTILES_metadata")
    ? tilesetJson.extensions["3DTILES_metadata"]
    : tilesetJson;
 
  let schemaLoader;
  if (defined(metadataJson.schemaUri)) {
    resource = resource.getDerivedResource({
      url: metadataJson.schemaUri,
    });
    schemaLoader = ResourceCache.getSchemaLoader({
      resource: resource,
    });
  } else if (defined(metadataJson.schema)) {
    schemaLoader = ResourceCache.getSchemaLoader({
      schema: metadataJson.schema,
    });
  } else {
    return;
  }
 
  await schemaLoader.load();
 
  const metadataExtension = new Cesium3DTilesetMetadata({
    schema: schemaLoader.schema,
    metadataJson: metadataJson,
  });
 
  ResourceCache.unload(schemaLoader);
 
  return metadataExtension;
}
 
const scratchPositionNormal = new Cartesian3();
const scratchCartographic = new Cartographic();
const scratchMatrix = new Matrix4();
const scratchCenter = new Cartesian3();
const scratchPosition = new Cartesian3();
const scratchDirection = new Cartesian3();
const scratchHalfHeight = new Cartesian3();
 
/**
 * @private
 * @param {Cesium3DTileset} tileset
 * @param {FrameState} frameState
 */
function updateDynamicScreenSpaceError(tileset, frameState) {
  let up;
  let direction;
  let height;
  let minimumHeight;
  let maximumHeight;
 
  const camera = frameState.camera;
  const root = tileset._root;
  const tileBoundingVolume = root.contentBoundingVolume;
 
  if (tileBoundingVolume instanceof TileBoundingRegion) {
    up = Cartesian3.normalize(camera.positionWC, scratchPositionNormal);
    direction = camera.directionWC;
    height = camera.positionCartographic.height;
    minimumHeight = tileBoundingVolume.minimumHeight;
    maximumHeight = tileBoundingVolume.maximumHeight;
  } else {
    // Transform camera position and direction into the local coordinate system of the tileset
    const transformLocal = Matrix4.inverseTransformation(
      root.computedTransform,
      scratchMatrix,
    );
    const ellipsoid = frameState.mapProjection.ellipsoid;
    const boundingVolume = tileBoundingVolume.boundingVolume;
    const centerLocal = Matrix4.multiplyByPoint(
      transformLocal,
      boundingVolume.center,
      scratchCenter,
    );
    if (Cartesian3.magnitude(centerLocal) > ellipsoid.minimumRadius) {
      // The tileset is defined in WGS84. Approximate the minimum and maximum height.
      const centerCartographic = Cartographic.fromCartesian(
        centerLocal,
        ellipsoid,
        scratchCartographic,
      );
      up = Cartesian3.normalize(camera.positionWC, scratchPositionNormal);
      direction = camera.directionWC;
      height = camera.positionCartographic.height;
      minimumHeight = 0.0;
      maximumHeight = centerCartographic.height * 2.0;
    } else {
      // The tileset is defined in local coordinates (z-up)
      const positionLocal = Matrix4.multiplyByPoint(
        transformLocal,
        camera.positionWC,
        scratchPosition,
      );
      up = Cartesian3.UNIT_Z;
      direction = Matrix4.multiplyByPointAsVector(
        transformLocal,
        camera.directionWC,
        scratchDirection,
      );
      direction = Cartesian3.normalize(direction, direction);
      height = positionLocal.z;
      if (tileBoundingVolume instanceof TileOrientedBoundingBox) {
        // Assuming z-up, the last column is the local z direction and
        // represents the height of the bounding box.
        const halfHeightVector = Matrix3.getColumn(
          boundingVolume.halfAxes,
          2,
          scratchHalfHeight,
        );
        const halfHeight = Cartesian3.magnitude(halfHeightVector);
        minimumHeight = centerLocal.z - halfHeight;
        maximumHeight = centerLocal.z + halfHeight;
      } else Eif (tileBoundingVolume instanceof TileBoundingSphere) {
        const radius = boundingVolume.radius;
        minimumHeight = centerLocal.z - radius;
        maximumHeight = centerLocal.z + radius;
      }
    }
  }
 
  // The range where the density starts to lessen. Start at the quarter height of the tileset.
  const heightFalloff = tileset.dynamicScreenSpaceErrorHeightFalloff;
  const heightClose =
    minimumHeight + (maximumHeight - minimumHeight) * heightFalloff;
  const heightFar = maximumHeight;
 
  const t = CesiumMath.clamp(
    (height - heightClose) / (heightFar - heightClose),
    0.0,
    1.0,
  );
 
  // Increase density as the camera tilts towards the horizon
  let horizonFactor = 1.0 - Math.abs(Cartesian3.dot(direction, up));
 
  // Weaken the horizon factor as the camera height increases, implying the camera is further away from the tileset.
  // The goal is to increase density for the "street view", not when viewing the tileset from a distance.
  horizonFactor = horizonFactor * (1.0 - t);
 
  tileset._dynamicScreenSpaceErrorComputedDensity =
    tileset.dynamicScreenSpaceErrorDensity * horizonFactor;
}
 
/**
 * @private
 * @param {Cesium3DTileset} tileset
 * @param {Cesium3DTile} tile
 */
function requestContent(tileset, tile) {
  Iif (tile.hasEmptyContent) {
    return;
  }
 
  const { statistics } = tileset;
  const contentExpired = tile.contentExpired;
 
  const promise = tile.requestContent();
  if (!defined(promise)) {
    return;
  }
 
  promise
    .then((content) => {
      if (!defined(content) || tile.isDestroyed() || tileset.isDestroyed()) {
        return;
      }
 
      tileset._processingQueue.push(tile);
      ++statistics.numberOfTilesProcessing;
    })
    .catch((error) => {
      handleTileFailure(error, tileset, tile);
    });
 
  if (contentExpired) {
    if (tile.hasTilesetContent || tile.hasImplicitContent) {
      destroySubtree(tileset, tile);
    } else {
      statistics.decrementLoadCounts(tile.content);
      --statistics.numberOfTilesWithContentReady;
    }
  }
 
  tileset._requestedTilesInFlight.push(tile);
}
 
function sortTilesByPriority(a, b) {
  return a._priority - b._priority;
}
 
/**
 * Perform any pass invariant tasks here. Called after the render pass.
 * @private
 * @param {FrameState} frameState
 */
Cesium3DTileset.prototype.postPassesUpdate = function (frameState) {
  if (!defined(this._root)) {
    return;
  }
 
  cancelOutOfViewRequests(this, frameState);
  raiseLoadProgressEvent(this, frameState);
  this._cache.unloadTiles(this, unloadTile);
 
  // If the style wasn't able to be applied this frame (for example,
  // the tileset was hidden), keep it dirty so the engine can try
  // to apply the style next frame.
  if (this._styleApplied) {
    this._styleEngine.resetDirty();
  }
  this._styleApplied = false;
};
 
/**
 * Perform any pass invariant tasks here. Called before any passes are executed.
 * @private
 * @param {FrameState} frameState
 */
Cesium3DTileset.prototype.prePassesUpdate = function (frameState) {
  if (!defined(this._root)) {
    return;
  }
 
  processTiles(this, frameState);
 
  // Update clipping planes
  const clippingPlanes = this._clippingPlanes;
  this._clippingPlanesOriginMatrixDirty = true;
  if (defined(clippingPlanes) && clippingPlanes.enabled) {
    clippingPlanes.update(frameState);
  }
 
  // Update clipping polygons
  const clippingPolygons = this._clippingPolygons;
  Iif (defined(clippingPolygons) && clippingPolygons.enabled) {
    clippingPolygons.update(frameState);
  }
 
  if (!defined(this._loadTimestamp)) {
    this._loadTimestamp = JulianDate.clone(frameState.time);
  }
  this._timeSinceLoad = Math.max(
    JulianDate.secondsDifference(frameState.time, this._loadTimestamp) * 1000,
    0.0,
  );
 
  if (this.dynamicScreenSpaceError) {
    updateDynamicScreenSpaceError(this, frameState);
  }
 
  Eif (frameState.newFrame) {
    this._cache.reset();
  }
};
 
/**
 * @private
 * @param {Cesium3DTileset} tileset
 * @param {FrameState} frameState
 */
function cancelOutOfViewRequests(tileset, frameState) {
  const requestedTilesInFlight = tileset._requestedTilesInFlight;
  let removeCount = 0;
  for (let i = 0; i < requestedTilesInFlight.length; ++i) {
    const tile = requestedTilesInFlight[i];
 
    // NOTE: This is framerate dependant so make sure the threshold check is small
    const outOfView = frameState.frameNumber - tile._touchedFrame >= 1;
    if (tile._contentState !== Cesium3DTileContentState.LOADING) {
      // No longer fetching from host, don't need to track it anymore. Gets marked as LOADING in Cesium3DTile::requestContent().
      ++removeCount;
      continue;
    } else if (outOfView) {
      // RequestScheduler will take care of cancelling it
      tile.cancelRequests();
      ++removeCount;
      continue;
    }
 
    if (removeCount > 0) {
      requestedTilesInFlight[i - removeCount] = tile;
    }
  }
 
  requestedTilesInFlight.length -= removeCount;
}
 
/**
 * Sort requests by priority before making any requests.
 * This makes it less likely that requests will be cancelled after being issued.
 * @private
 * @param {Cesium3DTileset} tileset
 */
function requestTiles(tileset) {
  const requestedTiles = tileset._requestedTiles;
  requestedTiles.sort(sortTilesByPriority);
  for (let i = 0; i < requestedTiles.length; ++i) {
    requestContent(tileset, requestedTiles[i]);
  }
}
 
/**
 * @private
 * @param {Error} error
 * @param {Cesium3DTileset} tileset
 * @param {Cesium3DTile} tile
 */
function handleTileFailure(error, tileset, tile) {
  Iif (tileset.isDestroyed()) {
    return;
  }
 
  let url;
  Eif (!tile.isDestroyed()) {
    url = tile._contentResource.url;
  }
 
  const message = defined(error.message) ? error.message : error.toString();
  if (tileset.tileFailed.numberOfListeners > 0) {
    tileset.tileFailed.raiseEvent({
      url: url,
      message: message,
    });
  } else {
    console.log(`A 3D tile failed to load: ${url}`);
    console.log(`Error: ${message}`);
    console.log(error.stack);
  }
}
 
/**
 * @private
 * @param {Cesium3DTileset} tileset
 */
function filterProcessingQueue(tileset) {
  const tiles = tileset._processingQueue;
 
  let removeCount = 0;
  for (let i = 0; i < tiles.length; ++i) {
    const tile = tiles[i];
    if (
      tile.isDestroyed() ||
      tile._contentState !== Cesium3DTileContentState.PROCESSING
    ) {
      ++removeCount;
      continue;
    }
    if (removeCount > 0) {
      tiles[i - removeCount] = tile;
    }
  }
  tiles.length -= removeCount;
}
 
const scratchUpdateHeightCartographic = new Cartographic();
const scratchUpdateHeightCartographic2 = new Cartographic();
const scratchUpdateHeightCartesian = new Cartesian3();
 
function processUpdateHeight(tileset, tile, frameState) {
  Eif (!tileset.enableCollision || !tileset.show) {
    return;
  }
 
  const heightCallbackData = tileset._addHeightCallbacks;
  const boundingSphere = tile.boundingSphere;
 
  for (const callbackData of heightCallbackData) {
    // No need to update if the tile was already visible last frame
    if (callbackData.invoked || tile._wasSelectedLastFrame) {
      continue;
    }
 
    const ellipsoid = callbackData.ellipsoid;
    const positionCartographic = Cartographic.clone(
      callbackData.positionCartographic,
      scratchUpdateHeightCartographic,
    );
    const centerCartographic = Cartographic.fromCartesian(
      boundingSphere.center,
      ellipsoid,
      scratchUpdateHeightCartographic2,
    );
 
    // This can be undefined when the bounding sphere is at the origin
    if (defined(centerCartographic)) {
      positionCartographic.height = centerCartographic.height;
    }
 
    const position = Cartographic.toCartesian(
      positionCartographic,
      ellipsoid,
      scratchUpdateHeightCartesian,
    );
    if (
      Cartesian3.distance(position, boundingSphere.center) <=
      boundingSphere.radius
    ) {
      callbackData.invoked = true;
      frameState.afterRender.push(() => {
        // Callback can be removed before it actually invoked at the end of the frame
        if (defined(callbackData.callback)) {
          callbackData.callback();
        }
        callbackData.invoked = false;
      });
    }
  }
}
 
/**
 * Process tiles in the PROCESSING state so they will eventually move to the READY state.
 * @private
 * @param {Cesium3DTileset} tileset
 * @param {Cesium3DTile} tile
 */
function processTiles(tileset, frameState) {
  filterProcessingQueue(tileset);
  const tiles = tileset._processingQueue;
 
  const { cacheBytes, maximumCacheOverflowBytes, statistics } = tileset;
  const cacheByteLimit = cacheBytes + maximumCacheOverflowBytes;
 
  let memoryExceeded = false;
  for (let i = 0; i < tiles.length; ++i) {
    if (tileset.totalMemoryUsageInBytes > cacheByteLimit) {
      memoryExceeded = true;
      break;
    }
 
    const tile = tiles[i];
    try {
      tile.process(tileset, frameState);
 
      if (tile.contentReady) {
        --statistics.numberOfTilesProcessing;
        tileset.tileLoad.raiseEvent(tile);
      }
    } catch (error) {
      --statistics.numberOfTilesProcessing;
      handleTileFailure(error, tileset, tile);
    }
  }
 
  if (tileset.totalMemoryUsageInBytes < cacheBytes) {
    decreaseScreenSpaceError(tileset);
  } else if (memoryExceeded && tiles.length > 0) {
    increaseScreenSpaceError(tileset);
  }
}
 
function increaseScreenSpaceError(tileset) {
  //>>includeStart('debug', pragmas.debug);
  oneTimeWarning(
    "increase-screenSpaceError",
    `The tiles needed to meet maximumScreenSpaceError would use more memory than allocated for this tileset.
    The tileset will be rendered with a larger screen space error (see memoryAdjustedScreenSpaceError).
    Consider using larger values for cacheBytes and maximumCacheOverflowBytes.`,
  );
  //>>includeEnd('debug');
 
  tileset._memoryAdjustedScreenSpaceError *= 1.02;
  const tiles = tileset._processingQueue;
  for (let i = 0; i < tiles.length; ++i) {
    tiles[i].updatePriority();
  }
  tiles.sort(sortTilesByPriority);
}
 
function decreaseScreenSpaceError(tileset) {
  tileset._memoryAdjustedScreenSpaceError = Math.max(
    tileset.memoryAdjustedScreenSpaceError / 1.02,
    tileset.maximumScreenSpaceError,
  );
}
 
const scratchCartesian = new Cartesian3();
 
const stringOptions = {
  maximumFractionDigits: 3,
};
 
/**
 * @private
 * @param {number} memorySizeInBytes
 * @returns {string}
 */
function formatMemoryString(memorySizeInBytes) {
  const memoryInMegabytes = memorySizeInBytes / 1048576;
  Eif (memoryInMegabytes < 1.0) {
    return memoryInMegabytes.toLocaleString(undefined, stringOptions);
  }
  return Math.round(memoryInMegabytes).toLocaleString();
}
 
/**
 * @private
 * @param {Cesium3DTile} tile
 * @returns {Cartesian3}
 */
function computeTileLabelPosition(tile) {
  const { halfAxes, radius, center } = tile.boundingVolume.boundingVolume;
 
  let position = Cartesian3.clone(center, scratchCartesian);
  if (defined(halfAxes)) {
    position.x += 0.75 * (halfAxes[0] + halfAxes[3] + halfAxes[6]);
    position.y += 0.75 * (halfAxes[1] + halfAxes[4] + halfAxes[7]);
    position.z += 0.75 * (halfAxes[2] + halfAxes[5] + halfAxes[8]);
  } else Eif (defined(radius)) {
    let normal = Cartesian3.normalize(center, scratchCartesian);
    normal = Cartesian3.multiplyByScalar(
      normal,
      0.75 * radius,
      scratchCartesian,
    );
    position = Cartesian3.add(normal, center, scratchCartesian);
  }
  return position;
}
 
/**
 * @private
 * @param {Cesium3DTile} tile
 * @param {Cesium3DTileset} tileset
 * @param {Cartesian3} position
 * @returns {Label}
 */
function addTileDebugLabel(tile, tileset, position) {
  let labelString = "";
  let attributes = 0;
 
  if (tileset.debugShowGeometricError) {
    labelString += `\nGeometric error: ${tile.geometricError}`;
    attributes++;
  }
 
  if (tileset.debugShowRenderingStatistics) {
    labelString += `\nCommands: ${tile.commandsLength}`;
    attributes++;
 
    // Don't display number of points or triangles if 0.
    const numberOfPoints = tile.content.pointsLength;
    Iif (numberOfPoints > 0) {
      labelString += `\nPoints: ${tile.content.pointsLength}`;
      attributes++;
    }
 
    const numberOfTriangles = tile.content.trianglesLength;
    Eif (numberOfTriangles > 0) {
      labelString += `\nTriangles: ${tile.content.trianglesLength}`;
      attributes++;
    }
 
    labelString += `\nFeatures: ${tile.content.featuresLength}`;
    attributes++;
  }
 
  if (tileset.debugShowMemoryUsage) {
    labelString += `\nTexture Memory: ${formatMemoryString(
      tile.content.texturesByteLength,
    )}`;
    labelString += `\nGeometry Memory: ${formatMemoryString(
      tile.content.geometryByteLength,
    )}`;
    attributes += 2;
  }
 
  if (tileset.debugShowUrl) {
    if (tile.hasMultipleContents) {
      labelString += "\nUrls:";
      const urls = tile.content.innerContentUrls;
      for (let i = 0; i < urls.length; i++) {
        labelString += `\n- ${urls[i]}`;
      }
      attributes += urls.length;
    } else {
      labelString += `\nUrl: ${tile._contentHeader.uri}`;
      attributes++;
    }
  }
 
  const newLabel = {
    text: labelString.substring(1),
    position: position,
    font: `${19 - attributes}px sans-serif`,
    showBackground: true,
    disableDepthTestDistance: Number.POSITIVE_INFINITY,
  };
 
  return tileset._tileDebugLabels.add(newLabel);
}
 
/**
 * @private
 * @param {Cesium3DTileset} tileset
 * @param {FrameState} frameState
 */
function updateTileDebugLabels(tileset, frameState) {
  const selectedTiles = tileset._selectedTiles;
  const selectedLength = selectedTiles.length;
  const emptyTiles = tileset._emptyTiles;
  const emptyLength = emptyTiles.length;
  tileset._tileDebugLabels.removeAll();
 
  if (tileset.debugPickedTileLabelOnly) {
    if (defined(tileset.debugPickedTile)) {
      const position = defined(tileset.debugPickPosition)
        ? tileset.debugPickPosition
        : computeTileLabelPosition(tileset.debugPickedTile);
      const label = addTileDebugLabel(
        tileset.debugPickedTile,
        tileset,
        position,
      );
      label.pixelOffset = new Cartesian2(15, -15); // Offset to avoid picking the label.
    }
  } else {
    for (let i = 0; i < selectedLength; ++i) {
      const tile = selectedTiles[i];
      addTileDebugLabel(tile, tileset, computeTileLabelPosition(tile));
    }
    for (let i = 0; i < emptyLength; ++i) {
      const tile = emptyTiles[i];
      if (tile.hasTilesetContent || tile.hasImplicitContent) {
        addTileDebugLabel(tile, tileset, computeTileLabelPosition(tile));
      }
    }
  }
  tileset._tileDebugLabels.update(frameState);
}
 
/**
 * @private
 * @param {Cesium3DTileset} tileset
 * @param {FrameState} frameState
 * @param {object} passOptions
 */
function updateTiles(tileset, frameState, passOptions) {
  tileset._styleEngine.applyStyle(tileset);
  tileset._styleApplied = true;
 
  const { commandList, context } = frameState;
  const numberOfInitialCommands = commandList.length;
  const selectedTiles = tileset._selectedTiles;
 
  const bivariateVisibilityTest =
    tileset.isSkippingLevelOfDetail &&
    tileset._hasMixedContent &&
    context.stencilBuffer &&
    selectedTiles.length > 0;
 
  tileset._backfaceCommands.length = 0;
 
  if (bivariateVisibilityTest) {
    if (!defined(tileset._stencilClearCommand)) {
      tileset._stencilClearCommand = new ClearCommand({
        stencil: 0,
        pass: Pass.CESIUM_3D_TILE,
        renderState: RenderState.fromCache({
          stencilMask: StencilConstants.SKIP_LOD_MASK,
        }),
      });
    }
    commandList.push(tileset._stencilClearCommand);
  }
 
  const { statistics, tileVisible } = tileset;
  const isRender = passOptions.isRender;
  const lengthBeforeUpdate = commandList.length;
 
  for (let i = 0; i < selectedTiles.length; ++i) {
    const tile = selectedTiles[i];
    // Raise the tileVisible event before update in case the tileVisible event
    // handler makes changes that update needs to apply to WebGL resources
    if (isRender) {
      tileVisible.raiseEvent(tile);
    }
    processUpdateHeight(tileset, tile, frameState);
    tile.update(tileset, frameState, passOptions);
    statistics.incrementSelectionCounts(tile.content);
    ++statistics.selected;
  }
  const emptyTiles = tileset._emptyTiles;
  for (let i = 0; i < emptyTiles.length; ++i) {
    const tile = emptyTiles[i];
    tile.update(tileset, frameState, passOptions);
  }
 
  let addedCommandsLength = commandList.length - lengthBeforeUpdate;
 
  tileset._backfaceCommands.trim();
 
  if (bivariateVisibilityTest) {
    /*
     * Consider 'effective leaf' tiles as selected tiles that have no selected descendants. They may have children,
     * but they are currently our effective leaves because they do not have selected descendants. These tiles
     * are those where with tile._finalResolution === true.
     * Let 'unresolved' tiles be those with tile._finalResolution === false.
     *
     * 1. Render just the backfaces of unresolved tiles in order to lay down z
     * 2. Render all frontfaces wherever tile._selectionDepth > stencilBuffer.
     *    Replace stencilBuffer with tile._selectionDepth, when passing the z test.
     *    Because children are always drawn before ancestors {@link Cesium3DTilesetTraversal#traverseAndSelect},
     *    this effectively draws children first and does not draw ancestors if a descendant has already
     *    been drawn at that pixel.
     *    Step 1 prevents child tiles from appearing on top when they are truly behind ancestor content.
     *    If they are behind the backfaces of the ancestor, then they will not be drawn.
     *
     * NOTE: Step 2 sometimes causes visual artifacts when backfacing child content has some faces that
     * partially face the camera and are inside of the ancestor content. Because they are inside, they will
     * not be culled by the depth writes in Step 1, and because they partially face the camera, the stencil tests
     * will draw them on top of the ancestor content.
     *
     * NOTE: Because we always render backfaces of unresolved tiles, if the camera is looking at the backfaces
     * of an object, they will always be drawn while loading, even if backface culling is enabled.
     */
 
    const backfaceCommands = tileset._backfaceCommands.values;
    const backfaceCommandsLength = backfaceCommands.length;
 
    commandList.length += backfaceCommandsLength;
 
    // copy commands to the back of the commandList
    for (let i = addedCommandsLength - 1; i >= 0; --i) {
      commandList[lengthBeforeUpdate + backfaceCommandsLength + i] =
        commandList[lengthBeforeUpdate + i];
    }
 
    // move backface commands to the front of the commandList
    for (let i = 0; i < backfaceCommandsLength; ++i) {
      commandList[lengthBeforeUpdate + i] = backfaceCommands[i];
    }
  }
 
  // Number of commands added by each update above
  addedCommandsLength = commandList.length - numberOfInitialCommands;
  statistics.numberOfCommands = addedCommandsLength;
 
  if (!isRender) {
    return;
  }
 
  // Only run EDL if simple attenuation is on
  Iif (
    tileset.pointCloudShading.attenuation &&
    tileset.pointCloudShading.eyeDomeLighting &&
    addedCommandsLength > 0
  ) {
    tileset._pointCloudEyeDomeLighting.update(
      frameState,
      numberOfInitialCommands,
      tileset.pointCloudShading,
      tileset.boundingSphere,
    );
  }
 
  if (
    tileset.debugShowGeometricError ||
    tileset.debugShowRenderingStatistics ||
    tileset.debugShowMemoryUsage ||
    tileset.debugShowUrl
  ) {
    if (!defined(tileset._tileDebugLabels)) {
      tileset._tileDebugLabels = new LabelCollection();
    }
    updateTileDebugLabels(tileset, frameState);
  } else {
    tileset._tileDebugLabels =
      tileset._tileDebugLabels && tileset._tileDebugLabels.destroy();
  }
}
 
const scratchStack = [];
 
/**
 * @private
 * @param {Cesium3DTileset} tileset
 * @param {Cesium3DTile} tile
 */
function destroySubtree(tileset, tile) {
  const root = tile;
  const stack = scratchStack;
  stack.push(tile);
  while (stack.length > 0) {
    tile = stack.pop();
    const children = tile.children;
    for (let i = 0; i < children.length; ++i) {
      stack.push(children[i]);
    }
    if (tile !== root) {
      destroyTile(tileset, tile);
      --tileset._statistics.numberOfTilesTotal;
    }
  }
  root.children = [];
}
 
/**
 * @private
 * @param {Cesium3DTileset} tileset
 * @param {Cesium3DTile} tile
 */
function unloadTile(tileset, tile) {
  tileset.tileUnload.raiseEvent(tile);
  tileset._statistics.decrementLoadCounts(tile.content);
  --tileset._statistics.numberOfTilesWithContentReady;
  tile.unloadContent();
}
 
/**
 * @private
 * @param {Cesium3DTileset} tileset
 * @param {Cesium3DTile} tile
 */
function destroyTile(tileset, tile) {
  tileset._cache.unloadTile(tileset, tile, unloadTile);
  tile.destroy();
}
 
/**
 * Unloads all tiles that weren't selected the previous frame.  This can be used to
 * explicitly manage the tile cache and reduce the total number of tiles loaded below
 * {@link Cesium3DTileset#cacheBytes}.
 * <p>
 * Tile unloads occur at the next frame to keep all the WebGL delete calls
 * within the render loop.
 * </p>
 */
Cesium3DTileset.prototype.trimLoadedTiles = function () {
  this._cache.trim();
};
 
/**
 * @private
 * @param {Cesium3DTileset} tileset
 * @param {FrameState} frameState
 */
function raiseLoadProgressEvent(tileset, frameState) {
  const statistics = tileset._statistics;
  const statisticsLast = tileset._statisticsLast;
 
  const numberOfPendingRequests = statistics.numberOfPendingRequests;
  const numberOfTilesProcessing = statistics.numberOfTilesProcessing;
  const lastNumberOfPendingRequest = statisticsLast.numberOfPendingRequests;
  const lastNumberOfTilesProcessing = statisticsLast.numberOfTilesProcessing;
 
  Cesium3DTilesetStatistics.clone(statistics, statisticsLast);
 
  const progressChanged =
    numberOfPendingRequests !== lastNumberOfPendingRequest ||
    numberOfTilesProcessing !== lastNumberOfTilesProcessing;
 
  if (progressChanged) {
    frameState.afterRender.push(function () {
      tileset.loadProgress.raiseEvent(
        numberOfPendingRequests,
        numberOfTilesProcessing,
      );
 
      return true;
    });
  }
 
  tileset._tilesLoaded =
    statistics.numberOfPendingRequests === 0 &&
    statistics.numberOfTilesProcessing === 0 &&
    statistics.numberOfAttemptedRequests === 0;
 
  // Events are raised (added to the afterRender queue) here since promises
  // may resolve outside of the update loop that then raise events, e.g.,
  // model's readyEvent
  if (progressChanged && tileset._tilesLoaded) {
    frameState.afterRender.push(function () {
      tileset.allTilesLoaded.raiseEvent();
      return true;
    });
    if (!tileset._initialTilesLoaded) {
      tileset._initialTilesLoaded = true;
      frameState.afterRender.push(function () {
        tileset.initialTilesLoaded.raiseEvent();
        return true;
      });
    }
  }
}
 
/**
 * @private
 * @param {Cesium3DTileset} tileset
 */
function resetMinimumMaximum(tileset) {
  tileset._heatmap.resetMinimumMaximum();
  tileset._minimumPriority.depth = Number.MAX_VALUE;
  tileset._maximumPriority.depth = -Number.MAX_VALUE;
  tileset._minimumPriority.foveatedFactor = Number.MAX_VALUE;
  tileset._maximumPriority.foveatedFactor = -Number.MAX_VALUE;
  tileset._minimumPriority.distance = Number.MAX_VALUE;
  tileset._maximumPriority.distance = -Number.MAX_VALUE;
  tileset._minimumPriority.reverseScreenSpaceError = Number.MAX_VALUE;
  tileset._maximumPriority.reverseScreenSpaceError = -Number.MAX_VALUE;
}
 
/**
 * @private
 * @param {Cesium3DTileset} tileset
 * @param {FrameState} frameState
 */
function detectModelMatrixChanged(tileset, frameState) {
  if (
    frameState.frameNumber === tileset._updatedModelMatrixFrame &&
    defined(tileset._previousModelMatrix)
  ) {
    return;
  }
 
  tileset._updatedModelMatrixFrame = frameState.frameNumber;
  tileset._modelMatrixChanged = !Matrix4.equals(
    tileset.modelMatrix,
    tileset._previousModelMatrix,
  );
  if (tileset._modelMatrixChanged) {
    tileset._previousModelMatrix = Matrix4.clone(
      tileset.modelMatrix,
      tileset._previousModelMatrix,
    );
  }
}
 
/**
 * @private
 * @param {Cesium3DTileset} tileset
 * @param {FrameState} frameState
 * @param {Cesium3DTilesetStatistics} passStatistics
 * @param {object} passOptions
 * @returns {boolean}
 */
function update(tileset, frameState, passStatistics, passOptions) {
  if (frameState.mode === SceneMode.MORPHING) {
    return false;
  }
 
  if (!defined(tileset._root)) {
    return false;
  }
 
  const statistics = tileset._statistics;
  statistics.clear();
 
  // Resets the visibility check for each pass
  ++tileset._updatedVisibilityFrame;
 
  // Update any tracked min max values
  resetMinimumMaximum(tileset);
 
  detectModelMatrixChanged(tileset, frameState);
  tileset._cullRequestsWhileMoving =
    tileset.cullRequestsWhileMoving && !tileset._modelMatrixChanged;
 
  const ready = tileset
    .getTraversal(passOptions)
    .selectTiles(tileset, frameState);
 
  if (passOptions.requestTiles) {
    requestTiles(tileset);
  }
 
  updateTiles(tileset, frameState, passOptions);
 
  // Update pass statistics
  Cesium3DTilesetStatistics.clone(statistics, passStatistics);
 
  if (passOptions.isRender) {
    const credits = tileset._credits;
    if (defined(credits) && statistics.selected !== 0) {
      for (let i = 0; i < credits.length; ++i) {
        const credit = credits[i];
        frameState.creditDisplay.addCreditToNextFrame(credit);
      }
    }
  }
 
  return ready;
}
 
function createCredits(tileset) {
  let credits = tileset._credits;
  if (!defined(credits)) {
    credits = [];
  }
  credits.length = 0;
 
  Iif (defined(tileset.resource.credits)) {
    tileset.resource.credits.forEach((credit) => {
      credits.push(Credit.clone(credit));
    });
  }
 
  const assetExtras = tileset.asset.extras;
  Iif (
    defined(assetExtras) &&
    defined(assetExtras.cesium) &&
    defined(assetExtras.cesium.credits)
  ) {
    const extraCredits = assetExtras.cesium.credits;
    for (let i = 0; i < extraCredits.length; ++i) {
      const credit = extraCredits[i];
      credits.push(new Credit(credit.html));
    }
  }
 
  credits.forEach(
    (credit) =>
      (credit.showOnScreen =
        credit.showOnScreen || tileset._showCreditsOnScreen),
  );
 
  tileset._credits = credits;
}
 
/**
 * @private
 * @param {object} passOptions
 * @returns {Cesium3DTilesetTraversal}
 */
Cesium3DTileset.prototype.getTraversal = function (passOptions) {
  const { pass } = passOptions;
  Iif (
    pass === Cesium3DTilePass.MOST_DETAILED_PRELOAD ||
    pass === Cesium3DTilePass.MOST_DETAILED_PICK
  ) {
    return Cesium3DTilesetMostDetailedTraversal;
  }
  return this.isSkippingLevelOfDetail
    ? Cesium3DTilesetSkipTraversal
    : Cesium3DTilesetBaseTraversal;
};
 
/**
 * @private
 * @param {FrameState} frameState
 */
Cesium3DTileset.prototype.update = function (frameState) {
  this.updateForPass(frameState, frameState.tilesetPassState);
};
 
/**
 * @private
 * @param {FrameState} frameState
 * @param {object} tilesetPassState
 */
Cesium3DTileset.prototype.updateForPass = function (
  frameState,
  tilesetPassState,
) {
  //>>includeStart('debug', pragmas.debug);
  Check.typeOf.object("frameState", frameState);
  Check.typeOf.object("tilesetPassState", tilesetPassState);
  //>>includeEnd('debug');
 
  this.imageryLayers._update();
 
  const pass = tilesetPassState.pass;
  if (
    (pass === Cesium3DTilePass.PRELOAD &&
      (!this.preloadWhenHidden || this.show)) ||
    (pass === Cesium3DTilePass.PRELOAD_FLIGHT &&
      (!this.preloadFlightDestinations ||
        (!this.show && !this.preloadWhenHidden))) ||
    (pass === Cesium3DTilePass.REQUEST_RENDER_MODE_DEFER_CHECK &&
      ((!this._cullRequestsWhileMoving && this.foveatedTimeDelay <= 0) ||
        !this.show))
  ) {
    return;
  }
 
  const originalCommandList = frameState.commandList;
  const originalCamera = frameState.camera;
  const originalCullingVolume = frameState.cullingVolume;
 
  tilesetPassState.ready = false;
 
  const passOptions = Cesium3DTilePass.getPassOptions(pass);
  const ignoreCommands = passOptions.ignoreCommands;
 
  const commandList = tilesetPassState.commandList ?? originalCommandList;
  const commandStart = commandList.length;
 
  frameState.commandList = commandList;
  frameState.camera = tilesetPassState.camera ?? originalCamera;
  frameState.cullingVolume =
    tilesetPassState.cullingVolume ?? originalCullingVolume;
 
  if (passOptions.isRender) {
    const environmentMapManager = this._environmentMapManager;
    if (defined(this._root)) {
      environmentMapManager.position = this.boundingSphere.center;
    }
    environmentMapManager.update(frameState);
  }
 
  // Update clipping polygons
  const clippingPolygons = this._clippingPolygons;
  Iif (defined(clippingPolygons) && clippingPolygons.enabled) {
    clippingPolygons.queueCommands(frameState);
  }
 
  const passStatistics = this._statisticsPerPass[pass];
 
  if (this.show || ignoreCommands) {
    this._pass = pass;
    tilesetPassState.ready = update(
      this,
      frameState,
      passStatistics,
      passOptions,
    );
  }
 
  if (ignoreCommands) {
    commandList.length = commandStart;
  }
 
  frameState.commandList = originalCommandList;
  frameState.camera = originalCamera;
  frameState.cullingVolume = originalCullingVolume;
};
 
/**
 * <code>true</code> if the tileset JSON file lists the extension in extensionsUsed; otherwise, <code>false</code>.
 * @param {string} extensionName The name of the extension to check.
 *
 * @returns {boolean} <code>true</code> if the tileset JSON file lists the extension in extensionsUsed; otherwise, <code>false</code>.
 */
Cesium3DTileset.prototype.hasExtension = function (extensionName) {
  if (!defined(this._extensionsUsed)) {
    return false;
  }
 
  return this._extensionsUsed.indexOf(extensionName) > -1;
};
 
/**
 * Returns true if this object was destroyed; otherwise, false.
 * <br /><br />
 * 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.
 *
 * @returns {boolean} <code>true</code> if this object was destroyed; otherwise, <code>false</code>.
 *
 * @see Cesium3DTileset#destroy
 */
Cesium3DTileset.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.
 * <br /><br />
 * 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.
 *
 * @exception {DeveloperError} This object was destroyed, i.e., destroy() was called.
 *
 * @example
 * tileset = tileset && tileset.destroy();
 *
 * @see Cesium3DTileset#isDestroyed
 */
Cesium3DTileset.prototype.destroy = function () {
  this._tileDebugLabels =
    this._tileDebugLabels && this._tileDebugLabels.destroy();
  this._clippingPlanes = this._clippingPlanes && this._clippingPlanes.destroy();
  this._clippingPolygons =
    this._clippingPolygons && this._clippingPolygons.destroy();
 
  // Traverse the tree and destroy all tiles
  if (defined(this._root)) {
    const stack = scratchStack;
    stack.push(this._root);
 
    while (stack.length > 0) {
      const tile = stack.pop();
      tile.destroy();
 
      const children = tile.children;
      for (let i = 0; i < children.length; ++i) {
        stack.push(children[i]);
      }
    }
  }
  this._root = undefined;
 
  if (
    this._shouldDestroyImageBasedLighting &&
    !this._imageBasedLighting.isDestroyed()
  ) {
    this._imageBasedLighting.destroy();
  }
  this._imageBasedLighting = undefined;
 
  Eif (!this._environmentMapManager.isDestroyed()) {
    this._environmentMapManager.destroy();
  }
  this._environmentMapManager = undefined;
 
  Eif (!this._imageryLayers.isDestroyed()) {
    this.imageryLayers.layerAdded.removeEventListener(
      this._imageryLayersListener,
    );
    this.imageryLayers.layerRemoved.removeEventListener(
      this._imageryLayersListener,
    );
    this.imageryLayers.layerMoved.removeEventListener(
      this._imageryLayersListener,
    );
    this.imageryLayers.layerShownOrHidden.removeEventListener(
      this._imageryLayersListener,
    );
    this._imageryLayers.destroy();
  }
  this._imageryLayers = undefined;
 
  return destroyObject(this);
};
 
Cesium3DTileset.supportedExtensions = {
  "3DTILES_metadata": true,
  "3DTILES_implicit_tiling": true,
  "3DTILES_content_gltf": true,
  "3DTILES_multiple_contents": true,
  "3DTILES_bounding_volume_S2": true,
  "3DTILES_batch_table_hierarchy": true,
  "3DTILES_draco_point_compression": true,
  MAXAR_content_geojson: true,
};
 
/**
 * Checks to see if a given extension is supported by Cesium3DTileset. If
 * the extension is not supported by Cesium3DTileset, it throws a RuntimeError.
 *
 * @param {object} extensionsRequired The extensions we wish to check
 *
 * @private
 */
Cesium3DTileset.checkSupportedExtensions = function (extensionsRequired) {
  for (let i = 0; i < extensionsRequired.length; i++) {
    if (!Cesium3DTileset.supportedExtensions[extensionsRequired[i]]) {
      throw new RuntimeError(
        `Unsupported 3D Tiles Extension: ${extensionsRequired[i]}`,
      );
    }
  }
};
 
const scratchGetHeightRay = new Ray();
const scratchIntersection = new Cartesian3();
const scratchGetHeightCartographic = new Cartographic();
 
/**
 * Get the height of the loaded surface at a given cartographic. This function will only take into account meshes for loaded tiles, not neccisarily the most detailed tiles available for a tileset. This function will always return undefined when sampling a point cloud.
 *
 * @param {Cartographic} cartographic The cartographic for which to find the height.
 * @param {Scene} scene The scene where visualization is taking place.
 * @returns {number|undefined} The height of the cartographic or undefined if it could not be found.
 *
 * @example
 * const tileset = await Cesium.Cesium3DTileset.fromIonAssetId(124624234);
 * scene.primitives.add(tileset);
 *
 * const height = tileset.getHeight(scene.camera.positionCartographic, scene);
 */
Cesium3DTileset.prototype.getHeight = function (cartographic, scene) {
  //>>includeStart('debug', pragmas.debug);
  Check.typeOf.object("cartographic", cartographic);
  Check.typeOf.object("scene", scene);
  //>>includeEnd('debug');
 
  let ellipsoid = scene.ellipsoid;
  Iif (!defined(ellipsoid)) {
    ellipsoid = Ellipsoid.WGS84;
  }
 
  const ray = scratchGetHeightRay;
  const position = ellipsoid.cartographicToCartesian(
    cartographic,
    ray.direction,
  );
  Cartesian3.normalize(ray.direction, ray.direction);
 
  ray.direction = Cartesian3.normalize(position, ray.direction);
  ray.direction = Cartesian3.negate(position, ray.direction);
  ray.origin = Cartesian3.multiplyByScalar(
    ray.direction,
    -2 * ellipsoid.maximumRadius,
    ray.origin,
  );
 
  const intersection = this.pick(ray, scene.frameState, scratchIntersection);
  Iif (!defined(intersection)) {
    return;
  }
 
  return ellipsoid.cartesianToCartographic(
    intersection,
    scratchGetHeightCartographic,
  )?.height;
};
 
/**
 * Calls the callback when a new tile is rendered that contains the given cartographic. The only parameter
 * is the cartographic position on the tile.
 *
 * @private
 *
 * @param {Scene} scene The scene where visualization is taking place.
 * @param {Cartographic} cartographic The cartographic position.
 * @param {Function} callback The function to be called when a new tile is loaded.
 * @param {Ellipsoid} [ellipsoid=Ellipsoid.WGS84] The ellipsoid to use.
 * @returns {Function} The function to remove this callback from the quadtree.
 */
Cesium3DTileset.prototype.updateHeight = function (
  cartographic,
  callback,
  ellipsoid,
) {
  ellipsoid = ellipsoid ?? Ellipsoid.WGS84;
 
  const object = {
    positionCartographic: cartographic,
    ellipsoid: ellipsoid,
    callback: callback,
    invoked: false,
  };
 
  const removeCallback = () => {
    const addedCallbacks = this._addHeightCallbacks;
    const length = addedCallbacks.length;
    for (let i = 0; i < length; ++i) {
      if (addedCallbacks[i] === object) {
        addedCallbacks.splice(i, 1);
        break;
      }
    }
 
    Eif (object.callback) {
      object.callback = undefined;
    }
  };
 
  this._addHeightCallbacks.push(object);
  return removeCallback;
};
 
const scratchSphereIntersection = new Interval();
const scratchPickIntersection = new Cartesian3();
 
/**
 * Find an intersection between a ray and the tileset surface that was rendered. The ray must be given in world coordinates.
 *
 * @param {Ray} ray The ray to test for intersection.
 * @param {FrameState} frameState The frame state.
 * @param {Cartesian3|undefined} [result] The intersection or <code>undefined</code> if none was found.
 * @returns {Cartesian3|undefined} The intersection or <code>undefined</code> if none was found.
 *
 * @private
 */
Cesium3DTileset.prototype.pick = function (ray, frameState, result) {
  Iif (!frameState.context.webgl2 && !this._enablePick) {
    return;
  }
 
  const selectedTiles = this._selectedTiles;
  const selectedLength = selectedTiles.length;
  const candidates = [];
 
  for (let i = 0; i < selectedLength; ++i) {
    const tile = selectedTiles[i];
    const boundsIntersection = IntersectionTests.raySphere(
      ray,
      tile.contentBoundingVolume.boundingSphere,
      scratchSphereIntersection,
    );
    Iif (!defined(boundsIntersection) || !defined(tile.content)) {
      continue;
    }
 
    candidates.push(tile);
  }
 
  const length = candidates.length;
  candidates.sort((a, b) => {
    const aDist = BoundingSphere.distanceSquaredTo(
      a.contentBoundingVolume.boundingSphere,
      ray.origin,
    );
    const bDist = BoundingSphere.distanceSquaredTo(
      b.contentBoundingVolume.boundingSphere,
      ray.origin,
    );
 
    return aDist - bDist;
  });
 
  let intersection;
  for (let i = 0; i < length; ++i) {
    const tile = candidates[i];
    const candidate = tile.content.pick(
      ray,
      frameState,
      scratchPickIntersection,
    );
 
    Eif (defined(candidate)) {
      intersection = Cartesian3.clone(candidate, result);
      return intersection;
    }
  }
};
 
/**
 * Returns true if the given glTF extension is used by this tileset.
 * <br/><br/>
 * Relies on the <code>3DTILES_content_gltf</code> extension and will return
 * false if that extension is not used.
 *
 * @param {string} gltfExtensionName The name of the glTF extension to check.
 * @returns {boolean} <code>true</code> if the glTF extension is used by this tileset; otherwise, <code>false</code>.
 *
 * @private
 */
Cesium3DTileset.prototype.isGltfExtensionUsed = function (gltfExtensionName) {
  if (this.hasExtension("3DTILES_content_gltf")) {
    if (!defined(this.extensions)) {
      return false;
    }
    const extensionsUsed =
      this.extensions["3DTILES_content_gltf"]?.extensionsUsed;
 
    Iif (!defined(extensionsUsed)) {
      return false;
    }
 
    return extensionsUsed.indexOf(gltfExtensionName) > -1;
  }
 
  return false;
};
 
/**
 * Returns true if the given glTF extension is used and required by this tileset.
 * <br/><br/>
 * Relies on the <code>3DTILES_content_gltf</code> extension and will return
 * <code>false</code> if that extension is not used.
 *
 * @param {string} gltfExtensionName The name of the glTF extension to check.
 * @returns {boolean} <code>true</code> if the glTF extension is required by this tileset; otherwise, <code>false</code>.
 *
 * @private
 */
Cesium3DTileset.prototype.isGltfExtensionRequired = function (
  gltfExtensionName,
) {
  if (this.isGltfExtensionUsed(gltfExtensionName)) {
    const extensionsRequired =
      this.extensions["3DTILES_content_gltf"].extensionsRequired;
 
    Iif (!defined(extensionsRequired)) {
      return false;
    }
 
    return extensionsRequired.indexOf(gltfExtensionName) > -1;
  }
 
  return false;
};
 
/**
 * Optimization option. Used as a callback when {@link Cesium3DTileset#foveatedScreenSpaceError} is true to control how much to raise the screen space error for tiles outside the foveated cone,
 * interpolating between {@link Cesium3DTileset#foveatedMinimumScreenSpaceErrorRelaxation} and {@link Cesium3DTileset#maximumScreenSpaceError}.
 *
 * @callback Cesium3DTileset.foveatedInterpolationCallback
 * @default Math.lerp
 *
 * @param {number} p The start value to interpolate.
 * @param {number} q The end value to interpolate.
 * @param {number} time The time of interpolation generally in the range <code>[0.0, 1.0]</code>.
 * @returns {number} The interpolated value.
 */
export default Cesium3DTileset;