Skip to content

Commit 03b3871

Browse files
authored
Merge pull request #20487 from linbingquan/dev-docs
Docs: Move to let/const, and clean up.
2 parents 84182a5 + 712f5cb commit 03b3871

File tree

181 files changed

+658
-655
lines changed

Some content is hidden

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

181 files changed

+658
-655
lines changed

docs/api/zh/audio/Audio.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ <h2>代码示例</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/zh/audio/AudioAnalyser.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ <h2>代码示例</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>代码示例</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>例子</h2>

docs/api/zh/audio/AudioListener.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ <h2>代码示例</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/zh/audio/PositionalAudio.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,24 @@ <h2>代码示例</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/zh/cameras/CubeCamera.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ <h2>代码示例</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/zh/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>代码示例</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/zh/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>代码示例</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

@@ -154,10 +154,10 @@ <h3>[method:null setViewOffset]( [param:Float fullWidth], [param:Float fullHeigh
154154
</pre>
155155
那对于每个显示器,你可以这样来设置、调用:<br />
156156

157-
<code>var w = 1920;
158-
var h = 1080;
159-
var fullWidth = w * 3;
160-
var fullHeight = h * 2;
157+
<code>const w = 1920;
158+
const h = 1080;
159+
const fullWidth = w * 3;
160+
const fullHeight = h * 2;
161161

162162
// A
163163
camera.setViewOffset( fullWidth, fullHeight, w * 0, h * 0, w, h );

docs/api/zh/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>代码示例</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/zh/core/BufferGeometry.html

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

2424
<h2>代码示例</h2>
2525
<code>
26-
var geometry = new THREE.BufferGeometry();
26+
const geometry = new THREE.BufferGeometry();
2727
// 创建一个简单的矩形. 在这里我们左上和右下顶点被复制了两次。
2828
// 因为在两个三角面片里,这两个顶点都需要被用到。
29-
var vertices = new Float32Array( [
29+
const vertices = new Float32Array( [
3030
-1.0, -1.0, 1.0,
3131
1.0, -1.0, 1.0,
3232
1.0, 1.0, 1.0,
@@ -38,8 +38,8 @@ <h2>代码示例</h2>
3838

3939
// itemSize = 3 因为每个顶点都是一个三元组。
4040
geometry.setAttribute( 'position', new THREE.BufferAttribute( vertices, 3 ) );
41-
var material = new THREE.MeshBasicMaterial( { color: 0xff0000 } );
42-
var mesh = new THREE.Mesh( geometry, material );
41+
const material = new THREE.MeshBasicMaterial( { color: 0xff0000 } );
42+
const mesh = new THREE.Mesh( geometry, material );
4343
</code>
4444

4545
<h2>例子</h2>

docs/api/zh/core/EventDispatcher.html

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,19 @@ <h2>代码示例</h2>
2020
<code>
2121
// 为自定义对象添加事件
2222

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

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

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

2929
};
3030

31-
};
32-
33-
// 将 EventDispatcher.prototype 与自定义对象 prototype 进行混合
34-
35-
Object.assign( Car.prototype, EventDispatcher.prototype );
31+
}
3632

3733
// 使用自定义对象的事件
3834

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

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

0 commit comments

Comments
 (0)