@deepblend/dsh-blender-contracts 0.21.0 → 0.22.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.
@@ -0,0 +1,94 @@
1
+ import { BlenderError, BlenderErrorCode } from './index.js'
2
+
3
+ export const CAMERA_FIT_VERSION = 'deepblend.camera-fit/v1'
4
+ export const CAMERA_FIT_LIMITS = Object.freeze({ entities: 64, meshes: 128, vertices: 2_000_000,
5
+ checkpointBytes: 1024 ** 3, reportBytes: 256 * 1024, toleranceMeters: .00002 })
6
+ const only = (v, keys) => v && typeof v === 'object' && !Array.isArray(v) && Object.keys(v).every(k => keys.includes(k))
7
+ const vector = (v, n = 3) => Array.isArray(v) && v.length === n && v.every(Number.isFinite)
8
+ const hash = v => typeof v === 'string' && /^[a-f0-9]{64}$/.test(v)
9
+ const id = v => typeof v === 'string' && /^[A-Za-z][A-Za-z0-9._-]{0,127}$/.test(v)
10
+ const integer = (v, a, b) => Number.isSafeInteger(v) && v >= a && v <= b
11
+ const positive = v => Number.isFinite(v) && v > 0
12
+ const same = (a, b) => JSON.stringify(a) === JSON.stringify(b)
13
+ const fail = (message, code = BlenderErrorCode.SCENE_VALIDATION_FAILED) => { throw new BlenderError(code, `Camera fit: ${message}`) }
14
+
15
+ export function validateCameraFitSelection(request) {
16
+ const invalid = message => fail(message, BlenderErrorCode.SCENE_PATCH_INVALID)
17
+ if (!Array.isArray(request?.entityIds) || !integer(request.entityIds.length, 1, CAMERA_FIT_LIMITS.entities) ||
18
+ !request.entityIds.every(id) || new Set(request.entityIds).size !== request.entityIds.length) invalid('select 1–64 distinct mesh entities or complete asset instances.')
19
+ if (!Array.isArray(request.assetInstanceIds) || request.assetInstanceIds.some(x => !request.entityIds.includes(x)) ||
20
+ new Set(request.assetInstanceIds).size !== request.assetInstanceIds.length) invalid('assetInstanceIds must name distinct selected asset roots.')
21
+ if (!id(request.cameraId) || !id(request.fittedCameraId) || request.cameraId === request.fittedCameraId) invalid('select a source camera and a distinct new camera ID.')
22
+ if (!integer(request.frame, 0, 1_000_000) || !Number.isFinite(request.margin) || request.margin < 0 || request.margin > .25 || !hash(request.checkpointSha256)) invalid('an explicit frame, margin from 0 to 0.25 and pinned checkpoint are required.')
23
+ const baseline = request.baselineCheckpointPath !== undefined || request.baselineCheckpointSha256 !== undefined
24
+ if (baseline && (typeof request.baselineCheckpointPath !== 'string' || !request.baselineCheckpointPath || !hash(request.baselineCheckpointSha256))) invalid('candidate verification requires both the baseline checkpoint path and SHA256.')
25
+ }
26
+
27
+ function optics(v) {
28
+ return positive(v.lens) && positive(v.sensorWidth) && positive(v.sensorHeight) &&
29
+ ['AUTO', 'HORIZONTAL', 'VERTICAL'].includes(v.sensorFit) && vector(v.shift, 2) &&
30
+ vector(v.clipping, 2) && v.clipping[0] > 0 && v.clipping[1] > v.clipping[0] &&
31
+ (v.fStop === undefined || positive(v.fStop))
32
+ }
33
+ const opticalKeys = ['lens', 'sensorWidth', 'sensorHeight', 'sensorFit', 'shift', 'clipping', 'fStop']
34
+
35
+ export function verifyCameraFitReport(report, request) {
36
+ validateCameraFitSelection(request)
37
+ const candidate = request.baselineCheckpointPath !== undefined
38
+ if (!only(report, ['schemaVersion', 'entityIds', 'assetInstanceIds', 'frame', 'cameraId', 'fittedCameraId', 'margin',
39
+ 'checkpointSha256', 'checkpointUnchanged', 'blenderVersion', 'members', 'view', 'camera', candidate ? 'baselineVerification' : 'proposal']) ||
40
+ Buffer.byteLength(JSON.stringify(report)) > CAMERA_FIT_LIMITS.reportBytes || report.schemaVersion !== CAMERA_FIT_VERSION ||
41
+ !same(report.entityIds, request.entityIds) || !same(report.assetInstanceIds, request.assetInstanceIds) ||
42
+ report.frame !== request.frame || report.cameraId !== request.cameraId || report.fittedCameraId !== request.fittedCameraId ||
43
+ report.margin !== request.margin || report.checkpointSha256 !== request.checkpointSha256 || report.checkpointUnchanged !== true ||
44
+ typeof report.blenderVersion !== 'string' || !report.blenderVersion || !Array.isArray(report.members) || report.members.length !== request.entityIds.length) fail('the native report differs from the selected frame, source or complete selection.')
45
+ const view = report.view, camera = report.camera
46
+ if (!only(view, ['resolution', 'percentage', 'pixelAspect', 'activeCamera']) ||
47
+ !(view.activeCamera === null || typeof view.activeCamera === 'string') || !vector(view.resolution, 2) ||
48
+ !view.resolution.every(x => integer(x, 1, 16384)) || !integer(view.percentage, 1, 100) ||
49
+ !vector(view.pixelAspect, 2) || !view.pixelAspect.every(positive) ||
50
+ !only(camera, ['id', ...opticalKeys, 'matrixWorld', 'focusDistance', 'focusObject']) ||
51
+ camera.id !== (candidate ? request.fittedCameraId : request.cameraId) || !optics(camera) || !positive(camera.focusDistance) ||
52
+ !(camera.focusObject === null || typeof camera.focusObject === 'string') ||
53
+ !Array.isArray(camera.matrixWorld) || camera.matrixWorld.length !== 4 || !camera.matrixWorld.every(row => vector(row, 4)) ||
54
+ !same(camera.matrixWorld[3], [0, 0, 0, 1])) fail('missing or inconsistent native camera calibration.')
55
+ let vertices = 0, meshes = 0
56
+ for (const [i, member] of report.members.entries()) {
57
+ if (!only(member, ['entityId', 'meshObjectCount', 'vertexCount', 'worldBoundsMeters', 'geometrySha256', 'projection']) ||
58
+ member.entityId !== request.entityIds[i] || !integer(member.meshObjectCount, 1, CAMERA_FIT_LIMITS.meshes) ||
59
+ !integer(member.vertexCount, 1, CAMERA_FIT_LIMITS.vertices) || !hash(member.geometrySha256) ||
60
+ !only(member.worldBoundsMeters, ['min', 'max']) || !vector(member.worldBoundsMeters.min) || !vector(member.worldBoundsMeters.max) ||
61
+ [...member.worldBoundsMeters.min, ...member.worldBoundsMeters.max].some(x => Math.abs(x) > 1e6) ||
62
+ member.worldBoundsMeters.min.some((x, axis) => x > member.worldBoundsMeters.max[axis])) fail('invalid native member identity, counts or bounds.')
63
+ vertices += member.vertexCount; meshes += member.meshObjectCount
64
+ const p = member.projection
65
+ if (!only(p, ['containedInClip', 'nearestDepthMeters', 'farthestDepthMeters', 'containedInFrame', 'normalizedBounds']) ||
66
+ !Number.isFinite(p.nearestDepthMeters) || !Number.isFinite(p.farthestDepthMeters) || p.nearestDepthMeters > p.farthestDepthMeters ||
67
+ p.containedInClip !== (p.nearestDepthMeters >= camera.clipping[0] && p.farthestDepthMeters <= camera.clipping[1]) ||
68
+ typeof p.containedInFrame !== 'boolean') fail('invalid independent vertex projection.')
69
+ if (p.nearestDepthMeters > 1e-8) {
70
+ const b = p.normalizedBounds
71
+ if (!only(b, ['min', 'max']) || !vector(b.min, 2) || !vector(b.max, 2) || b.min.some((x, axis) => x > b.max[axis]) ||
72
+ p.containedInFrame !== b.min.every((x, axis) => x >= request.margin && b.max[axis] <= 1-request.margin)) fail('projection bounds do not establish the claimed margin.')
73
+ } else if (p.normalizedBounds !== undefined || p.containedInFrame !== false) fail('vertices behind the camera cannot establish framing.')
74
+ if (candidate && (!p.containedInFrame || !p.containedInClip)) fail('the compiled candidate does not contain every selected member.')
75
+ }
76
+ if (vertices > CAMERA_FIT_LIMITS.vertices || meshes > CAMERA_FIT_LIMITS.meshes) fail('the aggregate selection exceeds the native geometry budget.')
77
+ if (candidate) {
78
+ const b = report.baselineVerification
79
+ if (!only(b, ['checkpointSha256', 'checkpointUnchanged', 'selectedGeometryUnchanged', 'originalObjectsUnchanged',
80
+ 'opticsAndRotationPreserved', 'maxVertexErrorMeters', 'toleranceMeters', 'originalObjectCount']) ||
81
+ b.checkpointSha256 !== request.baselineCheckpointSha256 || b.checkpointUnchanged !== true ||
82
+ b.selectedGeometryUnchanged !== true || b.originalObjectsUnchanged !== true || b.opticsAndRotationPreserved !== true ||
83
+ b.toleranceMeters !== CAMERA_FIT_LIMITS.toleranceMeters || !Number.isFinite(b.maxVertexErrorMeters) ||
84
+ b.maxVertexErrorMeters < 0 || b.maxVertexErrorMeters > b.toleranceMeters || !integer(b.originalObjectCount, 1, 100_000)) fail('the candidate does not verify its pinned native baseline.')
85
+ } else {
86
+ const p = report.proposal
87
+ if (!only(p, ['id', 'role', ...opticalKeys, 'transform', 'focusDistance']) || p.id !== request.fittedCameraId || p.role !== 'detail' ||
88
+ !optics(p) || opticalKeys.some(k => !same(p[k], camera[k])) ||
89
+ !only(p.transform, ['location', 'rotationEuler', 'scale']) || !vector(p.transform.location) ||
90
+ !vector(p.transform.rotationEuler) || !same(p.transform.scale, [1, 1, 1]) ||
91
+ (p.fStop === undefined ? p.focusDistance !== undefined : !positive(p.focusDistance))) fail('the proposed static camera does not preserve the measured optics.')
92
+ }
93
+ return report
94
+ }
package/lib/index.js CHANGED
@@ -893,6 +893,7 @@ export { SHOT_CAMERA_SELECTION_VERSION, SHOT_CAMERA_SELECTION_LIMITS, buildShotC
893
893
  normalizeShotCameraSelection, shotCameraForFrame } from './shot-render-selection.js'
894
894
  export { SURFACE_PLACEMENT_VERSION, SURFACE_PLACEMENT_LIMITS,
895
895
  validateSurfacePlacementSelection, verifySurfacePlacementReport } from './surface-placement.js'
896
+ export { CAMERA_FIT_VERSION, CAMERA_FIT_LIMITS, validateCameraFitSelection, verifyCameraFitReport } from './camera-fit.js'
896
897
  export { ASSEMBLY_PLACEMENT_VERSION, ASSEMBLY_PLACEMENT_BASIS_TOLERANCE, ASSEMBLY_PLACEMENT_UV_TOLERANCE, normalizeAssemblyPose,
897
898
  assemblyPoseMatrixMeters, planLampAssemblyPlacement, validateAssemblyPlacementSelection,
898
899
  verifyAssemblyPlacementReport } from './assembly-placement.js'
@@ -112,6 +112,31 @@ export interface GeometryInspectionReport {
112
112
  objectAxisBasis?: 'evaluated-object-axes-scaled'; surfaceSamples?: unknown[]; checkpointSha256: string; checkpointUnchanged: true;
113
113
  frame: number; blenderVersion: string; objects: GeometryInspectionObject[];
114
114
  }
115
+ /** Read-only proposal or verification of a new static camera over complete selected mesh sets. */
116
+ export type CameraFitRequest = RuntimeOptions & {
117
+ checkpointPath: string; checkpointSha256: string; entityIds: string[]; assetInstanceIds: string[];
118
+ frame: number; cameraId: string; fittedCameraId: string; margin: number; jobId?: string;
119
+ } & ({ baselineCheckpointPath: string; baselineCheckpointSha256: string }
120
+ | { baselineCheckpointPath?: never; baselineCheckpointSha256?: never });
121
+ export interface CameraFitMember {
122
+ entityId: string; meshObjectCount: number; vertexCount: number; geometrySha256: string;
123
+ worldBoundsMeters: { min: Vec3; max: Vec3 };
124
+ projection: { containedInClip: boolean; nearestDepthMeters: number; farthestDepthMeters: number;
125
+ containedInFrame: boolean; normalizedBounds?: { min: [number, number]; max: [number, number] } };
126
+ }
127
+ export interface CameraFitReport {
128
+ schemaVersion: 'deepblend.camera-fit/v1'; entityIds: string[]; assetInstanceIds: string[];
129
+ frame: number; cameraId: string; fittedCameraId: string; margin: number;
130
+ checkpointSha256: string; checkpointUnchanged: true; blenderVersion: string; members: CameraFitMember[];
131
+ view: { resolution: [number, number]; percentage: number; pixelAspect: [number, number]; activeCamera: string | null };
132
+ camera: { id: string; lens: number; sensorWidth: number; sensorHeight: number; sensorFit: 'AUTO' | 'HORIZONTAL' | 'VERTICAL';
133
+ shift: [number, number]; clipping: [number, number]; fStop?: number; matrixWorld: number[][];
134
+ focusDistance: number; focusObject: string | null };
135
+ proposal?: import('./schema-types.js').Camera;
136
+ baselineVerification?: { checkpointSha256: string; checkpointUnchanged: true; selectedGeometryUnchanged: true;
137
+ originalObjectsUnchanged: true; opticsAndRotationPreserved: true; maxVertexErrorMeters: number;
138
+ toleranceMeters: number; originalObjectCount: number };
139
+ }
115
140
  /** Read-only world-Z placement over complete evaluated meshes at one explicit frame. */
116
141
  export type SurfacePlacementRequest = RuntimeOptions & {
117
142
  checkpointPath: string; checkpointSha256: string; subjectEntityId: string; supportEntityId: string;
@@ -297,6 +322,8 @@ export interface LocalBlenderRuntime extends BlenderRuntime {
297
322
  inspectSurfacePlacement?(request: SurfacePlacementRequest): Promise<RuntimeActionResult<SurfacePlacementReport>>;
298
323
  /** Complete explicit member union and optional rigid candidate proof, always in an isolated batch. */
299
324
  inspectAssemblyPlacement?(request: AssemblyPlacementRequest): Promise<RuntimeActionResult<AssemblyPlacementReport>>;
325
+ /** Read-only proposal or independent full-mesh verification of one static fitted view. */
326
+ inspectCameraFit?(request: CameraFitRequest): Promise<RuntimeActionResult<CameraFitReport>>;
300
327
  runBootstrap(request: BlenderBootstrapRequest, options?: BootstrapOptions): Promise<BootstrapRunOutcome>;
301
328
  openSession(options?: RuntimeOptions & { cwd?: string; args?: string[] }): Promise<BlenderSession>;
302
329
  attachSession(socketPath: string, options?: { timeoutMs?: number }): Promise<BlenderSession>;
@@ -225,7 +225,7 @@ export const CAMERA_TARGET_UPDATE_HINT =
225
225
  'Retarget or clear cameras before removing their target entities.'
226
226
 
227
227
  export const CAMERA_UPDATE_FIELDS = Object.freeze([
228
- 'lens', 'sensorWidth', 'clipping', 'transform', 'targetEntityId', 'targetPoint', 'clearTarget', 'fStop', 'role',
228
+ 'lens', 'sensorWidth', 'sensorHeight', 'sensorFit', 'shift', 'clipping', 'transform', 'targetEntityId', 'targetPoint', 'clearTarget', 'fStop', 'focusDistance', 'role',
229
229
  ])
230
230
 
231
231
  /** Build an anchored error for a failed operation. */
@@ -1,7 +1,7 @@
1
1
  /** Generated by deepblend/tools/generate-sdk-types.mjs. Do not edit.
2
2
  * Types describe JSON shape. Numeric bounds, ID grammar and references still require validation. */
3
3
 
4
- /** Source SHA-256: b15e1b2a9c9080ea5dd8afa5453ab9a2e6465410fc072d6d2ec7e6dcba1001a5 */
4
+ /** Source SHA-256: a2bc3f59a2694da379aad5132d38052dfe98d2b690a5e7bf181b4b7d7bfb1d82 */
5
5
  export namespace SceneSpecSchema {
6
6
  export type Id = string;
7
7
  export type World = { "color"?: SceneSpecSchema.UnitColor; "strength"?: number; "environment"?: { "assetId": SceneSpecSchema.Id; "rotation"?: number; }; };
@@ -18,7 +18,7 @@ export namespace SceneSpecSchema {
18
18
  export type Generator = { "shape": "cube" | "uv_sphere" | "cylinder" | "cone" | "plane" | "torus" | "rounded_box" | "lathe" | "curve" | "handled_cup" | "mesh"; "size"?: SceneSpecSchema.PositiveNumber; "radius"?: SceneSpecSchema.PositiveNumber; "depth"?: SceneSpecSchema.PositiveNumber; "segments"?: number; "ringCount"?: number; "majorRadius"?: SceneSpecSchema.PositiveNumber; "minorRadius"?: SceneSpecSchema.PositiveNumber; "bevel"?: { "width"?: SceneSpecSchema.PositiveNumber; "segments"?: number; }; "profile"?: Array<[number, number]>; "closedProfile"?: boolean; "capEnds"?: boolean; "path"?: Array<SceneSpecSchema.Vec3>; "pathClosed"?: boolean; "pathInterpolation"?: "poly" | "bezier"; "curveResolution"?: number; "bevelResolution"?: number; "height"?: SceneSpecSchema.PositiveNumber; "wallThickness"?: SceneSpecSchema.PositiveNumber; "baseThickness"?: SceneSpecSchema.PositiveNumber; "footRound"?: SceneSpecSchema.PositiveNumber; "handleRadius"?: SceneSpecSchema.PositiveNumber; "handleLower"?: SceneSpecSchema.PositiveNumber; "handleUpper"?: SceneSpecSchema.PositiveNumber; "rootRadius"?: SceneSpecSchema.PositiveNumber; "rootLength"?: SceneSpecSchema.PositiveNumber; "sectionSegments"?: number; "handleSegments"?: number; "rootSegments"?: number; "wallRows"?: number; "rootTension"?: number; "dimensions"?: [SceneSpecSchema.PositiveNumber, SceneSpecSchema.PositiveNumber, SceneSpecSchema.PositiveNumber]; "vertices"?: Array<[number, number, number]>; "faces"?: Array<Array<number>>; "faceUvs"?: Array<Array<[number, number]>>; "smooth"?: boolean; };
19
19
  export type Entity = { "id": SceneSpecSchema.Id; "type": "asset-instance" | "generator" | "empty"; "assetId"?: string; "armatureId"?: string; "rigidBody"?: SceneSpecSchema.RigidBody; "cloth"?: SceneSpecSchema.Cloth; "softBody"?: SceneSpecSchema.SoftBody; "fluid"?: SceneSpecSchema.Fluid; "generator"?: SceneSpecSchema.Generator; "materialId"?: string; "transform"?: SceneSpecSchema.Transform; "tags"?: Array<string>; "locked"?: boolean; "visible"?: boolean; "modifiers"?: Array<SceneSpecSchema.ModelModifier>; "materialBindings"?: SceneSpecSchema.MaterialBindings; };
20
20
  export type Light = { "id": SceneSpecSchema.Id; "type": "area" | "point" | "spot" | "sun"; "transform"?: SceneSpecSchema.Transform; "energy"?: SceneSpecSchema.NonNegativeNumber; "color"?: SceneSpecSchema.UnitColor; "size"?: SceneSpecSchema.PositiveNumber; "spotSize"?: number; "spotBlend"?: number; "angle"?: number; };
21
- export type Camera = { "id": SceneSpecSchema.Id; "role"?: "active-camera" | "three-quarter" | "top" | "detail"; "lens"?: SceneSpecSchema.PositiveNumber; "sensorWidth"?: SceneSpecSchema.PositiveNumber; "clipping"?: [SceneSpecSchema.PositiveNumber, SceneSpecSchema.PositiveNumber]; "transform"?: SceneSpecSchema.Transform; "targetEntityId"?: string; "targetPoint"?: SceneSpecSchema.Vec3; "fStop"?: SceneSpecSchema.PositiveNumber; };
21
+ export type Camera = { "id": SceneSpecSchema.Id; "role"?: "active-camera" | "three-quarter" | "top" | "detail"; "lens"?: SceneSpecSchema.PositiveNumber; "sensorWidth"?: SceneSpecSchema.PositiveNumber; "clipping"?: [SceneSpecSchema.PositiveNumber, SceneSpecSchema.PositiveNumber]; "transform"?: SceneSpecSchema.Transform; "targetEntityId"?: string; "targetPoint"?: SceneSpecSchema.Vec3; "fStop"?: SceneSpecSchema.PositiveNumber; "sensorHeight"?: SceneSpecSchema.PositiveNumber; "sensorFit"?: "AUTO" | "HORIZONTAL" | "VERTICAL"; "shift"?: [number, number]; "focusDistance"?: SceneSpecSchema.PositiveNumber; };
22
22
  export type Shot = { "id": SceneSpecSchema.Id; "cameraId": string; "frameRange"?: [number, number]; "description"?: string; };
23
23
  export type AnimationKeyframe = { "frame": number; "value": number; "interpolation"?: "constant" | "linear" | "bezier" | "ease_in" | "ease_out" | "ease_in_out"; };
24
24
  export type AnimationTrack = { "id": SceneSpecSchema.Id; "targetKind"?: "entity" | "camera" | "material" | "bone"; "targetEntityId": string; "boneName"?: string; "property": "location.x" | "location.y" | "location.z" | "rotationEuler.x" | "rotationEuler.y" | "rotationEuler.z" | "scale.x" | "scale.y" | "scale.z" | "emissionStrength" | "roughness" | "metallic" | "ior" | "alpha" | "coatWeight" | "transmissionWeight" | "baseColor.r" | "baseColor.g" | "baseColor.b" | "emissionColor.r" | "emissionColor.g" | "emissionColor.b" | "anisotropic" | "anisotropicRotation"; "keyframes": Array<SceneSpecSchema.AnimationKeyframe>; };
@@ -42,7 +42,7 @@ export namespace SceneSpecSchema {
42
42
  }
43
43
  export type SceneSpec = SceneSpecSchema.Document;
44
44
 
45
- /** Source SHA-256: c11618c1c6e68d350405702b81768c784298451bf9049a51aba5fac2df019d87 */
45
+ /** Source SHA-256: 6e1f090ae9901b2ba9e97575cea9a4e39657c604c07b7854c3d4000667e123f9 */
46
46
  export namespace ScenePatchSchema {
47
47
  export type Id = string;
48
48
  export type License = { "source"?: string; "commercialUse"?: boolean; "attribution"?: string; };
@@ -57,10 +57,10 @@ export namespace ScenePatchSchema {
57
57
  export type Generator = { "shape": "cube" | "uv_sphere" | "cylinder" | "cone" | "plane" | "torus" | "rounded_box" | "lathe" | "curve" | "handled_cup" | "mesh"; "size"?: ScenePatchSchema.PositiveNumber; "radius"?: ScenePatchSchema.PositiveNumber; "depth"?: ScenePatchSchema.PositiveNumber; "segments"?: number; "ringCount"?: number; "majorRadius"?: ScenePatchSchema.PositiveNumber; "minorRadius"?: ScenePatchSchema.PositiveNumber; "bevel"?: { "width"?: ScenePatchSchema.PositiveNumber; "segments"?: number; }; "profile"?: Array<[number, number]>; "closedProfile"?: boolean; "capEnds"?: boolean; "path"?: Array<ScenePatchSchema.Vec3>; "pathClosed"?: boolean; "pathInterpolation"?: "poly" | "bezier"; "curveResolution"?: number; "bevelResolution"?: number; "height"?: ScenePatchSchema.PositiveNumber; "wallThickness"?: ScenePatchSchema.PositiveNumber; "baseThickness"?: ScenePatchSchema.PositiveNumber; "footRound"?: ScenePatchSchema.PositiveNumber; "handleRadius"?: ScenePatchSchema.PositiveNumber; "handleLower"?: ScenePatchSchema.PositiveNumber; "handleUpper"?: ScenePatchSchema.PositiveNumber; "rootRadius"?: ScenePatchSchema.PositiveNumber; "rootLength"?: ScenePatchSchema.PositiveNumber; "sectionSegments"?: number; "handleSegments"?: number; "rootSegments"?: number; "wallRows"?: number; "rootTension"?: number; "dimensions"?: [ScenePatchSchema.PositiveNumber, ScenePatchSchema.PositiveNumber, ScenePatchSchema.PositiveNumber]; "vertices"?: Array<[number, number, number]>; "faces"?: Array<Array<number>>; "faceUvs"?: Array<Array<[number, number]>>; "smooth"?: boolean; };
58
58
  export type Entity = { "id": ScenePatchSchema.Id; "type": "asset-instance" | "generator" | "empty"; "assetId"?: string; "generator"?: ScenePatchSchema.Generator; "materialId"?: string; "transform"?: { "location"?: ScenePatchSchema.Vec3; "rotationEuler"?: ScenePatchSchema.Vec3; "scale"?: ScenePatchSchema.Vec3; }; "tags"?: Array<string>; "locked"?: boolean; "visible"?: boolean; "modifiers"?: Array<ScenePatchSchema.ModelModifier>; "materialBindings"?: ScenePatchSchema.MaterialBindings; };
59
59
  export type Light = { "id": ScenePatchSchema.Id; "type": "area" | "point" | "spot" | "sun"; "transform"?: { "location"?: ScenePatchSchema.Vec3; "rotationEuler"?: ScenePatchSchema.Vec3; "scale"?: ScenePatchSchema.Vec3; }; "energy"?: ScenePatchSchema.NonNegativeNumber; "color"?: ScenePatchSchema.UnitColor; "size"?: ScenePatchSchema.PositiveNumber; "spotSize"?: number; "spotBlend"?: number; "angle"?: number; };
60
- export type Camera = { "id": ScenePatchSchema.Id; "role"?: "active-camera" | "three-quarter" | "top" | "detail"; "lens"?: ScenePatchSchema.PositiveNumber; "sensorWidth"?: ScenePatchSchema.PositiveNumber; "clipping"?: [ScenePatchSchema.PositiveNumber, ScenePatchSchema.PositiveNumber]; "transform"?: { "location"?: ScenePatchSchema.Vec3; "rotationEuler"?: ScenePatchSchema.Vec3; "scale"?: ScenePatchSchema.Vec3; }; "targetEntityId"?: string; "targetPoint"?: ScenePatchSchema.Vec3; "fStop"?: ScenePatchSchema.PositiveNumber; };
60
+ export type Camera = { "id": ScenePatchSchema.Id; "role"?: "active-camera" | "three-quarter" | "top" | "detail"; "lens"?: ScenePatchSchema.PositiveNumber; "sensorWidth"?: ScenePatchSchema.PositiveNumber; "clipping"?: [ScenePatchSchema.PositiveNumber, ScenePatchSchema.PositiveNumber]; "transform"?: { "location"?: ScenePatchSchema.Vec3; "rotationEuler"?: ScenePatchSchema.Vec3; "scale"?: ScenePatchSchema.Vec3; }; "targetEntityId"?: string; "targetPoint"?: ScenePatchSchema.Vec3; "fStop"?: ScenePatchSchema.PositiveNumber; "sensorHeight"?: ScenePatchSchema.PositiveNumber; "sensorFit"?: "AUTO" | "HORIZONTAL" | "VERTICAL"; "shift"?: [number, number]; "focusDistance"?: ScenePatchSchema.PositiveNumber; };
61
61
  export type AnimationTrack = { "id": ScenePatchSchema.Id; "targetKind"?: "entity" | "camera" | "material"; "targetEntityId": string; "property": "location.x" | "location.y" | "location.z" | "rotationEuler.x" | "rotationEuler.y" | "rotationEuler.z" | "scale.x" | "scale.y" | "scale.z" | "emissionStrength" | "roughness" | "metallic" | "ior" | "alpha" | "coatWeight" | "transmissionWeight" | "baseColor.r" | "baseColor.g" | "baseColor.b" | "emissionColor.r" | "emissionColor.g" | "emissionColor.b" | "anisotropic" | "anisotropicRotation"; "keyframes": Array<{ "frame": number; "value": number; "interpolation"?: "constant" | "linear" | "bezier" | "ease_in" | "ease_out" | "ease_in_out"; }>; };
62
62
  export type RenderProfile = { "engine"?: "eevee" | "cycles" | "workbench"; "resolution"?: [number, number]; "samples"?: number; "filmTransparent"?: boolean; "colorManagement"?: { "viewTransform"?: "Standard" | "AgX" | "Filmic" | "False Color" | "Raw"; "look"?: string; "exposure"?: number; }; "maxSamplesBudget"?: number; "raytracing"?: boolean; };
63
- export type Operation = ({ "op": "entity.transform.update"; "entityId": ScenePatchSchema.Id; "location"?: ScenePatchSchema.Vec3; "rotationEuler"?: ScenePatchSchema.Vec3; "scale"?: ScenePatchSchema.Vec3; }) | ({ "op": "entity.visibility.set"; "entityId": ScenePatchSchema.Id; "visible": boolean; }) | ({ "op": "entity.tags.set"; "entityId": ScenePatchSchema.Id; "tags": Array<string>; }) | ({ "op": "entity.add"; "entity": ScenePatchSchema.Entity; }) | ({ "op": "entity.remove"; "entityId": ScenePatchSchema.Id; }) | ({ "op": "entity.material.set"; "entityId": ScenePatchSchema.Id; "materialId": string | null; }) | ({ "op": "material.texture.set"; "materialId": ScenePatchSchema.Id; "texture": (ScenePatchSchema.ProceduralTexture) | (null); }) | ({ "op": "material.add"; "material": { "id": ScenePatchSchema.Id; "shader": "principled" | "emission" | "glass"; "parameters"?: ScenePatchSchema.MaterialParameters; "texture"?: ScenePatchSchema.ProceduralTexture; "images"?: ScenePatchSchema.MaterialImages; "tangent"?: ScenePatchSchema.MaterialTangent; }; }) | ({ "op": "material.parameter.update"; "materialId": ScenePatchSchema.Id; "parameter": "baseColor" | "metallic" | "roughness" | "ior" | "alpha" | "emissionColor" | "emissionStrength" | "coatWeight" | "transmissionWeight" | "anisotropic" | "anisotropicRotation"; "value": (number) | (ScenePatchSchema.UnitColor); }) | ({ "op": "light.add"; "light": ScenePatchSchema.Light; }) | ({ "op": "light.update"; "lightId": ScenePatchSchema.Id; "transform"?: { "location"?: ScenePatchSchema.Vec3; "rotationEuler"?: ScenePatchSchema.Vec3; "scale"?: ScenePatchSchema.Vec3; }; "energy"?: ScenePatchSchema.NonNegativeNumber; "color"?: ScenePatchSchema.UnitColor; "size"?: ScenePatchSchema.PositiveNumber; "spotSize"?: number; "spotBlend"?: number; "angle"?: number; }) | ({ "op": "light.remove"; "lightId": ScenePatchSchema.Id; }) | ({ "op": "camera.add"; "camera": ScenePatchSchema.Camera; }) | ({ "op": "camera.update"; "cameraId": ScenePatchSchema.Id; "role"?: "active-camera" | "three-quarter" | "top" | "detail"; "lens"?: ScenePatchSchema.PositiveNumber; "sensorWidth"?: ScenePatchSchema.PositiveNumber; "clipping"?: [ScenePatchSchema.PositiveNumber, ScenePatchSchema.PositiveNumber]; "transform"?: { "location"?: ScenePatchSchema.Vec3; "rotationEuler"?: ScenePatchSchema.Vec3; "scale"?: ScenePatchSchema.Vec3; }; "targetEntityId"?: string; "targetPoint"?: ScenePatchSchema.Vec3; "fStop"?: ScenePatchSchema.PositiveNumber; "clearTarget"?: true; }) | ({ "op": "camera.remove"; "cameraId": ScenePatchSchema.Id; }) | ({ "op": "animation.track.set"; "track": ScenePatchSchema.AnimationTrack; }) | ({ "op": "animation.track.remove"; "trackId": ScenePatchSchema.Id; }) | ({ "op": "shot.set"; "shot": { "id": ScenePatchSchema.Id; "cameraId": string; "frameRange"?: [number, number]; "description"?: string; }; }) | ({ "op": "shot.remove"; "shotId": ScenePatchSchema.Id; }) | ({ "op": "project.frameRange.set"; "frameStart": number; "frameEnd": number; "fps"?: number; }) | ({ "op": "render.profile.set"; "profileName": "preview" | "final"; "profile": ScenePatchSchema.RenderProfile; }) | ({ "op": "world.set"; "world": ScenePatchSchema.World; }) | ({ "op": "asset.add"; "asset": { "id": ScenePatchSchema.Id; "type": "glb" | "gltf" | "fbx" | "obj" | "usd" | "blend" | "png" | "jpg" | "jpeg" | "hdr" | "exr"; "path": string; "sha256"?: string; "license"?: ScenePatchSchema.License; }; }) | ({ "op": "asset.remove"; "assetId": ScenePatchSchema.Id; }) | ({ "op": "entity.generator.set"; "entityId": ScenePatchSchema.Id; "generator": ScenePatchSchema.Generator; }) | ({ "op": "entity.modifiers.set"; "entityId": ScenePatchSchema.Id; "modifiers": Array<ScenePatchSchema.ModelModifier>; }) | ({ "op": "material.images.set"; "materialId": ScenePatchSchema.Id; "images": (ScenePatchSchema.MaterialImages) | (null); }) | ({ "op": "entity.materialBindings.set"; "entityId": ScenePatchSchema.Id; "materialBindings": ScenePatchSchema.MaterialBindings; }) | ({ "op": "material.tangent.set"; "materialId": ScenePatchSchema.Id; "tangent": (ScenePatchSchema.MaterialTangent) | (null); }) | ({ "op": "project.brief.set"; "goal": string; "referenceImages": ScenePatchSchema.ReferenceImages; }) | ({ "op": "project.reviewSubject.set"; "entityId": (ScenePatchSchema.Id) | (null); });
63
+ export type Operation = ({ "op": "entity.transform.update"; "entityId": ScenePatchSchema.Id; "location"?: ScenePatchSchema.Vec3; "rotationEuler"?: ScenePatchSchema.Vec3; "scale"?: ScenePatchSchema.Vec3; }) | ({ "op": "entity.visibility.set"; "entityId": ScenePatchSchema.Id; "visible": boolean; }) | ({ "op": "entity.tags.set"; "entityId": ScenePatchSchema.Id; "tags": Array<string>; }) | ({ "op": "entity.add"; "entity": ScenePatchSchema.Entity; }) | ({ "op": "entity.remove"; "entityId": ScenePatchSchema.Id; }) | ({ "op": "entity.material.set"; "entityId": ScenePatchSchema.Id; "materialId": string | null; }) | ({ "op": "material.texture.set"; "materialId": ScenePatchSchema.Id; "texture": (ScenePatchSchema.ProceduralTexture) | (null); }) | ({ "op": "material.add"; "material": { "id": ScenePatchSchema.Id; "shader": "principled" | "emission" | "glass"; "parameters"?: ScenePatchSchema.MaterialParameters; "texture"?: ScenePatchSchema.ProceduralTexture; "images"?: ScenePatchSchema.MaterialImages; "tangent"?: ScenePatchSchema.MaterialTangent; }; }) | ({ "op": "material.parameter.update"; "materialId": ScenePatchSchema.Id; "parameter": "baseColor" | "metallic" | "roughness" | "ior" | "alpha" | "emissionColor" | "emissionStrength" | "coatWeight" | "transmissionWeight" | "anisotropic" | "anisotropicRotation"; "value": (number) | (ScenePatchSchema.UnitColor); }) | ({ "op": "light.add"; "light": ScenePatchSchema.Light; }) | ({ "op": "light.update"; "lightId": ScenePatchSchema.Id; "transform"?: { "location"?: ScenePatchSchema.Vec3; "rotationEuler"?: ScenePatchSchema.Vec3; "scale"?: ScenePatchSchema.Vec3; }; "energy"?: ScenePatchSchema.NonNegativeNumber; "color"?: ScenePatchSchema.UnitColor; "size"?: ScenePatchSchema.PositiveNumber; "spotSize"?: number; "spotBlend"?: number; "angle"?: number; }) | ({ "op": "light.remove"; "lightId": ScenePatchSchema.Id; }) | ({ "op": "camera.add"; "camera": ScenePatchSchema.Camera; }) | ({ "op": "camera.update"; "cameraId": ScenePatchSchema.Id; "role"?: "active-camera" | "three-quarter" | "top" | "detail"; "lens"?: ScenePatchSchema.PositiveNumber; "sensorWidth"?: ScenePatchSchema.PositiveNumber; "clipping"?: [ScenePatchSchema.PositiveNumber, ScenePatchSchema.PositiveNumber]; "transform"?: { "location"?: ScenePatchSchema.Vec3; "rotationEuler"?: ScenePatchSchema.Vec3; "scale"?: ScenePatchSchema.Vec3; }; "targetEntityId"?: string; "targetPoint"?: ScenePatchSchema.Vec3; "fStop"?: ScenePatchSchema.PositiveNumber; "clearTarget"?: true; "sensorHeight"?: ScenePatchSchema.PositiveNumber; "sensorFit"?: "AUTO" | "HORIZONTAL" | "VERTICAL"; "shift"?: [number, number]; "focusDistance"?: ScenePatchSchema.PositiveNumber; }) | ({ "op": "camera.remove"; "cameraId": ScenePatchSchema.Id; }) | ({ "op": "animation.track.set"; "track": ScenePatchSchema.AnimationTrack; }) | ({ "op": "animation.track.remove"; "trackId": ScenePatchSchema.Id; }) | ({ "op": "shot.set"; "shot": { "id": ScenePatchSchema.Id; "cameraId": string; "frameRange"?: [number, number]; "description"?: string; }; }) | ({ "op": "shot.remove"; "shotId": ScenePatchSchema.Id; }) | ({ "op": "project.frameRange.set"; "frameStart": number; "frameEnd": number; "fps"?: number; }) | ({ "op": "render.profile.set"; "profileName": "preview" | "final"; "profile": ScenePatchSchema.RenderProfile; }) | ({ "op": "world.set"; "world": ScenePatchSchema.World; }) | ({ "op": "asset.add"; "asset": { "id": ScenePatchSchema.Id; "type": "glb" | "gltf" | "fbx" | "obj" | "usd" | "blend" | "png" | "jpg" | "jpeg" | "hdr" | "exr"; "path": string; "sha256"?: string; "license"?: ScenePatchSchema.License; }; }) | ({ "op": "asset.remove"; "assetId": ScenePatchSchema.Id; }) | ({ "op": "entity.generator.set"; "entityId": ScenePatchSchema.Id; "generator": ScenePatchSchema.Generator; }) | ({ "op": "entity.modifiers.set"; "entityId": ScenePatchSchema.Id; "modifiers": Array<ScenePatchSchema.ModelModifier>; }) | ({ "op": "material.images.set"; "materialId": ScenePatchSchema.Id; "images": (ScenePatchSchema.MaterialImages) | (null); }) | ({ "op": "entity.materialBindings.set"; "entityId": ScenePatchSchema.Id; "materialBindings": ScenePatchSchema.MaterialBindings; }) | ({ "op": "material.tangent.set"; "materialId": ScenePatchSchema.Id; "tangent": (ScenePatchSchema.MaterialTangent) | (null); }) | ({ "op": "project.brief.set"; "goal": string; "referenceImages": ScenePatchSchema.ReferenceImages; }) | ({ "op": "project.reviewSubject.set"; "entityId": (ScenePatchSchema.Id) | (null); });
64
64
  export type ModelModifier = ({ "type": "solidify"; "thickness": number; "offset"?: number; }) | ({ "type": "mirror"; "axis": "x" | "y" | "z"; "merge"?: boolean; }) | ({ "type": "array"; "count": number; "offset": ScenePatchSchema.Vec3; }) | ({ "type": "boolean"; "operation": "union" | "difference" | "intersect"; "targetEntityId": ScenePatchSchema.Id; }) | ({ "type": "bevel"; "width": number; "segments"?: number; "angle"?: number; "miterInner"?: "arc" | "sharp"; }) | ({ "type": "subdivision"; "levels": number; "scheme"?: "catmull-clark" | "simple"; "boundaryMode"?: "all" | "preserve-corners"; }) | ({ "type": "surface_scatter"; "targetEntityIds": Array<ScenePatchSchema.Id>; "count": number; "seed"?: number; "anchorVertexIndices": Array<number>; "embedDepthMm"?: number; "scaleRange"?: [number, number]; "upwardBias"?: number; });
65
65
  export type ImageBinding = { "assetId": ScenePatchSchema.Id; "scale"?: ScenePatchSchema.Vec3; "offset"?: ScenePatchSchema.Vec3; "uvMap"?: string; "channel"?: "r" | "g" | "b" | "a"; "strength"?: number; };
66
66
  export type MaterialImages = { "baseColor"?: ScenePatchSchema.ImageBinding; "roughness"?: ScenePatchSchema.ImageBinding; "metallic"?: ScenePatchSchema.ImageBinding; "normal"?: ScenePatchSchema.ImageBinding; "alpha"?: ScenePatchSchema.ImageBinding; "emissionColor"?: ScenePatchSchema.ImageBinding; };
@@ -775,6 +775,29 @@
775
775
  },
776
776
  "fStop": {
777
777
  "$ref": "#/$defs/positiveNumber"
778
+ },
779
+ "sensorHeight": {
780
+ "$ref": "#/$defs/positiveNumber"
781
+ },
782
+ "sensorFit": {
783
+ "type": "string",
784
+ "enum": [
785
+ "AUTO",
786
+ "HORIZONTAL",
787
+ "VERTICAL"
788
+ ]
789
+ },
790
+ "shift": {
791
+ "type": "array",
792
+ "minItems": 2,
793
+ "maxItems": 2,
794
+ "items": {
795
+ "type": "number"
796
+ }
797
+ },
798
+ "focusDistance": {
799
+ "$ref": "#/$defs/positiveNumber",
800
+ "description": "Explicit focus distance in metres. With fStop, overrides automatic target focus without changing camera aim."
778
801
  }
779
802
  }
780
803
  },
@@ -1360,6 +1383,29 @@
1360
1383
  "type": "boolean",
1361
1384
  "const": true,
1362
1385
  "description": "Explicitly return to free rotation by removing both aim targets. Cannot accompany targetEntityId or targetPoint."
1386
+ },
1387
+ "sensorHeight": {
1388
+ "$ref": "#/$defs/positiveNumber"
1389
+ },
1390
+ "sensorFit": {
1391
+ "type": "string",
1392
+ "enum": [
1393
+ "AUTO",
1394
+ "HORIZONTAL",
1395
+ "VERTICAL"
1396
+ ]
1397
+ },
1398
+ "shift": {
1399
+ "type": "array",
1400
+ "minItems": 2,
1401
+ "maxItems": 2,
1402
+ "items": {
1403
+ "type": "number"
1404
+ }
1405
+ },
1406
+ "focusDistance": {
1407
+ "$ref": "#/$defs/positiveNumber",
1408
+ "description": "Explicit focus distance in metres. With fStop, overrides automatic target focus without changing camera aim."
1363
1409
  }
1364
1410
  }
1365
1411
  },
@@ -946,6 +946,29 @@
946
946
  },
947
947
  "fStop": {
948
948
  "$ref": "#/$defs/positiveNumber"
949
+ },
950
+ "sensorHeight": {
951
+ "$ref": "#/$defs/positiveNumber"
952
+ },
953
+ "sensorFit": {
954
+ "type": "string",
955
+ "enum": [
956
+ "AUTO",
957
+ "HORIZONTAL",
958
+ "VERTICAL"
959
+ ]
960
+ },
961
+ "shift": {
962
+ "type": "array",
963
+ "minItems": 2,
964
+ "maxItems": 2,
965
+ "items": {
966
+ "type": "number"
967
+ }
968
+ },
969
+ "focusDistance": {
970
+ "$ref": "#/$defs/positiveNumber",
971
+ "description": "Explicit focus distance in metres. With fStop, overrides automatic target focus without changing camera aim."
949
972
  }
950
973
  }
951
974
  },
package/lib/sdk.d.ts CHANGED
@@ -5,7 +5,12 @@ import type {
5
5
  } from './schema-types.js';
6
6
  export type * from './schema-types.js';
7
7
  export type * from './runtime-types.js';
8
- import type { ShotCameraSelection, AssemblyPlacementPose, AssemblyPlacementRequest, AssemblyPlacementReport } from './runtime-types.js';
8
+ import type { ShotCameraSelection, AssemblyPlacementPose, AssemblyPlacementRequest, AssemblyPlacementReport, CameraFitRequest, CameraFitReport } from './runtime-types.js';
9
+ export const CAMERA_FIT_VERSION: 'deepblend.camera-fit/v1';
10
+ export const CAMERA_FIT_LIMITS: Readonly<{ entities: 64; meshes: 128; vertices: 2000000;
11
+ checkpointBytes: number; reportBytes: number; toleranceMeters: 0.00002 }>;
12
+ export function validateCameraFitSelection(request: CameraFitRequest): void;
13
+ export function verifyCameraFitReport(report: unknown, request: CameraFitRequest): CameraFitReport;
9
14
  export const SHOT_CAMERA_SELECTION_VERSION: 'deepblend.shot-camera-selection/v1';
10
15
  export const SHOT_CAMERA_SELECTION_LIMITS: { readonly shots: 64; readonly bytes: 8192 };
11
16
  export function buildShotCameraSelection(spec: Pick<SceneSpec, 'cameras' | 'shots'>, frames: number[]): ShotCameraSelection;
package/lib/sdk.js CHANGED
@@ -5,6 +5,7 @@ import { BlenderError, BlenderErrorCode } from './index.js'
5
5
  import { validateRecipeManifest, RecipeError } from './recipe.js'
6
6
  export { SHOT_CAMERA_SELECTION_VERSION, SHOT_CAMERA_SELECTION_LIMITS, buildShotCameraSelection,
7
7
  normalizeShotCameraSelection, shotCameraForFrame } from './shot-render-selection.js'
8
+ export { CAMERA_FIT_VERSION, CAMERA_FIT_LIMITS, validateCameraFitSelection, verifyCameraFitReport } from './camera-fit.js'
8
9
 
9
10
  export {
10
11
  BLENDER_PROTOCOL_VERSION, SCENE_SCHEMA_VERSION, SCENE_PATCH_VERSION, HOST_API_VERSION,
package/lib/ui-api.js CHANGED
@@ -86,6 +86,7 @@ export const UI_ROUTES = Object.freeze([
86
86
  { id: 'project.recipeParameters', method: 'GET', path: '/deepblend/projects/:projectId/recipe-parameters', write: false, summary: 'Read saved assembly controls at one revision.' },
87
87
  { id: 'project.recipeParameters.update', method: 'POST', path: '/deepblend/projects/:projectId/recipe-parameters', write: true, summary: 'Save bounded assembly dimensions as an atomic revision.' },
88
88
  { id: 'project.surfacePlacement', method: 'POST', path: '/deepblend/projects/:projectId/surface-placement', write: true, summary: 'Measure and save an explicit entity or complete supported lamp placement.' },
89
+ { id: 'project.cameraFit', method: 'POST', path: '/deepblend/projects/:projectId/camera-fit', write: true, summary: 'Save a new static camera after independently verifying complete selected geometry fits the frame.' },
89
90
  { id: 'project.restore', method: 'POST', path: '/deepblend/projects/:projectId/restore', write: true, summary: 'Move the current revision pointer to a saved revision, preserving history without creating a new revision.' },
90
91
  { id: 'project.jobs', method: 'GET', path: '/deepblend/projects/:projectId/jobs', write: false, summary: 'Render/export jobs of a project.' },
91
92
  { id: 'project.job', method: 'GET', path: '/deepblend/projects/:projectId/jobs/:jobId', write: false, summary: 'One job with its live progress.' },
@@ -927,6 +928,7 @@ export const UI_TOOL_CARD_KEYS = Object.freeze([
927
928
  'blender_scene_get',
928
929
  'blender_scene_patch',
929
930
  'blender_place_on_surface',
931
+ 'blender_camera_fit',
930
932
  'blender_preview_render',
931
933
  'blender_scene_validate',
932
934
  'blender_revision_restore',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deepblend/dsh-blender-contracts",
3
- "version": "0.21.0",
3
+ "version": "0.22.0",
4
4
  "type": "module",
5
5
  "description": "DeepBlend Studio Service Definition, protocol contracts, and stable error codes.",
6
6
  "main": "lib/index.js",