@@ -6,20 +6,20 @@ import {DataMappings, concatenateData, packData} from './DataTools';
66import { vec3 } from 'gl-matrix' ;
77import { DataTexture } from '../renderer/DataTexture' ;
88
9- export enum ClassModes {
9+ export enum HierarchyTypes {
1010 NONE ,
1111 ADD ,
1212}
1313
1414export interface PointOptions {
15- positionClassMode ?: ClassModes
16- radiusClassMode ?: ClassModes
15+ positionClassMode ?: HierarchyTypes
16+ radiusClassMode ?: HierarchyTypes
1717 maxHierarchyDepth ?: number
1818}
1919
2020export interface PointData {
2121 id ?: number | string ;
22- class ?: number | string ;
22+ parentId ?: number | string ;
2323 x : number ;
2424 y : number ;
2525 z ?: number ;
@@ -30,7 +30,7 @@ export type PointDataMappings = DataMappings<PointData>;
3030
3131const kDefaultMappings : PointDataMappings = {
3232 id : ( entry : any , i ) => 'id' in entry ? entry . id : i ,
33- class : ( entry : any ) => entry . class ?? null ,
33+ parentId : ( entry : any ) => entry . parentId ?? null ,
3434 x : ( entry : any ) => entry . x ,
3535 y : ( entry : any ) => entry . y ,
3636 z : ( entry : any ) => 'z' in entry ? entry . z : 0.0 ,
@@ -45,7 +45,7 @@ const kGLTypesPoint: GLDataTypes<PointData> = {
4545} ;
4646
4747const kGLTypesClass : GLDataTypes < PointData > = {
48- class : PicoGL . INT ,
48+ parentId : PicoGL . INT ,
4949} ;
5050
5151export class GraphPoints extends DataTexture {
@@ -61,16 +61,16 @@ export class GraphPoints extends DataTexture {
6161
6262 private _frameBuffer : Framebuffer ;
6363
64- private _classBuffer : ArrayBuffer ;
65- private _classView : DataView ;
66- private _classTexture : Texture ;
64+ private _parentBuffer : ArrayBuffer ;
65+ private _parentView : DataView ;
66+ private _parentTexture : Texture ;
6767 private _pointBuffer : ArrayBuffer ;
6868 private _pointView : DataView ;
6969 private _pointTexture : Texture ;
7070
7171 private _localUniforms = {
72- uPositionClassMode : ClassModes . ADD ,
73- uRadiusClassMode : ClassModes . NONE ,
72+ uPositionHierarchyType : HierarchyTypes . ADD ,
73+ uRadiusHierarchyType : HierarchyTypes . NONE ,
7474 uMaxHierarchyDepth : 100 ,
7575 } ;
7676 private _dataArrayBuffer : Float32Array ;
@@ -80,18 +80,18 @@ export class GraphPoints extends DataTexture {
8080 return this . _length ;
8181 }
8282
83- public get positionClassMode ( ) : ClassModes {
84- return this . _localUniforms . uPositionClassMode ;
83+ public get positionHierarchyType ( ) : HierarchyTypes {
84+ return this . _localUniforms . uPositionHierarchyType ;
8585 }
86- public set positionClassMode ( value : ClassModes ) {
87- this . _localUniforms . uPositionClassMode = value ;
86+ public set positionHierarchyType ( value : HierarchyTypes ) {
87+ this . _localUniforms . uPositionHierarchyType = value ;
8888 }
8989
90- public get radiusClassMode ( ) : ClassModes {
91- return this . _localUniforms . uRadiusClassMode ;
90+ public get radiusHierarchyType ( ) : HierarchyTypes {
91+ return this . _localUniforms . uRadiusHierarchyType ;
9292 }
93- public set radiusClassMode ( value : ClassModes ) {
94- this . _localUniforms . uRadiusClassMode = value ;
93+ public set radiusHierarchyType ( value : HierarchyTypes ) {
94+ this . _localUniforms . uRadiusHierarchyType = value ;
9595 }
9696
9797 public get maxHierarchyDepth ( ) : number {
@@ -120,10 +120,10 @@ export class GraphPoints extends DataTexture {
120120 } ;
121121 this . bbCenter = vec3 . create ( ) ;
122122
123- const [ pointBuffer , classBuffer ] = this . packData ( data , mappings , true , true ) ;
123+ const [ pointBuffer , parentBuffer ] = this . packData ( data , mappings , true , true ) ;
124124
125- this . _classBuffer = classBuffer ;
126- this . _classView = new DataView ( this . _classBuffer ) ;
125+ this . _parentBuffer = parentBuffer ;
126+ this . _parentView = new DataView ( this . _parentBuffer ) ;
127127
128128 this . _pointBuffer = pointBuffer ;
129129 this . _pointView = new DataView ( this . _pointBuffer ) ;
@@ -142,19 +142,19 @@ export class GraphPoints extends DataTexture {
142142 super . destroy ( ) ;
143143 this . map . clear ( ) ;
144144
145- this . _classTexture . delete ( ) ;
145+ this . _parentTexture . delete ( ) ;
146146 this . _pointTexture . delete ( ) ;
147147
148- this . _classBuffer = null ;
148+ this . _parentBuffer = null ;
149149 this . _pointBuffer = null ;
150150 this . _dataArrayBuffer = null ;
151151 this . map = null ;
152152 }
153153
154154 public update ( ) : void {
155155 if ( this . dirty ) {
156- const classInt32 = new Int32Array ( this . _classBuffer ) ;
157- this . _classTexture . data ( classInt32 ) ;
156+ const parentInt32 = new Int32Array ( this . _parentBuffer ) ;
157+ this . _parentTexture . data ( parentInt32 ) ;
158158 const pointFloat32 = new Float32Array ( this . _pointBuffer ) ;
159159 this . _pointTexture . data ( pointFloat32 ) ;
160160
@@ -197,8 +197,8 @@ export class GraphPoints extends DataTexture {
197197 this . _pointView . setFloat32 ( index * 16 + 8 , pointView [ 2 ] , true ) ;
198198 this . _pointView . setFloat32 ( index * 16 + 12 , pointView [ 3 ] , true ) ;
199199
200- const classView = new Int32Array ( classBuffer ) ;
201- this . _classView . setInt32 ( index * 4 , classView [ 0 ] , true ) ;
200+ const parentView = new Int32Array ( classBuffer ) ;
201+ this . _parentView . setInt32 ( index * 4 , parentView [ 0 ] , true ) ;
202202
203203 this . dirty = true ;
204204 }
@@ -209,7 +209,7 @@ export class GraphPoints extends DataTexture {
209209
210210 public addPoints ( data : unknown [ ] , mappings : Partial < PointDataMappings > = { } ) : void {
211211 this . resizeTexture ( this . _length + data . length ) ;
212- const [ pointBuffer , classBuffer ] = this . packData ( data , mappings , false , true ) ;
212+ const [ pointBuffer , parentBuffer ] = this . packData ( data , mappings , false , true ) ;
213213
214214 // create and populate points buffer
215215 const pointBytes = new Uint32Array ( pointBuffer ) ;
@@ -220,14 +220,14 @@ export class GraphPoints extends DataTexture {
220220 pointBytesMerge . set ( pointBytesOld ) ;
221221 pointBytesMerge . set ( pointBytes , pointBytesOld . length ) ;
222222
223- // create and populate class buffer
224- const classBytes = new Uint32Array ( classBuffer ) ;
225- const classBytesOld = new Uint32Array ( this . _classBuffer , 0 , this . _length ) ;
226- this . _classBuffer = new ArrayBuffer ( this . capacity * 4 ) ; // 4 bytes for 1 float
227- this . _classView = new DataView ( this . _classBuffer ) ;
228- const classBytesMerge = new Uint32Array ( this . _classBuffer ) ;
229- classBytesMerge . set ( classBytesOld ) ;
230- classBytesMerge . set ( classBytes , classBytesOld . length ) ;
223+ // create and populate parent buffer
224+ const parentBytes = new Uint32Array ( parentBuffer ) ;
225+ const parentBytesOld = new Uint32Array ( this . _parentBuffer , 0 , this . _length ) ;
226+ this . _parentBuffer = new ArrayBuffer ( this . capacity * 4 ) ; // 4 bytes for 1 float
227+ this . _parentView = new DataView ( this . _parentBuffer ) ;
228+ const parentBytesMerge = new Uint32Array ( this . _parentBuffer ) ;
229+ parentBytesMerge . set ( parentBytesOld ) ;
230+ parentBytesMerge . set ( parentBytes , parentBytesOld . length ) ;
231231
232232 this . _length += data . length ;
233233 this . dirty = true ;
@@ -245,11 +245,11 @@ export class GraphPoints extends DataTexture {
245245 super . resizeTexture ( capacity ) ;
246246 const [ textureWidth , textureHeight ] = this . textureSize ;
247247
248- // resize / create class texture
249- if ( this . _classTexture ) {
250- this . _classTexture . resize ( textureWidth , textureHeight ) ;
248+ // resize / create parent texture
249+ if ( this . _parentTexture ) {
250+ this . _parentTexture . resize ( textureWidth , textureHeight ) ;
251251 } else {
252- this . _classTexture = this . context . createTexture2D ( textureWidth , textureHeight , {
252+ this . _parentTexture = this . context . createTexture2D ( textureWidth , textureHeight , {
253253 internalFormat : PicoGL . R32I ,
254254 } ) ;
255255 }
@@ -278,18 +278,18 @@ export class GraphPoints extends DataTexture {
278278 this . bb . max [ 1 ] = Math . max ( this . bb . max [ 1 ] , entry . y + entry . radius ) ;
279279 this . bb . max [ 2 ] = Math . max ( this . bb . max [ 2 ] , entry . z ) ;
280280 } ) ;
281- const classData = packData ( data , dataMappings , kGLTypesClass , potLength , ( i , entry ) => {
282- if ( entry . class === null ) {
283- entry . class = - 1 ;
281+ const parentData = packData ( data , dataMappings , kGLTypesClass , potLength , ( i , entry ) => {
282+ if ( entry . parentId === null ) {
283+ entry . parentId = - 1 ;
284284 } else {
285- entry . class = this . map . get ( entry . class ) ?? - 1 ;
285+ entry . parentId = this . map . get ( entry . parentId ) ?? - 1 ;
286286 }
287287 } ) ;
288288
289- return [ pointData , classData ] ;
289+ return [ pointData , parentData ] ;
290290 }
291291
292- protected processData ( context : App ) : Texture {
292+ protected processData ( context : App ) : void {
293293 const { gl} = context ;
294294
295295 // resize viewport to data texture size and save original viewport size
@@ -323,12 +323,12 @@ export class GraphPoints extends DataTexture {
323323 . primitive ( PicoGL . TRIANGLE_STRIP ) ;
324324 setDrawCallUniforms ( drawCall , Object . assign ( { } , this . _localUniforms , {
325325 uPointTexture : this . _pointTexture ,
326- uClassTexture : this . _classTexture ,
326+ uParentTexture : this . _parentTexture ,
327327 } ) ) ;
328328 drawCall . draw ( ) ;
329329
330330 // read points texture into stored buffer for point coordinates readback
331- this . readTextureAsync ( this . _frameBuffer . colorAttachments [ 0 ] ) . then ( texArrayBuffer => {
331+ this . readTextureAsync ( this . _texture ) . then ( texArrayBuffer => {
332332 this . _dataArrayBuffer = texArrayBuffer ;
333333 } ) ;
334334
0 commit comments