@soonspacejs/plugin-heat-map
Version:
Haet-map plugin for SoonSpace.js
110 lines (109 loc) • 3.47 kB
TypeScript
import { Box2, Matrix4, Vector3 } from 'three';
import SoonSpace, { IVector3, PlaneIVector2, SignalsState } from 'soonspacejs';
import type { PluginObject } from 'soonspacejs';
import HeatMap, { DataPoint } from 'heatmap-ts';
import CreateDrawing from './CreateDrawing';
export interface SceneDataPoint extends Omit<DataPoint, 'y'> {
z: number;
}
export interface ScenePolygonDataPoint extends DataPoint {
z: number;
}
export interface CanvasSize {
width: number;
height: number;
}
export interface CreateParam {
id: string;
name?: PluginObject['name'];
data: SceneDataPoint[];
yAxisHeight: number;
minPosition: PlaneIVector2;
maxPosition: PlaneIVector2;
min?: number;
max?: number;
radius?: number;
canvasScalar?: number;
}
export interface CreatePolygonParam {
id: string;
name?: PluginObject['name'];
data?: ScenePolygonDataPoint[];
points: IVector3[];
min?: number;
max?: number;
radius?: number;
}
export interface StartParam {
id: string;
name?: PluginObject['name'];
data: ScenePolygonDataPoint[];
points: IVector3[];
min?: number;
max?: number;
radius?: number;
value?: number | number[];
}
type DrawingModeKeyType = {
[keyType in 'keyDown' | 'keyUp']?: string[];
};
export type DrawingModeType = (keyof SignalsState | DrawingModeKeyType | 'time')[];
export interface DrawingParam {
id: string;
name?: PluginObject['name'];
data: ScenePolygonDataPoint[];
points: IVector3[];
min?: number;
max?: number;
radius?: number;
value?: number | number[];
timeInterval?: number;
distanceInterval?: number;
addTriggerType?: DrawingModeType;
doneTriggerType?: DrawingModeType;
undoTriggerType?: DrawingModeType;
onAdd?: (point: ScenePolygonDataPoint, data: ScenePolygonDataPoint[]) => void;
onUndo?: (point: ScenePolygonDataPoint, data: ScenePolygonDataPoint[]) => void;
beforePointUpdate?: (type: StartEventType, point: ScenePolygonDataPoint, data: ScenePolygonDataPoint[]) => boolean | ScenePolygonDataPoint;
}
export declare const enum StartEventType {
'add' = "add",
'undo' = "undo"
}
export interface StoreValue {
object: PluginObject;
canvas: HTMLCanvasElement;
param: CreateParam;
width: number;
height: number;
projectionMatrix?: Matrix4;
polygonBox?: Box2;
}
export interface StoreValuePolygon {
object: PluginObject;
canvas: HTMLCanvasElement;
param: CreatePolygonParam;
projectionMatrix: Matrix4;
polygonBox: Box2;
position: Vector3;
}
export default class HeatMapPlugin {
readonly ssp: SoonSpace;
hmInstance: HeatMap | null;
readonly store: Map<string | number, StoreValue | StoreValuePolygon>;
constructor(ssp: SoonSpace);
maxCanvasSize: number;
create(param: CreateParam): PluginObject;
createPolygon(param: CreatePolygonParam): PluginObject;
createDrawing(param: DrawingParam): CreateDrawing;
setData(id: CreateParam['id'], data: CreateParam['data']): PluginObject | void;
setDataPolygon(id: CreateParam['id'], data: Exclude<CreatePolygonParam['data'], undefined>): PluginObject | void;
getById(id: PluginObject['sid']): PluginObject | null;
getByName(name: string): PluginObject[];
removeById(id: PluginObject['sid']): boolean;
private createInitData;
private _formatCanvasSize;
private _formatData;
private _formatData_Polygon;
}
export {};