@@ -21,18 +21,18 @@ function distanceBetweenPoints([lon1, lat1, lon2, lat2]: number[]): number {
21
21
22
22
23
23
/**
24
- * Calculate speeds and apply colors to trajectory geometry using a color accessor
24
+ * Calculate speeds and write to numericProps attribute for trajectory geometry
25
25
*/
26
26
export function applyTrajectoryColors (
27
27
geometry : ProcessedGeometry ,
28
- getVertexColor : ( vertexData : { speed : number } , info : { index : number ; data : any [ ] ; target : any [ ] } ) => [ number , number , number , number ]
28
+ getVertexColor ? : ( vertexData : { speed : number } , info : { index : number ; data : any [ ] ; target : any [ ] } ) => [ number , number , number , number ]
29
29
) : void {
30
- // Add new attribute for per-vertex colors
31
- const { positions, attributes} = geometry ;
30
+ const { positions, attributes, numericProps} = geometry ;
32
31
const n = positions . value . length / positions . size ;
33
- attributes . getColor = { value : new Uint8Array ( 4 * n ) , size : 4 , normalized : true } ;
34
32
35
- // Calculate speed and apply colors
33
+ numericProps . speed = { value : new Float32Array ( n ) , size : 1 } ;
34
+
35
+ // Calculate speed and write to numericProps
36
36
let previousSpeed = 0 ;
37
37
38
38
for ( let i = 0 ; i < n ; i ++ ) {
@@ -68,8 +68,7 @@ export function applyTrajectoryColors(
68
68
speed = 100 ; // fallback speed
69
69
}
70
70
71
- // Use the provided color accessor
72
- const color = getVertexColor ( { speed} , { index : i , data : [ ] , target : [ ] } ) ;
73
- attributes . getColor . value . set ( color , 4 * i ) ;
71
+ // Write speed to numericProps
72
+ numericProps . speed . value [ i ] = speed ;
74
73
}
75
74
}
0 commit comments