<commit_before>/**
 * code to inject into the inspected page
 */
;(function(){
	
	
/**
 * define content script namespace
 * @type {Object}
 */
window.Inspect3js	= window.Inspect3js	|| {}

//////////////////////////////////////////////////////////////////////////////////
//		Comments
//////////////////////////////////////////////////////////////////////////////////
Inspect3js.reccursiveAddObject		= reccursiveAddObject
Inspect3js.reccursiveRemoveObject	= reccursiveRemoveObject
function reccursiveAddObject( object3d, parent ) {

	addObject( object3d, parent );

	// // in some rare conditions and broken demo, object3d.children is undefined
	// if( object3d.children === undefined )	return
	
	object3d.children.forEach( function( child ) {
		reccursiveAddObject( child, object3d  );
	} );

}
function reccursiveRemoveObject( object3d, parent ) {

	removeObject( object3d, parent );

	object3d.children.forEach( function( child ) {
		reccursiveRemoveObject( child, object3d  );
	} );

}

/**
 * adding object
 * @param {THREE.Object3D} object - 
 * @param {THREE.Object3D=} parent [description]
 */
function addObject( object, parent ) {
	// if( Inspect3js._objectsCache[ object.uuid ] !== undefined ) return
	Inspect3js._objectsCache[ object.uuid ] = object;

	var type = Inspect3js.getClassName( object );
	
	if( parent && ( type === 'PerspectiveCamera' || type === 'OrthographicCamera' ) ) {
		if( Inspect3js.getClassName( parent ) === 'Scene' ) {
			return;
		}
	}
	
	var label = type + (object.name ? ' - '+object.name: '')

	// console.log( '++ Adding Object ' + type + ' (' + object.uuid + ') (parent ' + ( parent?parent.uuid:'' ) + ')' );
	window.postMessage( { 
		source: 'ThreejsEditor', 
		method: 'addObject', 
		object3dUuid: object.uuid, 
		parentUuid: parent ? parent.uuid : null, 
		type: type, 
		label: label }
	, '*');
}

function removeObject( object, parent ) {

	//Inspect3js._objectsCache[ object.uuid ] = object;

	// var type = Inspect3js.getClassName( object );
	//console.log( '++ Removing Object ' + type + ' (' + object.uuid + ') (parent ' + ( parent?parent.uuid:'' ) + ')' );
	window.postMessage( {
		source	: 'ThreejsEditor', 
		method	: 'removeObject', 
		object3dUuid	: object.uuid, 
		parentUuid: parent ? parent.uuid : null
	}, '*');						
}


//////////////////////////////////////////////////////////////////////////////////
//		Comments
//////////////////////////////////////////////////////////////////////////////////

Inspect3js.instrumentWebGLRenderer	= function(renderer){
	var previousFunction = renderer.render;
	renderer.render = function(scene, camera) {
		previousFunction.apply( renderer, arguments );
		
		// reccursiveAddObject(scene)
		
		window.postMessage({
			source	: 'ThreejsEditor', 
			method	: 'render', 
			sceneId	: scene.uuid, 
			cameraId: camera.uuid
		}, '*');
	}
}
//////////////////////////////////////////////////////////////////////////////////
//		Comments
//////////////////////////////////////////////////////////////////////////////////

Inspect3js.instrumentObject	= function(object){
	if( object instanceof THREE.WebGLRenderer ) {
		Inspect3js.instrumentWebGLRenderer( object );			
	}else if( object instanceof THREE.Object3D ) {
		reccursiveAddObject( object );
	}
}

/**
 * instrument instanced objectsCache WebGLRenderer/Object3D in window.*
 * - aka totally ignore any others in closure or elsewhere ...
 */<commit_msg>no more notify render without need<commit_after>/**
 * code to inject into the inspected page
 */
;(function(){
	
	
/**
 * define content script namespace
 * @type {Object}
 */
window.Inspect3js	= window.Inspect3js	|| {}

//////////////////////////////////////////////////////////////////////////////////
//		Comments
//////////////////////////////////////////////////////////////////////////////////
Inspect3js.reccursiveAddObject		= reccursiveAddObject
Inspect3js.reccursiveRemoveObject	= reccursiveRemoveObject
function reccursiveAddObject( object3d, parent ) {

	addObject( object3d, parent );

	// // in some rare conditions and broken demo, object3d.children is undefined
	// if( object3d.children === undefined )	return
	
	object3d.children.forEach( function( child ) {
		reccursiveAddObject( child, object3d  );
	} );

}
function reccursiveRemoveObject( object3d, parent ) {

	removeObject( object3d, parent );

	object3d.children.forEach( function( child ) {
		reccursiveRemoveObject( child, object3d  );
	} );

}

/**
 * adding object
 * @param {THREE.Object3D} object - 
 * @param {THREE.Object3D=} parent [description]
 */
function addObject( object, parent ) {
	// if( Inspect3js._objectsCache[ object.uuid ] !== undefined ) return
	Inspect3js._objectsCache[ object.uuid ] = object;

	var type = Inspect3js.getClassName( object );
	
	if( parent && ( type === 'PerspectiveCamera' || type === 'OrthographicCamera' ) ) {
		if( Inspect3js.getClassName( parent ) === 'Scene' ) {
			return;
		}
	}
	
	var label = type + (object.name ? ' - '+object.name: '')

	// console.log( '++ Adding Object ' + type + ' (' + object.uuid + ') (parent ' + ( parent?parent.uuid:'' ) + ')' );
	window.postMessage( { 
		source: 'ThreejsEditor', 
		method: 'addObject', 
		object3dUuid: object.uuid, 
		parentUuid: parent ? parent.uuid : null, 
		type: type, 
		label: label }
	, '*');
}

function removeObject( object, parent ) {

	//Inspect3js._objectsCache[ object.uuid ] = object;

	// var type = Inspect3js.getClassName( object );
	//console.log( '++ Removing Object ' + type + ' (' + object.uuid + ') (parent ' + ( parent?parent.uuid:'' ) + ')' );
	window.postMessage( {
		source	: 'ThreejsEditor', 
		method	: 'removeObject', 
		object3dUuid	: object.uuid, 
		parentUuid: parent ? parent.uuid : null
	}, '*');						
}


//////////////////////////////////////////////////////////////////////////////////
//		Comments
//////////////////////////////////////////////////////////////////////////////////

Inspect3js.instrumentWebGLRenderer	= function(renderer){
	var previousFunction = renderer.render;
	renderer.render = function(scene, camera) {
		previousFunction.apply( renderer, arguments );
		
		// reccursiveAddObject(scene)
		
		// // notify render event 
		// // - disabled as it takes rescources and isnt used
		// window.postMessage({
		// 	source	: 'ThreejsEditor', 
		// 	method	: 'render', 
		// 	sceneId	: scene.uuid, 
		// 	cameraId: camera.uuid
		// }, '*');
	}
}
//////////////////////////////////////////////////////////////////////////////////
//		Comments
//////////////////////////////////////////////////////////////////////////////////

Inspect3js.instrumentObject	= function(object){
	if( object instanceof THREE.WebGLRenderer ) {
		Inspect3js.instrumentWebGLRenderer( object );			
	}else if( object instanceof THREE.Object3D ) {
		reccursiveAddObject( object );
	}
}

/**
 * instrument instanced objectsCache WebGLRenderer/Object3D in window.*
 * - aka totally ignore any others in closure or elsewhere ...
 */
{'fraction_non_alphanumeric': 0.26631062355658197, 'fraction_numerical': 0.008371824480369515, 'mean_word_length': 2.0632183908045976, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '3943828', 'n_tokens_mistral': 2135, 'n_tokens_neox': 1972, 'n_words': 430}