copper3d 3.10.3 → 3.11.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 +162 -4
- package/ai-index/guides/4D-MRI-LV-rendering.md +580 -0
- package/ai-index/guides/ai-assist-api.md +382 -0
- package/ai-index/guides/camera-framing.md +238 -0
- package/ai-index/guides/control-axes.md +124 -0
- package/ai-index/guides/copper3d-4D-API.md +219 -0
- package/ai-index/guides/copper3d-rendering-optimization.md +155 -0
- package/ai-index/guides/gltf-decoders.md +105 -0
- package/ai-index/guides/heart-sensor.md +137 -0
- package/ai-index/guides/load-callbacks.md +244 -0
- package/ai-index/guides/nrrd-tools.md +1868 -0
- package/ai-index/guides/on-demand-controls.md +154 -0
- package/ai-index/guides/rotation-pivot.md +197 -0
- package/ai-index/guides/scene-resources.md +227 -0
- package/ai-index/guides/segmentation-module.md +1516 -0
- package/ai-index/guides/surface-annotation-api.md +388 -0
- package/ai-index/guides/volume-display.md +194 -0
- package/ai-index/manifest.json +136 -0
- package/ai-index/symbols.json +1 -0
- package/dist/Utils/segmentation/DrawToolCore.d.ts +8 -0
- package/dist/Utils/segmentation/DrawToolCore.js +11 -0
- package/dist/Utils/segmentation/DrawToolCore.js.map +1 -1
- package/dist/Utils/segmentation/NrrdTools.d.ts +8 -0
- package/dist/Utils/segmentation/NrrdTools.js +10 -0
- package/dist/Utils/segmentation/NrrdTools.js.map +1 -1
- package/dist/Utils/segmentation/core/UndoManager.d.ts +12 -1
- package/dist/Utils/segmentation/core/UndoManager.js +33 -17
- package/dist/Utils/segmentation/core/UndoManager.js.map +1 -1
- package/dist/bundle.esm.js +57 -20
- package/dist/bundle.umd.js +57 -20
- package/dist/types/Utils/segmentation/DrawToolCore.d.ts +8 -0
- package/dist/types/Utils/segmentation/NrrdTools.d.ts +8 -0
- package/dist/types/Utils/segmentation/core/UndoManager.d.ts +12 -1
- package/package.json +7 -4
package/README.md
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# copper3d
|
|
2
2
|
|
|
3
|
+
[![CI][ci]][ci-url]
|
|
3
4
|
[![NPM Package][npm]][npm-url]
|
|
4
5
|
[![Read the Docs][readthedocs]][readthedocs-url]
|
|
5
6
|
[![Copper3d Examples][examples]][examples-url]
|
|
@@ -24,6 +25,128 @@ Very old: https://www.npmjs.com/package/gltfloader-plugin-test
|
|
|
24
25
|
|
|
25
26
|
---
|
|
26
27
|
|
|
28
|
+
### AI coding assistants (MCP)
|
|
29
|
+
|
|
30
|
+
copper3d ships a machine-readable index of its own API and guides. Point your AI
|
|
31
|
+
assistant at it through the [`copper3d-mcp`](https://www.npmjs.com/package/copper3d-mcp)
|
|
32
|
+
server and it can look up real signatures instead of inventing them.
|
|
33
|
+
|
|
34
|
+
It reads the index from the copper3d **installed in your project**, so what the
|
|
35
|
+
assistant sees always matches the version you actually depend on.
|
|
36
|
+
|
|
37
|
+
Four read-only tools: `copper3d_search_api`, `copper3d_get_symbol`,
|
|
38
|
+
`copper3d_list_guides`, `copper3d_get_guide`.
|
|
39
|
+
|
|
40
|
+
**Claude Code** — one command, no path needed:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
# just you, in this project
|
|
44
|
+
claude mcp add copper3d -- npx -y copper3d-mcp
|
|
45
|
+
|
|
46
|
+
# commit it to .mcp.json so the whole team gets it on clone
|
|
47
|
+
claude mcp add --scope project copper3d -- npx -y copper3d-mcp
|
|
48
|
+
|
|
49
|
+
# all your projects
|
|
50
|
+
claude mcp add --scope user copper3d -- npx -y copper3d-mcp
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
**Every other client** needs to be told where the project is, because they start
|
|
54
|
+
the server with a working directory that is not your project
|
|
55
|
+
([why](https://github.com/anthropics/claude-code/issues/75266)):
|
|
56
|
+
|
|
57
|
+
| Client | Config file | Root key | Needs `--project` |
|
|
58
|
+
|---|---|---|---|
|
|
59
|
+
| Claude Code | `claude mcp add`, or `.mcp.json` | `mcpServers` | no |
|
|
60
|
+
| Cursor | `.cursor/mcp.json` or `~/.cursor/mcp.json` | `mcpServers` | **yes** |
|
|
61
|
+
| VS Code / Copilot | `.vscode/mcp.json` | **`servers`** | **yes** |
|
|
62
|
+
| Claude Desktop | `%APPDATA%\Claude\claude_desktop_config.json`<br>`~/Library/Application Support/Claude/claude_desktop_config.json` | `mcpServers` | **yes** |
|
|
63
|
+
| Windsurf | `~/.codeium/windsurf/mcp_config.json` | `mcpServers` | **yes** |
|
|
64
|
+
|
|
65
|
+
<details>
|
|
66
|
+
<summary><b>Cursor</b> — <code>.cursor/mcp.json</code></summary>
|
|
67
|
+
|
|
68
|
+
```json
|
|
69
|
+
{
|
|
70
|
+
"mcpServers": {
|
|
71
|
+
"copper3d": {
|
|
72
|
+
"command": "npx",
|
|
73
|
+
"args": ["-y", "copper3d-mcp", "--project", "/absolute/path/to/your/project"]
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
</details>
|
|
80
|
+
|
|
81
|
+
<details>
|
|
82
|
+
<summary><b>VS Code / Copilot</b> — <code>.vscode/mcp.json</code> (note: <code>servers</code>, not <code>mcpServers</code>)</summary>
|
|
83
|
+
|
|
84
|
+
```json
|
|
85
|
+
{
|
|
86
|
+
"servers": {
|
|
87
|
+
"copper3d": {
|
|
88
|
+
"type": "stdio",
|
|
89
|
+
"command": "npx",
|
|
90
|
+
"args": ["-y", "copper3d-mcp", "--project", "${workspaceFolder}"]
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
</details>
|
|
97
|
+
|
|
98
|
+
<details>
|
|
99
|
+
<summary><b>Claude Desktop</b> — <code>claude_desktop_config.json</code></summary>
|
|
100
|
+
|
|
101
|
+
The absolute path is required here: Claude Desktop has no project, and it ignores
|
|
102
|
+
the `cwd` field.
|
|
103
|
+
|
|
104
|
+
```json
|
|
105
|
+
{
|
|
106
|
+
"mcpServers": {
|
|
107
|
+
"copper3d": {
|
|
108
|
+
"command": "npx",
|
|
109
|
+
"args": ["-y", "copper3d-mcp", "--project", "/absolute/path/to/your/project"]
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
</details>
|
|
116
|
+
|
|
117
|
+
<details>
|
|
118
|
+
<summary><b>Windsurf</b> — <code>~/.codeium/windsurf/mcp_config.json</code></summary>
|
|
119
|
+
|
|
120
|
+
```json
|
|
121
|
+
{
|
|
122
|
+
"mcpServers": {
|
|
123
|
+
"copper3d": {
|
|
124
|
+
"command": "npx",
|
|
125
|
+
"args": ["-y", "copper3d-mcp", "--project", "/absolute/path/to/your/project"]
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
</details>
|
|
132
|
+
|
|
133
|
+
**If it does not work**
|
|
134
|
+
|
|
135
|
+
| Symptom | Cause | Fix |
|
|
136
|
+
|---|---|---|
|
|
137
|
+
| Tools never appear in VS Code | Used `mcpServers` in `.vscode/mcp.json` | VS Code calls it `servers` |
|
|
138
|
+
| "AI index was not found" | copper3d not installed, or the client lost the project directory | `npm i copper3d`, then add `--project /abs/path` |
|
|
139
|
+
| Assistant still invents APIs | Server not connected | `claude mcp list`, or your client's MCP panel |
|
|
140
|
+
|
|
141
|
+
You can also skip discovery entirely by setting `COPPER3D_INDEX_PATH` to the
|
|
142
|
+
`node_modules/copper3d/ai-index` directory.
|
|
143
|
+
|
|
144
|
+
**What it does not do.** This is documentation lookup only. copper3d is a browser
|
|
145
|
+
WebGL library and the server is a Node process — it cannot render a scene, run your
|
|
146
|
+
code, or look at a canvas.
|
|
147
|
+
|
|
148
|
+
---
|
|
149
|
+
|
|
27
150
|
### Basic Usage
|
|
28
151
|
|
|
29
152
|
**Load demo**
|
|
@@ -169,9 +292,9 @@ new Copper.NrrdTools(container: HTMLDivElement, options?: { layers?: string[] })
|
|
|
169
292
|
| `options.layers` | `string[]` | `["layer1","layer2","layer3"]` | Named layers to create |
|
|
170
293
|
|
|
171
294
|
```typescript
|
|
172
|
-
// Custom layer set
|
|
295
|
+
// Custom layer set — any names, not just layerN
|
|
173
296
|
const nrrdTools = new Copper.NrrdTools(container, {
|
|
174
|
-
layers: ['
|
|
297
|
+
layers: ['tumour', 'edema', 'necrosis', 'vessel']
|
|
175
298
|
});
|
|
176
299
|
|
|
177
300
|
// Optional: show current slice index in a panel
|
|
@@ -345,6 +468,33 @@ const allChannelVis = nrrdTools.getChannelVisibility();
|
|
|
345
468
|
if (nrrdTools.hasLayerData('layer1')) await saveLayer('layer1');
|
|
346
469
|
```
|
|
347
470
|
|
|
471
|
+
**Reading and replacing a whole layer volume**
|
|
472
|
+
|
|
473
|
+
```typescript
|
|
474
|
+
// Move a mask from layer2 to layer3, undoably
|
|
475
|
+
const voxels = nrrdTools.getLayerVolume('layer2'); // a COPY, or null
|
|
476
|
+
if (voxels) nrrdTools.replaceLayerVolume('layer3', voxels, { undoable: true });
|
|
477
|
+
```
|
|
478
|
+
|
|
479
|
+
`copyLayerData(src, dst)` also copies between layers and is faster, but it writes the target
|
|
480
|
+
buffer directly and leaves nothing for Ctrl+Z. Use it only to mirror a backend cascade; if a
|
|
481
|
+
person triggered the change, go through the pair above.
|
|
482
|
+
|
|
483
|
+
---
|
|
484
|
+
|
|
485
|
+
### Mask render mode — fill or outline
|
|
486
|
+
|
|
487
|
+
```typescript
|
|
488
|
+
nrrdTools.setMaskRenderMode('outline'); // stroke only the boundary
|
|
489
|
+
nrrdTools.setMaskRenderMode('fill'); // paint the silhouette (default)
|
|
490
|
+
```
|
|
491
|
+
|
|
492
|
+
`"outline"` leaves each mask's interior clear so the tissue underneath stays readable. It is a
|
|
493
|
+
display decision only — what is stored, uploaded, exported and undone is the complete mask
|
|
494
|
+
either way — and it applies to every layer and channel at once, repainting immediately. The
|
|
495
|
+
pencil and eraser render the layer filled for the duration of a stroke, so you do not need to
|
|
496
|
+
leave outline mode to annotate.
|
|
497
|
+
|
|
348
498
|
---
|
|
349
499
|
|
|
350
500
|
### 7. Channel Color Customization
|
|
@@ -489,6 +639,9 @@ yourself. It throws on an unknown layer, or a channel outside `[1, 255]`.
|
|
|
489
639
|
| | `isLayerVisible(id)` | Query layer visibility |
|
|
490
640
|
| | `getLayerVisibility()` | All layer visibility map |
|
|
491
641
|
| | `hasLayerData(id)` | Check if layer has non-zero voxels |
|
|
642
|
+
| | `getLayerVolume(id)` | A **copy** of the layer's voxel buffer, or `null` |
|
|
643
|
+
| | `replaceLayerVolume(id, data, opts?)` | Replace the whole buffer; `{ undoable: true }` records one Ctrl+Z step |
|
|
644
|
+
| | `copyLayerData(src, dst)` | Copy voxels between layers — **not** undoable; keeps the target's colour map |
|
|
492
645
|
| | `setLayerOpacity(id, opacity)` | Set per-layer opacity (0.1–1.0), triggers re-render |
|
|
493
646
|
| | `getLayerOpacity(id)` | Read one layer's opacity |
|
|
494
647
|
| | `getLayerOpacityMap()` | All per-layer opacity values |
|
|
@@ -521,6 +674,8 @@ yourself. It throws on an unknown layer, or a channel outside `[1, 255]`.
|
|
|
521
674
|
| | `getBrushSize()` | Read current brush size |
|
|
522
675
|
| | `setPencilColor(hex)` | Set pencil stroke color (hex string) |
|
|
523
676
|
| | `getPencilColor()` | Read current pencil color |
|
|
677
|
+
| | `setMaskRenderMode(mode)` | `"fill"` or `"outline"` for every layer/channel; repaints immediately. Display only — the stored mask is unchanged |
|
|
678
|
+
| | `getMaskRenderMode()` | Read the current render mode |
|
|
524
679
|
| **Contrast** | `setWindowHigh(value)` | Set window high |
|
|
525
680
|
| | `setWindowLow(value)` | Set window low |
|
|
526
681
|
| | `finishWindowAdjustment()` | Repaint all contrast slices after drag ends |
|
|
@@ -586,8 +741,9 @@ interface IKeyBoardSettings {
|
|
|
586
741
|
|
|
587
742
|
interface ICommXYZ { x: number; y: number; z: number; }
|
|
588
743
|
|
|
589
|
-
type LayerId
|
|
590
|
-
type ChannelValue
|
|
744
|
+
type LayerId = 'layer1' | 'layer2' | 'layer3' | 'layer4'; // or any string
|
|
745
|
+
type ChannelValue = number; // 0 = empty/erased, 1..MAX_ENGINE_CHANNEL (255)
|
|
746
|
+
type MaskRenderMode = 'fill' | 'outline';
|
|
591
747
|
```
|
|
592
748
|
|
|
593
749
|
---
|
|
@@ -598,6 +754,8 @@ Special thanks to [Duke University dataset](https://wiki.cancerimagingarchive.ne
|
|
|
598
754
|
|
|
599
755
|
---
|
|
600
756
|
|
|
757
|
+
[ci]: https://github.com/LinkunGao/copper3d_visualisation/actions/workflows/ci.yml/badge.svg?branch=main
|
|
758
|
+
[ci-url]: https://github.com/LinkunGao/copper3d_visualisation/actions/workflows/ci.yml
|
|
601
759
|
[npm]: https://img.shields.io/npm/v/copper3d
|
|
602
760
|
[npm-url]: https://www.npmjs.com/package/copper3d
|
|
603
761
|
[readthedocs]: https://img.shields.io/readthedocs/copper3d_visualisation
|