@deepblend/dsh-blender-contracts 0.13.0 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,8 @@
1
1
  import { BlenderError, BlenderErrorCode } from './index.js'
2
2
 
3
3
  export const GEOMETRY_INSPECTION_VERSION = 'deepblend.geometry-inspection/v1'
4
+ export const OBJECT_AXES_INSPECTION_VERSION = 'deepblend.geometry-inspection/v3'
5
+ export const OBJECT_AXES_BASIS = 'evaluated-object-axes-scaled'
4
6
  export const SURFACE_INSPECTION_VERSION = 'deepblend.geometry-inspection/v2'
5
7
  export const GEOMETRY_INSPECTION_LIMITS = Object.freeze({ entities: 8, checkpointBytes: 1024 ** 3, reportBytes: 64 * 1024 })
6
8
  export const SURFACE_INSPECTION_LIMITS = Object.freeze({ samples: 8, vertices: 250_000, polygons: 250_000,
@@ -16,6 +18,7 @@ export function validateGeometrySelection(request) {
16
18
  new Set(request.entityIds).size !== request.entityIds.length) refuse('select 1–8 distinct non-empty entity IDs.')
17
19
  if (!Number.isSafeInteger(request.frame) || request.frame < 0 || request.frame > 1_000_000) refuse('an explicit integer frame from 0 to 1000000 is required.')
18
20
  if (typeof request.checkpointSha256 !== 'string' || !/^[a-f0-9]{64}$/.test(request.checkpointSha256)) refuse('the expected checkpoint SHA256 is required.')
21
+ if (request.objectAxes !== undefined && typeof request.objectAxes !== 'boolean') refuse('objectAxes must be boolean.')
19
22
  if (request.surfaceSamples !== undefined) validateSurfaceSelection(request)
20
23
  }
21
24
 
@@ -98,16 +101,17 @@ export function verifyGeometryReport(report, request) {
98
101
  validateGeometrySelection(request)
99
102
  const allowed = (value, keys) => value && typeof value === 'object' && Object.keys(value).every(key => keys.includes(key))
100
103
  if (!report || Buffer.byteLength(JSON.stringify(report)) > GEOMETRY_INSPECTION_LIMITS.reportBytes ||
101
- report.schemaVersion !== (request.surfaceSamples === undefined ? GEOMETRY_INSPECTION_VERSION : SURFACE_INSPECTION_VERSION) || report.checkpointSha256 !== request.checkpointSha256 ||
104
+ report.schemaVersion !== (request.objectAxes === true ? OBJECT_AXES_INSPECTION_VERSION : request.surfaceSamples === undefined ? GEOMETRY_INSPECTION_VERSION : SURFACE_INSPECTION_VERSION) || report.checkpointSha256 !== request.checkpointSha256 ||
102
105
  report.frame !== request.frame || report.checkpointUnchanged !== true ||
103
106
  typeof report.blenderVersion !== 'string' || !report.blenderVersion ||
104
107
  !Array.isArray(report.objects) || report.objects.length !== request.entityIds.length ||
105
- !allowed(report, ['schemaVersion', 'checkpointSha256', 'checkpointUnchanged', 'frame', 'blenderVersion', 'objects', ...(request.surfaceSamples === undefined ? [] : ['surfaceSamples'])])) refuse('the report does not match the requested source, frame or selection.')
108
+ !allowed(report, ['schemaVersion', 'checkpointSha256', 'checkpointUnchanged', 'frame', 'blenderVersion', 'objects', ...(request.objectAxes === true ? ['objectAxisBasis'] : []), ...(request.surfaceSamples === undefined ? [] : ['surfaceSamples'])])) refuse('the report does not match the requested source, frame or selection.')
109
+ if (request.objectAxes === true && report.objectAxisBasis !== OBJECT_AXES_BASIS) refuse('object-local basis differs from evaluated scaled object-axis coordinates.')
106
110
  const vector = (v, length) => Array.isArray(v) && v.length === length && v.every(Number.isFinite)
107
111
  for (const [index, object] of report.objects.entries()) {
108
112
  if (object?.entityId !== request.entityIds[index] || typeof object.type !== 'string' || !object.type) refuse('object identity differs from the selection.')
109
113
  const keys = object.available === false ? ['entityId', 'type', 'available', 'unavailableReason'] :
110
- ['entityId', 'type', 'available', 'worldBoundsMeters', 'worldAxisExtentMm', 'worldMatrix', 'scale', 'vertexCount', 'polygonCount']
114
+ ['entityId', 'type', 'available', 'worldBoundsMeters', 'worldAxisExtentMm', 'worldMatrix', 'scale', 'vertexCount', 'polygonCount', ...(request.objectAxes === true ? ['objectAxisStatus', 'objectAxisBoundsMeters', 'objectAxisExtentMm', 'objectAxisWorldMatrix'] : [])]
111
115
  if (!allowed(object, keys)) refuse('unsupported measurement fields are not accepted; this protocol does not establish wall thickness or clearance.')
112
116
  if (object.available === false) {
113
117
  if (!['viewport-disabled', 'not-mesh', 'empty-or-invalid-geometry'].includes(object.unavailableReason) ||
@@ -119,9 +123,45 @@ export function verifyGeometryReport(report, request) {
119
123
  !Array.isArray(object.worldMatrix) || object.worldMatrix.length !== 4 || !object.worldMatrix.every(row => vector(row, 4)) ||
120
124
  !Number.isSafeInteger(object.vertexCount) || object.vertexCount <= 0 ||
121
125
  !Number.isSafeInteger(object.polygonCount) || object.polygonCount < 0) refuse('a measured object contains invalid or non-finite geometry facts.')
126
+ if (request.objectAxes === true && object.objectAxisStatus === 'unsupported-object-axis-basis') {
127
+ if (['objectAxisBoundsMeters','objectAxisExtentMm','objectAxisWorldMatrix'].some(k=>Object.hasOwn(object,k))) refuse('unavailable object-axis measurements must not contain numbers.')
128
+ const m=object.worldMatrix, lengths=[0,1,2].map(i=>Math.hypot(...m.slice(0,3).map(r=>r[i])))
129
+ const regular=lengths.every(v=>Number.isFinite(v)&&v>1e-12) && m[3].every((v,i)=>v===(i===3?1:0))
130
+ && [0,1,2].every(a=>[0,1,2].every(b=>a===b||Math.abs(m.slice(0,3).reduce((sum,r)=>sum+r[a]*r[b],0)/lengths[a]/lengths[b])<=1e-6))
131
+ if(regular) refuse('unavailable object-axis basis contradicts the regular native transform.')
132
+ } else if (request.objectAxes === true) {
133
+ if(object.objectAxisStatus!=='measured') refuse('object-axis status is missing or invalid.')
134
+ const bounds = object.objectAxisBoundsMeters
135
+ if (!allowed(bounds, ['min', 'max']) || !vector(bounds?.min, 3) || !vector(bounds?.max, 3)
136
+ || !vector(object.objectAxisExtentMm, 3) || object.worldMatrix[3].some((v, i) => v !== (i === 3 ? 1 : 0))) refuse('invalid object-local bounds, extents or affine matrix.')
137
+ const basis = object.objectAxisWorldMatrix
138
+ if (!Array.isArray(basis) || basis.length !== 4 || !basis.every(row => vector(row, 4)) || basis[3].some((v,i)=>v!==(i===3?1:0))) refuse('invalid physical object-axis matrix.')
139
+ const lengths = [0,1,2].map(axis=>Math.hypot(...object.worldMatrix.slice(0,3).map(row=>row[axis])))
140
+ if (lengths.some(v=>v<=1e-12 || !Number.isFinite(v))) refuse('object-axis basis is degenerate.')
141
+ for (let row=0;row<3;row++) {
142
+ if (Math.abs(basis[row][3]-object.worldMatrix[row][3])>1e-9*Math.max(1,Math.abs(object.worldMatrix[row][3]))) refuse('object-axis origin differs from native transform.')
143
+ for(let axis=0;axis<3;axis++) if(Math.abs(basis[row][axis]-object.worldMatrix[row][axis]/lengths[axis])>1e-6) refuse('object-axis directions differ from normalized native transform.')
144
+ }
145
+ for(let a=0;a<3;a++)for(let b=a+1;b<3;b++)if(Math.abs(basis.slice(0,3).reduce((sum,row)=>sum+row[a]*row[b],0))>1e-6) refuse('object-axis directions are not orthogonal.')
146
+ const envelopeMin = [Infinity, Infinity, Infinity], envelopeMax = [-Infinity, -Infinity, -Infinity]
147
+ for (let corner = 0; corner < 8; corner++) {
148
+ const point = [0, 1, 2].map(axis => bounds[(corner >> axis) & 1 ? 'max' : 'min'][axis])
149
+ for (let axis = 0; axis < 3; axis++) {
150
+ const value = basis[axis][3] + point.reduce((sum, v, i) => sum + v*basis[axis][i], 0)
151
+ if (!Number.isFinite(value)) refuse('transformed object-local envelope is not finite.')
152
+ envelopeMin[axis] = Math.min(envelopeMin[axis], value); envelopeMax[axis] = Math.max(envelopeMax[axis], value)
153
+ }
154
+ }
155
+ for (let axis = 0; axis < 3; axis++) {
156
+ const extent = (bounds.max[axis] - bounds.min[axis])*1000
157
+ if (!Number.isFinite(extent) || extent < 0 || Math.abs(extent-object.objectAxisExtentMm[axis]) > Math.max(1e-6, Math.abs(extent)*1e-9)) refuse('object-local extents disagree with measured local bounds.')
158
+ const epsilon = 1e-6*Math.max(1, Math.abs(envelopeMin[axis]), Math.abs(envelopeMax[axis]))
159
+ if (object.worldBoundsMeters.min[axis] < envelopeMin[axis]-epsilon || object.worldBoundsMeters.max[axis] > envelopeMax[axis]+epsilon) refuse('world bounds exceed the transformed object-local envelope.')
160
+ }
161
+ }
122
162
  for (let axis = 0; axis < 3; axis++) {
123
163
  const extent = (object.worldBoundsMeters.max[axis] - object.worldBoundsMeters.min[axis]) * 1000
124
- if (extent < 0 || Math.abs(extent - object.worldAxisExtentMm[axis]) > Math.max(1e-6, Math.abs(extent) * 1e-9)) refuse('axis extents disagree with the measured world bounds.')
164
+ if (!Number.isFinite(extent) || extent < 0 || Math.abs(extent - object.worldAxisExtentMm[axis]) > Math.max(1e-6, Math.abs(extent) * 1e-9)) refuse('axis extents disagree with the measured world bounds.')
125
165
  }
126
166
  }
127
167
  if (request.surfaceSamples !== undefined) verifySurfaceSamples(report.surfaceSamples, request, report.objects)
package/lib/index.js CHANGED
@@ -523,6 +523,7 @@ export function warning(code, message, detail) {
523
523
  * @property {BlenderRenderSmokeTest|null} cyclesSmokeTest
524
524
  * @property {boolean} textBlockApi
525
525
  * @property {boolean} frameApi
526
+ * @property {string[]} [sceneFeatures] - explicitly supported SceneSpec compiler features.
526
527
  * @property {string|null} hostPlatform
527
528
  * @property {{ code: string, message: string, detail?: unknown }[]} warnings
528
529
  * @property {number} probedAt - epoch ms.
@@ -617,6 +618,7 @@ export function toCanonicalCapabilities(capabilities) {
617
618
  : {}),
618
619
  },
619
620
  version: capabilities.blenderVersion,
621
+ ...(Array.isArray(capabilities.sceneFeatures) ? { sceneFeatures: [...capabilities.sceneFeatures] } : {}),
620
622
  versionTuple: capabilities.blenderVersionTuple,
621
623
  pythonVersion: capabilities.pythonVersion,
622
624
  buildHash: capabilities.buildHash,
@@ -698,6 +700,9 @@ export {
698
700
  validateSceneSpec,
699
701
  compileSceneSpec,
700
702
  BOX_DIMENSIONS_FEATURE,
703
+ MESH_GEOMETRY_FEATURE,
704
+ SUBDIVISION_FEATURE,
705
+ SURFACE_SCATTER_FEATURE,
701
706
  requiredSceneFeatures,
702
707
  entityBoundingRadius,
703
708
  sceneProjection,
@@ -880,5 +885,5 @@ export {
880
885
  export { RECIPE_SCHEMA_VERSION, RECIPE_CAPABILITIES, RECIPE_LIMITS, RecipeError, recipeCapabilitiesForScene, validateRecipeManifest, validateRecipePackage, instantiateRecipe, instantiateRecipeLock } from './recipe.js'
881
886
  export { planRecipeGeometryEdit, recipeGeometryParameters } from './recipe-parameters.js'
882
887
 
883
- export { GEOMETRY_INSPECTION_VERSION, GEOMETRY_INSPECTION_LIMITS, SURFACE_INSPECTION_VERSION, SURFACE_INSPECTION_LIMITS,
888
+ export { OBJECT_AXES_INSPECTION_VERSION, OBJECT_AXES_BASIS, GEOMETRY_INSPECTION_VERSION, GEOMETRY_INSPECTION_LIMITS, SURFACE_INSPECTION_VERSION, SURFACE_INSPECTION_LIMITS,
884
889
  validateGeometrySelection, validateSurfaceSelection, verifySurfaceSamples, verifyGeometryReport } from './geometry-inspection.js'
@@ -0,0 +1,57 @@
1
+ /** Bounded, declarative control meshes. No expressions or executable code. */
2
+ export const MESH_FIELDS = Object.freeze(['vertices', 'faces', 'faceUvs', 'smooth'])
3
+ export const MESH_MAX_VERTICES = 32768
4
+ export const MESH_MAX_FACES = 32768
5
+ export const MESH_MAX_CORNERS = 131072
6
+
7
+ export function meshGeneratorIssues(generator) {
8
+ const issues = [], vertices = generator.vertices, faces = generator.faces
9
+ if (!Array.isArray(vertices) || vertices.length < 3 || vertices.length > MESH_MAX_VERTICES) {
10
+ issues.push('mesh requires 3 to 32768 local-space vertices')
11
+ return issues
12
+ }
13
+ if (vertices.some(point => !Array.isArray(point) || point.length !== 3 ||
14
+ point.some(value => !Number.isFinite(value) || Math.abs(value) > 1e6))) {
15
+ issues.push('mesh vertices require three finite local coordinates within ±1000000')
16
+ return issues
17
+ }
18
+ if (!Array.isArray(faces) || faces.length < 1 || faces.length > MESH_MAX_FACES) {
19
+ issues.push('mesh requires 1 to 32768 indexed faces')
20
+ return issues
21
+ }
22
+ if (faces.reduce((sum, face) => sum + (face?.length ?? 0), 0) > MESH_MAX_CORNERS) {
23
+ issues.push('mesh exceeds the 131072 face-corner budget')
24
+ return issues
25
+ }
26
+ const seen = new Set()
27
+ for (const [index, face] of faces.entries()) {
28
+ if (!Array.isArray(face) || face.length < 3 || face.length > 32 ||
29
+ face.some(vertex => !Number.isInteger(vertex) || vertex < 0 || vertex >= vertices.length) ||
30
+ new Set(face).size !== face.length) {
31
+ issues.push(`mesh face ${index} needs 3 to 32 distinct in-range vertex indices`)
32
+ continue
33
+ }
34
+ const key = [...face].sort((a, b) => a - b).join(',')
35
+ if (seen.has(key)) issues.push(`mesh face ${index} duplicates an existing face`)
36
+ seen.add(key)
37
+ const origin = vertices[face[0]], normal = [0, 0, 0]
38
+ let scaleSquared = 0
39
+ const points = face.map(vertex => vertices[vertex].map((value, axis) => value - origin[axis]))
40
+ for (const point of points) scaleSquared = Math.max(scaleSquared, point.reduce((sum, value) => sum + value * value, 0))
41
+ for (let corner = 1; corner < points.length - 1; corner++) {
42
+ const a = points[corner], b = points[corner + 1]
43
+ normal[0] += a[1] * b[2] - a[2] * b[1]
44
+ normal[1] += a[2] * b[0] - a[0] * b[2]
45
+ normal[2] += a[0] * b[1] - a[1] * b[0]
46
+ }
47
+ if (Math.hypot(...normal) <= scaleSquared * 1e-12) issues.push(`mesh face ${index} has zero or unstable area`)
48
+ }
49
+ if (generator.faceUvs !== undefined) {
50
+ if (!Array.isArray(generator.faceUvs) || generator.faceUvs.length !== faces.length ||
51
+ generator.faceUvs.some((corners, index) => !Array.isArray(corners) || !Array.isArray(faces[index]) || corners.length !== faces[index].length ||
52
+ corners.some(uv => !Array.isArray(uv) || uv.length !== 2 || uv.some(value => !Number.isFinite(value))))) {
53
+ issues.push('mesh faceUvs must supply one finite UV pair for every face corner')
54
+ }
55
+ }
56
+ return issues
57
+ }
@@ -122,13 +122,17 @@ export function planRecipeGeometryEdit(lock, currentSpec, parameterState, change
122
122
  if (!generators.has(actual.id)) generators.set(actual.id, structuredClone(actual.generator))
123
123
  generators.get(actual.id).dimensions[axis] = target.generator.dimensions[axis]
124
124
  } else {
125
- if (close(actual.transform.location[axis], target.transform.location[axis])) continue
126
- if (!locations.has(actual.id)) locations.set(actual.id, structuredClone(actual.transform.location))
127
- const delta = target.transform.location[axis] - entity(before.spec, actual.id).transform.location[axis]
128
- locations.get(actual.id)[axis] = target.transform.location[axis]
129
- if (binding.offsetAnimation === true) animationOffsets.set(`${actual.id}:${binding.axis}`, {
130
- entityId: actual.id, property: `location.${binding.axis}`, delta,
131
- })
125
+ const axes = speaker.rigidPose ? [0, 1, 2] : [axis]
126
+ for (const movedAxis of axes) {
127
+ if (close(actual.transform.location[movedAxis], target.transform.location[movedAxis])) continue
128
+ if (!locations.has(actual.id)) locations.set(actual.id, structuredClone(actual.transform.location))
129
+ const delta = target.transform.location[movedAxis] - entity(before.spec, actual.id).transform.location[movedAxis]
130
+ locations.get(actual.id)[movedAxis] = target.transform.location[movedAxis]
131
+ const movedName = ['x', 'y', 'z'][movedAxis]
132
+ if (binding.offsetAnimation === true) animationOffsets.set(`${actual.id}:${movedName}`, {
133
+ entityId: actual.id, property: `location.${movedName}`, delta,
134
+ })
135
+ }
132
136
  }
133
137
  }
134
138
  for (const offset of animationOffsets.values()) for (const track of currentSpec.animationTracks ?? []) {
package/lib/recipe.js CHANGED
@@ -3,13 +3,14 @@ import { inflateSync } from 'node:zlib'
3
3
  import { sha256, sha256Canonical } from './canonical.js'
4
4
  import { compileSchema } from './json-schema.js'
5
5
  import { decodePng } from './png.js'
6
- import { validateSceneSpec, compileSceneSpec, BOX_DIMENSIONS_FEATURE, requiredSceneFeatures } from './scene-spec.js'
6
+ import { validateSceneSpec, compileSceneSpec, BOX_DIMENSIONS_FEATURE, MESH_GEOMETRY_FEATURE, SUBDIVISION_FEATURE, SURFACE_SCATTER_FEATURE, requiredSceneFeatures } from './scene-spec.js'
7
7
  import { deformLatheShell, latheShellTargets } from './lathe-shell.js'
8
8
  import recipeSchema from './schemas/recipe.schema.json' with { type: 'json' }
9
9
 
10
10
  export const RECIPE_SCHEMA_VERSION = 'deepblend.recipe/v1'
11
11
  export const RECIPE_CAPABILITIES = Object.freeze([
12
12
  'geometry.primitive', BOX_DIMENSIONS_FEATURE, 'geometry.lathe', 'geometry.curve', 'geometry.handled_cup', 'geometry.handled_cup.tension', 'geometry.handled_cup.tension.extended', 'geometry.modifiers',
13
+ MESH_GEOMETRY_FEATURE, SUBDIVISION_FEATURE, SURFACE_SCATTER_FEATURE,
13
14
  'material.principled', 'material.glass', 'material.emission', 'material.procedural', 'material.procedural.uv', 'material.anisotropy',
14
15
  'animation.transform', 'animation.material',
15
16
  'recipe.geometry-bindings',
@@ -45,8 +46,8 @@ export class RecipeError extends Error {
45
46
  export function recipeCapabilitiesForScene(spec) {
46
47
  const used = new Set()
47
48
  for (const entity of spec.entities ?? []) {
48
- if (entity.type === 'generator') used.add(['lathe', 'curve', 'handled_cup'].includes(entity.generator.shape)
49
- ? `geometry.${entity.generator.shape}` : 'geometry.primitive')
49
+ if (entity.type === 'generator') used.add(entity.generator.shape === 'mesh' ? MESH_GEOMETRY_FEATURE
50
+ : ['lathe', 'curve', 'handled_cup'].includes(entity.generator.shape) ? `geometry.${entity.generator.shape}` : 'geometry.primitive')
50
51
  if (entity.modifiers?.length || entity.generator?.bevel) used.add('geometry.modifiers')
51
52
  if (entity.generator?.shape === 'handled_cup' && (entity.generator.rootTension ?? 1) !== 1) used.add('geometry.handled_cup.tension')
52
53
  if (entity.generator?.shape === 'handled_cup' && (entity.generator.rootTension ?? 1) > 1.5) used.add('geometry.handled_cup.tension.extended')
@@ -91,17 +91,19 @@ export interface CompileSceneRequest extends RuntimeOptions {
91
91
  onWorkingDirectory?: WorkingDirectoryCallback<CompileReport>;
92
92
  }
93
93
  export interface RenderOverrides { engine?: EngineKey; width?: number; height?: number; samples?: number }
94
- /** Optional native inspection. Bounds are world-axis extents, not wall thickness or intrinsic dimensions. */
94
+ /** Default world-axis bounds; optional physical object axes include native scale. Neither certifies semantic body dimensions or wall thickness. */
95
95
  export interface GeometryInspectionRequest extends RuntimeOptions {
96
- checkpointPath: string; checkpointSha256: string; entityIds: string[]; frame: number; jobId?: string;
96
+ checkpointPath: string; checkpointSha256: string; entityIds: string[]; frame: number; jobId?: string; objectAxes?: boolean; surfaceSamples?: unknown[];
97
97
  }
98
98
  export type GeometryInspectionObject = { entityId: string; type: string } & (
99
99
  { available: false; unavailableReason: 'viewport-disabled' | 'not-mesh' | 'empty-or-invalid-geometry' } |
100
100
  { available: true; worldBoundsMeters: { min: Vec3; max: Vec3 }; worldAxisExtentMm: Vec3;
101
+ objectAxisStatus?: 'measured' | 'unsupported-object-axis-basis'; objectAxisBoundsMeters?: { min: Vec3; max: Vec3 }; objectAxisExtentMm?: Vec3; objectAxisWorldMatrix?: number[][];
101
102
  worldMatrix: number[][]; scale: Vec3; vertexCount: number; polygonCount: number }
102
103
  );
103
104
  export interface GeometryInspectionReport {
104
- schemaVersion: 'deepblend.geometry-inspection/v1'; checkpointSha256: string; checkpointUnchanged: true;
105
+ schemaVersion: 'deepblend.geometry-inspection/v1' | 'deepblend.geometry-inspection/v2' | 'deepblend.geometry-inspection/v3';
106
+ objectAxisBasis?: 'evaluated-object-axes-scaled'; surfaceSamples?: unknown[]; checkpointSha256: string; checkpointUnchanged: true;
105
107
  frame: number; blenderVersion: string; objects: GeometryInspectionObject[];
106
108
  }
107
109
  export interface RenderPreviewRequest extends RuntimeOptions, RenderOverrides {
package/lib/scene-spec.js CHANGED
@@ -24,17 +24,25 @@ import { canonicalStringify, sha256Canonical } from './canonical.js'
24
24
  import { compileSchema, formatIssues } from './json-schema.js'
25
25
  import { referenceImageIssues } from './reference-images.js'
26
26
  import { HANDLED_CUP_FIELDS, handledCupIssues, resolveHandledCup } from './handled-cup.js'
27
+ import { MESH_FIELDS, meshGeneratorIssues } from './mesh-geometry.js'
27
28
  import sceneSpecSchema from './schemas/scene-spec.schema.json' with { type: 'json' }
28
29
 
29
30
  /** The one schema version this module understands. */
30
31
  export const SCENE_SCHEMA_VERSION = 'deepblend.scene/v1'
31
32
 
32
33
  export const BOX_DIMENSIONS_FEATURE = 'geometry.primitive.dimensions'
34
+ export const MESH_GEOMETRY_FEATURE = 'geometry.procedural.mesh'
35
+ export const SUBDIVISION_FEATURE = 'geometry.modifier.subdivision'
36
+ export const SURFACE_SCATTER_FEATURE = 'geometry.modifier.surface_scatter'
33
37
 
34
38
  /** Features whose absence must refuse compilation rather than reinterpret the scene. */
35
39
  export function requiredSceneFeatures(spec) {
36
- return spec.entities?.some(entity => entity.type === 'generator' && entity.generator?.dimensions !== undefined)
37
- ? [BOX_DIMENSIONS_FEATURE] : []
40
+ const entities = spec.entities ?? [], features = []
41
+ if (entities.some(entity => entity.type === 'generator' && entity.generator?.dimensions !== undefined)) features.push(BOX_DIMENSIONS_FEATURE)
42
+ if (entities.some(entity => entity.type === 'generator' && entity.generator?.shape === 'mesh')) features.push(MESH_GEOMETRY_FEATURE)
43
+ if (entities.some(entity => entity.modifiers?.some(modifier => modifier.type === 'subdivision'))) features.push(SUBDIVISION_FEATURE)
44
+ if (entities.some(entity => entity.modifiers?.some(modifier => modifier.type === 'surface_scatter'))) features.push(SURFACE_SCATTER_FEATURE)
45
+ return features
38
46
  }
39
47
 
40
48
  /**
@@ -406,6 +414,17 @@ export function validateSceneSpec(spec) {
406
414
  message: 'profile and closedProfile require lathe geometry; capEnds requires lathe or curve geometry' })
407
415
  }
408
416
  const generator = entity.generator
417
+ if (generator?.shape === 'mesh') {
418
+ for (const message of meshGeneratorIssues(generator)) errors.push({ severity: 'error',
419
+ code: 'SCENE_GENERATOR_PARAMETERS_INVALID', path: `${at}.generator`, message })
420
+ if (['size', 'radius', 'depth', 'segments', 'ringCount', 'majorRadius', 'minorRadius'].some(key => generator[key] !== undefined)) {
421
+ errors.push({ severity: 'error', code: 'SCENE_GENERATOR_PARAMETERS_INVALID', path: `${at}.generator`,
422
+ message: 'mesh geometry uses vertices and faces, not primitive dimensions or radial segments' })
423
+ }
424
+ } else if (generator && MESH_FIELDS.some(key => generator[key] !== undefined)) {
425
+ errors.push({ severity: 'error', code: 'SCENE_GENERATOR_PARAMETERS_INVALID', path: `${at}.generator`,
426
+ message: 'vertices, faces, faceUvs and smooth apply only to mesh geometry' })
427
+ }
409
428
  if (generator?.shape === 'curve') {
410
429
  const path = generator.path
411
430
  const invalid = message => errors.push({ severity: 'error', code: 'SCENE_GENERATOR_PATH_INVALID',
@@ -453,6 +472,28 @@ export function validateSceneSpec(spec) {
453
472
  message: 'mesh modifiers need geometry, nonzero thickness and nonzero array offset' })
454
473
  }
455
474
  if (modifier.type === 'boolean') requiresId('entities', modifier.targetEntityId, `${path}.targetEntityId`, 'boolean operand')
475
+ if (modifier.type === 'surface_scatter') {
476
+ const targets = modifier.targetEntityIds.map(id => document.entities.find(item => item.id === id))
477
+ for (const [targetIndex, id] of modifier.targetEntityIds.entries()) requiresId('entities', id, `${path}.targetEntityIds[${targetIndex}]`, 'surface scatter target')
478
+ const dependencyParts = new Map()
479
+ const collect = part => {
480
+ if (!part || dependencyParts.has(part.id)) return
481
+ dependencyParts.set(part.id, part)
482
+ for (const value of part.modifiers ?? []) if (value.type === 'boolean') collect(document.entities.find(item => item.id === value.targetEntityId))
483
+ }
484
+ collect(entity); targets.forEach(collect)
485
+ const parts = [...dependencyParts.values()], animated = new Set((document.animationTracks ?? [])
486
+ .filter(track => /^(location|rotationEuler|scale)(\.|$)/.test(track.property)).map(track => track.targetEntityId))
487
+ if (new Set(modifier.targetEntityIds).size !== modifier.targetEntityIds.length ||
488
+ new Set(modifier.anchorVertexIndices).size !== modifier.anchorVertexIndices.length ||
489
+ i !== entity.modifiers.length - 1 || parts.some(part => part.type !== 'generator' || animated.has(part.id) ||
490
+ ['armatureId', 'rigidBody', 'cloth', 'softBody', 'fluid'].some(key => part[key] !== undefined)) ||
491
+ modifier.targetEntityIds.includes(entity.id) || parts.some(part => part.id !== entity.id && part.modifiers?.some(value => value.type === 'surface_scatter')) ||
492
+ (modifier.scaleRange && modifier.scaleRange[0] > modifier.scaleRange[1])) {
493
+ errors.push({ severity: 'error', code: 'SCENE_MODIFIER_INVALID', path,
494
+ message: 'surface scatter must be last, use static generated mesh prototypes/targets without rigs or physics, omit self/nested scatter and use an ordered scale range' })
495
+ }
496
+ }
456
497
  }
457
498
  })
458
499
 
@@ -461,13 +502,14 @@ export function validateSceneSpec(spec) {
461
502
  const visitModifiers = id => {
462
503
  if (activeModifiers.has(id)) {
463
504
  errors.push({ severity: 'error', code: 'SCENE_MODIFIER_CYCLE', path: 'entities',
464
- message: `boolean dependency cycle includes entity "${id}"` })
505
+ message: `modifier dependency cycle includes entity "${id}"` })
465
506
  return
466
507
  }
467
508
  if (visitedModifiers.has(id)) return
468
509
  activeModifiers.add(id)
469
510
  for (const modifier of modifierEntities.get(id)?.modifiers ?? []) {
470
511
  if (modifier.type === 'boolean') visitModifiers(modifier.targetEntityId)
512
+ if (modifier.type === 'surface_scatter') for (const target of modifier.targetEntityIds) visitModifiers(target)
471
513
  }
472
514
  activeModifiers.delete(id)
473
515
  visitedModifiers.add(id)
@@ -706,6 +748,16 @@ export function compileSceneSpec(spec) {
706
748
  const scale = Math.max(...entity.transform.scale.map(Math.abs))
707
749
  if (modifier.type === 'solidify') entityBounds[entity.id].radius += Math.abs(modifier.thickness) * scale
708
750
  if (modifier.type === 'array') entityBounds[entity.id].radius += Math.hypot(...modifier.offset) * (modifier.count - 1) * scale
751
+ if (modifier.type === 'surface_scatter') {
752
+ const prototypeRadius = entityBounds[entity.id].radius * 2 * (modifier.scaleRange?.[1] ?? 1)
753
+ for (const id of modifier.targetEntityIds) {
754
+ const target = entities.find(candidate => candidate.id === id)
755
+ if (!target) continue
756
+ expandBooleanBounds(target)
757
+ const own = entityBounds[entity.id], other = entityBounds[id]
758
+ own.radius = Math.max(own.radius, Math.hypot(...own.location.map((value, axis) => value - other.location[axis])) + other.radius + prototypeRadius)
759
+ }
760
+ }
709
761
  if (modifier.type !== 'boolean' || modifier.operation !== 'union') continue
710
762
  const operand = entities.find(candidate => candidate.id === modifier.targetEntityId)
711
763
  if (!operand) continue
@@ -827,6 +879,8 @@ function resolveGenerator(generator) {
827
879
  bevelResolution: generator.bevelResolution ?? 8, capEnds: generator.capEnds ?? true }
828
880
  case 'handled_cup':
829
881
  return { ...base, ...resolveHandledCup(generator) }
882
+ case 'mesh':
883
+ return { ...base, ...generator, smooth: generator.smooth ?? false }
830
884
  default:
831
885
  return { ...generator }
832
886
  }
@@ -887,6 +941,7 @@ export function entityBoundingRadius(entity) {
887
941
  case 'lathe': radius = Math.max(...generator.profile.map(([r, z]) => Math.hypot(r, z))); break
888
942
  case 'curve': radius = Math.max(...generator.path.map(point => Math.hypot(...point))) *
889
943
  (generator.pathInterpolation === 'bezier' ? 2 : 1) + generator.radius; break
944
+ case 'mesh': radius = generator.vertices.reduce((bound, point) => Math.max(bound, Math.hypot(...point)), 0); break
890
945
  case 'handled_cup': {
891
946
  const p = resolveHandledCup(generator)
892
947
  radius = Math.hypot(p.radius + p.rootLength + (p.handleUpper - p.handleLower) / 2 + p.handleRadius, p.height)
@@ -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: 2fe4251bf80fa6f10a5c8b6d877250776c4b305a172c28224821d0082252c3a6 */
4
+ /** Source SHA-256: b15e1b2a9c9080ea5dd8afa5453ab9a2e6465410fc072d6d2ec7e6dcba1001a5 */
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; }; };
@@ -15,7 +15,7 @@ export namespace SceneSpecSchema {
15
15
  export type ProceduralTexture = ({ "type": "noise" | "wave" | "voronoi"; "scale": number; "detail"?: number; "distortion"?: number; "stretch"?: [number, number, number]; "bump"?: number; "roughnessVariation"?: number; "colorVariation"?: number; "coordinates"?: "object"; }) | ({ "type": "noise" | "wave" | "voronoi"; "scale": number; "detail"?: number; "distortion"?: number; "stretch"?: [number, number, number]; "bump"?: number; "roughnessVariation"?: number; "colorVariation"?: number; "coordinates": "uv"; "uvMap"?: string; });
16
16
  export type Material = { "id": SceneSpecSchema.Id; "shader": "principled" | "emission" | "glass"; "parameters"?: { "baseColor"?: SceneSpecSchema.UnitColor; "metallic"?: number; "roughness"?: number; "ior"?: number; "alpha"?: number; "emissionColor"?: SceneSpecSchema.UnitColor; "emissionStrength"?: SceneSpecSchema.NonNegativeNumber; "coatWeight"?: number; "transmissionWeight"?: number; "anisotropic"?: number; "anisotropicRotation"?: number; }; "texture"?: SceneSpecSchema.ProceduralTexture; "images"?: SceneSpecSchema.MaterialImages; "tangent"?: SceneSpecSchema.MaterialTangent; };
17
17
  export type Transform = { "location"?: SceneSpecSchema.Vec3; "rotationEuler"?: SceneSpecSchema.Vec3; "scale"?: SceneSpecSchema.Vec3; };
18
- export type Generator = { "shape": "cube" | "uv_sphere" | "cylinder" | "cone" | "plane" | "torus" | "rounded_box" | "lathe" | "curve" | "handled_cup"; "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]; };
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
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; };
@@ -30,7 +30,7 @@ export namespace SceneSpecSchema {
30
30
  export type Cloth = { "pinTop"?: boolean; "mass"?: number; "stiffness"?: number; };
31
31
  export type SoftBody = { "pinTop"?: boolean; "goal"?: number; "mass"?: number; };
32
32
  export type Fluid = { "role": "domain" | "inflow" | "outflow"; "domainType"?: "liquid" | "gas"; "resolution"?: number; "flowType"?: "liquid" | "smoke" | "fire" | "both"; };
33
- export type ModelModifier = ({ "type": "solidify"; "thickness": number; "offset"?: number; }) | ({ "type": "mirror"; "axis": "x" | "y" | "z"; "merge"?: boolean; }) | ({ "type": "array"; "count": number; "offset": SceneSpecSchema.Vec3; }) | ({ "type": "boolean"; "operation": "union" | "difference" | "intersect"; "targetEntityId": SceneSpecSchema.Id; }) | ({ "type": "bevel"; "width": number; "segments"?: number; "angle"?: number; "miterInner"?: "arc" | "sharp"; });
33
+ export type ModelModifier = ({ "type": "solidify"; "thickness": number; "offset"?: number; }) | ({ "type": "mirror"; "axis": "x" | "y" | "z"; "merge"?: boolean; }) | ({ "type": "array"; "count": number; "offset": SceneSpecSchema.Vec3; }) | ({ "type": "boolean"; "operation": "union" | "difference" | "intersect"; "targetEntityId": SceneSpecSchema.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<SceneSpecSchema.Id>; "count": number; "seed"?: number; "anchorVertexIndices": Array<number>; "embedDepthMm"?: number; "scaleRange"?: [number, number]; "upwardBias"?: number; });
34
34
  export type ImageBinding = { "assetId": SceneSpecSchema.Id; "scale"?: SceneSpecSchema.Vec3; "offset"?: SceneSpecSchema.Vec3; "uvMap"?: string; "channel"?: "r" | "g" | "b" | "a"; "strength"?: number; };
35
35
  export type MaterialImages = { "baseColor"?: SceneSpecSchema.ImageBinding; "roughness"?: SceneSpecSchema.ImageBinding; "metallic"?: SceneSpecSchema.ImageBinding; "normal"?: SceneSpecSchema.ImageBinding; "alpha"?: SceneSpecSchema.ImageBinding; "emissionColor"?: SceneSpecSchema.ImageBinding; };
36
36
  export type MaterialBinding = { "partId": string; "slotIndex"?: number; "materialId": SceneSpecSchema.Id; };
@@ -42,7 +42,7 @@ export namespace SceneSpecSchema {
42
42
  }
43
43
  export type SceneSpec = SceneSpecSchema.Document;
44
44
 
45
- /** Source SHA-256: b34ca16667f6771bdcc5ec7c503fe3ded71acadf2175e5e52e9f52ea7d532230 */
45
+ /** Source SHA-256: c11618c1c6e68d350405702b81768c784298451bf9049a51aba5fac2df019d87 */
46
46
  export namespace ScenePatchSchema {
47
47
  export type Id = string;
48
48
  export type License = { "source"?: string; "commercialUse"?: boolean; "attribution"?: string; };
@@ -54,14 +54,14 @@ export namespace ScenePatchSchema {
54
54
  export type TransformPatch = { "location"?: ScenePatchSchema.Vec3; "rotationEuler"?: ScenePatchSchema.Vec3; "scale"?: ScenePatchSchema.Vec3; };
55
55
  export type MaterialParameters = { "baseColor"?: ScenePatchSchema.UnitColor; "metallic"?: number; "roughness"?: number; "ior"?: number; "alpha"?: number; "emissionColor"?: ScenePatchSchema.UnitColor; "emissionStrength"?: ScenePatchSchema.NonNegativeNumber; "coatWeight"?: number; "transmissionWeight"?: number; "anisotropic"?: number; "anisotropicRotation"?: number; };
56
56
  export type ProceduralTexture = ({ "type": "noise" | "wave" | "voronoi"; "scale": number; "detail"?: number; "distortion"?: number; "stretch"?: [number, number, number]; "bump"?: number; "roughnessVariation"?: number; "colorVariation"?: number; "coordinates"?: "object"; }) | ({ "type": "noise" | "wave" | "voronoi"; "scale": number; "detail"?: number; "distortion"?: number; "stretch"?: [number, number, number]; "bump"?: number; "roughnessVariation"?: number; "colorVariation"?: number; "coordinates": "uv"; "uvMap"?: string; });
57
- export type Generator = { "shape": "cube" | "uv_sphere" | "cylinder" | "cone" | "plane" | "torus" | "rounded_box" | "lathe" | "curve" | "handled_cup"; "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]; };
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
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; };
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
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); });
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"; });
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; };
67
67
  export type MaterialBinding = { "partId": string; "slotIndex"?: number; "materialId": ScenePatchSchema.Id; };
@@ -73,12 +73,12 @@ export namespace ScenePatchSchema {
73
73
  }
74
74
  export type ScenePatch = ScenePatchSchema.Document;
75
75
 
76
- /** Source SHA-256: 45fa82b8cdab30e93ae35c1f8e3bfd6fdb0cc3647c3847365ebf87704d1312c3 */
76
+ /** Source SHA-256: d1a8a5d3d485ebe093028451164db1f89219577a31315787ead20828960195eb */
77
77
  export namespace RecipeSchema {
78
78
  export type Binding = ({ "kind": "material"; "materialId": string; "property": "baseColor" | "roughness"; }) | ({ "kind": "render-profile"; "profile": "preview" | "final"; "property": "exposure"; }) | ({ "kind": "entity"; "entityId": string; "property": "dimensions" | "location"; "axis": "x" | "y" | "z"; "multiplier": number; "offsetAnimation"?: boolean; "inputFloor"?: number; }) | ({ "kind": "camera"; "cameraId": string; "property": "location" | "targetPoint"; "axis": "x" | "y" | "z"; "multiplier": number; }) | ({ "kind": "generator"; "entityId": string; "property": "height" | "radius" | "wallThickness" | "handleLower" | "handleUpper" | "handleRadius" | "rootRadius" | "rootLength"; "multiplier": number; }) | ({ "kind": "lathe-shell"; "entityId": string; "linerEntityId": string; "outerPointCount": number; "linerStart": number; "linerPointCount": number; "rimHeight": number; "neckAnchorHeight": number; "multiplier": number; }) | ({ "kind": "curve-point"; "entityId": string; "pointIndex": number; "axis": "x" | "y" | "z"; "multiplier": number; "inputFloor"?: number; });
79
79
  export type ColorParameter = { "id": string; "title": string; "description"?: string; "bindings": Array<RecipeSchema.Binding>; "type": "color"; "default": [number, number, number]; };
80
80
  export type NumberParameter = { "id": string; "title": string; "description"?: string; "bindings": Array<RecipeSchema.Binding>; "type": "number"; "default": number; "minimum": number; "maximum": number; };
81
- export type Document = { "schemaVersion": "deepblend.recipe/v1"; "id": string; "version": string; "title": string; "description": string; "author": { "name": string; "url"?: string; }; "license": string; "source": { "url": string; "note"?: string; }; "compatibility": { "sceneSchemaVersion": "deepblend.scene/v1"; "capabilities": Array<"geometry.primitive" | "geometry.primitive.dimensions" | "geometry.lathe" | "geometry.curve" | "geometry.handled_cup" | "geometry.handled_cup.tension" | "geometry.handled_cup.tension.extended" | "geometry.modifiers" | "material.principled" | "material.glass" | "material.emission" | "material.procedural" | "material.procedural.uv" | "material.anisotropy" | "animation.transform" | "animation.material" | "recipe.geometry-bindings" | "recipe.generator-bindings" | "recipe.lathe-shell-bindings" | "recipe.curve-point-bindings" | "recipe.threshold-bindings">; }; "input": { "path": "scene-spec.json"; "sha256": string; }; "preview": { "path": "preview.png"; "sha256": string; "mediaType": "image/png"; "alt": string; }; "parameters": Array<(RecipeSchema.ColorParameter) | (RecipeSchema.NumberParameter)>; };
81
+ export type Document = { "schemaVersion": "deepblend.recipe/v1"; "id": string; "version": string; "title": string; "description": string; "author": { "name": string; "url"?: string; }; "license": string; "source": { "url": string; "note"?: string; }; "compatibility": { "sceneSchemaVersion": "deepblend.scene/v1"; "capabilities": Array<"geometry.primitive" | "geometry.primitive.dimensions" | "geometry.lathe" | "geometry.curve" | "geometry.handled_cup" | "geometry.handled_cup.tension" | "geometry.handled_cup.tension.extended" | "geometry.modifiers" | "material.principled" | "material.glass" | "material.emission" | "material.procedural" | "material.procedural.uv" | "material.anisotropy" | "animation.transform" | "animation.material" | "recipe.geometry-bindings" | "recipe.generator-bindings" | "recipe.lathe-shell-bindings" | "recipe.curve-point-bindings" | "recipe.threshold-bindings" | "geometry.procedural.mesh" | "geometry.modifier.subdivision" | "geometry.modifier.surface_scatter">; }; "input": { "path": "scene-spec.json"; "sha256": string; }; "preview": { "path": "preview.png"; "sha256": string; "mediaType": "image/png"; "alt": string; }; "parameters": Array<(RecipeSchema.ColorParameter) | (RecipeSchema.NumberParameter)>; };
82
82
  }
83
83
  export type RecipeManifest = RecipeSchema.Document;
84
84
  export type Entity = SceneSpecSchema.Entity;
@@ -97,7 +97,7 @@
97
97
  "capabilities": {
98
98
  "type": "array",
99
99
  "minItems": 1,
100
- "maxItems": 21,
100
+ "maxItems": 24,
101
101
  "items": {
102
102
  "enum": [
103
103
  "geometry.primitive",
@@ -120,7 +120,10 @@
120
120
  "recipe.generator-bindings",
121
121
  "recipe.lathe-shell-bindings",
122
122
  "recipe.curve-point-bindings",
123
- "recipe.threshold-bindings"
123
+ "recipe.threshold-bindings",
124
+ "geometry.procedural.mesh",
125
+ "geometry.modifier.subdivision",
126
+ "geometry.modifier.surface_scatter"
124
127
  ]
125
128
  }
126
129
  }
@@ -359,6 +359,7 @@
359
359
  "required": [
360
360
  "shape"
361
361
  ],
362
+ "description": "Deterministic procedural geometry. Lathe revolves a radius/height profile; handled_cup constructs a closed cup with shared-boundary flared handle roots. Coupled parameter constraints are checked before generation and the discrete output is validated. Mesh accepts bounded local vertices and indexed faces, optional per-corner UVs and smooth shading; it never accepts expressions or scripts.",
362
363
  "properties": {
363
364
  "shape": {
364
365
  "type": "string",
@@ -372,7 +373,8 @@
372
373
  "rounded_box",
373
374
  "lathe",
374
375
  "curve",
375
- "handled_cup"
376
+ "handled_cup",
377
+ "mesh"
376
378
  ]
377
379
  },
378
380
  "size": {
@@ -528,9 +530,62 @@
528
530
  "$ref": "#/$defs/positiveNumber"
529
531
  },
530
532
  "description": "Explicit local width, depth and height for cube or rounded_box, in scene units, before object transform and bevel. Mutually exclusive with scalar size."
533
+ },
534
+ "vertices": {
535
+ "type": "array",
536
+ "minItems": 3,
537
+ "maxItems": 32768,
538
+ "items": {
539
+ "type": "array",
540
+ "minItems": 3,
541
+ "maxItems": 3,
542
+ "items": {
543
+ "type": "number",
544
+ "minimum": -1000000,
545
+ "maximum": 1000000
546
+ }
547
+ },
548
+ "description": "Mesh-only local-space control points. Object transform is applied separately."
549
+ },
550
+ "faces": {
551
+ "type": "array",
552
+ "minItems": 1,
553
+ "maxItems": 32768,
554
+ "items": {
555
+ "type": "array",
556
+ "minItems": 3,
557
+ "maxItems": 32,
558
+ "items": {
559
+ "type": "integer",
560
+ "minimum": 0
561
+ }
562
+ },
563
+ "description": "Mesh-only ordered vertex indices; winding is preserved. Total face corners must not exceed 131072."
564
+ },
565
+ "faceUvs": {
566
+ "type": "array",
567
+ "minItems": 1,
568
+ "maxItems": 32768,
569
+ "items": {
570
+ "type": "array",
571
+ "minItems": 3,
572
+ "maxItems": 32,
573
+ "items": {
574
+ "type": "array",
575
+ "minItems": 2,
576
+ "maxItems": 2,
577
+ "items": {
578
+ "type": "number"
579
+ }
580
+ }
581
+ },
582
+ "description": "Optional mesh-only UV coordinates per face corner, including seams without splitting geometry. Omitted uses planar UVs."
583
+ },
584
+ "smooth": {
585
+ "type": "boolean",
586
+ "description": "Mesh-only smooth polygon shading; default false. Does not move or subdivide vertices."
531
587
  }
532
- },
533
- "description": "Deterministic procedural geometry. Lathe revolves a radius/height profile; handled_cup constructs a closed cup with shared-boundary flared handle roots. Coupled parameter constraints are checked before generation and the discrete output is validated."
588
+ }
534
589
  },
535
590
  "entity": {
536
591
  "type": "object",
@@ -1858,6 +1913,103 @@
1858
1913
  "description": "Inner corner join for this bevel modifier. Omitted values preserve the existing arc behavior."
1859
1914
  }
1860
1915
  }
1916
+ },
1917
+ {
1918
+ "type": "object",
1919
+ "additionalProperties": false,
1920
+ "required": [
1921
+ "type",
1922
+ "levels"
1923
+ ],
1924
+ "properties": {
1925
+ "type": {
1926
+ "const": "subdivision"
1927
+ },
1928
+ "levels": {
1929
+ "type": "integer",
1930
+ "minimum": 1,
1931
+ "maximum": 3
1932
+ },
1933
+ "scheme": {
1934
+ "type": "string",
1935
+ "enum": [
1936
+ "catmull-clark",
1937
+ "simple"
1938
+ ],
1939
+ "description": "Default catmull-clark smooths the control surface; simple refines without rounding it."
1940
+ },
1941
+ "boundaryMode": {
1942
+ "type": "string",
1943
+ "enum": [
1944
+ "all",
1945
+ "preserve-corners"
1946
+ ],
1947
+ "description": "Default all. Preserve-corners keeps corners of an open boundary while smoothing the remaining surface."
1948
+ }
1949
+ }
1950
+ },
1951
+ {
1952
+ "type": "object",
1953
+ "additionalProperties": false,
1954
+ "required": [
1955
+ "type",
1956
+ "targetEntityIds",
1957
+ "count",
1958
+ "anchorVertexIndices"
1959
+ ],
1960
+ "properties": {
1961
+ "type": {
1962
+ "const": "surface_scatter"
1963
+ },
1964
+ "targetEntityIds": {
1965
+ "type": "array",
1966
+ "minItems": 1,
1967
+ "maxItems": 8,
1968
+ "items": {
1969
+ "$ref": "#/$defs/id"
1970
+ }
1971
+ },
1972
+ "count": {
1973
+ "type": "integer",
1974
+ "minimum": 1,
1975
+ "maximum": 512
1976
+ },
1977
+ "seed": {
1978
+ "type": "integer",
1979
+ "minimum": 0,
1980
+ "maximum": 2147483647
1981
+ },
1982
+ "anchorVertexIndices": {
1983
+ "type": "array",
1984
+ "minItems": 1,
1985
+ "maxItems": 8,
1986
+ "items": {
1987
+ "type": "integer",
1988
+ "minimum": 0,
1989
+ "maximum": 999999
1990
+ }
1991
+ },
1992
+ "embedDepthMm": {
1993
+ "type": "number",
1994
+ "exclusiveMinimum": 0,
1995
+ "maximum": 100
1996
+ },
1997
+ "scaleRange": {
1998
+ "type": "array",
1999
+ "minItems": 2,
2000
+ "maxItems": 2,
2001
+ "items": {
2002
+ "type": "number",
2003
+ "minimum": 0.05,
2004
+ "maximum": 20
2005
+ }
2006
+ },
2007
+ "upwardBias": {
2008
+ "type": "number",
2009
+ "minimum": 0,
2010
+ "maximum": 1
2011
+ }
2012
+ }
1861
2013
  }
1862
2014
  ]
1863
2015
  },
@@ -541,7 +541,7 @@
541
541
  "required": [
542
542
  "shape"
543
543
  ],
544
- "description": "Deterministic procedural geometry. Lathe revolves a radius/height profile; handled_cup constructs a closed cup with shared-boundary flared handle roots. Coupled parameter constraints are checked before generation and the discrete output is validated.",
544
+ "description": "Deterministic procedural geometry. Lathe revolves a radius/height profile; handled_cup constructs a closed cup with shared-boundary flared handle roots. Coupled parameter constraints are checked before generation and the discrete output is validated. Mesh accepts bounded local vertices and indexed faces, optional per-corner UVs and smooth shading; it never accepts expressions or scripts.",
545
545
  "properties": {
546
546
  "shape": {
547
547
  "type": "string",
@@ -555,7 +555,8 @@
555
555
  "rounded_box",
556
556
  "lathe",
557
557
  "curve",
558
- "handled_cup"
558
+ "handled_cup",
559
+ "mesh"
559
560
  ]
560
561
  },
561
562
  "size": {
@@ -711,6 +712,60 @@
711
712
  "$ref": "#/$defs/positiveNumber"
712
713
  },
713
714
  "description": "Explicit local width, depth and height for cube or rounded_box, in scene units, before object transform and bevel. Mutually exclusive with scalar size."
715
+ },
716
+ "vertices": {
717
+ "type": "array",
718
+ "minItems": 3,
719
+ "maxItems": 32768,
720
+ "items": {
721
+ "type": "array",
722
+ "minItems": 3,
723
+ "maxItems": 3,
724
+ "items": {
725
+ "type": "number",
726
+ "minimum": -1000000,
727
+ "maximum": 1000000
728
+ }
729
+ },
730
+ "description": "Mesh-only local-space control points. Object transform is applied separately."
731
+ },
732
+ "faces": {
733
+ "type": "array",
734
+ "minItems": 1,
735
+ "maxItems": 32768,
736
+ "items": {
737
+ "type": "array",
738
+ "minItems": 3,
739
+ "maxItems": 32,
740
+ "items": {
741
+ "type": "integer",
742
+ "minimum": 0
743
+ }
744
+ },
745
+ "description": "Mesh-only ordered vertex indices; winding is preserved. Total face corners must not exceed 131072."
746
+ },
747
+ "faceUvs": {
748
+ "type": "array",
749
+ "minItems": 1,
750
+ "maxItems": 32768,
751
+ "items": {
752
+ "type": "array",
753
+ "minItems": 3,
754
+ "maxItems": 32,
755
+ "items": {
756
+ "type": "array",
757
+ "minItems": 2,
758
+ "maxItems": 2,
759
+ "items": {
760
+ "type": "number"
761
+ }
762
+ }
763
+ },
764
+ "description": "Optional mesh-only UV coordinates per face corner, including seams without splitting geometry. Omitted uses planar UVs."
765
+ },
766
+ "smooth": {
767
+ "type": "boolean",
768
+ "description": "Mesh-only smooth polygon shading; default false. Does not move or subdivide vertices."
714
769
  }
715
770
  }
716
771
  },
@@ -1402,6 +1457,103 @@
1402
1457
  "description": "Inner corner join for this bevel modifier. Omitted values preserve the existing arc behavior."
1403
1458
  }
1404
1459
  }
1460
+ },
1461
+ {
1462
+ "type": "object",
1463
+ "additionalProperties": false,
1464
+ "required": [
1465
+ "type",
1466
+ "levels"
1467
+ ],
1468
+ "properties": {
1469
+ "type": {
1470
+ "const": "subdivision"
1471
+ },
1472
+ "levels": {
1473
+ "type": "integer",
1474
+ "minimum": 1,
1475
+ "maximum": 3
1476
+ },
1477
+ "scheme": {
1478
+ "type": "string",
1479
+ "enum": [
1480
+ "catmull-clark",
1481
+ "simple"
1482
+ ],
1483
+ "description": "Default catmull-clark smooths the control surface; simple refines without rounding it."
1484
+ },
1485
+ "boundaryMode": {
1486
+ "type": "string",
1487
+ "enum": [
1488
+ "all",
1489
+ "preserve-corners"
1490
+ ],
1491
+ "description": "Default all. Preserve-corners keeps corners of an open boundary while smoothing the remaining surface."
1492
+ }
1493
+ }
1494
+ },
1495
+ {
1496
+ "type": "object",
1497
+ "additionalProperties": false,
1498
+ "required": [
1499
+ "type",
1500
+ "targetEntityIds",
1501
+ "count",
1502
+ "anchorVertexIndices"
1503
+ ],
1504
+ "properties": {
1505
+ "type": {
1506
+ "const": "surface_scatter"
1507
+ },
1508
+ "targetEntityIds": {
1509
+ "type": "array",
1510
+ "minItems": 1,
1511
+ "maxItems": 8,
1512
+ "items": {
1513
+ "$ref": "#/$defs/id"
1514
+ }
1515
+ },
1516
+ "count": {
1517
+ "type": "integer",
1518
+ "minimum": 1,
1519
+ "maximum": 512
1520
+ },
1521
+ "seed": {
1522
+ "type": "integer",
1523
+ "minimum": 0,
1524
+ "maximum": 2147483647
1525
+ },
1526
+ "anchorVertexIndices": {
1527
+ "type": "array",
1528
+ "minItems": 1,
1529
+ "maxItems": 8,
1530
+ "items": {
1531
+ "type": "integer",
1532
+ "minimum": 0,
1533
+ "maximum": 999999
1534
+ }
1535
+ },
1536
+ "embedDepthMm": {
1537
+ "type": "number",
1538
+ "exclusiveMinimum": 0,
1539
+ "maximum": 100
1540
+ },
1541
+ "scaleRange": {
1542
+ "type": "array",
1543
+ "minItems": 2,
1544
+ "maxItems": 2,
1545
+ "items": {
1546
+ "type": "number",
1547
+ "minimum": 0.05,
1548
+ "maximum": 20
1549
+ }
1550
+ },
1551
+ "upwardBias": {
1552
+ "type": "number",
1553
+ "minimum": 0,
1554
+ "maximum": 1
1555
+ }
1556
+ }
1405
1557
  }
1406
1558
  ]
1407
1559
  },
package/lib/sdk.d.ts CHANGED
@@ -33,6 +33,9 @@ export function validateSceneSpec(input: unknown): SceneSpecValidation;
33
33
  export function parseSceneSpec(input: unknown): SceneSpec;
34
34
  /** Does not validate first. Call parseSceneSpec or check validateSceneSpec before compiling. */
35
35
  export const BOX_DIMENSIONS_FEATURE: 'geometry.primitive.dimensions';
36
+ export const MESH_GEOMETRY_FEATURE: 'geometry.procedural.mesh';
37
+ export const SUBDIVISION_FEATURE: 'geometry.modifier.subdivision';
38
+ export const SURFACE_SCATTER_FEATURE: 'geometry.modifier.surface_scatter';
36
39
  export function requiredSceneFeatures(spec: SceneSpec): string[];
37
40
  export function compileSceneSpec(spec: SceneSpec): {
38
41
  spec: SceneSpec; notices: SceneSpecIssue[];
@@ -119,3 +122,7 @@ export function instantiateRecipeLock(lock: RecipeLock, changes?: RecipeValues,
119
122
  export function recipeGeometryParameters(manifest: RecipeManifest): RecipeManifest['parameters'];
120
123
  export function planRecipeGeometryEdit(lock: RecipeLock, currentSpec: SceneSpec,
121
124
  parameterState: RecipeParameterState | undefined, changes: Record<string, number>): RecipeGeometryPlan;
125
+
126
+ /** Opt-in actual evaluated mesh bounds, including object/world scale, excluding placement rotation/translation. */
127
+ export const OBJECT_AXES_INSPECTION_VERSION: "deepblend.geometry-inspection/v3";
128
+ export const OBJECT_AXES_BASIS: "evaluated-object-axes-scaled";
package/lib/sdk.js CHANGED
@@ -12,7 +12,7 @@ export { canonicalStringify, canonicalPretty, sha256, sha256Canonical } from './
12
12
  export {
13
13
  validateSceneSpec, compileSceneSpec, sceneSpecCanonicalText, sceneSpecDigest, specHash,
14
14
  reviewInputsDigest, summarizeSceneSpec,
15
- BOX_DIMENSIONS_FEATURE, requiredSceneFeatures,
15
+ BOX_DIMENSIONS_FEATURE, MESH_GEOMETRY_FEATURE, SUBDIVISION_FEATURE, SURFACE_SCATTER_FEATURE, requiredSceneFeatures,
16
16
  } from './scene-spec.js'
17
17
  export { SCENE_OPERATION_NAMES, validateScenePatch, applyPatchToSpec, buildOperationManifest } from './scene-patch.js'
18
18
  export {
@@ -5,7 +5,7 @@ const sources = new Set([
5
5
  ])
6
6
  const close = (a, b) => Number.isFinite(a) && Number.isFinite(b) && Math.abs(a - b) <= 1e-9
7
7
 
8
- export function translatedSpeakerAssembly(lock, current, before, after) {
8
+ function translatedOnly(lock, current, before, after) {
9
9
  if (!sources.has(lock.manifestSha256)) return { before, after }
10
10
  const parts = before.spec.entities.filter(entity => entity.id !== 'studio-floor')
11
11
  const anchor = parts.find(entity => entity.id === 'cabinet-shell')
@@ -39,3 +39,61 @@ export function translatedSpeakerAssembly(lock, current, before, after) {
39
39
  }
40
40
  return { before: translate(before), after: translate(after) }
41
41
  }
42
+
43
+ // XYZ Euler matrices match Blender's intrinsic object rotations (Rz * Ry * Rx).
44
+ const rotation = ([x, y, z]) => {
45
+ const cx = Math.cos(x), sx = Math.sin(x), cy = Math.cos(y), sy = Math.sin(y), cz = Math.cos(z), sz = Math.sin(z)
46
+ return [[cz*cy, cz*sy*sx-sz*cx, cz*sy*cx+sz*sx], [sz*cy, sz*sy*sx+cz*cx, sz*sy*cx-cz*sx], [-sy, cy*sx, cy*cx]]
47
+ }
48
+ const mul = (m, p) => m.map(row => row.reduce((sum, value, i) => sum + value*p[i], 0))
49
+ const transpose = m => m[0].map((_, i) => m.map(row => row[i]))
50
+ const product = (a, b) => a.map(row => transpose(b).map(column => row.reduce((s, v, i) => s + v*column[i], 0)))
51
+ const near = (a, b) => Array.isArray(a) && Array.isArray(b) ? a.length === b.length && a.every((v, i) => near(v, b[i]))
52
+ : Number.isFinite(a) && Number.isFinite(b) && Math.abs(a-b) <= 1e-6
53
+
54
+ /** Recognize a complete pinned rigid pose; partial and scaled placements remain conflicts. */
55
+ export function translatedSpeakerAssembly(lock, current, before, after) {
56
+ if (!sources.has(lock.manifestSha256)) return { before, after }
57
+ const parts = before.spec.entities.filter(e => e.id !== 'studio-floor')
58
+ const anchor = parts.find(e => e.id === 'cabinet-shell'), saved = current.entities.find(e => e.id === anchor?.id)
59
+ if (!saved?.transform?.rotationEuler) return translatedOnly(lock, current, before, after)
60
+ const matrix = product(rotation(saved.transform.rotationEuler), transpose(rotation(anchor.transform.rotationEuler)))
61
+ // Retain the existing exact translation checks for identity orientation.
62
+ if (near(matrix, [[1,0,0],[0,1,0],[0,0,1]])) return translatedOnly(lock, current, before, after)
63
+ const point = p => mul(matrix, p.map((v, i) => v-anchor.transform.location[i])).map((v, i) => v+saved.transform.location[i])
64
+ const actualParts = new Map(current.entities.map(e => [e.id, e]))
65
+ if (!parts.every(original => {
66
+ const actual = actualParts.get(original.id)
67
+ return actual?.type === original.type && near(actual.transform?.location, point(original.transform.location))
68
+ && near(rotation(actual.transform.rotationEuler), product(matrix, rotation(original.transform.rotationEuler)))
69
+ && original.transform.scale.every((v, i) => close(v, actual.transform.scale[i]))
70
+ })) return { before, after }
71
+ // A rotated translation curve needs a world-space rest anchor on every moved axis.
72
+ // Authored later keys/travel are preserved; absence of a coupled curve is unsafe.
73
+ for (const original of before.spec.animationTracks ?? []) {
74
+ if ((original.targetKind ?? 'entity') !== 'entity' || !actualParts.has(original.targetEntityId)
75
+ || !parts.some(e => e.id === original.targetEntityId) || !/^location\.[xyz]$/.test(original.property)) continue
76
+ const axis = ['x','y','z'].indexOf(original.property.at(-1))
77
+ const originalPart = parts.find(e => e.id === original.targetEntityId)
78
+ const rest = [...originalPart.transform.location]; rest[axis] = original.keyframes[0].value
79
+ const expected = point(rest)
80
+ for (let worldAxis = 0; worldAxis < 3; worldAxis++) {
81
+ if (Math.abs(matrix[worldAxis][axis]) <= 1e-9) continue
82
+ const candidates = (current.animationTracks ?? []).filter(t => (t.targetKind ?? 'entity') === 'entity'
83
+ && t.targetEntityId === original.targetEntityId && t.property === `location.${['x','y','z'][worldAxis]}`)
84
+ if (candidates.length !== 1 || candidates[0].keyframes[0]?.frame !== original.keyframes[0].frame
85
+ || !near(candidates[0].keyframes[0]?.value, expected[worldAxis])) return { before, after }
86
+ }
87
+ }
88
+ const posedBefore = structuredClone(before), posedAfter = structuredClone(after)
89
+ for (const original of parts) {
90
+ const actual = actualParts.get(original.id), next = posedAfter.spec.entities.find(e => e.id === original.id)
91
+ const old = posedBefore.spec.entities.find(e => e.id === original.id)
92
+ old.transform.location = [...actual.transform.location]
93
+ old.transform.rotationEuler = [...actual.transform.rotationEuler]
94
+ next.transform.location = mul(matrix, next.transform.location.map((v, i) => v-original.transform.location[i]))
95
+ .map((v, i) => v+actual.transform.location[i])
96
+ next.transform.rotationEuler = [...actual.transform.rotationEuler]
97
+ }
98
+ return { before: posedBefore, after: posedAfter, rigidPose: true }
99
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deepblend/dsh-blender-contracts",
3
- "version": "0.13.0",
3
+ "version": "0.15.0",
4
4
  "type": "module",
5
5
  "description": "DeepBlend Studio Service Definition, protocol contracts, and stable error codes.",
6
6
  "main": "lib/index.js",