{"size": 2220, "ext": "js", "max_stars_repo_path": "archive/lib-spider/vtk-parser/v-2021-01-27/vtk-parser.js", "max_stars_repo_name": "ladybug-tools/spider-2021", "max_stars_repo_stars_event_min_datetime": "2021-08-28T04:23:24.000Z", "max_stars_repo_stars_event_max_datetime": "2021-10-20T18:19:10.000Z", "max_issues_repo_path": "archive/lib-spider/vtk-parser/v-2021-01-27/vtk-parser.js", "max_issues_repo_name": "ladybug-tools/spider-2021", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "archive/lib-spider/vtk-parser/v-2021-01-27/vtk-parser.js", "max_forks_repo_name": "ladybug-tools/spider-2021", "max_forks_repo_forks_event_min_datetime": "2021-11-06T19:55:32.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-06T19:55:32.000Z"}
{"max_stars_count": 4, "max_issues_count": null, "max_forks_count": 1, "avg_line_length": 20.9433962264, "max_line_length": 98, "alphanum_fraction": 0.654954955}
const VTK = {};

VTK.init = function ( url ) {

	//console.log( "", 23 );
	if ( VTK.vtkLoader === undefined ) {

		VTK.vtkLoader = document.body.appendChild( document.createElement( 'script' ) );
		VTK.vtkLoader.onload = () => VTK.loadUrl( url );
		VTK.vtkLoader.src = "https://cdn.jsdelivr.net/npm/three@0.131/examples/js/loaders/VTKLoader.js";

	} else {

		VTK.loadUrl( url );

	}

};


VTK.readVTK = function ( inpFiles ) {

	if ( VTK.vtkLoader === undefined ) {

		VTK.vtkLoader = document.body.appendChild( document.createElement( 'script' ) );
		VTK.vtkLoader.onload = () => VTK.readFile( inpFiles );
		VTK.vtkLoader.src = "https://cdn.jsdelivr.net/npm/three@0.131/examples/js/loaders/VTKLoader.js";

	} else {

		VTK.readFile( file );

	}


}


VTK.readFile = function ( inpFiles ) {

	console.log( "23", inpFiles );
	const reader = new FileReader();

	reader.addEventListener( "load", () => VTK.loadUrl( reader.result ), false );

	if ( inpFiles.files[ 0 ] ) { reader.readAsDataURL( inpFiles.files[ 0 ] ); }

}


VTK.loadUrl = function ( url ) {

	const loader = new THREE.VTKLoader();

	loader.load( url, function ( geometry ) {

		geometry.center();
		geometry.computeVertexNormals();

		const material = new THREE.MeshLambertMaterial( { color: 0xffffff } );
		const mesh = new THREE.Mesh( geometry, material );
		//mesh.position.set( - 0.075, 0.005, 0 );
		mesh.scale.multiplyScalar( 50 );
		scene.add( mesh );

	} );

}
VTK.parseString = function ( file ) {

	console.log( "vtk file", file );

	var meta = THREE.LoaderUtils.decodeText( new Uint8Array( file, 0, 250 ) ).split( '\n' );

	//json = JSON.parse( file );

	console.log( "json", meta );

	const loader = new THREE.VTKLoader();

	geometry = loader.parse( file );

	console.log( "geo", geometry );

	THR.group = THR.getGroupNew();

	geometry.computeVertexNormals();
	geometry.center();

	const material = new THREE.MeshLambertMaterial( { color: 0x00ff00 } );
	const mesh = new THREE.Mesh( geometry, material );

	mesh.position.set( - 0.025, 0, 0 );
	mesh.scale.multiplyScalar( 0.01 );


		THR.group.add( mesh );

	THR.zoomObjectBoundingSphere();
	//console.log( "VTK.asset", VTK.asset );

	//THR.updateScene();

	//THR.zoomObjectBoundingSphere();

};