Skip to content

Commit

Permalink
Examples: Fix build.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mugen87 committed Oct 13, 2020
1 parent 5a97571 commit 43986ef
Showing 1 changed file with 24 additions and 24 deletions.
48 changes: 24 additions & 24 deletions examples/webgl_math_obb.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@

import Stats from './jsm/libs/stats.module.js';

var camera, scene, renderer, clock, controls, stats, raycaster, hitbox;
let camera, scene, renderer, clock, controls, stats, raycaster, hitbox;

var objects = [], mouse = new THREE.Vector2();
const objects = [], mouse = new THREE.Vector2();

init();
animate();
Expand All @@ -49,21 +49,21 @@

raycaster = new THREE.Raycaster();

var hemiLight = new THREE.HemisphereLight( 0xffffff, 0x222222, 1.5 );
const hemiLight = new THREE.HemisphereLight( 0xffffff, 0x222222, 1.5 );
hemiLight.position.set( 1, 1, 1 );
scene.add( hemiLight );

var size = new THREE.Vector3( 10, 5, 6 );
var geometry = new THREE.BoxBufferGeometry( size.x, size.y, size.z );
const size = new THREE.Vector3( 10, 5, 6 );
const geometry = new THREE.BoxBufferGeometry( size.x, size.y, size.z );

// setup OBB on geometry level (doing this manually for now)

geometry.userData.obb = new OBB();
geometry.userData.obb.halfSize.copy( size ).multiplyScalar( 0.5 );

for ( var i = 0; i < 100; i ++ ) {
for ( let i = 0; i < 100; i ++ ) {

var object = new THREE.Mesh( geometry, new THREE.MeshLambertMaterial( { color: 0x00ff00 } ) );
const object = new THREE.Mesh( geometry, new THREE.MeshLambertMaterial( { color: 0x00ff00 } ) );
object.matrixAutoUpdate = false;

object.position.x = Math.random() * 80 - 40;
Expand Down Expand Up @@ -127,19 +127,19 @@

raycaster.setFromCamera( mouse, camera );

var intersectionPoint = new THREE.Vector3();
var intersections = [];
const intersectionPoint = new THREE.Vector3();
const intersections = [];

for ( var i = 0, il = objects.length; i < il; i ++ ) {
for ( let i = 0, il = objects.length; i < il; i ++ ) {

var object = objects[ i ];
var obb = object.userData.obb;
const object = objects[ i ];
const obb = object.userData.obb;

var ray = raycaster.ray;
const ray = raycaster.ray;

if ( obb.intersectRay( ray, intersectionPoint ) !== null ) {

var distance = ray.origin.distanceTo( intersectionPoint );
const distance = ray.origin.distanceTo( intersectionPoint );
intersections.push( { distance: distance, object: object } );

}
Expand All @@ -156,7 +156,7 @@

} else {

var parent = hitbox.parent;
const parent = hitbox.parent;

if ( parent ) parent.remove( hitbox );

Expand Down Expand Up @@ -189,11 +189,11 @@

// transform cubes

var delta = clock.getDelta();
const delta = clock.getDelta();

for ( var i = 0, il = objects.length; i < il; i ++ ) {
for ( let i = 0, il = objects.length; i < il; i ++ ) {

var object = objects[ i ];
const object = objects[ i ];

object.rotation.x += delta * Math.PI * 0.20;
object.rotation.y += delta * Math.PI * 0.1;
Expand All @@ -214,15 +214,15 @@

// collision detection

for ( var i = 0, il = objects.length; i < il; i ++ ) {
for ( let i = 0, il = objects.length; i < il; i ++ ) {

var object = objects[ i ];
var obb = object.userData.obb;
const object = objects[ i ];
const obb = object.userData.obb;

for ( var j = i + 1, jl = objects.length; j < jl; j ++ ) {
for ( let j = i + 1, jl = objects.length; j < jl; j ++ ) {

var objectToTest = objects[ j ];
var obbToTest = objectToTest.userData.obb;
const objectToTest = objects[ j ];
const obbToTest = objectToTest.userData.obb;

// now perform intersection test

Expand Down

0 comments on commit 43986ef

Please sign in to comment.