@@ -127,6 +127,35 @@ test('ExtrusionGeometry produces the same ring for every point on the path', ()
127127 expect ( secondRing ) . toEqual ( firstRing ) ;
128128} ) ;
129129
130+ test ( 'ExtrusionGeometry produces identical rings across instances' , ( ) => {
131+ // The trig table is cached at module level and shared between instances, so
132+ // two geometries with the same radialSegments must produce identical rings.
133+ const radialSegments = 4 ;
134+ const ring = ( radialSegments + 1 ) * 3 ;
135+ const points = [ new Vector3 ( 0 , 0 , 0 ) , new Vector3 ( 1 , 0 , 0 ) ] ;
136+ const first = new ExtrusionGeometry ( points , 0.6 , 0.2 , radialSegments ) ;
137+ const second = new ExtrusionGeometry ( points , 0.6 , 0.2 , radialSegments ) ;
138+
139+ const firstRing = Array . from ( first . attributes . normal . array . slice ( 0 , ring ) ) ;
140+ const secondRing = Array . from ( second . attributes . normal . array . slice ( 0 , ring ) ) ;
141+
142+ expect ( secondRing ) . toEqual ( firstRing ) ;
143+ } ) ;
144+
145+ test ( 'ExtrusionGeometry builds a distinct ring per radialSegments value' , ( ) => {
146+ // A different radialSegments takes the cache-miss path and yields its own
147+ // table rather than reusing another entry.
148+ const points = [ new Vector3 ( 0 , 0 , 0 ) , new Vector3 ( 1 , 0 , 0 ) ] ;
149+ const coarse = new ExtrusionGeometry ( points , 0.6 , 0.2 , 3 ) ;
150+ const fine = new ExtrusionGeometry ( points , 0.6 , 0.2 , 5 ) ;
151+
152+ expect ( coarse . attributes . normal . count ) . toBe ( ( points . length + 1 ) * 4 ) ;
153+ expect ( fine . attributes . normal . count ) . toBe ( ( points . length + 1 ) * 6 ) ;
154+ expect ( Array . from ( coarse . attributes . normal . array . slice ( 0 , 12 ) ) ) . not . toEqual (
155+ Array . from ( fine . attributes . normal . array . slice ( 0 , 12 ) )
156+ ) ;
157+ } ) ;
158+
130159test ( 'ExtrusionGeometry orients each corner independently' , ( ) => {
131160 // The corner vectors are scratch objects shared between points, so stale
132161 // state from one point leaking into the next would show up as a corner
0 commit comments