@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.
Files changed (32) hide show
  1. package/README.md +42 -183
  2. package/fesm2022/naniteninja-trait-visual.mjs +2620 -3365
  3. package/fesm2022/naniteninja-trait-visual.mjs.map +1 -1
  4. package/lib/data/bundled-textures.generated.d.ts +3 -0
  5. package/lib/data/nodes.data.d.ts +3 -8
  6. package/lib/data/shader.d.ts +2 -0
  7. package/lib/data/shaders/customPaths.glsl.d.ts +1 -0
  8. package/lib/data/shaders/dyingStarPhase.glsl.d.ts +1 -0
  9. package/lib/data/shaders/galaxyPhase.glsl.d.ts +1 -0
  10. package/lib/data/shaders/nebulaPhase.glsl.d.ts +1 -0
  11. package/lib/objects/Blackhole.d.ts +3 -3
  12. package/lib/objects/Cluster.d.ts +8 -1
  13. package/lib/objects/GalaxyStars.d.ts +1 -0
  14. package/lib/services/black-hole-particle-field.d.ts +26 -2
  15. package/lib/services/galaxyPointCloud.d.ts +10 -0
  16. package/lib/services/node-actions.d.ts +2 -1
  17. package/lib/trait-visual-canvas/trait-visual-canvas.component.d.ts +220 -0
  18. package/lib/{app.types.d.ts → types/app.types.d.ts} +101 -1
  19. package/lib/types/canvas-config.d.ts +181 -0
  20. package/lib/types/node-info.type.d.ts +17 -0
  21. package/lib/types/particle-field.types.d.ts +2 -0
  22. package/lib/utils/createShaderMaterial.d.ts +8 -0
  23. package/lib/utils/createUniforms.d.ts +2 -0
  24. package/lib/utils/debug-ingest.constants.d.ts +2 -0
  25. package/lib/utils/debug-ingest.d.ts +12 -0
  26. package/lib/utils/galaxyGeometryForPhase.d.ts +1 -0
  27. package/lib/utils/window.util.d.ts +2 -2
  28. package/package.json +7 -24
  29. package/public-api.d.ts +9 -11
  30. package/lib/config-sidenav/config-sidenav.component.d.ts +0 -30
  31. package/lib/trait-visual.component.d.ts +0 -85
  32. package/lib/utils/on-right-click.util.d.ts +0 -4
package/README.md CHANGED
@@ -1,216 +1,75 @@
1
- # @naniteninja/trait-visual
1
+ # TraitVisualLib
2
2
 
3
- An Angular library for visualizing trait-based relationships in 3D space using Three.js. This library provides a pure visualization component that can be integrated into any Angular application to display personality traits, preferences, and attributes as an interactive 3D visualization.
3
+ This project was generated using [Angular CLI](https://github.com/angular/angular-cli) version 19.2.0.
4
4
 
5
- ## Installation
5
+ ## Code scaffolding
6
+
7
+ Angular CLI includes powerful code scaffolding tools. To generate a new component, run:
6
8
 
7
9
  ```bash
8
- npm install @naniteninja/trait-visual
10
+ ng generate component component-name
9
11
  ```
10
12
 
11
- ## Requirements
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
- ### 2. Prepare Your Data
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
- ## API Reference
19
+ ## Textures
73
20
 
74
- ### TraitVisualComponent
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
- The main visualization component.
23
+ If you want to override with your own assets, pass `assetsBaseUrl` (e.g. `/assets/`) and serve:
77
24
 
78
- #### Inputs
25
+ - `scale-texture.png`
26
+ - `color-tiles.png`
27
+ - `ani-tiles.exr`
79
28
 
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)
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
- #### Usage
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
- #### IHumanAttributes
33
+ To build the library, run:
113
34
 
114
- ```typescript
115
- interface IHumanAttributes {
116
- [key: string]: number;
117
- }
35
+ ```bash
36
+ ng build trait-visual-lib
118
37
  ```
119
38
 
120
- ### Configuration Utilities
39
+ This command will compile your project, and the build artifacts will be placed in the `dist/` directory.
121
40
 
122
- The library exports utility functions for working with node data:
41
+ ### Publishing the Library
123
42
 
124
- ```typescript
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
- // Get current attribute/preference counts
133
- console.log(dynamicCounts.attributes); // 5
134
- console.log(dynamicCounts.preferences); // 5
45
+ 1. Navigate to the `dist` directory:
46
+ ```bash
47
+ cd dist/trait-visual-lib
48
+ ```
135
49
 
136
- // Update counts
137
- updateCounts(7, 7);
50
+ 2. Run the `npm publish` command to publish your library to the npm registry:
51
+ ```bash
52
+ npm publish
53
+ ```
138
54
 
139
- // Get computed attribute weights from PCA
140
- console.log(attributeWeights);
55
+ ## Running unit tests
141
56
 
142
- // Get default node data (for reference)
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
- ## Features
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
- ## Styling
63
+ ## Running end-to-end tests
192
64
 
193
- The component uses minimal styling. You can style the wrapper element:
65
+ For end-to-end (e2e) testing, run:
194
66
 
195
- ```css
196
- tv-trait-visual {
197
- display: block;
198
- width: 100%;
199
- height: 100%;
200
- }
67
+ ```bash
68
+ ng e2e
201
69
  ```
202
70
 
203
- The canvas will fill its container. Ensure the container has defined dimensions.
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
- ## Author
73
+ ## Additional Resources
215
74
 
216
- naniteninja
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.