@@ -83,7 +83,7 @@ abstract class TransitionBase extends SlideChangeGl {
83
83
class Transition2d extends TransitionBase {
84
84
private static readonly DefaultFromColor = new Float32Array ( [ 0 , 0 , 0 , 0 ] ) ;
85
85
private static readonly DefaultToColor = new Float32Array ( [ 0 , 0 , 0 , 0 ] ) ;
86
- private _uniformCache : Record < string , WebGLUniformLocation > = { } ;
86
+ private _uniformCache = new Map < string , WebGLUniformLocation | null > ( ) ;
87
87
88
88
constructor ( transitionParameters : TransitionParameters ) {
89
89
super ( transitionParameters ) ;
@@ -140,15 +140,16 @@ class Transition2d extends TransitionBase {
140
140
gl . bufferData ( gl . ARRAY_BUFFER , positions , gl . STATIC_DRAW ) ;
141
141
}
142
142
143
- private getUniformLocation ( value : string ) {
144
- if ( this . program ) {
145
- if ( ! this . _uniformCache [ value ] )
146
- this . _uniformCache [ value ] = this . gl . getUniformLocation (
147
- this . program ,
148
- value ,
149
- ) ;
150
- return this . _uniformCache [ value ] ;
143
+ private getUniformLocation ( name : string ) : WebGLUniformLocation | null {
144
+ if ( ! this . program ) return null ;
145
+
146
+ if ( this . _uniformCache . has ( name ) ) {
147
+ return this . _uniformCache . get ( name ) ;
151
148
}
149
+
150
+ const loc = this . gl . getUniformLocation ( this . program , name ) ;
151
+ this . _uniformCache . set ( name , loc ) ;
152
+ return loc ;
152
153
}
153
154
154
155
public render ( nT : number , properties ?: AnimatedElementRenderProperties ) {
0 commit comments