You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
earthquake_3d_viewer_front/three/docs/api/zh/lights/DirectionalLight.html

126 lines
4.4 KiB
HTML

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="utf-8" />
<base href="../../../" />
<script src="page.js"></script>
<link type="text/css" rel="stylesheet" href="page.css" />
</head>
<body>
[page:Object3D] &rarr; [page:Light] &rarr;
<h1>平行光([name]</h1>
<p class="desc">
平行光是沿着特定方向发射的光。这种光的表现像是无限远,从它发出的光线都是平行的。常常用平行光来模拟太阳光的效果。
太阳足够远,因此我们可以认为太阳的位置是无限远,所以我们认为从太阳发出的光线也都是平行的。<br /><br />
平行光可以投射阴影 - 跳转至 [page:DirectionalLightShadow] 查看更多细节。
</p>
<h2>关于位置、目标和旋转说明</h2>
<p>
Three.js 的平行光常见的困惑是设置旋转没有效果。这是因为 three.js 的平行光类似与其他引擎的“目标平行光”。
<br /><br />
这意味着它的方向是从一个平行光的位置 [page:Object3D.position position] 到 [page:.target target] 的位置。
(而不是一个只有旋转分量的“自由平行光”)。<br /><br />
这样做是为了让光线投射阴影。[page:.shadow shadow] 摄像机需要一个位置来计算阴影。<br /><br />
有关更新目标的详细信息,请参阅 [page:.target target] 下面的目标属性。
</p>
<h2>代码示例</h2>
<code>
// 从上方照射的白色平行光,强度为 0.5。
const directionalLight = new THREE.DirectionalLight( 0xffffff, 0.5 );
scene.add( directionalLight );
</code>
<h2>例子</h2>
<p>
[example:misc_controls_fly controls / fly ]<br />
[example:webgl_effects_parallaxbarrier effects / parallaxbarrier ]<br />
[example:webgl_effects_stereo effects / stereo ]<br />
[example:webgl_geometry_extrude_splines geometry / extrude / splines ]<br />
[example:webgl_materials_bumpmap materials / bumpmap ]
</p>
<h2>构造器</h2>
<h3>[name]( [param:Color color], [param:Float intensity] )</h3>
<p>
[page:Color color] -(可选)一个表示颜色的 Color 的实例、字符串或数字默认为一个白色0xffffff的 [page:Color Color] 对象。<br />
[page:Float intensity] -(可选)光照的强度。默认值为 1。<br /><br />
创建一个新的 [name]。
</p>
<h2>属性</h2>
<p>公共属性请查看基类 [page:Light Light]。</p>
<h3>[property:Boolean castShadow]</h3>
<p>
此属性设置为 `true` 灯光将投射阴影。*注意*:这样做的代价比较高,需要通过调整让阴影看起来正确。
查看 [page:DirectionalLightShadow] 了解详细信息。
默认值为 `false`。
</p>
<h3>[property:Boolean isDirectionalLight]</h3>
<p>
只读,用于检查对象的类型是否为 [name]。
</p>
<h3>[property:Vector3 position]</h3>
<p>
假如这个值设置为 [page:Object3D.DEFAULT_UP] (0, 1, 0),光线将会从上往下照射。
</p>
<h3>[property:DirectionalLightShadow shadow]</h3>
<p>
[page:DirectionalLightShadow] 对象,用于计算该平行光产生的阴影。
</p>
<h3>[property:Object3D target]</h3>
<p>
灯光从它的位置([page:.position position])指向目标位置。默认的目标位置为`(0, 0, 0)`。<br />
*注意*:对于目标的位置,如果要改为除默认值之外的其他位置,该位置必须被添加到场景([page:Scene scene])中去。
<code>
scene.add( light.target );
</code>
这是为了让目标的 [page:Object3D.matrixWorld matrixWorld] 在每一帧自动更新。<br /><br />
也可以将目标设置为场景中的其他对象(任意拥有 [page:Object3D.position position] 属性的对象),如:
<code>
const targetObject = new THREE.Object3D();
scene.add(targetObject);
light.target = targetObject;
</code>
通过上述操作,光源就可以追踪目标对象了。
</p>
<h2>方法</h2>
<p>公共方法请查看基类 [page:Light Light]。</p>
<h3>[method:undefined dispose]()</h3>
<p>
释放由该实例分配的 GPU 相关资源。 当这个实例不再在你的应用中使用时,调用这个方法。
</p>
<h3>[method:this copy]( [param:DirectionalLight source] )</h3>
<p>
复制 source 的值到这个平行光源对象。
</p>
<h2>源码</h2>
<p>
[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
</p>
</body>
</html>