/** * class representing a tiled and multileveled mesh or point-cloud according to the OGC3DTiles 1.1 spec * @class * @extends {THREE.Object3D} */ export class OGC3DTile extends THREE.Object3D { /** * @param {Object} [properties] - the properties for this tileset * @param {String} [properties.url] - the url to the parent tileset.json * @param {Object} [properties.queryParams = undefined] - optional, path params to add to individual tile urls * @param {Number} [properties.geometricErrorMultiplier = 1] - the geometric error of the parent. 1.0 by default corresponds to a maxScreenSpaceError of 16 * @param {Boolean} [properties.loadOutsideView = false] - if truthy, tiles otside the camera frustum will be loaded with the least possible amount of detail * @param {TileLoader} [properties.tileLoader = undefined] - A tile loader that can be shared among tilesets in order to share a common cache. * @param {Function} [properties.meshCallback = undefined] - A callback function that will be called on every mesh (if TileLoader is provided, this function will be overridden by the tileLoader's own callback) * @param {Function} [properties.pointsCallback = undefined] - A callback function that will be called on every points (if TileLoader is provided, this function will be overridden by the tileLoader's own callback) * @param {Function} [properties.onLoadCallback = undefined] - A callback function that will be called when the root tile has been loaded * @param {OcclusionCullingService} [properties.occlusionCullingService = undefined] - A service that handles occlusion culling * @param {Boolean} [properties.centerModel = false] - If true, the tileset will be centered on 0,0,0 and in the case of georeferenced tilesets that use the "region" bounding volume, it will also be rotated so that the up axis matched the world y axis. * @param {Boolean} [properties.static = false] - If true, the tileset is considered static which improves performance but the matrices aren't automatically updated * @param {String} [properties.rootPath = undefined] - optional the root path for fetching children * @param {String} [properties.json = undefined] - optional json object representing the tileset sub-tree * @param {Number} [properties.parentGeometricError = undefined] - optional geometric error of the parent * @param {Object} [properties.parentBoundingVolume = undefined] - optional bounding volume of the parent * @param {String} [properties.parentRefine = undefined] - optional refine strategy of the parent of the parent * @param {THREE.Camera} [properties.cameraOnLoad = undefined] - optional the camera used when loading this particular sub-tile * @param {THREE.Box3|THREE.Sphere|OBB} [properties.clipShape = undefined] - optional, specify a clip shape object in world space and tiles outside of the shape will not be loaded. The shape is either a THREE.Box3, THREE.Sphere or OBB (import {OBB} from "threedtiles") * @param {OGC3DTile} [properties.parentTile = undefined] - optional the OGC3DTile object that loaded this tile as a child * @param {String} [properties.proxy = undefined] - optional the url to a proxy service. Instead of fetching tiles via a GET request, a POST will be sent to the proxy url with the real tile address in the body of the request. * @param {Boolean} [properties.displayErrors = false] - optional value indicating that errors should be shown on screen. * @param {THREE.Renderer} [properties.renderer = undefined] - optional the renderer used to display the tileset. Used to infer render resolution at runtime and to instantiate a ktx2loader on the fly if not provided. * @param {Number} [properties.domWidth = undefined] - optional the canvas width (used to calculate geometric error). If a renderer is provided, it'll be used instead, else a default value is used. * @param {Number} [properties.domHeight = undefined] - optional the canvas height (used to calculate geometric error). If a renderer is provided, it'll be used instead, else a default value is used. * @param {DracoLoader} [properties.dracoLoader = undefined] - optional a draco loader (three/addons). * @param {KTX2Loader} [properties.ktx2Loader = undefined] - optional a ktx2 loader (three/addons). * @param {Number} [properties.distanceBias = 1] - optional a bias that allows loading more or less detail closer to the camera relative to far away. The value should be a positive number. A value below 1 loads less detail near the camera and a value above 1 loads more detail near the camera. This needs to be compensated by the geometricErrorMultiplier in order to load a reasonable number of tiles. * @param {String} [properties.loadingStrategy = "INCREMENTAL"] - optional a strategy for loading tiles * - "INCREMENTAL" loads intermediate LODs and will load nearer tiles first * - "PERLEVEL" loads intermediate LODs and loads nearer tiles first but waits for all tiles of the lowest level to be loaded before loading higher detail tiles * - "IMMEDIATE" skips intermediate LODs. tiles are missing until loaded when moving to a new area * @param {String} [properties.drawBoundingVolume = false] - optional draws the bounding volume (may cause flickering) * @param {String} [properties.splatsFragmentShader = undefined] - optional pass a custom fragment shader for rendering splats * @param {number} [properties.splatsQuality = 0.75] - optional pass a visual quality for splats between 0 and 1. Lower quality improves performance at the cost of visual approximations. * @param {boolean} [properties.splatsCPUCulling = false] - optional if true, splats are culled on CPU asynchronously. Better frame-rate and faster sorting but splats are absent when camera moves quickly until sort finishes. * * @param {number} [properties.splatsExposureEV = 0.0] - optional exposure compensation in EV (stops). Typical useful range: -6 → +6. Positive brightens, negative darkens. * @param {number} [properties.splatsSaturation = 1.0] - optional saturation multiplier. Typical useful range: 0.0 → 2.0 (1.0 = unchanged). * @param {number} [properties.splatsContrast = 1.0] - optional contrast multiplier. Typical useful range: 0.0 → 2.0 (1.0 = unchanged). * @param {Array|Object} [properties.splatsTempTint = [0.0, 0.0]] - optional temperature and tint pair for simple white-balance adjustment. Values: temperature ∈ [-100,100], tint ∈ [-100,100]. Default [0,0]. * @param {Object} [properties.physics.sim = undefined] - physics sim helper {@link physics.js} * @param {String} [properties.physics.type = fixed] - type: 'dynamic' | 'kinematic' | 'fixed' (default 'fixed') * @param {String} [properties.physics.shape = none] - LEGACY single collider shape: 'none' | 'mesh' | 'bounds' | 'hull'. Used only when no advanced collider rules are provided. * @param {number} [properties.physics.mass = 1] - mass * @param {number} [properties.physics.maxLOD = infinity] - LEGACY global max LOD for constructing colliders. Higher is more accurate and more costly. Only the currently loaded LODs are used. * @param {Array|Vector3} [properties.physics.velocity = [0,0,0]] - velocity vector * @param {Array|Vector3} [properties.physics.angularVelocity = [0,0,0]] - angular velocity * * @param {Object} [properties.physics.colliders] - ADVANCED rules to mix different collider types by geometricError or by level (LOD). * @param {number} [properties.physics.colliders.maxLOD] - Global LOD cap for colliders. If omitted, falls back to properties.physics.maxLOD, else Infinity. * @param {string[]} [properties.physics.colliders.priority=["mesh","hull","bounds"]] - Priority when multiple rules match the same tile. First entry wins. * @param {Object[]} [properties.physics.colliders.byGeometricError] - Preferred criterion when provided. Inclusive ranges on geometricError. * @param {("mesh"|"hull"|"bounds")} properties.physics.colliders.byGeometricError[].shape - Collider type to use in this range. * @param {number} properties.physics.colliders.byGeometricError[].min - Inclusive minimum geometricError for the rule (defaults to -Infinity if omitted). * @param {number} properties.physics.colliders.byGeometricError[].max - Exclusive maximum geometricError for the rule (defaults to +Infinity if omitted). * @param {Object[]} [properties.physics.colliders.byLevel] - Fallback criterion when byGeometricError is absent/empty. Inclusive ranges on integer level (LOD). * @param {("mesh"|"hull"|"bounds")} properties.physics.colliders.byLevel[].shape - Collider type to use in this LOD interval. * @param {number} properties.physics.colliders.byLevel[].min - Inclusive minimum LOD (integer). * @param {number} properties.physics.colliders.byLevel[].max - Inclusive maximum LOD (integer). * @param {("mesh"|"hull"|"bounds")} [properties.physics.colliders.defaultShape] - Optional fallback shape when no rule matches. If omitted, legacy properties.physics.shape is used. If neither present, no collider is created. * * Selection rules: * - If colliders.byGeometricError has entries, it is used exclusively. Otherwise, byLevel is used when present. * - If multiple rules match, the first in colliders.priority is chosen (default priority is ["mesh","hull","bounds"]). * - If no rule matches, defaultShape is used; if absent, falls back to legacy properties.physics.shape; otherwise no collider is created. * - The colliders.maxLOD (or legacy maxLOD) acts as a global cap. Tiles with level > maxLOD never get colliders. * - When a tile becomes invisible, existing colliders at level === maxLOD are retained if the tile has children (as a fallback for deeper LODs), identical to legacy behavior. * e.g. (physics.colliders): * { * "maxLOD": 4, * "priority": ["mesh", "hull", "bounds"], * "byLevel": [ * { "shape": "mesh", "min": 4, "max": 4 }, * { "shape": "hull", "min": 3, "max": 3 }, * { "shape": "bounds", "min": 0, "max": 2 } * ], * "defaultShape": "bounds" * } */ constructor(properties?: { url?: string | undefined; queryParams?: Object | undefined; geometricErrorMultiplier?: number | undefined; loadOutsideView?: boolean | undefined; tileLoader?: TileLoader | undefined; meshCallback?: Function | undefined; pointsCallback?: Function | undefined; onLoadCallback?: Function | undefined; occlusionCullingService?: any; centerModel?: boolean | undefined; static?: boolean | undefined; rootPath?: string | undefined; json?: string | undefined; parentGeometricError?: number | undefined; parentBoundingVolume?: Object | undefined; parentRefine?: string | undefined; cameraOnLoad?: THREE.Camera | undefined; clipShape?: OBB | THREE.Box3 | THREE.Sphere | undefined; parentTile?: OGC3DTile | undefined; proxy?: string | undefined; displayErrors?: boolean | undefined; renderer?: any; domWidth?: number | undefined; domHeight?: number | undefined; dracoLoader?: any; ktx2Loader?: any; distanceBias?: number | undefined; loadingStrategy?: string | undefined; drawBoundingVolume?: string | undefined; splatsFragmentShader?: string | undefined; splatsQuality?: number | undefined; splatsCPUCulling?: boolean | undefined; splatsExposureEV?: number | undefined; splatsSaturation?: number | undefined; splatsContrast?: number | undefined; splatsTempTint?: Object | any[] | undefined; }); physics: any; splatsMesh: any; oldUltraMeshSplats: any; iosCompatibility: any; splatsQuality: number; splatsCPUCulling: boolean; contentURL: any[]; rendererSize: THREE.Vector2; loadingStrategy: string; distanceBias: number; proxy: string | undefined; drawBoundingVolume: string | boolean; displayErrors: boolean | undefined; displayCopyright: boolean; queryParams: { constructor: Function; toString(): string; toLocaleString(): string; valueOf(): Object; hasOwnProperty(v: PropertyKey): boolean; isPrototypeOf(v: Object): boolean; propertyIsEnumerable(v: PropertyKey): boolean; } | undefined; tileLoader: TileLoader | undefined; /** * To be called in the render loop. * @param {THREE.Camera} camera a camera that the tileset will be rendered with. * @returns {{numTilesLoaded: number, numTilesRendered: number, maxLOD: number, percentageLoaded: number}} An object containing describing the current state of the loaded tileset. */ update(camera: THREE.Camera): { numTilesLoaded: number; numTilesRendered: number; maxLOD: number; percentageLoaded: number; }; geometricErrorMultiplier: number; splatsCropRadius: number; splatsSizeMultiplier: number; /** @type {number} */ splatsExposureEV: number; /** @type {number} */ splatsSaturation: number; /** @type {number} */ splatsContrast: number; splatsTempTint: number[]; renderer: any; meshCallback: Function | undefined; loadOutsideView: boolean | undefined; cameraOnLoad: THREE.Camera | undefined; parentTile: OGC3DTile | undefined; occlusionCullingService: any; static: boolean | undefined; color: THREE.Color | undefined; colorID: number | undefined; childrenTiles: any[]; meshContent: any[]; materialVisibility: boolean; level: any; hasMeshContent: number; hasUnloadedJSONContent: number; centerModel: boolean | undefined; abortController: AbortController; onLoadCallback: Function | undefined; /** * specify a clip shape object in world space and tiles outside of the shape will not be loaded. * @param {THREE.Box3|THREE.Sphere|OBB} [clipShape = undefined] The shape is either a THREE.Box3, THREE.Sphere or OBB (import {OBB} from "threedtiles") */ setClipShape(clipShape?: THREE.Box3 | THREE.Sphere | OBB): void; clipShape: any; _setClipShape(clipShape: any): void; /** * Specify a size multiplier for splats * @param {number} sizeMultiplier */ setSplatsSizeMultiplier(sizeMultiplier: number): void; /** * specify a crop radius for splats * @param {number} cropRadius */ setSplatsCropRadius(cropRadius: number): void; /** * set a depth bias to render splats in front of other objects even when they are marginally behind. (avoids overlap issues when overlaying on mesh) * @param {number} depthBias */ setSplatsDepthBias(depthBias: number): void; splatsDepthBias: number | undefined; /** * Set the splats to use CPU culling. Faster sort and better frame rate at the cost of splats being absent when camera moves quickly. * @param {boolean} splatsCPUCulling */ setSplatsCPUCulling(splatsCPUCulling: boolean): void; setSplatsQuality(splatsQuality: any): void; /** * Set exposure compensation (EV stops) for splats in this tile. * @param {number} splatsExposureEV exposure in EV (stops). Useful range: -6 → +6. Positive brightens, negative darkens. */ setSplatsExposureEV(splatsExposureEV: number): void; /** * Set saturation multiplier for splats in this tile. * @param {number} splatsSaturation saturation multiplier. Useful range: 0.0 → 2.0 (1.0 = unchanged). */ setSplatsSaturation(splatsSaturation: number): void; /** * Set contrast multiplier for splats in this tile. * @param {number} splatsContrast contrast multiplier. Useful range: 0.0 → 2.0 (1.0 = unchanged). */ setSplatsContrast(splatsContrast: number): void; /** * Set temperature and tint for splats in this tile. * @param {number} splatsTemperature temperature adjustment in range [-100,100] (warm/cool). * @param {number} splatsTint tint adjustment in range [-100,100] (green/magenta). */ setSplatsTempTint(splatsTemperature: number, splatsTint: number): void; /** * Manually updates all the matrices of the tileset. * To be called after transforming a {@link OGC3DTile tileset} instantiated with the "static" option */ updateMatrices(): void; /** * Call this to specify the canvas width/height when it changes (used to compute tiles geometric error that controls tile refinement). * It's unnecessary to call this when the {@link OGC3DTile} is instantiated with the renderer. * * @param {Number} width * @param {Number} height */ setCanvasSize(width: number, height: number): void; _setup(properties: any): Promise; rootPath: any; isSetup: boolean | undefined; _assembleURL(root: any, relative: any): any; _extractQueryParams(url: any, params: any): any; _load(loadJson?: boolean, loadMesh?: boolean): Promise; /** * Disposes of all the resources used by the tileset. */ dispose(): void; deleted: boolean | undefined; _disposeMeshContent(): void; _disposeChildren(): void; raycast(raycaster: any, intersects: any): boolean | void; _updateImmediate(camera: any, frustum: any): void; shouldBeVisible: boolean | undefined; _statsImmediate(maxLOD: any, numTiles: any, percentageLoaded: any, numTilesRendered: any): void; _stats(maxLOD: any, numTiles: any, percentageLoaded: any, numTilesRendered: any): void; _trimTreeImmediate(): void; _updateNodeVisibilityImmediate(parentDisplaysMesh?: boolean): void; _shouldBeVisibleUpdateImmediate(): void; _setShouldNotBeVisibleRecursive(): void; _loadMeshImmediate(): void; _computeMetricRecursive(camera: any, frustum: any): void; metric: number | undefined; _expandTreeImmediate(camera: any): void; _update(camera: any, frustum: any): void; _loadJsonChildren(camera: any): void; _areAllChildrenLoadedAndHidden(): boolean; /** * Node is ready if it is outside frustum, if it was drawn at least once or if all it's children are ready * @returns true if ready */ _isReady(): boolean; _isReadyImmediate(): boolean; _changeContentVisibility(visibility: any): void; /** * Set the world-space pose of this tileset. * * IMPORTANT: When a physics simulation is attached (this.physics && this.physics.sim && this.physics.rigidBodyID), * you MUST use this method to transform the object. Do NOT modify transforms using THREE.Object3D core methods * (e.g. position.set, quaternion.set, applyQuaternion, setRotationFromEuler, etc.) because the physics engine * is authoritative for the object's transform. This method keeps the physics rigid body in sync and updates colliders. * * @param {THREE.Vector3} position - New world-space position. Must be an instance of THREE.Vector3. * @param {THREE.Euler|THREE.Quaternion} rotation - Rotation can be either a THREE.Euler or a THREE.Quaternion. * @param {THREE.Vector3} scale - New scale. Must be an instance of THREE.Vector3. * @throws {TypeError} If position or scale are not THREE.Vector3, or if rotation is not THREE.Euler/THREE.Quaternion. */ setPose(position: THREE.Vector3, rotation: THREE.Euler | THREE.Quaternion, scale: THREE.Vector3): void; _updateCollider(): void; _calculateUpdateMetric(camera: any, frustum: any): number; _getSiblings(): any[]; _calculateDistanceToCamera(camera: any): number; /** * Set the Geometric Error Multiplier for the tileset. * the {@param geometricErrorMultiplier} can be a number between 1 and infinity. * A {@param geometricErrorMultiplier} of 1 (default) corresponds to a max ScreenSpace error (MSE) of 16. * A lower {@param geometricErrorMultiplier} loads less detail (higher MSE) and a higher {@param geometricErrorMultiplier} loads more detail (lower MSE) * * @param {Number} geometricErrorMultiplier set the LOD multiplier for the entire tileset */ setGeometricErrorMultiplier(geometricErrorMultiplier: number): void; /** * Set the Distance Bias for the tileset. * the {@param distanceBias} can be a number between 0 and infinity. * A {@param distanceBias} is applied as an exponent to camera-to-tile distance. * the {@link geometricErrorMultiplier} should be used to balance out the amount of detail loaded * * @param {Number} distanceBias set the distance bias for the entire tileset */ setDistanceBias(distanceBias: number): void; _transformWGS84ToCartesian(lon: any, lat: any, h: any, sfct: any): void; hideCopyright(): void; showCopyright(): void; } /** * @returns a list of vendors that are required by copyright to be displayed in the app. */ export function getOGC3DTilesCopyrightInfo(): string[]; import * as THREE from 'three'; import { TileLoader } from "./TileLoader"; import { OBB } from "../geometry/obb";