@viji-dev/core 0.4.0 → 0.4.1

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/dist/index.d.ts CHANGED
@@ -11,81 +11,178 @@ declare interface AudioAnalysisState {
11
11
  };
12
12
  }
13
13
 
14
+ /**
15
+ * Real-time audio analysis for the main audio stream (`viji.audio`).
16
+ * Provides volume, frequency bands, beat detection (with triggers, events, BPM),
17
+ * spectral features, and access to raw FFT / waveform data.
18
+ *
19
+ * All numeric outputs are zeroed when `isConnected` is `false`.
20
+ */
14
21
  export declare interface AudioAPI {
22
+ /** `true` when an audio source is connected; otherwise all numeric fields read as `0` and helper methods return empty data. */
15
23
  isConnected: boolean;
24
+ /** Overall loudness across the stream. */
16
25
  volume: {
26
+ /** Instantaneous RMS volume in 0..1. */
17
27
  current: number;
28
+ /** Instantaneous peak amplitude in 0..1. */
18
29
  peak: number;
30
+ /** Volume with a 200ms decay envelope; rises fast, falls smoothly. Use for flicker-free animations. */
19
31
  smoothed: number;
20
32
  };
33
+ /** Energy in five fixed frequency bands, plus a smoothed companion (~150ms decay) for each. All in 0..1. */
21
34
  bands: {
35
+ /** Instant low-band energy (20–120 Hz, bass/kick range). 0..1. */
22
36
  low: number;
37
+ /** Instant low-mid energy (120–400 Hz). 0..1. */
23
38
  lowMid: number;
39
+ /** Instant mid energy (400–1600 Hz, vocals/instruments). 0..1. */
24
40
  mid: number;
41
+ /** Instant high-mid energy (1600–6000 Hz, cymbals/hi-hats). 0..1. */
25
42
  highMid: number;
43
+ /** Instant high-band energy (6000–16000 Hz, air/brilliance). 0..1. */
26
44
  high: number;
45
+ /** Smoothed `low` (~150ms decay). 0..1. */
27
46
  lowSmoothed: number;
47
+ /** Smoothed `lowMid` (~150ms decay). 0..1. */
28
48
  lowMidSmoothed: number;
49
+ /** Smoothed `mid` (~150ms decay). 0..1. */
29
50
  midSmoothed: number;
51
+ /** Smoothed `highMid` (~150ms decay). 0..1. */
30
52
  highMidSmoothed: number;
53
+ /** Smoothed `high` (~150ms decay). 0..1. */
31
54
  highSmoothed: number;
32
55
  };
56
+ /** Beat detection: fast/smoothed energy curves, single-frame boolean triggers, raw event list, and BPM tracking. */
33
57
  beat: {
58
+ /** Kick energy curve in 0..1 with a 300ms decay. Peaks on each detected kick. */
34
59
  kick: number;
60
+ /** Snare energy curve in 0..1 with a 300ms decay. */
35
61
  snare: number;
62
+ /** Hi-hat energy curve in 0..1 with a 300ms decay. */
36
63
  hat: number;
64
+ /** Energy curve for any beat type in 0..1 with a 300ms decay. */
37
65
  any: number;
66
+ /** Smoothed `kick` curve in 0..1 with a 500ms decay. Use for ambient pulses. */
38
67
  kickSmoothed: number;
68
+ /** Smoothed `snare` curve in 0..1 with a 500ms decay. */
39
69
  snareSmoothed: number;
70
+ /** Smoothed `hat` curve in 0..1 with a 500ms decay. */
40
71
  hatSmoothed: number;
72
+ /** Smoothed `any` curve in 0..1 with a 500ms decay. */
41
73
  anySmoothed: number;
74
+ /** Single-frame boolean triggers OR-accumulated between frames, so no detected beat is lost. */
42
75
  triggers: {
76
+ /** `true` for one frame when any beat is detected. */
43
77
  any: boolean;
78
+ /** `true` for one frame when a kick is detected. */
44
79
  kick: boolean;
80
+ /** `true` for one frame when a snare is detected. */
45
81
  snare: boolean;
82
+ /** `true` for one frame when a hi-hat is detected. */
46
83
  hat: boolean;
47
84
  };
85
+ /** All beats detected since the last render frame (zero or more). Cleared each frame. */
48
86
  events: Array<{
87
+ /** Which drum was detected. */
49
88
  type: 'kick' | 'snare' | 'hat';
89
+ /** Timestamp of the detection in milliseconds. */
50
90
  time: number;
91
+ /** Strength of the beat in 0..1. */
51
92
  strength: number;
52
93
  }>;
94
+ /** Currently detected tempo in beats per minute. Defaults to `120` when no audio. */
53
95
  bpm: number;
96
+ /** Confidence of the BPM tracker in 0..1. */
54
97
  confidence: number;
98
+ /** `true` when the BPM tracker has a stable lock on the current tempo. */
55
99
  isLocked: boolean;
56
100
  };
101
+ /** High-level spectral features derived from the FFT. */
57
102
  spectral: {
103
+ /** Normalized spectral centroid in 0..1 — higher values mean brighter, more treble-heavy sound. */
58
104
  brightness: number;
105
+ /** Normalized spectral flatness in 0..1 — higher values mean noisier (white-noise-like) sound; lower values mean tonal. */
59
106
  flatness: number;
60
107
  };
108
+ /**
109
+ * Returns the raw FFT magnitude spectrum as a `Uint8Array` (1024 bins, each 0..255).
110
+ * Bin `i` covers frequency `i × (sampleRate / fftSize)`. The returned array is a
111
+ * snapshot from the latest analysis tick — repeated calls in the same frame return the same data.
112
+ *
113
+ * @example
114
+ * const fft = viji.audio.getFrequencyData();
115
+ * for (let i = 0; i < fft.length; i++) drawBar(i, fft[i] / 255);
116
+ */
61
117
  getFrequencyData: () => Uint8Array;
118
+ /**
119
+ * Returns the raw time-domain waveform as a `Float32Array` (2048 PCM samples in -1..1).
120
+ * The returned array is a snapshot — repeated calls in the same frame return the same data.
121
+ *
122
+ * @example
123
+ * const wave = viji.audio.getWaveform();
124
+ * for (let i = 0; i < wave.length; i++) drawSample(i, wave[i]);
125
+ */
62
126
  getWaveform: () => Float32Array;
63
127
  }
64
128
 
129
+ /**
130
+ * Lightweight audio analysis for additional or device audio streams. A strict
131
+ * subset of `AudioAPI` — exposes volume, frequency bands, spectral features,
132
+ * and raw FFT/waveform access, but **no beat detection** (no `beat`, no BPM,
133
+ * no triggers, no events).
134
+ */
65
135
  declare interface AudioStreamAPI {
136
+ /** `true` when this audio stream is connected; otherwise all numeric fields read as `0`. */
66
137
  isConnected: boolean;
138
+ /** Overall loudness across the stream. */
67
139
  volume: {
140
+ /** Instantaneous RMS volume in 0..1. */
68
141
  current: number;
142
+ /** Instantaneous peak amplitude in 0..1. */
69
143
  peak: number;
144
+ /** Volume with a 200ms decay envelope. */
70
145
  smoothed: number;
71
146
  };
147
+ /** Energy in five fixed frequency bands, plus a smoothed companion (~150ms decay) for each. All in 0..1. */
72
148
  bands: {
149
+ /** Instant low-band energy (20–120 Hz). 0..1. */
73
150
  low: number;
151
+ /** Instant low-mid energy (120–400 Hz). 0..1. */
74
152
  lowMid: number;
153
+ /** Instant mid energy (400–1600 Hz). 0..1. */
75
154
  mid: number;
155
+ /** Instant high-mid energy (1600–6000 Hz). 0..1. */
76
156
  highMid: number;
157
+ /** Instant high-band energy (6000–16000 Hz). 0..1. */
77
158
  high: number;
159
+ /** Smoothed `low` (~150ms decay). 0..1. */
78
160
  lowSmoothed: number;
161
+ /** Smoothed `lowMid` (~150ms decay). 0..1. */
79
162
  lowMidSmoothed: number;
163
+ /** Smoothed `mid` (~150ms decay). 0..1. */
80
164
  midSmoothed: number;
165
+ /** Smoothed `highMid` (~150ms decay). 0..1. */
81
166
  highMidSmoothed: number;
167
+ /** Smoothed `high` (~150ms decay). 0..1. */
82
168
  highSmoothed: number;
83
169
  };
170
+ /** High-level spectral features derived from the FFT. */
84
171
  spectral: {
172
+ /** Normalized spectral centroid in 0..1. */
85
173
  brightness: number;
174
+ /** Normalized spectral flatness in 0..1. */
86
175
  flatness: number;
87
176
  };
177
+ /**
178
+ * Returns the raw FFT magnitude spectrum for this stream as a `Uint8Array`
179
+ * (1024 bins, each 0..255). Snapshot semantics — see `AudioAPI.getFrequencyData`.
180
+ */
88
181
  getFrequencyData: () => Uint8Array;
182
+ /**
183
+ * Returns the raw time-domain waveform for this stream as a `Float32Array`
184
+ * (2048 samples, each -1..1). Snapshot semantics — see `AudioAPI.getWaveform`.
185
+ */
89
186
  getWaveform: () => Float32Array;
90
187
  }
91
188
 
@@ -576,72 +673,178 @@ declare interface BeatEvent {
576
673
  bands?: string[];
577
674
  }
578
675
 
676
+ /**
677
+ * Configuration object passed to `viji.button()`. The host renders a clickable
678
+ * momentary button — the resulting `value` is `true` for one frame after press,
679
+ * then auto-resets to `false`.
680
+ */
579
681
  declare interface ButtonConfig {
682
+ /** Display name shown on the button in the parameter UI. Required. */
580
683
  label: string;
684
+ /** Optional tooltip / help text shown next to the control. */
581
685
  description?: string;
686
+ /** Group name for organizing related parameters under a shared heading. Default: `'general'`. */
582
687
  group?: string;
688
+ /** Visibility category — the control hides when its capability is unavailable. Default: `'general'`. */
583
689
  category?: ParameterCategory;
584
690
  }
585
691
 
692
+ /**
693
+ * Reactive object returned by `viji.button()`. `value` is a momentary flag —
694
+ * `true` for exactly one frame after the user clicks, then auto-resets to
695
+ * `false`. Use it to trigger discrete events from `render()`.
696
+ */
586
697
  declare interface ButtonParameter {
698
+ /** `true` for the single frame after the user clicks the button, `false` otherwise. */
587
699
  value: boolean;
700
+ /** Display name shown on the button in the parameter UI. */
588
701
  label: string;
702
+ /** Tooltip / help text for the control (empty string when not configured). */
589
703
  description?: string;
704
+ /** Group name under which the control appears in the UI. */
590
705
  group: string;
706
+ /** Visibility category — controls when the parameter is shown. */
591
707
  category: ParameterCategory;
592
708
  }
593
709
 
710
+ /**
711
+ * Options accepted by `VijiCore.captureFrame()` for snapshotting the current
712
+ * scene. Controls output format, encoding, and target resolution / aspect.
713
+ */
594
714
  export declare interface CaptureFrameOptions {
595
- /** Output format: 'blob' for encoded image, 'bitmap' for GPU-friendly ImageBitmap */
715
+ /** Output format: `'blob'` for an encoded image, `'bitmap'` for a GPU-friendly `ImageBitmap`. Default: `'blob'`. */
596
716
  format?: 'blob' | 'bitmap';
597
- /** MIME type for blob output (ignored for bitmap), e.g., 'image/png', 'image/jpeg', 'image/webp' */
717
+ /** MIME type for `'blob'` output (ignored for `'bitmap'`). Examples: `'image/png'`, `'image/jpeg'`, `'image/webp'`. */
598
718
  type?: string;
599
719
  /**
600
720
  * Target resolution.
601
- * - number: scale factor relative to current canvas size (e.g., 0.5 = 50%)
602
- * - { width, height }: exact output size; if aspect ratio differs from canvas,
603
- * the source is center-cropped to match the target aspect ratio before scaling
721
+ * - `number`: scale factor relative to the current canvas size (e.g., `0.5` = 50%).
722
+ * - `Resolution`: exact output size. If the aspect ratio differs from the
723
+ * canvas, the source is center-cropped before scaling.
604
724
  */
605
- resolution?: number | {
606
- width: number;
607
- height: number;
608
- };
725
+ resolution?: number | Resolution;
609
726
  }
610
727
 
728
+ /**
729
+ * Configuration object passed to `viji.color()`. Defines the color picker's
730
+ * label and UI grouping/visibility.
731
+ */
611
732
  declare interface ColorConfig {
733
+ /** Display name shown next to the color swatch in the parameter UI. Required. */
612
734
  label: string;
735
+ /** Optional tooltip / help text shown next to the control. */
613
736
  description?: string;
737
+ /** Group name for organizing related parameters under a shared heading. Default: `'general'`. */
614
738
  group?: string;
739
+ /** Visibility category — the control hides when its capability is unavailable. Default: `'general'`. */
615
740
  category?: ParameterCategory;
616
741
  }
617
742
 
743
+ /**
744
+ * Accepted input forms for color parameters. Internally normalized to canonical
745
+ * lowercase 6-digit hex `#rrggbb`. See `viji.color()` for full documentation.
746
+ *
747
+ * - `string`: hex (`#rrggbb`, `#rgb`), CSS `rgb(r, g, b)`, CSS `hsl(h, s%, l%)`,
748
+ * GLSL-style `vec3(r, g, b)` (0..1), or P5-style `hsb(h, s, b)` (0..360 / 0..100 / 0..100)
749
+ * - `{ r, g, b }`: RGB object with components in 0..255
750
+ * - `{ h, s, b }`: HSB object with `h` in 0..360, `s` and `b` in 0..100
751
+ */
752
+ declare type ColorInput = string | {
753
+ /** Red component in 0..255. */
754
+ r: number;
755
+ /** Green component in 0..255. */
756
+ g: number;
757
+ /** Blue component in 0..255. */
758
+ b: number;
759
+ } | {
760
+ /** Hue in 0..360. */
761
+ h: number;
762
+ /** Saturation in 0..100. */
763
+ s: number;
764
+ /** Brightness in 0..100. */
765
+ b: number;
766
+ };
767
+
768
+ /**
769
+ * Reactive object returned by `viji.color()`. `value` is always a canonical
770
+ * lowercase 6-digit hex string; `rgb` and `hsb` are derived accessors that are
771
+ * recomputed (and frozen) every time the user changes the color.
772
+ */
618
773
  declare interface ColorParameter {
774
+ /** Canonical hex color string `#rrggbb` (lowercase). Updates in real-time. */
619
775
  value: string;
776
+ /** RGB components as integers in 0..255 (frozen, recomputed when value changes). */
777
+ rgb: {
778
+ /** Red component, integer in 0..255. */
779
+ r: number;
780
+ /** Green component, integer in 0..255. */
781
+ g: number;
782
+ /** Blue component, integer in 0..255. */
783
+ b: number;
784
+ };
785
+ /** HSB components: `h` in 0..360, `s` and `b` in 0..100 (frozen, recomputed when value changes). */
786
+ hsb: {
787
+ /** Hue in 0..360. */
788
+ h: number;
789
+ /** Saturation in 0..100. */
790
+ s: number;
791
+ /** Brightness in 0..100. */
792
+ b: number;
793
+ };
794
+ /** Display name shown next to the swatch in the parameter UI. */
620
795
  label: string;
796
+ /** Tooltip / help text for the control (empty string when not configured). */
621
797
  description?: string;
798
+ /** Group name under which the control appears in the UI. */
622
799
  group: string;
800
+ /** Visibility category — controls when the parameter is shown. */
623
801
  category: ParameterCategory;
624
802
  }
625
803
 
804
+ /**
805
+ * Configuration object passed to `viji.coordinate()`. The host renders a 2D
806
+ * draggable pad; both `x` and `y` are clamped to `-1..1`.
807
+ */
626
808
  declare interface CoordinateConfig {
809
+ /** Snap increment for both `x` and `y` components. Default: `0.01`. */
627
810
  step?: number;
811
+ /** Display name shown next to the pad in the parameter UI. Required. */
628
812
  label: string;
813
+ /** Optional tooltip / help text shown next to the control. */
629
814
  description?: string;
815
+ /** Group name for organizing related parameters under a shared heading. Default: `'general'`. */
630
816
  group?: string;
817
+ /** Visibility category — the control hides when its capability is unavailable. Default: `'general'`. */
631
818
  category?: ParameterCategory;
632
819
  }
633
820
 
821
+ /**
822
+ * Reactive object returned by `viji.coordinate()`. `value.x` and `value.y` are
823
+ * always in `-1..1`; the host UI renders a draggable 2D pad.
824
+ */
634
825
  declare interface CoordinateParameter {
826
+ /** Current `{ x, y }` position. Both components are in `-1..1`. Updates in real-time. */
635
827
  value: CoordinateValue;
828
+ /** Snap increment for both `x` and `y` components. */
636
829
  step: number;
830
+ /** Display name shown next to the pad in the parameter UI. */
637
831
  label: string;
832
+ /** Tooltip / help text for the control (empty string when not configured). */
638
833
  description?: string;
834
+ /** Group name under which the control appears in the UI. */
639
835
  group: string;
836
+ /** Visibility category — controls when the parameter is shown. */
640
837
  category: ParameterCategory;
641
838
  }
642
839
 
840
+ /**
841
+ * Two-component coordinate, both axes in `-1..1` (centered on the canvas).
842
+ * Returned and consumed by `viji.coordinate()`.
843
+ */
643
844
  declare type CoordinateValue = {
845
+ /** Horizontal axis in `-1..1` (left to right, `0` = canvas center). */
644
846
  x: number;
847
+ /** Vertical axis in `-1..1` (bottom to top, `0` = canvas center). */
645
848
  y: number;
646
849
  };
647
850
 
@@ -656,34 +859,55 @@ declare interface CoreCapabilities {
656
859
  hasGeneral: boolean;
657
860
  }
658
861
 
862
+ /**
863
+ * Identifier for an individual computer-vision feature pipeline. Returned by
864
+ * `VideoAPI.cv.getActiveFeatures()` and used internally to track state.
865
+ */
659
866
  declare type CVFeature = 'faceDetection' | 'faceMesh' | 'handTracking' | 'poseDetection' | 'bodySegmentation' | 'emotionDetection';
660
867
 
868
+ /**
869
+ * Computer-vision processing rate relative to the scene's render rate.
870
+ * `'full'` runs CV every frame, `'half'` every other frame, `'quarter'` every
871
+ * fourth, `'eighth'` every eighth — lower rates reduce CPU/GPU cost.
872
+ */
661
873
  declare type CVFrameRateMode = 'full' | 'half' | 'quarter' | 'eighth';
662
874
 
663
875
  /**
664
- * DeviceMotionEvent acceleration data
665
- * Matches native DeviceMotionEvent.acceleration structure
876
+ * Device motion data sourced from the platform's `DeviceMotionEvent`. All
877
+ * accelerations are in metres per second squared (m/s²); rotation rates are
878
+ * in degrees per second. Inner objects may be `null` when the underlying
879
+ * sensor is unavailable, and individual axes may be `null` on platforms that
880
+ * report only some components.
666
881
  */
667
882
  declare interface DeviceMotionData {
668
- /** Acceleration without gravity (m/s²) */
883
+ /** Acceleration without gravity (m/s²). `null` when no accelerometer is available. */
669
884
  acceleration: {
885
+ /** Acceleration along the device's X axis in m/s². `null` if unsupported. */
670
886
  x: number | null;
887
+ /** Acceleration along the device's Y axis in m/s². `null` if unsupported. */
671
888
  y: number | null;
889
+ /** Acceleration along the device's Z axis in m/s². `null` if unsupported. */
672
890
  z: number | null;
673
891
  } | null;
674
- /** Acceleration including gravity (m/s²) */
892
+ /** Acceleration including gravity (m/s²). `null` when no accelerometer is available. */
675
893
  accelerationIncludingGravity: {
894
+ /** Acceleration including gravity along the device's X axis in m/s². `null` if unsupported. */
676
895
  x: number | null;
896
+ /** Acceleration including gravity along the device's Y axis in m/s². `null` if unsupported. */
677
897
  y: number | null;
898
+ /** Acceleration including gravity along the device's Z axis in m/s². `null` if unsupported. */
678
899
  z: number | null;
679
900
  } | null;
680
- /** Rotation rate (degrees/second) */
901
+ /** Angular rotation rate (degrees per second). `null` when no gyroscope is available. */
681
902
  rotationRate: {
903
+ /** Rotation rate around the device's Z axis in deg/s. `null` if unsupported. */
682
904
  alpha: number | null;
905
+ /** Rotation rate around the device's X axis in deg/s. `null` if unsupported. */
683
906
  beta: number | null;
907
+ /** Rotation rate around the device's Y axis in deg/s. `null` if unsupported. */
684
908
  gamma: number | null;
685
909
  } | null;
686
- /** Interval between updates (milliseconds) */
910
+ /** Interval between sensor updates in milliseconds. */
687
911
  interval: number;
688
912
  }
689
913
 
@@ -703,10 +927,13 @@ declare interface DeviceOrientationData {
703
927
  }
704
928
 
705
929
  /**
706
- * Complete device sensor state (internal device - no id/name)
930
+ * Sensor snapshot for the device running the scene. Both fields read `null`
931
+ * when the corresponding sensor is unavailable or has not delivered a sample yet.
707
932
  */
708
933
  declare interface DeviceSensorState {
934
+ /** Motion data (acceleration, rotation rate, sampling interval). `null` if no motion sensor is available. */
709
935
  motion: DeviceMotionData | null;
936
+ /** Orientation data (alpha/beta/gamma in degrees). `null` if no orientation sensor is available. */
710
937
  orientation: DeviceOrientationData | null;
711
938
  }
712
939
 
@@ -724,93 +951,183 @@ declare interface DeviceState extends DeviceSensorState {
724
951
  audio: AudioStreamAPI | null;
725
952
  }
726
953
 
954
+ /**
955
+ * 52 ARKit-compatible face blendshape coefficients (each in 0..1) derived from
956
+ * MediaPipe FaceLandmarker. All fields are `0` unless emotion detection is
957
+ * enabled. Available on each `FaceData.blendshapes`.
958
+ */
727
959
  declare interface FaceBlendshapes {
960
+ /** Coefficient (0..1) for the inner brow of the left eye pulling down. */
728
961
  browDownLeft: number;
962
+ /** Coefficient (0..1) for the inner brow of the right eye pulling down. */
729
963
  browDownRight: number;
964
+ /** Coefficient (0..1) for both inner brows pulling up. */
730
965
  browInnerUp: number;
966
+ /** Coefficient (0..1) for the outer left brow pulling up. */
731
967
  browOuterUpLeft: number;
968
+ /** Coefficient (0..1) for the outer right brow pulling up. */
732
969
  browOuterUpRight: number;
970
+ /** Coefficient (0..1) for puffed cheeks. */
733
971
  cheekPuff: number;
972
+ /** Coefficient (0..1) for the left cheek squinting. */
734
973
  cheekSquintLeft: number;
974
+ /** Coefficient (0..1) for the right cheek squinting. */
735
975
  cheekSquintRight: number;
976
+ /** Coefficient (0..1) for the left eyelid closing. */
736
977
  eyeBlinkLeft: number;
978
+ /** Coefficient (0..1) for the right eyelid closing. */
737
979
  eyeBlinkRight: number;
980
+ /** Coefficient (0..1) for the left eye looking down. */
738
981
  eyeLookDownLeft: number;
982
+ /** Coefficient (0..1) for the right eye looking down. */
739
983
  eyeLookDownRight: number;
984
+ /** Coefficient (0..1) for the left eye looking inward (toward the nose). */
740
985
  eyeLookInLeft: number;
986
+ /** Coefficient (0..1) for the right eye looking inward. */
741
987
  eyeLookInRight: number;
988
+ /** Coefficient (0..1) for the left eye looking outward (away from the nose). */
742
989
  eyeLookOutLeft: number;
990
+ /** Coefficient (0..1) for the right eye looking outward. */
743
991
  eyeLookOutRight: number;
992
+ /** Coefficient (0..1) for the left eye looking up. */
744
993
  eyeLookUpLeft: number;
994
+ /** Coefficient (0..1) for the right eye looking up. */
745
995
  eyeLookUpRight: number;
996
+ /** Coefficient (0..1) for the left eye squinting. */
746
997
  eyeSquintLeft: number;
998
+ /** Coefficient (0..1) for the right eye squinting. */
747
999
  eyeSquintRight: number;
1000
+ /** Coefficient (0..1) for the left eye opening wide. */
748
1001
  eyeWideLeft: number;
1002
+ /** Coefficient (0..1) for the right eye opening wide. */
749
1003
  eyeWideRight: number;
1004
+ /** Coefficient (0..1) for the jaw moving forward. */
750
1005
  jawForward: number;
1006
+ /** Coefficient (0..1) for the jaw moving left. */
751
1007
  jawLeft: number;
1008
+ /** Coefficient (0..1) for the jaw opening (mouth open). */
752
1009
  jawOpen: number;
1010
+ /** Coefficient (0..1) for the jaw moving right. */
753
1011
  jawRight: number;
1012
+ /** Coefficient (0..1) for the mouth closing tightly. */
754
1013
  mouthClose: number;
1014
+ /** Coefficient (0..1) for a dimple appearing on the left side. */
755
1015
  mouthDimpleLeft: number;
1016
+ /** Coefficient (0..1) for a dimple appearing on the right side. */
756
1017
  mouthDimpleRight: number;
1018
+ /** Coefficient (0..1) for the left mouth corner pulling down (frown). */
757
1019
  mouthFrownLeft: number;
1020
+ /** Coefficient (0..1) for the right mouth corner pulling down (frown). */
758
1021
  mouthFrownRight: number;
1022
+ /** Coefficient (0..1) for funneling the lips outward. */
759
1023
  mouthFunnel: number;
1024
+ /** Coefficient (0..1) for the mouth shifting left. */
760
1025
  mouthLeft: number;
1026
+ /** Coefficient (0..1) for the lower lip on the left pulling down. */
761
1027
  mouthLowerDownLeft: number;
1028
+ /** Coefficient (0..1) for the lower lip on the right pulling down. */
762
1029
  mouthLowerDownRight: number;
1030
+ /** Coefficient (0..1) for the left lip pressing inward. */
763
1031
  mouthPressLeft: number;
1032
+ /** Coefficient (0..1) for the right lip pressing inward. */
764
1033
  mouthPressRight: number;
1034
+ /** Coefficient (0..1) for puckered lips. */
765
1035
  mouthPucker: number;
1036
+ /** Coefficient (0..1) for the mouth shifting right. */
766
1037
  mouthRight: number;
1038
+ /** Coefficient (0..1) for the lower lip rolling inward. */
767
1039
  mouthRollLower: number;
1040
+ /** Coefficient (0..1) for the upper lip rolling inward. */
768
1041
  mouthRollUpper: number;
1042
+ /** Coefficient (0..1) for the lower lip shrugging. */
769
1043
  mouthShrugLower: number;
1044
+ /** Coefficient (0..1) for the upper lip shrugging. */
770
1045
  mouthShrugUpper: number;
1046
+ /** Coefficient (0..1) for the left mouth corner pulling up (smile). */
771
1047
  mouthSmileLeft: number;
1048
+ /** Coefficient (0..1) for the right mouth corner pulling up (smile). */
772
1049
  mouthSmileRight: number;
1050
+ /** Coefficient (0..1) for the left mouth corner stretching outward. */
773
1051
  mouthStretchLeft: number;
1052
+ /** Coefficient (0..1) for the right mouth corner stretching outward. */
774
1053
  mouthStretchRight: number;
1054
+ /** Coefficient (0..1) for the upper lip on the left raising. */
775
1055
  mouthUpperUpLeft: number;
1056
+ /** Coefficient (0..1) for the upper lip on the right raising. */
776
1057
  mouthUpperUpRight: number;
1058
+ /** Coefficient (0..1) for the left side of the nose sneering. */
777
1059
  noseSneerLeft: number;
1060
+ /** Coefficient (0..1) for the right side of the nose sneering. */
778
1061
  noseSneerRight: number;
1062
+ /** Coefficient (0..1) for the tongue protruding. */
779
1063
  tongueOut: number;
780
1064
  }
781
1065
 
1066
+ /**
1067
+ * One detected face produced by the video CV pipeline. Always carries `id`,
1068
+ * `bounds`, `center`, and `confidence`; the rest is populated only when the
1069
+ * matching CV feature is enabled (face mesh for `landmarks` and `headPose`,
1070
+ * emotion detection for `expressions` and `blendshapes`).
1071
+ */
782
1072
  export declare interface FaceData {
1073
+ /** Index-based face identifier (`0`, `1`, …). Stable within a single frame, may change between frames. */
783
1074
  id: number;
1075
+ /** Bounding box, all components normalized to 0..1 of the source frame. */
784
1076
  bounds: {
1077
+ /** Left edge of the face bounding box, normalized 0..1. */
785
1078
  x: number;
1079
+ /** Top edge of the face bounding box, normalized 0..1. */
786
1080
  y: number;
1081
+ /** Width of the face bounding box, normalized 0..1. */
787
1082
  width: number;
1083
+ /** Height of the face bounding box, normalized 0..1. */
788
1084
  height: number;
789
1085
  };
1086
+ /** Center of the bounding box, normalized 0..1. */
790
1087
  center: {
1088
+ /** Horizontal center of the face, normalized 0..1. */
791
1089
  x: number;
1090
+ /** Vertical center of the face, normalized 0..1. */
792
1091
  y: number;
793
1092
  };
1093
+ /** Detection confidence in 0..1. */
794
1094
  confidence: number;
1095
+ /** 468 normalized face mesh landmarks when face mesh is enabled; empty array otherwise. */
795
1096
  landmarks: {
1097
+ /** Horizontal landmark coordinate, normalized 0..1. */
796
1098
  x: number;
1099
+ /** Vertical landmark coordinate, normalized 0..1. */
797
1100
  y: number;
1101
+ /** Optional depth (relative). */
798
1102
  z?: number;
799
1103
  }[];
1104
+ /** Seven expression confidence scores in 0..1. All zero unless emotion detection is enabled. */
800
1105
  expressions: {
1106
+ /** Confidence (0..1) of a neutral expression. */
801
1107
  neutral: number;
1108
+ /** Confidence (0..1) of a happy / smiling expression. */
802
1109
  happy: number;
1110
+ /** Confidence (0..1) of a sad expression. */
803
1111
  sad: number;
1112
+ /** Confidence (0..1) of an angry expression. */
804
1113
  angry: number;
1114
+ /** Confidence (0..1) of a surprised expression. */
805
1115
  surprised: number;
1116
+ /** Confidence (0..1) of a disgusted expression. */
806
1117
  disgusted: number;
1118
+ /** Confidence (0..1) of a fearful expression. */
807
1119
  fearful: number;
808
1120
  };
1121
+ /** Estimated head rotation. All zero unless face mesh is enabled. */
809
1122
  headPose: {
1123
+ /** Up/down rotation in degrees (-90..90). */
810
1124
  pitch: number;
1125
+ /** Left/right rotation in degrees (-90..90). */
811
1126
  yaw: number;
1127
+ /** Tilt rotation in degrees (-180..180). */
812
1128
  roll: number;
813
1129
  };
1130
+ /** 52 ARKit-compatible facial muscle coefficients. All zero unless emotion detection is enabled. */
814
1131
  blendshapes: FaceBlendshapes;
815
1132
  }
816
1133
 
@@ -820,77 +1137,165 @@ declare interface FrameRateInfo {
820
1137
  effectiveRefreshRate: number;
821
1138
  }
822
1139
 
1140
+ /**
1141
+ * Render-loop pacing mode. `'full'` runs `render()` on every animation frame
1142
+ * (~60 FPS). `'half'` runs every second frame (~30 FPS), saving CPU/GPU on
1143
+ * lower-cost scenes.
1144
+ */
823
1145
  declare type FrameRateMode = 'full' | 'half';
824
1146
 
1147
+ /**
1148
+ * One named frequency band reported by the audio analyzer
1149
+ * (e.g., `{ name: 'low', min: 20, max: 120 }`). Frequencies are in Hertz.
1150
+ */
825
1151
  export declare interface FrequencyBand {
1152
+ /** Human-readable band name (e.g., `'low'`, `'mid'`, `'high'`). */
826
1153
  name: string;
1154
+ /** Lower edge of the band in Hertz (inclusive). */
827
1155
  min: number;
1156
+ /** Upper edge of the band in Hertz (exclusive). */
828
1157
  max: number;
829
1158
  }
830
1159
 
1160
+ /**
1161
+ * One detected hand produced by the video CV pipeline. Carries 21 landmarks,
1162
+ * a palm shortcut, and ML-classified gesture confidence scores. Up to two
1163
+ * hands appear in `VideoAPI.hands` simultaneously.
1164
+ */
831
1165
  export declare interface HandData {
1166
+ /** Index-based hand identifier (`0` or `1`). */
832
1167
  id: number;
1168
+ /** Which hand. Always lowercase. */
833
1169
  handedness: 'left' | 'right';
1170
+ /** Detection confidence in 0..1. */
834
1171
  confidence: number;
1172
+ /** Bounding box, all components normalized to 0..1 of the source frame. */
835
1173
  bounds: {
1174
+ /** Left edge of the hand bounding box, normalized 0..1. */
836
1175
  x: number;
1176
+ /** Top edge of the hand bounding box, normalized 0..1. */
837
1177
  y: number;
1178
+ /** Width of the hand bounding box, normalized 0..1. */
838
1179
  width: number;
1180
+ /** Height of the hand bounding box, normalized 0..1. */
839
1181
  height: number;
840
1182
  };
1183
+ /** 21 MediaPipe hand landmarks, normalized 0..1. */
841
1184
  landmarks: {
1185
+ /** Horizontal landmark coordinate, normalized 0..1. */
842
1186
  x: number;
1187
+ /** Vertical landmark coordinate, normalized 0..1. */
843
1188
  y: number;
1189
+ /** Depth (relative). */
844
1190
  z: number;
845
1191
  }[];
1192
+ /** Palm center — equivalent to `landmarks[9]` (middle-finger MCP). */
846
1193
  palm: {
1194
+ /** Palm horizontal coordinate, normalized 0..1. */
847
1195
  x: number;
1196
+ /** Palm vertical coordinate, normalized 0..1. */
848
1197
  y: number;
1198
+ /** Palm depth (relative). */
849
1199
  z: number;
850
1200
  };
1201
+ /**
1202
+ * ML-classified gesture confidences from MediaPipe GestureRecognizer.
1203
+ * Each value is in 0..1; multiple gestures can fire simultaneously.
1204
+ */
851
1205
  gestures: {
1206
+ /** Confidence (0..1) of a closed-fist gesture. */
852
1207
  fist: number;
1208
+ /** Confidence (0..1) of an open-palm gesture. */
853
1209
  openPalm: number;
1210
+ /** Confidence (0..1) of a peace / victory sign. */
854
1211
  peace: number;
1212
+ /** Confidence (0..1) of a thumbs-up gesture. */
855
1213
  thumbsUp: number;
1214
+ /** Confidence (0..1) of a thumbs-down gesture. */
856
1215
  thumbsDown: number;
1216
+ /** Confidence (0..1) of a pointing-up gesture. */
857
1217
  pointing: number;
1218
+ /** Confidence (0..1) of the ASL "I love you" sign. */
858
1219
  iLoveYou: number;
859
1220
  };
860
1221
  }
861
1222
 
1223
+ /**
1224
+ * Configuration object passed to `viji.image()`. The host renders an upload
1225
+ * field; the user-supplied image becomes available as an `ImageBitmap` (Native)
1226
+ * or a P5 image wrapper (P5 renderer).
1227
+ */
862
1228
  declare interface ImageConfig {
1229
+ /** Display name shown next to the upload field in the parameter UI. Required. */
863
1230
  label: string;
1231
+ /** Optional tooltip / help text shown next to the control. */
864
1232
  description?: string;
1233
+ /** Group name for organizing related parameters under a shared heading. Default: `'general'`. */
865
1234
  group?: string;
1235
+ /** Visibility category — the control hides when its capability is unavailable. Default: `'general'`. */
866
1236
  category?: ParameterCategory;
867
1237
  }
868
1238
 
1239
+ /**
1240
+ * Reactive object returned by `viji.image()`. `value` is `null` until the user
1241
+ * uploads an image; in P5 scenes a `.p5` accessor is also added at runtime so
1242
+ * the image works directly with `image()`, `texture()`, etc.
1243
+ */
869
1244
  declare interface ImageParameter {
1245
+ /** Uploaded image as an `ImageBitmap`, or `null` until the user provides one. */
870
1246
  value: ImageBitmap | null;
871
1247
  /** P5-compatible image wrapper. Only available in the P5 renderer — added at runtime by the P5 adapter. */
872
1248
  readonly p5?: any;
1249
+ /** Display name shown next to the upload field in the parameter UI. */
873
1250
  label: string;
1251
+ /** Tooltip / help text for the control (empty string when not configured). */
874
1252
  description?: string;
1253
+ /** Group name under which the control appears in the UI. */
875
1254
  group: string;
1255
+ /** Visibility category — controls when the parameter is shown. */
876
1256
  category: ParameterCategory;
877
1257
  }
878
1258
 
879
1259
  declare type InstrumentType = 'kick' | 'snare' | 'hat';
880
1260
 
1261
+ /**
1262
+ * Keyboard input state for the current frame: per-key press / hold / release
1263
+ * queries (case-insensitive), the live set of held keys, modifier flags, and
1264
+ * a Shadertoy-compatible texture buffer for shader-side keyboard reads.
1265
+ *
1266
+ * Key names follow the browser's `event.key` standard
1267
+ * (`'a'`, `'arrowup'`, `' '` for Space, `'enter'`, `'escape'`, etc.).
1268
+ */
881
1269
  export declare interface KeyboardAPI {
1270
+ /** Returns `true` while the named key is held. Case-insensitive. */
882
1271
  isPressed(key: string): boolean;
1272
+ /** Returns `true` for exactly one frame on the rising edge of the named key (no key-repeat). Case-insensitive. */
883
1273
  wasPressed(key: string): boolean;
1274
+ /** Returns `true` for exactly one frame on the falling edge of the named key. Case-insensitive. */
884
1275
  wasReleased(key: string): boolean;
1276
+ /** Set of all currently held keys, lowercased. Persists across frames. */
885
1277
  activeKeys: Set<string>;
1278
+ /** Set of keys whose key-down fired this frame, lowercased. Cleared each frame. */
886
1279
  pressedThisFrame: Set<string>;
1280
+ /** Set of keys whose key-up fired this frame, lowercased. Cleared each frame. */
887
1281
  releasedThisFrame: Set<string>;
1282
+ /** Most recently pressed key in its original case (e.g., `'A'` when Shift is held). */
888
1283
  lastKeyPressed: string;
1284
+ /** Most recently released key in its original case. */
889
1285
  lastKeyReleased: string;
1286
+ /** `true` while the Shift key is held. */
890
1287
  shift: boolean;
1288
+ /** `true` while the Ctrl key is held. */
891
1289
  ctrl: boolean;
1290
+ /** `true` while the Alt (or Option) key is held. */
892
1291
  alt: boolean;
1292
+ /** `true` while the Meta (Windows / Cmd) key is held. */
893
1293
  meta: boolean;
1294
+ /**
1295
+ * Shadertoy-compatible 256×3 keyboard texture (256 keycodes × 3 rows).
1296
+ * Row 0: held state (1 / 0). Row 1: pressed-this-frame (1 / 0). Row 2: per-key toggle.
1297
+ * Bound to a uniform sampler in shader scenes; rarely needed in JS.
1298
+ */
894
1299
  textureData: Uint8Array;
895
1300
  }
896
1301
 
@@ -904,21 +1309,43 @@ export declare interface KeyboardEventData {
904
1309
  metaKey: boolean;
905
1310
  }
906
1311
 
1312
+ /**
1313
+ * Mouse input state for the current frame: position, individual button states,
1314
+ * per-frame movement, scroll wheel, and frame-based press / release events.
1315
+ * Coordinates are in canvas-space pixels with `(0, 0)` at the top-left corner.
1316
+ *
1317
+ * For interactions that should also work on touch devices, prefer `viji.pointer`.
1318
+ */
907
1319
  export declare interface MouseAPI {
1320
+ /** Canvas-space X position in pixels. */
908
1321
  x: number;
1322
+ /** Canvas-space Y position in pixels. */
909
1323
  y: number;
1324
+ /** `true` when the cursor is currently over the canvas. */
910
1325
  isInCanvas: boolean;
1326
+ /** `true` if any mouse button is currently held. */
911
1327
  isPressed: boolean;
1328
+ /** `true` while the left mouse button is held. */
912
1329
  leftButton: boolean;
1330
+ /** `true` while the right mouse button is held. The browser context menu is suppressed on the canvas. */
913
1331
  rightButton: boolean;
1332
+ /** `true` while the middle (wheel) mouse button is held. */
914
1333
  middleButton: boolean;
1334
+ /** Horizontal movement this frame in pixels. Resets to `0` each frame. */
915
1335
  deltaX: number;
1336
+ /** Vertical movement this frame in pixels. Resets to `0` each frame. */
916
1337
  deltaY: number;
1338
+ /** Vertical scroll accumulated this frame (alias of `wheelY`). Resets to `0` each frame. */
917
1339
  wheelDelta: number;
1340
+ /** Horizontal scroll accumulated this frame (e.g., trackpad gestures, tilt-wheel mice). Resets to `0` each frame. */
918
1341
  wheelX: number;
1342
+ /** Vertical scroll accumulated this frame. Resets to `0` each frame. */
919
1343
  wheelY: number;
1344
+ /** `true` for exactly one frame when any button is first pressed, then auto-resets. */
920
1345
  wasPressed: boolean;
1346
+ /** `true` for exactly one frame when any button is released, then auto-resets. */
921
1347
  wasReleased: boolean;
1348
+ /** `true` if the mouse moved this frame (any non-zero `deltaX` / `deltaY`). Resets each frame. */
922
1349
  wasMoved: boolean;
923
1350
  }
924
1351
 
@@ -933,24 +1360,47 @@ export declare interface MouseEventData {
933
1360
  isInCanvas?: boolean;
934
1361
  }
935
1362
 
1363
+ /**
1364
+ * Configuration object passed to `viji.number()`. Defines the bounds, step,
1365
+ * label, and UI grouping/visibility for a precise numeric input.
1366
+ */
936
1367
  declare interface NumberConfig {
1368
+ /** Inclusive minimum value. Default: `0`. */
937
1369
  min?: number;
1370
+ /** Inclusive maximum value. Default: `100`. */
938
1371
  max?: number;
1372
+ /** Increment between values. Default: `1`. */
939
1373
  step?: number;
1374
+ /** Display name shown next to the input in the parameter UI. Required. */
940
1375
  label: string;
1376
+ /** Optional tooltip / help text shown next to the control. */
941
1377
  description?: string;
1378
+ /** Group name for organizing related parameters under a shared heading. Default: `'general'`. */
942
1379
  group?: string;
1380
+ /** Visibility category — the control hides when its capability is unavailable. Default: `'general'`. */
943
1381
  category?: ParameterCategory;
944
1382
  }
945
1383
 
1384
+ /**
1385
+ * Reactive object returned by `viji.number()`. Like `SliderParameter` but the
1386
+ * host UI renders a precise numeric input rather than a draggable slider.
1387
+ */
946
1388
  declare interface NumberParameter {
1389
+ /** Current numeric value in the configured `min..max` range. Updates in real-time. */
947
1390
  value: number;
1391
+ /** Inclusive minimum value. */
948
1392
  min: number;
1393
+ /** Inclusive maximum value. */
949
1394
  max: number;
1395
+ /** Increment between values. */
950
1396
  step: number;
1397
+ /** Display name shown next to the input in the parameter UI. */
951
1398
  label: string;
1399
+ /** Tooltip / help text for the control (empty string when not configured). */
952
1400
  description?: string;
1401
+ /** Group name under which the control appears in the UI. */
953
1402
  group: string;
1403
+ /** Visibility category — controls when the parameter is shown. */
954
1404
  category: ParameterCategory;
955
1405
  }
956
1406
 
@@ -963,6 +1413,11 @@ export declare interface ParameterAPI {
963
1413
  [key: string]: any;
964
1414
  }
965
1415
 
1416
+ /**
1417
+ * Visibility category for a parameter. The host hides parameters whose category
1418
+ * is not currently available (e.g., `'audio'` controls hide when no audio
1419
+ * source is connected). `'general'` parameters are always visible.
1420
+ */
966
1421
  declare type ParameterCategory = 'audio' | 'video' | 'interaction' | 'general';
967
1422
 
968
1423
  export declare interface ParameterConfig {
@@ -1052,141 +1507,290 @@ declare interface PLLState {
1052
1507
  driftRate: number;
1053
1508
  }
1054
1509
 
1510
+ /**
1511
+ * Unified pointer that abstracts mouse and primary touch into a single input
1512
+ * stream. Recommended for click / drag / position-tracking interactions that
1513
+ * should work identically on desktop and mobile.
1514
+ *
1515
+ * Use `viji.mouse` for mouse-specific features (right click, middle click,
1516
+ * scroll wheel); use `viji.touches` for multi-touch, pressure, or radius.
1517
+ */
1055
1518
  declare interface PointerAPI {
1519
+ /** Canvas-space X position in pixels. */
1056
1520
  x: number;
1521
+ /** Canvas-space Y position in pixels. */
1057
1522
  y: number;
1523
+ /** Horizontal movement since the last frame in pixels. */
1058
1524
  deltaX: number;
1525
+ /** Vertical movement since the last frame in pixels. */
1059
1526
  deltaY: number;
1527
+ /** `true` while the pointer is "down" — left mouse button held, or a touch active. */
1060
1528
  isDown: boolean;
1529
+ /** `true` for exactly one frame when the pointer becomes down, then auto-resets. */
1061
1530
  wasPressed: boolean;
1531
+ /** `true` for exactly one frame when the pointer is released, then auto-resets. */
1062
1532
  wasReleased: boolean;
1533
+ /** `true` while the pointer is within the canvas bounds. */
1063
1534
  isInCanvas: boolean;
1535
+ /** Currently active input source — `'touch'` when at least one touch is active, otherwise `'mouse'` (or `'none'` when the cursor is off-canvas). */
1064
1536
  type: 'mouse' | 'touch' | 'none';
1065
1537
  }
1066
1538
 
1539
+ /**
1540
+ * Detected body pose from MediaPipe BlazePose. `landmarks` contains 33 points;
1541
+ * the `face` / `torso` / `leftArm` / `rightArm` / `leftLeg` / `rightLeg` arrays
1542
+ * are pre-grouped slices for convenience.
1543
+ */
1067
1544
  declare interface PoseData {
1545
+ /** Average landmark visibility in 0..1. */
1068
1546
  confidence: number;
1547
+ /** 33 BlazePose landmarks, normalized 0..1. Each carries a per-point `visibility` score. */
1069
1548
  landmarks: {
1549
+ /** Horizontal landmark coordinate, normalized 0..1. */
1070
1550
  x: number;
1551
+ /** Vertical landmark coordinate, normalized 0..1. */
1071
1552
  y: number;
1553
+ /** Depth (relative). */
1072
1554
  z: number;
1555
+ /** Visibility / confidence of this individual landmark in 0..1. */
1073
1556
  visibility: number;
1074
1557
  }[];
1558
+ /** Face landmarks (BlazePose indices 0..10). Coordinates normalized 0..1. */
1075
1559
  face: {
1560
+ /** Horizontal landmark coordinate, normalized 0..1. */
1076
1561
  x: number;
1562
+ /** Vertical landmark coordinate, normalized 0..1. */
1077
1563
  y: number;
1078
1564
  }[];
1565
+ /** Torso landmarks (BlazePose indices 11, 12, 23, 24). Coordinates normalized 0..1. */
1079
1566
  torso: {
1567
+ /** Horizontal landmark coordinate, normalized 0..1. */
1080
1568
  x: number;
1569
+ /** Vertical landmark coordinate, normalized 0..1. */
1081
1570
  y: number;
1082
1571
  }[];
1572
+ /** Left-arm landmarks (BlazePose indices 11, 13, 15). Coordinates normalized 0..1. */
1083
1573
  leftArm: {
1574
+ /** Horizontal landmark coordinate, normalized 0..1. */
1084
1575
  x: number;
1576
+ /** Vertical landmark coordinate, normalized 0..1. */
1085
1577
  y: number;
1086
1578
  }[];
1579
+ /** Right-arm landmarks (BlazePose indices 12, 14, 16). Coordinates normalized 0..1. */
1087
1580
  rightArm: {
1581
+ /** Horizontal landmark coordinate, normalized 0..1. */
1088
1582
  x: number;
1583
+ /** Vertical landmark coordinate, normalized 0..1. */
1089
1584
  y: number;
1090
1585
  }[];
1586
+ /** Left-leg landmarks (BlazePose indices 23, 25, 27, 29, 31). Coordinates normalized 0..1. */
1091
1587
  leftLeg: {
1588
+ /** Horizontal landmark coordinate, normalized 0..1. */
1092
1589
  x: number;
1590
+ /** Vertical landmark coordinate, normalized 0..1. */
1093
1591
  y: number;
1094
1592
  }[];
1593
+ /** Right-leg landmarks (BlazePose indices 24, 26, 28, 30, 32). Coordinates normalized 0..1. */
1095
1594
  rightLeg: {
1595
+ /** Horizontal landmark coordinate, normalized 0..1. */
1096
1596
  x: number;
1597
+ /** Vertical landmark coordinate, normalized 0..1. */
1097
1598
  y: number;
1098
1599
  }[];
1099
1600
  }
1100
1601
 
1101
1602
  declare type RendererType = 'native' | 'p5' | 'shader';
1102
1603
 
1604
+ /**
1605
+ * Discrete pixel dimensions for a canvas, frame capture, or render target.
1606
+ */
1103
1607
  export declare type Resolution = {
1608
+ /** Width in pixels (positive integer). */
1104
1609
  width: number;
1610
+ /** Height in pixels (positive integer). */
1105
1611
  height: number;
1106
1612
  };
1107
1613
 
1614
+ /**
1615
+ * Per-pixel person/background segmentation mask. Mask dimensions reflect the
1616
+ * ML model's output and may differ from the source video frame.
1617
+ */
1108
1618
  declare interface SegmentationData {
1619
+ /** Flat per-pixel mask: each byte is `0` (background) or `1` (person). Length = `width * height`. */
1109
1620
  mask: Uint8Array;
1621
+ /** Mask width in pixels. */
1110
1622
  width: number;
1623
+ /** Mask height in pixels. */
1111
1624
  height: number;
1112
1625
  }
1113
1626
 
1627
+ /**
1628
+ * Configuration object passed to `viji.select()`. The host renders the choices
1629
+ * as a dropdown or segmented control.
1630
+ */
1114
1631
  declare interface SelectConfig {
1632
+ /** Available choices. The element type (`string` or `number`) becomes the parameter's value type. Required. */
1115
1633
  options: string[] | number[];
1634
+ /** Display name shown next to the dropdown in the parameter UI. Required. */
1116
1635
  label: string;
1636
+ /** Optional tooltip / help text shown next to the control. */
1117
1637
  description?: string;
1638
+ /** Group name for organizing related parameters under a shared heading. Default: `'general'`. */
1118
1639
  group?: string;
1640
+ /** Visibility category — the control hides when its capability is unavailable. Default: `'general'`. */
1119
1641
  category?: ParameterCategory;
1120
1642
  }
1121
1643
 
1644
+ /**
1645
+ * Reactive object returned by `viji.select()`. `value` matches the element type
1646
+ * of the configured `options` array (`string` or `number`).
1647
+ */
1122
1648
  declare interface SelectParameter {
1649
+ /** Currently selected option. Updates in real-time when the user changes the selection. */
1123
1650
  value: string | number;
1651
+ /** The full list of choices originally configured. */
1124
1652
  options: string[] | number[];
1653
+ /** Display name shown next to the dropdown in the parameter UI. */
1125
1654
  label: string;
1655
+ /** Tooltip / help text for the control (empty string when not configured). */
1126
1656
  description?: string;
1657
+ /** Group name under which the control appears in the UI. */
1127
1658
  group: string;
1659
+ /** Visibility category — controls when the parameter is shown. */
1128
1660
  category: ParameterCategory;
1129
1661
  }
1130
1662
 
1663
+ /**
1664
+ * Configuration object passed to `viji.slider()`. Defines the slider's bounds,
1665
+ * increment, label, and UI grouping/visibility.
1666
+ */
1131
1667
  declare interface SliderConfig {
1668
+ /** Inclusive minimum value of the slider. Default: `0`. */
1132
1669
  min?: number;
1670
+ /** Inclusive maximum value of the slider. Default: `100`. */
1133
1671
  max?: number;
1672
+ /** Increment between values. Default: `1`. */
1134
1673
  step?: number;
1674
+ /** Display name shown next to the control in the parameter UI. Required. */
1135
1675
  label: string;
1676
+ /** Optional tooltip / help text shown next to the control. */
1136
1677
  description?: string;
1678
+ /** Group name for organizing related parameters under a shared heading. Default: `'general'`. */
1137
1679
  group?: string;
1680
+ /** Visibility category — the control hides when its capability is unavailable. Default: `'general'`. */
1138
1681
  category?: ParameterCategory;
1139
1682
  }
1140
1683
 
1684
+ /**
1685
+ * Reactive object returned by `viji.slider()`. `value` updates in real-time as
1686
+ * the user drags the control; the remaining fields mirror the configuration.
1687
+ */
1141
1688
  declare interface SliderParameter {
1689
+ /** Current slider value in the configured `min..max` range. Updates in real-time. */
1142
1690
  value: number;
1691
+ /** Inclusive minimum value of the slider. */
1143
1692
  min: number;
1693
+ /** Inclusive maximum value of the slider. */
1144
1694
  max: number;
1695
+ /** Increment between values. */
1145
1696
  step: number;
1697
+ /** Display name shown next to the control in the parameter UI. */
1146
1698
  label: string;
1699
+ /** Tooltip / help text for the control (empty string when not configured). */
1147
1700
  description?: string;
1701
+ /** Group name under which the control appears in the UI. */
1148
1702
  group: string;
1703
+ /** Visibility category — controls when the parameter is shown. */
1149
1704
  category: ParameterCategory;
1150
1705
  }
1151
1706
 
1707
+ /**
1708
+ * Configuration object passed to `viji.text()`. The host renders a single-line
1709
+ * text input field.
1710
+ */
1152
1711
  declare interface TextConfig {
1712
+ /** Display name shown next to the text field in the parameter UI. Required. */
1153
1713
  label: string;
1714
+ /** Optional tooltip / help text shown next to the control. */
1154
1715
  description?: string;
1716
+ /** Group name for organizing related parameters under a shared heading. Default: `'general'`. */
1155
1717
  group?: string;
1718
+ /** Visibility category — the control hides when its capability is unavailable. Default: `'general'`. */
1156
1719
  category?: ParameterCategory;
1720
+ /** Maximum character count enforced by the host UI. Default: `1000`. */
1157
1721
  maxLength?: number;
1158
1722
  }
1159
1723
 
1724
+ /**
1725
+ * Reactive object returned by `viji.text()`. `value` updates as the user types
1726
+ * and is enforced to be no longer than `maxLength` by the host UI.
1727
+ */
1160
1728
  declare interface TextParameter {
1729
+ /** Current text content. Updates in real-time as the user types. */
1161
1730
  value: string;
1731
+ /** Maximum character count enforced by the host UI. */
1162
1732
  maxLength?: number;
1733
+ /** Display name shown next to the input in the parameter UI. */
1163
1734
  label: string;
1735
+ /** Tooltip / help text for the control (empty string when not configured). */
1164
1736
  description?: string;
1737
+ /** Group name under which the control appears in the UI. */
1165
1738
  group: string;
1739
+ /** Visibility category — controls when the parameter is shown. */
1166
1740
  category: ParameterCategory;
1167
1741
  }
1168
1742
 
1743
+ /**
1744
+ * Configuration object passed to `viji.toggle()`. Defines the on/off switch's
1745
+ * label and UI grouping/visibility.
1746
+ */
1169
1747
  declare interface ToggleConfig {
1748
+ /** Display name shown next to the switch in the parameter UI. Required. */
1170
1749
  label: string;
1750
+ /** Optional tooltip / help text shown next to the control. */
1171
1751
  description?: string;
1752
+ /** Group name for organizing related parameters under a shared heading. Default: `'general'`. */
1172
1753
  group?: string;
1754
+ /** Visibility category — the control hides when its capability is unavailable. Default: `'general'`. */
1173
1755
  category?: ParameterCategory;
1174
1756
  }
1175
1757
 
1758
+ /**
1759
+ * Reactive object returned by `viji.toggle()`. `value` flips between `true`
1760
+ * and `false` as the user interacts with the switch.
1761
+ */
1176
1762
  declare interface ToggleParameter {
1763
+ /** Current state of the switch. Updates in real-time when the user toggles it. */
1177
1764
  value: boolean;
1765
+ /** Display name shown next to the switch in the parameter UI. */
1178
1766
  label: string;
1767
+ /** Tooltip / help text for the control (empty string when not configured). */
1179
1768
  description?: string;
1769
+ /** Group name under which the control appears in the UI. */
1180
1770
  group: string;
1771
+ /** Visibility category — controls when the parameter is shown. */
1181
1772
  category: ParameterCategory;
1182
1773
  }
1183
1774
 
1775
+ /**
1776
+ * Multi-touch input state. Lists all active touches, plus per-frame
1777
+ * `started` / `moved` / `ended` arrays for frame-based gesture handling.
1778
+ *
1779
+ * For single-point interactions that should also work with a mouse, prefer
1780
+ * `viji.pointer` — it switches automatically between mouse and primary touch.
1781
+ */
1184
1782
  export declare interface TouchAPI {
1783
+ /** All currently active touch points. Order is stable but not ordered by id. */
1185
1784
  points: TouchPoint[];
1785
+ /** Number of currently active touches (equivalent to `points.length`). */
1186
1786
  count: number;
1787
+ /** Touches that started this frame (also visible in `points`). Cleared each frame. */
1187
1788
  started: TouchPoint[];
1789
+ /** Touches that moved this frame. Cleared each frame. */
1188
1790
  moved: TouchPoint[];
1791
+ /** Touches that ended this frame. Each entry has `isEnding === true`. Cleared each frame. */
1189
1792
  ended: TouchPoint[];
1793
+ /** Convenience shortcut to `points[0]`, or `null` when no touches are active. */
1190
1794
  primary: TouchPoint | null;
1191
1795
  }
1192
1796
 
@@ -1204,25 +1808,52 @@ export declare interface TouchEventData {
1204
1808
  }>;
1205
1809
  }
1206
1810
 
1811
+ /**
1812
+ * One active touch contact reported by `TouchAPI`. Position, pressure, radius,
1813
+ * rotation, per-frame movement, velocity, and lifecycle flags. Coordinates are
1814
+ * in canvas-space pixels.
1815
+ *
1816
+ * Some fields (notably `pressure` / `force`, `radiusX` / `radiusY`,
1817
+ * `rotationAngle`) are passed through from the device — values vary by
1818
+ * platform; many devices report `0` when unsupported.
1819
+ */
1207
1820
  declare interface TouchPoint {
1821
+ /** Stable touch identifier across frames for the duration of this contact. */
1208
1822
  id: number;
1823
+ /** Canvas-space X position in pixels. */
1209
1824
  x: number;
1825
+ /** Canvas-space Y position in pixels. */
1210
1826
  y: number;
1827
+ /** Touch pressure in 0..1 (device-dependent; often `0` on devices without force support). */
1211
1828
  pressure: number;
1829
+ /** Contact radius — `Math.max(radiusX, radiusY)` in pixels. */
1212
1830
  radius: number;
1831
+ /** Horizontal contact radius in pixels (raw device value). */
1213
1832
  radiusX: number;
1833
+ /** Vertical contact radius in pixels (raw device value). */
1214
1834
  radiusY: number;
1835
+ /** Contact area rotation in radians (raw device value). */
1215
1836
  rotationAngle: number;
1837
+ /** Touch force in 0..1 — alias of `pressure`. */
1216
1838
  force: number;
1839
+ /** `true` while the touch position is within the canvas bounds. */
1217
1840
  isInCanvas: boolean;
1841
+ /** Horizontal movement since the last frame in pixels. */
1218
1842
  deltaX: number;
1843
+ /** Vertical movement since the last frame in pixels. */
1219
1844
  deltaY: number;
1845
+ /** Movement velocity in pixels per second, computed by Viji. */
1220
1846
  velocity: {
1847
+ /** Horizontal velocity component in pixels per second. */
1221
1848
  x: number;
1849
+ /** Vertical velocity component in pixels per second. */
1222
1850
  y: number;
1223
1851
  };
1852
+ /** `true` for exactly one frame when this touch starts, then auto-resets. */
1224
1853
  isNew: boolean;
1854
+ /** `true` while the touch is ongoing. */
1225
1855
  isActive: boolean;
1856
+ /** `true` for exactly one frame when this touch ends, then auto-resets. */
1226
1857
  isEnding: boolean;
1227
1858
  }
1228
1859
 
@@ -1234,25 +1865,81 @@ declare type TrackingState = 'TRACKING' | 'LOCKED' | 'BREAKDOWN' | 'LOST';
1234
1865
 
1235
1866
  export declare const VERSION = "0.3.29";
1236
1867
 
1868
+ /**
1869
+ * Real-time video API: drawable frame, dimensions, and computer-vision results
1870
+ * (faces, hands, pose, segmentation). Activate individual CV features through `cv.*`.
1871
+ *
1872
+ * When `isConnected` is `false`, `currentFrame` is `null`, all dimensions are `0`,
1873
+ * and CV result fields hold their empty defaults.
1874
+ */
1237
1875
  export declare interface VideoAPI {
1876
+ /** `true` when a video stream is connected. When `false`, all other fields hold their default empty values. */
1238
1877
  isConnected: boolean;
1878
+ /** Latest video frame, drawable directly with `ctx.drawImage()`. `null` when disconnected. */
1239
1879
  currentFrame: OffscreenCanvas | ImageBitmap | null;
1880
+ /** Source video frame width in pixels. `0` when disconnected. */
1240
1881
  frameWidth: number;
1882
+ /** Source video frame height in pixels. `0` when disconnected. */
1241
1883
  frameHeight: number;
1884
+ /** Source video frame rate in Hz (frames per second). `0` when disconnected. */
1242
1885
  frameRate: number;
1886
+ /**
1887
+ * Returns the latest frame as raw RGBA `ImageData` for per-pixel CPU analysis,
1888
+ * or `null` when disconnected. Slow compared to drawing `currentFrame` directly —
1889
+ * use only when you need to read individual pixel values.
1890
+ */
1243
1891
  getFrameData: () => ImageData | null;
1892
+ /** Detected faces (empty array when face detection is off or no faces are visible). */
1244
1893
  faces: FaceData[];
1894
+ /** Detected hands (up to 2; empty array when hand tracking is off or no hands are visible). */
1245
1895
  hands: HandData[];
1896
+ /** Detected body pose, or `null` when pose detection is off or no pose is visible. */
1246
1897
  pose: PoseData | null;
1898
+ /** Body segmentation mask, or `null` when segmentation is off. */
1247
1899
  segmentation: SegmentationData | null;
1900
+ /**
1901
+ * Computer-vision feature control. Each `enable*` method toggles a specific CV
1902
+ * pipeline; results land in the corresponding `faces` / `hands` / `pose` /
1903
+ * `segmentation` field on the next available frame. Multiple features can be
1904
+ * active simultaneously, but each adds CPU/GPU and WebGL-context cost.
1905
+ */
1248
1906
  cv: {
1907
+ /**
1908
+ * Toggle face detection (bounding box, center, confidence, id).
1909
+ * @returns Resolves once the underlying pipeline has finished switching.
1910
+ */
1249
1911
  enableFaceDetection(enabled: boolean): Promise<void>;
1912
+ /**
1913
+ * Toggle 468-point face mesh + head pose (`pitch`, `yaw`, `roll`). Implies
1914
+ * face detection.
1915
+ * @returns Resolves once the pipeline has finished switching.
1916
+ */
1250
1917
  enableFaceMesh(enabled: boolean): Promise<void>;
1918
+ /**
1919
+ * Toggle 7 expressions + 52 ARKit blendshape coefficients on each face.
1920
+ * Implies face mesh.
1921
+ * @returns Resolves once the pipeline has finished switching.
1922
+ */
1251
1923
  enableEmotionDetection(enabled: boolean): Promise<void>;
1924
+ /**
1925
+ * Toggle 21-point hand landmarks + ML-classified gesture confidences for up
1926
+ * to two hands.
1927
+ * @returns Resolves once the pipeline has finished switching.
1928
+ */
1252
1929
  enableHandTracking(enabled: boolean): Promise<void>;
1930
+ /**
1931
+ * Toggle 33-point BlazePose body landmarks (face / torso / arms / legs).
1932
+ * @returns Resolves once the pipeline has finished switching.
1933
+ */
1253
1934
  enablePoseDetection(enabled: boolean): Promise<void>;
1935
+ /**
1936
+ * Toggle per-pixel person/background segmentation mask.
1937
+ * @returns Resolves once the pipeline has finished switching.
1938
+ */
1254
1939
  enableBodySegmentation(enabled: boolean): Promise<void>;
1940
+ /** Returns the list of CV features currently enabled on this stream. */
1255
1941
  getActiveFeatures(): CVFeature[];
1942
+ /** Returns `true` if the CV worker is actively processing frames. */
1256
1943
  isProcessing(): boolean;
1257
1944
  };
1258
1945
  }
@@ -1266,37 +1953,157 @@ export declare interface VideoAPI {
1266
1953
  */
1267
1954
  export declare type VideoStreamType = 'main' | 'additional' | 'directFrame' | 'device';
1268
1955
 
1956
+ /**
1957
+ * The Viji API surface available to artist code as the global `viji` object.
1958
+ * Groups canvas access, timing, connected media APIs, user interaction, device
1959
+ * sensors, parameter helpers, and the `useContext()` selector.
1960
+ */
1269
1961
  export declare interface VijiAPI {
1962
+ /** The `OffscreenCanvas` driving the scene. The host owns its lifecycle and dimensions; prefer `useContext()` over touching this directly. */
1270
1963
  canvas: OffscreenCanvas;
1964
+ /** 2D rendering context. `undefined` until `viji.useContext('2d')` is called; afterwards equals the cached context. */
1271
1965
  ctx?: OffscreenCanvasRenderingContext2D;
1966
+ /** WebGL rendering context. `undefined` until `viji.useContext('webgl')` or `'webgl2'` is called; afterwards equals the cached context. */
1272
1967
  gl?: WebGLRenderingContext | WebGL2RenderingContext;
1968
+ /** Current canvas width in pixels. Updates automatically when the host resizes the canvas — read every frame. */
1273
1969
  width: number;
1970
+ /** Current canvas height in pixels. Updates automatically when the host resizes the canvas — read every frame. */
1274
1971
  height: number;
1972
+ /** Seconds elapsed since the scene started (monotonically increasing float). Use for oscillations and absolute-time effects. */
1275
1973
  time: number;
1974
+ /** Seconds since the previous frame. Use for accumulation: movement, physics, fades — anything that should progress per second regardless of FPS. */
1276
1975
  deltaTime: number;
1976
+ /** Integer frame counter starting at `0` and incrementing by `1` each frame. */
1277
1977
  frameCount: number;
1978
+ /** Target frames-per-second for the host's current frame-rate mode (`60` for `'full'`, `30` for `'half'`). */
1278
1979
  fps: number;
1980
+ /** Real-time analysis of the main audio stream: volume, frequency bands, beat detection, spectral features. Fields are zeroed when no audio source is connected. */
1279
1981
  audio: AudioAPI;
1982
+ /** Main video stream API: pixel access, frame metadata, and computer-vision results (face, hands, pose, segmentation). */
1280
1983
  video: VideoAPI;
1984
+ /** Additional video streams provided by the host. These do not run CV processing — use them for raw pixel access only. */
1281
1985
  videoStreams: VideoAPI[];
1986
+ /** Additional audio streams (lightweight analysis: volume, bands, spectral). No beat detection — use the main `audio` for that. */
1282
1987
  audioStreams: AudioStreamAPI[];
1988
+ /** Mouse position, buttons, wheel, and per-frame movement state. Coordinates are in canvas pixels. */
1283
1989
  mouse: MouseAPI;
1990
+ /** Keyboard state: per-frame press/release queries, currently held keys, and modifier flags. */
1284
1991
  keyboard: KeyboardAPI;
1992
+ /** Multi-touch state: count, primary touch shortcut, and the per-frame `started` / `moved` / `ended` arrays. */
1285
1993
  touches: TouchAPI;
1994
+ /** Unified pointer (mouse + primary touch) — convenient single-point input that works on both desktop and mobile. */
1286
1995
  pointer: PointerAPI;
1996
+ /** Internal device sensors (motion + orientation) reported by the device running the scene. */
1287
1997
  device: DeviceSensorState;
1998
+ /** External connected devices reporting sensor / camera / audio. Each entry has its own `id`, `name`, and per-device API surface. */
1288
1999
  devices: DeviceState[];
2000
+ /**
2001
+ * Declares a numeric slider parameter. The host UI renders a draggable slider.
2002
+ * Must be called at the top level of the scene — never inside `render()`.
2003
+ *
2004
+ * @example
2005
+ * const radius = viji.slider(50, { min: 10, max: 200, step: 1, label: 'Radius' });
2006
+ * // ...
2007
+ * function render(viji) { drawCircle(radius.value); }
2008
+ */
1289
2009
  slider: (defaultValue: number, config: SliderConfig) => SliderParameter;
1290
- color: (defaultValue: string, config: ColorConfig) => ColorParameter;
2010
+ /**
2011
+ * Declares a color parameter. Accepts hex strings, CSS color functions, or RGB / HSB objects;
2012
+ * the value is always normalized to a canonical lowercase hex string and exposes derived `.rgb` / `.hsb` accessors.
2013
+ * Must be called at the top level of the scene — never inside `render()`.
2014
+ *
2015
+ * @example
2016
+ * const tint = viji.color('#ff6600', { label: 'Tint' });
2017
+ * // tint.value -> '#ff6600', tint.rgb -> { r: 255, g: 102, b: 0 }, tint.hsb -> { h: 24, s: 100, b: 100 }
2018
+ */
2019
+ color: (defaultValue: ColorInput, config: ColorConfig) => ColorParameter;
2020
+ /**
2021
+ * Declares a boolean toggle parameter. The host UI renders an on/off switch.
2022
+ * Must be called at the top level of the scene — never inside `render()`.
2023
+ *
2024
+ * @example
2025
+ * const showTrail = viji.toggle(true, { label: 'Show Trail' });
2026
+ */
1291
2027
  toggle: (defaultValue: boolean, config: ToggleConfig) => ToggleParameter;
2028
+ /**
2029
+ * Declares a dropdown selection parameter. The element type of `options`
2030
+ * (`string` or `number`) determines the parameter's value type.
2031
+ * Must be called at the top level of the scene — never inside `render()`.
2032
+ *
2033
+ * @example
2034
+ * const shape = viji.select('circle', { options: ['circle', 'square', 'triangle'], label: 'Shape' });
2035
+ */
1292
2036
  select: (defaultValue: string | number, config: SelectConfig) => SelectParameter;
2037
+ /**
2038
+ * Declares a text input parameter. The host UI renders a single-line text field.
2039
+ * Must be called at the top level of the scene — never inside `render()`.
2040
+ *
2041
+ * @example
2042
+ * const caption = viji.text('Hello', { label: 'Caption', maxLength: 64 });
2043
+ */
1293
2044
  text: (defaultValue: string, config: TextConfig) => TextParameter;
2045
+ /**
2046
+ * Declares a precise numeric input parameter. Like `slider()` but the host UI
2047
+ * shows a number field instead of a draggable handle.
2048
+ * Must be called at the top level of the scene — never inside `render()`.
2049
+ *
2050
+ * @example
2051
+ * const count = viji.number(12, { min: 1, max: 64, step: 1, label: 'Count' });
2052
+ */
1294
2053
  number: (defaultValue: number, config: NumberConfig) => NumberParameter;
2054
+ /**
2055
+ * Declares an image upload parameter. The user-supplied image becomes available
2056
+ * as `value` (an `ImageBitmap`); in P5 scenes a `.p5` accessor is also added at runtime.
2057
+ * Must be called at the top level of the scene — never inside `render()`.
2058
+ *
2059
+ * @example
2060
+ * const tex = viji.image(null, { label: 'Texture' });
2061
+ * if (tex.value) ctx.drawImage(tex.value, 0, 0, viji.width, viji.height);
2062
+ */
1295
2063
  image: (defaultValue: null, config: ImageConfig) => ImageParameter;
2064
+ /**
2065
+ * Declares a momentary button parameter. `value` is `true` for one frame after
2066
+ * the user clicks, then auto-resets — perfect for triggering discrete events.
2067
+ * Must be called at the top level of the scene — never inside `render()`.
2068
+ *
2069
+ * @example
2070
+ * const reset = viji.button({ label: 'Reset' });
2071
+ * function render(viji) { if (reset.value) state = initialState; }
2072
+ */
1296
2073
  button: (config: ButtonConfig) => ButtonParameter;
2074
+ /**
2075
+ * Declares a 2D coordinate parameter. Both `value.x` and `value.y` are in `-1..1`.
2076
+ * Must be called at the top level of the scene — never inside `render()`.
2077
+ *
2078
+ * @example
2079
+ * const origin = viji.coordinate({ x: 0, y: 0 }, { label: 'Origin' });
2080
+ * const cx = viji.width / 2 + origin.value.x * viji.width * 0.4;
2081
+ */
1297
2082
  coordinate: (defaultValue: CoordinateValue, config: CoordinateConfig) => CoordinateParameter;
2083
+ /**
2084
+ * Selects the 2D canvas rendering context. Returns the same instance on
2085
+ * subsequent calls and also stores it on `viji.ctx`. A canvas only supports
2086
+ * one context type — if a different context type was already requested,
2087
+ * the call returns `null`. Choose ONE type and use it for the entire scene.
2088
+ *
2089
+ * @example
2090
+ * const ctx = viji.useContext('2d');
2091
+ * ctx.fillRect(0, 0, viji.width, viji.height);
2092
+ */
1298
2093
  useContext(type: '2d'): OffscreenCanvasRenderingContext2D | null;
2094
+ /**
2095
+ * Selects a WebGL 1 rendering context. Returns the same instance on subsequent
2096
+ * calls and also stores it on `viji.gl`. A canvas only supports one context
2097
+ * type — if a different context type was already requested, the call returns
2098
+ * `null`. Choose ONE type and use it for the entire scene.
2099
+ */
1299
2100
  useContext(type: 'webgl'): WebGLRenderingContext | null;
2101
+ /**
2102
+ * Selects a WebGL 2 rendering context. Returns the same instance on subsequent
2103
+ * calls and also stores it on `viji.gl`. A canvas only supports one context
2104
+ * type — if a different context type was already requested, the call returns
2105
+ * `null`. Choose ONE type and use it for the entire scene.
2106
+ */
1300
2107
  useContext(type: 'webgl2'): WebGL2RenderingContext | null;
1301
2108
  }
1302
2109
 
@@ -1454,11 +2261,20 @@ export declare class VijiCore {
1454
2261
  * Get parameter definition by name
1455
2262
  */
1456
2263
  private getParameterDefinition;
2264
+ /**
2265
+ * For color parameters, accept rich input forms (hex, RGB/HSB objects, CSS / GLSL strings)
2266
+ * and normalize them to canonical lowercase hex `#rrggbb` before they go on the wire.
2267
+ * This keeps the host<->worker contract simple (always a hex string) while letting
2268
+ * external callers use whichever form is most convenient.
2269
+ *
2270
+ * Non-color values are returned unchanged.
2271
+ */
2272
+ private normalizeColorInputIfNeeded;
1457
2273
  /**
1458
2274
  * Set a single parameter value
1459
2275
  * Handles all parameter types including images intelligently
1460
2276
  */
1461
- setParameter(name: string, value: ParameterValue | File | Blob): Promise<void>;
2277
+ setParameter(name: string, value: ParameterValue | ColorInput | File | Blob): Promise<void>;
1462
2278
  /**
1463
2279
  * Internal method to handle image parameter loading and transfer
1464
2280
  * Loads the image on the host side and creates TWO ImageBitmaps:
@@ -1467,9 +2283,12 @@ export declare class VijiCore {
1467
2283
  */
1468
2284
  private handleImageParameter;
1469
2285
  /**
1470
- * Set multiple parameter values efficiently
2286
+ * Set multiple parameter values efficiently.
2287
+ *
2288
+ * For color parameters, accepts the same rich input forms as `setParameter`
2289
+ * (hex, RGB/HSB objects, CSS / GLSL strings); they are normalized to canonical hex.
1471
2290
  */
1472
- setParameters(values: Record<string, ParameterValue>): Promise<void>;
2291
+ setParameters(values: Record<string, ParameterValue | ColorInput>): Promise<void>;
1473
2292
  /**
1474
2293
  * Get current parameter value
1475
2294
  */