drone-camera 0.0.0-stage → 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/LICENSE +21 -0
- package/README.md +157 -2
- package/index.d.ts +51 -0
- package/index.d.ts.map +1 -0
- package/index.js +20474 -0
- package/index.js.map +1 -0
- package/index.umd.cjs +1361 -0
- package/index.umd.cjs.map +1 -0
- package/lib/drone-capture-manifest.d.ts +169 -0
- package/lib/drone-capture-manifest.d.ts.map +1 -0
- package/lib/drone-capture-panel.d.ts +135 -0
- package/lib/drone-capture-panel.d.ts.map +1 -0
- package/lib/drone-capture.d.ts +380 -0
- package/lib/drone-capture.d.ts.map +1 -0
- package/lib/drone-cesium-mission.d.ts +120 -0
- package/lib/drone-cesium-mission.d.ts.map +1 -0
- package/lib/drone-cesium-rig.d.ts +50 -0
- package/lib/drone-cesium-rig.d.ts.map +1 -0
- package/lib/drone-cesium.d.ts +519 -0
- package/lib/drone-cesium.d.ts.map +1 -0
- package/lib/drone-control.d.ts +188 -0
- package/lib/drone-control.d.ts.map +1 -0
- package/lib/drone-engine.d.ts +70 -0
- package/lib/drone-engine.d.ts.map +1 -0
- package/lib/drone-exif.d.ts +64 -0
- package/lib/drone-exif.d.ts.map +1 -0
- package/lib/drone-fly.d.ts +545 -0
- package/lib/drone-fly.d.ts.map +1 -0
- package/lib/drone-gallery.d.ts +146 -0
- package/lib/drone-gallery.d.ts.map +1 -0
- package/lib/drone-husky-model.d.ts +22 -0
- package/lib/drone-husky-model.d.ts.map +1 -0
- package/lib/drone-image-utils.d.ts +67 -0
- package/lib/drone-image-utils.d.ts.map +1 -0
- package/lib/drone-image-viewer.d.ts +97 -0
- package/lib/drone-image-viewer.d.ts.map +1 -0
- package/lib/drone-lights.d.ts +194 -0
- package/lib/drone-lights.d.ts.map +1 -0
- package/lib/drone-minimap.d.ts +155 -0
- package/lib/drone-minimap.d.ts.map +1 -0
- package/lib/drone-panel.d.ts +265 -0
- package/lib/drone-panel.d.ts.map +1 -0
- package/lib/drone-panorama-viewer.d.ts +162 -0
- package/lib/drone-panorama-viewer.d.ts.map +1 -0
- package/lib/drone-panorama.d.ts +242 -0
- package/lib/drone-panorama.d.ts.map +1 -0
- package/lib/drone-photogrammetry.d.ts +207 -0
- package/lib/drone-photogrammetry.d.ts.map +1 -0
- package/lib/drone-radar.d.ts +136 -0
- package/lib/drone-radar.d.ts.map +1 -0
- package/lib/drone-reconstruction-preview.d.ts +84 -0
- package/lib/drone-reconstruction-preview.d.ts.map +1 -0
- package/lib/drone-rig.d.ts +385 -0
- package/lib/drone-rig.d.ts.map +1 -0
- package/lib/drone-sim.d.ts +883 -0
- package/lib/drone-sim.d.ts.map +1 -0
- package/lib/drone-stitch.d.ts +84 -0
- package/lib/drone-stitch.d.ts.map +1 -0
- package/lib/drone-world.d.ts +194 -0
- package/lib/drone-world.d.ts.map +1 -0
- package/lib/mission-editor.d.ts +116 -0
- package/lib/mission-editor.d.ts.map +1 -0
- package/lib/mission-panel.d.ts +173 -0
- package/lib/mission-panel.d.ts.map +1 -0
- package/package.json +61 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 chenlong2019
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,158 @@
|
|
|
1
|
-
|
|
1
|
+
<div align="center">
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
# drone-camera
|
|
4
|
+
|
|
5
|
+
**A framework-agnostic drone control library for the browser — one flight core, two renderers (three.js & CesiumJS).**
|
|
6
|
+
|
|
7
|
+
[](https://github.com/chenlong2019/drone-camera/blob/main/LICENSE)
|
|
8
|
+
[](./tsconfig.lib.json)
|
|
9
|
+

|
|
10
|
+

|
|
11
|
+
|
|
12
|
+
[中文文档](https://github.com/chenlong2019/drone-camera/blob/main/README.zh-CN.md)
|
|
13
|
+
|
|
14
|
+
</div>
|
|
15
|
+
|
|
16
|
+
<table>
|
|
17
|
+
<tr>
|
|
18
|
+
<td width="50%"><img src="https://cdn.jsdelivr.net/gh/chenlong2019/drone-camera@main/docs/images/three-follow.jpg" alt="three.js backend: follow camera, flight panel, mini-map" /></td>
|
|
19
|
+
<td width="50%"><img src="https://cdn.jsdelivr.net/gh/chenlong2019/drone-camera@main/docs/images/cesium-mission.jpg" alt="Cesium backend: real-Earth mission editing over satellite imagery" /></td>
|
|
20
|
+
</tr>
|
|
21
|
+
<tr>
|
|
22
|
+
<td align="center"><sub><b>three.js</b> — follow camera, flight panel, mini-map (local sandbox)</sub></td>
|
|
23
|
+
<td align="center"><sub><b>CesiumJS</b> — real-Earth coordinates (ENU/ECEF), in-scene waypoint editing</sub></td>
|
|
24
|
+
</tr>
|
|
25
|
+
</table>
|
|
26
|
+
|
|
27
|
+
## Why
|
|
28
|
+
|
|
29
|
+
Browser drone simulators exist. GIS drones on a 3D globe exist. **One flight core driving both — with a complete camera-to-panorama pipeline — does not.** drone-camera fills that gap:
|
|
30
|
+
|
|
31
|
+
- **One core, two renderers** — the same `DroneSim` flight-state machine (physics, battery, failsafes, geofence, obstacle AABB) drives a three.js WebGPU sandbox *and* a CesiumJS real-Earth backend. Switch backends with a single option; panels, mission editor and mini-map don't change.
|
|
32
|
+
- **Zero-dependency core** — `drone-sim` runs in Node or a Web Worker with no DOM, no three, no browser. Test your flight logic headlessly.
|
|
33
|
+
- **Complete imaging pipeline** — photo/video capture with camera intrinsics, automated panorama flights (wide / 180° / full 360°), pose-based stitching (no feature matching, no OpenCV), an equirectangular viewer, and a capture gallery with EXIF/GPS import for real photos.
|
|
34
|
+
- **AI-ready** — an MCP server exposes 14 `drone_*` tools so an AI agent can fly the drone, edit missions, and take photos. Headless driver included.
|
|
35
|
+
- **Framework-free UI** — panels are plain DOM (Vue/React/svelte/no-framework, all fine). The library itself imports nothing from any UI framework.
|
|
36
|
+
|
|
37
|
+
## Install
|
|
38
|
+
|
|
39
|
+
```sh
|
|
40
|
+
npm install drone-camera three
|
|
41
|
+
# TypeScript users:
|
|
42
|
+
npm install -D @types/three
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
> three.js is a **peer dependency** and stays external in ESM builds, so you never get two copies of three on one page. A UMD build with three bundled is also included (`index.umd.cjs`, exposes `window.DroneControl`).
|
|
46
|
+
|
|
47
|
+
## Quick start (three.js)
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
import * as THREE from 'three'
|
|
51
|
+
import { WebGPURenderer } from 'three/webgpu'
|
|
52
|
+
import { OrbitControls } from 'three/addons/controls/OrbitControls.js'
|
|
53
|
+
import { createDroneControl, DroneControlPanel } from 'drone-camera'
|
|
54
|
+
|
|
55
|
+
const scene = new THREE.Scene()
|
|
56
|
+
const camera = new THREE.PerspectiveCamera(60, innerWidth / innerHeight, 0.1, 4000)
|
|
57
|
+
const renderer = new WebGPURenderer({ antialias: true })
|
|
58
|
+
renderer.setSize(innerWidth, innerHeight)
|
|
59
|
+
document.body.appendChild(renderer.domElement)
|
|
60
|
+
const controls = new OrbitControls(camera, renderer.domElement)
|
|
61
|
+
|
|
62
|
+
// Assembles physics core + vehicle rig + gimbal + night LED lights + ranging radar.
|
|
63
|
+
// No modelUrl → built-in procedural quadcopter (zero assets required).
|
|
64
|
+
const drone = await createDroneControl({ engine: 'three', scene, camera, renderer, controls })
|
|
65
|
+
|
|
66
|
+
// Native DOM panel: arm/takeoff/land, sticks, flight modes, camera views, photo & video.
|
|
67
|
+
new DroneControlPanel(drone)
|
|
68
|
+
|
|
69
|
+
renderer.setAnimationLoop(() => {
|
|
70
|
+
drone.animate()
|
|
71
|
+
if (drone.isOrbitView) controls.update()
|
|
72
|
+
drone.captureRecordingFrame() // gimbal framing for photo/video, no-op otherwise
|
|
73
|
+
drone.onBeforeRender()
|
|
74
|
+
renderer.render(scene, camera)
|
|
75
|
+
drone.onAfterRender()
|
|
76
|
+
})
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Orbit around it, switch to FPV, gimbal it, take a photo — all from the panel. Keyboard flight is built in.
|
|
80
|
+
|
|
81
|
+
## Switch to CesiumJS (same code, real Earth)
|
|
82
|
+
|
|
83
|
+
```ts
|
|
84
|
+
import { createDroneControl, loadCesiumScript } from 'drone-camera'
|
|
85
|
+
|
|
86
|
+
await loadCesiumScript('/Cesium/Cesium.js')
|
|
87
|
+
|
|
88
|
+
// ENU/ECEF earth coordinates; origin altitude auto-sampled from terrain
|
|
89
|
+
const drone = await createDroneControl({ engine: 'cesium', viewer, lon: 116.391, lat: 39.906 })
|
|
90
|
+
|
|
91
|
+
// Same panels — new DroneControlPanel(drone) works unchanged.
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Features
|
|
95
|
+
|
|
96
|
+
| | |
|
|
97
|
+
|---|---|
|
|
98
|
+
| ✈️ Flight core | State machine (disarmed → armed → takeoff → flight → RTH → land), battery model, failsafes, altitude/distance ceilings, obstacle AABB avoidance, event log |
|
|
99
|
+
| 🎮 Control | Stick normalization, keyboard control, motion/normal modes, speed & attitude limits |
|
|
100
|
+
| 🛰 Backends | `three` (WebGPU sandbox) and `cesium` (real Earth) behind one interface — `createDroneControl({ engine })` |
|
|
101
|
+
| 🧊 Vehicle | Procedural built-in quadcopter or any GLB; arms/props/gimbal driven by semantic node names; night LED lights; ranging radar |
|
|
102
|
+
| 📷 Capture | Photo & video with camera pose + intrinsics, gimbal framing, capture sessions |
|
|
103
|
+
| 🌏 Panorama | Auto flight patterns (wide 9-shot / 180° 21-shot / 360°), pose-based stitching to equirectangular, spherical WebGL viewer |
|
|
104
|
+
| 🗺 Missions | In-scene waypoint editing (drag / Shift-altitude / insert / delete), execution, JSON/CSV/Manifest export |
|
|
105
|
+
| 🖥 UI | Plain-DOM flight panel, mission panel, capture panel, mini-map, gallery popups — mount anywhere |
|
|
106
|
+
| 🤖 AI | MCP server with 14 tools + headless CLI driver for scripted/agent flights |
|
|
107
|
+
|
|
108
|
+
## Panorama in three lines
|
|
109
|
+
|
|
110
|
+
```ts
|
|
111
|
+
import { CaptureService, PanoramaCapture } from 'drone-camera'
|
|
112
|
+
|
|
113
|
+
const capture = new CaptureService({ provider: drone }) // drone = your engine host
|
|
114
|
+
const session = capture.createSession({ source: 'virtual-camera', name: 'Around the tower' })
|
|
115
|
+
const pano = new PanoramaCapture(capture)
|
|
116
|
+
await pano.start(session.id, 'pano-360') // body spins for yaw, gimbal stacks pitch rows
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Stitching exploits the fact that every shot's camera pose is known exactly — images are back-projected onto the equirectangular canvas, no feature matching or OpenCV involved.
|
|
120
|
+
|
|
121
|
+
## Documentation
|
|
122
|
+
|
|
123
|
+
Full API reference, generated from the library's own `.d.ts`:
|
|
124
|
+
|
|
125
|
+
- `docs/` route in the demo app — usage guide
|
|
126
|
+
- `api-docs/` route — **1088 documented members** across 24 modules
|
|
127
|
+
- `class-map/` route — interactive architecture map (Vue Flow)
|
|
128
|
+
|
|
129
|
+
## Demo
|
|
130
|
+
|
|
131
|
+
```sh
|
|
132
|
+
npm install
|
|
133
|
+
npm run dev # → /three-demo /cesium-demo /docs /api-docs
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## AI agent mode (MCP)
|
|
137
|
+
|
|
138
|
+
The repo ships `mcp/drone-mcp-server.mjs` — a stdio MCP server exposing the running demo to an AI agent: take off, fly waypoints, edit missions, gimbal, shoot panoramas, read radar, screenshot. Wire it into any MCP client and let the model fly.
|
|
139
|
+
|
|
140
|
+
## Architecture
|
|
141
|
+
|
|
142
|
+
```
|
|
143
|
+
┌───────────────────────── UI (plain DOM, framework-free) ─────────────────────────┐
|
|
144
|
+
│ DroneControlPanel MissionPanel CapturePanel MiniMap Gallery │
|
|
145
|
+
└──────────────────────────────────────┬───────────────────────────────────────────┘
|
|
146
|
+
│ host interfaces (not inheritance)
|
|
147
|
+
┌──────────────────────────────────────┴───────────────────────────────────────────┐
|
|
148
|
+
│ createDroneControl({ engine: 'three' | 'cesium' }) │
|
|
149
|
+
├──────────────────────────────┬────────────────────────────────────────────────────┤
|
|
150
|
+
│ DroneFly (three.js/WebGPU) │ CesiumDroneAdapter (ENU/ECEF real Earth) │
|
|
151
|
+
├──────────────────────────────┴────────────────────────────────────────────────────┤
|
|
152
|
+
│ DroneSim — zero-dependency flight core (Node / Worker / browser) │
|
|
153
|
+
└───────────────────────────────────────────────────────────────────────────────────┘
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## License
|
|
157
|
+
|
|
158
|
+
[MIT](https://github.com/chenlong2019/drone-camera/blob/main/LICENSE)
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 无人机控制系统(Drone Control System)—— 独立 npm 库 / ES6 模块统一入口。
|
|
3
|
+
*
|
|
4
|
+
* 迁移自 first-app 的 src/lib/three-engine,仅取「飞控」相关模块,
|
|
5
|
+
* 不含模型查看器、模型体检、批处理、赛道等其它模块。
|
|
6
|
+
*
|
|
7
|
+
* 设计约定:
|
|
8
|
+
* - 本入口只做「再导出」,不含任何业务装配逻辑,也不引用 Vue —— 整个 src/lib 与框架无关;
|
|
9
|
+
* - `three` 系列模块在 ESM 库构建里全部 external(作为 peerDependency,由使用方提供实例),
|
|
10
|
+
* 避免同一页面出现两份 three 实例(WebGPURenderer 与 TSL 节点会因此彻底失效);
|
|
11
|
+
* - 真正零依赖的只有 `./drone-camera/drone-sim`,可单独在 Node / Web Worker 中运行。
|
|
12
|
+
*
|
|
13
|
+
* 渲染后端(两套实现同一个 DronePanelHost 接口,由 `createDroneControl({ engine })` 装配):
|
|
14
|
+
* - `engine: 'three'` —— DroneFly:three.js + WebGPURenderer 飞行沙盒(缺省)
|
|
15
|
+
* - `engine: 'cesium'` —— CesiumDroneAdapter:地球坐标系(ENU/ECEF)下的飞行
|
|
16
|
+
* 飞行内核都是同一个 DroneSim;控制面板 / 航线面板 / 鹰眼图 / 键盘控制完全不区分后端。
|
|
17
|
+
*
|
|
18
|
+
* 运行期资产(非构建依赖,由使用方自行提供):
|
|
19
|
+
* - `drone-fly.initialize()` 不传 `modelUrl` 时用**内置积木机体**(程序化几何体拼的四轴,
|
|
20
|
+
* 零资产依赖,节点命名与真机 ID 表一致,机臂/桨叶/云台/灯光/雷达全部可用);
|
|
21
|
+
* - 要真机模型就显式传路径:`.initialize({ modelUrl: DRONE_MODEL_URL })`(默认指向
|
|
22
|
+
* `/models/djiair_renamed.glb`)或任意自己的 `.glb`。
|
|
23
|
+
*/
|
|
24
|
+
export * from './lib/drone-sim';
|
|
25
|
+
export * from './lib/drone-control';
|
|
26
|
+
export * from './lib/drone-world';
|
|
27
|
+
export * from './lib/drone-rig';
|
|
28
|
+
export * from './lib/drone-lights';
|
|
29
|
+
export * from './lib/drone-radar';
|
|
30
|
+
export * from './lib/mission-editor';
|
|
31
|
+
export * from './lib/drone-fly';
|
|
32
|
+
export * from './lib/drone-cesium-rig';
|
|
33
|
+
export * from './lib/drone-cesium-mission';
|
|
34
|
+
export * from './lib/drone-cesium';
|
|
35
|
+
export * from './lib/drone-engine';
|
|
36
|
+
export * from './lib/drone-panel';
|
|
37
|
+
export * from './lib/mission-panel';
|
|
38
|
+
export * from './lib/drone-minimap';
|
|
39
|
+
export * from './lib/drone-exif';
|
|
40
|
+
export * from './lib/drone-capture';
|
|
41
|
+
export * from './lib/drone-capture-manifest';
|
|
42
|
+
export * from './lib/drone-capture-panel';
|
|
43
|
+
export * from './lib/drone-gallery';
|
|
44
|
+
export * from './lib/drone-image-utils';
|
|
45
|
+
export * from './lib/drone-image-viewer';
|
|
46
|
+
export * from './lib/drone-panorama-viewer';
|
|
47
|
+
export * from './lib/drone-panorama';
|
|
48
|
+
export * from './lib/drone-stitch';
|
|
49
|
+
export * from './lib/drone-photogrammetry';
|
|
50
|
+
export * from './lib/drone-reconstruction-preview';
|
|
51
|
+
//# sourceMappingURL=index.d.ts.map
|
package/index.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/lib/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAMH,cAAc,0BAA0B,CAAA;AAKxC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,4BAA4B,CAAA;AAC1C,cAAc,0BAA0B,CAAA;AACxC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,4BAA4B,CAAA;AAC1C,cAAc,+BAA+B,CAAA;AAM7C,cAAc,0BAA0B,CAAA;AAexC,cAAc,iCAAiC,CAAA;AAC/C,cAAc,qCAAqC,CAAA;AACnD,cAAc,6BAA6B,CAAA;AAO3C,cAAc,6BAA6B,CAAA;AAM3C,cAAc,4BAA4B,CAAA;AAM1C,cAAc,8BAA8B,CAAA;AAO5C,cAAc,8BAA8B,CAAA;AAwB5C,cAAc,2BAA2B,CAAA;AACzC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,uCAAuC,CAAA;AACrD,cAAc,oCAAoC,CAAA;AAClD,cAAc,8BAA8B,CAAA;AAC5C,cAAc,kCAAkC,CAAA;AAChD,cAAc,mCAAmC,CAAA;AACjD,cAAc,sCAAsC,CAAA;AACpD,cAAc,+BAA+B,CAAA;AAC7C,cAAc,6BAA6B,CAAA;AAC3C,cAAc,qCAAqC,CAAA;AACnD,cAAc,6CAA6C,CAAA"}
|