Skip to content

Commit 342946c

Browse files
committed
Examples: webgl_loader_3dm clean up.
1 parent 2aa9472 commit 342946c

File tree

1 file changed

+24
-31
lines changed

1 file changed

+24
-31
lines changed

examples/webgl_loader_3dm.html

Lines changed: 24 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,21 @@
88
<style>
99
#loader {
1010
border: 5px solid #f3f3f3; /* Light grey */
11-
border-top: 5px solid #3d3d3d; /* Grey */
12-
border-radius: 50%;
13-
width: 40px;
14-
height: 40px;
15-
animation: spin 1s linear infinite;
16-
position: absolute;
17-
top: 50%;
18-
left: 50%;
19-
z-index: 2;
20-
}
21-
11+
border-top: 5px solid #3d3d3d; /* Grey */
12+
border-radius: 50%;
13+
width: 40px;
14+
height: 40px;
15+
animation: spin 1s linear infinite;
16+
position: absolute;
17+
top: 50%;
18+
left: 50%;
19+
z-index: 2;
20+
}
21+
2222
@keyframes spin {
23-
0% { transform: rotate(0deg); }
24-
100% { transform: rotate(360deg); }
25-
}
23+
0% { transform: rotate(0deg); }
24+
100% { transform: rotate(360deg); }
25+
}
2626
</style>
2727
</head>
2828

@@ -41,33 +41,33 @@
4141

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

44-
let container, controls;
4544
let camera, scene, renderer;
46-
let gui;
45+
let controls, gui;
4746

4847
init();
4948
animate();
5049

5150
function init() {
5251

5352
THREE.Object3D.DefaultUp = new THREE.Vector3( 0, 0, 1 );
54-
container = document.createElement( 'div' );
55-
document.body.appendChild( container );
53+
54+
renderer = new THREE.WebGLRenderer( { antialias: true } );
55+
renderer.setPixelRatio( window.devicePixelRatio );
56+
renderer.setSize( window.innerWidth, window.innerHeight );
57+
renderer.outputEncoding = THREE.sRGBEncoding;
58+
document.body.appendChild( renderer.domElement );
5659

5760
camera = new THREE.PerspectiveCamera( 60, window.innerWidth / window.innerHeight, 1, 1000 );
5861
camera.position.set( 26, - 40, 5 );
5962

6063
scene = new THREE.Scene();
6164

62-
const directionalLight = new THREE.DirectionalLight( 0xffffff );
65+
const directionalLight = new THREE.DirectionalLight( 0xffffff, 2 );
6366
directionalLight.position.set( 0, 0, 2 );
64-
directionalLight.castShadow = true;
65-
directionalLight.intensity = 2;
6667
scene.add( directionalLight );
6768

6869
const loader = new Rhino3dmLoader();
6970
loader.setLibraryPath( 'https://cdn.jsdelivr.net/npm/[email protected]/' );
70-
7171
loader.load( 'models/3dm/Rhino_Logo.3dm', function ( object ) {
7272

7373
scene.add( object );
@@ -78,15 +78,7 @@
7878

7979
} );
8080

81-
const width = window.innerWidth;
82-
const height = window.innerHeight;
83-
84-
renderer = new THREE.WebGLRenderer( { antialias: true } );
85-
renderer.setPixelRatio( window.devicePixelRatio );
86-
renderer.setSize( width, height );
87-
container.appendChild( renderer.domElement );
88-
89-
controls = new OrbitControls( camera, container );
81+
controls = new OrbitControls( camera, renderer.domElement );
9082

9183
window.addEventListener( 'resize', resize );
9284

@@ -116,6 +108,7 @@
116108
function initGUI( layers ) {
117109

118110
gui = new GUI( { width: 300 } );
111+
119112
const layersControl = gui.addFolder( 'layers' );
120113
layersControl.open();
121114

0 commit comments

Comments
 (0)