@deepblend/dsh-blender-bundle 0.29.0 → 0.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/client.js +91 -44
- package/package.json +7 -7
package/lib/client.js
CHANGED
|
@@ -283,6 +283,10 @@ window.__ModuleLoader__.load({
|
|
|
283
283
|
"assets.newMaterial": "创建新的基础材质并覆盖所选范围",
|
|
284
284
|
"assets.nativeHelp": "原生节点没有可编辑的公共定义;需明确创建新材质覆盖所选范围。",
|
|
285
285
|
"assets.replaceTexture": "用图片替换此材质的程序化纹理",
|
|
286
|
+
"assets.applyToTimberPartner": "也将此贴图和 UV 设置应用到 {name}",
|
|
287
|
+
"assets.replaceTimberTexture": "确认替换所选木条现有的程序化纹理",
|
|
288
|
+
"assets.saveTimberPair": "保存两组木条并预览",
|
|
289
|
+
"assets.timberPairUnavailable": "请选择一组具有可编辑材质的已保存半搭接木条,再选择要一起应用的木条。",
|
|
286
290
|
"assets.localAnimated": "来源材质含动画,局部复制会丢失动画。请选择共享修改或明确创建新材质。",
|
|
287
291
|
"assets.animatedChannel": "该通道由动画驱动,不能在此覆盖。",
|
|
288
292
|
"assets.imageHelp": "保留其他通道;缺少 UV 时保存会明确失败。共享修改影响该材质所有使用者。",
|
|
@@ -1209,6 +1213,10 @@ window.__ModuleLoader__.load({
|
|
|
1209
1213
|
"assets.newMaterial": "Create a new basic material and override this target",
|
|
1210
1214
|
"assets.nativeHelp": "Native nodes have no editable public definition; explicitly create a replacement material for this target.",
|
|
1211
1215
|
"assets.replaceTexture": "Replace this material’s procedural texture with image maps",
|
|
1216
|
+
"assets.applyToTimberPartner": "Apply these settings to {name} too",
|
|
1217
|
+
"assets.replaceTimberTexture": "Replace procedural textures on both groups",
|
|
1218
|
+
"assets.saveTimberPair": "Save both timber groups and preview",
|
|
1219
|
+
"assets.timberPairUnavailable": "Choose a member of a saved timber joint with editable materials, then select its partner.",
|
|
1212
1220
|
"assets.localAnimated": "A local copy would lose source material animation. Choose shared editing or explicitly create a new material.",
|
|
1213
1221
|
"assets.animatedChannel": "This channel is animated and cannot be overridden here.",
|
|
1214
1222
|
"assets.imageHelp": "Other maps are preserved. Missing UVs cause an explicit save failure. Shared editing affects all material users.",
|
|
@@ -3356,9 +3364,25 @@ window.__ModuleLoader__.load({
|
|
|
3356
3364
|
editorSelectMaterial(editor, editorEffectiveMaterialId(editor))
|
|
3357
3365
|
return editor
|
|
3358
3366
|
}
|
|
3367
|
+
function pairedAssetEditor(draft, primary = assetEditor(draft)) {
|
|
3368
|
+
if (draft.kind !== 'image' || draft.channel !== 'baseColor'
|
|
3369
|
+
|| draft.target !== 'entity' || draft.scope !== 'local' || draft.newMaterial) return null
|
|
3370
|
+
const joint = draft.scene.halfLaps?.find(pair => editorHalfLapPartner(pair, draft.entityId))
|
|
3371
|
+
const entityId = editorHalfLapPartner(joint, draft.entityId)
|
|
3372
|
+
if (!entityId) return null
|
|
3373
|
+
const partner = assetEditor({ ...draft, entityId })
|
|
3374
|
+
return [primary, partner].every(editor => {
|
|
3375
|
+
const entity = editor?.original, material = editor?.material.definition
|
|
3376
|
+
return entity?.kind === 'generator' && entity.generator?.shape === 'mesh' && !entity.locked
|
|
3377
|
+
&& ['principled', 'glass'].includes(material?.shader)
|
|
3378
|
+
&& !editor.tracks.some(track => track.targetKind === 'material' && track.targetId === material.id)
|
|
3379
|
+
}) ? partner : null
|
|
3380
|
+
}
|
|
3381
|
+
|
|
3359
3382
|
function resetAssetBinding(draft) {
|
|
3360
3383
|
const source = draft.newMaterial ? null : assetEditor(draft)?.material.definition
|
|
3361
3384
|
draft.binding = editorClone(source?.images?.[draft.channel] || {})
|
|
3385
|
+
draft.includeTimberPartner = false
|
|
3362
3386
|
draft.replaceTexture = false
|
|
3363
3387
|
}
|
|
3364
3388
|
function createAssetDraft(scene, projectId, entry, inspection, entityId) {
|
|
@@ -3374,6 +3398,47 @@ window.__ModuleLoader__.load({
|
|
|
3374
3398
|
resetAssetBinding(draft)
|
|
3375
3399
|
return draft
|
|
3376
3400
|
}
|
|
3401
|
+
function appendImageAssetOperations(operations, draft, asset, fail, editor = assetEditor(draft)) {
|
|
3402
|
+
const target = editor?.original
|
|
3403
|
+
if (!editor || target.kind === 'empty' || target.locked) fail('target')
|
|
3404
|
+
if (!['entity', 'part', 'slot'].includes(draft.target) || !['local', 'shared'].includes(draft.scope)) fail('target scope')
|
|
3405
|
+
if (draft.target !== 'entity') {
|
|
3406
|
+
const part = target.assetParts?.find(item => item.partId === draft.partId)
|
|
3407
|
+
const sourceAsset = draft.scene.nodes.assets.find(item => item.id === target.assetId)
|
|
3408
|
+
if (target.kind !== 'asset-instance' || !part || part.selectorVersion !== 1 || !sourceAsset?.sha256 || part.assetSha256 !== sourceAsset.sha256) fail('source part inventory')
|
|
3409
|
+
if (draft.target === 'slot' && (draft.slotIndex === '' || !part.sourceMaterialSlots.some(slot => slot.index === Number(draft.slotIndex)))) fail('source slot')
|
|
3410
|
+
}
|
|
3411
|
+
const original = editor.material.definition
|
|
3412
|
+
if (!draft.newMaterial && (!original || !['principled', 'glass'].includes(original.shader))) throw new Error(t('assets.nativeHelp'))
|
|
3413
|
+
const animated = editor.tracks.filter(track => track.targetKind === 'material' && track.targetId === original?.id)
|
|
3414
|
+
if (!draft.newMaterial && draft.scope === 'local' && animated.length) throw new Error(t('assets.localAnimated'))
|
|
3415
|
+
if (!draft.newMaterial && animated.some(track => track.property === draft.channel || track.property?.startsWith(`${draft.channel}.`))) throw new Error(t('assets.animatedChannel'))
|
|
3416
|
+
if (!ASSET_CHANNELS.includes(draft.channel)) fail('image channel')
|
|
3417
|
+
const binding = { ...editorClone(draft.binding), assetId: asset.id }
|
|
3418
|
+
if (binding.uvMap !== undefined && (typeof binding.uvMap !== 'string' || !binding.uvMap.trim())) fail('UV name')
|
|
3419
|
+
for (const key of ['scale', 'offset']) if (binding[key] !== undefined && (!Array.isArray(binding[key]) || binding[key].length !== 3 || !binding[key].every(Number.isFinite))) fail(key)
|
|
3420
|
+
if (binding.channel !== undefined && (!['roughness', 'metallic', 'alpha'].includes(draft.channel) || !['r', 'g', 'b', 'a'].includes(binding.channel))) fail('image channel')
|
|
3421
|
+
if (binding.strength !== undefined && (draft.channel !== 'normal' || !Number.isFinite(binding.strength) || binding.strength < 0 || binding.strength > 10)) fail('normal strength')
|
|
3422
|
+
const material = draft.newMaterial ? { id: draft.newMaterialId, shader: 'principled', parameters: { baseColor: [0.8, 0.8, 0.8, 1], roughness: 0.5, metallic: 0 } } : editorClone(original)
|
|
3423
|
+
if (material.texture && !draft.replaceTexture) fail('procedural texture must be explicitly replaced')
|
|
3424
|
+
const images = { ...editorClone(material.images || {}), [draft.channel]: binding }
|
|
3425
|
+
let materialId = material.id
|
|
3426
|
+
if (draft.newMaterial || draft.scope === 'local') {
|
|
3427
|
+
materialId = draft.newMaterialId; material.id = materialId; material.images = images; delete material.texture
|
|
3428
|
+
operations.push({ op: 'material.add', material })
|
|
3429
|
+
if (draft.target === 'entity') operations.push({ op: 'entity.material.set', entityId: draft.entityId, materialId })
|
|
3430
|
+
else {
|
|
3431
|
+
const slotIndex = draft.target === 'slot' ? Number(draft.slotIndex) : undefined
|
|
3432
|
+
const bindings = editorClone(target.materialBindings || []).filter(binding => !(binding.partId === draft.partId && binding.slotIndex === slotIndex))
|
|
3433
|
+
bindings.push({ partId: draft.partId, ...(slotIndex === undefined ? {} : { slotIndex }), materialId })
|
|
3434
|
+
operations.push({ op: 'entity.materialBindings.set', entityId: draft.entityId, materialBindings: bindings })
|
|
3435
|
+
}
|
|
3436
|
+
} else {
|
|
3437
|
+
if (material.texture) operations.push({ op: 'material.texture.set', materialId, texture: null })
|
|
3438
|
+
operations.push({ op: 'material.images.set', materialId, images })
|
|
3439
|
+
}
|
|
3440
|
+
}
|
|
3441
|
+
|
|
3377
3442
|
function buildAssetPatch(draft) {
|
|
3378
3443
|
if (!draft) throw new Error(t('assets.invalid', { field: 'draft' }))
|
|
3379
3444
|
const fail = field => { throw new Error(t('assets.invalid', { field })) }
|
|
@@ -3409,44 +3474,12 @@ window.__ModuleLoader__.load({
|
|
|
3409
3474
|
operations.push({ op: 'world.set', world: { ...editorClone(draft.world), strength: draft.strength,
|
|
3410
3475
|
environment: { ...editorClone(draft.world.environment || {}), assetId: asset.id, rotation: draft.rotation } } })
|
|
3411
3476
|
} else {
|
|
3412
|
-
const
|
|
3413
|
-
if (
|
|
3414
|
-
|
|
3415
|
-
if (
|
|
3416
|
-
|
|
3417
|
-
|
|
3418
|
-
if (target.kind !== 'asset-instance' || !part || part.selectorVersion !== 1 || !sourceAsset?.sha256 || part.assetSha256 !== sourceAsset.sha256) fail('source part inventory')
|
|
3419
|
-
if (draft.target === 'slot' && (draft.slotIndex === '' || !part.sourceMaterialSlots.some(slot => slot.index === Number(draft.slotIndex)))) fail('source slot')
|
|
3420
|
-
}
|
|
3421
|
-
const original = editor.material.definition
|
|
3422
|
-
if (!draft.newMaterial && (!original || !['principled', 'glass'].includes(original.shader))) throw new Error(t('assets.nativeHelp'))
|
|
3423
|
-
const animated = editor.tracks.filter(track => track.targetKind === 'material' && track.targetId === original?.id)
|
|
3424
|
-
if (!draft.newMaterial && draft.scope === 'local' && animated.length) throw new Error(t('assets.localAnimated'))
|
|
3425
|
-
if (!draft.newMaterial && animated.some(track => track.property === draft.channel || track.property?.startsWith(`${draft.channel}.`))) throw new Error(t('assets.animatedChannel'))
|
|
3426
|
-
if (!ASSET_CHANNELS.includes(draft.channel)) fail('image channel')
|
|
3427
|
-
const binding = { ...editorClone(draft.binding), assetId: asset.id }
|
|
3428
|
-
if (binding.uvMap !== undefined && (typeof binding.uvMap !== 'string' || !binding.uvMap.trim())) fail('UV name')
|
|
3429
|
-
for (const key of ['scale', 'offset']) if (binding[key] !== undefined && (!Array.isArray(binding[key]) || binding[key].length !== 3 || !binding[key].every(Number.isFinite))) fail(key)
|
|
3430
|
-
if (binding.channel !== undefined && (!['roughness', 'metallic', 'alpha'].includes(draft.channel) || !['r', 'g', 'b', 'a'].includes(binding.channel))) fail('image channel')
|
|
3431
|
-
if (binding.strength !== undefined && (draft.channel !== 'normal' || !Number.isFinite(binding.strength) || binding.strength < 0 || binding.strength > 10)) fail('normal strength')
|
|
3432
|
-
const material = draft.newMaterial ? { id: draft.newMaterialId, shader: 'principled', parameters: { baseColor: [0.8, 0.8, 0.8, 1], roughness: 0.5, metallic: 0 } } : editorClone(original)
|
|
3433
|
-
if (material.texture && !draft.replaceTexture) fail('procedural texture must be explicitly replaced')
|
|
3434
|
-
const images = { ...editorClone(material.images || {}), [draft.channel]: binding }
|
|
3435
|
-
let materialId = material.id
|
|
3436
|
-
if (draft.newMaterial || draft.scope === 'local') {
|
|
3437
|
-
materialId = draft.newMaterialId; material.id = materialId; material.images = images; delete material.texture
|
|
3438
|
-
operations.push({ op: 'material.add', material })
|
|
3439
|
-
if (draft.target === 'entity') operations.push({ op: 'entity.material.set', entityId: draft.entityId, materialId })
|
|
3440
|
-
else {
|
|
3441
|
-
const slotIndex = draft.target === 'slot' ? Number(draft.slotIndex) : undefined
|
|
3442
|
-
const bindings = editorClone(target.materialBindings || []).filter(binding => !(binding.partId === draft.partId && binding.slotIndex === slotIndex))
|
|
3443
|
-
bindings.push({ partId: draft.partId, ...(slotIndex === undefined ? {} : { slotIndex }), materialId })
|
|
3444
|
-
operations.push({ op: 'entity.materialBindings.set', entityId: draft.entityId, materialBindings: bindings })
|
|
3445
|
-
}
|
|
3446
|
-
} else {
|
|
3447
|
-
if (material.texture) operations.push({ op: 'material.texture.set', materialId, texture: null })
|
|
3448
|
-
operations.push({ op: 'material.images.set', materialId, images })
|
|
3449
|
-
}
|
|
3477
|
+
const partner = draft.includeTimberPartner ? pairedAssetEditor(draft) : null
|
|
3478
|
+
if (draft.includeTimberPartner && !partner) throw new Error(t('assets.timberPairUnavailable'))
|
|
3479
|
+
appendImageAssetOperations(operations, draft, asset, fail)
|
|
3480
|
+
if (partner) appendImageAssetOperations(operations, {
|
|
3481
|
+
...draft, entityId: partner.original.id, newMaterialId: `${draft.newMaterialId}-partner`,
|
|
3482
|
+
}, asset, fail, partner)
|
|
3450
3483
|
}
|
|
3451
3484
|
return { projectId: draft.projectId, baseRevision: draft.baseRevision, saveCheckpoint: true, renderPreview: true, actor: 'ui', operations }
|
|
3452
3485
|
}
|
|
@@ -5141,9 +5174,15 @@ window.__ModuleLoader__.load({
|
|
|
5141
5174
|
updateAsset: (field, value) => {
|
|
5142
5175
|
const projectId = data.activeProjectId, current = data.assetDrafts[projectId]
|
|
5143
5176
|
if (!current || data.assetWork[projectId]?.busy) return
|
|
5144
|
-
const allowed = ['newEntityId', 'location', 'rotationEuler', 'scale', 'hideEntityId', 'makeSubject', 'entityId', 'target', 'partId', 'slotIndex', 'scope', 'newMaterial', 'channel', 'binding', 'replaceTexture', 'strength', 'rotation']
|
|
5177
|
+
const allowed = ['newEntityId', 'location', 'rotationEuler', 'scale', 'hideEntityId', 'makeSubject', 'entityId', 'target', 'partId', 'slotIndex', 'scope', 'newMaterial', 'channel', 'binding', 'replaceTexture', 'includeTimberPartner', 'strength', 'rotation']
|
|
5145
5178
|
if (!allowed.includes(field)) return
|
|
5179
|
+
if (field === 'includeTimberPartner' && (typeof value !== 'boolean' || !pairedAssetEditor(current))) return
|
|
5146
5180
|
const draft = editorClone(current); draft[field] = editorClone(value)
|
|
5181
|
+
if (field === 'includeTimberPartner') draft.replaceTexture = false
|
|
5182
|
+
if (field === 'scope' && draft.includeTimberPartner && !pairedAssetEditor(draft)) {
|
|
5183
|
+
draft.includeTimberPartner = false
|
|
5184
|
+
draft.replaceTexture = false
|
|
5185
|
+
}
|
|
5147
5186
|
if (['entityId', 'target'].includes(field)) { draft.partId = ''; draft.slotIndex = '' }
|
|
5148
5187
|
if (field === 'partId') draft.slotIndex = ''
|
|
5149
5188
|
if (['entityId', 'target', 'partId', 'slotIndex', 'channel', 'newMaterial'].includes(field)) resetAssetBinding(draft)
|
|
@@ -6847,21 +6886,26 @@ window.__ModuleLoader__.load({
|
|
|
6847
6886
|
const choose = (label, field, value, entries, change) => el('label', { className: 'db-row' }, label,
|
|
6848
6887
|
el('select', { className: 'db-input', 'aria-label': label, 'data-field': field, value, disabled: busy, onChange: event => change(event.target.value) },
|
|
6849
6888
|
entries.map(([id, name]) => el('option', { value: id, key: id }, name))))
|
|
6850
|
-
const check = (label, field, value, change) => el('label', {
|
|
6851
|
-
|
|
6889
|
+
const check = (label, field, value, change, inline = false) => el('label', {
|
|
6890
|
+
className: 'db-row', ...(inline ? { style: { flexWrap: 'nowrap', overflowWrap: 'anywhere' } } : {}),
|
|
6891
|
+
}, el('input', { type: 'checkbox', 'data-field': field, checked: value, disabled: busy,
|
|
6892
|
+
onChange: event => change(event.target.checked) }), label)
|
|
6852
6893
|
const vector = (name, field, values, factor) => el('div', { className: 'db-inline' }, EDITOR_AXES.map((axis, index) => number(`${name} ${axis}`, `asset-${field}-${axis}`,
|
|
6853
6894
|
values[index] === null ? '' : values[index] * factor, value => { const next = [...values]; next[index] = value === null ? null : value / factor; update(field, next) })))
|
|
6854
|
-
let editor, material, part, error, affected = []
|
|
6895
|
+
let editor, material, partner, part, error, affected = []
|
|
6855
6896
|
if (draft) {
|
|
6856
6897
|
error = assetDraftError(draft)
|
|
6857
6898
|
if (draft.kind === 'image') {
|
|
6858
6899
|
editor = assetEditor(draft); material = editor?.material.definition
|
|
6900
|
+
partner = pairedAssetEditor(draft, editor)
|
|
6859
6901
|
part = editor?.original.assetParts?.find(item => item.partId === draft.partId)
|
|
6860
6902
|
affected = draft.scene.nodes.entities.filter(entity => entity.materialId === material?.id
|
|
6861
6903
|
|| entity.materialBindings?.some(binding => binding.materialId === material?.id)
|
|
6862
6904
|
|| entity.assetParts?.some(item => item.materialSlots?.some(slot => slot.materialId === material?.id))).map(entity => entity.id)
|
|
6863
6905
|
}
|
|
6864
6906
|
}
|
|
6907
|
+
const paired = draft?.includeTimberPartner && partner
|
|
6908
|
+
const replaceTexture = !draft?.newMaterial && (material?.texture || (paired && partner.material.definition.texture))
|
|
6865
6909
|
const mapSetting = (key, value) => { const binding = editorClone(draft.binding); if (value === undefined) delete binding[key]; else binding[key] = value; update('binding', binding) }
|
|
6866
6910
|
return el('section', { className: 'db-card', 'data-assets-library': projectId, 'data-asset-base-revision': draft?.baseRevision || '', 'data-asset-conflict': String(conflict) },
|
|
6867
6911
|
el('h4', null, t('assets.title')), el('p', { className: 'db-muted' }, t('assets.help')),
|
|
@@ -6957,10 +7001,13 @@ window.__ModuleLoader__.load({
|
|
|
6957
7001
|
['roughness', 'metallic', 'alpha'].includes(draft.channel) ? choose(t('assets.scalarChannel'), 'asset-scalar-channel', draft.binding.channel || 'r', ['r', 'g', 'b', 'a'].map(value => [value, value]), value => mapSetting('channel', value)) : null,
|
|
6958
7002
|
draft.channel === 'normal' ? number(t('assets.normalStrength'), 'asset-normal-strength', editorNumberDefault(draft.binding.strength, 1), value => mapSetting('strength', value), { min: 0, max: 10 }) : null,
|
|
6959
7003
|
draft.channel === 'emissionColor' ? el('p', { className: 'db-muted' }, t('assets.emissionHelp')) : null,
|
|
6960
|
-
|
|
7004
|
+
partner ? check(t('assets.applyToTimberPartner', { name: partner.original.name || partner.original.id }),
|
|
7005
|
+
'asset-include-timber-partner', Boolean(paired), value => update('includeTimberPartner', value), true) : null,
|
|
7006
|
+
replaceTexture ? check(paired ? t('assets.replaceTimberTexture') : t('assets.replaceTexture'),
|
|
7007
|
+
'asset-replace-texture', draft.replaceTexture, value => update('replaceTexture', value), Boolean(paired)) : null) : null,
|
|
6961
7008
|
error ? el('p', { className: 'db-error' }, error) : null,
|
|
6962
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,
|
|
6963
|
-
onClick: actions.applyAsset, children: t('assets.apply') }), Button({ action: 'asset-reset', disabled: busy, onClick: actions.discardAsset, children: t('assets.reset') }))) : null)
|
|
7010
|
+
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)
|
|
6964
7011
|
}
|
|
6965
7012
|
|
|
6966
7013
|
function CameraFitEditor(ctx) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deepblend/dsh-blender-bundle",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.30.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.
|
|
48
|
-
"@deepblend/dsh-blender-host": "0.
|
|
49
|
-
"@deepblend/dsh-blender-preset": "0.
|
|
50
|
-
"@deepblend/dsh-blender-provider-local": "0.
|
|
51
|
-
"@deepblend/dsh-blender-tool": "0.
|
|
52
|
-
"@deepblend/dsh-blender-ui": "0.
|
|
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"
|
|
53
53
|
},
|
|
54
54
|
"type": "module",
|
|
55
55
|
"license": "MIT",
|