lambda360view 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 +135 -0
- package/dist/index.d.ts +98 -0
- package/dist/index.esm.js +1472 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +1493 -0
- package/dist/index.js.map +1 -0
- package/package.json +54 -0
package/README.md
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
# lambda360view
|
|
2
|
+
|
|
3
|
+
A React component library for displaying 3D CAD-like models with edge rendering, built with [react-three-fiber](https://github.com/pmndrs/react-three-fiber).
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- 📦 Load hierarchical 3D model data (vertices, normals, triangles, edges)
|
|
10
|
+
- 🎨 Per-part color and transparency support
|
|
11
|
+
- ✏️ Edge line rendering for CAD-style visualization
|
|
12
|
+
- 🖱️ Built-in orbit controls (rotate, zoom, pan)
|
|
13
|
+
- 📐 Automatic camera positioning based on bounding box
|
|
14
|
+
- ⚛️ Pure React + TypeScript implementation
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install lambda360view
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### Peer Dependencies
|
|
23
|
+
|
|
24
|
+
Make sure you have these peer dependencies installed:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
npm install react react-dom three @react-three/fiber @react-three/drei
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Usage
|
|
31
|
+
|
|
32
|
+
```tsx
|
|
33
|
+
import { Lambda360View } from 'lambda360view';
|
|
34
|
+
import type { ModelData } from 'lambda360view';
|
|
35
|
+
|
|
36
|
+
// Your model data
|
|
37
|
+
const model: ModelData = {
|
|
38
|
+
version: 3,
|
|
39
|
+
name: "myModel",
|
|
40
|
+
id: "/myModel",
|
|
41
|
+
parts: [
|
|
42
|
+
{
|
|
43
|
+
id: "/myModel/part1",
|
|
44
|
+
name: "part1",
|
|
45
|
+
type: "shapes",
|
|
46
|
+
shape: {
|
|
47
|
+
vertices: new Float32Array([...]),
|
|
48
|
+
normals: new Float32Array([...]),
|
|
49
|
+
triangles: new Uint32Array([...]),
|
|
50
|
+
edges: new Float32Array([...]),
|
|
51
|
+
},
|
|
52
|
+
color: "#ff6600",
|
|
53
|
+
loc: [[0, 0, 0], [0, 0, 0, 1]], // [position, quaternion]
|
|
54
|
+
}
|
|
55
|
+
],
|
|
56
|
+
bb: { xmin: -10, xmax: 10, ymin: -10, ymax: 10, zmin: -10, zmax: 10 },
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
function App() {
|
|
60
|
+
return (
|
|
61
|
+
<Lambda360View
|
|
62
|
+
model={model}
|
|
63
|
+
backgroundColor="#f0f0f0"
|
|
64
|
+
edgeColor="#000000"
|
|
65
|
+
showEdges={true}
|
|
66
|
+
width="100vw"
|
|
67
|
+
height="100vh"
|
|
68
|
+
/>
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Props
|
|
74
|
+
|
|
75
|
+
| Prop | Type | Default | Description |
|
|
76
|
+
|------|------|---------|-------------|
|
|
77
|
+
| `model` | `ModelData` | required | The 3D model data to display |
|
|
78
|
+
| `backgroundColor` | `string` | `"#1a1a2e"` | Canvas background color |
|
|
79
|
+
| `edgeColor` | `string` | `"#000000"` | Color for edge lines |
|
|
80
|
+
| `showEdges` | `boolean` | `true` | Whether to render edges |
|
|
81
|
+
| `width` | `string \| number` | `"100%"` | Container width |
|
|
82
|
+
| `height` | `string \| number` | `"100%"` | Container height |
|
|
83
|
+
| `className` | `string` | - | Additional CSS class |
|
|
84
|
+
| `style` | `CSSProperties` | - | Additional inline styles |
|
|
85
|
+
|
|
86
|
+
## Model Data Format
|
|
87
|
+
|
|
88
|
+
The library accepts a hierarchical model format with the following structure:
|
|
89
|
+
|
|
90
|
+
```typescript
|
|
91
|
+
interface ModelData {
|
|
92
|
+
version: number;
|
|
93
|
+
name: string;
|
|
94
|
+
id: string;
|
|
95
|
+
parts: Part[];
|
|
96
|
+
bb: BoundingBox;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
interface Part {
|
|
100
|
+
id: string;
|
|
101
|
+
name: string;
|
|
102
|
+
type: string;
|
|
103
|
+
shape?: ShapeData;
|
|
104
|
+
color?: string;
|
|
105
|
+
alpha?: number;
|
|
106
|
+
loc?: [[number, number, number], [number, number, number, number]];
|
|
107
|
+
parts?: Part[]; // Nested child parts
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
interface ShapeData {
|
|
111
|
+
vertices: Float32Array; // [x1, y1, z1, x2, y2, z2, ...]
|
|
112
|
+
normals: Float32Array; // [nx1, ny1, nz1, ...]
|
|
113
|
+
triangles: Uint32Array; // Triangle indices
|
|
114
|
+
edges: Float32Array; // Line segment pairs for edges
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## Example
|
|
119
|
+
|
|
120
|
+
See the [examples](./examples) directory for a complete Next.js example displaying a hexapod robot model.
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
# Run the example
|
|
124
|
+
npm install
|
|
125
|
+
npm run build
|
|
126
|
+
cd examples && npm run dev
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## License
|
|
130
|
+
|
|
131
|
+
MIT
|
|
132
|
+
|
|
133
|
+
## Author
|
|
134
|
+
|
|
135
|
+
[lzpel](https://github.com/lzpel)
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import React$1 from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Type definitions for hexapod.js format 3D model data
|
|
5
|
+
*/
|
|
6
|
+
/** Shape data containing geometry information */
|
|
7
|
+
interface ShapeData {
|
|
8
|
+
vertices: Float32Array;
|
|
9
|
+
normals: Float32Array;
|
|
10
|
+
triangles: Uint32Array;
|
|
11
|
+
edges: Float32Array;
|
|
12
|
+
obj_vertices?: Float32Array;
|
|
13
|
+
face_types?: Uint32Array;
|
|
14
|
+
edge_types?: Uint32Array;
|
|
15
|
+
triangles_per_face?: Uint32Array;
|
|
16
|
+
segments_per_edge?: Uint32Array;
|
|
17
|
+
}
|
|
18
|
+
/** Location data: [position, quaternion] */
|
|
19
|
+
type Location = [
|
|
20
|
+
[
|
|
21
|
+
number,
|
|
22
|
+
number,
|
|
23
|
+
number
|
|
24
|
+
],
|
|
25
|
+
[
|
|
26
|
+
number,
|
|
27
|
+
number,
|
|
28
|
+
number,
|
|
29
|
+
number
|
|
30
|
+
]
|
|
31
|
+
];
|
|
32
|
+
/** Individual part in the model hierarchy */
|
|
33
|
+
interface Part {
|
|
34
|
+
id: string;
|
|
35
|
+
name: string;
|
|
36
|
+
type: string;
|
|
37
|
+
subtype?: string;
|
|
38
|
+
shape?: ShapeData;
|
|
39
|
+
color?: string;
|
|
40
|
+
alpha?: number;
|
|
41
|
+
loc?: Location;
|
|
42
|
+
parts?: Part[];
|
|
43
|
+
state?: number[];
|
|
44
|
+
texture?: string | null;
|
|
45
|
+
renderback?: boolean;
|
|
46
|
+
accuracy?: number | null;
|
|
47
|
+
bb?: BoundingBox | null;
|
|
48
|
+
}
|
|
49
|
+
/** Bounding box dimensions */
|
|
50
|
+
interface BoundingBox {
|
|
51
|
+
xmin: number;
|
|
52
|
+
xmax: number;
|
|
53
|
+
ymin: number;
|
|
54
|
+
ymax: number;
|
|
55
|
+
zmin: number;
|
|
56
|
+
zmax: number;
|
|
57
|
+
}
|
|
58
|
+
/** Root model data structure */
|
|
59
|
+
interface ModelData {
|
|
60
|
+
version: number;
|
|
61
|
+
parts: Part[];
|
|
62
|
+
name: string;
|
|
63
|
+
id: string;
|
|
64
|
+
loc?: Location;
|
|
65
|
+
normal_len?: number;
|
|
66
|
+
bb: BoundingBox;
|
|
67
|
+
}
|
|
68
|
+
/** Props for Lambda360View component */
|
|
69
|
+
interface Lambda360ViewProps {
|
|
70
|
+
/** Model data to display */
|
|
71
|
+
model: ModelData;
|
|
72
|
+
/** Background color (default: #1a1a2e) */
|
|
73
|
+
backgroundColor?: string;
|
|
74
|
+
/** Edge color (default: #000000) */
|
|
75
|
+
edgeColor?: string;
|
|
76
|
+
/** Whether to show edges (default: true) */
|
|
77
|
+
showEdges?: boolean;
|
|
78
|
+
/** Canvas width (default: 100%) */
|
|
79
|
+
width?: string | number;
|
|
80
|
+
/** Canvas height (default: 100%) */
|
|
81
|
+
height?: string | number;
|
|
82
|
+
/** Additional className for container */
|
|
83
|
+
className?: string;
|
|
84
|
+
/** Additional style for container */
|
|
85
|
+
style?: React.CSSProperties;
|
|
86
|
+
/** Up axis direction: 'Y' (default), 'Z', or '-Y', '-Z' */
|
|
87
|
+
upAxis?: 'Y' | 'Z' | '-Y' | '-Z';
|
|
88
|
+
/** Use orthographic camera instead of perspective (default: false) */
|
|
89
|
+
orthographic?: boolean;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Lambda360View - A 3D viewer component for CAD-like models with edge display
|
|
94
|
+
*/
|
|
95
|
+
declare const Lambda360View: React$1.FC<Lambda360ViewProps>;
|
|
96
|
+
|
|
97
|
+
export { Lambda360View };
|
|
98
|
+
export type { BoundingBox, Lambda360ViewProps, Location, ModelData, Part, ShapeData };
|