Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@types/webxr

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/webxr - npm Package Compare versions

Comparing version 0.0.0 to 0.1.0

337

webxr/index.d.ts

@@ -1,7 +0,8 @@

// Type definitions for webxr 0.0
// Type definitions for non-npm package webxr 0.1
// Project: https://www.w3.org/TR/webxr/
// Definitions by: Rob Rohan <https://github.com/robrohan>
// Raanan Weber <https://github.com/RaananW>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// Minimum TypeScript Version: 3.7
//
// Most of this was hand written and... more or less copied from the following

@@ -19,8 +20,62 @@ // sites:

export type EventHandler = (event: Event) => any;
/**
* Available session modes
*/
export type XRSessionMode = 'inline' | 'immersive-vr' | 'immersive-ar';
export type XRSessionMode = 'immersive-vr' | 'inline' | 'immersive-ar';
/**
* Reference space types
*/
export type XRReferenceSpaceType = 'viewer' | 'local' | 'local-floor' | 'bounded-floor' | 'unbounded';
export type XREnvironmentBlendMode = 'opaque' | 'additive' | 'alpha-blend';
export type XRVisibilityState = 'visible' | 'visible-blurred' | 'hidden';
/**
* Handedness types
*/
export type XRHandedness = 'none' | 'left' | 'right';
/**
* InputSource target ray modes
*/
export type XRTargetRayMode = 'gaze' | 'tracked-pointer' | 'screen';
/**
* Eye types
*/
export type XREye = 'none' | 'left' | 'right';
/**
* Type of XR events available
*/
export type XREventType =
| 'devicechange'
| 'visibilitychange'
| 'end'
| 'inputsourceschange'
| 'select'
| 'selectstart'
| 'selectend'
| 'squeeze'
| 'squeezestart'
| 'squeezeend'
| 'reset';
export type XRFrameRequestCallback = (time: DOMHighResTimeStamp, frame: XRFrame) => void;
export type XRPlaneSet = Set<XRPlane>;
export type XRAnchorSet = Set<XRAnchor>;
export type XREventHandler = EventHandlerNonNull;
// tslint:disable-next-line no-empty-interface
export interface XRLayer extends EventTarget {}
export interface XRSessionInit {
optionalFeatures?: string[];
requiredFeatures?: string[];
}
export interface XRSessionEvent extends Event {

@@ -36,18 +91,19 @@ readonly session: XRSession;

export interface XRViewport {
readonly height: number;
readonly width: number;
readonly x: number;
readonly y: number;
readonly width: number;
readonly height: number;
}
export interface XRWebGLLayerInit {
alpha: boolean;
antialias: boolean;
depth: boolean;
framebufferScaleFactor: number;
ignoreDepthValues: boolean;
stencil: boolean;
antialias?: boolean;
depth?: boolean;
stencil?: boolean;
alpha?: boolean;
multiview?: boolean;
framebufferScaleFactor?: number;
}
export class XRWebGLLayer {
static getNativeFramebufferScaleFactor(session: XRSession): number;
constructor(

@@ -60,4 +116,4 @@ session: XRSession,

readonly framebuffer: WebGLFramebuffer;
readonly frameBufferWidth: number;
readonly frameBufferHeight: number;
readonly framebufferWidth: number;
readonly framebufferHeight: number;
readonly ignoreDepthValues: boolean;

@@ -71,6 +127,6 @@ getViewport: (view: XRView) => XRViewport;

export interface XRRenderState {
readonly baseLayer: XRWebGLLayer;
readonly baseLayer?: XRWebGLLayer;
readonly depthFar: number;
readonly depthNear: number;
readonly inlineVerticalFieldOfView: number;
readonly inlineVerticalFieldOfView?: number;
}

@@ -82,26 +138,23 @@

depthNear: number;
inlineVerticalFieldOfView: number;
inlineVerticalFieldOfView?: number;
layers?: XRLayer[];
}
export interface XRReferenceSpace extends XRSpace {
onreset: EventHandler;
// [NewObject] XRReferenceSpace
getOffsetReferenceSpace: (originOffset: XRRigidTransform) => XRReferenceSpace;
getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
onreset: XREventHandler;
}
// tslint:disable-next-line no-empty-interface
export interface XRBoundedReferenceSpace extends XRSpace {}
export interface XRBoundedReferenceSpace extends XRSpace {
readonly boundsGeometry: DOMPointReadOnly[];
}
export interface XRInputSource {
// A DOMString indicating the methodology used to
// produce the target ray: gaze, tracked-pointer, or screen.
readonly targetRayMode: 'gaze' | 'tracked-pointer' | 'screen';
// tracks the pose which is used to render objects which should
// appear as if they're held in the hand indicated by handedness.
// The orientation of this space indicates the angle at which the hand
// is gripping the object.
readonly gripSpace: XRSpace;
readonly handedness: XRHandedness;
readonly targetRayMode: XRTargetRayMode;
readonly targetRaySpace: XRSpace;
readonly handedness: 'left' | 'right' | 'none';
readonly profiles: string;
readonly gripSpace?: XRSpace;
readonly gamepad?: Gamepad;
readonly profiles: string[];
readonly hand?: XRHand;
}

@@ -116,4 +169,19 @@

readonly session: XRSession;
getPose: (space: XRSpace, baseSpace: XRSpace) => XRPose;
getViewerPose: (referenceSpace: XRReferenceSpace) => XRViewerPose;
getPose(space: XRSpace, baseSpace: XRSpace): XRPose | null;
getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | null;
// AR
getHitTestResults(hitTestSource: XRHitTestSource): XRHitTestResult[];
getHitTestResultsForTransientInput(
hitTestSource: XRTransientInputHitTestSource,
): XRTransientInputHitTestResult[];
// Anchors
trackedAnchors?: XRAnchorSet;
createAnchor?(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
// Planes
worldInformation?: {
detectedPlanes?: XRPlaneSet;
};
// Hand tracking
getJointPose?(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
}

@@ -128,13 +196,18 @@

export interface XRSession extends EventTarget {
export interface XRSession {
addEventListener(
type: XREventType,
listener: XREventHandler,
options?: boolean | AddEventListenerOptions,
): void;
removeEventListener(
type: XREventType,
listener: XREventHandler,
options?: boolean | EventListenerOptions,
): void;
/**
* Returns this session's blend mode which denotes how much of the real-world
* environment is visible through the XR device
*/
readonly environmentBlendMode: 'opaque' | 'additive' | 'alpha-blend';
/**
* Returns a list of this session's XRInputSources, each representing an input device
* used to control the camera and/or scene.
*/
readonly inputSources: XRInputSourceArray;
readonly inputSources: XRInputSource[];
/**

@@ -145,4 +218,3 @@ * object which contains options affecting how the imagery is rendered.

readonly renderState: XRRenderState;
readonly visibilityState: 'hidden' | 'visible' | 'visible-blurred';
readonly visibilityState: XRVisibilityState;
/**

@@ -158,3 +230,3 @@ * Removes a callback from the animation frame painting callback from

*/
end: (event?: XRSessionEvent) => Promise<void>;
end(): Promise<void>;
/**

@@ -167,48 +239,165 @@ * Schedules the specified method to be called the next time the user agent

*/
requestAnimationFrame: (callback: XRFrameRequestCallback) => number;
requestAnimationFrame: XRFrameRequestCallback;
/**
* Requests that a new XRReferenceSpace of the specified type be created.
* Requests that a new XRReferenceSpace of the specified export type be created.
* Returns a promise which resolves with the XRReferenceSpace or
* XRBoundedReferenceSpace which was requested, or throws a NotSupportedError if
* the requested space type isn't supported by the device.
* the requested space export type isn't supported by the device.
*/
requestReferenceSpace: (
s: 'bounded-floor' | 'local' | 'local-floor' | 'unbounded' | 'viewer',
) => Promise<XRReferenceSpace | XRBoundedReferenceSpace>;
requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace | XRBoundedReferenceSpace>;
updateRenderState: (newState: XRRenderStateInit) => void;
updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
onend: XREventHandler;
oninputsourceschange: XREventHandler;
onselect: XREventHandler;
onselectstart: XREventHandler;
onselectend: XREventHandler;
onsqueeze: XREventHandler;
onsqueezestart: XREventHandler;
onsqueezeend: XREventHandler;
onvisibilitychange: XREventHandler;
// hit test
requestHitTestSource?(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
requestHitTestSourceForTransientInput?(
options: XRTransientInputHitTestOptionsInit,
): Promise<XRTransientInputHitTestSource>;
// legacy AR hit test
requestHitTest?(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
// legacy plane detection
updateWorldTrackingState?(options: { planeDetectionState?: { enabled: boolean } }): void;
}
export interface XRViewerPose {
export interface XRViewerPose extends XRPose {
readonly views: XRView[];
}
export interface XRDomPoint {
readonly x: number;
readonly y: number;
readonly z: number;
readonly w: number;
export class XRRigidTransform {
constructor(position?: DOMPointInit, direction?: DOMPointInit);
position: DOMPointReadOnly;
orientation: DOMPointReadOnly;
matrix: Float32Array;
inverse: XRRigidTransform;
}
export class XRRigidTransform {
constructor(position?: DOMPointInit, orientation?: DOMPointInit);
readonly matrix: Float32Array;
readonly orientation: XRDomPoint;
readonly position: XRDomPoint;
readonly inverse: XRRigidTransform;
export interface XRView {
readonly eye: XREye;
readonly projectionMatrix: Float32Array;
readonly transform: XRRigidTransform;
readonly recommendedViewportScale?: number;
requestViewportScale(scale: number): void;
}
export interface XRViewPort {
readonly height: number;
readonly width: number;
readonly x: number;
readonly y: number;
export interface XRInputSourceChangeEvent extends Event {
session: XRSession;
removed: XRInputSource[];
added: XRInputSource[];
}
export interface XRView {
device: any;
readonly eye: 'right' | 'left';
sessionId: number;
readonly transform: XRRigidTransform;
readonly projectionMatrix: Float32Array;
// Experimental/Draft features
export class XRRay {
constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
origin: DOMPointReadOnly;
direction: DOMPointReadOnly;
matrix: Float32Array;
}
export enum XRHitTestTrackableType {
'point',
'plane',
'mesh',
}
export interface XRHitResult {
hitMatrix: Float32Array;
}
export interface XRTransientInputHitTestResult {
readonly inputSource: XRInputSource;
readonly results: XRHitTestResult[];
}
export interface XRHitTestResult {
getPose(baseSpace: XRSpace): XRPose | undefined;
// When anchor system is enabled
createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
}
export interface XRHitTestSource {
cancel(): void;
}
export interface XRTransientInputHitTestSource {
cancel(): void;
}
export interface XRHitTestOptionsInit {
space: XRSpace;
entityTypes?: XRHitTestTrackableType[];
offsetRay?: XRRay;
}
export interface XRTransientInputHitTestOptionsInit {
profile: string;
entityTypes?: XRHitTestTrackableType[];
offsetRay?: XRRay;
}
export interface XRAnchor {
anchorSpace: XRSpace;
delete(): void;
}
export interface XRPlane {
orientation: 'Horizontal' | 'Vertical';
planeSpace: XRSpace;
polygon: DOMPointReadOnly[];
lastChangedTime: number;
}
// tslint:disable-next-line no-empty-interface
export interface XRJointSpace extends XRSpace {}
export interface XRJointPose extends XRPose {
radius: number | undefined;
}
export interface XRHand extends Iterable<XRJointSpace> {
readonly length: number;
[index: number]: XRJointSpace;
readonly WRIST: number;
readonly THUMB_METACARPAL: number;
readonly THUMB_PHALANX_PROXIMAL: number;
readonly THUMB_PHALANX_DISTAL: number;
readonly THUMB_PHALANX_TIP: number;
readonly INDEX_METACARPAL: number;
readonly INDEX_PHALANX_PROXIMAL: number;
readonly INDEX_PHALANX_INTERMEDIATE: number;
readonly INDEX_PHALANX_DISTAL: number;
readonly INDEX_PHALANX_TIP: number;
readonly MIDDLE_METACARPAL: number;
readonly MIDDLE_PHALANX_PROXIMAL: number;
readonly MIDDLE_PHALANX_INTERMEDIATE: number;
readonly MIDDLE_PHALANX_DISTAL: number;
readonly MIDDLE_PHALANX_TIP: number;
readonly RING_METACARPAL: number;
readonly RING_PHALANX_PROXIMAL: number;
readonly RING_PHALANX_INTERMEDIATE: number;
readonly RING_PHALANX_DISTAL: number;
readonly RING_PHALANX_TIP: number;
readonly LITTLE_METACARPAL: number;
readonly LITTLE_PHALANX_PROXIMAL: number;
readonly LITTLE_PHALANX_INTERMEDIATE: number;
readonly LITTLE_PHALANX_DISTAL: number;
readonly LITTLE_PHALANX_TIP: number;
}
{
"name": "@types/webxr",
"version": "0.0.0",
"version": "0.1.0",
"description": "TypeScript definitions for webxr",

@@ -11,2 +11,7 @@ "license": "MIT",

"githubUsername": "robrohan"
},
{
"name": "Raanan Weber",
"url": "https://github.com/RaananW",
"githubUsername": "RaananW"
}

@@ -23,4 +28,4 @@ ],

"dependencies": {},
"typesPublisherContentHash": "0ddce6b295833dcb02ca4b31bcb0aa43bb3f4df6a81954ec3272f02c692846c2",
"typesPublisherContentHash": "14c863085536304dcfb9f130ce1ba4fe2f6ac8a84055ba6424e039838e019d22",
"typeScriptVersion": "3.7"
}

@@ -11,3 +11,3 @@ # Installation

### Additional Details
* Last updated: Tue, 08 Sep 2020 12:01:21 GMT
* Last updated: Fri, 16 Oct 2020 18:08:57 GMT
* Dependencies: none

@@ -17,2 +17,2 @@ * Global values: none

# Credits
These definitions were written by [Rob Rohan](https://github.com/robrohan).
These definitions were written by [Rob Rohan](https://github.com/robrohan), and [Raanan Weber](https://github.com/RaananW).
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc