|
@@ -106,11 +106,11 @@ scene.add(mesh);
|
|
}
|
|
}
|
|
```
|
|
```
|
|
|
|
|
|
-빛을 받을 물체를 만들었으니 이제 조명을 추가해보죠!
|
|
|
|
|
|
+빛을 받을 물체를 만들었으니 이제 조명을 가지고 놀아봅시다!
|
|
|
|
|
|
## `AmbientLight`
|
|
## `AmbientLight`
|
|
|
|
|
|
-먼저 `AmbientLight`를 써보겠습니다.
|
|
|
|
|
|
+먼저 `AmbientLight`(자연광)를 써보겠습니다.
|
|
|
|
|
|
```js
|
|
```js
|
|
const color = 0xFFFFFF;
|
|
const color = 0xFFFFFF;
|
|
@@ -119,16 +119,11 @@ const light = new THREE.AmbientLight(color, intensity);
|
|
scene.add(light);
|
|
scene.add(light);
|
|
```
|
|
```
|
|
|
|
|
|
-Let's also make it so we can adjust the light's parameters.
|
|
|
|
-We'll use [dat.GUI](https://github.com/dataarts/dat.gui) again.
|
|
|
|
-To be able to adjust the color via dat.GUI we need a small helper
|
|
|
|
-that presents a property to dat.GUI that looks like a CSS hex color string
|
|
|
|
-(eg: `#FF8844`). Our helper will get the color from a named property,
|
|
|
|
-convert it to a hex string to offer to dat.GUI. When dat.GUI tries
|
|
|
|
-to set the helper's property we'll assign the result back to the light's
|
|
|
|
-color.
|
|
|
|
-
|
|
|
|
-Here's the helper:
|
|
|
|
|
|
+이 조명도 [dat.GUI](https://github.com/dataarts/dat.gui)를 사용해
|
|
|
|
+속성을 조정할 수 있도록 만들겠습니다. dat.GUI로 색상을 조정하려면 간단한
|
|
|
|
+헬퍼 클래스가 필요합니다. 이 클래스는 색상을 CSS hex(예: `#FF8844`) 값으로
|
|
|
|
+변경해 dat.GUI에 넘겨주는 역할을 할 거예요. 그리고 dat.GUI가 클래스의
|
|
|
|
+속성을 지정할 때, 이를 조명에 직접 지정하도록 합니다.
|
|
|
|
|
|
```js
|
|
```js
|
|
class ColorGUIHelper {
|
|
class ColorGUIHelper {
|
|
@@ -145,7 +140,7 @@ class ColorGUIHelper {
|
|
}
|
|
}
|
|
```
|
|
```
|
|
|
|
|
|
-And here's our code setting up dat.GUI
|
|
|
|
|
|
+아래는 dat.GUI를 만드는 코드입니다.
|
|
|
|
|
|
```js
|
|
```js
|
|
const gui = new GUI();
|
|
const gui = new GUI();
|
|
@@ -153,45 +148,39 @@ gui.addColor(new ColorGUIHelper(light, 'color'), 'value').name('color');
|
|
gui.add(light, 'intensity', 0, 2, 0.01);
|
|
gui.add(light, 'intensity', 0, 2, 0.01);
|
|
```
|
|
```
|
|
|
|
|
|
-And here's the result
|
|
|
|
|
|
+결과물은 다음과 같죠.
|
|
|
|
|
|
{{{example url="../threejs-lights-ambient.html" }}}
|
|
{{{example url="../threejs-lights-ambient.html" }}}
|
|
|
|
|
|
-Click and drag in the scene to *orbit* the camera.
|
|
|
|
|
|
+카메라를 *공전시키기(orbit)* 위해 화면을 드래그해보세요.
|
|
|
|
|
|
-Notice there is no definition. The shapes are flat. The `AmbientLight` effectively
|
|
|
|
-just multiplies the material's color by the light's color times the
|
|
|
|
-intensity.
|
|
|
|
|
|
+물체들이 평평하고, 윤곽이 뚜렷하지 않습니다. `AmbientLight`는 물체와
|
|
|
|
+조명의 색, 그리고 조명의 밝기를 곱한 것과 같죠.
|
|
|
|
|
|
color = materialColor * light.color * light.intensity;
|
|
color = materialColor * light.color * light.intensity;
|
|
|
|
|
|
-That's it. It has no direction.
|
|
|
|
-This style of ambient lighting is actually not all that
|
|
|
|
-useful as lighting as it's 100% even so other than changing the color
|
|
|
|
-of everything in the scene it doesn't look much like *lighting*.
|
|
|
|
-What it does help with is making the darks not too dark.
|
|
|
|
|
|
+이게 전부입니다. `AmbientLight`에는 방향이라는 개념이 없죠. 주변광은
|
|
|
|
+완전히 고르게 적용되고 공간 안 물체의 색을 바꾸는 역할만 하기 때문에
|
|
|
|
+실용적이지 않은데다 그다지 *조명*처럼 느껴지지도 않습니다. 어두운 장면을
|
|
|
|
+덜 어둡게 만드는 정도에만 도움이 되죠.
|
|
|
|
|
|
## `HemisphereLight`
|
|
## `HemisphereLight`
|
|
|
|
|
|
-Let's switch the code to a `HemisphereLight`. A `HemisphereLight`
|
|
|
|
-takes a sky color and a ground color and just multiplies the
|
|
|
|
-material's color between those 2 colors—the sky color if the
|
|
|
|
-surface of the object is pointing up and the ground color if
|
|
|
|
-the surface of the object is pointing down.
|
|
|
|
-
|
|
|
|
-Here's the new code
|
|
|
|
|
|
+조명을 `HemisphereLight`(반구광)으로 바꾸겠습니다. `HemisphereLight`는
|
|
|
|
+천장과 바닥의 색을 인자로 받아, 물체의 천장을 바라보는 면은 천장 색, 바닥을
|
|
|
|
+바라보는 면은 바닥 색으로 혼합합니다.
|
|
|
|
|
|
```js
|
|
```js
|
|
-const color = 0xFFFFFF;
|
|
-const color = 0xFFFFFF;
|
|
-+const skyColor = 0xB1E1FF; // light blue
|
|
|
|
-+const groundColor = 0xB97A20; // brownish orange
|
|
|
|
|
|
++const skyColor = 0xB1E1FF; // 하늘색
|
|
|
|
++const groundColor = 0xB97A20; // 오렌지 브라운
|
|
const intensity = 1;
|
|
const intensity = 1;
|
|
-const light = new THREE.AmbientLight(color, intensity);
|
|
-const light = new THREE.AmbientLight(color, intensity);
|
|
+const light = new THREE.HemisphereLight(skyColor, groundColor, intensity);
|
|
+const light = new THREE.HemisphereLight(skyColor, groundColor, intensity);
|
|
scene.add(light);
|
|
scene.add(light);
|
|
```
|
|
```
|
|
|
|
|
|
-Let's also update the dat.GUI code to edit both colors
|
|
|
|
|
|
+마찬가지로 dat.GUI를 수정해 두 색상을 조정할 수 있도록 합니다.
|
|
|
|
|
|
```js
|
|
```js
|
|
const gui = new GUI();
|
|
const gui = new GUI();
|
|
@@ -201,20 +190,17 @@ const gui = new GUI();
|
|
gui.add(light, 'intensity', 0, 2, 0.01);
|
|
gui.add(light, 'intensity', 0, 2, 0.01);
|
|
```
|
|
```
|
|
|
|
|
|
-The result:
|
|
|
|
-
|
|
|
|
{{{example url="../threejs-lights-hemisphere.html" }}}
|
|
{{{example url="../threejs-lights-hemisphere.html" }}}
|
|
|
|
|
|
-Notice again there is almost no definition, everything looks kind
|
|
|
|
-of flat. The `HemisphereLight` used in combination with another light
|
|
|
|
-can help give a nice kind of influence of the color of the sky
|
|
|
|
-and ground. In that way it's best used in combination with some
|
|
|
|
-other light or a substitute for an `AmbientLight`.
|
|
|
|
|
|
+이 또한 그다지 입체적이지 않습니다. 아까보다는 낮지만 전체적으로 2D처럼
|
|
|
|
+보이네요. `HemisphereLight`는 주로 풍경을 표현하거나 할 때 다른 조명과
|
|
|
|
+함께 사용합니다. 다른 조명과 조합할 때 유용하고, 간단히는 `AmbientLight`
|
|
|
|
+대신 사용할 수 있죠.
|
|
|
|
|
|
## `DirectionalLight`
|
|
## `DirectionalLight`
|
|
|
|
|
|
-Let's switch the code to a `DirectionalLight`.
|
|
|
|
-A `DirectionalLight` is often used to represent the sun.
|
|
|
|
|
|
+이번에는 조명을 `DirectionalLight`(직사광)로 바꿔보죠. `DirectionalLight`는
|
|
|
|
+주로 태양을 표현할 때 사용합니다.
|
|
|
|
|
|
```js
|
|
```js
|
|
const color = 0xFFFFFF;
|
|
const color = 0xFFFFFF;
|
|
@@ -226,12 +212,11 @@ scene.add(light);
|
|
scene.add(light.target);
|
|
scene.add(light.target);
|
|
```
|
|
```
|
|
|
|
|
|
-Notice that we had to add the `light` and the `light.target`
|
|
|
|
-to the scene. A three.js `DirectionalLight` will shine
|
|
|
|
-in the direction of its target.
|
|
|
|
|
|
+먼저 `light`와 `light.target`(목표)을 모두 장면에 추가해야 합니다.
|
|
|
|
+그래야 Three.js의 `DirectionalLight`가 목표가 있는 방향으로 빛을
|
|
|
|
+쬘 테니까요.
|
|
|
|
|
|
-Let's make it so we can move the target by adding it to
|
|
|
|
-our GUI.
|
|
|
|
|
|
+이 역시 GUI를 사용해 목표의 위치를 조정할 수 있도록 만들겠습니다.
|
|
|
|
|
|
```js
|
|
```js
|
|
const gui = new GUI();
|
|
const gui = new GUI();
|
|
@@ -244,22 +229,21 @@ gui.add(light.target.position, 'y', 0, 10);
|
|
|
|
|
|
{{{example url="../threejs-lights-directional.html" }}}
|
|
{{{example url="../threejs-lights-directional.html" }}}
|
|
|
|
|
|
-It's kind of hard to see what's going on. Three.js has a bunch
|
|
|
|
-of helper objects we can add to our scene to help visualize
|
|
|
|
-invisible parts of a scene. In this case we'll use the
|
|
|
|
-`DirectionalLightHelper` which will draw a plane, to represent
|
|
|
|
-the light, and a line from the light to the target. We just
|
|
|
|
-pass it the light and add it to the scene.
|
|
|
|
|
|
+조명의 위치가 보이지 않으니 정확한 동작을 확인하기가 좀 어렵네요.
|
|
|
|
+다행히 Three.js에는 눈에 보이지 않는 요소의 시각화를 도와주는
|
|
|
|
+다양한 헬퍼 객체가 있습니다. 이 경우 `DirectionalLightHelper`를
|
|
|
|
+사용해 조명을 면으로, 조명의 방향을 선으로 나타낼 수 있습니다.
|
|
|
|
+사용법도 간단해서 조명을 인자로 넘겨주고 생성한 인스턴스를 장면에
|
|
|
|
+추가하면 됩니다.
|
|
|
|
|
|
```js
|
|
```js
|
|
const helper = new THREE.DirectionalLightHelper(light);
|
|
const helper = new THREE.DirectionalLightHelper(light);
|
|
scene.add(helper);
|
|
scene.add(helper);
|
|
```
|
|
```
|
|
|
|
|
|
-While we're at it let's make it so we can set both the position
|
|
|
|
-of the light and the target. To do this we'll make a function
|
|
|
|
-that given a `Vector3` will adjust its `x`, `y`, and `z` properties
|
|
|
|
-using `dat.GUI`.
|
|
|
|
|
|
+하는 김에 조명과 목표 둘 다 위치를 조정할 수 있도록 하겠습니다.
|
|
|
|
+`Vector3` 객체를 인자로 받아, `dat.GUI`로 이 객체의 `x`, `y`,
|
|
|
|
+`z` 속성을 조정하는 함수를 하나 만듭니다.
|
|
|
|
|
|
```js
|
|
```js
|
|
function makeXYZGUI(gui, vector3, name, onChangeFn) {
|
|
function makeXYZGUI(gui, vector3, name, onChangeFn) {
|
|
@@ -271,13 +255,12 @@ function makeXYZGUI(gui, vector3, name, onChangeFn) {
|
|
}
|
|
}
|
|
```
|
|
```
|
|
|
|
|
|
-Note that we need to call the helper's `update` function
|
|
|
|
-anytime we change something so the helper knows to update
|
|
|
|
-itself. As such we pass in an `onChangeFn` function to
|
|
|
|
-get called anytime dat.GUI updates a value.
|
|
|
|
|
|
+헬퍼 객체를 사용할 때는 헬퍼 객체의 `update` 메서드를 수동으로
|
|
|
|
+호출해줘야 합니다. 한 예로 dat.GUI가 객체 속성을 변경할 때마다
|
|
|
|
+인자로 넘겨준 `onChangeFn`에서 헬퍼 객체의 `update` 메서드를
|
|
|
|
+호출할 수 있죠.
|
|
|
|
|
|
-Then we can use that for both the light's position
|
|
|
|
-and the target's position like this
|
|
|
|
|
|
+그리고 조명의 위치, 목표의 위치 객체에 방금 만든 함수를 각각 적용합니다.
|
|
|
|
|
|
```js
|
|
```js
|
|
+function updateLight{
|
|
+function updateLight{
|
|
@@ -294,20 +277,19 @@ gui.add(light, 'intensity', 0, 2, 0.01);
|
|
+makeXYZGUI(gui, light.target.position, 'target', updateLight);
|
|
+makeXYZGUI(gui, light.target.position, 'target', updateLight);
|
|
```
|
|
```
|
|
|
|
|
|
-Now we can move the light, and its target
|
|
|
|
|
|
+이제 조명, 목표의 위치를 각각 조정할 수 있습니다.
|
|
|
|
|
|
{{{example url="../threejs-lights-directional-w-helper.html" }}}
|
|
{{{example url="../threejs-lights-directional-w-helper.html" }}}
|
|
|
|
|
|
-Orbit the camera and it gets easier to see. The plane
|
|
|
|
-represents a `DirectionalLight` because a directional
|
|
|
|
-light computes light coming in one direction. There is no
|
|
|
|
-*point* the light comes from, it's an infinite plane of light
|
|
|
|
-shooting out parallel rays of light.
|
|
|
|
|
|
+카메라를 돌려보면 아까보다 훨씬 동작이 명확하게 보일 겁니다.
|
|
|
|
+평면은 `DirectionalLight`를 나타내는데, 이는 직사광이 어느
|
|
|
|
+*한 점*에서 뻗어나오는 조명이 아니기 때문입니다. 무한한 광원이
|
|
|
|
+목표를 향해 평행하게 빛을 내리쬐는 것이죠.
|
|
|
|
|
|
## `PointLight`
|
|
## `PointLight`
|
|
|
|
|
|
-A `PointLight` is a light that sits at a point and shoots light
|
|
|
|
-in all directions from that point. Let's change the code.
|
|
|
|
|
|
+`PointLight`는 한 점에서 무한히 뻗어나가는 광원입니다. 코드를
|
|
|
|
+다시 한 번 수정해보죠.
|
|
|
|
|
|
```js
|
|
```js
|
|
const color = 0xFFFFFF;
|
|
const color = 0xFFFFFF;
|
|
@@ -320,7 +302,7 @@ scene.add(light);
|
|
-scene.add(light.target);
|
|
-scene.add(light.target);
|
|
```
|
|
```
|
|
|
|
|
|
-Let's also switch to a `PointLightHelper`
|
|
|
|
|
|
+헬퍼 객체도 `PointLightHelper`로 바꾸겠습니다.
|
|
|
|
|
|
```js
|
|
```js
|
|
-const helper = new THREE.DirectionalLightHelper(light);
|
|
-const helper = new THREE.DirectionalLightHelper(light);
|
|
@@ -328,7 +310,8 @@ Let's also switch to a `PointLightHelper`
|
|
scene.add(helper);
|
|
scene.add(helper);
|
|
```
|
|
```
|
|
|
|
|
|
-and as there is no target the `onChange` function can be simpler.
|
|
|
|
|
|
+`PointLight`에는 목표가 없으므로 `onChange` 함수도 훨씬 간단하게
|
|
|
|
+짤 수 있습니다.
|
|
|
|
|
|
```js
|
|
```js
|
|
function updateLight{
|
|
function updateLight{
|
|
@@ -338,17 +321,15 @@ function updateLight{
|
|
-updateLight();
|
|
-updateLight();
|
|
```
|
|
```
|
|
|
|
|
|
-Note that at some level a `PointLightHelper` has no um, point.
|
|
|
|
-It just draws a small wireframe diamond. It could just as easily
|
|
|
|
-be any shape you want, just add a mesh to the light itself.
|
|
|
|
|
|
+`PointLightHelper`는 점의 표상을 그립니다. 점의 표상이란 점으로는 확인이 어려우니,
|
|
|
|
+기본값으로 다이아몬드 형태의 와이어프레임(wireframe)을 대신 그려놓은 것이죠. 점의
|
|
|
|
+형태는 조명에 `mesh` 객체를 하나 넘겨 얼마든지 바꿀 수 있습니다.
|
|
|
|
|
|
-A `PointLight` has the added property of [`distance`](PointLight.distance).
|
|
|
|
-If the `distance` is 0 then the `PointLight` shines to
|
|
|
|
-infinity. If the `distance` is greater than 0 then the light shines
|
|
|
|
-its full intensity at the light and fades to no influence at `distance`
|
|
|
|
-units away from the light.
|
|
|
|
|
|
+`PointLight`에는 추가로 [`distance`](PointLight.distance) 속성이 있습니다.
|
|
|
|
+`distance`가이 0이면 `PointLight`의 밝기가 무한대임을 의미하고, 0보다 크면
|
|
|
|
+`distance`에 지정된 거리만큼만 영향을 미칩니다.
|
|
|
|
|
|
-Let's setup the GUI so we can adjust the distance.
|
|
|
|
|
|
+거리도 조정할 수 있도록 GUI에 추가하겠습니다.
|
|
|
|
|
|
```js
|
|
```js
|
|
const gui = new GUI();
|
|
const gui = new GUI();
|
|
@@ -360,25 +341,24 @@ makeXYZGUI(gui, light.position, 'position', updateLight);
|
|
-makeXYZGUI(gui, light.target.position, 'target', updateLight);
|
|
-makeXYZGUI(gui, light.target.position, 'target', updateLight);
|
|
```
|
|
```
|
|
|
|
|
|
-And now try it out.
|
|
|
|
|
|
+이제 한 번 테스트해보죠.
|
|
|
|
|
|
{{{example url="../threejs-lights-point.html" }}}
|
|
{{{example url="../threejs-lights-point.html" }}}
|
|
|
|
|
|
-Notice when `distance` is > 0 how the light fades out.
|
|
|
|
|
|
+`distance`가 0보다 클 때 조명의 밝기를 잘 관찰해보세요.
|
|
|
|
|
|
## `SpotLight`
|
|
## `SpotLight`
|
|
|
|
|
|
-Spotlights are effectively a point light with a cone
|
|
|
|
-attached where the light only shines inside the cone.
|
|
|
|
-There's actually 2 cones. An outer cone and an inner
|
|
|
|
-cone. Between the inner cone and the outer cone the
|
|
|
|
-light fades from full intensity to zero.
|
|
|
|
|
|
+스포트라이트는 비유하자면 원뿔 안의 `PointLight`입니다.
|
|
|
|
+차이점은 원뿔 안에서만 빛난다는 점이죠. `SpotLight`의
|
|
|
|
+원뿔은 종류는 외부 원뿔과 내부 원뿔 두 가지입니다.
|
|
|
|
+빛의 밝기는 내부 원뿔에서 가장 세고, 외부 원뿔에 가까워질수록
|
|
|
|
+0까지 낮아집니다.
|
|
|
|
|
|
-To use a `SpotLight` we need a target just like
|
|
|
|
-the directional light. The light's cone will
|
|
|
|
-open toward the target.
|
|
|
|
|
|
+`DirectionalLight`와 마찬가지로 `SpotLight`도 목표의 위치를
|
|
|
|
+정해줘야 합니다. 원뿔의 밑면이 해당 목표물을 바라보게 되죠.
|
|
|
|
|
|
-Modifying our `DirectionalLight` with helper from above
|
|
|
|
|
|
+위 예제의 `DirectionalLight`와 헬퍼 객체를 수정하겠습니다.
|
|
|
|
|
|
```js
|
|
```js
|
|
const color = 0xFFFFFF;
|
|
const color = 0xFFFFFF;
|
|
@@ -393,21 +373,19 @@ scene.add(light.target);
|
|
scene.add(helper);
|
|
scene.add(helper);
|
|
```
|
|
```
|
|
|
|
|
|
-The spotlight's cone's angle is set with the [`angle`](SpotLight.angle)
|
|
|
|
-property in radians. We'll use our `DegRadHelper` from the
|
|
|
|
-[texture article](threejs-textures.html) to present a UI in
|
|
|
|
-degrees.
|
|
|
|
|
|
+원뿔의 내각은 [`angle`](SpotLight.angle)에 호도(radians)값을 지정해
|
|
|
|
+설정합니다. [텍스처 예제](threejs-textures.html)에서 사용했던 `DegRadHelper`
|
|
|
|
+객체를 사용해 UI에는 도(degrees)로 표시하도록 하겠습니다.
|
|
|
|
|
|
```js
|
|
```js
|
|
gui.add(new DegRadHelper(light, 'angle'), 'value', 0, 90).name('angle').onChange(updateLight);
|
|
gui.add(new DegRadHelper(light, 'angle'), 'value', 0, 90).name('angle').onChange(updateLight);
|
|
```
|
|
```
|
|
|
|
|
|
-The inner cone is defined by setting the [`penumbra`](SpotLight.penumbra) property
|
|
|
|
-as a percentage from the outer cone. In other words when `penumbra` is 0 then the
|
|
|
|
-inner code is the same size (0 = no difference) from the outer cone. When the
|
|
|
|
-`penumbra` is 1 then the light fades starting in the center of the cone to the
|
|
|
|
-outer cone. When `penumbra` is .5 then the light fades starting from 50% between
|
|
|
|
-the center of the outer cone.
|
|
|
|
|
|
+내부 원뿔의 크기는 [`penumbra(반음영)`](SpotLight.penumbra) 속성을 외부
|
|
|
|
+원뿔에 대한 비율(퍼센트)로 지정해 사용합니다. 다시 말해 `penumbra` 속성이
|
|
|
|
+0이면 외부 원뿔과 크기가 동일하다는 것이고, 1이면 빛이 중앙에서부터 외부
|
|
|
|
+원뿔까지 점점 희미해짐을 의미하죠. `penumbra` 속성이 0.5이라면? 중앙과 외부
|
|
|
|
+원뿔의 사이 50% 지점부터 빛이 희미해짐을 의미합니다.
|
|
|
|
|
|
```js
|
|
```js
|
|
gui.add(light, 'penumbra', 0, 1, 0.01);
|
|
gui.add(light, 'penumbra', 0, 1, 0.01);
|
|
@@ -415,21 +393,20 @@ gui.add(light, 'penumbra', 0, 1, 0.01);
|
|
|
|
|
|
{{{example url="../threejs-lights-spot-w-helper.html" }}}
|
|
{{{example url="../threejs-lights-spot-w-helper.html" }}}
|
|
|
|
|
|
-Notice with the default `penumbra` of 0 the spotlight has a very sharp edge
|
|
|
|
-whereas as you adjust the `penumbra` toward 1 the edge blurs.
|
|
|
|
|
|
+`penumbra` 속성이 0일 때는 빛의 경계가 굉장히 분명한 것이 보일 겁니다.
|
|
|
|
+`penumbra` 속성을 1에 가깝게 조정하면 경계가 점점 흐릿해지죠.
|
|
|
|
|
|
-It might be hard to see the *cone* of the spotlight. The reason is it's
|
|
|
|
-below the ground. Shorten the distance to around 5 and you'll see the open
|
|
|
|
-end of the cone.
|
|
|
|
|
|
+`SpotLight`가 *원뿔 모양*처럼 보이지 않을지도 모릅니다. 이는 바닥이 원뿔의
|
|
|
|
+거리보다 가까이 있기 때문으로, `distance`를 약 5 정도로 조정하면 원뿔의 밑면을
|
|
|
|
+확인할 수 있을 겁니다.
|
|
|
|
|
|
## `RectAreaLight`
|
|
## `RectAreaLight`
|
|
|
|
|
|
-There's one more type of light, the `RectAreaLight`, which represents
|
|
|
|
-exactly what it sounds like, a rectangular area of light like a long
|
|
|
|
-fluorescent light or maybe a frosted sky light in a ceiling.
|
|
|
|
|
|
+마지막으로 살펴볼 조명은 `RectAreaLight`입니다. 이름 그대로 사각 형태의
|
|
|
|
+조명으로, 형광등이나 천장의 유리를 통과하는 태양빛을 표현하기에 적합합니다.
|
|
|
|
|
|
-The `RectAreaLight` only works with the `MeshStandardMaterial` and the
|
|
|
|
-`MeshPhysicalMaterial` so let's change all our materials to `MeshStandardMaterial`
|
|
|
|
|
|
+`RectAreaLight`는 `MeshStandardMaterial`과 `MeshPhysicalMaterial`만
|
|
|
|
+지원합니다. 예전 코드에서 재질(material)을 `MeshStandardMaterial`로 바꾸겠습니다.
|
|
|
|
|
|
```js
|
|
```js
|
|
...
|
|
...
|
|
@@ -466,16 +443,16 @@ The `RectAreaLight` only works with the `MeshStandardMaterial` and the
|
|
}
|
|
}
|
|
```
|
|
```
|
|
|
|
|
|
-To use the `RectAreaLight` we need to include some extra three.js optional data and we'll
|
|
|
|
-include the `RectAreaLightHelper` to help us visualize the light
|
|
|
|
|
|
+`RectAreaLight`를 사용하려면 별도의 데이터를 불러와야 합니다. 또한
|
|
|
|
+`RectAreaLightHelper`도 같이 불러와 조명을 시각화하겠습니다.
|
|
|
|
|
|
```js
|
|
```js
|
|
import * as THREE from './resources/three/r115/build/three.module.js';
|
|
import * as THREE from './resources/three/r115/build/three.module.js';
|
|
-+import {RectAreaLightUniformsLib} from './resources/threejs/r115/examples/jsm/lights/RectAreaLightUniformsLib.js';
|
|
|
|
-+import {RectAreaLightHelper} from './resources/threejs/r115/examples/jsm/helpers/RectAreaLightHelper.js';
|
|
|
|
|
|
++import { RectAreaLightUniformsLib } from './resources/threejs/r115/examples/jsm/lights/RectAreaLightUniformsLib.js';
|
|
|
|
++import { RectAreaLightHelper } from './resources/threejs/r115/examples/jsm/helpers/RectAreaLightHelper.js';
|
|
```
|
|
```
|
|
|
|
|
|
-and we need to call `RectAreaLightUniformsLib.init`
|
|
|
|
|
|
+모듈을 불러온 후 `RectAreaLightUniformsLib.init` 메서드를 호출합니다.
|
|
|
|
|
|
```js
|
|
```js
|
|
function main() {
|
|
function main() {
|
|
@@ -484,10 +461,10 @@ function main() {
|
|
+ RectAreaLightUniformsLib.init();
|
|
+ RectAreaLightUniformsLib.init();
|
|
```
|
|
```
|
|
|
|
|
|
-If you forget the data the light will still work but it will look funny so
|
|
|
|
-be sure to remember to include the extra data.
|
|
|
|
|
|
+데이터를 불러오지 않아도 에러는 발생하지 않지만, 이상하게 보일 것이므로
|
|
|
|
+데이터를 불러와야 한다는 것을 꼭 기억하기 바랍니다.
|
|
|
|
|
|
-Now we can create the light
|
|
|
|
|
|
+이제 조명을 추가합니다.
|
|
|
|
|
|
```js
|
|
```js
|
|
const color = 0xFFFFFF;
|
|
const color = 0xFFFFFF;
|
|
@@ -503,13 +480,11 @@ scene.add(light);
|
|
*light.add(helper);
|
|
*light.add(helper);
|
|
```
|
|
```
|
|
|
|
|
|
-One thing to notice is that unlike the `DirectionalLight` and the `SpotLight`, the
|
|
|
|
-`RectAreaLight` does not use a target. It just uses its rotation. Another thing
|
|
|
|
-to notice is the helper needs to be a child of the light. It is not a child of the
|
|
|
|
-scene like other helpers.
|
|
|
|
|
|
+`RectAreaLight`는 `DirectionalLight`, `SpotLight`와 달리 목표를 사용하지 않습니다.
|
|
|
|
+빛의 방향은 `rotation`으로 설정할 수 있죠. 또 `RectAreaLightHelper`는 직접 조명을
|
|
|
|
+자식으로 두는 다른 헬퍼 객체와 달리, 해당 조명의 자식이어야 합니다.
|
|
|
|
|
|
-Let's also adjust the GUI. We'll make it so we can rotate the light and adjust
|
|
|
|
-its `width` and `height`
|
|
|
|
|
|
+조명의 `rotation`, `width`, `height` 속성을 조정할 수 있도록 GUI도 수정해줍니다.
|
|
|
|
|
|
```js
|
|
```js
|
|
const gui = new GUI();
|
|
const gui = new GUI();
|
|
@@ -524,32 +499,31 @@ gui.add(new DegRadHelper(light.rotation, 'z'), 'value', -180, 180).name('z rotat
|
|
makeXYZGUI(gui, light.position, 'position', updateLight);
|
|
makeXYZGUI(gui, light.position, 'position', updateLight);
|
|
```
|
|
```
|
|
|
|
|
|
-And here is that.
|
|
|
|
-
|
|
|
|
{{{example url="../threejs-lights-rectarea.html" }}}
|
|
{{{example url="../threejs-lights-rectarea.html" }}}
|
|
|
|
|
|
-One thing we didn't cover is that there is a setting on the `WebGLRenderer`
|
|
|
|
-called `physicallyCorrectLights`. It effects how light falls off as distance from light.
|
|
|
|
-It only affects `PointLight` and `SpotLight`. `RectAreaLight` does this automatically.
|
|
|
|
|
|
+하나 설명하지 않은 것이 있습니다. 위 예제에는 `WebGLRenderer`의 `physicallyCorrectLights(물리 기반 조명)`
|
|
|
|
+설정이 있습니다. 이는 거리에 따라 빛이 어떻게 떨어질지 결정하는 속성으로,
|
|
|
|
+`PointLight`와 `SpotLight`가 이 설정의 영향을 받습니다. `RectAreaLight`는
|
|
|
|
+마찬가지로 설정의 영향도 받고, 기본적으로 이 설정을 사용하죠.
|
|
|
|
|
|
-For lights though the basic idea is you don't set a distance for them to fade out,
|
|
|
|
-and you don't set `intensity`. Instead you set the [`power`](PointLight.power) of
|
|
|
|
-the light in lumens and then three.js will use physics calculations like real lights.
|
|
|
|
-The units of three.js in this case are meters and a 60w light bulb would have
|
|
|
|
-around 800 lumens. There's also a [`decay`](PointLight.decay) property. It should
|
|
|
|
-be set to `2` for realistic decay.
|
|
|
|
|
|
+이 설정을 사용하면 기본적으로 조명의 `distance`나 `intensity` 대신
|
|
|
|
+[`power`](PointLight.power) 속성을 루멘(lumens) 단위로 설정해야 합니다.
|
|
|
|
+그러면 Three.js는 물리적 계산을 통해 실제 광원을 흉내내죠. 예제의
|
|
|
|
+거리 단위는 미터(meters)이니, 60w짜리 전구는 약 800루멘 정도일 겁니다.
|
|
|
|
+그리고 조명의 부서짐(decay) 정도를 설정하는 [`decay`](PointLight.decay)
|
|
|
|
+속성도 있습니다. 현실적인 조명을 위해서는 `2` 정도가 적당하죠.
|
|
|
|
|
|
-Let's test that.
|
|
|
|
|
|
+한 번 예제를 만들어 테스트해봅시다.
|
|
|
|
|
|
-First we'll turn on physically correct lights
|
|
|
|
|
|
+먼저 `renderer`의 `physicallyCorrectLights` 속성을 켭니다.
|
|
|
|
|
|
```js
|
|
```js
|
|
const renderer = new THREE.WebGLRenderer({canvas});
|
|
const renderer = new THREE.WebGLRenderer({canvas});
|
|
+renderer.physicallyCorrectLights = true;
|
|
+renderer.physicallyCorrectLights = true;
|
|
```
|
|
```
|
|
|
|
|
|
-Then we'll set the `power` to 800 lumens, the `decay` to 2, and
|
|
|
|
-the `distance` to `Infinity`.
|
|
|
|
|
|
+그리고 `power`를 800루멘으로, `decay` 속성을 2로, `distance`
|
|
|
|
+속성을 `Infinity`로 설정합니다.
|
|
|
|
|
|
```js
|
|
```js
|
|
const color = 0xFFFFFF;
|
|
const color = 0xFFFFFF;
|
|
@@ -560,7 +534,8 @@ light.decay = 2;
|
|
light.distance = Infinity;
|
|
light.distance = Infinity;
|
|
```
|
|
```
|
|
|
|
|
|
-and we'll add gui so we can change the `power` and `decay`
|
|
|
|
|
|
+마지막으로 GUI를 추가해 `power`와 `decay` 속성을 조정할 수 있도록
|
|
|
|
+해줍니다.
|
|
|
|
|
|
```js
|
|
```js
|
|
const gui = new GUI();
|
|
const gui = new GUI();
|
|
@@ -571,11 +546,10 @@ gui.add(light, 'power', 0, 2000);
|
|
|
|
|
|
{{{example url="../threejs-lights-point-physically-correct.html" }}}
|
|
{{{example url="../threejs-lights-point-physically-correct.html" }}}
|
|
|
|
|
|
-It's important to note each light you add to the scene slows down how fast
|
|
|
|
-three.js renders the scene so you should always try to use as few as
|
|
|
|
-possible to achieve your goals.
|
|
|
|
|
|
+조명은 `renderer`가 장면을 렌더링하는 속도에 영향을 미칩니다. 그러니
|
|
|
|
+가능한 적은 조명을 쓰는 게 좋죠.
|
|
|
|
|
|
-Next up let's go over [dealing with cameras](threejs-cameras.html).
|
|
|
|
|
|
+다음 장에서는 [카메라 조작법](threejs-cameras.html)에 대해 알아보겠습니다.
|
|
|
|
|
|
<canvas id="c"></canvas>
|
|
<canvas id="c"></canvas>
|
|
-<script type="module" src="resources/threejs-lights.js"></script>
|
|
|
|
|
|
+<script type="module" src="../resources/threejs-lights.js"></script>
|