|
@@ -47,51 +47,51 @@
|
|
|
function parseASCII( data ) {
|
|
|
|
|
|
// connectivity of the triangles
|
|
|
- var indices = []; // triangles vertices
|
|
|
+ const indices = []; // triangles vertices
|
|
|
|
|
|
- var positions = []; // red, green, blue colors in the range 0 to 1
|
|
|
+ const positions = []; // red, green, blue colors in the range 0 to 1
|
|
|
|
|
|
- var colors = []; // normal vector, one per vertex
|
|
|
+ const colors = []; // normal vector, one per vertex
|
|
|
|
|
|
- var normals = [];
|
|
|
- var result; // pattern for detecting the end of a number sequence
|
|
|
+ const normals = [];
|
|
|
+ let result; // pattern for detecting the end of a number sequence
|
|
|
|
|
|
- var patWord = /^[^\d.\s-]+/; // pattern for reading vertices, 3 floats or integers
|
|
|
+ const patWord = /^[^\d.\s-]+/; // pattern for reading vertices, 3 floats or integers
|
|
|
|
|
|
- var pat3Floats = /(\-?\d+\.?[\d\-\+e]*)\s+(\-?\d+\.?[\d\-\+e]*)\s+(\-?\d+\.?[\d\-\+e]*)/g; // pattern for connectivity, an integer followed by any number of ints
|
|
|
+ const pat3Floats = /(\-?\d+\.?[\d\-\+e]*)\s+(\-?\d+\.?[\d\-\+e]*)\s+(\-?\d+\.?[\d\-\+e]*)/g; // pattern for connectivity, an integer followed by any number of ints
|
|
|
// the first integer is the number of polygon nodes
|
|
|
|
|
|
- var patConnectivity = /^(\d+)\s+([\s\d]*)/; // indicates start of vertex data section
|
|
|
+ const patConnectivity = /^(\d+)\s+([\s\d]*)/; // indicates start of vertex data section
|
|
|
|
|
|
- var patPOINTS = /^POINTS /; // indicates start of polygon connectivity section
|
|
|
+ const patPOINTS = /^POINTS /; // indicates start of polygon connectivity section
|
|
|
|
|
|
- var patPOLYGONS = /^POLYGONS /; // indicates start of triangle strips section
|
|
|
+ const patPOLYGONS = /^POLYGONS /; // indicates start of triangle strips section
|
|
|
|
|
|
- var patTRIANGLE_STRIPS = /^TRIANGLE_STRIPS /; // POINT_DATA number_of_values
|
|
|
+ const patTRIANGLE_STRIPS = /^TRIANGLE_STRIPS /; // POINT_DATA number_of_values
|
|
|
|
|
|
- var patPOINT_DATA = /^POINT_DATA[ ]+(\d+)/; // CELL_DATA number_of_polys
|
|
|
+ const patPOINT_DATA = /^POINT_DATA[ ]+(\d+)/; // CELL_DATA number_of_polys
|
|
|
|
|
|
- var patCELL_DATA = /^CELL_DATA[ ]+(\d+)/; // Start of color section
|
|
|
+ const patCELL_DATA = /^CELL_DATA[ ]+(\d+)/; // Start of color section
|
|
|
|
|
|
- var patCOLOR_SCALARS = /^COLOR_SCALARS[ ]+(\w+)[ ]+3/; // NORMALS Normals float
|
|
|
+ const patCOLOR_SCALARS = /^COLOR_SCALARS[ ]+(\w+)[ ]+3/; // NORMALS Normals float
|
|
|
|
|
|
- var patNORMALS = /^NORMALS[ ]+(\w+)[ ]+(\w+)/;
|
|
|
- var inPointsSection = false;
|
|
|
- var inPolygonsSection = false;
|
|
|
- var inTriangleStripSection = false;
|
|
|
- var inPointDataSection = false;
|
|
|
- var inCellDataSection = false;
|
|
|
- var inColorSection = false;
|
|
|
- var inNormalsSection = false;
|
|
|
- var lines = data.split( '\n' );
|
|
|
+ const patNORMALS = /^NORMALS[ ]+(\w+)[ ]+(\w+)/;
|
|
|
+ let inPointsSection = false;
|
|
|
+ let inPolygonsSection = false;
|
|
|
+ let inTriangleStripSection = false;
|
|
|
+ let inPointDataSection = false;
|
|
|
+ let inCellDataSection = false;
|
|
|
+ let inColorSection = false;
|
|
|
+ let inNormalsSection = false;
|
|
|
+ const lines = data.split( '\n' );
|
|
|
|
|
|
- for ( var i in lines ) {
|
|
|
+ for ( const i in lines ) {
|
|
|
|
|
|
- var line = lines[ i ].trim();
|
|
|
+ const line = lines[ i ].trim();
|
|
|
|
|
|
if ( line.indexOf( 'DATASET' ) === 0 ) {
|
|
|
|
|
|
- var dataset = line.split( ' ' )[ 1 ];
|
|
|
+ const dataset = line.split( ' ' )[ 1 ];
|
|
|
if ( dataset !== 'POLYDATA' ) throw new Error( 'Unsupported DATASET type: ' + dataset );
|
|
|
|
|
|
} else if ( inPointsSection ) {
|
|
@@ -100,9 +100,9 @@
|
|
|
while ( ( result = pat3Floats.exec( line ) ) !== null ) {
|
|
|
|
|
|
if ( patWord.exec( line ) !== null ) break;
|
|
|
- var x = parseFloat( result[ 1 ] );
|
|
|
- var y = parseFloat( result[ 2 ] );
|
|
|
- var z = parseFloat( result[ 3 ] );
|
|
|
+ const x = parseFloat( result[ 1 ] );
|
|
|
+ const y = parseFloat( result[ 2 ] );
|
|
|
+ const z = parseFloat( result[ 3 ] );
|
|
|
positions.push( x, y, z );
|
|
|
|
|
|
}
|
|
@@ -112,19 +112,18 @@
|
|
|
if ( ( result = patConnectivity.exec( line ) ) !== null ) {
|
|
|
|
|
|
// numVertices i0 i1 i2 ...
|
|
|
- var numVertices = parseInt( result[ 1 ] );
|
|
|
- var inds = result[ 2 ].split( /\s+/ );
|
|
|
+ const numVertices = parseInt( result[ 1 ] );
|
|
|
+ const inds = result[ 2 ].split( /\s+/ );
|
|
|
|
|
|
if ( numVertices >= 3 ) {
|
|
|
|
|
|
- var i0 = parseInt( inds[ 0 ] );
|
|
|
- var i1, i2;
|
|
|
- var k = 1; // split the polygon in numVertices - 2 triangles
|
|
|
+ const i0 = parseInt( inds[ 0 ] );
|
|
|
+ let k = 1; // split the polygon in numVertices - 2 triangles
|
|
|
|
|
|
- for ( var j = 0; j < numVertices - 2; ++ j ) {
|
|
|
+ for ( let j = 0; j < numVertices - 2; ++ j ) {
|
|
|
|
|
|
- i1 = parseInt( inds[ k ] );
|
|
|
- i2 = parseInt( inds[ k + 1 ] );
|
|
|
+ const i1 = parseInt( inds[ k ] );
|
|
|
+ const i2 = parseInt( inds[ k + 1 ] );
|
|
|
indices.push( i0, i1, i2 );
|
|
|
k ++;
|
|
|
|
|
@@ -139,27 +138,26 @@
|
|
|
if ( ( result = patConnectivity.exec( line ) ) !== null ) {
|
|
|
|
|
|
// numVertices i0 i1 i2 ...
|
|
|
- var numVertices = parseInt( result[ 1 ] );
|
|
|
- var inds = result[ 2 ].split( /\s+/ );
|
|
|
+ const numVertices = parseInt( result[ 1 ] );
|
|
|
+ const inds = result[ 2 ].split( /\s+/ );
|
|
|
|
|
|
if ( numVertices >= 3 ) {
|
|
|
|
|
|
- var i0, i1, i2; // split the polygon in numVertices - 2 triangles
|
|
|
-
|
|
|
- for ( var j = 0; j < numVertices - 2; j ++ ) {
|
|
|
+ // split the polygon in numVertices - 2 triangles
|
|
|
+ for ( let j = 0; j < numVertices - 2; j ++ ) {
|
|
|
|
|
|
if ( j % 2 === 1 ) {
|
|
|
|
|
|
- i0 = parseInt( inds[ j ] );
|
|
|
- i1 = parseInt( inds[ j + 2 ] );
|
|
|
- i2 = parseInt( inds[ j + 1 ] );
|
|
|
+ const i0 = parseInt( inds[ j ] );
|
|
|
+ const i1 = parseInt( inds[ j + 2 ] );
|
|
|
+ const i2 = parseInt( inds[ j + 1 ] );
|
|
|
indices.push( i0, i1, i2 );
|
|
|
|
|
|
} else {
|
|
|
|
|
|
- i0 = parseInt( inds[ j ] );
|
|
|
- i1 = parseInt( inds[ j + 1 ] );
|
|
|
- i2 = parseInt( inds[ j + 2 ] );
|
|
|
+ const i0 = parseInt( inds[ j ] );
|
|
|
+ const i1 = parseInt( inds[ j + 1 ] );
|
|
|
+ const i2 = parseInt( inds[ j + 2 ] );
|
|
|
indices.push( i0, i1, i2 );
|
|
|
|
|
|
}
|
|
@@ -178,9 +176,9 @@
|
|
|
while ( ( result = pat3Floats.exec( line ) ) !== null ) {
|
|
|
|
|
|
if ( patWord.exec( line ) !== null ) break;
|
|
|
- var r = parseFloat( result[ 1 ] );
|
|
|
- var g = parseFloat( result[ 2 ] );
|
|
|
- var b = parseFloat( result[ 3 ] );
|
|
|
+ const r = parseFloat( result[ 1 ] );
|
|
|
+ const g = parseFloat( result[ 2 ] );
|
|
|
+ const b = parseFloat( result[ 3 ] );
|
|
|
colors.push( r, g, b );
|
|
|
|
|
|
}
|
|
@@ -191,9 +189,9 @@
|
|
|
while ( ( result = pat3Floats.exec( line ) ) !== null ) {
|
|
|
|
|
|
if ( patWord.exec( line ) !== null ) break;
|
|
|
- var nx = parseFloat( result[ 1 ] );
|
|
|
- var ny = parseFloat( result[ 2 ] );
|
|
|
- var nz = parseFloat( result[ 3 ] );
|
|
|
+ const nx = parseFloat( result[ 1 ] );
|
|
|
+ const ny = parseFloat( result[ 2 ] );
|
|
|
+ const nz = parseFloat( result[ 3 ] );
|
|
|
normals.push( nx, ny, nz );
|
|
|
|
|
|
}
|
|
@@ -254,7 +252,7 @@
|
|
|
|
|
|
}
|
|
|
|
|
|
- var geometry = new THREE.BufferGeometry();
|
|
|
+ let geometry = new THREE.BufferGeometry();
|
|
|
geometry.setIndex( indices );
|
|
|
geometry.setAttribute( 'position', new THREE.Float32BufferAttribute( positions, 3 ) );
|
|
|
|
|
@@ -277,17 +275,17 @@
|
|
|
|
|
|
// cell
|
|
|
geometry = geometry.toNonIndexed();
|
|
|
- var numTriangles = geometry.attributes.position.count / 3;
|
|
|
+ const numTriangles = geometry.attributes.position.count / 3;
|
|
|
|
|
|
if ( colors.length === numTriangles * 3 ) {
|
|
|
|
|
|
- var newColors = [];
|
|
|
+ const newColors = [];
|
|
|
|
|
|
- for ( var i = 0; i < numTriangles; i ++ ) {
|
|
|
+ for ( let i = 0; i < numTriangles; i ++ ) {
|
|
|
|
|
|
- var r = colors[ 3 * i + 0 ];
|
|
|
- var g = colors[ 3 * i + 1 ];
|
|
|
- var b = colors[ 3 * i + 2 ];
|
|
|
+ const r = colors[ 3 * i + 0 ];
|
|
|
+ const g = colors[ 3 * i + 1 ];
|
|
|
+ const b = colors[ 3 * i + 2 ];
|
|
|
newColors.push( r, g, b );
|
|
|
newColors.push( r, g, b );
|
|
|
newColors.push( r, g, b );
|
|
@@ -306,22 +304,21 @@
|
|
|
|
|
|
function parseBinary( data ) {
|
|
|
|
|
|
- var count, pointIndex, i, numberOfPoints, s;
|
|
|
- var buffer = new Uint8Array( data );
|
|
|
- var dataView = new DataView( data ); // Points and normals, by default, are empty
|
|
|
+ const buffer = new Uint8Array( data );
|
|
|
+ const dataView = new DataView( data ); // Points and normals, by default, are empty
|
|
|
|
|
|
- var points = [];
|
|
|
- var normals = [];
|
|
|
- var indices = []; // Going to make a big array of strings
|
|
|
+ let points = [];
|
|
|
+ let normals = [];
|
|
|
+ let indices = []; // Going to make a big array of strings
|
|
|
|
|
|
- var vtk = [];
|
|
|
- var index = 0;
|
|
|
+ const vtk = [];
|
|
|
+ let index = 0;
|
|
|
|
|
|
function findString( buffer, start ) {
|
|
|
|
|
|
- var index = start;
|
|
|
- var c = buffer[ index ];
|
|
|
- var s = [];
|
|
|
+ let index = start;
|
|
|
+ let c = buffer[ index ];
|
|
|
+ const s = [];
|
|
|
|
|
|
while ( c !== 10 ) {
|
|
|
|
|
@@ -340,7 +337,7 @@
|
|
|
|
|
|
}
|
|
|
|
|
|
- var state, line;
|
|
|
+ let state, line;
|
|
|
|
|
|
while ( true ) {
|
|
|
|
|
@@ -350,20 +347,20 @@
|
|
|
|
|
|
if ( line.indexOf( 'DATASET' ) === 0 ) {
|
|
|
|
|
|
- var dataset = line.split( ' ' )[ 1 ];
|
|
|
+ const dataset = line.split( ' ' )[ 1 ];
|
|
|
if ( dataset !== 'POLYDATA' ) throw new Error( 'Unsupported DATASET type: ' + dataset );
|
|
|
|
|
|
} else if ( line.indexOf( 'POINTS' ) === 0 ) {
|
|
|
|
|
|
vtk.push( line ); // Add the points
|
|
|
|
|
|
- numberOfPoints = parseInt( line.split( ' ' )[ 1 ], 10 ); // Each point is 3 4-byte floats
|
|
|
+ const numberOfPoints = parseInt( line.split( ' ' )[ 1 ], 10 ); // Each point is 3 4-byte floats
|
|
|
|
|
|
- count = numberOfPoints * 4 * 3;
|
|
|
+ const count = numberOfPoints * 4 * 3;
|
|
|
points = new Float32Array( numberOfPoints * 3 );
|
|
|
- pointIndex = state.next;
|
|
|
+ let pointIndex = state.next;
|
|
|
|
|
|
- for ( i = 0; i < numberOfPoints; i ++ ) {
|
|
|
+ for ( let i = 0; i < numberOfPoints; i ++ ) {
|
|
|
|
|
|
points[ 3 * i ] = dataView.getFloat32( pointIndex, false );
|
|
|
points[ 3 * i + 1 ] = dataView.getFloat32( pointIndex + 4, false );
|
|
@@ -377,22 +374,22 @@
|
|
|
|
|
|
} else if ( line.indexOf( 'TRIANGLE_STRIPS' ) === 0 ) {
|
|
|
|
|
|
- var numberOfStrips = parseInt( line.split( ' ' )[ 1 ], 10 );
|
|
|
- var size = parseInt( line.split( ' ' )[ 2 ], 10 ); // 4 byte integers
|
|
|
+ const numberOfStrips = parseInt( line.split( ' ' )[ 1 ], 10 );
|
|
|
+ const size = parseInt( line.split( ' ' )[ 2 ], 10 ); // 4 byte integers
|
|
|
|
|
|
- count = size * 4;
|
|
|
+ const count = size * 4;
|
|
|
indices = new Uint32Array( 3 * size - 9 * numberOfStrips );
|
|
|
- var indicesIndex = 0;
|
|
|
- pointIndex = state.next;
|
|
|
+ let indicesIndex = 0;
|
|
|
+ let pointIndex = state.next;
|
|
|
|
|
|
- for ( i = 0; i < numberOfStrips; i ++ ) {
|
|
|
+ for ( let i = 0; i < numberOfStrips; i ++ ) {
|
|
|
|
|
|
// For each strip, read the first value, then record that many more points
|
|
|
- var indexCount = dataView.getInt32( pointIndex, false );
|
|
|
- var strip = [];
|
|
|
+ const indexCount = dataView.getInt32( pointIndex, false );
|
|
|
+ const strip = [];
|
|
|
pointIndex += 4;
|
|
|
|
|
|
- for ( s = 0; s < indexCount; s ++ ) {
|
|
|
+ for ( let s = 0; s < indexCount; s ++ ) {
|
|
|
|
|
|
strip.push( dataView.getInt32( pointIndex, false ) );
|
|
|
pointIndex += 4;
|
|
@@ -400,7 +397,7 @@
|
|
|
} // retrieves the n-2 triangles from the triangle strip
|
|
|
|
|
|
|
|
|
- for ( var j = 0; j < indexCount - 2; j ++ ) {
|
|
|
+ for ( let j = 0; j < indexCount - 2; j ++ ) {
|
|
|
|
|
|
if ( j % 2 ) {
|
|
|
|
|
@@ -425,22 +422,22 @@
|
|
|
|
|
|
} else if ( line.indexOf( 'POLYGONS' ) === 0 ) {
|
|
|
|
|
|
- var numberOfStrips = parseInt( line.split( ' ' )[ 1 ], 10 );
|
|
|
- var size = parseInt( line.split( ' ' )[ 2 ], 10 ); // 4 byte integers
|
|
|
+ const numberOfStrips = parseInt( line.split( ' ' )[ 1 ], 10 );
|
|
|
+ const size = parseInt( line.split( ' ' )[ 2 ], 10 ); // 4 byte integers
|
|
|
|
|
|
- count = size * 4;
|
|
|
+ const count = size * 4;
|
|
|
indices = new Uint32Array( 3 * size - 9 * numberOfStrips );
|
|
|
- var indicesIndex = 0;
|
|
|
- pointIndex = state.next;
|
|
|
+ let indicesIndex = 0;
|
|
|
+ let pointIndex = state.next;
|
|
|
|
|
|
- for ( i = 0; i < numberOfStrips; i ++ ) {
|
|
|
+ for ( let i = 0; i < numberOfStrips; i ++ ) {
|
|
|
|
|
|
// For each strip, read the first value, then record that many more points
|
|
|
- var indexCount = dataView.getInt32( pointIndex, false );
|
|
|
- var strip = [];
|
|
|
+ const indexCount = dataView.getInt32( pointIndex, false );
|
|
|
+ const strip = [];
|
|
|
pointIndex += 4;
|
|
|
|
|
|
- for ( s = 0; s < indexCount; s ++ ) {
|
|
|
+ for ( let s = 0; s < indexCount; s ++ ) {
|
|
|
|
|
|
strip.push( dataView.getInt32( pointIndex, false ) );
|
|
|
pointIndex += 4;
|
|
@@ -448,7 +445,7 @@
|
|
|
} // divide the polygon in n-2 triangle
|
|
|
|
|
|
|
|
|
- for ( var j = 1; j < indexCount - 1; j ++ ) {
|
|
|
+ for ( let j = 1; j < indexCount - 1; j ++ ) {
|
|
|
|
|
|
indices[ indicesIndex ++ ] = strip[ 0 ];
|
|
|
indices[ indicesIndex ++ ] = strip[ j ];
|
|
@@ -463,15 +460,15 @@
|
|
|
|
|
|
} else if ( line.indexOf( 'POINT_DATA' ) === 0 ) {
|
|
|
|
|
|
- numberOfPoints = parseInt( line.split( ' ' )[ 1 ], 10 ); // Grab the next line
|
|
|
+ const numberOfPoints = parseInt( line.split( ' ' )[ 1 ], 10 ); // Grab the next line
|
|
|
|
|
|
state = findString( buffer, state.next ); // Now grab the binary data
|
|
|
|
|
|
- count = numberOfPoints * 4 * 3;
|
|
|
+ const count = numberOfPoints * 4 * 3;
|
|
|
normals = new Float32Array( numberOfPoints * 3 );
|
|
|
- pointIndex = state.next;
|
|
|
+ let pointIndex = state.next;
|
|
|
|
|
|
- for ( i = 0; i < numberOfPoints; i ++ ) {
|
|
|
+ for ( let i = 0; i < numberOfPoints; i ++ ) {
|
|
|
|
|
|
normals[ 3 * i ] = dataView.getFloat32( pointIndex, false );
|
|
|
normals[ 3 * i + 1 ] = dataView.getFloat32( pointIndex + 4, false );
|
|
@@ -496,7 +493,7 @@
|
|
|
|
|
|
}
|
|
|
|
|
|
- var geometry = new THREE.BufferGeometry();
|
|
|
+ const geometry = new THREE.BufferGeometry();
|
|
|
geometry.setIndex( new THREE.BufferAttribute( indices, 1 ) );
|
|
|
geometry.setAttribute( 'position', new THREE.BufferAttribute( points, 3 ) );
|
|
|
|
|
@@ -522,7 +519,7 @@
|
|
|
|
|
|
function Int32Concat( first, second ) {
|
|
|
|
|
|
- var firstLength = first.length,
|
|
|
+ const firstLength = first.length,
|
|
|
result = new Int32Array( firstLength + second.length );
|
|
|
result.set( first );
|
|
|
result.set( second, firstLength );
|
|
@@ -536,7 +533,7 @@
|
|
|
function xmlToJson( xml ) {
|
|
|
|
|
|
// Create the return object
|
|
|
- var obj = {};
|
|
|
+ let obj = {};
|
|
|
|
|
|
if ( xml.nodeType === 1 ) {
|
|
|
|
|
@@ -548,9 +545,9 @@
|
|
|
|
|
|
obj[ 'attributes' ] = {};
|
|
|
|
|
|
- for ( var j = 0; j < xml.attributes.length; j ++ ) {
|
|
|
+ for ( let j = 0; j < xml.attributes.length; j ++ ) {
|
|
|
|
|
|
- var attribute = xml.attributes.item( j );
|
|
|
+ const attribute = xml.attributes.item( j );
|
|
|
obj[ 'attributes' ][ attribute.nodeName ] = attribute.nodeValue.trim();
|
|
|
|
|
|
}
|
|
@@ -569,26 +566,26 @@
|
|
|
|
|
|
if ( xml.hasChildNodes() ) {
|
|
|
|
|
|
- for ( var i = 0; i < xml.childNodes.length; i ++ ) {
|
|
|
+ for ( let i = 0; i < xml.childNodes.length; i ++ ) {
|
|
|
|
|
|
- var item = xml.childNodes.item( i );
|
|
|
- var nodeName = item.nodeName;
|
|
|
+ const item = xml.childNodes.item( i );
|
|
|
+ const nodeName = item.nodeName;
|
|
|
|
|
|
if ( typeof obj[ nodeName ] === 'undefined' ) {
|
|
|
|
|
|
- var tmp = xmlToJson( item );
|
|
|
+ const tmp = xmlToJson( item );
|
|
|
if ( tmp !== '' ) obj[ nodeName ] = tmp;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
if ( typeof obj[ nodeName ].push === 'undefined' ) {
|
|
|
|
|
|
- var old = obj[ nodeName ];
|
|
|
+ const old = obj[ nodeName ];
|
|
|
obj[ nodeName ] = [ old ];
|
|
|
|
|
|
}
|
|
|
|
|
|
- var tmp = xmlToJson( item );
|
|
|
+ const tmp = xmlToJson( item );
|
|
|
if ( tmp !== '' ) obj[ nodeName ].push( tmp );
|
|
|
|
|
|
}
|
|
@@ -604,20 +601,11 @@
|
|
|
|
|
|
function Base64toByteArray( b64 ) {
|
|
|
|
|
|
- var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array;
|
|
|
- var i;
|
|
|
- var lookup = [];
|
|
|
- var revLookup = [];
|
|
|
- var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
|
|
- var len = code.length;
|
|
|
+ const Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array;
|
|
|
+ const revLookup = [];
|
|
|
+ const code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
|
|
|
|
|
- for ( i = 0; i < len; i ++ ) {
|
|
|
-
|
|
|
- lookup[ i ] = code[ i ];
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- for ( i = 0; i < len; ++ i ) {
|
|
|
+ for ( let i = 0, l = code.length; i < l; ++ i ) {
|
|
|
|
|
|
revLookup[ code.charCodeAt( i ) ] = i;
|
|
|
|
|
@@ -625,8 +613,7 @@
|
|
|
|
|
|
revLookup[ '-'.charCodeAt( 0 ) ] = 62;
|
|
|
revLookup[ '_'.charCodeAt( 0 ) ] = 63;
|
|
|
- var j, l, tmp, placeHolders, arr;
|
|
|
- var len = b64.length;
|
|
|
+ const len = b64.length;
|
|
|
|
|
|
if ( len % 4 > 0 ) {
|
|
|
|
|
@@ -634,14 +621,15 @@
|
|
|
|
|
|
}
|
|
|
|
|
|
- placeHolders = b64[ len - 2 ] === '=' ? 2 : b64[ len - 1 ] === '=' ? 1 : 0;
|
|
|
- arr = new Arr( len * 3 / 4 - placeHolders );
|
|
|
- l = placeHolders > 0 ? len - 4 : len;
|
|
|
- var L = 0;
|
|
|
+ const placeHolders = b64[ len - 2 ] === '=' ? 2 : b64[ len - 1 ] === '=' ? 1 : 0;
|
|
|
+ const arr = new Arr( len * 3 / 4 - placeHolders );
|
|
|
+ const l = placeHolders > 0 ? len - 4 : len;
|
|
|
+ let L = 0;
|
|
|
+ let i, j;
|
|
|
|
|
|
for ( i = 0, j = 0; i < l; i += 4, j += 3 ) {
|
|
|
|
|
|
- tmp = revLookup[ b64.charCodeAt( i ) ] << 18 | revLookup[ b64.charCodeAt( i + 1 ) ] << 12 | revLookup[ b64.charCodeAt( i + 2 ) ] << 6 | revLookup[ b64.charCodeAt( i + 3 ) ];
|
|
|
+ const tmp = revLookup[ b64.charCodeAt( i ) ] << 18 | revLookup[ b64.charCodeAt( i + 1 ) ] << 12 | revLookup[ b64.charCodeAt( i + 2 ) ] << 6 | revLookup[ b64.charCodeAt( i + 3 ) ];
|
|
|
arr[ L ++ ] = ( tmp & 0xFF0000 ) >> 16;
|
|
|
arr[ L ++ ] = ( tmp & 0xFF00 ) >> 8;
|
|
|
arr[ L ++ ] = tmp & 0xFF;
|
|
@@ -650,12 +638,12 @@
|
|
|
|
|
|
if ( placeHolders === 2 ) {
|
|
|
|
|
|
- tmp = revLookup[ b64.charCodeAt( i ) ] << 2 | revLookup[ b64.charCodeAt( i + 1 ) ] >> 4;
|
|
|
+ const tmp = revLookup[ b64.charCodeAt( i ) ] << 2 | revLookup[ b64.charCodeAt( i + 1 ) ] >> 4;
|
|
|
arr[ L ++ ] = tmp & 0xFF;
|
|
|
|
|
|
} else if ( placeHolders === 1 ) {
|
|
|
|
|
|
- tmp = revLookup[ b64.charCodeAt( i ) ] << 10 | revLookup[ b64.charCodeAt( i + 1 ) ] << 4 | revLookup[ b64.charCodeAt( i + 2 ) ] >> 2;
|
|
|
+ const tmp = revLookup[ b64.charCodeAt( i ) ] << 10 | revLookup[ b64.charCodeAt( i + 1 ) ] << 4 | revLookup[ b64.charCodeAt( i + 2 ) ] >> 2;
|
|
|
arr[ L ++ ] = tmp >> 8 & 0xFF;
|
|
|
arr[ L ++ ] = tmp & 0xFF;
|
|
|
|
|
@@ -667,7 +655,7 @@
|
|
|
|
|
|
function parseDataArray( ele, compressed ) {
|
|
|
|
|
|
- var numBytes = 0;
|
|
|
+ let numBytes = 0;
|
|
|
|
|
|
if ( json.attributes.header_type === 'UInt64' ) {
|
|
|
|
|
@@ -677,20 +665,19 @@
|
|
|
|
|
|
numBytes = 4;
|
|
|
|
|
|
- } // Check the format
|
|
|
+ }
|
|
|
|
|
|
+ let txt, content; // Check the format
|
|
|
|
|
|
if ( ele.attributes.format === 'binary' && compressed ) {
|
|
|
|
|
|
- var rawData, content, byteData, blocks, cSizeStart, headerSize, padding, dataOffsets, currentOffset;
|
|
|
-
|
|
|
if ( ele.attributes.type === 'Float32' ) {
|
|
|
|
|
|
- var txt = new Float32Array();
|
|
|
+ txt = new Float32Array();
|
|
|
|
|
|
} else if ( ele.attributes.type === 'Int64' ) {
|
|
|
|
|
|
- var txt = new Int32Array();
|
|
|
+ txt = new Int32Array();
|
|
|
|
|
|
} // VTP data with the header has the following structure:
|
|
|
// [#blocks][#u-size][#p-size][#c-size-1][#c-size-2]...[#c-size-#blocks][DATA]
|
|
@@ -705,31 +692,31 @@
|
|
|
// computed by summing the compressed block sizes from preceding blocks according to the header.
|
|
|
|
|
|
|
|
|
- rawData = ele[ '#text' ];
|
|
|
- byteData = Base64toByteArray( rawData );
|
|
|
- blocks = byteData[ 0 ];
|
|
|
+ const rawData = ele[ '#text' ];
|
|
|
+ const byteData = Base64toByteArray( rawData );
|
|
|
+ let blocks = byteData[ 0 ];
|
|
|
|
|
|
- for ( var i = 1; i < numBytes - 1; i ++ ) {
|
|
|
+ for ( let i = 1; i < numBytes - 1; i ++ ) {
|
|
|
|
|
|
blocks = blocks | byteData[ i ] << i * numBytes;
|
|
|
|
|
|
}
|
|
|
|
|
|
- headerSize = ( blocks + 3 ) * numBytes;
|
|
|
- padding = headerSize % 3 > 0 ? 3 - headerSize % 3 : 0;
|
|
|
+ let headerSize = ( blocks + 3 ) * numBytes;
|
|
|
+ const padding = headerSize % 3 > 0 ? 3 - headerSize % 3 : 0;
|
|
|
headerSize = headerSize + padding;
|
|
|
- dataOffsets = [];
|
|
|
- currentOffset = headerSize;
|
|
|
+ const dataOffsets = [];
|
|
|
+ let currentOffset = headerSize;
|
|
|
dataOffsets.push( currentOffset ); // Get the blocks sizes after the compression.
|
|
|
// There are three blocks before c-size-i, so we skip 3*numBytes
|
|
|
|
|
|
- cSizeStart = 3 * numBytes;
|
|
|
+ const cSizeStart = 3 * numBytes;
|
|
|
|
|
|
- for ( var i = 0; i < blocks; i ++ ) {
|
|
|
+ for ( let i = 0; i < blocks; i ++ ) {
|
|
|
|
|
|
- var currentBlockSize = byteData[ i * numBytes + cSizeStart ];
|
|
|
+ let currentBlockSize = byteData[ i * numBytes + cSizeStart ];
|
|
|
|
|
|
- for ( var j = 1; j < numBytes - 1; j ++ ) {
|
|
|
+ for ( let j = 1; j < numBytes - 1; j ++ ) {
|
|
|
|
|
|
// Each data point consists of 8 bytes regardless of the header type
|
|
|
currentBlockSize = currentBlockSize | byteData[ i * numBytes + cSizeStart + j ] << j * 8;
|
|
@@ -741,9 +728,9 @@
|
|
|
|
|
|
}
|
|
|
|
|
|
- for ( var i = 0; i < dataOffsets.length - 1; i ++ ) {
|
|
|
+ for ( let i = 0; i < dataOffsets.length - 1; i ++ ) {
|
|
|
|
|
|
- var data = fflate.unzlibSync( byteData.slice( dataOffsets[ i ], dataOffsets[ i + 1 ] ) ); // eslint-disable-line no-undef
|
|
|
+ const data = fflate.unzlibSync( byteData.slice( dataOffsets[ i ], dataOffsets[ i + 1 ] ) ); // eslint-disable-line no-undef
|
|
|
|
|
|
content = data.buffer;
|
|
|
|
|
@@ -781,7 +768,7 @@
|
|
|
|
|
|
if ( ele.attributes.format === 'binary' && ! compressed ) {
|
|
|
|
|
|
- var content = Base64toByteArray( ele[ '#text' ] ); // VTP data for the uncompressed case has the following structure:
|
|
|
+ content = Base64toByteArray( ele[ '#text' ] ); // VTP data for the uncompressed case has the following structure:
|
|
|
// [#bytes][DATA]
|
|
|
// where "[#bytes]" is an integer value specifying the number of bytes in the block of data following it.
|
|
|
|
|
@@ -791,7 +778,7 @@
|
|
|
|
|
|
if ( ele[ '#text' ] ) {
|
|
|
|
|
|
- var content = ele[ '#text' ].split( /\s+/ ).filter( function ( el ) {
|
|
|
+ content = ele[ '#text' ].split( /\s+/ ).filter( function ( el ) {
|
|
|
|
|
|
if ( el !== '' ) return el;
|
|
|
|
|
@@ -799,7 +786,7 @@
|
|
|
|
|
|
} else {
|
|
|
|
|
|
- var content = new Int32Array( 0 ).buffer;
|
|
|
+ content = new Int32Array( 0 ).buffer;
|
|
|
|
|
|
}
|
|
|
|
|
@@ -809,15 +796,15 @@
|
|
|
|
|
|
if ( ele.attributes.type === 'Float32' ) {
|
|
|
|
|
|
- var txt = new Float32Array( content );
|
|
|
+ txt = new Float32Array( content );
|
|
|
|
|
|
} else if ( ele.attributes.type === 'Int32' ) {
|
|
|
|
|
|
- var txt = new Int32Array( content );
|
|
|
+ txt = new Int32Array( content );
|
|
|
|
|
|
} else if ( ele.attributes.type === 'Int64' ) {
|
|
|
|
|
|
- var txt = new Int32Array( content );
|
|
|
+ txt = new Int32Array( content );
|
|
|
|
|
|
if ( ele.attributes.format === 'binary' ) {
|
|
|
|
|
@@ -840,84 +827,47 @@
|
|
|
// Get Dom
|
|
|
|
|
|
|
|
|
- var dom = null;
|
|
|
-
|
|
|
- if ( window.DOMParser ) {
|
|
|
-
|
|
|
- try {
|
|
|
-
|
|
|
- dom = new DOMParser().parseFromString( stringFile, 'text/xml' );
|
|
|
-
|
|
|
- } catch ( e ) {
|
|
|
-
|
|
|
- dom = null;
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- } else if ( window.ActiveXObject ) {
|
|
|
-
|
|
|
- try {
|
|
|
-
|
|
|
- dom = new ActiveXObject( 'Microsoft.XMLDOM' ); // eslint-disable-line no-undef
|
|
|
-
|
|
|
- dom.async = false;
|
|
|
-
|
|
|
- if ( ! dom.loadXML() ) {
|
|
|
-
|
|
|
- throw new Error( dom.parseError.reason + dom.parseError.srcText );
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- } catch ( e ) {
|
|
|
-
|
|
|
- dom = null;
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- } else {
|
|
|
-
|
|
|
- throw new Error( 'Cannot parse xml string!' );
|
|
|
+ const dom = new DOMParser().parseFromString( stringFile, 'application/xml' ); // Get the doc
|
|
|
|
|
|
- } // Get the doc
|
|
|
+ const doc = dom.documentElement; // Convert to json
|
|
|
|
|
|
-
|
|
|
- var doc = dom.documentElement; // Convert to json
|
|
|
-
|
|
|
- var json = xmlToJson( doc );
|
|
|
- var points = [];
|
|
|
- var normals = [];
|
|
|
- var indices = [];
|
|
|
+ const json = xmlToJson( doc );
|
|
|
+ let points = [];
|
|
|
+ let normals = [];
|
|
|
+ let indices = [];
|
|
|
|
|
|
if ( json.PolyData ) {
|
|
|
|
|
|
- var piece = json.PolyData.Piece;
|
|
|
- var compressed = json.attributes.hasOwnProperty( 'compressor' ); // Can be optimized
|
|
|
+ const piece = json.PolyData.Piece;
|
|
|
+ const compressed = json.attributes.hasOwnProperty( 'compressor' ); // Can be optimized
|
|
|
// Loop through the sections
|
|
|
|
|
|
- var sections = [ 'PointData', 'Points', 'Strips', 'Polys' ]; // +['CellData', 'Verts', 'Lines'];
|
|
|
+ const sections = [ 'PointData', 'Points', 'Strips', 'Polys' ]; // +['CellData', 'Verts', 'Lines'];
|
|
|
|
|
|
- var sectionIndex = 0,
|
|
|
- numberOfSections = sections.length;
|
|
|
+ let sectionIndex = 0;
|
|
|
+ const numberOfSections = sections.length;
|
|
|
|
|
|
while ( sectionIndex < numberOfSections ) {
|
|
|
|
|
|
- var section = piece[ sections[ sectionIndex ] ]; // If it has a DataArray in it
|
|
|
+ const section = piece[ sections[ sectionIndex ] ]; // If it has a DataArray in it
|
|
|
|
|
|
if ( section && section.DataArray ) {
|
|
|
|
|
|
// Depending on the number of DataArrays
|
|
|
+ let arr;
|
|
|
+
|
|
|
if ( Object.prototype.toString.call( section.DataArray ) === '[object Array]' ) {
|
|
|
|
|
|
- var arr = section.DataArray;
|
|
|
+ arr = section.DataArray;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
- var arr = [ section.DataArray ];
|
|
|
+ arr = [ section.DataArray ];
|
|
|
|
|
|
}
|
|
|
|
|
|
- var dataArrayIndex = 0,
|
|
|
- numberOfDataArrays = arr.length;
|
|
|
+ let dataArrayIndex = 0;
|
|
|
+ const numberOfDataArrays = arr.length;
|
|
|
|
|
|
while ( dataArrayIndex < numberOfDataArrays ) {
|
|
|
|
|
@@ -936,18 +886,22 @@
|
|
|
|
|
|
// if iti is point data
|
|
|
case 'PointData':
|
|
|
- var numberOfPoints = parseInt( piece.attributes.NumberOfPoints );
|
|
|
- var normalsName = section.attributes.Normals;
|
|
|
+ {
|
|
|
|
|
|
- if ( numberOfPoints > 0 ) {
|
|
|
+ const numberOfPoints = parseInt( piece.attributes.NumberOfPoints );
|
|
|
+ const normalsName = section.attributes.Normals;
|
|
|
|
|
|
- for ( var i = 0, len = arr.length; i < len; i ++ ) {
|
|
|
+ if ( numberOfPoints > 0 ) {
|
|
|
|
|
|
- if ( normalsName === arr[ i ].attributes.Name ) {
|
|
|
+ for ( let i = 0, len = arr.length; i < len; i ++ ) {
|
|
|
|
|
|
- var components = arr[ i ].attributes.NumberOfComponents;
|
|
|
- normals = new Float32Array( numberOfPoints * components );
|
|
|
- normals.set( arr[ i ].text, 0 );
|
|
|
+ if ( normalsName === arr[ i ].attributes.Name ) {
|
|
|
+
|
|
|
+ const components = arr[ i ].attributes.NumberOfComponents;
|
|
|
+ normals = new Float32Array( numberOfPoints * components );
|
|
|
+ normals.set( arr[ i ].text, 0 );
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
@@ -959,13 +913,17 @@
|
|
|
// if it is points
|
|
|
|
|
|
case 'Points':
|
|
|
- var numberOfPoints = parseInt( piece.attributes.NumberOfPoints );
|
|
|
+ {
|
|
|
|
|
|
- if ( numberOfPoints > 0 ) {
|
|
|
+ const numberOfPoints = parseInt( piece.attributes.NumberOfPoints );
|
|
|
|
|
|
- var components = section.DataArray.attributes.NumberOfComponents;
|
|
|
- points = new Float32Array( numberOfPoints * components );
|
|
|
- points.set( section.DataArray.text, 0 );
|
|
|
+ if ( numberOfPoints > 0 ) {
|
|
|
+
|
|
|
+ const components = section.DataArray.attributes.NumberOfComponents;
|
|
|
+ points = new Float32Array( numberOfPoints * components );
|
|
|
+ points.set( section.DataArray.text, 0 );
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
@@ -973,46 +931,50 @@
|
|
|
// if it is strips
|
|
|
|
|
|
case 'Strips':
|
|
|
- var numberOfStrips = parseInt( piece.attributes.NumberOfStrips );
|
|
|
+ {
|
|
|
|
|
|
- if ( numberOfStrips > 0 ) {
|
|
|
+ const numberOfStrips = parseInt( piece.attributes.NumberOfStrips );
|
|
|
|
|
|
- var connectivity = new Int32Array( section.DataArray[ 0 ].text.length );
|
|
|
- var offset = new Int32Array( section.DataArray[ 1 ].text.length );
|
|
|
- connectivity.set( section.DataArray[ 0 ].text, 0 );
|
|
|
- offset.set( section.DataArray[ 1 ].text, 0 );
|
|
|
- var size = numberOfStrips + connectivity.length;
|
|
|
- indices = new Uint32Array( 3 * size - 9 * numberOfStrips );
|
|
|
- var indicesIndex = 0;
|
|
|
+ if ( numberOfStrips > 0 ) {
|
|
|
|
|
|
- for ( var i = 0, len = numberOfStrips; i < len; i ++ ) {
|
|
|
+ const connectivity = new Int32Array( section.DataArray[ 0 ].text.length );
|
|
|
+ const offset = new Int32Array( section.DataArray[ 1 ].text.length );
|
|
|
+ connectivity.set( section.DataArray[ 0 ].text, 0 );
|
|
|
+ offset.set( section.DataArray[ 1 ].text, 0 );
|
|
|
+ const size = numberOfStrips + connectivity.length;
|
|
|
+ indices = new Uint32Array( 3 * size - 9 * numberOfStrips );
|
|
|
+ let indicesIndex = 0;
|
|
|
|
|
|
- var strip = [];
|
|
|
+ for ( let i = 0, len = numberOfStrips; i < len; i ++ ) {
|
|
|
|
|
|
- for ( var s = 0, len1 = offset[ i ], len0 = 0; s < len1 - len0; s ++ ) {
|
|
|
+ const strip = [];
|
|
|
|
|
|
- strip.push( connectivity[ s ] );
|
|
|
- if ( i > 0 ) len0 = offset[ i - 1 ];
|
|
|
+ for ( let s = 0, len1 = offset[ i ], len0 = 0; s < len1 - len0; s ++ ) {
|
|
|
|
|
|
- }
|
|
|
+ strip.push( connectivity[ s ] );
|
|
|
+ if ( i > 0 ) len0 = offset[ i - 1 ];
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
- for ( var j = 0, len1 = offset[ i ], len0 = 0; j < len1 - len0 - 2; j ++ ) {
|
|
|
+ for ( let j = 0, len1 = offset[ i ], len0 = 0; j < len1 - len0 - 2; j ++ ) {
|
|
|
|
|
|
- if ( j % 2 ) {
|
|
|
+ if ( j % 2 ) {
|
|
|
|
|
|
- indices[ indicesIndex ++ ] = strip[ j ];
|
|
|
- indices[ indicesIndex ++ ] = strip[ j + 2 ];
|
|
|
- indices[ indicesIndex ++ ] = strip[ j + 1 ];
|
|
|
+ indices[ indicesIndex ++ ] = strip[ j ];
|
|
|
+ indices[ indicesIndex ++ ] = strip[ j + 2 ];
|
|
|
+ indices[ indicesIndex ++ ] = strip[ j + 1 ];
|
|
|
|
|
|
- } else {
|
|
|
+ } else {
|
|
|
|
|
|
- indices[ indicesIndex ++ ] = strip[ j ];
|
|
|
- indices[ indicesIndex ++ ] = strip[ j + 1 ];
|
|
|
- indices[ indicesIndex ++ ] = strip[ j + 2 ];
|
|
|
+ indices[ indicesIndex ++ ] = strip[ j ];
|
|
|
+ indices[ indicesIndex ++ ] = strip[ j + 1 ];
|
|
|
+ indices[ indicesIndex ++ ] = strip[ j + 2 ];
|
|
|
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
- if ( i > 0 ) len0 = offset[ i - 1 ];
|
|
|
+ if ( i > 0 ) len0 = offset[ i - 1 ];
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
@@ -1024,48 +986,52 @@
|
|
|
// if it is polys
|
|
|
|
|
|
case 'Polys':
|
|
|
- var numberOfPolys = parseInt( piece.attributes.NumberOfPolys );
|
|
|
+ {
|
|
|
|
|
|
- if ( numberOfPolys > 0 ) {
|
|
|
+ const numberOfPolys = parseInt( piece.attributes.NumberOfPolys );
|
|
|
|
|
|
- var connectivity = new Int32Array( section.DataArray[ 0 ].text.length );
|
|
|
- var offset = new Int32Array( section.DataArray[ 1 ].text.length );
|
|
|
- connectivity.set( section.DataArray[ 0 ].text, 0 );
|
|
|
- offset.set( section.DataArray[ 1 ].text, 0 );
|
|
|
- var size = numberOfPolys + connectivity.length;
|
|
|
- indices = new Uint32Array( 3 * size - 9 * numberOfPolys );
|
|
|
- var indicesIndex = 0,
|
|
|
- connectivityIndex = 0;
|
|
|
- var i = 0,
|
|
|
- len = numberOfPolys,
|
|
|
- len0 = 0;
|
|
|
+ if ( numberOfPolys > 0 ) {
|
|
|
|
|
|
- while ( i < len ) {
|
|
|
+ const connectivity = new Int32Array( section.DataArray[ 0 ].text.length );
|
|
|
+ const offset = new Int32Array( section.DataArray[ 1 ].text.length );
|
|
|
+ connectivity.set( section.DataArray[ 0 ].text, 0 );
|
|
|
+ offset.set( section.DataArray[ 1 ].text, 0 );
|
|
|
+ const size = numberOfPolys + connectivity.length;
|
|
|
+ indices = new Uint32Array( 3 * size - 9 * numberOfPolys );
|
|
|
+ let indicesIndex = 0,
|
|
|
+ connectivityIndex = 0;
|
|
|
+ let i = 0,
|
|
|
+ len0 = 0;
|
|
|
+ const len = numberOfPolys;
|
|
|
|
|
|
- var poly = [];
|
|
|
- var s = 0,
|
|
|
- len1 = offset[ i ];
|
|
|
+ while ( i < len ) {
|
|
|
|
|
|
- while ( s < len1 - len0 ) {
|
|
|
+ const poly = [];
|
|
|
+ let s = 0;
|
|
|
+ const len1 = offset[ i ];
|
|
|
|
|
|
- poly.push( connectivity[ connectivityIndex ++ ] );
|
|
|
- s ++;
|
|
|
+ while ( s < len1 - len0 ) {
|
|
|
|
|
|
- }
|
|
|
+ poly.push( connectivity[ connectivityIndex ++ ] );
|
|
|
+ s ++;
|
|
|
|
|
|
- var j = 1;
|
|
|
+ }
|
|
|
|
|
|
- while ( j < len1 - len0 - 1 ) {
|
|
|
+ let j = 1;
|
|
|
|
|
|
- indices[ indicesIndex ++ ] = poly[ 0 ];
|
|
|
- indices[ indicesIndex ++ ] = poly[ j ];
|
|
|
- indices[ indicesIndex ++ ] = poly[ j + 1 ];
|
|
|
- j ++;
|
|
|
+ while ( j < len1 - len0 - 1 ) {
|
|
|
|
|
|
- }
|
|
|
+ indices[ indicesIndex ++ ] = poly[ 0 ];
|
|
|
+ indices[ indicesIndex ++ ] = poly[ j ];
|
|
|
+ indices[ indicesIndex ++ ] = poly[ j + 1 ];
|
|
|
+ j ++;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ i ++;
|
|
|
+ len0 = offset[ i - 1 ];
|
|
|
|
|
|
- i ++;
|
|
|
- len0 = offset[ i - 1 ];
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
@@ -1084,7 +1050,7 @@
|
|
|
|
|
|
}
|
|
|
|
|
|
- var geometry = new THREE.BufferGeometry();
|
|
|
+ const geometry = new THREE.BufferGeometry();
|
|
|
geometry.setIndex( new THREE.BufferAttribute( indices, 1 ) );
|
|
|
geometry.setAttribute( 'position', new THREE.BufferAttribute( points, 3 ) );
|
|
|
|
|
@@ -1105,7 +1071,7 @@
|
|
|
} // get the 5 first lines of the files to check if there is the key word binary
|
|
|
|
|
|
|
|
|
- var meta = THREE.LoaderUtils.decodeText( new Uint8Array( data, 0, 250 ) ).split( '\n' );
|
|
|
+ const meta = THREE.LoaderUtils.decodeText( new Uint8Array( data, 0, 250 ) ).split( '\n' );
|
|
|
|
|
|
if ( meta[ 0 ].indexOf( 'xml' ) !== - 1 ) {
|
|
|
|