@@ -41,6 +41,7 @@ setupHTML();
4141
4242const { canvas : expectedCanvas , ctx : expectedCtx } = createCanvas ( ) ;
4343const { canvas : diffCanvas , ctx : diffCtx } = createCanvas ( ) ;
44+ const { canvas : terrainDepthCanvas , ctx : terrainDepthCtx } = createCanvas ( ) ;
4445let map ;
4546
4647tape . onFinish ( ( ) => {
@@ -191,10 +192,11 @@ async function runTest(t) {
191192 // 1. get pixel data from test canvas as Uint8Array
192193 if ( options . output === "terrainDepth" ) {
193194 const pixels = drawTerrainDepth ( map , w , h ) ;
194- actualImageData = Uint8Array . from ( pixels ) ;
195- }
196-
197- if ( ! actualImageData ) {
195+ if ( ! pixels ) {
196+ throw new Error ( 'Failed to render terrain depth, make sure that terrain is enabled on the render test' ) ;
197+ }
198+ actualImageData = Uint8ClampedArray . from ( pixels ) ;
199+ } else {
198200 actualImageData = new Uint8Array ( gl . drawingBufferWidth * gl . drawingBufferHeight * 4 ) ;
199201 gl . readPixels ( 0 , 0 , w , h , gl . RGBA , gl . UNSIGNED_BYTE , actualImageData ) ;
200202
@@ -230,7 +232,17 @@ async function runTest(t) {
230232 }
231233
232234 let fileInfo ;
233- const actual = map . getCanvas ( ) . toDataURL ( ) ;
235+ let actual ;
236+
237+ if ( options . output === "terrainDepth" ) {
238+ terrainDepthCanvas . width = w ;
239+ terrainDepthCanvas . height = h ;
240+ const terrainDepthData = new ImageData ( actualImageData , w , h ) ;
241+ terrainDepthCtx . putImageData ( terrainDepthData , 0 , 0 ) ;
242+ actual = terrainDepthCanvas . toDataURL ( ) ;
243+ } else {
244+ actual = map . getCanvas ( ) . toDataURL ( ) ;
245+ }
234246
235247 if ( process . env . UPDATE ) {
236248 fileInfo = [
0 commit comments