@viji-dev/core 0.2.7 → 0.2.9
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/README.md +135 -2
- package/dist/artist-dts.js +1 -1
- package/dist/artist-global.d.ts +151 -6
- package/dist/artist-js-ambient.d.ts +66 -0
- package/dist/artist-jsdoc.d.ts +66 -0
- package/dist/assets/P5WorkerAdapter-bO_02bv6.js +345 -0
- package/dist/assets/P5WorkerAdapter-bO_02bv6.js.map +1 -0
- package/dist/assets/ShaderWorkerAdapter-Cn60jh9g.js +939 -0
- package/dist/assets/ShaderWorkerAdapter-Cn60jh9g.js.map +1 -0
- package/dist/assets/cv-tasks.worker.js +623 -0
- package/dist/assets/p5.min-BBA6UiVb.js +16810 -0
- package/dist/assets/p5.min-BBA6UiVb.js.map +1 -0
- package/dist/assets/viji.worker-Cbdf1a6N.js +2235 -0
- package/dist/assets/viji.worker-Cbdf1a6N.js.map +1 -0
- package/dist/assets/vision_bundle.js +2 -0
- package/dist/assets/wasm/vision_wasm_internal.js +20 -0
- package/dist/assets/wasm/vision_wasm_internal.wasm +0 -0
- package/dist/assets/wasm/vision_wasm_nosimd_internal.js +20 -0
- package/dist/assets/wasm/vision_wasm_nosimd_internal.wasm +0 -0
- package/dist/index.d.ts +182 -13
- package/dist/index.js +104 -22
- package/dist/index.js.map +1 -1
- package/package.json +13 -6
- package/dist/assets/viji.worker-BKsgIT1d.js +0 -1428
- package/dist/assets/viji.worker-BKsgIT1d.js.map +0 -1
package/README.md
CHANGED
|
@@ -183,8 +183,8 @@ console.log('Current frame rate mode:', config.frameRateMode);
|
|
|
183
183
|
|
|
184
184
|
```typescript
|
|
185
185
|
// Frame rate control
|
|
186
|
-
await core.
|
|
187
|
-
await core.
|
|
186
|
+
await core.setFrameRate('full'); // Set to 60fps mode
|
|
187
|
+
await core.setFrameRate('half'); // Set to 30fps mode
|
|
188
188
|
|
|
189
189
|
// Resolution control
|
|
190
190
|
await core.setResolution(0.75); // Set to 75% of container size
|
|
@@ -1018,6 +1018,139 @@ function render(viji) {
|
|
|
1018
1018
|
}
|
|
1019
1019
|
```
|
|
1020
1020
|
|
|
1021
|
+
## 🎨 P5.js Support
|
|
1022
|
+
|
|
1023
|
+
Viji Core supports **P5.js** as an optional rendering library. P5.js provides familiar creative coding APIs while maintaining all Viji features including audio reactivity, video processing, and parameter management.
|
|
1024
|
+
|
|
1025
|
+
### Enabling P5.js Mode
|
|
1026
|
+
|
|
1027
|
+
Add a single comment at the top of your scene code:
|
|
1028
|
+
|
|
1029
|
+
```javascript
|
|
1030
|
+
// @renderer p5
|
|
1031
|
+
|
|
1032
|
+
function setup(viji, p5) {
|
|
1033
|
+
p5.colorMode(p5.HSB);
|
|
1034
|
+
}
|
|
1035
|
+
|
|
1036
|
+
function render(viji, p5) {
|
|
1037
|
+
p5.background(220);
|
|
1038
|
+
p5.fill(255, 0, 0);
|
|
1039
|
+
p5.ellipse(viji.mouse.x, viji.mouse.y, 50, 50);
|
|
1040
|
+
}
|
|
1041
|
+
```
|
|
1042
|
+
|
|
1043
|
+
### What Works
|
|
1044
|
+
|
|
1045
|
+
- ✅ All P5.js drawing functions (shapes, colors, transforms, typography)
|
|
1046
|
+
- ✅ P5.js math utilities (`noise()`, `random()`, `map()`, `lerp()`)
|
|
1047
|
+
- ✅ P5.js vectors (`p5.Vector` class)
|
|
1048
|
+
- ✅ WebGL mode (`p5.WEBGL`)
|
|
1049
|
+
- ✅ Full Viji integration (audio, video, parameters, interaction)
|
|
1050
|
+
|
|
1051
|
+
### What Doesn't Work
|
|
1052
|
+
|
|
1053
|
+
- ❌ p5.dom (use Viji parameters instead)
|
|
1054
|
+
- ❌ p5.sound (use `viji.audio` instead)
|
|
1055
|
+
- ❌ P5.js events (use `viji.mouse`/`keyboard`/`touches` instead)
|
|
1056
|
+
- ❌ Direct image loading (use Viji image parameters instead)
|
|
1057
|
+
|
|
1058
|
+
### Audio Reactive P5.js Example
|
|
1059
|
+
|
|
1060
|
+
```javascript
|
|
1061
|
+
// @renderer p5
|
|
1062
|
+
|
|
1063
|
+
const audioReactive = viji.toggle(true, {
|
|
1064
|
+
label: 'Audio Reactive',
|
|
1065
|
+
category: 'audio'
|
|
1066
|
+
});
|
|
1067
|
+
|
|
1068
|
+
const bassReactivity = viji.slider(1.0, {
|
|
1069
|
+
min: 0,
|
|
1070
|
+
max: 3.0,
|
|
1071
|
+
label: 'Bass Reactivity',
|
|
1072
|
+
category: 'audio'
|
|
1073
|
+
});
|
|
1074
|
+
|
|
1075
|
+
function render(viji, p5) {
|
|
1076
|
+
p5.background(0);
|
|
1077
|
+
|
|
1078
|
+
if (audioReactive.value && viji.audio.isConnected) {
|
|
1079
|
+
const bass = viji.audio.bands.bass;
|
|
1080
|
+
const volume = viji.audio.volume.rms;
|
|
1081
|
+
|
|
1082
|
+
const hue = bass * 360 * bassReactivity.value;
|
|
1083
|
+
const size = 100 + volume * 200;
|
|
1084
|
+
|
|
1085
|
+
p5.colorMode(p5.HSB);
|
|
1086
|
+
p5.fill(hue, 80, 100);
|
|
1087
|
+
p5.ellipse(p5.width / 2, p5.height / 2, size, size);
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
1090
|
+
```
|
|
1091
|
+
|
|
1092
|
+
### Image Parameters
|
|
1093
|
+
|
|
1094
|
+
```javascript
|
|
1095
|
+
// @renderer p5
|
|
1096
|
+
|
|
1097
|
+
const bgImage = viji.image(null, {
|
|
1098
|
+
label: 'Background Image',
|
|
1099
|
+
group: 'media',
|
|
1100
|
+
accept: 'image/*'
|
|
1101
|
+
});
|
|
1102
|
+
|
|
1103
|
+
function render(viji, p5) {
|
|
1104
|
+
p5.background(220);
|
|
1105
|
+
|
|
1106
|
+
if (bgImage.value) {
|
|
1107
|
+
p5.image(bgImage.value, 0, 0, p5.width, p5.height);
|
|
1108
|
+
}
|
|
1109
|
+
|
|
1110
|
+
// Draw on top of image
|
|
1111
|
+
p5.fill(255, 0, 0, 128);
|
|
1112
|
+
p5.ellipse(viji.mouse.x, viji.mouse.y, 50, 50);
|
|
1113
|
+
}
|
|
1114
|
+
```
|
|
1115
|
+
|
|
1116
|
+
### Getting Renderer Type
|
|
1117
|
+
|
|
1118
|
+
```typescript
|
|
1119
|
+
const core = new VijiCore({
|
|
1120
|
+
hostContainer: container,
|
|
1121
|
+
sceneCode: sceneCode
|
|
1122
|
+
});
|
|
1123
|
+
|
|
1124
|
+
await core.initialize();
|
|
1125
|
+
|
|
1126
|
+
// Check which renderer is being used (from stats, like FPS/resolution)
|
|
1127
|
+
const stats = core.getStats();
|
|
1128
|
+
const rendererType = stats.rendererType; // 'native' | 'p5'
|
|
1129
|
+
```
|
|
1130
|
+
|
|
1131
|
+
### Loading Image Parameters
|
|
1132
|
+
|
|
1133
|
+
```typescript
|
|
1134
|
+
core.onParametersDefined((groups) => {
|
|
1135
|
+
groups.forEach(group => {
|
|
1136
|
+
Object.entries(group.parameters).forEach(([name, def]) => {
|
|
1137
|
+
if (def.type === 'image') {
|
|
1138
|
+
// Create file picker
|
|
1139
|
+
const input = createFileInput(name, def);
|
|
1140
|
+
input.addEventListener('change', async (e) => {
|
|
1141
|
+
const file = e.target.files[0];
|
|
1142
|
+
if (file) {
|
|
1143
|
+
await core.setParameter(name, file); // Unified API handles images automatically
|
|
1144
|
+
}
|
|
1145
|
+
});
|
|
1146
|
+
}
|
|
1147
|
+
});
|
|
1148
|
+
});
|
|
1149
|
+
});
|
|
1150
|
+
```
|
|
1151
|
+
|
|
1152
|
+
**See `docs/16-p5js-integration.md` for comprehensive documentation including migration guides, troubleshooting, and advanced examples.**
|
|
1153
|
+
|
|
1021
1154
|
## 🏗️ Architecture
|
|
1022
1155
|
|
|
1023
1156
|
### Security Model
|
package/dist/artist-dts.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const artistDts = "declare namespace VijiCore {\n declare interface AnalysisConfiguration {\r\n fftSize?: number;\r\n smoothing?: number;\r\n frequencyBands?: FrequencyBand[];\r\n beatDetection?: boolean;\r\n onsetDetection?: boolean;\r\n }\r\n\n declare interface AudioAPI {\r\n isConnected: boolean;\r\n volume: {\r\n rms: number;\r\n peak: number;\r\n };\r\n beat?: {\r\n isKick: boolean;\r\n confidence: number;\r\n };\r\n bands: Record<string, number>;\r\n getFrequencyData: () => Uint8Array;\r\n }\r\n\n declare interface CaptureFrameOptions {\r\n /** MIME type for output, e.g., 'image/png', 'image/jpeg', 'image/webp' */\r\n type?: string;\r\n /**\r\n * Target resolution.\r\n * - number: scale factor relative to current canvas size (e.g., 0.5 = 50%)\r\n * - { width, height }: exact output size; if aspect ratio differs from canvas,\r\n * the source is center-cropped to match the target aspect ratio before scaling\r\n */\r\n resolution?: number | {\r\n width: number;\r\n height: number;\r\n };\r\n }\r\n\n declare interface ColorConfig {\r\n label: string;\r\n description?: string;\r\n group?: string;\r\n category?: ParameterCategory;\r\n }\r\n\n declare interface ColorParameter {\r\n value: string;\r\n label: string;\r\n description?: string;\r\n group: string;\r\n category: ParameterCategory;\r\n }\r\n\n declare interface FaceData {\r\n bounds: {\r\n x: number;\r\n y: number;\r\n width: number;\r\n height: number;\r\n };\r\n confidence: number;\r\n landmarks: {\r\n x: number;\r\n y: number;\r\n }[];\r\n expressions: Record<string, number>;\r\n }\r\n\n declare type FrameRateMode = 'full' | 'half';\r\n\n declare interface FrequencyBand {\r\n name: string;\r\n min: number;\r\n max: number;\r\n }\r\n\n declare interface HandData {\r\n palm: {\r\n x: number;\r\n y: number;\r\n };\r\n fingers: {\r\n x: number;\r\n y: number;\r\n }[];\r\n gestures: Record<string, boolean>;\r\n }\r\n\n declare interface KeyboardAPI {\r\n isPressed(key: string): boolean;\r\n wasPressed(key: string): boolean;\r\n wasReleased(key: string): boolean;\r\n activeKeys: Set<string>;\r\n pressedThisFrame: Set<string>;\r\n releasedThisFrame: Set<string>;\r\n lastKeyPressed: string;\r\n lastKeyReleased: string;\r\n shift: boolean;\r\n ctrl: boolean;\r\n alt: boolean;\r\n meta: boolean;\r\n }\r\n\n declare interface MouseAPI {\r\n x: number;\r\n y: number;\r\n isInCanvas: boolean;\r\n isPressed: boolean;\r\n leftButton: boolean;\r\n rightButton: boolean;\r\n middleButton: boolean;\r\n velocity: {\r\n x: number;\r\n y: number;\r\n };\r\n deltaX: number;\r\n deltaY: number;\r\n wheelDelta: number;\r\n wheelX: number;\r\n wheelY: number;\r\n wasPressed: boolean;\r\n wasReleased: boolean;\r\n wasMoved: boolean;\r\n }\r\n\n declare interface NumberConfig {\r\n min?: number;\r\n max?: number;\r\n step?: number;\r\n label: string;\r\n description?: string;\r\n group?: string;\r\n category?: ParameterCategory;\r\n }\r\n\n declare interface NumberParameter {\r\n value: number;\r\n min: number;\r\n max: number;\r\n step: number;\r\n label: string;\r\n description?: string;\r\n group: string;\r\n category: ParameterCategory;\r\n }\r\n\n declare type ParameterCategory = 'audio' | 'video' | 'interaction' | 'general';\r\n\n declare type Resolution = {\r\n width: number;\r\n height: number;\r\n };\r\n\n declare interface SelectConfig {\r\n options: string[] | number[];\r\n label: string;\r\n description?: string;\r\n group?: string;\r\n category?: ParameterCategory;\r\n }\r\n\n declare interface SelectParameter {\r\n value: string | number;\r\n options: string[] | number[];\r\n label: string;\r\n description?: string;\r\n group: string;\r\n category: ParameterCategory;\r\n }\r\n\n declare interface SliderConfig {\r\n min?: number;\r\n max?: number;\r\n step?: number;\r\n label: string;\r\n description?: string;\r\n group?: string;\r\n category?: ParameterCategory;\r\n }\r\n\n declare interface SliderParameter {\r\n value: number;\r\n min: number;\r\n max: number;\r\n step: number;\r\n label: string;\r\n description?: string;\r\n group: string;\r\n category: ParameterCategory;\r\n }\r\n\n declare interface TextConfig {\r\n label: string;\r\n description?: string;\r\n group?: string;\r\n category?: ParameterCategory;\r\n maxLength?: number;\r\n }\r\n\n declare interface TextParameter {\r\n value: string;\r\n maxLength?: number;\r\n label: string;\r\n description?: string;\r\n group: string;\r\n category: ParameterCategory;\r\n }\r\n\n declare interface ToggleConfig {\r\n label: string;\r\n description?: string;\r\n group?: string;\r\n category?: ParameterCategory;\r\n }\r\n\n declare interface ToggleParameter {\r\n value: boolean;\r\n label: string;\r\n description?: string;\r\n group: string;\r\n category: ParameterCategory;\r\n }\r\n\n declare interface TouchAPI {\r\n points: TouchPoint[];\r\n count: number;\r\n started: TouchPoint[];\r\n moved: TouchPoint[];\r\n ended: TouchPoint[];\r\n primary: TouchPoint | null;\r\n gestures: TouchGestureAPI;\r\n }\r\n\n declare interface TouchGestureAPI {\r\n isPinching: boolean;\r\n isRotating: boolean;\r\n isPanning: boolean;\r\n isTapping: boolean;\r\n pinchScale: number;\r\n pinchDelta: number;\r\n rotationAngle: number;\r\n rotationDelta: number;\r\n panDelta: {\r\n x: number;\r\n y: number;\r\n };\r\n tapCount: number;\r\n lastTapTime: number;\r\n tapPosition: {\r\n x: number;\r\n y: number;\r\n } | null;\r\n }\r\n\n declare interface TouchPoint {\r\n id: number;\r\n x: number;\r\n y: number;\r\n pressure: number;\r\n radius: number;\r\n radiusX: number;\r\n radiusY: number;\r\n rotationAngle: number;\r\n force: number;\r\n deltaX: number;\r\n deltaY: number;\r\n velocity: {\r\n x: number;\r\n y: number;\r\n };\r\n isNew: boolean;\r\n isActive: boolean;\r\n isEnding: boolean;\r\n }\r\n\n declare const VERSION = \"0.2.4\";\r\n\n declare interface VideoAPI {\r\n isConnected: boolean;\r\n currentFrame: OffscreenCanvas | null;\r\n frameWidth: number;\r\n frameHeight: number;\r\n frameRate: number;\r\n getFrameData: () => ImageData | null;\r\n faces: FaceData[];\r\n hands: HandData[];\r\n }\r\n\n declare interface VijiAPI {\r\n canvas: OffscreenCanvas;\r\n ctx?: OffscreenCanvasRenderingContext2D;\r\n gl?: WebGL2RenderingContext;\r\n width: number;\r\n height: number;\r\n pixelRatio: number;\r\n time: number;\r\n deltaTime: number;\r\n frameCount: number;\r\n fps: number;\r\n audio: AudioAPI;\r\n video: VideoAPI;\r\n mouse: MouseAPI;\r\n keyboard: KeyboardAPI;\r\n touches: TouchAPI;\r\n slider: (defaultValue: number, config: SliderConfig) => SliderParameter;\r\n color: (defaultValue: string, config: ColorConfig) => ColorParameter;\r\n toggle: (defaultValue: boolean, config: ToggleConfig) => ToggleParameter;\r\n select: (defaultValue: string | number, config: SelectConfig) => SelectParameter;\r\n text: (defaultValue: string, config: TextConfig) => TextParameter;\r\n number: (defaultValue: number, config: NumberConfig) => NumberParameter;\r\n useContext(type: '2d'): OffscreenCanvasRenderingContext2D;\n useContext(type: 'webgl'): WebGLRenderingContext | WebGL2RenderingContext;\r\n }\r\n}\n\ndeclare const viji: VijiCore.VijiAPI;\ndeclare function render(viji: VijiCore.VijiAPI): void;\n";
|
|
1
|
+
export const artistDts = "declare namespace VijiCore {\n declare interface AnalysisConfiguration {\r\n fftSize?: number;\r\n smoothing?: number;\r\n frequencyBands?: FrequencyBand[];\r\n beatDetection?: boolean;\r\n onsetDetection?: boolean;\r\n }\r\n\n declare interface AudioAPI {\r\n isConnected: boolean;\r\n volume: {\r\n rms: number;\r\n peak: number;\r\n };\r\n beat?: {\r\n isKick: boolean;\r\n confidence: number;\r\n };\r\n bands: Record<string, number>;\r\n getFrequencyData: () => Uint8Array;\r\n }\r\n\n declare interface CaptureFrameOptions {\r\n /** MIME type for output, e.g., 'image/png', 'image/jpeg', 'image/webp' */\r\n type?: string;\r\n /**\r\n * Target resolution.\r\n * - number: scale factor relative to current canvas size (e.g., 0.5 = 50%)\r\n * - { width, height }: exact output size; if aspect ratio differs from canvas,\r\n * the source is center-cropped to match the target aspect ratio before scaling\r\n */\r\n resolution?: number | {\r\n width: number;\r\n height: number;\r\n };\r\n }\r\n\n declare interface ColorConfig {\r\n label: string;\r\n description?: string;\r\n group?: string;\r\n category?: ParameterCategory;\r\n }\r\n\n declare interface ColorParameter {\r\n value: string;\r\n label: string;\r\n description?: string;\r\n group: string;\r\n category: ParameterCategory;\r\n }\r\n\n declare type CVFeature = 'faceDetection' | 'faceMesh' | 'handTracking' | 'poseDetection' | 'bodySegmentation';\r\n\n declare type CVFrameRateMode = 'full' | 'half' | 'quarter' | 'eighth';\r\n\n declare interface FaceData {\r\n id: number;\r\n bounds: {\r\n x: number;\r\n y: number;\r\n width: number;\r\n height: number;\r\n };\r\n confidence: number;\r\n landmarks?: {\r\n x: number;\r\n y: number;\r\n z?: number;\r\n }[];\r\n expressions: {\r\n neutral: number;\r\n happy: number;\r\n sad: number;\r\n angry: number;\r\n surprised: number;\r\n disgusted: number;\r\n fearful: number;\r\n };\r\n headPose: {\r\n pitch: number;\r\n yaw: number;\r\n roll: number;\r\n };\r\n }\r\n\n declare type FrameRateMode = 'full' | 'half';\r\n\n declare interface FrequencyBand {\r\n name: string;\r\n min: number;\r\n max: number;\r\n }\r\n\n declare interface HandData {\r\n id: number;\r\n handedness: 'left' | 'right';\r\n confidence: number;\r\n bounds: {\r\n x: number;\r\n y: number;\r\n width: number;\r\n height: number;\r\n };\r\n landmarks: {\r\n x: number;\r\n y: number;\r\n z: number;\r\n }[];\r\n palm: {\r\n x: number;\r\n y: number;\r\n z: number;\r\n };\r\n fingers: {\r\n thumb: {\r\n tip: {\r\n x: number;\r\n y: number;\r\n z: number;\r\n };\r\n extended: boolean;\r\n };\r\n index: {\r\n tip: {\r\n x: number;\r\n y: number;\r\n z: number;\r\n };\r\n extended: boolean;\r\n };\r\n middle: {\r\n tip: {\r\n x: number;\r\n y: number;\r\n z: number;\r\n };\r\n extended: boolean;\r\n };\r\n ring: {\r\n tip: {\r\n x: number;\r\n y: number;\r\n z: number;\r\n };\r\n extended: boolean;\r\n };\r\n pinky: {\r\n tip: {\r\n x: number;\r\n y: number;\r\n z: number;\r\n };\r\n extended: boolean;\r\n };\r\n };\r\n gestures: {\r\n fist: number;\r\n openPalm: number;\r\n peace: number;\r\n thumbsUp: number;\r\n pointing: number;\r\n };\r\n }\r\n\n declare interface ImageConfig {\r\n label: string;\r\n description?: string;\r\n group?: string;\r\n category?: ParameterCategory;\r\n }\r\n\n declare interface ImageParameter {\r\n value: ImageBitmap | OffscreenCanvas | null;\r\n label: string;\r\n description?: string;\r\n group: string;\r\n category: ParameterCategory;\r\n }\r\n\n declare interface KeyboardAPI {\r\n isPressed(key: string): boolean;\r\n wasPressed(key: string): boolean;\r\n wasReleased(key: string): boolean;\r\n activeKeys: Set<string>;\r\n pressedThisFrame: Set<string>;\r\n releasedThisFrame: Set<string>;\r\n lastKeyPressed: string;\r\n lastKeyReleased: string;\r\n shift: boolean;\r\n ctrl: boolean;\r\n alt: boolean;\r\n meta: boolean;\r\n }\r\n\n declare interface MouseAPI {\r\n x: number;\r\n y: number;\r\n isInCanvas: boolean;\r\n isPressed: boolean;\r\n leftButton: boolean;\r\n rightButton: boolean;\r\n middleButton: boolean;\r\n velocity: {\r\n x: number;\r\n y: number;\r\n };\r\n deltaX: number;\r\n deltaY: number;\r\n wheelDelta: number;\r\n wheelX: number;\r\n wheelY: number;\r\n wasPressed: boolean;\r\n wasReleased: boolean;\r\n wasMoved: boolean;\r\n }\r\n\n declare interface NumberConfig {\r\n min?: number;\r\n max?: number;\r\n step?: number;\r\n label: string;\r\n description?: string;\r\n group?: string;\r\n category?: ParameterCategory;\r\n }\r\n\n declare interface NumberParameter {\r\n value: number;\r\n min: number;\r\n max: number;\r\n step: number;\r\n label: string;\r\n description?: string;\r\n group: string;\r\n category: ParameterCategory;\r\n }\r\n\n declare type ParameterCategory = 'audio' | 'video' | 'interaction' | 'general';\r\n\n declare interface PoseData {\r\n confidence: number;\r\n landmarks: {\r\n x: number;\r\n y: number;\r\n z: number;\r\n visibility: number;\r\n }[];\r\n face: {\r\n x: number;\r\n y: number;\r\n }[];\r\n torso: {\r\n x: number;\r\n y: number;\r\n }[];\r\n leftArm: {\r\n x: number;\r\n y: number;\r\n }[];\r\n rightArm: {\r\n x: number;\r\n y: number;\r\n }[];\r\n leftLeg: {\r\n x: number;\r\n y: number;\r\n }[];\r\n rightLeg: {\r\n x: number;\r\n y: number;\r\n }[];\r\n }\r\n\n declare type Resolution = {\r\n width: number;\r\n height: number;\r\n };\r\n\n declare interface SegmentationData {\r\n mask: Uint8Array;\r\n width: number;\r\n height: number;\r\n }\r\n\n declare interface SelectConfig {\r\n options: string[] | number[];\r\n label: string;\r\n description?: string;\r\n group?: string;\r\n category?: ParameterCategory;\r\n }\r\n\n declare interface SelectParameter {\r\n value: string | number;\r\n options: string[] | number[];\r\n label: string;\r\n description?: string;\r\n group: string;\r\n category: ParameterCategory;\r\n }\r\n\n declare interface SliderConfig {\r\n min?: number;\r\n max?: number;\r\n step?: number;\r\n label: string;\r\n description?: string;\r\n group?: string;\r\n category?: ParameterCategory;\r\n }\r\n\n declare interface SliderParameter {\r\n value: number;\r\n min: number;\r\n max: number;\r\n step: number;\r\n label: string;\r\n description?: string;\r\n group: string;\r\n category: ParameterCategory;\r\n }\r\n\n declare interface TextConfig {\r\n label: string;\r\n description?: string;\r\n group?: string;\r\n category?: ParameterCategory;\r\n maxLength?: number;\r\n }\r\n\n declare interface TextParameter {\r\n value: string;\r\n maxLength?: number;\r\n label: string;\r\n description?: string;\r\n group: string;\r\n category: ParameterCategory;\r\n }\r\n\n declare interface ToggleConfig {\r\n label: string;\r\n description?: string;\r\n group?: string;\r\n category?: ParameterCategory;\r\n }\r\n\n declare interface ToggleParameter {\r\n value: boolean;\r\n label: string;\r\n description?: string;\r\n group: string;\r\n category: ParameterCategory;\r\n }\r\n\n declare interface TouchAPI {\r\n points: TouchPoint[];\r\n count: number;\r\n started: TouchPoint[];\r\n moved: TouchPoint[];\r\n ended: TouchPoint[];\r\n primary: TouchPoint | null;\r\n gestures: TouchGestureAPI;\r\n }\r\n\n declare interface TouchGestureAPI {\r\n isPinching: boolean;\r\n isRotating: boolean;\r\n isPanning: boolean;\r\n isTapping: boolean;\r\n pinchScale: number;\r\n pinchDelta: number;\r\n rotationAngle: number;\r\n rotationDelta: number;\r\n panDelta: {\r\n x: number;\r\n y: number;\r\n };\r\n tapCount: number;\r\n lastTapTime: number;\r\n tapPosition: {\r\n x: number;\r\n y: number;\r\n } | null;\r\n }\r\n\n declare interface TouchPoint {\r\n id: number;\r\n x: number;\r\n y: number;\r\n pressure: number;\r\n radius: number;\r\n radiusX: number;\r\n radiusY: number;\r\n rotationAngle: number;\r\n force: number;\r\n deltaX: number;\r\n deltaY: number;\r\n velocity: {\r\n x: number;\r\n y: number;\r\n };\r\n isNew: boolean;\r\n isActive: boolean;\r\n isEnding: boolean;\r\n }\r\n\n declare const VERSION = \"0.2.9\";\r\n\n declare interface VideoAPI {\r\n isConnected: boolean;\r\n currentFrame: OffscreenCanvas | null;\r\n frameWidth: number;\r\n frameHeight: number;\r\n frameRate: number;\r\n getFrameData: () => ImageData | null;\r\n faces: FaceData[];\r\n hands: HandData[];\r\n pose: PoseData | null;\r\n segmentation: SegmentationData | null;\r\n cv: {\r\n enableFaceDetection(enabled: boolean): Promise<void>;\r\n enableFaceMesh(enabled: boolean): Promise<void>;\r\n enableHandTracking(enabled: boolean): Promise<void>;\r\n enablePoseDetection(enabled: boolean): Promise<void>;\r\n enableBodySegmentation(enabled: boolean): Promise<void>;\r\n getActiveFeatures(): CVFeature[];\r\n isProcessing(): boolean;\r\n };\r\n }\r\n\n declare interface VijiAPI {\r\n canvas: OffscreenCanvas;\r\n ctx?: OffscreenCanvasRenderingContext2D;\r\n gl?: WebGL2RenderingContext;\r\n width: number;\r\n height: number;\r\n pixelRatio: number;\r\n time: number;\r\n deltaTime: number;\r\n frameCount: number;\r\n fps: number;\r\n audio: AudioAPI;\r\n video: VideoAPI;\r\n mouse: MouseAPI;\r\n keyboard: KeyboardAPI;\r\n touches: TouchAPI;\r\n slider: (defaultValue: number, config: SliderConfig) => SliderParameter;\r\n color: (defaultValue: string, config: ColorConfig) => ColorParameter;\r\n toggle: (defaultValue: boolean, config: ToggleConfig) => ToggleParameter;\r\n select: (defaultValue: string | number, config: SelectConfig) => SelectParameter;\r\n text: (defaultValue: string, config: TextConfig) => TextParameter;\r\n number: (defaultValue: number, config: NumberConfig) => NumberParameter;\r\n image: (defaultValue: null, config: ImageConfig) => ImageParameter;\r\n useContext(type: '2d'): OffscreenCanvasRenderingContext2D;\n useContext(type: 'webgl'): WebGLRenderingContext | WebGL2RenderingContext;\r\n }\r\n}\n\ndeclare const viji: VijiCore.VijiAPI;\ndeclare function render(viji: VijiCore.VijiAPI): void;\n";
|
package/dist/artist-global.d.ts
CHANGED
|
@@ -51,7 +51,12 @@ declare namespace VijiCore {
|
|
|
51
51
|
category: ParameterCategory;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
declare type CVFeature = 'faceDetection' | 'faceMesh' | 'handTracking' | 'poseDetection' | 'bodySegmentation';
|
|
55
|
+
|
|
56
|
+
declare type CVFrameRateMode = 'full' | 'half' | 'quarter' | 'eighth';
|
|
57
|
+
|
|
54
58
|
declare interface FaceData {
|
|
59
|
+
id: number;
|
|
55
60
|
bounds: {
|
|
56
61
|
x: number;
|
|
57
62
|
y: number;
|
|
@@ -59,11 +64,25 @@ declare namespace VijiCore {
|
|
|
59
64
|
height: number;
|
|
60
65
|
};
|
|
61
66
|
confidence: number;
|
|
62
|
-
landmarks
|
|
67
|
+
landmarks?: {
|
|
63
68
|
x: number;
|
|
64
69
|
y: number;
|
|
70
|
+
z?: number;
|
|
65
71
|
}[];
|
|
66
|
-
expressions:
|
|
72
|
+
expressions: {
|
|
73
|
+
neutral: number;
|
|
74
|
+
happy: number;
|
|
75
|
+
sad: number;
|
|
76
|
+
angry: number;
|
|
77
|
+
surprised: number;
|
|
78
|
+
disgusted: number;
|
|
79
|
+
fearful: number;
|
|
80
|
+
};
|
|
81
|
+
headPose: {
|
|
82
|
+
pitch: number;
|
|
83
|
+
yaw: number;
|
|
84
|
+
roll: number;
|
|
85
|
+
};
|
|
67
86
|
}
|
|
68
87
|
|
|
69
88
|
declare type FrameRateMode = 'full' | 'half';
|
|
@@ -75,15 +94,89 @@ declare namespace VijiCore {
|
|
|
75
94
|
}
|
|
76
95
|
|
|
77
96
|
declare interface HandData {
|
|
78
|
-
|
|
97
|
+
id: number;
|
|
98
|
+
handedness: 'left' | 'right';
|
|
99
|
+
confidence: number;
|
|
100
|
+
bounds: {
|
|
79
101
|
x: number;
|
|
80
102
|
y: number;
|
|
103
|
+
width: number;
|
|
104
|
+
height: number;
|
|
81
105
|
};
|
|
82
|
-
|
|
106
|
+
landmarks: {
|
|
83
107
|
x: number;
|
|
84
108
|
y: number;
|
|
109
|
+
z: number;
|
|
85
110
|
}[];
|
|
86
|
-
|
|
111
|
+
palm: {
|
|
112
|
+
x: number;
|
|
113
|
+
y: number;
|
|
114
|
+
z: number;
|
|
115
|
+
};
|
|
116
|
+
fingers: {
|
|
117
|
+
thumb: {
|
|
118
|
+
tip: {
|
|
119
|
+
x: number;
|
|
120
|
+
y: number;
|
|
121
|
+
z: number;
|
|
122
|
+
};
|
|
123
|
+
extended: boolean;
|
|
124
|
+
};
|
|
125
|
+
index: {
|
|
126
|
+
tip: {
|
|
127
|
+
x: number;
|
|
128
|
+
y: number;
|
|
129
|
+
z: number;
|
|
130
|
+
};
|
|
131
|
+
extended: boolean;
|
|
132
|
+
};
|
|
133
|
+
middle: {
|
|
134
|
+
tip: {
|
|
135
|
+
x: number;
|
|
136
|
+
y: number;
|
|
137
|
+
z: number;
|
|
138
|
+
};
|
|
139
|
+
extended: boolean;
|
|
140
|
+
};
|
|
141
|
+
ring: {
|
|
142
|
+
tip: {
|
|
143
|
+
x: number;
|
|
144
|
+
y: number;
|
|
145
|
+
z: number;
|
|
146
|
+
};
|
|
147
|
+
extended: boolean;
|
|
148
|
+
};
|
|
149
|
+
pinky: {
|
|
150
|
+
tip: {
|
|
151
|
+
x: number;
|
|
152
|
+
y: number;
|
|
153
|
+
z: number;
|
|
154
|
+
};
|
|
155
|
+
extended: boolean;
|
|
156
|
+
};
|
|
157
|
+
};
|
|
158
|
+
gestures: {
|
|
159
|
+
fist: number;
|
|
160
|
+
openPalm: number;
|
|
161
|
+
peace: number;
|
|
162
|
+
thumbsUp: number;
|
|
163
|
+
pointing: number;
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
declare interface ImageConfig {
|
|
168
|
+
label: string;
|
|
169
|
+
description?: string;
|
|
170
|
+
group?: string;
|
|
171
|
+
category?: ParameterCategory;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
declare interface ImageParameter {
|
|
175
|
+
value: ImageBitmap | OffscreenCanvas | null;
|
|
176
|
+
label: string;
|
|
177
|
+
description?: string;
|
|
178
|
+
group: string;
|
|
179
|
+
category: ParameterCategory;
|
|
87
180
|
}
|
|
88
181
|
|
|
89
182
|
declare interface KeyboardAPI {
|
|
@@ -146,11 +239,51 @@ declare namespace VijiCore {
|
|
|
146
239
|
|
|
147
240
|
declare type ParameterCategory = 'audio' | 'video' | 'interaction' | 'general';
|
|
148
241
|
|
|
242
|
+
declare interface PoseData {
|
|
243
|
+
confidence: number;
|
|
244
|
+
landmarks: {
|
|
245
|
+
x: number;
|
|
246
|
+
y: number;
|
|
247
|
+
z: number;
|
|
248
|
+
visibility: number;
|
|
249
|
+
}[];
|
|
250
|
+
face: {
|
|
251
|
+
x: number;
|
|
252
|
+
y: number;
|
|
253
|
+
}[];
|
|
254
|
+
torso: {
|
|
255
|
+
x: number;
|
|
256
|
+
y: number;
|
|
257
|
+
}[];
|
|
258
|
+
leftArm: {
|
|
259
|
+
x: number;
|
|
260
|
+
y: number;
|
|
261
|
+
}[];
|
|
262
|
+
rightArm: {
|
|
263
|
+
x: number;
|
|
264
|
+
y: number;
|
|
265
|
+
}[];
|
|
266
|
+
leftLeg: {
|
|
267
|
+
x: number;
|
|
268
|
+
y: number;
|
|
269
|
+
}[];
|
|
270
|
+
rightLeg: {
|
|
271
|
+
x: number;
|
|
272
|
+
y: number;
|
|
273
|
+
}[];
|
|
274
|
+
}
|
|
275
|
+
|
|
149
276
|
declare type Resolution = {
|
|
150
277
|
width: number;
|
|
151
278
|
height: number;
|
|
152
279
|
};
|
|
153
280
|
|
|
281
|
+
declare interface SegmentationData {
|
|
282
|
+
mask: Uint8Array;
|
|
283
|
+
width: number;
|
|
284
|
+
height: number;
|
|
285
|
+
}
|
|
286
|
+
|
|
154
287
|
declare interface SelectConfig {
|
|
155
288
|
options: string[] | number[];
|
|
156
289
|
label: string;
|
|
@@ -273,7 +406,7 @@ declare namespace VijiCore {
|
|
|
273
406
|
isEnding: boolean;
|
|
274
407
|
}
|
|
275
408
|
|
|
276
|
-
declare const VERSION = "0.2.
|
|
409
|
+
declare const VERSION = "0.2.9";
|
|
277
410
|
|
|
278
411
|
declare interface VideoAPI {
|
|
279
412
|
isConnected: boolean;
|
|
@@ -284,6 +417,17 @@ declare namespace VijiCore {
|
|
|
284
417
|
getFrameData: () => ImageData | null;
|
|
285
418
|
faces: FaceData[];
|
|
286
419
|
hands: HandData[];
|
|
420
|
+
pose: PoseData | null;
|
|
421
|
+
segmentation: SegmentationData | null;
|
|
422
|
+
cv: {
|
|
423
|
+
enableFaceDetection(enabled: boolean): Promise<void>;
|
|
424
|
+
enableFaceMesh(enabled: boolean): Promise<void>;
|
|
425
|
+
enableHandTracking(enabled: boolean): Promise<void>;
|
|
426
|
+
enablePoseDetection(enabled: boolean): Promise<void>;
|
|
427
|
+
enableBodySegmentation(enabled: boolean): Promise<void>;
|
|
428
|
+
getActiveFeatures(): CVFeature[];
|
|
429
|
+
isProcessing(): boolean;
|
|
430
|
+
};
|
|
287
431
|
}
|
|
288
432
|
|
|
289
433
|
declare interface VijiAPI {
|
|
@@ -308,6 +452,7 @@ declare namespace VijiCore {
|
|
|
308
452
|
select: (defaultValue: string | number, config: SelectConfig) => SelectParameter;
|
|
309
453
|
text: (defaultValue: string, config: TextConfig) => TextParameter;
|
|
310
454
|
number: (defaultValue: number, config: NumberConfig) => NumberParameter;
|
|
455
|
+
image: (defaultValue: null, config: ImageConfig) => ImageParameter;
|
|
311
456
|
useContext(type: '2d'): OffscreenCanvasRenderingContext2D;
|
|
312
457
|
useContext(type: 'webgl'): WebGLRenderingContext | WebGL2RenderingContext;
|
|
313
458
|
}
|
|
@@ -69,6 +69,15 @@
|
|
|
69
69
|
* @property {ParameterCategory} [category] - category property
|
|
70
70
|
*/
|
|
71
71
|
|
|
72
|
+
/**
|
|
73
|
+
* Configuration for image parameters
|
|
74
|
+
* @typedef {Object} ImageConfig
|
|
75
|
+
* @property {string} label - label property
|
|
76
|
+
* @property {string} [description] - description property
|
|
77
|
+
* @property {string} [group] - group property
|
|
78
|
+
* @property {ParameterCategory} [category] - category property
|
|
79
|
+
*/
|
|
80
|
+
|
|
72
81
|
/**
|
|
73
82
|
* Parameter object for slider parameters
|
|
74
83
|
* @typedef {Object} SliderParameter
|
|
@@ -137,6 +146,16 @@
|
|
|
137
146
|
* @property {ParameterCategory} category - category property
|
|
138
147
|
*/
|
|
139
148
|
|
|
149
|
+
/**
|
|
150
|
+
* Parameter object for image parameters
|
|
151
|
+
* @typedef {Object} ImageParameter
|
|
152
|
+
* @property {ImageBitmap | OffscreenCanvas |null} value - value property
|
|
153
|
+
* @property {string} label - label property
|
|
154
|
+
* @property {string} [description] - description property
|
|
155
|
+
* @property {string} group - group property
|
|
156
|
+
* @property {ParameterCategory} category - category property
|
|
157
|
+
*/
|
|
158
|
+
|
|
140
159
|
/**
|
|
141
160
|
* Audio analysis API - provides real-time audio data and frequency analysis
|
|
142
161
|
* @typedef {Object} AudioAPI
|
|
@@ -157,6 +176,9 @@
|
|
|
157
176
|
* @property {() => ImageData |null} getFrameData - getFrameData property
|
|
158
177
|
* @property {FaceData[]} faces - faces property
|
|
159
178
|
* @property {HandData[]} hands - hands property
|
|
179
|
+
* @property {PoseData |null} pose - pose property
|
|
180
|
+
* @property {SegmentationData |null} segmentation - segmentation property
|
|
181
|
+
* @property {{} cv - cv property
|
|
160
182
|
*/
|
|
161
183
|
|
|
162
184
|
/**
|
|
@@ -224,6 +246,50 @@
|
|
|
224
246
|
* @property {(defaultValue: string | number, config: SelectConfig) => SelectParameter} select - select property
|
|
225
247
|
* @property {(defaultValue: string, config: TextConfig) => TextParameter} text - text property
|
|
226
248
|
* @property {(defaultValue: number, config: NumberConfig) => NumberParameter} number - number property
|
|
249
|
+
* @property {(defaultValue: null, config: ImageConfig) => ImageParameter} image - image property
|
|
250
|
+
*/
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* FaceData interface
|
|
254
|
+
* @typedef {Object} FaceData
|
|
255
|
+
* @property {number} id - id property
|
|
256
|
+
* @property {{} bounds - bounds property
|
|
257
|
+
* @property {number} x - x property
|
|
258
|
+
* @property {number} y - y property
|
|
259
|
+
* @property {number} width - width property
|
|
260
|
+
* @property {number} height - height property
|
|
261
|
+
*/
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* HandData interface
|
|
265
|
+
* @typedef {Object} HandData
|
|
266
|
+
* @property {number} id - id property
|
|
267
|
+
* @property {'left' | 'right'} handedness - handedness property
|
|
268
|
+
* @property {number} confidence - confidence property
|
|
269
|
+
* @property {{} bounds - bounds property
|
|
270
|
+
* @property {number} x - x property
|
|
271
|
+
* @property {number} y - y property
|
|
272
|
+
* @property {number} width - width property
|
|
273
|
+
* @property {number} height - height property
|
|
274
|
+
*/
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* PoseData interface
|
|
278
|
+
* @typedef {Object} PoseData
|
|
279
|
+
* @property {number} confidence - confidence property
|
|
280
|
+
* @property {{} landmarks - landmarks property
|
|
281
|
+
* @property {number} x - x property
|
|
282
|
+
* @property {number} y - y property
|
|
283
|
+
* @property {number} z - z property
|
|
284
|
+
* @property {number} visibility - visibility property
|
|
285
|
+
*/
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* SegmentationData interface
|
|
289
|
+
* @typedef {Object} SegmentationData
|
|
290
|
+
* @property {Uint8Array} mask - mask property
|
|
291
|
+
* @property {number} width - width property
|
|
292
|
+
* @property {number} height - height property
|
|
227
293
|
*/
|
|
228
294
|
|
|
229
295
|
/**
|
package/dist/artist-jsdoc.d.ts
CHANGED
|
@@ -65,6 +65,15 @@
|
|
|
65
65
|
* @property {ParameterCategory} [category] - category property
|
|
66
66
|
*/
|
|
67
67
|
|
|
68
|
+
/**
|
|
69
|
+
* Configuration for image parameters
|
|
70
|
+
* @typedef {Object} ImageConfig
|
|
71
|
+
* @property {string} label - label property
|
|
72
|
+
* @property {string} [description] - description property
|
|
73
|
+
* @property {string} [group] - group property
|
|
74
|
+
* @property {ParameterCategory} [category] - category property
|
|
75
|
+
*/
|
|
76
|
+
|
|
68
77
|
/**
|
|
69
78
|
* Parameter object for slider parameters
|
|
70
79
|
* @typedef {Object} SliderParameter
|
|
@@ -133,6 +142,16 @@
|
|
|
133
142
|
* @property {ParameterCategory} category - category property
|
|
134
143
|
*/
|
|
135
144
|
|
|
145
|
+
/**
|
|
146
|
+
* Parameter object for image parameters
|
|
147
|
+
* @typedef {Object} ImageParameter
|
|
148
|
+
* @property {ImageBitmap | OffscreenCanvas |null} value - value property
|
|
149
|
+
* @property {string} label - label property
|
|
150
|
+
* @property {string} [description] - description property
|
|
151
|
+
* @property {string} group - group property
|
|
152
|
+
* @property {ParameterCategory} category - category property
|
|
153
|
+
*/
|
|
154
|
+
|
|
136
155
|
/**
|
|
137
156
|
* Audio analysis API - provides real-time audio data and frequency analysis
|
|
138
157
|
* @typedef {Object} AudioAPI
|
|
@@ -153,6 +172,9 @@
|
|
|
153
172
|
* @property {() => ImageData |null} getFrameData - getFrameData property
|
|
154
173
|
* @property {FaceData[]} faces - faces property
|
|
155
174
|
* @property {HandData[]} hands - hands property
|
|
175
|
+
* @property {PoseData |null} pose - pose property
|
|
176
|
+
* @property {SegmentationData |null} segmentation - segmentation property
|
|
177
|
+
* @property {{} cv - cv property
|
|
156
178
|
*/
|
|
157
179
|
|
|
158
180
|
/**
|
|
@@ -220,6 +242,50 @@
|
|
|
220
242
|
* @property {(defaultValue: string | number, config: SelectConfig) => SelectParameter} select - select property
|
|
221
243
|
* @property {(defaultValue: string, config: TextConfig) => TextParameter} text - text property
|
|
222
244
|
* @property {(defaultValue: number, config: NumberConfig) => NumberParameter} number - number property
|
|
245
|
+
* @property {(defaultValue: null, config: ImageConfig) => ImageParameter} image - image property
|
|
246
|
+
*/
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* FaceData interface
|
|
250
|
+
* @typedef {Object} FaceData
|
|
251
|
+
* @property {number} id - id property
|
|
252
|
+
* @property {{} bounds - bounds property
|
|
253
|
+
* @property {number} x - x property
|
|
254
|
+
* @property {number} y - y property
|
|
255
|
+
* @property {number} width - width property
|
|
256
|
+
* @property {number} height - height property
|
|
257
|
+
*/
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* HandData interface
|
|
261
|
+
* @typedef {Object} HandData
|
|
262
|
+
* @property {number} id - id property
|
|
263
|
+
* @property {'left' | 'right'} handedness - handedness property
|
|
264
|
+
* @property {number} confidence - confidence property
|
|
265
|
+
* @property {{} bounds - bounds property
|
|
266
|
+
* @property {number} x - x property
|
|
267
|
+
* @property {number} y - y property
|
|
268
|
+
* @property {number} width - width property
|
|
269
|
+
* @property {number} height - height property
|
|
270
|
+
*/
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* PoseData interface
|
|
274
|
+
* @typedef {Object} PoseData
|
|
275
|
+
* @property {number} confidence - confidence property
|
|
276
|
+
* @property {{} landmarks - landmarks property
|
|
277
|
+
* @property {number} x - x property
|
|
278
|
+
* @property {number} y - y property
|
|
279
|
+
* @property {number} z - z property
|
|
280
|
+
* @property {number} visibility - visibility property
|
|
281
|
+
*/
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* SegmentationData interface
|
|
285
|
+
* @typedef {Object} SegmentationData
|
|
286
|
+
* @property {Uint8Array} mask - mask property
|
|
287
|
+
* @property {number} width - width property
|
|
288
|
+
* @property {number} height - height property
|
|
223
289
|
*/
|
|
224
290
|
|
|
225
291
|
/**
|