# @geoql/maplibre-gl-starfield 中文文档

规范地址：https://npmcn.com/package/%40geoql/maplibre-gl-starfield/

版本：0\.1\.4
npm 元数据更新时间：2026-10-29T12:55:02.346Z
中文译文更新时间：2026-11-16T04:56:24.753Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40geoql/maplibre-gl-starfield
原文对照：https://npmcn.com/package/%40geoql/maplibre-gl-starfield/?lang=original
项目主页：https://maplibre-gl-starfield.geoql.in/
源码仓库：https://github.com/geoql/maplibre-gl-starfield

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：64.6 kB，7 个文件
- 模块格式：ES Module
- TypeScript 类型：包内自带
- Node.js 要求：\>=24\.0\.0
- 运行依赖：0 个
- peer 依赖：three \>=0\.135\.0，maplibre-gl \>=3\.0\.0
- 首次发布：2026-02-07T22:49:16.300Z
- 最新版本发布：2026-10-29T12:55:01.580Z
- 近 30 天下载量：2477（2026-10-16 至 2026-11-14，npm 官方下载统计）
- 已发布版本数：7（近 12 个月 7 个）

## 中文简介

一个 MapLibre GL JS 自定义层,用于渲染一个带有银河系全景的 Three.js Starfield 天盒

## 安装

```sh
npm install @geoql/maplibre-gl-starfield
```

也可以使用：`pnpm add @geoql/maplibre-gl-starfield`、`yarn add @geoql/maplibre-gl-starfield`、`bun add @geoql/maplibre-gl-starfield`

## README

# @geoql/ maplibre-gl-starfield (英语)

三.js 星地天盒自定义层 [MapLibre GL 联合来文](https://maplibre.org/) 地球预测.

[![npm version](https://img.shields.io/npm/v/@geoql/maplibre-gl-starfield.svg)](https://www.npmjs.com/package/@geoql/maplibre-gl-starfield) [![JSR](https://jsr.io/badges/@geoql/maplibre-gl-starfield)](https://jsr.io/@geoql/maplibre-gl-starfield) [![npm bundle size](https://img.shields.io/bundlephobia/minzip/@geoql/maplibre-gl-starfield)](https://bundlephobia.com/package/@geoql/maplibre-gl-starfield) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

[![oxlint](https://img.shields.io/badge/linter-oxlint-7c5dfa?logo=oxc)](https://oxc.rs/) [![tsdown](https://img.shields.io/badge/bundler-tsdown-3178c6)](https://tsdown.dev/) [![typescript](https://img.shields.io/npm/dependency-version/@geoql/maplibre-gl-starfield/dev/typescript?logo=TypeScript)](https://www.typescriptlang.org/)

**[现场演示](https://maplibre-gl-starfield.geoql.in/?utm_source=github&utm_medium=readme&utm_campaign=maplibre-gl-starfield)** • 妇女 [无](https://www.npmjs.com/package/@geoql/maplibre-gl-starfield) • 妇女 [日 尔](https://jsr.io/@geoql/maplibre-gl-starfield)

将可选的等角星系/密道全景纹理与可配置的亮度相接,再用添加剂混合成上千个个点星. 适合需要类似空间背景的地球投影图——地震可视化,卫星跟踪仪,飞行路径等等.

## 安装

```bash
# npm
npm install @geoql/maplibre-gl-starfield maplibre-gl three

# pnpm
pnpm add @geoql/maplibre-gl-starfield maplibre-gl three

# yarn
yarn add @geoql/maplibre-gl-starfield maplibre-gl three

# JSR
pnpm dlx jsr add @geoql/maplibre-gl-starfield
```

## 使用量

```typescript
import * as maplibregl from 'maplibre-gl';
import { MaplibreStarfieldLayer } from '@geoql/maplibre-gl-starfield';
import 'maplibre-gl/dist/maplibre-gl.css';

const map = new maplibregl.Map({
  container: 'map',
  style: {
    version: 8,
    projection: { type: 'globe' },
    sources: {
      satellite: {
        type: 'raster',
        tiles: [
          'https://tiles.maps.eox.at/wmts/1.0.0/s2cloudless-2020_3857/default/g/{z}/{y}/{x}.jpg',
        ],
        tileSize: 256,
        attribution: '© EOX IT Services GmbH - S2 Cloudless',
      },
    },
    layers: [{ id: 'satellite', type: 'raster', source: 'satellite' }],
  },
  center: [0, 20],
  zoom: 1.5,
});

map.on('load', () => {
  const starfield = new MaplibreStarfieldLayer({
    galaxyTextureUrl: '/milkyway.jpg', // your panorama image
    galaxyBrightness: 0.35,
    starCount: 4000,
    starSize: 2.0,
  });

  // Add below all other layers so stars render behind the globe
  map.addLayer(starfield, map.getStyle().layers[0]?.id);
});
```

## 选项

```typescript
interface MaplibreStarfieldLayerOptions {
  id?: string;
  starCount?: number;
  starSize?: number;
  starColor?: number;
  galaxyTextureUrl?: string;
  galaxyBrightness?: number;
}
```

| 选项 | 类型 | 默认 | 说明 |
| --- | --- | --- | --- |
| `id` | `string` | `'starfield'` | 独特的层 ID |
| `starCount` | `number` | `4000` | 单个点星数 |
| `starSize` | `number` | `2.0` | 恒星基点大小(随机±60%) |
| `starColor` | `number` | `0xffffff` | 点星的正弦颜色 |
| `galaxyTextureUrl` | `string` | `undefined` | URL 到正方形全景图像 。 如果省去,则只让点星渲染出. |
| `galaxyBrightness` | `number` | `0.35` | 银河纹理的亮度乘以 (0-1) |

## 银河纹理

这个图书馆的确是 **没有** 捆绑一个银河系图像。 您需要通过 `galaxyTextureUrl`。 。 。 .

一个伟大的自由选择是 **ESO/S. Brunier 银河全景** (单位:千美元)[来源](https://www.eso.org/public/images/eso0932a/)),根据 [CC BY 4.0 (英语)](https://creativecommons.org/licenses/by/4.0/)。为了在质量和文件大小方面保持良好的平衡,下载并调整大小为~4096x2048:

```bash
# Download the 6000×3000 original (8 MB)
curl -o milkyway_full.jpg "https://cdn.eso.org/images/large/eso0932a.jpg"

# Resize to 4096×2048 (~3 MB)
sips --resampleWidth 4096 milkyway_full.jpg --out public/milkyway.jpg
```

> **归属**:ESO/S.布鲁尼尔 - [CC BY 4.0 (英语)](https://creativecommons.org/licenses/by/4.0/)

## 如何运作

该图层执行 MapLibre 的 `CustomLayerInterface` 并和 MapLibre 共享 WebGL 上下文 :

1.  **银河系** -一个三.js `SphereGeometry` 与 `BackSide` 渲染, 以全景图像纹理 。 通过顶点遮蔽术在接近无限深度的地方被渲染出.
2.  **点星** (单位:千美元) `Points` 以天然发光的添加剂混合制成.
3.  **相机同步** ——投影矩阵从MapLibre的模型-视图-投影矩阵中分解出,并脱去翻译,因此无论缩放/平放,天盒都保持无限.

## 出口

```typescript
// Main class
export { MaplibreStarfieldLayer } from '@geoql/maplibre-gl-starfield';

// Default export (same class)
export { default } from '@geoql/maplibre-gl-starfield';

// Types
export type { MaplibreStarfieldLayerOptions } from '@geoql/maplibre-gl-starfield';
```

## 所需资源

-   MapLibre GL 联合来文
-   三.js 0.135.0 (韩语)
-   节点.js 24.0.0

## 捐款

1.  叉并创建特性分支从 `main`
2.  以下更改 [常规承诺](https://www.conventionalcommits.org/)
3.  确保承诺得到签署([为什么?](https://withblue.ink/2020/05/17/how-and-why-to-sign-git-commits.html)(中文(简体) )
4.  提交 PR

```bash
pnpm install
pnpm run build
pnpm run lint
pnpm run typecheck
```

演示会住在这里 `example/` 并运行在云浮工人在 [马图利布尔-gl-starfield.geoql.in](https://maplibre-gl-starfield.geoql.in/)。使用节点 26 或后会.

```bash
pnpm run dev:demo     # local dev server
pnpm run build:demo   # build the library, then the demo
pnpm run deploy:demo  # build and deploy the Worker (needs wrangler login)
```

## 更多来自作者

-   [映射- gl- snow](https://maplibre-gl-snow.geoql.in/?utm_source=github&utm_medium=readme&utm_campaign=maplibre-gl-starfield) — WebGPU 雪粒层
-   [映射- gl- 风](https://maplibre-gl-wind.geoql.in/?utm_source=github&utm_medium=readme&utm_campaign=maplibre-gl-starfield) ——风粒子动画层
-   [映射- gl- 比较](https://maplibre-gl-compare.geoql.in/?utm_source=github&utm_medium=readme&utm_campaign=maplibre-gl-starfield) ——刷卡式地图对比控制
-   [映射- gl- 检查](https://maplibre-gl-inspect.geoql.in/?utm_source=github&utm_medium=readme&utm_campaign=maplibre-gl-starfield) 检查矢量瓦片特征及其属性
-   [v 地图](https://v-maplibre.geoql.in/?utm_source=github&utm_medium=readme&utm_campaign=maplibre-gl-starfield) 用于 MapLibre GL 的 50+ Vue 3 组件
-   [映射图](https://mapcn-vue.geoql.in/?utm_source=github&utm_medium=readme&utm_campaign=maplibre-gl-starfield) 复制到应用程序中的 shadcn- vue 映射组件

见每个项目 [vinayakkulkarni.dev/项目](https://vinayakkulkarni.dev/projects?utm_source=github&utm_medium=readme&utm_campaign=maplibre-gl-starfield) 财务报告和审定财务报表 [地理单位](https://geoql.in/?utm_source=github&utm_medium=readme&utm_campaign=maplibre-gl-starfield)。 。 。 .

## 许可证

[麻省理工学院](https://npmcn.com/package/%40geoql/maplibre-gl-starfield/LICENSE)

## 常见问题

### @geoql/maplibre-gl-starfield 是什么？

一个 MapLibre GL JS 自定义层,用于渲染一个带有银河系全景的 Three\.js Starfield 天盒

### 如何安装 @geoql/maplibre-gl-starfield？

在项目目录运行 npm install @geoql/maplibre-gl-starfield，或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖：three（\>=0\.135\.0）、maplibre-gl（\>=3\.0\.0）。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖，Yarn 需要手动安装。

### @geoql/maplibre-gl-starfield 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @geoql/maplibre-gl-starfield 支持 ESM 还是 CommonJS？

以 ES Module 形式发布，推荐使用 import 引入。在 CommonJS 项目中，Node\.js 20\.19\+ / 22\.12\+ 可以直接 require\(\) 不含顶层 await 的 ES Module，更早的版本需要改用动态 import\(\)。

### @geoql/maplibre-gl-starfield 需要什么版本的 Node\.js？

package\.json 的 engines 字段要求 Node\.js \>=24\.0\.0。版本不符时 npm 默认只给出警告，开启 engine-strict 后会拒绝安装。

### @geoql/maplibre-gl-starfield 可以商用吗？

@geoql/maplibre-gl-starfield 使用 MIT 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @geoql/maplibre-gl-starfield 的下载量有多少？

根据 npm 官方下载统计，@geoql/maplibre-gl-starfield 在 2026/10/16 – 2026/11/14 这 30 天内被下载 2,477 次，日均约 83 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @geoql/maplibre-gl-starfield 还在维护吗？

最新版本 0\.1\.4 发布于 2026/10/29（17 天前）；至今共发布 7 个版本，其中过去 12 个月发布了 7 个；首次发布于 2026/02/08。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

