@occluze/umber 0.2.1 → 0.3.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.md +21 -0
- package/README.md +78 -48
- package/dist/chunks/badge.js +2 -0
- package/dist/chunks/basis.js +2 -0
- package/dist/chunks/basis_transcoder.js +2 -0
- package/dist/chunks/basis_transcoder.wasm +0 -0
- package/dist/chunks/capture.js +2 -2
- package/dist/chunks/covers.js +2 -2
- package/dist/chunks/curves.js +2 -0
- package/dist/chunks/flip.js +2 -2
- package/dist/chunks/fx.js +2 -102
- package/dist/chunks/gl.js +2 -180
- package/dist/chunks/glsl.js +2 -239
- package/dist/chunks/inspect.js +2 -6
- package/dist/chunks/instances.js +2 -93
- package/dist/chunks/layers.js +2 -21
- package/dist/chunks/licence.js +2 -2
- package/dist/chunks/morph.js +2 -2
- package/dist/chunks/patch.js +2 -0
- package/dist/chunks/prepared.js +2 -0
- package/dist/chunks/profiler.js +2 -0
- package/dist/chunks/restore.js +2 -2
- package/dist/chunks/shapes.js +2 -2
- package/dist/chunks/sim.js +2 -22
- package/dist/chunks/text.js +2 -52
- package/dist/chunks/video.js +2 -2
- package/dist/chunks/views.js +2 -2
- package/dist/chunks/vocabulary.js +2 -0
- package/dist/chunks/warm.js +2 -2
- package/dist/frameworks/astro.mjs +2 -0
- package/dist/frameworks/react.mjs +2 -0
- package/dist/frameworks/svelte.mjs +2 -0
- package/dist/frameworks/vue.mjs +2 -0
- package/dist/modules/debug.js +2 -36
- package/dist/modules/debug.mjs +2 -36
- package/dist/modules/handoff.js +2 -2
- package/dist/modules/handoff.mjs +2 -2
- package/dist/modules/input.js +2 -2
- package/dist/modules/input.mjs +2 -2
- package/dist/modules/router-swap.js +2 -13
- package/dist/modules/router.js +2 -2
- package/dist/modules/router.mjs +2 -2
- package/dist/modules/scroll-more.js +2 -0
- package/dist/modules/scroll-touch.js +2 -0
- package/dist/modules/scroll.js +2 -2
- package/dist/modules/scroll.mjs +2 -2
- package/dist/modules/scrollfx.js +2 -0
- package/dist/modules/scrollfx.mjs +2 -0
- package/dist/modules/scrub.js +2 -8
- package/dist/modules/scrub.mjs +2 -8
- package/dist/modules/three.js +2 -0
- package/dist/modules/three.mjs +2 -0
- package/dist/node/assets.mjs +9 -0
- package/dist/node/astro.mjs +47 -0
- package/dist/node/cli.mjs +109 -0
- package/dist/node/shared-3Q24RNIF.mjs +602 -0
- package/dist/node/shared-4FIU6DYP.mjs +200 -0
- package/dist/node/vite.mjs +10 -0
- package/dist/umber.css +2 -2
- package/dist/umber.js +2 -2
- package/dist/umber.mjs +2 -2
- package/docs/AI-quick.md +116 -54
- package/docs/AI.md +1275 -805
- package/docs/npm.md +37 -26
- package/package.json +181 -12
- package/types/assets.d.ts +87 -0
- package/types/astro.d.ts +43 -0
- package/types/debug.d.ts +17 -16
- package/types/esm.d.ts +12 -12
- package/types/global.d.ts +17 -0
- package/types/handoff.d.ts +26 -25
- package/types/input.d.ts +63 -55
- package/types/loop.d.ts +75 -0
- package/types/module.d.ts +108 -0
- package/types/react.d.ts +15 -0
- package/types/router.d.ts +87 -45
- package/types/scroll.d.ts +96 -38
- package/types/scrollfx.d.ts +80 -0
- package/types/scrub.d.ts +33 -32
- package/types/svelte.d.ts +16 -0
- package/types/three.d.ts +226 -0
- package/types/umber.d.ts +633 -357
- package/types/vite.d.ts +33 -0
- package/types/vue.d.ts +14 -0
package/types/three.d.ts
ADDED
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for the three module (@occluze/umber/three).
|
|
3
|
+
*
|
|
4
|
+
* three.js inside Umber's one canvas: glTF models and scenes tied to elements, drawn with
|
|
5
|
+
* the visit's one THREE.WebGLRenderer on Umber's context, in Umber's frame (its clock, its
|
|
6
|
+
* sleep at rest) and under its passes. three.js is the site's own: a peer import("three")
|
|
7
|
+
* the first time a page needs it, or the module object you pass. These types name three's
|
|
8
|
+
* own (`import type ... from "three"`): install three (and @types/three) next to Umber.
|
|
9
|
+
*
|
|
10
|
+
* import { Three } from "@occluze/umber/three";
|
|
11
|
+
* umber.use(Three); // or umber.use(Three, { three: THREE, addons: { GLTFLoader } })
|
|
12
|
+
* <script src=".../umber@x.y.z/modules/three.js"></script> (registers itself; an import map names "three")
|
|
13
|
+
*
|
|
14
|
+
* HTML: <div data-umber="model" data-umber-src="chair.glb"> with data-umber-model-fit, -fov, -zoom,
|
|
15
|
+
* -rotate, -turn, -spin, -tilt, -play, -scrub, -environment and -scene (or --umber-model-<key>).
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import type * as THREE from "three";
|
|
19
|
+
import type { AnimationMixer, Group, Object3D, PerspectiveCamera, Scene, Texture, WebGLRenderer } from "three";
|
|
20
|
+
import type { GLTF, GLTFLoader } from "three/addons/loaders/GLTFLoader.js";
|
|
21
|
+
import type { DRACOLoader } from "three/addons/loaders/DRACOLoader.js";
|
|
22
|
+
import type { KTX2Loader } from "three/addons/loaders/KTX2Loader.js";
|
|
23
|
+
import type { MeshoptDecoder } from "three/addons/libs/meshopt_decoder.module.js";
|
|
24
|
+
import type { RoomEnvironment } from "three/addons/environments/RoomEnvironment.js";
|
|
25
|
+
import type { clone } from "three/addons/utils/SkeletonUtils.js";
|
|
26
|
+
import type { Umber, Tracker, UmberModule, View, ViewFrame } from "./umber.js";
|
|
27
|
+
|
|
28
|
+
/** The three.js module (`import * as THREE from "three"`). */
|
|
29
|
+
export type ThreeModule = typeof THREE;
|
|
30
|
+
|
|
31
|
+
/** The three.js add-ons the module uses, each only when a page needs it. */
|
|
32
|
+
export interface Addons {
|
|
33
|
+
GLTFLoader: typeof GLTFLoader;
|
|
34
|
+
/** Draco-compressed geometry (KHR_draco_mesh_compression). */
|
|
35
|
+
DRACOLoader: typeof DRACOLoader;
|
|
36
|
+
/** KTX2 / Basis textures (KHR_texture_basisu). */
|
|
37
|
+
KTX2Loader: typeof KTX2Loader;
|
|
38
|
+
/** meshopt-compressed buffers (EXT_meshopt_compression). */
|
|
39
|
+
MeshoptDecoder: typeof MeshoptDecoder;
|
|
40
|
+
/** The "room" environment map. */
|
|
41
|
+
RoomEnvironment: typeof RoomEnvironment;
|
|
42
|
+
/** SkeletonUtils.clone: a skinned model on a second element. */
|
|
43
|
+
clone: typeof clone;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Where the decoders' workers load their wasm from. @default jsDelivr, for the three.js version on the page */
|
|
47
|
+
export interface DecoderPaths {
|
|
48
|
+
/** DRACOLoader.setDecoderPath. */
|
|
49
|
+
draco?: string;
|
|
50
|
+
/** KTX2Loader.setTranscoderPath. */
|
|
51
|
+
basis?: string;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** umber.use(Three, options). */
|
|
55
|
+
export interface ThreeOptions {
|
|
56
|
+
/** three.js: the module itself (bundled with the site), or a function that imports it. @default import("three") */
|
|
57
|
+
three?: ThreeModule | (() => Promise<ThreeModule>);
|
|
58
|
+
/** three.js add-ons the site bundled itself; any left out is import()ed from "three/addons/..." when needed. */
|
|
59
|
+
addons?: Partial<Addons>;
|
|
60
|
+
decoders?: DecoderPaths;
|
|
61
|
+
/** ms GPU memory of a model no element shows is kept, for the next page. @default 10000 */
|
|
62
|
+
keep?: number;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** What a scene's light is: the shared room map, none, or a texture of your own. */
|
|
66
|
+
export type EnvironmentChoice = "room" | "none" | Texture;
|
|
67
|
+
|
|
68
|
+
export type ModelStatus = "waiting" | "loading" | "ready" | "error" | "destroyed";
|
|
69
|
+
|
|
70
|
+
/** What a model's onFrame() hooks get, every drawn frame. */
|
|
71
|
+
export interface ModelFrame {
|
|
72
|
+
/** Seconds since the last frame (0 under reduced motion). */
|
|
73
|
+
dt: number;
|
|
74
|
+
time: number;
|
|
75
|
+
/** 0 as the element enters at the bottom, 1 as it leaves at the top. */
|
|
76
|
+
progress: number;
|
|
77
|
+
/** Scroll velocity, px per second. */
|
|
78
|
+
velocity: number;
|
|
79
|
+
reducedMotion: boolean;
|
|
80
|
+
model: Model;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** umber.three.model(el): one data-umber="model" element's model. */
|
|
84
|
+
export interface Model {
|
|
85
|
+
readonly el: Element;
|
|
86
|
+
readonly status: ModelStatus;
|
|
87
|
+
/** The model once it is in its scene (also when it comes back after a lost context); null when it failed or its element left. */
|
|
88
|
+
readonly ready: Promise<Model | null>;
|
|
89
|
+
/** Its own scene, or the page scene (scene "page"). */
|
|
90
|
+
readonly scene: Scene | null;
|
|
91
|
+
readonly camera: PerspectiveCamera | null;
|
|
92
|
+
/** The file's scene: this element's copy (it shares geometry, materials and textures with other elements showing the same file). */
|
|
93
|
+
readonly object: Object3D | null;
|
|
94
|
+
/** The group turned by turn, spin and tilt, sized to 1 world unit; move or turn it from onFrame(). */
|
|
95
|
+
readonly pivot: Group | null;
|
|
96
|
+
readonly gltf: GLTF | null;
|
|
97
|
+
/** Made when the file has animations. */
|
|
98
|
+
readonly mixer: AnimationMixer | null;
|
|
99
|
+
/** Its pin in the page scene (scene "page"). */
|
|
100
|
+
readonly pin: Pin | null;
|
|
101
|
+
readonly progress: number;
|
|
102
|
+
readonly velocity: number;
|
|
103
|
+
/** Before each draw; return true to draw the next frame too. Returns its off(). */
|
|
104
|
+
onFrame(fn: (f: ModelFrame) => unknown): () => void;
|
|
105
|
+
/** Draw it again (after changing it outside onFrame()). */
|
|
106
|
+
wake(): void;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** umber.three.scene(el, options). */
|
|
110
|
+
export interface SceneOptions {
|
|
111
|
+
/** Your scene. @default a new THREE.Scene */
|
|
112
|
+
scene?: Scene;
|
|
113
|
+
/** Your camera, left as it is (its aspect follows the box). @default a PerspectiveCamera at 1 world unit = 1 CSS px */
|
|
114
|
+
camera?: PerspectiveCamera;
|
|
115
|
+
/** Vertical field of view of the default camera, degrees. @default 30 */
|
|
116
|
+
fov?: number;
|
|
117
|
+
/** "room" (a soft studio light, shared by every scene), "none", or your own texture. @default "room" */
|
|
118
|
+
environment?: EnvironmentChoice;
|
|
119
|
+
/** Before each drawn frame; return true to draw the next frame too. */
|
|
120
|
+
animate?: (f: ViewFrame<Scene, PerspectiveCamera, WebGLRenderer | null>) => boolean | undefined;
|
|
121
|
+
/** Free the scene's geometries, materials and textures when the element leaves the page. @default true for the scene made here, false for yours */
|
|
122
|
+
dispose?: boolean;
|
|
123
|
+
/** Clip drawing to the element's box. @default true */
|
|
124
|
+
scissor?: boolean;
|
|
125
|
+
/** Fade with the element's opacity. @default true */
|
|
126
|
+
followOpacity?: boolean;
|
|
127
|
+
/** Max device px per CSS px (a heavy scene drawn smaller). */
|
|
128
|
+
dpr?: number;
|
|
129
|
+
/** Under the page's passes (data-umber-pass), like Umber's planes. @default true */
|
|
130
|
+
passes?: boolean;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** What umber.three.scene() resolves with. */
|
|
134
|
+
export interface ThreeScene {
|
|
135
|
+
readonly el: HTMLElement;
|
|
136
|
+
readonly scene: Scene;
|
|
137
|
+
readonly camera: PerspectiveCamera;
|
|
138
|
+
readonly view: View;
|
|
139
|
+
/** Read on every drawn frame: change it any time. */
|
|
140
|
+
environment: EnvironmentChoice;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** pin(object, el, options). */
|
|
144
|
+
export interface PinOptions {
|
|
145
|
+
/**
|
|
146
|
+
* The object's size: "none" leaves it as it is (world units are CSS px), "contain" and
|
|
147
|
+
* "cover" scale a 1-unit object to the box's shorter or longer side (a data-umber="model"
|
|
148
|
+
* is 1 unit across). @default "none"
|
|
149
|
+
*/
|
|
150
|
+
fit?: "contain" | "cover" | "none";
|
|
151
|
+
/** World units (CSS px) toward the camera. @default 0 */
|
|
152
|
+
z?: number;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/** An object pinned to an element in the page scene. */
|
|
156
|
+
export interface Pin {
|
|
157
|
+
readonly el: Element;
|
|
158
|
+
readonly object: Object3D;
|
|
159
|
+
/** The group that moves with the element (the object hangs in it, as you placed it). */
|
|
160
|
+
readonly holder: Group;
|
|
161
|
+
readonly tracker: Tracker;
|
|
162
|
+
/** 0 as the element enters at the bottom, 1 as it leaves at the top. */
|
|
163
|
+
readonly progress: number;
|
|
164
|
+
remove(): void;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/** What umber.three.page() resolves with. */
|
|
168
|
+
export interface PageScene {
|
|
169
|
+
readonly scene: Scene;
|
|
170
|
+
readonly camera: PerspectiveCamera;
|
|
171
|
+
readonly view: View;
|
|
172
|
+
/** The fixed element the scene is drawn over (the end of <body>). */
|
|
173
|
+
readonly el: HTMLElement;
|
|
174
|
+
environment: EnvironmentChoice;
|
|
175
|
+
/** Move `object` with `el`'s box every frame. Removed when el leaves the page. */
|
|
176
|
+
pin(object: Object3D, el: string | Element, options?: PinOptions): Pin | null;
|
|
177
|
+
/** Before each drawn frame (after the pins moved); return true to draw the next frame too. Returns its off(). */
|
|
178
|
+
onFrame(fn: (f: ViewFrame<Scene, PerspectiveCamera, WebGLRenderer | null>) => boolean | undefined): () => void;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/** umber.three. */
|
|
182
|
+
export interface ThreeApi {
|
|
183
|
+
/** three.js, imported on the first call; null when it can't load (said once). */
|
|
184
|
+
load(): Promise<ThreeModule | null>;
|
|
185
|
+
/** The visit's one renderer on Umber's canvas (umber.renderer(THREE) with this three.js); null when GL is off. */
|
|
186
|
+
renderer(): Promise<WebGLRenderer | null>;
|
|
187
|
+
/** A data-umber="model" element's model (its handle exists before the file is here: await model.ready). null when no element matches. */
|
|
188
|
+
model(el: string | Element): Model | null;
|
|
189
|
+
/** A three.js scene drawn in el's box, its camera at 1 world unit = 1 CSS px. null when GL is off. */
|
|
190
|
+
scene(el: string | Element, options?: SceneOptions): Promise<ThreeScene | null>;
|
|
191
|
+
/** The page scene: one scene over the viewport, objects pinned to elements. null when GL is off. */
|
|
192
|
+
page(): Promise<PageScene | null>;
|
|
193
|
+
/** A soft key, fill and sky light added to `scene` (for materials the environment does not light enough). null until three.js is here. */
|
|
194
|
+
lights(scene: Scene, intensity?: number): Group | null;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/** data-umber-model-<key> / --umber-model-<key>, with their defaults. */
|
|
198
|
+
export declare const MODEL_OPTIONS: {
|
|
199
|
+
fit: string;
|
|
200
|
+
fov: number;
|
|
201
|
+
zoom: number;
|
|
202
|
+
rotate: string;
|
|
203
|
+
turn: number;
|
|
204
|
+
spin: number;
|
|
205
|
+
tilt: number;
|
|
206
|
+
play: string;
|
|
207
|
+
scrub: boolean;
|
|
208
|
+
environment: string;
|
|
209
|
+
scene: string;
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
declare module "./umber.js" {
|
|
213
|
+
interface Umber {
|
|
214
|
+
/** The three module's three.js on Umber's canvas (types/three.d.ts). */
|
|
215
|
+
readonly three: ThreeApi;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/** umber.use(Three, options), createUmber({ modules: [[Three, options]] }). */
|
|
220
|
+
export declare const Three: UmberModule;
|
|
221
|
+
|
|
222
|
+
/** The same without umber.use(): adds umber.three to `engine`. */
|
|
223
|
+
export declare function addThree(engine: Umber, options?: ThreeOptions): ThreeApi;
|
|
224
|
+
|
|
225
|
+
/** @alias The same module as the named export, for `import Three from`. */
|
|
226
|
+
export default Three;
|