<commit_before><!DOCTYPE html>

<html>

<head>
	<title>Collisions - Physijs</title>
	
	<link rel="stylesheet" type="text/css" href="css/styles.css" />
	
	<script type="text/javascript" src="js/three.min.js"></script>
	<script type="text/javascript" src="js/stats.js"></script>
	<script type="text/javascript" src="../physi.js"></script>
	
	<script type="text/javascript">
	
	'use strict';
	
	Physijs.scripts.worker = '../physijs_worker.js';
	Physijs.scripts.ammo = 'examples/js/ammo.js';
	
	var initScene, render, _boxes = [], spawnBox,
		renderer, render_stats, physics_stats, scene, ground_material, ground, light, camera;
	
	initScene = function() {
		renderer = new THREE.WebGLRenderer({ antialias: true });
		renderer.setSize( window.innerWidth, window.innerHeight );
		renderer.shadowMapEnabled = true;
		renderer.shadowMapSoft = true;
		document.getElementById( 'viewport' ).appendChild( renderer.domElement );
		
		render_stats = new Stats();
		render_stats.domElement.style.position = 'absolute';
		render_stats.domElement.style.top = '0px';
		render_stats.domElement.style.zIndex = 100;
		document.getElementById( 'viewport' ).appendChild( render_stats.domElement );
		
		physics_stats = new Stats();
		physics_stats.domElement.style.position = 'absolute';
		physics_stats.domElement.style.top = '50px';
		physics_stats.domElement.style.zIndex = 100;
		document.getElementById( 'viewport' ).appendChild( physics_stats.domElement );

		scene = new Physijs.Scene;
		scene.setGravity(new THREE.Vector3( 0, -30, 0 ));
		scene.addEventListener(
			'update',
			function() {
				scene.simulate( undefined, 1 );
				physics_stats.update();
			}
		);
		
		camera = new THREE.PerspectiveCamera(
			35,
			window.innerWidth / window.innerHeight,
			1,
			1000
		);
		camera.position.set( 60, 50, 60 );
		camera.lookAt( scene.position );
		scene.add( camera );
		
		// Light
		light = new THREE.DirectionalLight( 0xFFFFFF );
		light.position.set( 20, 40, -15 );
		light.target.position.copy( scene.position );
		light.castShadow = true;
		light.shadowCameraLeft = -60;
		light.shadowCameraTop = -60;
		light.shadowCameraRight = 60;
		light.shadowCameraBottom = 60;
		light.shadowCameraNear = 20;
		light.shadowCameraFar = 200;
		light.shadowBias = -.0001
		light.shadowMapWidth = light.shadowMapHeight = 2048;
		light.shadowDarkness = .7;
		scene.add( light );
		
		// Ground
		ground_material = Physijs.createMaterial(
			new THREE.MeshLambertMaterial({ map: THREE.ImageUtils.loadTexture( 'images/rocks.jpg' ) }),
			.8, // high friction
			.3 // low restitution
		);
		ground_material.map.wrapS = ground_material.map.wrapT = THREE.RepeatWrapping;
		ground_material.map.repeat.set( 3, 3 );
		
		ground = new Physijs.BoxMesh(
			new THREE.BoxGeometry(100, 1, 100),
			ground_material,
			0 // mass
		);
		ground.receiveShadow = true;
		scene.add( ground );
		
		spawnBox();
		
		requestAnimationFrame( render );
		scene.simulate();
	};
	
	spawnBox = (function() {
		var box_geometry = new THREE.BoxGeometry( 4, 4, 4 ),
			handleCollision = function( collided_with, linearVelocity, angularVelocity ) {
				switch ( ++this.collisions ) {
					
					case 1:
						this.material.color.setHex(0xcc8855);
						break;
					
					case 2:
						this.material.color.setHex(0xbb9955);
						break;
					
					case 3:
						this.material.color.setHex(0xaaaa55);
						break;
					
					case 4:
						this.material.color.setHex(0x99bb55);
						break;
					
					case 5:
						this.material.color.setHex(0x88cc55);
						break;
					
					case 6:
						this.material.color.setHex(0x77dd55);
						break;
				}
			},
			createBox = function() {
				var box, material;
				
				material = Physijs.createMaterial(
					new THREE.MeshLambertMaterial({ map: THREE.ImageUtils.loadTexture( 'images/plywood.jpg' ) }),
					.6, // medium friction
					.3 // low restitution
				);
				material.map.wrapS = material.map.wrapT = THREE.RepeatWrapping;
				material.map.repeat.set( .5, .5 );
				
				//material = new THREE.MeshLambertMaterial({ map: THREE.ImageUtils.loadTexture( 'images/rocks.jpg' ) });
				
				box = new Physijs.BoxMesh(
					box_geometry,
					material
				);
				box.collisions = 0;
				
				box.position.set(
					Math.random() * 15 - 7.5,
					25,
					Math.random() * 15 - 7.5
				);
				
				box.rotation.set(
					Math.random() * Math.PI,
					Math.random() * Math.PI,
					Math.random() * Math.PI
				);
				
				box.castShadow = true;
				box.addEventListener( 'collision', handleCollision );
				box.addEventListener( 'ready', spawnBox );
				scene.add( box );
			};
		
		return function() {
			setTimeout( createBox, 1000 );
		};
	})();
	
	render = function() {
		requestAnimationFrame( render );
		renderer.render( scene, camera );
		render_stats.update();
	};
	
	window.onload = initScene;
	
	</script>
</head>

<body>
	<div id="heading">
		<h1>Collisions</h1>
		<p>Demonstrating the collision callback</p>
	</div>
	<div id="viewport"></div>
</body>

</html><commit_msg>Update to three.js#69, ammo.js#2ca0f1b and fix whitespace<commit_after><!DOCTYPE html>

<html>

<head>
    <title>Collisions - Physijs</title>

    <link rel="stylesheet" type="text/css" href="css/styles.css" />

    <script type="text/javascript" src="js/three.69.min.js"></script>
    <script type="text/javascript" src="js/stats.js"></script>
    <script type="text/javascript" src="../physi.js"></script>

    <script type="text/javascript">

    'use strict';

    Physijs.scripts.worker = '../physijs_worker.js';
    Physijs.scripts.ammo = 'examples/js/ammo.2ca0f1b.js';

    var initScene, render, _boxes = [], spawnBox,
        renderer, render_stats, physics_stats, scene, ground_material, ground, light, camera;

    initScene = function() {
        renderer = new THREE.WebGLRenderer({ antialias: true });
        renderer.setSize( window.innerWidth, window.innerHeight );
        renderer.shadowMapEnabled = true;
        renderer.shadowMapSoft = true;
        document.getElementById( 'viewport' ).appendChild( renderer.domElement );

        render_stats = new Stats();
        render_stats.domElement.style.position = 'absolute';
        render_stats.domElement.style.top = '0px';
        render_stats.domElement.style.zIndex = 100;
        document.getElementById( 'viewport' ).appendChild( render_stats.domElement );

        physics_stats = new Stats();
        physics_stats.domElement.style.position = 'absolute';
        physics_stats.domElement.style.top = '50px';
        physics_stats.domElement.style.zIndex = 100;
        document.getElementById( 'viewport' ).appendChild( physics_stats.domElement );

        scene = new Physijs.Scene;
        scene.setGravity(new THREE.Vector3( 0, -30, 0 ));
        scene.addEventListener(
            'update',
            function() {
                scene.simulate( undefined, 1 );
                physics_stats.update();
            }
        );

        camera = new THREE.PerspectiveCamera(
            35,
            window.innerWidth / window.innerHeight,
            1,
            1000
        );
        camera.position.set( 60, 50, 60 );
        camera.lookAt( scene.position );
        scene.add( camera );

        // Light
        light = new THREE.DirectionalLight( 0xFFFFFF );
        light.position.set( 20, 40, -15 );
        light.target.position.copy( scene.position );
        light.castShadow = true;
        light.shadowCameraLeft = -60;
        light.shadowCameraTop = -60;
        light.shadowCameraRight = 60;
        light.shadowCameraBottom = 60;
        light.shadowCameraNear = 20;
        light.shadowCameraFar = 200;
        light.shadowBias = -.0001
        light.shadowMapWidth = light.shadowMapHeight = 2048;
        light.shadowDarkness = .7;
        scene.add( light );

        // Ground
        ground_material = Physijs.createMaterial(
            new THREE.MeshLambertMaterial({ map: THREE.ImageUtils.loadTexture( 'images/rocks.jpg' ) }),
            .8, // high friction
            .3 // low restitution
        );
        ground_material.map.wrapS = ground_material.map.wrapT = THREE.RepeatWrapping;
        ground_material.map.repeat.set( 3, 3 );

        ground = new Physijs.BoxMesh(
            new THREE.BoxGeometry(100, 1, 100),
            ground_material,
            0 // mass
        );
        ground.receiveShadow = true;
        scene.add( ground );

        spawnBox();

        requestAnimationFrame( render );
        scene.simulate();
    };

    spawnBox = (function() {
        var box_geometry = new THREE.BoxGeometry( 4, 4, 4 ),
            handleCollision = function( collided_with, linearVelocity, angularVelocity ) {
                switch ( ++this.collisions ) {

                    case 1:
                        this.material.color.setHex(0xcc8855);
                        break;

                    case 2:
                        this.material.color.setHex(0xbb9955);
                        break;

                    case 3:
                        this.material.color.setHex(0xaaaa55);
                        break;

                    case 4:
                        this.material.color.setHex(0x99bb55);
                        break;

                    case 5:
                        this.material.color.setHex(0x88cc55);
                        break;

                    case 6:
                        this.material.color.setHex(0x77dd55);
                        break;
                }
            },
            createBox = function() {
                var box, material;

                material = Physijs.createMaterial(
                    new THREE.MeshLambertMaterial({ map: THREE.ImageUtils.loadTexture( 'images/plywood.jpg' ) }),
                    .6, // medium friction
                    .3 // low restitution
                );
                material.map.wrapS = material.map.wrapT = THREE.RepeatWrapping;
                material.map.repeat.set( .5, .5 );

                //material = new THREE.MeshLambertMaterial({ map: THREE.ImageUtils.loadTexture( 'images/rocks.jpg' ) });

                box = new Physijs.BoxMesh(
                    box_geometry,
                    material
                );
                box.collisions = 0;

                box.position.set(
                    Math.random() * 15 - 7.5,
                    25,
                    Math.random() * 15 - 7.5
                );

                box.rotation.set(
                    Math.random() * Math.PI,
                    Math.random() * Math.PI,
                    Math.random() * Math.PI
                );

                box.castShadow = true;
                box.addEventListener( 'collision', handleCollision );
                box.addEventListener( 'ready', spawnBox );
                scene.add( box );
            };

        return function() {
            setTimeout( createBox, 1000 );
        };
    })();

    render = function() {
        requestAnimationFrame( render );
        renderer.render( scene, camera );
        render_stats.update();
    };

    window.onload = initScene;

    </script>
</head>

<body>
    <div id="heading">
        <h1>Collisions</h1>
        <p>Demonstrating the collision callback</p>
    </div>
    <div id="viewport"></div>
</body>

</html>
{'fraction_non_alphanumeric': 0.12700249199003205, 'fraction_numerical': 0.023495906016375936, 'mean_word_length': 2.0618528610354225, 'pattern_counts': {'":': 0, '<': 55, '<?xml version=': 0, '>': 55, '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': '1844233', 'n_tokens_mistral': 4003, 'n_tokens_neox': 3320, 'n_words': 643}