Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: Move to let/const, and clean up. #20487

Merged
merged 4 commits into from
Oct 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/api/zh/audio/Audio.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ <h2>代码示例</h2>

<code>
// create an AudioListener and add it to the camera
var listener = new THREE.AudioListener();
const listener = new THREE.AudioListener();
camera.add( listener );

// create a global audio source
var sound = new THREE.Audio( listener );
const sound = new THREE.Audio( listener );

// load a sound and set it as the Audio object's buffer
var audioLoader = new THREE.AudioLoader();
const audioLoader = new THREE.AudioLoader();
audioLoader.load( 'sounds/ambient.ogg', function( buffer ) {
sound.setBuffer( buffer );
sound.setLoop( true );
Expand Down
10 changes: 5 additions & 5 deletions docs/api/zh/audio/AudioAnalyser.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ <h2>代码示例</h2>

<code>
// create an AudioListener and add it to the camera
var listener = new THREE.AudioListener();
const listener = new THREE.AudioListener();
camera.add( listener );

// create an Audio source
var sound = new THREE.Audio( listener );
const sound = new THREE.Audio( listener );

// load a sound and set it as the Audio object's buffer
var audioLoader = new THREE.AudioLoader();
const audioLoader = new THREE.AudioLoader();
audioLoader.load( 'sounds/ambient.ogg', function( buffer ) {
sound.setBuffer( buffer );
sound.setLoop(true);
Expand All @@ -38,10 +38,10 @@ <h2>代码示例</h2>
});

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

// get the average frequency of the sound
var data = analyser.getAverageFrequency();
const data = analyser.getAverageFrequency();
</code>

<h2>例子</h2>
Expand Down
6 changes: 3 additions & 3 deletions docs/api/zh/audio/AudioListener.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ <h2>代码示例</h2>

<code>
// create an AudioListener and add it to the camera
var listener = new THREE.AudioListener();
const listener = new THREE.AudioListener();
camera.add( listener );

// create a global audio source
var sound = new THREE.Audio( listener );
const sound = new THREE.Audio( listener );

// load a sound and set it as the Audio object's buffer
var audioLoader = new THREE.AudioLoader();
const audioLoader = new THREE.AudioLoader();
audioLoader.load( 'sounds/ambient.ogg', function( buffer ) {
sound.setBuffer( buffer );
sound.setLoop(true);
Expand Down
12 changes: 6 additions & 6 deletions docs/api/zh/audio/PositionalAudio.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,24 @@ <h2>代码示例</h2>

<code>
// create an AudioListener and add it to the camera
var listener = new THREE.AudioListener();
const listener = new THREE.AudioListener();
camera.add( listener );

// create the PositionalAudio object (passing in the listener)
var sound = new THREE.PositionalAudio( listener );
const sound = new THREE.PositionalAudio( listener );

// load a sound and set it as the PositionalAudio object's buffer
var audioLoader = new THREE.AudioLoader();
const audioLoader = new THREE.AudioLoader();
audioLoader.load( 'sounds/song.ogg', function( buffer ) {
sound.setBuffer( buffer );
sound.setRefDistance( 20 );
sound.play();
});

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

// finally add the sound to the mesh
Expand Down
8 changes: 4 additions & 4 deletions docs/api/zh/cameras/CubeCamera.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ <h2>代码示例</h2>

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

// Create cube camera
var cubeCamera = new THREE.CubeCamera( 1, 100000, cubeRenderTarget );
const cubeCamera = new THREE.CubeCamera( 1, 100000, cubeRenderTarget );
scene.add( cubeCamera );

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

// Update the render target cube
Expand Down
2 changes: 1 addition & 1 deletion docs/api/zh/cameras/OrthographicCamera.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ <h1>正交相机([name])</h1>
<h2>代码示例</h2>

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

Expand Down
10 changes: 5 additions & 5 deletions docs/api/zh/cameras/PerspectiveCamera.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ <h1>透视相机([name])</h1>
<h2>代码示例</h2>

<code>
var camera = new THREE.PerspectiveCamera( 45, width / height, 1, 1000 );
const camera = new THREE.PerspectiveCamera( 45, width / height, 1, 1000 );
scene.add( camera );
</code>

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

<code>var w = 1920;
var h = 1080;
var fullWidth = w * 3;
var fullHeight = h * 2;
<code>const w = 1920;
const h = 1080;
const fullWidth = w * 3;
const fullHeight = h * 2;

// A
camera.setViewOffset( fullWidth, fullHeight, w * 0, h * 0, w, h );
Expand Down
2 changes: 1 addition & 1 deletion docs/api/zh/constants/CustomBlendingEquations.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ <h1>自定义混合方程常量(Custom Blending Equation Constants)</h1>
<h2>代码示例</h2>

<code>
var material = new THREE.MeshBasicMaterial( {color: 0x00ff00} );
const material = new THREE.MeshBasicMaterial( {color: 0x00ff00} );
material.blending = THREE.CustomBlending;
material.blendEquation = THREE.AddEquation; //default
material.blendSrc = THREE.SrcAlphaFactor; //default
Expand Down
8 changes: 4 additions & 4 deletions docs/api/zh/core/BufferGeometry.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ <h1>[name]</h1>

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

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

<h2>例子</h2>
Expand Down
12 changes: 4 additions & 8 deletions docs/api/zh/core/EventDispatcher.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,19 @@ <h2>代码示例</h2>
<code>
// 为自定义对象添加事件

var Car = function () {
class Car extends EventDispatcher {

this.start = function () {
start() {

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

};

};

// 将 EventDispatcher.prototype 与自定义对象 prototype 进行混合

Object.assign( Car.prototype, EventDispatcher.prototype );
}

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

var car = new Car();
const car = new Car();

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

Expand Down
12 changes: 6 additions & 6 deletions docs/api/zh/core/Face3.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@ <h1>[name]</h1>
<h2>代码示例</h2>

<code>
var material = new THREE.MeshStandardMaterial( { color : 0x00cc00 } );
const material = new THREE.MeshStandardMaterial( { color : 0x00cc00 } );

// 创建仅有一个三角形面的几何体
var geometry = new THREE.Geometry();
const geometry = new THREE.Geometry();
geometry.vertices.push( new THREE.Vector3( -50, -50, 0 ) );
geometry.vertices.push( new THREE.Vector3( 50, -50, 0 ) );
geometry.vertices.push( new THREE.Vector3( 50, 50, 0 ) );

// 利用顶点 0, 1, 2 创建一个面
var normal = new THREE.Vector3( 0, 0, 1 ); //optional
var color = new THREE.Color( 0xffaa00 ); //optional
var materialIndex = 0; //optional
var face = new THREE.Face3( 0, 1, 2, normal, color, materialIndex );
const normal = new THREE.Vector3( 0, 0, 1 ); //optional
const color = new THREE.Color( 0xffaa00 ); //optional
const materialIndex = 0; //optional
const face = new THREE.Face3( 0, 1, 2, normal, color, materialIndex );

// 将创建的面添加到几何体的面的队列
geometry.faces.push( face );
Expand Down
2 changes: 1 addition & 1 deletion docs/api/zh/core/Geometry.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ <h1>[name]</h1>
<h2>代码示例</h2>

<code>
var geometry = new THREE.Geometry();
const geometry = new THREE.Geometry();

geometry.vertices.push(
new THREE.Vector3( -10, 10, 0 ),
Expand Down
8 changes: 4 additions & 4 deletions docs/api/zh/core/Raycaster.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ <h1>光线投射[name]</h1>

<h2>代码示例</h2>
<code>
var raycaster = new THREE.Raycaster();
var mouse = new THREE.Vector2();
const raycaster = new THREE.Raycaster();
const mouse = new THREE.Vector2();

function onMouseMove( event ) {

Expand All @@ -35,9 +35,9 @@ <h2>代码示例</h2>
raycaster.setFromCamera( mouse, camera );

// 计算物体和射线的焦点
var intersects = raycaster.intersectObjects( scene.children );
const intersects = raycaster.intersectObjects( scene.children );

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

intersects[ i ].object.material.color.set( 0xff0000 );

Expand Down
4 changes: 2 additions & 2 deletions docs/api/zh/core/Uniform.html
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,11 @@ <h2>Structured Uniforms with Arrays</h2>
It's also possible to manage *structs* in arrays. The syntax for this use case looks like so:
</p>
<code>
var entry1 = {
const entry1 = {
position: new Vector3(),
direction: new Vector3( 0, 0, 1 )
};
var entry2 = {
const entry2 = {
position: new Vector3( 1, 1, 1 ),
direction: new Vector3( 0, 1, 0 )
};
Expand Down
10 changes: 5 additions & 5 deletions docs/api/zh/extras/core/Path.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@ <h1>路径([name])</h1>
<h2>代码示例</h2>

<code>
var path = new THREE.Path();
const path = new THREE.Path();

path.lineTo( 0, 0.8 );
path.quadraticCurveTo( 0, 1, 0.2, 1 );
path.lineTo( 1, 1 );

var points = path.getPoints();
const points = path.getPoints();

var geometry = new THREE.BufferGeometry().setFromPoints( points );
var material = new THREE.LineBasicMaterial( { color: 0xffffff } );
const geometry = new THREE.BufferGeometry().setFromPoints( points );
const material = new THREE.LineBasicMaterial( { color: 0xffffff } );

var line = new THREE.Line( geometry, material );
const line = new THREE.Line( geometry, material );
scene.add( line );
</code>

Expand Down
8 changes: 4 additions & 4 deletions docs/api/zh/extras/core/Shape.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ <h1>形状([name])</h1>
<h2>代码示例</h2>

<code>
var heartShape = new THREE.Shape();
const heartShape = new THREE.Shape();

heartShape.moveTo( 25, 25 );
heartShape.bezierCurveTo( 25, 25, 20, 0, 0, 0 );
Expand All @@ -30,11 +30,11 @@ <h2>代码示例</h2>
heartShape.bezierCurveTo( 80, 35, 80, 0, 50, 0 );
heartShape.bezierCurveTo( 35, 0, 25, 25, 25, 25 );

var extrudeSettings = { amount: 8, bevelEnabled: true, bevelSegments: 2, steps: 2, bevelSize: 1, bevelThickness: 1 };
const extrudeSettings = { amount: 8, bevelEnabled: true, bevelSegments: 2, steps: 2, bevelSize: 1, bevelThickness: 1 };

var geometry = new THREE.ExtrudeBufferGeometry( heartShape, extrudeSettings );
const geometry = new THREE.ExtrudeBufferGeometry( heartShape, extrudeSettings );

var mesh = new THREE.Mesh( geometry, new THREE.MeshPhongMaterial() );
const mesh = new THREE.Mesh( geometry, new THREE.MeshPhongMaterial() );
</code>

<h2>例子</h2>
Expand Down
10 changes: 5 additions & 5 deletions docs/api/zh/extras/curves/CatmullRomCurve3.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,21 @@ <h2>代码示例</h2>

<code>
//Create a closed wavey loop
var curve = new THREE.CatmullRomCurve3( [
const curve = new THREE.CatmullRomCurve3( [
new THREE.Vector3( -10, 0, 10 ),
new THREE.Vector3( -5, 5, 5 ),
new THREE.Vector3( 0, 0, 0 ),
new THREE.Vector3( 5, -5, 5 ),
new THREE.Vector3( 10, 0, 10 )
] );

var points = curve.getPoints( 50 );
var geometry = new THREE.BufferGeometry().setFromPoints( points );
const points = curve.getPoints( 50 );
const geometry = new THREE.BufferGeometry().setFromPoints( points );

var material = new THREE.LineBasicMaterial( { color : 0xff0000 } );
const material = new THREE.LineBasicMaterial( { color : 0xff0000 } );

// Create the final object to add to the scene
var curveObject = new THREE.Line( geometry, material );
const curveObject = new THREE.Line( geometry, material );
</code>

<h2>例子</h2>
Expand Down
10 changes: 5 additions & 5 deletions docs/api/zh/extras/curves/CubicBezierCurve.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,20 @@ <h1>二维三次贝塞尔曲线([name])</h1>
<h2>代码示例</h2>

<code>
var curve = new THREE.CubicBezierCurve(
const curve = new THREE.CubicBezierCurve(
new THREE.Vector2( -10, 0 ),
new THREE.Vector2( -5, 15 ),
new THREE.Vector2( 20, 15 ),
new THREE.Vector2( 10, 0 )
);

var points = curve.getPoints( 50 );
var geometry = new THREE.BufferGeometry().setFromPoints( points );
const points = curve.getPoints( 50 );
const geometry = new THREE.BufferGeometry().setFromPoints( points );

var material = new THREE.LineBasicMaterial( { color : 0xff0000 } );
const material = new THREE.LineBasicMaterial( { color : 0xff0000 } );

// Create the final object to add to the scene
var curveObject = new THREE.Line( geometry, material );
const curveObject = new THREE.Line( geometry, material );
</code>

<h2>构造函数</h2>
Expand Down
Loading