@deepblend/dsh-blender-contracts 0.21.0 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/camera-fit.js +94 -0
- package/lib/index.js +1 -0
- package/lib/mesh-uv.js +69 -0
- package/lib/runtime-types.d.ts +27 -0
- package/lib/scene-patch.js +21 -1
- package/lib/schema-types.d.ts +5 -5
- package/lib/schemas/scene-patch.schema.json +74 -0
- package/lib/schemas/scene-spec.schema.json +23 -0
- package/lib/sdk.d.ts +6 -1
- package/lib/sdk.js +1 -0
- package/lib/ui-api.js +2 -0
- package/package.json +1 -1
|
@@ -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'
|
package/lib/mesh-uv.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { meshGeneratorIssues } from './mesh-geometry.js'
|
|
2
|
+
|
|
3
|
+
const subtract = (a, b) => a.map((value, axis) => value - b[axis])
|
|
4
|
+
const dot = (a, b) => a.reduce((sum, value, axis) => sum + value * b[axis], 0)
|
|
5
|
+
const cross = (a, b) => [a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]]
|
|
6
|
+
const unit = vector => {
|
|
7
|
+
const length = Math.hypot(...vector)
|
|
8
|
+
if (!(length > 0)) throw new Error('face has no stable projection direction')
|
|
9
|
+
return vector.map(value => value / length)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** Explicit corner UVs, leaving control geometry and legacy missing-UV behavior alone.
|
|
13
|
+
* Each planar face starts at (0, 0); islands overlap intentionally for repeating
|
|
14
|
+
* textures. One mesh-wide divisor retains aspect and relative texel density.
|
|
15
|
+
*/
|
|
16
|
+
export function projectMeshFaceUvs(generator, { quarterTurns = 0, scale = 1 } = {}) {
|
|
17
|
+
if (generator?.shape !== 'mesh') throw new Error('UV projection requires a mesh generator')
|
|
18
|
+
if (!Number.isInteger(quarterTurns) || quarterTurns < 0 || quarterTurns > 3
|
|
19
|
+
|| !Number.isFinite(scale) || scale < 0.0001 || scale > 10000) {
|
|
20
|
+
throw new Error('UV projection needs quarterTurns 0–3 and scale 0.0001–10000')
|
|
21
|
+
}
|
|
22
|
+
const { vertices, faces } = generator
|
|
23
|
+
const issues = meshGeneratorIssues({ vertices, faces })
|
|
24
|
+
if (issues.length) throw new Error(issues[0])
|
|
25
|
+
const low = [Infinity, Infinity, Infinity], high = [-Infinity, -Infinity, -Infinity]
|
|
26
|
+
for (const vertex of vertices) for (let axis = 0; axis < 3; axis++) {
|
|
27
|
+
low[axis] = Math.min(low[axis], vertex[axis])
|
|
28
|
+
high[axis] = Math.max(high[axis], vertex[axis])
|
|
29
|
+
}
|
|
30
|
+
const size = Math.max(...high.map((value, axis) => value - low[axis]))
|
|
31
|
+
return faces.map((face, index) => {
|
|
32
|
+
const origin = vertices[face[0]], points = face.map(vertex => subtract(vertices[vertex], origin))
|
|
33
|
+
let normal = [0, 0, 0]
|
|
34
|
+
for (let corner = 1; corner < points.length - 1; corner++) {
|
|
35
|
+
const area = cross(points[corner], points[corner + 1])
|
|
36
|
+
normal = normal.map((value, axis) => value + area[axis])
|
|
37
|
+
}
|
|
38
|
+
normal = unit(normal)
|
|
39
|
+
const span = Math.max(...points.map(point => Math.hypot(...point)))
|
|
40
|
+
if (points.some(point => Math.abs(dot(point, normal)) > span * 1e-6)) {
|
|
41
|
+
throw new Error(`mesh face ${index} is not planar; split it into planar faces before UV projection`)
|
|
42
|
+
}
|
|
43
|
+
let best = null
|
|
44
|
+
for (let corner = 0; corner < points.length; corner++) {
|
|
45
|
+
const edge = subtract(points[(corner + 1) % points.length], points[corner])
|
|
46
|
+
const tangent = edge.map((value, axis) => value - normal[axis] * dot(edge, normal))
|
|
47
|
+
const lengthSquared = dot(tangent, tangent)
|
|
48
|
+
if (!(lengthSquared > 0)) continue
|
|
49
|
+
let direction = unit(tangent)
|
|
50
|
+
const axis = [0, 1, 2].sort((a, b) => Math.abs(direction[b]) - Math.abs(direction[a]) || a - b)[0]
|
|
51
|
+
if (direction[axis] < 0) direction = direction.map(value => -value)
|
|
52
|
+
direction = direction.map(value => value === 0 ? 0 : value)
|
|
53
|
+
const rank = JSON.stringify(direction)
|
|
54
|
+
if (best === null || lengthSquared > best.lengthSquared || lengthSquared === best.lengthSquared && rank < best.rank) {
|
|
55
|
+
best = { lengthSquared, direction, rank }
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (best === null) throw new Error(`mesh face ${index} has no stable edge`)
|
|
59
|
+
const u = best.direction, v = unit(cross(normal, u))
|
|
60
|
+
let coordinates = points.map(point => [dot(point, u) / size * scale, dot(point, v) / size * scale])
|
|
61
|
+
for (let turn = 0; turn < quarterTurns; turn++) coordinates = coordinates.map(([x, y]) => [-y, x])
|
|
62
|
+
const minimum = [0, 1].map(axis => Math.min(...coordinates.map(point => point[axis])))
|
|
63
|
+
return coordinates.map(point => point.map((value, axis) => {
|
|
64
|
+
const result = value - minimum[axis]
|
|
65
|
+
if (!Number.isFinite(result)) throw new Error(`mesh face ${index} produced non-finite UVs`)
|
|
66
|
+
return result === 0 ? 0 : result
|
|
67
|
+
}))
|
|
68
|
+
})
|
|
69
|
+
}
|
package/lib/runtime-types.d.ts
CHANGED
|
@@ -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>;
|
package/lib/scene-patch.js
CHANGED
|
@@ -20,6 +20,7 @@ import { compileSchema, formatIssues } from './json-schema.js'
|
|
|
20
20
|
import { collectionForKind, sceneSpecDigest, specHash } from './scene-spec.js'
|
|
21
21
|
import { referenceImageIssues } from './reference-images.js'
|
|
22
22
|
import { specChangeAudit } from './spec-change-audit.js'
|
|
23
|
+
import { projectMeshFaceUvs } from './mesh-uv.js'
|
|
23
24
|
import scenePatchSchema from './schemas/scene-patch.schema.json' with { type: 'json' }
|
|
24
25
|
|
|
25
26
|
const validatePatchStructure = compileSchema(scenePatchSchema, { id: 'scene-patch.schema.json' })
|
|
@@ -69,6 +70,7 @@ export const SCENE_OPERATION_NAMES = Object.freeze([
|
|
|
69
70
|
'material.tangent.set',
|
|
70
71
|
'project.brief.set',
|
|
71
72
|
'project.reviewSubject.set',
|
|
73
|
+
'entity.uv.project',
|
|
72
74
|
])
|
|
73
75
|
|
|
74
76
|
/** The `id` grammar shared with SceneSpec. */const ID_PATTERN = /^[a-zA-Z][a-zA-Z0-9._-]*$/
|
|
@@ -225,7 +227,7 @@ export const CAMERA_TARGET_UPDATE_HINT =
|
|
|
225
227
|
'Retarget or clear cameras before removing their target entities.'
|
|
226
228
|
|
|
227
229
|
export const CAMERA_UPDATE_FIELDS = Object.freeze([
|
|
228
|
-
'lens', 'sensorWidth', 'clipping', 'transform', 'targetEntityId', 'targetPoint', 'clearTarget', 'fStop', 'role',
|
|
230
|
+
'lens', 'sensorWidth', 'sensorHeight', 'sensorFit', 'shift', 'clipping', 'transform', 'targetEntityId', 'targetPoint', 'clearTarget', 'fStop', 'focusDistance', 'role',
|
|
229
231
|
])
|
|
230
232
|
|
|
231
233
|
/** Build an anchored error for a failed operation. */
|
|
@@ -478,6 +480,24 @@ export function applyPatchToSpec(spec, patch) {
|
|
|
478
480
|
break
|
|
479
481
|
}
|
|
480
482
|
|
|
483
|
+
case 'entity.uv.project': {
|
|
484
|
+
const at = indexOfId(next.entities, operation.entityId)
|
|
485
|
+
if (at < 0) fail('PATCH_TARGET_MISSING', `no entity "${operation.entityId}" exists in this scene`)
|
|
486
|
+
const entity = next.entities[at]
|
|
487
|
+
if (entity.type !== 'generator' || entity.generator?.shape !== 'mesh') {
|
|
488
|
+
fail('PATCH_OPERATION_INVALID', `${op} requires a mesh generator; imported assets and other shapes retain their UVs`)
|
|
489
|
+
}
|
|
490
|
+
let faceUvs
|
|
491
|
+
try { faceUvs = projectMeshFaceUvs(entity.generator, operation) }
|
|
492
|
+
catch (error) { fail('PATCH_OPERATION_INVALID', error.message) }
|
|
493
|
+
const changed = JSON.stringify(entity.generator.faceUvs) !== JSON.stringify(faceUvs)
|
|
494
|
+
if (changed) next.entities[at] = { ...entity, generator: { ...entity.generator, faceUvs } }
|
|
495
|
+
applied.push({ op, target: entity.id,
|
|
496
|
+
summary: changed ? `projected repeating texture UVs per face on entity "${entity.id}"` : `entity "${entity.id}" face UVs already match this projection`,
|
|
497
|
+
changedPaths: changed ? [`entities.${entity.id}.generator.faceUvs`] : [] })
|
|
498
|
+
break
|
|
499
|
+
}
|
|
500
|
+
|
|
481
501
|
case 'entity.generator.set':
|
|
482
502
|
case 'entity.modifiers.set': {
|
|
483
503
|
const at = indexOfId(next.entities, operation.entityId)
|
package/lib/schema-types.d.ts
CHANGED
|
@@ -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:
|
|
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:
|
|
45
|
+
/** Source SHA-256: d2bb4d3c1d1cb8d288d29f94d3458008fe31e0ffed8cd66e1f9936a6fcf593b0 */
|
|
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); }) | ({ "op": "entity.uv.project"; "entityId": ScenePatchSchema.Id; "quarterTurns"?: number; "scale"?: number; });
|
|
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
|
},
|
|
@@ -1781,6 +1827,34 @@
|
|
|
1781
1827
|
]
|
|
1782
1828
|
}
|
|
1783
1829
|
}
|
|
1830
|
+
},
|
|
1831
|
+
{
|
|
1832
|
+
"type": "object",
|
|
1833
|
+
"additionalProperties": false,
|
|
1834
|
+
"required": [
|
|
1835
|
+
"op",
|
|
1836
|
+
"entityId"
|
|
1837
|
+
],
|
|
1838
|
+
"properties": {
|
|
1839
|
+
"op": {
|
|
1840
|
+
"const": "entity.uv.project"
|
|
1841
|
+
},
|
|
1842
|
+
"entityId": {
|
|
1843
|
+
"$ref": "#/$defs/id"
|
|
1844
|
+
},
|
|
1845
|
+
"quarterTurns": {
|
|
1846
|
+
"type": "integer",
|
|
1847
|
+
"minimum": 0,
|
|
1848
|
+
"maximum": 3,
|
|
1849
|
+
"description": "Quarter turns after per-face projection; default 0."
|
|
1850
|
+
},
|
|
1851
|
+
"scale": {
|
|
1852
|
+
"type": "number",
|
|
1853
|
+
"minimum": 0.0001,
|
|
1854
|
+
"maximum": 10000,
|
|
1855
|
+
"description": "UV repetitions per longest local mesh extent; default 1. Larger values repeat the texture more often. Islands overlap and are not packed."
|
|
1856
|
+
}
|
|
1857
|
+
}
|
|
1784
1858
|
}
|
|
1785
1859
|
]
|
|
1786
1860
|
},
|
|
@@ -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