@laplace.live/persona-sdk 1.9.0 → 1.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import type { AssetRef, Attach, EnvironmentLook, ModelFormat, MToonTuning, ObjectContent, ObjectSpace, SceneEnvironment, SceneLight, SceneLightType, ScreenPlacement, VrmPlacement } from '../wire/types.ts';
1
+ import type { AssetRef, Attach, EnvironmentLook, ModelFormat, MToonTuning, ObjectContent, ObjectSpace, SceneEnvironment, SceneLight, SceneLightCameraFollowOptions, SceneLightType, ScreenPlacement, VrmPlacement } from '../wire/types.ts';
2
2
  export declare function clamp(v: number, min: number, max: number): number;
3
3
  /** Clamp to the unit interval. */
4
4
  export declare function clamp01(v: number): number;
@@ -13,6 +13,7 @@ export declare function hexColorOr(v: unknown, fallback: string): string;
13
13
  /** Drop the alpha byte a picker's hex input can produce (`#rrggbbaa` → `#rrggbb`). */
14
14
  export declare function opaqueHex(hex: string): string;
15
15
  export declare const SCENE_LIGHT_INTENSITY_MAX = 2;
16
+ export declare const SCENE_SKYBOX_INTENSITY_MAX = 2;
16
17
  /**
17
18
  * Point lights need headroom against inverse-square decay; directional and ambient
18
19
  * lights have no falloff and would wash out the stage at the same intensity.
@@ -63,6 +64,17 @@ export declare const ELEVATION_LIMIT: number;
63
64
  /** Manual navigation distance bounds; authored cameras retain signed, unrestricted distances. */
64
65
  export declare const DISTANCE_MIN = 0.35;
65
66
  export declare const DISTANCE_MAX = 20;
67
+ /** A scene's manual navigation distance bounds, in world units. */
68
+ export interface CameraDistanceLimits {
69
+ min: number;
70
+ max: number;
71
+ }
72
+ /**
73
+ * {@link DISTANCE_MIN} and {@link DISTANCE_MAX}, widened in proportion for an Environment Model placed larger
74
+ * or smaller than a ~10 m room. Neither bound ever narrows.
75
+ * @param setRadius The loaded set's own bounding radius, before its placement scale; null until one has loaded.
76
+ */
77
+ export declare function cameraDistanceLimits(env: Pick<SceneEnvironment, 'modelAssetId' | 'modelPlace'>, setRadius: number | null): CameraDistanceLimits;
66
78
  /** ×2 doubles Cubism's own breath amplitude — past that the head sway reads as a nod, not a breath. */
67
79
  export declare const BREATH_DEPTH_MAX = 2;
68
80
  export declare const MTOON_NORMAL_SCALE_MAX = 2;
@@ -78,6 +90,8 @@ export declare const MTOON_UV_ANIMATION_MAX = 4;
78
90
  export declare function defaultMToonTuning(): MToonTuning;
79
91
  export declare const DEFAULT_LIGHT_AZIMUTH_DEG = 45;
80
92
  export declare const DEFAULT_LIGHT_ELEVATION_DEG: number;
93
+ /** What a following light tracks when `followCameraOptions` is omitted. */
94
+ export declare const DEFAULT_LIGHT_FOLLOW_CAMERA_OPTIONS: SceneLightCameraFollowOptions;
81
95
  /** A fresh light of `type`, at the defaults that read sensibly for that type. */
82
96
  export declare function defaultSceneLightOf(type: SceneLightType): SceneLight;
83
97
  /**
@@ -115,17 +129,18 @@ export declare function applyEnvironmentLook(env: SceneEnvironment, look: Enviro
115
129
  * simply arrive wearing it.
116
130
  */
117
131
  export declare function environmentLookIsUntouched(env: SceneEnvironment, reference: SceneEnvironment): boolean;
132
+ /** An environment asset: the 3D set (`modelAssetId`) or the equirect map (`iblAssetId`). */
133
+ export type EnvironmentSlot = 'model' | 'map';
118
134
  /**
119
- * Point an environment at one asset, or at none.
120
- *
121
- * {@link SceneEnvironment.iblAssetId} and {@link SceneEnvironment.modelAssetId} are a
122
- * single slot — a scene wears an equirect map or a 3D set — so this clears whichever
123
- * the pick is not. `bakeFromModel` goes with the set: on for a set arriving where none was,
124
- * kept across a swap, dropped otherwise — it wins over a picked map, so a stale one would
125
- * leave a fresh map lighting nothing.
126
- * Light overrides index the set's own lamps, so a different set — or none — drops them.
127
- * `modelLook` stays put: the stage replaces it as the next set parses, and the desktop
128
- * reads the outgoing one as what the scene wears now when deciding to adopt the next.
135
+ * The edit that removes one environment asset, or both for null. The model takes its baking and
136
+ * light overrides along; removing only the map hands lighting to a remaining model. `modelLook`
137
+ * stays, as in {@link environmentWithAsset}.
138
+ */
139
+ export declare function environmentClearPatch(env: SceneEnvironment, slot: EnvironmentSlot | null): Partial<Pick<SceneEnvironment, 'iblAssetId' | 'modelAssetId' | 'bakeFromModel' | 'modelLightOverrides'>>;
140
+ /**
141
+ * Pick a model or map without removing the other; null clears both for legacy callers.
142
+ * A picked map becomes the lighting source. A first model generates lighting only without a map.
143
+ * `modelLook` stays put so the desktop can compare the outgoing look before adopting the next.
129
144
  * @returns A new environment; the input is untouched.
130
145
  */
131
146
  export declare function environmentWithAsset(env: SceneEnvironment, asset: Pick<AssetRef, 'id' | 'kind'> | null): SceneEnvironment;
@@ -29,6 +29,7 @@ export function opaqueHex(hex) {
29
29
  return /^#[0-9a-f]{8}$/i.test(hex) ? hex.slice(0, 7) : hex;
30
30
  }
31
31
  export const SCENE_LIGHT_INTENSITY_MAX = 2;
32
+ export const SCENE_SKYBOX_INTENSITY_MAX = 2;
32
33
  /**
33
34
  * Point lights need headroom against inverse-square decay; directional and ambient
34
35
  * lights have no falloff and would wash out the stage at the same intensity.
@@ -90,6 +91,17 @@ export const ELEVATION_LIMIT = (80 * Math.PI) / 180;
90
91
  /** Manual navigation distance bounds; authored cameras retain signed, unrestricted distances. */
91
92
  export const DISTANCE_MIN = 0.35;
92
93
  export const DISTANCE_MAX = 20;
94
+ /** Bounding radius of the set the distance bounds are sized for: a ~10 m room {@link DISTANCE_MAX} frames whole. */
95
+ const DISTANCE_SET_RADIUS = 5;
96
+ /**
97
+ * {@link DISTANCE_MIN} and {@link DISTANCE_MAX}, widened in proportion for an Environment Model placed larger
98
+ * or smaller than a ~10 m room. Neither bound ever narrows.
99
+ * @param setRadius The loaded set's own bounding radius, before its placement scale; null until one has loaded.
100
+ */
101
+ export function cameraDistanceLimits(env, setRadius) {
102
+ const size = env.modelAssetId === null || setRadius === null ? 1 : (setRadius * env.modelPlace.scale) / DISTANCE_SET_RADIUS;
103
+ return { min: DISTANCE_MIN * Math.min(1, size), max: DISTANCE_MAX * Math.max(1, size) };
104
+ }
93
105
  /** ×2 doubles Cubism's own breath amplitude — past that the head sway reads as a nod, not a breath. */
94
106
  export const BREATH_DEPTH_MAX = 2;
95
107
  export const MTOON_NORMAL_SCALE_MAX = 2;
@@ -124,12 +136,20 @@ export function defaultMToonTuning() {
124
136
  // Angles at which lightDirection reproduces (1,1,1).normalize() — the app's original hardcoded light.
125
137
  export const DEFAULT_LIGHT_AZIMUTH_DEG = 45;
126
138
  export const DEFAULT_LIGHT_ELEVATION_DEG = (Math.asin(1 / Math.sqrt(3)) * 180) / Math.PI;
139
+ /** What a following light tracks when `followCameraOptions` is omitted. */
140
+ export const DEFAULT_LIGHT_FOLLOW_CAMERA_OPTIONS = {
141
+ position: true,
142
+ rotation: true,
143
+ distance: true,
144
+ };
127
145
  /** A fresh light of `type`, at the defaults that read sensibly for that type. */
128
146
  export function defaultSceneLightOf(type) {
129
147
  return {
130
148
  id: crypto.randomUUID(),
131
149
  type,
132
150
  enabled: true,
151
+ followCamera: false,
152
+ followCameraOptions: { ...DEFAULT_LIGHT_FOLLOW_CAMERA_OPTIONS },
133
153
  color: '#ffffff',
134
154
  // Ambient is a flat albedo floor with no shading — 1.0 alone washes the model out.
135
155
  intensity: type === 'ambient' ? 0.4 : 1,
@@ -210,27 +230,32 @@ export function environmentLookIsUntouched(env, reference) {
210
230
  return looked(env) === looked(reference);
211
231
  }
212
232
  /**
213
- * Point an environment at one asset, or at none.
214
- *
215
- * {@link SceneEnvironment.iblAssetId} and {@link SceneEnvironment.modelAssetId} are a
216
- * single slot — a scene wears an equirect map or a 3D set — so this clears whichever
217
- * the pick is not. `bakeFromModel` goes with the set: on for a set arriving where none was,
218
- * kept across a swap, dropped otherwise — it wins over a picked map, so a stale one would
219
- * leave a fresh map lighting nothing.
220
- * Light overrides index the set's own lamps, so a different set — or none — drops them.
221
- * `modelLook` stays put: the stage replaces it as the next set parses, and the desktop
222
- * reads the outgoing one as what the scene wears now when deciding to adopt the next.
233
+ * The edit that removes one environment asset, or both for null. The model takes its baking and
234
+ * light overrides along; removing only the map hands lighting to a remaining model. `modelLook`
235
+ * stays, as in {@link environmentWithAsset}.
236
+ */
237
+ export function environmentClearPatch(env, slot) {
238
+ if (slot === 'map')
239
+ return { iblAssetId: null, bakeFromModel: env.modelAssetId !== null };
240
+ const model = { modelAssetId: null, bakeFromModel: false, modelLightOverrides: {} };
241
+ return slot === 'model' ? model : { ...model, iblAssetId: null };
242
+ }
243
+ /**
244
+ * Pick a model or map without removing the other; null clears both for legacy callers.
245
+ * A picked map becomes the lighting source. A first model generates lighting only without a map.
246
+ * `modelLook` stays put so the desktop can compare the outgoing look before adopting the next.
223
247
  * @returns A new environment; the input is untouched.
224
248
  */
225
249
  export function environmentWithAsset(env, asset) {
226
- const isSet = asset?.kind === 'prop';
227
- const modelAssetId = isSet ? asset.id : null;
250
+ if (asset === null)
251
+ return { ...env, ...environmentClearPatch(env, null) };
252
+ if (asset.kind !== 'prop')
253
+ return { ...env, iblAssetId: asset.id, bakeFromModel: false };
228
254
  return {
229
255
  ...env,
230
- iblAssetId: asset !== null && !isSet ? asset.id : null,
231
- modelAssetId,
232
- bakeFromModel: isSet && (env.modelAssetId === null || env.bakeFromModel),
233
- modelLightOverrides: modelAssetId === env.modelAssetId ? env.modelLightOverrides : {},
256
+ modelAssetId: asset.id,
257
+ bakeFromModel: env.modelAssetId === null ? env.iblAssetId === null : env.bakeFromModel,
258
+ modelLightOverrides: asset.id === env.modelAssetId ? env.modelLightOverrides : {},
234
259
  };
235
260
  }
236
261
  export const PLACE_2D_SCALE_MIN = 0.01;
@@ -22,6 +22,9 @@ export interface SceneAssetInfo {
22
22
  /** Metadata for the active scene, tagged so a response from a previous scene can be discarded. */
23
23
  export interface SceneInspection {
24
24
  sceneId: string;
25
- environment: Omit<SceneAssetInfo, 'mediaSize'>;
25
+ environment: Omit<SceneAssetInfo, 'mediaSize'> & {
26
+ /** The set's own bounding radius before placement scale, for `cameraDistanceLimits`; omitted by older hosts. */
27
+ radius?: number | null;
28
+ };
26
29
  objects: Record<string, SceneAssetInfo>;
27
30
  }
@@ -3,7 +3,7 @@ import type { ControllerMovementConfig, ControllerState } from '../values/contro
3
3
  import type { LipSyncCalibrationCommand, LipSyncConfig, LipSyncMode, LipSyncState } from '../values/lipsync.ts';
4
4
  import type { SceneInspection } from '../values/stage-info.ts';
5
5
  import type { EventName } from './events.ts';
6
- import type { AnchorOption, AppCapability, AssetKind, AssetRef, Attach, AttachHeadAngle, AutomationInfo, BindingInput, Expression, ExpressionPersistence, HandTrackingMode, HotkeyConfig, HotkeyState, InjectEntry, InjectTarget, InstanceRuntime, JsonValue, LayerEffectKey, LayerEffects, LayerEffectsPatch, MediaPipeConfig, ModelInfo, ModelRef, MotionGroup, MToonTuning, ObjectContent, ObjectLightOverride, ObjectSpace, Place2D, Place3D, PlayingMotion, PoseSourceId, PoseStatus, Scene, SceneItem, ScenePatch, SceneState, ScreenPlacement, Settings, SettingsPatch, TrackingSourceConfig, TrackingSourceId, TrackingSourceKind, TrackingStatus, VrmPlacement } from './types.ts';
6
+ import type { AnchorOption, AppCapability, AssetKind, AssetRef, Attach, AttachHeadAngle, AutomationInfo, BindingInput, Expression, ExpressionPersistence, HandTrackingMode, HotkeyConfig, HotkeyState, InjectEntry, InjectTarget, InstanceRuntime, JsonValue, LayerEffectKey, LayerEffects, LayerEffectsPatch, MediaPipeConfig, ModelInfo, ModelRef, MotionGroup, MToonTuning, ObjectContent, ObjectLightOverride, ObjectSpace, Place2D, Place3D, PlayingMotion, PoseSourceId, PoseStatus, Scene, SceneItem, SceneLight, SceneLightCameraFollowOptions, ScenePatch, SceneState, ScreenPlacement, Settings, SettingsPatch, TrackingSourceConfig, TrackingSourceId, TrackingSourceKind, TrackingStatus, VrmPlacement } from './types.ts';
7
7
  /** Marker for methods that take no parameters; the client lets you omit the argument. */
8
8
  export type EmptyRequest = Record<never, never>;
9
9
  /** Marker for methods whose success response carries no data. */
@@ -40,6 +40,17 @@ export type ScenePatchRequest = ScenePatch;
40
40
  export interface ScenePatchResponse {
41
41
  scene: Scene;
42
42
  }
43
+ /** Rebase one active-scene light against the displayed camera without moving or re-aiming it. */
44
+ export interface SceneSetLightFollowCameraRequest {
45
+ lightId: string;
46
+ followCamera: boolean;
47
+ /** Merges independent follow choices while preserving the light's displayed pose. */
48
+ options?: Partial<SceneLightCameraFollowOptions>;
49
+ }
50
+ export interface SceneSetLightFollowCameraResponse {
51
+ /** The rebased light, or null if it no longer exists in the active scene. */
52
+ light: SceneLight | null;
53
+ }
43
54
  export type InstanceListRequest = EmptyRequest;
44
55
  export interface InstanceListResponse {
45
56
  instances: InstanceRuntime[];
@@ -667,6 +678,10 @@ export interface MethodMap {
667
678
  request: ScenePatchRequest;
668
679
  response: ScenePatchResponse;
669
680
  };
681
+ 'scene.setLightFollowCamera': {
682
+ request: SceneSetLightFollowCameraRequest;
683
+ response: SceneSetLightFollowCameraResponse;
684
+ };
670
685
  'instance.list': {
671
686
  request: InstanceListRequest;
672
687
  response: InstanceListResponse;
@@ -113,6 +113,15 @@ export declare const requestSchemas: {
113
113
  'scene.delete': z.ZodObject<{
114
114
  sceneId: z.ZodString;
115
115
  }, z.core.$strip>;
116
+ 'scene.setLightFollowCamera': z.ZodObject<{
117
+ lightId: z.ZodString;
118
+ followCamera: z.ZodBoolean;
119
+ options: z.ZodOptional<z.ZodObject<{
120
+ position: z.ZodOptional<z.ZodBoolean>;
121
+ rotation: z.ZodOptional<z.ZodBoolean>;
122
+ distance: z.ZodOptional<z.ZodBoolean>;
123
+ }, z.core.$strip>>;
124
+ }, z.core.$strip>;
116
125
  'instance.add': z.ZodObject<{
117
126
  modelId: z.ZodString;
118
127
  }, z.core.$strip>;
@@ -78,6 +78,11 @@ export const requestSchemas = {
78
78
  'scene.duplicate': z.object({ sceneId: nonEmpty }),
79
79
  'scene.rename': z.object({ sceneId: nonEmpty, name: nonEmpty }),
80
80
  'scene.delete': z.object({ sceneId: nonEmpty }),
81
+ 'scene.setLightFollowCamera': z.object({
82
+ lightId: nonEmpty,
83
+ followCamera: z.boolean(),
84
+ options: z.object({ position: z.boolean(), rotation: z.boolean(), distance: z.boolean() }).partial().optional(),
85
+ }),
81
86
  'instance.add': z.object({ modelId: nonEmpty }),
82
87
  'instance.setModel': z.object({ instanceId: nonEmpty, modelId: nonEmpty }),
83
88
  'object.add': z.object({
@@ -341,6 +341,25 @@ export declare const SHADOW_QUALITY_LEVELS: readonly ["off", "low", "medium", "h
341
341
  export type ShadowQuality = (typeof SHADOW_QUALITY_LEVELS)[number];
342
342
  export declare const SHADOW_FILTERS: readonly ["pcf", "pcss"];
343
343
  export type ShadowFilter = (typeof SHADOW_FILTERS)[number];
344
+ /** Camera components followed by a light; omitted options default to all true. */
345
+ export interface SceneLightCameraFollowOptions {
346
+ /** Follow the camera's target/pan translation. */
347
+ position: boolean;
348
+ /** Follow the camera's world rotation, including roll. */
349
+ rotation: boolean;
350
+ /** Follow the signed orbit distance from target to camera. */
351
+ distance: boolean;
352
+ }
353
+ /** Frozen camera components used when the matching follow option is disabled. */
354
+ export interface SceneLightCameraFollowReference extends Pick<OrbitTransform, 'targetX' | 'targetY' | 'targetZ' | 'distance'> {
355
+ /** Unit quaternion in world space. */
356
+ rotation: {
357
+ x: number;
358
+ y: number;
359
+ z: number;
360
+ w: number;
361
+ };
362
+ }
344
363
  /**
345
364
  * One scene light. Angles are degrees. Directional lights aim with
346
365
  * azimuth/elevation and sit at x/y/z (which moves their handle and shadow
@@ -354,6 +373,12 @@ export interface SceneLight {
354
373
  type: SceneLightType;
355
374
  /** Mutes illumination and shadows. Defaults to true; omitted by hosts without light toggles. */
356
375
  enabled?: boolean;
376
+ /** Camera-relative placement and angles; defaults to false. Gate editing on `camera-follow-lights`; ambient ignores it. */
377
+ followCamera?: boolean;
378
+ /** Independent camera components; omitted means all true. */
379
+ followCameraOptions?: SceneLightCameraFollowOptions;
380
+ /** Missing references use target zero, identity rotation, and distance zero for disabled components. */
381
+ followCameraReference?: SceneLightCameraFollowReference;
357
382
  color: string;
358
383
  intensity: number;
359
384
  azimuth: number;
@@ -840,11 +865,8 @@ export interface EnvironmentLook {
840
865
  color: SceneColorGrade;
841
866
  }
842
867
  /**
843
- * The world the 3D stage sits in: one environment — a map, or a 3D set the avatar
844
- * stands inside — the scene-global fog, and post-processing.
845
- *
846
- * The two asset ids are a single slot the editors write through
847
- * {@link environmentWithAsset}: at most one is ever set.
868
+ * The world the 3D stage sits in: independent environment map and 3D set,
869
+ * scene-global fog, and post-processing.
848
870
  */
849
871
  export interface SceneEnvironment {
850
872
  /** Equirectangular `.hdr` or image driving the environment lighting, or null. */
@@ -856,14 +878,21 @@ export interface SceneEnvironment {
856
878
  * has no IBL term of its own and the app adds one.
857
879
  */
858
880
  iblAvatarAmount: number;
881
+ /** Show the selected map, falling back to the model's sky, independently of the lighting source. */
859
882
  showSkybox: boolean;
883
+ /** Visible skybox blur, 0..1; defaults to 0. Omitted by older hosts. */
884
+ skyboxBlur?: number;
885
+ /** Visible skybox brightness, 0..2; defaults to 1. Omitted by older hosts. */
886
+ skyboxIntensity?: number;
887
+ /** Panorama and lighting yaw in radians; defaults to 0 and may wrap beyond one turn. Omitted by older hosts. */
888
+ iblRotation?: number;
860
889
  /** A `prop` asset (glb/gltf) rendered as the set the scene sits in, or null. */
861
890
  modelAssetId: string | null;
862
891
  /** Where that set sits, in the same units as an object's `place3d`. */
863
892
  modelPlace: Place3D;
864
893
  /**
865
- * Bake the set's geometry into the environment lighting. It wins over
866
- * {@link SceneEnvironment.iblAssetId}, so it only means anything with a set.
894
+ * Generate lighting from the set, using the selected map or the set's sky as input.
895
+ * False uses the map directly; the skybox remains independent of this choice.
867
896
  */
868
897
  bakeFromModel: boolean;
869
898
  /** Whether lights baked into the set render at all. */
@@ -940,7 +969,7 @@ export interface ScenePatch {
940
969
  * App-level features a client gates on (never version-sniff): `hello` and
941
970
  * `app.info` report them — the per-app mirror of {@link InstanceRuntime.capabilities}.
942
971
  */
943
- export declare const APP_CAPABILITIES: readonly ["storage", "speech", "automations", "controllers", "model-editing", "asset-inspection", "layer-effects", "scene-transitions", "area-lights", "spot-lights", "shadow-filters"];
972
+ export declare const APP_CAPABILITIES: readonly ["storage", "speech", "automations", "controllers", "model-editing", "asset-inspection", "layer-effects", "scene-transitions", "area-lights", "spot-lights", "camera-follow-lights", "shadow-filters", "environment-map-model"];
944
973
  export type AppCapability = (typeof APP_CAPABILITIES)[number];
945
974
  export declare function isAppCapability(v: unknown): v is AppCapability;
946
975
  /** What a loaded model instance can do; absent capabilities answer `unsupported-for-format`. */
@@ -42,7 +42,9 @@ export const APP_CAPABILITIES = [
42
42
  'scene-transitions',
43
43
  'area-lights',
44
44
  'spot-lights',
45
+ 'camera-follow-lights',
45
46
  'shadow-filters',
47
+ 'environment-map-model',
46
48
  ];
47
49
  export function isAppCapability(v) {
48
50
  return isOneOf(v, APP_CAPABILITIES);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@laplace.live/persona-sdk",
3
- "version": "1.9.0",
3
+ "version": "1.10.0",
4
4
  "description": "TypeScript SDK and wire schema for the LAPLACE Persona plugin API",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -34,7 +34,7 @@
34
34
  "node": ">=24"
35
35
  },
36
36
  "dependencies": {
37
- "zod": "^4.6.2"
37
+ "zod": "^4.6.4"
38
38
  },
39
39
  "scripts": {
40
40
  "build": "rimraf dist && tsc -p tsconfig.build.json",