@instruktlabs/kiln 1.2.2 → 1.2.3
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/.claude-plugin/plugin.json +1 -1
- package/.codex-plugin/plugin.json +1 -1
- package/CHANGELOG.md +74 -0
- package/README.md +7 -0
- package/dist/agent-run.mjs +6392 -1477
- package/dist/build.json +23 -23
- package/dist/cli.mjs +8453 -3407
- package/dist/evaluator-worker.mjs +16608 -12387
- package/dist/mcp-engine.mjs +6746 -1725
- package/dist/mcp-server.mjs +4 -4
- package/dist/viewer/app.js +203 -199
- package/dist/viewer/chat.html +209 -205
- package/dist/viewer/style.css +10 -0
- package/docs/atlas-provenance.md +23 -0
- package/docs/community-exporter.md +27 -0
- package/docs/export-profiles.md +20 -0
- package/docs/material-library.md +9 -5
- package/docs/procedural-surfaces-v3.md +276 -0
- package/docs/projects-and-live-review.md +1 -1
- package/docs/rendering.md +41 -0
- package/docs/sdk.md +53 -0
- package/docs/tools-operations.md +2 -2
- package/docs/tools.md +3 -3
- package/lib/asset-materials-node.d.ts +3 -3
- package/lib/asset-materials-node.js +29 -33
- package/lib/assets-node.d.ts +1 -1
- package/lib/assets-node.js +11 -4
- package/lib/assets.d.ts +4 -2
- package/lib/assets.js +61 -16
- package/lib/atlas-provenance.d.ts +86 -0
- package/lib/atlas-provenance.js +448 -0
- package/lib/character.d.ts +11 -2
- package/lib/character.js +90 -2
- package/lib/community-exporter.d.ts +3 -2
- package/lib/community-exporter.js +139 -3
- package/lib/discovery/helper-contracts.js +161 -7
- package/lib/discovery/helper-specs.js +49 -4
- package/lib/discovery/shapes.js +20 -7
- package/lib/engine-identity.d.ts +1 -1
- package/lib/engine-identity.js +1 -1
- package/lib/evaluator/authoring-diagnostic.d.ts +1 -1
- package/lib/evaluator/authoring-diagnostic.js +12 -0
- package/lib/evaluator/protocol.d.ts +2 -2
- package/lib/evaluator/protocol.js +16 -6
- package/lib/evaluator/subprocess.js +2 -2
- package/lib/exporter-node.js +9 -1
- package/lib/geometry-budget.d.ts +7 -0
- package/lib/geometry-budget.js +8 -0
- package/lib/gltf-texture-binding.d.ts +6 -0
- package/lib/gltf-texture-binding.js +54 -0
- package/lib/material-authoring-node.d.ts +6 -0
- package/lib/material-authoring-node.js +49 -0
- package/lib/material-authoring-schema.d.ts +871 -0
- package/lib/material-authoring-schema.js +310 -0
- package/lib/material-export.d.ts +5 -0
- package/lib/material-export.js +21 -0
- package/lib/material-library-node.d.ts +34 -8
- package/lib/material-library-node.js +691 -11
- package/lib/material-library.d.ts +3704 -4
- package/lib/material-library.js +272 -0
- package/lib/mcp-core.d.ts +1 -1
- package/lib/pinned-material-map.d.ts +33 -0
- package/lib/pinned-material-map.js +1 -0
- package/lib/portable-material-runtime.d.ts +5 -0
- package/lib/portable-material-runtime.js +160 -0
- package/lib/portable-sampler-runtime.d.ts +4 -0
- package/lib/portable-sampler-runtime.js +26 -0
- package/lib/portable-sampler.d.ts +11 -0
- package/lib/portable-sampler.js +42 -0
- package/lib/primitives.d.ts +15 -3
- package/lib/primitives.js +24 -4
- package/lib/procedural-material-v2.d.ts +2 -0
- package/lib/procedural-material-v2.js +2 -1
- package/lib/procedural-material-v3.d.ts +72 -0
- package/lib/procedural-material-v3.js +162 -0
- package/lib/procedural-texture-v2-compiler.d.ts +31 -0
- package/lib/procedural-texture-v2-compiler.js +172 -0
- package/lib/procedural-texture-v3-contract.d.ts +125 -0
- package/lib/procedural-texture-v3-contract.js +333 -0
- package/lib/procedural-texture-v3.d.ts +12 -0
- package/lib/procedural-texture-v3.js +165 -0
- package/lib/procedural-texture.d.ts +9 -31
- package/lib/procedural-texture.js +43 -170
- package/lib/project-bundle-node.d.ts +1 -1
- package/lib/project-bundle-node.js +70 -13
- package/lib/project-bundle.d.ts +91 -3
- package/lib/project-bundle.js +48 -7
- package/lib/qa/atlas.d.ts +21 -0
- package/lib/qa/atlas.js +474 -0
- package/lib/qa/index.d.ts +1 -0
- package/lib/qa/index.js +1 -0
- package/lib/qa/material.js +2 -0
- package/lib/qa/skin-integrity.d.ts +18 -0
- package/lib/qa/skin-integrity.js +221 -0
- package/lib/render-service-host.js +4 -7
- package/lib/render.d.ts +3 -3
- package/lib/render.js +108 -16
- package/lib/skin-binding.d.ts +20 -0
- package/lib/skin-binding.js +144 -0
- package/lib/texture-atlas-contract.d.ts +97 -0
- package/lib/texture-atlas-contract.js +414 -0
- package/lib/texture-atlas-pixels.d.ts +73 -0
- package/lib/texture-atlas-pixels.js +290 -0
- package/lib/texture-atlas.d.ts +10 -0
- package/lib/texture-atlas.js +143 -0
- package/lib/texture-bake.d.ts +3 -0
- package/lib/texture-bake.js +66 -11
- package/lib/texture-resolver.d.ts +22 -0
- package/lib/texture-resolver.js +24 -0
- package/lib/tools/materials.js +8 -7
- package/lib/tools/registry.js +5 -16
- package/lib/tools/review.js +1 -1
- package/lib/uv-data.d.ts +32 -0
- package/lib/uv-data.js +172 -0
- package/lib/uv-shapes.js +3 -0
- package/lib/uv.d.ts +9 -3
- package/lib/uv.js +53 -82
- package/lib/views/camera.d.ts +3 -3
- package/lib/views/camera.js +32 -28
- package/lib/views/face-policy.d.ts +9 -0
- package/lib/views/face-policy.js +16 -0
- package/lib/views/glb.js +218 -24
- package/lib/views/pose.d.ts +7 -1
- package/lib/views/pose.js +63 -12
- package/lib/views/raster.d.ts +6 -2
- package/lib/views/raster.js +49 -37
- package/lib/views/scene-copy.d.ts +6 -0
- package/lib/views/scene-copy.js +73 -0
- package/lib/views/scene-raster.js +2 -1
- package/lib/views/triangle-coverage.d.ts +8 -0
- package/lib/views/triangle-coverage.js +58 -0
- package/lib/workspace-node.js +7 -3
- package/lib/workspace.d.ts +2 -2
- package/package.json +3 -1
- package/plugin.json +1 -1
- package/plugins/kiln-engine/.claude-plugin/plugin.json +1 -1
- package/plugins/kiln-engine/README.md +3 -3
- package/plugins/kiln-engine/package-provenance.json +6 -6
- package/plugins/kiln-engine/plugin.json +1 -1
- package/plugins/kiln-engine/runtime.json +1 -1
- package/skills/kiln-author-asset/references/geometry-recipes.md +124 -0
- package/skills/kiln-author-asset/references/projects-and-materials.md +32 -2
- package/skills/kiln-compose-scene/references/runtime-scenes.md +19 -0
- package/skills/kiln-qa-asset/references/integration-checks.md +37 -2
- package/src/asset-materials-node.ts +38 -45
- package/src/assets-node.ts +22 -5
- package/src/assets.ts +61 -20
- package/src/atlas-provenance.ts +522 -0
- package/src/character.ts +107 -2
- package/src/community-exporter.ts +143 -3
- package/src/discovery/helper-contracts.ts +188 -7
- package/src/discovery/helper-specs.ts +69 -4
- package/src/discovery/shapes.ts +25 -9
- package/src/engine-identity.ts +1 -1
- package/src/evaluator/authoring-diagnostic.ts +19 -1
- package/src/evaluator/protocol.ts +19 -9
- package/src/evaluator/subprocess.ts +2 -2
- package/src/exporter-node.ts +12 -1
- package/src/generated/mcp-manifest.json +3 -3
- package/src/geometry-budget.ts +8 -0
- package/src/gltf-texture-binding.ts +60 -0
- package/src/material-authoring-node.ts +68 -0
- package/src/material-authoring-schema.ts +343 -0
- package/src/material-export.ts +25 -0
- package/src/material-library-node.ts +840 -16
- package/src/material-library.ts +348 -5
- package/src/pinned-material-map.ts +43 -0
- package/src/portable-material-runtime.ts +200 -0
- package/src/portable-sampler-runtime.ts +40 -0
- package/src/portable-sampler.ts +54 -0
- package/src/primitives.ts +98 -4
- package/src/procedural-material-v2.ts +2 -1
- package/src/procedural-material-v3.ts +224 -0
- package/src/procedural-texture-v2-compiler.ts +234 -0
- package/src/procedural-texture-v3-contract.ts +437 -0
- package/src/procedural-texture-v3.ts +220 -0
- package/src/procedural-texture.ts +61 -229
- package/src/project-bundle-node.ts +106 -14
- package/src/project-bundle.ts +61 -18
- package/src/project-cli.ts +29 -17
- package/src/qa/atlas.ts +597 -0
- package/src/qa/index.ts +1 -0
- package/src/qa/material.ts +2 -0
- package/src/qa/skin-integrity.ts +291 -0
- package/src/render-service-host.ts +4 -6
- package/src/render.ts +133 -15
- package/src/skin-binding.ts +225 -0
- package/src/texture-atlas-contract.ts +558 -0
- package/src/texture-atlas-pixels.ts +456 -0
- package/src/texture-atlas.ts +185 -0
- package/src/texture-bake.ts +88 -10
- package/src/texture-resolver.ts +55 -0
- package/src/tools/materials.ts +15 -11
- package/src/tools/registry.ts +5 -15
- package/src/tools/review.ts +1 -1
- package/src/uv-data.ts +238 -0
- package/src/uv-shapes.ts +3 -0
- package/src/uv.ts +73 -128
- package/src/viewer/app.ts +37 -0
- package/src/viewer/live-panel.ts +57 -1
- package/src/viewer/material-preview-panel.ts +140 -0
- package/src/viewer/material-preview.ts +138 -0
- package/src/viewer/materials-panel.ts +34 -5
- package/src/viewer/navigation.ts +2 -0
- package/src/views/camera.ts +37 -40
- package/src/views/face-policy.ts +20 -0
- package/src/views/glb.ts +294 -17
- package/src/views/pose.ts +71 -13
- package/src/views/raster.ts +73 -46
- package/src/views/scene-copy.ts +86 -0
- package/src/views/scene-raster.ts +2 -1
- package/src/views/triangle-coverage.ts +78 -0
- package/src/workspace-node.ts +11 -3
- package/src/workspace.ts +2 -2
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
/** Advertisable field shapes only. Existing canonicalizers own semantics and budgets. */
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import {
|
|
4
|
+
type CanonicalProceduralTextureSpecV2,
|
|
5
|
+
MIN_PROCEDURAL_SIZE,
|
|
6
|
+
MAX_PROCEDURAL_SIZE,
|
|
7
|
+
MAX_PROCEDURAL_LAYERS,
|
|
8
|
+
MAX_PROCEDURAL_PATTERN_COUNT,
|
|
9
|
+
MAX_NOISE_OCTAVES,
|
|
10
|
+
} from './procedural-material-v2';
|
|
11
|
+
import {
|
|
12
|
+
MAX_PROCEDURAL_V3_EDGE,
|
|
13
|
+
MAX_PROCEDURAL_V3_OPERATIONS,
|
|
14
|
+
MAX_PROCEDURAL_V3_VERTICES,
|
|
15
|
+
MAX_PROCEDURAL_V3_STAMPS,
|
|
16
|
+
MAX_PROCEDURAL_V3_PALETTE,
|
|
17
|
+
PROCEDURAL_TEXTURE_V3_COMPILER_ID,
|
|
18
|
+
} from './procedural-texture-v3-contract';
|
|
19
|
+
import { TEXTURE_ATLAS_COMPILER_ID, TEXTURE_ATLAS_LIMITS } from './texture-atlas-contract';
|
|
20
|
+
import {
|
|
21
|
+
PORTABLE_MIN_FILTERS_V1,
|
|
22
|
+
PORTABLE_MAG_FILTERS_V1,
|
|
23
|
+
PORTABLE_WRAPS_V1,
|
|
24
|
+
} from './portable-sampler';
|
|
25
|
+
import { TEXTURE_USAGES } from './texture-contract';
|
|
26
|
+
|
|
27
|
+
/** Persisted V2 shape: all canonical fields required, no author defaults or transforms. */
|
|
28
|
+
export const canonicalLegacyV2FieldSchema = (() => {
|
|
29
|
+
const color = z.number().int().min(0).max(0xffffff);
|
|
30
|
+
const count = z.number().int().min(1).max(MAX_PROCEDURAL_PATTERN_COUNT);
|
|
31
|
+
const angleDeg = z.number().min(-36000).max(36000);
|
|
32
|
+
const unit = z.number().min(0).max(1);
|
|
33
|
+
const common = { blend: z.enum(['normal', 'multiply', 'screen', 'overlay']), opacity: unit };
|
|
34
|
+
return z
|
|
35
|
+
.object({
|
|
36
|
+
schemaVersion: z.literal(2),
|
|
37
|
+
size: z.number().int().min(MIN_PROCEDURAL_SIZE).max(MAX_PROCEDURAL_SIZE),
|
|
38
|
+
usage: z.enum(TEXTURE_USAGES),
|
|
39
|
+
name: z.string().min(1).max(80).optional(),
|
|
40
|
+
layers: z
|
|
41
|
+
.array(
|
|
42
|
+
z.discriminatedUnion('op', [
|
|
43
|
+
z.object({ op: z.literal('solid'), color, ...common }).strict(),
|
|
44
|
+
z
|
|
45
|
+
.object({
|
|
46
|
+
op: z.literal('checker'),
|
|
47
|
+
colorA: color,
|
|
48
|
+
colorB: color,
|
|
49
|
+
squares: count,
|
|
50
|
+
...common,
|
|
51
|
+
})
|
|
52
|
+
.strict(),
|
|
53
|
+
z
|
|
54
|
+
.object({
|
|
55
|
+
op: z.literal('stripes'),
|
|
56
|
+
colorA: color,
|
|
57
|
+
colorB: color,
|
|
58
|
+
count,
|
|
59
|
+
angleDeg,
|
|
60
|
+
...common,
|
|
61
|
+
})
|
|
62
|
+
.strict(),
|
|
63
|
+
z
|
|
64
|
+
.object({ op: z.literal('gradient'), from: color, to: color, angleDeg, ...common })
|
|
65
|
+
.strict(),
|
|
66
|
+
z
|
|
67
|
+
.object({
|
|
68
|
+
op: z.literal('bricks'),
|
|
69
|
+
brick: color,
|
|
70
|
+
mortar: color,
|
|
71
|
+
rows: count,
|
|
72
|
+
cols: count,
|
|
73
|
+
mortarWidth: unit,
|
|
74
|
+
stagger: unit,
|
|
75
|
+
...common,
|
|
76
|
+
})
|
|
77
|
+
.strict(),
|
|
78
|
+
z
|
|
79
|
+
.object({
|
|
80
|
+
op: z.literal('noise'),
|
|
81
|
+
colorA: color,
|
|
82
|
+
colorB: color,
|
|
83
|
+
scale: count,
|
|
84
|
+
octaves: z.number().int().min(1).max(MAX_NOISE_OCTAVES),
|
|
85
|
+
seed: z.number().int().min(-2147483648).max(2147483647),
|
|
86
|
+
...common,
|
|
87
|
+
})
|
|
88
|
+
.strict(),
|
|
89
|
+
]),
|
|
90
|
+
)
|
|
91
|
+
.min(1)
|
|
92
|
+
.max(MAX_PROCEDURAL_LAYERS),
|
|
93
|
+
})
|
|
94
|
+
.strict();
|
|
95
|
+
})();
|
|
96
|
+
|
|
97
|
+
/** Inject author V2 without a circular import. Optional persisted leaf must have no defaults. */
|
|
98
|
+
export function makeMaterialAuthoringSchemas<S extends z.ZodType<CanonicalProceduralTextureSpecV2>>(
|
|
99
|
+
legacyV2Schema: S,
|
|
100
|
+
canonicalLegacyV2Schema: z.ZodType<CanonicalProceduralTextureSpecV2> = canonicalLegacyV2FieldSchema,
|
|
101
|
+
) {
|
|
102
|
+
const integer = (min: number, max: number) => z.number().int().min(min).max(max);
|
|
103
|
+
const byte = integer(0, 255);
|
|
104
|
+
const coordinate = integer(-4096, 4096);
|
|
105
|
+
const point = z.tuple([coordinate, coordinate]);
|
|
106
|
+
const rgba = z.tuple([byte, byte, byte, byte]);
|
|
107
|
+
const usage = z.enum(TEXTURE_USAGES);
|
|
108
|
+
const hash = z.templateLiteral(['sha256:', z.string().regex(/^[a-f0-9]{64}$/)]);
|
|
109
|
+
const name = z.string().min(1).max(80);
|
|
110
|
+
const stableId = z.string().regex(/^[a-z][a-z0-9_-]{0,79}$/);
|
|
111
|
+
const mapId = z.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9_.:/-]{0,199}$/);
|
|
112
|
+
const dimensions = { width: integer(1, 4096), height: integer(1, 4096) };
|
|
113
|
+
const pixelRectangleSchema = z
|
|
114
|
+
.object({ x: coordinate, y: coordinate, width: integer(1, 2048), height: integer(1, 2048) })
|
|
115
|
+
.strict();
|
|
116
|
+
const atlasRectangleSchema = z
|
|
117
|
+
.object({ x: integer(0, 4096), y: integer(0, 4096), ...dimensions })
|
|
118
|
+
.strict();
|
|
119
|
+
const shape = z.discriminatedUnion('kind', [
|
|
120
|
+
pixelRectangleSchema.extend({ kind: z.literal('rectangle') }).strict(),
|
|
121
|
+
pixelRectangleSchema.extend({ kind: z.literal('ellipse') }).strict(),
|
|
122
|
+
z
|
|
123
|
+
.object({
|
|
124
|
+
kind: z.literal('polygon'),
|
|
125
|
+
points: z.array(point).min(3).max(MAX_PROCEDURAL_V3_VERTICES),
|
|
126
|
+
})
|
|
127
|
+
.strict(),
|
|
128
|
+
z.object({ kind: z.literal('line'), from: point, to: point, width: integer(1, 2048) }).strict(),
|
|
129
|
+
]);
|
|
130
|
+
const paint = z.object({ op: z.literal('paint'), shape, rgba, opacity: byte }).strict();
|
|
131
|
+
const mask = z
|
|
132
|
+
.object({ op: z.literal('mask'), shape, alpha: byte, invert: z.boolean() })
|
|
133
|
+
.strict();
|
|
134
|
+
const stamps = z
|
|
135
|
+
.object({
|
|
136
|
+
op: z.literal('stamps'),
|
|
137
|
+
shape,
|
|
138
|
+
rgba,
|
|
139
|
+
opacity: byte,
|
|
140
|
+
count: integer(1, MAX_PROCEDURAL_V3_STAMPS),
|
|
141
|
+
seed: integer(0, 0xffffffff),
|
|
142
|
+
area: pixelRectangleSchema,
|
|
143
|
+
periodic: z.boolean(),
|
|
144
|
+
})
|
|
145
|
+
.strict();
|
|
146
|
+
const legacy = z
|
|
147
|
+
.object({ op: z.literal('legacy-v2'), spec: legacyV2Schema, alpha: byte, opacity: byte })
|
|
148
|
+
.strict();
|
|
149
|
+
const palette = z
|
|
150
|
+
.object({
|
|
151
|
+
colors: z.array(integer(0, 0xffffff)).min(1).max(MAX_PROCEDURAL_V3_PALETTE),
|
|
152
|
+
dither: z.enum(['none', 'bayer4']),
|
|
153
|
+
})
|
|
154
|
+
.strict();
|
|
155
|
+
const proceduralBase = {
|
|
156
|
+
schemaVersion: z.literal(3),
|
|
157
|
+
width: integer(4, MAX_PROCEDURAL_V3_EDGE),
|
|
158
|
+
height: integer(4, MAX_PROCEDURAL_V3_EDGE),
|
|
159
|
+
usage,
|
|
160
|
+
name: name.optional(),
|
|
161
|
+
background: rgba,
|
|
162
|
+
};
|
|
163
|
+
const canonicalProceduralTextureSpecV3Schema = z
|
|
164
|
+
.object({
|
|
165
|
+
...proceduralBase,
|
|
166
|
+
operations: z
|
|
167
|
+
.array(
|
|
168
|
+
z.discriminatedUnion('op', [
|
|
169
|
+
paint,
|
|
170
|
+
mask,
|
|
171
|
+
stamps,
|
|
172
|
+
legacy.extend({ spec: canonicalLegacyV2Schema }),
|
|
173
|
+
]),
|
|
174
|
+
)
|
|
175
|
+
.max(MAX_PROCEDURAL_V3_OPERATIONS),
|
|
176
|
+
palette: palette.optional(),
|
|
177
|
+
})
|
|
178
|
+
.strict();
|
|
179
|
+
const proceduralTextureSpecV3Schema = z
|
|
180
|
+
.object({
|
|
181
|
+
...proceduralBase,
|
|
182
|
+
usage: usage.optional(),
|
|
183
|
+
background: rgba.optional(),
|
|
184
|
+
operations: z
|
|
185
|
+
.array(
|
|
186
|
+
z.discriminatedUnion('op', [
|
|
187
|
+
paint.partial({ opacity: true }),
|
|
188
|
+
mask.partial({ alpha: true, invert: true }),
|
|
189
|
+
stamps.partial({ opacity: true, periodic: true }),
|
|
190
|
+
legacy.partial({ alpha: true, opacity: true }),
|
|
191
|
+
]),
|
|
192
|
+
)
|
|
193
|
+
.max(MAX_PROCEDURAL_V3_OPERATIONS),
|
|
194
|
+
palette: palette.partial({ dither: true }).optional(),
|
|
195
|
+
})
|
|
196
|
+
.strict();
|
|
197
|
+
const portableSamplerSchema = z
|
|
198
|
+
.object({
|
|
199
|
+
minFilter: z.enum(PORTABLE_MIN_FILTERS_V1),
|
|
200
|
+
magFilter: z.enum(PORTABLE_MAG_FILTERS_V1),
|
|
201
|
+
wrapS: z.enum(PORTABLE_WRAPS_V1),
|
|
202
|
+
wrapT: z.enum(PORTABLE_WRAPS_V1),
|
|
203
|
+
})
|
|
204
|
+
.strict();
|
|
205
|
+
const materialMapPinSchema = z
|
|
206
|
+
.object({ resourceId: stableId, revisionId: hash, sha256: hash })
|
|
207
|
+
.strict();
|
|
208
|
+
const resourceSource = z
|
|
209
|
+
.object({
|
|
210
|
+
kind: z.literal('resource'),
|
|
211
|
+
resourceId: mapId,
|
|
212
|
+
pin: materialMapPinSchema,
|
|
213
|
+
expected: z
|
|
214
|
+
.object({ ...dimensions, imageSha256: hash, decodedPixelHash: hash })
|
|
215
|
+
.partial()
|
|
216
|
+
.strict()
|
|
217
|
+
.optional(),
|
|
218
|
+
})
|
|
219
|
+
.strict();
|
|
220
|
+
const region = z
|
|
221
|
+
.object({
|
|
222
|
+
name: stableId,
|
|
223
|
+
content: atlasRectangleSchema,
|
|
224
|
+
gutter: integer(0, 32),
|
|
225
|
+
edgeMode: z.enum(['copy-edge', 'mask-rgb-dilate']),
|
|
226
|
+
source: z.discriminatedUnion('kind', [
|
|
227
|
+
z
|
|
228
|
+
.object({ kind: z.literal('procedural'), spec: canonicalProceduralTextureSpecV3Schema })
|
|
229
|
+
.strict(),
|
|
230
|
+
resourceSource,
|
|
231
|
+
]),
|
|
232
|
+
crop: atlasRectangleSchema.optional(),
|
|
233
|
+
})
|
|
234
|
+
.strict();
|
|
235
|
+
const atlasBase = {
|
|
236
|
+
schemaVersion: z.literal(1),
|
|
237
|
+
width: integer(4, TEXTURE_ATLAS_LIMITS.edge),
|
|
238
|
+
height: integer(4, TEXTURE_ATLAS_LIMITS.edge),
|
|
239
|
+
usage,
|
|
240
|
+
sampler: portableSamplerSchema,
|
|
241
|
+
};
|
|
242
|
+
const canonicalTextureAtlasSpecV1Schema = z
|
|
243
|
+
.object({ ...atlasBase, regions: z.array(region).min(1).max(TEXTURE_ATLAS_LIMITS.regions) })
|
|
244
|
+
.strict();
|
|
245
|
+
const textureAtlasSpecV1Schema = z
|
|
246
|
+
.object({
|
|
247
|
+
...atlasBase,
|
|
248
|
+
sampler: portableSamplerSchema.optional(),
|
|
249
|
+
regions: z
|
|
250
|
+
.array(
|
|
251
|
+
region
|
|
252
|
+
.extend({
|
|
253
|
+
source: z.discriminatedUnion('kind', [
|
|
254
|
+
z
|
|
255
|
+
.object({ kind: z.literal('procedural'), spec: proceduralTextureSpecV3Schema })
|
|
256
|
+
.strict(),
|
|
257
|
+
resourceSource,
|
|
258
|
+
]),
|
|
259
|
+
})
|
|
260
|
+
.partial({ gutter: true, edgeMode: true }),
|
|
261
|
+
)
|
|
262
|
+
.min(1)
|
|
263
|
+
.max(TEXTURE_ATLAS_LIMITS.regions),
|
|
264
|
+
})
|
|
265
|
+
.strict();
|
|
266
|
+
const verifiedPinnedMaterialMapDescriptorSchema = z
|
|
267
|
+
.object({
|
|
268
|
+
materialId: stableId,
|
|
269
|
+
revisionId: hash,
|
|
270
|
+
resourceId: mapId,
|
|
271
|
+
slot: z.enum(['baseColor', 'normal', 'metallicRoughness', 'emissive', 'occlusion']),
|
|
272
|
+
usage,
|
|
273
|
+
colorSpace: z.enum(['srgb', 'linear']),
|
|
274
|
+
...dimensions,
|
|
275
|
+
encodedByteLength: integer(1, TEXTURE_ATLAS_LIMITS.encodedSourceBytes),
|
|
276
|
+
imageSha256: hash,
|
|
277
|
+
decodedPixelHash: hash.optional(),
|
|
278
|
+
})
|
|
279
|
+
.strict();
|
|
280
|
+
const sourceManifestBase = {
|
|
281
|
+
id: z.string().min(1).max(1024),
|
|
282
|
+
...dimensions,
|
|
283
|
+
decodedPixelHash: hash,
|
|
284
|
+
};
|
|
285
|
+
const sourceManifest = z.discriminatedUnion('kind', [
|
|
286
|
+
z
|
|
287
|
+
.object({
|
|
288
|
+
...sourceManifestBase,
|
|
289
|
+
kind: z.literal('procedural'),
|
|
290
|
+
recipeHash: hash,
|
|
291
|
+
compilerId: z.literal(PROCEDURAL_TEXTURE_V3_COMPILER_ID),
|
|
292
|
+
})
|
|
293
|
+
.strict(),
|
|
294
|
+
z
|
|
295
|
+
.object({
|
|
296
|
+
...sourceManifestBase,
|
|
297
|
+
kind: z.literal('resource'),
|
|
298
|
+
descriptor: verifiedPinnedMaterialMapDescriptorSchema,
|
|
299
|
+
})
|
|
300
|
+
.strict(),
|
|
301
|
+
]);
|
|
302
|
+
const textureAtlasManifestV1Schema = z
|
|
303
|
+
.object({
|
|
304
|
+
version: z.literal('kiln.atlas-manifest.v1'),
|
|
305
|
+
compilerId: z.literal(TEXTURE_ATLAS_COMPILER_ID),
|
|
306
|
+
width: atlasBase.width,
|
|
307
|
+
height: atlasBase.height,
|
|
308
|
+
usage,
|
|
309
|
+
origin: z.literal('top-left'),
|
|
310
|
+
sampler: portableSamplerSchema,
|
|
311
|
+
specHash: hash,
|
|
312
|
+
layoutHash: hash,
|
|
313
|
+
decodedPixelHash: hash,
|
|
314
|
+
atlasPixelHash: hash,
|
|
315
|
+
sources: z.array(sourceManifest).min(1).max(TEXTURE_ATLAS_LIMITS.sources),
|
|
316
|
+
regions: z
|
|
317
|
+
.array(
|
|
318
|
+
z
|
|
319
|
+
.object({
|
|
320
|
+
name: stableId,
|
|
321
|
+
content: atlasRectangleSchema,
|
|
322
|
+
allocation: atlasRectangleSchema,
|
|
323
|
+
crop: atlasRectangleSchema,
|
|
324
|
+
sourceId: z.string().min(1).max(1024),
|
|
325
|
+
})
|
|
326
|
+
.strict(),
|
|
327
|
+
)
|
|
328
|
+
.min(1)
|
|
329
|
+
.max(TEXTURE_ATLAS_LIMITS.regions),
|
|
330
|
+
manifestHash: hash,
|
|
331
|
+
})
|
|
332
|
+
.strict();
|
|
333
|
+
return {
|
|
334
|
+
portableSamplerSchema,
|
|
335
|
+
proceduralTextureSpecV3Schema,
|
|
336
|
+
canonicalProceduralTextureSpecV3Schema,
|
|
337
|
+
textureAtlasSpecV1Schema,
|
|
338
|
+
canonicalTextureAtlasSpecV1Schema,
|
|
339
|
+
textureAtlasManifestV1Schema,
|
|
340
|
+
materialMapPinSchema,
|
|
341
|
+
verifiedPinnedMaterialMapDescriptorSchema,
|
|
342
|
+
};
|
|
343
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { BackSide, type Mesh, type Object3D, type Sprite } from 'three';
|
|
2
|
+
import { AuthoringDiagnosticError } from './evaluator/authoring-diagnostic';
|
|
3
|
+
|
|
4
|
+
/** glTF has front-only or double-sided materials, but no back-only flag. Reject
|
|
5
|
+
* that intent before baking/conversion instead of silently changing visibility.
|
|
6
|
+
* Unused material slots do not describe an exported primitive. */
|
|
7
|
+
export function assertPortableMaterialSides(root: Object3D): void {
|
|
8
|
+
root.traverse((node) => {
|
|
9
|
+
const mesh = node as Mesh;
|
|
10
|
+
if (!mesh.isMesh && !(node as Sprite).isSprite) return;
|
|
11
|
+
const materials = mesh.material;
|
|
12
|
+
const used = Array.isArray(materials)
|
|
13
|
+
? [...new Set(mesh.geometry.groups.map((group) => group.materialIndex ?? 0))].map(
|
|
14
|
+
(index) => ({ material: materials[index], index }),
|
|
15
|
+
)
|
|
16
|
+
: [{ material: materials, index: 0 }];
|
|
17
|
+
for (const { material, index } of used) {
|
|
18
|
+
if (!material || material.side !== BackSide) continue;
|
|
19
|
+
throw new AuthoringDiagnosticError(
|
|
20
|
+
'EXPORT_MATERIAL_SIDE_UNSUPPORTED',
|
|
21
|
+
`EXPORT_MATERIAL_SIDE_UNSUPPORTED ${node.name || '<unnamed part>'}: material ${material.name || `<slot ${index}>`} uses BackSide, which glTF cannot encode directly. Author inward-facing geometry with FrontSide, or choose DoubleSide when both faces are intended.`,
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|