@@ -10,6 +10,8 @@ suite('loadModel', function() {
1010 const inconsistentColorObjFile = '/test/unit/assets/eg1.obj' ;
1111 const objMtlMissing = '/test/unit/assets/objMtlMissing.obj' ;
1212 const validSTLfileWithoutExtension = '/test/unit/assets/ascii' ;
13+ const validCubeFile = '/test/unit/assets/cube.obj' ;
14+ const negativeIndexCubeFile = '/test/unit/assets/cube-negative-indices.obj' ;
1315
1416 beforeAll ( async ( ) => {
1517 loading ( mockP5 , mockP5Prototype ) ;
@@ -115,4 +117,20 @@ suite('loadModel', function() {
115117 const model = await mockP5Prototype . loadModel ( validSTLfileWithoutExtension , '.STL' ) ;
116118 assert . instanceOf ( model , Geometry ) ;
117119 } ) ;
120+
121+ test ( 'OBJ with negative vertex indices loads correctly' , async function ( ) {
122+ const model = await mockP5Prototype . loadModel ( negativeIndexCubeFile ) ;
123+ assert . instanceOf ( model , Geometry ) ;
124+ assert . isAbove ( model . vertices . length , 0 , 'Model should have vertices' ) ;
125+ assert . isAbove ( model . faces . length , 0 , 'Model should have faces' ) ;
126+ } ) ;
127+
128+ test ( 'OBJ negative indices produce same geometry as positive' , async function ( ) {
129+ const positiveModel = await mockP5Prototype . loadModel ( validCubeFile ) ;
130+ const negativeModel = await mockP5Prototype . loadModel ( negativeIndexCubeFile ) ;
131+ assert . equal ( positiveModel . vertices . length , negativeModel . vertices . length ,
132+ 'Vertex count should match' ) ;
133+ assert . equal ( positiveModel . faces . length , negativeModel . faces . length ,
134+ 'Face count should match' ) ;
135+ } ) ;
118136} ) ;
0 commit comments