<commit_before>/**
 * @author Mugen87 / https://github.com/Mugen87
 */

import * as THREE from 'https://cdn.jsdelivr.net/npm/three@0.109/build/three.module.js';

function createConvexRegionHelper( navMesh ) {

	const regions = navMesh.regions;

	const geometry = new THREE.BufferGeometry();
	const material = new THREE.MeshBasicMaterial( { vertexColors: THREE.VertexColors } );

	const mesh = new THREE.Mesh( geometry, material );

	const positions = [];
	const colors = [];

	const color = new THREE.Color();

	for ( let region of regions ) {

		// one color for each convex region

		color.setHex( Math.random() * 0xffffff );

		// count edges

		let edge = region.edge;
		const edges = [];

		do {

			edges.push( edge );

			edge = edge.next;

		} while ( edge !== region.edge );

		// triangulate

		const triangleCount = ( edges.length - 2 );

		for ( let i = 1, l = triangleCount; i <= l; i ++ ) {

			const v1 = edges[ 0 ].vertex;
			const v2 = edges[ i + 0 ].vertex;
			const v3 = edges[ i + 1 ].vertex;

			positions.push( v1.x, v1.y, v1.z );
			positions.push( v2.x, v2.y, v2.z );
			positions.push( v3.x, v3.y, v3.z );

			colors.push( color.r, color.g, color.b );
			colors.push( color.r, color.g, color.b );
			colors.push( color.r, color.g, color.b );

		}

	}

	geometry.addAttribute( 'position', new THREE.Float32BufferAttribute( positions, 3 ) );
	geometry.addAttribute( 'color', new THREE.Float32BufferAttribute( colors, 3 ) );

	return mesh;

}


export { createConvexRegionHelper };
<commit_msg>Update NavMeshHelper.js (#69)<commit_after>/**
 * @author Mugen87 / https://github.com/Mugen87
 */

import * as THREE from 'https://cdn.jsdelivr.net/npm/three@0.109/build/three.module.js';

function createConvexRegionHelper( navMesh ) {

	const regions = navMesh.regions;

	const geometry = new THREE.BufferGeometry();
	const material = new THREE.MeshBasicMaterial( { vertexColors: THREE.VertexColors } );

	const mesh = new THREE.Mesh( geometry, material );

	const positions = [];
	const colors = [];

	const color = new THREE.Color();

	for ( let region of regions ) {

		// one color for each convex region

		color.setHex( Math.random() * 0xffffff );

		// count edges

		let edge = region.edge;
		const edges = [];

		do {

			edges.push( edge );

			edge = edge.next;

		} while ( edge !== region.edge );

		// triangulate

		const triangleCount = ( edges.length - 2 );

		for ( let i = 1, l = triangleCount; i <= l; i ++ ) {

			const v1 = edges[ 0 ].vertex;
			const v2 = edges[ i + 0 ].vertex;
			const v3 = edges[ i + 1 ].vertex;

			positions.push( v1.x, v1.y, v1.z );
			positions.push( v2.x, v2.y, v2.z );
			positions.push( v3.x, v3.y, v3.z );

			colors.push( color.r, color.g, color.b );
			colors.push( color.r, color.g, color.b );
			colors.push( color.r, color.g, color.b );

		}

	}

	geometry.setAttribute( 'position', new THREE.Float32BufferAttribute( positions, 3 ) );
	geometry.setAttribute( 'color', new THREE.Float32BufferAttribute( colors, 3 ) );

	return mesh;

}


export { createConvexRegionHelper };

{'fraction_non_alphanumeric': 0.15223097112860892, 'fraction_numerical': 0.021653543307086614, 'mean_word_length': 3.054521276595745, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3009306', 'n_tokens_mistral': 1215, 'n_tokens_neox': 1035, 'n_words': 280}