MCPcopy
hub / github.com/potree/potree / constructor

Method constructor

libs/three.js/loaders/VOXLoader.js:165–256  ·  view source on GitHub ↗
( chunk )

Source from the content-addressed store, hash-verified

163class VOXMesh extends Mesh {
164
165 constructor( chunk ) {
166
167 const data = chunk.data;
168 const size = chunk.size;
169 const palette = chunk.palette;
170
171 //
172
173 const vertices = [];
174 const colors = [];
175
176 const nx = [ 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1 ];
177 const px = [ 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0 ];
178 const py = [ 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1 ];
179 const ny = [ 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0 ];
180 const nz = [ 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0 ];
181 const pz = [ 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 1 ];
182
183 function add( tile, x, y, z, r, g, b ) {
184
185 x -= size.x / 2;
186 y -= size.z / 2;
187 z += size.y / 2;
188
189 for ( let i = 0; i < 18; i += 3 ) {
190
191 vertices.push( tile[ i + 0 ] + x, tile[ i + 1 ] + y, tile[ i + 2 ] + z );
192 colors.push( r, g, b );
193
194 }
195
196 }
197
198 // Store data in a volume for sampling
199
200 const offsety = size.x;
201 const offsetz = size.x * size.y;
202
203 const array = new Uint8Array( size.x * size.y * size.z );
204
205 for ( let j = 0; j < data.length; j += 4 ) {
206
207 const x = data[ j + 0 ];
208 const y = data[ j + 1 ];
209 const z = data[ j + 2 ];
210
211 const index = x + ( y * offsety ) + ( z * offsetz );
212
213 array[ index ] = 255;
214
215 }
216
217 // Construct geometry
218
219 let hasColors = false;
220
221 for ( let j = 0; j < data.length; j += 4 ) {
222

Callers

nothing calls this directly

Calls 1

addFunction · 0.50

Tested by

no test coverage detected