-
Notifications
You must be signed in to change notification settings - Fork 30.6k
webvr-api: Make webvr-api consistent with latest lib.es6.d.ts #24690
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,15 @@ | ||
| // Type definitions for WebVR API | ||
| // Project: https://w3c.github.io/webvr/ | ||
| // Definitions by: six a <https://github.com/lostfictions> | ||
| // Definitions by: efokschaner <https://github.com/efokschaner> | ||
| // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped | ||
|
|
||
| // Typescript doesn't allow redefinition of type aliases even if they match, | ||
| // thus the _dt_alias to signal this being an alias for the use of DefinitelyTyped | ||
| type VRDisplayEventReason_dt_alias = "mounted" | "navigation" | "requested" | "unmounted"; | ||
|
|
||
| // Typescript doesn't allow redefinition of type aliases even if they match, | ||
| // thus the _dt_alias to signal this being an alias for the use of DefinitelyTyped | ||
| type VREye_dt_alias = "left" | "right"; | ||
|
|
||
| interface VRDisplay extends EventTarget { | ||
| /** | ||
|
|
@@ -55,7 +62,7 @@ interface VRDisplay extends EventTarget { | |
| exitPresent(): Promise<void>; | ||
|
|
||
| /* Return the current VREyeParameters for the given eye. */ | ||
| getEyeParameters(whichEye: string): VREyeParameters; | ||
| getEyeParameters(whichEye: VREye_dt_alias): VREyeParameters; | ||
|
|
||
| /** | ||
| * Populates the passed VRFrameData with the information required to render | ||
|
|
@@ -69,6 +76,7 @@ interface VRDisplay extends EventTarget { | |
| getLayers(): VRLayer[]; | ||
|
|
||
| /** | ||
| * @deprecated | ||
| * Return a VRPose containing the future predicted pose of the VRDisplay | ||
| * when the current frame will be presented. The value returned will not | ||
| * change until JavaScript has returned control to the browser. | ||
|
|
@@ -138,6 +146,11 @@ interface VRDisplayCapabilities { | |
| readonly maxLayers: number; | ||
| } | ||
|
|
||
| declare var VRDisplayCapabilities: { | ||
| prototype: VRDisplayCapabilities; | ||
| new(): VRDisplayCapabilities; | ||
| }; | ||
|
|
||
| interface VREyeParameters { | ||
| /** @deprecated */ | ||
| readonly fieldOfView: VRFieldOfView; | ||
|
|
@@ -146,13 +159,23 @@ interface VREyeParameters { | |
| readonly renderWidth: number; | ||
| } | ||
|
|
||
| declare var VREyeParameters: { | ||
| prototype: VREyeParameters; | ||
| new(): VREyeParameters; | ||
| }; | ||
|
|
||
| interface VRFieldOfView { | ||
| readonly downDegrees: number; | ||
| readonly leftDegrees: number; | ||
| readonly rightDegrees: number; | ||
| readonly upDegrees: number; | ||
| } | ||
|
|
||
| declare var VRFieldOfView: { | ||
| prototype: VRFieldOfView; | ||
| new(): VRFieldOfView; | ||
| }; | ||
|
|
||
| interface VRFrameData { | ||
| readonly leftProjectionMatrix: Float32Array; | ||
| readonly leftViewMatrix: Float32Array; | ||
|
|
@@ -163,9 +186,9 @@ interface VRFrameData { | |
| } | ||
|
|
||
| declare var VRFrameData: { | ||
| prototype: VRFrameData | ||
| new(): VRFrameData | ||
| } | ||
| prototype: VRFrameData; | ||
| new(): VRFrameData; | ||
| }; | ||
|
|
||
| interface VRPose { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why not make VRDisplayCapabalities, VREyeParameters, VRFieldOfView, VRPose and VRFrameData
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think i've done it precisely the same as they are in https://github.com/Microsoft/TypeScript/blob/master/lib/lib.es6.d.ts So although I agree it's a weird pattern I see no reason not to match the official defs to avoid confusion. Does that seem sound?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fair enough. :) |
||
| readonly angularAcceleration: Float32Array | null; | ||
|
|
@@ -177,6 +200,11 @@ interface VRPose { | |
| readonly timestamp: number; | ||
| } | ||
|
|
||
| declare var VRPose: { | ||
| prototype: VRPose; | ||
| new(): VRPose; | ||
| }; | ||
|
|
||
| interface VRStageParameters { | ||
| sittingToStandingTransform?: Float32Array; | ||
| sizeX?: number; | ||
|
|
@@ -188,13 +216,40 @@ interface Navigator { | |
| readonly activeVRDisplays: ReadonlyArray<VRDisplay>; | ||
| } | ||
|
|
||
| interface VRDisplayEventInit extends EventInit { | ||
| display: VRDisplay; | ||
| reason?: VRDisplayEventReason_dt_alias; | ||
| } | ||
|
|
||
| interface VRDisplayEvent extends Event { | ||
| readonly display: VRDisplay; | ||
| readonly reason: VRDisplayEventReason_dt_alias | null; | ||
| } | ||
|
|
||
| declare var VRDisplayEvent: { | ||
| prototype: VRDisplayEvent; | ||
| new(type: string, eventInitDict: VRDisplayEventInit): VRDisplayEvent; | ||
| }; | ||
|
|
||
| interface Window { | ||
| onvrdisplayconnected: ((this: Window, ev: Event) => any) | null; | ||
| onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null; | ||
| onvrdisplayactivate: ((this: Window, ev: Event) => any) | null; | ||
| onvrdisplayblur: ((this: Window, ev: Event) => any) | null; | ||
| onvrdisplayconnect: ((this: Window, ev: Event) => any) | null; | ||
| onvrdisplaydeactivate: ((this: Window, ev: Event) => any) | null; | ||
| onvrdisplaydisconnect: ((this: Window, ev: Event) => any) | null; | ||
| onvrdisplayfocus: ((this: Window, ev: Event) => any) | null; | ||
| onvrdisplaypointerrestricted: ((this: Window, ev: Event) => any) | null; | ||
| onvrdisplaypointerunrestricted: ((this: Window, ev: Event) => any) | null; | ||
| onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null; | ||
| addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void; | ||
| addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void; | ||
| addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void; | ||
| addEventListener(type: "vrdisplayactivate", listener: (this: Window, ev: Event) => any, useCapture?: boolean): void; | ||
| addEventListener(type: "vrdisplayblur", listener: (this: Window, ev: Event) => any, useCapture?: boolean): void; | ||
| addEventListener(type: "vrdisplayconnect", listener: (this: Window, ev: Event) => any, useCapture?: boolean): void; | ||
| addEventListener(type: "vrdisplaydeactivate", listener: (this: Window, ev: Event) => any, useCapture?: boolean): void; | ||
| addEventListener(type: "vrdisplaydisconnect", listener: (this: Window, ev: Event) => any, useCapture?: boolean): void; | ||
| addEventListener(type: "vrdisplayfocus", listener: (this: Window, ev: Event) => any, useCapture?: boolean): void; | ||
| addEventListener(type: "vrdisplaypointerrestricted", listener: (this: Window, ev: Event) => any, useCapture?: boolean): void; | ||
| addEventListener(type: "vrdisplaypointerunrestricted", listener: (this: Window, ev: Event) => any, useCapture?: boolean): void; | ||
| addEventListener(type: "vrdisplaypresentchange", listener: (this: Window, ev: Event) => any, useCapture?: boolean): void; | ||
| } | ||
|
|
||
| interface Gamepad { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where are these defined? Can you just change the originals?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh nm this is in lib.dom.d.ts. I had no idea this stuff was built-in to the browser.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They're defined in https://github.com/Microsoft/TypeScript/blob/master/lib/lib.es6.d.ts
We wouldn't want to change those. Think of this typing as a backport of the official definitions for TS versions that don't yet have them. And these typings in here need to work even when the official definitions are visible and doing it this way works. The type alias' don't conflict nor do the functions they're used by.