@y250031003/amap-sky-debug 0.1.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/README.md +74 -0
- package/dist-lib/amap-sky-debug.css +2 -0
- package/dist-lib/amap-sky-debug.js +184 -0
- package/dist-lib/amap-sky-debug.umd.cjs +1 -0
- package/package.json +43 -0
- package/types/index.d.ts +61 -0
package/README.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# @y250031003/amap-sky-debug
|
|
2
|
+
|
|
3
|
+
用于覆盖和调试高德 3D 地图天空颜色。
|
|
4
|
+
|
|
5
|
+
提供两种用法:
|
|
6
|
+
|
|
7
|
+
- 方法:`setFixedSkyColors`
|
|
8
|
+
直接在地图初始化时覆盖内部颜色,不依赖组件。
|
|
9
|
+
- 组件:`SkyDebugPanel`
|
|
10
|
+
在页面右上角显示调试面板,实时查看和调整颜色。
|
|
11
|
+
|
|
12
|
+
## 安装
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm i @y250031003/amap-sky-debug
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
如果你要使用调试面板,需要额外引入样式:
|
|
19
|
+
|
|
20
|
+
```js
|
|
21
|
+
import '@y250031003/amap-sky-debug/dist-lib/amap-sky-debug.css'
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## 方法用法
|
|
25
|
+
|
|
26
|
+
```js
|
|
27
|
+
import { setFixedSkyColors } from '@y250031003/amap-sky-debug'
|
|
28
|
+
|
|
29
|
+
setFixedSkyColors(map, {
|
|
30
|
+
sky: '#548cd6',
|
|
31
|
+
atmosphere: '#548cd6',
|
|
32
|
+
ground: '#0000ff',
|
|
33
|
+
})
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
说明:
|
|
37
|
+
|
|
38
|
+
- `sky`
|
|
39
|
+
顶部天空主色
|
|
40
|
+
- `atmosphere`
|
|
41
|
+
大气层颜色,低缩放时更明显
|
|
42
|
+
- `ground`
|
|
43
|
+
地平线过渡色
|
|
44
|
+
|
|
45
|
+
## 组件用法
|
|
46
|
+
|
|
47
|
+
```vue
|
|
48
|
+
<template>
|
|
49
|
+
<SkyDebugPanel :map="mapRef" />
|
|
50
|
+
</template>
|
|
51
|
+
|
|
52
|
+
<script setup>
|
|
53
|
+
import { ref } from 'vue'
|
|
54
|
+
import { SkyDebugPanel } from '@y250031003/amap-sky-debug'
|
|
55
|
+
import '@y250031003/amap-sky-debug/dist-lib/amap-sky-debug.css'
|
|
56
|
+
|
|
57
|
+
const mapRef = ref(null)
|
|
58
|
+
</script>
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## 导出
|
|
62
|
+
|
|
63
|
+
```js
|
|
64
|
+
import {
|
|
65
|
+
SkyDebugPanel,
|
|
66
|
+
defaultSkyPalette,
|
|
67
|
+
setFixedSkyColors,
|
|
68
|
+
readSkyDebugState,
|
|
69
|
+
} from '@y250031003/amap-sky-debug'
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## 类型
|
|
73
|
+
|
|
74
|
+
包内自带 `types/index.d.ts`,可直接在 TypeScript 项目中使用。
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
.debug-panel[data-v-c91aa86d]{z-index:10;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);color:#e8eefc;background:#0c121ed1;border:1px solid #ffffff24;border-radius:12px;min-width:320px;padding:14px 16px;font:12px/1.4 SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;position:absolute;top:16px;right:16px}.debug-title[data-v-c91aa86d]{margin-bottom:10px;font-size:13px;font-weight:700}.debug-summary[data-v-c91aa86d]{color:#e8eefcb8;margin-bottom:12px}.debug-row[data-v-c91aa86d]{align-items:center;gap:10px;display:flex}.debug-row+.debug-row[data-v-c91aa86d]{margin-top:10px}.debug-swatch[data-v-c91aa86d]{border:1px solid #ffffff2e;border-radius:4px;flex:0 0 18px;width:18px;height:18px}.debug-label[data-v-c91aa86d]{color:#e8eefcb8}.debug-help[data-v-c91aa86d]{color:#e8eefc8f;margin-top:2px}.debug-value[data-v-c91aa86d]{word-break:break-all;margin-top:2px}.debug-meta[data-v-c91aa86d]{color:#e8eefcb8;margin-top:12px}.debug-controls[data-v-c91aa86d]{border-top:1px solid #ffffff14;margin-top:14px;padding-top:12px}.debug-toggle[data-v-c91aa86d]{color:#e8eefce6;align-items:center;gap:8px;margin-bottom:10px;display:flex}.debug-control[data-v-c91aa86d]{justify-content:space-between;align-items:center;gap:12px;display:flex}.debug-control+.debug-control[data-v-c91aa86d]{margin-top:8px}.debug-control-label[data-v-c91aa86d]{color:#e8eefcb8}.debug-color[data-v-c91aa86d]{cursor:pointer;background:0 0;border:1px solid #ffffff2e;border-radius:6px;width:42px;height:28px;padding:0}
|
|
2
|
+
/*$vite$:1*/
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { createElementBlock as e, createElementVNode as t, normalizeStyle as n, onBeforeUnmount as r, openBlock as i, ref as a, toDisplayString as o, vModelCheckbox as s, vModelText as c, watch as l, withDirectives as u } from "vue";
|
|
2
|
+
//#region src/utils/skyColors.js
|
|
3
|
+
var d = {
|
|
4
|
+
sky: "#548cd6",
|
|
5
|
+
atmosphere: "#548cd6",
|
|
6
|
+
ground: "#0000ff"
|
|
7
|
+
}, f = /* @__PURE__ */ new WeakMap(), p = (e) => {
|
|
8
|
+
if (typeof e != "string" || !/^#([\da-f]{6})$/i.test(e)) return [
|
|
9
|
+
0,
|
|
10
|
+
0,
|
|
11
|
+
0,
|
|
12
|
+
1
|
|
13
|
+
];
|
|
14
|
+
let t = e.slice(1).match(/.{2}/g).map((e) => parseInt(e, 16));
|
|
15
|
+
return [
|
|
16
|
+
t[0] / 255,
|
|
17
|
+
t[1] / 255,
|
|
18
|
+
t[2] / 255,
|
|
19
|
+
1
|
|
20
|
+
];
|
|
21
|
+
}, m = (e) => {
|
|
22
|
+
let [t, n, r] = p(e);
|
|
23
|
+
return [
|
|
24
|
+
Math.round(t * 255),
|
|
25
|
+
Math.round(n * 255),
|
|
26
|
+
Math.round(r * 255),
|
|
27
|
+
255
|
|
28
|
+
];
|
|
29
|
+
}, h = (e) => {
|
|
30
|
+
if (!Array.isArray(e) || e.length < 4) return "rgba(0, 0, 0, 0)";
|
|
31
|
+
let t = e.slice(0, 3).map((e) => Math.round(e <= 1 ? e * 255 : e)), n = e[3] > 1 ? +(e[3] / 255).toFixed(3) : +e[3].toFixed(3);
|
|
32
|
+
return `rgba(${t[0]}, ${t[1]}, ${t[2]}, ${n})`;
|
|
33
|
+
}, g = (e = "rgba(0, 0, 0, 0)") => ({
|
|
34
|
+
css: e,
|
|
35
|
+
text: e
|
|
36
|
+
}), _ = (e, t = d, n = !0) => {
|
|
37
|
+
if (!e?.mapStyle) return;
|
|
38
|
+
let r = f.get(e);
|
|
39
|
+
if (r || (r = {
|
|
40
|
+
JF: e.JF.bind(e),
|
|
41
|
+
sX: e.sX.bind(e),
|
|
42
|
+
dn: e.mapStyle.dn.bind(e.mapStyle)
|
|
43
|
+
}, f.set(e, r)), !n) {
|
|
44
|
+
e.JF = r.JF, e.sX = r.sX, e.mapStyle.dn = r.dn, e.setNeedUpdate(!0);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
e.JF = () => p(t.sky), e.sX = () => p(t.atmosphere), e.mapStyle.dn = (...e) => {
|
|
48
|
+
let n = r.dn(...e);
|
|
49
|
+
if (e[0] === 30001 && e[1] === 1) {
|
|
50
|
+
let e = m(t.ground), r = p(t.ground);
|
|
51
|
+
return {
|
|
52
|
+
...n,
|
|
53
|
+
faceColor: {
|
|
54
|
+
...n?.faceColor || {},
|
|
55
|
+
rgba: e,
|
|
56
|
+
U8t: r,
|
|
57
|
+
normalize() {
|
|
58
|
+
return r;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
return n;
|
|
64
|
+
}, e.setNeedUpdate(!0);
|
|
65
|
+
}, v = (e) => {
|
|
66
|
+
if (!e?.mapStyle?.dn) return {
|
|
67
|
+
zoom: "-",
|
|
68
|
+
sky: g(),
|
|
69
|
+
atmosphere: g(),
|
|
70
|
+
ground: g()
|
|
71
|
+
};
|
|
72
|
+
let t = Math.floor(e.getZoom()), n = e.mapStyle.dn(30001, 1, t), r = n?.faceColor?.rgba || n?.faceColor?.U8t;
|
|
73
|
+
return {
|
|
74
|
+
zoom: t,
|
|
75
|
+
sky: {
|
|
76
|
+
css: h(e.JF?.(t)),
|
|
77
|
+
text: h(e.JF?.(t))
|
|
78
|
+
},
|
|
79
|
+
atmosphere: {
|
|
80
|
+
css: h(e.sX?.(t)),
|
|
81
|
+
text: h(e.sX?.(t))
|
|
82
|
+
},
|
|
83
|
+
ground: {
|
|
84
|
+
css: h(r),
|
|
85
|
+
text: h(r)
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
}, y = (e, t) => {
|
|
89
|
+
let n = e.__vccOpts || e;
|
|
90
|
+
for (let [e, r] of t) n[e] = r;
|
|
91
|
+
return n;
|
|
92
|
+
}, b = { class: "debug-panel" }, x = { class: "debug-row" }, S = { class: "debug-value" }, C = { class: "debug-row" }, w = { class: "debug-value" }, T = { class: "debug-row" }, E = { class: "debug-value" }, D = { class: "debug-controls" }, O = { class: "debug-toggle" }, k = { class: "debug-control" }, A = { class: "debug-control" }, j = { class: "debug-control" }, M = { class: "debug-meta" }, N = /* @__PURE__ */ y({
|
|
93
|
+
__name: "SkyDebugPanel",
|
|
94
|
+
props: {
|
|
95
|
+
map: {
|
|
96
|
+
type: Object,
|
|
97
|
+
default: null
|
|
98
|
+
},
|
|
99
|
+
initialPalette: {
|
|
100
|
+
type: Object,
|
|
101
|
+
default: () => d
|
|
102
|
+
},
|
|
103
|
+
enabledByDefault: {
|
|
104
|
+
type: Boolean,
|
|
105
|
+
default: !0
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
setup(f) {
|
|
109
|
+
let p = f, m = 0, h = a({
|
|
110
|
+
zoom: "-",
|
|
111
|
+
sky: g(),
|
|
112
|
+
atmosphere: g(),
|
|
113
|
+
ground: g()
|
|
114
|
+
}), y = a({
|
|
115
|
+
enabled: p.enabledByDefault,
|
|
116
|
+
...d,
|
|
117
|
+
...p.initialPalette
|
|
118
|
+
}), N = () => {
|
|
119
|
+
p.map && _(p.map, y.value, y.value.enabled);
|
|
120
|
+
}, P = () => {
|
|
121
|
+
p.map && (h.value = v(p.map), m = requestAnimationFrame(P));
|
|
122
|
+
};
|
|
123
|
+
return l(() => p.map, (e) => {
|
|
124
|
+
cancelAnimationFrame(m), e && (N(), P());
|
|
125
|
+
}, { immediate: !0 }), r(() => {
|
|
126
|
+
cancelAnimationFrame(m);
|
|
127
|
+
}), (r, a) => (i(), e("div", b, [
|
|
128
|
+
a[14] ||= t("div", { class: "debug-title" }, "天空调试面板 / Sky Debug", -1),
|
|
129
|
+
a[15] ||= t("div", { class: "debug-summary" }, " 用于覆盖高德内部天空取色逻辑。 `JF` 控制顶部天空,`sX` 控制低缩放大气层,`30001-1` 控制地平线过渡色。 ", -1),
|
|
130
|
+
t("div", x, [t("span", {
|
|
131
|
+
class: "debug-swatch",
|
|
132
|
+
style: n({ background: h.value.sky.css })
|
|
133
|
+
}, null, 4), t("div", null, [
|
|
134
|
+
a[4] ||= t("div", { class: "debug-label" }, "顶部天空 / Top Sky (`JF`)", -1),
|
|
135
|
+
a[5] ||= t("div", { class: "debug-help" }, "高缩放时主要可见,控制天空上半部分主色。", -1),
|
|
136
|
+
t("div", S, o(h.value.sky.text), 1)
|
|
137
|
+
])]),
|
|
138
|
+
t("div", C, [t("span", {
|
|
139
|
+
class: "debug-swatch",
|
|
140
|
+
style: n({ background: h.value.atmosphere.css })
|
|
141
|
+
}, null, 4), t("div", null, [
|
|
142
|
+
a[6] ||= t("div", { class: "debug-label" }, "大气层 / Atmosphere (`sX`)", -1),
|
|
143
|
+
a[7] ||= t("div", { class: "debug-help" }, "低缩放更明显,通常在 `zoom <= 11` 时更容易看到。", -1),
|
|
144
|
+
t("div", w, o(h.value.atmosphere.text), 1)
|
|
145
|
+
])]),
|
|
146
|
+
t("div", T, [t("span", {
|
|
147
|
+
class: "debug-swatch",
|
|
148
|
+
style: n({ background: h.value.ground.css })
|
|
149
|
+
}, null, 4), t("div", null, [
|
|
150
|
+
a[8] ||= t("div", { class: "debug-label" }, "地平线过渡 / Horizon Blend (`30001-1`)", -1),
|
|
151
|
+
a[9] ||= t("div", { class: "debug-help" }, "来自地面主色,会参与天空靠近地面的过渡混色。", -1),
|
|
152
|
+
t("div", E, o(h.value.ground.text), 1)
|
|
153
|
+
])]),
|
|
154
|
+
t("div", D, [
|
|
155
|
+
t("label", O, [u(t("input", {
|
|
156
|
+
"onUpdate:modelValue": a[0] ||= (e) => y.value.enabled = e,
|
|
157
|
+
type: "checkbox",
|
|
158
|
+
onChange: N
|
|
159
|
+
}, null, 544), [[s, y.value.enabled]]), a[10] ||= t("span", null, "启用覆盖 / Enable Override", -1)]),
|
|
160
|
+
t("div", k, [a[11] ||= t("span", { class: "debug-control-label" }, "顶部天空 / Top Sky", -1), u(t("input", {
|
|
161
|
+
"onUpdate:modelValue": a[1] ||= (e) => y.value.sky = e,
|
|
162
|
+
class: "debug-color",
|
|
163
|
+
type: "color",
|
|
164
|
+
onInput: N
|
|
165
|
+
}, null, 544), [[c, y.value.sky]])]),
|
|
166
|
+
t("div", A, [a[12] ||= t("span", { class: "debug-control-label" }, "大气层 / Atmosphere", -1), u(t("input", {
|
|
167
|
+
"onUpdate:modelValue": a[2] ||= (e) => y.value.atmosphere = e,
|
|
168
|
+
class: "debug-color",
|
|
169
|
+
type: "color",
|
|
170
|
+
onInput: N
|
|
171
|
+
}, null, 544), [[c, y.value.atmosphere]])]),
|
|
172
|
+
t("div", j, [a[13] ||= t("span", { class: "debug-control-label" }, "地平线过渡 / Horizon", -1), u(t("input", {
|
|
173
|
+
"onUpdate:modelValue": a[3] ||= (e) => y.value.ground = e,
|
|
174
|
+
class: "debug-color",
|
|
175
|
+
type: "color",
|
|
176
|
+
onInput: N
|
|
177
|
+
}, null, 544), [[c, y.value.ground]])])
|
|
178
|
+
]),
|
|
179
|
+
t("div", M, "当前缩放 / Zoom " + o(h.value.zoom), 1)
|
|
180
|
+
]));
|
|
181
|
+
}
|
|
182
|
+
}, [["__scopeId", "data-v-c91aa86d"]]);
|
|
183
|
+
//#endregion
|
|
184
|
+
export { N as SkyDebugPanel, g as createColorState, d as defaultSkyPalette, m as hexToByteRgba, p as hexToUnitRgba, v as readSkyDebugState, h as rgbaToCss, _ as setFixedSkyColors };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`vue`)):typeof define==`function`&&define.amd?define([`exports`,`vue`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.AmapSkyDebug={},e.Vue))})(this,function(e,t){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var n={sky:`#548cd6`,atmosphere:`#548cd6`,ground:`#0000ff`},r=new WeakMap,i=e=>{if(typeof e!=`string`||!/^#([\da-f]{6})$/i.test(e))return[0,0,0,1];let t=e.slice(1).match(/.{2}/g).map(e=>parseInt(e,16));return[t[0]/255,t[1]/255,t[2]/255,1]},a=e=>{let[t,n,r]=i(e);return[Math.round(t*255),Math.round(n*255),Math.round(r*255),255]},o=e=>{if(!Array.isArray(e)||e.length<4)return`rgba(0, 0, 0, 0)`;let t=e.slice(0,3).map(e=>Math.round(e<=1?e*255:e)),n=e[3]>1?+(e[3]/255).toFixed(3):+e[3].toFixed(3);return`rgba(${t[0]}, ${t[1]}, ${t[2]}, ${n})`},s=(e=`rgba(0, 0, 0, 0)`)=>({css:e,text:e}),c=(e,t=n,o=!0)=>{if(!e?.mapStyle)return;let s=r.get(e);if(s||(s={JF:e.JF.bind(e),sX:e.sX.bind(e),dn:e.mapStyle.dn.bind(e.mapStyle)},r.set(e,s)),!o){e.JF=s.JF,e.sX=s.sX,e.mapStyle.dn=s.dn,e.setNeedUpdate(!0);return}e.JF=()=>i(t.sky),e.sX=()=>i(t.atmosphere),e.mapStyle.dn=(...e)=>{let n=s.dn(...e);if(e[0]===30001&&e[1]===1){let e=a(t.ground),r=i(t.ground);return{...n,faceColor:{...n?.faceColor||{},rgba:e,U8t:r,normalize(){return r}}}}return n},e.setNeedUpdate(!0)},l=e=>{if(!e?.mapStyle?.dn)return{zoom:`-`,sky:s(),atmosphere:s(),ground:s()};let t=Math.floor(e.getZoom()),n=e.mapStyle.dn(30001,1,t),r=n?.faceColor?.rgba||n?.faceColor?.U8t;return{zoom:t,sky:{css:o(e.JF?.(t)),text:o(e.JF?.(t))},atmosphere:{css:o(e.sX?.(t)),text:o(e.sX?.(t))},ground:{css:o(r),text:o(r)}}},u=(e,t)=>{let n=e.__vccOpts||e;for(let[e,r]of t)n[e]=r;return n},d={class:`debug-panel`},f={class:`debug-row`},p={class:`debug-value`},m={class:`debug-row`},h={class:`debug-value`},g={class:`debug-row`},_={class:`debug-value`},v={class:`debug-controls`},y={class:`debug-toggle`},b={class:`debug-control`},x={class:`debug-control`},S={class:`debug-control`},C={class:`debug-meta`};e.SkyDebugPanel=u({__name:`SkyDebugPanel`,props:{map:{type:Object,default:null},initialPalette:{type:Object,default:()=>n},enabledByDefault:{type:Boolean,default:!0}},setup(e){let r=e,i=0,a=(0,t.ref)({zoom:`-`,sky:s(),atmosphere:s(),ground:s()}),o=(0,t.ref)({enabled:r.enabledByDefault,...n,...r.initialPalette}),u=()=>{r.map&&c(r.map,o.value,o.value.enabled)},w=()=>{r.map&&(a.value=l(r.map),i=requestAnimationFrame(w))};return(0,t.watch)(()=>r.map,e=>{cancelAnimationFrame(i),e&&(u(),w())},{immediate:!0}),(0,t.onBeforeUnmount)(()=>{cancelAnimationFrame(i)}),(e,n)=>((0,t.openBlock)(),(0,t.createElementBlock)(`div`,d,[n[14]||=(0,t.createElementVNode)(`div`,{class:`debug-title`},`天空调试面板 / Sky Debug`,-1),n[15]||=(0,t.createElementVNode)(`div`,{class:`debug-summary`}," 用于覆盖高德内部天空取色逻辑。 `JF` 控制顶部天空,`sX` 控制低缩放大气层,`30001-1` 控制地平线过渡色。 ",-1),(0,t.createElementVNode)(`div`,f,[(0,t.createElementVNode)(`span`,{class:`debug-swatch`,style:(0,t.normalizeStyle)({background:a.value.sky.css})},null,4),(0,t.createElementVNode)(`div`,null,[n[4]||=(0,t.createElementVNode)(`div`,{class:`debug-label`},"顶部天空 / Top Sky (`JF`)",-1),n[5]||=(0,t.createElementVNode)(`div`,{class:`debug-help`},`高缩放时主要可见,控制天空上半部分主色。`,-1),(0,t.createElementVNode)(`div`,p,(0,t.toDisplayString)(a.value.sky.text),1)])]),(0,t.createElementVNode)(`div`,m,[(0,t.createElementVNode)(`span`,{class:`debug-swatch`,style:(0,t.normalizeStyle)({background:a.value.atmosphere.css})},null,4),(0,t.createElementVNode)(`div`,null,[n[6]||=(0,t.createElementVNode)(`div`,{class:`debug-label`},"大气层 / Atmosphere (`sX`)",-1),n[7]||=(0,t.createElementVNode)(`div`,{class:`debug-help`},"低缩放更明显,通常在 `zoom <= 11` 时更容易看到。",-1),(0,t.createElementVNode)(`div`,h,(0,t.toDisplayString)(a.value.atmosphere.text),1)])]),(0,t.createElementVNode)(`div`,g,[(0,t.createElementVNode)(`span`,{class:`debug-swatch`,style:(0,t.normalizeStyle)({background:a.value.ground.css})},null,4),(0,t.createElementVNode)(`div`,null,[n[8]||=(0,t.createElementVNode)(`div`,{class:`debug-label`},"地平线过渡 / Horizon Blend (`30001-1`)",-1),n[9]||=(0,t.createElementVNode)(`div`,{class:`debug-help`},`来自地面主色,会参与天空靠近地面的过渡混色。`,-1),(0,t.createElementVNode)(`div`,_,(0,t.toDisplayString)(a.value.ground.text),1)])]),(0,t.createElementVNode)(`div`,v,[(0,t.createElementVNode)(`label`,y,[(0,t.withDirectives)((0,t.createElementVNode)(`input`,{"onUpdate:modelValue":n[0]||=e=>o.value.enabled=e,type:`checkbox`,onChange:u},null,544),[[t.vModelCheckbox,o.value.enabled]]),n[10]||=(0,t.createElementVNode)(`span`,null,`启用覆盖 / Enable Override`,-1)]),(0,t.createElementVNode)(`div`,b,[n[11]||=(0,t.createElementVNode)(`span`,{class:`debug-control-label`},`顶部天空 / Top Sky`,-1),(0,t.withDirectives)((0,t.createElementVNode)(`input`,{"onUpdate:modelValue":n[1]||=e=>o.value.sky=e,class:`debug-color`,type:`color`,onInput:u},null,544),[[t.vModelText,o.value.sky]])]),(0,t.createElementVNode)(`div`,x,[n[12]||=(0,t.createElementVNode)(`span`,{class:`debug-control-label`},`大气层 / Atmosphere`,-1),(0,t.withDirectives)((0,t.createElementVNode)(`input`,{"onUpdate:modelValue":n[2]||=e=>o.value.atmosphere=e,class:`debug-color`,type:`color`,onInput:u},null,544),[[t.vModelText,o.value.atmosphere]])]),(0,t.createElementVNode)(`div`,S,[n[13]||=(0,t.createElementVNode)(`span`,{class:`debug-control-label`},`地平线过渡 / Horizon`,-1),(0,t.withDirectives)((0,t.createElementVNode)(`input`,{"onUpdate:modelValue":n[3]||=e=>o.value.ground=e,class:`debug-color`,type:`color`,onInput:u},null,544),[[t.vModelText,o.value.ground]])])]),(0,t.createElementVNode)(`div`,C,`当前缩放 / Zoom `+(0,t.toDisplayString)(a.value.zoom),1)]))}},[[`__scopeId`,`data-v-c91aa86d`]]),e.createColorState=s,e.defaultSkyPalette=n,e.hexToByteRgba=a,e.hexToUnitRgba=i,e.readSkyDebugState=l,e.rgbaToCss=o,e.setFixedSkyColors=c});
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@y250031003/amap-sky-debug",
|
|
3
|
+
"private": false,
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist-lib/amap-sky-debug.umd.cjs",
|
|
7
|
+
"module": "./dist-lib/amap-sky-debug.js",
|
|
8
|
+
"types": "./types/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./types/index.d.ts",
|
|
12
|
+
"import": "./dist-lib/amap-sky-debug.js",
|
|
13
|
+
"require": "./dist-lib/amap-sky-debug.umd.cjs"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist-lib",
|
|
18
|
+
"types"
|
|
19
|
+
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"dev": "vite",
|
|
22
|
+
"build": "vue-tsc -b && vite build",
|
|
23
|
+
"build:lib": "vite build --mode lib",
|
|
24
|
+
"prepublishOnly": "npm run build:lib",
|
|
25
|
+
"preview": "vite preview"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@vuemap/vue-amap": "^2.1.17",
|
|
29
|
+
"@vuemap/vue-amap-loca": "^2.1.2",
|
|
30
|
+
"vue": "^3.5.32"
|
|
31
|
+
},
|
|
32
|
+
"peerDependencies": {
|
|
33
|
+
"vue": "^3.5.0"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@types/node": "^24.12.2",
|
|
37
|
+
"@vitejs/plugin-vue": "^6.0.5",
|
|
38
|
+
"@vue/tsconfig": "^0.9.1",
|
|
39
|
+
"typescript": "~6.0.2",
|
|
40
|
+
"vite": "^8.0.4",
|
|
41
|
+
"vue-tsc": "^3.2.6"
|
|
42
|
+
}
|
|
43
|
+
}
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { DefineComponent } from 'vue'
|
|
2
|
+
|
|
3
|
+
export interface SkyPalette {
|
|
4
|
+
sky: string
|
|
5
|
+
atmosphere: string
|
|
6
|
+
ground: string
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface ColorState {
|
|
10
|
+
css: string
|
|
11
|
+
text: string
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface SkyDebugState {
|
|
15
|
+
zoom: number | '-'
|
|
16
|
+
sky: ColorState
|
|
17
|
+
atmosphere: ColorState
|
|
18
|
+
ground: ColorState
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface AMapLike {
|
|
22
|
+
JF: (zoom?: number) => number[]
|
|
23
|
+
sX: (zoom?: number) => number[]
|
|
24
|
+
getZoom: () => number
|
|
25
|
+
setNeedUpdate: (needUpdate: boolean) => void
|
|
26
|
+
mapStyle: {
|
|
27
|
+
dn: (...args: any[]) => any
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface SkyDebugPanelProps {
|
|
32
|
+
map?: AMapLike | null
|
|
33
|
+
initialPalette?: Partial<SkyPalette>
|
|
34
|
+
enabledByDefault?: boolean
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export const defaultSkyPalette: SkyPalette
|
|
38
|
+
|
|
39
|
+
export function hexToUnitRgba(hex: string): number[]
|
|
40
|
+
export function hexToByteRgba(hex: string): number[]
|
|
41
|
+
export function rgbaToCss(rgba: number[]): string
|
|
42
|
+
export function createColorState(css?: string): ColorState
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* 覆写高德 3D 地图内部天空取色逻辑。
|
|
46
|
+
*
|
|
47
|
+
* - `map.JF()`:顶部天空主色
|
|
48
|
+
* - `map.sX()`:大气层底色
|
|
49
|
+
* - `map.mapStyle.dn(30001, 1, zoom).faceColor`:地平线过渡色
|
|
50
|
+
*/
|
|
51
|
+
export function setFixedSkyColors(
|
|
52
|
+
map: AMapLike,
|
|
53
|
+
palette?: Partial<SkyPalette>,
|
|
54
|
+
enabled?: boolean
|
|
55
|
+
): void
|
|
56
|
+
|
|
57
|
+
export function readSkyDebugState(map: AMapLike | null | undefined): SkyDebugState
|
|
58
|
+
|
|
59
|
+
export const SkyDebugPanel: DefineComponent<SkyDebugPanelProps>
|
|
60
|
+
|
|
61
|
+
export default SkyDebugPanel
|