@lrplrplrp/dsh-live2d 0.1.0 → 0.1.2
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/assets/model_list.json +2 -2
- package/lib/client.js +99 -71
- package/package.json +3 -2
- package/assets/BCSZ1.1/BCSZ1.1.cdi3.json +0 -470
- package/assets/BCSZ1.1/BCSZ1.1.moc3 +0 -0
- package/assets/BCSZ1.1/BCSZ1.1.model3.json +0 -174
- package/assets/BCSZ1.1/BCSZ1.1.physics3.json +0 -2494
- package/assets/BCSZ1.1/SZ-/344/270/215/345/217/230.motion3.json +0 -13703
- package/assets/BCSZ1.1/SZ-/344/270/255/345/215/210.motion3.json +0 -7201
- package/assets/BCSZ1.1/SZ-/345/210/235/350/247/201.motion3.json +0 -27609
- package/assets/BCSZ1.1/SZ-/345/244/234/346/231/232.motion3.json +0 -14909
- package/assets/BCSZ1.1/SZ-/345/244/264/351/245/260.motion3.json +0 -69
- package/assets/BCSZ1.1/SZ-/345/260/276/345/267/264.motion3.json +0 -840
- package/assets/BCSZ1.1/SZ-/345/261/221/347/234/274/347/245/236.motion3.json +0 -69
- package/assets/BCSZ1.1/SZ-/345/275/222/351/233/266.motion3.json +0 -300
- package/assets/BCSZ1.1/SZ-/346/227/240/350/201/212.motion3.json +0 -6617
- package/assets/BCSZ1.1/SZ-/346/227/251/344/270/212/345/245/275.motion3.json +0 -16785
- package/assets/BCSZ1.1/template.json +0 -59
- package/assets/BCSZ1.1/textures/texture_00.png +0 -0
- package/assets/BCSZ1.1/waifu-tips-BCSZ.json +0 -49
- package/assets/BCSZ1.1//345/205/253/351/207/215/347/245/236/345/255/220-/344/270/215/345/217/230.wav +0 -0
- package/assets/BCSZ1.1//345/205/253/351/207/215/347/245/236/345/255/220-/344/270/255/345/215/210.wav +0 -0
- package/assets/BCSZ1.1//345/205/253/351/207/215/347/245/236/345/255/220-/345/210/235/350/247/201.wav +0 -0
- package/assets/BCSZ1.1//345/205/253/351/207/215/347/245/236/345/255/220-/345/244/234/346/231/232.wav +0 -0
- package/assets/BCSZ1.1//345/205/253/351/207/215/347/245/236/345/255/220-/346/227/240/350/201/212.wav +0 -0
- package/assets/BCSZ1.1//345/205/253/351/207/215/347/245/236/345/255/220-/346/227/251/344/270/212.wav +0 -0
package/assets/model_list.json
CHANGED
package/lib/client.js
CHANGED
|
@@ -204,8 +204,9 @@ window.__ModuleLoader__.load({ id: 'dsh-live2d', factory: (require) => {
|
|
|
204
204
|
const LIVE2D_CSS = [
|
|
205
205
|
'#dsh-live2d-container {',
|
|
206
206
|
' position: fixed;',
|
|
207
|
-
'
|
|
208
|
-
' left:
|
|
207
|
+
' top: 24px;',
|
|
208
|
+
' left: 24px;',
|
|
209
|
+
' bottom: auto;',
|
|
209
210
|
' z-index: 9999;',
|
|
210
211
|
// 容器本身不拦截指针事件,画布区域点击完全穿透到页面,不影响输入;
|
|
211
212
|
// 只有拖拽图标与画布大小手柄单独开启 pointer-events。
|
|
@@ -243,52 +244,48 @@ window.__ModuleLoader__.load({ id: 'dsh-live2d', factory: (require) => {
|
|
|
243
244
|
'#dsh-live2d-container:hover .dsh-live2d-label {',
|
|
244
245
|
' opacity: 1;',
|
|
245
246
|
'}',
|
|
246
|
-
//
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
'
|
|
250
|
-
'
|
|
251
|
-
'
|
|
252
|
-
'
|
|
247
|
+
// 控制浮层:固定定位,位置由 JS 动态计算——理想位置是画布右下角,
|
|
248
|
+
// 但会被夹在视口内(画布拖出屏幕时,图标停在离画布右下角最近的屏幕边缘)。
|
|
249
|
+
// 浮层本身不拦截指针(pointer-events:none),只有里面的图标可点。
|
|
250
|
+
'#dsh-live2d-controls {',
|
|
251
|
+
' position: fixed;',
|
|
252
|
+
' z-index: 10000;',
|
|
253
|
+
' display: flex;',
|
|
254
|
+
' align-items: center;',
|
|
255
|
+
' gap: 8px;',
|
|
256
|
+
' pointer-events: none;',
|
|
257
|
+
'}',
|
|
258
|
+
// 画布大小拖拽手柄:常驻右下角浮层,与移动图标并排
|
|
259
|
+
'#dsh-live2d-controls .dsh-live2d-resize {',
|
|
260
|
+
' width: 16px;',
|
|
261
|
+
' height: 16px;',
|
|
253
262
|
' border-right: 2px solid rgba(96,165,250,0.9);',
|
|
254
263
|
' border-bottom: 2px solid rgba(96,165,250,0.9);',
|
|
255
264
|
' cursor: nwse-resize;',
|
|
256
|
-
' opacity: 0;',
|
|
257
|
-
' transition: opacity 0.2s;',
|
|
265
|
+
' opacity: 0.7;',
|
|
258
266
|
' pointer-events: auto;',
|
|
259
|
-
'
|
|
267
|
+
' flex: none;',
|
|
260
268
|
'}',
|
|
261
|
-
|
|
262
|
-
'
|
|
263
|
-
'
|
|
264
|
-
|
|
265
|
-
'#dsh-live2d-container .dsh-live2d-drag {',
|
|
266
|
-
' position: absolute;',
|
|
267
|
-
' right: 9px;',
|
|
268
|
-
' bottom: 9px;',
|
|
269
|
-
' width: 22px;',
|
|
270
|
-
' height: 22px;',
|
|
269
|
+
// 拖拽移动图标:常驻右下角浮层
|
|
270
|
+
'#dsh-live2d-controls .dsh-live2d-drag {',
|
|
271
|
+
' width: 26px;',
|
|
272
|
+
' height: 26px;',
|
|
271
273
|
' display: flex;',
|
|
272
274
|
' align-items: center;',
|
|
273
275
|
' justify-content: center;',
|
|
274
276
|
' border-radius: 6px;',
|
|
275
|
-
' background: rgba(31,41,55,0.
|
|
276
|
-
' color: rgba(226,232,240,0.
|
|
277
|
-
' font-size:
|
|
277
|
+
' background: rgba(31,41,55,0.75);',
|
|
278
|
+
' color: rgba(226,232,240,0.95);',
|
|
279
|
+
' font-size: 15px;',
|
|
278
280
|
' line-height: 1;',
|
|
279
281
|
' cursor: grab;',
|
|
280
282
|
' user-select: none;',
|
|
281
283
|
' pointer-events: auto;',
|
|
282
|
-
' opacity: 0;',
|
|
283
|
-
'
|
|
284
|
-
' z-index: 2;',
|
|
285
|
-
'}',
|
|
286
|
-
'#dsh-live2d-container.hovering .dsh-live2d-drag {',
|
|
287
|
-
' opacity: 0.9;',
|
|
284
|
+
' opacity: 0.85;',
|
|
285
|
+
' flex: none;',
|
|
288
286
|
'}',
|
|
289
|
-
'#dsh-live2d-
|
|
287
|
+
'#dsh-live2d-controls .dsh-live2d-drag:active {',
|
|
290
288
|
' cursor: grabbing;',
|
|
291
|
-
' opacity: 0.9;',
|
|
292
289
|
'}',
|
|
293
290
|
].join('\n')
|
|
294
291
|
|
|
@@ -691,17 +688,38 @@ window.__ModuleLoader__.load({ id: 'dsh-live2d', factory: (require) => {
|
|
|
691
688
|
* 会优先满足 bottom,拖动看起来"完全没反应"。
|
|
692
689
|
*/
|
|
693
690
|
function place(containerEl, x, y) {
|
|
694
|
-
//
|
|
695
|
-
//
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
const maxY = Math.max(0, window.innerHeight - rect.height)
|
|
699
|
-
containerEl.style.left = Math.min(Math.max(x, 0), maxX) + 'px'
|
|
700
|
-
containerEl.style.top = Math.min(Math.max(y, 0), maxY) + 'px'
|
|
691
|
+
// 画布可自由定位(允许拖出屏幕),仅写入 left/top;bottom 必须置 auto,
|
|
692
|
+
// 否则 left/top 与 bottom 同时生效时浏览器优先满足 bottom,拖动无反应。
|
|
693
|
+
containerEl.style.left = x + 'px'
|
|
694
|
+
containerEl.style.top = y + 'px'
|
|
701
695
|
containerEl.style.bottom = 'auto'
|
|
702
696
|
}
|
|
703
697
|
|
|
704
|
-
|
|
698
|
+
// 控制浮层跟随画布右下角:clamp=true 时被夹在视口内(画布在屏幕内时图标贴
|
|
699
|
+
// 画布右下角;画布拖出屏幕时图标停在最近屏幕边缘);clamp=false 时不夹边,
|
|
700
|
+
// 用于拖动画布大小手柄的过程中——否则手柄会被夹在视口底边,鼠标越过后即
|
|
701
|
+
// 收不到 pointermove,表现为"向下拖不动"。
|
|
702
|
+
function updateControls(containerEl, controlsEl, clamp = true) {
|
|
703
|
+
if (!containerEl || !controlsEl) return
|
|
704
|
+
const cr = containerEl.getBoundingClientRect()
|
|
705
|
+
const cs = controlsEl.getBoundingClientRect()
|
|
706
|
+
const w = cs.width || 60
|
|
707
|
+
const h = cs.height || 34
|
|
708
|
+
const OFFSET = 4 // 图标相对画布右下角内缩一点
|
|
709
|
+
const MARGIN = 4 // 离屏幕边缘的最小间距
|
|
710
|
+
let x = cr.right - w - OFFSET
|
|
711
|
+
let y = cr.bottom - h - OFFSET
|
|
712
|
+
if (clamp) {
|
|
713
|
+
x = Math.min(Math.max(x, MARGIN), window.innerWidth - w - MARGIN)
|
|
714
|
+
y = Math.min(Math.max(y, MARGIN), window.innerHeight - h - MARGIN)
|
|
715
|
+
}
|
|
716
|
+
controlsEl.style.left = x + 'px'
|
|
717
|
+
controlsEl.style.top = y + 'px'
|
|
718
|
+
controlsEl.style.right = 'auto'
|
|
719
|
+
controlsEl.style.bottom = 'auto'
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
function setupDrag(handleEl, containerEl, controlsEl) {
|
|
705
723
|
let pointerId = null
|
|
706
724
|
let startX = 0
|
|
707
725
|
let startY = 0
|
|
@@ -756,6 +774,7 @@ window.__ModuleLoader__.load({ id: 'dsh-live2d', factory: (require) => {
|
|
|
756
774
|
curX = origX + (e.clientX - startX)
|
|
757
775
|
curY = origY + (e.clientY - startY)
|
|
758
776
|
place(containerEl, curX, curY)
|
|
777
|
+
updateControls(containerEl, controlsEl)
|
|
759
778
|
e.preventDefault()
|
|
760
779
|
}
|
|
761
780
|
|
|
@@ -855,6 +874,7 @@ window.__ModuleLoader__.load({ id: 'dsh-live2d', factory: (require) => {
|
|
|
855
874
|
function Live2DWidget() {
|
|
856
875
|
const containerRef = useRef(null)
|
|
857
876
|
const dragHandleRef = useRef(null)
|
|
877
|
+
const controlsRef = useRef(null)
|
|
858
878
|
const engineRef = useRef(null)
|
|
859
879
|
const cleanupDragRef = useRef(null)
|
|
860
880
|
const lastStateRef = useRef(DSHState.IDLE)
|
|
@@ -887,28 +907,19 @@ window.__ModuleLoader__.load({ id: 'dsh-live2d', factory: (require) => {
|
|
|
887
907
|
engine.init(containerRef.current).then((ok) => {
|
|
888
908
|
if (ok) {
|
|
889
909
|
engine.playAnimation('IDLE')
|
|
910
|
+
updateControls(containerRef.current, controlsRef.current)
|
|
890
911
|
}
|
|
891
912
|
})
|
|
892
913
|
|
|
893
|
-
cleanupDragRef.current = setupDrag(dragHandleRef.current, containerRef.current)
|
|
914
|
+
cleanupDragRef.current = setupDrag(dragHandleRef.current, containerRef.current, controlsRef.current)
|
|
894
915
|
|
|
895
|
-
//
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
const onMouseMove = (e) => {
|
|
899
|
-
const el = containerRef.current
|
|
900
|
-
if (!el) return
|
|
901
|
-
const rect = el.getBoundingClientRect()
|
|
902
|
-
const inside = e.clientX >= rect.left && e.clientX <= rect.right &&
|
|
903
|
-
e.clientY >= rect.top && e.clientY <= rect.bottom
|
|
904
|
-
if (inside) el.classList.add('hovering')
|
|
905
|
-
else el.classList.remove('hovering')
|
|
906
|
-
}
|
|
907
|
-
window.addEventListener('mousemove', onMouseMove)
|
|
916
|
+
// 窗口尺寸变化时把图标夹回视口内(画布可能因此相对移出屏幕)
|
|
917
|
+
const onResize = () => updateControls(containerRef.current, controlsRef.current)
|
|
918
|
+
window.addEventListener('resize', onResize)
|
|
908
919
|
|
|
909
920
|
return () => {
|
|
910
921
|
cleanupDragRef.current?.()
|
|
911
|
-
window.removeEventListener('
|
|
922
|
+
window.removeEventListener('resize', onResize)
|
|
912
923
|
engine.destroy()
|
|
913
924
|
}
|
|
914
925
|
}, [])
|
|
@@ -941,6 +952,7 @@ window.__ModuleLoader__.load({ id: 'dsh-live2d', factory: (require) => {
|
|
|
941
952
|
if (!engine || !engine.ready) return
|
|
942
953
|
const factor = e.deltaY < 0 ? 1.08 : 1 / 1.08
|
|
943
954
|
engine.zoomBy(factor)
|
|
955
|
+
updateControls(containerRef.current, controlsRef.current)
|
|
944
956
|
}, [])
|
|
945
957
|
|
|
946
958
|
// 画布大小手柄:拖动右下角改变 canvasWidth/canvasHeight
|
|
@@ -953,20 +965,27 @@ window.__ModuleLoader__.load({ id: 'dsh-live2d', factory: (require) => {
|
|
|
953
965
|
|
|
954
966
|
const startX = e.clientX
|
|
955
967
|
const startY = e.clientY
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
968
|
+
// 起点尺寸必须取 canvas 自身(CSS 像素),不能取 container 的
|
|
969
|
+
// getBoundingClientRect():container 是 pointer-events:none 且内含一个
|
|
970
|
+
// position:fixed 的控制浮层,某些布局下其 rect 高度会塌缩为 0 / 与画布
|
|
971
|
+
// 不一致,导致 startH 错乱、向下拖时 h 计算异常、画布大小"拖不动"。
|
|
972
|
+
const canvasEl = engine.canvas
|
|
973
|
+
const startW = canvasEl ? canvasEl.offsetWidth : containerEl.getBoundingClientRect().width
|
|
974
|
+
const startH = canvasEl ? canvasEl.offsetHeight : containerEl.getBoundingClientRect().height
|
|
959
975
|
const pointerId = e.pointerId
|
|
960
976
|
|
|
961
|
-
try { e.
|
|
977
|
+
try { e.currentTarget.setPointerCapture(pointerId) } catch {}
|
|
962
978
|
|
|
963
979
|
const move = (ev) => {
|
|
964
980
|
if (ev.pointerId !== pointerId) return
|
|
965
981
|
const dw = ev.clientX - startX
|
|
966
982
|
const dh = ev.clientY - startY
|
|
983
|
+
// 拖动过程中不夹边(clamp=false):手柄自由跟随画布右下角,向下拖
|
|
984
|
+
// 时不会被夹在视口底边、鼠标越过后收不到 pointermove 而"拖不动"。
|
|
967
985
|
const w = Math.min(800, Math.max(100, startW + dw))
|
|
968
986
|
const h = Math.min(800, Math.max(100, startH + dh))
|
|
969
987
|
engine.setCanvasSize(w, h)
|
|
988
|
+
updateControls(containerEl, controlsRef.current, false)
|
|
970
989
|
}
|
|
971
990
|
const up = (ev) => {
|
|
972
991
|
if (ev.pointerId !== pointerId) return
|
|
@@ -974,6 +993,8 @@ window.__ModuleLoader__.load({ id: 'dsh-live2d', factory: (require) => {
|
|
|
974
993
|
window.removeEventListener('pointermove', move)
|
|
975
994
|
window.removeEventListener('pointerup', up)
|
|
976
995
|
window.removeEventListener('pointercancel', up)
|
|
996
|
+
// 松手后把图标夹回视口内(静止状态始终留在网页可见区域)。
|
|
997
|
+
updateControls(containerEl, controlsRef.current, true)
|
|
977
998
|
}
|
|
978
999
|
window.addEventListener('pointermove', move)
|
|
979
1000
|
window.addEventListener('pointerup', up)
|
|
@@ -985,18 +1006,25 @@ window.__ModuleLoader__.load({ id: 'dsh-live2d', factory: (require) => {
|
|
|
985
1006
|
id: 'dsh-live2d-container',
|
|
986
1007
|
onWheel: onWheel,
|
|
987
1008
|
},
|
|
988
|
-
//
|
|
989
|
-
|
|
990
|
-
ref: dragHandleRef,
|
|
991
|
-
className: 'dsh-live2d-drag',
|
|
992
|
-
title: '拖动移动看板娘;鼠标滚轮缩放模型大小',
|
|
993
|
-
}, '✥'),
|
|
994
|
-
// 画布大小手柄:仅鼠标悬停画布(容器)时显示
|
|
1009
|
+
// 控制浮层:固定钉在视口右下角,独立于画布。画布可以拖出屏幕,
|
|
1010
|
+
// 但这两个图标始终留在页面内可见可点。
|
|
995
1011
|
h('div', {
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1012
|
+
ref: controlsRef,
|
|
1013
|
+
id: 'dsh-live2d-controls',
|
|
1014
|
+
},
|
|
1015
|
+
// 画布大小手柄
|
|
1016
|
+
h('div', {
|
|
1017
|
+
className: 'dsh-live2d-resize',
|
|
1018
|
+
title: '拖动改变画布大小',
|
|
1019
|
+
onPointerDown: onResizePointerDown,
|
|
1020
|
+
}),
|
|
1021
|
+
// 拖拽移动图标:只有拖动它才能移动整个看板娘
|
|
1022
|
+
h('div', {
|
|
1023
|
+
ref: dragHandleRef,
|
|
1024
|
+
className: 'dsh-live2d-drag',
|
|
1025
|
+
title: '拖动移动看板娘;鼠标滚轮缩放模型大小',
|
|
1026
|
+
}, '✥'),
|
|
1027
|
+
),
|
|
1000
1028
|
)
|
|
1001
1029
|
}
|
|
1002
1030
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lrplrplrp/dsh-live2d",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Live2D 看板娘插件 for DeepSeek Harness — 可拖动的 Live2D 模型,支持 DSH 状态驱动动画、本地模型导入和完整配置页。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
},
|
|
12
12
|
"files": [
|
|
13
13
|
"lib/",
|
|
14
|
-
"assets/",
|
|
14
|
+
"assets/deepseek_l2d/",
|
|
15
|
+
"assets/model_list.json",
|
|
15
16
|
"cordis.patch.yml",
|
|
16
17
|
"README.md",
|
|
17
18
|
"LICENSE"
|