@deepblend/dsh-blender-contracts 0.20.0 → 0.21.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/assembly-placement.js +166 -0
- package/lib/index.js +3 -0
- package/lib/lamp-placement.js +2 -2
- package/lib/runtime-types.d.ts +27 -0
- package/lib/sdk.d.ts +13 -1
- package/lib/sdk.js +3 -0
- package/lib/surface-placement.js +2 -2
- package/lib/ui-api.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
/** One complete pinned lamp, with a relative world pose followed by measured settling. */
|
|
2
|
+
import { BlenderError, BlenderErrorCode } from './index.js'
|
|
3
|
+
import { LAMP_ASSEMBLY_MANIFEST_SHA256 } from './lamp-placement.js'
|
|
4
|
+
import { instantiateRecipeLock } from './recipe.js'
|
|
5
|
+
import { planRecipeGeometryEdit } from './recipe-parameters.js'
|
|
6
|
+
import { canonicalStringify } from './canonical.js'
|
|
7
|
+
import { SURFACE_PLACEMENT_LIMITS, validateSurfacePlacementSelection,
|
|
8
|
+
verifySurfacePlacementReport, verifyPlacementObject } from './surface-placement.js'
|
|
9
|
+
|
|
10
|
+
export const ASSEMBLY_PLACEMENT_VERSION = 'deepblend.assembly-placement/v1'
|
|
11
|
+
export const ASSEMBLY_PLACEMENT_BASIS_TOLERANCE = 1e-6
|
|
12
|
+
export const ASSEMBLY_PLACEMENT_UV_TOLERANCE = 1e-6
|
|
13
|
+
const only = (value, keys) => value && typeof value === 'object' && !Array.isArray(value)
|
|
14
|
+
&& Object.keys(value).every(key => keys.includes(key))
|
|
15
|
+
const vector = value => Array.isArray(value) && value.length === 3 && value.every(Number.isFinite)
|
|
16
|
+
const id = value => typeof value === 'string' && /^[A-Za-z][A-Za-z0-9._-]{0,127}$/.test(value)
|
|
17
|
+
const refuse = (message, code = BlenderErrorCode.SCENE_PATCH_INVALID) => { throw new BlenderError(code, `Assembly placement: ${message}`) }
|
|
18
|
+
const near = (a, b, tolerance = 1e-9) => Array.isArray(a) && Array.isArray(b)
|
|
19
|
+
? a.length === b.length && a.every((value, index) => near(value, b[index], tolerance))
|
|
20
|
+
: Number.isFinite(a) && Number.isFinite(b) && Math.abs(a - b) <= tolerance
|
|
21
|
+
|
|
22
|
+
/** Millimetres, relative world translation, relative upright yaw, then world-Z settling. */
|
|
23
|
+
export function normalizeAssemblyPose(input = {}, defaultPivotMm = [0, 0, 0]) {
|
|
24
|
+
if (!only(input, ['translationMm', 'yawDegrees', 'pivotMm'])) refuse('pose accepts translationMm, yawDegrees and pivotMm only.')
|
|
25
|
+
const pose = { translationMm: input.translationMm === undefined ? [0, 0, 0] : input.translationMm,
|
|
26
|
+
yawDegrees: input.yawDegrees === undefined ? 0 : input.yawDegrees,
|
|
27
|
+
pivotMm: input.pivotMm === undefined ? defaultPivotMm : input.pivotMm }
|
|
28
|
+
if (![pose.translationMm, pose.pivotMm].every(value => vector(value) && value.every(axis => Math.abs(axis) <= 1_000_000))
|
|
29
|
+
|| !Number.isFinite(pose.yawDegrees) || Math.abs(pose.yawDegrees) > 360) {
|
|
30
|
+
refuse('pose requires finite 3-vectors within ±1000000 mm and a relative yaw within ±360 degrees.')
|
|
31
|
+
}
|
|
32
|
+
return structuredClone(pose)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function assemblyPoseMatrixMeters(pose) {
|
|
36
|
+
const { translationMm, yawDegrees, pivotMm } = normalizeAssemblyPose(pose)
|
|
37
|
+
const angle = yawDegrees * Math.PI / 180, c = Math.cos(angle), s = Math.sin(angle)
|
|
38
|
+
const [x, y] = pivotMm.map(value => value / 1000), [dx, dy, dz] = translationMm.map(value => value / 1000)
|
|
39
|
+
return [[c, -s, 0, x - c * x + s * y + dx], [s, c, 0, y - s * x - c * y + dy],
|
|
40
|
+
[0, 0, 1, dz], [0, 0, 0, 1]]
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function uprightMatrix(matrix) {
|
|
44
|
+
return Array.isArray(matrix) && matrix.length === 4 && matrix.every(row => Array.isArray(row) && row.length === 4
|
|
45
|
+
&& row.every(value => Number.isFinite(value) && Math.abs(value) <= 1e6))
|
|
46
|
+
&& near(matrix[3], [0, 0, 0, 1]) && near(matrix[2].slice(0, 3), [0, 0, 1])
|
|
47
|
+
&& near([matrix[0][2], matrix[1][2]], [0, 0])
|
|
48
|
+
&& near(matrix[0][0], matrix[1][1]) && near(matrix[0][1], -matrix[1][0])
|
|
49
|
+
&& near(matrix[0][0] ** 2 + matrix[1][0] ** 2, 1)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function planLampAssemblyPlacement(lock, currentSpec, parameterState, inputPose = {}) {
|
|
53
|
+
if (lock?.manifestSha256 !== LAMP_ASSEMBLY_MANIFEST_SHA256) {
|
|
54
|
+
refuse('whole-recipe placement requires the saved metal-lamp 2.2.0 origin.', BlenderErrorCode.UNSUPPORTED_ACTION)
|
|
55
|
+
}
|
|
56
|
+
// Also validates every member's complete static rigid pose and all controlled geometry,
|
|
57
|
+
// including unchanged/no-op requests. It never overwrites an independent edit.
|
|
58
|
+
planRecipeGeometryEdit(lock, currentSpec, parameterState, {})
|
|
59
|
+
const origin = instantiateRecipeLock(lock), memberEntityIds = origin.spec.entities
|
|
60
|
+
.filter(entity => entity.id !== 'studio-floor').map(entity => entity.id).sort()
|
|
61
|
+
if (memberEntityIds.length !== 23 || new Set(memberEntityIds).size !== 23) {
|
|
62
|
+
refuse('the pinned origin does not define exactly23 product members.', BlenderErrorCode.SCENE_VALIDATION_FAILED)
|
|
63
|
+
}
|
|
64
|
+
const selected = new Set(memberEntityIds), anchor = currentSpec.entities.find(entity => entity.id === 'weighted-base')
|
|
65
|
+
for (const entity of currentSpec.entities) {
|
|
66
|
+
if ((entity.modifiers ?? []).some(modifier => selected.has(modifier.targetEntityId)
|
|
67
|
+
|| modifier.targetEntityIds?.some(value => selected.has(value)))) {
|
|
68
|
+
refuse(`moving the lamp would affect a cross-entity geometry dependency on ${entity.id}.`, BlenderErrorCode.UNSUPPORTED_ACTION)
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
if ((currentSpec.animationTracks ?? []).some(track => (track.targetKind ?? 'entity') === 'entity' && selected.has(track.targetEntityId))) {
|
|
72
|
+
refuse('all lamp members must be static at the selected frame.', BlenderErrorCode.UNSUPPORTED_ACTION)
|
|
73
|
+
}
|
|
74
|
+
const pose = normalizeAssemblyPose(inputPose, (anchor.transform?.location ?? [0, 0, 0]).map(value => value * 1000))
|
|
75
|
+
const poseMatrixMeters = assemblyPoseMatrixMeters(pose)
|
|
76
|
+
const operations = memberEntityIds.map(entityId => {
|
|
77
|
+
const entity = currentSpec.entities.find(value => value.id === entityId), p = entity.transform?.location ?? [0, 0, 0]
|
|
78
|
+
const angles = entity.transform?.rotationEuler ?? [0, 0, 0]
|
|
79
|
+
return { op: 'entity.transform.update', entityId,
|
|
80
|
+
location: poseMatrixMeters.slice(0, 3).map(row => row[0] * p[0] + row[1] * p[1] + row[2] * p[2] + row[3]),
|
|
81
|
+
rotationEuler: [angles[0], angles[1], angles[2] + pose.yawDegrees * Math.PI / 180] }
|
|
82
|
+
})
|
|
83
|
+
return { subjectEntityId: anchor.id, memberEntityIds, pose, poseMatrixMeters, operations }
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export function validateAssemblyPlacementSelection(request) {
|
|
87
|
+
validateSurfacePlacementSelection({ subjectEntityId: request?.subjectEntityId, supportEntityId: request?.supportEntityId,
|
|
88
|
+
frame: request?.frame, clearanceMm: request?.clearanceMm, checkpointSha256: request?.checkpointSha256 })
|
|
89
|
+
const ids = request.memberEntityIds
|
|
90
|
+
if (!Array.isArray(ids) || !ids.length || ids.length > SURFACE_PLACEMENT_LIMITS.meshes
|
|
91
|
+
|| !ids.every(id) || new Set(ids).size !== ids.length || !ids.includes(request.subjectEntityId)
|
|
92
|
+
|| ids.includes(request.supportEntityId) || canonicalStringify(ids) !== canonicalStringify([...ids].sort())) {
|
|
93
|
+
refuse('select the complete, sorted, distinct subject members, excluding the support.')
|
|
94
|
+
}
|
|
95
|
+
const pose = normalizeAssemblyPose(request.pose)
|
|
96
|
+
if (canonicalStringify(pose) !== canonicalStringify(request.pose)) refuse('native measurement needs a fully resolved pose and pivot.')
|
|
97
|
+
const fields = ['baselineCheckpointPath', 'baselineCheckpointSha256', 'expectedWorldMatrixMeters']
|
|
98
|
+
if (fields.some(key => request[key] !== undefined) && (!fields.every(key => request[key] !== undefined)
|
|
99
|
+
|| typeof request.baselineCheckpointPath !== 'string' || !request.baselineCheckpointPath
|
|
100
|
+
|| !/^[a-f0-9]{64}$/.test(request.baselineCheckpointSha256 ?? '') || !uprightMatrix(request.expectedWorldMatrixMeters))) {
|
|
101
|
+
refuse('candidate verification requires its exact baseline and one rigid upright world matrix.')
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** Validate a native union-of-meshes witness and a proof for every saved member. */
|
|
106
|
+
export function verifyAssemblyPlacementReport(report, request) {
|
|
107
|
+
validateAssemblyPlacementSelection(request)
|
|
108
|
+
const fail = message => refuse(message, BlenderErrorCode.SCENE_VALIDATION_FAILED)
|
|
109
|
+
const keys = ['schemaVersion', 'axis', 'checkpointSha256', 'checkpointUnchanged', 'frame', 'blenderVersion',
|
|
110
|
+
'subjectEntityId', 'supportEntityId', 'clearanceMm', 'translationMeters', 'subjectContactMeters', 'supportContactMeters',
|
|
111
|
+
'placedSubjectContactMeters', 'subjectTriangleIndex', 'supportTriangleIndex', 'statistics', 'subject', 'support',
|
|
112
|
+
'memberEntityIds', 'members', 'pose', 'poseMatrixMeters', 'resultWorldMatrixMeters', 'subjectContactEntityId',
|
|
113
|
+
...(request.baselineCheckpointPath === undefined ? [] : ['baselineVerification'])]
|
|
114
|
+
if (!only(report, keys) || report.schemaVersion !== ASSEMBLY_PLACEMENT_VERSION
|
|
115
|
+
|| Buffer.byteLength(JSON.stringify(report)) > 256 * 1024
|
|
116
|
+
|| canonicalStringify(report.memberEntityIds) !== canonicalStringify(request.memberEntityIds)
|
|
117
|
+
|| canonicalStringify(report.pose) !== canonicalStringify(request.pose)
|
|
118
|
+
|| !near(report.poseMatrixMeters, assemblyPoseMatrixMeters(request.pose), 1e-12)) fail('the native report does not bind the complete requested assembly and pose.')
|
|
119
|
+
// Keep the existing contact, source, finite geometry and vertical gap checks.
|
|
120
|
+
const pairKeys = keys.filter(key => !['members', 'memberEntityIds', 'pose', 'poseMatrixMeters', 'resultWorldMatrixMeters',
|
|
121
|
+
'subjectContactEntityId', 'baselineVerification'].includes(key))
|
|
122
|
+
const pair = Object.fromEntries(pairKeys.map(key => [key, report[key]]))
|
|
123
|
+
pair.schemaVersion = 'deepblend.surface-placement/v1'
|
|
124
|
+
verifySurfacePlacementReport(pair, { subjectEntityId: request.subjectEntityId, supportEntityId: request.supportEntityId,
|
|
125
|
+
checkpointSha256: request.checkpointSha256, frame: request.frame, clearanceMm: request.clearanceMm })
|
|
126
|
+
const expectedResult = assemblyPoseMatrixMeters(request.pose); expectedResult[2][3] += report.translationMeters[2]
|
|
127
|
+
if (!uprightMatrix(report.resultWorldMatrixMeters) || !near(report.resultWorldMatrixMeters, expectedResult, 1e-12)
|
|
128
|
+
|| !Array.isArray(report.members) || report.members.length !== request.memberEntityIds.length) fail('invalid complete result transform or member set.')
|
|
129
|
+
const totals = { meshObjectCount: 0, vertexCount: 0, triangleCount: 0 }, low = [Infinity, Infinity, Infinity], high = [-Infinity, -Infinity, -Infinity]
|
|
130
|
+
let triangleOffset = 0, contactMember = null
|
|
131
|
+
for (const [index, member] of report.members.entries()) {
|
|
132
|
+
if (!only(member, ['entityId', 'geometry']) || member.entityId !== request.memberEntityIds[index]) fail('native member identity/order differs from the pinned selection.')
|
|
133
|
+
verifyPlacementObject(member.geometry)
|
|
134
|
+
for (const key of Object.keys(totals)) totals[key] += member.geometry[key]
|
|
135
|
+
for (let axis = 0; axis < 3; axis++) {
|
|
136
|
+
low[axis] = Math.min(low[axis], member.geometry.worldBoundsMeters.min[axis])
|
|
137
|
+
high[axis] = Math.max(high[axis], member.geometry.worldBoundsMeters.max[axis])
|
|
138
|
+
}
|
|
139
|
+
if (report.subjectTriangleIndex >= triangleOffset && report.subjectTriangleIndex < triangleOffset + member.geometry.triangleCount) contactMember = member.entityId
|
|
140
|
+
triangleOffset += member.geometry.triangleCount
|
|
141
|
+
}
|
|
142
|
+
const anchor = report.members.find(member => member.entityId === request.subjectEntityId)
|
|
143
|
+
if (Object.keys(totals).some(key => report.subject[key] !== totals[key])
|
|
144
|
+
|| !near(report.subject.worldBoundsMeters.min, low) || !near(report.subject.worldBoundsMeters.max, high)
|
|
145
|
+
|| !near(report.subject.rootWorldMatrix, anchor.geometry.rootWorldMatrix)
|
|
146
|
+
|| report.subjectContactEntityId !== contactMember) fail('aggregate geometry omits or misidentifies a selected native member.')
|
|
147
|
+
if (request.baselineCheckpointPath !== undefined) {
|
|
148
|
+
const proof = report.baselineVerification
|
|
149
|
+
if (!only(proof, ['checkpointSha256', 'checkpointUnchanged', 'worldMatrixMeters', 'members', 'supportUnchanged',
|
|
150
|
+
'supportMaxErrorMeters', 'toleranceMeters', 'basisTolerance', 'uvTolerance']) || proof.checkpointSha256 !== request.baselineCheckpointSha256
|
|
151
|
+
|| proof.checkpointUnchanged !== true || proof.supportUnchanged !== true
|
|
152
|
+
|| !near(proof.worldMatrixMeters, request.expectedWorldMatrixMeters, 1e-12)
|
|
153
|
+
|| proof.toleranceMeters !== SURFACE_PLACEMENT_LIMITS.toleranceMeters || proof.basisTolerance !== ASSEMBLY_PLACEMENT_BASIS_TOLERANCE
|
|
154
|
+
|| proof.uvTolerance !== ASSEMBLY_PLACEMENT_UV_TOLERANCE
|
|
155
|
+
|| !Number.isFinite(proof.supportMaxErrorMeters) || proof.supportMaxErrorMeters < 0 || proof.supportMaxErrorMeters > proof.toleranceMeters
|
|
156
|
+
|| !Array.isArray(proof.members) || proof.members.length !== request.memberEntityIds.length) fail('missing or invalid complete baseline verification.')
|
|
157
|
+
for (const [index, member] of proof.members.entries()) {
|
|
158
|
+
if (!only(member, ['entityId', 'rigidTransform', 'maxVertexErrorMeters', 'maxRootPositionErrorMeters', 'maxRootBasisError', 'maxUvError'])
|
|
159
|
+
|| member.entityId !== request.memberEntityIds[index] || member.rigidTransform !== true
|
|
160
|
+
|| ![member.maxVertexErrorMeters, member.maxRootPositionErrorMeters].every(value => Number.isFinite(value) && value >= 0 && value <= proof.toleranceMeters)
|
|
161
|
+
|| !Number.isFinite(member.maxRootBasisError) || member.maxRootBasisError < 0 || member.maxRootBasisError > proof.basisTolerance
|
|
162
|
+
|| !Number.isFinite(member.maxUvError) || member.maxUvError < 0 || member.maxUvError > proof.uvTolerance) fail('one or more native members did not follow the complete rigid transform.')
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
return report
|
|
166
|
+
}
|
package/lib/index.js
CHANGED
|
@@ -893,3 +893,6 @@ 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 { ASSEMBLY_PLACEMENT_VERSION, ASSEMBLY_PLACEMENT_BASIS_TOLERANCE, ASSEMBLY_PLACEMENT_UV_TOLERANCE, normalizeAssemblyPose,
|
|
897
|
+
assemblyPoseMatrixMeters, planLampAssemblyPlacement, validateAssemblyPlacementSelection,
|
|
898
|
+
verifyAssemblyPlacementReport } from './assembly-placement.js'
|
package/lib/lamp-placement.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** Continue the complete pinned 2.2 lamp after a static translation and upright yaw. */
|
|
2
2
|
import { RecipeError } from './recipe.js'
|
|
3
3
|
|
|
4
|
-
const
|
|
4
|
+
export const LAMP_ASSEMBLY_MANIFEST_SHA256 = '0d59d5340acc9334fbc9787a51fe1dc66fae39631534d581281770013e59c0b5'
|
|
5
5
|
const near = (a, b) => Array.isArray(a) && Array.isArray(b)
|
|
6
6
|
? a.length === b.length && a.every((value, index) => near(value, b[index]))
|
|
7
7
|
: Number.isFinite(a) && Number.isFinite(b) && Math.abs(a - b) <= 1e-9
|
|
@@ -21,7 +21,7 @@ const refuse = conflicts => {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
export function placedLampAssembly(lock, current, before, after) {
|
|
24
|
-
if (lock.manifestSha256 !==
|
|
24
|
+
if (lock.manifestSha256 !== LAMP_ASSEMBLY_MANIFEST_SHA256) return { before, after }
|
|
25
25
|
current = structuredClone(current)
|
|
26
26
|
const parts = before.spec.entities.filter(entity => entity.id !== 'studio-floor')
|
|
27
27
|
const actualParts = new Map(current.entities.map(entity => [entity.id, entity]))
|
package/lib/runtime-types.d.ts
CHANGED
|
@@ -133,6 +133,31 @@ export interface SurfacePlacementReport {
|
|
|
133
133
|
subjectRigidTranslation: true; supportUnchanged: true; subjectMaxErrorMeters: number; supportMaxErrorMeters: number;
|
|
134
134
|
toleranceMeters: number };
|
|
135
135
|
}
|
|
136
|
+
export interface AssemblyPlacementPose {
|
|
137
|
+
/** Relative world translation after rotation, in millimetres; Z is provisional before settling. */
|
|
138
|
+
translationMm: Vec3;
|
|
139
|
+
/** Relative upright yaw in degrees, positive counter-clockwise viewed from above. */
|
|
140
|
+
yawDegrees: number;
|
|
141
|
+
/** World pivot in millimetres. The Host defaults it to the current saved base origin. */
|
|
142
|
+
pivotMm: Vec3;
|
|
143
|
+
}
|
|
144
|
+
export type AssemblyPlacementRequest = RuntimeOptions & {
|
|
145
|
+
checkpointPath: string; checkpointSha256: string; subjectEntityId: string; memberEntityIds: string[];
|
|
146
|
+
supportEntityId: string; frame: number; clearanceMm?: number; pose: AssemblyPlacementPose; jobId?: string;
|
|
147
|
+
} & ({ baselineCheckpointPath: string; baselineCheckpointSha256: string; expectedWorldMatrixMeters: number[][] }
|
|
148
|
+
| { baselineCheckpointPath?: never; baselineCheckpointSha256?: never; expectedWorldMatrixMeters?: never });
|
|
149
|
+
export interface AssemblyPlacementMemberProof {
|
|
150
|
+
entityId: string; rigidTransform: true; maxVertexErrorMeters: number; maxRootPositionErrorMeters: number;
|
|
151
|
+
maxRootBasisError: number; maxUvError: number;
|
|
152
|
+
}
|
|
153
|
+
export interface AssemblyPlacementReport extends Omit<SurfacePlacementReport, 'schemaVersion' | 'baselineVerification'> {
|
|
154
|
+
schemaVersion: 'deepblend.assembly-placement/v1'; memberEntityIds: string[];
|
|
155
|
+
members: Array<{ entityId: string; geometry: SurfacePlacementObject }>;
|
|
156
|
+
pose: AssemblyPlacementPose; poseMatrixMeters: number[][]; resultWorldMatrixMeters: number[][]; subjectContactEntityId: string;
|
|
157
|
+
baselineVerification?: { checkpointSha256: string; checkpointUnchanged: true; worldMatrixMeters: number[][];
|
|
158
|
+
members: AssemblyPlacementMemberProof[]; supportUnchanged: true; supportMaxErrorMeters: number;
|
|
159
|
+
toleranceMeters: number; basisTolerance: number; uvTolerance: number };
|
|
160
|
+
}
|
|
136
161
|
export interface RenderPreviewRequest extends RuntimeOptions, RenderOverrides {
|
|
137
162
|
checkpointPath: string; outputPath: string; cameraId?: string; frame?: number; jobId?: string;
|
|
138
163
|
session?: boolean;
|
|
@@ -270,6 +295,8 @@ export interface LocalBlenderRuntime extends BlenderRuntime {
|
|
|
270
295
|
inspectGeometry?(request: GeometryInspectionRequest): Promise<RuntimeActionResult<GeometryInspectionReport>>;
|
|
271
296
|
/** Optional isolated measurement; baseline verification proves the saved rigid move before Host publication. */
|
|
272
297
|
inspectSurfacePlacement?(request: SurfacePlacementRequest): Promise<RuntimeActionResult<SurfacePlacementReport>>;
|
|
298
|
+
/** Complete explicit member union and optional rigid candidate proof, always in an isolated batch. */
|
|
299
|
+
inspectAssemblyPlacement?(request: AssemblyPlacementRequest): Promise<RuntimeActionResult<AssemblyPlacementReport>>;
|
|
273
300
|
runBootstrap(request: BlenderBootstrapRequest, options?: BootstrapOptions): Promise<BootstrapRunOutcome>;
|
|
274
301
|
openSession(options?: RuntimeOptions & { cwd?: string; args?: string[] }): Promise<BlenderSession>;
|
|
275
302
|
attachSession(socketPath: string, options?: { timeoutMs?: number }): Promise<BlenderSession>;
|
package/lib/sdk.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ 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 } from './runtime-types.js';
|
|
8
|
+
import type { ShotCameraSelection, AssemblyPlacementPose, AssemblyPlacementRequest, AssemblyPlacementReport } from './runtime-types.js';
|
|
9
9
|
export const SHOT_CAMERA_SELECTION_VERSION: 'deepblend.shot-camera-selection/v1';
|
|
10
10
|
export const SHOT_CAMERA_SELECTION_LIMITS: { readonly shots: 64; readonly bytes: 8192 };
|
|
11
11
|
export function buildShotCameraSelection(spec: Pick<SceneSpec, 'cameras' | 'shots'>, frames: number[]): ShotCameraSelection;
|
|
@@ -138,6 +138,18 @@ export function instantiateRecipeLock(lock: RecipeLock, changes?: RecipeValues,
|
|
|
138
138
|
export function recipeGeometryParameters(manifest: RecipeManifest): RecipeManifest['parameters'];
|
|
139
139
|
export function planRecipeGeometryEdit(lock: RecipeLock, currentSpec: SceneSpec,
|
|
140
140
|
parameterState: RecipeParameterState | undefined, changes: Record<string, number>): RecipeGeometryPlan;
|
|
141
|
+
export const ASSEMBLY_PLACEMENT_VERSION: 'deepblend.assembly-placement/v1';
|
|
142
|
+
export const ASSEMBLY_PLACEMENT_BASIS_TOLERANCE: 0.000001;
|
|
143
|
+
export const ASSEMBLY_PLACEMENT_UV_TOLERANCE: 0.000001;
|
|
144
|
+
export function normalizeAssemblyPose(input?: Partial<AssemblyPlacementPose>, defaultPivotMm?: [number, number, number]): AssemblyPlacementPose;
|
|
145
|
+
export function assemblyPoseMatrixMeters(pose: AssemblyPlacementPose): number[][];
|
|
146
|
+
export function planLampAssemblyPlacement(lock: RecipeLock, currentSpec: SceneSpec,
|
|
147
|
+
parameterState: RecipeParameterState | undefined, inputPose?: Partial<AssemblyPlacementPose>): {
|
|
148
|
+
subjectEntityId: string; memberEntityIds: string[]; pose: AssemblyPlacementPose; poseMatrixMeters: number[][];
|
|
149
|
+
operations: Array<Extract<ScenePatchOperation, { op: 'entity.transform.update' }>>;
|
|
150
|
+
};
|
|
151
|
+
export function validateAssemblyPlacementSelection(request: AssemblyPlacementRequest): void;
|
|
152
|
+
export function verifyAssemblyPlacementReport(report: unknown, request: AssemblyPlacementRequest): AssemblyPlacementReport;
|
|
141
153
|
|
|
142
154
|
/** Opt-in actual evaluated mesh bounds, including object/world scale, excluding placement rotation/translation. */
|
|
143
155
|
export const OBJECT_AXES_INSPECTION_VERSION: "deepblend.geometry-inspection/v3";
|
package/lib/sdk.js
CHANGED
|
@@ -23,6 +23,9 @@ export {
|
|
|
23
23
|
recipeCapabilitiesForScene, validateRecipeManifest, validateRecipePackage, instantiateRecipe, instantiateRecipeLock,
|
|
24
24
|
} from './recipe.js'
|
|
25
25
|
export { planRecipeGeometryEdit, recipeGeometryParameters } from './recipe-parameters.js'
|
|
26
|
+
export { ASSEMBLY_PLACEMENT_VERSION, ASSEMBLY_PLACEMENT_BASIS_TOLERANCE, ASSEMBLY_PLACEMENT_UV_TOLERANCE,
|
|
27
|
+
normalizeAssemblyPose, assemblyPoseMatrixMeters, planLampAssemblyPlacement,
|
|
28
|
+
validateAssemblyPlacementSelection, verifyAssemblyPlacementReport } from './assembly-placement.js'
|
|
26
29
|
|
|
27
30
|
/** Validate untrusted JSON and return a separate document; never assert a type without checking it. */
|
|
28
31
|
export function parseSceneSpec(input) {
|
package/lib/surface-placement.js
CHANGED
|
@@ -28,7 +28,7 @@ export function validateSurfacePlacementSelection(request) {
|
|
|
28
28
|
!hash(request.baselineCheckpointSha256) || !translation(request.expectedTranslationMeters))) invalid('baseline verification requires a checkpoint path, SHA256 and a world-Z translation together.')
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
function
|
|
31
|
+
export function verifyPlacementObject(value) {
|
|
32
32
|
if (!only(value, ['meshObjectCount', 'vertexCount', 'triangleCount', 'rootWorldMatrix', 'worldBoundsMeters']) ||
|
|
33
33
|
!integer(value.meshObjectCount, 1, SURFACE_PLACEMENT_LIMITS.meshes) ||
|
|
34
34
|
!integer(value.vertexCount, 3, SURFACE_PLACEMENT_LIMITS.vertices) ||
|
|
@@ -57,7 +57,7 @@ export function verifySurfacePlacementReport(report, request) {
|
|
|
57
57
|
report.clearanceMm !== (request.clearanceMm ?? 0) || typeof report.blenderVersion !== 'string' || !report.blenderVersion ||
|
|
58
58
|
!translation(report.translationMeters) || !vector(report.subjectContactMeters) || !vector(report.supportContactMeters) || !vector(report.placedSubjectContactMeters) ||
|
|
59
59
|
!only(report.statistics, ['candidatePairs']) || !integer(report.statistics.candidatePairs, 1, SURFACE_PLACEMENT_LIMITS.candidatePairs)) refuse('the report differs from the requested source, frame, selection or bounded protocol.')
|
|
60
|
-
|
|
60
|
+
verifyPlacementObject(report.subject); verifyPlacementObject(report.support)
|
|
61
61
|
if (!integer(report.subjectTriangleIndex, 0, report.subject.triangleCount - 1) ||
|
|
62
62
|
!integer(report.supportTriangleIndex, 0, report.support.triangleCount - 1)) refuse('the contact triangle is outside the measured geometry.')
|
|
63
63
|
const s = report.subjectContactMeters, t = report.supportContactMeters, p = report.placedSubjectContactMeters
|
package/lib/ui-api.js
CHANGED
|
@@ -85,6 +85,7 @@ export const UI_ROUTES = Object.freeze([
|
|
|
85
85
|
{ id: 'project.patch', method: 'POST', path: '/deepblend/projects/:projectId/patch', write: true, summary: 'Apply a ScenePatch as one atomic revision.' },
|
|
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
|
+
{ 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.' },
|
|
88
89
|
{ 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.' },
|
|
89
90
|
{ id: 'project.jobs', method: 'GET', path: '/deepblend/projects/:projectId/jobs', write: false, summary: 'Render/export jobs of a project.' },
|
|
90
91
|
{ id: 'project.job', method: 'GET', path: '/deepblend/projects/:projectId/jobs/:jobId', write: false, summary: 'One job with its live progress.' },
|
package/package.json
CHANGED