UNPKG

@giro3d/piero-plugin-cityjson

Version:

Load CityJSON datasets in Piero

81 lines (80 loc) 3.2 kB
import { default as PickableFeatures } from '@giro3d/giro3d/core/picking/PickableFeatures'; import { default as PickOptions } from '@giro3d/giro3d/core/picking/PickOptions'; import { default as PickResult } from '@giro3d/giro3d/core/picking/PickResult'; import { DataProjectionMixin, FeatureProjectionMixin, UrlOrDataMixin } from '../../piero/src/giro3d/sources/mixins'; import { Vector2 } from '../../../node_modules/three'; import { default as Entity3D } from '@giro3d/giro3d/entities/Entity3D'; import { CityObjectsMesh } from 'cityjson-threejs-loader'; export declare const isObject: (obj: unknown) => obj is object; /** * Feature returned when picking on CityJSON objects */ export interface CityJSONFeature { /** Intersection info from CityJSON library */ cityjsonInfo: CityJSONIntersectionInfo; /** CityJSON object picked */ citymodel: any; } /** * Object returned by CityJSON's `resolveIntersectionInfo`, used when picking */ export interface CityJSONIntersectionInfo { boundaryIndex: number; geometryIndex: number; lodIndex: number; objectId: string; objectIndex: number; objectTypeIndex: number; surfaceTypeIndex: number; vertexId: number; } /** * Pick result on {@link CityJSONEntity | CityJSON entities} */ export interface CityJSONPickResult extends PickResult<CityJSONFeature> { entity: CityJSONEntity; features?: CityJSONFeature[]; isCityJSONPickResult: true; object: CityObjectsMesh; } export declare const isCityJSONPickResult: (obj: unknown) => obj is CityJSONPickResult; /** * Source interface for {@link CityJSONEntity} */ export interface CityJSONSource extends DataProjectionMixin, Required<FeatureProjectionMixin>, UrlOrDataMixin { } /** * Entity for displaying a CityJSON file */ export default class CityJSONEntity extends Entity3D implements PickableFeatures<CityJSONFeature, CityJSONPickResult> { readonly isCityJSONEntity = true; readonly isPickableFeatures = true; readonly source: CityJSONSource; readonly type = "CityJSONEntity"; /** Array of the available Levels Of Details in this CityJSON model */ get availableLods(): string[] | null; /** * Gets the displayed index of Level Of Details, from {@link availableLods}. * If `-1` or out of bounds, displays all levels. */ get displayedLodIdx(): number; /** * Sets the displayed index of Level Of Details, from {@link availableLods}. * If `-1` or out of bounds, displays all levels. * @param lodIdx - Index from {@link availableLods} */ set displayedLodIdx(lodIdx: number); /** Gets whether the theme uses semantics or not */ get showSemantics(): boolean; /** Sets whether the theme uses semantics or not */ set showSemantics(v: boolean); private _availableLods; private _displayedLodIdx; private _showSemantics; constructor(source: CityJSONSource); static isCityJSONEntity: (obj: object) => obj is CityJSONEntity; pick(canvasCoords: Vector2, options?: PickOptions): CityJSONPickResult[]; pickFeaturesFrom(pickedResult: CityJSONPickResult): CityJSONFeature[]; preprocess(): Promise<void>; private traverseCityMaterials; }