Add individuals metadata

This commit is contained in:
MrKBear 2022-02-18 13:36:11 +08:00
parent a3791eecd1
commit b9ffe91f8f
3 changed files with 32 additions and 5 deletions

View File

@ -27,7 +27,7 @@ class ClassicRenderer extends BasicRenderer<{}, IClassicRendererParams> {
*/
private lastScale: number = 0;
private readonly cubeRadius = 2**.5;
private readonly farFogLine = 2.5;
private readonly farFogLine = 2.2;
/**
*

View File

@ -15,11 +15,17 @@ class Group {
*
* @param count
*/
public new(count: number = 1): this {
public new(count: number = 1): Individual {
let newIndividual: Individual | undefined;
for (let i = 0; i < count; i++) {
this.individuals.add(new Individual(this));
newIndividual = new Individual(this);
this.individuals.add(newIndividual);
}
return this;
if (newIndividual) {
return newIndividual;
} else {
return new Individual(this);
}
}
/**
@ -101,7 +107,7 @@ class Group {
}
/**
*
*
* @param
*/
public runner(t: number): void {

View File

@ -1,4 +1,5 @@
import type { Group } from "./Group";
import { ObjectID } from "./Renderer";
/**
*
@ -108,6 +109,26 @@ class Individual {
public distanceTo(position: Individual | number[]): number {
return Individual.vectorLength(this.vectorTo(position));
}
/**
* Behavior 使
*/
private metaData: Map<ObjectID, any> = new Map();
/**
*
*/
public getData<T = any>(key: ObjectID): T {
return this.metaData.get(key);
}
/**
*
*/
public setData<T = any>(key: ObjectID, value: T): T {
this.metaData.set(key, value);
return value;
}
}
export default Individual;