Skip to content

Commit

Permalink
Merge pull request #841 from mlankamp/master
Browse files Browse the repository at this point in the history
Updated typings and added new types
  • Loading branch information
xeolabs committed Apr 12, 2022
2 parents 85d7083 + ee35bcb commit 7d1ae1a
Show file tree
Hide file tree
Showing 11 changed files with 214 additions and 46 deletions.
39 changes: 29 additions & 10 deletions types/plugins/AnnotationsPlugin/AnnotationsPlugin.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,7 @@ export declare class AnnotationsPlugin extends Plugin {
entity?: Entity;
pickResult?: PickResult;
occludable?: boolean;
values?: {
String: (string | number);
};
values?: { [key: string]: string | number };
markerShown?: boolean;
labelShown?: boolean;
eye?: number[];
Expand All @@ -120,12 +118,33 @@ export declare class AnnotationsPlugin extends Plugin {
* @param {String} event The annotationCreated event
* @param {Function} callback Callback fired on the event
*/
on(event: "annotationCreated", callback: (annotationId: string)=> void): void;
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 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;
}
2 changes: 1 addition & 1 deletion types/viewer/Viewer.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ export declare class Viewer {
* @param {Boolean} [params.includeGizmos=false] When true, will include gizmos like {@link SectionPlane} in the snapshot.
* @returns {String} String-encoded image data URI.
*/
getSnapshot(params?: any): string;
getSnapshot(params: { width?: number, height?: number, format?: "jpeg" | "png"| "bmp", includeGizmos?: boolean }): string;

/**
* Exits snapshot mode.
Expand Down
2 changes: 2 additions & 0 deletions types/viewer/scene/PerformanceModel/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from "./PerformanceModel";
export * from "./PerformanceNode";
17 changes: 14 additions & 3 deletions types/viewer/scene/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
export * from "./camera";
export * from "./CameraControl/CameraControl";
export * from "./Component";
export * from "./Entity";

export * from "./camera";
export * from "./CameraControl/CameraControl";
export * from "./geometry";
export * from "./marker";
export * from "./materials";
export * from "./math/math";
export * from "./PerformanceModel/PerformanceModel";
export * from "./mementos";
export * from "./mesh";
export * from "./nodes";
export * from "./PerformanceModel";
export * from "./scene/Scene";
export * from "./sectionPlane";
export * from "./viewport";
export * from "./webgl";
84 changes: 52 additions & 32 deletions types/viewer/scene/math/math.d.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,56 @@
declare const math: {
unglobalizeObjectId(modelId: string, globalId: string): string;
globalizeObjectId(modelId: string, objectId: string): string;

/**
* Returns a new, uninitialized two-element vector.
* @returns {Number[]}
*/
vec2: (values?: number[]) => number[];

/**
* Returns a new, uninitialized three-element vector.
* @returns {Number[]}
*/
vec3: (values?: number[]) => number[];

/**
* Returns a new, uninitialized four-element vector.
* @returns {Number[]}
*/
vec4: (values?: number[]) => number[];

/**
* Gets the center of a 2D AABB.
* @returns {Number[]}
*/
getAABB2Center(aabb: number[], dest?: (values?: number[]) => number[]): number[];

/**
* Gets the center of an AABB.
* @returns {Number[]}
*/
getAABB3Center(aabb: number[], dest?: (values?: number[]) => number[]): number[];
/**
* The number of radiians in a degree (0.0174532925).
*/
DEGTORAD: 0.017453292;

/**
* The number of degrees in a radian.
*/
RADTODEG: 57.295779513;

unglobalizeObjectId(modelId: string, globalId: string): string;
globalizeObjectId(modelId: string, objectId: string): string;

/**
* Returns a new, uninitialized two-element vector.
* @returns {Number[]}
*/
vec2: (values?: number[]) => number[];

/**
* Returns a new, uninitialized three-element vector.
* @returns {Number[]}
*/
vec3: (values?: number[]) => number[];

/**
* Returns a new, uninitialized four-element vector.
* @returns {Number[]}
*/
vec4: (values?: number[]) => number[];

/**
* Gets the center of a 2D AABB.
* @returns {Number[]}
*/
getAABB2Center(aabb: number[], dest?: (values?: number[]) => number[]): number[];

/**
* Gets the center of an AABB.
* @returns {Number[]}
*/
getAABB3Center(aabb: number[], dest?: (values?: number[]) => number[]): number[];

/**
* Gets the diagonal size of an AABB3 given as minima and maxima.
*/
getAABB3Diag: (aabb: number[]) => number;

/**
* Normalizes a three-element vector
*/
normalizeVec3: (v: number[], dest?: any) => number[];
};

export {math};
28 changes: 28 additions & 0 deletions types/viewer/scene/mementos/CameraMemento.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { Scene } from "../scene/Scene";

/**
* Saves and restores the state of a {@link Scene}'s {@link Camera}.
*/
export declare class CameraMemento {
/**
* Creates a CameraState.
*
* @param {Scene} [scene] When given, immediately saves the state of the given {@link Scene}'s {@link Camera}.
*/
constructor(scene?: Scene);

/**
* Saves the state of the given {@link Scene}'s {@link Camera}.
*
* @param {Scene} scene The scene that contains the {@link Camera}.
*/
saveCamera(scene: Scene): void;

/**
* Restores a {@link Scene}'s {@link Camera} to the state previously captured with {@link CameraMemento#saveCamera}.
*
* @param {Scene} scene The scene.
* @param {Function} [done] When this callback is given, will fly the {@link Camera} to the saved state then fire the callback. Otherwise will just jump the Camera to the saved state.
*/
restoreCamera(scene: Scene, done?: ()=> void): void;
}
44 changes: 44 additions & 0 deletions types/viewer/scene/mementos/ModelMemento.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { Scene } from "../scene/Scene";
import { MetaModel } from '../../metadata/MetaModel';
/**
* Saves and restores a snapshot of the visual state of the {@link Entity}'s of a model within a {@link Scene}.
*/
export declare class ModelMemento {
/**
* Saves a snapshot of the visual state of the {@link Entity}'s that represent objects within a model.
*
* @param {Scene} scene The scene.
* @param {MetaModel} metaModel Represents the model. Corresponds with an {@link Entity} that represents the model in the scene.
* @param {Object} [mask] Masks what state gets saved. Saves all state when not supplied.
* @param {boolean} [mask.visible] Saves {@link Entity#visible} values when ````true````.
* @param {boolean} [mask.edges] Saves {@link Entity#edges} values when ````true````.
* @param {boolean} [mask.xrayed] Saves {@link Entity#xrayed} values when ````true````.
* @param {boolean} [mask.highlighted] Saves {@link Entity#highlighted} values when ````true````.
* @param {boolean} [mask.selected] Saves {@link Entity#selected} values when ````true````.
* @param {boolean} [mask.clippable] Saves {@link Entity#clippable} values when ````true````.
* @param {boolean} [mask.pickable] Saves {@link Entity#pickable} values when ````true````.
* @param {boolean} [mask.colorize] Saves {@link Entity#colorize} values when ````true````.
* @param {boolean} [mask.opacity] Saves {@link Entity#opacity} values when ````true````.
*/
saveObjects(scene: Scene, metaModel: MetaModel, mask?: {
visible?: boolean;
edges?: boolean;
xrayed?: boolean;
highlighted?: boolean;
selected?: boolean;
clippable?: boolean;
pickable?: boolean;
colorize?: boolean;
opacity?: boolean;
}): void;

/**
* Restores a {@link Scene}'s {@link Entity}'s to their state previously captured with {@link ModelMemento#saveObjects}.
*
* Assumes that the model has not been destroyed or modified since saving.
*
* @param {Scene} scene The scene that was given to {@link ModelMemento#saveObjects}.
* @param {MetaModel} metaModel The metamodel that was given to {@link ModelMemento#saveObjects}.
*/
restoreObjects(scene: Scene, metaModel: MetaModel): void;
}
39 changes: 39 additions & 0 deletions types/viewer/scene/mementos/ObjectsMemento.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { Scene } from "../scene/Scene";

/**
* Saves and restores a snapshot of the visual state of the {@link Entity}'s that represent objects within a {@link Scene}.
*/
export declare class ObjectsMemento {
/**
* Saves a snapshot of the visual state of the {@link Entity}'s that represent objects within a {@link Scene}.
*
* @param {Scene} scene The scene.
* @param {Object} [mask] Masks what state gets saved. Saves all state when not supplied.
* @param {boolean} [mask.visible] Saves {@link Entity#visible} values when ````true````.
* @param {boolean} [mask.edges] Saves {@link Entity#edges} values when ````true````.
* @param {boolean} [mask.xrayed] Saves {@link Entity#xrayed} values when ````true````.
* @param {boolean} [mask.highlighted] Saves {@link Entity#highlighted} values when ````true````.
* @param {boolean} [mask.selected] Saves {@link Entity#selected} values when ````true````.
* @param {boolean} [mask.clippable] Saves {@link Entity#clippable} values when ````true````.
* @param {boolean} [mask.pickable] Saves {@link Entity#pickable} values when ````true````.
* @param {boolean} [mask.colorize] Saves {@link Entity#colorize} values when ````true````.
* @param {boolean} [mask.opacity] Saves {@link Entity#opacity} values when ````true````.
*/
saveObjects(scene: Scene, mask?: {
visible?: boolean;
edges?: boolean;
xrayed?: boolean;
highlighted?: boolean;
selected?: boolean;
clippable?: boolean;
pickable?: boolean;
colorize?: boolean;
opacity?: boolean;
}): void;

/**
* Restores a {@link Scene}'s {@link Entity}'s to their state previously captured with {@link ObjectsMemento#saveObjects}.
* @param {Scene} scene The scene.
*/
restoreObjects(scene: Scene): void;
}
3 changes: 3 additions & 0 deletions types/viewer/scene/mementos/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from "./CameraMemento";
export * from "./ModelMemento";
export * from "./ObjectsMemento";
1 change: 1 addition & 0 deletions types/viewer/scene/viewport/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./Viewport";
1 change: 1 addition & 0 deletions types/viewer/scene/webgl/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./PickResult";

0 comments on commit 7d1ae1a

Please sign in to comment.