Created
September 11, 2018 17:59
-
-
Save nkint/603fe4821b415d8c2adffd4387823759 to your computer and use it in GitHub Desktop.
some stck.gl types
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare module 'draw-triangles-2d' { | |
function draw( | |
context: CanvasRenderingContext2D, | |
positions: Vec3[], | |
cells: Vec2[], | |
start?: number, | |
end?: number, | |
): void | |
export = draw | |
} | |
declare module 'orbit-controls' { | |
function createControls(opts: { | |
position?: Vec3 // the initial position of the camera, default [0, 0, 1] | |
up?: Vec3 // the initial direction of the camera, default [0, 1, 0] | |
target?: Vec3 // the center of the orbit, default [0, 0, 0] | |
phi?: number // the initial rotation in radians, phi in spherical coordinates, default Math.PI/2 | |
theta?: number // the initial rotation in radians, theta in spherical coordinates, default 0 | |
distance?: number // the distance from the target, default 1 | |
damping?: number // how fast the controls slow down, between 0 and 1, default 0.25 | |
rotateSpeed?: number // the speed of the rotation, default 0.28 | |
zoomSpeed?: number // the speed of the zoom, default 0.0075 | |
zoom?: boolean // enable zooming, default true | |
rotate?: boolean // enable rotating, default true | |
phiBounds?: Vec2 // the bounds of the phi rotation, default [0, Math.PI] | |
thetaBounds?: Vec2 // the bounds of the theta rotation, default [-Infinity, Infinity] | |
distanceBounds?: Vec2 // the bounds of the distance, default [0, Infinity] | |
parent?: Window | HTMLElement // the parent element, default window | |
element?: Window | HTMLElement // the element, default window | |
}): { | |
update(): void | |
copyInto(position: Vec3, direction: Vec3, up: Vec3): void // Apply the control's current state to a target camera. | |
enable(): void | |
disable(): void | |
position: Vec3 | |
direction: Vec3 | |
up: Vec3 | |
phi: number | |
theta: number | |
distance: number | |
damping: number | |
rotateSpeed: number | |
zoomSpeed: number | |
pinchSpeed: number | |
pinch: boolean | |
zoom: boolean | |
rotate: boolean | |
phiBounds: Vec2 | |
thetaBounds: Vec2 | |
distanceBounds: Vec2 | |
dragging: Readonly<boolean> | |
pinching: Readonly<boolean> | |
} | |
export = createControls | |
} | |
type Vec2 = [number, number] | |
type Vec3 = [number, number, number] | |
type Vec4 = [number, number, number, number] | |
type Mat4 = [ | |
number, | |
number, | |
number, | |
number, | |
number, | |
number, | |
number, | |
number, | |
number, | |
number, | |
number, | |
number, | |
number, | |
number, | |
number, | |
number | |
] | |
declare module 'perspective-camera' { | |
function createCamera(opts?: { | |
fov?: number // field of view in radians, default Math.PI / 4 | |
far?: number // the far range, default 100 | |
near?: number // the near range, default 1 / 100 | |
position?: Vec3 // the camera position, default [0, 0, 0] | |
direction?: Vec3 // the camera direction, default [0, 0, -1] | |
up?: Vec3 // the camera up vector, default [0, 1, 0] | |
viewport?: [number, number, number, number] // the screen-space viewport bounds, default [-1, -1, 1, 1] | |
}): { | |
update(): void | |
identity(): void | |
translate(i: Vec3): void | |
lookAt(i: Vec3): void | |
project(i: Vec3): Vec3 | |
unproject(i: Vec3): Vec3 | |
createPickingRay(i: Vec3): any | |
viewport: Vec4 | |
projection: Mat4 | |
view: Mat4 | |
position: Vec3 | |
direction: Vec3 | |
up: Vec3 | |
} | |
export = createCamera | |
} | |
declare module 'primitive-torus' { | |
function createTorus(opts?: { | |
majorRadius?: number | |
minorRadius?: number | |
majorSegments?: number | |
minorSegments?: number | |
arc?: number | |
}): { | |
positions: Vec3[] | |
cells: Vec2[] | |
uvs: Vec2[] | |
normals: Vec3[] | |
} | |
export = createTorus | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment