123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640 |
- import ApproximateTerrainHeights from "../Core/ApproximateTerrainHeights.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 Credit from "../Core/Credit.js";
- import defaultValue from "../Core/defaultValue.js";
- import defined from "../Core/defined.js";
- import deprecationWarning from "../Core/deprecationWarning.js";
- import destroyObject from "../Core/destroyObject.js";
- import DeveloperError from "../Core/DeveloperError.js";
- import Ellipsoid from "../Core/Ellipsoid.js";
- import Event from "../Core/Event.js";
- import JulianDate from "../Core/JulianDate.js";
- import ManagedArray from "../Core/ManagedArray.js";
- import CesiumMath from "../Core/Math.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 when from "../ThirdParty/when.js";
- import Axis from "./Axis.js";
- import Cesium3DTile from "./Cesium3DTile.js";
- import Cesium3DTileColorBlendMode from "./Cesium3DTileColorBlendMode.js";
- import Cesium3DTileContentState from "./Cesium3DTileContentState.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 LabelCollection from "./LabelCollection.js";
- import PointCloudEyeDomeLighting from "./PointCloudEyeDomeLighting.js";
- import PointCloudShading from "./PointCloudShading.js";
- import SceneMode from "./SceneMode.js";
- import ShadowMode from "./ShadowMode.js";
- import StencilConstants from "./StencilConstants.js";
- import TileBoundingRegion from "./TileBoundingRegion.js";
- import TileBoundingSphere from "./TileBoundingSphere.js";
- import TileOrientedBoundingBox from "./TileOrientedBoundingBox.js";
- function Cesium3DTileset(options) {
- options = defaultValue(options, defaultValue.EMPTY_OBJECT);
-
- Check.defined("options.url", options.url);
-
- this._url = undefined;
- this._basePath = undefined;
- this._root = undefined;
- this._asset = undefined;
- this._properties = undefined;
- this._geometricError = undefined;
- this._extensionsUsed = undefined;
- this._extensions = undefined;
- this._gltfUpAxis = 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._cullWithChildrenBounds = defaultValue(
- options.cullWithChildrenBounds,
- true
- );
- this._allTilesAdditive = true;
- this._hasMixedContent = false;
- this._stencilClearCommand = undefined;
- this._backfaceCommands = new ManagedArray();
- this._maximumScreenSpaceError = defaultValue(
- options.maximumScreenSpaceError,
- 16
- );
- this._maximumMemoryUsage = defaultValue(options.maximumMemoryUsage, 512);
- this._styleEngine = new Cesium3DTileStyleEngine();
- this._modelMatrix = defined(options.modelMatrix)
- ? Matrix4.clone(options.modelMatrix)
- : Matrix4.clone(Matrix4.IDENTITY);
- this._statistics = new Cesium3DTilesetStatistics();
- this._statisticsLast = new Cesium3DTilesetStatistics();
- this._statisticsPerPass = new Array(Cesium3DTilePass.NUMBER_OF_PASSES);
- for (var 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
- );
-
- this.cullRequestsWhileMoving = defaultValue(
- options.cullRequestsWhileMoving,
- true
- );
- this._cullRequestsWhileMoving = false;
-
- this.cullRequestsWhileMovingMultiplier = defaultValue(
- options.cullRequestsWhileMovingMultiplier,
- 60.0
- );
-
- this.progressiveResolutionHeightFraction = CesiumMath.clamp(
- defaultValue(options.progressiveResolutionHeightFraction, 0.3),
- 0.0,
- 0.5
- );
-
- this.preferLeaves = defaultValue(options.preferLeaves, false);
- this._tilesLoaded = false;
- this._initialTilesLoaded = false;
- this._tileDebugLabels = undefined;
- this._readyPromise = when.defer();
- this._classificationType = options.classificationType;
- this._ellipsoid = defaultValue(options.ellipsoid, Ellipsoid.WGS84);
- this._initialClippingPlanesOriginMatrix = Matrix4.IDENTITY;
- this._clippingPlanesOriginMatrix = undefined;
- this._clippingPlanesOriginMatrixDirty = true;
-
- this.preloadWhenHidden = defaultValue(options.preloadWhenHidden, false);
-
- this.preloadFlightDestinations = defaultValue(
- options.preloadFlightDestinations,
- true
- );
- this._pass = undefined;
-
- this.dynamicScreenSpaceError = defaultValue(
- options.dynamicScreenSpaceError,
- false
- );
-
- this.foveatedScreenSpaceError = defaultValue(
- options.foveatedScreenSpaceError,
- true
- );
- this._foveatedConeSize = defaultValue(options.foveatedConeSize, 0.1);
- this._foveatedMinimumScreenSpaceErrorRelaxation = defaultValue(
- options.foveatedMinimumScreenSpaceErrorRelaxation,
- 0.0
- );
-
- this.foveatedInterpolationCallback = defaultValue(
- options.foveatedInterpolationCallback,
- CesiumMath.lerp
- );
-
- this.foveatedTimeDelay = defaultValue(options.foveatedTimeDelay, 0.2);
-
- this.dynamicScreenSpaceErrorDensity = 0.00278;
-
- this.dynamicScreenSpaceErrorFactor = 4.0;
-
- this.dynamicScreenSpaceErrorHeightFalloff = 0.25;
- this._dynamicScreenSpaceErrorComputedDensity = 0.0;
-
- this.shadows = defaultValue(options.shadows, ShadowMode.ENABLED);
-
- this.show = defaultValue(options.show, true);
-
- this.colorBlendMode = Cesium3DTileColorBlendMode.HIGHLIGHT;
-
- this.colorBlendAmount = 0.5;
-
- this.pointCloudShading = new PointCloudShading(options.pointCloudShading);
- this._pointCloudEyeDomeLighting = new PointCloudEyeDomeLighting();
-
- this.loadProgress = new Event();
-
- this.allTilesLoaded = new Event();
-
- this.initialTilesLoaded = new Event();
-
- this.tileLoad = new Event();
-
- this.tileUnload = new Event();
-
- this.tileFailed = new Event();
-
- this.tileVisible = new Event();
-
- this.skipLevelOfDetail = defaultValue(options.skipLevelOfDetail, false);
- this._skipLevelOfDetail = this.skipLevelOfDetail;
- this._disableSkipLevelOfDetail = false;
-
- this.baseScreenSpaceError = defaultValue(options.baseScreenSpaceError, 1024);
-
- this.skipScreenSpaceErrorFactor = defaultValue(
- options.skipScreenSpaceErrorFactor,
- 16
- );
-
- this.skipLevels = defaultValue(options.skipLevels, 1);
-
- this.immediatelyLoadDesiredLevelOfDetail = defaultValue(
- options.immediatelyLoadDesiredLevelOfDetail,
- false
- );
-
- this.loadSiblings = defaultValue(options.loadSiblings, false);
- this._clippingPlanes = undefined;
- this.clippingPlanes = options.clippingPlanes;
- this._imageBasedLightingFactor = new Cartesian2(1.0, 1.0);
- Cartesian2.clone(
- options.imageBasedLightingFactor,
- this._imageBasedLightingFactor
- );
-
- this.lightColor = options.lightColor;
-
- this.luminanceAtZenith = defaultValue(options.luminanceAtZenith, 0.2);
-
- this.sphericalHarmonicCoefficients = options.sphericalHarmonicCoefficients;
-
- this.specularEnvironmentMaps = options.specularEnvironmentMaps;
-
- this.backFaceCulling = defaultValue(options.backFaceCulling, true);
-
- this.debugFreezeFrame = defaultValue(options.debugFreezeFrame, false);
-
- this.debugColorizeTiles = defaultValue(options.debugColorizeTiles, false);
-
- this.debugWireframe = defaultValue(options.debugWireframe, false);
-
- this.debugShowBoundingVolume = defaultValue(
- options.debugShowBoundingVolume,
- false
- );
-
- this.debugShowContentBoundingVolume = defaultValue(
- options.debugShowContentBoundingVolume,
- false
- );
-
- this.debugShowViewerRequestVolume = defaultValue(
- options.debugShowViewerRequestVolume,
- false
- );
- this._tileDebugLabels = undefined;
- this.debugPickedTileLabelOnly = false;
- this.debugPickedTile = undefined;
- this.debugPickPosition = undefined;
-
- this.debugShowGeometricError = defaultValue(
- options.debugShowGeometricError,
- false
- );
-
- this.debugShowRenderingStatistics = defaultValue(
- options.debugShowRenderingStatistics,
- false
- );
-
- this.debugShowMemoryUsage = defaultValue(options.debugShowMemoryUsage, false);
-
- this.debugShowUrl = defaultValue(options.debugShowUrl, false);
- var that = this;
- var resource;
- when(options.url)
- .then(function (url) {
- var basePath;
- resource = Resource.createIfNeeded(url);
-
- that._credits = resource.credits;
- if (resource.extension === "json") {
- basePath = resource.getBaseUri(true);
- } else if (resource.isDataUri) {
- basePath = "";
- }
- that._url = resource.url;
- that._basePath = basePath;
- return Cesium3DTileset.loadJson(resource);
- })
- .then(function (tilesetJson) {
- that._root = that.loadTileset(resource, tilesetJson);
- var gltfUpAxis = defined(tilesetJson.asset.gltfUpAxis)
- ? Axis.fromName(tilesetJson.asset.gltfUpAxis)
- : Axis.Y;
- var asset = tilesetJson.asset;
- that._asset = asset;
- that._properties = tilesetJson.properties;
- that._geometricError = tilesetJson.geometricError;
- that._extensionsUsed = tilesetJson.extensionsUsed;
- that._extensions = tilesetJson.extensions;
- that._gltfUpAxis = gltfUpAxis;
- that._extras = tilesetJson.extras;
- var extras = asset.extras;
- if (
- defined(extras) &&
- defined(extras.cesium) &&
- defined(extras.cesium.credits)
- ) {
- var extraCredits = extras.cesium.credits;
- var credits = that._credits;
- if (!defined(credits)) {
- credits = [];
- that._credits = credits;
- }
- for (var i = 0; i < extraCredits.length; ++i) {
- var credit = extraCredits[i];
- credits.push(new Credit(credit.html, credit.showOnScreen));
- }
- }
-
-
- var boundingVolume = that._root.createBoundingVolume(
- tilesetJson.root.boundingVolume,
- Matrix4.IDENTITY
- );
- var clippingPlanesOrigin = boundingVolume.boundingSphere.center;
-
-
-
-
- var originCartographic = that._ellipsoid.cartesianToCartographic(
- clippingPlanesOrigin
- );
- if (
- defined(originCartographic) &&
- originCartographic.height >
- ApproximateTerrainHeights._defaultMinTerrainHeight
- ) {
- that._initialClippingPlanesOriginMatrix = Transforms.eastNorthUpToFixedFrame(
- clippingPlanesOrigin
- );
- }
- that._clippingPlanesOriginMatrix = Matrix4.clone(
- that._initialClippingPlanesOriginMatrix
- );
- that._readyPromise.resolve(that);
- })
- .otherwise(function (error) {
- that._readyPromise.reject(error);
- });
- }
- Object.defineProperties(Cesium3DTileset.prototype, {
-
- isCesium3DTileset: {
- get: function () {
- return true;
- },
- },
-
- asset: {
- get: function () {
-
- if (!this.ready) {
- throw new DeveloperError(
- "The tileset is not loaded. Use Cesium3DTileset.readyPromise or wait for Cesium3DTileset.ready to be true."
- );
- }
-
- return this._asset;
- },
- },
-
- extensions: {
- get: function () {
-
- if (!this.ready) {
- throw new DeveloperError(
- "The tileset is not loaded. Use Cesium3DTileset.readyPromise or wait for Cesium3DTileset.ready to be true."
- );
- }
-
- return this._extensions;
- },
- },
-
- clippingPlanes: {
- get: function () {
- return this._clippingPlanes;
- },
- set: function (value) {
- ClippingPlaneCollection.setOwner(value, this, "_clippingPlanes");
- },
- },
-
- properties: {
- get: function () {
-
- if (!this.ready) {
- throw new DeveloperError(
- "The tileset is not loaded. Use Cesium3DTileset.readyPromise or wait for Cesium3DTileset.ready to be true."
- );
- }
-
- return this._properties;
- },
- },
-
- ready: {
- get: function () {
- return defined(this._root);
- },
- },
-
- readyPromise: {
- get: function () {
- return this._readyPromise.promise;
- },
- },
-
- tilesLoaded: {
- get: function () {
- return this._tilesLoaded;
- },
- },
-
- url: {
- get: function () {
- return this._url;
- },
- },
-
- 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;
- },
- },
-
- style: {
- get: function () {
- return this._styleEngine.style;
- },
- set: function (value) {
- this._styleEngine.style = value;
- },
- },
-
- maximumScreenSpaceError: {
- get: function () {
- return this._maximumScreenSpaceError;
- },
- set: function (value) {
-
- Check.typeOf.number.greaterThanOrEquals(
- "maximumScreenSpaceError",
- value,
- 0
- );
-
- this._maximumScreenSpaceError = value;
- },
- },
-
- maximumMemoryUsage: {
- get: function () {
- return this._maximumMemoryUsage;
- },
- set: function (value) {
-
- Check.typeOf.number.greaterThanOrEquals("value", value, 0);
-
- this._maximumMemoryUsage = value;
- },
- },
-
- root: {
- get: function () {
-
- if (!this.ready) {
- throw new DeveloperError(
- "The tileset is not loaded. Use Cesium3DTileset.readyPromise or wait for Cesium3DTileset.ready to be true."
- );
- }
-
- return this._root;
- },
- },
-
- boundingSphere: {
- get: function () {
-
- if (!this.ready) {
- throw new DeveloperError(
- "The tileset is not loaded. Use Cesium3DTileset.readyPromise or wait for Cesium3DTileset.ready to be true."
- );
- }
-
- this._root.updateTransform(this._modelMatrix);
- return this._root.boundingSphere;
- },
- },
-
- modelMatrix: {
- get: function () {
- return this._modelMatrix;
- },
- set: function (value) {
- this._modelMatrix = Matrix4.clone(value, this._modelMatrix);
- },
- },
-
- timeSinceLoad: {
- get: function () {
- return this._timeSinceLoad;
- },
- },
-
- totalMemoryUsageInBytes: {
- get: function () {
- var statistics = this._statistics;
- return (
- statistics.texturesByteLength +
- statistics.geometryByteLength +
- statistics.batchTableByteLength
- );
- },
- },
-
- clippingPlanesOriginMatrix: {
- get: function () {
- if (!defined(this._clippingPlanesOriginMatrix)) {
- return Matrix4.IDENTITY;
- }
- if (this._clippingPlanesOriginMatrixDirty) {
- Matrix4.multiply(
- this.root.computedTransform,
- this._initialClippingPlanesOriginMatrix,
- this._clippingPlanesOriginMatrix
- );
- this._clippingPlanesOriginMatrixDirty = false;
- }
- return this._clippingPlanesOriginMatrix;
- },
- },
-
- styleEngine: {
- get: function () {
- return this._styleEngine;
- },
- },
-
- statistics: {
- get: function () {
- return this._statistics;
- },
- },
-
- classificationType: {
- get: function () {
- return this._classificationType;
- },
- },
-
- ellipsoid: {
- get: function () {
- return this._ellipsoid;
- },
- },
-
- foveatedConeSize: {
- get: function () {
- return this._foveatedConeSize;
- },
- set: function (value) {
-
- Check.typeOf.number.greaterThanOrEquals("foveatedConeSize", value, 0.0);
- Check.typeOf.number.lessThanOrEquals("foveatedConeSize", value, 1.0);
-
- this._foveatedConeSize = value;
- },
- },
-
- foveatedMinimumScreenSpaceErrorRelaxation: {
- get: function () {
- return this._foveatedMinimumScreenSpaceErrorRelaxation;
- },
- set: function (value) {
-
- Check.typeOf.number.greaterThanOrEquals(
- "foveatedMinimumScreenSpaceErrorRelaxation",
- value,
- 0.0
- );
- Check.typeOf.number.lessThanOrEquals(
- "foveatedMinimumScreenSpaceErrorRelaxation",
- value,
- this.maximumScreenSpaceError
- );
-
- this._foveatedMinimumScreenSpaceErrorRelaxation = value;
- },
- },
-
- extras: {
- get: function () {
-
- if (!this.ready) {
- throw new DeveloperError(
- "The tileset is not loaded. Use Cesium3DTileset.readyPromise or wait for Cesium3DTileset.ready to be true."
- );
- }
-
- return this._extras;
- },
- },
-
- imageBasedLightingFactor: {
- get: function () {
- return this._imageBasedLightingFactor;
- },
- set: function (value) {
-
- Check.typeOf.object("imageBasedLightingFactor", value);
- Check.typeOf.number.greaterThanOrEquals(
- "imageBasedLightingFactor.x",
- value.x,
- 0.0
- );
- Check.typeOf.number.lessThanOrEquals(
- "imageBasedLightingFactor.x",
- value.x,
- 1.0
- );
- Check.typeOf.number.greaterThanOrEquals(
- "imageBasedLightingFactor.y",
- value.y,
- 0.0
- );
- Check.typeOf.number.lessThanOrEquals(
- "imageBasedLightingFactor.y",
- value.y,
- 1.0
- );
-
- Cartesian2.clone(value, this._imageBasedLightingFactor);
- },
- },
- });
- Cesium3DTileset.loadJson = function (tilesetUrl) {
- var resource = Resource.createIfNeeded(tilesetUrl);
- return resource.fetchJson();
- };
- Cesium3DTileset.prototype.makeStyleDirty = function () {
- this._styleEngine.makeDirty();
- };
- Cesium3DTileset.prototype.loadTileset = function (
- resource,
- tilesetJson,
- parentTile
- ) {
- var asset = tilesetJson.asset;
- if (!defined(asset)) {
- throw new RuntimeError("Tileset must have an asset property.");
- }
- if (asset.version !== "0.0" && asset.version !== "1.0") {
- throw new RuntimeError("The tileset must be 3D Tiles version 0.0 or 1.0.");
- }
- var statistics = this._statistics;
- var tilesetVersion = asset.tilesetVersion;
- if (defined(tilesetVersion)) {
-
- this._basePath += "?v=" + tilesetVersion;
- resource.setQueryParameters({ v: tilesetVersion });
- }
-
-
- var rootTile = new Cesium3DTile(this, resource, tilesetJson.root, parentTile);
-
-
- if (defined(parentTile)) {
- parentTile.children.push(rootTile);
- rootTile._depth = parentTile._depth + 1;
- }
- var stack = [];
- stack.push(rootTile);
- while (stack.length > 0) {
- var tile = stack.pop();
- ++statistics.numberOfTilesTotal;
- this._allTilesAdditive =
- this._allTilesAdditive && tile.refine === Cesium3DTileRefine.ADD;
- var children = tile._header.children;
- if (defined(children)) {
- var length = children.length;
- for (var i = 0; i < length; ++i) {
- var childHeader = children[i];
- var childTile = new Cesium3DTile(this, resource, childHeader, tile);
- tile.children.push(childTile);
- childTile._depth = tile._depth + 1;
- stack.push(childTile);
- }
- }
- if (this._cullWithChildrenBounds) {
- Cesium3DTileOptimizations.checkChildrenWithinParent(tile);
- }
- }
- return rootTile;
- };
- var scratchPositionNormal = new Cartesian3();
- var scratchCartographic = new Cartographic();
- var scratchMatrix = new Matrix4();
- var scratchCenter = new Cartesian3();
- var scratchPosition = new Cartesian3();
- var scratchDirection = new Cartesian3();
- function updateDynamicScreenSpaceError(tileset, frameState) {
- var up;
- var direction;
- var height;
- var minimumHeight;
- var maximumHeight;
- var camera = frameState.camera;
- var root = tileset._root;
- var 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 {
-
- var transformLocal = Matrix4.inverseTransformation(
- root.computedTransform,
- scratchMatrix
- );
- var ellipsoid = frameState.mapProjection.ellipsoid;
- var boundingVolume = tileBoundingVolume.boundingVolume;
- var centerLocal = Matrix4.multiplyByPoint(
- transformLocal,
- boundingVolume.center,
- scratchCenter
- );
- if (Cartesian3.magnitude(centerLocal) > ellipsoid.minimumRadius) {
-
- var 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 {
-
- var 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) {
-
- var boxHeight = root._header.boundingVolume.box[11];
- minimumHeight = centerLocal.z - boxHeight;
- maximumHeight = centerLocal.z + boxHeight;
- } else if (tileBoundingVolume instanceof TileBoundingSphere) {
- var radius = boundingVolume.radius;
- minimumHeight = centerLocal.z - radius;
- maximumHeight = centerLocal.z + radius;
- }
- }
- }
-
- var heightFalloff = tileset.dynamicScreenSpaceErrorHeightFalloff;
- var heightClose =
- minimumHeight + (maximumHeight - minimumHeight) * heightFalloff;
- var heightFar = maximumHeight;
- var t = CesiumMath.clamp(
- (height - heightClose) / (heightFar - heightClose),
- 0.0,
- 1.0
- );
-
- var dot = Math.abs(Cartesian3.dot(direction, up));
- var horizonFactor = 1.0 - dot;
-
-
- horizonFactor = horizonFactor * (1.0 - t);
- var density = tileset.dynamicScreenSpaceErrorDensity;
- density *= horizonFactor;
- tileset._dynamicScreenSpaceErrorComputedDensity = density;
- }
- function requestContent(tileset, tile) {
- if (tile.hasEmptyContent) {
- return;
- }
- var statistics = tileset._statistics;
- var expired = tile.contentExpired;
- var requested = tile.requestContent();
- if (!requested) {
- ++statistics.numberOfAttemptedRequests;
- return;
- }
- if (expired) {
- if (tile.hasTilesetContent) {
- destroySubtree(tileset, tile);
- } else {
- statistics.decrementLoadCounts(tile.content);
- --statistics.numberOfTilesWithContentReady;
- }
- }
- ++statistics.numberOfPendingRequests;
- tileset._requestedTilesInFlight.push(tile);
- tile.contentReadyToProcessPromise.then(addToProcessingQueue(tileset, tile));
- tile.contentReadyPromise
- .then(handleTileSuccess(tileset, tile))
- .otherwise(handleTileFailure(tileset, tile));
- }
- function sortRequestByPriority(a, b) {
- return a._priority - b._priority;
- }
- Cesium3DTileset.prototype.postPassesUpdate = function (frameState) {
- if (!this.ready) {
- return;
- }
- cancelOutOfViewRequests(this, frameState);
- raiseLoadProgressEvent(this, frameState);
- this._cache.unloadTiles(this, unloadTile);
- };
- Cesium3DTileset.prototype.prePassesUpdate = function (frameState) {
- if (!this.ready) {
- return;
- }
- processTiles(this, frameState);
-
- var clippingPlanes = this._clippingPlanes;
- this._clippingPlanesOriginMatrixDirty = true;
- if (defined(clippingPlanes) && clippingPlanes.enabled) {
- clippingPlanes.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
- );
- this._skipLevelOfDetail =
- this.skipLevelOfDetail &&
- !defined(this._classificationType) &&
- !this._disableSkipLevelOfDetail &&
- !this._allTilesAdditive;
- if (this.dynamicScreenSpaceError) {
- updateDynamicScreenSpaceError(this, frameState);
- }
- if (frameState.newFrame) {
- this._cache.reset();
- }
- };
- function cancelOutOfViewRequests(tileset, frameState) {
- var requestedTilesInFlight = tileset._requestedTilesInFlight;
- var removeCount = 0;
- var length = requestedTilesInFlight.length;
- for (var i = 0; i < length; ++i) {
- var tile = requestedTilesInFlight[i];
-
- var outOfView = frameState.frameNumber - tile._touchedFrame >= 1;
- if (tile._contentState !== Cesium3DTileContentState.LOADING) {
-
- ++removeCount;
- continue;
- } else if (outOfView) {
-
- tile._request.cancel();
- ++removeCount;
- continue;
- }
- if (removeCount > 0) {
- requestedTilesInFlight[i - removeCount] = tile;
- }
- }
- requestedTilesInFlight.length -= removeCount;
- }
- function requestTiles(tileset, isAsync) {
-
-
- var requestedTiles = tileset._requestedTiles;
- var length = requestedTiles.length;
- requestedTiles.sort(sortRequestByPriority);
- for (var i = 0; i < length; ++i) {
- requestContent(tileset, requestedTiles[i]);
- }
- }
- function addToProcessingQueue(tileset, tile) {
- return function () {
- tileset._processingQueue.push(tile);
- --tileset._statistics.numberOfPendingRequests;
- ++tileset._statistics.numberOfTilesProcessing;
- };
- }
- function handleTileFailure(tileset, tile) {
- return function (error) {
- var url = tile._contentResource.url;
- var 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);
- }
- };
- }
- function handleTileSuccess(tileset, tile) {
- return function () {
- --tileset._statistics.numberOfTilesProcessing;
- if (!tile.hasTilesetContent) {
-
-
- tileset._statistics.incrementLoadCounts(tile.content);
- ++tileset._statistics.numberOfTilesWithContentReady;
- ++tileset._statistics.numberOfLoadedTilesTotal;
-
- tileset._cache.add(tile);
- }
- tileset.tileLoad.raiseEvent(tile);
- };
- }
- function filterProcessingQueue(tileset) {
- var tiles = tileset._processingQueue;
- var length = tiles.length;
- var removeCount = 0;
- for (var i = 0; i < length; ++i) {
- var tile = tiles[i];
- if (tile._contentState !== Cesium3DTileContentState.PROCESSING) {
- ++removeCount;
- continue;
- }
- if (removeCount > 0) {
- tiles[i - removeCount] = tile;
- }
- }
- tiles.length -= removeCount;
- }
- function processTiles(tileset, frameState) {
- filterProcessingQueue(tileset);
- var tiles = tileset._processingQueue;
- var length = tiles.length;
-
- for (var i = 0; i < length; ++i) {
- tiles[i].process(tileset, frameState);
- }
- }
- var scratchCartesian = new Cartesian3();
- var stringOptions = {
- maximumFractionDigits: 3,
- };
- function formatMemoryString(memorySizeInBytes) {
- var memoryInMegabytes = memorySizeInBytes / 1048576;
- if (memoryInMegabytes < 1.0) {
- return memoryInMegabytes.toLocaleString(undefined, stringOptions);
- }
- return Math.round(memoryInMegabytes).toLocaleString();
- }
- function computeTileLabelPosition(tile) {
- var boundingVolume = tile.boundingVolume.boundingVolume;
- var halfAxes = boundingVolume.halfAxes;
- var radius = boundingVolume.radius;
- var position = Cartesian3.clone(boundingVolume.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 if (defined(radius)) {
- var normal = Cartesian3.normalize(boundingVolume.center, scratchCartesian);
- normal = Cartesian3.multiplyByScalar(
- normal,
- 0.75 * radius,
- scratchCartesian
- );
- position = Cartesian3.add(normal, boundingVolume.center, scratchCartesian);
- }
- return position;
- }
- function addTileDebugLabel(tile, tileset, position) {
- var labelString = "";
- var attributes = 0;
- if (tileset.debugShowGeometricError) {
- labelString += "\nGeometric error: " + tile.geometricError;
- attributes++;
- }
- if (tileset.debugShowRenderingStatistics) {
- labelString += "\nCommands: " + tile.commandsLength;
- attributes++;
-
- var numberOfPoints = tile.content.pointsLength;
- if (numberOfPoints > 0) {
- labelString += "\nPoints: " + tile.content.pointsLength;
- attributes++;
- }
- var numberOfTriangles = tile.content.trianglesLength;
- if (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) {
- labelString += "\nUrl: " + tile._header.content.uri;
- attributes++;
- }
- var newLabel = {
- text: labelString.substring(1),
- position: position,
- font: 19 - attributes + "px sans-serif",
- showBackground: true,
- disableDepthTestDistance: Number.POSITIVE_INFINITY,
- };
- return tileset._tileDebugLabels.add(newLabel);
- }
- function updateTileDebugLabels(tileset, frameState) {
- var i;
- var tile;
- var selectedTiles = tileset._selectedTiles;
- var selectedLength = selectedTiles.length;
- var emptyTiles = tileset._emptyTiles;
- var emptyLength = emptyTiles.length;
- tileset._tileDebugLabels.removeAll();
- if (tileset.debugPickedTileLabelOnly) {
- if (defined(tileset.debugPickedTile)) {
- var position = defined(tileset.debugPickPosition)
- ? tileset.debugPickPosition
- : computeTileLabelPosition(tileset.debugPickedTile);
- var label = addTileDebugLabel(tileset.debugPickedTile, tileset, position);
- label.pixelOffset = new Cartesian2(15, -15);
- }
- } else {
- for (i = 0; i < selectedLength; ++i) {
- tile = selectedTiles[i];
- addTileDebugLabel(tile, tileset, computeTileLabelPosition(tile));
- }
- for (i = 0; i < emptyLength; ++i) {
- tile = emptyTiles[i];
- if (tile.hasTilesetContent) {
- addTileDebugLabel(tile, tileset, computeTileLabelPosition(tile));
- }
- }
- }
- tileset._tileDebugLabels.update(frameState);
- }
- function updateTiles(tileset, frameState, passOptions) {
- tileset._styleEngine.applyStyle(tileset, passOptions);
- var isRender = passOptions.isRender;
- var statistics = tileset._statistics;
- var commandList = frameState.commandList;
- var numberOfInitialCommands = commandList.length;
- var selectedTiles = tileset._selectedTiles;
- var selectedLength = selectedTiles.length;
- var emptyTiles = tileset._emptyTiles;
- var emptyLength = emptyTiles.length;
- var tileVisible = tileset.tileVisible;
- var i;
- var tile;
- var bivariateVisibilityTest =
- tileset._skipLevelOfDetail &&
- tileset._hasMixedContent &&
- frameState.context.stencilBuffer &&
- selectedLength > 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);
- }
- var lengthBeforeUpdate = commandList.length;
- for (i = 0; i < selectedLength; ++i) {
- tile = selectedTiles[i];
-
-
- if (isRender) {
- tileVisible.raiseEvent(tile);
- }
- tile.update(tileset, frameState, passOptions);
- statistics.incrementSelectionCounts(tile.content);
- ++statistics.selected;
- }
- for (i = 0; i < emptyLength; ++i) {
- tile = emptyTiles[i];
- tile.update(tileset, frameState, passOptions);
- }
- var addedCommandsLength = commandList.length - lengthBeforeUpdate;
- tileset._backfaceCommands.trim();
- if (bivariateVisibilityTest) {
-
- var backfaceCommands = tileset._backfaceCommands.values;
- var backfaceCommandsLength = backfaceCommands.length;
- commandList.length += backfaceCommandsLength;
-
- for (i = addedCommandsLength - 1; i >= 0; --i) {
- commandList[lengthBeforeUpdate + backfaceCommandsLength + i] =
- commandList[lengthBeforeUpdate + i];
- }
-
- for (i = 0; i < backfaceCommandsLength; ++i) {
- commandList[lengthBeforeUpdate + i] = backfaceCommands[i];
- }
- }
-
- addedCommandsLength = commandList.length - numberOfInitialCommands;
- statistics.numberOfCommands = addedCommandsLength;
-
- if (
- isRender &&
- tileset.pointCloudShading.attenuation &&
- tileset.pointCloudShading.eyeDomeLighting &&
- addedCommandsLength > 0
- ) {
- tileset._pointCloudEyeDomeLighting.update(
- frameState,
- numberOfInitialCommands,
- tileset.pointCloudShading,
- tileset.boundingSphere
- );
- }
- if (isRender) {
- 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();
- }
- }
- }
- var scratchStack = [];
- function destroySubtree(tileset, tile) {
- var root = tile;
- var stack = scratchStack;
- stack.push(tile);
- while (stack.length > 0) {
- tile = stack.pop();
- var children = tile.children;
- var length = children.length;
- for (var i = 0; i < length; ++i) {
- stack.push(children[i]);
- }
- if (tile !== root) {
- destroyTile(tileset, tile);
- --tileset._statistics.numberOfTilesTotal;
- }
- }
- root.children = [];
- }
- function unloadTile(tileset, tile) {
- tileset.tileUnload.raiseEvent(tile);
- tileset._statistics.decrementLoadCounts(tile.content);
- --tileset._statistics.numberOfTilesWithContentReady;
- tile.unloadContent();
- }
- function destroyTile(tileset, tile) {
- tileset._cache.unloadTile(tileset, tile, unloadTile);
- tile.destroy();
- }
- Cesium3DTileset.prototype.trimLoadedTiles = function () {
- this._cache.trim();
- };
- function raiseLoadProgressEvent(tileset, frameState) {
- var statistics = tileset._statistics;
- var statisticsLast = tileset._statisticsLast;
- var numberOfPendingRequests = statistics.numberOfPendingRequests;
- var numberOfTilesProcessing = statistics.numberOfTilesProcessing;
- var lastNumberOfPendingRequest = statisticsLast.numberOfPendingRequests;
- var lastNumberOfTilesProcessing = statisticsLast.numberOfTilesProcessing;
- Cesium3DTilesetStatistics.clone(statistics, statisticsLast);
- var progressChanged =
- numberOfPendingRequests !== lastNumberOfPendingRequest ||
- numberOfTilesProcessing !== lastNumberOfTilesProcessing;
- if (progressChanged) {
- frameState.afterRender.push(function () {
- tileset.loadProgress.raiseEvent(
- numberOfPendingRequests,
- numberOfTilesProcessing
- );
- });
- }
- tileset._tilesLoaded =
- statistics.numberOfPendingRequests === 0 &&
- statistics.numberOfTilesProcessing === 0 &&
- statistics.numberOfAttemptedRequests === 0;
-
-
-
- if (progressChanged && tileset._tilesLoaded) {
- frameState.afterRender.push(function () {
- tileset.allTilesLoaded.raiseEvent();
- });
- if (!tileset._initialTilesLoaded) {
- tileset._initialTilesLoaded = true;
- frameState.afterRender.push(function () {
- tileset.initialTilesLoaded.raiseEvent();
- });
- }
- }
- }
- 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;
- }
- function detectModelMatrixChanged(tileset, frameState) {
- if (
- frameState.frameNumber !== tileset._updatedModelMatrixFrame ||
- !defined(tileset._previousModelMatrix)
- ) {
- tileset._updatedModelMatrixFrame = frameState.frameNumber;
- tileset._modelMatrixChanged = !Matrix4.equals(
- tileset.modelMatrix,
- tileset._previousModelMatrix
- );
- tileset._previousModelMatrix = Matrix4.clone(
- tileset.modelMatrix,
- tileset._previousModelMatrix
- );
- }
- }
- function update(tileset, frameState, passStatistics, passOptions) {
- if (frameState.mode === SceneMode.MORPHING) {
- return false;
- }
- if (!tileset.ready) {
- return false;
- }
- var statistics = tileset._statistics;
- statistics.clear();
- var isRender = passOptions.isRender;
-
- ++tileset._updatedVisibilityFrame;
-
- resetMinimumMaximum(tileset);
- detectModelMatrixChanged(tileset, frameState);
- tileset._cullRequestsWhileMoving =
- tileset.cullRequestsWhileMoving && !tileset._modelMatrixChanged;
- var ready = passOptions.traversal.selectTiles(tileset, frameState);
- if (passOptions.requestTiles) {
- requestTiles(tileset);
- }
- updateTiles(tileset, frameState, passOptions);
-
- Cesium3DTilesetStatistics.clone(statistics, passStatistics);
- if (isRender) {
- var credits = tileset._credits;
- if (defined(credits) && statistics.selected !== 0) {
- var length = credits.length;
- for (var i = 0; i < length; ++i) {
- frameState.creditDisplay.addCredit(credits[i]);
- }
- }
- }
- return ready;
- }
- Cesium3DTileset.prototype.update = function (frameState) {
- this.updateForPass(frameState, frameState.tilesetPassState);
- };
- Cesium3DTileset.prototype.updateForPass = function (
- frameState,
- tilesetPassState
- ) {
-
- Check.typeOf.object("frameState", frameState);
- Check.typeOf.object("tilesetPassState", tilesetPassState);
-
- var 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;
- }
- var originalCommandList = frameState.commandList;
- var originalCamera = frameState.camera;
- var originalCullingVolume = frameState.cullingVolume;
- tilesetPassState.ready = false;
- var passOptions = Cesium3DTilePass.getPassOptions(pass);
- var ignoreCommands = passOptions.ignoreCommands;
- var commandList = defaultValue(
- tilesetPassState.commandList,
- originalCommandList
- );
- var commandStart = commandList.length;
- frameState.commandList = commandList;
- frameState.camera = defaultValue(tilesetPassState.camera, originalCamera);
- frameState.cullingVolume = defaultValue(
- tilesetPassState.cullingVolume,
- originalCullingVolume
- );
- var 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;
- };
- Cesium3DTileset.prototype.hasExtension = function (extensionName) {
- if (!defined(this._extensionsUsed)) {
- return false;
- }
- return this._extensionsUsed.indexOf(extensionName) > -1;
- };
- Cesium3DTileset.prototype.isDestroyed = function () {
- return false;
- };
- Cesium3DTileset.prototype.destroy = function () {
- this._tileDebugLabels =
- this._tileDebugLabels && this._tileDebugLabels.destroy();
- this._clippingPlanes = this._clippingPlanes && this._clippingPlanes.destroy();
-
- if (defined(this._root)) {
- var stack = scratchStack;
- stack.push(this._root);
- while (stack.length > 0) {
- var tile = stack.pop();
- tile.destroy();
- var children = tile.children;
- var length = children.length;
- for (var i = 0; i < length; ++i) {
- stack.push(children[i]);
- }
- }
- }
- this._root = undefined;
- return destroyObject(this);
- };
- export default Cesium3DTileset;
|