@naniteninja/trait-visual 1.0.4 → 1.0.5
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 +41 -184
- package/fesm2022/naniteninja-trait-visual.mjs +1850 -3389
- package/fesm2022/naniteninja-trait-visual.mjs.map +1 -1
- package/lib/data/nodes.data.d.ts +1 -1
- 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 -1
- 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 +19 -1
- package/lib/services/galaxyPointClound.d.ts +11 -0
- package/lib/services/node-actions.d.ts +2 -1
- package/lib/trait-visual-canvas/trait-visual-canvas.component.d.ts +128 -0
- package/lib/{app.types.d.ts → types/app.types.d.ts} +40 -0
- package/lib/types/canvas-config.d.ts +67 -0
- package/lib/utils/createShaderMaterial.d.ts +8 -0
- package/lib/utils/createUniforms.d.ts +2 -0
- package/lib/utils/galaxyGeometryForPhase.d.ts +1 -0
- package/lib/utils/window.util.d.ts +2 -2
- package/package.json +9 -26
- package/public-api.d.ts +6 -11
- package/lib/config-sidenav/config-sidenav.component.d.ts +0 -30
- package/lib/services/stellar-dust-field.d.ts +0 -102
- package/lib/trait-visual.component.d.ts +0 -85
- package/lib/types/dust-field.types.d.ts +0 -61
- package/lib/utils/on-right-click.util.d.ts +0 -4
package/README.md
CHANGED
|
@@ -1,216 +1,73 @@
|
|
|
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
|
-
##
|
|
73
|
-
|
|
74
|
-
### TraitVisualComponent
|
|
75
|
-
|
|
76
|
-
The main visualization component.
|
|
19
|
+
## Host app assets
|
|
77
20
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
- `nodeData: INodeData[]` (required) - Array of node data to visualize
|
|
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)
|
|
85
|
-
|
|
86
|
-
#### Usage
|
|
87
|
-
|
|
88
|
-
```html
|
|
89
|
-
<tv-trait-visual
|
|
90
|
-
[nodeData]="nodeData"
|
|
91
|
-
[attributeWeights]="attributeWeights"
|
|
92
|
-
[preferenceWeights]="preferenceWeights"
|
|
93
|
-
></tv-trait-visual>
|
|
94
|
-
```
|
|
21
|
+
The canvas loads textures from the host app. The host must either serve these files at the root, or pass `assetsBaseUrl` to the component:
|
|
95
22
|
|
|
96
|
-
|
|
23
|
+
- `scale-texture.png`
|
|
24
|
+
- `color-tiles.png`
|
|
25
|
+
- `ani-tiles.exr`
|
|
97
26
|
|
|
98
|
-
|
|
27
|
+
Example: `<tv-trait-visual-canvas [config]="config" assetsBaseUrl="/assets/"></tv-trait-visual-canvas>` if the host serves them from `/assets/`.
|
|
99
28
|
|
|
100
|
-
|
|
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
|
-
```
|
|
29
|
+
## Building
|
|
111
30
|
|
|
112
|
-
|
|
31
|
+
To build the library, run:
|
|
113
32
|
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
[key: string]: number;
|
|
117
|
-
}
|
|
33
|
+
```bash
|
|
34
|
+
ng build trait-visual-lib
|
|
118
35
|
```
|
|
119
36
|
|
|
120
|
-
|
|
37
|
+
This command will compile your project, and the build artifacts will be placed in the `dist/` directory.
|
|
121
38
|
|
|
122
|
-
|
|
39
|
+
### Publishing the Library
|
|
123
40
|
|
|
124
|
-
|
|
125
|
-
import {
|
|
126
|
-
dynamicCounts,
|
|
127
|
-
updateCounts,
|
|
128
|
-
attributeWeights,
|
|
129
|
-
nodeData
|
|
130
|
-
} from '@naniteninja/trait-visual';
|
|
41
|
+
Once the project is built, you can publish your library by following these steps:
|
|
131
42
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
43
|
+
1. Navigate to the `dist` directory:
|
|
44
|
+
```bash
|
|
45
|
+
cd dist/trait-visual-lib
|
|
46
|
+
```
|
|
135
47
|
|
|
136
|
-
|
|
137
|
-
|
|
48
|
+
2. Run the `npm publish` command to publish your library to the npm registry:
|
|
49
|
+
```bash
|
|
50
|
+
npm publish
|
|
51
|
+
```
|
|
138
52
|
|
|
139
|
-
|
|
140
|
-
console.log(attributeWeights);
|
|
53
|
+
## Running unit tests
|
|
141
54
|
|
|
142
|
-
|
|
143
|
-
console.log(nodeData);
|
|
144
|
-
```
|
|
55
|
+
To execute unit tests with the [Karma](https://karma-runner.github.io) test runner, use the following command:
|
|
145
56
|
|
|
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
|
-
}
|
|
57
|
+
```bash
|
|
58
|
+
ng test
|
|
189
59
|
```
|
|
190
60
|
|
|
191
|
-
##
|
|
61
|
+
## Running end-to-end tests
|
|
192
62
|
|
|
193
|
-
|
|
63
|
+
For end-to-end (e2e) testing, run:
|
|
194
64
|
|
|
195
|
-
```
|
|
196
|
-
|
|
197
|
-
display: block;
|
|
198
|
-
width: 100%;
|
|
199
|
-
height: 100%;
|
|
200
|
-
}
|
|
65
|
+
```bash
|
|
66
|
+
ng e2e
|
|
201
67
|
```
|
|
202
68
|
|
|
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
|
|
69
|
+
Angular CLI does not come with an end-to-end testing framework by default. You can choose one that suits your needs.
|
|
213
70
|
|
|
214
|
-
##
|
|
71
|
+
## Additional Resources
|
|
215
72
|
|
|
216
|
-
|
|
73
|
+
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.
|