@deepblend/dsh-blender-contracts 0.22.0 → 0.24.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 +8 -3
- package/lib/mesh-uv.js +69 -0
- package/lib/photography-snapshot.js +32 -0
- package/lib/runtime-types.d.ts +5 -0
- package/lib/scene-patch.js +28 -0
- package/lib/schema-types.d.ts +2 -2
- package/lib/schemas/scene-patch.schema.json +37 -0
- package/lib/ui-api.js +15 -2
- package/package.json +1 -1
package/lib/camera-fit.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { BlenderError, BlenderErrorCode } from './index.js'
|
|
2
|
+
import { PHOTOGRAPHY_SNAPSHOT_LIMITS, validatePhotographySnapshot, verifyPhotographySnapshot } from './photography-snapshot.js'
|
|
2
3
|
|
|
3
4
|
export const CAMERA_FIT_VERSION = 'deepblend.camera-fit/v1'
|
|
4
5
|
export const CAMERA_FIT_LIMITS = Object.freeze({ entities: 64, meshes: 128, vertices: 2_000_000,
|
|
@@ -13,15 +14,18 @@ const same = (a, b) => JSON.stringify(a) === JSON.stringify(b)
|
|
|
13
14
|
const fail = (message, code = BlenderErrorCode.SCENE_VALIDATION_FAILED) => { throw new BlenderError(code, `Camera fit: ${message}`) }
|
|
14
15
|
|
|
15
16
|
export function validateCameraFitSelection(request) {
|
|
17
|
+
if (request?.photography !== undefined) validatePhotographySnapshot(request.photography)
|
|
16
18
|
const invalid = message => fail(message, BlenderErrorCode.SCENE_PATCH_INVALID)
|
|
17
|
-
|
|
18
|
-
|
|
19
|
+
const entityLimit = request?.photography === undefined ? CAMERA_FIT_LIMITS.entities : PHOTOGRAPHY_SNAPSHOT_LIMITS.entities
|
|
20
|
+
if (!Array.isArray(request?.entityIds) || !integer(request.entityIds.length, 1, entityLimit) ||
|
|
21
|
+
!request.entityIds.every(id) || new Set(request.entityIds).size !== request.entityIds.length) invalid(`select 1–${entityLimit} distinct mesh entities or complete asset instances.`)
|
|
19
22
|
if (!Array.isArray(request.assetInstanceIds) || request.assetInstanceIds.some(x => !request.entityIds.includes(x)) ||
|
|
20
23
|
new Set(request.assetInstanceIds).size !== request.assetInstanceIds.length) invalid('assetInstanceIds must name distinct selected asset roots.')
|
|
21
24
|
if (!id(request.cameraId) || !id(request.fittedCameraId) || request.cameraId === request.fittedCameraId) invalid('select a source camera and a distinct new camera ID.')
|
|
22
25
|
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
26
|
const baseline = request.baselineCheckpointPath !== undefined || request.baselineCheckpointSha256 !== undefined
|
|
24
27
|
if (baseline && (typeof request.baselineCheckpointPath !== 'string' || !request.baselineCheckpointPath || !hash(request.baselineCheckpointSha256))) invalid('candidate verification requires both the baseline checkpoint path and SHA256.')
|
|
28
|
+
if (baseline && request.photography !== undefined) invalid('photography sampling requires a saved source, not a fitted candidate.')
|
|
25
29
|
}
|
|
26
30
|
|
|
27
31
|
function optics(v) {
|
|
@@ -36,12 +40,13 @@ export function verifyCameraFitReport(report, request) {
|
|
|
36
40
|
validateCameraFitSelection(request)
|
|
37
41
|
const candidate = request.baselineCheckpointPath !== undefined
|
|
38
42
|
if (!only(report, ['schemaVersion', 'entityIds', 'assetInstanceIds', 'frame', 'cameraId', 'fittedCameraId', 'margin',
|
|
39
|
-
'checkpointSha256', 'checkpointUnchanged', 'blenderVersion', 'members', 'view', 'camera', candidate ? 'baselineVerification' : 'proposal']) ||
|
|
43
|
+
'checkpointSha256', 'checkpointUnchanged', 'blenderVersion', 'members', 'view', 'camera', candidate ? 'baselineVerification' : 'proposal', ...(request.photography === undefined ? [] : ['photography'])]) ||
|
|
40
44
|
Buffer.byteLength(JSON.stringify(report)) > CAMERA_FIT_LIMITS.reportBytes || report.schemaVersion !== CAMERA_FIT_VERSION ||
|
|
41
45
|
!same(report.entityIds, request.entityIds) || !same(report.assetInstanceIds, request.assetInstanceIds) ||
|
|
42
46
|
report.frame !== request.frame || report.cameraId !== request.cameraId || report.fittedCameraId !== request.fittedCameraId ||
|
|
43
47
|
report.margin !== request.margin || report.checkpointSha256 !== request.checkpointSha256 || report.checkpointUnchanged !== true ||
|
|
44
48
|
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.')
|
|
49
|
+
if (request.photography !== undefined) verifyPhotographySnapshot(report.photography, request.photography)
|
|
45
50
|
const view = report.view, camera = report.camera
|
|
46
51
|
if (!only(view, ['resolution', 'percentage', 'pixelAspect', 'activeCamera']) ||
|
|
47
52
|
!(view.activeCamera === null || typeof view.activeCamera === 'string') || !vector(view.resolution, 2) ||
|
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
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { BlenderError, BlenderErrorCode } from './index.js'
|
|
2
|
+
|
|
3
|
+
export const PHOTOGRAPHY_SNAPSHOT_LIMITS = Object.freeze({ entities: 128, lights: 32 })
|
|
4
|
+
|
|
5
|
+
const only = (v, keys) => v && typeof v === 'object' && !Array.isArray(v) && Object.keys(v).every(k => keys.includes(k))
|
|
6
|
+
const vector = v => Array.isArray(v) && v.length === 3 && v.every(Number.isFinite)
|
|
7
|
+
const fail = message => { throw new BlenderError(BlenderErrorCode.SCENE_VALIDATION_FAILED, `Photography snapshot: ${message}`) }
|
|
8
|
+
|
|
9
|
+
export function validatePhotographySnapshot(selection) {
|
|
10
|
+
if (!only(selection, ['lightIds', 'cameraMustBeStatic']) || typeof selection.cameraMustBeStatic !== 'boolean'
|
|
11
|
+
|| !Array.isArray(selection.lightIds) || selection.lightIds.length > PHOTOGRAPHY_SNAPSHOT_LIMITS.lights || new Set(selection.lightIds).size !== selection.lightIds.length
|
|
12
|
+
|| selection.lightIds.some(id => typeof id !== 'string' || !/^[A-Za-z][A-Za-z0-9._-]{0,127}$/.test(id))) fail('choose at most 32 distinct named lights and an explicit camera-static requirement.')
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function verifyPhotographySnapshot(snapshot, selection) {
|
|
16
|
+
validatePhotographySnapshot(selection)
|
|
17
|
+
if (!only(snapshot, ['schemaVersion', 'staticGeometry', 'staticLights', 'cameraStatic', 'cameraRotationEuler', 'lights'])
|
|
18
|
+
|| snapshot.schemaVersion !== 'deepblend.photography-snapshot/v1' || snapshot.staticGeometry !== true || snapshot.staticLights !== true
|
|
19
|
+
|| typeof snapshot.cameraStatic !== 'boolean' || selection.cameraMustBeStatic && snapshot.cameraStatic !== true
|
|
20
|
+
|| !vector(snapshot.cameraRotationEuler) || !Array.isArray(snapshot.lights) || snapshot.lights.length !== selection.lightIds.length) fail('the runtime did not verify the requested static product and lighting snapshot.')
|
|
21
|
+
for (const [index, light] of snapshot.lights.entries()) {
|
|
22
|
+
const sun = light.type === 'sun', spot = light.type === 'spot'
|
|
23
|
+
if (!only(light, ['id', 'type', 'energy', 'color', 'transform', ...(sun ? ['angle'] : ['size']), ...(spot ? ['spotSize', 'spotBlend'] : [])])
|
|
24
|
+
|| light.id !== selection.lightIds[index] || !['area', 'point', 'spot', 'sun'].includes(light.type)
|
|
25
|
+
|| !Number.isFinite(light.energy) || light.energy < 0 || !vector(light.color) || light.color.some(c => c < 0 || c > 1)
|
|
26
|
+
|| !only(light.transform, ['location', 'rotationEuler', 'scale']) || !vector(light.transform.location)
|
|
27
|
+
|| !vector(light.transform.rotationEuler) || !vector(light.transform.scale) || light.transform.scale.some(s => s <= 0)
|
|
28
|
+
|| (sun ? !Number.isFinite(light.angle) || light.angle < 0 || light.angle > Math.PI : !Number.isFinite(light.size) || light.size <= 0)
|
|
29
|
+
|| spot && (!Number.isFinite(light.spotSize) || light.spotSize <= 0 || light.spotSize > Math.PI || !Number.isFinite(light.spotBlend) || light.spotBlend < 0 || light.spotBlend > 1)) fail('a sampled light differs from the requested identity or supported native settings.')
|
|
30
|
+
}
|
|
31
|
+
return snapshot
|
|
32
|
+
}
|
package/lib/runtime-types.d.ts
CHANGED
|
@@ -116,6 +116,7 @@ export interface GeometryInspectionReport {
|
|
|
116
116
|
export type CameraFitRequest = RuntimeOptions & {
|
|
117
117
|
checkpointPath: string; checkpointSha256: string; entityIds: string[]; assetInstanceIds: string[];
|
|
118
118
|
frame: number; cameraId: string; fittedCameraId: string; margin: number; jobId?: string;
|
|
119
|
+
photography?: { lightIds: string[]; cameraMustBeStatic: boolean };
|
|
119
120
|
} & ({ baselineCheckpointPath: string; baselineCheckpointSha256: string }
|
|
120
121
|
| { baselineCheckpointPath?: never; baselineCheckpointSha256?: never });
|
|
121
122
|
export interface CameraFitMember {
|
|
@@ -133,6 +134,8 @@ export interface CameraFitReport {
|
|
|
133
134
|
shift: [number, number]; clipping: [number, number]; fStop?: number; matrixWorld: number[][];
|
|
134
135
|
focusDistance: number; focusObject: string | null };
|
|
135
136
|
proposal?: import('./schema-types.js').Camera;
|
|
137
|
+
photography?: { schemaVersion: 'deepblend.photography-snapshot/v1'; staticGeometry: true; staticLights: true;
|
|
138
|
+
cameraStatic: boolean; cameraRotationEuler: Vec3; lights: import('./schema-types.js').Light[] };
|
|
136
139
|
baselineVerification?: { checkpointSha256: string; checkpointUnchanged: true; selectedGeometryUnchanged: true;
|
|
137
140
|
originalObjectsUnchanged: true; opticsAndRotationPreserved: true; maxVertexErrorMeters: number;
|
|
138
141
|
toleranceMeters: number; originalObjectCount: number };
|
|
@@ -231,6 +234,8 @@ export interface FrameSequenceHandle {
|
|
|
231
234
|
export interface FrameSequenceRequest extends RuntimeOptions {
|
|
232
235
|
checkpointPath: string; frames: number[]; jobDirectory: string; cameraId?: string; profileName?: string;
|
|
233
236
|
profile?: RenderProfile; frameRange?: [number, number]; jobId?: string; attemptToken?: string;
|
|
237
|
+
motionFrameAudit?: { entityIds: string[]; assetInstanceIds: string[] };
|
|
238
|
+
motionFrameAuditOnly?: boolean;
|
|
234
239
|
filePrefix?: string; padding?: number;
|
|
235
240
|
}
|
|
236
241
|
export interface ShotCameraSelection {
|
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,8 @@ 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',
|
|
74
|
+
'project.aspectRatio.set',
|
|
72
75
|
])
|
|
73
76
|
|
|
74
77
|
/** The `id` grammar shared with SceneSpec. */const ID_PATTERN = /^[a-zA-Z][a-zA-Z0-9._-]*$/
|
|
@@ -478,6 +481,24 @@ export function applyPatchToSpec(spec, patch) {
|
|
|
478
481
|
break
|
|
479
482
|
}
|
|
480
483
|
|
|
484
|
+
case 'entity.uv.project': {
|
|
485
|
+
const at = indexOfId(next.entities, operation.entityId)
|
|
486
|
+
if (at < 0) fail('PATCH_TARGET_MISSING', `no entity "${operation.entityId}" exists in this scene`)
|
|
487
|
+
const entity = next.entities[at]
|
|
488
|
+
if (entity.type !== 'generator' || entity.generator?.shape !== 'mesh') {
|
|
489
|
+
fail('PATCH_OPERATION_INVALID', `${op} requires a mesh generator; imported assets and other shapes retain their UVs`)
|
|
490
|
+
}
|
|
491
|
+
let faceUvs
|
|
492
|
+
try { faceUvs = projectMeshFaceUvs(entity.generator, operation) }
|
|
493
|
+
catch (error) { fail('PATCH_OPERATION_INVALID', error.message) }
|
|
494
|
+
const changed = JSON.stringify(entity.generator.faceUvs) !== JSON.stringify(faceUvs)
|
|
495
|
+
if (changed) next.entities[at] = { ...entity, generator: { ...entity.generator, faceUvs } }
|
|
496
|
+
applied.push({ op, target: entity.id,
|
|
497
|
+
summary: changed ? `projected repeating texture UVs per face on entity "${entity.id}"` : `entity "${entity.id}" face UVs already match this projection`,
|
|
498
|
+
changedPaths: changed ? [`entities.${entity.id}.generator.faceUvs`] : [] })
|
|
499
|
+
break
|
|
500
|
+
}
|
|
501
|
+
|
|
481
502
|
case 'entity.generator.set':
|
|
482
503
|
case 'entity.modifiers.set': {
|
|
483
504
|
const at = indexOfId(next.entities, operation.entityId)
|
|
@@ -935,6 +956,13 @@ export function applyPatchToSpec(spec, patch) {
|
|
|
935
956
|
break
|
|
936
957
|
}
|
|
937
958
|
|
|
959
|
+
case 'project.aspectRatio.set': {
|
|
960
|
+
next.project = { ...next.project, aspectRatio: operation.aspectRatio }
|
|
961
|
+
applied.push({ op, target: next.project.id, summary: `set the project aspect ratio to ${operation.aspectRatio}`,
|
|
962
|
+
changedPaths: ['project.aspectRatio'] })
|
|
963
|
+
break
|
|
964
|
+
}
|
|
965
|
+
|
|
938
966
|
case 'render.profile.set': {
|
|
939
967
|
const existing = next.renderProfiles[operation.profileName]
|
|
940
968
|
// A render profile is a COST DECLARATION, and `resolution` is the part of
|
package/lib/schema-types.d.ts
CHANGED
|
@@ -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: 80fac11f778970d7fb1b9531671a6e05d00c07e9140f3953e27b3883b3a19cbe */
|
|
46
46
|
export namespace ScenePatchSchema {
|
|
47
47
|
export type Id = string;
|
|
48
48
|
export type License = { "source"?: string; "commercialUse"?: boolean; "attribution"?: string; };
|
|
@@ -60,7 +60,7 @@ export namespace ScenePatchSchema {
|
|
|
60
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; "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); });
|
|
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; }) | ({ "op": "project.aspectRatio.set"; "aspectRatio": string; });
|
|
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; };
|
|
@@ -1827,6 +1827,43 @@
|
|
|
1827
1827
|
]
|
|
1828
1828
|
}
|
|
1829
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
|
+
}
|
|
1858
|
+
},
|
|
1859
|
+
{
|
|
1860
|
+
"type": "object",
|
|
1861
|
+
"additionalProperties": false,
|
|
1862
|
+
"required": ["op", "aspectRatio"],
|
|
1863
|
+
"properties": {
|
|
1864
|
+
"op": { "const": "project.aspectRatio.set" },
|
|
1865
|
+
"aspectRatio": { "type": "string", "pattern": "^[0-9]+:[0-9]+$" }
|
|
1866
|
+
}
|
|
1830
1867
|
}
|
|
1831
1868
|
]
|
|
1832
1869
|
},
|
package/lib/ui-api.js
CHANGED
|
@@ -45,6 +45,7 @@ export const UI_REST_MARKER = '*'
|
|
|
45
45
|
* @type {ReadonlyArray<{ id: string, method: string, path: string, write: boolean, summary: string }>}
|
|
46
46
|
*/
|
|
47
47
|
export const UI_ROUTES = Object.freeze([
|
|
48
|
+
{ id: 'readiness.imageInput', method: 'POST', path: '/deepblend/readiness/image-input', write: true, summary: 'Explicitly test the configured review route with one randomized image input challenge.' },
|
|
48
49
|
{ id: 'capabilities', method: 'GET', path: '/deepblend/capabilities', write: false, summary: 'Blender capabilities and the settings card.' },
|
|
49
50
|
// The first route this product serves FOR SOMEBODY ELSE TO READ. Everything else on this surface
|
|
50
51
|
// exists so the workbench can render itself; this one exists so a user can hand a maintainer the
|
|
@@ -87,9 +88,16 @@ export const UI_ROUTES = Object.freeze([
|
|
|
87
88
|
{ id: 'project.recipeParameters.update', method: 'POST', path: '/deepblend/projects/:projectId/recipe-parameters', write: true, summary: 'Save bounded assembly dimensions as an atomic revision.' },
|
|
88
89
|
{ 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
90
|
{ 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.' },
|
|
91
|
+
{ id: 'project.photographyReuse', method: 'POST', path: '/deepblend/projects/:projectId/photography-reuse', write: true, summary: 'Explicitly inspect saved product bounds and return an adapted photography draft without saving a scene.' },
|
|
90
92
|
{ 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.' },
|
|
91
93
|
{ id: 'project.jobs', method: 'GET', path: '/deepblend/projects/:projectId/jobs', write: false, summary: 'Render/export jobs of a project.' },
|
|
92
94
|
{ id: 'project.job', method: 'GET', path: '/deepblend/projects/:projectId/jobs/:jobId', write: false, summary: 'One job with its live progress.' },
|
|
95
|
+
{ id: 'project.job.video', method: 'GET', path: '/deepblend/projects/:projectId/jobs/:jobId/video', write: false, summary: 'Download the verified video for one explicit job and revision.' },
|
|
96
|
+
{ id: 'project.job.frame', method: 'GET', path: '/deepblend/projects/:projectId/jobs/:jobId/frames/:frame', write: false, summary: 'Download a provenance-bound frame from a completed render job.' },
|
|
97
|
+
{ id: 'project.motionPreview.create', method: 'POST', path: '/deepblend/projects/:projectId/motion-previews', write: true, summary: 'Render a private camera motion candidate without publishing a revision.' },
|
|
98
|
+
{ id: 'project.motionPreview.video', method: 'GET', path: '/deepblend/projects/:projectId/motion-previews/:candidateId/video', write: false, summary: 'Play a verified private camera motion preview.' },
|
|
99
|
+
{ id: 'project.motionPreview.save', method: 'POST', path: '/deepblend/projects/:projectId/motion-previews/:candidateId/save', write: true, summary: 'Save the explicitly accepted camera motion candidate.' },
|
|
100
|
+
{ id: 'project.motionPreview.discard', method: 'POST', path: '/deepblend/projects/:projectId/motion-previews/:candidateId/discard', write: true, summary: 'Discard an unpublished camera motion candidate.' },
|
|
93
101
|
{ id: 'project.job.cancel', method: 'POST', path: '/deepblend/projects/:projectId/jobs/:jobId/cancel', write: true, summary: 'Cancel a running job and verify the process is gone.' },
|
|
94
102
|
{ id: 'project.render', method: 'POST', path: '/deepblend/projects/:projectId/render', write: true, summary: 'Start a delivery render (or resume one).' },
|
|
95
103
|
{ id: 'project.editableSnapshots.create', method: 'POST', path: '/deepblend/projects/:projectId/editable-snapshots', write: true, summary: 'Prepare or resume an immutable editable snapshot of one explicit revision.' },
|
|
@@ -408,8 +416,10 @@ export function buildSceneTree(spec, context = {}) {
|
|
|
408
416
|
fps: spec?.project?.fps ?? null,
|
|
409
417
|
frameStart: spec?.project?.frameStart ?? null,
|
|
410
418
|
frameEnd: spec?.project?.frameEnd ?? null,
|
|
419
|
+
aspectRatio: spec?.project?.aspectRatio ?? null,
|
|
411
420
|
activeCamera: spec?.project?.activeCamera ?? null,
|
|
412
421
|
},
|
|
422
|
+
renderProfiles: clone(spec?.renderProfiles ?? null),
|
|
413
423
|
world: clone(spec?.world ?? null),
|
|
414
424
|
reviewSubject: clone(resolveSubject(spec)),
|
|
415
425
|
assetParts: clone(assetParts),
|
|
@@ -483,6 +493,7 @@ export function buildQaView({ projectId, revision, validation = null, review = n
|
|
|
483
493
|
artistic: clone(review?.referenceInputError ? { status: 'unassessable', dimensions: {} } : review?.artistic ?? { status: 'unassessable', dimensions: {} }),
|
|
484
494
|
referenceImages: clone(review?.referenceImages ?? []),
|
|
485
495
|
reviewInputsDigest: review?.reviewInputsDigest ?? null,
|
|
496
|
+
inputScope: clone(review?.inputScope ?? null),
|
|
486
497
|
referenceInputError: clone(review?.referenceInputError ?? null),
|
|
487
498
|
iteration: review?.iteration ?? null,
|
|
488
499
|
subjectId: review?.subjectId ?? null,
|
|
@@ -580,7 +591,7 @@ export function buildJobView(job, options) {
|
|
|
580
591
|
// from a list written here: a second opinion about which statuses are
|
|
581
592
|
// terminal is exactly the copy that rots (D38, D43, D57, D60).
|
|
582
593
|
cancelable: live,
|
|
583
|
-
resumable: ['failed', 'cancelled', 'recovering'].includes(job.status),
|
|
594
|
+
resumable: job.persistencePending !== true && ['failed', 'cancelled', 'recovering'].includes(job.status),
|
|
584
595
|
deliverable: job.status === 'completed' && job.delivery !== null,
|
|
585
596
|
approval: buildApprovalView({ record: { expectedFrames: expected, warnings: job.warnings ?? [] }, threshold: options?.threshold ?? Number.POSITIVE_INFINITY }),
|
|
586
597
|
detail: describeJobForHuman(job),
|
|
@@ -622,6 +633,7 @@ function describeFrameProvenance(provenance) {
|
|
|
622
633
|
*/
|
|
623
634
|
export function describeJobForHuman(job) {
|
|
624
635
|
const frames = `${job.completedFrames ?? 0}/${job.expectedFrames ?? 0} 帧`
|
|
636
|
+
if (job.persistencePending === true) return `任务已停止,但结果尚未保存:${frames}。请检查磁盘空间及写入权限后刷新,再继续任务。`
|
|
625
637
|
switch (job.status) {
|
|
626
638
|
case 'queued': return `排队中:${frames}`
|
|
627
639
|
case 'running': return job.estimatedRemainingMs === null || job.estimatedRemainingMs === undefined
|
|
@@ -629,7 +641,8 @@ export function describeJobForHuman(job) {
|
|
|
629
641
|
: `渲染中:${frames},预计还剩 ${formatDuration(job.estimatedRemainingMs)}`
|
|
630
642
|
case 'stopping': return `正在停止:${frames}`
|
|
631
643
|
case 'recovering': return `进程已消失,可从缺失帧继续:${frames}`
|
|
632
|
-
case 'completed': return job.delivery === null ? `已完成:${frames}`
|
|
644
|
+
case 'completed': return job.delivery === null ? `已完成:${frames}`
|
|
645
|
+
: job.delivery?.kind === 'still' ? `已交付:${frames},图片来源已核验` : `已交付:${frames},视频已校验`
|
|
633
646
|
case 'failed': return `失败(${job.errorCode ?? '未分类'}):${frames},可继续渲染`
|
|
634
647
|
case 'cancelled': return `已取消:${frames},可继续渲染`
|
|
635
648
|
default: return `${job.status}:${frames}`
|
package/package.json
CHANGED