-
Notifications
You must be signed in to change notification settings - Fork 298
/
Copy pathAnnotationsPlugin.d.ts
150 lines (137 loc) · 7.9 KB
/
AnnotationsPlugin.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
import { PickResult } from "../../viewer/scene/webgl/PickResult";
import { Entity, Plugin, Viewer } from "../../viewer";
import { Annotation } from "./Annotation";
export declare type AnnotationsPluginConfiguration = {
/** Optional ID for this plugin, so that we can find it within {@link Viewer.plugins}. */
id?: string;
/** HTML text template for Annotation markers. Defaults to ````<div></div>````. Ignored on {@link Annotation}s configured with a ````markerElementId````. */
markerHTML?: string;
/** HTML text template for Annotation labels. Defaults to ````<div></div>````. Ignored on {@link Annotation}s configured with a ````labelElementId````. */
labelHTML?: string;
/** Container DOM element for markers and labels. Defaults to ````document.body````. */
container?: HTMLElement;
/** Map of default values to insert into the HTML templates for the marker and label. */
values?: { [key: string]: string | number };
/** The amount by which each {@link Annotation} is offset from the surface of its {@link Entity} when we create the Annotation by supplying a {@link PickResult} to {@link AnnotationsPlugin.createAnnotation}.*/
surfaceOffset?: number;
};
/**
* {@link Viewer} plugin that creates {@link Annotation}s.
*/
export declare class AnnotationsPlugin extends Plugin {
/**
* @constructor
* @param {Viewer} viewer The Viewer.
* @param {AnnotationsPluginConfiguration} cfg Plugin configuration.
*/
constructor(viewer: Viewer, cfg: AnnotationsPluginConfiguration);
/**
* The {@link Annotation}s created by {@link AnnotationsPlugin.createAnnotation}, each mapped to its {@link Annotation.id}.
* @type {{String:Annotation}}
*/
annotations: { [key:string]: Annotation };
/**
* Sets the amount by which each {@link Annotation} is offset from the surface of its {@link Entity}, when we
* create the Annotation by supplying a {@link PickResult} to {@link AnnotationsPlugin.createAnnotation}.
*
* See the class comments for more info.
*
* This is ````0.3```` by default.
*
* @param {Number} surfaceOffset The surface offset.
*/
set surfaceOffset(arg: number);
/**
* Gets the amount by which an {@link Annotation} is offset from the surface of its {@link Entity} when
* created by {@link AnnotationsPlugin.createAnnotation}, when we
* create the Annotation by supplying a {@link PickResult} to {@link AnnotationsPlugin.createAnnotation}.
*
* This is ````0.3```` by default.
*
* @returns {Number} The surface offset.
*/
get surfaceOffset(): number;
/**
* Creates an {@link Annotation}.
*
* The Annotation is then registered by {@link Annotation.id} in {@link AnnotationsPlugin.annotations}.
*
* @param {Object} params Annotation configuration.
* @param {String} params.id Unique ID to assign to {@link Annotation.id}. The Annotation will be registered by this in {@link AnnotationsPlugin.annotations} and {@link Scene.components}. Must be unique among all components in the {@link Viewer}.
* @param {String} [params.markerElementId] ID of pre-existing DOM element to render the marker. This overrides ````markerHTML```` and does not support ````values```` (data is baked into the label DOM element).
* @param {String} [params.labelElementId] ID of pre-existing DOM element to render the label. This overrides ````labelHTML```` and does not support ````values```` (data is baked into the label DOM element).
* @param {String} [params.markerHTML] HTML text template for the Annotation marker. Defaults to the marker HTML given to the AnnotationsPlugin constructor. Ignored if you provide ````markerElementId````.
* @param {String} [params.labelHTML] HTML text template for the Annotation label. Defaults to the label HTML given to the AnnotationsPlugin constructor. Ignored if you provide ````labelElementId````.
* @param {Number[]} [params.worldPos=[0,0,0]] World-space position of the Annotation marker, assigned to {@link Annotation.worldPos}.
* @param {Entity} [params.entity] Optional {@link Entity} to associate the Annotation with. Causes {@link Annotation.visible} to be ````false```` whenever {@link Entity.visible} is also ````false````.
* @param {PickResult} [params.pickResult] Sets the Annotation's World-space position and direction vector from the given {@link PickResult}'s {@link PickResult.worldPos} and {@link PickResult.worldNormal}, and the Annotation's Entity from {@link PickResult.entity}. Causes ````worldPos```` and ````entity```` parameters to be ignored, if they are also given.
* @param {Boolean} [params.occludable=false] Indicates whether or not the {@link Annotation} marker and label are hidden whenever the marker occluded by {@link Entity}s in the {@link Scene}. The
* {@link Scene} periodically occlusion-tests all Annotations on every 20th "tick" (which represents a rendered frame). We can adjust that frequency via property {@link Scene.ticksPerOcclusionTest}.
* @param {{String:(String|Number)}} [params.values={}] Map of values to insert into the HTML templates for the marker and label. These will be inserted in addition to any values given to the AnnotationsPlugin constructor.
* @param {Boolean} [params.markerShown=true] Whether to initially show the {@link Annotation} marker.
* @param {Boolean} [params.labelShown=false] Whether to initially show the {@link Annotation} label.
* @param {Number[]} [params.eye] Optional World-space position for {@link Camera.eye}, used when this Annotation is associated with a {@link Camera} position.
* @param {Number[]} [params.look] Optional World-space position for {@link Camera.look}, used when this Annotation is associated with a {@link Camera} position.
* @param {Number[]} [params.up] Optional World-space position for {@link Camera.up}, used when this Annotation is associated with a {@link Camera} position.
* @param {String} [params.projection] Optional projection type for {@link Camera.projection}, used when this Annotation is associated with a {@link Camera} position.
* @returns {Annotation} The new {@link Annotation}.
*/
createAnnotation(params: {
id: string;
markerElementId?: string;
labelElementId?: string;
markerHTML?: string;
labelHTML?: string;
worldPos?: number[];
entity?: Entity;
pickResult?: PickResult;
occludable?: boolean;
values?: { [key: string]: string | number };
markerShown?: boolean;
labelShown?: boolean;
eye?: number[];
look?: number[];
up?: number[];
projection?: string;
}): Annotation;
/**
* Destroys an {@link Annotation}.
*
* @param {String} id ID of Annotation to destroy.
*/
destroyAnnotation(id: string): void;
/**
* Destroys all {@link Annotation}s.
*/
clear(): void;
/**
* Fires when a annotation is created.
* @param {String} event The annotationCreated event
* @param {Function} callback Callback fired on the event
*/
on(event: "annotationCreated", callback: (annotationId: string)=> void): void;
/**
* Fires when a annotation is destroyed.
* @param {String} event The annotationDestroyed event
* @param {Function} callback Callback fired on the event
*/
on(event: "annotationDestroyed", callback: (annotationId: string)=> void): void;
/**
* Fires when a mouse enters a annotation.
* @param {String} event The markerMouseEnter event
* @param {Function} callback Callback fired on the event
*/
on(event: "markerMouseEnter", callback: (annotation: Annotation)=> void): void;
/**
* Fires when a mouse leave an annotation.
* @param {String} event The markerMouseLeave event
* @param {Function} callback Callback fired on the event
*/
on(event: "markerMouseLeave", callback: (annotation: Annotation)=> void): void;
/**
* Fires when a mouse leave an annotation.
* @param {String} event The markerClicked event
* @param {Function} callback Callback fired on the event
*/
on(event: "markerClicked", callback: (annotation: Annotation)=> void): void;
}