@wave3d/core 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 +60 -0
- package/dist/_virtual/_rolldown/runtime.js +13 -0
- package/dist/config/model.d.ts +240 -0
- package/dist/config/model.js +496 -0
- package/dist/config/model.js.map +1 -0
- package/dist/core-loader.d.ts +10 -0
- package/dist/core-loader.js +12 -0
- package/dist/core-loader.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +3 -0
- package/dist/presets.d.ts +8 -0
- package/dist/presets.js +544 -0
- package/dist/presets.js.map +1 -0
- package/dist/renderer/WaveGeometry.d.ts +31 -0
- package/dist/renderer/WaveGeometry.js +92 -0
- package/dist/renderer/WaveGeometry.js.map +1 -0
- package/dist/renderer/WaveRenderer.d.ts +232 -0
- package/dist/renderer/WaveRenderer.js +1118 -0
- package/dist/renderer/WaveRenderer.js.map +1 -0
- package/dist/renderer/heroPalette.d.ts +10 -0
- package/dist/renderer/heroPalette.js +34 -0
- package/dist/renderer/heroPalette.js.map +1 -0
- package/dist/renderer/index.d.ts +4 -0
- package/dist/renderer/index.js +4 -0
- package/dist/renderer/palette.d.ts +67 -0
- package/dist/renderer/palette.js +535 -0
- package/dist/renderer/palette.js.map +1 -0
- package/dist/renderer/shaders.js +545 -0
- package/dist/renderer/shaders.js.map +1 -0
- package/dist/shell/createWave.d.ts +58 -0
- package/dist/shell/createWave.js +161 -0
- package/dist/shell/createWave.js.map +1 -0
- package/dist/shell/poster.js +64 -0
- package/dist/shell/poster.js.map +1 -0
- package/dist/shell/probe.js +34 -0
- package/dist/shell/probe.js.map +1 -0
- package/dist/standalone/wave3d.standalone.js +13507 -0
- package/dist/standalone.d.ts +13 -0
- package/dist/standalone.js +17 -0
- package/dist/standalone.js.map +1 -0
- package/dist/studio/StudioWaveRenderer.d.ts +187 -0
- package/dist/studio/StudioWaveRenderer.js +905 -0
- package/dist/studio/StudioWaveRenderer.js.map +1 -0
- package/dist/studio/index.d.ts +3 -0
- package/dist/studio/index.js +3 -0
- package/dist/studio/randomize.d.ts +28 -0
- package/dist/studio/randomize.js +264 -0
- package/dist/studio/randomize.js.map +1 -0
- package/dist/util/base64.js +14 -0
- package/dist/util/base64.js.map +1 -0
- package/dist/util/math.js +18 -0
- package/dist/util/math.js.map +1 -0
- package/package.json +76 -0
- package/skills/wave3d/SKILL.md +158 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BackgroundImageFit, BackgroundMode, BasicGradientType, BlendMode, ColorStop, DEFAULT_LIGHT_POSITION, GradientType, LightConfig, MAX_COLORS, MAX_LIGHTS, MAX_MESH_POINTS, MAX_NOISE_BANDS, MAX_WAVES, MeshGradientPoint, NoiseBand, PaletteSource, SceneConfig, StudioConfig, Vec2, Vec3, WaveConfig, createDefaultConfig, createDefaultMeshPoints, createLight, createNoiseBand, ensureCamera, ensureSceneDefaults, ensureStudioConfig, makeStops, makeWave, makeWaveSpread, normalizeBackground, normalizeWave, resizeWaves } from "./config/model.js";
|
|
2
|
+
import { WaveRenderer } from "./renderer/WaveRenderer.js";
|
|
3
|
+
import { FallbackReason, WaveHandle, WaveOptions, WaveState } from "./shell/createWave.js";
|
|
4
|
+
import { PRESETS } from "./presets.js";
|
|
5
|
+
|
|
6
|
+
//#region src/standalone.d.ts
|
|
7
|
+
/** {@link createWaveImpl} with the engine already bundled in (synchronous upgrade). */
|
|
8
|
+
declare function createWave(container: HTMLElement, config?: Partial<StudioConfig>, options?: WaveOptions): WaveHandle;
|
|
9
|
+
/** The drop-in embed contract: an alias of {@link createWave}. */
|
|
10
|
+
declare const mountWave: typeof createWave;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { BackgroundImageFit, BackgroundMode, BasicGradientType, BlendMode, ColorStop, DEFAULT_LIGHT_POSITION, type FallbackReason, GradientType, LightConfig, MAX_COLORS, MAX_LIGHTS, MAX_MESH_POINTS, MAX_NOISE_BANDS, MAX_WAVES, MeshGradientPoint, NoiseBand, PRESETS, PaletteSource, SceneConfig, StudioConfig, Vec2, Vec3, WaveConfig, type WaveHandle, type WaveOptions, WaveRenderer, type WaveState, createDefaultConfig, createDefaultMeshPoints, createLight, createNoiseBand, createWave, ensureCamera, ensureSceneDefaults, ensureStudioConfig, makeStops, makeWave, makeWaveSpread, mountWave, normalizeBackground, normalizeWave, resizeWaves };
|
|
13
|
+
//# sourceMappingURL=standalone.d.ts.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { DEFAULT_LIGHT_POSITION, MAX_COLORS, MAX_LIGHTS, MAX_MESH_POINTS, MAX_NOISE_BANDS, MAX_WAVES, createDefaultConfig, createDefaultMeshPoints, createLight, createNoiseBand, ensureCamera, ensureSceneDefaults, ensureStudioConfig, makeStops, makeWave, makeWaveSpread, normalizeBackground, normalizeWave, resizeWaves } from "./config/model.js";
|
|
2
|
+
import { createWaveImpl } from "./shell/createWave.js";
|
|
3
|
+
import { WaveRenderer } from "./renderer/WaveRenderer.js";
|
|
4
|
+
import { PRESETS } from "./presets.js";
|
|
5
|
+
import { core_loader_exports } from "./core-loader.js";
|
|
6
|
+
//#region src/standalone.ts
|
|
7
|
+
const loadCore = () => Promise.resolve(core_loader_exports);
|
|
8
|
+
/** {@link createWaveImpl} with the engine already bundled in (synchronous upgrade). */
|
|
9
|
+
function createWave(container, config = {}, options = {}) {
|
|
10
|
+
return createWaveImpl(loadCore, container, config, options);
|
|
11
|
+
}
|
|
12
|
+
/** The drop-in embed contract: an alias of {@link createWave}. */
|
|
13
|
+
const mountWave = createWave;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { DEFAULT_LIGHT_POSITION, MAX_COLORS, MAX_LIGHTS, MAX_MESH_POINTS, MAX_NOISE_BANDS, MAX_WAVES, PRESETS, WaveRenderer, createDefaultConfig, createDefaultMeshPoints, createLight, createNoiseBand, createWave, ensureCamera, ensureSceneDefaults, ensureStudioConfig, makeStops, makeWave, makeWaveSpread, mountWave, normalizeBackground, normalizeWave, resizeWaves };
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=standalone.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"standalone.js","names":["core"],"sources":["../src/standalone.ts"],"sourcesContent":["// The single-file CDN / standalone build entry. Unlike the `.` shell — which fetches the engine on\n// demand — this statically imports the engine (three bundled in) and pre-binds createWave/mountWave\n// with a synchronous loadCore, so a plain <script type=\"module\"> from a CDN upgrades with no extra\n// network round-trip. This is also the runtime the studio inlines into its exported embed HTML.\nimport * as core from \"./core-loader\";\nimport { createWaveImpl } from \"./shell/createWave\";\nimport type { WaveOptions, WaveHandle } from \"./shell/createWave\";\nimport type { StudioConfig } from \"./config/model\";\n\n// Synchronous core — the engine is already bundled into this file, so there is no dynamic import\n// (which is exactly why the standalone stays a single file: createWaveImpl never references the\n// public createWave's `import(\"./core-loader\")` default).\nconst loadCore = (): Promise<typeof core> => Promise.resolve(core);\n\n/** {@link createWaveImpl} with the engine already bundled in (synchronous upgrade). */\nexport function createWave(\n container: HTMLElement,\n config: Partial<StudioConfig> = {},\n options: WaveOptions = {},\n): WaveHandle {\n return createWaveImpl(loadCore, container, config, options);\n}\n\n/** The drop-in embed contract: an alias of {@link createWave}. */\nexport const mountWave = createWave;\n\n// CDN users get the raw engine, presets, and full model directly too.\nexport { WaveRenderer } from \"./renderer/WaveRenderer\";\nexport { PRESETS } from \"./presets\";\nexport * from \"./config/model\";\nexport type { WaveOptions, WaveHandle, WaveState, FallbackReason } from \"./shell/createWave\";\n"],"mappings":";;;;;;AAYA,MAAM,iBAAuC,QAAQ,QAAQA,mBAAI;;AAGjE,SAAgB,WACd,WACA,SAAgC,CAAC,GACjC,UAAuB,CAAC,GACZ;CACZ,OAAO,eAAe,UAAU,WAAW,QAAQ,OAAO;AAC5D;;AAGA,MAAa,YAAY"}
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { WaveRenderer } from "../renderer/WaveRenderer.js";
|
|
2
|
+
|
|
3
|
+
//#region src/studio/StudioWaveRenderer.d.ts
|
|
4
|
+
declare class StudioWaveRenderer extends WaveRenderer {
|
|
5
|
+
/** Set while the panel drives the camera, so orbit's 'change' doesn't re-refresh the
|
|
6
|
+
* panel mid-drag (the panel already knows the new value). */
|
|
7
|
+
private suppressCameraChange;
|
|
8
|
+
private readonly miniBox;
|
|
9
|
+
private readonly miniSphere;
|
|
10
|
+
private readonly miniTmpA;
|
|
11
|
+
private readonly miniTmpB;
|
|
12
|
+
private readonly miniPrevColor;
|
|
13
|
+
private readonly miniSize;
|
|
14
|
+
private readonly miniBlendPrev;
|
|
15
|
+
private readonly miniTransPrev;
|
|
16
|
+
private cameraRigOn;
|
|
17
|
+
private cameraRigCollapsed;
|
|
18
|
+
private minimapCamera?;
|
|
19
|
+
private camMarker?;
|
|
20
|
+
/** Gold markers in the minimap, one per rig light (positions/colours tracked live). */
|
|
21
|
+
private minimapLights;
|
|
22
|
+
/** Shown in the rig when no light has been added yet, so the light is always visible there.
|
|
23
|
+
* Matches where "drag in 3D" creates the first light, so the marker doesn't jump when added. */
|
|
24
|
+
private readonly defaultRigLight;
|
|
25
|
+
private minimapBtn?;
|
|
26
|
+
private readonly overlay;
|
|
27
|
+
private readonly raycaster;
|
|
28
|
+
private orbit?;
|
|
29
|
+
private transform?;
|
|
30
|
+
/** Whether the main view orbit/zoom/pan is on (studio); off for the embed. */
|
|
31
|
+
private mainOrbitOn;
|
|
32
|
+
private lightHelpers;
|
|
33
|
+
/** Which 3D-editing gizmo is active: none, dragging lights, or dragging the wave/waves. */
|
|
34
|
+
private editMode;
|
|
35
|
+
private selectedLight;
|
|
36
|
+
/** Wave/wave drag handles: index 0 = the whole-wave box (moves config.position); 1..N =
|
|
37
|
+
* per-wave spheres (move each layer's offset), shown only when there's >1 wave. */
|
|
38
|
+
private waveHelpers;
|
|
39
|
+
private selectedWave;
|
|
40
|
+
/** Gizmo operation: "translate" moves the handle, "rotate" spins the whole wave. */
|
|
41
|
+
private gizmoMode;
|
|
42
|
+
/** Active free screen-plane drag of a handle (grab anywhere on the marker, camera locked). */
|
|
43
|
+
private dragState?;
|
|
44
|
+
private readonly dragPlane;
|
|
45
|
+
/** Active left-drag camera pan in edit mode (the press missed every handle → move the view). */
|
|
46
|
+
private panState?;
|
|
47
|
+
/** Camera snapshot taken when entering a 3D-edit mode and restored verbatim on exit, so the
|
|
48
|
+
* view returns exactly where it was (position + ortho zoom + up) rather than snapping to the
|
|
49
|
+
* authored hero framing. */
|
|
50
|
+
private returnCamera;
|
|
51
|
+
/** Set by the panel: fired after a gizmo drag/selection so sliders can refresh. */
|
|
52
|
+
onLightsChanged?: (selected: number) => void;
|
|
53
|
+
/** Set by the panel: fired after orbit moves the camera so sliders can refresh. */
|
|
54
|
+
onCameraChanged?: () => void;
|
|
55
|
+
/** Set by the panel: fired after a wave/wave gizmo drag/selection so the position and
|
|
56
|
+
* per-wave offset sliders can refresh. */
|
|
57
|
+
onWaveChanged?: () => void;
|
|
58
|
+
/** True while any drag-in-3D gizmo owns the camera (light or wave). */
|
|
59
|
+
private get editing();
|
|
60
|
+
isLightEditMode(): boolean;
|
|
61
|
+
isWaveEditMode(): boolean;
|
|
62
|
+
/** Toggle 3D light editing: show draggable light handles; off restores the prior view. */
|
|
63
|
+
setLightEditMode(on: boolean): Promise<void>;
|
|
64
|
+
/** Toggle 3D wave/wave editing: drag the whole wave (and each wave when there's >1). */
|
|
65
|
+
setWaveEditMode(on: boolean): Promise<void>;
|
|
66
|
+
/** Enter/leave/switch a 3D-edit mode. Modes are mutually exclusive — turning one on turns
|
|
67
|
+
* the other off. The camera is snapshotted on the first entry and restored on the final exit
|
|
68
|
+
* (so light↔wave switches keep the same return view). */
|
|
69
|
+
private setEditMode;
|
|
70
|
+
/** In edit mode, take PAN off OrbitControls' left button so left-drag is free to grab handles;
|
|
71
|
+
* onPointerDown/Move pan the camera manually when a left-press misses every handle (so panning
|
|
72
|
+
* never fights the object drag). Right-drag still rotates the camera; scroll/middle zooms. */
|
|
73
|
+
private setOrbitForEdit;
|
|
74
|
+
/** Switch the wave-edit gizmo between moving handles and rotating the whole wave. Rotate
|
|
75
|
+
* targets the whole-wave box (config.rotation), so selecting it makes the intent obvious. */
|
|
76
|
+
setGizmoMode(mode: "translate" | "rotate"): void;
|
|
77
|
+
getGizmoMode(): "translate" | "rotate";
|
|
78
|
+
/** Snapshot the live camera so leaving edit mode returns exactly here (incl. ortho zoom). */
|
|
79
|
+
private captureReturnCamera;
|
|
80
|
+
/** Restore the snapshot from captureReturnCamera (falls back to the authored hero camera). */
|
|
81
|
+
private restoreReturnCamera;
|
|
82
|
+
/** Turn on mouse/trackpad orbit + zoom + pan + arrow-key orbit (studio only). */
|
|
83
|
+
enableOrbit(): Promise<void>;
|
|
84
|
+
/** Arrow keys orbit the camera around the target (←/→ azimuth, ↑/↓ elevation). */
|
|
85
|
+
private onKeyDown;
|
|
86
|
+
/** Reset the camera to the straight-on hero framing at the configured distance. */
|
|
87
|
+
resetView(): void;
|
|
88
|
+
/** Dolly/aim the camera so the whole wave fills the viewport (keeps the view angle).
|
|
89
|
+
* Fits the geometry box's actual *projected* screen extent — tighter than a bounding
|
|
90
|
+
* sphere for a flat, diagonal ribbon. */
|
|
91
|
+
fitToView(): void;
|
|
92
|
+
/** Dolly the camera to a distance from the orbit target (or set z when no orbit). */
|
|
93
|
+
setCameraDistance(d: number): void;
|
|
94
|
+
/** The current look-at target (orbit's if present, else from config). */
|
|
95
|
+
private camTarget;
|
|
96
|
+
/** Read the camera as orbit values for the panel (angles in degrees). */
|
|
97
|
+
getCameraOrbit(): {
|
|
98
|
+
azimuth: number;
|
|
99
|
+
elevation: number;
|
|
100
|
+
distance: number;
|
|
101
|
+
panX: number;
|
|
102
|
+
panY: number;
|
|
103
|
+
};
|
|
104
|
+
/** Place the camera at azimuth/elevation (degrees) + distance around the target. */
|
|
105
|
+
setCameraOrbit(azimuthDeg: number, elevationDeg: number, distance: number): void;
|
|
106
|
+
/** Roll the camera around its view axis (degrees) — tilts the composition without
|
|
107
|
+
* moving the camera. Applied after positioning; reset by any orbit interaction. */
|
|
108
|
+
rollView(deg: number): void;
|
|
109
|
+
/** Pan: move the look-at target (and camera with it) to (x, y) in world units. */
|
|
110
|
+
setCameraTarget(x: number, y: number): void;
|
|
111
|
+
/** Ortho zoom MULTIPLIER (the camera has no real fov). 1 = the responsive base framing (the hero crop). */
|
|
112
|
+
getZoom(): number;
|
|
113
|
+
setZoom(zoom: number): void;
|
|
114
|
+
duplicateOffset(): {
|
|
115
|
+
x: number;
|
|
116
|
+
y: number;
|
|
117
|
+
z: number;
|
|
118
|
+
};
|
|
119
|
+
/** Toggle the corner camera-rig minimap (studio aid; off in the embed). */
|
|
120
|
+
setCameraRig(on: boolean): void;
|
|
121
|
+
/** Corner rectangle (logical px) for the minimap viewport. */
|
|
122
|
+
private minimapRect;
|
|
123
|
+
/** Place the collapse button at the minimap's top-right (or bottom corner when collapsed). */
|
|
124
|
+
private positionMinimapBtn;
|
|
125
|
+
/** Build the minimap's fixed 3rd-person camera + the camera/light markers (once). */
|
|
126
|
+
private ensureMinimap;
|
|
127
|
+
/** The lights the rig should show: the configured lights, or a single default-position
|
|
128
|
+
* marker when none has been added yet — so the light is always visible in the rig. */
|
|
129
|
+
private rigLights;
|
|
130
|
+
/** Reconcile the minimap's light markers with the rig lights (count, position, colour). */
|
|
131
|
+
private syncMinimapLights;
|
|
132
|
+
/** Fit the minimap's 3rd-person camera to the wave (+ lights) and size/place the camera
|
|
133
|
+
* proxy, so the rig reads at any scene scale. The main camera is orthographic — its literal
|
|
134
|
+
* distance is arbitrary — so the proxy sits a fixed multiple of the scene radius back along
|
|
135
|
+
* the true view direction rather than at the far-away ortho position. */
|
|
136
|
+
private frameMinimap;
|
|
137
|
+
/** Draw the camera-rig minimap into a corner viewport (called after the main render). */
|
|
138
|
+
private renderMinimap;
|
|
139
|
+
private ensureOrbit;
|
|
140
|
+
private onCursorDown;
|
|
141
|
+
private onCursorUp;
|
|
142
|
+
private ensureGizmo;
|
|
143
|
+
private onControlsChange;
|
|
144
|
+
/** Persist the live camera (position/target/distance) into the config. */
|
|
145
|
+
private writeCameraToConfig;
|
|
146
|
+
/** Pointer position in normalized device coords (-1..1), from a canvas-relative event. */
|
|
147
|
+
private pointerNdc;
|
|
148
|
+
private onPointerDown;
|
|
149
|
+
private onPointerMove;
|
|
150
|
+
private onPointerUp;
|
|
151
|
+
private selectLight;
|
|
152
|
+
private selectWaveHandle;
|
|
153
|
+
/** Gizmo drag → route to the active mode's writer. */
|
|
154
|
+
private onGizmoMoved;
|
|
155
|
+
/** Light gizmo drag → write the moved handle back into the config + uniforms. */
|
|
156
|
+
private onLightGizmoMoved;
|
|
157
|
+
/** Wave gizmo drag → the whole-wave box writes config.position (and the wave handles
|
|
158
|
+
* follow it); a per-wave sphere writes that layer's offset (relative to config.position). */
|
|
159
|
+
private onWaveGizmoMoved;
|
|
160
|
+
/** Reconcile the helper spheres with config.lights (count, position, colour). */
|
|
161
|
+
private syncLightHelpers;
|
|
162
|
+
private clearLightHelpers;
|
|
163
|
+
/** Reconcile the wave drag handles with config: one box handle per wave, sitting at that
|
|
164
|
+
* wave's absolute position (and oriented to its rotation so the rotate gizmo starts there). */
|
|
165
|
+
private syncWaveHelpers;
|
|
166
|
+
private clearWaveHelpers;
|
|
167
|
+
/** Reposition just the wave MESHES from each wave's absolute transform — the transform
|
|
168
|
+
* subset of refresh(), used live during a wave gizmo drag so the ribbon follows without a
|
|
169
|
+
* full uniform re-push or a helper resync. */
|
|
170
|
+
private pushWaveTransforms;
|
|
171
|
+
/** Pull the camera back to a 3/4 angle that frames the edit target: the origin wave + all
|
|
172
|
+
* lights (light mode), or a region around config.position + the handles (wave mode). */
|
|
173
|
+
private frameEditCamera;
|
|
174
|
+
/** Restore the authored camera (from config) — used when leaving light-edit. */
|
|
175
|
+
private restoreHeroCamera;
|
|
176
|
+
/** Push only the light uniforms (used live during a gizmo drag). */
|
|
177
|
+
private pushLightUniforms;
|
|
178
|
+
protected isCameraExternallyDriven(): boolean;
|
|
179
|
+
protected onAfterRefresh(): void;
|
|
180
|
+
protected onAfterRenderFrame(): void;
|
|
181
|
+
protected onAfterResize(): void;
|
|
182
|
+
protected applyCameraFromConfig(): void;
|
|
183
|
+
dispose(): void;
|
|
184
|
+
}
|
|
185
|
+
//#endregion
|
|
186
|
+
export { StudioWaveRenderer };
|
|
187
|
+
//# sourceMappingURL=StudioWaveRenderer.d.ts.map
|