three-vr-player 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +128 -0
- package/dist/Player.d.ts +42 -0
- package/dist/VideoSource-pc2RM7bl.js +240 -0
- package/dist/VideoSource-pc2RM7bl.js.map +1 -0
- package/dist/core/LookControls.d.ts +37 -0
- package/dist/core/StereoScene.d.ts +47 -0
- package/dist/core/VideoSource.d.ts +15 -0
- package/dist/core/index.d.ts +7 -0
- package/dist/core/projections.d.ts +20 -0
- package/dist/core/proxy.d.ts +16 -0
- package/dist/core.js +14 -0
- package/dist/core.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/three-vr-player.js +263 -0
- package/dist/three-vr-player.js.map +1 -0
- package/dist/three-vr-player.standalone.js +3726 -0
- package/dist/three-vr-player.standalone.js.map +1 -0
- package/dist/types.d.ts +32 -0
- package/dist/ui/ControlsUI.d.ts +27 -0
- package/dist/ui/format.d.ts +2 -0
- package/dist/webcomponent.d.ts +17 -0
- package/package.json +39 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export type Projection = '180-sbs' | '180-mono' | '360-mono' | '360-sbs' | '360-tb' | 'flat-2d' | 'flat-sbs-full' | 'flat-sbs-half';
|
|
2
|
+
export interface PlayerOptions {
|
|
3
|
+
/** Initial source URL. If omitted, call `player.load(src)` later. */
|
|
4
|
+
src?: string;
|
|
5
|
+
/** Projection mode. Default `'180-sbs'` (or auto-detected from `src`). */
|
|
6
|
+
projection?: Projection;
|
|
7
|
+
/** Guess the projection from the src filename on load. Default `true`. */
|
|
8
|
+
autoDetect?: boolean;
|
|
9
|
+
/** Render the built-in controls UI. Default `true`. */
|
|
10
|
+
controls?: boolean;
|
|
11
|
+
/** Optional CORS proxy (e.g. a mediaflow-proxy) for cross-origin sources. */
|
|
12
|
+
proxy?: {
|
|
13
|
+
url: string;
|
|
14
|
+
apiPassword?: string;
|
|
15
|
+
headers?: Record<string, string>;
|
|
16
|
+
};
|
|
17
|
+
/** Swap which eye's half is shown (for reversed sources). Default `false`. */
|
|
18
|
+
swapEyes?: boolean;
|
|
19
|
+
/** Vertical field of view in degrees. Default `70`. */
|
|
20
|
+
fov?: number;
|
|
21
|
+
/** Supersampling factor (× devicePixelRatio, capped at 4). Default `1.5`. */
|
|
22
|
+
supersampling?: number;
|
|
23
|
+
/** `crossOrigin` for the `<video>`. Default `'anonymous'`; `null` to omit. */
|
|
24
|
+
crossOrigin?: 'anonymous' | 'use-credentials' | null;
|
|
25
|
+
/** Persist view settings to localStorage. Default `false`. */
|
|
26
|
+
persistSettings?: boolean;
|
|
27
|
+
/** Mount into a Shadow DOM for style isolation. Default `true`. */
|
|
28
|
+
shadowDom?: boolean;
|
|
29
|
+
/** Show the Enter-VR button when a headset is available. Default `true`. */
|
|
30
|
+
vrButton?: boolean;
|
|
31
|
+
}
|
|
32
|
+
export type PlayerEvent = 'ready' | 'play' | 'pause' | 'ended' | 'error' | 'timeupdate' | 'projectionchange' | 'enterxr' | 'exitxr';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Projection } from '../types.js';
|
|
2
|
+
|
|
3
|
+
/** What the ControlsUI needs from the Player to drive playback + view. */
|
|
4
|
+
export interface PlayerBridge {
|
|
5
|
+
video: HTMLVideoElement;
|
|
6
|
+
surface: HTMLElement;
|
|
7
|
+
fullscreenTarget: HTMLElement;
|
|
8
|
+
vrButton: HTMLElement;
|
|
9
|
+
vrSupported(): Promise<boolean>;
|
|
10
|
+
getProjection(): Projection;
|
|
11
|
+
setProjection(p: Projection): void;
|
|
12
|
+
setSwapEyes(v: boolean): void;
|
|
13
|
+
setFov(deg: number): void;
|
|
14
|
+
setSupersampling(x: number): void;
|
|
15
|
+
initial: {
|
|
16
|
+
swapEyes: boolean;
|
|
17
|
+
fov: number;
|
|
18
|
+
supersampling: number;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/** Builds the controls bar + settings/menus inside `root` and wires them to `bridge`. */
|
|
22
|
+
export declare class ControlsUI {
|
|
23
|
+
private readonly nodes;
|
|
24
|
+
private readonly disposers;
|
|
25
|
+
constructor(root: ParentNode, bridge: PlayerBridge);
|
|
26
|
+
dispose(): void;
|
|
27
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Player } from './Player.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* `<three-video src="…" projection="180-sbs" controls>` — a framework-agnostic
|
|
5
|
+
* custom element wrapping {@link Player}. Give it a size via CSS.
|
|
6
|
+
*/
|
|
7
|
+
export declare class ThreeVideoElement extends HTMLElement {
|
|
8
|
+
private player?;
|
|
9
|
+
static get observedAttributes(): string[];
|
|
10
|
+
connectedCallback(): void;
|
|
11
|
+
attributeChangedCallback(name: string, _old: string | null, value: string | null): void;
|
|
12
|
+
disconnectedCallback(): void;
|
|
13
|
+
private numAttr;
|
|
14
|
+
/** The underlying Player instance (for programmatic control). */
|
|
15
|
+
get api(): Player | undefined;
|
|
16
|
+
}
|
|
17
|
+
export declare function registerWebComponent(tag?: string): void;
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "three-vr-player",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Embeddable web player for 180/360 and side-by-side/top-bottom 3D video, undistorted on desktop and in WebXR. Built on three.js.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": "dartagnan309",
|
|
8
|
+
"repository": { "type": "git", "url": "https://github.com/dartagnan309/three-vr-player" },
|
|
9
|
+
"keywords": ["webxr", "vr", "180", "360", "sbs", "stereo", "video", "three", "player", "equirectangular"],
|
|
10
|
+
"sideEffects": ["**/*.css", "./dist/three-vr-player.js", "./dist/three-vr-player.standalone.js"],
|
|
11
|
+
"files": ["dist"],
|
|
12
|
+
"main": "./dist/three-vr-player.js",
|
|
13
|
+
"module": "./dist/three-vr-player.js",
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"exports": {
|
|
16
|
+
".": { "types": "./dist/index.d.ts", "import": "./dist/three-vr-player.js" },
|
|
17
|
+
"./core": { "types": "./dist/core/index.d.ts", "import": "./dist/core.js" },
|
|
18
|
+
"./standalone": "./dist/three-vr-player.standalone.js"
|
|
19
|
+
},
|
|
20
|
+
"scripts": {
|
|
21
|
+
"dev": "vite --config vite.demo.config.ts",
|
|
22
|
+
"build": "vite build && vite build --config vite.standalone.config.ts",
|
|
23
|
+
"build:demo": "vite build --config vite.demo.config.ts",
|
|
24
|
+
"typecheck": "tsc --noEmit",
|
|
25
|
+
"test": "vitest run"
|
|
26
|
+
},
|
|
27
|
+
"peerDependencies": { "three": ">=0.160.0 <1" },
|
|
28
|
+
"optionalDependencies": { "hls.js": "^1.5.0" },
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"three": "^0.160.0",
|
|
31
|
+
"hls.js": "^1.5.13",
|
|
32
|
+
"@types/three": "^0.160.0",
|
|
33
|
+
"typescript": "^5.4.0",
|
|
34
|
+
"vite": "^5.2.0",
|
|
35
|
+
"vite-plugin-dts": "^3.9.0",
|
|
36
|
+
"vitest": "^1.5.0",
|
|
37
|
+
"jsdom": "^24.0.0"
|
|
38
|
+
}
|
|
39
|
+
}
|