Skip to content

Commit 9476ac3

Browse files
authored
Merge pull request #20484 from Mugen87/dev51
Docs: Move to let/const.
2 parents 9156391 + fe45628 commit 9476ac3

File tree

187 files changed

+970
-968
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

187 files changed

+970
-968
lines changed

docs/api/en/audio/Audio.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ <h2>Code Example</h2>
2222

2323
<code>
2424
// create an AudioListener and add it to the camera
25-
var listener = new THREE.AudioListener();
25+
const listener = new THREE.AudioListener();
2626
camera.add( listener );
2727

2828
// create a global audio source
29-
var sound = new THREE.Audio( listener );
29+
const sound = new THREE.Audio( listener );
3030

3131
// load a sound and set it as the Audio object's buffer
32-
var audioLoader = new THREE.AudioLoader();
32+
const audioLoader = new THREE.AudioLoader();
3333
audioLoader.load( 'sounds/ambient.ogg', function( buffer ) {
3434
sound.setBuffer( buffer );
3535
sound.setLoop( true );

docs/api/en/audio/AudioAnalyser.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ <h2>Code Example</h2>
2222

2323
<code>
2424
// create an AudioListener and add it to the camera
25-
var listener = new THREE.AudioListener();
25+
const listener = new THREE.AudioListener();
2626
camera.add( listener );
2727

2828
// create an Audio source
29-
var sound = new THREE.Audio( listener );
29+
const sound = new THREE.Audio( listener );
3030

3131
// load a sound and set it as the Audio object's buffer
32-
var audioLoader = new THREE.AudioLoader();
32+
const audioLoader = new THREE.AudioLoader();
3333
audioLoader.load( 'sounds/ambient.ogg', function( buffer ) {
3434
sound.setBuffer( buffer );
3535
sound.setLoop(true);
@@ -38,10 +38,10 @@ <h2>Code Example</h2>
3838
});
3939

4040
// create an AudioAnalyser, passing in the sound and desired fftSize
41-
var analyser = new THREE.AudioAnalyser( sound, 32 );
41+
const analyser = new THREE.AudioAnalyser( sound, 32 );
4242

4343
// get the average frequency of the sound
44-
var data = analyser.getAverageFrequency();
44+
const data = analyser.getAverageFrequency();
4545
</code>
4646

4747
<h2>Examples</h2>

docs/api/en/audio/AudioListener.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ <h2>Code Example</h2>
2222

2323
<code>
2424
// create an AudioListener and add it to the camera
25-
var listener = new THREE.AudioListener();
25+
const listener = new THREE.AudioListener();
2626
camera.add( listener );
2727

2828
// create a global audio source
29-
var sound = new THREE.Audio( listener );
29+
const sound = new THREE.Audio( listener );
3030

3131
// load a sound and set it as the Audio object's buffer
32-
var audioLoader = new THREE.AudioLoader();
32+
const audioLoader = new THREE.AudioLoader();
3333
audioLoader.load( 'sounds/ambient.ogg', function( buffer ) {
3434
sound.setBuffer( buffer );
3535
sound.setLoop(true);

docs/api/en/audio/PositionalAudio.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,24 @@ <h2>Code Example</h2>
2222

2323
<code>
2424
// create an AudioListener and add it to the camera
25-
var listener = new THREE.AudioListener();
25+
const listener = new THREE.AudioListener();
2626
camera.add( listener );
2727

2828
// create the PositionalAudio object (passing in the listener)
29-
var sound = new THREE.PositionalAudio( listener );
29+
const sound = new THREE.PositionalAudio( listener );
3030

3131
// load a sound and set it as the PositionalAudio object's buffer
32-
var audioLoader = new THREE.AudioLoader();
32+
const audioLoader = new THREE.AudioLoader();
3333
audioLoader.load( 'sounds/song.ogg', function( buffer ) {
3434
sound.setBuffer( buffer );
3535
sound.setRefDistance( 20 );
3636
sound.play();
3737
});
3838

3939
// create an object for the sound to play from
40-
var sphere = new THREE.SphereBufferGeometry( 20, 32, 16 );
41-
var material = new THREE.MeshPhongMaterial( { color: 0xff2200 } );
42-
var mesh = new THREE.Mesh( sphere, material );
40+
const sphere = new THREE.SphereBufferGeometry( 20, 32, 16 );
41+
const material = new THREE.MeshPhongMaterial( { color: 0xff2200 } );
42+
const mesh = new THREE.Mesh( sphere, material );
4343
scene.add( mesh );
4444

4545
// finally add the sound to the mesh

docs/api/en/cameras/CubeCamera.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ <h2>Code Example</h2>
1818

1919
<code>
2020
// Create cube render target
21-
var cubeRenderTarget = new THREE.WebGLCubeRenderTarget( 128, { format: THREE.RGBFormat, generateMipmaps: true, minFilter: THREE.LinearMipmapLinearFilter } );
21+
const cubeRenderTarget = new THREE.WebGLCubeRenderTarget( 128, { format: THREE.RGBFormat, generateMipmaps: true, minFilter: THREE.LinearMipmapLinearFilter } );
2222

2323
// Create cube camera
24-
var cubeCamera = new THREE.CubeCamera( 1, 100000, cubeRenderTarget );
24+
const cubeCamera = new THREE.CubeCamera( 1, 100000, cubeRenderTarget );
2525
scene.add( cubeCamera );
2626

2727
// Create car
28-
var chromeMaterial = new THREE.MeshLambertMaterial( { color: 0xffffff, envMap: cubeRenderTarget.texture } );
29-
var car = new Mesh( carGeometry, chromeMaterial );
28+
const chromeMaterial = new THREE.MeshLambertMaterial( { color: 0xffffff, envMap: cubeRenderTarget.texture } );
29+
const car = new Mesh( carGeometry, chromeMaterial );
3030
scene.add( car );
3131

3232
// Update the render target cube

docs/api/en/cameras/OrthographicCamera.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ <h1>[name]</h1>
2424
<h2>Code Example</h2>
2525

2626
<code>
27-
var camera = new THREE.OrthographicCamera( width / - 2, width / 2, height / 2, height / - 2, 1, 1000 );
27+
const camera = new THREE.OrthographicCamera( width / - 2, width / 2, height / 2, height / - 2, 1, 1000 );
2828
scene.add( camera );
2929
</code>
3030

docs/api/en/cameras/PerspectiveCamera.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ <h1>[name]</h1>
2222
<h2>Code Example</h2>
2323

2424
<code>
25-
var camera = new THREE.PerspectiveCamera( 45, width / height, 1, 1000 );
25+
const camera = new THREE.PerspectiveCamera( 45, width / height, 1, 1000 );
2626
scene.add( camera );
2727
</code>
2828

@@ -160,10 +160,10 @@ <h3>[method:null setViewOffset]( [param:Float fullWidth], [param:Float fullHeigh
160160

161161
then for each monitor you would call it like this:<br />
162162

163-
<code>var w = 1920;
164-
var h = 1080;
165-
var fullWidth = w * 3;
166-
var fullHeight = h * 2;
163+
<code>const w = 1920;
164+
const h = 1080;
165+
const fullWidth = w * 3;
166+
const fullHeight = h * 2;
167167

168168
// A
169169
camera.setViewOffset( fullWidth, fullHeight, w * 0, h * 0, w, h );

docs/api/en/constants/CustomBlendingEquations.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ <h1>Custom Blending Equation Constants</h1>
1717
<h2>Code Example</h2>
1818

1919
<code>
20-
var material = new THREE.MeshBasicMaterial( {color: 0x00ff00} );
20+
const material = new THREE.MeshBasicMaterial( {color: 0x00ff00} );
2121
material.blending = THREE.CustomBlending;
2222
material.blendEquation = THREE.AddEquation; //default
2323
material.blendSrc = THREE.SrcAlphaFactor; //default

docs/api/en/core/BufferGeometry.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ <h1>[name]</h1>
2424

2525
<h2>Code Example</h2>
2626
<code>
27-
var geometry = new THREE.BufferGeometry();
27+
const geometry = new THREE.BufferGeometry();
2828
// create a simple square shape. We duplicate the top left and bottom right
2929
// vertices because each vertex needs to appear once per triangle.
30-
var vertices = new Float32Array( [
30+
const vertices = new Float32Array( [
3131
-1.0, -1.0, 1.0,
3232
1.0, -1.0, 1.0,
3333
1.0, 1.0, 1.0,
@@ -39,8 +39,8 @@ <h2>Code Example</h2>
3939

4040
// itemSize = 3 because there are 3 values (components) per vertex
4141
geometry.setAttribute( 'position', new THREE.BufferAttribute( vertices, 3 ) );
42-
var material = new THREE.MeshBasicMaterial( { color: 0xff0000 } );
43-
var mesh = new THREE.Mesh( geometry, material );
42+
const material = new THREE.MeshBasicMaterial( { color: 0xff0000 } );
43+
const mesh = new THREE.Mesh( geometry, material );
4444
</code>
4545

4646
<h2>Examples</h2>

docs/api/en/core/EventDispatcher.html

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,27 +20,23 @@ <h2>Code Example</h2>
2020
<code>
2121
// Adding events to a custom object
2222

23-
var Car = function () {
23+
class Car extends EventDispatcher {
2424

25-
this.start = function () {
25+
start() {
2626

27-
this.dispatchEvent( { type: 'start', message: 'vroom vroom!' } );
27+
this.dispatchEvent( { type: 'start', message: 'vroom vroom!' } );
2828

29-
};
29+
}
3030

3131
};
3232

33-
// Mixing the EventDispatcher.prototype with the custom object prototype
34-
35-
Object.assign( Car.prototype, EventDispatcher.prototype );
36-
3733
// Using events with the custom object
3834

39-
var car = new Car();
35+
const car = new Car();
4036

4137
car.addEventListener( 'start', function ( event ) {
4238

43-
alert( event.message );
39+
alert( event.message );
4440

4541
} );
4642

0 commit comments

Comments
 (0)