UNPKG

@openglobus/og

Version:

[openglobus](https://www.openglobus.org/) is a javascript/typescript library designed to display interactive 3d maps and planets with map tiles, imagery and vector data, markers, and 3D objects. It uses the WebGL technology, open source, and completely fr

258 lines (257 loc) 7.25 kB
import { Entity } from "./Entity"; import { Quat, Vec3, Vec4 } from "../math/index"; import { GeoObjectHandler } from "./GeoObjectHandler"; import { InstanceData } from "./InstanceData"; import type { NumberArray3 } from "../math/Vec3"; import type { NumberArray4 } from "../math/Vec4"; import { Object3d } from "../Object3d"; export declare const LOCAL_FORWARD: Vec3; /** * Interface for GeoObject parameters. * @typedef {Object} IGeoObjectParams * @property {Object3d} [object3d] - 3D object associated with the geo object. * @property {string} [objSrc] - Source url of the 3D object. * @property {string} [tag] - Unique instancing drawing identifier tag. * @property {Vec3 | NumberArray3} [position] - Position in Cartesian coordinates. * @property {number | Vec3 | NumberArray3} [scale] - Scale of the object. * @property {Vec3 | NumberArray3} [translate] - Translation offset. * @property {Vec4 | NumberArray4 | string} [color] - RGBA color or HTML color string. * @property {boolean} [visibility] - Visibility flag. */ export interface IGeoObjectParams { object3d?: Object3d; objSrc?: string; tag?: string; position?: Vec3 | NumberArray3; scale?: number | Vec3 | NumberArray3; translate?: Vec3 | NumberArray3; color?: Vec4 | NumberArray4 | string; visibility?: boolean; } /** * Represents 3D object on the the globe or 3d space * @class * @param {IGeoObjectParams} options - Geo object parameters: * @param {Object3d} [options.object3d] - 3D object associated with the geo object. * @param {string} [options.objSrc] - Source url of the 3D object. * @param {string} [options.tag] - Unique instancing drawing identifier tag. * @param {Vec3 | NumberArray3} [options.position] - Position in Cartesian coordinates. * @param {number | Vec3 | NumberArray3} [options.scale=1] - Scale of the object. * @param {Vec3 | NumberArray3} [options.translate] - Translation offset. * @param {Vec4 | NumberArray4 | string} [options.color] - RGBA color or HTML color string. * @param {boolean} [options.visibility=true] - Visibility flag. * * @todo: GeoObject and GeoObjectHandler provides instanced objects only. * It would be nice if it could provide not instanced rendering loop too. */ declare class GeoObject { protected _tag: string; static __counter__: number; /** * Entity instance that holds this geo object. * @public * @type {Entity} */ _entity: Entity | null; /** * Geo object center cartesian position. * @protected * @type {Vec3} */ protected _position: Vec3; _rtcPositionHigh: Vec3; _rtcPositionLow: Vec3; protected _scale: Vec3; protected _translate: Vec3; protected _localPosition: Vec3; /** * RGBA color. * @public * @type {Vec4} */ _color: Vec4; protected _qFrame: Quat; _qRot: Quat; protected _direction: Vec3; _handler: GeoObjectHandler | null; _handlerIndex: number; _tagData: InstanceData | null; _tagDataIndex: number; protected _object3d: Object3d; _objectSrc?: string; protected _visibility: boolean; protected _children: GeoObject[]; constructor(options: IGeoObjectParams); /** * Gets the unique tag of the geo object. * @returns {string} */ get tag(): string; /** * Gets the position of the geo object. * @public * @returns {Vec3} */ getPosition(): Vec3; /** * Gets the 3D object associated with this geo object. * @public * @returns {Object3d} */ get object3d(): Object3d; /** * Gets geometry mesh vertices. * @public * @returns {number[]} */ get vertices(): number[]; /** * Gets geometry mesh normals. * @public * @returns {number[]} */ get normals(): number[]; /** * Gets geometry mesh texture coordinates. * @public * @returns {number[]} */ get texCoords(): number[]; /** * Gets geometry mesh indices. * @public * @returns {number[]} */ get indices(): number[]; /** * Sets the opacity of the geo object. * @param {number} a - Opacity value (0 to 1). */ setOpacity(a: number): void; /** * Gets the opacity of the geo object. * @returns {number} */ getOpacity(): number; /** * Sets the color of the geo object. * @param {number} r - Red component. * @param {number} g - Green component. * @param {number} b - Blue component. * @param {number} [a] - Alpha component. */ setColor(r: number, g: number, b: number, a?: number): void; /** * Sets color. * @public * @param {Vec3 | Vec4} color - RGBA vector. */ setColor4v(color: Vec3 | Vec4): void; /** * Sets geo object visibility. * @public * @param {boolean} visibility - Visibility flag. */ setVisibility(visibility: boolean): void; /** * Returns geo object visibility. * @public * @returns {boolean} */ getVisibility(): boolean; /** * Sets geo object position. * @public * @param {number} x - X coordinate. * @param {number} y - Y coordinate. * @param {number} z - Z coordinate. */ setPosition(x: number, y: number, z: number): void; updateRTCPosition(): void; /** * Sets geo object position. * @public * @param {Vec3} position - Cartesian coordinates. */ setPosition3v(position: Vec3): void; /** * Sets Object3d for the object * @param {Object3d} object */ setObject(object: Object3d): void; /** * Sets the object url source. * @param {string} src */ setObjectSrc(src: string): void; /** * Sets object HTML color. * @param {string} color */ setColorHTML(color: string): void; /** * Sets scales. * @public * @param {number} scale */ setScale(scale: number): void; /** * Sets X, Y, Z axis scales * @public * @param {Vec3} scale */ setScale3v(scale: Vec3): void; /** * Gets scale. * @publci * @returns {Vec3} */ getScale(): Vec3; setTranslate3v(translate: Vec3): void; getTranslate(): Vec3; /** * Sets local offset position. * @param {Vec3} localPosition */ setLocalPosition3v(localPosition: Vec3): void; /** * Gets local offset position. * @public * @returns {Vec3} */ getLocalPosition(): Vec3; /** * Removes the geo object from the handler. * @public */ remove(): void; /** * Sets billboard picking color. * @public * @param {Vec3} color - Picking color. */ setPickingColor3v(color: Vec3): void; /** * Sets the rotation quaternion. * @public * @param {Quat} qRot - Rotation quaternion. */ setRotation(qRot: Quat): void; /** * Returns orientation quaternion. * @public * @returns {Quat} */ getRotation(): Quat; /** * Update object rotation */ updateRotation(): void; /** * Returns object direction * @publcu * @returns {Vec3} */ getDirection(): Vec3; } export { GeoObject };