@deepblend/dsh-blender-bundle 0.30.0 → 0.32.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.
Files changed (2) hide show
  1. package/lib/client.js +189 -67
  2. package/package.json +7 -7
package/lib/client.js CHANGED
@@ -286,6 +286,10 @@ window.__ModuleLoader__.load({
286
286
  "assets.applyToTimberPartner": "也将此贴图和 UV 设置应用到 {name}",
287
287
  "assets.replaceTimberTexture": "确认替换所选木条现有的程序化纹理",
288
288
  "assets.saveTimberPair": "保存两组木条并预览",
289
+ "assets.rebuildTimberUvs": "同时重建两组 UV",
290
+ "assets.rebuildTimberUvsHelp": "使用同一 UV 层的其他贴图也会按新坐标渲染。",
291
+ "assets.rebuildDefaultUv": "重建时请选择 UVMap,或留空使用默认 UV 层。",
292
+ "assets.rebuildUvUnavailable": "当前宿主无法重建 UV。取消勾选后即可保存贴图。",
289
293
  "assets.timberPairUnavailable": "请选择一组具有可编辑材质的已保存半搭接木条,再选择要一起应用的木条。",
290
294
  "assets.localAnimated": "来源材质含动画,局部复制会丢失动画。请选择共享修改或明确创建新材质。",
291
295
  "assets.animatedChannel": "该通道由动画驱动,不能在此覆盖。",
@@ -938,6 +942,7 @@ window.__ModuleLoader__.load({
938
942
  'revisions.sourceUnknown': '暂无法确认工程内容变化',
939
943
  'revisions.restore': '恢复',
940
944
  "snapshot.title": "保存可编辑副本",
945
+ "snapshot.includeJob": "加入可编辑副本",
941
946
  "snapshot.scope": "包含 Blender 工程、源文件与相关外部素材。",
942
947
  "snapshot.details": "副本范围",
943
948
  "snapshot.detailText": "仅包含选定的已保存版本。仅用于观察的外部参考图不另行附带;工程内嵌内容未另行检查。可附带同版本的已完成影片和图片。未保存的编辑不会进入副本。",
@@ -1216,6 +1221,10 @@ window.__ModuleLoader__.load({
1216
1221
  "assets.applyToTimberPartner": "Apply these settings to {name} too",
1217
1222
  "assets.replaceTimberTexture": "Replace procedural textures on both groups",
1218
1223
  "assets.saveTimberPair": "Save both timber groups and preview",
1224
+ "assets.rebuildTimberUvs": "Rebuild both UV maps",
1225
+ "assets.rebuildTimberUvsHelp": "Other images on the same UV layer will follow the new coordinates.",
1226
+ "assets.rebuildDefaultUv": "Choose UVMap or leave the layer blank to rebuild the default UVs.",
1227
+ "assets.rebuildUvUnavailable": "This host cannot rebuild UVs. Clear the checkbox to save the image map.",
1219
1228
  "assets.timberPairUnavailable": "Choose a member of a saved timber joint with editable materials, then select its partner.",
1220
1229
  "assets.localAnimated": "A local copy would lose source material animation. Choose shared editing or explicitly create a new material.",
1221
1230
  "assets.animatedChannel": "This channel is animated and cannot be overridden here.",
@@ -1868,6 +1877,7 @@ window.__ModuleLoader__.load({
1868
1877
  'revisions.sourceUnknown': 'Project content change could not be confirmed',
1869
1878
  'revisions.restore': 'restore',
1870
1879
  "snapshot.title": "Save an editable copy",
1880
+ "snapshot.includeJob": "Include in editable copy",
1871
1881
  "snapshot.scope": "Includes the Blender project, source files and relevant external assets.",
1872
1882
  "snapshot.details": "What the copy includes",
1873
1883
  "snapshot.detailText": "Includes only the selected saved version. External images used only as visual references are omitted; embedded content is not separately inspected. You can include completed videos and stills from the same version. Unsaved edits are not included.",
@@ -3088,18 +3098,23 @@ window.__ModuleLoader__.load({
3088
3098
  return cameras.find(camera => camera.id === requested) ?? cameras[0]
3089
3099
  }
3090
3100
 
3091
- function timberUvPreviewIntent(state, draft = editorDraftFor(state), patch) {
3101
+ function timberUvPreviewSource(state, draft) {
3092
3102
  const scene = state.selected?.scene
3093
- if (!state.timberUvPreviewSupported || state.view !== 'scene' || !draft?.uvProjection?.includePartner
3103
+ if (!state.timberUvPreviewSupported || state.view !== 'scene' || !draft
3094
3104
  || !scene || draft.baseRevision !== scene.revision || !/^[a-f0-9]{64}$/.test(scene.digest ?? '')
3095
- || !/^[a-f0-9]{64}$/.test(state.storeIdentity ?? '')) return null
3096
- const partner = editorTimberUvPartner(draft)
3105
+ || !/^[a-f0-9]{64}$/.test(state.storeIdentity ?? '') || !Number.isInteger(scene.project.frameStart)) return null
3097
3106
  const camera = timberUvPreviewCamera(scene, draft)
3098
- if (!partner || !camera || !Number.isInteger(scene.project.frameStart)) return null
3107
+ return camera ? { expectedDigest: scene.digest, expectedStoreIdentity: state.storeIdentity,
3108
+ cameraId: camera.id, frame: scene.project.frameStart } : null
3109
+ }
3110
+
3111
+ function timberUvPreviewIntent(state, draft = editorDraftFor(state), patch) {
3112
+ if (!draft?.uvProjection?.includePartner) return null
3113
+ const source = timberUvPreviewSource(state, draft), partner = editorTimberUvPartner(draft)
3114
+ if (!source || !partner) return null
3099
3115
  try { patch ??= buildEditorPatch(draft) } catch { return null }
3100
- const key = JSON.stringify([state.storeIdentity, scene.digest, camera.id, patch])
3101
- return { key, patch, expectedDigest: scene.digest, expectedStoreIdentity: state.storeIdentity,
3102
- cameraId: camera.id, frame: scene.project.frameStart, entities: [draft.entityId, partner.id] }
3116
+ const key = JSON.stringify(['editor', source, patch])
3117
+ return { ...source, kind: 'editor', key, patch, entities: [draft.entityId, partner.id] }
3103
3118
  }
3104
3119
 
3105
3120
  function verifiedTimberUvPreview(preview, intent) {
@@ -3383,6 +3398,7 @@ window.__ModuleLoader__.load({
3383
3398
  const source = draft.newMaterial ? null : assetEditor(draft)?.material.definition
3384
3399
  draft.binding = editorClone(source?.images?.[draft.channel] || {})
3385
3400
  draft.includeTimberPartner = false
3401
+ draft.uvProjection = null
3386
3402
  draft.replaceTexture = false
3387
3403
  }
3388
3404
  function createAssetDraft(scene, projectId, entry, inspection, entityId) {
@@ -3480,11 +3496,27 @@ window.__ModuleLoader__.load({
3480
3496
  if (partner) appendImageAssetOperations(operations, {
3481
3497
  ...draft, entityId: partner.original.id, newMaterialId: `${draft.newMaterialId}-partner`,
3482
3498
  }, asset, fail, partner)
3499
+ if (draft.uvProjection) {
3500
+ const { quarterTurns, scale } = draft.uvProjection
3501
+ if (!partner || !Number.isInteger(quarterTurns) || quarterTurns < 0 || quarterTurns > 3) fail(t('editor.uv.direction'))
3502
+ if (!Number.isFinite(scale) || scale < 0.0001 || scale > 10000) throw new Error(t('editor.uv.scaleInvalid'))
3503
+ if (draft.binding.uvMap && draft.binding.uvMap !== 'UVMap') throw new Error(t('assets.rebuildDefaultUv'))
3504
+ for (const entityId of [draft.entityId, partner.original.id]) operations.push({ op: 'entity.uv.project', entityId, quarterTurns, scale })
3505
+ }
3483
3506
  }
3484
3507
  return { projectId: draft.projectId, baseRevision: draft.baseRevision, saveCheckpoint: true, renderPreview: true, actor: 'ui', operations }
3485
3508
  }
3486
3509
  function assetDraftError(draft) { try { buildAssetPatch(draft); return null } catch (error) { return error.message } }
3487
3510
 
3511
+ function assetTimberUvPreviewIntent(state, draft = state.assetDrafts?.[state.activeProjectId], patch) {
3512
+ if (!draft?.includeTimberPartner || !draft.uvProjection) return null
3513
+ const source = timberUvPreviewSource(state, draft), partner = pairedAssetEditor(draft)
3514
+ if (!source || !partner) return null
3515
+ try { patch ??= buildAssetPatch(draft) } catch { return null }
3516
+ const key = JSON.stringify(['asset', source, patch])
3517
+ return { ...source, kind: 'asset', key, patch, entities: [draft.entityId, partner.original.id] }
3518
+ }
3519
+
3488
3520
  function inspectionForm(state) {
3489
3521
  const scene = state.selected?.scene
3490
3522
  if (!scene) return null
@@ -3861,13 +3893,36 @@ window.__ModuleLoader__.load({
3861
3893
  const snapshotContextKey = state => state.projectsRoot && state.storeIdentity && state.activeProjectId
3862
3894
  ? JSON.stringify([state.projectsRoot, state.storeIdentity, state.activeProjectId]) : null
3863
3895
  const snapshotEntry = state => state.editableSnapshots?.[snapshotContextKey(state)] || null
3864
- const snapshotVideos = (state, revision) => (state.jobs || []).filter(job => job.status === 'completed'
3865
- && job.revisionId === revision && typeof job.delivery?.videoPath === 'string' && job.delivery.videoPath.length > 0)
3866
- const snapshotImages = (state, revision) => (state.jobs || []).filter(job => job.status === 'completed' && job.revisionId === revision
3896
+ const snapshotVideoJob = job => job.status === 'completed'
3897
+ && typeof job.delivery?.videoPath === 'string' && job.delivery.videoPath.length > 0
3898
+ const snapshotImageJob = job => job.status === 'completed'
3867
3899
  && job.delivery?.kind === 'still' && job.delivery.verified === true && Number.isSafeInteger(job.delivery.image?.frame)
3868
- && /^[a-f0-9]{64}$/.test(job.delivery.image?.sha256 || '') && /^[a-zA-Z0-9][a-zA-Z0-9_-]{0,95}$/.test(job.jobId || ''))
3900
+ && /^[a-f0-9]{64}$/.test(job.delivery.image?.sha256 || '') && /^[a-zA-Z0-9][a-zA-Z0-9_-]{0,95}$/.test(job.jobId || '')
3901
+ const snapshotVideos = (state, revision) => (state.jobs || []).filter(job => job.revisionId === revision && snapshotVideoJob(job))
3902
+ const snapshotImages = (state, revision) => (state.jobs || []).filter(job => job.revisionId === revision && snapshotImageJob(job))
3869
3903
  const snapshotSupported = state => state.editableSnapshotProtocol === 1 && /^[a-f0-9]{64}$/.test(state.storeIdentity || '')
3870
3904
  && state.editableSnapshotAvailability?.available === true
3905
+ const snapshotWorking = entry => entry?.result?.state === 'preparing' || Object.values(entry?.busy || {}).some(Boolean)
3906
+ function snapshotJobSelection(state, job) {
3907
+ const entry = snapshotEntry(state)
3908
+ if (!entry || !snapshotSupported(state) || job?.delivery?.verified !== true
3909
+ || !/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,95}$/.test(job.jobId || '')
3910
+ || !state.selected?.revisions?.some(item => item.revision === job.revisionId)) return null
3911
+ const image = job.delivery.kind === 'still'
3912
+ if (image ? !state.snapshotImagesSupported || !snapshotImageJob(job)
3913
+ : !snapshotVideoJob(job) || !/^[a-f0-9]{64}$/.test(job.delivery.sha256 || '')) return null
3914
+ const sameRevision = entry.revision === job.revisionId
3915
+ const imageJobIds = sameRevision ? entry.imageJobIds || [] : []
3916
+ const full = image && imageJobIds.length >= 16 && !imageJobIds.includes(job.jobId)
3917
+ return {
3918
+ disabled: snapshotWorking(entry) || full,
3919
+ selection: {
3920
+ revision: job.revisionId,
3921
+ videoJobId: image ? (sameRevision ? entry.videoJobId || null : null) : job.jobId,
3922
+ imageJobIds: image && !full ? [...new Set([...imageJobIds, job.jobId])].sort() : imageJobIds,
3923
+ },
3924
+ }
3925
+ }
3871
3926
  const snapshotSameSelection = entry => entry?.handle && entry.revision === entry.handle.revision && entry.videoJobId === entry.handle.videoJobId
3872
3927
  && JSON.stringify(entry.imageJobIds || []) === JSON.stringify(entry.handle.imageJobIds || [])
3873
3928
  const snapshotBytes = value => value >= 1048576 ? `${(value / 1048576).toFixed(1)} MiB` : value >= 1024 ? `${(value / 1024).toFixed(1)} KiB` : `${value} B`
@@ -4148,13 +4203,40 @@ window.__ModuleLoader__.load({
4148
4203
  halfLapPreviewController = undefined
4149
4204
  next.halfLapPreview = null
4150
4205
  }
4151
- if (next.timberUvPreview && timberUvPreviewIntent(next)?.key !== next.timberUvPreview.key) {
4152
- timberUvPreviewController?.abort()
4153
- timberUvPreviewController = undefined
4154
- next.timberUvPreview = null
4206
+ if (next.timberUvPreview) {
4207
+ const intent = next.timberUvPreview.kind === 'asset' ? assetTimberUvPreviewIntent(next) : timberUvPreviewIntent(next)
4208
+ if (intent?.key !== next.timberUvPreview.key) {
4209
+ timberUvPreviewController?.abort()
4210
+ timberUvPreviewController = undefined
4211
+ next.timberUvPreview = null
4212
+ }
4155
4213
  }
4156
4214
  data = next; notify()
4157
4215
  }
4216
+
4217
+ async function renderTimberUvPreview(intent) {
4218
+ if (!intent || data.busy.editor || timberUvPreviewController || halfLapPreviewController) return
4219
+ const controller = new AbortController()
4220
+ timberUvPreviewController = controller
4221
+ const { kind, key, patch, expectedDigest, expectedStoreIdentity, cameraId } = intent
4222
+ const active = () => running && timberUvPreviewController === controller && !controller.signal.aborted
4223
+ set({ timberUvPreview: { kind, key, busy: true } })
4224
+ try {
4225
+ const response = await fetchImpl(projectRoute(patch.projectId, '/timber-uv-preview'), {
4226
+ method: 'POST', headers: { 'content-type': 'application/json', accept: 'application/json' }, signal: controller.signal,
4227
+ body: JSON.stringify({ patch, expectedDigest, expectedStoreIdentity, cameraId }),
4228
+ })
4229
+ const payload = await response.json()
4230
+ if (!active()) return
4231
+ if (!response.ok || !payload.ok) throw new Error(payload.error?.message || response.status)
4232
+ if (!verifiedTimberUvPreview(payload.preview, intent)) throw new Error(t('inspection.mismatch'))
4233
+ set({ timberUvPreview: { kind, key, result: payload.preview } })
4234
+ } catch (error) {
4235
+ if (active()) set({ timberUvPreview: { kind, key, error: error.message || String(error) } })
4236
+ } finally {
4237
+ if (timberUvPreviewController === controller) timberUvPreviewController = undefined
4238
+ }
4239
+ }
4158
4240
  /** Change one nested table. @param {'forms'|'busy'|'notices'} table @param {string} key @param {any} value */
4159
4241
  const setIn = (table, key, value) => { data = { ...data, [table]: { ...data[table], [key]: value } }; notify() }
4160
4242
 
@@ -4502,14 +4584,14 @@ window.__ModuleLoader__.load({
4502
4584
  }
4503
4585
  function setSnapshotSelection(field, value) {
4504
4586
  const key = snapshotContextKey(data), entry = data.editableSnapshots[key]
4505
- if (!entry || entry.result?.state === 'preparing' || Object.values(entry.busy || {}).some(Boolean)) return
4587
+ if (!entry || snapshotWorking(entry)) return
4506
4588
  if (field === 'revision' && !(data.selected?.revisions || []).some(item => item.revision === value)) return
4507
4589
  if (field === 'videoJobId' && value && !snapshotVideos(data, entry.revision).some(job => job.jobId === value)) return
4508
4590
  changeSnapshot(key, { [field]: value || null, ...(field === 'revision' ? { videoJobId: null, imageJobIds: [] } : {}) })
4509
4591
  }
4510
4592
  function setSnapshotImage(id, selected) {
4511
4593
  const key = snapshotContextKey(data), entry = data.editableSnapshots[key]
4512
- if (!entry || !data.snapshotImagesSupported || entry.result?.state === 'preparing' || Object.values(entry.busy || {}).some(Boolean)) return
4594
+ if (!entry || !data.snapshotImagesSupported || snapshotWorking(entry)) return
4513
4595
  const ids = new Set(entry.imageJobIds || [])
4514
4596
  if (selected && !snapshotImages(data, entry.revision).some(job => job.jobId === id) || !selected && !ids.has(id)) return
4515
4597
  if (selected && ids.size >= 16 && !ids.has(id)) return
@@ -4892,6 +4974,15 @@ window.__ModuleLoader__.load({
4892
4974
  setSnapshotRevision: value => setSnapshotSelection('revision', value),
4893
4975
  setSnapshotVideo: value => setSnapshotSelection('videoJobId', value),
4894
4976
  setSnapshotImage,
4977
+ includeDeliveryInSnapshot: (jobId, revision, context) => {
4978
+ if (!context || context !== snapshotContextKey(data)) return
4979
+ const job = data.jobs.find(item => item.jobId === jobId && item.revisionId === revision)
4980
+ const copy = snapshotJobSelection(data, job)
4981
+ if (!copy || copy.disabled) return
4982
+ changeSnapshot(context, copy.selection)
4983
+ actions.setView('revisions')
4984
+ return true
4985
+ },
4895
4986
  prepareEditableSnapshot: () => snapshotRequest('prepare'),
4896
4987
  checkEditableSnapshot: () => snapshotRequest('check'),
4897
4988
  cancelEditableSnapshot: () => snapshotRequest('cancel'),
@@ -5174,13 +5265,18 @@ window.__ModuleLoader__.load({
5174
5265
  updateAsset: (field, value) => {
5175
5266
  const projectId = data.activeProjectId, current = data.assetDrafts[projectId]
5176
5267
  if (!current || data.assetWork[projectId]?.busy) return
5177
- const allowed = ['newEntityId', 'location', 'rotationEuler', 'scale', 'hideEntityId', 'makeSubject', 'entityId', 'target', 'partId', 'slotIndex', 'scope', 'newMaterial', 'channel', 'binding', 'replaceTexture', 'includeTimberPartner', 'strength', 'rotation']
5268
+ const allowed = ['newEntityId', 'location', 'rotationEuler', 'scale', 'hideEntityId', 'makeSubject', 'entityId', 'target', 'partId', 'slotIndex', 'scope', 'newMaterial', 'channel', 'binding', 'replaceTexture', 'includeTimberPartner', 'uvProjection', 'strength', 'rotation']
5178
5269
  if (!allowed.includes(field)) return
5179
5270
  if (field === 'includeTimberPartner' && (typeof value !== 'boolean' || !pairedAssetEditor(current))) return
5271
+ if (field === 'uvProjection' && value && (!data.timberUvPreviewSupported || !current.includeTimberPartner || !pairedAssetEditor(current))) return
5180
5272
  const draft = editorClone(current); draft[field] = editorClone(value)
5181
- if (field === 'includeTimberPartner') draft.replaceTexture = false
5273
+ if (field === 'includeTimberPartner') {
5274
+ draft.replaceTexture = false
5275
+ if (!value) draft.uvProjection = null
5276
+ }
5182
5277
  if (field === 'scope' && draft.includeTimberPartner && !pairedAssetEditor(draft)) {
5183
5278
  draft.includeTimberPartner = false
5279
+ draft.uvProjection = null
5184
5280
  draft.replaceTexture = false
5185
5281
  }
5186
5282
  if (['entityId', 'target'].includes(field)) { draft.partId = ''; draft.slotIndex = '' }
@@ -5196,13 +5292,20 @@ window.__ModuleLoader__.load({
5196
5292
  },
5197
5293
  applyAsset: async () => {
5198
5294
  const projectId = data.activeProjectId, draft = data.assetDrafts[projectId]
5295
+ const texture = data.timberUvPreview
5199
5296
  if (!draft || data.assetWork[projectId]?.busy || data.busy.editor || data.busy.patch || data.busy.restore
5297
+ || (texture?.kind === 'asset' && texture.busy)
5200
5298
  || data.visualRuns[projectId]?.busy || draft.baseRevision !== data.selected?.scene?.revision) return
5201
5299
  let patch
5202
- try { patch = buildAssetPatch(draft) } catch (error) { assetWork(projectId, { error: error.message }); return }
5300
+ try {
5301
+ if (draft.uvProjection && !data.timberUvPreviewSupported) throw new Error(t('assets.rebuildUvUnavailable'))
5302
+ patch = buildAssetPatch(draft)
5303
+ } catch (error) { assetWork(projectId, { error: error.message }); return }
5304
+ const inspection = texture?.result && assetTimberUvPreviewIntent(data, draft, patch)?.key === texture.key ? texture.result : null
5305
+ const request = inspection ? { patch, expectedSpecHash: inspection.candidateSpecHash, expectedStoreIdentity: inspection.storeIdentity } : { patch }
5203
5306
  const beforePreviews = editorClone(data.previews?.revisions?.find(item => item.revision === draft.baseRevision)?.previews || [])
5204
5307
  assetWork(projectId, { busy: 'saving', error: null, message: null }); setIn('busy', 'editor', true)
5205
- const outcome = await postJson(fetchImpl, projectRoute(projectId, '/patch'), { patch })
5308
+ const outcome = await postJson(fetchImpl, projectRoute(projectId, '/patch'), request)
5206
5309
  setIn('busy', 'editor', false); assetWork(projectId, { busy: null })
5207
5310
  if (outcome.ok) {
5208
5311
  const revision = outcome.payload.revision.revision, drafts = { ...data.assetDrafts }; delete drafts[projectId]
@@ -5664,30 +5767,8 @@ window.__ModuleLoader__.load({
5664
5767
  timberUvPreviewController = undefined
5665
5768
  set({ timberUvPreview: null })
5666
5769
  },
5667
- previewTimberUv: async () => {
5668
- const intent = timberUvPreviewIntent(data)
5669
- if (!intent || data.busy.editor || timberUvPreviewController || halfLapPreviewController) return
5670
- const controller = new AbortController()
5671
- timberUvPreviewController = controller
5672
- const { key, patch, expectedDigest, expectedStoreIdentity, cameraId } = intent
5673
- const active = () => running && timberUvPreviewController === controller && !controller.signal.aborted
5674
- set({ timberUvPreview: { key, busy: true } })
5675
- try {
5676
- const response = await fetchImpl(projectRoute(patch.projectId, '/timber-uv-preview'), {
5677
- method: 'POST', headers: { 'content-type': 'application/json', accept: 'application/json' }, signal: controller.signal,
5678
- body: JSON.stringify({ patch, expectedDigest, expectedStoreIdentity, cameraId }),
5679
- })
5680
- const payload = await response.json()
5681
- if (!active()) return
5682
- if (!response.ok || !payload.ok) throw new Error(payload.error?.message || response.status)
5683
- if (!verifiedTimberUvPreview(payload.preview, intent)) throw new Error(t('inspection.mismatch'))
5684
- set({ timberUvPreview: { key, result: payload.preview } })
5685
- } catch (error) {
5686
- if (active()) set({ timberUvPreview: { key, error: error.message || String(error) } })
5687
- } finally {
5688
- if (timberUvPreviewController === controller) timberUvPreviewController = undefined
5689
- }
5690
- },
5770
+ previewTimberUv: () => renderTimberUvPreview(timberUvPreviewIntent(data)),
5771
+ previewAssetTimberUv: () => !data.assetWork[data.activeProjectId]?.busy && renderTimberUvPreview(assetTimberUvPreviewIntent(data)),
5691
5772
  updateEditor: (section, path, value) => {
5692
5773
  const current = editorDraftFor(data)
5693
5774
  if (!current || data.busy.editor || !['transform', 'generator', 'modifiers', 'material', 'uvProjection'].includes(section)) return
@@ -6699,7 +6780,8 @@ window.__ModuleLoader__.load({
6699
6780
  uvScene?.nodes.cameras?.length > 1 ? choose(t('editor.uv.previewCamera'), 'editor-uv-camera',
6700
6781
  timberUvPreviewCamera(uvScene, draft)?.id, uvScene.nodes.cameras.map(camera => [camera.id, camera.name || camera.id]),
6701
6782
  value => actions.updateEditor('uvProjection', ['cameraId'], value)) : null,
6702
- TimberUvPreview({ work: uvWork, apply, disabled: disabled || !uvIntent || slotWork?.busy === true, actions }),
6783
+ TimberUvPreview({ work: uvWork, apply, disabled: disabled || !uvIntent || state.halfLapPreview?.busy === true
6784
+ || (state.timberUvPreview?.kind === 'asset' && state.timberUvPreview.busy), actions }),
6703
6785
  ] : null,
6704
6786
  ] : null),
6705
6787
  halfLapOptions.length ? el('fieldset', { key: 'half-lap', 'data-half-lap-editor': true, disabled, style: { border: 0, padding: 0, margin: '16px 0' } },
@@ -6713,7 +6795,7 @@ window.__ModuleLoader__.load({
6713
6795
  actions.setEditorHalfLapWidth, { factor: 1000, min: 0, max: 5, step: .05,
6714
6796
  invalid: halfLapEdgeWidth < 0 || halfLapEdgeWidth > .005, error: t('editor.halfLap.edgeInvalid') }) : null,
6715
6797
  halfLapPartner ? el('p', { className: 'db-muted', key: 'edge-width-help' }, t('editor.halfLap.edgeHelp')) : null,
6716
- slotIntent ? HalfLapPreview({ slotWork, apply: uvResult ? null : apply, disabled: disabled || uvWork?.busy === true, actions }) : null) : null] : null,
6798
+ slotIntent ? HalfLapPreview({ slotWork, apply: uvResult ? null : apply, disabled: disabled || state.timberUvPreview?.busy === true, actions }) : null) : null] : null,
6717
6799
  el('p', { className: 'db-muted', key: 'local-size' }, t('editor.localDimensions', { scale: (draft.entity.transform.scale || [1, 1, 1]).join(' × ') })),
6718
6800
  geometry.shape === 'rounded_box' ? el('p', { className: 'db-muted', key: 'rounded' }, t('editor.roundedRequired')) : null,
6719
6801
  geometry.shape === 'handled_cup' ? el('p', { className: 'db-muted', key: 'cup-help' }, t('editor.cupHelp')) : null,
@@ -6830,14 +6912,16 @@ window.__ModuleLoader__.load({
6830
6912
  onClick: () => actions.setReviewSubject(draft.entityId), children: t('brief.subjectShortcut') }), restore))
6831
6913
  }
6832
6914
 
6833
- function TimberUvPreview({ work, apply, disabled, actions }) {
6915
+ function TimberUvPreview({ work, apply, disabled, actions, asset = false }) {
6834
6916
  const result = work?.result
6835
- return el('div', { key: 'uv-preview', 'data-timber-uv-preview': result ? 'ready' : work?.busy ? 'loading' : work?.error ? 'error' : 'idle',
6917
+ const action = asset ? 'asset-timber-uv-preview' : 'timber-uv-preview'
6918
+ return el('div', { key: 'uv-preview', [`data-${action}`]: result ? 'ready' : work?.busy ? 'loading' : work?.error ? 'error' : 'idle',
6836
6919
  'aria-busy': work?.busy === true },
6837
6920
  el('div', { className: 'db-inline' },
6838
- Button({ action: 'timber-uv-preview', disabled: disabled || work?.busy === true,
6839
- children: work?.busy ? t('editor.uv.previewBusy') : t('editor.uv.preview'), onClick: actions.previewTimberUv }),
6840
- work?.busy ? Button({ action: 'timber-uv-preview-cancel', children: t('geometry.cancel'), onClick: actions.cancelTimberUvPreview }) : null),
6921
+ Button({ action, disabled: disabled || work?.busy === true,
6922
+ children: work?.busy ? t('editor.uv.previewBusy') : t('editor.uv.preview'),
6923
+ onClick: asset ? actions.previewAssetTimberUv : actions.previewTimberUv }),
6924
+ work?.busy ? Button({ action: `${action}-cancel`, children: t('geometry.cancel'), onClick: actions.cancelTimberUvPreview }) : null),
6841
6925
  result ? el('figure', { style: { margin: '12px 0' } },
6842
6926
  el('img', { src: `data:image/png;base64,${result.image.pngBase64}`, alt: t('editor.uv.previewImage'),
6843
6927
  width: result.image.width, height: result.image.height, style: { display: 'block', width: '100%', height: 'auto' } }),
@@ -6894,7 +6978,7 @@ window.__ModuleLoader__.load({
6894
6978
  values[index] === null ? '' : values[index] * factor, value => { const next = [...values]; next[index] = value === null ? null : value / factor; update(field, next) })))
6895
6979
  let editor, material, partner, part, error, affected = []
6896
6980
  if (draft) {
6897
- error = assetDraftError(draft)
6981
+ error = draft.uvProjection && !state.timberUvPreviewSupported ? t('assets.rebuildUvUnavailable') : assetDraftError(draft)
6898
6982
  if (draft.kind === 'image') {
6899
6983
  editor = assetEditor(draft); material = editor?.material.definition
6900
6984
  partner = pairedAssetEditor(draft, editor)
@@ -6906,6 +6990,13 @@ window.__ModuleLoader__.load({
6906
6990
  }
6907
6991
  const paired = draft?.includeTimberPartner && partner
6908
6992
  const replaceTexture = !draft?.newMaterial && (material?.texture || (paired && partner.material.definition.texture))
6993
+ const canRebuildUvs = paired && state.timberUvPreviewSupported
6994
+ const uv = canRebuildUvs && draft.uvProjection
6995
+ const uvIntent = uv && assetTimberUvPreviewIntent(state, draft)
6996
+ const uvWork = uvIntent && state.timberUvPreview?.key === uvIntent.key ? state.timberUvPreview : null
6997
+ const cameraChoices = state.selected?.scene?.nodes?.cameras || []
6998
+ const sharesUv = uv && [material, partner.material.definition].some(item =>
6999
+ Object.entries(item.images || {}).some(([channel, binding]) => channel !== 'baseColor' && (!binding.uvMap || binding.uvMap === 'UVMap')))
6909
7000
  const mapSetting = (key, value) => { const binding = editorClone(draft.binding); if (value === undefined) delete binding[key]; else binding[key] = value; update('binding', binding) }
6910
7001
  return el('section', { className: 'db-card', 'data-assets-library': projectId, 'data-asset-base-revision': draft?.baseRevision || '', 'data-asset-conflict': String(conflict) },
6911
7002
  el('h4', null, t('assets.title')), el('p', { className: 'db-muted' }, t('assets.help')),
@@ -7004,9 +7095,24 @@ window.__ModuleLoader__.load({
7004
7095
  partner ? check(t('assets.applyToTimberPartner', { name: partner.original.name || partner.original.id }),
7005
7096
  'asset-include-timber-partner', Boolean(paired), value => update('includeTimberPartner', value), true) : null,
7006
7097
  replaceTexture ? check(paired ? t('assets.replaceTimberTexture') : t('assets.replaceTexture'),
7007
- 'asset-replace-texture', draft.replaceTexture, value => update('replaceTexture', value), Boolean(paired)) : null) : null,
7008
- error ? el('p', { className: 'db-error' }, error) : null,
7009
- el('div', { className: 'db-inline' }, Button({ action: 'asset-apply', tone: 'primary', disabled: busy || conflict || Boolean(error) || state.busy.editor || state.busy.patch || state.busy.restore || state.visualRuns[projectId]?.busy,
7098
+ 'asset-replace-texture', draft.replaceTexture, value => update('replaceTexture', value), Boolean(paired)) : null,
7099
+ canRebuildUvs || draft.uvProjection ? check(t('assets.rebuildTimberUvs'), 'asset-rebuild-timber-uvs', Boolean(draft.uvProjection),
7100
+ value => update('uvProjection', value ? { quarterTurns: 0, scale: 1 } : null), true) : null,
7101
+ uv ? [
7102
+ sharesUv ? el('p', { key: 'uv-help', className: 'db-muted' }, t('assets.rebuildTimberUvsHelp')) : null,
7103
+ choose(t('editor.uv.direction'), 'asset-uv-direction', String(uv.quarterTurns),
7104
+ [0, 1, 2, 3].map(turn => [String(turn), `${turn * 90}°`]), value => update('uvProjection', { ...uv, quarterTurns: Number(value) })),
7105
+ number(t('editor.uv.scale'), 'asset-uv-repeats', uv.scale, value => update('uvProjection', { ...uv, scale: value }),
7106
+ { min: 0.0001, max: 10000, 'aria-invalid': !Number.isFinite(uv.scale) || uv.scale < 0.0001 || uv.scale > 10000 }),
7107
+ cameraChoices.length > 1 ? choose(t('editor.uv.previewCamera'), 'asset-uv-camera',
7108
+ timberUvPreviewCamera(state.selected.scene, draft)?.id, cameraChoices.map(camera => [camera.id, camera.name || camera.id]),
7109
+ value => update('uvProjection', { ...uv, cameraId: value })) : null,
7110
+ TimberUvPreview({ work: uvWork, actions, asset: true,
7111
+ disabled: busy || conflict || !uvIntent || state.busy.editor || state.halfLapPreview?.busy === true
7112
+ || (state.timberUvPreview?.kind === 'editor' && state.timberUvPreview.busy) }),
7113
+ ] : null) : null,
7114
+ error ? el('p', { className: 'db-error', role: 'alert' }, error) : null,
7115
+ el('div', { className: 'db-inline' }, Button({ action: 'asset-apply', tone: 'primary', disabled: busy || conflict || Boolean(error) || uvWork?.busy === true || state.busy.editor || state.busy.patch || state.busy.restore || state.visualRuns[projectId]?.busy,
7010
7116
  onClick: actions.applyAsset, children: paired ? t('assets.saveTimberPair') : t('assets.apply') }), Button({ action: 'asset-reset', disabled: busy, onClick: actions.discardAsset, children: t('assets.reset') }))) : null)
7011
7117
  }
7012
7118
 
@@ -7779,6 +7885,30 @@ window.__ModuleLoader__.load({
7779
7885
  Button({ action: 'save-wide-frame', tone: 'primary', disabled: pending || Object.values(state.busy).some(Boolean), onClick: actions.saveWideFrame, children: t('aspect.apply') })))
7780
7886
  }
7781
7887
 
7888
+ function JobDeliveryActions(state, actions, job) {
7889
+ const frame = renderSingleFrameLink(state, job)
7890
+ const copy = snapshotJobSelection(state, job)
7891
+ const video = state.renderVideoDownloadSupported && state.editableSnapshotAvailability?.available === true
7892
+ && /^[a-f0-9]{64}$/.test(state.storeIdentity || '') && job.status === 'completed' && job.delivery?.verified === true
7893
+ && /^r[0-9]{4,}$/.test(job.revisionId || '') && /^[a-zA-Z0-9][a-zA-Z0-9_-]{0,95}$/.test(job.jobId || '')
7894
+ && /^[a-f0-9]{64}$/.test(job.delivery.sha256 || '')
7895
+ ? el('a', { className: 'db-btn', 'data-action': `download-video:${job.jobId}`,
7896
+ href: projectRoute(state.activeProjectId, `/jobs/${encodeURIComponent(job.jobId)}/video?revision=${encodeURIComponent(job.revisionId)}&sha256=${job.delivery.sha256}&storeIdentity=${state.storeIdentity}`),
7897
+ download: true }, t('jobs.downloadVideo', { revision: job.revisionId })) : null
7898
+ const path = !video && typeof job.delivery?.videoPath === 'string' && job.delivery.videoPath
7899
+ if (!frame && !video && !copy && !path) return null
7900
+ return el('div', { className: 'db-inline' }, frame, video,
7901
+ copy ? Button({ action: `snapshot-include-delivery:${job.jobId}`, disabled: copy.disabled,
7902
+ onClick: event => {
7903
+ const mount = event?.currentTarget?.closest('.db-root')?.parentElement
7904
+ if (actions.includeDeliveryInSnapshot(job.jobId, job.revisionId, snapshotContextKey(state))) {
7905
+ mount?.ownerDocument.defaultView?.requestAnimationFrame(() => mount.querySelector('[data-editable-snapshot]')?.focus())
7906
+ }
7907
+ },
7908
+ children: t('snapshot.includeJob') }) : null,
7909
+ path ? el('div', { className: 'db-muted db-mono' }, `video ${path}`) : null)
7910
+ }
7911
+
7782
7912
  /** 任务: live progress, cancel, resume, and the approval threshold. */
7783
7913
  function JobsView(ctx) {
7784
7914
  const state = ctx.state
@@ -7821,15 +7951,7 @@ window.__ModuleLoader__.load({
7821
7951
  el('div', { className: 'db-muted', 'data-job-detail': job.jobId }, `${job.detail} · ${job.progress.percent}% · 缺失 ${job.progress.missing} · 损坏 ${job.progress.corrupt}`),
7822
7952
  el('div', { className: 'db-muted', 'data-job-provenance': job.jobId }, jobProvenanceText(job)),
7823
7953
  job.errorCode ? el('div', { className: 'db-error', style: { marginTop: '4px' } }, `${job.errorCode}: ${job.message || ''}`) : null,
7824
- renderSingleFrameLink(state, job),
7825
- state.renderVideoDownloadSupported && state.editableSnapshotAvailability?.available === true
7826
- && /^[a-f0-9]{64}$/.test(state.storeIdentity || '') && job.status === 'completed' && job.delivery?.verified === true
7827
- && /^r[0-9]{4,}$/.test(job.revisionId || '') && /^[a-zA-Z0-9][a-zA-Z0-9_-]{0,95}$/.test(job.jobId || '')
7828
- && /^[a-f0-9]{64}$/.test(job.delivery.sha256 || '')
7829
- ? el('a', { className: 'db-btn', 'data-action': `download-video:${job.jobId}`,
7830
- href: projectRoute(state.activeProjectId, `/jobs/${encodeURIComponent(job.jobId)}/video?revision=${encodeURIComponent(job.revisionId)}&sha256=${job.delivery.sha256}&storeIdentity=${state.storeIdentity}`),
7831
- download: true }, t('jobs.downloadVideo', { revision: job.revisionId }))
7832
- : job.delivery ? el('div', { className: 'db-muted db-mono' }, `video ${job.delivery.videoPath || ''}`) : null,
7954
+ JobDeliveryActions(state, actions, job),
7833
7955
  ))),
7834
7956
  ),
7835
7957
 
@@ -7985,7 +8107,7 @@ window.__ModuleLoader__.load({
7985
8107
  const phases = { writing: t('snapshot.copying'), verifying: t('snapshot.verifying'), publishing: t('snapshot.publishing') }
7986
8108
  const done = result?.phase === 'verifying' ? result.verifiedBytes : result?.writtenBytes
7987
8109
  const measured = result?.phase === 'writing' && Number.isSafeInteger(done) && done >= 0 && Number.isSafeInteger(result?.totalBytes) && result.totalBytes > 0
7988
- return el('section', { className: 'db-card', 'data-editable-snapshot': result?.state || 'idle', 'aria-label': t('snapshot.title') },
8110
+ return el('section', { className: 'db-card', 'data-editable-snapshot': result?.state || 'idle', 'aria-label': t('snapshot.title'), tabIndex: -1 },
7989
8111
  el('h4', null, t('snapshot.title')),
7990
8112
  el('p', { className: 'db-muted' }, t('snapshot.scope')),
7991
8113
  Disclosure({ state, actions }, 'snapshot-scope', t('snapshot.details'), {}, el('p', { className: 'db-muted', style: { maxWidth: '72ch' } }, t('snapshot.detailText'))),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deepblend/dsh-blender-bundle",
3
- "version": "0.30.0",
3
+ "version": "0.32.0",
4
4
  "description": "Create Blender product scenes in DSH with editable recipes, model imports, previews and PNG/MP4 delivery; includes workbench and agent configuration.",
5
5
  "main": "lib/index.js",
6
6
  "bin": {
@@ -44,12 +44,12 @@
44
44
  }
45
45
  },
46
46
  "dependencies": {
47
- "@deepblend/dsh-blender-contracts": "0.30.0",
48
- "@deepblend/dsh-blender-host": "0.30.0",
49
- "@deepblend/dsh-blender-preset": "0.30.0",
50
- "@deepblend/dsh-blender-provider-local": "0.30.0",
51
- "@deepblend/dsh-blender-tool": "0.30.0",
52
- "@deepblend/dsh-blender-ui": "0.30.0"
47
+ "@deepblend/dsh-blender-contracts": "0.32.0",
48
+ "@deepblend/dsh-blender-host": "0.32.0",
49
+ "@deepblend/dsh-blender-preset": "0.32.0",
50
+ "@deepblend/dsh-blender-provider-local": "0.32.0",
51
+ "@deepblend/dsh-blender-tool": "0.32.0",
52
+ "@deepblend/dsh-blender-ui": "0.32.0"
53
53
  },
54
54
  "type": "module",
55
55
  "license": "MIT",