Skip to content

Commit a36141f

Browse files
committed
VOXLoader: Fixed chunk parsing.
1 parent 189ab49 commit a36141f

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

examples/jsm/loaders/VOXLoader.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class VOXLoader extends Loader {
5151

5252
const data = new DataView( buffer );
5353

54-
const id = data.getInt32( 0, true );
54+
const id = data.getUint32( 0, true );
5555
const version = data.getUint32( 4, true );
5656

5757
if ( id !== 542658390 || version !== 150 ) {
@@ -107,18 +107,18 @@ class VOXLoader extends Loader {
107107

108108
for ( let j = 0; j < 4; j ++ ) {
109109

110-
id += String.fromCharCode( data.getInt8( i ++, true ) );
110+
id += String.fromCharCode( data.getUint8( i ++, true ) );
111111

112112
}
113113

114-
const chunkSize = data.getInt32( i, true ); i += 4;
115-
data.getInt32( i, true ); i += 4; // childChunks
114+
const chunkSize = data.getUint32( i, true ); i += 4;
115+
data.getUint32( i, true ); i += 4; // childChunks
116116

117117
if ( id === 'SIZE' ) {
118118

119-
const x = data.getInt32( i, true ); i += 4;
120-
const y = data.getInt32( i, true ); i += 4;
121-
const z = data.getInt32( i, true ); i += 4;
119+
const x = data.getUint32( i, true ); i += 4;
120+
const y = data.getUint32( i, true ); i += 4;
121+
const z = data.getUint32( i, true ); i += 4;
122122

123123
chunk = {
124124
palette: DEFAULT_PALETTE,
@@ -131,8 +131,8 @@ class VOXLoader extends Loader {
131131

132132
} else if ( id === 'XYZI' ) {
133133

134-
const numVoxels = data.getInt32( i, true ); i += 4;
135-
chunk.data = new Int8Array( buffer, i, numVoxels * 4 );
134+
const numVoxels = data.getUint32( i, true ); i += 4;
135+
chunk.data = new Uint8Array( buffer, i, numVoxels * 4 );
136136

137137
i += numVoxels * 4;
138138

@@ -142,7 +142,7 @@ class VOXLoader extends Loader {
142142

143143
for ( let j = 0; j < 256; j ++ ) {
144144

145-
palette[ j + 1 ] = data.getInt32( i, true ); i += 4;
145+
palette[ j + 1 ] = data.getUint32( i, true ); i += 4;
146146

147147
}
148148

@@ -278,15 +278,15 @@ class VOXDataTexture3D extends DataTexture3D {
278278

279279
const array = new Uint8Array( size.x * size.y * size.z );
280280

281-
for ( let j = 0, k = 0; j < data.length; j += 4, k ++ ) {
281+
for ( let j = 0; j < data.length; j += 4 ) {
282282

283283
const x = data[ j + 0 ];
284284
const y = data[ j + 1 ];
285285
const z = data[ j + 2 ];
286286

287287
const index = x + ( y * offsety ) + ( z * offsetz );
288288

289-
array[ index ] = 255.0;
289+
array[ index ] = 255;
290290

291291
}
292292

0 commit comments

Comments
 (0)