Skip to content

Commit d5832eb

Browse files
committed
feat: some stuff for publishing
1 parent 10331b6 commit d5832eb

4 files changed

Lines changed: 159 additions & 1 deletion

File tree

README.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,94 @@ This application renders interactive 3D plane-mesh wireframe structures with clo
1111
- Responsive design for various screen sizes
1212
- Performance-optimized rendering
1313

14+
## Using as a Package
15+
16+
### Import from Git (Recommended for Development)
17+
18+
You can import this package directly from Git without publishing to npm:
19+
20+
```bash
21+
npm install git+https://github.com/yourusername/toroid-wireframe-clouds.git
22+
```
23+
24+
Or add to your `package.json`:
25+
26+
```json
27+
{
28+
"dependencies": {
29+
"toroid-wireframe-clouds": "git+https://github.com/yourusername/toroid-wireframe-clouds.git"
30+
}
31+
}
32+
```
33+
34+
### Usage Examples
35+
36+
#### Basic Scene Component
37+
38+
```tsx
39+
import { MainScene } from 'toroid-wireframe-clouds';
40+
41+
function App() {
42+
return <MainScene />;
43+
}
44+
```
45+
46+
#### Custom Three.js Scene
47+
48+
```tsx
49+
import { ThreeScene, type SceneParameters } from 'toroid-wireframe-clouds';
50+
51+
function MyScene() {
52+
const parameters: SceneParameters = {
53+
gridWidth: 10,
54+
gridHeight: 10,
55+
arcReach: 0.5,
56+
twistX: 45,
57+
twistY: 30,
58+
twistZ: 15,
59+
twistNoise: 0.2,
60+
cameraPositionX: 0,
61+
cameraPositionY: 0,
62+
cameraPositionZ: 10,
63+
cameraTargetX: 0,
64+
cameraTargetY: 0,
65+
cameraTargetZ: 0,
66+
};
67+
68+
return (
69+
<ThreeScene
70+
parameters={parameters}
71+
onCameraStateChange={(cameraState) => console.log('Camera:', cameraState)}
72+
/>
73+
);
74+
}
75+
```
76+
77+
#### Programmatic Scene Creation
78+
79+
```tsx
80+
import { createScene, type SceneSetup } from 'toroid-wireframe-clouds';
81+
82+
const container = document.getElementById('scene-container');
83+
const sceneSetup: SceneSetup = createScene(container);
84+
85+
// Start animation loop
86+
function animate() {
87+
sceneSetup.animate();
88+
requestAnimationFrame(animate);
89+
}
90+
animate();
91+
92+
// Cleanup when done
93+
sceneSetup.cleanup();
94+
```
95+
96+
### Available Exports
97+
98+
- **Components**: `MainScene`, `ThreeScene`, `SceneForm`, `StatsOverlay`, `DrawCallsOverlay`
99+
- **Functions**: `createScene`
100+
- **Types**: `SceneParameters`, `CameraState`, `SceneSetup`
101+
14102
## Getting Started
15103

16104
### Prerequisites
@@ -40,6 +128,12 @@ This application renders interactive 3D plane-mesh wireframe structures with clo
40128
npm run build
41129
```
42130

131+
### Building Library Distribution
132+
133+
```bash
134+
npm run build:lib
135+
```
136+
43137
The built files will be in the `dist` directory, ready for deployment.
44138

45139
## Project Structure

package.json

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,23 @@
11
{
22
"name": "toroid-wireframe-clouds",
3-
"private": true,
43
"version": "0.0.0",
54
"type": "module",
5+
"main": "./dist/index.js",
6+
"module": "./dist/index.js",
7+
"types": "./dist/index.d.ts",
8+
"exports": {
9+
".": {
10+
"import": "./dist/index.js",
11+
"types": "./dist/index.d.ts"
12+
}
13+
},
14+
"files": [
15+
"dist"
16+
],
617
"scripts": {
718
"dev": "vite",
819
"build": "tsc -b && vite build",
20+
"build:lib": "tsc -p tsconfig.lib.json",
921
"lint": "eslint .",
1022
"preview": "vite preview"
1123
},

src/index.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Main exports for the toroid-wireframe-clouds package
2+
3+
// Core components
4+
export { MainScene } from './layouts/main-scene';
5+
export { ThreeScene } from './components/three-scene';
6+
export { SceneForm } from './components/scene-form';
7+
export { StatsOverlay } from './components/stats-overlay';
8+
export { DrawCallsOverlay } from './components/draw-calls-overlay';
9+
10+
// Scene creation and management
11+
export { createScene } from './layouts/main-scene/scene-initiation';
12+
13+
// Types
14+
export type { SceneSetup, CameraState } from './layouts/main-scene/scene-initiation';
15+
export type { SceneParameters } from './components/scene-form';
16+
17+
// Re-export Three.js for convenience
18+
export * as THREE from 'three';

tsconfig.lib.json

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"outDir": "./dist",
5+
"declaration": true,
6+
"declarationMap": true,
7+
"sourceMap": true,
8+
"module": "ESNext",
9+
"target": "ES2020",
10+
"moduleResolution": "bundler",
11+
"allowImportingTsExtensions": false,
12+
"noEmit": false,
13+
"isolatedModules": true,
14+
"skipLibCheck": true,
15+
"esModuleInterop": true,
16+
"allowSyntheticDefaultImports": true,
17+
"forceConsistentCasingInFileNames": true,
18+
"strict": true,
19+
"jsx": "react-jsx"
20+
},
21+
"include": [
22+
"src/index.ts",
23+
"src/layouts/**/*",
24+
"src/components/**/*"
25+
],
26+
"exclude": [
27+
"node_modules",
28+
"dist",
29+
"src/main.tsx",
30+
"src/App.tsx",
31+
"src/App.css",
32+
"src/index.css"
33+
]
34+
}

0 commit comments

Comments
 (0)