@@ -15,7 +15,7 @@ export type Buffers = {
1515 index : IndexArray ,
1616 position : Float32Array ,
1717 normal : Float32Array ,
18- uvs : [ Option < Float32Array > , Option < Float32Array > ] ,
18+ uv : Option < Float32Array > ,
1919} ;
2020
2121type BuffersAndSkirt = Buffers & {
@@ -96,28 +96,7 @@ function allocateBuffers(
9696 skirt,
9797 position : new Float32Array ( nVertex * 3 ) ,
9898 normal : new Float32Array ( nVertex * 3 ) ,
99- // 2 UV set per tile: wgs84 (uv[0]) and pseudo-mercator (pm, uv[1])
100- // - wgs84: 1 texture per tile because tiles are using wgs84
101- // projection
102- // - pm: use multiple textures per tile.
103- // +-------------------------+
104- // | |
105- // | Texture 0 |
106- // +-------------------------+
107- // | |
108- // | Texture 1 |
109- // +-------------------------+
110- // | |
111- // | Texture 2 |
112- // +-------------------------+
113- // * u = wgs84.u
114- // * v = textureid + v in builder texture
115- uvs : [
116- cache ?. uv ?? new Float32Array ( nVertex * 2 ) ,
117- builder . computeExtraOffset !== undefined
118- ? new Float32Array ( nVertex )
119- : undefined ,
120- ] ,
99+ uv : cache ?. uv ?? new Float32Array ( nVertex * 2 ) ,
121100 } ;
122101}
123102
@@ -126,12 +105,7 @@ function computeUv0(uv: Float32Array, id: number, u: number, v: number): void {
126105 uv [ id * 2 + 1 ] = v ;
127106}
128107
129- function initComputeUv1 ( value : number ) : ( uv : Float32Array , id : number ) => void {
130- return ( uv : Float32Array , id : number ) : void => { uv [ id ] = value ; } ;
131- }
132-
133- type ComputeUvs =
134- [ typeof computeUv0 | ( ( ) => void ) , ReturnType < typeof initComputeUv1 > ?] ;
108+ type ComputeUvs = typeof computeUv0 ;
135109
136110interface ComputeBuffersParams extends TileBuilderPrepareParams {
137111 center : THREE . Vector3 ;
@@ -172,8 +146,7 @@ export function computeBuffers(
172146 cache ,
173147 ) ;
174148
175- const computeUvs : ComputeUvs =
176- [ cache === undefined ? computeUv0 : ( ) => { } ] ;
149+ const computeUv : ComputeUvs = cache === undefined ? computeUv0 : ( ) => { } ;
177150
178151 const preparedParams = builder . prepare ( params ) ;
179152
@@ -182,12 +155,6 @@ export function computeBuffers(
182155
183156 preparedParams . coordinates . y = builder . vProject ( v , params . extent ) ;
184157
185- if ( builder . computeExtraOffset !== undefined ) {
186- computeUvs [ 1 ] = initComputeUv1 (
187- builder . computeExtraOffset ( preparedParams ) as number ,
188- ) ;
189- }
190-
191158 for ( let x = 0 ; x <= nSeg ; x ++ ) {
192159 const u = x / nSeg ;
193160 const id_m3 = ( y * nVertex + x ) * 3 ;
@@ -211,12 +178,7 @@ export function computeBuffers(
211178
212179 vertex . toArray ( outBuffers . position , id_m3 ) ;
213180 normal . toArray ( outBuffers . normal , id_m3 ) ;
214-
215- for ( const [ index , computeUv ] of computeUvs . entries ( ) ) {
216- if ( computeUv !== undefined ) {
217- computeUv ( outBuffers . uvs [ index ] ! , y * nVertex + x , u , v ) ;
218- }
219- }
181+ computeUv ( outBuffers . uv , y * nVertex + x , u , v ) ;
220182 }
221183 }
222184
@@ -325,11 +287,7 @@ export function computeBuffers(
325287 outBuffers . normal [ id_m3 + 1 ] = outBuffers . normal [ id2_m3 + 1 ] ;
326288 outBuffers . normal [ id_m3 + 2 ] = outBuffers . normal [ id2_m3 + 2 ] ;
327289
328- buildSkirt . uv ( outBuffers . uvs [ 0 ] , start + i , id ) ;
329-
330- if ( outBuffers . uvs [ 1 ] !== undefined ) {
331- outBuffers . uvs [ 1 ] [ start + i ] = outBuffers . uvs [ 1 ] [ id ] ;
332- }
290+ buildSkirt . uv ( outBuffers . uv , start + i , id ) ;
333291
334292 const idf = ( i + 1 ) % outBuffers . skirt ! . length ;
335293
@@ -346,7 +304,7 @@ export function computeBuffers(
346304 return {
347305 index : outBuffers . index ,
348306 position : outBuffers . position ,
349- uvs : outBuffers . uvs ,
307+ uv : outBuffers . uv ,
350308 normal : outBuffers . normal ,
351309 } ;
352310}
0 commit comments