@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 CHANGED
@@ -1,216 +1,73 @@
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
73
-
74
- ### TraitVisualComponent
75
-
76
- The main visualization component.
19
+ ## Host app assets
77
20
 
78
- #### Inputs
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
- ### Types
23
+ - `scale-texture.png`
24
+ - `color-tiles.png`
25
+ - `ani-tiles.exr`
97
26
 
98
- #### INodeData
27
+ Example: `<tv-trait-visual-canvas [config]="config" assetsBaseUrl="/assets/"></tv-trait-visual-canvas>` if the host serves them from `/assets/`.
99
28
 
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
- ```
29
+ ## Building
111
30
 
112
- #### IHumanAttributes
31
+ To build the library, run:
113
32
 
114
- ```typescript
115
- interface IHumanAttributes {
116
- [key: string]: number;
117
- }
33
+ ```bash
34
+ ng build trait-visual-lib
118
35
  ```
119
36
 
120
- ### Configuration Utilities
37
+ This command will compile your project, and the build artifacts will be placed in the `dist/` directory.
121
38
 
122
- The library exports utility functions for working with node data:
39
+ ### Publishing the Library
123
40
 
124
- ```typescript
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
- // Get current attribute/preference counts
133
- console.log(dynamicCounts.attributes); // 5
134
- console.log(dynamicCounts.preferences); // 5
43
+ 1. Navigate to the `dist` directory:
44
+ ```bash
45
+ cd dist/trait-visual-lib
46
+ ```
135
47
 
136
- // Update counts
137
- updateCounts(7, 7);
48
+ 2. Run the `npm publish` command to publish your library to the npm registry:
49
+ ```bash
50
+ npm publish
51
+ ```
138
52
 
139
- // Get computed attribute weights from PCA
140
- console.log(attributeWeights);
53
+ ## Running unit tests
141
54
 
142
- // Get default node data (for reference)
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
- ## 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
- }
57
+ ```bash
58
+ ng test
189
59
  ```
190
60
 
191
- ## Styling
61
+ ## Running end-to-end tests
192
62
 
193
- The component uses minimal styling. You can style the wrapper element:
63
+ For end-to-end (e2e) testing, run:
194
64
 
195
- ```css
196
- tv-trait-visual {
197
- display: block;
198
- width: 100%;
199
- height: 100%;
200
- }
65
+ ```bash
66
+ ng e2e
201
67
  ```
202
68
 
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
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
- ## Author
71
+ ## Additional Resources
215
72
 
216
- naniteninja
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.