@naniteninja/trait-visual 1.0.4 → 1.0.7
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 +42 -183
- package/fesm2022/naniteninja-trait-visual.mjs +2620 -3365
- package/fesm2022/naniteninja-trait-visual.mjs.map +1 -1
- package/lib/data/bundled-textures.generated.d.ts +3 -0
- package/lib/data/nodes.data.d.ts +3 -8
- package/lib/data/shader.d.ts +2 -0
- package/lib/data/shaders/customPaths.glsl.d.ts +1 -0
- package/lib/data/shaders/dyingStarPhase.glsl.d.ts +1 -0
- package/lib/data/shaders/galaxyPhase.glsl.d.ts +1 -0
- package/lib/data/shaders/nebulaPhase.glsl.d.ts +1 -0
- package/lib/objects/Blackhole.d.ts +3 -3
- package/lib/objects/Cluster.d.ts +8 -1
- package/lib/objects/GalaxyStars.d.ts +1 -0
- package/lib/services/black-hole-particle-field.d.ts +26 -2
- package/lib/services/galaxyPointCloud.d.ts +10 -0
- package/lib/services/node-actions.d.ts +2 -1
- package/lib/trait-visual-canvas/trait-visual-canvas.component.d.ts +220 -0
- package/lib/{app.types.d.ts → types/app.types.d.ts} +101 -1
- package/lib/types/canvas-config.d.ts +181 -0
- package/lib/types/node-info.type.d.ts +17 -0
- package/lib/types/particle-field.types.d.ts +2 -0
- package/lib/utils/createShaderMaterial.d.ts +8 -0
- package/lib/utils/createUniforms.d.ts +2 -0
- package/lib/utils/debug-ingest.constants.d.ts +2 -0
- package/lib/utils/debug-ingest.d.ts +12 -0
- package/lib/utils/galaxyGeometryForPhase.d.ts +1 -0
- package/lib/utils/window.util.d.ts +2 -2
- package/package.json +7 -24
- package/public-api.d.ts +9 -11
- package/lib/config-sidenav/config-sidenav.component.d.ts +0 -30
- package/lib/trait-visual.component.d.ts +0 -85
- package/lib/utils/on-right-click.util.d.ts +0 -4
package/README.md
CHANGED
|
@@ -1,216 +1,75 @@
|
|
|
1
|
-
#
|
|
1
|
+
# TraitVisualLib
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
This project was generated using [Angular CLI](https://github.com/angular/angular-cli) version 19.2.0.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Code scaffolding
|
|
6
|
+
|
|
7
|
+
Angular CLI includes powerful code scaffolding tools. To generate a new component, run:
|
|
6
8
|
|
|
7
9
|
```bash
|
|
8
|
-
|
|
10
|
+
ng generate component component-name
|
|
9
11
|
```
|
|
10
12
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
- Angular 20.0.0 or higher
|
|
14
|
-
- Three.js (included as dependency)
|
|
15
|
-
- ml-pca (included as dependency)
|
|
16
|
-
|
|
17
|
-
## Quick Start
|
|
18
|
-
|
|
19
|
-
### 1. Import the Component
|
|
20
|
-
|
|
21
|
-
```typescript
|
|
22
|
-
import { TraitVisualComponent } from '@naniteninja/trait-visual';
|
|
23
|
-
|
|
24
|
-
@Component({
|
|
25
|
-
selector: 'app-my-component',
|
|
26
|
-
standalone: true,
|
|
27
|
-
imports: [TraitVisualComponent],
|
|
28
|
-
template: `
|
|
29
|
-
<tv-trait-visual
|
|
30
|
-
[nodeData]="myNodeData"
|
|
31
|
-
[attributeWeights]="myAttributeWeights"
|
|
32
|
-
[preferenceWeights]="myPreferenceWeights"
|
|
33
|
-
></tv-trait-visual>
|
|
34
|
-
`
|
|
35
|
-
})
|
|
36
|
-
export class MyComponent {
|
|
37
|
-
// Your component logic
|
|
38
|
-
}
|
|
39
|
-
```
|
|
13
|
+
For a complete list of available schematics (such as `components`, `directives`, or `pipes`), run:
|
|
40
14
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
```typescript
|
|
44
|
-
import { INodeData } from '@naniteninja/trait-visual';
|
|
45
|
-
|
|
46
|
-
const myNodeData: INodeData[] = [
|
|
47
|
-
{
|
|
48
|
-
id: 1,
|
|
49
|
-
name: 'Central Node',
|
|
50
|
-
initialPosition: [0, 0, 0],
|
|
51
|
-
isSupermassiveBlackhole: true,
|
|
52
|
-
color: '#C300FF',
|
|
53
|
-
attributes: { attr1: 50, attr2: 75, attr3: 25 },
|
|
54
|
-
preferences: { attr1: 100, attr2: 80, attr3: 60 }
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
id: 2,
|
|
58
|
-
name: 'Node 1',
|
|
59
|
-
initialPosition: [5, 0, 0],
|
|
60
|
-
isSupermassiveBlackhole: false,
|
|
61
|
-
color: '#FF3366',
|
|
62
|
-
attributes: { attr1: 0, attr2: 50, attr3: 100 },
|
|
63
|
-
preferences: { attr1: 0, attr2: 0, attr3: 0 }
|
|
64
|
-
}
|
|
65
|
-
// ... more nodes
|
|
66
|
-
];
|
|
67
|
-
|
|
68
|
-
const myAttributeWeights = [1.0, 1.2, 0.8];
|
|
69
|
-
const myPreferenceWeights = [1.0, 1.0, 1.0];
|
|
15
|
+
```bash
|
|
16
|
+
ng generate --help
|
|
70
17
|
```
|
|
71
18
|
|
|
72
|
-
##
|
|
19
|
+
## Textures
|
|
73
20
|
|
|
74
|
-
|
|
21
|
+
The library ships with built-in textures (scale, color tiles, animation tiles). You do not need to serve any texture files for the canvas to work. Leave `assetsBaseUrl` empty or omit it.
|
|
75
22
|
|
|
76
|
-
|
|
23
|
+
If you want to override with your own assets, pass `assetsBaseUrl` (e.g. `/assets/`) and serve:
|
|
77
24
|
|
|
78
|
-
|
|
25
|
+
- `scale-texture.png`
|
|
26
|
+
- `color-tiles.png`
|
|
27
|
+
- `ani-tiles.exr`
|
|
79
28
|
|
|
80
|
-
-
|
|
81
|
-
- `attributeWeights?: number[]` - Weights for attribute calculations (optional)
|
|
82
|
-
- `preferenceWeights?: number[]` - Weights for preference calculations (optional)
|
|
83
|
-
- `attributeCount?: number` - Number of attributes per node (optional)
|
|
84
|
-
- `preferenceCount?: number` - Number of preferences per node (optional)
|
|
29
|
+
Example: `<tv-trait-visual-canvas [config]="config"></tv-trait-visual-canvas>` uses built-in textures; add `assetsBaseUrl="/assets/"` only if you serve custom files at that path.
|
|
85
30
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
```html
|
|
89
|
-
<tv-trait-visual
|
|
90
|
-
[nodeData]="nodeData"
|
|
91
|
-
[attributeWeights]="attributeWeights"
|
|
92
|
-
[preferenceWeights]="preferenceWeights"
|
|
93
|
-
></tv-trait-visual>
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
### Types
|
|
97
|
-
|
|
98
|
-
#### INodeData
|
|
99
|
-
|
|
100
|
-
```typescript
|
|
101
|
-
interface INodeData {
|
|
102
|
-
id: number;
|
|
103
|
-
name: string;
|
|
104
|
-
initialPosition: [number, number, number];
|
|
105
|
-
isSupermassiveBlackhole: boolean;
|
|
106
|
-
color: string;
|
|
107
|
-
attributes: IHumanAttributes; // Record<string, number>
|
|
108
|
-
preferences: IHumanAttributes; // Record<string, number>
|
|
109
|
-
}
|
|
110
|
-
```
|
|
31
|
+
## Building
|
|
111
32
|
|
|
112
|
-
|
|
33
|
+
To build the library, run:
|
|
113
34
|
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
[key: string]: number;
|
|
117
|
-
}
|
|
35
|
+
```bash
|
|
36
|
+
ng build trait-visual-lib
|
|
118
37
|
```
|
|
119
38
|
|
|
120
|
-
|
|
39
|
+
This command will compile your project, and the build artifacts will be placed in the `dist/` directory.
|
|
121
40
|
|
|
122
|
-
|
|
41
|
+
### Publishing the Library
|
|
123
42
|
|
|
124
|
-
|
|
125
|
-
import {
|
|
126
|
-
dynamicCounts,
|
|
127
|
-
updateCounts,
|
|
128
|
-
attributeWeights,
|
|
129
|
-
nodeData
|
|
130
|
-
} from '@naniteninja/trait-visual';
|
|
43
|
+
Once the project is built, you can publish your library by following these steps:
|
|
131
44
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
45
|
+
1. Navigate to the `dist` directory:
|
|
46
|
+
```bash
|
|
47
|
+
cd dist/trait-visual-lib
|
|
48
|
+
```
|
|
135
49
|
|
|
136
|
-
|
|
137
|
-
|
|
50
|
+
2. Run the `npm publish` command to publish your library to the npm registry:
|
|
51
|
+
```bash
|
|
52
|
+
npm publish
|
|
53
|
+
```
|
|
138
54
|
|
|
139
|
-
|
|
140
|
-
console.log(attributeWeights);
|
|
55
|
+
## Running unit tests
|
|
141
56
|
|
|
142
|
-
|
|
143
|
-
console.log(nodeData);
|
|
144
|
-
```
|
|
57
|
+
To execute unit tests with the [Karma](https://karma-runner.github.io) test runner, use the following command:
|
|
145
58
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
- **3D Visualization**: Interactive Three.js-based 3D visualization
|
|
149
|
-
- **PCA-based Positioning**: Nodes are positioned in 3D space using Principal Component Analysis
|
|
150
|
-
- **Dynamic Updates**: Component reacts to input changes via Angular's change detection
|
|
151
|
-
- **Customizable**: Full control over node data, weights, and attributes
|
|
152
|
-
- **Standalone Component**: No additional module setup required
|
|
153
|
-
|
|
154
|
-
## Example: Complete Integration
|
|
155
|
-
|
|
156
|
-
```typescript
|
|
157
|
-
import { Component, OnInit } from '@angular/core';
|
|
158
|
-
import { TraitVisualComponent, INodeData } from '@naniteninja/trait-visual';
|
|
159
|
-
|
|
160
|
-
@Component({
|
|
161
|
-
selector: 'app-personality-visualizer',
|
|
162
|
-
standalone: true,
|
|
163
|
-
imports: [TraitVisualComponent],
|
|
164
|
-
template: `
|
|
165
|
-
<div style="width: 100vw; height: 100vh;">
|
|
166
|
-
<tv-trait-visual
|
|
167
|
-
[nodeData]="nodes"
|
|
168
|
-
[attributeWeights]="attrWeights"
|
|
169
|
-
[preferenceWeights]="prefWeights"
|
|
170
|
-
></tv-trait-visual>
|
|
171
|
-
</div>
|
|
172
|
-
`
|
|
173
|
-
})
|
|
174
|
-
export class PersonalityVisualizerComponent implements OnInit {
|
|
175
|
-
nodes: INodeData[] = [];
|
|
176
|
-
attrWeights: number[] = [1, 1, 1, 1, 1];
|
|
177
|
-
prefWeights: number[] = [1, 1, 1, 1, 1];
|
|
178
|
-
|
|
179
|
-
ngOnInit() {
|
|
180
|
-
// Load or generate your node data
|
|
181
|
-
this.nodes = this.generateNodeData();
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
private generateNodeData(): INodeData[] {
|
|
185
|
-
// Your data generation logic
|
|
186
|
-
return [];
|
|
187
|
-
}
|
|
188
|
-
}
|
|
59
|
+
```bash
|
|
60
|
+
ng test
|
|
189
61
|
```
|
|
190
62
|
|
|
191
|
-
##
|
|
63
|
+
## Running end-to-end tests
|
|
192
64
|
|
|
193
|
-
|
|
65
|
+
For end-to-end (e2e) testing, run:
|
|
194
66
|
|
|
195
|
-
```
|
|
196
|
-
|
|
197
|
-
display: block;
|
|
198
|
-
width: 100%;
|
|
199
|
-
height: 100%;
|
|
200
|
-
}
|
|
67
|
+
```bash
|
|
68
|
+
ng e2e
|
|
201
69
|
```
|
|
202
70
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
## Browser Support
|
|
206
|
-
|
|
207
|
-
- Modern browsers with WebGL support
|
|
208
|
-
- Chrome, Firefox, Safari, Edge (latest versions)
|
|
209
|
-
|
|
210
|
-
## License
|
|
211
|
-
|
|
212
|
-
MIT
|
|
71
|
+
Angular CLI does not come with an end-to-end testing framework by default. You can choose one that suits your needs.
|
|
213
72
|
|
|
214
|
-
##
|
|
73
|
+
## Additional Resources
|
|
215
74
|
|
|
216
|
-
|
|
75
|
+
For more information on using the Angular CLI, including detailed command references, visit the [Angular CLI Overview and Command Reference](https://angular.dev/tools/cli) page.
|