@juun-roh/cesium-utils
Version:
Utilities to handle Cesium classes easier.
97 lines (93 loc) • 3.2 kB
text/typescript
export { CesiumCollection, CesiumCollectionItem, Collection, CollectionEventType, EventHandler, NonFunction, Tag, WithTag } from './collection/index.cjs';
import { Entity, Cesium3DTileFeature, GroundPrimitive, Primitive, Model, Cesium3DTileset, Color, Viewer } from 'cesium';
export { H as HybridTerrainProvider, T as TerrainArea, a as TileRange } from './hybrid-terrain-provider-C4b9z5pv.cjs';
export { TerrainAreaCollection, computeRectangle } from './terrain/index.cjs';
export { TerrainVisualizer, isGetterOnly } from './utils/index.cjs';
export { cloneViewer, syncCamera } from './viewer/index.cjs';
interface IHighlight {
show(object: any, options?: HighlightOptions): void;
hide(): void;
destroy(): void;
color: Color;
}
interface HighlightOptions {
color?: Color;
outline?: boolean;
width?: number;
}
type PickedObject = {
id?: Entity;
primitive?: Primitive | GroundPrimitive | Model | Cesium3DTileset;
tileset?: Cesium3DTileset;
detail?: {
model?: Model;
};
};
type Picked = Entity | Cesium3DTileFeature | GroundPrimitive | PickedObject;
/**
* @class
* Lightweight multiton highlight manager for Cesium using flyweight pattern.
*
* @example
* ```
* // Setup
* const viewer1 = new Viewer('cesiumContainer1');
* const viewer2 = new Viewer('cesiumContainer2');
*
* const highlighter1 = Highlight.getInstance(viewer1);
* const highlighter2 = Highlight.getInstance(viewer2);
*
* // This highlight only affects viewer1
* highlighter1.show(someEntity, Color.RED);
*
* // This highlight only affects viewer2
* highlighter2.show(someEntity, Color.BLUE);
*
* // When done with viewers
* Highlight.releaseInstance(viewer1);
* Highlight.releaseInstance(viewer2);
* viewer1.destroy();
* viewer2.destroy();
* ```
*/
declare class Highlight {
private static instances;
private _surface;
private _silhouette;
private _color;
/**
* Creates a new `Highlight` instance.
* @private Use {@link getInstance `Highlight.getInstance()`}
* @param viewer A viewer to create highlight entity in
*/
private constructor();
/**
* Gets or creates highlight instance from a viewer.
* @param viewer The viewer to get or create a new instance from.
*/
static getInstance(viewer: Viewer): Highlight;
/**
* Releases the highlight instance associated with a viewer.
* @param viewer The viewer whose highlight instance should be released.
*/
static releaseInstance(viewer: Viewer): void;
/**
* Highlights a picked object or a direct instance.
* @param picked The result of `Scene.pick()` or direct instance to be highlighted.
* @param options Optional style for the highlight.
*/
show(picked: Picked, options?: HighlightOptions): void | Entity;
private _getObject;
/**
* Clears the current highlight effects.
*/
hide(): void;
/** Gets the highlight color. */
get color(): Color;
/**
* Sets the highlight color.
* @param color The new color for highlights
*/
set color(color: Color);
}
export { Highlight, type HighlightOptions, type IHighlight, type Picked, type PickedObject };