Skip to content

Commit

Permalink
Merge pull request #20507 from Mugen87/dev51
Browse files Browse the repository at this point in the history
Examples: More clean up.
  • Loading branch information
Mugen87 committed Oct 13, 2020
2 parents e8701d2 + 06a998b commit 2b082dc
Show file tree
Hide file tree
Showing 108 changed files with 2,176 additions and 2,117 deletions.
28 changes: 14 additions & 14 deletions examples/webgl_loader_3dm.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@

import { GUI } from './jsm/libs/dat.gui.module.js';

var container, controls;
var camera, scene, renderer;
var gui;
let container, controls;
let camera, scene, renderer;
let gui;

init();
animate();
Expand All @@ -39,13 +39,13 @@

scene = new THREE.Scene();

var directionalLight = new THREE.DirectionalLight( 0xffffff );
const directionalLight = new THREE.DirectionalLight( 0xffffff );
directionalLight.position.set( 0, 0, 2 );
directionalLight.castShadow = true;
directionalLight.intensity = 2;
scene.add( directionalLight );

var loader = new Rhino3dmLoader();
const loader = new Rhino3dmLoader();
loader.setLibraryPath( 'jsm/libs/rhino3dm/' );

loader.load( 'models/3dm/Rhino_Logo.3dm', function ( object ) {
Expand All @@ -55,8 +55,8 @@

} );

var width = window.innerWidth;
var height = window.innerHeight;
const width = window.innerWidth;
const height = window.innerHeight;

renderer = new THREE.WebGLRenderer( { antialias: true } );
renderer.setPixelRatio( window.devicePixelRatio );
Expand All @@ -71,8 +71,8 @@

function resize() {

var width = window.innerWidth;
var height = window.innerHeight;
const width = window.innerWidth;
const height = window.innerHeight;

camera.aspect = width / height;
camera.updateProjectionMatrix();
Expand All @@ -93,23 +93,23 @@
function initGUI( layers ) {

gui = new GUI( { width: 300 } );
var layersControl = gui.addFolder( 'layers' );
const layersControl = gui.addFolder( 'layers' );
layersControl.open();

for ( var i = 0; i < layers.length; i ++ ) {
for ( let i = 0; i < layers.length; i ++ ) {

var layer = layers[ i ];
const layer = layers[ i ];
layersControl.add( layer, 'visible' ).name( layer.name ).onChange( function ( val ) {

var name = this.object.name;
const name = this.object.name;

scene.traverse( function ( child ) {

if ( child.userData.hasOwnProperty( 'attributes' ) ) {

if ( 'layerIndex' in child.userData.attributes ) {

var layerName = layers[ child.userData.attributes.layerIndex ].name;
const layerName = layers[ child.userData.attributes.layerIndex ].name;

if ( layerName === name ) {

Expand Down
11 changes: 5 additions & 6 deletions examples/webgl_loader_3ds.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
import { TrackballControls } from './jsm/controls/TrackballControls.js';
import { TDSLoader } from './jsm/loaders/TDSLoader.js';

var container, controls;
var camera, scene, renderer;
let container, controls;
let camera, scene, renderer;

init();
animate();
Expand All @@ -36,15 +36,14 @@
scene = new THREE.Scene();
scene.add( new THREE.HemisphereLight() );

var directionalLight = new THREE.DirectionalLight( 0xffeedd );
const directionalLight = new THREE.DirectionalLight( 0xffeedd );
directionalLight.position.set( 0, 0, 2 );
scene.add( directionalLight );

//3ds files dont store normal maps
var loader = new THREE.TextureLoader();
var normal = loader.load( 'models/3ds/portalgun/textures/normal.jpg' );
const normal = new THREE.TextureLoader().load( 'models/3ds/portalgun/textures/normal.jpg' );

var loader = new TDSLoader( );
const loader = new TDSLoader( );
loader.setResourcePath( 'models/3ds/portalgun/textures/' );
loader.load( 'models/3ds/portalgun/portalgun.3ds', function ( object ) {

Expand Down
16 changes: 8 additions & 8 deletions examples/webgl_loader_3mf.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
import { ThreeMFLoader } from './jsm/loaders/3MFLoader.js';
import { GUI } from './jsm/libs/dat.gui.module.js';

var camera, scene, renderer, object, loader, controls;
let camera, scene, renderer, object, loader, controls;

var params = {
const params = {
asset: 'cube_gears'
};

var assets = [
const assets = [
'cube_gears',
'facecolors',
'multipletextures',
Expand Down Expand Up @@ -69,15 +69,15 @@
controls.enablePan = false;
controls.update();

var pointLight = new THREE.PointLight( 0xffffff, 0.8 );
const pointLight = new THREE.PointLight( 0xffffff, 0.8 );
camera.add( pointLight );

var manager = new THREE.LoadingManager();
const manager = new THREE.LoadingManager();

manager.onLoad = function () {

var aabb = new THREE.Box3().setFromObject( object );
var center = aabb.getCenter( new THREE.Vector3() );
const aabb = new THREE.Box3().setFromObject( object );
const center = aabb.getCenter( new THREE.Vector3() );

object.position.x += ( object.position.x - center.x );
object.position.y += ( object.position.y - center.y );
Expand All @@ -97,7 +97,7 @@

//

var gui = new GUI( { width: 300 } );
const gui = new GUI( { width: 300 } );
gui.add( params, 'asset', assets ).onChange( function ( value ) {

loadAsset( value );
Expand Down
16 changes: 8 additions & 8 deletions examples/webgl_loader_3mf_materials.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import { OrbitControls } from './jsm/controls/OrbitControls.js';
import { ThreeMFLoader } from './jsm/loaders/3MFLoader.js';

var camera, scene, renderer;
let camera, scene, renderer;

init();

Expand All @@ -40,11 +40,11 @@

//

var hemiLight = new THREE.HemisphereLight( 0xffffff, 0x444444 );
const hemiLight = new THREE.HemisphereLight( 0xffffff, 0x444444 );
hemiLight.position.set( 0, 100, 0 );
scene.add( hemiLight );

var dirLight = new THREE.DirectionalLight( 0xffffff );
const dirLight = new THREE.DirectionalLight( 0xffffff );
dirLight.position.set( - 0, 40, 50 );
dirLight.castShadow = true;
dirLight.shadow.camera.top = 50;
Expand All @@ -56,13 +56,13 @@
dirLight.shadow.mapSize.set( 1024, 1024 );
scene.add( dirLight );

// scene.add( new CameraHelper( dirLight.shadow.camera ) );
// scene.add( new THREE.CameraHelper( dirLight.shadow.camera ) );

//

var manager = new THREE.LoadingManager();
const manager = new THREE.LoadingManager();

var loader = new ThreeMFLoader( manager );
const loader = new ThreeMFLoader( manager );
loader.load( './models/3mf/truck.3mf', function ( object ) {

object.quaternion.setFromEuler( new THREE.Euler( - Math.PI / 2, 0, 0 ) ); // z-up conversion
Expand All @@ -87,7 +87,7 @@

//

var ground = new THREE.Mesh( new THREE.PlaneBufferGeometry( 1000, 1000 ), new THREE.MeshPhongMaterial( { color: 0x999999, depthWrite: false } ) );
const ground = new THREE.Mesh( new THREE.PlaneBufferGeometry( 1000, 1000 ), new THREE.MeshPhongMaterial( { color: 0x999999, depthWrite: false } ) );
ground.rotation.x = - Math.PI / 2;
ground.position.y = 11;
ground.receiveShadow = true;
Expand All @@ -105,7 +105,7 @@

//

var controls = new OrbitControls( camera, renderer.domElement );
const controls = new OrbitControls( camera, renderer.domElement );
controls.addEventListener( 'change', render );
controls.minDistance = 50;
controls.maxDistance = 200;
Expand Down
8 changes: 4 additions & 4 deletions examples/webgl_loader_amf.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import { OrbitControls } from './jsm/controls/OrbitControls.js';
import { AMFLoader } from './jsm/loaders/AMFLoader.js';

var camera, scene, renderer;
let camera, scene, renderer;

init();

Expand All @@ -48,7 +48,7 @@

scene.add( camera );

var grid = new THREE.GridHelper( 50, 50, 0xffffff, 0x555555 );
const grid = new THREE.GridHelper( 50, 50, 0xffffff, 0x555555 );
grid.rotateOnAxis( new THREE.Vector3( 1, 0, 0 ), 90 * ( Math.PI / 180 ) );
scene.add( grid );

Expand All @@ -57,15 +57,15 @@
renderer.setSize( window.innerWidth, window.innerHeight );
document.body.appendChild( renderer.domElement );

var loader = new AMFLoader();
const loader = new AMFLoader();
loader.load( './models/amf/rook.amf', function ( amfobject ) {

scene.add( amfobject );
render();

} );

var controls = new OrbitControls( camera, renderer.domElement );
const controls = new OrbitControls( camera, renderer.domElement );
controls.addEventListener( 'change', render );
controls.target.set( 0, 1.2, 2 );
controls.update();
Expand Down
16 changes: 8 additions & 8 deletions examples/webgl_loader_assimp.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
import { OrbitControls } from './jsm/controls/OrbitControls.js';
import { AssimpLoader } from './jsm/loaders/AssimpLoader.js';

var container, stats;
var camera, scene, renderer;
var animation;
let container, stats;
let camera, scene, renderer;
let animation;

init();

Expand All @@ -41,11 +41,11 @@

scene = new THREE.Scene();

var ambient = new THREE.HemisphereLight( 0x8888fff, 0xff8888, 0.5 );
const ambient = new THREE.HemisphereLight( 0x8888fff, 0xff8888, 0.5 );
ambient.position.set( 0, 1, 0 );
scene.add( ambient );

var light = new THREE.DirectionalLight( 0xffffff, 1 );
const light = new THREE.DirectionalLight( 0xffffff, 1 );
light.position.set( 0, 4, 4 ).normalize();
scene.add( light );

Expand All @@ -54,17 +54,17 @@
renderer.setSize( window.innerWidth, window.innerHeight );
container.appendChild( renderer.domElement );

var controls = new OrbitControls( camera, renderer.domElement );
const controls = new OrbitControls( camera, renderer.domElement );
controls.minDistance = 750;
controls.maxDistance = 2500;

stats = new Stats();
container.appendChild( stats.dom );

var loader = new AssimpLoader();
const loader = new AssimpLoader();
loader.load( './models/assimp/octaminator/Octaminator.assimp', function ( result ) {

var object = result.object;
const object = result.object;

object.position.y = - 100;
object.rotation.x = Math.PI / 2;
Expand Down
12 changes: 6 additions & 6 deletions examples/webgl_loader_bvh.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,21 @@
import { OrbitControls } from './jsm/controls/OrbitControls.js';
import { BVHLoader } from './jsm/loaders/BVHLoader.js';

var clock = new THREE.Clock();
const clock = new THREE.Clock();

var camera, controls, scene, renderer;
var mixer, skeletonHelper;
let camera, controls, scene, renderer;
let mixer, skeletonHelper;

init();
animate();

var loader = new BVHLoader();
const loader = new BVHLoader();
loader.load( "models/bvh/pirouette.bvh", function ( result ) {

skeletonHelper = new THREE.SkeletonHelper( result.skeleton.bones[ 0 ] );
skeletonHelper.skeleton = result.skeleton; // allow animation mixer to bind to THREE.SkeletonHelper directly

var boneContainer = new THREE.Group();
const boneContainer = new THREE.Group();
boneContainer.add( result.skeleton.bones[ 0 ] );

scene.add( skeletonHelper );
Expand Down Expand Up @@ -91,7 +91,7 @@

requestAnimationFrame( animate );

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

if ( mixer ) mixer.update( delta );

Expand Down
14 changes: 7 additions & 7 deletions examples/webgl_loader_collada.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@

import { ColladaLoader } from './jsm/loaders/ColladaLoader.js';

var container, stats, clock;
var camera, scene, renderer, elf;
let container, stats, clock;
let camera, scene, renderer, elf;

init();
animate();
Expand All @@ -42,15 +42,15 @@

// loading manager

var loadingManager = new THREE.LoadingManager( function () {
const loadingManager = new THREE.LoadingManager( function () {

scene.add( elf );

} );

// collada

var loader = new ColladaLoader( loadingManager );
const loader = new ColladaLoader( loadingManager );
loader.load( './models/collada/elf/elf.dae', function ( collada ) {

elf = collada.scene;
Expand All @@ -59,10 +59,10 @@

//

var ambientLight = new THREE.AmbientLight( 0xcccccc, 0.4 );
const ambientLight = new THREE.AmbientLight( 0xcccccc, 0.4 );
scene.add( ambientLight );

var directionalLight = new THREE.DirectionalLight( 0xffffff, 0.8 );
const directionalLight = new THREE.DirectionalLight( 0xffffff, 0.8 );
directionalLight.position.set( 1, 1, 0 ).normalize();
scene.add( directionalLight );

Expand Down Expand Up @@ -104,7 +104,7 @@

function render() {

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

if ( elf !== undefined ) {

Expand Down
Loading

0 comments on commit 2b082dc

Please sign in to comment.