@@ -32,15 +32,34 @@ describe("BufferPolygonCollection", () => {
3232
3333 collection . get ( 0 , polygon ) ;
3434 expect ( polygon . vertexCount , 3 ) ;
35- expect ( polygon . getPositions ( new Float64Array ( 9 ) ) ) . toEqual ( positions1 ) ;
35+ expect ( polygon . getPositions ( ) ) . toEqual ( positions1 ) ;
3636
3737 collection . get ( 1 , polygon ) ;
3838 expect ( polygon . vertexCount , 3 ) ;
39- expect ( polygon . getPositions ( new Float64Array ( 9 ) ) ) . toEqual ( positions2 ) ;
39+ expect ( polygon . getPositions ( ) ) . toEqual ( positions2 ) ;
4040
4141 collection . get ( 2 , polygon ) ;
4242 expect ( polygon . vertexCount , 4 ) ;
43- expect ( polygon . getPositions ( new Float64Array ( 12 ) ) ) . toEqual ( positions3 ) ;
43+ expect ( polygon . getPositions ( ) ) . toEqual ( positions3 ) ;
44+ } ) ;
45+
46+ it ( "outerPositions" , ( ) => {
47+ const collection = new BufferPolygonCollection ( ) ;
48+ const polygon = new BufferPolygon ( ) ;
49+
50+ const positions = new Float64Array ( [
51+ ...createBoxPositions ( 2 ) , // outer loop
52+ ...createBoxPositions ( 1 ) , // hole
53+ ] ) ;
54+ const holes = new Uint32Array ( [ 3 ] ) ;
55+
56+ collection . add ( { positions, holes } , polygon ) ;
57+
58+ expect ( polygon . vertexCount , 6 ) ;
59+ expect ( polygon . holeCount , 1 ) ;
60+ expect ( polygon . outerVertexCount , 3 ) ;
61+ expect ( polygon . getPositions ( ) ) . toEqual ( positions ) ;
62+ expect ( polygon . getOuterPositions ( ) ) . toEqual ( createBoxPositions ( 2 ) ) ;
4463 } ) ;
4564
4665 it ( "holes" , ( ) => {
@@ -71,7 +90,8 @@ describe("BufferPolygonCollection", () => {
7190
7291 collection . get ( 2 , polygon ) ;
7392 expect ( polygon . holeCount , 1 ) ;
74- expect ( polygon . getHoles ( new Uint32Array ( 1 ) ) ) . toEqual ( holes3 ) ;
93+ expect ( polygon . getHoles ( ) ) . toEqual ( holes3 ) ;
94+ expect ( polygon . getHolePositions ( 0 ) ) . toEqual ( createBoxPositions ( 1 ) ) ;
7595 } ) ;
7696
7797 it ( "triangles" , ( ) => {
@@ -96,15 +116,15 @@ describe("BufferPolygonCollection", () => {
96116
97117 collection . get ( 0 , polygon ) ;
98118 expect ( polygon . triangleCount , 2 ) ;
99- expect ( polygon . getTriangles ( new Uint32Array ( 6 ) ) ) . toEqual ( triangles1 ) ;
119+ expect ( polygon . getTriangles ( ) ) . toEqual ( triangles1 ) ;
100120
101121 collection . get ( 1 , polygon ) ;
102122 expect ( polygon . triangleCount , 1 ) ;
103- expect ( polygon . getTriangles ( new Uint32Array ( 3 ) ) ) . toEqual ( triangles2 ) ;
123+ expect ( polygon . getTriangles ( ) ) . toEqual ( triangles2 ) ;
104124
105125 collection . get ( 2 , polygon ) ;
106126 expect ( polygon . triangleCount , 1 ) ;
107- expect ( polygon . getTriangles ( new Uint32Array ( 3 ) ) ) . toEqual ( triangles3 ) ;
127+ expect ( polygon . getTriangles ( ) ) . toEqual ( triangles3 ) ;
108128 } ) ;
109129
110130 it ( "show" , ( ) => {
@@ -219,25 +239,19 @@ describe("BufferPolygonCollection", () => {
219239
220240 dst . get ( 0 , polygon ) ;
221241 expect ( polygon . getColor ( color ) ) . toEqual ( Color . RED ) ;
222- expect ( polygon . getPositions ( new Float64Array ( positions1 . length ) ) ) . toEqual (
223- positions1 ,
224- ) ;
242+ expect ( polygon . getPositions ( ) ) . toEqual ( positions1 ) ;
225243 expect ( polygon . holeCount ) . toBe ( 0 ) ;
226244 expect ( polygon . triangleCount ) . toBe ( 2 ) ;
227245
228246 dst . get ( 1 , polygon ) ;
229247 expect ( polygon . getColor ( color ) ) . toEqual ( Color . GREEN ) ;
230- expect ( polygon . getPositions ( new Float64Array ( positions2 . length ) ) ) . toEqual (
231- positions2 ,
232- ) ;
248+ expect ( polygon . getPositions ( ) ) . toEqual ( positions2 ) ;
233249 expect ( polygon . holeCount ) . toBe ( 0 ) ;
234250 expect ( polygon . triangleCount ) . toBe ( 2 ) ;
235251
236252 dst . get ( 2 , polygon ) ;
237253 expect ( polygon . getColor ( color ) ) . toEqual ( Color . BLUE ) ;
238- expect ( polygon . getPositions ( new Float64Array ( positions3 . length ) ) ) . toEqual (
239- positions3 ,
240- ) ;
254+ expect ( polygon . getPositions ( ) ) . toEqual ( positions3 ) ;
241255 expect ( polygon . holeCount ) . toBe ( 1 ) ;
242256 expect ( polygon . triangleCount ) . toBe ( 2 ) ;
243257 } ) ;
0 commit comments